Skip to content

Commit f7d6ec2

Browse files
committed
Add stackHeight to the instruction type
1 parent daf9691 commit f7d6ec2

File tree

7 files changed

+44
-92
lines changed

7 files changed

+44
-92
lines changed

.changeset/sharp-steaks-admire.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@solana/rpc-types': patch
3+
'@solana/rpc-api': patch
4+
---
5+
6+
The `TransactionInstruction` RPC type now has `stackHeight`

packages/rpc-api/src/__typetests__/get-block-type-test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,7 @@ async () => {
512512
accounts: readonly number[];
513513
data: Base58EncodedBytes;
514514
programIdIndex: number;
515+
stackHeight?: number;
515516
}>[];
516517
}>[];
517518
logMessages: readonly string[] | null;
@@ -736,6 +737,7 @@ async () => {
736737
accounts: readonly number[];
737738
data: Base58EncodedBytes;
738739
programIdIndex: number;
740+
stackHeight?: number;
739741
}>[];
740742
}>[];
741743
logMessages: readonly string[] | null;

packages/rpc-api/src/getTransaction.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ type TransactionInstruction = Readonly<{
7373
accounts: readonly number[];
7474
data: Base58EncodedBytes;
7575
programIdIndex: number;
76+
stackHeight?: number;
7677
}>;
7778

7879
type TransactionJson = Readonly<{
@@ -92,6 +93,7 @@ type PartiallyDecodedTransactionInstruction = Readonly<{
9293
accounts: readonly Address[];
9394
data: Base58EncodedBytes;
9495
programId: Address;
96+
stackHeight?: number;
9597
}>;
9698

9799
type ParsedTransactionInstruction = Readonly<{
@@ -101,6 +103,7 @@ type ParsedTransactionInstruction = Readonly<{
101103
};
102104
program: string;
103105
programId: Address;
106+
stackHeight?: number;
104107
}>;
105108

106109
type TransactionJsonParsed = Readonly<{

packages/rpc-api/src/index.ts

Lines changed: 12 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ import {
33
AllowedNumericKeypaths,
44
getDefaultParamsTransformerForSolanaRpc,
55
getDefaultResponseTransformerForSolanaRpc,
6+
innerInstructionsConfigs,
67
jsonParsedAccountsConfigs,
78
jsonParsedTokenAccountsConfigs,
89
KEYPATH_WILDCARD,
10+
messageConfig,
911
ParamsTransformerConfig,
1012
} from '@solana/rpc-transformers';
1113

@@ -223,70 +225,15 @@ function getAllowedNumericKeypaths(): AllowedNumericKeypaths<RpcApi<SolanaRpcApi
223225
'decimals',
224226
],
225227
['transactions', KEYPATH_WILDCARD, 'meta', 'rewards', KEYPATH_WILDCARD, 'commission'],
226-
['transactions', KEYPATH_WILDCARD, 'meta', 'innerInstructions', KEYPATH_WILDCARD, 'index'],
227-
[
228+
...innerInstructionsConfigs.map(c => [
228229
'transactions',
229230
KEYPATH_WILDCARD,
230231
'meta',
231232
'innerInstructions',
232233
KEYPATH_WILDCARD,
233-
'instructions',
234-
KEYPATH_WILDCARD,
235-
'programIdIndex',
236-
],
237-
[
238-
'transactions',
239-
KEYPATH_WILDCARD,
240-
'meta',
241-
'innerInstructions',
242-
KEYPATH_WILDCARD,
243-
'instructions',
244-
KEYPATH_WILDCARD,
245-
'accounts',
246-
KEYPATH_WILDCARD,
247-
],
248-
[
249-
'transactions',
250-
KEYPATH_WILDCARD,
251-
'transaction',
252-
'message',
253-
'addressTableLookups',
254-
KEYPATH_WILDCARD,
255-
'writableIndexes',
256-
KEYPATH_WILDCARD,
257-
],
258-
[
259-
'transactions',
260-
KEYPATH_WILDCARD,
261-
'transaction',
262-
'message',
263-
'addressTableLookups',
264-
KEYPATH_WILDCARD,
265-
'readonlyIndexes',
266-
KEYPATH_WILDCARD,
267-
],
268-
[
269-
'transactions',
270-
KEYPATH_WILDCARD,
271-
'transaction',
272-
'message',
273-
'instructions',
274-
KEYPATH_WILDCARD,
275-
'programIdIndex',
276-
],
277-
[
278-
'transactions',
279-
KEYPATH_WILDCARD,
280-
'transaction',
281-
'message',
282-
'instructions',
283-
KEYPATH_WILDCARD,
284-
'accounts',
285-
KEYPATH_WILDCARD,
286-
],
287-
['transactions', KEYPATH_WILDCARD, 'transaction', 'message', 'header', 'numReadonlySignedAccounts'],
288-
['transactions', KEYPATH_WILDCARD, 'transaction', 'message', 'header', 'numReadonlyUnsignedAccounts'],
289-
['transactions', KEYPATH_WILDCARD, 'transaction', 'message', 'header', 'numRequiredSignatures'],
234+
...c,
235+
]),
236+
...messageConfig.map(c => ['transactions', KEYPATH_WILDCARD, 'transaction', 'message', ...c] as const),
290237
['rewards', KEYPATH_WILDCARD, 'commission'],
291238
],
292239
getBlockTime: [[]],
@@ -333,45 +280,18 @@ function getAllowedNumericKeypaths(): AllowedNumericKeypaths<RpcApi<SolanaRpcApi
333280
['meta', 'postTokenBalances', KEYPATH_WILDCARD, 'accountIndex'],
334281
['meta', 'postTokenBalances', KEYPATH_WILDCARD, 'uiTokenAmount', 'decimals'],
335282
['meta', 'rewards', KEYPATH_WILDCARD, 'commission'],
336-
['meta', 'innerInstructions', KEYPATH_WILDCARD, 'index'],
337-
['meta', 'innerInstructions', KEYPATH_WILDCARD, 'instructions', KEYPATH_WILDCARD, 'programIdIndex'],
338-
[
339-
'meta',
340-
'innerInstructions',
341-
KEYPATH_WILDCARD,
342-
'instructions',
343-
KEYPATH_WILDCARD,
344-
'accounts',
345-
KEYPATH_WILDCARD,
346-
],
347-
[
348-
'transaction',
349-
'message',
350-
'addressTableLookups',
351-
KEYPATH_WILDCARD,
352-
'writableIndexes',
353-
KEYPATH_WILDCARD,
354-
],
355-
[
356-
'transaction',
357-
'message',
358-
'addressTableLookups',
359-
KEYPATH_WILDCARD,
360-
'readonlyIndexes',
361-
KEYPATH_WILDCARD,
362-
],
363-
['transaction', 'message', 'instructions', KEYPATH_WILDCARD, 'programIdIndex'],
364-
['transaction', 'message', 'instructions', KEYPATH_WILDCARD, 'accounts', KEYPATH_WILDCARD],
365-
['transaction', 'message', 'header', 'numReadonlySignedAccounts'],
366-
['transaction', 'message', 'header', 'numReadonlyUnsignedAccounts'],
367-
['transaction', 'message', 'header', 'numRequiredSignatures'],
283+
...innerInstructionsConfigs.map(c => ['meta', 'innerInstructions', KEYPATH_WILDCARD, ...c]),
284+
...messageConfig.map(c => ['transaction', 'message', ...c] as const),
368285
],
369286
getVersion: [['feature-set']],
370287
getVoteAccounts: [
371288
['current', KEYPATH_WILDCARD, 'commission'],
372289
['delinquent', KEYPATH_WILDCARD, 'commission'],
373290
],
374-
simulateTransaction: jsonParsedAccountsConfigs.map(c => ['value', 'accounts', KEYPATH_WILDCARD, ...c]),
291+
simulateTransaction: [
292+
...jsonParsedAccountsConfigs.map(c => ['value', 'accounts', KEYPATH_WILDCARD, ...c]),
293+
...innerInstructionsConfigs.map(c => ['value', 'innerInstructions', KEYPATH_WILDCARD, ...c]),
294+
],
375295
};
376296
}
377297
return memoizedKeypaths;

