feat: support pre and post token balances (#13603)
* feat: support pre and post token balances * fix: define tokenbalance * fix: change pre/post balances to array
This commit is contained in:
@@ -373,6 +373,12 @@ type ParsedInnerInstruction = {
|
||||
instructions: (ParsedInstruction | PartiallyDecodedInstruction)[],
|
||||
};
|
||||
|
||||
type TokenBalance = {
|
||||
accountIndex: number,
|
||||
mint: string,
|
||||
uiTokenAmount: TokenAmount,
|
||||
};
|
||||
|
||||
/**
|
||||
* Metadata for a parsed confirmed transaction on the ledger
|
||||
*
|
||||
@@ -382,6 +388,8 @@ type ParsedInnerInstruction = {
|
||||
* @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 {Array<TokenBalance>} preTokenBalances The token balances of the transaction accounts before processing
|
||||
* @property {Array<TokenBalance>} postTokenBalances The token balances of the transaction accounts after processing
|
||||
* @property {object|null} err The error result of transaction processing
|
||||
*/
|
||||
type ParsedConfirmedTransactionMeta = {
|
||||
@@ -390,6 +398,8 @@ type ParsedConfirmedTransactionMeta = {
|
||||
preBalances: Array<number>,
|
||||
postBalances: Array<number>,
|
||||
logMessages?: Array<string>,
|
||||
preTokenBalances?: Array<TokenBalance>,
|
||||
postTokenBalances?: Array<TokenBalance>,
|
||||
err: TransactionError | null,
|
||||
};
|
||||
|
||||
@@ -1178,6 +1188,36 @@ const ConfirmedTransactionMetaResult = struct.union([
|
||||
preBalances: struct.array(['number']),
|
||||
postBalances: struct.array(['number']),
|
||||
logMessages: struct.union([struct.array(['string']), 'null', 'undefined']),
|
||||
preTokenBalances: struct.union([
|
||||
struct.array([
|
||||
struct.pick({
|
||||
accountIndex: 'number',
|
||||
mint: 'string',
|
||||
uiTokenAmount: struct.pick({
|
||||
amount: 'string',
|
||||
decimals: 'number',
|
||||
uiAmount: 'number',
|
||||
}),
|
||||
}),
|
||||
]),
|
||||
'null',
|
||||
'undefined',
|
||||
]),
|
||||
postTokenBalances: struct.union([
|
||||
struct.array([
|
||||
struct.pick({
|
||||
accountIndex: 'number',
|
||||
mint: 'string',
|
||||
uiTokenAmount: struct.pick({
|
||||
amount: 'string',
|
||||
decimals: 'number',
|
||||
uiAmount: 'number',
|
||||
}),
|
||||
}),
|
||||
]),
|
||||
'null',
|
||||
'undefined',
|
||||
]),
|
||||
}),
|
||||
]);
|
||||
/**
|
||||
@@ -1214,6 +1254,36 @@ const ParsedConfirmedTransactionMetaResult = struct.union([
|
||||
preBalances: struct.array(['number']),
|
||||
postBalances: struct.array(['number']),
|
||||
logMessages: struct.union([struct.array(['string']), 'null', 'undefined']),
|
||||
preTokenBalances: struct.union([
|
||||
struct.array([
|
||||
struct.pick({
|
||||
accountIndex: 'number',
|
||||
mint: 'string',
|
||||
uiTokenAmount: struct.pick({
|
||||
amount: 'string',
|
||||
decimals: 'number',
|
||||
uiAmount: 'number',
|
||||
}),
|
||||
}),
|
||||
]),
|
||||
'null',
|
||||
'undefined',
|
||||
]),
|
||||
postTokenBalances: struct.union([
|
||||
struct.array([
|
||||
struct.pick({
|
||||
accountIndex: 'number',
|
||||
mint: 'string',
|
||||
uiTokenAmount: struct.pick({
|
||||
amount: 'string',
|
||||
decimals: 'number',
|
||||
uiAmount: 'number',
|
||||
}),
|
||||
}),
|
||||
]),
|
||||
'null',
|
||||
'undefined',
|
||||
]),
|
||||
}),
|
||||
]);
|
||||
|
||||
|
Reference in New Issue
Block a user