From fdcf599b88b1df4fe7f9fdea1bca287770255075 Mon Sep 17 00:00:00 2001 From: billettc Date: Tue, 25 Jan 2022 07:13:45 -0500 Subject: [PATCH 1/2] support for solana --- .gitignore | 2 + chain/solana.ts | 113 ++++++++++++++++++++++++++++++++++++++++++++++++ index.ts | 2 + 3 files changed, 117 insertions(+) create mode 100644 chain/solana.ts diff --git a/.gitignore b/.gitignore index 2d2f72e..3f4fc5e 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,5 @@ typings/ # build files *.wasm +.idea/ +.idea diff --git a/chain/solana.ts b/chain/solana.ts new file mode 100644 index 0000000..2fb66a5 --- /dev/null +++ b/chain/solana.ts @@ -0,0 +1,113 @@ +import '../common/eager_offset' +import {Bytes} from '../common/collections' + +// Most types from this namespace are direct mappings or adaptations from: +// https://github.com/streamingfast/proto-near/blob/develop/sf/near/codec/v1/codec.proto +export namespace solana { + export type CryptoHash = Bytes + + export class Block { + constructor( + public number: u64, + public previous_block: u64, + public genesis_unix_timestamp: u64, + public clock_unix_timestamp: u64, + public root_num: u64, + public transaction_count: u32, + public version: u32, + public id: CryptoHash, + public previous_id: CryptoHash, + public last_entry_hash: CryptoHash, + public transactions: Transaction[], + public account_changes_file_ref: String[], + public has_split_account_changes: bool, + ) { + } + } + + export class Transaction { + constructor( + public index: u64, + public id: CryptoHash, + public additional_signatures: CryptoHash[], + public header: MessageHeader, + public account_keys: CryptoHash[], + public recent_blockhash: CryptoHash, + public log_messages: String[], + public instructions: Instruction[], + public error: TransactionError, + public failed: bool, + ) { + } + } + + export class MessageHeader { + constructor( + public num_required_signatures: u32, + public num_readonly_signed_accounts: u32, + public num_readonly_unsigned_accounts: u32, + ) { + } + } + + export class TransactionError { + constructor( + public error: String + ) { + } + } + + export class Instruction { + constructor( + public ordinal: u32, + public parent_ordinal: u32, + public depth: u32, + public programId: CryptoHash, + public account_keys: CryptoHash[], + public data: CryptoHash, + public balance_changes: BalanceChange[], + public account_changes: AccountChange[], + public error: InstructionError, + public failed: bool, + ) { + //todo: convert programId from base58 to string + } + } + + export class BalanceChange { + constructor( + public public_key: CryptoHash, + public prev_lamports: u64, + public new_laports: u64, + ) { + + } + } + + export class AccountChange { + constructor( + public pub_key: CryptoHash, + public prev_data: CryptoHash, + public new_data: CryptoHash, + public new_data_length: u64, + ) { + } + } + + export class InstructionError { + constructor( + public error: String + ) { + } + } + + export class InstructionWithBlock { + constructor( + public block_num: u64, + public instruction: Instruction, + public block_id: CryptoHash, + public transaction_id: CryptoHash, + ) { + } + } +} \ No newline at end of file diff --git a/index.ts b/index.ts index 438a289..fc1b15e 100644 --- a/index.ts +++ b/index.ts @@ -4,6 +4,8 @@ import './common/eager_offset' export * from './chain/ethereum' // NEAR support export * from './chain/near' +// Solana support +export * from './chain/solana' // Regular re-exports export * from './common/numbers' export * from './common/collections' From a9e8272be1fcd32222174b528df561bdb4d44bda Mon Sep 17 00:00:00 2001 From: billettc Date: Wed, 9 Feb 2022 14:33:07 -0500 Subject: [PATCH 2/2] add logs solana instruction --- chain/solana.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/chain/solana.ts b/chain/solana.ts index 2fb66a5..b4f3fe8 100644 --- a/chain/solana.ts +++ b/chain/solana.ts @@ -67,6 +67,7 @@ export namespace solana { public data: CryptoHash, public balance_changes: BalanceChange[], public account_changes: AccountChange[], + public log_messages: String[], public error: InstructionError, public failed: bool, ) {