From 55e783c79718e60fc5a035b61bb2d58768fc9522 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Mon, 26 Feb 2024 08:59:32 -0800 Subject: [PATCH] Fix EVM.Address struct in funding transaction (#85) --- lib/flow/fund.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/flow/fund.ts b/lib/flow/fund.ts index 4da040d..0a94214 100644 --- a/lib/flow/fund.ts +++ b/lib/flow/fund.ts @@ -105,7 +105,11 @@ export async function fundAccount( const {tx, amount} = tokens[addressType] if (addressType === "FLOWEVM") { - const addressBytes = Array.from(Buffer.from(address, "hex")).map(b => + const withoutPrefix = fcl.sansPrefix(address) + if (!withoutPrefix) { + throw new Error("Invalid address") + } + const addressBytes = Array.from(Buffer.from(withoutPrefix, "hex")).map(b => b.toString() ) @@ -116,9 +120,10 @@ export async function fundAccount( { fields: [{name: "bytes", value: addressBytes}], }, - t.Struct(`A.${publicConfig.contractEVM}.EVM.EVMAddress`, [ - {value: t.Array(t.UInt8)}, - ]) + t.Struct( + `A.${fcl.sansPrefix(publicConfig.contractEVM)}.EVM.EVMAddress`, + [{value: t.Array(t.UInt8)}] + ) ), fcl.arg(amount, t.UFix64), fcl.arg("60000", t.UInt64),