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

refactor(experimental): graphql: token-2022 extensions: InitializeTokenGroup #2687

Merged
merged 3 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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