Skip to content

Commit

Permalink
Merge pull request onflow#5280 from onflow/ramtin/5227-evm-reduce-the…
Browse files Browse the repository at this point in the history
…-scope-of-deposit

[Flow EVM] reducing the scope of deposit to COAs only
  • Loading branch information
ramtinms authored Jan 24, 2024
2 parents 38c825f + e893b21 commit 098ff23
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
11 changes: 5 additions & 6 deletions fvm/evm/evm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,9 @@ func TestEVMAddressDeposit(t *testing.T) {
let vault <- minter.mintTokens(amount: 1.23)
destroy minter
let address = EVM.EVMAddress(
bytes: [2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
)
address.deposit(from: <-vault)
let bridgedAccount <- EVM.createBridgedAccount()
bridgedAccount.deposit(from: <-vault)
destroy bridgedAccount
}
`,
sc.EVMContract.Address.HexWithPrefix(),
Expand Down Expand Up @@ -195,7 +194,7 @@ func TestBridgedAccountWithdraw(t *testing.T) {
destroy minter
let bridgedAccount <- EVM.createBridgedAccount()
bridgedAccount.address().deposit(from: <-vault)
bridgedAccount.deposit(from: <-vault)
let vault2 <- bridgedAccount.withdraw(balance: EVM.Balance(flow: 1.23))
let balance = vault2.balance
Expand Down Expand Up @@ -254,7 +253,7 @@ func TestBridgedAccountDeploy(t *testing.T) {
destroy minter
let bridgedAccount <- EVM.createBridgedAccount()
bridgedAccount.address().deposit(from: <-vault)
bridgedAccount.deposit(from: <-vault)
let address = bridgedAccount.deploy(
code: [],
Expand Down
14 changes: 4 additions & 10 deletions fvm/evm/stdlib/contract.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@ contract EVM {
self.bytes = bytes
}

/// Deposits the given vault into the EVM account with the given address
access(all)
fun deposit(from: @FlowToken.Vault) {
InternalEVM.deposit(
from: <-from,
to: self.bytes
)
}

/// Balance of the address
access(all)
fun balance(): Balance {
Expand Down Expand Up @@ -81,7 +72,10 @@ contract EVM {
/// Deposits the given vault into the bridged account's balance
access(all)
fun deposit(from: @FlowToken.Vault) {
self.address().deposit(from: <-from)
InternalEVM.deposit(
from: <-from,
to: self.addressBytes
)
}

/// Withdraws the balance from the bridged account's balance
Expand Down
11 changes: 5 additions & 6 deletions fvm/evm/stdlib/contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3075,7 +3075,7 @@ func TestEVMAddressDeposit(t *testing.T) {
handler := &testContractHandler{

accountByAddress: func(fromAddress types.Address, isAuthorized bool) types.Account {
assert.Equal(t, types.Address{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, fromAddress)
assert.Equal(t, types.Address{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, fromAddress)
assert.False(t, isAuthorized)

return &testFlowAccount{
Expand Down Expand Up @@ -3111,10 +3111,9 @@ func TestEVMAddressDeposit(t *testing.T) {
let vault <- minter.mintTokens(amount: 1.23)
destroy minter
let address = EVM.EVMAddress(
bytes: [2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
)
address.deposit(from: <-vault)
let bridgedAccount <- EVM.createBridgedAccount()
bridgedAccount.deposit(from: <-vault)
destroy bridgedAccount
}
`)

Expand Down Expand Up @@ -3236,7 +3235,7 @@ func TestBridgedAccountWithdraw(t *testing.T) {
destroy minter
let bridgedAccount <- EVM.createBridgedAccount()
bridgedAccount.address().deposit(from: <-vault)
bridgedAccount.deposit(from: <-vault)
let vault2 <- bridgedAccount.withdraw(balance: EVM.Balance(flow: 1.23))
let balance = vault2.balance
Expand Down

0 comments on commit 098ff23

Please sign in to comment.