From 1d3a80b519702e0cf3a326b573505cd2cc63c809 Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Mon, 26 Feb 2024 15:26:24 -0800 Subject: [PATCH] sansPrefix evm addr --- components/FundAccountSubmitted.tsx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/components/FundAccountSubmitted.tsx b/components/FundAccountSubmitted.tsx index 813412f..ee4b070 100644 --- a/components/FundAccountSubmitted.tsx +++ b/components/FundAccountSubmitted.tsx @@ -72,15 +72,28 @@ access(all) fun main(account: Address): UFix64 { try { setIsFetchingBalance(true) + const addressType = getAddressType(result.address) + let addressArg + const addressArgType = - publicConfig.network === "testnet" || - getAddressType(result.address) === "FLOW" + publicConfig.network === "testnet" || addressType === "FLOW" ? t.Address : t.String + if (addressType === "FLOWEVM") { + const withoutPrefix = fcl.sansPrefix(result.address) + if (!withoutPrefix) { + throw new Error("Invalid address") + } + + addressArg = withoutPrefix + } else { + addressArg = addr + } + const balance = await sendScript({ script: balanceScript, - args: [fcl.arg(addr, addressArgType)], + args: [fcl.arg(addressArg, addressArgType)], }) setBalance(balance) } catch (error) {