Skip to content

Commit

Permalink
fix Config.getEVMAddressAssociated which failed for handled tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
sisyphusSmiling committed Dec 20, 2024
1 parent 027f676 commit 4f9050d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cadence/contracts/bridge/FlowEVMBridgeConfig.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ contract FlowEVMBridgeConfig {
///
access(all)
view fun getEVMAddressAssociated(with type: Type): EVM.EVMAddress? {
return self.registeredTypes[type]?.evmAddress
if !self.typeHasTokenHandler(type) {
return self.registeredTypes[type]?.evmAddress
}
return self.borrowTokenHandler(type)!.getTargetEVMAddress()
}

/// Retrieves the type associated with a given EVMAddress if it has been onboarded to the bridge
Expand Down Expand Up @@ -535,6 +538,9 @@ contract FlowEVMBridgeConfig {
///
access(FlowEVMBridgeHandlerInterfaces.Admin)
fun removeAssociationByType(_ type: Type): EVM.EVMAddress {
pre {
!FlowEVMBridgeConfig.typeHasTokenHandler(type): "Cannot remove associations for Types fulfilled by TokenHandlers"
}
let evmAssociation = FlowEVMBridgeConfig.registeredTypes.remove(key: type)
?? panic("No association found for type ".concat(type.identifier))
let typeAssociation = FlowEVMBridgeConfig.evmAddressHexToType.remove(key: evmAssociation.evmAddress.toString())
Expand Down

0 comments on commit 4f9050d

Please sign in to comment.