Skip to content

Latest commit

 

History

History
416 lines (250 loc) · 9.77 KB

README.md

File metadata and controls

416 lines (250 loc) · 9.77 KB

@debridge-finance/solana-transaction-parser

@debridge-finance/solana-transaction-parser

Table of contents

Classes

Interfaces

Type Aliases

Functions

Type Aliases

IdlAccount

Ƭ IdlAccount: Object

Type declaration

Name Type
isMut boolean
isSigner boolean
name string

Defined in

interfaces.ts:133


IdlAccounts

Ƭ IdlAccounts: Object

Type declaration

Name Type
accounts IdlAccount[]
name string

Defined in

interfaces.ts:139


InstructionNames

Ƭ InstructionNames<I>: I["instructions"][number]["name"]

Type parameters

Name Type
I extends Idl

Defined in

interfaces.ts:49


InstructionParserInfo

Ƭ InstructionParserInfo: [string, ParserFunction<Idl, string>]

public key as base58 string, parser

Defined in

interfaces.ts:35


InstructionParsers

Ƭ InstructionParsers: Map<string, ParserFunction<Idl, string>>

Map which keys are programIds (base58-encoded) and values are ix parsers

Defined in

interfaces.ts:26


IxByName

Ƭ IxByName<I, IxName>: I["instructions"][number] & { name: IxName }

Interface to get instruction by name from IDL

Type parameters

Name Type
I extends Idl
IxName extends I["instructions"][number]["name"]

Defined in

interfaces.ts:131


LogContext

Ƭ LogContext: Object

Context of logs for specific instruction

Type declaration

Name Type
dataLogs string[]
depth number
errors string[]
id number
instructionIndex number
logMessages string[]
programId string
rawLogs string[]

Defined in

interfaces.ts:7


ParsedArgs

Ƭ ParsedArgs: Object

Index signature

▪ [key: string]: unknown

Defined in

interfaces.ts:53


ParsedIdlArgs

Ƭ ParsedIdlArgs<I, IxName>: ParsedIdlArgsByInstructionName<I, IxByName<I, IxName>>

Type parameters

Name Type
I extends Idl
IxName extends InstructionNames<I> = InstructionNames<I>

Defined in

interfaces.ts:51


ParsedIdlArgsByInstructionName

Ƭ 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

Type parameters

Name Type
I extends Idl
Ix extends I["instructions"][number]

Defined in

interfaces.ts:45


ParsedInstruction

Ƭ ParsedInstruction<I, IxName>: UnknownInstruction | ParsedIdlInstruction<I, IxName> | ParsedCustomInstruction

Type parameters

Name Type
I extends Idl
IxName extends InstructionNames<I> = InstructionNames<I>

Defined in

interfaces.ts:64


ParserFunction

Ƭ ParserFunction<I, IxName>: (arg: TransactionInstruction) => ParsedInstruction<I, IxName>

Type parameters

Name Type
I extends Idl
IxName extends InstructionNames<I>

Type declaration

▸ (arg): ParsedInstruction<I, IxName>

Function that takes transaction ix and returns parsed variant

Parameters
Name Type
arg TransactionInstruction
Returns

ParsedInstruction<I, IxName>

Defined in

interfaces.ts:30


TransactionWithLogs

Ƭ TransactionWithLogs: Object

Type declaration

Name Type
logs? string[]
transaction Transaction

Defined in

interfaces.ts:18


UnknownInstruction

Ƭ UnknownInstruction: Object

Type declaration

Name Type
accounts ParsedAccount[]
args { unknown: unknown }
args.unknown unknown
name "unknown" | string
programId PublicKey

Defined in

interfaces.ts:57

Functions

compiledInstructionToInstruction

compiledInstructionToInstruction(compiledInstruction, parsedAccounts): TransactionInstruction

Converts compiled instruction into common TransactionInstruction

Parameters

Name Type Description
compiledInstruction CompiledInstruction
parsedAccounts AccountMeta[] account meta, result of parseTransactionAccounts

Returns

TransactionInstruction

TransactionInstruction


flattenTransactionResponse

flattenTransactionResponse(transaction): Transaction

Converts transaction response with CPI into artifical transaction that contains all instructions from tx and CPI

Parameters

Name Type Description
transaction TransactionResponse transactionResponse to convert from

Returns

Transaction

Transaction object


hexToBuffer

hexToBuffer(data): Buffer

Parameters

Name Type
data string

Returns

Buffer


parseLogs

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

Parameters

Name Type Description
logs string[] logs from TransactionResponse.meta.logs

Returns

LogContext[]

parsed logs with call depth and additional context


parseTransactionAccounts

parseTransactionAccounts(message): AccountMeta[]

Parse transaction message and extract account metas

Parameters

Name Type Description
message Message transaction message

Returns

AccountMeta[]

parsed accounts metas


parsedInstructionToInstruction

parsedInstructionToInstruction(parsedInstruction, accountMeta): TransactionInstruction

Parameters

Name Type
parsedInstruction PartiallyDecodedInstruction
accountMeta AccountMeta[]

Returns

TransactionInstruction