-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update .getCapability() to return nil if cap disallowed + tests
- Loading branch information
1 parent
84ab4b8
commit ccb3637
Showing
5 changed files
with
69 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import "HybridCustody" | ||
|
||
import "NonFungibleToken" | ||
import "MetadataViews" | ||
import "ExampleNFT" | ||
|
||
// Verify that a child address borrowed as a child will let the parent borrow an NFT provider capability | ||
pub fun main(parent: Address, child: Address, returnsNil: Bool): Bool { | ||
let acct = getAuthAccount(parent) | ||
let m = acct.borrow<&HybridCustody.Manager>(from: HybridCustody.ManagerStoragePath) | ||
?? panic("manager does not exist") | ||
|
||
let childAcct = m.borrowAccount(addr: child) ?? panic("child account not found") | ||
|
||
let d = ExampleNFT.resolveView(Type<MetadataViews.NFTCollectionData>())! as! MetadataViews.NFTCollectionData | ||
|
||
let nakedCap = childAcct.getCapability(path: d.providerPath, type: Type<&{NonFungibleToken.Provider}>()) | ||
|
||
return returnsNil ? nakedCap == nil : nakedCap?.borrow<&{NonFungibleToken.Provider}>() != nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters