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

New patch state, key, account API #250

Closed
ChaoticTempest opened this issue Dec 6, 2022 · 0 comments · Fixed by #291
Closed

New patch state, key, account API #250

ChaoticTempest opened this issue Dec 6, 2022 · 0 comments · Fixed by #291

Comments

@ChaoticTempest
Copy link
Member

So far only Worker::patch_state is available for users to patch values into, with #124 trying to add the rest (patch_account, patch_keys), but that hasn't had much progress for a while.

Instead of that, I suggest a simpler API that should be easier to add.

We can have a Worker::<Sandbox>::patch(AccountId) which very similar and consistent with APIs like {Account, Contract}::batch(AccountId) that can be a builder that takes multiple entries to patching state or keys, along with patching account as well:

worker.patch(AccountId)
    .access_key(public_key, AccessKey::function_call_access())
    .access_key(public_key, AccessKey::full_access())
    .access_keys(impl Iterator<(PublicKey, AccessKey)>)
    .state(key: &[u8], val: &[u8])
    .state(...)
    .states(impl Iterator<(&[u8], &[u8])>)
    .account(AccountDetails)
    // or change up the account from what's currently on the chain
    .account_from_current(|account: AccountDetails| {
         account.balance = 10000;
         account
    })
    .await?;

We can also continue to provide the non-builder versions as well as to not require switching over to this syntax for users of patch_state already, and have two newer API surfaces patch_key(AccountId, AccessKey) and patch_account(AccountId, AccountDetails)

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 a pull request may close this issue.

1 participant