forked from onflow/hybrid-custody
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend AccountPublic to allow retrieval of Factory and Filter capabil…
…ities (onflow#153) Without this, it's very difficult to detect whether a certain capability is allowed to be retrieved unless you run scripts manually. With helper methods like this (I'm sure others will be needed), you can borrow and return details of the filter/factory yourself and then process them offline
- Loading branch information
1 parent
5ac8e29
commit 8e4f566
Showing
3 changed files
with
41 additions
and
0 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,19 @@ | ||
import "HybridCustody" | ||
|
||
// @addr - The address of the child account | ||
// @parent - The parent account that this child is assigned to | ||
pub fun main(addr: Address, parent: Address): Bool { | ||
let identifier = HybridCustody.getChildAccountIdentifier(parent) | ||
let path = PrivatePath(identifier: identifier) ?? panic("invalid public path identifier for parent address") | ||
|
||
let acctPublic = getAuthAccount(addr).getCapability<&HybridCustody.ChildAccount{HybridCustody.AccountPublic}>(path) | ||
.borrow() ?? panic("account public not found") | ||
|
||
let factory = acctPublic.getCapabilityFactoryManager() | ||
assert(factory != nil, message: "capability factory is not valid") | ||
|
||
let filter = acctPublic.getCapabilityFilter() | ||
assert(filter != nil, message: "capability filter is not valid") | ||
|
||
return true | ||
} |
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