feat: add support for inner instructions metadata (#13224)
* add-inner-trx * add compiled instructions * remove type parsed inner instruction mistake Co-authored-by: Viacheslav Tsurka <vt@parity.digital>
This commit is contained in:
committed by
GitHub
parent
fbc07bf327
commit
fe8c5b0f0f
23
web3.js/module.d.ts
vendored
23
web3.js/module.d.ts
vendored
@ -1,5 +1,4 @@
|
|||||||
declare module '@solana/web3.js' {
|
declare module '@solana/web3.js' {
|
||||||
import {Buffer} from 'buffer';
|
|
||||||
import * as BufferLayout from 'buffer-layout';
|
import * as BufferLayout from 'buffer-layout';
|
||||||
|
|
||||||
// === src/publickey.js ===
|
// === src/publickey.js ===
|
||||||
@ -138,8 +137,28 @@ declare module '@solana/web3.js' {
|
|||||||
logs: Array<string> | null;
|
logs: Array<string> | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type CompiledInnerInstruction = {
|
||||||
|
index: number;
|
||||||
|
instructions: CompiledInstruction[];
|
||||||
|
};
|
||||||
|
|
||||||
export type ConfirmedTransactionMeta = {
|
export type ConfirmedTransactionMeta = {
|
||||||
fee: number;
|
fee: number;
|
||||||
|
innerInstructions?: CompiledInnerInstruction[];
|
||||||
|
preBalances: Array<number>;
|
||||||
|
postBalances: Array<number>;
|
||||||
|
logMessages?: Array<string>;
|
||||||
|
err: TransactionError | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ParsedInnerInstruction = {
|
||||||
|
index: number;
|
||||||
|
instructions: (ParsedInstruction | PartiallyDecodedInstruction)[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ParsedConfirmedTransactionMeta = {
|
||||||
|
fee: number;
|
||||||
|
innerInstructions?: ParsedInnerInstruction[];
|
||||||
preBalances: Array<number>;
|
preBalances: Array<number>;
|
||||||
postBalances: Array<number>;
|
postBalances: Array<number>;
|
||||||
logMessages?: Array<string>;
|
logMessages?: Array<string>;
|
||||||
@ -199,7 +218,7 @@ declare module '@solana/web3.js' {
|
|||||||
export type ParsedConfirmedTransaction = {
|
export type ParsedConfirmedTransaction = {
|
||||||
slot: number;
|
slot: number;
|
||||||
transaction: ParsedTransaction;
|
transaction: ParsedTransaction;
|
||||||
meta: ConfirmedTransactionMeta | null;
|
meta: ParsedConfirmedTransactionMeta | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ParsedAccountData = {
|
export type ParsedAccountData = {
|
||||||
|
@ -152,8 +152,28 @@ declare module '@solana/web3.js' {
|
|||||||
logs: Array<string> | null,
|
logs: Array<string> | null,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
declare export type CompiledInnerInstruction = {
|
||||||
|
index: number,
|
||||||
|
instructions: CompiledInstruction[],
|
||||||
|
};
|
||||||
|
|
||||||
declare export type ConfirmedTransactionMeta = {
|
declare export type ConfirmedTransactionMeta = {
|
||||||
fee: number,
|
fee: number,
|
||||||
|
innerInstructions?: CompiledInnerInstruction[],
|
||||||
|
preBalances: Array<number>,
|
||||||
|
postBalances: Array<number>,
|
||||||
|
logMessages?: Array<string>,
|
||||||
|
err: TransactionError | null,
|
||||||
|
};
|
||||||
|
|
||||||
|
declare export type ParsedInnerInstruction = {
|
||||||
|
index: number,
|
||||||
|
instructions: (ParsedInstruction | PartiallyDecodedInstruction)[],
|
||||||
|
};
|
||||||
|
|
||||||
|
declare export type ParsedConfirmedTransactionMeta = {
|
||||||
|
fee: number,
|
||||||
|
innerInstructions?: ParsedInnerInstruction[],
|
||||||
preBalances: Array<number>,
|
preBalances: Array<number>,
|
||||||
postBalances: Array<number>,
|
postBalances: Array<number>,
|
||||||
logMessages?: Array<string>,
|
logMessages?: Array<string>,
|
||||||
@ -225,7 +245,7 @@ declare module '@solana/web3.js' {
|
|||||||
declare export type ParsedConfirmedTransaction = {
|
declare export type ParsedConfirmedTransaction = {
|
||||||
slot: number,
|
slot: number,
|
||||||
transaction: ParsedTransaction,
|
transaction: ParsedTransaction,
|
||||||
meta: ConfirmedTransactionMeta | null,
|
meta: ParsedConfirmedTransactionMeta | null,
|
||||||
};
|
};
|
||||||
|
|
||||||
declare export type KeyedAccountInfo = {
|
declare export type KeyedAccountInfo = {
|
||||||
|
@ -367,11 +367,47 @@ const SimulatedTransactionResponseValidator = jsonRpcResultAndContext(
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
type PartiallyDecodedInnerInstruction = {
|
||||||
|
index: number,
|
||||||
|
instructions: PartiallyDecodedInstruction[],
|
||||||
|
};
|
||||||
|
|
||||||
|
type ParsedInnerInstruction = {
|
||||||
|
index: number,
|
||||||
|
instructions: (ParsedInstruction | PartiallyDecodedInnerInstruction)[],
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Metadata for a parsed confirmed transaction on the ledger
|
||||||
|
*
|
||||||
|
* @typedef {Object} ParsedConfirmedTransactionMeta
|
||||||
|
* @property {number} fee The fee charged for processing the transaction
|
||||||
|
* @property {Array<ParsedInnerInstruction>} innerInstructions An array of cross program invoked parsed instructions
|
||||||
|
* @property {Array<number>} preBalances The balances of the transaction accounts before processing
|
||||||
|
* @property {Array<number>} postBalances The balances of the transaction accounts after processing
|
||||||
|
* @property {Array<string>} logMessages An array of program log messages emitted during a transaction
|
||||||
|
* @property {object|null} err The error result of transaction processing
|
||||||
|
*/
|
||||||
|
type ParsedConfirmedTransactionMeta = {
|
||||||
|
fee: number,
|
||||||
|
innerInstructions?: ParsedInnerInstruction[],
|
||||||
|
preBalances: Array<number>,
|
||||||
|
postBalances: Array<number>,
|
||||||
|
logMessages?: Array<string>,
|
||||||
|
err: TransactionError | null,
|
||||||
|
};
|
||||||
|
|
||||||
|
type CompiledInnerInstruction = {
|
||||||
|
index: number,
|
||||||
|
instructions: CompiledInstruction[],
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Metadata for a confirmed transaction on the ledger
|
* Metadata for a confirmed transaction on the ledger
|
||||||
*
|
*
|
||||||
* @typedef {Object} ConfirmedTransactionMeta
|
* @typedef {Object} ConfirmedTransactionMeta
|
||||||
* @property {number} fee The fee charged for processing the transaction
|
* @property {number} fee The fee charged for processing the transaction
|
||||||
|
* @property {Array<CompiledInnerInstruction>} innerInstructions An array of cross program invoked instructions
|
||||||
* @property {Array<number>} preBalances The balances of the transaction accounts before processing
|
* @property {Array<number>} preBalances The balances of the transaction accounts before processing
|
||||||
* @property {Array<number>} postBalances The balances of the transaction accounts after processing
|
* @property {Array<number>} postBalances The balances of the transaction accounts after processing
|
||||||
* @property {Array<string>} logMessages An array of program log messages emitted during a transaction
|
* @property {Array<string>} logMessages An array of program log messages emitted during a transaction
|
||||||
@ -379,6 +415,7 @@ const SimulatedTransactionResponseValidator = jsonRpcResultAndContext(
|
|||||||
*/
|
*/
|
||||||
type ConfirmedTransactionMeta = {
|
type ConfirmedTransactionMeta = {
|
||||||
fee: number,
|
fee: number,
|
||||||
|
innerInstructions?: CompiledInnerInstruction[],
|
||||||
preBalances: Array<number>,
|
preBalances: Array<number>,
|
||||||
postBalances: Array<number>,
|
postBalances: Array<number>,
|
||||||
logMessages?: Array<string>,
|
logMessages?: Array<string>,
|
||||||
@ -478,7 +515,7 @@ type ParsedTransaction = {
|
|||||||
type ParsedConfirmedTransaction = {
|
type ParsedConfirmedTransaction = {
|
||||||
slot: number,
|
slot: number,
|
||||||
transaction: ParsedTransaction,
|
transaction: ParsedTransaction,
|
||||||
meta: ConfirmedTransactionMeta | null,
|
meta: ParsedConfirmedTransactionMeta | null,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1126,6 +1163,58 @@ const ConfirmedTransactionMetaResult = struct.union([
|
|||||||
struct.pick({
|
struct.pick({
|
||||||
err: TransactionErrorResult,
|
err: TransactionErrorResult,
|
||||||
fee: 'number',
|
fee: 'number',
|
||||||
|
innerInstructions: struct.union(
|
||||||
|
struct.array([
|
||||||
|
struct({
|
||||||
|
index: 'number',
|
||||||
|
instructions: struct.array([
|
||||||
|
struct({
|
||||||
|
accounts: struct.array(['number']),
|
||||||
|
data: 'string',
|
||||||
|
programIdIndex: 'number',
|
||||||
|
}),
|
||||||
|
]),
|
||||||
|
}),
|
||||||
|
]),
|
||||||
|
'null',
|
||||||
|
'undefined',
|
||||||
|
),
|
||||||
|
preBalances: struct.array(['number']),
|
||||||
|
postBalances: struct.array(['number']),
|
||||||
|
logMessages: struct.union([struct.array(['string']), 'null', 'undefined']),
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
const ParsedConfirmedTransactionMetaResult = struct.union([
|
||||||
|
'null',
|
||||||
|
struct.pick({
|
||||||
|
err: TransactionErrorResult,
|
||||||
|
fee: 'number',
|
||||||
|
innerInstructions: struct.union(
|
||||||
|
struct.array([
|
||||||
|
struct({
|
||||||
|
index: 'number',
|
||||||
|
instructions: struct.array([
|
||||||
|
struct.union([
|
||||||
|
struct({
|
||||||
|
accounts: struct.array(['string']),
|
||||||
|
data: 'string',
|
||||||
|
programId: 'string',
|
||||||
|
}),
|
||||||
|
struct({
|
||||||
|
parsed: 'any',
|
||||||
|
program: 'string',
|
||||||
|
programId: 'string',
|
||||||
|
}),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
}),
|
||||||
|
]),
|
||||||
|
'null',
|
||||||
|
'undefined',
|
||||||
|
),
|
||||||
preBalances: struct.array(['number']),
|
preBalances: struct.array(['number']),
|
||||||
postBalances: struct.array(['number']),
|
postBalances: struct.array(['number']),
|
||||||
logMessages: struct.union([struct.array(['string']), 'null', 'undefined']),
|
logMessages: struct.union([struct.array(['string']), 'null', 'undefined']),
|
||||||
@ -1186,7 +1275,7 @@ const GetParsedConfirmedTransactionRpcResult = jsonRpcResult(
|
|||||||
struct.pick({
|
struct.pick({
|
||||||
slot: 'number',
|
slot: 'number',
|
||||||
transaction: ParsedConfirmedTransactionResult,
|
transaction: ParsedConfirmedTransactionResult,
|
||||||
meta: ConfirmedTransactionMetaResult,
|
meta: ParsedConfirmedTransactionMetaResult,
|
||||||
}),
|
}),
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user