diff --git a/Makefile b/Makefile index 415643d76..08d3526db 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/api/cadence/transactions/create_bridged_account.cdc b/api/cadence/transactions/create_bridged_account.cdc new file mode 100644 index 000000000..78737807d --- /dev/null +++ b/api/cadence/transactions/create_bridged_account.cdc @@ -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( + 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")!) + } +} diff --git a/flow.json b/flow.json new file mode 100644 index 000000000..42683fe87 --- /dev/null +++ b/flow.json @@ -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": [] + } + } +} \ No newline at end of file