@subql/types-solana 0.0.0-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
+ // SPDX-License-Identifier: GPL-3.0
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.SolanaHandlerKind = exports.SolanaDatasourceKind = void 0;
6
+ /**
7
+ * Kind of Solana datasource.
8
+ * @enum {string}
9
+ */
10
+ var SolanaDatasourceKind;
11
+ (function (SolanaDatasourceKind) {
12
+ /**
13
+ * The runtime kind of Solana datasource.
14
+ */
15
+ SolanaDatasourceKind["Runtime"] = "solana/Runtime";
16
+ })(SolanaDatasourceKind || (exports.SolanaDatasourceKind = SolanaDatasourceKind = {}));
17
+ /**
18
+ * Enum representing the kind of Solana handler.
19
+ * @enum {string}
20
+ */
21
+ var SolanaHandlerKind;
22
+ (function (SolanaHandlerKind) {
23
+ /**
24
+ * Handler for Solana blocks.
25
+ */
26
+ SolanaHandlerKind["Block"] = "solana/BlockHandler";
27
+ /**
28
+ * Handler for Solana transactions.
29
+ */
30
+ SolanaHandlerKind["Transaction"] = "solana/TransactionHandler";
31
+ /**
32
+ * Handler for Solana instructions.
33
+ */
34
+ SolanaHandlerKind["Instruction"] = "solana/InstructionHandler";
35
+ /**
36
+ * Handler for Solana logs.
37
+ */
38
+ SolanaHandlerKind["Log"] = "solana/LogHandler";
39
+ })(SolanaHandlerKind || (exports.SolanaHandlerKind = SolanaHandlerKind = {}));
40
+ //# sourceMappingURL=project.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.js","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;AAiCnC;;;GAGG;AACH,IAAY,oBAKX;AALD,WAAY,oBAAoB;IAC9B;;OAEG;IACH,kDAA0B,CAAA;AAC5B,CAAC,EALW,oBAAoB,oCAApB,oBAAoB,QAK/B;AAED;;;GAGG;AACH,IAAY,iBAmBX;AAnBD,WAAY,iBAAiB;IAC3B;;OAEG;IACH,kDAA6B,CAAA;IAC7B;;OAEG;IACH,8DAAyC,CAAA;IAEzC;;OAEG;IACH,8DAAyC,CAAA;IAEzC;;OAEG;IACH,8CAAyB,CAAA;AAC3B,CAAC,EAnBW,iBAAiB,iCAAjB,iBAAiB,QAmB5B","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport {\n BaseTemplateDataSource,\n IProjectNetworkConfig,\n CommonSubqueryProject,\n FileReference,\n Processor,\n ProjectManifestV1_0_0,\n BaseDataSource,\n SecondLayerHandlerProcessor_0_0_0,\n SecondLayerHandlerProcessor_1_0_0,\n DsProcessor,\n BaseCustomDataSource,\n IEndpointConfig,\n} from '@subql/types-core';\nimport {\n SolanaBlockFilter,\n SolanaLogFilter,\n SolanaTransactionFilter,\n SolanaInstructionFilter,\n SolanaBlock,\n SolanaTransaction,\n SolanaInstruction,\n SolanaLogMessage,\n} from './solana';\ntype ApiWrapper = unknown; // TODO\n\nexport type RuntimeDatasourceTemplate = BaseTemplateDataSource<SubqlRuntimeDatasource>;\nexport type CustomDatasourceTemplate = BaseTemplateDataSource<SubqlCustomDatasource>;\n\nexport type SolanaProjectManifestV1_0_0 = ProjectManifestV1_0_0<SubqlRuntimeDatasource | SubqlCustomDatasource>;\n\n/**\n * Kind of Solana datasource.\n * @enum {string}\n */\nexport enum SolanaDatasourceKind {\n /**\n * The runtime kind of Solana datasource.\n */\n Runtime = 'solana/Runtime',\n}\n\n/**\n * Enum representing the kind of Solana handler.\n * @enum {string}\n */\nexport enum SolanaHandlerKind {\n /**\n * Handler for Solana blocks.\n */\n Block = 'solana/BlockHandler',\n /**\n * Handler for Solana transactions.\n */\n Transaction = 'solana/TransactionHandler',\n\n /**\n * Handler for Solana instructions.\n */\n Instruction = 'solana/InstructionHandler',\n\n /**\n * Handler for Solana logs.\n */\n Log = 'solana/LogHandler',\n}\n\nexport type SolanaRuntimeHandlerInputMap = {\n [SolanaHandlerKind.Block]: SolanaBlock;\n [SolanaHandlerKind.Transaction]: SolanaTransaction;\n [SolanaHandlerKind.Instruction]: SolanaInstruction;\n [SolanaHandlerKind.Log]: SolanaLogMessage;\n};\n\ntype SolanaRuntimeFilterMap = {\n [SolanaHandlerKind.Block]: SolanaBlockFilter;\n [SolanaHandlerKind.Transaction]: SolanaTransactionFilter;\n [SolanaHandlerKind.Instruction]: SolanaInstructionFilter;\n [SolanaHandlerKind.Log]: SolanaLogFilter;\n};\n\n/**\n * Represents a handler for Solana blocks.\n * @type {SubqlCustomHandler<SolanaHandlerKind.Block, SolanaBlockFilter>}\n */\nexport type SubqlBlockHandler = SubqlCustomHandler<SolanaHandlerKind.Block, SolanaBlockFilter>;\n/**\n * Represents a handler for Solana transactions.\n * @type {SubqlCustomHandler<SolanaHandlerKind.Transaction, SolanaTransactionFilter>}\n */\nexport type SubqlTransactionHandler = SubqlCustomHandler<SolanaHandlerKind.Transaction, SolanaTransactionFilter>;\n\n/**\n * Represents a handler for Solana transactions.\n * @type {SubqlCustomHandler<SolanaHandlerKind.Instruction, SolanaInstructionFilter>}\n */\nexport type SubqlInstructionHandler = SubqlCustomHandler<SolanaHandlerKind.Instruction, SolanaInstructionFilter>;\n\n/**\n * Represents a handler for Solana log.\n * @type {SubqlCustomHandler<SolanaHandlerKind.Log, SolanaLogFilter>}\n */\nexport type SubqlLogHandler = SubqlCustomHandler<SolanaHandlerKind.Log, SolanaLogFilter>;\n\n/**\n * Represents a generic custom handler for Solana.\n * @interface\n * @template K - The kind of the handler (default: string).\n * @template F - The filter type for the handler (default: Record<string, unknown>).\n */\nexport interface SubqlCustomHandler<K extends string = string, F = Record<string, unknown>> {\n /**\n * The kind of handler. For `solana/Runtime` datasources this is either `Block`, `Transaction`, `Instruction` or `Log` kinds.\n * The value of this will determine the filter options as well as the data provided to your handler function\n * @type {SolanaHandlerKind.Block | SolanaHandlerKind.Transaction | string }\n * @example\n * kind: SolanaHandlerKind.Block // Defined with an enum, this is used for runtime datasources\n\n */\n kind: K;\n /**\n * The name of your handler function. This must be defined and exported from your code.\n * @type {string}\n * @example\n * handler: 'handleBlock'\n */\n handler: string;\n /**\n * The filter for the handler. The handler kind will determine the possible filters (optional).\n *\n * @type {F}\n */\n filter?: F;\n}\n\n/**\n * Represents a runtime handler for Solana, which can be a block handler, transaction handler, or log handler.\n * @type {SubqlBlockHandler | SubqlTransactionHandler }\n */\nexport type SubqlRuntimeHandler =\n | SubqlBlockHandler\n | SubqlTransactionHandler\n | SubqlInstructionHandler\n | SubqlLogHandler;\n\n/**\n * Represents a handler for Solana, which can be a runtime handler or a custom handler with unknown filter type.\n * @type {SubqlRuntimeHandler | SubqlCustomHandler<string, unknown>}\n */\nexport type SubqlHandler = SubqlRuntimeHandler | SubqlCustomHandler<string, unknown>;\n\n/**\n * Represents a filter for Solana runtime handlers, which can be a block filter, call filter, or event filter.\n * @type {SolanaBlockFilter | SolanaTransactionFilter | SolanaInstructionFilter | SolanaLogFilter}\n */\nexport type SubqlHandlerFilter =\n | SolanaBlockFilter\n | SolanaTransactionFilter\n | SolanaInstructionFilter\n | SolanaLogFilter;\n\n/**\n * Represents a mapping for Solana handlers, extending FileReference.\n * @interface\n * @extends {FileReference}\n */\nexport interface SubqlMapping<T extends SubqlHandler = SubqlHandler> extends FileReference {\n /**\n * An array of handlers associated with the mapping.\n * @type {T[]}\n * @example\n * handlers: [{\n kind: SolanaHandlerKind.Transaction,\n handler: 'handleTransfer',\n filter: {\n programId: 'JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4',\n }\n }]\n */\n handlers: T[];\n}\n\n/**\n * Represents a runtime datasource for Solana.\n * @interface\n * @template M - The mapping type for the datasource (default: SubqlMapping<SubqlRuntimeHandler>).\n */\nexport interface SubqlRuntimeDatasource<M extends SubqlMapping<SubqlRuntimeHandler> = SubqlMapping<SubqlRuntimeHandler>>\n extends BaseDataSource<SubqlRuntimeHandler, M> {\n /**\n * The kind of the datasource, which is `solana/Runtime`.\n * @type {SolanaDatasourceKind.Runtime}\n */\n kind: SolanaDatasourceKind.Runtime;\n /**\n * A map of a program address to an IDL file\n * These are used for codegen to generate handler inputs and contract interfaces\n * @example\n * assets: new Map([\n * ['JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4', { file: \"./idls/JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4.idl.json\" }],\n * ['swapFpHZwjELNnjvThjajtiVmkz3yPQEHjLtka2fwHW', { file: \"./idls/swapFpHZwjELNnjvThjajtiVmkz3yPQEHjLtka2fwHW.idl.json\" }],\n * ])\n * */\n // This must be assets so they are correctly loaded\n assets?: Map<string, FileReference>;\n}\n\nexport type SubqlDatasource = SubqlRuntimeDatasource | SubqlCustomDatasource;\n\nexport interface SubqlCustomDatasource<\n K extends string = string,\n M extends SubqlMapping = SubqlMapping<SubqlCustomHandler>,\n O = any\n> extends BaseCustomDataSource<SubqlHandler, M> /*ISubqlDatasource<M>*/ {\n /**\n * The kind of the datasource, which is `solana/Runtime`.\n * @type {K}\n */\n kind: K;\n /**\n * A map of a program address to an IDL file\n * These are used for codegen to generate handler inputs and contract interfaces\n * @example\n * assets: new Map([\n * ['JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4', { file: \"./idls/JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4.idl.json\" }],\n * ['swapFpHZwjELNnjvThjajtiVmkz3yPQEHjLtka2fwHW', { file: \"./idls/swapFpHZwjELNnjvThjajtiVmkz3yPQEHjLtka2fwHW.idl.json\" }],\n * ])\n * */\n // This must be assets so they are correctly loaded\n assets?: Map<string, FileReference>;\n // /**\n // * @example\n // * processor: {\n // * file: './node_modules/@subql/frontier-evm-processor/dist/bundle.js',\n // * options: {\n // * abi: 'erc20',\n // * address: '0x322E86852e492a7Ee17f28a78c663da38FB33bfb',\n // * }\n // * }\n // */\n processor: Processor<O>;\n}\n\nexport type SecondLayerHandlerProcessor<\n K extends SolanaHandlerKind,\n F extends Record<string, unknown>, // SolanaRuntimeFilterMap?\n E,\n DS extends SubqlCustomDatasource = SubqlCustomDatasource\n> =\n | SecondLayerHandlerProcessor_0_0_0<K, SolanaRuntimeHandlerInputMap, SolanaRuntimeFilterMap, F, E, DS, ApiWrapper>\n | SecondLayerHandlerProcessor_1_0_0<K, SolanaRuntimeHandlerInputMap, SolanaRuntimeFilterMap, F, E, DS, ApiWrapper>;\n\nexport type SecondLayerHandlerProcessorArray<\n K extends string,\n F extends Record<string, unknown>,\n T,\n DS extends SubqlCustomDatasource<K> = SubqlCustomDatasource<K>\n> =\n | SecondLayerHandlerProcessor<SolanaHandlerKind.Block, F, T, DS>\n | SecondLayerHandlerProcessor<SolanaHandlerKind.Transaction, F, T, DS>\n | SecondLayerHandlerProcessor<SolanaHandlerKind.Instruction, F, T, DS>\n | SecondLayerHandlerProcessor<SolanaHandlerKind.Log, F, T, DS>;\n\nexport type SubqlDatasourceProcessor<\n K extends string,\n F extends Record<string, unknown>,\n DS extends SubqlCustomDatasource<K> = SubqlCustomDatasource<K>,\n P extends Record<string, SecondLayerHandlerProcessorArray<K, F, any, DS>> = Record<\n string,\n SecondLayerHandlerProcessorArray<K, F, any, DS>\n >\n> = DsProcessor<DS, P, ApiWrapper>;\n\nexport interface ISolanaEndpointConfig extends IEndpointConfig {\n /**\n * The request timeout in MS for the Solana RPC.\n * @default 30_000\n */\n requestTimeout?: number;\n}\n\n/**\n * Represents a Solana subquery network configuration, which is based on the CommonSubqueryNetworkConfig template.\n * @type {IProjectNetworkConfig}\n */\nexport type SolanaNetworkConfig = IProjectNetworkConfig<ISolanaEndpointConfig>;\n\n/**\n * Represents a Solana project configuration based on the CommonSubqueryProject template.\n * @type {CommonSubqueryProject<SolanaNetworkConfig, SubqlDatasource, RuntimeDatasourceTemplate | CustomDatasourceTemplate>}\n */\nexport type SolanaProject<DS extends SubqlDatasource = SubqlRuntimeDatasource> = CommonSubqueryProject<\n SolanaNetworkConfig,\n SubqlRuntimeDatasource | DS,\n BaseTemplateDataSource<SubqlRuntimeDatasource> | BaseTemplateDataSource<DS>\n>;\n"]}
@@ -0,0 +1,200 @@
1
+ import type { Address } from '@solana/addresses';
2
+ import { TransactionVersion } from '@solana/kit';
3
+ import type { TransactionForFullJson, UnixTimestamp, Blockhash, Slot, Base58EncodedBytes, Lamports, TransactionError, TransactionStatus, TokenBalance, Reward, Base64EncodedDataResponse } from '@solana/rpc-types';
4
+ import type { BlockFilter } from '@subql/types-core';
5
+ type AddressTableLookup = Readonly<{
6
+ /** public key for an address lookup table account. */
7
+ accountKey: Address;
8
+ /** List of indices used to load addresses of readonly accounts from a lookup table. */
9
+ readableIndexes: readonly number[];
10
+ /** List of indices used to load addresses of writable accounts from a lookup table. */
11
+ writableIndexes: readonly number[];
12
+ }>;
13
+ type TransactionForFullMetaLoadedAddresses = Readonly<{
14
+ /** Addresses loaded from lookup tables */
15
+ loadedAddresses: {
16
+ readonly: readonly Address[];
17
+ writable: readonly Address[];
18
+ };
19
+ }>;
20
+ type TransactionForFullTransactionAddressTableLookups = Readonly<{
21
+ message: {
22
+ addressTableLookups?: readonly AddressTableLookup[] | null;
23
+ };
24
+ }>;
25
+ type TransactionForFullTransactionJsonBase = Readonly<{
26
+ message: {
27
+ accountKeys: readonly Address[];
28
+ header: {
29
+ numReadonlySignedAccounts: number;
30
+ numReadonlyUnsignedAccounts: number;
31
+ numRequiredSignatures: number;
32
+ };
33
+ instructions: readonly SolanaInstruction[];
34
+ recentBlockhash: Blockhash;
35
+ };
36
+ signatures: readonly Base58EncodedBytes[];
37
+ }>;
38
+ type ReturnData = {
39
+ /** the return data itself */
40
+ data: Base64EncodedDataResponse;
41
+ /** the program that generated the return data */
42
+ programId: Address;
43
+ };
44
+ export type DecodedData<T = any> = {
45
+ name: string;
46
+ data: T;
47
+ };
48
+ export type SolanaLogMessage<T = any> = {
49
+ /** The raw log message **/
50
+ message: string;
51
+ /** A promise for the decoded message. This will be lazily evaluated unless it is matched by a datasource filter then it will resolve instantly */
52
+ decodedMessage: Promise<DecodedData<T> | null>;
53
+ /** The program address that emitted the message */
54
+ programId: string;
55
+ /** The original index of the unparsed log */
56
+ logIndex: number;
57
+ type: 'log' | 'data' | 'other';
58
+ };
59
+ type TransactionForFullMetaBase = Readonly<{
60
+ /** number of compute units consumed by the transaction */
61
+ computeUnitsConsumed?: bigint;
62
+ /** Error if transaction failed, null if transaction succeeded. */
63
+ err: TransactionError | null;
64
+ /** fee this transaction was charged */
65
+ fee: Lamports;
66
+ /** parsed log messages, can be null if log recording was not enabled for the message. */
67
+ logs: SolanaLogMessage[] | null;
68
+ /** array of account balances after the transaction was processed */
69
+ postBalances: readonly Lamports[];
70
+ /** List of token balances from after the transaction was processed or omitted if token balance recording was not yet enabled during this transaction */
71
+ postTokenBalances?: readonly TokenBalance[];
72
+ /** array of account balances from before the transaction was processed */
73
+ preBalances: readonly Lamports[];
74
+ /** List of token balances from before the transaction was processed or omitted if token balance recording was not yet enabled during this transaction */
75
+ preTokenBalances?: readonly TokenBalance[];
76
+ /** the most-recent return data generated by an instruction in the transaction */
77
+ returnData?: ReturnData;
78
+ /** transaction-level rewards */
79
+ rewards: readonly Reward[] | null;
80
+ /**
81
+ * Transaction status
82
+ * @deprecated
83
+ */
84
+ status: TransactionStatus;
85
+ }>;
86
+ export type TransactionForFullMetaInnerInstructionsUnparsed = Readonly<{
87
+ innerInstructions: readonly Readonly<{
88
+ /** The index of the instruction in the transaction */
89
+ index: number;
90
+ /** The instruction */
91
+ instructions: readonly SolanaInstruction[];
92
+ }>[];
93
+ }>;
94
+ export type SolanaTransaction = {
95
+ meta: (TransactionForFullMetaBase & TransactionForFullMetaInnerInstructionsUnparsed & TransactionForFullMetaLoadedAddresses) | null;
96
+ transaction: TransactionForFullTransactionAddressTableLookups & TransactionForFullTransactionJsonBase;
97
+ version: TransactionVersion;
98
+ block: BaseSolanaBlock;
99
+ };
100
+ export type SolanaInstruction<T = any> = Readonly<{
101
+ /** The index of the instruction within the transaction.
102
+ * If it is an inner transaction then the index is prefixed by the index of the outer instruction
103
+ * @example [3, 1] The 2nd inner instruction for the 4rd instruction */
104
+ index: number[];
105
+ accounts: readonly number[];
106
+ data: Base58EncodedBytes;
107
+ /** A promise for the decoded message. This will be lazily evaluated unless it is matched by a datasource filter then it will resolve instantly */
108
+ decodedData: Promise<DecodedData<T> | null>;
109
+ programIdIndex: number;
110
+ stackHeight?: number;
111
+ transaction: TransactionForFullJson<0>;
112
+ block: BaseSolanaBlock;
113
+ }>;
114
+ export type BaseSolanaBlock = Readonly<{
115
+ /** The number of blocks beneath this block */
116
+ blockHeight: bigint;
117
+ /** Estimated production time, as Unix timestamp */
118
+ blockTime: UnixTimestamp;
119
+ /** the blockhash of this block */
120
+ blockhash: Blockhash;
121
+ /** The slot index of this block's parent */
122
+ parentSlot: Slot;
123
+ /** The blockhash of this block's parent */
124
+ previousBlockhash: Blockhash;
125
+ }>;
126
+ export type SolanaBlock = Readonly<BaseSolanaBlock & {
127
+ transactions: readonly SolanaTransaction[];
128
+ }>;
129
+ export type SolanaBlockFilter = BlockFilter;
130
+ /**
131
+ * Represents a filter for Solana Transactions
132
+ * @interface
133
+ * @extends {SolanaTransactionFilter}
134
+ */
135
+ export interface SolanaTransactionFilter {
136
+ /**
137
+ * The account key of the transaction signer.
138
+ * */
139
+ signerAccountKey?: string;
140
+ }
141
+ export type InstructionAccountFilter = null | string[];
142
+ /**
143
+ * Represents a filter for Solana instructions
144
+ * @interface
145
+ * @extends {SolanaInstructionFilter}
146
+ */
147
+ export interface SolanaInstructionFilter {
148
+ /**
149
+ * The account key of the program that is interacted with.
150
+ * @example
151
+ * programId: "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"
152
+ * */
153
+ programId?: string;
154
+ /**
155
+ * The discriminator of the instruction data. This can be in hex, base58 or an Anchor program function name
156
+ * @example
157
+ * discriminator: "claim_token"
158
+ * @example
159
+ * discriminator: "74ce1bbfa6130049"
160
+ * */
161
+ discriminator?: string;
162
+ /**
163
+ * Instruction accounts by their index, null to skip that index or an array of addresses to match one of. This is limited to the first 16 accounts for performance optimisations.
164
+ * @example
165
+ * accounts: [null, null, ["GnjWvvFY1ZhWj5wJSZBxcpP6PqYmdXFaGgdgFKKYoZ1V"]] // Match instructions where the 3rd account is "GnjWvvFY1ZhWj5wJSZBxcpP6PqYmdXFaGgdgFKKYoZ1V"
166
+ * */
167
+ accounts?: [
168
+ InstructionAccountFilter,
169
+ InstructionAccountFilter?,
170
+ InstructionAccountFilter?,
171
+ InstructionAccountFilter?,
172
+ InstructionAccountFilter?,
173
+ InstructionAccountFilter?,
174
+ InstructionAccountFilter?,
175
+ InstructionAccountFilter?,
176
+ InstructionAccountFilter?,
177
+ InstructionAccountFilter?,
178
+ InstructionAccountFilter?,
179
+ InstructionAccountFilter?,
180
+ InstructionAccountFilter?,
181
+ InstructionAccountFilter?,
182
+ InstructionAccountFilter?,
183
+ InstructionAccountFilter?
184
+ ];
185
+ includeFailed?: boolean;
186
+ }
187
+ /**
188
+ * Represents a filter for Solana logs
189
+ * @interface
190
+ * @extends {SolanaLogFilter}
191
+ */
192
+ export interface SolanaLogFilter {
193
+ /**
194
+ * The account key of the program that is interacted with.
195
+ * @example
196
+ * programId: "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"
197
+ * */
198
+ programId?: string;
199
+ }
200
+ export {};
package/dist/solana.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
+ // SPDX-License-Identifier: GPL-3.0
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ //# sourceMappingURL=solana.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solana.js","sourceRoot":"","sources":["../src/solana.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport type {Address} from '@solana/addresses';\nimport {TransactionVersion} from '@solana/kit';\nimport type {\n TransactionForFullJson,\n UnixTimestamp,\n Blockhash,\n Slot,\n Base58EncodedBytes,\n Lamports,\n TransactionError,\n TransactionStatus,\n TokenBalance,\n Reward,\n Base64EncodedDataResponse,\n} from '@solana/rpc-types';\nimport type {BlockFilter} from '@subql/types-core';\n\ntype AddressTableLookup = Readonly<{\n /** public key for an address lookup table account. */\n accountKey: Address;\n /** List of indices used to load addresses of readonly accounts from a lookup table. */\n readableIndexes: readonly number[];\n /** List of indices used to load addresses of writable accounts from a lookup table. */\n writableIndexes: readonly number[];\n}>;\n\ntype TransactionForFullMetaLoadedAddresses = Readonly<{\n /** Addresses loaded from lookup tables */\n loadedAddresses: {\n readonly: readonly Address[];\n writable: readonly Address[];\n };\n}>;\n\ntype TransactionForFullTransactionAddressTableLookups = Readonly<{\n message: {\n addressTableLookups?: readonly AddressTableLookup[] | null;\n };\n}>;\n\ntype TransactionForFullTransactionJsonBase = Readonly<{\n message: {\n accountKeys: readonly Address[];\n header: {\n numReadonlySignedAccounts: number;\n numReadonlyUnsignedAccounts: number;\n numRequiredSignatures: number;\n };\n instructions: readonly SolanaInstruction[];\n recentBlockhash: Blockhash;\n };\n signatures: readonly Base58EncodedBytes[];\n}>;\n\ntype ReturnData = {\n /** the return data itself */\n data: Base64EncodedDataResponse;\n /** the program that generated the return data */\n programId: Address;\n};\n\nexport type DecodedData<T = any> = {\n name: string;\n data: T;\n};\n\nexport type SolanaLogMessage<T = any> = {\n /** The raw log message **/\n message: string;\n /** A promise for the decoded message. This will be lazily evaluated unless it is matched by a datasource filter then it will resolve instantly */\n decodedMessage: Promise<DecodedData<T> | null>;\n /** The program address that emitted the message */\n programId: string;\n /** The original index of the unparsed log */\n logIndex: number;\n\n type: 'log' | 'data' | 'other';\n};\n\ntype TransactionForFullMetaBase = Readonly<{\n /** number of compute units consumed by the transaction */\n computeUnitsConsumed?: bigint;\n /** Error if transaction failed, null if transaction succeeded. */\n err: TransactionError | null;\n /** fee this transaction was charged */\n fee: Lamports;\n /** parsed log messages, can be null if log recording was not enabled for the message. */\n logs: SolanaLogMessage[] | null;\n /** array of account balances after the transaction was processed */\n postBalances: readonly Lamports[];\n /** List of token balances from after the transaction was processed or omitted if token balance recording was not yet enabled during this transaction */\n postTokenBalances?: readonly TokenBalance[];\n /** array of account balances from before the transaction was processed */\n preBalances: readonly Lamports[];\n /** List of token balances from before the transaction was processed or omitted if token balance recording was not yet enabled during this transaction */\n preTokenBalances?: readonly TokenBalance[];\n /** the most-recent return data generated by an instruction in the transaction */\n returnData?: ReturnData;\n /** transaction-level rewards */\n rewards: readonly Reward[] | null;\n /**\n * Transaction status\n * @deprecated\n */\n status: TransactionStatus;\n}>;\n\n// type TransactionForFullMetaLoadedAddresses = Readonly<{\n// /** Addresses loaded from lookup tables */\n// loadedAddresses: {\n// readonly: readonly Address[];\n// writable: readonly Address[];\n// };\n// }>;\n\nexport type TransactionForFullMetaInnerInstructionsUnparsed = Readonly<{\n innerInstructions: readonly Readonly<{\n /** The index of the instruction in the transaction */\n index: number;\n /** The instruction */\n instructions: readonly SolanaInstruction[];\n }>[];\n}>;\n\nexport type SolanaTransaction = {\n meta:\n | (TransactionForFullMetaBase &\n TransactionForFullMetaInnerInstructionsUnparsed &\n TransactionForFullMetaLoadedAddresses)\n | null;\n transaction: TransactionForFullTransactionAddressTableLookups & TransactionForFullTransactionJsonBase;\n version: TransactionVersion;\n block: BaseSolanaBlock;\n};\n\nexport type SolanaInstruction<T = any> = Readonly<{\n /** The index of the instruction within the transaction.\n * If it is an inner transaction then the index is prefixed by the index of the outer instruction\n * @example [3, 1] The 2nd inner instruction for the 4rd instruction */\n index: number[];\n accounts: readonly number[];\n /* The raw instruction data, in base58 encoding */\n data: Base58EncodedBytes;\n /** A promise for the decoded message. This will be lazily evaluated unless it is matched by a datasource filter then it will resolve instantly */\n decodedData: Promise<DecodedData<T> | null>;\n programIdIndex: number;\n stackHeight?: number;\n\n // Variation from the original @solana/rpc-types to allow linking back to the transaction\n // Use the original pacakge type here so we dont have a circular reference beyond Tx -> Inst -> Tx\n transaction: TransactionForFullJson<0>;\n block: BaseSolanaBlock;\n}>;\n\nexport type BaseSolanaBlock = Readonly<{\n // From GetBlockApiResponseBase\n /** The number of blocks beneath this block */\n blockHeight: bigint;\n /** Estimated production time, as Unix timestamp */\n blockTime: UnixTimestamp;\n /** the blockhash of this block */\n blockhash: Blockhash;\n /** The slot index of this block's parent */\n parentSlot: Slot;\n /** The blockhash of this block's parent */\n previousBlockhash: Blockhash;\n}>;\n\n// Extracted equivalent https://github.com/anza-xyz/kit/blob/main/packages/rpc-api/src/getBlock.ts#L285\nexport type SolanaBlock = Readonly<\n BaseSolanaBlock & {\n // From GetBlockApiResponseWithTransactions\n transactions: readonly SolanaTransaction[];\n }\n>;\n\nexport type SolanaBlockFilter = BlockFilter;\n\n/**\n * Represents a filter for Solana Transactions\n * @interface\n * @extends {SolanaTransactionFilter}\n */\nexport interface SolanaTransactionFilter {\n // TODO could this be multiple addresses?\n /**\n * The account key of the transaction signer.\n * */\n signerAccountKey?: string;\n}\n\nexport type InstructionAccountFilter = null | string[];\n\n/**\n * Represents a filter for Solana instructions\n * @interface\n * @extends {SolanaInstructionFilter}\n */\nexport interface SolanaInstructionFilter {\n /**\n * The account key of the program that is interacted with.\n * @example\n * programId: \"JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4\"\n * */\n programId?: string;\n\n /**\n * The discriminator of the instruction data. This can be in hex, base58 or an Anchor program function name\n * @example\n * discriminator: \"claim_token\"\n * @example\n * discriminator: \"74ce1bbfa6130049\"\n * */\n discriminator?: string;\n\n /**\n * Instruction accounts by their index, null to skip that index or an array of addresses to match one of. This is limited to the first 16 accounts for performance optimisations.\n * @example\n * accounts: [null, null, [\"GnjWvvFY1ZhWj5wJSZBxcpP6PqYmdXFaGgdgFKKYoZ1V\"]] // Match instructions where the 3rd account is \"GnjWvvFY1ZhWj5wJSZBxcpP6PqYmdXFaGgdgFKKYoZ1V\"\n * */\n accounts?: [\n InstructionAccountFilter,\n InstructionAccountFilter?,\n InstructionAccountFilter?,\n InstructionAccountFilter?,\n InstructionAccountFilter?,\n InstructionAccountFilter?,\n InstructionAccountFilter?,\n InstructionAccountFilter?,\n InstructionAccountFilter?,\n InstructionAccountFilter?,\n InstructionAccountFilter?,\n InstructionAccountFilter?,\n InstructionAccountFilter?,\n InstructionAccountFilter?,\n InstructionAccountFilter?,\n InstructionAccountFilter?\n ];\n\n /* Include failed instructions. By default failed instructions are not included */\n includeFailed?: boolean;\n}\n\n/**\n * Represents a filter for Solana logs\n * @interface\n * @extends {SolanaLogFilter}\n */\nexport interface SolanaLogFilter {\n /**\n * The account key of the program that is interacted with.\n * @example\n * programId: \"JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4\"\n * */\n programId?: string;\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@subql/types-solana",
3
+ "version": "0.0.0-1",
4
+ "description": "",
5
+ "homepage": "https://github.com/subquery/subql-solana",
6
+ "repository": "github:subquery/subql-solana",
7
+ "scripts": {
8
+ "test": "echo \"Error: no test specified\" && exit 1",
9
+ "build": "rm -rf dist && tsc -b",
10
+ "changelog:release": "echo \"Updating changelog $npm_package_version\" && npx chan release $npm_package_version --git-url \"https://github.com/subquery/subql-solana\" --release-prefix=\"types-solana/\""
11
+ },
12
+ "author": "Ian He",
13
+ "main": "dist/index.js",
14
+ "license": "GPL-3.0",
15
+ "files": [
16
+ "src/global.d.ts",
17
+ "/dist"
18
+ ],
19
+ "dependencies": {
20
+ "@solana/kit": "^2.1.0",
21
+ "@subql/types-core": "^2.0.1"
22
+ },
23
+ "stableVersion": "0.0.0-0"
24
+ }