From 873396d628b0b379ec2bb846f418b68a49f7d94a Mon Sep 17 00:00:00 2001 From: Supun Setunga Date: Thu, 15 Feb 2024 16:47:44 +0530 Subject: [PATCH] Fix code --- fvm/evm/evm_test.go | 15 ++++++++++----- fvm/evm/stdlib/contract.cdc | 9 +++++---- fvm/evm/stdlib/contract_test.go | 15 ++++++++++----- fvm/fvm_test.go | 3 ++- .../scripts/addKeysToAccountTransaction.cdc | 2 +- .../benchmark/scripts/dataHeavyContract.cdc | 4 ++-- .../benchmark/scripts/dataHeavyTransaction.cdc | 2 +- .../benchmark/scripts/ledgerHeavyContract.cdc | 4 ++-- ledger/complete/compactor_test.go | 2 +- ledger/complete/wal/wal.go | 2 +- 10 files changed, 35 insertions(+), 23 deletions(-) diff --git a/fvm/evm/evm_test.go b/fvm/evm/evm_test.go index 43c7b18eb5a..8ec7836fb42 100644 --- a/fvm/evm/evm_test.go +++ b/fvm/evm/evm_test.go @@ -329,12 +329,17 @@ func TestCadenceArch(t *testing.T) { import EVM from %s transaction { - prepare(account: AuthAccount) { + prepare(account: auth(Capabilities, SaveValue) &Account) { let bridgedAccount1 <- EVM.createBridgedAccount() - account.save<@EVM.BridgedAccount>(<-bridgedAccount1, - to: /storage/bridgedAccount) - account.link<&EVM.BridgedAccount{EVM.Addressable}>(/public/bridgedAccount, - target: /storage/bridgedAccount) + + account.storage.save<@EVM.BridgedAccount>( + <-bridgedAccount1, + to: /storage/bridgedAccount + ) + + let bridgedAccount = account.capabilities.storage + .issue<&EVM.BridgedAccount>(/storage/bridgedAccount) + account.capabilities.publish(bridgedAccount, at: /public/bridgedAccount) } } `, diff --git a/fvm/evm/stdlib/contract.cdc b/fvm/evm/stdlib/contract.cdc index dbcedbeb9a9..78178f6b4b6 100644 --- a/fvm/evm/stdlib/contract.cdc +++ b/fvm/evm/stdlib/contract.cdc @@ -4,7 +4,8 @@ import "FlowToken" access(all) contract EVM { - pub event BridgedAccountCreated(addressBytes: [UInt8; 20]) + access(all) + event BridgedAccountCreated(addressBytes: [UInt8; 20]) /// EVMAddress is an EVM-compatible address access(all) @@ -276,12 +277,12 @@ contract EVM { let isValid = keyList.verify( signatureSet: signatureSet, - signedData: signedData + signedData: signedData, + domainSeparationTag: "FLOW-V0.0-user" ) assert(isValid, message: "signatures not valid") - let coaRef = acc.getCapability(path) - .borrow<&EVM.BridgedAccount{EVM.Addressable}>() + let coaRef = acc.capabilities.borrow<&EVM.BridgedAccount>(path) ?? panic("could not borrow bridge account's address") // verify evm address matching diff --git a/fvm/evm/stdlib/contract_test.go b/fvm/evm/stdlib/contract_test.go index 67ec36cce89..bf6e7d3d58d 100644 --- a/fvm/evm/stdlib/contract_test.go +++ b/fvm/evm/stdlib/contract_test.go @@ -3775,12 +3775,17 @@ func TestEVMValidateCOAOwnershipProof(t *testing.T) { import EVM from 0x1 transaction { - prepare(account: AuthAccount) { + prepare(account: auth(Capabilities, SaveValue) &Account) { let bridgedAccount1 <- EVM.createBridgedAccount() - account.save<@EVM.BridgedAccount>(<-bridgedAccount1, - to: /storage/bridgedAccount) - account.link<&EVM.BridgedAccount{EVM.Addressable}>(/public/bridgedAccount, - target: /storage/bridgedAccount) + + account.storage.save<@EVM.BridgedAccount>( + <-bridgedAccount1, + to: /storage/bridgedAccount + ) + + let bridgedAccount = account.capabilities.storage + .issue<&EVM.BridgedAccount>(/storage/bridgedAccount) + account.capabilities.publish(bridgedAccount, at: /public/bridgedAccount) } }`) diff --git a/fvm/fvm_test.go b/fvm/fvm_test.go index 752a189ed99..cdb6946b202 100644 --- a/fvm/fvm_test.go +++ b/fvm/fvm_test.go @@ -2986,7 +2986,7 @@ func TestEVM(t *testing.T) { require.NoError(t, err) require.NoError(t, output.Err) - require.Len(t, output.Events, 6) + require.Len(t, output.Events, 7) evmLocation := types.EVMLocation{} @@ -3002,6 +3002,7 @@ func TestEVM(t *testing.T) { []common.TypeID{ evmLocation.TypeID(nil, string(types.EventTypeTransactionExecuted)), evmLocation.TypeID(nil, string(types.EventTypeBlockExecuted)), + "A.f8d6e0586b0a20c7.EVM.BridgedAccountCreated", "A.0ae53cb6e3f42a79.FlowToken.TokensWithdrawn", "A.ee82856bf20e2aa6.FungibleToken.Withdrawn", evmLocation.TypeID(nil, string(types.EventTypeTransactionExecuted)), diff --git a/integration/benchmark/scripts/addKeysToAccountTransaction.cdc b/integration/benchmark/scripts/addKeysToAccountTransaction.cdc index 3530357ddfb..500dc894c92 100644 --- a/integration/benchmark/scripts/addKeysToAccountTransaction.cdc +++ b/integration/benchmark/scripts/addKeysToAccountTransaction.cdc @@ -1,5 +1,5 @@ transaction(keys: [[UInt8]]) { - prepare(signer: auth(AddContract) &Account) { + prepare(signer: auth(AddContract, AddKey) &Account) { for key in keys { let publicKey = PublicKey( publicKey: key, diff --git a/integration/benchmark/scripts/dataHeavyContract.cdc b/integration/benchmark/scripts/dataHeavyContract.cdc index e5b12462005..8b8e86589ab 100644 --- a/integration/benchmark/scripts/dataHeavyContract.cdc +++ b/integration/benchmark/scripts/dataHeavyContract.cdc @@ -12,9 +12,9 @@ access(all) contract DataHeavy { access(all) struct Item { - pub let itemID: UInt32 + access(all) let itemID: UInt32 - pub let metadata: {String: String} + access(all) let metadata: {String: String} init(_ metadata: {String: String}) { self.itemID = DataHeavy.itemCounter diff --git a/integration/benchmark/scripts/dataHeavyTransaction.cdc b/integration/benchmark/scripts/dataHeavyTransaction.cdc index 8d0deaecf3c..0638779a87c 100644 --- a/integration/benchmark/scripts/dataHeavyTransaction.cdc +++ b/integration/benchmark/scripts/dataHeavyTransaction.cdc @@ -1,7 +1,7 @@ import DataHeavy from 0x%s transaction { - prepare(acct: AuthAccount) {} + prepare(acct: &Account) {} execute { DataHeavy.LedgerInteractionHeavy(100) DataHeavy.EventHeavy(100) diff --git a/integration/benchmark/scripts/ledgerHeavyContract.cdc b/integration/benchmark/scripts/ledgerHeavyContract.cdc index 353547924c7..1fa13888ec8 100644 --- a/integration/benchmark/scripts/ledgerHeavyContract.cdc +++ b/integration/benchmark/scripts/ledgerHeavyContract.cdc @@ -12,9 +12,9 @@ access(all) contract LedgerHeavy { access(all) struct Item { - pub let itemID: UInt32 + access(all) let itemID: UInt32 - pub let metadata: {String: String} + access(all) let metadata: {String: String} init(_ metadata: {String: String}) { self.itemID = LedgerHeavy.itemCounter diff --git a/ledger/complete/compactor_test.go b/ledger/complete/compactor_test.go index 3258361cb04..e06eff54ec1 100644 --- a/ledger/complete/compactor_test.go +++ b/ledger/complete/compactor_test.go @@ -816,7 +816,7 @@ func replaySegments( updateFn func(update *ledger.TrieUpdate) error, deleteFn func(rootHash ledger.RootHash) error, ) error { - sr, err := prometheusWAL.NewSegmentsRangeReader(unittest.Logger(), prometheusWAL.SegmentRange{ + sr, err := prometheusWAL.NewSegmentsRangeReader(prometheusWAL.SegmentRange{ Dir: dir, First: 0, Last: to, diff --git a/ledger/complete/wal/wal.go b/ledger/complete/wal/wal.go index 4f8d04082c2..8471079680f 100644 --- a/ledger/complete/wal/wal.go +++ b/ledger/complete/wal/wal.go @@ -262,7 +262,7 @@ func (w *DiskWAL) replay( Int("loaded_checkpoint", loadedCheckpoint). Msgf("replaying segments from %d to %d", startSegment, to) - sr, err := prometheusWAL.NewSegmentsRangeReader(w.log, prometheusWAL.SegmentRange{ + sr, err := prometheusWAL.NewSegmentsRangeReader(prometheusWAL.SegmentRange{ Dir: w.wal.Dir(), First: startSegment, Last: to,