diff --git a/src/background/controller/wallet.ts b/src/background/controller/wallet.ts index ba591074..e5e3b81c 100644 --- a/src/background/controller/wallet.ts +++ b/src/background/controller/wallet.ts @@ -1104,8 +1104,27 @@ export class WalletController extends BaseController { ids: number, receiver: string ): Promise => transactionService.bridgeNftFromEvmToFlow(flowIdentifier, ids, receiver); - getAssociatedFlowIdentifier = async (address: string): Promise => - transactionService.getAssociatedFlowIdentifier(address); + // getAssociatedFlowIdentifier = async (address: string): Promise => + // transactionService.getAssociatedFlowIdentifier(address); + + getAssociatedFlowIdentifier = async (address: string): Promise => { + const network = await userWalletService.getNetwork(); + const allScripts = await openapiService.getCadenceScripts(); + const encodedScript = allScripts.scripts[network]?.bridge?.getAssociatedFlowIdentifier; + + if (!encodedScript) { + throw new Error('Script get_associated_flow_identifier not found in bridge category'); + } + + // Decode the base64 script + const script = atob(encodedScript); + + const result = await fcl.query({ + cadence: script, + args: (arg, t) => [arg(address, t.String)], + }); + return result; + }; sendNFT = async (recipient: string, id: number, token: NFTModelV2): Promise => transactionService.sendNFT(recipient, id, token); sendNBANFT = async (recipient: string, id: number, token: NFTModelV2): Promise =>