From 02aab3f2c2995ff898ef6c6a912c17e21daafaaa Mon Sep 17 00:00:00 2001 From: Giovanni Sanchez <108043524+sisyphusSmiling@users.noreply.github.com> Date: Wed, 22 May 2024 11:17:38 -0500 Subject: [PATCH] add get_associated_type script --- cadence/scripts/bridge/get_associated_type.cdc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 cadence/scripts/bridge/get_associated_type.cdc diff --git a/cadence/scripts/bridge/get_associated_type.cdc b/cadence/scripts/bridge/get_associated_type.cdc new file mode 100644 index 00000000..52520f03 --- /dev/null +++ b/cadence/scripts/bridge/get_associated_type.cdc @@ -0,0 +1,17 @@ +import "EVM" + +import "EVMUtils" +import "FlowEVMBridgeConfig" + +/// Returns the Cadence Type associated with the given EVM address (as its hex String) +/// +/// @param evmAddressHex: The hex-encoded address of the EVM contract as a String +/// +/// @return The Cadence Type associated with the EVM address or nil if the address is not onboarded. `nil` may also be +/// returned if the address is not a valid EVM address. +/// +access(all) +fun main(addressHex: String): Type? { + let address = EVMUtils.getEVMAddressFromHexString(address: addressHex) + return address != nil ? FlowEVMBridgeConfig.getTypeAssociated(with: address!) : nil +}