Skip to content

Commit

Permalink
refactor(experimental): graphql: token-2022 extensions: HarvestWithhe…
Browse files Browse the repository at this point in the history
…ldConfidentialTransferTokensToMint
  • Loading branch information
nasjuice committed May 7, 2024
1 parent 0a6503e commit 5031010
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/rpc-graphql/src/__tests__/__setup__.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2500,6 +2500,21 @@ export const mockTransactionToken2022AllExtensions = {
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
stackHeight: null,
},
{
parsed: {
info: {
mint: 'FsHcsGiY43QmZc6yTgwYC1DA5U3ZgycXxn3bd2oBjrEZ',
sourceAccounts: [
'2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB',
'2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB',
],
},
type: 'harvestWithheldConfidentialTransferTokensToMint',
},
program: 'spl-token',
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
stackHeight: null,
},
// TODO (more) ...
],
recentBlockhash: '6vRS7MoToVccMqfQecdVC6UbmARaT5mha91zhreqnce9',
Expand Down
38 changes: 38 additions & 0 deletions packages/rpc-graphql/src/__tests__/transaction-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3125,6 +3125,44 @@ describe('transaction', () => {
},
});
});

it('harvest-withheld-confidential-transfer-tokens-to-mint', async () => {
expect.assertions(1);
const source = /* GraphQL */ `
query testQuery($signature: Signature!) {
transaction(signature: $signature) {
message {
instructions {
programId
... on SplTokenHarvestWithheldConfidentialTransferTokensToMint {
mint {
address
}
sourceAccounts
}
}
}
}
}
`;
const result = await rpcGraphQL.query(source, { signature });
expect(result).toMatchObject({
data: {
transaction: {
message: {
instructions: expect.arrayContaining([
{
mint: {
address: expect.any(String),
},
sourceAccounts: expect.arrayContaining([expect.any(String)]),
},
]),
},
},
},
});
});
});
});
});
6 changes: 6 additions & 0 deletions packages/rpc-graphql/src/resolvers/instruction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ export const instructionResolvers = {
SplTokenGetAccountDataSizeInstruction: {
mint: resolveAccount('mint'),
},
SplTokenHarvestWithheldConfidentialTransferTokensToMint: {
mint: resolveAccount('mint'),
},
SplTokenHarvestWithheldTokensToMint: {
mint: resolveAccount('mint'),
},
Expand Down Expand Up @@ -853,6 +856,9 @@ export const instructionResolvers = {
) {
return 'SplTokenWithdrawWithheldConfidentialTransferTokensFromAccounts';
}
if (jsonParsedConfigs.instructionType === 'harvestWithheldConfidentialTransferTokensToMint') {
return 'SplTokenHarvestWithheldConfidentialTransferTokensToMint';
}
}
if (jsonParsedConfigs.programName === 'stake') {
if (jsonParsedConfigs.instructionType === 'initialize') {
Expand Down
9 changes: 9 additions & 0 deletions packages/rpc-graphql/src/schema/instruction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,15 @@ export const instructionTypeDefs = /* GraphQL */ `
withdrawWithheldAuthority: Account
}
"""
SplToken-2022: HarvestWithheldConfidentialTransferTokensToMint instruction
"""
type SplTokenHarvestWithheldConfidentialTransferTokensToMint implements TransactionInstruction {
programId: Address
mint: Account
sourceAccounts: [Address]
}
type Lockup {
custodian: Account
epoch: Epoch
Expand Down

0 comments on commit 5031010

Please sign in to comment.