Skip to content

Commit

Permalink
refactor(experimental): graphql: token-2022 extensions: InitializeCon…
Browse files Browse the repository at this point in the history
…fidentialTransferFeeConfig
  • Loading branch information
nasjuice committed May 8, 2024
1 parent f54c9be commit 6208721
Show file tree
Hide file tree
Showing 4 changed files with 83 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 @@ -2571,6 +2571,21 @@ export const mockTransactionToken2022AllExtensions = {
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
stackHeight: null,
},
{
parsed: {
info: {
authority: 'FsHcsGiY43QmZc6yTgwYC1DA5U3ZgycXxn3bd2oBjrEZ',
withdrawWithheldAuthorityElgamalPubkey: null,
harvestToMintEnabled: true,
withheldAmount: '57fZKMs9YqFhu6fENwKTe7mGZh+wJbIvYkQ3LI/FDnOdc2w7',
mint: '2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB',
},
type: 'initializeConfidentialTransferFeeConfig',
},
program: 'spl-token',
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
stackHeight: null,
},
// TODO (more) ...
],
recentBlockhash: '6vRS7MoToVccMqfQecdVC6UbmARaT5mha91zhreqnce9',
Expand Down
49 changes: 49 additions & 0 deletions packages/rpc-graphql/src/__tests__/transaction-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3285,6 +3285,55 @@ describe('transaction', () => {
},
});
});

it('initialize-confidential-transfer-fee-config', async () => {
expect.assertions(1);
const source = /* GraphQL */ `
query testQuery($signature: Signature!) {
transaction(signature: $signature) {
message {
instructions {
programId
... on SplTokenInitializeConfidentialTransferFeeConfig {
authority {
address
}
harvestToMintEnabled
mint {
address
}
withdrawWithheldAuthorityElgamalPubkey
withheldAmount
}
}
}
}
}
`;
const result = await rpcGraphQL.query(source, { signature });
expect(result).toMatchObject({
data: {
transaction: {
message: {
instructions: expect.arrayContaining([
{
authority: {
address: expect.any(String),
},
harvestToMintEnabled: expect.any(Boolean),
mint: {
address: expect.any(String),
},
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
withdrawWithheldAuthorityElgamalPubkey: null,
withheldAmount: expect.any(String),
},
]),
},
},
},
});
});
});
});
});
7 changes: 7 additions & 0 deletions packages/rpc-graphql/src/resolvers/instruction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,10 @@ export const instructionResolvers = {
owner: resolveAccount('owner'),
rentSysvar: resolveAccount('rentSysvar'),
},
SplTokenInitializeConfidentialTransferFeeConfig: {
authority: resolveAccount('authority'),
mint: resolveAccount('mint'),
},
SplTokenInitializeConfidentialTransferMint: {
authority: resolveAccount('authority'),
mint: resolveAccount('mint'),
Expand Down Expand Up @@ -875,6 +879,9 @@ export const instructionResolvers = {
if (jsonParsedConfigs.instructionType === 'disableConfidentialTransferFeeHarvestToMint') {
return 'SplTokenDisableConfidentialTransferFeeHarvestToMint';
}
if (jsonParsedConfigs.instructionType === 'initializeConfidentialTransferFeeConfig') {
return 'SplTokenInitializeConfidentialTransferFeeConfig';
}
}
if (jsonParsedConfigs.programName === 'stake') {
if (jsonParsedConfigs.instructionType === 'initialize') {
Expand Down
12 changes: 12 additions & 0 deletions packages/rpc-graphql/src/schema/instruction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,18 @@ export const instructionTypeDefs = /* GraphQL */ `
signers: Address
}
"""
SplToken-2022: InitializeConfidentialTransferFeeConfig instruction
"""
type SplTokenInitializeConfidentialTransferFeeConfig implements TransactionInstruction {
programId: Address
authority: Account
harvestToMintEnabled: Boolean
mint: Account
withdrawWithheldAuthorityElgamalPubkey: Address
withheldAmount: String
}
type Lockup {
custodian: Account
epoch: Epoch
Expand Down

0 comments on commit 6208721

Please sign in to comment.