diff --git a/.gitignore b/.gitignore index 0390b458..2fdec21a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,23 @@ -/target -/test-ledger +# Solana +test-ledger -yellowstone-grpc-geyser/config-test.json -dump.rdb -*.sw? -.idea/ -.vscode +# Rust +target + +# Node.js +examples/typescript/dist +examples/typescript/node_modules +yellowstone-grpc-client-nodejs/dist +yellowstone-grpc-client-nodejs/node_modules +yellowstone-grpc-client-nodejs/src/grpc + +# Python venv -__pycache__/ \ No newline at end of file +__pycache__/ + +# IDE +.idea +.vscode + +# Configs +yellowstone-grpc-geyser/config-test.json diff --git a/CHANGELOG.md b/CHANGELOG.md index b5d86561..584ae34d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ The minor version will be incremented upon a breaking change and the patch versi - geyser: optimize consuming of new filters ([#439](https://github.com/rpcpool/yellowstone-grpc/pull/439)) - proto: add filter by lamports ([#369](https://github.com/rpcpool/yellowstone-grpc/pull/369)) - geyser: use Arc wrapped messages in block message ([#446](https://github.com/rpcpool/yellowstone-grpc/pull/446)) +- node: remove generated grpc files ([#447](https://github.com/rpcpool/yellowstone-grpc/pull/447)) ### Breaking diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..d2a253a5 --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +clean-nodejs: + rm -rf examples/typescript/dist + rm -rf examples/typescript/node_modules + rm -rf yellowstone-grpc-client-nodejs/dist + rm -rf yellowstone-grpc-client-nodejs/node_modules + rm -rf yellowstone-grpc-client-nodejs/src/grpc diff --git a/examples/typescript/.gitignore b/examples/typescript/.gitignore deleted file mode 100644 index ba012b89..00000000 --- a/examples/typescript/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -node_modules - -# Ignore built files -dist/**/* diff --git a/yellowstone-grpc-client-nodejs/.gitignore b/yellowstone-grpc-client-nodejs/.gitignore deleted file mode 100644 index ba012b89..00000000 --- a/yellowstone-grpc-client-nodejs/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -node_modules - -# Ignore built files -dist/**/* diff --git a/yellowstone-grpc-client-nodejs/package.json b/yellowstone-grpc-client-nodejs/package.json index af1d4e42..67d7748a 100644 --- a/yellowstone-grpc-client-nodejs/package.json +++ b/yellowstone-grpc-client-nodejs/package.json @@ -9,7 +9,7 @@ "scripts": { "build": "npm run grpc-generate && tsc -p .", "fmt": "prettier -w .", - "grpc-generate": "protoc -I../yellowstone-grpc-proto/proto --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_opt=forceLong=string --ts_proto_opt=outputServices=grpc-js --experimental_allow_proto3_optional --ts_proto_out=./src/grpc geyser.proto" + "grpc-generate": "mkdir -p src/grpc && protoc -I../yellowstone-grpc-proto/proto --plugin=node_modules/.bin/protoc-gen-ts_proto --ts_proto_opt=forceLong=string --ts_proto_opt=outputServices=grpc-js --experimental_allow_proto3_optional --ts_proto_out=src/grpc geyser.proto" }, "repository": { "type": "git", diff --git a/yellowstone-grpc-client-nodejs/src/grpc/geyser.ts b/yellowstone-grpc-client-nodejs/src/grpc/geyser.ts deleted file mode 100644 index e975aa93..00000000 --- a/yellowstone-grpc-client-nodejs/src/grpc/geyser.ts +++ /dev/null @@ -1,4648 +0,0 @@ -/* eslint-disable */ -import { - CallOptions, - ChannelCredentials, - Client, - ClientDuplexStream, - ClientOptions, - ClientUnaryCall, - handleBidiStreamingCall, - handleUnaryCall, - makeGenericClientConstructor, - Metadata, - ServiceError, - UntypedServiceImplementation, -} from "@grpc/grpc-js"; -import * as Long from "long"; -import * as _m0 from "protobufjs/minimal"; -import { - BlockHeight, - Rewards, - Transaction, - TransactionError, - TransactionStatusMeta, - UnixTimestamp, -} from "./solana-storage"; - -export const protobufPackage = "geyser"; - -export enum CommitmentLevel { - PROCESSED = 0, - CONFIRMED = 1, - FINALIZED = 2, - UNRECOGNIZED = -1, -} - -export function commitmentLevelFromJSON(object: any): CommitmentLevel { - switch (object) { - case 0: - case "PROCESSED": - return CommitmentLevel.PROCESSED; - case 1: - case "CONFIRMED": - return CommitmentLevel.CONFIRMED; - case 2: - case "FINALIZED": - return CommitmentLevel.FINALIZED; - case -1: - case "UNRECOGNIZED": - default: - return CommitmentLevel.UNRECOGNIZED; - } -} - -export function commitmentLevelToJSON(object: CommitmentLevel): string { - switch (object) { - case CommitmentLevel.PROCESSED: - return "PROCESSED"; - case CommitmentLevel.CONFIRMED: - return "CONFIRMED"; - case CommitmentLevel.FINALIZED: - return "FINALIZED"; - case CommitmentLevel.UNRECOGNIZED: - default: - return "UNRECOGNIZED"; - } -} - -export interface SubscribeRequest { - accounts: { [key: string]: SubscribeRequestFilterAccounts }; - slots: { [key: string]: SubscribeRequestFilterSlots }; - transactions: { [key: string]: SubscribeRequestFilterTransactions }; - transactionsStatus: { [key: string]: SubscribeRequestFilterTransactions }; - blocks: { [key: string]: SubscribeRequestFilterBlocks }; - blocksMeta: { [key: string]: SubscribeRequestFilterBlocksMeta }; - entry: { [key: string]: SubscribeRequestFilterEntry }; - commitment?: CommitmentLevel | undefined; - accountsDataSlice: SubscribeRequestAccountsDataSlice[]; - ping?: SubscribeRequestPing | undefined; -} - -export interface SubscribeRequest_AccountsEntry { - key: string; - value: SubscribeRequestFilterAccounts | undefined; -} - -export interface SubscribeRequest_SlotsEntry { - key: string; - value: SubscribeRequestFilterSlots | undefined; -} - -export interface SubscribeRequest_TransactionsEntry { - key: string; - value: SubscribeRequestFilterTransactions | undefined; -} - -export interface SubscribeRequest_TransactionsStatusEntry { - key: string; - value: SubscribeRequestFilterTransactions | undefined; -} - -export interface SubscribeRequest_BlocksEntry { - key: string; - value: SubscribeRequestFilterBlocks | undefined; -} - -export interface SubscribeRequest_BlocksMetaEntry { - key: string; - value: SubscribeRequestFilterBlocksMeta | undefined; -} - -export interface SubscribeRequest_EntryEntry { - key: string; - value: SubscribeRequestFilterEntry | undefined; -} - -export interface SubscribeRequestFilterAccounts { - account: string[]; - owner: string[]; - filters: SubscribeRequestFilterAccountsFilter[]; -} - -export interface SubscribeRequestFilterAccountsFilter { - memcmp?: SubscribeRequestFilterAccountsFilterMemcmp | undefined; - lamports?: SubscribeRequestFilterAccountsFilterLamports | undefined; - datasize?: string | undefined; - tokenAccountState?: boolean | undefined; -} - -export interface SubscribeRequestFilterAccountsFilterMemcmp { - offset: string; - bytes?: Uint8Array | undefined; - base58?: string | undefined; - base64?: string | undefined; -} - -export interface SubscribeRequestFilterAccountsFilterLamports { - eq?: string | undefined; - ne?: string | undefined; - lt?: string | undefined; - gt?: string | undefined; -} - -export interface SubscribeRequestFilterSlots { - filterByCommitment?: boolean | undefined; -} - -export interface SubscribeRequestFilterTransactions { - vote?: boolean | undefined; - failed?: boolean | undefined; - signature?: string | undefined; - accountInclude: string[]; - accountExclude: string[]; - accountRequired: string[]; -} - -export interface SubscribeRequestFilterBlocks { - accountInclude: string[]; - includeTransactions?: boolean | undefined; - includeAccounts?: boolean | undefined; - includeEntries?: boolean | undefined; -} - -export interface SubscribeRequestFilterBlocksMeta { -} - -export interface SubscribeRequestFilterEntry { -} - -export interface SubscribeRequestAccountsDataSlice { - offset: string; - length: string; -} - -export interface SubscribeRequestPing { - id: number; -} - -export interface SubscribeUpdate { - filters: string[]; - account?: SubscribeUpdateAccount | undefined; - slot?: SubscribeUpdateSlot | undefined; - transaction?: SubscribeUpdateTransaction | undefined; - transactionStatus?: SubscribeUpdateTransactionStatus | undefined; - block?: SubscribeUpdateBlock | undefined; - ping?: SubscribeUpdatePing | undefined; - pong?: SubscribeUpdatePong | undefined; - blockMeta?: SubscribeUpdateBlockMeta | undefined; - entry?: SubscribeUpdateEntry | undefined; -} - -export interface SubscribeUpdateAccount { - account: SubscribeUpdateAccountInfo | undefined; - slot: string; - isStartup: boolean; -} - -export interface SubscribeUpdateAccountInfo { - pubkey: Uint8Array; - lamports: string; - owner: Uint8Array; - executable: boolean; - rentEpoch: string; - data: Uint8Array; - writeVersion: string; - txnSignature?: Uint8Array | undefined; -} - -export interface SubscribeUpdateSlot { - slot: string; - parent?: string | undefined; - status: CommitmentLevel; -} - -export interface SubscribeUpdateTransaction { - transaction: SubscribeUpdateTransactionInfo | undefined; - slot: string; -} - -export interface SubscribeUpdateTransactionInfo { - signature: Uint8Array; - isVote: boolean; - transaction: Transaction | undefined; - meta: TransactionStatusMeta | undefined; - index: string; -} - -export interface SubscribeUpdateTransactionStatus { - slot: string; - signature: Uint8Array; - isVote: boolean; - index: string; - err: TransactionError | undefined; -} - -export interface SubscribeUpdateBlock { - slot: string; - blockhash: string; - rewards: Rewards | undefined; - blockTime: UnixTimestamp | undefined; - blockHeight: BlockHeight | undefined; - parentSlot: string; - parentBlockhash: string; - executedTransactionCount: string; - transactions: SubscribeUpdateTransactionInfo[]; - updatedAccountCount: string; - accounts: SubscribeUpdateAccountInfo[]; - entriesCount: string; - entries: SubscribeUpdateEntry[]; -} - -export interface SubscribeUpdateBlockMeta { - slot: string; - blockhash: string; - rewards: Rewards | undefined; - blockTime: UnixTimestamp | undefined; - blockHeight: BlockHeight | undefined; - parentSlot: string; - parentBlockhash: string; - executedTransactionCount: string; - entriesCount: string; -} - -export interface SubscribeUpdateEntry { - slot: string; - index: string; - numHashes: string; - hash: Uint8Array; - executedTransactionCount: string; - /** added in v1.18, for solana 1.17 value is always 0 */ - startingTransactionIndex: string; -} - -export interface SubscribeUpdatePing { -} - -export interface SubscribeUpdatePong { - id: number; -} - -export interface PingRequest { - count: number; -} - -export interface PongResponse { - count: number; -} - -export interface GetLatestBlockhashRequest { - commitment?: CommitmentLevel | undefined; -} - -export interface GetLatestBlockhashResponse { - slot: string; - blockhash: string; - lastValidBlockHeight: string; -} - -export interface GetBlockHeightRequest { - commitment?: CommitmentLevel | undefined; -} - -export interface GetBlockHeightResponse { - blockHeight: string; -} - -export interface GetSlotRequest { - commitment?: CommitmentLevel | undefined; -} - -export interface GetSlotResponse { - slot: string; -} - -export interface GetVersionRequest { -} - -export interface GetVersionResponse { - version: string; -} - -export interface IsBlockhashValidRequest { - blockhash: string; - commitment?: CommitmentLevel | undefined; -} - -export interface IsBlockhashValidResponse { - slot: string; - valid: boolean; -} - -function createBaseSubscribeRequest(): SubscribeRequest { - return { - accounts: {}, - slots: {}, - transactions: {}, - transactionsStatus: {}, - blocks: {}, - blocksMeta: {}, - entry: {}, - commitment: undefined, - accountsDataSlice: [], - ping: undefined, - }; -} - -export const SubscribeRequest = { - encode(message: SubscribeRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - Object.entries(message.accounts).forEach(([key, value]) => { - SubscribeRequest_AccountsEntry.encode({ key: key as any, value }, writer.uint32(10).fork()).ldelim(); - }); - Object.entries(message.slots).forEach(([key, value]) => { - SubscribeRequest_SlotsEntry.encode({ key: key as any, value }, writer.uint32(18).fork()).ldelim(); - }); - Object.entries(message.transactions).forEach(([key, value]) => { - SubscribeRequest_TransactionsEntry.encode({ key: key as any, value }, writer.uint32(26).fork()).ldelim(); - }); - Object.entries(message.transactionsStatus).forEach(([key, value]) => { - SubscribeRequest_TransactionsStatusEntry.encode({ key: key as any, value }, writer.uint32(82).fork()).ldelim(); - }); - Object.entries(message.blocks).forEach(([key, value]) => { - SubscribeRequest_BlocksEntry.encode({ key: key as any, value }, writer.uint32(34).fork()).ldelim(); - }); - Object.entries(message.blocksMeta).forEach(([key, value]) => { - SubscribeRequest_BlocksMetaEntry.encode({ key: key as any, value }, writer.uint32(42).fork()).ldelim(); - }); - Object.entries(message.entry).forEach(([key, value]) => { - SubscribeRequest_EntryEntry.encode({ key: key as any, value }, writer.uint32(66).fork()).ldelim(); - }); - if (message.commitment !== undefined) { - writer.uint32(48).int32(message.commitment); - } - for (const v of message.accountsDataSlice) { - SubscribeRequestAccountsDataSlice.encode(v!, writer.uint32(58).fork()).ldelim(); - } - if (message.ping !== undefined) { - SubscribeRequestPing.encode(message.ping, writer.uint32(74).fork()).ldelim(); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeRequest { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeRequest(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - const entry1 = SubscribeRequest_AccountsEntry.decode(reader, reader.uint32()); - if (entry1.value !== undefined) { - message.accounts[entry1.key] = entry1.value; - } - continue; - case 2: - if (tag !== 18) { - break; - } - - const entry2 = SubscribeRequest_SlotsEntry.decode(reader, reader.uint32()); - if (entry2.value !== undefined) { - message.slots[entry2.key] = entry2.value; - } - continue; - case 3: - if (tag !== 26) { - break; - } - - const entry3 = SubscribeRequest_TransactionsEntry.decode(reader, reader.uint32()); - if (entry3.value !== undefined) { - message.transactions[entry3.key] = entry3.value; - } - continue; - case 10: - if (tag !== 82) { - break; - } - - const entry10 = SubscribeRequest_TransactionsStatusEntry.decode(reader, reader.uint32()); - if (entry10.value !== undefined) { - message.transactionsStatus[entry10.key] = entry10.value; - } - continue; - case 4: - if (tag !== 34) { - break; - } - - const entry4 = SubscribeRequest_BlocksEntry.decode(reader, reader.uint32()); - if (entry4.value !== undefined) { - message.blocks[entry4.key] = entry4.value; - } - continue; - case 5: - if (tag !== 42) { - break; - } - - const entry5 = SubscribeRequest_BlocksMetaEntry.decode(reader, reader.uint32()); - if (entry5.value !== undefined) { - message.blocksMeta[entry5.key] = entry5.value; - } - continue; - case 8: - if (tag !== 66) { - break; - } - - const entry8 = SubscribeRequest_EntryEntry.decode(reader, reader.uint32()); - if (entry8.value !== undefined) { - message.entry[entry8.key] = entry8.value; - } - continue; - case 6: - if (tag !== 48) { - break; - } - - message.commitment = reader.int32() as any; - continue; - case 7: - if (tag !== 58) { - break; - } - - message.accountsDataSlice.push(SubscribeRequestAccountsDataSlice.decode(reader, reader.uint32())); - continue; - case 9: - if (tag !== 74) { - break; - } - - message.ping = SubscribeRequestPing.decode(reader, reader.uint32()); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): SubscribeRequest { - return { - accounts: isObject(object.accounts) - ? Object.entries(object.accounts).reduce<{ [key: string]: SubscribeRequestFilterAccounts }>( - (acc, [key, value]) => { - acc[key] = SubscribeRequestFilterAccounts.fromJSON(value); - return acc; - }, - {}, - ) - : {}, - slots: isObject(object.slots) - ? Object.entries(object.slots).reduce<{ [key: string]: SubscribeRequestFilterSlots }>((acc, [key, value]) => { - acc[key] = SubscribeRequestFilterSlots.fromJSON(value); - return acc; - }, {}) - : {}, - transactions: isObject(object.transactions) - ? Object.entries(object.transactions).reduce<{ [key: string]: SubscribeRequestFilterTransactions }>( - (acc, [key, value]) => { - acc[key] = SubscribeRequestFilterTransactions.fromJSON(value); - return acc; - }, - {}, - ) - : {}, - transactionsStatus: isObject(object.transactionsStatus) - ? Object.entries(object.transactionsStatus).reduce<{ [key: string]: SubscribeRequestFilterTransactions }>( - (acc, [key, value]) => { - acc[key] = SubscribeRequestFilterTransactions.fromJSON(value); - return acc; - }, - {}, - ) - : {}, - blocks: isObject(object.blocks) - ? Object.entries(object.blocks).reduce<{ [key: string]: SubscribeRequestFilterBlocks }>((acc, [key, value]) => { - acc[key] = SubscribeRequestFilterBlocks.fromJSON(value); - return acc; - }, {}) - : {}, - blocksMeta: isObject(object.blocksMeta) - ? Object.entries(object.blocksMeta).reduce<{ [key: string]: SubscribeRequestFilterBlocksMeta }>( - (acc, [key, value]) => { - acc[key] = SubscribeRequestFilterBlocksMeta.fromJSON(value); - return acc; - }, - {}, - ) - : {}, - entry: isObject(object.entry) - ? Object.entries(object.entry).reduce<{ [key: string]: SubscribeRequestFilterEntry }>((acc, [key, value]) => { - acc[key] = SubscribeRequestFilterEntry.fromJSON(value); - return acc; - }, {}) - : {}, - commitment: isSet(object.commitment) ? commitmentLevelFromJSON(object.commitment) : undefined, - accountsDataSlice: Array.isArray(object?.accountsDataSlice) - ? object.accountsDataSlice.map((e: any) => SubscribeRequestAccountsDataSlice.fromJSON(e)) - : [], - ping: isSet(object.ping) ? SubscribeRequestPing.fromJSON(object.ping) : undefined, - }; - }, - - toJSON(message: SubscribeRequest): unknown { - const obj: any = {}; - obj.accounts = {}; - if (message.accounts) { - Object.entries(message.accounts).forEach(([k, v]) => { - obj.accounts[k] = SubscribeRequestFilterAccounts.toJSON(v); - }); - } - obj.slots = {}; - if (message.slots) { - Object.entries(message.slots).forEach(([k, v]) => { - obj.slots[k] = SubscribeRequestFilterSlots.toJSON(v); - }); - } - obj.transactions = {}; - if (message.transactions) { - Object.entries(message.transactions).forEach(([k, v]) => { - obj.transactions[k] = SubscribeRequestFilterTransactions.toJSON(v); - }); - } - obj.transactionsStatus = {}; - if (message.transactionsStatus) { - Object.entries(message.transactionsStatus).forEach(([k, v]) => { - obj.transactionsStatus[k] = SubscribeRequestFilterTransactions.toJSON(v); - }); - } - obj.blocks = {}; - if (message.blocks) { - Object.entries(message.blocks).forEach(([k, v]) => { - obj.blocks[k] = SubscribeRequestFilterBlocks.toJSON(v); - }); - } - obj.blocksMeta = {}; - if (message.blocksMeta) { - Object.entries(message.blocksMeta).forEach(([k, v]) => { - obj.blocksMeta[k] = SubscribeRequestFilterBlocksMeta.toJSON(v); - }); - } - obj.entry = {}; - if (message.entry) { - Object.entries(message.entry).forEach(([k, v]) => { - obj.entry[k] = SubscribeRequestFilterEntry.toJSON(v); - }); - } - message.commitment !== undefined && - (obj.commitment = message.commitment !== undefined ? commitmentLevelToJSON(message.commitment) : undefined); - if (message.accountsDataSlice) { - obj.accountsDataSlice = message.accountsDataSlice.map((e) => - e ? SubscribeRequestAccountsDataSlice.toJSON(e) : undefined - ); - } else { - obj.accountsDataSlice = []; - } - message.ping !== undefined && (obj.ping = message.ping ? SubscribeRequestPing.toJSON(message.ping) : undefined); - return obj; - }, - - create, I>>(base?: I): SubscribeRequest { - return SubscribeRequest.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): SubscribeRequest { - const message = createBaseSubscribeRequest(); - message.accounts = Object.entries(object.accounts ?? {}).reduce<{ [key: string]: SubscribeRequestFilterAccounts }>( - (acc, [key, value]) => { - if (value !== undefined) { - acc[key] = SubscribeRequestFilterAccounts.fromPartial(value); - } - return acc; - }, - {}, - ); - message.slots = Object.entries(object.slots ?? {}).reduce<{ [key: string]: SubscribeRequestFilterSlots }>( - (acc, [key, value]) => { - if (value !== undefined) { - acc[key] = SubscribeRequestFilterSlots.fromPartial(value); - } - return acc; - }, - {}, - ); - message.transactions = Object.entries(object.transactions ?? {}).reduce< - { [key: string]: SubscribeRequestFilterTransactions } - >((acc, [key, value]) => { - if (value !== undefined) { - acc[key] = SubscribeRequestFilterTransactions.fromPartial(value); - } - return acc; - }, {}); - message.transactionsStatus = Object.entries(object.transactionsStatus ?? {}).reduce< - { [key: string]: SubscribeRequestFilterTransactions } - >((acc, [key, value]) => { - if (value !== undefined) { - acc[key] = SubscribeRequestFilterTransactions.fromPartial(value); - } - return acc; - }, {}); - message.blocks = Object.entries(object.blocks ?? {}).reduce<{ [key: string]: SubscribeRequestFilterBlocks }>( - (acc, [key, value]) => { - if (value !== undefined) { - acc[key] = SubscribeRequestFilterBlocks.fromPartial(value); - } - return acc; - }, - {}, - ); - message.blocksMeta = Object.entries(object.blocksMeta ?? {}).reduce< - { [key: string]: SubscribeRequestFilterBlocksMeta } - >((acc, [key, value]) => { - if (value !== undefined) { - acc[key] = SubscribeRequestFilterBlocksMeta.fromPartial(value); - } - return acc; - }, {}); - message.entry = Object.entries(object.entry ?? {}).reduce<{ [key: string]: SubscribeRequestFilterEntry }>( - (acc, [key, value]) => { - if (value !== undefined) { - acc[key] = SubscribeRequestFilterEntry.fromPartial(value); - } - return acc; - }, - {}, - ); - message.commitment = object.commitment ?? undefined; - message.accountsDataSlice = - object.accountsDataSlice?.map((e) => SubscribeRequestAccountsDataSlice.fromPartial(e)) || []; - message.ping = (object.ping !== undefined && object.ping !== null) - ? SubscribeRequestPing.fromPartial(object.ping) - : undefined; - return message; - }, -}; - -function createBaseSubscribeRequest_AccountsEntry(): SubscribeRequest_AccountsEntry { - return { key: "", value: undefined }; -} - -export const SubscribeRequest_AccountsEntry = { - encode(message: SubscribeRequest_AccountsEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== "") { - writer.uint32(10).string(message.key); - } - if (message.value !== undefined) { - SubscribeRequestFilterAccounts.encode(message.value, writer.uint32(18).fork()).ldelim(); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeRequest_AccountsEntry { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeRequest_AccountsEntry(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.key = reader.string(); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.value = SubscribeRequestFilterAccounts.decode(reader, reader.uint32()); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): SubscribeRequest_AccountsEntry { - return { - key: isSet(object.key) ? String(object.key) : "", - value: isSet(object.value) ? SubscribeRequestFilterAccounts.fromJSON(object.value) : undefined, - }; - }, - - toJSON(message: SubscribeRequest_AccountsEntry): unknown { - const obj: any = {}; - message.key !== undefined && (obj.key = message.key); - message.value !== undefined && - (obj.value = message.value ? SubscribeRequestFilterAccounts.toJSON(message.value) : undefined); - return obj; - }, - - create, I>>(base?: I): SubscribeRequest_AccountsEntry { - return SubscribeRequest_AccountsEntry.fromPartial(base ?? {}); - }, - - fromPartial, I>>( - object: I, - ): SubscribeRequest_AccountsEntry { - const message = createBaseSubscribeRequest_AccountsEntry(); - message.key = object.key ?? ""; - message.value = (object.value !== undefined && object.value !== null) - ? SubscribeRequestFilterAccounts.fromPartial(object.value) - : undefined; - return message; - }, -}; - -function createBaseSubscribeRequest_SlotsEntry(): SubscribeRequest_SlotsEntry { - return { key: "", value: undefined }; -} - -export const SubscribeRequest_SlotsEntry = { - encode(message: SubscribeRequest_SlotsEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== "") { - writer.uint32(10).string(message.key); - } - if (message.value !== undefined) { - SubscribeRequestFilterSlots.encode(message.value, writer.uint32(18).fork()).ldelim(); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeRequest_SlotsEntry { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeRequest_SlotsEntry(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.key = reader.string(); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.value = SubscribeRequestFilterSlots.decode(reader, reader.uint32()); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): SubscribeRequest_SlotsEntry { - return { - key: isSet(object.key) ? String(object.key) : "", - value: isSet(object.value) ? SubscribeRequestFilterSlots.fromJSON(object.value) : undefined, - }; - }, - - toJSON(message: SubscribeRequest_SlotsEntry): unknown { - const obj: any = {}; - message.key !== undefined && (obj.key = message.key); - message.value !== undefined && - (obj.value = message.value ? SubscribeRequestFilterSlots.toJSON(message.value) : undefined); - return obj; - }, - - create, I>>(base?: I): SubscribeRequest_SlotsEntry { - return SubscribeRequest_SlotsEntry.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): SubscribeRequest_SlotsEntry { - const message = createBaseSubscribeRequest_SlotsEntry(); - message.key = object.key ?? ""; - message.value = (object.value !== undefined && object.value !== null) - ? SubscribeRequestFilterSlots.fromPartial(object.value) - : undefined; - return message; - }, -}; - -function createBaseSubscribeRequest_TransactionsEntry(): SubscribeRequest_TransactionsEntry { - return { key: "", value: undefined }; -} - -export const SubscribeRequest_TransactionsEntry = { - encode(message: SubscribeRequest_TransactionsEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== "") { - writer.uint32(10).string(message.key); - } - if (message.value !== undefined) { - SubscribeRequestFilterTransactions.encode(message.value, writer.uint32(18).fork()).ldelim(); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeRequest_TransactionsEntry { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeRequest_TransactionsEntry(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.key = reader.string(); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.value = SubscribeRequestFilterTransactions.decode(reader, reader.uint32()); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): SubscribeRequest_TransactionsEntry { - return { - key: isSet(object.key) ? String(object.key) : "", - value: isSet(object.value) ? SubscribeRequestFilterTransactions.fromJSON(object.value) : undefined, - }; - }, - - toJSON(message: SubscribeRequest_TransactionsEntry): unknown { - const obj: any = {}; - message.key !== undefined && (obj.key = message.key); - message.value !== undefined && - (obj.value = message.value ? SubscribeRequestFilterTransactions.toJSON(message.value) : undefined); - return obj; - }, - - create, I>>( - base?: I, - ): SubscribeRequest_TransactionsEntry { - return SubscribeRequest_TransactionsEntry.fromPartial(base ?? {}); - }, - - fromPartial, I>>( - object: I, - ): SubscribeRequest_TransactionsEntry { - const message = createBaseSubscribeRequest_TransactionsEntry(); - message.key = object.key ?? ""; - message.value = (object.value !== undefined && object.value !== null) - ? SubscribeRequestFilterTransactions.fromPartial(object.value) - : undefined; - return message; - }, -}; - -function createBaseSubscribeRequest_TransactionsStatusEntry(): SubscribeRequest_TransactionsStatusEntry { - return { key: "", value: undefined }; -} - -export const SubscribeRequest_TransactionsStatusEntry = { - encode(message: SubscribeRequest_TransactionsStatusEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== "") { - writer.uint32(10).string(message.key); - } - if (message.value !== undefined) { - SubscribeRequestFilterTransactions.encode(message.value, writer.uint32(18).fork()).ldelim(); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeRequest_TransactionsStatusEntry { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeRequest_TransactionsStatusEntry(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.key = reader.string(); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.value = SubscribeRequestFilterTransactions.decode(reader, reader.uint32()); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): SubscribeRequest_TransactionsStatusEntry { - return { - key: isSet(object.key) ? String(object.key) : "", - value: isSet(object.value) ? SubscribeRequestFilterTransactions.fromJSON(object.value) : undefined, - }; - }, - - toJSON(message: SubscribeRequest_TransactionsStatusEntry): unknown { - const obj: any = {}; - message.key !== undefined && (obj.key = message.key); - message.value !== undefined && - (obj.value = message.value ? SubscribeRequestFilterTransactions.toJSON(message.value) : undefined); - return obj; - }, - - create, I>>( - base?: I, - ): SubscribeRequest_TransactionsStatusEntry { - return SubscribeRequest_TransactionsStatusEntry.fromPartial(base ?? {}); - }, - - fromPartial, I>>( - object: I, - ): SubscribeRequest_TransactionsStatusEntry { - const message = createBaseSubscribeRequest_TransactionsStatusEntry(); - message.key = object.key ?? ""; - message.value = (object.value !== undefined && object.value !== null) - ? SubscribeRequestFilterTransactions.fromPartial(object.value) - : undefined; - return message; - }, -}; - -function createBaseSubscribeRequest_BlocksEntry(): SubscribeRequest_BlocksEntry { - return { key: "", value: undefined }; -} - -export const SubscribeRequest_BlocksEntry = { - encode(message: SubscribeRequest_BlocksEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== "") { - writer.uint32(10).string(message.key); - } - if (message.value !== undefined) { - SubscribeRequestFilterBlocks.encode(message.value, writer.uint32(18).fork()).ldelim(); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeRequest_BlocksEntry { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeRequest_BlocksEntry(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.key = reader.string(); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.value = SubscribeRequestFilterBlocks.decode(reader, reader.uint32()); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): SubscribeRequest_BlocksEntry { - return { - key: isSet(object.key) ? String(object.key) : "", - value: isSet(object.value) ? SubscribeRequestFilterBlocks.fromJSON(object.value) : undefined, - }; - }, - - toJSON(message: SubscribeRequest_BlocksEntry): unknown { - const obj: any = {}; - message.key !== undefined && (obj.key = message.key); - message.value !== undefined && - (obj.value = message.value ? SubscribeRequestFilterBlocks.toJSON(message.value) : undefined); - return obj; - }, - - create, I>>(base?: I): SubscribeRequest_BlocksEntry { - return SubscribeRequest_BlocksEntry.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): SubscribeRequest_BlocksEntry { - const message = createBaseSubscribeRequest_BlocksEntry(); - message.key = object.key ?? ""; - message.value = (object.value !== undefined && object.value !== null) - ? SubscribeRequestFilterBlocks.fromPartial(object.value) - : undefined; - return message; - }, -}; - -function createBaseSubscribeRequest_BlocksMetaEntry(): SubscribeRequest_BlocksMetaEntry { - return { key: "", value: undefined }; -} - -export const SubscribeRequest_BlocksMetaEntry = { - encode(message: SubscribeRequest_BlocksMetaEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== "") { - writer.uint32(10).string(message.key); - } - if (message.value !== undefined) { - SubscribeRequestFilterBlocksMeta.encode(message.value, writer.uint32(18).fork()).ldelim(); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeRequest_BlocksMetaEntry { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeRequest_BlocksMetaEntry(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.key = reader.string(); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.value = SubscribeRequestFilterBlocksMeta.decode(reader, reader.uint32()); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): SubscribeRequest_BlocksMetaEntry { - return { - key: isSet(object.key) ? String(object.key) : "", - value: isSet(object.value) ? SubscribeRequestFilterBlocksMeta.fromJSON(object.value) : undefined, - }; - }, - - toJSON(message: SubscribeRequest_BlocksMetaEntry): unknown { - const obj: any = {}; - message.key !== undefined && (obj.key = message.key); - message.value !== undefined && - (obj.value = message.value ? SubscribeRequestFilterBlocksMeta.toJSON(message.value) : undefined); - return obj; - }, - - create, I>>( - base?: I, - ): SubscribeRequest_BlocksMetaEntry { - return SubscribeRequest_BlocksMetaEntry.fromPartial(base ?? {}); - }, - - fromPartial, I>>( - object: I, - ): SubscribeRequest_BlocksMetaEntry { - const message = createBaseSubscribeRequest_BlocksMetaEntry(); - message.key = object.key ?? ""; - message.value = (object.value !== undefined && object.value !== null) - ? SubscribeRequestFilterBlocksMeta.fromPartial(object.value) - : undefined; - return message; - }, -}; - -function createBaseSubscribeRequest_EntryEntry(): SubscribeRequest_EntryEntry { - return { key: "", value: undefined }; -} - -export const SubscribeRequest_EntryEntry = { - encode(message: SubscribeRequest_EntryEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== "") { - writer.uint32(10).string(message.key); - } - if (message.value !== undefined) { - SubscribeRequestFilterEntry.encode(message.value, writer.uint32(18).fork()).ldelim(); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeRequest_EntryEntry { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeRequest_EntryEntry(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.key = reader.string(); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.value = SubscribeRequestFilterEntry.decode(reader, reader.uint32()); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): SubscribeRequest_EntryEntry { - return { - key: isSet(object.key) ? String(object.key) : "", - value: isSet(object.value) ? SubscribeRequestFilterEntry.fromJSON(object.value) : undefined, - }; - }, - - toJSON(message: SubscribeRequest_EntryEntry): unknown { - const obj: any = {}; - message.key !== undefined && (obj.key = message.key); - message.value !== undefined && - (obj.value = message.value ? SubscribeRequestFilterEntry.toJSON(message.value) : undefined); - return obj; - }, - - create, I>>(base?: I): SubscribeRequest_EntryEntry { - return SubscribeRequest_EntryEntry.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): SubscribeRequest_EntryEntry { - const message = createBaseSubscribeRequest_EntryEntry(); - message.key = object.key ?? ""; - message.value = (object.value !== undefined && object.value !== null) - ? SubscribeRequestFilterEntry.fromPartial(object.value) - : undefined; - return message; - }, -}; - -function createBaseSubscribeRequestFilterAccounts(): SubscribeRequestFilterAccounts { - return { account: [], owner: [], filters: [] }; -} - -export const SubscribeRequestFilterAccounts = { - encode(message: SubscribeRequestFilterAccounts, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - for (const v of message.account) { - writer.uint32(18).string(v!); - } - for (const v of message.owner) { - writer.uint32(26).string(v!); - } - for (const v of message.filters) { - SubscribeRequestFilterAccountsFilter.encode(v!, writer.uint32(34).fork()).ldelim(); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeRequestFilterAccounts { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeRequestFilterAccounts(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 2: - if (tag !== 18) { - break; - } - - message.account.push(reader.string()); - continue; - case 3: - if (tag !== 26) { - break; - } - - message.owner.push(reader.string()); - continue; - case 4: - if (tag !== 34) { - break; - } - - message.filters.push(SubscribeRequestFilterAccountsFilter.decode(reader, reader.uint32())); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): SubscribeRequestFilterAccounts { - return { - account: Array.isArray(object?.account) ? object.account.map((e: any) => String(e)) : [], - owner: Array.isArray(object?.owner) ? object.owner.map((e: any) => String(e)) : [], - filters: Array.isArray(object?.filters) - ? object.filters.map((e: any) => SubscribeRequestFilterAccountsFilter.fromJSON(e)) - : [], - }; - }, - - toJSON(message: SubscribeRequestFilterAccounts): unknown { - const obj: any = {}; - if (message.account) { - obj.account = message.account.map((e) => e); - } else { - obj.account = []; - } - if (message.owner) { - obj.owner = message.owner.map((e) => e); - } else { - obj.owner = []; - } - if (message.filters) { - obj.filters = message.filters.map((e) => e ? SubscribeRequestFilterAccountsFilter.toJSON(e) : undefined); - } else { - obj.filters = []; - } - return obj; - }, - - create, I>>(base?: I): SubscribeRequestFilterAccounts { - return SubscribeRequestFilterAccounts.fromPartial(base ?? {}); - }, - - fromPartial, I>>( - object: I, - ): SubscribeRequestFilterAccounts { - const message = createBaseSubscribeRequestFilterAccounts(); - message.account = object.account?.map((e) => e) || []; - message.owner = object.owner?.map((e) => e) || []; - message.filters = object.filters?.map((e) => SubscribeRequestFilterAccountsFilter.fromPartial(e)) || []; - return message; - }, -}; - -function createBaseSubscribeRequestFilterAccountsFilter(): SubscribeRequestFilterAccountsFilter { - return { memcmp: undefined, lamports: undefined, datasize: undefined, tokenAccountState: undefined }; -} - -export const SubscribeRequestFilterAccountsFilter = { - encode(message: SubscribeRequestFilterAccountsFilter, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.memcmp !== undefined) { - SubscribeRequestFilterAccountsFilterMemcmp.encode(message.memcmp, writer.uint32(10).fork()).ldelim(); - } - if (message.lamports !== undefined) { - SubscribeRequestFilterAccountsFilterLamports.encode(message.lamports, writer.uint32(34).fork()).ldelim(); - } - if (message.datasize !== undefined) { - writer.uint32(16).uint64(message.datasize); - } - if (message.tokenAccountState !== undefined) { - writer.uint32(24).bool(message.tokenAccountState); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeRequestFilterAccountsFilter { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeRequestFilterAccountsFilter(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.memcmp = SubscribeRequestFilterAccountsFilterMemcmp.decode(reader, reader.uint32()); - continue; - case 4: - if (tag !== 34) { - break; - } - - message.lamports = SubscribeRequestFilterAccountsFilterLamports.decode(reader, reader.uint32()); - continue; - case 2: - if (tag !== 16) { - break; - } - - message.datasize = longToString(reader.uint64() as Long); - continue; - case 3: - if (tag !== 24) { - break; - } - - message.tokenAccountState = reader.bool(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): SubscribeRequestFilterAccountsFilter { - return { - memcmp: isSet(object.memcmp) ? SubscribeRequestFilterAccountsFilterMemcmp.fromJSON(object.memcmp) : undefined, - lamports: isSet(object.lamports) - ? SubscribeRequestFilterAccountsFilterLamports.fromJSON(object.lamports) - : undefined, - datasize: isSet(object.datasize) ? String(object.datasize) : undefined, - tokenAccountState: isSet(object.tokenAccountState) ? Boolean(object.tokenAccountState) : undefined, - }; - }, - - toJSON(message: SubscribeRequestFilterAccountsFilter): unknown { - const obj: any = {}; - message.memcmp !== undefined && - (obj.memcmp = message.memcmp ? SubscribeRequestFilterAccountsFilterMemcmp.toJSON(message.memcmp) : undefined); - message.lamports !== undefined && (obj.lamports = message.lamports - ? SubscribeRequestFilterAccountsFilterLamports.toJSON(message.lamports) - : undefined); - message.datasize !== undefined && (obj.datasize = message.datasize); - message.tokenAccountState !== undefined && (obj.tokenAccountState = message.tokenAccountState); - return obj; - }, - - create, I>>( - base?: I, - ): SubscribeRequestFilterAccountsFilter { - return SubscribeRequestFilterAccountsFilter.fromPartial(base ?? {}); - }, - - fromPartial, I>>( - object: I, - ): SubscribeRequestFilterAccountsFilter { - const message = createBaseSubscribeRequestFilterAccountsFilter(); - message.memcmp = (object.memcmp !== undefined && object.memcmp !== null) - ? SubscribeRequestFilterAccountsFilterMemcmp.fromPartial(object.memcmp) - : undefined; - message.lamports = (object.lamports !== undefined && object.lamports !== null) - ? SubscribeRequestFilterAccountsFilterLamports.fromPartial(object.lamports) - : undefined; - message.datasize = object.datasize ?? undefined; - message.tokenAccountState = object.tokenAccountState ?? undefined; - return message; - }, -}; - -function createBaseSubscribeRequestFilterAccountsFilterMemcmp(): SubscribeRequestFilterAccountsFilterMemcmp { - return { offset: "0", bytes: undefined, base58: undefined, base64: undefined }; -} - -export const SubscribeRequestFilterAccountsFilterMemcmp = { - encode(message: SubscribeRequestFilterAccountsFilterMemcmp, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.offset !== "0") { - writer.uint32(8).uint64(message.offset); - } - if (message.bytes !== undefined) { - writer.uint32(18).bytes(message.bytes); - } - if (message.base58 !== undefined) { - writer.uint32(26).string(message.base58); - } - if (message.base64 !== undefined) { - writer.uint32(34).string(message.base64); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeRequestFilterAccountsFilterMemcmp { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeRequestFilterAccountsFilterMemcmp(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.offset = longToString(reader.uint64() as Long); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.bytes = reader.bytes(); - continue; - case 3: - if (tag !== 26) { - break; - } - - message.base58 = reader.string(); - continue; - case 4: - if (tag !== 34) { - break; - } - - message.base64 = reader.string(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): SubscribeRequestFilterAccountsFilterMemcmp { - return { - offset: isSet(object.offset) ? String(object.offset) : "0", - bytes: isSet(object.bytes) ? bytesFromBase64(object.bytes) : undefined, - base58: isSet(object.base58) ? String(object.base58) : undefined, - base64: isSet(object.base64) ? String(object.base64) : undefined, - }; - }, - - toJSON(message: SubscribeRequestFilterAccountsFilterMemcmp): unknown { - const obj: any = {}; - message.offset !== undefined && (obj.offset = message.offset); - message.bytes !== undefined && - (obj.bytes = message.bytes !== undefined ? base64FromBytes(message.bytes) : undefined); - message.base58 !== undefined && (obj.base58 = message.base58); - message.base64 !== undefined && (obj.base64 = message.base64); - return obj; - }, - - create, I>>( - base?: I, - ): SubscribeRequestFilterAccountsFilterMemcmp { - return SubscribeRequestFilterAccountsFilterMemcmp.fromPartial(base ?? {}); - }, - - fromPartial, I>>( - object: I, - ): SubscribeRequestFilterAccountsFilterMemcmp { - const message = createBaseSubscribeRequestFilterAccountsFilterMemcmp(); - message.offset = object.offset ?? "0"; - message.bytes = object.bytes ?? undefined; - message.base58 = object.base58 ?? undefined; - message.base64 = object.base64 ?? undefined; - return message; - }, -}; - -function createBaseSubscribeRequestFilterAccountsFilterLamports(): SubscribeRequestFilterAccountsFilterLamports { - return { eq: undefined, ne: undefined, lt: undefined, gt: undefined }; -} - -export const SubscribeRequestFilterAccountsFilterLamports = { - encode(message: SubscribeRequestFilterAccountsFilterLamports, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.eq !== undefined) { - writer.uint32(8).uint64(message.eq); - } - if (message.ne !== undefined) { - writer.uint32(16).uint64(message.ne); - } - if (message.lt !== undefined) { - writer.uint32(24).uint64(message.lt); - } - if (message.gt !== undefined) { - writer.uint32(32).uint64(message.gt); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeRequestFilterAccountsFilterLamports { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeRequestFilterAccountsFilterLamports(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.eq = longToString(reader.uint64() as Long); - continue; - case 2: - if (tag !== 16) { - break; - } - - message.ne = longToString(reader.uint64() as Long); - continue; - case 3: - if (tag !== 24) { - break; - } - - message.lt = longToString(reader.uint64() as Long); - continue; - case 4: - if (tag !== 32) { - break; - } - - message.gt = longToString(reader.uint64() as Long); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): SubscribeRequestFilterAccountsFilterLamports { - return { - eq: isSet(object.eq) ? String(object.eq) : undefined, - ne: isSet(object.ne) ? String(object.ne) : undefined, - lt: isSet(object.lt) ? String(object.lt) : undefined, - gt: isSet(object.gt) ? String(object.gt) : undefined, - }; - }, - - toJSON(message: SubscribeRequestFilterAccountsFilterLamports): unknown { - const obj: any = {}; - message.eq !== undefined && (obj.eq = message.eq); - message.ne !== undefined && (obj.ne = message.ne); - message.lt !== undefined && (obj.lt = message.lt); - message.gt !== undefined && (obj.gt = message.gt); - return obj; - }, - - create, I>>( - base?: I, - ): SubscribeRequestFilterAccountsFilterLamports { - return SubscribeRequestFilterAccountsFilterLamports.fromPartial(base ?? {}); - }, - - fromPartial, I>>( - object: I, - ): SubscribeRequestFilterAccountsFilterLamports { - const message = createBaseSubscribeRequestFilterAccountsFilterLamports(); - message.eq = object.eq ?? undefined; - message.ne = object.ne ?? undefined; - message.lt = object.lt ?? undefined; - message.gt = object.gt ?? undefined; - return message; - }, -}; - -function createBaseSubscribeRequestFilterSlots(): SubscribeRequestFilterSlots { - return { filterByCommitment: undefined }; -} - -export const SubscribeRequestFilterSlots = { - encode(message: SubscribeRequestFilterSlots, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.filterByCommitment !== undefined) { - writer.uint32(8).bool(message.filterByCommitment); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeRequestFilterSlots { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeRequestFilterSlots(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.filterByCommitment = reader.bool(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): SubscribeRequestFilterSlots { - return { filterByCommitment: isSet(object.filterByCommitment) ? Boolean(object.filterByCommitment) : undefined }; - }, - - toJSON(message: SubscribeRequestFilterSlots): unknown { - const obj: any = {}; - message.filterByCommitment !== undefined && (obj.filterByCommitment = message.filterByCommitment); - return obj; - }, - - create, I>>(base?: I): SubscribeRequestFilterSlots { - return SubscribeRequestFilterSlots.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): SubscribeRequestFilterSlots { - const message = createBaseSubscribeRequestFilterSlots(); - message.filterByCommitment = object.filterByCommitment ?? undefined; - return message; - }, -}; - -function createBaseSubscribeRequestFilterTransactions(): SubscribeRequestFilterTransactions { - return { - vote: undefined, - failed: undefined, - signature: undefined, - accountInclude: [], - accountExclude: [], - accountRequired: [], - }; -} - -export const SubscribeRequestFilterTransactions = { - encode(message: SubscribeRequestFilterTransactions, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.vote !== undefined) { - writer.uint32(8).bool(message.vote); - } - if (message.failed !== undefined) { - writer.uint32(16).bool(message.failed); - } - if (message.signature !== undefined) { - writer.uint32(42).string(message.signature); - } - for (const v of message.accountInclude) { - writer.uint32(26).string(v!); - } - for (const v of message.accountExclude) { - writer.uint32(34).string(v!); - } - for (const v of message.accountRequired) { - writer.uint32(50).string(v!); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeRequestFilterTransactions { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeRequestFilterTransactions(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.vote = reader.bool(); - continue; - case 2: - if (tag !== 16) { - break; - } - - message.failed = reader.bool(); - continue; - case 5: - if (tag !== 42) { - break; - } - - message.signature = reader.string(); - continue; - case 3: - if (tag !== 26) { - break; - } - - message.accountInclude.push(reader.string()); - continue; - case 4: - if (tag !== 34) { - break; - } - - message.accountExclude.push(reader.string()); - continue; - case 6: - if (tag !== 50) { - break; - } - - message.accountRequired.push(reader.string()); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): SubscribeRequestFilterTransactions { - return { - vote: isSet(object.vote) ? Boolean(object.vote) : undefined, - failed: isSet(object.failed) ? Boolean(object.failed) : undefined, - signature: isSet(object.signature) ? String(object.signature) : undefined, - accountInclude: Array.isArray(object?.accountInclude) ? object.accountInclude.map((e: any) => String(e)) : [], - accountExclude: Array.isArray(object?.accountExclude) ? object.accountExclude.map((e: any) => String(e)) : [], - accountRequired: Array.isArray(object?.accountRequired) ? object.accountRequired.map((e: any) => String(e)) : [], - }; - }, - - toJSON(message: SubscribeRequestFilterTransactions): unknown { - const obj: any = {}; - message.vote !== undefined && (obj.vote = message.vote); - message.failed !== undefined && (obj.failed = message.failed); - message.signature !== undefined && (obj.signature = message.signature); - if (message.accountInclude) { - obj.accountInclude = message.accountInclude.map((e) => e); - } else { - obj.accountInclude = []; - } - if (message.accountExclude) { - obj.accountExclude = message.accountExclude.map((e) => e); - } else { - obj.accountExclude = []; - } - if (message.accountRequired) { - obj.accountRequired = message.accountRequired.map((e) => e); - } else { - obj.accountRequired = []; - } - return obj; - }, - - create, I>>( - base?: I, - ): SubscribeRequestFilterTransactions { - return SubscribeRequestFilterTransactions.fromPartial(base ?? {}); - }, - - fromPartial, I>>( - object: I, - ): SubscribeRequestFilterTransactions { - const message = createBaseSubscribeRequestFilterTransactions(); - message.vote = object.vote ?? undefined; - message.failed = object.failed ?? undefined; - message.signature = object.signature ?? undefined; - message.accountInclude = object.accountInclude?.map((e) => e) || []; - message.accountExclude = object.accountExclude?.map((e) => e) || []; - message.accountRequired = object.accountRequired?.map((e) => e) || []; - return message; - }, -}; - -function createBaseSubscribeRequestFilterBlocks(): SubscribeRequestFilterBlocks { - return { accountInclude: [], includeTransactions: undefined, includeAccounts: undefined, includeEntries: undefined }; -} - -export const SubscribeRequestFilterBlocks = { - encode(message: SubscribeRequestFilterBlocks, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - for (const v of message.accountInclude) { - writer.uint32(10).string(v!); - } - if (message.includeTransactions !== undefined) { - writer.uint32(16).bool(message.includeTransactions); - } - if (message.includeAccounts !== undefined) { - writer.uint32(24).bool(message.includeAccounts); - } - if (message.includeEntries !== undefined) { - writer.uint32(32).bool(message.includeEntries); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeRequestFilterBlocks { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeRequestFilterBlocks(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.accountInclude.push(reader.string()); - continue; - case 2: - if (tag !== 16) { - break; - } - - message.includeTransactions = reader.bool(); - continue; - case 3: - if (tag !== 24) { - break; - } - - message.includeAccounts = reader.bool(); - continue; - case 4: - if (tag !== 32) { - break; - } - - message.includeEntries = reader.bool(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): SubscribeRequestFilterBlocks { - return { - accountInclude: Array.isArray(object?.accountInclude) ? object.accountInclude.map((e: any) => String(e)) : [], - includeTransactions: isSet(object.includeTransactions) ? Boolean(object.includeTransactions) : undefined, - includeAccounts: isSet(object.includeAccounts) ? Boolean(object.includeAccounts) : undefined, - includeEntries: isSet(object.includeEntries) ? Boolean(object.includeEntries) : undefined, - }; - }, - - toJSON(message: SubscribeRequestFilterBlocks): unknown { - const obj: any = {}; - if (message.accountInclude) { - obj.accountInclude = message.accountInclude.map((e) => e); - } else { - obj.accountInclude = []; - } - message.includeTransactions !== undefined && (obj.includeTransactions = message.includeTransactions); - message.includeAccounts !== undefined && (obj.includeAccounts = message.includeAccounts); - message.includeEntries !== undefined && (obj.includeEntries = message.includeEntries); - return obj; - }, - - create, I>>(base?: I): SubscribeRequestFilterBlocks { - return SubscribeRequestFilterBlocks.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): SubscribeRequestFilterBlocks { - const message = createBaseSubscribeRequestFilterBlocks(); - message.accountInclude = object.accountInclude?.map((e) => e) || []; - message.includeTransactions = object.includeTransactions ?? undefined; - message.includeAccounts = object.includeAccounts ?? undefined; - message.includeEntries = object.includeEntries ?? undefined; - return message; - }, -}; - -function createBaseSubscribeRequestFilterBlocksMeta(): SubscribeRequestFilterBlocksMeta { - return {}; -} - -export const SubscribeRequestFilterBlocksMeta = { - encode(_: SubscribeRequestFilterBlocksMeta, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeRequestFilterBlocksMeta { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeRequestFilterBlocksMeta(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(_: any): SubscribeRequestFilterBlocksMeta { - return {}; - }, - - toJSON(_: SubscribeRequestFilterBlocksMeta): unknown { - const obj: any = {}; - return obj; - }, - - create, I>>( - base?: I, - ): SubscribeRequestFilterBlocksMeta { - return SubscribeRequestFilterBlocksMeta.fromPartial(base ?? {}); - }, - - fromPartial, I>>( - _: I, - ): SubscribeRequestFilterBlocksMeta { - const message = createBaseSubscribeRequestFilterBlocksMeta(); - return message; - }, -}; - -function createBaseSubscribeRequestFilterEntry(): SubscribeRequestFilterEntry { - return {}; -} - -export const SubscribeRequestFilterEntry = { - encode(_: SubscribeRequestFilterEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeRequestFilterEntry { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeRequestFilterEntry(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(_: any): SubscribeRequestFilterEntry { - return {}; - }, - - toJSON(_: SubscribeRequestFilterEntry): unknown { - const obj: any = {}; - return obj; - }, - - create, I>>(base?: I): SubscribeRequestFilterEntry { - return SubscribeRequestFilterEntry.fromPartial(base ?? {}); - }, - - fromPartial, I>>(_: I): SubscribeRequestFilterEntry { - const message = createBaseSubscribeRequestFilterEntry(); - return message; - }, -}; - -function createBaseSubscribeRequestAccountsDataSlice(): SubscribeRequestAccountsDataSlice { - return { offset: "0", length: "0" }; -} - -export const SubscribeRequestAccountsDataSlice = { - encode(message: SubscribeRequestAccountsDataSlice, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.offset !== "0") { - writer.uint32(8).uint64(message.offset); - } - if (message.length !== "0") { - writer.uint32(16).uint64(message.length); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeRequestAccountsDataSlice { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeRequestAccountsDataSlice(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.offset = longToString(reader.uint64() as Long); - continue; - case 2: - if (tag !== 16) { - break; - } - - message.length = longToString(reader.uint64() as Long); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): SubscribeRequestAccountsDataSlice { - return { - offset: isSet(object.offset) ? String(object.offset) : "0", - length: isSet(object.length) ? String(object.length) : "0", - }; - }, - - toJSON(message: SubscribeRequestAccountsDataSlice): unknown { - const obj: any = {}; - message.offset !== undefined && (obj.offset = message.offset); - message.length !== undefined && (obj.length = message.length); - return obj; - }, - - create, I>>( - base?: I, - ): SubscribeRequestAccountsDataSlice { - return SubscribeRequestAccountsDataSlice.fromPartial(base ?? {}); - }, - - fromPartial, I>>( - object: I, - ): SubscribeRequestAccountsDataSlice { - const message = createBaseSubscribeRequestAccountsDataSlice(); - message.offset = object.offset ?? "0"; - message.length = object.length ?? "0"; - return message; - }, -}; - -function createBaseSubscribeRequestPing(): SubscribeRequestPing { - return { id: 0 }; -} - -export const SubscribeRequestPing = { - encode(message: SubscribeRequestPing, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.id !== 0) { - writer.uint32(8).int32(message.id); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeRequestPing { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeRequestPing(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.id = reader.int32(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): SubscribeRequestPing { - return { id: isSet(object.id) ? Number(object.id) : 0 }; - }, - - toJSON(message: SubscribeRequestPing): unknown { - const obj: any = {}; - message.id !== undefined && (obj.id = Math.round(message.id)); - return obj; - }, - - create, I>>(base?: I): SubscribeRequestPing { - return SubscribeRequestPing.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): SubscribeRequestPing { - const message = createBaseSubscribeRequestPing(); - message.id = object.id ?? 0; - return message; - }, -}; - -function createBaseSubscribeUpdate(): SubscribeUpdate { - return { - filters: [], - account: undefined, - slot: undefined, - transaction: undefined, - transactionStatus: undefined, - block: undefined, - ping: undefined, - pong: undefined, - blockMeta: undefined, - entry: undefined, - }; -} - -export const SubscribeUpdate = { - encode(message: SubscribeUpdate, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - for (const v of message.filters) { - writer.uint32(10).string(v!); - } - if (message.account !== undefined) { - SubscribeUpdateAccount.encode(message.account, writer.uint32(18).fork()).ldelim(); - } - if (message.slot !== undefined) { - SubscribeUpdateSlot.encode(message.slot, writer.uint32(26).fork()).ldelim(); - } - if (message.transaction !== undefined) { - SubscribeUpdateTransaction.encode(message.transaction, writer.uint32(34).fork()).ldelim(); - } - if (message.transactionStatus !== undefined) { - SubscribeUpdateTransactionStatus.encode(message.transactionStatus, writer.uint32(82).fork()).ldelim(); - } - if (message.block !== undefined) { - SubscribeUpdateBlock.encode(message.block, writer.uint32(42).fork()).ldelim(); - } - if (message.ping !== undefined) { - SubscribeUpdatePing.encode(message.ping, writer.uint32(50).fork()).ldelim(); - } - if (message.pong !== undefined) { - SubscribeUpdatePong.encode(message.pong, writer.uint32(74).fork()).ldelim(); - } - if (message.blockMeta !== undefined) { - SubscribeUpdateBlockMeta.encode(message.blockMeta, writer.uint32(58).fork()).ldelim(); - } - if (message.entry !== undefined) { - SubscribeUpdateEntry.encode(message.entry, writer.uint32(66).fork()).ldelim(); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeUpdate { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeUpdate(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.filters.push(reader.string()); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.account = SubscribeUpdateAccount.decode(reader, reader.uint32()); - continue; - case 3: - if (tag !== 26) { - break; - } - - message.slot = SubscribeUpdateSlot.decode(reader, reader.uint32()); - continue; - case 4: - if (tag !== 34) { - break; - } - - message.transaction = SubscribeUpdateTransaction.decode(reader, reader.uint32()); - continue; - case 10: - if (tag !== 82) { - break; - } - - message.transactionStatus = SubscribeUpdateTransactionStatus.decode(reader, reader.uint32()); - continue; - case 5: - if (tag !== 42) { - break; - } - - message.block = SubscribeUpdateBlock.decode(reader, reader.uint32()); - continue; - case 6: - if (tag !== 50) { - break; - } - - message.ping = SubscribeUpdatePing.decode(reader, reader.uint32()); - continue; - case 9: - if (tag !== 74) { - break; - } - - message.pong = SubscribeUpdatePong.decode(reader, reader.uint32()); - continue; - case 7: - if (tag !== 58) { - break; - } - - message.blockMeta = SubscribeUpdateBlockMeta.decode(reader, reader.uint32()); - continue; - case 8: - if (tag !== 66) { - break; - } - - message.entry = SubscribeUpdateEntry.decode(reader, reader.uint32()); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): SubscribeUpdate { - return { - filters: Array.isArray(object?.filters) ? object.filters.map((e: any) => String(e)) : [], - account: isSet(object.account) ? SubscribeUpdateAccount.fromJSON(object.account) : undefined, - slot: isSet(object.slot) ? SubscribeUpdateSlot.fromJSON(object.slot) : undefined, - transaction: isSet(object.transaction) ? SubscribeUpdateTransaction.fromJSON(object.transaction) : undefined, - transactionStatus: isSet(object.transactionStatus) - ? SubscribeUpdateTransactionStatus.fromJSON(object.transactionStatus) - : undefined, - block: isSet(object.block) ? SubscribeUpdateBlock.fromJSON(object.block) : undefined, - ping: isSet(object.ping) ? SubscribeUpdatePing.fromJSON(object.ping) : undefined, - pong: isSet(object.pong) ? SubscribeUpdatePong.fromJSON(object.pong) : undefined, - blockMeta: isSet(object.blockMeta) ? SubscribeUpdateBlockMeta.fromJSON(object.blockMeta) : undefined, - entry: isSet(object.entry) ? SubscribeUpdateEntry.fromJSON(object.entry) : undefined, - }; - }, - - toJSON(message: SubscribeUpdate): unknown { - const obj: any = {}; - if (message.filters) { - obj.filters = message.filters.map((e) => e); - } else { - obj.filters = []; - } - message.account !== undefined && - (obj.account = message.account ? SubscribeUpdateAccount.toJSON(message.account) : undefined); - message.slot !== undefined && (obj.slot = message.slot ? SubscribeUpdateSlot.toJSON(message.slot) : undefined); - message.transaction !== undefined && - (obj.transaction = message.transaction ? SubscribeUpdateTransaction.toJSON(message.transaction) : undefined); - message.transactionStatus !== undefined && (obj.transactionStatus = message.transactionStatus - ? SubscribeUpdateTransactionStatus.toJSON(message.transactionStatus) - : undefined); - message.block !== undefined && (obj.block = message.block ? SubscribeUpdateBlock.toJSON(message.block) : undefined); - message.ping !== undefined && (obj.ping = message.ping ? SubscribeUpdatePing.toJSON(message.ping) : undefined); - message.pong !== undefined && (obj.pong = message.pong ? SubscribeUpdatePong.toJSON(message.pong) : undefined); - message.blockMeta !== undefined && - (obj.blockMeta = message.blockMeta ? SubscribeUpdateBlockMeta.toJSON(message.blockMeta) : undefined); - message.entry !== undefined && (obj.entry = message.entry ? SubscribeUpdateEntry.toJSON(message.entry) : undefined); - return obj; - }, - - create, I>>(base?: I): SubscribeUpdate { - return SubscribeUpdate.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): SubscribeUpdate { - const message = createBaseSubscribeUpdate(); - message.filters = object.filters?.map((e) => e) || []; - message.account = (object.account !== undefined && object.account !== null) - ? SubscribeUpdateAccount.fromPartial(object.account) - : undefined; - message.slot = (object.slot !== undefined && object.slot !== null) - ? SubscribeUpdateSlot.fromPartial(object.slot) - : undefined; - message.transaction = (object.transaction !== undefined && object.transaction !== null) - ? SubscribeUpdateTransaction.fromPartial(object.transaction) - : undefined; - message.transactionStatus = (object.transactionStatus !== undefined && object.transactionStatus !== null) - ? SubscribeUpdateTransactionStatus.fromPartial(object.transactionStatus) - : undefined; - message.block = (object.block !== undefined && object.block !== null) - ? SubscribeUpdateBlock.fromPartial(object.block) - : undefined; - message.ping = (object.ping !== undefined && object.ping !== null) - ? SubscribeUpdatePing.fromPartial(object.ping) - : undefined; - message.pong = (object.pong !== undefined && object.pong !== null) - ? SubscribeUpdatePong.fromPartial(object.pong) - : undefined; - message.blockMeta = (object.blockMeta !== undefined && object.blockMeta !== null) - ? SubscribeUpdateBlockMeta.fromPartial(object.blockMeta) - : undefined; - message.entry = (object.entry !== undefined && object.entry !== null) - ? SubscribeUpdateEntry.fromPartial(object.entry) - : undefined; - return message; - }, -}; - -function createBaseSubscribeUpdateAccount(): SubscribeUpdateAccount { - return { account: undefined, slot: "0", isStartup: false }; -} - -export const SubscribeUpdateAccount = { - encode(message: SubscribeUpdateAccount, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.account !== undefined) { - SubscribeUpdateAccountInfo.encode(message.account, writer.uint32(10).fork()).ldelim(); - } - if (message.slot !== "0") { - writer.uint32(16).uint64(message.slot); - } - if (message.isStartup === true) { - writer.uint32(24).bool(message.isStartup); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeUpdateAccount { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeUpdateAccount(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.account = SubscribeUpdateAccountInfo.decode(reader, reader.uint32()); - continue; - case 2: - if (tag !== 16) { - break; - } - - message.slot = longToString(reader.uint64() as Long); - continue; - case 3: - if (tag !== 24) { - break; - } - - message.isStartup = reader.bool(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): SubscribeUpdateAccount { - return { - account: isSet(object.account) ? SubscribeUpdateAccountInfo.fromJSON(object.account) : undefined, - slot: isSet(object.slot) ? String(object.slot) : "0", - isStartup: isSet(object.isStartup) ? Boolean(object.isStartup) : false, - }; - }, - - toJSON(message: SubscribeUpdateAccount): unknown { - const obj: any = {}; - message.account !== undefined && - (obj.account = message.account ? SubscribeUpdateAccountInfo.toJSON(message.account) : undefined); - message.slot !== undefined && (obj.slot = message.slot); - message.isStartup !== undefined && (obj.isStartup = message.isStartup); - return obj; - }, - - create, I>>(base?: I): SubscribeUpdateAccount { - return SubscribeUpdateAccount.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): SubscribeUpdateAccount { - const message = createBaseSubscribeUpdateAccount(); - message.account = (object.account !== undefined && object.account !== null) - ? SubscribeUpdateAccountInfo.fromPartial(object.account) - : undefined; - message.slot = object.slot ?? "0"; - message.isStartup = object.isStartup ?? false; - return message; - }, -}; - -function createBaseSubscribeUpdateAccountInfo(): SubscribeUpdateAccountInfo { - return { - pubkey: new Uint8Array(0), - lamports: "0", - owner: new Uint8Array(0), - executable: false, - rentEpoch: "0", - data: new Uint8Array(0), - writeVersion: "0", - txnSignature: undefined, - }; -} - -export const SubscribeUpdateAccountInfo = { - encode(message: SubscribeUpdateAccountInfo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.pubkey.length !== 0) { - writer.uint32(10).bytes(message.pubkey); - } - if (message.lamports !== "0") { - writer.uint32(16).uint64(message.lamports); - } - if (message.owner.length !== 0) { - writer.uint32(26).bytes(message.owner); - } - if (message.executable === true) { - writer.uint32(32).bool(message.executable); - } - if (message.rentEpoch !== "0") { - writer.uint32(40).uint64(message.rentEpoch); - } - if (message.data.length !== 0) { - writer.uint32(50).bytes(message.data); - } - if (message.writeVersion !== "0") { - writer.uint32(56).uint64(message.writeVersion); - } - if (message.txnSignature !== undefined) { - writer.uint32(66).bytes(message.txnSignature); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeUpdateAccountInfo { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeUpdateAccountInfo(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.pubkey = reader.bytes(); - continue; - case 2: - if (tag !== 16) { - break; - } - - message.lamports = longToString(reader.uint64() as Long); - continue; - case 3: - if (tag !== 26) { - break; - } - - message.owner = reader.bytes(); - continue; - case 4: - if (tag !== 32) { - break; - } - - message.executable = reader.bool(); - continue; - case 5: - if (tag !== 40) { - break; - } - - message.rentEpoch = longToString(reader.uint64() as Long); - continue; - case 6: - if (tag !== 50) { - break; - } - - message.data = reader.bytes(); - continue; - case 7: - if (tag !== 56) { - break; - } - - message.writeVersion = longToString(reader.uint64() as Long); - continue; - case 8: - if (tag !== 66) { - break; - } - - message.txnSignature = reader.bytes(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): SubscribeUpdateAccountInfo { - return { - pubkey: isSet(object.pubkey) ? bytesFromBase64(object.pubkey) : new Uint8Array(0), - lamports: isSet(object.lamports) ? String(object.lamports) : "0", - owner: isSet(object.owner) ? bytesFromBase64(object.owner) : new Uint8Array(0), - executable: isSet(object.executable) ? Boolean(object.executable) : false, - rentEpoch: isSet(object.rentEpoch) ? String(object.rentEpoch) : "0", - data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(0), - writeVersion: isSet(object.writeVersion) ? String(object.writeVersion) : "0", - txnSignature: isSet(object.txnSignature) ? bytesFromBase64(object.txnSignature) : undefined, - }; - }, - - toJSON(message: SubscribeUpdateAccountInfo): unknown { - const obj: any = {}; - message.pubkey !== undefined && - (obj.pubkey = base64FromBytes(message.pubkey !== undefined ? message.pubkey : new Uint8Array(0))); - message.lamports !== undefined && (obj.lamports = message.lamports); - message.owner !== undefined && - (obj.owner = base64FromBytes(message.owner !== undefined ? message.owner : new Uint8Array(0))); - message.executable !== undefined && (obj.executable = message.executable); - message.rentEpoch !== undefined && (obj.rentEpoch = message.rentEpoch); - message.data !== undefined && - (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array(0))); - message.writeVersion !== undefined && (obj.writeVersion = message.writeVersion); - message.txnSignature !== undefined && - (obj.txnSignature = message.txnSignature !== undefined ? base64FromBytes(message.txnSignature) : undefined); - return obj; - }, - - create, I>>(base?: I): SubscribeUpdateAccountInfo { - return SubscribeUpdateAccountInfo.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): SubscribeUpdateAccountInfo { - const message = createBaseSubscribeUpdateAccountInfo(); - message.pubkey = object.pubkey ?? new Uint8Array(0); - message.lamports = object.lamports ?? "0"; - message.owner = object.owner ?? new Uint8Array(0); - message.executable = object.executable ?? false; - message.rentEpoch = object.rentEpoch ?? "0"; - message.data = object.data ?? new Uint8Array(0); - message.writeVersion = object.writeVersion ?? "0"; - message.txnSignature = object.txnSignature ?? undefined; - return message; - }, -}; - -function createBaseSubscribeUpdateSlot(): SubscribeUpdateSlot { - return { slot: "0", parent: undefined, status: 0 }; -} - -export const SubscribeUpdateSlot = { - encode(message: SubscribeUpdateSlot, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.slot !== "0") { - writer.uint32(8).uint64(message.slot); - } - if (message.parent !== undefined) { - writer.uint32(16).uint64(message.parent); - } - if (message.status !== 0) { - writer.uint32(24).int32(message.status); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeUpdateSlot { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeUpdateSlot(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.slot = longToString(reader.uint64() as Long); - continue; - case 2: - if (tag !== 16) { - break; - } - - message.parent = longToString(reader.uint64() as Long); - continue; - case 3: - if (tag !== 24) { - break; - } - - message.status = reader.int32() as any; - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): SubscribeUpdateSlot { - return { - slot: isSet(object.slot) ? String(object.slot) : "0", - parent: isSet(object.parent) ? String(object.parent) : undefined, - status: isSet(object.status) ? commitmentLevelFromJSON(object.status) : 0, - }; - }, - - toJSON(message: SubscribeUpdateSlot): unknown { - const obj: any = {}; - message.slot !== undefined && (obj.slot = message.slot); - message.parent !== undefined && (obj.parent = message.parent); - message.status !== undefined && (obj.status = commitmentLevelToJSON(message.status)); - return obj; - }, - - create, I>>(base?: I): SubscribeUpdateSlot { - return SubscribeUpdateSlot.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): SubscribeUpdateSlot { - const message = createBaseSubscribeUpdateSlot(); - message.slot = object.slot ?? "0"; - message.parent = object.parent ?? undefined; - message.status = object.status ?? 0; - return message; - }, -}; - -function createBaseSubscribeUpdateTransaction(): SubscribeUpdateTransaction { - return { transaction: undefined, slot: "0" }; -} - -export const SubscribeUpdateTransaction = { - encode(message: SubscribeUpdateTransaction, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.transaction !== undefined) { - SubscribeUpdateTransactionInfo.encode(message.transaction, writer.uint32(10).fork()).ldelim(); - } - if (message.slot !== "0") { - writer.uint32(16).uint64(message.slot); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeUpdateTransaction { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeUpdateTransaction(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.transaction = SubscribeUpdateTransactionInfo.decode(reader, reader.uint32()); - continue; - case 2: - if (tag !== 16) { - break; - } - - message.slot = longToString(reader.uint64() as Long); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): SubscribeUpdateTransaction { - return { - transaction: isSet(object.transaction) ? SubscribeUpdateTransactionInfo.fromJSON(object.transaction) : undefined, - slot: isSet(object.slot) ? String(object.slot) : "0", - }; - }, - - toJSON(message: SubscribeUpdateTransaction): unknown { - const obj: any = {}; - message.transaction !== undefined && - (obj.transaction = message.transaction ? SubscribeUpdateTransactionInfo.toJSON(message.transaction) : undefined); - message.slot !== undefined && (obj.slot = message.slot); - return obj; - }, - - create, I>>(base?: I): SubscribeUpdateTransaction { - return SubscribeUpdateTransaction.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): SubscribeUpdateTransaction { - const message = createBaseSubscribeUpdateTransaction(); - message.transaction = (object.transaction !== undefined && object.transaction !== null) - ? SubscribeUpdateTransactionInfo.fromPartial(object.transaction) - : undefined; - message.slot = object.slot ?? "0"; - return message; - }, -}; - -function createBaseSubscribeUpdateTransactionInfo(): SubscribeUpdateTransactionInfo { - return { signature: new Uint8Array(0), isVote: false, transaction: undefined, meta: undefined, index: "0" }; -} - -export const SubscribeUpdateTransactionInfo = { - encode(message: SubscribeUpdateTransactionInfo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.signature.length !== 0) { - writer.uint32(10).bytes(message.signature); - } - if (message.isVote === true) { - writer.uint32(16).bool(message.isVote); - } - if (message.transaction !== undefined) { - Transaction.encode(message.transaction, writer.uint32(26).fork()).ldelim(); - } - if (message.meta !== undefined) { - TransactionStatusMeta.encode(message.meta, writer.uint32(34).fork()).ldelim(); - } - if (message.index !== "0") { - writer.uint32(40).uint64(message.index); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeUpdateTransactionInfo { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeUpdateTransactionInfo(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.signature = reader.bytes(); - continue; - case 2: - if (tag !== 16) { - break; - } - - message.isVote = reader.bool(); - continue; - case 3: - if (tag !== 26) { - break; - } - - message.transaction = Transaction.decode(reader, reader.uint32()); - continue; - case 4: - if (tag !== 34) { - break; - } - - message.meta = TransactionStatusMeta.decode(reader, reader.uint32()); - continue; - case 5: - if (tag !== 40) { - break; - } - - message.index = longToString(reader.uint64() as Long); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): SubscribeUpdateTransactionInfo { - return { - signature: isSet(object.signature) ? bytesFromBase64(object.signature) : new Uint8Array(0), - isVote: isSet(object.isVote) ? Boolean(object.isVote) : false, - transaction: isSet(object.transaction) ? Transaction.fromJSON(object.transaction) : undefined, - meta: isSet(object.meta) ? TransactionStatusMeta.fromJSON(object.meta) : undefined, - index: isSet(object.index) ? String(object.index) : "0", - }; - }, - - toJSON(message: SubscribeUpdateTransactionInfo): unknown { - const obj: any = {}; - message.signature !== undefined && - (obj.signature = base64FromBytes(message.signature !== undefined ? message.signature : new Uint8Array(0))); - message.isVote !== undefined && (obj.isVote = message.isVote); - message.transaction !== undefined && - (obj.transaction = message.transaction ? Transaction.toJSON(message.transaction) : undefined); - message.meta !== undefined && (obj.meta = message.meta ? TransactionStatusMeta.toJSON(message.meta) : undefined); - message.index !== undefined && (obj.index = message.index); - return obj; - }, - - create, I>>(base?: I): SubscribeUpdateTransactionInfo { - return SubscribeUpdateTransactionInfo.fromPartial(base ?? {}); - }, - - fromPartial, I>>( - object: I, - ): SubscribeUpdateTransactionInfo { - const message = createBaseSubscribeUpdateTransactionInfo(); - message.signature = object.signature ?? new Uint8Array(0); - message.isVote = object.isVote ?? false; - message.transaction = (object.transaction !== undefined && object.transaction !== null) - ? Transaction.fromPartial(object.transaction) - : undefined; - message.meta = (object.meta !== undefined && object.meta !== null) - ? TransactionStatusMeta.fromPartial(object.meta) - : undefined; - message.index = object.index ?? "0"; - return message; - }, -}; - -function createBaseSubscribeUpdateTransactionStatus(): SubscribeUpdateTransactionStatus { - return { slot: "0", signature: new Uint8Array(0), isVote: false, index: "0", err: undefined }; -} - -export const SubscribeUpdateTransactionStatus = { - encode(message: SubscribeUpdateTransactionStatus, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.slot !== "0") { - writer.uint32(8).uint64(message.slot); - } - if (message.signature.length !== 0) { - writer.uint32(18).bytes(message.signature); - } - if (message.isVote === true) { - writer.uint32(24).bool(message.isVote); - } - if (message.index !== "0") { - writer.uint32(32).uint64(message.index); - } - if (message.err !== undefined) { - TransactionError.encode(message.err, writer.uint32(42).fork()).ldelim(); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeUpdateTransactionStatus { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeUpdateTransactionStatus(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.slot = longToString(reader.uint64() as Long); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.signature = reader.bytes(); - continue; - case 3: - if (tag !== 24) { - break; - } - - message.isVote = reader.bool(); - continue; - case 4: - if (tag !== 32) { - break; - } - - message.index = longToString(reader.uint64() as Long); - continue; - case 5: - if (tag !== 42) { - break; - } - - message.err = TransactionError.decode(reader, reader.uint32()); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): SubscribeUpdateTransactionStatus { - return { - slot: isSet(object.slot) ? String(object.slot) : "0", - signature: isSet(object.signature) ? bytesFromBase64(object.signature) : new Uint8Array(0), - isVote: isSet(object.isVote) ? Boolean(object.isVote) : false, - index: isSet(object.index) ? String(object.index) : "0", - err: isSet(object.err) ? TransactionError.fromJSON(object.err) : undefined, - }; - }, - - toJSON(message: SubscribeUpdateTransactionStatus): unknown { - const obj: any = {}; - message.slot !== undefined && (obj.slot = message.slot); - message.signature !== undefined && - (obj.signature = base64FromBytes(message.signature !== undefined ? message.signature : new Uint8Array(0))); - message.isVote !== undefined && (obj.isVote = message.isVote); - message.index !== undefined && (obj.index = message.index); - message.err !== undefined && (obj.err = message.err ? TransactionError.toJSON(message.err) : undefined); - return obj; - }, - - create, I>>( - base?: I, - ): SubscribeUpdateTransactionStatus { - return SubscribeUpdateTransactionStatus.fromPartial(base ?? {}); - }, - - fromPartial, I>>( - object: I, - ): SubscribeUpdateTransactionStatus { - const message = createBaseSubscribeUpdateTransactionStatus(); - message.slot = object.slot ?? "0"; - message.signature = object.signature ?? new Uint8Array(0); - message.isVote = object.isVote ?? false; - message.index = object.index ?? "0"; - message.err = (object.err !== undefined && object.err !== null) - ? TransactionError.fromPartial(object.err) - : undefined; - return message; - }, -}; - -function createBaseSubscribeUpdateBlock(): SubscribeUpdateBlock { - return { - slot: "0", - blockhash: "", - rewards: undefined, - blockTime: undefined, - blockHeight: undefined, - parentSlot: "0", - parentBlockhash: "", - executedTransactionCount: "0", - transactions: [], - updatedAccountCount: "0", - accounts: [], - entriesCount: "0", - entries: [], - }; -} - -export const SubscribeUpdateBlock = { - encode(message: SubscribeUpdateBlock, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.slot !== "0") { - writer.uint32(8).uint64(message.slot); - } - if (message.blockhash !== "") { - writer.uint32(18).string(message.blockhash); - } - if (message.rewards !== undefined) { - Rewards.encode(message.rewards, writer.uint32(26).fork()).ldelim(); - } - if (message.blockTime !== undefined) { - UnixTimestamp.encode(message.blockTime, writer.uint32(34).fork()).ldelim(); - } - if (message.blockHeight !== undefined) { - BlockHeight.encode(message.blockHeight, writer.uint32(42).fork()).ldelim(); - } - if (message.parentSlot !== "0") { - writer.uint32(56).uint64(message.parentSlot); - } - if (message.parentBlockhash !== "") { - writer.uint32(66).string(message.parentBlockhash); - } - if (message.executedTransactionCount !== "0") { - writer.uint32(72).uint64(message.executedTransactionCount); - } - for (const v of message.transactions) { - SubscribeUpdateTransactionInfo.encode(v!, writer.uint32(50).fork()).ldelim(); - } - if (message.updatedAccountCount !== "0") { - writer.uint32(80).uint64(message.updatedAccountCount); - } - for (const v of message.accounts) { - SubscribeUpdateAccountInfo.encode(v!, writer.uint32(90).fork()).ldelim(); - } - if (message.entriesCount !== "0") { - writer.uint32(96).uint64(message.entriesCount); - } - for (const v of message.entries) { - SubscribeUpdateEntry.encode(v!, writer.uint32(106).fork()).ldelim(); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeUpdateBlock { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeUpdateBlock(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.slot = longToString(reader.uint64() as Long); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.blockhash = reader.string(); - continue; - case 3: - if (tag !== 26) { - break; - } - - message.rewards = Rewards.decode(reader, reader.uint32()); - continue; - case 4: - if (tag !== 34) { - break; - } - - message.blockTime = UnixTimestamp.decode(reader, reader.uint32()); - continue; - case 5: - if (tag !== 42) { - break; - } - - message.blockHeight = BlockHeight.decode(reader, reader.uint32()); - continue; - case 7: - if (tag !== 56) { - break; - } - - message.parentSlot = longToString(reader.uint64() as Long); - continue; - case 8: - if (tag !== 66) { - break; - } - - message.parentBlockhash = reader.string(); - continue; - case 9: - if (tag !== 72) { - break; - } - - message.executedTransactionCount = longToString(reader.uint64() as Long); - continue; - case 6: - if (tag !== 50) { - break; - } - - message.transactions.push(SubscribeUpdateTransactionInfo.decode(reader, reader.uint32())); - continue; - case 10: - if (tag !== 80) { - break; - } - - message.updatedAccountCount = longToString(reader.uint64() as Long); - continue; - case 11: - if (tag !== 90) { - break; - } - - message.accounts.push(SubscribeUpdateAccountInfo.decode(reader, reader.uint32())); - continue; - case 12: - if (tag !== 96) { - break; - } - - message.entriesCount = longToString(reader.uint64() as Long); - continue; - case 13: - if (tag !== 106) { - break; - } - - message.entries.push(SubscribeUpdateEntry.decode(reader, reader.uint32())); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): SubscribeUpdateBlock { - return { - slot: isSet(object.slot) ? String(object.slot) : "0", - blockhash: isSet(object.blockhash) ? String(object.blockhash) : "", - rewards: isSet(object.rewards) ? Rewards.fromJSON(object.rewards) : undefined, - blockTime: isSet(object.blockTime) ? UnixTimestamp.fromJSON(object.blockTime) : undefined, - blockHeight: isSet(object.blockHeight) ? BlockHeight.fromJSON(object.blockHeight) : undefined, - parentSlot: isSet(object.parentSlot) ? String(object.parentSlot) : "0", - parentBlockhash: isSet(object.parentBlockhash) ? String(object.parentBlockhash) : "", - executedTransactionCount: isSet(object.executedTransactionCount) ? String(object.executedTransactionCount) : "0", - transactions: Array.isArray(object?.transactions) - ? object.transactions.map((e: any) => SubscribeUpdateTransactionInfo.fromJSON(e)) - : [], - updatedAccountCount: isSet(object.updatedAccountCount) ? String(object.updatedAccountCount) : "0", - accounts: Array.isArray(object?.accounts) - ? object.accounts.map((e: any) => SubscribeUpdateAccountInfo.fromJSON(e)) - : [], - entriesCount: isSet(object.entriesCount) ? String(object.entriesCount) : "0", - entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => SubscribeUpdateEntry.fromJSON(e)) : [], - }; - }, - - toJSON(message: SubscribeUpdateBlock): unknown { - const obj: any = {}; - message.slot !== undefined && (obj.slot = message.slot); - message.blockhash !== undefined && (obj.blockhash = message.blockhash); - message.rewards !== undefined && (obj.rewards = message.rewards ? Rewards.toJSON(message.rewards) : undefined); - message.blockTime !== undefined && - (obj.blockTime = message.blockTime ? UnixTimestamp.toJSON(message.blockTime) : undefined); - message.blockHeight !== undefined && - (obj.blockHeight = message.blockHeight ? BlockHeight.toJSON(message.blockHeight) : undefined); - message.parentSlot !== undefined && (obj.parentSlot = message.parentSlot); - message.parentBlockhash !== undefined && (obj.parentBlockhash = message.parentBlockhash); - message.executedTransactionCount !== undefined && (obj.executedTransactionCount = message.executedTransactionCount); - if (message.transactions) { - obj.transactions = message.transactions.map((e) => e ? SubscribeUpdateTransactionInfo.toJSON(e) : undefined); - } else { - obj.transactions = []; - } - message.updatedAccountCount !== undefined && (obj.updatedAccountCount = message.updatedAccountCount); - if (message.accounts) { - obj.accounts = message.accounts.map((e) => e ? SubscribeUpdateAccountInfo.toJSON(e) : undefined); - } else { - obj.accounts = []; - } - message.entriesCount !== undefined && (obj.entriesCount = message.entriesCount); - if (message.entries) { - obj.entries = message.entries.map((e) => e ? SubscribeUpdateEntry.toJSON(e) : undefined); - } else { - obj.entries = []; - } - return obj; - }, - - create, I>>(base?: I): SubscribeUpdateBlock { - return SubscribeUpdateBlock.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): SubscribeUpdateBlock { - const message = createBaseSubscribeUpdateBlock(); - message.slot = object.slot ?? "0"; - message.blockhash = object.blockhash ?? ""; - message.rewards = (object.rewards !== undefined && object.rewards !== null) - ? Rewards.fromPartial(object.rewards) - : undefined; - message.blockTime = (object.blockTime !== undefined && object.blockTime !== null) - ? UnixTimestamp.fromPartial(object.blockTime) - : undefined; - message.blockHeight = (object.blockHeight !== undefined && object.blockHeight !== null) - ? BlockHeight.fromPartial(object.blockHeight) - : undefined; - message.parentSlot = object.parentSlot ?? "0"; - message.parentBlockhash = object.parentBlockhash ?? ""; - message.executedTransactionCount = object.executedTransactionCount ?? "0"; - message.transactions = object.transactions?.map((e) => SubscribeUpdateTransactionInfo.fromPartial(e)) || []; - message.updatedAccountCount = object.updatedAccountCount ?? "0"; - message.accounts = object.accounts?.map((e) => SubscribeUpdateAccountInfo.fromPartial(e)) || []; - message.entriesCount = object.entriesCount ?? "0"; - message.entries = object.entries?.map((e) => SubscribeUpdateEntry.fromPartial(e)) || []; - return message; - }, -}; - -function createBaseSubscribeUpdateBlockMeta(): SubscribeUpdateBlockMeta { - return { - slot: "0", - blockhash: "", - rewards: undefined, - blockTime: undefined, - blockHeight: undefined, - parentSlot: "0", - parentBlockhash: "", - executedTransactionCount: "0", - entriesCount: "0", - }; -} - -export const SubscribeUpdateBlockMeta = { - encode(message: SubscribeUpdateBlockMeta, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.slot !== "0") { - writer.uint32(8).uint64(message.slot); - } - if (message.blockhash !== "") { - writer.uint32(18).string(message.blockhash); - } - if (message.rewards !== undefined) { - Rewards.encode(message.rewards, writer.uint32(26).fork()).ldelim(); - } - if (message.blockTime !== undefined) { - UnixTimestamp.encode(message.blockTime, writer.uint32(34).fork()).ldelim(); - } - if (message.blockHeight !== undefined) { - BlockHeight.encode(message.blockHeight, writer.uint32(42).fork()).ldelim(); - } - if (message.parentSlot !== "0") { - writer.uint32(48).uint64(message.parentSlot); - } - if (message.parentBlockhash !== "") { - writer.uint32(58).string(message.parentBlockhash); - } - if (message.executedTransactionCount !== "0") { - writer.uint32(64).uint64(message.executedTransactionCount); - } - if (message.entriesCount !== "0") { - writer.uint32(72).uint64(message.entriesCount); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeUpdateBlockMeta { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeUpdateBlockMeta(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.slot = longToString(reader.uint64() as Long); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.blockhash = reader.string(); - continue; - case 3: - if (tag !== 26) { - break; - } - - message.rewards = Rewards.decode(reader, reader.uint32()); - continue; - case 4: - if (tag !== 34) { - break; - } - - message.blockTime = UnixTimestamp.decode(reader, reader.uint32()); - continue; - case 5: - if (tag !== 42) { - break; - } - - message.blockHeight = BlockHeight.decode(reader, reader.uint32()); - continue; - case 6: - if (tag !== 48) { - break; - } - - message.parentSlot = longToString(reader.uint64() as Long); - continue; - case 7: - if (tag !== 58) { - break; - } - - message.parentBlockhash = reader.string(); - continue; - case 8: - if (tag !== 64) { - break; - } - - message.executedTransactionCount = longToString(reader.uint64() as Long); - continue; - case 9: - if (tag !== 72) { - break; - } - - message.entriesCount = longToString(reader.uint64() as Long); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): SubscribeUpdateBlockMeta { - return { - slot: isSet(object.slot) ? String(object.slot) : "0", - blockhash: isSet(object.blockhash) ? String(object.blockhash) : "", - rewards: isSet(object.rewards) ? Rewards.fromJSON(object.rewards) : undefined, - blockTime: isSet(object.blockTime) ? UnixTimestamp.fromJSON(object.blockTime) : undefined, - blockHeight: isSet(object.blockHeight) ? BlockHeight.fromJSON(object.blockHeight) : undefined, - parentSlot: isSet(object.parentSlot) ? String(object.parentSlot) : "0", - parentBlockhash: isSet(object.parentBlockhash) ? String(object.parentBlockhash) : "", - executedTransactionCount: isSet(object.executedTransactionCount) ? String(object.executedTransactionCount) : "0", - entriesCount: isSet(object.entriesCount) ? String(object.entriesCount) : "0", - }; - }, - - toJSON(message: SubscribeUpdateBlockMeta): unknown { - const obj: any = {}; - message.slot !== undefined && (obj.slot = message.slot); - message.blockhash !== undefined && (obj.blockhash = message.blockhash); - message.rewards !== undefined && (obj.rewards = message.rewards ? Rewards.toJSON(message.rewards) : undefined); - message.blockTime !== undefined && - (obj.blockTime = message.blockTime ? UnixTimestamp.toJSON(message.blockTime) : undefined); - message.blockHeight !== undefined && - (obj.blockHeight = message.blockHeight ? BlockHeight.toJSON(message.blockHeight) : undefined); - message.parentSlot !== undefined && (obj.parentSlot = message.parentSlot); - message.parentBlockhash !== undefined && (obj.parentBlockhash = message.parentBlockhash); - message.executedTransactionCount !== undefined && (obj.executedTransactionCount = message.executedTransactionCount); - message.entriesCount !== undefined && (obj.entriesCount = message.entriesCount); - return obj; - }, - - create, I>>(base?: I): SubscribeUpdateBlockMeta { - return SubscribeUpdateBlockMeta.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): SubscribeUpdateBlockMeta { - const message = createBaseSubscribeUpdateBlockMeta(); - message.slot = object.slot ?? "0"; - message.blockhash = object.blockhash ?? ""; - message.rewards = (object.rewards !== undefined && object.rewards !== null) - ? Rewards.fromPartial(object.rewards) - : undefined; - message.blockTime = (object.blockTime !== undefined && object.blockTime !== null) - ? UnixTimestamp.fromPartial(object.blockTime) - : undefined; - message.blockHeight = (object.blockHeight !== undefined && object.blockHeight !== null) - ? BlockHeight.fromPartial(object.blockHeight) - : undefined; - message.parentSlot = object.parentSlot ?? "0"; - message.parentBlockhash = object.parentBlockhash ?? ""; - message.executedTransactionCount = object.executedTransactionCount ?? "0"; - message.entriesCount = object.entriesCount ?? "0"; - return message; - }, -}; - -function createBaseSubscribeUpdateEntry(): SubscribeUpdateEntry { - return { - slot: "0", - index: "0", - numHashes: "0", - hash: new Uint8Array(0), - executedTransactionCount: "0", - startingTransactionIndex: "0", - }; -} - -export const SubscribeUpdateEntry = { - encode(message: SubscribeUpdateEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.slot !== "0") { - writer.uint32(8).uint64(message.slot); - } - if (message.index !== "0") { - writer.uint32(16).uint64(message.index); - } - if (message.numHashes !== "0") { - writer.uint32(24).uint64(message.numHashes); - } - if (message.hash.length !== 0) { - writer.uint32(34).bytes(message.hash); - } - if (message.executedTransactionCount !== "0") { - writer.uint32(40).uint64(message.executedTransactionCount); - } - if (message.startingTransactionIndex !== "0") { - writer.uint32(48).uint64(message.startingTransactionIndex); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeUpdateEntry { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeUpdateEntry(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.slot = longToString(reader.uint64() as Long); - continue; - case 2: - if (tag !== 16) { - break; - } - - message.index = longToString(reader.uint64() as Long); - continue; - case 3: - if (tag !== 24) { - break; - } - - message.numHashes = longToString(reader.uint64() as Long); - continue; - case 4: - if (tag !== 34) { - break; - } - - message.hash = reader.bytes(); - continue; - case 5: - if (tag !== 40) { - break; - } - - message.executedTransactionCount = longToString(reader.uint64() as Long); - continue; - case 6: - if (tag !== 48) { - break; - } - - message.startingTransactionIndex = longToString(reader.uint64() as Long); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): SubscribeUpdateEntry { - return { - slot: isSet(object.slot) ? String(object.slot) : "0", - index: isSet(object.index) ? String(object.index) : "0", - numHashes: isSet(object.numHashes) ? String(object.numHashes) : "0", - hash: isSet(object.hash) ? bytesFromBase64(object.hash) : new Uint8Array(0), - executedTransactionCount: isSet(object.executedTransactionCount) ? String(object.executedTransactionCount) : "0", - startingTransactionIndex: isSet(object.startingTransactionIndex) ? String(object.startingTransactionIndex) : "0", - }; - }, - - toJSON(message: SubscribeUpdateEntry): unknown { - const obj: any = {}; - message.slot !== undefined && (obj.slot = message.slot); - message.index !== undefined && (obj.index = message.index); - message.numHashes !== undefined && (obj.numHashes = message.numHashes); - message.hash !== undefined && - (obj.hash = base64FromBytes(message.hash !== undefined ? message.hash : new Uint8Array(0))); - message.executedTransactionCount !== undefined && (obj.executedTransactionCount = message.executedTransactionCount); - message.startingTransactionIndex !== undefined && (obj.startingTransactionIndex = message.startingTransactionIndex); - return obj; - }, - - create, I>>(base?: I): SubscribeUpdateEntry { - return SubscribeUpdateEntry.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): SubscribeUpdateEntry { - const message = createBaseSubscribeUpdateEntry(); - message.slot = object.slot ?? "0"; - message.index = object.index ?? "0"; - message.numHashes = object.numHashes ?? "0"; - message.hash = object.hash ?? new Uint8Array(0); - message.executedTransactionCount = object.executedTransactionCount ?? "0"; - message.startingTransactionIndex = object.startingTransactionIndex ?? "0"; - return message; - }, -}; - -function createBaseSubscribeUpdatePing(): SubscribeUpdatePing { - return {}; -} - -export const SubscribeUpdatePing = { - encode(_: SubscribeUpdatePing, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeUpdatePing { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeUpdatePing(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(_: any): SubscribeUpdatePing { - return {}; - }, - - toJSON(_: SubscribeUpdatePing): unknown { - const obj: any = {}; - return obj; - }, - - create, I>>(base?: I): SubscribeUpdatePing { - return SubscribeUpdatePing.fromPartial(base ?? {}); - }, - - fromPartial, I>>(_: I): SubscribeUpdatePing { - const message = createBaseSubscribeUpdatePing(); - return message; - }, -}; - -function createBaseSubscribeUpdatePong(): SubscribeUpdatePong { - return { id: 0 }; -} - -export const SubscribeUpdatePong = { - encode(message: SubscribeUpdatePong, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.id !== 0) { - writer.uint32(8).int32(message.id); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeUpdatePong { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSubscribeUpdatePong(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.id = reader.int32(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): SubscribeUpdatePong { - return { id: isSet(object.id) ? Number(object.id) : 0 }; - }, - - toJSON(message: SubscribeUpdatePong): unknown { - const obj: any = {}; - message.id !== undefined && (obj.id = Math.round(message.id)); - return obj; - }, - - create, I>>(base?: I): SubscribeUpdatePong { - return SubscribeUpdatePong.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): SubscribeUpdatePong { - const message = createBaseSubscribeUpdatePong(); - message.id = object.id ?? 0; - return message; - }, -}; - -function createBasePingRequest(): PingRequest { - return { count: 0 }; -} - -export const PingRequest = { - encode(message: PingRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.count !== 0) { - writer.uint32(8).int32(message.count); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): PingRequest { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBasePingRequest(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.count = reader.int32(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): PingRequest { - return { count: isSet(object.count) ? Number(object.count) : 0 }; - }, - - toJSON(message: PingRequest): unknown { - const obj: any = {}; - message.count !== undefined && (obj.count = Math.round(message.count)); - return obj; - }, - - create, I>>(base?: I): PingRequest { - return PingRequest.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): PingRequest { - const message = createBasePingRequest(); - message.count = object.count ?? 0; - return message; - }, -}; - -function createBasePongResponse(): PongResponse { - return { count: 0 }; -} - -export const PongResponse = { - encode(message: PongResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.count !== 0) { - writer.uint32(8).int32(message.count); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): PongResponse { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBasePongResponse(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.count = reader.int32(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): PongResponse { - return { count: isSet(object.count) ? Number(object.count) : 0 }; - }, - - toJSON(message: PongResponse): unknown { - const obj: any = {}; - message.count !== undefined && (obj.count = Math.round(message.count)); - return obj; - }, - - create, I>>(base?: I): PongResponse { - return PongResponse.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): PongResponse { - const message = createBasePongResponse(); - message.count = object.count ?? 0; - return message; - }, -}; - -function createBaseGetLatestBlockhashRequest(): GetLatestBlockhashRequest { - return { commitment: undefined }; -} - -export const GetLatestBlockhashRequest = { - encode(message: GetLatestBlockhashRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.commitment !== undefined) { - writer.uint32(8).int32(message.commitment); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): GetLatestBlockhashRequest { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseGetLatestBlockhashRequest(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.commitment = reader.int32() as any; - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): GetLatestBlockhashRequest { - return { commitment: isSet(object.commitment) ? commitmentLevelFromJSON(object.commitment) : undefined }; - }, - - toJSON(message: GetLatestBlockhashRequest): unknown { - const obj: any = {}; - message.commitment !== undefined && - (obj.commitment = message.commitment !== undefined ? commitmentLevelToJSON(message.commitment) : undefined); - return obj; - }, - - create, I>>(base?: I): GetLatestBlockhashRequest { - return GetLatestBlockhashRequest.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): GetLatestBlockhashRequest { - const message = createBaseGetLatestBlockhashRequest(); - message.commitment = object.commitment ?? undefined; - return message; - }, -}; - -function createBaseGetLatestBlockhashResponse(): GetLatestBlockhashResponse { - return { slot: "0", blockhash: "", lastValidBlockHeight: "0" }; -} - -export const GetLatestBlockhashResponse = { - encode(message: GetLatestBlockhashResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.slot !== "0") { - writer.uint32(8).uint64(message.slot); - } - if (message.blockhash !== "") { - writer.uint32(18).string(message.blockhash); - } - if (message.lastValidBlockHeight !== "0") { - writer.uint32(24).uint64(message.lastValidBlockHeight); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): GetLatestBlockhashResponse { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseGetLatestBlockhashResponse(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.slot = longToString(reader.uint64() as Long); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.blockhash = reader.string(); - continue; - case 3: - if (tag !== 24) { - break; - } - - message.lastValidBlockHeight = longToString(reader.uint64() as Long); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): GetLatestBlockhashResponse { - return { - slot: isSet(object.slot) ? String(object.slot) : "0", - blockhash: isSet(object.blockhash) ? String(object.blockhash) : "", - lastValidBlockHeight: isSet(object.lastValidBlockHeight) ? String(object.lastValidBlockHeight) : "0", - }; - }, - - toJSON(message: GetLatestBlockhashResponse): unknown { - const obj: any = {}; - message.slot !== undefined && (obj.slot = message.slot); - message.blockhash !== undefined && (obj.blockhash = message.blockhash); - message.lastValidBlockHeight !== undefined && (obj.lastValidBlockHeight = message.lastValidBlockHeight); - return obj; - }, - - create, I>>(base?: I): GetLatestBlockhashResponse { - return GetLatestBlockhashResponse.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): GetLatestBlockhashResponse { - const message = createBaseGetLatestBlockhashResponse(); - message.slot = object.slot ?? "0"; - message.blockhash = object.blockhash ?? ""; - message.lastValidBlockHeight = object.lastValidBlockHeight ?? "0"; - return message; - }, -}; - -function createBaseGetBlockHeightRequest(): GetBlockHeightRequest { - return { commitment: undefined }; -} - -export const GetBlockHeightRequest = { - encode(message: GetBlockHeightRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.commitment !== undefined) { - writer.uint32(8).int32(message.commitment); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): GetBlockHeightRequest { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseGetBlockHeightRequest(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.commitment = reader.int32() as any; - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): GetBlockHeightRequest { - return { commitment: isSet(object.commitment) ? commitmentLevelFromJSON(object.commitment) : undefined }; - }, - - toJSON(message: GetBlockHeightRequest): unknown { - const obj: any = {}; - message.commitment !== undefined && - (obj.commitment = message.commitment !== undefined ? commitmentLevelToJSON(message.commitment) : undefined); - return obj; - }, - - create, I>>(base?: I): GetBlockHeightRequest { - return GetBlockHeightRequest.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): GetBlockHeightRequest { - const message = createBaseGetBlockHeightRequest(); - message.commitment = object.commitment ?? undefined; - return message; - }, -}; - -function createBaseGetBlockHeightResponse(): GetBlockHeightResponse { - return { blockHeight: "0" }; -} - -export const GetBlockHeightResponse = { - encode(message: GetBlockHeightResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.blockHeight !== "0") { - writer.uint32(8).uint64(message.blockHeight); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): GetBlockHeightResponse { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseGetBlockHeightResponse(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.blockHeight = longToString(reader.uint64() as Long); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): GetBlockHeightResponse { - return { blockHeight: isSet(object.blockHeight) ? String(object.blockHeight) : "0" }; - }, - - toJSON(message: GetBlockHeightResponse): unknown { - const obj: any = {}; - message.blockHeight !== undefined && (obj.blockHeight = message.blockHeight); - return obj; - }, - - create, I>>(base?: I): GetBlockHeightResponse { - return GetBlockHeightResponse.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): GetBlockHeightResponse { - const message = createBaseGetBlockHeightResponse(); - message.blockHeight = object.blockHeight ?? "0"; - return message; - }, -}; - -function createBaseGetSlotRequest(): GetSlotRequest { - return { commitment: undefined }; -} - -export const GetSlotRequest = { - encode(message: GetSlotRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.commitment !== undefined) { - writer.uint32(8).int32(message.commitment); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): GetSlotRequest { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseGetSlotRequest(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.commitment = reader.int32() as any; - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): GetSlotRequest { - return { commitment: isSet(object.commitment) ? commitmentLevelFromJSON(object.commitment) : undefined }; - }, - - toJSON(message: GetSlotRequest): unknown { - const obj: any = {}; - message.commitment !== undefined && - (obj.commitment = message.commitment !== undefined ? commitmentLevelToJSON(message.commitment) : undefined); - return obj; - }, - - create, I>>(base?: I): GetSlotRequest { - return GetSlotRequest.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): GetSlotRequest { - const message = createBaseGetSlotRequest(); - message.commitment = object.commitment ?? undefined; - return message; - }, -}; - -function createBaseGetSlotResponse(): GetSlotResponse { - return { slot: "0" }; -} - -export const GetSlotResponse = { - encode(message: GetSlotResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.slot !== "0") { - writer.uint32(8).uint64(message.slot); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): GetSlotResponse { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseGetSlotResponse(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.slot = longToString(reader.uint64() as Long); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): GetSlotResponse { - return { slot: isSet(object.slot) ? String(object.slot) : "0" }; - }, - - toJSON(message: GetSlotResponse): unknown { - const obj: any = {}; - message.slot !== undefined && (obj.slot = message.slot); - return obj; - }, - - create, I>>(base?: I): GetSlotResponse { - return GetSlotResponse.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): GetSlotResponse { - const message = createBaseGetSlotResponse(); - message.slot = object.slot ?? "0"; - return message; - }, -}; - -function createBaseGetVersionRequest(): GetVersionRequest { - return {}; -} - -export const GetVersionRequest = { - encode(_: GetVersionRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): GetVersionRequest { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseGetVersionRequest(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(_: any): GetVersionRequest { - return {}; - }, - - toJSON(_: GetVersionRequest): unknown { - const obj: any = {}; - return obj; - }, - - create, I>>(base?: I): GetVersionRequest { - return GetVersionRequest.fromPartial(base ?? {}); - }, - - fromPartial, I>>(_: I): GetVersionRequest { - const message = createBaseGetVersionRequest(); - return message; - }, -}; - -function createBaseGetVersionResponse(): GetVersionResponse { - return { version: "" }; -} - -export const GetVersionResponse = { - encode(message: GetVersionResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.version !== "") { - writer.uint32(10).string(message.version); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): GetVersionResponse { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseGetVersionResponse(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.version = reader.string(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): GetVersionResponse { - return { version: isSet(object.version) ? String(object.version) : "" }; - }, - - toJSON(message: GetVersionResponse): unknown { - const obj: any = {}; - message.version !== undefined && (obj.version = message.version); - return obj; - }, - - create, I>>(base?: I): GetVersionResponse { - return GetVersionResponse.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): GetVersionResponse { - const message = createBaseGetVersionResponse(); - message.version = object.version ?? ""; - return message; - }, -}; - -function createBaseIsBlockhashValidRequest(): IsBlockhashValidRequest { - return { blockhash: "", commitment: undefined }; -} - -export const IsBlockhashValidRequest = { - encode(message: IsBlockhashValidRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.blockhash !== "") { - writer.uint32(10).string(message.blockhash); - } - if (message.commitment !== undefined) { - writer.uint32(16).int32(message.commitment); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): IsBlockhashValidRequest { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseIsBlockhashValidRequest(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.blockhash = reader.string(); - continue; - case 2: - if (tag !== 16) { - break; - } - - message.commitment = reader.int32() as any; - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): IsBlockhashValidRequest { - return { - blockhash: isSet(object.blockhash) ? String(object.blockhash) : "", - commitment: isSet(object.commitment) ? commitmentLevelFromJSON(object.commitment) : undefined, - }; - }, - - toJSON(message: IsBlockhashValidRequest): unknown { - const obj: any = {}; - message.blockhash !== undefined && (obj.blockhash = message.blockhash); - message.commitment !== undefined && - (obj.commitment = message.commitment !== undefined ? commitmentLevelToJSON(message.commitment) : undefined); - return obj; - }, - - create, I>>(base?: I): IsBlockhashValidRequest { - return IsBlockhashValidRequest.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): IsBlockhashValidRequest { - const message = createBaseIsBlockhashValidRequest(); - message.blockhash = object.blockhash ?? ""; - message.commitment = object.commitment ?? undefined; - return message; - }, -}; - -function createBaseIsBlockhashValidResponse(): IsBlockhashValidResponse { - return { slot: "0", valid: false }; -} - -export const IsBlockhashValidResponse = { - encode(message: IsBlockhashValidResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.slot !== "0") { - writer.uint32(8).uint64(message.slot); - } - if (message.valid === true) { - writer.uint32(16).bool(message.valid); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): IsBlockhashValidResponse { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseIsBlockhashValidResponse(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.slot = longToString(reader.uint64() as Long); - continue; - case 2: - if (tag !== 16) { - break; - } - - message.valid = reader.bool(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): IsBlockhashValidResponse { - return { - slot: isSet(object.slot) ? String(object.slot) : "0", - valid: isSet(object.valid) ? Boolean(object.valid) : false, - }; - }, - - toJSON(message: IsBlockhashValidResponse): unknown { - const obj: any = {}; - message.slot !== undefined && (obj.slot = message.slot); - message.valid !== undefined && (obj.valid = message.valid); - return obj; - }, - - create, I>>(base?: I): IsBlockhashValidResponse { - return IsBlockhashValidResponse.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): IsBlockhashValidResponse { - const message = createBaseIsBlockhashValidResponse(); - message.slot = object.slot ?? "0"; - message.valid = object.valid ?? false; - return message; - }, -}; - -export type GeyserService = typeof GeyserService; -export const GeyserService = { - subscribe: { - path: "/geyser.Geyser/Subscribe", - requestStream: true, - responseStream: true, - requestSerialize: (value: SubscribeRequest) => Buffer.from(SubscribeRequest.encode(value).finish()), - requestDeserialize: (value: Buffer) => SubscribeRequest.decode(value), - responseSerialize: (value: SubscribeUpdate) => Buffer.from(SubscribeUpdate.encode(value).finish()), - responseDeserialize: (value: Buffer) => SubscribeUpdate.decode(value), - }, - ping: { - path: "/geyser.Geyser/Ping", - requestStream: false, - responseStream: false, - requestSerialize: (value: PingRequest) => Buffer.from(PingRequest.encode(value).finish()), - requestDeserialize: (value: Buffer) => PingRequest.decode(value), - responseSerialize: (value: PongResponse) => Buffer.from(PongResponse.encode(value).finish()), - responseDeserialize: (value: Buffer) => PongResponse.decode(value), - }, - getLatestBlockhash: { - path: "/geyser.Geyser/GetLatestBlockhash", - requestStream: false, - responseStream: false, - requestSerialize: (value: GetLatestBlockhashRequest) => - Buffer.from(GetLatestBlockhashRequest.encode(value).finish()), - requestDeserialize: (value: Buffer) => GetLatestBlockhashRequest.decode(value), - responseSerialize: (value: GetLatestBlockhashResponse) => - Buffer.from(GetLatestBlockhashResponse.encode(value).finish()), - responseDeserialize: (value: Buffer) => GetLatestBlockhashResponse.decode(value), - }, - getBlockHeight: { - path: "/geyser.Geyser/GetBlockHeight", - requestStream: false, - responseStream: false, - requestSerialize: (value: GetBlockHeightRequest) => Buffer.from(GetBlockHeightRequest.encode(value).finish()), - requestDeserialize: (value: Buffer) => GetBlockHeightRequest.decode(value), - responseSerialize: (value: GetBlockHeightResponse) => Buffer.from(GetBlockHeightResponse.encode(value).finish()), - responseDeserialize: (value: Buffer) => GetBlockHeightResponse.decode(value), - }, - getSlot: { - path: "/geyser.Geyser/GetSlot", - requestStream: false, - responseStream: false, - requestSerialize: (value: GetSlotRequest) => Buffer.from(GetSlotRequest.encode(value).finish()), - requestDeserialize: (value: Buffer) => GetSlotRequest.decode(value), - responseSerialize: (value: GetSlotResponse) => Buffer.from(GetSlotResponse.encode(value).finish()), - responseDeserialize: (value: Buffer) => GetSlotResponse.decode(value), - }, - isBlockhashValid: { - path: "/geyser.Geyser/IsBlockhashValid", - requestStream: false, - responseStream: false, - requestSerialize: (value: IsBlockhashValidRequest) => Buffer.from(IsBlockhashValidRequest.encode(value).finish()), - requestDeserialize: (value: Buffer) => IsBlockhashValidRequest.decode(value), - responseSerialize: (value: IsBlockhashValidResponse) => - Buffer.from(IsBlockhashValidResponse.encode(value).finish()), - responseDeserialize: (value: Buffer) => IsBlockhashValidResponse.decode(value), - }, - getVersion: { - path: "/geyser.Geyser/GetVersion", - requestStream: false, - responseStream: false, - requestSerialize: (value: GetVersionRequest) => Buffer.from(GetVersionRequest.encode(value).finish()), - requestDeserialize: (value: Buffer) => GetVersionRequest.decode(value), - responseSerialize: (value: GetVersionResponse) => Buffer.from(GetVersionResponse.encode(value).finish()), - responseDeserialize: (value: Buffer) => GetVersionResponse.decode(value), - }, -} as const; - -export interface GeyserServer extends UntypedServiceImplementation { - subscribe: handleBidiStreamingCall; - ping: handleUnaryCall; - getLatestBlockhash: handleUnaryCall; - getBlockHeight: handleUnaryCall; - getSlot: handleUnaryCall; - isBlockhashValid: handleUnaryCall; - getVersion: handleUnaryCall; -} - -export interface GeyserClient extends Client { - subscribe(): ClientDuplexStream; - subscribe(options: Partial): ClientDuplexStream; - subscribe(metadata: Metadata, options?: Partial): ClientDuplexStream; - ping(request: PingRequest, callback: (error: ServiceError | null, response: PongResponse) => void): ClientUnaryCall; - ping( - request: PingRequest, - metadata: Metadata, - callback: (error: ServiceError | null, response: PongResponse) => void, - ): ClientUnaryCall; - ping( - request: PingRequest, - metadata: Metadata, - options: Partial, - callback: (error: ServiceError | null, response: PongResponse) => void, - ): ClientUnaryCall; - getLatestBlockhash( - request: GetLatestBlockhashRequest, - callback: (error: ServiceError | null, response: GetLatestBlockhashResponse) => void, - ): ClientUnaryCall; - getLatestBlockhash( - request: GetLatestBlockhashRequest, - metadata: Metadata, - callback: (error: ServiceError | null, response: GetLatestBlockhashResponse) => void, - ): ClientUnaryCall; - getLatestBlockhash( - request: GetLatestBlockhashRequest, - metadata: Metadata, - options: Partial, - callback: (error: ServiceError | null, response: GetLatestBlockhashResponse) => void, - ): ClientUnaryCall; - getBlockHeight( - request: GetBlockHeightRequest, - callback: (error: ServiceError | null, response: GetBlockHeightResponse) => void, - ): ClientUnaryCall; - getBlockHeight( - request: GetBlockHeightRequest, - metadata: Metadata, - callback: (error: ServiceError | null, response: GetBlockHeightResponse) => void, - ): ClientUnaryCall; - getBlockHeight( - request: GetBlockHeightRequest, - metadata: Metadata, - options: Partial, - callback: (error: ServiceError | null, response: GetBlockHeightResponse) => void, - ): ClientUnaryCall; - getSlot( - request: GetSlotRequest, - callback: (error: ServiceError | null, response: GetSlotResponse) => void, - ): ClientUnaryCall; - getSlot( - request: GetSlotRequest, - metadata: Metadata, - callback: (error: ServiceError | null, response: GetSlotResponse) => void, - ): ClientUnaryCall; - getSlot( - request: GetSlotRequest, - metadata: Metadata, - options: Partial, - callback: (error: ServiceError | null, response: GetSlotResponse) => void, - ): ClientUnaryCall; - isBlockhashValid( - request: IsBlockhashValidRequest, - callback: (error: ServiceError | null, response: IsBlockhashValidResponse) => void, - ): ClientUnaryCall; - isBlockhashValid( - request: IsBlockhashValidRequest, - metadata: Metadata, - callback: (error: ServiceError | null, response: IsBlockhashValidResponse) => void, - ): ClientUnaryCall; - isBlockhashValid( - request: IsBlockhashValidRequest, - metadata: Metadata, - options: Partial, - callback: (error: ServiceError | null, response: IsBlockhashValidResponse) => void, - ): ClientUnaryCall; - getVersion( - request: GetVersionRequest, - callback: (error: ServiceError | null, response: GetVersionResponse) => void, - ): ClientUnaryCall; - getVersion( - request: GetVersionRequest, - metadata: Metadata, - callback: (error: ServiceError | null, response: GetVersionResponse) => void, - ): ClientUnaryCall; - getVersion( - request: GetVersionRequest, - metadata: Metadata, - options: Partial, - callback: (error: ServiceError | null, response: GetVersionResponse) => void, - ): ClientUnaryCall; -} - -export const GeyserClient = makeGenericClientConstructor(GeyserService, "geyser.Geyser") as unknown as { - new (address: string, credentials: ChannelCredentials, options?: Partial): GeyserClient; - service: typeof GeyserService; -}; - -declare var self: any | undefined; -declare var window: any | undefined; -declare var global: any | undefined; -var tsProtoGlobalThis: any = (() => { - if (typeof globalThis !== "undefined") { - return globalThis; - } - if (typeof self !== "undefined") { - return self; - } - if (typeof window !== "undefined") { - return window; - } - if (typeof global !== "undefined") { - return global; - } - throw "Unable to locate global object"; -})(); - -function bytesFromBase64(b64: string): Uint8Array { - if (tsProtoGlobalThis.Buffer) { - return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, "base64")); - } else { - const bin = tsProtoGlobalThis.atob(b64); - const arr = new Uint8Array(bin.length); - for (let i = 0; i < bin.length; ++i) { - arr[i] = bin.charCodeAt(i); - } - return arr; - } -} - -function base64FromBytes(arr: Uint8Array): string { - if (tsProtoGlobalThis.Buffer) { - return tsProtoGlobalThis.Buffer.from(arr).toString("base64"); - } else { - const bin: string[] = []; - arr.forEach((byte) => { - bin.push(String.fromCharCode(byte)); - }); - return tsProtoGlobalThis.btoa(bin.join("")); - } -} - -type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; - -export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> - : T extends {} ? { [K in keyof T]?: DeepPartial } - : Partial; - -type KeysOfUnion = T extends T ? keyof T : never; -export type Exact = P extends Builtin ? P - : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; - -function longToString(long: Long) { - return long.toString(); -} - -// If you get a compile-error about 'Constructor and ... have no overlap', -// add '--ts_proto_opt=esModuleInterop=true' as a flag when calling 'protoc'. -if (_m0.util.Long !== Long) { - _m0.util.Long = Long as any; - _m0.configure(); -} - -function isObject(value: any): boolean { - return typeof value === "object" && value !== null; -} - -function isSet(value: any): boolean { - return value !== null && value !== undefined; -} diff --git a/yellowstone-grpc-client-nodejs/src/grpc/solana-storage.ts b/yellowstone-grpc-client-nodejs/src/grpc/solana-storage.ts deleted file mode 100644 index 0a089228..00000000 --- a/yellowstone-grpc-client-nodejs/src/grpc/solana-storage.ts +++ /dev/null @@ -1,2235 +0,0 @@ -/* eslint-disable */ -import * as Long from "long"; -import * as _m0 from "protobufjs/minimal"; - -export const protobufPackage = "solana.storage.ConfirmedBlock"; - -export enum RewardType { - Unspecified = 0, - Fee = 1, - Rent = 2, - Staking = 3, - Voting = 4, - UNRECOGNIZED = -1, -} - -export function rewardTypeFromJSON(object: any): RewardType { - switch (object) { - case 0: - case "Unspecified": - return RewardType.Unspecified; - case 1: - case "Fee": - return RewardType.Fee; - case 2: - case "Rent": - return RewardType.Rent; - case 3: - case "Staking": - return RewardType.Staking; - case 4: - case "Voting": - return RewardType.Voting; - case -1: - case "UNRECOGNIZED": - default: - return RewardType.UNRECOGNIZED; - } -} - -export function rewardTypeToJSON(object: RewardType): string { - switch (object) { - case RewardType.Unspecified: - return "Unspecified"; - case RewardType.Fee: - return "Fee"; - case RewardType.Rent: - return "Rent"; - case RewardType.Staking: - return "Staking"; - case RewardType.Voting: - return "Voting"; - case RewardType.UNRECOGNIZED: - default: - return "UNRECOGNIZED"; - } -} - -export interface ConfirmedBlock { - previousBlockhash: string; - blockhash: string; - parentSlot: string; - transactions: ConfirmedTransaction[]; - rewards: Reward[]; - blockTime: UnixTimestamp | undefined; - blockHeight: BlockHeight | undefined; - numPartitions: NumPartitions | undefined; -} - -export interface ConfirmedTransaction { - transaction: Transaction | undefined; - meta: TransactionStatusMeta | undefined; -} - -export interface Transaction { - signatures: Uint8Array[]; - message: Message | undefined; -} - -export interface Message { - header: MessageHeader | undefined; - accountKeys: Uint8Array[]; - recentBlockhash: Uint8Array; - instructions: CompiledInstruction[]; - versioned: boolean; - addressTableLookups: MessageAddressTableLookup[]; -} - -export interface MessageHeader { - numRequiredSignatures: number; - numReadonlySignedAccounts: number; - numReadonlyUnsignedAccounts: number; -} - -export interface MessageAddressTableLookup { - accountKey: Uint8Array; - writableIndexes: Uint8Array; - readonlyIndexes: Uint8Array; -} - -export interface TransactionStatusMeta { - err: TransactionError | undefined; - fee: string; - preBalances: string[]; - postBalances: string[]; - innerInstructions: InnerInstructions[]; - innerInstructionsNone: boolean; - logMessages: string[]; - logMessagesNone: boolean; - preTokenBalances: TokenBalance[]; - postTokenBalances: TokenBalance[]; - rewards: Reward[]; - loadedWritableAddresses: Uint8Array[]; - loadedReadonlyAddresses: Uint8Array[]; - returnData: ReturnData | undefined; - returnDataNone: boolean; - /** - * Sum of compute units consumed by all instructions. - * Available since Solana v1.10.35 / v1.11.6. - * Set to `None` for txs executed on earlier versions. - */ - computeUnitsConsumed?: string | undefined; -} - -export interface TransactionError { - err: Uint8Array; -} - -export interface InnerInstructions { - index: number; - instructions: InnerInstruction[]; -} - -export interface InnerInstruction { - programIdIndex: number; - accounts: Uint8Array; - data: Uint8Array; - /** - * Invocation stack height of an inner instruction. - * Available since Solana v1.14.6 - * Set to `None` for txs executed on earlier versions. - */ - stackHeight?: number | undefined; -} - -export interface CompiledInstruction { - programIdIndex: number; - accounts: Uint8Array; - data: Uint8Array; -} - -export interface TokenBalance { - accountIndex: number; - mint: string; - uiTokenAmount: UiTokenAmount | undefined; - owner: string; - programId: string; -} - -export interface UiTokenAmount { - uiAmount: number; - decimals: number; - amount: string; - uiAmountString: string; -} - -export interface ReturnData { - programId: Uint8Array; - data: Uint8Array; -} - -export interface Reward { - pubkey: string; - lamports: string; - postBalance: string; - rewardType: RewardType; - commission: string; -} - -export interface Rewards { - rewards: Reward[]; - numPartitions: NumPartitions | undefined; -} - -export interface UnixTimestamp { - timestamp: string; -} - -export interface BlockHeight { - blockHeight: string; -} - -export interface NumPartitions { - numPartitions: string; -} - -function createBaseConfirmedBlock(): ConfirmedBlock { - return { - previousBlockhash: "", - blockhash: "", - parentSlot: "0", - transactions: [], - rewards: [], - blockTime: undefined, - blockHeight: undefined, - numPartitions: undefined, - }; -} - -export const ConfirmedBlock = { - encode(message: ConfirmedBlock, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.previousBlockhash !== "") { - writer.uint32(10).string(message.previousBlockhash); - } - if (message.blockhash !== "") { - writer.uint32(18).string(message.blockhash); - } - if (message.parentSlot !== "0") { - writer.uint32(24).uint64(message.parentSlot); - } - for (const v of message.transactions) { - ConfirmedTransaction.encode(v!, writer.uint32(34).fork()).ldelim(); - } - for (const v of message.rewards) { - Reward.encode(v!, writer.uint32(42).fork()).ldelim(); - } - if (message.blockTime !== undefined) { - UnixTimestamp.encode(message.blockTime, writer.uint32(50).fork()).ldelim(); - } - if (message.blockHeight !== undefined) { - BlockHeight.encode(message.blockHeight, writer.uint32(58).fork()).ldelim(); - } - if (message.numPartitions !== undefined) { - NumPartitions.encode(message.numPartitions, writer.uint32(66).fork()).ldelim(); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): ConfirmedBlock { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseConfirmedBlock(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.previousBlockhash = reader.string(); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.blockhash = reader.string(); - continue; - case 3: - if (tag !== 24) { - break; - } - - message.parentSlot = longToString(reader.uint64() as Long); - continue; - case 4: - if (tag !== 34) { - break; - } - - message.transactions.push(ConfirmedTransaction.decode(reader, reader.uint32())); - continue; - case 5: - if (tag !== 42) { - break; - } - - message.rewards.push(Reward.decode(reader, reader.uint32())); - continue; - case 6: - if (tag !== 50) { - break; - } - - message.blockTime = UnixTimestamp.decode(reader, reader.uint32()); - continue; - case 7: - if (tag !== 58) { - break; - } - - message.blockHeight = BlockHeight.decode(reader, reader.uint32()); - continue; - case 8: - if (tag !== 66) { - break; - } - - message.numPartitions = NumPartitions.decode(reader, reader.uint32()); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): ConfirmedBlock { - return { - previousBlockhash: isSet(object.previousBlockhash) ? String(object.previousBlockhash) : "", - blockhash: isSet(object.blockhash) ? String(object.blockhash) : "", - parentSlot: isSet(object.parentSlot) ? String(object.parentSlot) : "0", - transactions: Array.isArray(object?.transactions) - ? object.transactions.map((e: any) => ConfirmedTransaction.fromJSON(e)) - : [], - rewards: Array.isArray(object?.rewards) ? object.rewards.map((e: any) => Reward.fromJSON(e)) : [], - blockTime: isSet(object.blockTime) ? UnixTimestamp.fromJSON(object.blockTime) : undefined, - blockHeight: isSet(object.blockHeight) ? BlockHeight.fromJSON(object.blockHeight) : undefined, - numPartitions: isSet(object.numPartitions) ? NumPartitions.fromJSON(object.numPartitions) : undefined, - }; - }, - - toJSON(message: ConfirmedBlock): unknown { - const obj: any = {}; - message.previousBlockhash !== undefined && (obj.previousBlockhash = message.previousBlockhash); - message.blockhash !== undefined && (obj.blockhash = message.blockhash); - message.parentSlot !== undefined && (obj.parentSlot = message.parentSlot); - if (message.transactions) { - obj.transactions = message.transactions.map((e) => e ? ConfirmedTransaction.toJSON(e) : undefined); - } else { - obj.transactions = []; - } - if (message.rewards) { - obj.rewards = message.rewards.map((e) => e ? Reward.toJSON(e) : undefined); - } else { - obj.rewards = []; - } - message.blockTime !== undefined && - (obj.blockTime = message.blockTime ? UnixTimestamp.toJSON(message.blockTime) : undefined); - message.blockHeight !== undefined && - (obj.blockHeight = message.blockHeight ? BlockHeight.toJSON(message.blockHeight) : undefined); - message.numPartitions !== undefined && - (obj.numPartitions = message.numPartitions ? NumPartitions.toJSON(message.numPartitions) : undefined); - return obj; - }, - - create, I>>(base?: I): ConfirmedBlock { - return ConfirmedBlock.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): ConfirmedBlock { - const message = createBaseConfirmedBlock(); - message.previousBlockhash = object.previousBlockhash ?? ""; - message.blockhash = object.blockhash ?? ""; - message.parentSlot = object.parentSlot ?? "0"; - message.transactions = object.transactions?.map((e) => ConfirmedTransaction.fromPartial(e)) || []; - message.rewards = object.rewards?.map((e) => Reward.fromPartial(e)) || []; - message.blockTime = (object.blockTime !== undefined && object.blockTime !== null) - ? UnixTimestamp.fromPartial(object.blockTime) - : undefined; - message.blockHeight = (object.blockHeight !== undefined && object.blockHeight !== null) - ? BlockHeight.fromPartial(object.blockHeight) - : undefined; - message.numPartitions = (object.numPartitions !== undefined && object.numPartitions !== null) - ? NumPartitions.fromPartial(object.numPartitions) - : undefined; - return message; - }, -}; - -function createBaseConfirmedTransaction(): ConfirmedTransaction { - return { transaction: undefined, meta: undefined }; -} - -export const ConfirmedTransaction = { - encode(message: ConfirmedTransaction, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.transaction !== undefined) { - Transaction.encode(message.transaction, writer.uint32(10).fork()).ldelim(); - } - if (message.meta !== undefined) { - TransactionStatusMeta.encode(message.meta, writer.uint32(18).fork()).ldelim(); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): ConfirmedTransaction { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseConfirmedTransaction(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.transaction = Transaction.decode(reader, reader.uint32()); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.meta = TransactionStatusMeta.decode(reader, reader.uint32()); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): ConfirmedTransaction { - return { - transaction: isSet(object.transaction) ? Transaction.fromJSON(object.transaction) : undefined, - meta: isSet(object.meta) ? TransactionStatusMeta.fromJSON(object.meta) : undefined, - }; - }, - - toJSON(message: ConfirmedTransaction): unknown { - const obj: any = {}; - message.transaction !== undefined && - (obj.transaction = message.transaction ? Transaction.toJSON(message.transaction) : undefined); - message.meta !== undefined && (obj.meta = message.meta ? TransactionStatusMeta.toJSON(message.meta) : undefined); - return obj; - }, - - create, I>>(base?: I): ConfirmedTransaction { - return ConfirmedTransaction.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): ConfirmedTransaction { - const message = createBaseConfirmedTransaction(); - message.transaction = (object.transaction !== undefined && object.transaction !== null) - ? Transaction.fromPartial(object.transaction) - : undefined; - message.meta = (object.meta !== undefined && object.meta !== null) - ? TransactionStatusMeta.fromPartial(object.meta) - : undefined; - return message; - }, -}; - -function createBaseTransaction(): Transaction { - return { signatures: [], message: undefined }; -} - -export const Transaction = { - encode(message: Transaction, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - for (const v of message.signatures) { - writer.uint32(10).bytes(v!); - } - if (message.message !== undefined) { - Message.encode(message.message, writer.uint32(18).fork()).ldelim(); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): Transaction { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseTransaction(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.signatures.push(reader.bytes()); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.message = Message.decode(reader, reader.uint32()); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): Transaction { - return { - signatures: Array.isArray(object?.signatures) ? object.signatures.map((e: any) => bytesFromBase64(e)) : [], - message: isSet(object.message) ? Message.fromJSON(object.message) : undefined, - }; - }, - - toJSON(message: Transaction): unknown { - const obj: any = {}; - if (message.signatures) { - obj.signatures = message.signatures.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array(0))); - } else { - obj.signatures = []; - } - message.message !== undefined && (obj.message = message.message ? Message.toJSON(message.message) : undefined); - return obj; - }, - - create, I>>(base?: I): Transaction { - return Transaction.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): Transaction { - const message = createBaseTransaction(); - message.signatures = object.signatures?.map((e) => e) || []; - message.message = (object.message !== undefined && object.message !== null) - ? Message.fromPartial(object.message) - : undefined; - return message; - }, -}; - -function createBaseMessage(): Message { - return { - header: undefined, - accountKeys: [], - recentBlockhash: new Uint8Array(0), - instructions: [], - versioned: false, - addressTableLookups: [], - }; -} - -export const Message = { - encode(message: Message, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.header !== undefined) { - MessageHeader.encode(message.header, writer.uint32(10).fork()).ldelim(); - } - for (const v of message.accountKeys) { - writer.uint32(18).bytes(v!); - } - if (message.recentBlockhash.length !== 0) { - writer.uint32(26).bytes(message.recentBlockhash); - } - for (const v of message.instructions) { - CompiledInstruction.encode(v!, writer.uint32(34).fork()).ldelim(); - } - if (message.versioned === true) { - writer.uint32(40).bool(message.versioned); - } - for (const v of message.addressTableLookups) { - MessageAddressTableLookup.encode(v!, writer.uint32(50).fork()).ldelim(); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): Message { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseMessage(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.header = MessageHeader.decode(reader, reader.uint32()); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.accountKeys.push(reader.bytes()); - continue; - case 3: - if (tag !== 26) { - break; - } - - message.recentBlockhash = reader.bytes(); - continue; - case 4: - if (tag !== 34) { - break; - } - - message.instructions.push(CompiledInstruction.decode(reader, reader.uint32())); - continue; - case 5: - if (tag !== 40) { - break; - } - - message.versioned = reader.bool(); - continue; - case 6: - if (tag !== 50) { - break; - } - - message.addressTableLookups.push(MessageAddressTableLookup.decode(reader, reader.uint32())); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): Message { - return { - header: isSet(object.header) ? MessageHeader.fromJSON(object.header) : undefined, - accountKeys: Array.isArray(object?.accountKeys) ? object.accountKeys.map((e: any) => bytesFromBase64(e)) : [], - recentBlockhash: isSet(object.recentBlockhash) ? bytesFromBase64(object.recentBlockhash) : new Uint8Array(0), - instructions: Array.isArray(object?.instructions) - ? object.instructions.map((e: any) => CompiledInstruction.fromJSON(e)) - : [], - versioned: isSet(object.versioned) ? Boolean(object.versioned) : false, - addressTableLookups: Array.isArray(object?.addressTableLookups) - ? object.addressTableLookups.map((e: any) => MessageAddressTableLookup.fromJSON(e)) - : [], - }; - }, - - toJSON(message: Message): unknown { - const obj: any = {}; - message.header !== undefined && (obj.header = message.header ? MessageHeader.toJSON(message.header) : undefined); - if (message.accountKeys) { - obj.accountKeys = message.accountKeys.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array(0))); - } else { - obj.accountKeys = []; - } - message.recentBlockhash !== undefined && - (obj.recentBlockhash = base64FromBytes( - message.recentBlockhash !== undefined ? message.recentBlockhash : new Uint8Array(0), - )); - if (message.instructions) { - obj.instructions = message.instructions.map((e) => e ? CompiledInstruction.toJSON(e) : undefined); - } else { - obj.instructions = []; - } - message.versioned !== undefined && (obj.versioned = message.versioned); - if (message.addressTableLookups) { - obj.addressTableLookups = message.addressTableLookups.map((e) => - e ? MessageAddressTableLookup.toJSON(e) : undefined - ); - } else { - obj.addressTableLookups = []; - } - return obj; - }, - - create, I>>(base?: I): Message { - return Message.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): Message { - const message = createBaseMessage(); - message.header = (object.header !== undefined && object.header !== null) - ? MessageHeader.fromPartial(object.header) - : undefined; - message.accountKeys = object.accountKeys?.map((e) => e) || []; - message.recentBlockhash = object.recentBlockhash ?? new Uint8Array(0); - message.instructions = object.instructions?.map((e) => CompiledInstruction.fromPartial(e)) || []; - message.versioned = object.versioned ?? false; - message.addressTableLookups = object.addressTableLookups?.map((e) => MessageAddressTableLookup.fromPartial(e)) || - []; - return message; - }, -}; - -function createBaseMessageHeader(): MessageHeader { - return { numRequiredSignatures: 0, numReadonlySignedAccounts: 0, numReadonlyUnsignedAccounts: 0 }; -} - -export const MessageHeader = { - encode(message: MessageHeader, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.numRequiredSignatures !== 0) { - writer.uint32(8).uint32(message.numRequiredSignatures); - } - if (message.numReadonlySignedAccounts !== 0) { - writer.uint32(16).uint32(message.numReadonlySignedAccounts); - } - if (message.numReadonlyUnsignedAccounts !== 0) { - writer.uint32(24).uint32(message.numReadonlyUnsignedAccounts); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): MessageHeader { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseMessageHeader(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.numRequiredSignatures = reader.uint32(); - continue; - case 2: - if (tag !== 16) { - break; - } - - message.numReadonlySignedAccounts = reader.uint32(); - continue; - case 3: - if (tag !== 24) { - break; - } - - message.numReadonlyUnsignedAccounts = reader.uint32(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): MessageHeader { - return { - numRequiredSignatures: isSet(object.numRequiredSignatures) ? Number(object.numRequiredSignatures) : 0, - numReadonlySignedAccounts: isSet(object.numReadonlySignedAccounts) ? Number(object.numReadonlySignedAccounts) : 0, - numReadonlyUnsignedAccounts: isSet(object.numReadonlyUnsignedAccounts) - ? Number(object.numReadonlyUnsignedAccounts) - : 0, - }; - }, - - toJSON(message: MessageHeader): unknown { - const obj: any = {}; - message.numRequiredSignatures !== undefined && - (obj.numRequiredSignatures = Math.round(message.numRequiredSignatures)); - message.numReadonlySignedAccounts !== undefined && - (obj.numReadonlySignedAccounts = Math.round(message.numReadonlySignedAccounts)); - message.numReadonlyUnsignedAccounts !== undefined && - (obj.numReadonlyUnsignedAccounts = Math.round(message.numReadonlyUnsignedAccounts)); - return obj; - }, - - create, I>>(base?: I): MessageHeader { - return MessageHeader.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): MessageHeader { - const message = createBaseMessageHeader(); - message.numRequiredSignatures = object.numRequiredSignatures ?? 0; - message.numReadonlySignedAccounts = object.numReadonlySignedAccounts ?? 0; - message.numReadonlyUnsignedAccounts = object.numReadonlyUnsignedAccounts ?? 0; - return message; - }, -}; - -function createBaseMessageAddressTableLookup(): MessageAddressTableLookup { - return { accountKey: new Uint8Array(0), writableIndexes: new Uint8Array(0), readonlyIndexes: new Uint8Array(0) }; -} - -export const MessageAddressTableLookup = { - encode(message: MessageAddressTableLookup, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.accountKey.length !== 0) { - writer.uint32(10).bytes(message.accountKey); - } - if (message.writableIndexes.length !== 0) { - writer.uint32(18).bytes(message.writableIndexes); - } - if (message.readonlyIndexes.length !== 0) { - writer.uint32(26).bytes(message.readonlyIndexes); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): MessageAddressTableLookup { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseMessageAddressTableLookup(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.accountKey = reader.bytes(); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.writableIndexes = reader.bytes(); - continue; - case 3: - if (tag !== 26) { - break; - } - - message.readonlyIndexes = reader.bytes(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): MessageAddressTableLookup { - return { - accountKey: isSet(object.accountKey) ? bytesFromBase64(object.accountKey) : new Uint8Array(0), - writableIndexes: isSet(object.writableIndexes) ? bytesFromBase64(object.writableIndexes) : new Uint8Array(0), - readonlyIndexes: isSet(object.readonlyIndexes) ? bytesFromBase64(object.readonlyIndexes) : new Uint8Array(0), - }; - }, - - toJSON(message: MessageAddressTableLookup): unknown { - const obj: any = {}; - message.accountKey !== undefined && - (obj.accountKey = base64FromBytes(message.accountKey !== undefined ? message.accountKey : new Uint8Array(0))); - message.writableIndexes !== undefined && - (obj.writableIndexes = base64FromBytes( - message.writableIndexes !== undefined ? message.writableIndexes : new Uint8Array(0), - )); - message.readonlyIndexes !== undefined && - (obj.readonlyIndexes = base64FromBytes( - message.readonlyIndexes !== undefined ? message.readonlyIndexes : new Uint8Array(0), - )); - return obj; - }, - - create, I>>(base?: I): MessageAddressTableLookup { - return MessageAddressTableLookup.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): MessageAddressTableLookup { - const message = createBaseMessageAddressTableLookup(); - message.accountKey = object.accountKey ?? new Uint8Array(0); - message.writableIndexes = object.writableIndexes ?? new Uint8Array(0); - message.readonlyIndexes = object.readonlyIndexes ?? new Uint8Array(0); - return message; - }, -}; - -function createBaseTransactionStatusMeta(): TransactionStatusMeta { - return { - err: undefined, - fee: "0", - preBalances: [], - postBalances: [], - innerInstructions: [], - innerInstructionsNone: false, - logMessages: [], - logMessagesNone: false, - preTokenBalances: [], - postTokenBalances: [], - rewards: [], - loadedWritableAddresses: [], - loadedReadonlyAddresses: [], - returnData: undefined, - returnDataNone: false, - computeUnitsConsumed: undefined, - }; -} - -export const TransactionStatusMeta = { - encode(message: TransactionStatusMeta, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.err !== undefined) { - TransactionError.encode(message.err, writer.uint32(10).fork()).ldelim(); - } - if (message.fee !== "0") { - writer.uint32(16).uint64(message.fee); - } - writer.uint32(26).fork(); - for (const v of message.preBalances) { - writer.uint64(v); - } - writer.ldelim(); - writer.uint32(34).fork(); - for (const v of message.postBalances) { - writer.uint64(v); - } - writer.ldelim(); - for (const v of message.innerInstructions) { - InnerInstructions.encode(v!, writer.uint32(42).fork()).ldelim(); - } - if (message.innerInstructionsNone === true) { - writer.uint32(80).bool(message.innerInstructionsNone); - } - for (const v of message.logMessages) { - writer.uint32(50).string(v!); - } - if (message.logMessagesNone === true) { - writer.uint32(88).bool(message.logMessagesNone); - } - for (const v of message.preTokenBalances) { - TokenBalance.encode(v!, writer.uint32(58).fork()).ldelim(); - } - for (const v of message.postTokenBalances) { - TokenBalance.encode(v!, writer.uint32(66).fork()).ldelim(); - } - for (const v of message.rewards) { - Reward.encode(v!, writer.uint32(74).fork()).ldelim(); - } - for (const v of message.loadedWritableAddresses) { - writer.uint32(98).bytes(v!); - } - for (const v of message.loadedReadonlyAddresses) { - writer.uint32(106).bytes(v!); - } - if (message.returnData !== undefined) { - ReturnData.encode(message.returnData, writer.uint32(114).fork()).ldelim(); - } - if (message.returnDataNone === true) { - writer.uint32(120).bool(message.returnDataNone); - } - if (message.computeUnitsConsumed !== undefined) { - writer.uint32(128).uint64(message.computeUnitsConsumed); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): TransactionStatusMeta { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseTransactionStatusMeta(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.err = TransactionError.decode(reader, reader.uint32()); - continue; - case 2: - if (tag !== 16) { - break; - } - - message.fee = longToString(reader.uint64() as Long); - continue; - case 3: - if (tag === 24) { - message.preBalances.push(longToString(reader.uint64() as Long)); - - continue; - } - - if (tag === 26) { - const end2 = reader.uint32() + reader.pos; - while (reader.pos < end2) { - message.preBalances.push(longToString(reader.uint64() as Long)); - } - - continue; - } - - break; - case 4: - if (tag === 32) { - message.postBalances.push(longToString(reader.uint64() as Long)); - - continue; - } - - if (tag === 34) { - const end2 = reader.uint32() + reader.pos; - while (reader.pos < end2) { - message.postBalances.push(longToString(reader.uint64() as Long)); - } - - continue; - } - - break; - case 5: - if (tag !== 42) { - break; - } - - message.innerInstructions.push(InnerInstructions.decode(reader, reader.uint32())); - continue; - case 10: - if (tag !== 80) { - break; - } - - message.innerInstructionsNone = reader.bool(); - continue; - case 6: - if (tag !== 50) { - break; - } - - message.logMessages.push(reader.string()); - continue; - case 11: - if (tag !== 88) { - break; - } - - message.logMessagesNone = reader.bool(); - continue; - case 7: - if (tag !== 58) { - break; - } - - message.preTokenBalances.push(TokenBalance.decode(reader, reader.uint32())); - continue; - case 8: - if (tag !== 66) { - break; - } - - message.postTokenBalances.push(TokenBalance.decode(reader, reader.uint32())); - continue; - case 9: - if (tag !== 74) { - break; - } - - message.rewards.push(Reward.decode(reader, reader.uint32())); - continue; - case 12: - if (tag !== 98) { - break; - } - - message.loadedWritableAddresses.push(reader.bytes()); - continue; - case 13: - if (tag !== 106) { - break; - } - - message.loadedReadonlyAddresses.push(reader.bytes()); - continue; - case 14: - if (tag !== 114) { - break; - } - - message.returnData = ReturnData.decode(reader, reader.uint32()); - continue; - case 15: - if (tag !== 120) { - break; - } - - message.returnDataNone = reader.bool(); - continue; - case 16: - if (tag !== 128) { - break; - } - - message.computeUnitsConsumed = longToString(reader.uint64() as Long); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): TransactionStatusMeta { - return { - err: isSet(object.err) ? TransactionError.fromJSON(object.err) : undefined, - fee: isSet(object.fee) ? String(object.fee) : "0", - preBalances: Array.isArray(object?.preBalances) ? object.preBalances.map((e: any) => String(e)) : [], - postBalances: Array.isArray(object?.postBalances) ? object.postBalances.map((e: any) => String(e)) : [], - innerInstructions: Array.isArray(object?.innerInstructions) - ? object.innerInstructions.map((e: any) => InnerInstructions.fromJSON(e)) - : [], - innerInstructionsNone: isSet(object.innerInstructionsNone) ? Boolean(object.innerInstructionsNone) : false, - logMessages: Array.isArray(object?.logMessages) ? object.logMessages.map((e: any) => String(e)) : [], - logMessagesNone: isSet(object.logMessagesNone) ? Boolean(object.logMessagesNone) : false, - preTokenBalances: Array.isArray(object?.preTokenBalances) - ? object.preTokenBalances.map((e: any) => TokenBalance.fromJSON(e)) - : [], - postTokenBalances: Array.isArray(object?.postTokenBalances) - ? object.postTokenBalances.map((e: any) => TokenBalance.fromJSON(e)) - : [], - rewards: Array.isArray(object?.rewards) ? object.rewards.map((e: any) => Reward.fromJSON(e)) : [], - loadedWritableAddresses: Array.isArray(object?.loadedWritableAddresses) - ? object.loadedWritableAddresses.map((e: any) => bytesFromBase64(e)) - : [], - loadedReadonlyAddresses: Array.isArray(object?.loadedReadonlyAddresses) - ? object.loadedReadonlyAddresses.map((e: any) => bytesFromBase64(e)) - : [], - returnData: isSet(object.returnData) ? ReturnData.fromJSON(object.returnData) : undefined, - returnDataNone: isSet(object.returnDataNone) ? Boolean(object.returnDataNone) : false, - computeUnitsConsumed: isSet(object.computeUnitsConsumed) ? String(object.computeUnitsConsumed) : undefined, - }; - }, - - toJSON(message: TransactionStatusMeta): unknown { - const obj: any = {}; - message.err !== undefined && (obj.err = message.err ? TransactionError.toJSON(message.err) : undefined); - message.fee !== undefined && (obj.fee = message.fee); - if (message.preBalances) { - obj.preBalances = message.preBalances.map((e) => e); - } else { - obj.preBalances = []; - } - if (message.postBalances) { - obj.postBalances = message.postBalances.map((e) => e); - } else { - obj.postBalances = []; - } - if (message.innerInstructions) { - obj.innerInstructions = message.innerInstructions.map((e) => e ? InnerInstructions.toJSON(e) : undefined); - } else { - obj.innerInstructions = []; - } - message.innerInstructionsNone !== undefined && (obj.innerInstructionsNone = message.innerInstructionsNone); - if (message.logMessages) { - obj.logMessages = message.logMessages.map((e) => e); - } else { - obj.logMessages = []; - } - message.logMessagesNone !== undefined && (obj.logMessagesNone = message.logMessagesNone); - if (message.preTokenBalances) { - obj.preTokenBalances = message.preTokenBalances.map((e) => e ? TokenBalance.toJSON(e) : undefined); - } else { - obj.preTokenBalances = []; - } - if (message.postTokenBalances) { - obj.postTokenBalances = message.postTokenBalances.map((e) => e ? TokenBalance.toJSON(e) : undefined); - } else { - obj.postTokenBalances = []; - } - if (message.rewards) { - obj.rewards = message.rewards.map((e) => e ? Reward.toJSON(e) : undefined); - } else { - obj.rewards = []; - } - if (message.loadedWritableAddresses) { - obj.loadedWritableAddresses = message.loadedWritableAddresses.map((e) => - base64FromBytes(e !== undefined ? e : new Uint8Array(0)) - ); - } else { - obj.loadedWritableAddresses = []; - } - if (message.loadedReadonlyAddresses) { - obj.loadedReadonlyAddresses = message.loadedReadonlyAddresses.map((e) => - base64FromBytes(e !== undefined ? e : new Uint8Array(0)) - ); - } else { - obj.loadedReadonlyAddresses = []; - } - message.returnData !== undefined && - (obj.returnData = message.returnData ? ReturnData.toJSON(message.returnData) : undefined); - message.returnDataNone !== undefined && (obj.returnDataNone = message.returnDataNone); - message.computeUnitsConsumed !== undefined && (obj.computeUnitsConsumed = message.computeUnitsConsumed); - return obj; - }, - - create, I>>(base?: I): TransactionStatusMeta { - return TransactionStatusMeta.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): TransactionStatusMeta { - const message = createBaseTransactionStatusMeta(); - message.err = (object.err !== undefined && object.err !== null) - ? TransactionError.fromPartial(object.err) - : undefined; - message.fee = object.fee ?? "0"; - message.preBalances = object.preBalances?.map((e) => e) || []; - message.postBalances = object.postBalances?.map((e) => e) || []; - message.innerInstructions = object.innerInstructions?.map((e) => InnerInstructions.fromPartial(e)) || []; - message.innerInstructionsNone = object.innerInstructionsNone ?? false; - message.logMessages = object.logMessages?.map((e) => e) || []; - message.logMessagesNone = object.logMessagesNone ?? false; - message.preTokenBalances = object.preTokenBalances?.map((e) => TokenBalance.fromPartial(e)) || []; - message.postTokenBalances = object.postTokenBalances?.map((e) => TokenBalance.fromPartial(e)) || []; - message.rewards = object.rewards?.map((e) => Reward.fromPartial(e)) || []; - message.loadedWritableAddresses = object.loadedWritableAddresses?.map((e) => e) || []; - message.loadedReadonlyAddresses = object.loadedReadonlyAddresses?.map((e) => e) || []; - message.returnData = (object.returnData !== undefined && object.returnData !== null) - ? ReturnData.fromPartial(object.returnData) - : undefined; - message.returnDataNone = object.returnDataNone ?? false; - message.computeUnitsConsumed = object.computeUnitsConsumed ?? undefined; - return message; - }, -}; - -function createBaseTransactionError(): TransactionError { - return { err: new Uint8Array(0) }; -} - -export const TransactionError = { - encode(message: TransactionError, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.err.length !== 0) { - writer.uint32(10).bytes(message.err); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): TransactionError { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseTransactionError(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.err = reader.bytes(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): TransactionError { - return { err: isSet(object.err) ? bytesFromBase64(object.err) : new Uint8Array(0) }; - }, - - toJSON(message: TransactionError): unknown { - const obj: any = {}; - message.err !== undefined && - (obj.err = base64FromBytes(message.err !== undefined ? message.err : new Uint8Array(0))); - return obj; - }, - - create, I>>(base?: I): TransactionError { - return TransactionError.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): TransactionError { - const message = createBaseTransactionError(); - message.err = object.err ?? new Uint8Array(0); - return message; - }, -}; - -function createBaseInnerInstructions(): InnerInstructions { - return { index: 0, instructions: [] }; -} - -export const InnerInstructions = { - encode(message: InnerInstructions, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.index !== 0) { - writer.uint32(8).uint32(message.index); - } - for (const v of message.instructions) { - InnerInstruction.encode(v!, writer.uint32(18).fork()).ldelim(); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): InnerInstructions { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseInnerInstructions(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.index = reader.uint32(); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.instructions.push(InnerInstruction.decode(reader, reader.uint32())); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): InnerInstructions { - return { - index: isSet(object.index) ? Number(object.index) : 0, - instructions: Array.isArray(object?.instructions) - ? object.instructions.map((e: any) => InnerInstruction.fromJSON(e)) - : [], - }; - }, - - toJSON(message: InnerInstructions): unknown { - const obj: any = {}; - message.index !== undefined && (obj.index = Math.round(message.index)); - if (message.instructions) { - obj.instructions = message.instructions.map((e) => e ? InnerInstruction.toJSON(e) : undefined); - } else { - obj.instructions = []; - } - return obj; - }, - - create, I>>(base?: I): InnerInstructions { - return InnerInstructions.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): InnerInstructions { - const message = createBaseInnerInstructions(); - message.index = object.index ?? 0; - message.instructions = object.instructions?.map((e) => InnerInstruction.fromPartial(e)) || []; - return message; - }, -}; - -function createBaseInnerInstruction(): InnerInstruction { - return { programIdIndex: 0, accounts: new Uint8Array(0), data: new Uint8Array(0), stackHeight: undefined }; -} - -export const InnerInstruction = { - encode(message: InnerInstruction, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.programIdIndex !== 0) { - writer.uint32(8).uint32(message.programIdIndex); - } - if (message.accounts.length !== 0) { - writer.uint32(18).bytes(message.accounts); - } - if (message.data.length !== 0) { - writer.uint32(26).bytes(message.data); - } - if (message.stackHeight !== undefined) { - writer.uint32(32).uint32(message.stackHeight); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): InnerInstruction { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseInnerInstruction(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.programIdIndex = reader.uint32(); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.accounts = reader.bytes(); - continue; - case 3: - if (tag !== 26) { - break; - } - - message.data = reader.bytes(); - continue; - case 4: - if (tag !== 32) { - break; - } - - message.stackHeight = reader.uint32(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): InnerInstruction { - return { - programIdIndex: isSet(object.programIdIndex) ? Number(object.programIdIndex) : 0, - accounts: isSet(object.accounts) ? bytesFromBase64(object.accounts) : new Uint8Array(0), - data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(0), - stackHeight: isSet(object.stackHeight) ? Number(object.stackHeight) : undefined, - }; - }, - - toJSON(message: InnerInstruction): unknown { - const obj: any = {}; - message.programIdIndex !== undefined && (obj.programIdIndex = Math.round(message.programIdIndex)); - message.accounts !== undefined && - (obj.accounts = base64FromBytes(message.accounts !== undefined ? message.accounts : new Uint8Array(0))); - message.data !== undefined && - (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array(0))); - message.stackHeight !== undefined && (obj.stackHeight = Math.round(message.stackHeight)); - return obj; - }, - - create, I>>(base?: I): InnerInstruction { - return InnerInstruction.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): InnerInstruction { - const message = createBaseInnerInstruction(); - message.programIdIndex = object.programIdIndex ?? 0; - message.accounts = object.accounts ?? new Uint8Array(0); - message.data = object.data ?? new Uint8Array(0); - message.stackHeight = object.stackHeight ?? undefined; - return message; - }, -}; - -function createBaseCompiledInstruction(): CompiledInstruction { - return { programIdIndex: 0, accounts: new Uint8Array(0), data: new Uint8Array(0) }; -} - -export const CompiledInstruction = { - encode(message: CompiledInstruction, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.programIdIndex !== 0) { - writer.uint32(8).uint32(message.programIdIndex); - } - if (message.accounts.length !== 0) { - writer.uint32(18).bytes(message.accounts); - } - if (message.data.length !== 0) { - writer.uint32(26).bytes(message.data); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): CompiledInstruction { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseCompiledInstruction(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.programIdIndex = reader.uint32(); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.accounts = reader.bytes(); - continue; - case 3: - if (tag !== 26) { - break; - } - - message.data = reader.bytes(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): CompiledInstruction { - return { - programIdIndex: isSet(object.programIdIndex) ? Number(object.programIdIndex) : 0, - accounts: isSet(object.accounts) ? bytesFromBase64(object.accounts) : new Uint8Array(0), - data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(0), - }; - }, - - toJSON(message: CompiledInstruction): unknown { - const obj: any = {}; - message.programIdIndex !== undefined && (obj.programIdIndex = Math.round(message.programIdIndex)); - message.accounts !== undefined && - (obj.accounts = base64FromBytes(message.accounts !== undefined ? message.accounts : new Uint8Array(0))); - message.data !== undefined && - (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array(0))); - return obj; - }, - - create, I>>(base?: I): CompiledInstruction { - return CompiledInstruction.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): CompiledInstruction { - const message = createBaseCompiledInstruction(); - message.programIdIndex = object.programIdIndex ?? 0; - message.accounts = object.accounts ?? new Uint8Array(0); - message.data = object.data ?? new Uint8Array(0); - return message; - }, -}; - -function createBaseTokenBalance(): TokenBalance { - return { accountIndex: 0, mint: "", uiTokenAmount: undefined, owner: "", programId: "" }; -} - -export const TokenBalance = { - encode(message: TokenBalance, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.accountIndex !== 0) { - writer.uint32(8).uint32(message.accountIndex); - } - if (message.mint !== "") { - writer.uint32(18).string(message.mint); - } - if (message.uiTokenAmount !== undefined) { - UiTokenAmount.encode(message.uiTokenAmount, writer.uint32(26).fork()).ldelim(); - } - if (message.owner !== "") { - writer.uint32(34).string(message.owner); - } - if (message.programId !== "") { - writer.uint32(42).string(message.programId); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): TokenBalance { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseTokenBalance(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.accountIndex = reader.uint32(); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.mint = reader.string(); - continue; - case 3: - if (tag !== 26) { - break; - } - - message.uiTokenAmount = UiTokenAmount.decode(reader, reader.uint32()); - continue; - case 4: - if (tag !== 34) { - break; - } - - message.owner = reader.string(); - continue; - case 5: - if (tag !== 42) { - break; - } - - message.programId = reader.string(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): TokenBalance { - return { - accountIndex: isSet(object.accountIndex) ? Number(object.accountIndex) : 0, - mint: isSet(object.mint) ? String(object.mint) : "", - uiTokenAmount: isSet(object.uiTokenAmount) ? UiTokenAmount.fromJSON(object.uiTokenAmount) : undefined, - owner: isSet(object.owner) ? String(object.owner) : "", - programId: isSet(object.programId) ? String(object.programId) : "", - }; - }, - - toJSON(message: TokenBalance): unknown { - const obj: any = {}; - message.accountIndex !== undefined && (obj.accountIndex = Math.round(message.accountIndex)); - message.mint !== undefined && (obj.mint = message.mint); - message.uiTokenAmount !== undefined && - (obj.uiTokenAmount = message.uiTokenAmount ? UiTokenAmount.toJSON(message.uiTokenAmount) : undefined); - message.owner !== undefined && (obj.owner = message.owner); - message.programId !== undefined && (obj.programId = message.programId); - return obj; - }, - - create, I>>(base?: I): TokenBalance { - return TokenBalance.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): TokenBalance { - const message = createBaseTokenBalance(); - message.accountIndex = object.accountIndex ?? 0; - message.mint = object.mint ?? ""; - message.uiTokenAmount = (object.uiTokenAmount !== undefined && object.uiTokenAmount !== null) - ? UiTokenAmount.fromPartial(object.uiTokenAmount) - : undefined; - message.owner = object.owner ?? ""; - message.programId = object.programId ?? ""; - return message; - }, -}; - -function createBaseUiTokenAmount(): UiTokenAmount { - return { uiAmount: 0, decimals: 0, amount: "", uiAmountString: "" }; -} - -export const UiTokenAmount = { - encode(message: UiTokenAmount, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.uiAmount !== 0) { - writer.uint32(9).double(message.uiAmount); - } - if (message.decimals !== 0) { - writer.uint32(16).uint32(message.decimals); - } - if (message.amount !== "") { - writer.uint32(26).string(message.amount); - } - if (message.uiAmountString !== "") { - writer.uint32(34).string(message.uiAmountString); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): UiTokenAmount { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseUiTokenAmount(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 9) { - break; - } - - message.uiAmount = reader.double(); - continue; - case 2: - if (tag !== 16) { - break; - } - - message.decimals = reader.uint32(); - continue; - case 3: - if (tag !== 26) { - break; - } - - message.amount = reader.string(); - continue; - case 4: - if (tag !== 34) { - break; - } - - message.uiAmountString = reader.string(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): UiTokenAmount { - return { - uiAmount: isSet(object.uiAmount) ? Number(object.uiAmount) : 0, - decimals: isSet(object.decimals) ? Number(object.decimals) : 0, - amount: isSet(object.amount) ? String(object.amount) : "", - uiAmountString: isSet(object.uiAmountString) ? String(object.uiAmountString) : "", - }; - }, - - toJSON(message: UiTokenAmount): unknown { - const obj: any = {}; - message.uiAmount !== undefined && (obj.uiAmount = message.uiAmount); - message.decimals !== undefined && (obj.decimals = Math.round(message.decimals)); - message.amount !== undefined && (obj.amount = message.amount); - message.uiAmountString !== undefined && (obj.uiAmountString = message.uiAmountString); - return obj; - }, - - create, I>>(base?: I): UiTokenAmount { - return UiTokenAmount.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): UiTokenAmount { - const message = createBaseUiTokenAmount(); - message.uiAmount = object.uiAmount ?? 0; - message.decimals = object.decimals ?? 0; - message.amount = object.amount ?? ""; - message.uiAmountString = object.uiAmountString ?? ""; - return message; - }, -}; - -function createBaseReturnData(): ReturnData { - return { programId: new Uint8Array(0), data: new Uint8Array(0) }; -} - -export const ReturnData = { - encode(message: ReturnData, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.programId.length !== 0) { - writer.uint32(10).bytes(message.programId); - } - if (message.data.length !== 0) { - writer.uint32(18).bytes(message.data); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): ReturnData { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseReturnData(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.programId = reader.bytes(); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.data = reader.bytes(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): ReturnData { - return { - programId: isSet(object.programId) ? bytesFromBase64(object.programId) : new Uint8Array(0), - data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(0), - }; - }, - - toJSON(message: ReturnData): unknown { - const obj: any = {}; - message.programId !== undefined && - (obj.programId = base64FromBytes(message.programId !== undefined ? message.programId : new Uint8Array(0))); - message.data !== undefined && - (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array(0))); - return obj; - }, - - create, I>>(base?: I): ReturnData { - return ReturnData.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): ReturnData { - const message = createBaseReturnData(); - message.programId = object.programId ?? new Uint8Array(0); - message.data = object.data ?? new Uint8Array(0); - return message; - }, -}; - -function createBaseReward(): Reward { - return { pubkey: "", lamports: "0", postBalance: "0", rewardType: 0, commission: "" }; -} - -export const Reward = { - encode(message: Reward, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.pubkey !== "") { - writer.uint32(10).string(message.pubkey); - } - if (message.lamports !== "0") { - writer.uint32(16).int64(message.lamports); - } - if (message.postBalance !== "0") { - writer.uint32(24).uint64(message.postBalance); - } - if (message.rewardType !== 0) { - writer.uint32(32).int32(message.rewardType); - } - if (message.commission !== "") { - writer.uint32(42).string(message.commission); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): Reward { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseReward(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.pubkey = reader.string(); - continue; - case 2: - if (tag !== 16) { - break; - } - - message.lamports = longToString(reader.int64() as Long); - continue; - case 3: - if (tag !== 24) { - break; - } - - message.postBalance = longToString(reader.uint64() as Long); - continue; - case 4: - if (tag !== 32) { - break; - } - - message.rewardType = reader.int32() as any; - continue; - case 5: - if (tag !== 42) { - break; - } - - message.commission = reader.string(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): Reward { - return { - pubkey: isSet(object.pubkey) ? String(object.pubkey) : "", - lamports: isSet(object.lamports) ? String(object.lamports) : "0", - postBalance: isSet(object.postBalance) ? String(object.postBalance) : "0", - rewardType: isSet(object.rewardType) ? rewardTypeFromJSON(object.rewardType) : 0, - commission: isSet(object.commission) ? String(object.commission) : "", - }; - }, - - toJSON(message: Reward): unknown { - const obj: any = {}; - message.pubkey !== undefined && (obj.pubkey = message.pubkey); - message.lamports !== undefined && (obj.lamports = message.lamports); - message.postBalance !== undefined && (obj.postBalance = message.postBalance); - message.rewardType !== undefined && (obj.rewardType = rewardTypeToJSON(message.rewardType)); - message.commission !== undefined && (obj.commission = message.commission); - return obj; - }, - - create, I>>(base?: I): Reward { - return Reward.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): Reward { - const message = createBaseReward(); - message.pubkey = object.pubkey ?? ""; - message.lamports = object.lamports ?? "0"; - message.postBalance = object.postBalance ?? "0"; - message.rewardType = object.rewardType ?? 0; - message.commission = object.commission ?? ""; - return message; - }, -}; - -function createBaseRewards(): Rewards { - return { rewards: [], numPartitions: undefined }; -} - -export const Rewards = { - encode(message: Rewards, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - for (const v of message.rewards) { - Reward.encode(v!, writer.uint32(10).fork()).ldelim(); - } - if (message.numPartitions !== undefined) { - NumPartitions.encode(message.numPartitions, writer.uint32(18).fork()).ldelim(); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): Rewards { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseRewards(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.rewards.push(Reward.decode(reader, reader.uint32())); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.numPartitions = NumPartitions.decode(reader, reader.uint32()); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): Rewards { - return { - rewards: Array.isArray(object?.rewards) ? object.rewards.map((e: any) => Reward.fromJSON(e)) : [], - numPartitions: isSet(object.numPartitions) ? NumPartitions.fromJSON(object.numPartitions) : undefined, - }; - }, - - toJSON(message: Rewards): unknown { - const obj: any = {}; - if (message.rewards) { - obj.rewards = message.rewards.map((e) => e ? Reward.toJSON(e) : undefined); - } else { - obj.rewards = []; - } - message.numPartitions !== undefined && - (obj.numPartitions = message.numPartitions ? NumPartitions.toJSON(message.numPartitions) : undefined); - return obj; - }, - - create, I>>(base?: I): Rewards { - return Rewards.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): Rewards { - const message = createBaseRewards(); - message.rewards = object.rewards?.map((e) => Reward.fromPartial(e)) || []; - message.numPartitions = (object.numPartitions !== undefined && object.numPartitions !== null) - ? NumPartitions.fromPartial(object.numPartitions) - : undefined; - return message; - }, -}; - -function createBaseUnixTimestamp(): UnixTimestamp { - return { timestamp: "0" }; -} - -export const UnixTimestamp = { - encode(message: UnixTimestamp, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.timestamp !== "0") { - writer.uint32(8).int64(message.timestamp); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): UnixTimestamp { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseUnixTimestamp(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.timestamp = longToString(reader.int64() as Long); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): UnixTimestamp { - return { timestamp: isSet(object.timestamp) ? String(object.timestamp) : "0" }; - }, - - toJSON(message: UnixTimestamp): unknown { - const obj: any = {}; - message.timestamp !== undefined && (obj.timestamp = message.timestamp); - return obj; - }, - - create, I>>(base?: I): UnixTimestamp { - return UnixTimestamp.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): UnixTimestamp { - const message = createBaseUnixTimestamp(); - message.timestamp = object.timestamp ?? "0"; - return message; - }, -}; - -function createBaseBlockHeight(): BlockHeight { - return { blockHeight: "0" }; -} - -export const BlockHeight = { - encode(message: BlockHeight, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.blockHeight !== "0") { - writer.uint32(8).uint64(message.blockHeight); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): BlockHeight { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseBlockHeight(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.blockHeight = longToString(reader.uint64() as Long); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): BlockHeight { - return { blockHeight: isSet(object.blockHeight) ? String(object.blockHeight) : "0" }; - }, - - toJSON(message: BlockHeight): unknown { - const obj: any = {}; - message.blockHeight !== undefined && (obj.blockHeight = message.blockHeight); - return obj; - }, - - create, I>>(base?: I): BlockHeight { - return BlockHeight.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): BlockHeight { - const message = createBaseBlockHeight(); - message.blockHeight = object.blockHeight ?? "0"; - return message; - }, -}; - -function createBaseNumPartitions(): NumPartitions { - return { numPartitions: "0" }; -} - -export const NumPartitions = { - encode(message: NumPartitions, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.numPartitions !== "0") { - writer.uint32(8).uint64(message.numPartitions); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): NumPartitions { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseNumPartitions(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.numPartitions = longToString(reader.uint64() as Long); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): NumPartitions { - return { numPartitions: isSet(object.numPartitions) ? String(object.numPartitions) : "0" }; - }, - - toJSON(message: NumPartitions): unknown { - const obj: any = {}; - message.numPartitions !== undefined && (obj.numPartitions = message.numPartitions); - return obj; - }, - - create, I>>(base?: I): NumPartitions { - return NumPartitions.fromPartial(base ?? {}); - }, - - fromPartial, I>>(object: I): NumPartitions { - const message = createBaseNumPartitions(); - message.numPartitions = object.numPartitions ?? "0"; - return message; - }, -}; - -declare var self: any | undefined; -declare var window: any | undefined; -declare var global: any | undefined; -var tsProtoGlobalThis: any = (() => { - if (typeof globalThis !== "undefined") { - return globalThis; - } - if (typeof self !== "undefined") { - return self; - } - if (typeof window !== "undefined") { - return window; - } - if (typeof global !== "undefined") { - return global; - } - throw "Unable to locate global object"; -})(); - -function bytesFromBase64(b64: string): Uint8Array { - if (tsProtoGlobalThis.Buffer) { - return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, "base64")); - } else { - const bin = tsProtoGlobalThis.atob(b64); - const arr = new Uint8Array(bin.length); - for (let i = 0; i < bin.length; ++i) { - arr[i] = bin.charCodeAt(i); - } - return arr; - } -} - -function base64FromBytes(arr: Uint8Array): string { - if (tsProtoGlobalThis.Buffer) { - return tsProtoGlobalThis.Buffer.from(arr).toString("base64"); - } else { - const bin: string[] = []; - arr.forEach((byte) => { - bin.push(String.fromCharCode(byte)); - }); - return tsProtoGlobalThis.btoa(bin.join("")); - } -} - -type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; - -export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> - : T extends {} ? { [K in keyof T]?: DeepPartial } - : Partial; - -type KeysOfUnion = T extends T ? keyof T : never; -export type Exact = P extends Builtin ? P - : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; - -function longToString(long: Long) { - return long.toString(); -} - -// If you get a compile-error about 'Constructor and ... have no overlap', -// add '--ts_proto_opt=esModuleInterop=true' as a flag when calling 'protoc'. -if (_m0.util.Long !== Long) { - _m0.util.Long = Long as any; - _m0.configure(); -} - -function isSet(value: any): boolean { - return value !== null && value !== undefined; -}