diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4600b59..5ef3648 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,6 +34,7 @@ jobs: NEXT_PUBLIC_CONTRACT_FUNGIBLE_TOKEN: "0xee82856bf20e2aa6" NEXT_PUBLIC_CONTRACT_FLOW_TOKEN: "0x0ae53cb6e3f42a79" NEXT_PUBLIC_CONTRACT_FUSD: "0xf8d6e0586b0a20c7" + NEXT_PUBLIC_CONTRACT_EVM: "0xf8d6e0586b0a20c7" NEXT_PUBLIC_NETWORK: "testnet" strategy: diff --git a/lib/flow/account.ts b/lib/flow/account.ts index 4229bfe..bf20c48 100644 --- a/lib/flow/account.ts +++ b/lib/flow/account.ts @@ -1,7 +1,7 @@ import * as fcl from "@onflow/fcl" import * as t from "@onflow/types" import publicConfig from "../publicConfig" -import { sendTransaction } from "./send" +import {sendTransaction} from "./send" const accountCreatedEventType = "flow.AccountCreated" @@ -50,37 +50,37 @@ transaction(publicKey: String, flowTokenAmount: UFix64, sigAlgorithm: UInt8, has ` export async function createAccount( - publicKey: string, - sigAlgo: number, - hashAlgo: number, - authorization: fcl.Authorization + publicKey: string, + sigAlgo: number, + hashAlgo: number, + authorization: fcl.Authorization ) { - const result = await sendTransaction({ - transaction: txCreateAccount, - args: [ - fcl.arg(publicKey, t.String), - fcl.arg(publicConfig.tokenAmountFlow, t.UFix64), - fcl.arg(sigAlgo.toString(), t.UInt8), - fcl.arg(hashAlgo.toString(), t.UInt8), - ], - authorizations: [authorization], - payer: authorization, - proposer: authorization, - }) - - const accountCreatedEvent = result.events.find( - (event: fcl.Event) => event.type === accountCreatedEventType - ) - - if (!accountCreatedEvent) { - throw "Transaction did not emit account creation event" - } - - const address = accountCreatedEvent.data.address - const transactionId = accountCreatedEvent.transactionId - - return { - address, - transactionId, - } + const result = await sendTransaction({ + transaction: txCreateAccount, + args: [ + fcl.arg(publicKey, t.String), + fcl.arg(publicConfig.tokenAmountFlow, t.UFix64), + fcl.arg(sigAlgo.toString(), t.UInt8), + fcl.arg(hashAlgo.toString(), t.UInt8), + ], + authorizations: [authorization], + payer: authorization, + proposer: authorization, + }) + + const accountCreatedEvent = result.events.find( + (event: fcl.Event) => event.type === accountCreatedEventType + ) + + if (!accountCreatedEvent) { + throw "Transaction did not emit account creation event" + } + + const address = accountCreatedEvent.data.address + const transactionId = accountCreatedEvent.transactionId + + return { + address, + transactionId, + } } diff --git a/lib/flow/fund.ts b/lib/flow/fund.ts index 526d1b7..af5e2b7 100644 --- a/lib/flow/fund.ts +++ b/lib/flow/fund.ts @@ -59,30 +59,30 @@ transaction(address: Address, amount: UFix64) { type TokenType = "FLOW" | "FUSD" type Token = { - tx: string - amount: string + tx: string + amount: string } type Tokens = Record export const tokens: Tokens = { - FLOW: {tx: txFundAccountFLOW, amount: TOKEN_FUNDING_AMOUNTS[FLOW_TYPE]}, - FUSD: {tx: txFundAccountFUSD, amount: TOKEN_FUNDING_AMOUNTS[FUSD_TYPE]}, + FLOW: {tx: txFundAccountFLOW, amount: TOKEN_FUNDING_AMOUNTS[FLOW_TYPE]}, + FUSD: {tx: txFundAccountFUSD, amount: TOKEN_FUNDING_AMOUNTS[FUSD_TYPE]}, } export async function fundAccount( - address: string, - token: TokenType, - authorization: fcl.Authorization + address: string, + token: TokenType, + authorization: fcl.Authorization ) { - const {tx, amount} = tokens[token] + const {tx, amount} = tokens[token] - await sendTransaction({ - transaction: tx, - args: [fcl.arg(address, t.Address), fcl.arg(amount, t.UFix64)], - authorizations: [authorization], - payer: authorization, - proposer: authorization, - }) + await sendTransaction({ + transaction: tx, + args: [fcl.arg(address, t.Address), fcl.arg(amount, t.UFix64)], + authorizations: [authorization], + payer: authorization, + proposer: authorization, + }) - return amount + return amount }