-
Notifications
You must be signed in to change notification settings - Fork 908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
You can now request innerInstructions
with simulation
#2868
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@solana/rpc-api': patch | ||
--- | ||
|
||
The `simulateTransaction` RPC method now accepts an `innerInstructions` param. When `true`, the simulation result will include an array of inner instructions, if any. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ import type { | |
Slot, | ||
SolanaRpcResponse, | ||
TransactionError, | ||
TransactionForFullMetaInnerInstructionsParsed, | ||
TransactionForFullMetaInnerInstructionsUnparsed, | ||
U64UnsafeBeyond2Pow53Minus1, | ||
} from '@solana/rpc-types'; | ||
import type { Base64EncodedWireTransaction } from '@solana/transactions'; | ||
|
@@ -21,6 +23,12 @@ type SimulateTransactionConfigBase = Readonly<{ | |
* @defaultValue finalized | ||
* */ | ||
commitment?: Commitment; | ||
/** | ||
* If `true` the response will include inner instructions. These inner instructions will be | ||
* `jsonParsed` where possible, otherwise `json`. | ||
* @defaultValue false | ||
*/ | ||
innerInstructions?: boolean; | ||
/** The minimum slot that the request can be evaluated at */ | ||
minContextSlot?: Slot; | ||
}>; | ||
|
@@ -74,6 +82,10 @@ type AccountsConfigWithBase64Encoding = Readonly<{ | |
}; | ||
}>; | ||
|
||
type WithInnerInstructionsConfig = Readonly<{ | ||
innerInstructions: true; | ||
}>; | ||
|
||
type SimulateTransactionApiResponseBase = SolanaRpcResponse<{ | ||
/** Error if transaction failed, null if transaction succeeded. */ | ||
err: TransactionError | null; | ||
|
@@ -95,7 +107,22 @@ type SimulateTransactionApiResponseWithAccounts<T extends AccountInfoBase> = Sol | |
accounts: (T | null)[]; | ||
}>; | ||
|
||
type SimulateTransactionApiResponseWithInnerInstructions = SolanaRpcResponse< | ||
TransactionForFullMetaInnerInstructionsParsed | TransactionForFullMetaInnerInstructionsUnparsed | ||
>; | ||
|
||
export interface SimulateTransactionApi extends RpcApiMethods { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to double the number of overloads here, to be able to express ‘inner instructions on’ and ‘inner instructions off’ :( This still keeps us under the (current) max of 24, but as soon as we want to add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh crap that's rough. |
||
/** @deprecated Set `encoding` to `'base64'` when calling this method */ | ||
simulateTransaction( | ||
base58EncodedWireTransaction: Base58EncodedBytes, | ||
config: AccountsConfigWithBase64Encoding & | ||
SigVerifyAndReplaceRecentBlockhashConfig & | ||
SimulateTransactionConfigBase & | ||
WithInnerInstructionsConfig, | ||
): SimulateTransactionApiResponseBase & | ||
SimulateTransactionApiResponseWithAccounts<AccountInfoBase & AccountInfoWithBase64EncodedData> & | ||
SimulateTransactionApiResponseWithInnerInstructions; | ||
|
||
/** @deprecated Set `encoding` to `'base64'` when calling this method */ | ||
simulateTransaction( | ||
base58EncodedWireTransaction: Base58EncodedBytes, | ||
|
@@ -105,6 +132,17 @@ export interface SimulateTransactionApi extends RpcApiMethods { | |
): SimulateTransactionApiResponseBase & | ||
SimulateTransactionApiResponseWithAccounts<AccountInfoBase & AccountInfoWithBase64EncodedData>; | ||
|
||
/** @deprecated Set `encoding` to `'base64'` when calling this method */ | ||
simulateTransaction( | ||
base58EncodedWireTransaction: Base58EncodedBytes, | ||
config: AccountsConfigWithBase64EncodingZstdCompression & | ||
SigVerifyAndReplaceRecentBlockhashConfig & | ||
SimulateTransactionConfigBase & | ||
WithInnerInstructionsConfig, | ||
): SimulateTransactionApiResponseBase & | ||
SimulateTransactionApiResponseWithAccounts<AccountInfoBase & AccountInfoWithBase64EncodedZStdCompressedData> & | ||
SimulateTransactionApiResponseWithInnerInstructions; | ||
|
||
/** @deprecated Set `encoding` to `'base64'` when calling this method */ | ||
simulateTransaction( | ||
base58EncodedWireTransaction: Base58EncodedBytes, | ||
|
@@ -114,6 +152,17 @@ export interface SimulateTransactionApi extends RpcApiMethods { | |
): SimulateTransactionApiResponseBase & | ||
SimulateTransactionApiResponseWithAccounts<AccountInfoBase & AccountInfoWithBase64EncodedZStdCompressedData>; | ||
|
||
/** @deprecated Set `encoding` to `'base64'` when calling this method */ | ||
simulateTransaction( | ||
base58EncodedWireTransaction: Base58EncodedBytes, | ||
config: AccountsConfigWithJsonParsedEncoding & | ||
SigVerifyAndReplaceRecentBlockhashConfig & | ||
SimulateTransactionConfigBase & | ||
WithInnerInstructionsConfig, | ||
): SimulateTransactionApiResponseBase & | ||
SimulateTransactionApiResponseWithAccounts<AccountInfoBase & AccountInfoWithJsonData> & | ||
SimulateTransactionApiResponseWithInnerInstructions; | ||
|
||
/** @deprecated Set `encoding` to `'base64'` when calling this method */ | ||
simulateTransaction( | ||
base58EncodedWireTransaction: Base58EncodedBytes, | ||
|
@@ -123,12 +172,31 @@ export interface SimulateTransactionApi extends RpcApiMethods { | |
): SimulateTransactionApiResponseBase & | ||
SimulateTransactionApiResponseWithAccounts<AccountInfoBase & AccountInfoWithJsonData>; | ||
|
||
/** @deprecated Set `encoding` to `'base64'` when calling this method */ | ||
simulateTransaction( | ||
base58EncodedWireTransaction: Base58EncodedBytes, | ||
config?: SigVerifyAndReplaceRecentBlockhashConfig & SimulateTransactionConfigBase & WithInnerInstructionsConfig, | ||
): SimulateTransactionApiResponseBase & | ||
SimulateTransactionApiResponseWithInnerInstructions & | ||
SolanaRpcResponse<{ readonly accounts: null }>; | ||
|
||
/** @deprecated Set `encoding` to `'base64'` when calling this method */ | ||
simulateTransaction( | ||
base58EncodedWireTransaction: Base58EncodedBytes, | ||
config?: SigVerifyAndReplaceRecentBlockhashConfig & SimulateTransactionConfigBase, | ||
): SimulateTransactionApiResponseBase & SolanaRpcResponse<{ readonly accounts: null }>; | ||
|
||
/** Simulate sending a transaction */ | ||
simulateTransaction( | ||
base64EncodedWireTransaction: Base64EncodedWireTransaction, | ||
config: AccountsConfigWithBase64Encoding & | ||
SigVerifyAndReplaceRecentBlockhashConfig & | ||
SimulateTransactionConfigBase & | ||
WithInnerInstructionsConfig & { encoding: 'base64' }, | ||
): SimulateTransactionApiResponseBase & | ||
SimulateTransactionApiResponseWithAccounts<AccountInfoBase & AccountInfoWithBase64EncodedData> & | ||
SimulateTransactionApiResponseWithInnerInstructions; | ||
|
||
/** Simulate sending a transaction */ | ||
simulateTransaction( | ||
base64EncodedWireTransaction: Base64EncodedWireTransaction, | ||
|
@@ -138,6 +206,17 @@ export interface SimulateTransactionApi extends RpcApiMethods { | |
): SimulateTransactionApiResponseBase & | ||
SimulateTransactionApiResponseWithAccounts<AccountInfoBase & AccountInfoWithBase64EncodedData>; | ||
|
||
/** Simulate sending a transaction */ | ||
simulateTransaction( | ||
base64EncodedWireTransaction: Base64EncodedWireTransaction, | ||
config: AccountsConfigWithBase64EncodingZstdCompression & | ||
SigVerifyAndReplaceRecentBlockhashConfig & | ||
SimulateTransactionConfigBase & | ||
WithInnerInstructionsConfig & { encoding: 'base64' }, | ||
): SimulateTransactionApiResponseBase & | ||
SimulateTransactionApiResponseWithAccounts<AccountInfoBase & AccountInfoWithBase64EncodedZStdCompressedData> & | ||
SimulateTransactionApiResponseWithInnerInstructions; | ||
|
||
/** Simulate sending a transaction */ | ||
simulateTransaction( | ||
base64EncodedWireTransaction: Base64EncodedWireTransaction, | ||
|
@@ -147,6 +226,17 @@ export interface SimulateTransactionApi extends RpcApiMethods { | |
): SimulateTransactionApiResponseBase & | ||
SimulateTransactionApiResponseWithAccounts<AccountInfoBase & AccountInfoWithBase64EncodedZStdCompressedData>; | ||
|
||
/** Simulate sending a transaction */ | ||
simulateTransaction( | ||
base64EncodedWireTransaction: Base64EncodedWireTransaction, | ||
config: AccountsConfigWithJsonParsedEncoding & | ||
SigVerifyAndReplaceRecentBlockhashConfig & | ||
SimulateTransactionConfigBase & | ||
WithInnerInstructionsConfig & { encoding: 'base64' }, | ||
): SimulateTransactionApiResponseBase & | ||
SimulateTransactionApiResponseWithAccounts<AccountInfoBase & AccountInfoWithJsonData> & | ||
SimulateTransactionApiResponseWithInnerInstructions; | ||
|
||
/** Simulate sending a transaction */ | ||
simulateTransaction( | ||
base64EncodedWireTransaction: Base64EncodedWireTransaction, | ||
|
@@ -156,6 +246,16 @@ export interface SimulateTransactionApi extends RpcApiMethods { | |
): SimulateTransactionApiResponseBase & | ||
SimulateTransactionApiResponseWithAccounts<AccountInfoBase & AccountInfoWithJsonData>; | ||
|
||
/** Simulate sending a transaction */ | ||
simulateTransaction( | ||
base64EncodedWireTransaction: Base64EncodedWireTransaction, | ||
config: SigVerifyAndReplaceRecentBlockhashConfig & | ||
SimulateTransactionConfigBase & | ||
WithInnerInstructionsConfig & { encoding: 'base64' }, | ||
): SimulateTransactionApiResponseBase & | ||
SimulateTransactionApiResponseWithInnerInstructions & | ||
SolanaRpcResponse<{ readonly accounts: null }>; | ||
|
||
/** Simulate sending a transaction */ | ||
simulateTransaction( | ||
base64EncodedWireTransaction: Base64EncodedWireTransaction, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,7 +144,7 @@ type TransactionForFullMetaBase = Readonly<{ | |
status: TransactionStatus; | ||
}>; | ||
|
||
type TransactionForFullMetaInnerInstructionsUnparsed = Readonly<{ | ||
export type TransactionForFullMetaInnerInstructionsUnparsed = Readonly<{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mcintyre94, is there a reason we don't use these in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure, but my guess would be that it was before we untangled the rpc packages and it would have caused a circular dependency mess. Probably can be changed now! |
||
innerInstructions: readonly Readonly<{ | ||
/** The index of the instruction in the transaction */ | ||
index: number; | ||
|
@@ -153,7 +153,7 @@ type TransactionForFullMetaInnerInstructionsUnparsed = Readonly<{ | |
}>[]; | ||
}>; | ||
|
||
type TransactionForFullMetaInnerInstructionsParsed = Readonly<{ | ||
export type TransactionForFullMetaInnerInstructionsParsed = Readonly<{ | ||
innerInstructions: readonly Readonly<{ | ||
/** The index of the instruction in the transaction */ | ||
index: number; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Starting to regret what I might have signed up for with this comment....