-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca4c65c
commit 0c2899f
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import "EVM" | ||
|
||
import "FlowEVMBridgeConfig" | ||
import "FlowEVMBridgeUtils" | ||
|
||
access(all) | ||
fun main(coaHost: Address): String { | ||
let coa = getAuthAccount<auth(BorrowValue) &Account>(coaHost) | ||
.storage | ||
.borrow<auth(EVM.Call) &EVM.CadenceOwnedAccount>(from: /storage/evm) | ||
?? panic("Could not borrow CadenceOwnedAccount from host=".concat(coaHost.toString())) | ||
let res = coa.call( | ||
to: FlowEVMBridgeUtils.getBridgeFactoryEVMAddress(), | ||
data: EVM.encodeABIWithSignature("getRegistry()", []), | ||
gasLimit: FlowEVMBridgeConfig.gasLimit, | ||
value: EVM.Balance(attoflow: UInt(0)) | ||
) | ||
|
||
assert( | ||
res.status == EVM.Status.successful, | ||
message: "getRegistry call to FlowEVMBridgeFactory failed" | ||
) | ||
|
||
let decodedRes = EVM.decodeABI(types: [Type<EVM.EVMAddress>()], data: res.data) | ||
|
||
assert(decodedRes.length == 1, message: "Invalid response length") | ||
|
||
return (decodedRes[0] as! EVM.EVMAddress).toString() | ||
} |