Skip to content

Commit 5fa6c60

Browse files
committed
You can now request innerInstructions with simulation
1 parent be36bab commit 5fa6c60

File tree

3 files changed

+107
-2
lines changed

3 files changed

+107
-2
lines changed

.changeset/calm-camels-decide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@solana/rpc-api': patch
3+
---
4+
5+
The `simulateTransaction` RPC method now accepts an `innerInstructions` param. When `true`, the simulation result will include an array of inner instructions, if any.

packages/rpc-api/src/simulateTransaction.ts

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import type {
1111
Slot,
1212
SolanaRpcResponse,
1313
TransactionError,
14+
TransactionForFullMetaInnerInstructionsParsed,
15+
TransactionForFullMetaInnerInstructionsUnparsed,
1416
U64UnsafeBeyond2Pow53Minus1,
1517
} from '@solana/rpc-types';
1618
import type { Base64EncodedWireTransaction } from '@solana/transactions';
@@ -21,6 +23,12 @@ type SimulateTransactionConfigBase = Readonly<{
2123
* @defaultValue finalized
2224
* */
2325
commitment?: Commitment;
26+
/**
27+
* If `true` the response will include inner instructions. These inner instructions will be
28+
* `jsonParsed` where possible, otherwise `json`.
29+
* @defaultValue false
30+
*/
31+
innerInstructions?: boolean;
2432
/** The minimum slot that the request can be evaluated at */
2533
minContextSlot?: Slot;
2634
}>;
@@ -74,6 +82,10 @@ type AccountsConfigWithBase64Encoding = Readonly<{
7482
};
7583
}>;
7684

85+
type WithInnerInstructionsConfig = Readonly<{
86+
innerInstructions: true;
87+
}>;
88+
7789
type SimulateTransactionApiResponseBase = SolanaRpcResponse<{
7890
/** Error if transaction failed, null if transaction succeeded. */
7991
err: TransactionError | null;
@@ -95,7 +107,22 @@ type SimulateTransactionApiResponseWithAccounts<T extends AccountInfoBase> = Sol
95107
accounts: (T | null)[];
96108
}>;
97109

