@sentio/sdk 1.36.0-rc.1 → 1.36.0-rc.3
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/lib/aptos/network.d.ts +1 -1
- package/lib/aptos/network.js +7 -7
- package/lib/aptos/network.js.map +1 -1
- package/lib/aptos-codegen/codegen.js +1 -1
- package/lib/aptos-codegen/codegen.js.map +1 -1
- package/lib/core/bind-options.d.ts +0 -4
- package/lib/core/bind-options.js +1 -5
- package/lib/core/bind-options.js.map +1 -1
- package/lib/core/context.d.ts +0 -7
- package/lib/core/context.js +2 -27
- package/lib/core/context.js.map +1 -1
- package/lib/core/index.d.ts +5 -3
- package/lib/core/index.js +7 -5
- package/lib/core/index.js.map +1 -1
- package/lib/core/solana-context.d.ts +12 -0
- package/lib/core/solana-context.js +34 -0
- package/lib/core/solana-context.js.map +1 -0
- package/lib/core/solana-options.d.ts +9 -0
- package/lib/core/solana-options.js +13 -0
- package/lib/core/solana-options.js.map +1 -0
- package/lib/core/solana-processor.d.ts +3 -2
- package/lib/core/solana-processor.js +5 -2
- package/lib/core/solana-processor.js.map +1 -1
- package/lib/service.js +2 -2
- package/lib/service.js.map +1 -1
- package/lib/utils/chain.d.ts +86 -6
- package/lib/utils/chain.js +95 -91
- package/lib/utils/chain.js.map +1 -1
- package/package.json +2 -11
- package/src/aptos/network.ts +6 -6
- package/src/aptos-codegen/codegen.ts +2 -2
- package/src/core/bind-options.ts +0 -5
- package/src/core/context.ts +2 -29
- package/src/core/index.ts +6 -4
- package/src/core/solana-context.ts +35 -0
- package/src/core/solana-options.ts +10 -0
- package/src/core/solana-processor.ts +6 -3
- package/src/service.ts +3 -3
- package/src/utils/chain.ts +94 -91
|
@@ -5,7 +5,7 @@ import { MoveFunction, MoveModule, MoveModuleBytecode, MoveStruct } from 'aptos-
|
|
|
5
5
|
import { AccountModulesImportInfo, AccountRegister, generateType } from './typegen'
|
|
6
6
|
import { getMeaningfulFunctionParams, isFrameworkAccount, moduleQname, SPLITTER } from '../aptos/utils'
|
|
7
7
|
import chalk from 'chalk'
|
|
8
|
-
import { AptosNetwork,
|
|
8
|
+
import { AptosNetwork, getAptosChainName, getRpcClient } from '../aptos/network'
|
|
9
9
|
import { parseMoveType } from '../aptos/types'
|
|
10
10
|
|
|
11
11
|
export function codeGenAptosProcessor(abisDir: string, outDir = 'src/types/aptos') {
|
|
@@ -65,7 +65,7 @@ export async function generateForNetwork(srcDir: string, outputDir: string, netw
|
|
|
65
65
|
|
|
66
66
|
while (loader.pendingAccounts.size > 0) {
|
|
67
67
|
for (const account of loader.pendingAccounts) {
|
|
68
|
-
console.log(`download dependent module for account ${account} at ${
|
|
68
|
+
console.log(`download dependent module for account ${account} at ${getAptosChainName(network)}`)
|
|
69
69
|
|
|
70
70
|
try {
|
|
71
71
|
const modules = await client.getAccountModules(account)
|
package/src/core/bind-options.ts
CHANGED
|
@@ -38,11 +38,6 @@ export class BindInternalOptions {
|
|
|
38
38
|
endBlock?: Long
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
export class SolanaBindOptions extends BindOptions {
|
|
42
|
-
declare network?: string
|
|
43
|
-
processInnerInstruction?: boolean
|
|
44
|
-
}
|
|
45
|
-
|
|
46
41
|
export class AccountBindOptions {
|
|
47
42
|
address: string
|
|
48
43
|
network?: Networkish
|
package/src/core/context.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { normalizeLabels } from './meter'
|
|
|
5
5
|
import Long from 'long'
|
|
6
6
|
import { Trace } from './trace'
|
|
7
7
|
import { Labels } from './metadata'
|
|
8
|
-
import {
|
|
8
|
+
import { CHAIN_IDS } from '../utils/chain'
|
|
9
9
|
import { BaseContext } from './base-context'
|
|
10
10
|
|
|
11
11
|
export abstract class EthContext extends BaseContext {
|
|
@@ -156,33 +156,6 @@ export class BoundContractView<TContract extends BaseContract, TContractView ext
|
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
export class SolanaContext extends BaseContext {
|
|
160
|
-
address: string
|
|
161
|
-
programName: string
|
|
162
|
-
blockNumber: Long
|
|
163
|
-
|
|
164
|
-
constructor(programName: string, address: string, slot: Long) {
|
|
165
|
-
super()
|
|
166
|
-
this.programName = programName
|
|
167
|
-
this.address = address
|
|
168
|
-
this.blockNumber = slot
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
getMetaData(name: string, labels: Labels): RecordMetaData {
|
|
172
|
-
return {
|
|
173
|
-
address: this.address,
|
|
174
|
-
contractName: this.programName,
|
|
175
|
-
blockNumber: this.blockNumber,
|
|
176
|
-
transactionIndex: 0,
|
|
177
|
-
transactionHash: '', // TODO add
|
|
178
|
-
logIndex: 0,
|
|
179
|
-
chainId: SOL_MAINMET_ID, // TODO set in context
|
|
180
|
-
name: name,
|
|
181
|
-
labels: normalizeLabels(labels),
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
159
|
export class SuiContext extends BaseContext {
|
|
187
160
|
address: string
|
|
188
161
|
moduleName: string
|
|
@@ -202,7 +175,7 @@ export class SuiContext extends BaseContext {
|
|
|
202
175
|
transactionIndex: 0,
|
|
203
176
|
transactionHash: '', // TODO
|
|
204
177
|
logIndex: 0,
|
|
205
|
-
chainId:
|
|
178
|
+
chainId: CHAIN_IDS.SUI_DEVNET, // TODO set in context
|
|
206
179
|
name: name,
|
|
207
180
|
labels: normalizeLabels(labels),
|
|
208
181
|
}
|
package/src/core/index.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
export { BigDecimal } from './big-decimal'
|
|
2
|
-
export { ContractContext, ContractView, BoundContractView
|
|
2
|
+
export { ContractContext, ContractView, BoundContractView } from './context'
|
|
3
3
|
export { CounterBinding, Meter, GaugeBinding, Counter, Gauge, MetricOptions } from './meter'
|
|
4
4
|
export { EventTracker, AccountEventTracker } from './event-tracker'
|
|
5
5
|
export { type Numberish, toBigInteger, toMetricValue } from './numberish'
|
|
6
6
|
|
|
7
|
-
export { BindOptions
|
|
7
|
+
export { BindOptions } from './bind-options'
|
|
8
8
|
|
|
9
9
|
export { BaseProcessor } from './base-processor'
|
|
10
10
|
export { GenericProcessor } from './generic-processor'
|
|
11
11
|
export { BaseProcessorTemplate } from './base-processor-template'
|
|
12
|
-
export { SolanaBaseProcessor } from './solana-processor'
|
|
13
12
|
export { SuiBaseProcessor, SuiBindOptions } from './sui-processor'
|
|
14
|
-
|
|
13
|
+
|
|
14
|
+
export { SolanaContext } from './solana-context'
|
|
15
|
+
export { SolanaBindOptions } from './solana-options'
|
|
16
|
+
export { SolanaBaseProcessor } from './solana-processor'
|
|
15
17
|
|
|
16
18
|
export type { TypedCallTrace, Trace } from './trace'
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { BaseContext } from './base-context'
|
|
2
|
+
import Long from 'long'
|
|
3
|
+
import { Labels } from './metadata'
|
|
4
|
+
import { RecordMetaData } from '@sentio/sdk'
|
|
5
|
+
import { CHAIN_IDS } from '../utils/chain'
|
|
6
|
+
import { normalizeLabels } from './meter'
|
|
7
|
+
|
|
8
|
+
export class SolanaContext extends BaseContext {
|
|
9
|
+
network: string
|
|
10
|
+
address: string
|
|
11
|
+
programName: string
|
|
12
|
+
blockNumber: Long
|
|
13
|
+
|
|
14
|
+
constructor(programName: string, network: string, address: string, slot: Long) {
|
|
15
|
+
super()
|
|
16
|
+
this.network = network || CHAIN_IDS.SOLANA_MAINNET
|
|
17
|
+
this.programName = programName
|
|
18
|
+
this.address = address
|
|
19
|
+
this.blockNumber = slot
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
getMetaData(name: string, labels: Labels): RecordMetaData {
|
|
23
|
+
return {
|
|
24
|
+
address: this.address,
|
|
25
|
+
contractName: this.programName,
|
|
26
|
+
blockNumber: this.blockNumber,
|
|
27
|
+
transactionIndex: 0,
|
|
28
|
+
transactionHash: '', // TODO add
|
|
29
|
+
logIndex: 0,
|
|
30
|
+
chainId: this.network,
|
|
31
|
+
name: name,
|
|
32
|
+
labels: normalizeLabels(labels),
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ProcessResult } from '../gen'
|
|
2
|
-
import { SolanaContext } from './context'
|
|
2
|
+
import { SolanaContext } from './solana-context'
|
|
3
3
|
import Long from 'long'
|
|
4
4
|
import { Instruction } from '@project-serum/anchor'
|
|
5
|
-
import { SolanaBindOptions } from './
|
|
5
|
+
import { SolanaBindOptions } from './solana-options'
|
|
6
6
|
import { ListStateStorage } from '../state/state-storage'
|
|
7
|
+
import { CHAIN_IDS } from '../utils/chain'
|
|
7
8
|
|
|
8
9
|
type IndexConfigure = {
|
|
9
10
|
startSlot: Long
|
|
@@ -21,6 +22,7 @@ export class SolanaBaseProcessor {
|
|
|
21
22
|
address: string
|
|
22
23
|
endpoint: string
|
|
23
24
|
contractName: string
|
|
25
|
+
network: string
|
|
24
26
|
processInnerInstruction: boolean
|
|
25
27
|
config: IndexConfigure = { startSlot: new Long(0) }
|
|
26
28
|
decodeInstruction: (rawInstruction: string) => Instruction | null
|
|
@@ -37,6 +39,7 @@ export class SolanaBaseProcessor {
|
|
|
37
39
|
this.address = options.address
|
|
38
40
|
this.contractName = options.name || ''
|
|
39
41
|
this.processInnerInstruction = options.processInnerInstruction || false
|
|
42
|
+
this.network = options.network || CHAIN_IDS.SOLANA_MAINNET
|
|
40
43
|
if (options.startBlock) {
|
|
41
44
|
this.startSlot(options.startBlock)
|
|
42
45
|
}
|
|
@@ -84,7 +87,7 @@ export class SolanaBaseProcessor {
|
|
|
84
87
|
handler: SolanaInstructionHandler,
|
|
85
88
|
slot: Long
|
|
86
89
|
): ProcessResult {
|
|
87
|
-
const ctx = new SolanaContext(this.contractName, this.address, slot)
|
|
90
|
+
const ctx = new SolanaContext(this.contractName, this.network, this.address, slot)
|
|
88
91
|
handler(parsedInstruction, ctx, accounts)
|
|
89
92
|
return ctx.getProcessResult()
|
|
90
93
|
}
|
package/src/service.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Block, Log } from '@ethersproject/abstract-provider'
|
|
2
2
|
import { CallContext, ServerError, Status } from 'nice-grpc'
|
|
3
|
-
import {
|
|
3
|
+
import { CHAIN_IDS } from './utils/chain'
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
AccountConfig,
|
|
@@ -277,7 +277,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
277
277
|
processorType: USER_PROCESSOR,
|
|
278
278
|
contract: {
|
|
279
279
|
name: solanaProcessor.contractName,
|
|
280
|
-
chainId:
|
|
280
|
+
chainId: CHAIN_IDS.SOLANA_MAINNET,
|
|
281
281
|
address: solanaProcessor.address,
|
|
282
282
|
abi: '',
|
|
283
283
|
},
|
|
@@ -303,7 +303,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
303
303
|
processorType: USER_PROCESSOR,
|
|
304
304
|
contract: {
|
|
305
305
|
name: 'sui contract',
|
|
306
|
-
chainId:
|
|
306
|
+
chainId: CHAIN_IDS.SUI_DEVNET,
|
|
307
307
|
address: suiProcessor.address,
|
|
308
308
|
abi: '',
|
|
309
309
|
},
|
package/src/utils/chain.ts
CHANGED
|
@@ -1,100 +1,103 @@
|
|
|
1
1
|
// copy from https://github.com/DefiLlama/chainlist/blob/main/constants/chainIds.js
|
|
2
2
|
// and https://besu.hyperledger.org/en/stable/Concepts/NetworkID-And-ChainID/
|
|
3
3
|
|
|
4
|
-
export const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
4
|
+
export const CHAIN_IDS = {
|
|
5
|
+
KARDIA: '0',
|
|
6
|
+
ETHEREUM: '1',
|
|
7
|
+
EXPANSE: '2',
|
|
8
|
+
ROPSTEN: '3',
|
|
9
|
+
RINKEBY: '4',
|
|
10
|
+
GOERLI: '5',
|
|
11
|
+
KOTTI: '6',
|
|
12
|
+
UBIQ: '8',
|
|
13
|
+
OPTIMISM: '10',
|
|
14
|
+
SONGBIRD: '19',
|
|
15
|
+
ELASTOS: '20',
|
|
16
|
+
CRONOS: '25',
|
|
17
|
+
RSK: '30',
|
|
18
|
+
TELOS: '40',
|
|
19
|
+
XDC: '50',
|
|
20
|
+
CSC: '52',
|
|
21
|
+
ZYX: '55',
|
|
22
|
+
BINANCE: '56',
|
|
23
|
+
SYSCOIN: '57',
|
|
24
|
+
GOCHAIN: '60',
|
|
25
|
+
ETHCLASSIC: '61',
|
|
26
|
+
MORDOR: '63',
|
|
27
|
+
OKEXCHAIN: '66',
|
|
28
|
+
HOO: '70',
|
|
29
|
+
METER: '82',
|
|
30
|
+
TOMOCHAIN: '88',
|
|
31
|
+
XDAI: '100',
|
|
32
|
+
VELAS: '106',
|
|
33
|
+
THUNDERCORE: '108',
|
|
34
|
+
FUSE: '122',
|
|
35
|
+
HECO: '128',
|
|
36
|
+
POLYGON: '137',
|
|
37
|
+
XDAIARB: '200',
|
|
38
|
+
ASTOR: '212',
|
|
39
|
+
ENERGYWEB: '246',
|
|
40
|
+
FANTOM: '250',
|
|
41
|
+
HPB: '269',
|
|
42
|
+
BOBA: '288',
|
|
43
|
+
KUCOIN: '321',
|
|
44
|
+
SHIDEN: '336',
|
|
45
|
+
THETA: '361',
|
|
46
|
+
SX: '416',
|
|
47
|
+
CANDLE: '534',
|
|
48
|
+
ASTAR: '592',
|
|
49
|
+
CALLISTO: '820',
|
|
50
|
+
WANCHAIN: '888',
|
|
51
|
+
METIS: '1088',
|
|
52
|
+
OMCHAIN: '1246',
|
|
53
|
+
MOONBEAM: '1284',
|
|
54
|
+
MOONRIVER: '1285',
|
|
55
|
+
DEV: '2018',
|
|
56
|
+
RONIN: '2020',
|
|
57
|
+
KAVA: '2222',
|
|
58
|
+
EZCHAIN: '2612',
|
|
59
|
+
PHI: '4181',
|
|
60
|
+
IOTEX: '4689',
|
|
61
|
+
XLC: '5050',
|
|
62
|
+
NAHMII: '5551',
|
|
63
|
+
NMACTEST: '7777',
|
|
64
|
+
KLAYTN: '8217',
|
|
65
|
+
EVMOS: '9001',
|
|
66
|
+
SMARTBCH: '10000',
|
|
67
|
+
CRYSTALEUM: '103090',
|
|
68
|
+
FUSION: '32659',
|
|
69
|
+
ARBITRUM: '42161',
|
|
70
|
+
CELO: '42220',
|
|
71
|
+
OASIS: '42262',
|
|
72
|
+
AVALANCHE: '43114',
|
|
73
|
+
GODWOKEN: '71402',
|
|
74
|
+
AKROMA: '200625',
|
|
75
|
+
POLIS: '333999',
|
|
76
|
+
ARBITRUM_TEST: '421613',
|
|
77
|
+
SEPOLIA: '11155111',
|
|
78
|
+
AURORA: '1313161554',
|
|
79
|
+
HARMONY: '1666600000',
|
|
80
|
+
PALM: '11297108109',
|
|
81
|
+
CURIO: '836542336838601',
|
|
82
|
+
SOLANA_MAINNET: 'sol_mainnet',
|
|
83
|
+
SOLANA_DEVNET: 'sol_devnet',
|
|
84
|
+
SOLANA_TESTNET: 'sol_testnet',
|
|
85
|
+
SOLANA_PYTH: 'sol_pyth',
|
|
86
|
+
SUI_DEVNET: 'sui_devnet',
|
|
87
|
+
APTOS_MAINNET: 'aptos_mainnet',
|
|
88
|
+
APTOS_TESTNET: 'aptos_testnet',
|
|
82
89
|
}
|
|
83
90
|
|
|
84
|
-
export const
|
|
85
|
-
export const SOL_DEVNET_ID = 'sol_devnet'
|
|
86
|
-
export const SOL_TESTNENT_ID = 'sol_testnet'
|
|
87
|
-
CHAIN_MAP[SOL_MAINMET_ID] = 'solana'
|
|
88
|
-
CHAIN_MAP[SOL_DEVNET_ID] = 'solana-dev'
|
|
89
|
-
CHAIN_MAP[SOL_TESTNENT_ID] = 'solana-test'
|
|
91
|
+
export const CHAIN_MAP: Record<string, string> = {}
|
|
90
92
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
for (const [key, value] of Object.entries(CHAIN_IDS)) {
|
|
94
|
+
const parts = key.split('_')
|
|
95
|
+
CHAIN_MAP[value] = parts
|
|
96
|
+
.map((part, index) => {
|
|
97
|
+
return part[0] + part.slice(1).toLowerCase()
|
|
98
|
+
})
|
|
99
|
+
.join(' ')
|
|
100
|
+
}
|
|
98
101
|
|
|
99
102
|
export function getChainName(chainId: string | number | null | undefined): string {
|
|
100
103
|
if (typeof chainId === 'number') {
|