@debridge-finance/solana-transaction-parser
- IdlAccount
- IdlAccounts
- InstructionNames
- InstructionParserInfo
- InstructionParsers
- IxByName
- LogContext
- ParsedArgs
- ParsedIdlArgs
- ParsedIdlArgsByInstructionName
- ParsedInstruction
- ParserFunction
- TransactionWithLogs
- UnknownInstruction
- compiledInstructionToInstruction
- flattenTransactionResponse
- hexToBuffer
- parseLogs
- parseTransactionAccounts
- parsedInstructionToInstruction
Ƭ IdlAccount: Object
Name | Type |
---|---|
isMut |
boolean |
isSigner |
boolean |
name |
string |
Ƭ IdlAccounts: Object
Name | Type |
---|---|
accounts |
IdlAccount [] |
name |
string |
Ƭ InstructionNames<I
>: I
["instructions"
][number
]["name"
]
Name | Type |
---|---|
I |
extends Idl |
Ƭ InstructionParserInfo: [string
, ParserFunction
<Idl
, string
>]
public key as base58 string, parser
Ƭ InstructionParsers: Map
<string
, ParserFunction
<Idl
, string
>>
Map which keys are programIds (base58-encoded) and values are ix parsers
Ƭ IxByName<I
, IxName
>: I
["instructions"
][number
] & { name
: IxName
}
Interface to get instruction by name from IDL
Name | Type |
---|---|
I |
extends Idl |
IxName |
extends I ["instructions" ][number ]["name" ] |
Ƭ LogContext: Object
Context of logs for specific instruction
Name | Type |
---|---|
dataLogs |
string [] |
depth |
number |
errors |
string [] |
id |
number |
instructionIndex |
number |
logMessages |
string [] |
programId |
string |
rawLogs |
string [] |
Ƭ ParsedArgs: Object
▪ [key: string
]: unknown
Ƭ ParsedIdlArgs<I
, IxName
>: ParsedIdlArgsByInstructionName
<I
, IxByName
<I
, IxName
>>
Name | Type |
---|---|
I |
extends Idl |
IxName |
extends InstructionNames <I > = InstructionNames <I > |
Ƭ ParsedIdlArgsByInstructionName<I
, Ix
>: { [ArgName in Ix["args"][number]["name"]]: DecodeType<(Ix["args"][number] & Object)["type"], IdlTypes<I>> }
Instructions args with correct types for specific instruction by instruction name
Name | Type |
---|---|
I |
extends Idl |
Ix |
extends I ["instructions" ][number ] |
Ƭ ParsedInstruction<I
, IxName
>: UnknownInstruction
| ParsedIdlInstruction
<I
, IxName
> | ParsedCustomInstruction
Name | Type |
---|---|
I |
extends Idl |
IxName |
extends InstructionNames <I > = InstructionNames <I > |
Ƭ ParserFunction<I
, IxName
>: (arg
: TransactionInstruction
) => ParsedInstruction
<I
, IxName
>
Name | Type |
---|---|
I |
extends Idl |
IxName |
extends InstructionNames <I > |
▸ (arg
): ParsedInstruction
<I
, IxName
>
Function that takes transaction ix and returns parsed variant
Name | Type |
---|---|
arg |
TransactionInstruction |
ParsedInstruction
<I
, IxName
>
Ƭ TransactionWithLogs: Object
Name | Type |
---|---|
logs? |
string [] |
transaction |
Transaction |
Ƭ UnknownInstruction: Object
Name | Type |
---|---|
accounts |
ParsedAccount [] |
args |
{ unknown : unknown } |
args.unknown |
unknown |
name |
"unknown" | string |
programId |
PublicKey |
▸ compiledInstructionToInstruction(compiledInstruction
, parsedAccounts
): TransactionInstruction
Converts compiled instruction into common TransactionInstruction
Name | Type | Description |
---|---|---|
compiledInstruction |
CompiledInstruction |
|
parsedAccounts |
AccountMeta [] |
account meta, result of parseTransactionAccounts |
TransactionInstruction
TransactionInstruction
▸ flattenTransactionResponse(transaction
): Transaction
Converts transaction response with CPI into artifical transaction that contains all instructions from tx and CPI
Name | Type | Description |
---|---|---|
transaction |
TransactionResponse |
transactionResponse to convert from |
Transaction
Transaction object
▸ hexToBuffer(data
): Buffer
Name | Type |
---|---|
data |
string |
Buffer
▸ parseLogs(logs
): LogContext
[]
Parses transaction logs and provides additional context such as
- programId that generated the message
- call id of instruction, that generated the message
- call depth of instruction
- data messages, log messages and error messages
Name | Type | Description |
---|---|---|
logs |
string [] |
logs from TransactionResponse.meta.logs |
parsed logs with call depth and additional context
▸ parseTransactionAccounts(message
): AccountMeta
[]
Parse transaction message and extract account metas
Name | Type | Description |
---|---|---|
message |
Message |
transaction message |
AccountMeta
[]
parsed accounts metas
▸ parsedInstructionToInstruction(parsedInstruction
, accountMeta
): TransactionInstruction
Name | Type |
---|---|
parsedInstruction |
PartiallyDecodedInstruction |
accountMeta |
AccountMeta [] |
TransactionInstruction