Skip to content

Commit

Permalink
graphql: token-2022 extensions: InitializeTransferFeeConfig (#2575)
Browse files Browse the repository at this point in the history
* #2406: initializeTransferFeeConfig

* #2406: initializeTransferFeeConfig test

* #2406: Fix lint issue
  • Loading branch information
Hrushi20 committed Apr 27, 2024
1 parent 3bf31e7 commit 7151be6
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
54 changes: 54 additions & 0 deletions packages/rpc-graphql/src/__tests__/transaction-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,60 @@ describe('transaction', () => {
},
});
});

it('initialize-transferFee-config', async () => {
expect.assertions(1);
const source = /* GraphQL */ `
query testQuery($signature: Signature!) {
transaction(signature: $signature) {
message {
instructions {
programId
... on SplTokenInitializeTransferFeeConfig {
mint {
address
}
transferFeeBasisPoints
maximumFee
transferFeeConfigAuthority {
address
}
withdrawWithheldAuthority {
address
}
}
}
}
}
}
`;

const result = await rpcGraphQL.query(source, { signature });
expect(result).toMatchObject({
data: {
transaction: {
message: {
instructions: expect.arrayContaining([
{
maximumFee: expect.any(Number),
mint: {
address: expect.any(String),
},
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
transferFeeBasisPoints: expect.any(Number),
transferFeeConfigAuthority: {
address: expect.any(String),
},
withdrawWithheldAuthority: {
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 @@ -239,6 +239,11 @@ export const instructionResolvers = {
delegate: resolveAccount('delegate'),
mint: resolveAccount('mint'),
},
SplTokenInitializeTransferFeeConfig: {
mint: resolveAccount('mint'),
transferFeeConfigAuthority: resolveAccount('transferFeeConfigAuthority'),
withdrawWithheldAuthority: resolveAccount('withdrawWithheldAuthority'),
},
SplTokenMintToCheckedInstruction: {
account: resolveAccount('account'),
authority: resolveAccount('authority'),
Expand Down Expand Up @@ -547,6 +552,9 @@ export const instructionResolvers = {
if (jsonParsedConfigs.instructionType === 'updateMetadataPointer') {
return 'SplTokenUpdateMetadataPointerInstruction';
}
if (jsonParsedConfigs.instructionType === 'initializeTransferFeeConfig') {
return 'SplTokenInitializeTransferFeeConfig';
}
}
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 @@ -541,6 +541,18 @@ export const instructionTypeDefs = /* GraphQL */ `
mint: Account
}
"""
SplToken-2022: InitializeTransferFeeConfig instruction
"""
type SplTokenInitializeTransferFeeConfig implements TransactionInstruction {
programId: Address
mint: Account
transferFeeBasisPoints: Int
transferFeeConfigAuthority: Account
withdrawWithheldAuthority: Account
maximumFee: Int
}
# TODO: Extensions!
# ...
Expand Down

0 comments on commit 7151be6

Please sign in to comment.