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

[x/programs] Support key deletion #737

Merged
merged 7 commits into from
Mar 5, 2024

Conversation

najeal
Copy link
Contributor

@najeal najeal commented Feb 19, 2024

This PR does the following:
It enhances state import module and usage adding delete function to delete keys from the State.
It updates the Token example to use the delete function throught a new public program function burn_from.

Closes #590

wasmlanche_sdk: update state module import - add delete function
imports/pstate: add delete function
This function is using the new delete function being available from the state import module
@najeal najeal force-pushed the x-program-key-deletion branch from dd4fed7 to ce0469d Compare February 20, 2024 20:38
Copy link
Contributor

@richardpringle richardpringle left a comment

Choose a reason for hiding this comment

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

Hey @najeal, thanks for the PR!

We're starting to get a little more strict with reviews here, so I apologize if you followed an existing pattern and I asked you to change something.

The change requests should be simple enough, though!

Feel free to let me know if you have any questions.

x/programs/examples/imports/pstate/pstate.go Outdated Show resolved Hide resolved
x/programs/rust/examples/token/src/lib.rs Show resolved Hide resolved
// check balance of alice
result, err = rt.Call(ctx, "get_balance", programIDPtr, alicePtr)
require.NoError(err)
require.Equal(int64(0), result[0])
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔, this test doesn't guarantee that the behaviour is as intended. We should check the state and ensure the key is no longer there.

x/programs/rust/wasmlanche_sdk/src/state.rs Outdated Show resolved Hide resolved
delete function returns -1 when removing key from state fails
Access state db to verify key has been deleted after calling burn_from function
richardpringle
richardpringle previously approved these changes Feb 27, 2024
require: None,
}, owner_key)
.expect("failed to burn alice tokens");
assert_eq!(resp.error, None);
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@richardpringle
Copy link
Contributor

@najeal, looks like you need to run cargo fmt

@richardpringle
Copy link
Contributor

@najeal, can you mention me in a comment if I forget about this? Everything looks good, we just need CI to pass

@najeal
Copy link
Contributor Author

najeal commented Mar 5, 2024

@richardpringle CI passed 🙂

@richardpringle richardpringle merged commit cc26511 into ava-labs:main Mar 5, 2024
37 checks passed
@najeal najeal deleted the x-program-key-deletion branch March 5, 2024 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[x/programs] Support key deletion
2 participants