diff --git a/.changeset/sharp-steaks-admire.md b/.changeset/sharp-steaks-admire.md new file mode 100644 index 00000000000..ae5ab59ee63 --- /dev/null +++ b/.changeset/sharp-steaks-admire.md @@ -0,0 +1,6 @@ +--- +'@solana/rpc-types': patch +'@solana/rpc-api': patch +--- + +The `TransactionInstruction` RPC type now has `stackHeight` diff --git a/packages/rpc-api/src/__typetests__/get-block-type-test.ts b/packages/rpc-api/src/__typetests__/get-block-type-test.ts index 16da553a342..cd8c8923dde 100644 --- a/packages/rpc-api/src/__typetests__/get-block-type-test.ts +++ b/packages/rpc-api/src/__typetests__/get-block-type-test.ts @@ -512,6 +512,7 @@ async () => { accounts: readonly number[]; data: Base58EncodedBytes; programIdIndex: number; + stackHeight?: number; }>[]; }>[]; logMessages: readonly string[] | null; @@ -736,6 +737,7 @@ async () => { accounts: readonly number[]; data: Base58EncodedBytes; programIdIndex: number; + stackHeight?: number; }>[]; }>[]; logMessages: readonly string[] | null; diff --git a/packages/rpc-api/src/getTransaction.ts b/packages/rpc-api/src/getTransaction.ts index 49881841961..bd897a9f2b4 100644 --- a/packages/rpc-api/src/getTransaction.ts +++ b/packages/rpc-api/src/getTransaction.ts @@ -73,6 +73,7 @@ type TransactionInstruction = Readonly<{ accounts: readonly number[]; data: Base58EncodedBytes; programIdIndex: number; + stackHeight?: number; }>; type TransactionJson = Readonly<{ @@ -92,6 +93,7 @@ type PartiallyDecodedTransactionInstruction = Readonly<{ accounts: readonly Address[]; data: Base58EncodedBytes; programId: Address; + stackHeight?: number; }>; type ParsedTransactionInstruction = Readonly<{ @@ -101,6 +103,7 @@ type ParsedTransactionInstruction = Readonly<{ }; program: string; programId: Address; + stackHeight?: number; }>; type TransactionJsonParsed = Readonly<{ diff --git a/packages/rpc-api/src/index.ts b/packages/rpc-api/src/index.ts index 8d40c9929d8..0aa518702c9 100644 --- a/packages/rpc-api/src/index.ts +++ b/packages/rpc-api/src/index.ts @@ -3,9 +3,11 @@ import { AllowedNumericKeypaths, getDefaultParamsTransformerForSolanaRpc, getDefaultResponseTransformerForSolanaRpc, + innerInstructionsConfigs, jsonParsedAccountsConfigs, jsonParsedTokenAccountsConfigs, KEYPATH_WILDCARD, + messageConfig, ParamsTransformerConfig, } from '@solana/rpc-transformers'; @@ -223,70 +225,15 @@ function getAllowedNumericKeypaths(): AllowedNumericKeypaths [ 'transactions', KEYPATH_WILDCARD, 'meta', 'innerInstructions', KEYPATH_WILDCARD, - 'instructions', - KEYPATH_WILDCARD, - 'programIdIndex', - ], - [ - 'transactions', - KEYPATH_WILDCARD, - 'meta', - 'innerInstructions', - KEYPATH_WILDCARD, - 'instructions', - KEYPATH_WILDCARD, - 'accounts', - KEYPATH_WILDCARD, - ], - [ - 'transactions', - KEYPATH_WILDCARD, - 'transaction', - 'message', - 'addressTableLookups', - KEYPATH_WILDCARD, - 'writableIndexes', - KEYPATH_WILDCARD, - ], - [ - 'transactions', - KEYPATH_WILDCARD, - 'transaction', - 'message', - 'addressTableLookups', - KEYPATH_WILDCARD, - 'readonlyIndexes', - KEYPATH_WILDCARD, - ], - [ - 'transactions', - KEYPATH_WILDCARD, - 'transaction', - 'message', - 'instructions', - KEYPATH_WILDCARD, - 'programIdIndex', - ], - [ - 'transactions', - KEYPATH_WILDCARD, - 'transaction', - 'message', - 'instructions', - KEYPATH_WILDCARD, - 'accounts', - KEYPATH_WILDCARD, - ], - ['transactions', KEYPATH_WILDCARD, 'transaction', 'message', 'header', 'numReadonlySignedAccounts'], - ['transactions', KEYPATH_WILDCARD, 'transaction', 'message', 'header', 'numReadonlyUnsignedAccounts'], - ['transactions', KEYPATH_WILDCARD, 'transaction', 'message', 'header', 'numRequiredSignatures'], + ...c, + ]), + ...messageConfig.map(c => ['transactions', KEYPATH_WILDCARD, 'transaction', 'message', ...c] as const), ['rewards', KEYPATH_WILDCARD, 'commission'], ], getBlockTime: [[]], @@ -333,45 +280,18 @@ function getAllowedNumericKeypaths(): AllowedNumericKeypaths ['meta', 'innerInstructions', KEYPATH_WILDCARD, ...c]), + ...messageConfig.map(c => ['transaction', 'message', ...c] as const), ], getVersion: [['feature-set']], getVoteAccounts: [ ['current', KEYPATH_WILDCARD, 'commission'], ['delinquent', KEYPATH_WILDCARD, 'commission'], ], - simulateTransaction: jsonParsedAccountsConfigs.map(c => ['value', 'accounts', KEYPATH_WILDCARD, ...c]), + simulateTransaction: [ + ...jsonParsedAccountsConfigs.map(c => ['value', 'accounts', KEYPATH_WILDCARD, ...c]), + ...innerInstructionsConfigs.map(c => ['value', 'innerInstructions', KEYPATH_WILDCARD, ...c]), + ], }; } return memoizedKeypaths; diff --git a/packages/rpc-subscriptions-api/src/__typetests__/block-notifications-type-test.ts b/packages/rpc-subscriptions-api/src/__typetests__/block-notifications-type-test.ts index 734d2244998..364f60d6cc3 100644 --- a/packages/rpc-subscriptions-api/src/__typetests__/block-notifications-type-test.ts +++ b/packages/rpc-subscriptions-api/src/__typetests__/block-notifications-type-test.ts @@ -724,6 +724,7 @@ type ExpectedMetaForFullBase58 = { accounts: readonly number[]; data: Base58EncodedBytes; programIdIndex: number; + stackHeight?: number; }>[]; }>[]; logMessages: readonly string[] | null; @@ -990,6 +991,7 @@ type ExpectedMetaForFullBase64 = { accounts: readonly number[]; data: Base58EncodedBytes; programIdIndex: number; + stackHeight?: number; }>[]; }>[]; logMessages: readonly string[] | null; diff --git a/packages/rpc-transformers/src/response-transformer-allowed-numeric-values.ts b/packages/rpc-transformers/src/response-transformer-allowed-numeric-values.ts index 2431f7528e6..4810bfbf51d 100644 --- a/packages/rpc-transformers/src/response-transformer-allowed-numeric-values.ts +++ b/packages/rpc-transformers/src/response-transformer-allowed-numeric-values.ts @@ -37,3 +37,19 @@ export const jsonParsedAccountsConfigs = [ ['data', 'parsed', 'info', 'commission'], ['data', 'parsed', 'info', 'votes', KEYPATH_WILDCARD, 'confirmationCount'], ]; +export const innerInstructionsConfigs = [ + ['index'], + ['instructions', KEYPATH_WILDCARD, 'accounts', KEYPATH_WILDCARD], + ['instructions', KEYPATH_WILDCARD, 'programIdIndex'], + ['instructions', KEYPATH_WILDCARD, 'stackHeight'], +]; +export const messageConfig = [ + ['addressTableLookups', KEYPATH_WILDCARD, 'writableIndexes', KEYPATH_WILDCARD], + ['addressTableLookups', KEYPATH_WILDCARD, 'readonlyIndexes', KEYPATH_WILDCARD], + ['header', 'numReadonlySignedAccounts'], + ['header', 'numReadonlyUnsignedAccounts'], + ['header', 'numRequiredSignatures'], + ['instructions', KEYPATH_WILDCARD, 'accounts', KEYPATH_WILDCARD], + ['instructions', KEYPATH_WILDCARD, 'programIdIndex'], + ['instructions', KEYPATH_WILDCARD, 'stackHeight'], +] as const; diff --git a/packages/rpc-types/src/transaction.ts b/packages/rpc-types/src/transaction.ts index 07b1d1bcb05..10a09416ced 100644 --- a/packages/rpc-types/src/transaction.ts +++ b/packages/rpc-types/src/transaction.ts @@ -25,12 +25,14 @@ type ParsedTransactionInstruction = Readonly<{ }; program: string; programId: Address; + stackHeight?: number; }>; type PartiallyDecodedTransactionInstruction = Readonly<{ accounts: readonly Address[]; data: Base58EncodedBytes; programId: Address; + stackHeight?: number; }>; type ReturnData = { @@ -44,6 +46,7 @@ type TransactionInstruction = Readonly<{ accounts: readonly number[]; data: Base58EncodedBytes; programIdIndex: number; + stackHeight?: number; }>; type TransactionParsedAccountLegacy = Readonly<{