F
Flow5mo ago
Giovanni S

Giovanni S | Flow (2024-06-27)

I'm running to an issue running accessing a contract value in a Crescendo transaction - 9900f1b3e3d1c2ac98b4d70662b6e24506dc7ef745854f5467da1eeca4bae52f I need to access the dereferenced EVMAddress value in order to encode it. I also tried dereferencing in e971eb7ebfb42f2774032c98bb4be710626fb1cd8c838667af42b30a0d6e8cfb with * operator but I'm getting an error
[Error Code: 1101] error caused by: 1 error occurred:
* transaction preprocess failed: [Error Code: 1101] cadence runtime error: Execution failed:
error: cannot apply unary operation * to type
--> cfa5ce8cd7444c5a3ae8f4dc4aa4a237e6d86157c9134464aec93931210cb0e2:23:33
|
23 | let factoryEVMAddress = *FlowEVMBridgeUtils.bridgeFactoryEVMAddress
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected primitive or container of primitives, got `EVM.EVMAddress`
[Error Code: 1101] error caused by: 1 error occurred:
* transaction preprocess failed: [Error Code: 1101] cadence runtime error: Execution failed:
error: cannot apply unary operation * to type
--> cfa5ce8cd7444c5a3ae8f4dc4aa4a237e6d86157c9134464aec93931210cb0e2:23:33
|
23 | let factoryEVMAddress = *FlowEVMBridgeUtils.bridgeFactoryEVMAddress
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected primitive or container of primitives, got `EVM.EVMAddress`
Anyone know how I should be accessing contract fields by value now?
8 Replies
Needle
Needle5mo ago
I've created a thread for your message. Please continue any relevant discussion in this thread. You can rename this thread using /title <new title> If this is a technical question that others may benefit from, considering also asking it on Stackoverflow: https://stackoverflow.com/questions/ask?tags=onflow-cadence
Giovanni S
Giovanni SOP5mo ago
I checked in on this FLIP but couldn't find an example https://github.com/onflow/flips/blob/main/cadence/20240612-import-contract-as-reference.md cc @turbolent @Supun
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
Giovanni S
Giovanni SOP5mo ago
EVM.encodeABI takes an array of values as [AnyStruct] but only certain types can be encoded such that they're interprettable by EVM as compatible bytecode. These valid types include EVMAddress but I'm assuming that passing a reference to an EVMAddress is a different type. In the original transaction without dereferencing, I get this error
❯ flow-c1 transactions send cadence/transactions/bridge/admin/evm/set_registrar.cdc 5e52d93e181bab8c9dbbdedac562c644711f0516 --signer crescendo-flow-evm-bridge -n crescendo
Transaction ID: 9900f1b3e3d1c2ac98b4d70662b6e24506dc7ef745854f5467da1eeca4bae52f

Block ID 2d8660933718b4c904a4259ad28b7ce329d41a606fc68ec713af7357e87a9a76
Block Height 196394952
❌ Transaction Error
[Error Code: 1101] error caused by: 1 error occurred:
* transaction execute failed: [Error Code: 1101] cadence runtime error: Execution failed:
--> 9900f1b3e3d1c2ac98b4d70662b6e24506dc7ef745854f5467da1eeca4bae52f:25:18
|
25 | data: EVM.encodeABIWithSignature(
26 | "setRegistrar(address)",
27 | [FlowEVMBridgeUtils.bridgeFactoryEVMAddress]
28 | ),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: failed to ABI encode value of type &A.8c5303eaa26202d6.EVM.EVMAddress
--> 8c5303eaa26202d6.EVM:579:8
|
579 | let arguments = InternalEVM.encodeABI(values)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
❯ flow-c1 transactions send cadence/transactions/bridge/admin/evm/set_registrar.cdc 5e52d93e181bab8c9dbbdedac562c644711f0516 --signer crescendo-flow-evm-bridge -n crescendo
Transaction ID: 9900f1b3e3d1c2ac98b4d70662b6e24506dc7ef745854f5467da1eeca4bae52f

Block ID 2d8660933718b4c904a4259ad28b7ce329d41a606fc68ec713af7357e87a9a76
Block Height 196394952
❌ Transaction Error
[Error Code: 1101] error caused by: 1 error occurred:
* transaction execute failed: [Error Code: 1101] cadence runtime error: Execution failed:
--> 9900f1b3e3d1c2ac98b4d70662b6e24506dc7ef745854f5467da1eeca4bae52f:25:18
|
25 | data: EVM.encodeABIWithSignature(
26 | "setRegistrar(address)",
27 | [FlowEVMBridgeUtils.bridgeFactoryEVMAddress]
28 | ),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: failed to ABI encode value of type &A.8c5303eaa26202d6.EVM.EVMAddress
--> 8c5303eaa26202d6.EVM:579:8
|
579 | let arguments = InternalEVM.encodeABI(values)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
Giovanni S
Giovanni SOP5mo ago
Ah yeah, that makese sense. Is there a correct way to access the contract field or is this a bug?
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
Giovanni S
Giovanni SOP5mo ago
Ah, got it. Thank you
Want results from more Discord servers?
Add your server