Skip to content

Commit

Permalink
sansPrefix evm addr
Browse files Browse the repository at this point in the history
  • Loading branch information
chasefleming committed Feb 26, 2024
1 parent 8912608 commit 1d3a80b
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions components/FundAccountSubmitted.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 1d3a80b

Please sign in to comment.