diff --git a/packages/rpc-graphql/src/__tests__/__setup__.ts b/packages/rpc-graphql/src/__tests__/__setup__.ts index 8ae333fbb4da..c15c3f811325 100644 --- a/packages/rpc-graphql/src/__tests__/__setup__.ts +++ b/packages/rpc-graphql/src/__tests__/__setup__.ts @@ -1686,6 +1686,32 @@ export const mockTransactionToken2022AllExtensions = { programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb', stackHeight: null, }, + { + parsed: { + info: { + authority: '2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB', + destination: '2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB', + feeAmount: { + amount: '5000', + decimals: 9, + uiAmount: 0.000005, + uiAmountString: '0.000005', + }, + mint: 'FsHcsGiY43QmZc6yTgwYC1DA5U3ZgycXxn3bd2oBjrEZ', + source: '2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB', + tokenAmount: { + amount: '1000000000000000', + decimals: 9, + uiAmount: 1000000, + uiAmountString: '1000000', + }, + }, + type: 'transferCheckedWithFee', + }, + program: 'spl-token', + programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb', + stackHeight: null, + }, // TODO (more) ... ], recentBlockhash: '6vRS7MoToVccMqfQecdVC6UbmARaT5mha91zhreqnce9', diff --git a/packages/rpc-graphql/src/__tests__/transaction-tests.ts b/packages/rpc-graphql/src/__tests__/transaction-tests.ts index 8efd5a56e727..1da42d641546 100644 --- a/packages/rpc-graphql/src/__tests__/transaction-tests.ts +++ b/packages/rpc-graphql/src/__tests__/transaction-tests.ts @@ -895,6 +895,86 @@ describe('transaction', () => { }, }); }); + + it('transfer-checked-with-fee', async () => { + expect.assertions(1); + const source = /* GraphQL */ ` + query testQuery($signature: Signature!) { + transaction(signature: $signature) { + message { + instructions { + programId + ... on SplTokenTransferCheckedWithFee { + mint { + address + } + authority { + address + } + source { + address + } + destination { + address + } + feeAmount { + amount + decimals + uiAmount + uiAmountString + } + tokenAmount { + amount + decimals + uiAmount + uiAmountString + } + } + } + } + } + } + `; + + const result = await rpcGraphQL.query(source, { signature }); + expect(result).toMatchObject({ + data: { + transaction: { + message: { + instructions: expect.arrayContaining([ + { + authority: { + address: expect.any(String), + }, + destination: { + address: expect.any(String), + }, + feeAmount: { + amount: expect.any(String), + decimals: expect.any(Number), + uiAmount: null, // can't convert decimal to BigInt + uiAmountString: expect.any(String), + }, + mint: { + address: expect.any(String), + }, + programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb', + source: { + address: expect.any(String), + }, + tokenAmount: { + amount: expect.any(String), + decimals: expect.any(Number), + uiAmount: expect.any(BigInt), + uiAmountString: expect.any(String), + }, + }, + ]), + }, + }, + }, + }); + }); }); }); }); diff --git a/packages/rpc-graphql/src/resolvers/instruction.ts b/packages/rpc-graphql/src/resolvers/instruction.ts index 80589855b709..9e0289aef534 100644 --- a/packages/rpc-graphql/src/resolvers/instruction.ts +++ b/packages/rpc-graphql/src/resolvers/instruction.ts @@ -284,6 +284,12 @@ export const instructionResolvers = { multisigAuthority: resolveAccount('multisigAuthority'), source: resolveAccount('source'), }, + SplTokenTransferCheckedWithFee: { + authority: resolveAccount('authority'), + destination: resolveAccount('destination'), + mint: resolveAccount('mint'), + source: resolveAccount('source'), + }, SplTokenTransferInstruction: { authority: resolveAccount('authority'), destination: resolveAccount('destination'), @@ -555,6 +561,9 @@ export const instructionResolvers = { if (jsonParsedConfigs.instructionType === 'initializeTransferFeeConfig') { return 'SplTokenInitializeTransferFeeConfig'; } + if (jsonParsedConfigs.instructionType === 'transferCheckedWithFee') { + return 'SplTokenTransferCheckedWithFee'; + } } if (jsonParsedConfigs.programName === 'stake') { if (jsonParsedConfigs.instructionType === 'initialize') { diff --git a/packages/rpc-graphql/src/schema/instruction.ts b/packages/rpc-graphql/src/schema/instruction.ts index c0fc11cd1c96..5a3b9ac71e7a 100644 --- a/packages/rpc-graphql/src/schema/instruction.ts +++ b/packages/rpc-graphql/src/schema/instruction.ts @@ -553,6 +553,19 @@ export const instructionTypeDefs = /* GraphQL */ ` maximumFee: Int } + """ + SplToken-2022: TransferCheckedWithFee instruction + """ + type SplTokenTransferCheckedWithFee implements TransactionInstruction { + programId: Address + authority: Account + destination: Account + feeAmount: TokenAmount + mint: Account + source: Account + tokenAmount: TokenAmount + } + # TODO: Extensions! # ...