diff --git a/lib/hooks/useLambdaState.tsx b/lib/hooks/useLambdaState.tsx index 9e851af33a..d0b9852071 100644 --- a/lib/hooks/useLambdaState.tsx +++ b/lib/hooks/useLambdaState.tsx @@ -1,10 +1,14 @@ import { useQuery } from '@tanstack/react-query'; -export function useLambdaState() { +export function useLambdaState(addressHash: string) { const { data, error, isLoading } = useQuery({ - queryKey: [ 'lambda-state' ], - queryFn: async() => { - const response = await fetch('https://ark-lambda-api.vercel.app/api/ark-lambda'); + queryKey: ['lambda-state', addressHash], + queryFn: async () => { + if (!addressHash) return null; + const response = await fetch(`https://ark-lambda-api.vercel.app/api/ark-lambda/eth-info?hash=${addressHash.toLowerCase()}`) + if (!response.ok) { + throw new Error('Network response was not ok'); + } return response.json(); }, }); diff --git a/nextjs/csp/policies/ad.ts b/nextjs/csp/policies/ad.ts index 5c8b56bdf1..0431d54144 100644 --- a/nextjs/csp/policies/ad.ts +++ b/nextjs/csp/policies/ad.ts @@ -12,6 +12,7 @@ export function ad(): CspDev.DirectiveDescriptor { 'coinzilla.com', '*.coinzilla.com', 'https://ark-lambda-api.vercel.app', + 'https://ark-lambda-api.vercel.app/api', 'https://request-global.czilladx.com', // adbutler diff --git a/ui/address/AddressArweaveAddress.tsx b/ui/address/AddressArweaveAddress.tsx index 25e52d173b..c4366fde3e 100644 --- a/ui/address/AddressArweaveAddress.tsx +++ b/ui/address/AddressArweaveAddress.tsx @@ -16,12 +16,12 @@ const Link = chakra((props: any) => { const AddressArweaveAddress = ({ addressHash }: any) => { const [arweaveAddress, setArweaveAddress] = useState(null); - const { data, isLoading } = useLambdaState(); + const { data, isLoading } = useLambdaState(addressHash); const searchArksByKey = (state: any, ethereumAddress: string) => { if (!ethereumAddress || !state) return null; - if (state.arks?.[ethereumAddress.toLowerCase()]) { - return { ethereumAddress: ethereumAddress.toLowerCase(), arweaveLinkings: state.arks[ethereumAddress.toLowerCase()][0].arweave_address, callTXID: state.arks[ethereumAddress.toLowerCase()][0].call_txid }; + if (state?.ark) { + return { ethereumAddress: ethereumAddress.toLowerCase(), arweaveLinkings: state.ark[0].arweave_address, callTXID: state.ark[0].call_txid }; } else { return null; } @@ -31,7 +31,7 @@ const AddressArweaveAddress = ({ addressHash }: any) => { const fetchArweaveAddress = async () => { if (addressHash && data) { // @ts-ignore - const result = searchArksByKey(data?.data, addressHash); + const result = searchArksByKey(data, addressHash); setArweaveAddress(result ? result.arweaveLinkings : null); } };