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: UpdateGroupAu…
Browse files Browse the repository at this point in the history
…thority
  • Loading branch information
nasjuice committed May 8, 2024
1 parent f257848 commit 74bbca2
Show file tree
Hide file tree
Showing 4 changed files with 80 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 @@ -2614,6 +2614,19 @@ export const mockTransactionToken2022AllExtensions = {
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
stackHeight: null,
},
{
parsed: {
info: {
group: 'FsHcsGiY43QmZc6yTgwYC1DA5U3ZgycXxn3bd2oBjrEZ',
updateAuthority: 'FsHcsGiY43QmZc6yTgwYC1DA5U3ZgycXxn3bd2oBjrEZ',
newAuthority: 'FsHcsGiY43QmZc6yTgwYC1DA5U3ZgycXxn3bd2oBjrEZ',
},
type: 'updateTokenGroupAuthority',
},
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 @@ -3436,6 +3436,55 @@ describe('transaction', () => {
},
});
});

it('update-group-authority', async () => {
expect.assertions(1);
const source = /* GraphQL */ `
query testQuery($signature: Signature!) {
transaction(signature: $signature) {
message {
instructions {
programId
... on SplTokenGroupUpdateGroupAuthority {
group {
address
}
newAuthority {
address
}
updateAuthority {
address
}
}
}
}
}
}
`;
const result = await rpcGraphQL.query(source, { signature });
expect(result).toMatchObject({
data: {
transaction: {
message: {
instructions: expect.arrayContaining([
{
group: {
address: expect.any(String),
},
newAuthority: {
address: expect.any(String),
},
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
updateAuthority: {
address: expect.any(String),
},
},
]),
},
},
},
});
});
});
});
});
8 changes: 8 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,11 @@ export const instructionResolvers = {
mintAuthority: resolveAccount('mintAuthority'),
updateAuthority: resolveAccount('updateAuthority'),
},
SplTokenGroupUpdateGroupAuthority: {
group: resolveAccount('group'),
newAuthority: resolveAccount('newAuthority'),
updateAuthority: resolveAccount('updateAuthority'),
},
SplTokenGroupUpdateGroupMaxSize: {
group: resolveAccount('group'),
updateAuthority: resolveAccount('updateAuthority'),
Expand Down Expand Up @@ -898,6 +903,9 @@ export const instructionResolvers = {
if (jsonParsedConfigs.instructionType === 'updateTokenGroupMaxSize') {
return 'SplTokenGroupUpdateGroupMaxSize';
}
if (jsonParsedConfigs.instructionType === 'updateTokenGroupAuthority') {
return 'SplTokenGroupUpdateGroupAuthority';
}
}
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 @@ -1036,6 +1036,16 @@ export const instructionTypeDefs = /* GraphQL */ `
updateAuthority: Account
}
"""
Spl Token Group: UpdateGroupAuthority instruction
"""
type SplTokenGroupUpdateGroupAuthority implements TransactionInstruction {
programId: Address
group: Account
newAuthority: Account
updateAuthority: Account
}
type Lockup {
custodian: Account
epoch: Epoch
Expand Down

0 comments on commit 74bbca2

Please sign in to comment.