Skip to content
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

Updates batch unlock to only publish if needed #447

Merged
merged 3 commits into from
Sep 9, 2024

Conversation

joshuahannan
Copy link
Member

@joshuahannan joshuahannan commented Sep 6, 2024

Updates the transaction to unlock tokens in a batch of accounts to only publish a capability to the bad accounts dictionary if one already wasn't there

Edit: Also updates the emulator and CLI versions to ensure the tests pass and removes mentions of previewnet

@joshuahannan joshuahannan requested a review from Kay-Zee September 6, 2024 22:38
let unlockingBadAccountCap = admin.capabilities.storage.issue<&{Address: UFix64}>(/storage/unlockingBadAccounts)
admin.capabilities.publish(unlockingBadAccountCap, at: /public/unlockingBadAccounts)
let unlockingBadAccountCap = admin.capabilities.get<&{Address: UFix64}>(/public/unlockingBadAccounts)
if !unlockingBadAccountCap.check() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check() returns true if it exists?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. 👍

let unlockingBadAccountCap = admin.capabilities.get<&{Address: UFix64}>(/public/unlockingBadAccounts)
if !unlockingBadAccountCap.check() {
let unlockingBadAccountCap = admin.capabilities.storage.issue<&{Address: UFix64}>(/storage/unlockingBadAccounts)
admin.capabilities.unpublish(/public/unlockingBadAccounts)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing unpublishing a non-existent path is just a no-op?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct, nothing will happen if there isn't anything there

admin.capabilities.publish(unlockingBadAccountCap, at: /public/unlockingBadAccounts)
let unlockingBadAccountCap = admin.capabilities.get<&{Address: UFix64}>(/public/unlockingBadAccounts)
if !unlockingBadAccountCap.check() {
let unlockingBadAccountCap = admin.capabilities.storage.issue<&{Address: UFix64}>(/storage/unlockingBadAccounts)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess the extra let is just shadowing this var, which isn't a problem since it's only used here in this if.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, shouldn't be a problem to shadow it

@joshuahannan joshuahannan merged commit 5634f76 into master Sep 9, 2024
2 checks passed
@joshuahannan joshuahannan deleted the update-unlock-batch branch September 9, 2024 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants