@subql/common-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.
- package/CHANGELOG.md +7 -0
- package/LICENSE +674 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/codegen/codegen.d.ts +4 -0
- package/dist/codegen/codegen.js +68 -0
- package/dist/codegen/codegen.js.map +1 -0
- package/dist/codegen/codegen.spec.d.ts +1 -0
- package/dist/codegen/codegen.spec.js +130 -0
- package/dist/codegen/codegen.spec.js.map +1 -0
- package/dist/codegen/idl.d.ts +11 -0
- package/dist/codegen/idl.js +88 -0
- package/dist/codegen/idl.js.map +1 -0
- package/dist/codegen/index.d.ts +2 -0
- package/dist/codegen/index.js +21 -0
- package/dist/codegen/index.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/project/index.d.ts +7 -0
- package/dist/project/index.js +27 -0
- package/dist/project/index.js.map +1 -0
- package/dist/project/load.d.ts +2 -0
- package/dist/project/load.js +12 -0
- package/dist/project/load.js.map +1 -0
- package/dist/project/models.d.ts +81 -0
- package/dist/project/models.js +270 -0
- package/dist/project/models.js.map +1 -0
- package/dist/project/project.spec.d.ts +1 -0
- package/dist/project/project.spec.js +109 -0
- package/dist/project/project.spec.js.map +1 -0
- package/dist/project/types.d.ts +4 -0
- package/dist/project/types.js +5 -0
- package/dist/project/types.js.map +1 -0
- package/dist/project/utils.d.ts +9 -0
- package/dist/project/utils.js +30 -0
- package/dist/project/utils.js.map +1 -0
- package/dist/project/versioned/ProjectManifestVersioned.d.ts +26 -0
- package/dist/project/versioned/ProjectManifestVersioned.js +56 -0
- package/dist/project/versioned/ProjectManifestVersioned.js.map +1 -0
- package/dist/project/versioned/index.d.ts +2 -0
- package/dist/project/versioned/index.js +21 -0
- package/dist/project/versioned/index.js.map +1 -0
- package/dist/project/versioned/v1_0_0/index.d.ts +1 -0
- package/dist/project/versioned/v1_0_0/index.js +20 -0
- package/dist/project/versioned/v1_0_0/index.js.map +1 -0
- package/dist/project/versioned/v1_0_0/model.d.ts +52 -0
- package/dist/project/versioned/v1_0_0/model.js +236 -0
- package/dist/project/versioned/v1_0_0/model.js.map +1 -0
- package/package.json +40 -0
- package/src/codegen/codegen.spec.ts +145 -0
- package/src/codegen/codegen.ts +90 -0
- package/src/codegen/idl.ts +89 -0
- package/src/codegen/index.ts +5 -0
- package/src/index.ts +16 -0
- package/src/project/index.ts +11 -0
- package/src/project/load.ts +10 -0
- package/src/project/models.ts +213 -0
- package/src/project/project.spec.ts +123 -0
- package/src/project/types.ts +19 -0
- package/src/project/utils.ts +50 -0
- package/src/project/versioned/ProjectManifestVersioned.ts +71 -0
- package/src/project/versioned/index.ts +5 -0
- package/src/project/versioned/v1_0_0/index.ts +4 -0
- package/src/project/versioned/v1_0_0/model.ts +200 -0
- package/templates/idl.ts.ejs +10 -0
- package/test/abiTest/project.yaml +51 -0
- package/test/project_1.0.0.yaml +91 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: GPL-3.0
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
BaseDeploymentV1_0_0,
|
|
6
|
+
CommonEndpointConfig,
|
|
7
|
+
CommonProjectNetworkV1_0_0,
|
|
8
|
+
FileType,
|
|
9
|
+
IsNetworkEndpoint,
|
|
10
|
+
ParentProjectModel,
|
|
11
|
+
ProjectManifestBaseImpl,
|
|
12
|
+
RunnerNodeImpl,
|
|
13
|
+
RunnerQueryBaseModel,
|
|
14
|
+
} from '@subql/common';
|
|
15
|
+
import { BaseMapping, NodeSpec, RunnerSpecs, QuerySpec, ParentProject } from '@subql/types-core';
|
|
16
|
+
import {
|
|
17
|
+
CustomDatasourceTemplate,
|
|
18
|
+
SolanaProjectManifestV1_0_0,
|
|
19
|
+
ISolanaEndpointConfig,
|
|
20
|
+
RuntimeDatasourceTemplate,
|
|
21
|
+
SubqlCustomDatasource,
|
|
22
|
+
SubqlMapping,
|
|
23
|
+
SubqlRuntimeDatasource,
|
|
24
|
+
} from '@subql/types-solana';
|
|
25
|
+
import { plainToInstance, Transform, TransformFnParams, Type } from 'class-transformer';
|
|
26
|
+
import {
|
|
27
|
+
Equals,
|
|
28
|
+
IsArray,
|
|
29
|
+
IsIn,
|
|
30
|
+
IsNotEmpty,
|
|
31
|
+
IsObject,
|
|
32
|
+
IsOptional,
|
|
33
|
+
IsPositive,
|
|
34
|
+
IsString,
|
|
35
|
+
ValidateNested,
|
|
36
|
+
validateSync,
|
|
37
|
+
} from 'class-validator';
|
|
38
|
+
import { CustomDataSourceBase, RuntimeDataSourceBase } from '../../models';
|
|
39
|
+
import { SubqlSolanaDataSource, SubqlRuntimeHandler } from '../../types';
|
|
40
|
+
|
|
41
|
+
const SOLANA_NODE_NAME = `@subql/node-solana`;
|
|
42
|
+
|
|
43
|
+
export class SolanaRunnerNodeImpl extends RunnerNodeImpl {
|
|
44
|
+
@IsIn([SOLANA_NODE_NAME], {
|
|
45
|
+
message: `Runner Solana node name is incorrect, supposed to be '${SOLANA_NODE_NAME}'`,
|
|
46
|
+
})
|
|
47
|
+
name: string = SOLANA_NODE_NAME;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function validateObject(object: any, errorMessage = 'failed to validate object.'): void {
|
|
51
|
+
const errors = validateSync(object, { whitelist: true, forbidNonWhitelisted: true });
|
|
52
|
+
if (errors?.length) {
|
|
53
|
+
const errorMsgs = errors.map((e) => e.toString()).join('\n');
|
|
54
|
+
throw new Error(`${errorMessage}\n${errorMsgs}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export class SolanaRuntimeDataSourceImpl
|
|
59
|
+
extends RuntimeDataSourceBase<SubqlMapping<SubqlRuntimeHandler>>
|
|
60
|
+
implements SubqlRuntimeDatasource {
|
|
61
|
+
validate(): void {
|
|
62
|
+
return validateObject(this, 'failed to validate runtime datasource.');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export class SolanaCustomDataSourceImpl<K extends string = string, M extends BaseMapping<any> = BaseMapping<any>>
|
|
67
|
+
extends CustomDataSourceBase<K, M>
|
|
68
|
+
implements SubqlCustomDatasource<K, M> {
|
|
69
|
+
validate(): void {
|
|
70
|
+
return validateObject(this, 'failed to validate custom datasource.');
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export class RuntimeDatasourceTemplateImpl extends SolanaRuntimeDataSourceImpl implements RuntimeDatasourceTemplate {
|
|
75
|
+
@IsString()
|
|
76
|
+
name!: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export class CustomDatasourceTemplateImpl extends SolanaCustomDataSourceImpl implements CustomDatasourceTemplate {
|
|
80
|
+
@IsString()
|
|
81
|
+
name!: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export class SolanaRunnerSpecsImpl implements RunnerSpecs {
|
|
85
|
+
@IsObject()
|
|
86
|
+
@ValidateNested()
|
|
87
|
+
@Type(() => SolanaRunnerNodeImpl)
|
|
88
|
+
node!: NodeSpec;
|
|
89
|
+
@IsObject()
|
|
90
|
+
@ValidateNested()
|
|
91
|
+
@Type(() => RunnerQueryBaseModel)
|
|
92
|
+
query!: QuerySpec;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export class ProjectNetworkDeploymentV1_0_0 {
|
|
96
|
+
@IsNotEmpty()
|
|
97
|
+
@Transform(({ value }: TransformFnParams) => value.trim())
|
|
98
|
+
@IsString()
|
|
99
|
+
chainId!: string;
|
|
100
|
+
@IsOptional()
|
|
101
|
+
@IsArray()
|
|
102
|
+
bypassBlocks?: (number | `${number}-${number}`)[];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export class SolanaEndpointConfig extends CommonEndpointConfig implements ISolanaEndpointConfig {
|
|
106
|
+
@IsOptional()
|
|
107
|
+
@IsPositive()
|
|
108
|
+
batchSize?: number;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export class ProjectNetworkV1_0_0 extends CommonProjectNetworkV1_0_0<void> {
|
|
112
|
+
@IsOptional()
|
|
113
|
+
@IsNetworkEndpoint(SolanaEndpointConfig)
|
|
114
|
+
endpoint: string | string[] | Record<string, CommonEndpointConfig> = {};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export class DeploymentV1_0_0 extends BaseDeploymentV1_0_0 {
|
|
118
|
+
@Transform((params) => {
|
|
119
|
+
if (params.value.genesisHash && !params.value.chainId) {
|
|
120
|
+
params.value.chainId = params.value.genesisHash;
|
|
121
|
+
}
|
|
122
|
+
return plainToInstance(ProjectNetworkDeploymentV1_0_0, params.value);
|
|
123
|
+
})
|
|
124
|
+
@ValidateNested()
|
|
125
|
+
@Type(() => ProjectNetworkDeploymentV1_0_0)
|
|
126
|
+
network!: ProjectNetworkDeploymentV1_0_0;
|
|
127
|
+
@IsObject()
|
|
128
|
+
@ValidateNested()
|
|
129
|
+
@Type(() => SolanaRunnerSpecsImpl)
|
|
130
|
+
runner!: RunnerSpecs;
|
|
131
|
+
@IsArray()
|
|
132
|
+
@ValidateNested()
|
|
133
|
+
@Type(() => SolanaCustomDataSourceImpl, {
|
|
134
|
+
discriminator: {
|
|
135
|
+
property: 'kind',
|
|
136
|
+
subTypes: [{ value: SolanaRuntimeDataSourceImpl, name: 'solana/Runtime' }],
|
|
137
|
+
},
|
|
138
|
+
keepDiscriminatorProperty: true,
|
|
139
|
+
})
|
|
140
|
+
dataSources!: (SubqlRuntimeDatasource | SubqlCustomDatasource)[];
|
|
141
|
+
@IsOptional()
|
|
142
|
+
@IsArray()
|
|
143
|
+
@ValidateNested()
|
|
144
|
+
@Type(() => CustomDatasourceTemplateImpl, {
|
|
145
|
+
discriminator: {
|
|
146
|
+
property: 'kind',
|
|
147
|
+
subTypes: [{ value: RuntimeDatasourceTemplateImpl, name: 'solana/Runtime' }],
|
|
148
|
+
},
|
|
149
|
+
keepDiscriminatorProperty: true,
|
|
150
|
+
})
|
|
151
|
+
templates?: (RuntimeDatasourceTemplate | CustomDatasourceTemplate)[];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export class ProjectManifestV1_0_0Impl
|
|
155
|
+
extends ProjectManifestBaseImpl<DeploymentV1_0_0>
|
|
156
|
+
implements SolanaProjectManifestV1_0_0 {
|
|
157
|
+
constructor() {
|
|
158
|
+
super(DeploymentV1_0_0);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
@Equals('1.0.0')
|
|
162
|
+
specVersion = '1.0.0';
|
|
163
|
+
@Type(() => SolanaCustomDataSourceImpl, {
|
|
164
|
+
discriminator: {
|
|
165
|
+
property: 'kind',
|
|
166
|
+
subTypes: [{ value: SolanaRuntimeDataSourceImpl, name: 'solana/Runtime' }],
|
|
167
|
+
},
|
|
168
|
+
keepDiscriminatorProperty: true,
|
|
169
|
+
})
|
|
170
|
+
dataSources!: SubqlSolanaDataSource[];
|
|
171
|
+
@Type(() => ProjectNetworkV1_0_0)
|
|
172
|
+
network!: ProjectNetworkV1_0_0;
|
|
173
|
+
@IsString()
|
|
174
|
+
name!: string;
|
|
175
|
+
@IsString()
|
|
176
|
+
version!: string;
|
|
177
|
+
@ValidateNested()
|
|
178
|
+
@Type(() => FileType)
|
|
179
|
+
schema!: FileType;
|
|
180
|
+
@IsOptional()
|
|
181
|
+
@IsArray()
|
|
182
|
+
@ValidateNested()
|
|
183
|
+
@Type(() => CustomDatasourceTemplateImpl, {
|
|
184
|
+
discriminator: {
|
|
185
|
+
property: 'kind',
|
|
186
|
+
subTypes: [{ value: RuntimeDatasourceTemplateImpl, name: 'solana/Runtime' }],
|
|
187
|
+
},
|
|
188
|
+
keepDiscriminatorProperty: true,
|
|
189
|
+
})
|
|
190
|
+
templates?: (RuntimeDatasourceTemplate | CustomDatasourceTemplate)[];
|
|
191
|
+
@IsObject()
|
|
192
|
+
@ValidateNested()
|
|
193
|
+
@Type(() => SolanaRunnerSpecsImpl)
|
|
194
|
+
runner!: RunnerSpecs;
|
|
195
|
+
|
|
196
|
+
@IsOptional()
|
|
197
|
+
@IsObject()
|
|
198
|
+
@Type(() => ParentProjectModel)
|
|
199
|
+
parent?: ParentProject;
|
|
200
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
|
|
3
|
+
// Auto-generated , DO NOT EDIT
|
|
4
|
+
import { SolanaInstruction, SolanaLogMessage } from '@subql/types-solana';
|
|
5
|
+
|
|
6
|
+
import {<% props.instructions.forEach(function(inst){ %><%= inst %>InstructionDataArgs, <% }); %>} from '../program-interfaces/<%=props.name%>/instructions';
|
|
7
|
+
|
|
8
|
+
<% props.instructions.forEach(function(inst){ %>
|
|
9
|
+
export type <%=inst %>Instruction = SolanaInstruction<<%=inst%>InstructionDataArgs>
|
|
10
|
+
<% }); %>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
specVersion: '1.0.0'
|
|
2
|
+
name: 'example'
|
|
3
|
+
|
|
4
|
+
version: '0.0.1'
|
|
5
|
+
runner:
|
|
6
|
+
node:
|
|
7
|
+
name: '@subql/node-ethereum'
|
|
8
|
+
version: '*'
|
|
9
|
+
query:
|
|
10
|
+
name: '@subql/query'
|
|
11
|
+
version: '*'
|
|
12
|
+
description: ''
|
|
13
|
+
repository: ''
|
|
14
|
+
schema:
|
|
15
|
+
file: './schema.graphql'
|
|
16
|
+
network:
|
|
17
|
+
chainId: '1'
|
|
18
|
+
endpoint: 'aaa'
|
|
19
|
+
dictionary: ''
|
|
20
|
+
|
|
21
|
+
customDs:
|
|
22
|
+
assets:
|
|
23
|
+
abi:
|
|
24
|
+
file: ./erc20.json
|
|
25
|
+
artifact:
|
|
26
|
+
file: ./abis/Erc20.sol/erc20.json
|
|
27
|
+
dataSources:
|
|
28
|
+
- kind: ethereum/Runtime
|
|
29
|
+
options:
|
|
30
|
+
abi: Erc20
|
|
31
|
+
assets:
|
|
32
|
+
Erc20:
|
|
33
|
+
file: './abis/erc20.json'
|
|
34
|
+
startBlock: 1
|
|
35
|
+
mapping:
|
|
36
|
+
file: ''
|
|
37
|
+
handlers:
|
|
38
|
+
- handler: handleTransaction
|
|
39
|
+
kind: ethereum/BlockHandler
|
|
40
|
+
- kind: ethereum/Runtime
|
|
41
|
+
options:
|
|
42
|
+
abi: 'artifactErc20'
|
|
43
|
+
assets:
|
|
44
|
+
'artifactErc20':
|
|
45
|
+
file: './abis/Erc20.sol/Erc20.json'
|
|
46
|
+
startBlock: 1
|
|
47
|
+
mapping:
|
|
48
|
+
file: ''
|
|
49
|
+
handlers:
|
|
50
|
+
- handler: handleTransaction
|
|
51
|
+
kind: ethereum/BlockHandler
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
specVersion: '1.0.0'
|
|
2
|
+
|
|
3
|
+
name: 'test'
|
|
4
|
+
version: '0.0.1'
|
|
5
|
+
runner:
|
|
6
|
+
node:
|
|
7
|
+
name: '@subql/node-solana'
|
|
8
|
+
version: '*'
|
|
9
|
+
query:
|
|
10
|
+
name: '@subql/query'
|
|
11
|
+
version: '*'
|
|
12
|
+
description: 'This project can be use as a starting point for developing your new Solana SubQuery project'
|
|
13
|
+
repository: 'https://github.com/subquery/solana-subql-starter'
|
|
14
|
+
|
|
15
|
+
schema:
|
|
16
|
+
file: './schema.graphql'
|
|
17
|
+
|
|
18
|
+
network:
|
|
19
|
+
# endpoint: "fill it in"
|
|
20
|
+
chainId: '1'
|
|
21
|
+
dictionary: 'https://eth-dict.api.onfinality.io/'
|
|
22
|
+
endpoint: 'wss://eth.api.onfinality.io/ws?apikey='
|
|
23
|
+
|
|
24
|
+
dataSources:
|
|
25
|
+
- kind: solana/Runtime
|
|
26
|
+
startBlock: 12369621
|
|
27
|
+
mapping:
|
|
28
|
+
file: './dist/index.js'
|
|
29
|
+
handlers:
|
|
30
|
+
- handler: handlePoolCreated
|
|
31
|
+
kind: solana/LogHandler
|
|
32
|
+
filter:
|
|
33
|
+
topics:
|
|
34
|
+
- PoolCreated(address indexed token0, address indexed token1, uint24 indexed fee, int24 tickSpacing, address pool)
|
|
35
|
+
# solana/contract
|
|
36
|
+
- kind: solana/Runtime
|
|
37
|
+
startBlock: 12369651
|
|
38
|
+
mapping:
|
|
39
|
+
file: './dist/index.js'
|
|
40
|
+
handlers:
|
|
41
|
+
- handler: handleIncreaseLiquidity
|
|
42
|
+
kind: solana/LogHandler
|
|
43
|
+
filter:
|
|
44
|
+
topics:
|
|
45
|
+
- IncreaseLiquidity (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1)
|
|
46
|
+
- handler: handleDecreaseLiquidity
|
|
47
|
+
kind: solana/LogHandler
|
|
48
|
+
filter:
|
|
49
|
+
topics:
|
|
50
|
+
- DecreaseLiquidity (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1)
|
|
51
|
+
- handler: handleCollect
|
|
52
|
+
kind: solana/LogHandler
|
|
53
|
+
filter:
|
|
54
|
+
topics:
|
|
55
|
+
- Collect (uint256 tokenId, address recipient, uint256 amount0, uint256 amount1)
|
|
56
|
+
- handler: handleTransfer
|
|
57
|
+
kind: solana/LogHandler
|
|
58
|
+
filter:
|
|
59
|
+
topics:
|
|
60
|
+
- Transfer (address from, address to, uint256 tokenId)
|
|
61
|
+
templates:
|
|
62
|
+
- name: Pool
|
|
63
|
+
kind: solana/Runtime
|
|
64
|
+
mapping:
|
|
65
|
+
file: './dist/index.js'
|
|
66
|
+
handlers:
|
|
67
|
+
- handler: handleInitialize
|
|
68
|
+
kind: solana/LogHandler
|
|
69
|
+
filter:
|
|
70
|
+
topics:
|
|
71
|
+
- Initialize (uint160,int24)
|
|
72
|
+
- handler: handleSwap
|
|
73
|
+
kind: solana/LogHandler
|
|
74
|
+
filter:
|
|
75
|
+
topics:
|
|
76
|
+
- Swap (address sender, address recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick)
|
|
77
|
+
- handler: handleMint
|
|
78
|
+
kind: solana/LogHandler
|
|
79
|
+
filter:
|
|
80
|
+
topics:
|
|
81
|
+
- Mint(address sender, address owner, int24 tickLower, int24 tickUpper, uint128 amount, uint256 amount0, uint256 amount1)
|
|
82
|
+
- handler: handleBurn
|
|
83
|
+
kind: solana/LogHandler
|
|
84
|
+
filter:
|
|
85
|
+
topics:
|
|
86
|
+
- Burn(indexed address,indexed int24,indexed int24,uint128,uint256,uint256)
|
|
87
|
+
- handler: handleFlash
|
|
88
|
+
kind: solana/LogHandler
|
|
89
|
+
filter:
|
|
90
|
+
topics:
|
|
91
|
+
- Flash(indexed address,indexed address,uint256,uint256,uint256,uint256)
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"rootDir": "src",
|
|
5
|
+
"tsBuildInfoFile": "dist/.tsbuildinfo",
|
|
6
|
+
"outDir": "dist",
|
|
7
|
+
"noImplicitAny": true,
|
|
8
|
+
"strict": true
|
|
9
|
+
},
|
|
10
|
+
"references": [{"path": "../types"}],
|
|
11
|
+
"include": ["src/**/*"]
|
|
12
|
+
}
|