Skip to content

Commit

Permalink
add get_associated_type script
Browse files Browse the repository at this point in the history
  • Loading branch information
sisyphusSmiling committed May 22, 2024
1 parent 7e8d4df commit 02aab3f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cadence/scripts/bridge/get_associated_type.cdc
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 02aab3f

Please sign in to comment.