Skip to content

Commit

Permalink
fix escrow.isInitialized
Browse files Browse the repository at this point in the history
  • Loading branch information
sisyphusSmiling committed Apr 6, 2024
1 parent 4ff453e commit e7fe26f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions cadence/contracts/bridge/FlowEVMBridgeNFTEscrow.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,12 @@ access(all) contract FlowEVMBridgeNFTEscrow {
/// Retrieves an entitled locker for the given type or nil if it doesn't exist
///
access(self) view fun borrowLocker(forType: Type): auth(NonFungibleToken.Withdraw) &Locker? {
let lockerPath = FlowEVMBridgeUtils.deriveEscrowStoragePath(fromType: forType)
?? panic("Problem deriving locker path")
return self.account.storage.borrow<auth(NonFungibleToken.Withdraw) &Locker>(from: lockerPath)
if let lockerPath = FlowEVMBridgeUtils.deriveEscrowStoragePath(fromType: forType) {
if self.account.storage.type(at: lockerPath) == Type<@Locker>() {
return self.account.storage.borrow<auth(NonFungibleToken.Withdraw) &Locker>(from: lockerPath)
}
}
return nil
}

/*********************
Expand Down
9 changes: 6 additions & 3 deletions cadence/contracts/bridge/FlowEVMBridgeTokenEscrow.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,12 @@ access(all) contract FlowEVMBridgeTokenEscrow {
/// Retrieves an entitled locker for the given type or nil if it doesn't exist
///
access(self) view fun borrowLocker(forType: Type): auth(FungibleToken.Withdraw) &Locker? {
let lockerPath = FlowEVMBridgeUtils.deriveEscrowStoragePath(fromType: forType)
?? panic("Problem deriving locker path")
return self.account.storage.borrow<auth(FungibleToken.Withdraw) &Locker>(from: lockerPath)
if let lockerPath = FlowEVMBridgeUtils.deriveEscrowStoragePath(fromType: forType) {
if self.account.storage.type(at: lockerPath) == Type<@Locker>() {
return self.account.storage.borrow<auth(FungibleToken.Withdraw) &Locker>(from: lockerPath)
}
}
return nil
}

/*********************
Expand Down

0 comments on commit e7fe26f

Please sign in to comment.