Skip to content

Commit

Permalink
Merge pull request #46 from m-Peter/setup-improvements
Browse files Browse the repository at this point in the history
Setup improvements for running the Flow EVM Gateway
  • Loading branch information
nialexsan authored Feb 9, 2024
2 parents 0b6d8ab + 49bea52 commit b4cff0a
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,15 @@ generate:

.PHONY: ci
ci: check-tidy test

.PHONY: start-emulator
start-emulator:
./flow-x86_64-linux- emulator --evm-enabled

.PHONY: setup-account
setup-account:
./flow-x86_64-linux- transactions send api/cadence/transactions/create_bridged_account.cdc 1500.0 --network=emulator --signer=emulator-account

.PHONY: start
start:
go run ./cmd/server/main.go
26 changes: 26 additions & 0 deletions api/cadence/transactions/create_bridged_account.cdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import EVM from 0xf8d6e0586b0a20c7 // todo dynamically set
import FungibleToken from 0xee82856bf20e2aa6
import FlowToken from 0x0ae53cb6e3f42a79

transaction(amount: UFix64) {
let sentVault: @FlowToken.Vault
let auth: auth(Storage) &Account

prepare(signer: auth(Storage) &Account) {
let vaultRef = signer.storage.borrow<auth(FungibleToken.Withdrawable) &FlowToken.Vault>(
from: /storage/flowTokenVault
) ?? panic("Could not borrow reference to the owner's Vault!")

self.sentVault <- vaultRef.withdraw(amount: amount) as! @FlowToken.Vault
self.auth = signer
}

execute {
let account <- EVM.createBridgedAccount()
log(account.address())
account.deposit(from: <-self.sentVault)

log(account.balance().flow)
self.auth.storage.save<@EVM.BridgedAccount>(<-account, to: StoragePath(identifier: "evm")!)
}
}
18 changes: 18 additions & 0 deletions flow.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"contracts": {},
"networks": {
"emulator": "127.0.0.1:3569",
"testing": "127.0.0.1:3569"
},
"accounts": {
"emulator-account": {
"address": "0xf8d6e0586b0a20c7",
"key": "2619878f0e2ff438d17835c2a4561cb87b4d24d72d12ec34569acd0dd4af7c21"
}
},
"deployments": {
"emulator": {
"emulator-account": []
}
}
}

0 comments on commit b4cff0a

Please sign in to comment.