Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
refactor(experimental): graphql: token-2022 extensions: InitializeTok…
Browse files Browse the repository at this point in the history
…enGroup (#2687)

* refactor(experimental): graphql: token-2022 extensions: InitializeTokenGroup

* refactor schema name
  • Loading branch information
nasjuice authored May 8, 2024
1 parent 3f57edb commit bc01a5b
Show file tree
Hide file tree
Showing 4 changed files with 93 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 @@ -2586,6 +2586,21 @@ export const mockTransactionToken2022AllExtensions = {
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
stackHeight: null,
},
{
parsed: {
info: {
group: 'FsHcsGiY43QmZc6yTgwYC1DA5U3ZgycXxn3bd2oBjrEZ',
maxSize: 22,
mintAuthority: '2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB',
updateAuthority: 'FsHcsGiY43QmZc6yTgwYC1DA5U3ZgycXxn3bd2oBjrEZ',
mint: '2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB',
},
type: 'initializeTokenGroup',
},
program: 'spl-token',
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
stackHeight: null,
},
// TODO (more) ...
],
recentBlockhash: '6vRS7MoToVccMqfQecdVC6UbmARaT5mha91zhreqnce9',
Expand Down
57 changes: 57 additions & 0 deletions packages/rpc-graphql/src/__tests__/transaction-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3334,6 +3334,63 @@ describe('transaction', () => {
},
});
});

it('initialize-token-group', async () => {
expect.assertions(1);
const source = /* GraphQL */ `
query testQuery($signature: Signature!) {
transaction(signature: $signature) {
message {
instructions {
programId
... on SplTokenGroupInitializeGroup {
group {
address
}
maxSize
mint {
address
}
mintAuthority {
address
}
updateAuthority {
address
}
}
}
}
}
}
`;
const result = await rpcGraphQL.query(source, { signature });
expect(result).toMatchObject({
data: {
transaction: {
message: {
instructions: expect.arrayContaining([
{
group: {
address: expect.any(String),
},
maxSize: expect.any(BigInt),
mint: {
address: expect.any(String),
},
mintAuthority: {
address: expect.any(String),
},
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
updateAuthority: {
address: expect.any(String),
},
},
]),
},
},
},
});
});
});
});
});
9 changes: 9 additions & 0 deletions packages/rpc-graphql/src/resolvers/instruction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,12 @@ export const instructionResolvers = {
SplTokenGetAccountDataSizeInstruction: {
mint: resolveAccount('mint'),
},
SplTokenGroupInitializeGroup: {
group: resolveAccount('group'),
mint: resolveAccount('mint'),
mintAuthority: resolveAccount('mintAuthority'),
updateAuthority: resolveAccount('updateAuthority'),
},
SplTokenHarvestWithheldConfidentialTransferTokensToMint: {
mint: resolveAccount('mint'),
},
Expand Down Expand Up @@ -882,6 +888,9 @@ export const instructionResolvers = {
if (jsonParsedConfigs.instructionType === 'initializeConfidentialTransferFeeConfig') {
return 'SplTokenInitializeConfidentialTransferFeeConfig';
}
if (jsonParsedConfigs.instructionType === 'initializeTokenGroup') {
return 'SplTokenGroupInitializeGroup';
}
}
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 @@ -1014,6 +1014,18 @@ export const instructionTypeDefs = /* GraphQL */ `
withheldAmount: String
}
"""
Spl Token Group: InitializeGroup instruction
"""
type SplTokenGroupInitializeGroup implements TransactionInstruction {
programId: Address
group: Account
maxSize: BigInt
mint: Account
mintAuthority: Account
updateAuthority: Account
}
type Lockup {
custodian: Account
epoch: Epoch
Expand Down

0 comments on commit bc01a5b

Please sign in to comment.