-
Notifications
You must be signed in to change notification settings - Fork 924
Add Token Extension 2022 Extension schema in Graphql along with tests. #2535
Add Token Extension 2022 Extension schema in Graphql along with tests. #2535
Conversation
|
@buffalojoec, can you review the sample |
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.
Here's what initializeTransferFeeConfig
looks like on the RPC if you just create a token using the CLI on the local validator and then query the transaction.
"instructions": [
{
"parsed": {
"info": {
"lamports": 2825760,
"newAccount": "EXXcv32qEKo7nfs4dKnseB977Ky9qpedQzeqLG2nD8kJ",
"owner": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb",
"source": "2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB",
"space": 278
},
"type": "createAccount"
},
"program": "system",
"programId": "11111111111111111111111111111111",
"stackHeight": null
},
{
"parsed": {
"info": {
"maximumFee": 5000,
"mint": "EXXcv32qEKo7nfs4dKnseB977Ky9qpedQzeqLG2nD8kJ",
"transferFeeBasisPoints": 50,
"transferFeeConfigAuthority": "2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB",
"withdrawWithheldAuthority": "2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB"
},
"type": "initializeTransferFeeConfig"
},
"program": "spl-token",
"programId": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb",
"stackHeight": null
},
{
"parsed": {
"info": {
"decimals": 9,
"mint": "EXXcv32qEKo7nfs4dKnseB977Ky9qpedQzeqLG2nD8kJ",
"mintAuthority": "2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB",
"rentSysvar": "SysvarRent111111111111111111111111111111111"
},
"type": "initializeMint"
},
"program": "spl-token",
"programId": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb",
"stackHeight": null
}
],
As you can see, the transaction-status
, and therefore the jsonParsed
module of the RPC, just treats Token-2022 extension instructions as any old Token-2022 instruction.
Let's do exactly that with GraphQL! Here's an example of what I mean:
type SplToken2022InitializeTransferFeeConfigInstruction implements TransactionInstrucion {
programId: Address
maximumFee: BigInt
mint: Account
transferFeeConfigAuthority: Account
withdrawWithheldAuthority: Account
}
What do you think?
type TransferFeeExtension { | ||
mint: String | ||
transferFeeBasisPoints: Int | ||
maximumFee: Int | ||
transferFeeConfigAuthority: String | ||
withdrawWithheldAuthority: String | ||
source: String | ||
destination: String | ||
tokenAmount: TokenAmount | ||
feeAmount: TokenAmount | ||
signers: [Address] | ||
authority: String | ||
multisigWithdrawWithheldAuthority: String | ||
feeRecipient: String | ||
sourceAccounts: [String] | ||
multisigtransferFeeConfigAuthority: String | ||
multisigAuthority: String | ||
} |
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.
TransferFeeExtension
actually has its own set of instructions, as each extension does. I think you've globbed together all of them here:
TransferCheckedWithFee
WithdrawWithheldTokensFromMint
WithdrawWithheldTokensFromAccounts
HarvestWithheldTokensToMint
SetTransferFee
As I mentioned in my comment here, all Token-2022 extensions actually have their own set of instructions (sometimes just one), and we can just treat each of those instructions as individual Token-2022 instructions! |
@Hrushi20 Thanks for taking on this effort. I'm pumped we're going to be adding support for Token-2022 extensions! I have a few suggestions, if you don't mind. For starters, maybe let's use the issue to track the overall effort, and then just do one PR per extension, where you add the extension to the schema and add a test? They'll all be super small but it will be easier to track as we go. I can update the issue with a list of all instructions if that's easier? To start the process off, it might be a huge help to create a token on the CLI that has every single extension possible, and just copy-paste that transaction into the |
@Hrushi20 I've updated the issue with the big list of all extensions. #2406 (comment) And I've also added a PR with a mock transaction! #2544 |
Hey! Thanks a lot for explaining and helping me out. I'll start of by creating a token having all extensions and adding it to __setup.js. Then we add incrementally add schema and test them separately in different PR's. |
I did this already! I linked a PR in my previous comment where I laid this up. If you follow the Graphite stack I also did a couple extensions with tests, as reference. |
I missed that comment. Too late here in my country. Will work on this tmr. Thanks :) |
I think we can close this, since we've rallied around the issue and you've got a few other PR's in flight! |
Because there has been no activity on this PR for 14 days since it was merged, it has been automatically locked. Please open a new issue if it requires a follow up. |
Additional:
Need to add tests to above schemas.