-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add entitlement for locked account creator #423
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -661,14 +661,16 @@ access(all) contract LockedTokens { | |
} | ||
} | ||
|
||
access(all) entitlement AccountCreator | ||
|
||
access(all) resource interface AddAccount { | ||
access(all) fun addAccount( | ||
access(AccountCreator) fun addAccount( | ||
sharedAccountAddress: Address, | ||
unlockedAccountAddress: Address, | ||
tokenAdmin: Capability<auth(FungibleToken.Withdraw) &LockedTokenManager>) | ||
} | ||
|
||
/// Resource that the Dapper Labs token admin | ||
/// Resource that the Flow token admin | ||
/// stores in their account to manage the vesting schedule | ||
/// for all the token holders | ||
access(all) resource TokenAdminCollection: AddAccount { | ||
|
@@ -682,7 +684,7 @@ access(all) contract LockedTokens { | |
|
||
/// Add a new account's locked token manager capability | ||
/// to the record | ||
access(all) fun addAccount( | ||
access(AccountCreator) fun addAccount( | ||
sharedAccountAddress: Address, | ||
unlockedAccountAddress: Address, | ||
tokenAdmin: Capability<auth(FungibleToken.Withdraw) &LockedTokenManager>) | ||
|
@@ -703,27 +705,27 @@ access(all) contract LockedTokens { | |
} | ||
|
||
access(all) resource interface LockedAccountCreatorPublic { | ||
access(all) fun addCapability(cap: Capability<&TokenAdminCollection>) | ||
access(all) fun addCapability(cap: Capability<auth(LockedTokens.AccountCreator) &TokenAdminCollection>) | ||
} | ||
|
||
// account creators store this resource in their account | ||
// in order to be able to register accounts who have locked tokens | ||
access(all) resource LockedAccountCreator: LockedAccountCreatorPublic, AddAccount { | ||
|
||
access(self) var addAccountCapability: Capability<&TokenAdminCollection>? | ||
access(self) var addAccountCapability: Capability<auth(LockedTokens.AccountCreator) &TokenAdminCollection>? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will be migrated by default, correct? We don't need a custom migration for this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe so since the prior capability was on the resource, but I'd want to double check with @turbolent There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please try migrating the contract and see if the entitlement is inferred to be required now. From what I can see, it should and no custom migration should be required (if someone had a |
||
|
||
init() { | ||
self.addAccountCapability = nil | ||
} | ||
|
||
access(all) fun addCapability(cap: Capability<&TokenAdminCollection>) { | ||
access(all) fun addCapability(cap: Capability<auth(LockedTokens.AccountCreator) &TokenAdminCollection>) { | ||
pre { | ||
cap.borrow() != nil: "Invalid token admin collection capability" | ||
} | ||
self.addAccountCapability = cap | ||
} | ||
|
||
access(all) fun addAccount(sharedAccountAddress: Address, | ||
access(AccountCreator) fun addAccount(sharedAccountAddress: Address, | ||
unlockedAccountAddress: Address, | ||
tokenAdmin: Capability<auth(FungibleToken.Withdraw) &LockedTokenManager>) { | ||
|
||
|
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.