Skip to content

Commit

Permalink
refactor(experimental): graphql: token-2022 extensions: UpdateGroupMa…
Browse files Browse the repository at this point in the history
…xSize
  • Loading branch information
nasjuice committed May 8, 2024
1 parent bc01a5b commit e9d24f8
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/rpc-graphql/src/__tests__/__setup__.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2601,6 +2601,19 @@ export const mockTransactionToken2022AllExtensions = {
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
stackHeight: null,
},
{
parsed: {
info: {
group: 'FsHcsGiY43QmZc6yTgwYC1DA5U3ZgycXxn3bd2oBjrEZ',
maxSize: 22,
updateAuthority: 'FsHcsGiY43QmZc6yTgwYC1DA5U3ZgycXxn3bd2oBjrEZ',
},
type: 'updateTokenGroupMaxSize',
},
program: 'spl-token',
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
stackHeight: null,
},
// TODO (more) ...
],
recentBlockhash: '6vRS7MoToVccMqfQecdVC6UbmARaT5mha91zhreqnce9',
Expand Down
45 changes: 45 additions & 0 deletions packages/rpc-graphql/src/__tests__/transaction-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3391,6 +3391,51 @@ describe('transaction', () => {
},
});
});

it('update-group-max-size', async () => {
expect.assertions(1);
const source = /* GraphQL */ `
query testQuery($signature: Signature!) {
transaction(signature: $signature) {
message {
instructions {
programId
... on SplTokenGroupUpdateGroupMaxSize {
group {
address
}
maxSize
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),
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
updateAuthority: {
address: 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 @@ -296,6 +296,10 @@ export const instructionResolvers = {
mintAuthority: resolveAccount('mintAuthority'),
updateAuthority: resolveAccount('updateAuthority'),
},
SplTokenGroupUpdateGroupMaxSize: {
group: resolveAccount('group'),
updateAuthority: resolveAccount('updateAuthority'),
},
SplTokenHarvestWithheldConfidentialTransferTokensToMint: {
mint: resolveAccount('mint'),
},
Expand Down Expand Up @@ -891,6 +895,9 @@ export const instructionResolvers = {
if (jsonParsedConfigs.instructionType === 'initializeTokenGroup') {
return 'SplTokenGroupInitializeGroup';
}
if (jsonParsedConfigs.instructionType === 'updateTokenGroupMaxSize') {
return 'SplTokenGroupUpdateGroupMaxSize';
}
}
if (jsonParsedConfigs.programName === 'stake') {
if (jsonParsedConfigs.instructionType === 'initialize') {
Expand Down
10 changes: 10 additions & 0 deletions packages/rpc-graphql/src/schema/instruction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,16 @@ export const instructionTypeDefs = /* GraphQL */ `
updateAuthority: Account
}
"""
Spl Token Group: UpdateGroupMaxSize instruction
"""
type SplTokenGroupUpdateGroupMaxSize implements TransactionInstruction {
programId: Address
group: Account
maxSize: BigInt
updateAuthority: Account
}
type Lockup {
custodian: Account
epoch: Epoch
Expand Down

0 comments on commit e9d24f8

Please sign in to comment.