-
Notifications
You must be signed in to change notification settings - Fork 14
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
Allow token transfer -- SPL token policy example #446
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
2ba1bbe
to
00100cc
Compare
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.
Looking 🔥 thus far. In terms of next steps:
- minor: feature needs a changeset (
pnpm run changeset
) - hooking it up with an example in
with-solana
would be amazing - combining with https://github.com/tkhq/sdk/blob/main/examples/kitchen-sink/src/sdk-server/createPolicy.ts to compute a token address + create a policy based on it would be doubly amazing
stoked about this
@andrewkmin couple notes here!! Given that the associated token address calculating method is readily available by from Solana, I think creating a wrapper function for it and exposing may be less helpful/ a point of confusion/extra weight for us. I think what's most helpful is a full example of how to use this with Same with combining this with I've created an extensive example with instructions that I think is most helpful in helping folks understand how to best use our SPL support. Let me know if this makes sense overall. |
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.
looking good overall!
examples/with-solana/README.md
Outdated
|
||
```bash | ||
New policy created! | ||
- Name: Let non root user send SPL transfers to the ATA of WARCHEST: 6nDvKk6emwskFLtEpbQgFX6rsMtzbNY4LkvaNnzkvBaq |
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.
should we specify which SPL token we're working with given ATA's are token-specific?
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.
did you mean to resolve this one? you could also mention that we're allowing specifically the transfer to the ATA of the warchest wallet associated with the newly created token
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.
looks good overall, just some minor comments consider~!
examples/with-solana/README.md
Outdated
@@ -166,7 +166,138 @@ Token balance for warchest: 0.0001 | |||
|
|||
Enjoy! | |||
|
|||
### 6/ Stackblitz Example | |||
### 6/ Running the "Create SPL token transfer policy" example |
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.
tiny nit: the reason I would include the with
preposition here is that this example contains more than just creating a policy — we're creating a policy and then using it in practice :)
examples/with-solana/README.md
Outdated
|
||
```bash | ||
New policy created! | ||
- Name: Let non root user send SPL transfers to the ATA of WARCHEST: 6nDvKk6emwskFLtEpbQgFX6rsMtzbNY4LkvaNnzkvBaq |
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.
did you mean to resolve this one? you could also mention that we're allowing specifically the transfer to the ATA of the warchest wallet associated with the newly created token
Summary & Motivation
This PR creates an example that highlights the flow of using our policy engine's support for SPL token transfers! Specifically we show how to allow a user (non root user) to send a Solana SPL token transfer by calculating the "associated token address" of the receiving account, given the mint address of the token that we are transferring.
The steps included are
How I Tested These Changes
Tested the example multiple times
Did you add a changeset?
If updating one of our packages, you'll likely need to add a changeset to your PR. To do so, run
pnpm changeset
.pnpm changeset
will generate a file where you should write a human friendly message about the changes. Note how this (example) includes the package name (should be auto added by the command) along with the type of semver change (major.minor.patch) (which you should set).These changes will be used at release time to determine what packages to publish and how to bump their version. For more context see this comment.