Skip to content

Commit

Permalink
update EVM.Result & implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
sisyphusSmiling committed Apr 26, 2024
1 parent 36efcd5 commit 1a10bd0
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 10 deletions.
6 changes: 5 additions & 1 deletion cadence/contracts/bridge/FlowEVMBridgeUtils.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,10 @@ contract FlowEVMBridgeUtils {
gasLimit: 15000000,
value: EVM.Balance(attoflow: 0)
)
self.bridgeFactoryEVMAddress = evmResult.deployedContractAddress
assert(
evmResult.status == EVM.Status.successful && evmResult.deployedContractAddress != nil,
message: "Bridge factory deployment failed"
)
self.bridgeFactoryEVMAddress = evmResult.deployedContractAddress!
}
}
19 changes: 14 additions & 5 deletions cadence/contracts/standards/EVM.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -198,22 +198,27 @@ contract EVM {

/// returns the newly deployed contract address
/// if the transaction caused such a deployment
/// otherwise the value is empty.
/// otherwise the value is nil.
access(all)
let deployedContractAddress: [UInt8; 20]
let deployedContract: EVMAddress?

init(
status: Status,
errorCode: UInt64,
gasUsed: UInt64,
data: [UInt8],
contractAddress: [UInt8; 20]
contractAddress: [UInt8; 20]?
) {
self.status = status
self.errorCode = errorCode
self.gasUsed = gasUsed
self.data = data
self.deployedContractAddress = contractAddress

if let addressBytes = contractAddress {
self.deployedContract = EVMAddress(bytes: addressBytes)
} else {
self.deployedContract = nil
}
}
}

Expand Down Expand Up @@ -565,10 +570,14 @@ contract EVM {
access(all)
let totalSupply: Int

init(height: UInt64, hash: String, totalSupply: Int) {
access(all)
let timestamp: UInt64

init(height: UInt64, hash: String, totalSupply: Int, timestamp: UInt64) {
self.height = height
self.hash = hash
self.totalSupply = totalSupply
self.timestamp = timestamp
}
}

Expand Down
7 changes: 5 additions & 2 deletions cadence/tests/contracts/EVMDeployer.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ access(all) contract EVMDeployer {
gasLimit: 15_000_000,
value: EVM.Balance(attoflow: value)
)
assert(evmResult.status == EVM.Status.successful, message: "EVM deployment failed")
assert(
evmResult.status == EVM.Status.successful && evmResult.deployedContractAddress != nil,
message: "EVM contract deployment failed"
)

self.deployedAddresses[name] = evmResult.deployedContractAddress
self.deployedAddresses[name] = evmResult.deployedContractAddress!
}

access(self) fun borrowCOA(): auth(EVM.Deploy) &EVM.CadenceOwnedAccount {
Expand Down
2 changes: 1 addition & 1 deletion cadence/tests/test_helpers.cdc

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion cadence/transactions/evm/deploy.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ transaction(bytecode: String, gasLimit: UInt64, value: UFix64) {
gasLimit: gasLimit,
value: valueBalance
)
assert(evmResult.status == EVM.Status.successful, message: "EVM deployment failed")
assert(
evmResult.status == EVM.Status.successful && evmResult.deployedContractAddress != nil,
message: "Bridge factory deployment failed"
)
}
}

0 comments on commit 1a10bd0

Please sign in to comment.