mirror of
https://github.com/neynarxyz/create-farcaster-mini-app.git
synced 2025-11-15 23:58:56 -05:00
fix: update custody address lookup to use free api
This commit is contained in:
parent
eba6b89593
commit
40e40543cd
28
bin/init.js
28
bin/init.js
@ -60,34 +60,6 @@ async function queryNeynarApp(apiKey) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function lookupFidByCustodyAddress(custodyAddress, apiKey) {
|
|
||||||
if (!apiKey) {
|
|
||||||
throw new Error('Neynar API key is required');
|
|
||||||
}
|
|
||||||
const lowerCasedCustodyAddress = custodyAddress.toLowerCase();
|
|
||||||
|
|
||||||
const response = await fetch(
|
|
||||||
`https://api.neynar.com/v2/farcaster/user/bulk-by-address?addresses=${lowerCasedCustodyAddress}&address_types=custody_address`,
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
'accept': 'application/json',
|
|
||||||
'x-api-key': apiKey
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`Failed to lookup FID: ${response.statusText}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = await response.json();
|
|
||||||
if (!data[lowerCasedCustodyAddress]?.length && !data[lowerCasedCustodyAddress][0].custody_address) {
|
|
||||||
throw new Error('No FID found for this custody address');
|
|
||||||
}
|
|
||||||
|
|
||||||
return data[lowerCasedCustodyAddress][0].fid;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Export the main CLI function for programmatic use
|
// Export the main CLI function for programmatic use
|
||||||
export async function init() {
|
export async function init() {
|
||||||
printWelcomeMessage();
|
printWelcomeMessage();
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@neynar/create-farcaster-mini-app",
|
"name": "@neynar/create-farcaster-mini-app",
|
||||||
"version": "1.2.16",
|
"version": "1.2.17",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"private": false,
|
"private": false,
|
||||||
"access": "public",
|
"access": "public",
|
||||||
|
|||||||
@ -20,9 +20,10 @@ async function lookupFidByCustodyAddress(custodyAddress, apiKey) {
|
|||||||
if (!apiKey) {
|
if (!apiKey) {
|
||||||
throw new Error('Neynar API key is required');
|
throw new Error('Neynar API key is required');
|
||||||
}
|
}
|
||||||
|
const lowerCasedCustodyAddress = custodyAddress.toLowerCase();
|
||||||
|
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`https://api.neynar.com/v2/farcaster/user/custody-address?custody_address=${custodyAddress}`,
|
`https://api.neynar.com/v2/farcaster/user/bulk-by-address?addresses=${lowerCasedCustodyAddress}&address_types=custody_address`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
'accept': 'application/json',
|
'accept': 'application/json',
|
||||||
@ -36,11 +37,11 @@ async function lookupFidByCustodyAddress(custodyAddress, apiKey) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (!data.user?.fid) {
|
if (!data[lowerCasedCustodyAddress]?.length || !data[lowerCasedCustodyAddress][0].custody_address) {
|
||||||
throw new Error('No FID found for this custody address');
|
throw new Error('No FID found for this custody address');
|
||||||
}
|
}
|
||||||
|
|
||||||
return data.user.fid;
|
return data[lowerCasedCustodyAddress][0].fid;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadEnvLocal() {
|
async function loadEnvLocal() {
|
||||||
|
|||||||
@ -28,9 +28,10 @@ async function lookupFidByCustodyAddress(custodyAddress, apiKey) {
|
|||||||
if (!apiKey) {
|
if (!apiKey) {
|
||||||
throw new Error('Neynar API key is required');
|
throw new Error('Neynar API key is required');
|
||||||
}
|
}
|
||||||
|
const lowerCasedCustodyAddress = custodyAddress.toLowerCase();
|
||||||
|
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`https://api.neynar.com/v2/farcaster/user/custody-address?custody_address=${custodyAddress}`,
|
`https://api.neynar.com/v2/farcaster/user/bulk-by-address?addresses=${lowerCasedCustodyAddress}&address_types=custody_address`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
'accept': 'application/json',
|
'accept': 'application/json',
|
||||||
@ -44,11 +45,11 @@ async function lookupFidByCustodyAddress(custodyAddress, apiKey) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (!data.user?.fid) {
|
if (!data[lowerCasedCustodyAddress]?.length || !data[lowerCasedCustodyAddress][0].custody_address) {
|
||||||
throw new Error('No FID found for this custody address');
|
throw new Error('No FID found for this custody address');
|
||||||
}
|
}
|
||||||
|
|
||||||
return data.user.fid;
|
return data[lowerCasedCustodyAddress][0].fid;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function generateFarcasterMetadata(domain, fid, accountAddress, seedPhrase, webhookUrl) {
|
async function generateFarcasterMetadata(domain, fid, accountAddress, seedPhrase, webhookUrl) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user