Skip to content

Commit

Permalink
Merge branch 'evm-enabled' into giovanni/update-evm
Browse files Browse the repository at this point in the history
  • Loading branch information
chasefleming committed Feb 24, 2024
2 parents 3564b5f + 021e7e9 commit 0b5af6c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
]
Expand Down
42 changes: 33 additions & 9 deletions lib/flow/fund.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion modules.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0b5af6c

Please sign in to comment.