package shreder import ( "fmt" "time" "github.com/gagliardetto/solana-go" ) type AccountNotFoundError struct { Index int Len int } func NewAccountNotFoundError(i, l int) error { return &AccountNotFoundError{i, l} } func (e AccountNotFoundError) Error() string { return fmt.Sprintf("account index %d out of range, len=%d", e.Index, e.Len) } type Instructions struct { ProgramIDIndex uint8 Accounts []uint8 Data []byte } type AddressTableLookup struct { AccountKey solana.PublicKey WritableIndexes []uint8 ReadonlyIndexes []uint8 } type VersionedTransaction struct { Signatures []solana.Signature StaticAccountKeys []solana.PublicKey Instructions []Instructions AddressTableLookups []AddressTableLookup Block uint64 Time time.Time } func (vt VersionedTransaction) GetSignature() string { if len(vt.Signatures) == 0 { return "" } return vt.Signatures[0].String() } func (vtp *VersionedTransaction) FillAccount(account solana.PublicKey) { vtp.StaticAccountKeys = append(vtp.StaticAccountKeys, account) } func (vt VersionedTransaction) GetAccount(idx int) (solana.PublicKey, error) { if idx < len(vt.StaticAccountKeys) { return vt.StaticAccountKeys[idx], nil } return solana.PublicKey{}, NewAccountNotFoundError(idx, len(vt.StaticAccountKeys)) }