Skip to content

Commit

Permalink
Fix code
Browse files Browse the repository at this point in the history
  • Loading branch information
SupunS committed Feb 15, 2024
1 parent baf9cc3 commit 873396d
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 23 deletions.
15 changes: 10 additions & 5 deletions fvm/evm/evm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
`,
Expand Down
9 changes: 5 additions & 4 deletions fvm/evm/stdlib/contract.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
15 changes: 10 additions & 5 deletions fvm/evm/stdlib/contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}`)

Expand Down
3 changes: 2 additions & 1 deletion fvm/fvm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}

Expand All @@ -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)),
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
4 changes: 2 additions & 2 deletions integration/benchmark/scripts/dataHeavyContract.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion integration/benchmark/scripts/dataHeavyTransaction.cdc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import DataHeavy from 0x%s

transaction {
prepare(acct: AuthAccount) {}
prepare(acct: &Account) {}
execute {
DataHeavy.LedgerInteractionHeavy(100)
DataHeavy.EventHeavy(100)
Expand Down
4 changes: 2 additions & 2 deletions integration/benchmark/scripts/ledgerHeavyContract.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ledger/complete/compactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion ledger/complete/wal/wal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 873396d

Please sign in to comment.