Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(experimental): graphql: token-2022 extensions: InitializeTokenGroupMember #2691

Merged
merged 2 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 @@ -2627,6 +2627,21 @@ export const mockTransactionToken2022AllExtensions = {
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
stackHeight: null,
},
{
parsed: {
info: {
member: 'FsHcsGiY43QmZc6yTgwYC1DA5U3ZgycXxn3bd2oBjrEZ',
memberMint: 'FsHcsGiY43QmZc6yTgwYC1DA5U3ZgycXxn3bd2oBjrEZ',
memberMintAuthority: 'FsHcsGiY43QmZc6yTgwYC1DA5U3ZgycXxn3bd2oBjrEZ',
group: 'FsHcsGiY43QmZc6yTgwYC1DA5U3ZgycXxn3bd2oBjrEZ',
groupUpdateAuthority: 'FsHcsGiY43QmZc6yTgwYC1DA5U3ZgycXxn3bd2oBjrEZ',
},
type: 'initializeTokenGroupMember',
},
program: 'spl-token',
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
stackHeight: null,
},
// TODO (more) ...
],
recentBlockhash: '6vRS7MoToVccMqfQecdVC6UbmARaT5mha91zhreqnce9',
Expand Down
61 changes: 61 additions & 0 deletions packages/rpc-graphql/src/__tests__/transaction-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3485,6 +3485,67 @@ describe('transaction', () => {
},
});
});

it('initialize-token-group-member', async () => {
expect.assertions(1);
const source = /* GraphQL */ `
query testQuery($signature: Signature!) {
transaction(signature: $signature) {
message {
instructions {
programId
... on SplTokenGroupInitializeMember {
group {
address
}
groupUpdateAuthority {
address
}
member {
address
}
memberMint {
address
}
memberMintAuthority {
address
}
}
}
}
}
}
`;
const result = await rpcGraphQL.query(source, { signature });
expect(result).toMatchObject({
data: {
transaction: {
message: {
instructions: expect.arrayContaining([
{
group: {
address: expect.any(String),
},
groupUpdateAuthority: {
address: expect.any(String),
},
member: {
address: expect.any(String),
},
memberMint: {
address: expect.any(String),
},
memberMintAuthority: {
address: expect.any(String),
},
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
},
]),
},
},
},
});
});
});
});
});
10 changes: 10 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,13 @@ export const instructionResolvers = {
mintAuthority: resolveAccount('mintAuthority'),
updateAuthority: resolveAccount('updateAuthority'),
},
SplTokenGroupInitializeMember: {
group: resolveAccount('group'),
groupUpdateAuthority: resolveAccount('groupUpdateAuthority'),
member: resolveAccount('member'),
memberMint: resolveAccount('memberMint'),
memberMintAuthority: resolveAccount('memberMintAuthority'),
},
SplTokenGroupUpdateGroupAuthority: {
group: resolveAccount('group'),
newAuthority: resolveAccount('newAuthority'),
Expand Down Expand Up @@ -906,6 +913,9 @@ export const instructionResolvers = {
if (jsonParsedConfigs.instructionType === 'updateTokenGroupAuthority') {
return 'SplTokenGroupUpdateGroupAuthority';
}
if (jsonParsedConfigs.instructionType === 'initializeTokenGroupMember') {
return 'SplTokenGroupInitializeMember';
}
}
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 @@ -1046,6 +1046,18 @@ export const instructionTypeDefs = /* GraphQL */ `
updateAuthority: Account
}

"""
Spl Token Group: InitializeMember instruction
"""
type SplTokenGroupInitializeMember implements TransactionInstruction {
programId: Address
group: Account
groupUpdateAuthority: Account
member: Account
memberMint: Account
memberMintAuthority: Account
}

type Lockup {
custodian: Account
epoch: Epoch
Expand Down