packages/rpc-subscriptions-api/src/__typetests__/block-notifications-type-test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ type ExpectedMetaForFullBase58 = {
724724
accounts: readonly number[];
725725
data: Base58EncodedBytes;
726726
programIdIndex: number;
727+
stackHeight?: number;
727728
}>[];
728729
}>[];
729730
logMessages: readonly string[] | null;
@@ -990,6 +991,7 @@ type ExpectedMetaForFullBase64 = {
990991
accounts: readonly number[];
991992
data: Base58EncodedBytes;
992993
programIdIndex: number;
994+
stackHeight?: number;
993995
}>[];
994996
}>[];
995997
logMessages: readonly string[] | null;

packages/rpc-transformers/src/response-transformer-allowed-numeric-values.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,19 @@ export const jsonParsedAccountsConfigs = [
3737
['data', 'parsed', 'info', 'commission'],
3838
['data', 'parsed', 'info', 'votes', KEYPATH_WILDCARD, 'confirmationCount'],
3939
];
40+
export const innerInstructionsConfigs = [
41+
['index'],
42+
['instructions', KEYPATH_WILDCARD, 'accounts', KEYPATH_WILDCARD],
43+
['instructions', KEYPATH_WILDCARD, 'programIdIndex'],
44+
['instructions', KEYPATH_WILDCARD, 'stackHeight'],
45+
];
46+
export const messageConfig = [
47+
['addressTableLookups', KEYPATH_WILDCARD, 'writableIndexes', KEYPATH_WILDCARD],
48+
['addressTableLookups', KEYPATH_WILDCARD, 'readonlyIndexes', KEYPATH_WILDCARD],
49+
['header', 'numReadonlySignedAccounts'],
50+
['header', 'numReadonlyUnsignedAccounts'],
51+
['header', 'numRequiredSignatures'],
52+
['instructions', KEYPATH_WILDCARD, 'accounts', KEYPATH_WILDCARD],
53+
['instructions', KEYPATH_WILDCARD, 'programIdIndex'],
54+
['instructions', KEYPATH_WILDCARD, 'stackHeight'],
55+
] as const;

packages/rpc-types/src/transaction.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ type ParsedTransactionInstruction = Readonly<{
2525
};
2626
program: string;
2727
programId: Address;
28+
stackHeight?: number;
2829
}>;
2930

3031
type PartiallyDecodedTransactionInstruction = Readonly<{
3132
accounts: readonly Address[];
3233
data: Base58EncodedBytes;
3334
programId: Address;
35+
stackHeight?: number;
3436
}>;
3537

3638
type ReturnData = {
@@ -44,6 +46,7 @@ type TransactionInstruction = Readonly<{
4446
accounts: readonly number[];
4547
data: Base58EncodedBytes;
4648
programIdIndex: number;
49+
stackHeight?: number;
4750
}>;
4851

4952
type TransactionParsedAccountLegacy = Readonly<{

0 commit comments

Comments
 (0)