Skip to content

Commit e3dc73e

Browse files
committed
make borrowNFT return Optional
1 parent f663bed commit e3dc73e

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

nft-provider-aggregator/contracts/NFTProviderAggregator.cdc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ access(all) contract NFTProviderAggregator {
180180

181181
/// Borrow the collection of an NFT located in one of multiple collections through iterating over each collection
182182
///
183-
access(all) view fun borrowNFTCollection(id: UInt64): &{NonFungibleToken.Provider, NonFungibleToken.CollectionPublic} {
183+
access(all) view fun borrowNFTCollection(id: UInt64): &{NonFungibleToken.Provider, NonFungibleToken.CollectionPublic}? {
184184
for collectionUUID in self.nftProviderCapabilities.keys {
185185
// Check capabilities can still be borrowed since a NFT provider capability may pass the
186186
// pre-condition checks at the time of being added with the addNFTWithdrawCapability method but
@@ -204,7 +204,7 @@ access(all) contract NFTProviderAggregator {
204204
}
205205
}
206206
}
207-
panic("missing NFT")
207+
return nil
208208
}
209209

210210
/// Withdraw an NFT located in one of multiple collections through iterating over each collection
@@ -215,8 +215,8 @@ access(all) contract NFTProviderAggregator {
215215

216216
/// Borrow an NFT located in one of multiple collections through iterating over each collection
217217
///
218-
access(all) view fun borrowNFT(id: UInt64): &{NonFungibleToken.NFT} {
219-
return self.borrowNFTCollection(id: id).borrowNFT(id)!
218+
access(all) view fun borrowNFT(id: UInt64): &{NonFungibleToken.NFT}? {
219+
return self.borrowNFTCollection(id: id)?.borrowNFT(id) ?? nil
220220
}
221221

222222
/// Create and return a Supplier resource

0 commit comments

Comments
 (0)