Skip to content

Commit

Permalink
refactor(experimental): graphql: token-2022 extensions: WithdrawWithh…
Browse files Browse the repository at this point in the history
…eldConfidentialTransferTokensFromMint
  • Loading branch information
nasjuice committed May 7, 2024
1 parent 31fd8a8 commit 8758a3c
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 0 deletions.
34 changes: 34 additions & 0 deletions packages/rpc-graphql/src/__tests__/__setup__.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2424,6 +2424,40 @@ export const mockTransactionToken2022AllExtensions = {
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
stackHeight: null,
},
{
parsed: {
info: {
mint: 'FsHcsGiY43QmZc6yTgwYC1DA5U3ZgycXxn3bd2oBjrEZ',
feeRecipient: '2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB',
instructionsSysvar: 'SysvarRent111111111111111111111111111111111',
proofInstructionOffset: 1,
withdrawWithheldAuthority: '2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB',
},
type: 'withdrawWithheldConfidentialTransferTokensFromMint',
},
program: 'spl-token',
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
stackHeight: null,
},
{
parsed: {
info: {
mint: 'FsHcsGiY43QmZc6yTgwYC1DA5U3ZgycXxn3bd2oBjrEZ',
feeRecipient: '2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB',
instructionsSysvar: 'SysvarRent111111111111111111111111111111111',
proofInstructionOffset: 1,
multisigWithdrawWithheldAuthority: '2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB',
signers: [
'2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB',
'2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB',
],
},
type: 'withdrawWithheldConfidentialTransferTokensFromMint',
},
program: 'spl-token',
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
stackHeight: null,
},
// TODO (more) ...
],
recentBlockhash: '6vRS7MoToVccMqfQecdVC6UbmARaT5mha91zhreqnce9',
Expand Down
81 changes: 81 additions & 0 deletions packages/rpc-graphql/src/__tests__/transaction-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2960,6 +2960,87 @@ describe('transaction', () => {
},
});
});

it('withdraw-withheld-confidential-transfer-tokens-from-mint', async () => {
expect.assertions(1);
const source = /* GraphQL */ `
query testQuery($signature: Signature!) {
transaction(signature: $signature) {
message {
instructions {
programId
... on SplTokenWithdrawWithheldConfidentialTransferTokensFromMint {
feeRecipient {
address
}
instructionsSysvar {
address
}
mint {
address
}
multisigWithdrawWithheldAuthority {
address
}
proofInstructionOffset
signers
withdrawWithheldAuthority {
address
}
}
}
}
}
}
`;
const result = await rpcGraphQL.query(source, { signature });
expect(result).toMatchObject({
data: {
transaction: {
message: {
instructions: expect.arrayContaining([
{
feeRecipient: {
address: expect.any(String),
},
instructionsSyvar: {
address: expect.any(String),
},
mint: {
address: expect.any(String),
},
multisigWithdrawWithheldAuthority: null,
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
proofInstructionOffset: expect.any(Number),
signers: null,
withdrawWithheldAuthority: {
address: expect.any(String),
},
},
{
feeRecipient: {
address: expect.any(String),
},
instructionsSyvar: {
address: expect.any(String),
},
mint: {
address: expect.any(String),
},
multisigWithdrawWithheldAuthority: {
address: expect.any(String),
},
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
proofInstructionOffset: expect.any(Number),
signers: expect.arrayContaining([expect.any(String)]),
withdrawWithheldAuthority: null,
},
]),
},
},
},
});
});
});
});
});
10 changes: 10 additions & 0 deletions packages/rpc-graphql/src/resolvers/instruction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,13 @@ export const instructionResolvers = {
owner: resolveAccount('owner'),
source: resolveAccount('source'),
},
SplTokenWithdrawWithheldConfidentialTransferTokensFromMint: {
feeRecipient: resolveAccount('feeRecipient'),
instructionsSyvar: resolveAccount('instructionsSyvar'),
mint: resolveAccount('mint'),
multisigWithdrawWithheldAuthority: resolveAccount('multisigWithdrawWithheldAuthority'),
withdrawWithheldAuthority: resolveAccount('withdrawWithheldAuthority'),
},
SplTokenWithdrawWithheldTokensFromAccounts: {
feeRecipient: resolveAccount('feeRecipient'),
mint: resolveAccount('mint'),
Expand Down Expand Up @@ -836,6 +843,9 @@ export const instructionResolvers = {
if (jsonParsedConfigs.instructionType === 'updateConfidentialTransferMint') {
return 'SplTokenUpdateConfidentialTransferMint';
}
if (jsonParsedConfigs.instructionType === 'withdrawWithheldConfidentialTransferTokensFromMint') {
return 'SplTokenWithdrawWithheldConfidentialTransferTokensFromMint';
}
}
if (jsonParsedConfigs.programName === 'stake') {
if (jsonParsedConfigs.instructionType === 'initialize') {
Expand Down
14 changes: 14 additions & 0 deletions packages/rpc-graphql/src/schema/instruction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,20 @@ export const instructionTypeDefs = /* GraphQL */ `
newConfidentialTransferMintAuthority: Account
}
"""
SplToken-2022: WithdrawWithheldConfidentialTransferTokensFromMint instruction
"""
type SplTokenWithdrawWithheldConfidentialTransferTokensFromMint implements TransactionInstruction {
programId: Address
feeRecipient: Account
instructionsSyvar: Account
mint: Account
multisigWithdrawWithheldAuthority: Account
proofInstructionOffset: Int
signers: [Address]
withdrawWithheldAuthority: Account
}
# TODO: Extensions!
# ...
Expand Down

0 comments on commit 8758a3c

Please sign in to comment.