diff --git a/.eslintrc.json b/.eslintrc.json index cb300c2..1ff58ad 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -22,7 +22,8 @@ "files": ["*.ts", "*.tsx"], "plugins": ["@typescript-eslint"], "rules": { - "@typescript-eslint/explicit-module-boundary-types": "off" + "@typescript-eslint/explicit-module-boundary-types": "off", + "@typescript-eslint/no-explicit-any": "off" } } ] diff --git a/lib/flow/fund.ts b/lib/flow/fund.ts index 7bc43cd..ed9ba40 100644 --- a/lib/flow/fund.ts +++ b/lib/flow/fund.ts @@ -12,7 +12,7 @@ transaction(address: Address, amount: UFix64) { let tokenAdmin: &FlowToken.Administrator let tokenReceiver: &{FungibleToken.Receiver} - prepare(signer: AuthAccount) { + prepare(signer: auth(BorrowValue) &Account) { self.tokenAdmin = signer.storage.borrow<&FlowToken.Administrator>(from: /storage/flowTokenAdmin) ?? panic("Signer is not the token admin") @@ -101,13 +101,37 @@ export async function fundAccount( const {tx, amount} = tokens[addressType] - await sendTransaction({ - transaction: tx, - args: [fcl.arg(address, t.Address), fcl.arg(amount, t.UFix64)], - authorizations: [authorization], - payer: authorization, - proposer: authorization, - }) - + if (addressType === "FLOWEVM") { + const addressBytes = Array.from(Buffer.from(address, "hex")).map(b => + b.toString() + ) + + await sendTransaction({ + transaction: tx, + args: [ + fcl.arg( + { + fields: [{name: "bytes", value: addressBytes}], + }, + t.Struct(`A.${publicConfig.contractEVM}.EVM.EVMAddress`, [ + {value: t.Array(t.UInt8)}, + ]) + ), + fcl.arg(amount, t.UFix64), + fcl.arg("60000", t.UInt64), + ], + authorizations: [authorization], + payer: authorization, + proposer: authorization, + }) + } else { + await sendTransaction({ + transaction: tx, + args: [fcl.arg(address, t.Address), fcl.arg(amount, t.UFix64)], + authorizations: [authorization], + payer: authorization, + proposer: authorization, + }) + } return amount } diff --git a/modules.d.ts b/modules.d.ts index 3d4175f..7903dce 100644 --- a/modules.d.ts +++ b/modules.d.ts @@ -70,7 +70,7 @@ declare module "@onflow/fcl" { export function script(script: string): unknown export function decode(): unknown export function authz(): Authorization - export function arg(encodedPublicKey: string, type: string): TransactionArg + export function arg(value: any, type: string): TransactionArg export function args(args: TransactionArg[]): unknown export function authorizations(authorizations: Authorization[]): unknown export function proposer(proposer: Authorization): unknown