110+
type SimulateTransactionApiResponseWithInnerInstructions = SolanaRpcResponse<
111+
TransactionForFullMetaInnerInstructionsParsed | TransactionForFullMetaInnerInstructionsUnparsed
112+
>;
113+
98114
export interface SimulateTransactionApi extends RpcApiMethods {
115+
/** @deprecated Set `encoding` to `'base64'` when calling this method */
116+
simulateTransaction(
117+
base58EncodedWireTransaction: Base58EncodedBytes,
118+
config: AccountsConfigWithBase64Encoding &
119+
SigVerifyAndReplaceRecentBlockhashConfig &
120+
SimulateTransactionConfigBase &
121+
WithInnerInstructionsConfig,
122+
): SimulateTransactionApiResponseBase &
123+
SimulateTransactionApiResponseWithAccounts<AccountInfoBase & AccountInfoWithBase64EncodedData> &
124+
SimulateTransactionApiResponseWithInnerInstructions;
125+
99126
/** @deprecated Set `encoding` to `'base64'` when calling this method */
100127
simulateTransaction(
101128
base58EncodedWireTransaction: Base58EncodedBytes,
@@ -105,6 +132,17 @@ export interface SimulateTransactionApi extends RpcApiMethods {
105132
): SimulateTransactionApiResponseBase &
106133
SimulateTransactionApiResponseWithAccounts<AccountInfoBase & AccountInfoWithBase64EncodedData>;
107134

135+
/** @deprecated Set `encoding` to `'base64'` when calling this method */
136+
simulateTransaction(
137+
base58EncodedWireTransaction: Base58EncodedBytes,
138+
config: AccountsConfigWithBase64EncodingZstdCompression &
139+
SigVerifyAndReplaceRecentBlockhashConfig &
140+
SimulateTransactionConfigBase &
141+
WithInnerInstructionsConfig,
142+
): SimulateTransactionApiResponseBase &
143+
SimulateTransactionApiResponseWithAccounts<AccountInfoBase & AccountInfoWithBase64EncodedZStdCompressedData> &
144+
SimulateTransactionApiResponseWithInnerInstructions;
145+
108146
/** @deprecated Set `encoding` to `'base64'` when calling this method */
109147
simulateTransaction(
110148
base58EncodedWireTransaction: Base58EncodedBytes,
@@ -114,6 +152,17 @@ export interface SimulateTransactionApi extends RpcApiMethods {
114152
): SimulateTransactionApiResponseBase &
115153
SimulateTransactionApiResponseWithAccounts<AccountInfoBase & AccountInfoWithBase64EncodedZStdCompressedData>;
116154

155+
/** @deprecated Set `encoding` to `'base64'` when calling this method */
156+
simulateTransaction(
157+
base58EncodedWireTransaction: Base58EncodedBytes,
158+
config: AccountsConfigWithJsonParsedEncoding &
159+
SigVerifyAndReplaceRecentBlockhashConfig &
160+
SimulateTransactionConfigBase &
161+
WithInnerInstructionsConfig,
162+
): SimulateTransactionApiResponseBase &
163+
SimulateTransactionApiResponseWithAccounts<AccountInfoBase & AccountInfoWithJsonData> &
164+
SimulateTransactionApiResponseWithInnerInstructions;
165+
117166
/** @deprecated Set `encoding` to `'base64'` when calling this method */
118167
simulateTransaction(
119168
base58EncodedWireTransaction: Base58EncodedBytes,
@@ -123,12 +172,31 @@ export interface SimulateTransactionApi extends RpcApiMethods {
123172
): SimulateTransactionApiResponseBase &
124173
SimulateTransactionApiResponseWithAccounts<AccountInfoBase & AccountInfoWithJsonData>;
125174

175+
/** @deprecated Set `encoding` to `'base64'` when calling this method */
176+
simulateTransaction(
177+
base58EncodedWireTransaction: Base58EncodedBytes,
178+
config?: SigVerifyAndReplaceRecentBlockhashConfig & SimulateTransactionConfigBase & WithInnerInstructionsConfig,
179+
): SimulateTransactionApiResponseBase &
180+
SimulateTransactionApiResponseWithInnerInstructions &
181+
SolanaRpcResponse<{ readonly accounts: null }>;
182+
126183
/** @deprecated Set `encoding` to `'base64'` when calling this method */
127184
simulateTransaction(
128185
base58EncodedWireTransaction: Base58EncodedBytes,
129186
config?: SigVerifyAndReplaceRecentBlockhashConfig & SimulateTransactionConfigBase,
130187
): SimulateTransactionApiResponseBase & SolanaRpcResponse<{ readonly accounts: null }>;
131188

189+
/** Simulate sending a transaction */
190+
simulateTransaction(
191+
base64EncodedWireTransaction: Base64EncodedWireTransaction,
192+
config: AccountsConfigWithBase64Encoding &
193+
SigVerifyAndReplaceRecentBlockhashConfig &
194+
SimulateTransactionConfigBase &
195+
WithInnerInstructionsConfig & { encoding: 'base64' },
196+
): SimulateTransactionApiResponseBase &
197+
SimulateTransactionApiResponseWithAccounts<AccountInfoBase & AccountInfoWithBase64EncodedData> &
198+
SimulateTransactionApiResponseWithInnerInstructions;
199+
132200
/** Simulate sending a transaction */
133201
simulateTransaction(
134202
base64EncodedWireTransaction: Base64EncodedWireTransaction,
@@ -138,6 +206,17 @@ export interface SimulateTransactionApi extends RpcApiMethods {
138206
): SimulateTransactionApiResponseBase &
139207
SimulateTransactionApiResponseWithAccounts<AccountInfoBase & AccountInfoWithBase64EncodedData>;
140208

209+
/** Simulate sending a transaction */
210+
simulateTransaction(
211+
base64EncodedWireTransaction: Base64EncodedWireTransaction,
212+
config: AccountsConfigWithBase64EncodingZstdCompression &
213+
SigVerifyAndReplaceRecentBlockhashConfig &
214+
SimulateTransactionConfigBase &
215+
WithInnerInstructionsConfig & { encoding: 'base64' },
216+
): SimulateTransactionApiResponseBase &
217+
SimulateTransactionApiResponseWithAccounts<AccountInfoBase & AccountInfoWithBase64EncodedZStdCompressedData> &
218+
SimulateTransactionApiResponseWithInnerInstructions;
219+
141220
/** Simulate sending a transaction */
142221
simulateTransaction(
143222
base64EncodedWireTransaction: Base64EncodedWireTransaction,
@@ -147,6 +226,17 @@ export interface SimulateTransactionApi extends RpcApiMethods {
147226
): SimulateTransactionApiResponseBase &
148227
SimulateTransactionApiResponseWithAccounts<AccountInfoBase & AccountInfoWithBase64EncodedZStdCompressedData>;
149228

229+
/** Simulate sending a transaction */
230+
simulateTransaction(
231+
base64EncodedWireTransaction: Base64EncodedWireTransaction,
232+
config: AccountsConfigWithJsonParsedEncoding &
233+
SigVerifyAndReplaceRecentBlockhashConfig &
234+
SimulateTransactionConfigBase &
235+
WithInnerInstructionsConfig & { encoding: 'base64' },
236+
): SimulateTransactionApiResponseBase &
237+
SimulateTransactionApiResponseWithAccounts<AccountInfoBase & AccountInfoWithJsonData> &
238+
SimulateTransactionApiResponseWithInnerInstructions;
239+
150240
/** Simulate sending a transaction */
151241
simulateTransaction(
152242
base64EncodedWireTransaction: Base64EncodedWireTransaction,
@@ -156,6 +246,16 @@ export interface SimulateTransactionApi extends RpcApiMethods {
156246
): SimulateTransactionApiResponseBase &
157247
SimulateTransactionApiResponseWithAccounts<AccountInfoBase & AccountInfoWithJsonData>;
158248

249+
/** Simulate sending a transaction */
250+
simulateTransaction(
251+
base64EncodedWireTransaction: Base64EncodedWireTransaction,
252+
config: SigVerifyAndReplaceRecentBlockhashConfig &
253+
SimulateTransactionConfigBase &
254+
WithInnerInstructionsConfig & { encoding: 'base64' },
255+
): SimulateTransactionApiResponseBase &
256+
SimulateTransactionApiResponseWithInnerInstructions &
257+
SolanaRpcResponse<{ readonly accounts: null }>;
258+
159259
/** Simulate sending a transaction */
160260
simulateTransaction(
161261
base64EncodedWireTransaction: Base64EncodedWireTransaction,

packages/rpc-types/src/transaction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ type TransactionForFullMetaBase = Readonly<{
144144
status: TransactionStatus;
145145
}>;
146146

147-
type TransactionForFullMetaInnerInstructionsUnparsed = Readonly<{
147+
export type TransactionForFullMetaInnerInstructionsUnparsed = Readonly<{
148148
innerInstructions: readonly Readonly<{
149149
/** The index of the instruction in the transaction */
150150
index: number;
@@ -153,7 +153,7 @@ type TransactionForFullMetaInnerInstructionsUnparsed = Readonly<{
153153
}>[];
154154
}>;
155155

156-
type TransactionForFullMetaInnerInstructionsParsed = Readonly<{
156+
export type TransactionForFullMetaInnerInstructionsParsed = Readonly<{
157157
innerInstructions: readonly Readonly<{
158158
/** The index of the instruction in the transaction */
159159
index: number;

0 commit comments

Comments
 (0)