@sentio/sdk 2.14.4 → 2.15.0-rc.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/lib/aptos/api.d.ts +1 -2
- package/lib/aptos/api.js +2 -2
- package/lib/aptos/api.js.map +1 -1
- package/lib/aptos/aptos-chain-adapter.d.ts +1 -1
- package/lib/aptos/aptos-chain-adapter.js +17 -13
- package/lib/aptos/aptos-chain-adapter.js.map +1 -1
- package/lib/aptos/aptos-processor.js +3 -3
- package/lib/aptos/aptos-processor.js.map +1 -1
- package/lib/aptos/context.d.ts +2 -2
- package/lib/aptos/context.js +3 -4
- package/lib/aptos/context.js.map +1 -1
- package/lib/aptos/ext/coin.js +2 -2
- package/lib/aptos/ext/coin.js.map +1 -1
- package/lib/aptos/network.d.ts +7 -7
- package/lib/aptos/network.js +6 -19
- package/lib/aptos/network.js.map +1 -1
- package/lib/core/base-context.d.ts +2 -1
- package/lib/core/base-context.js.map +1 -1
- package/lib/core/chain.d.ts +194 -93
- package/lib/core/chain.js +112 -96
- package/lib/core/chain.js.map +1 -1
- package/lib/core/yaml-contract-config.d.ts +2 -1
- package/lib/core/yaml-contract-config.js.map +1 -1
- package/lib/eth/account-processor.d.ts +3 -2
- package/lib/eth/account-processor.js +3 -3
- package/lib/eth/account-processor.js.map +1 -1
- package/lib/eth/base-processor-template.d.ts +2 -3
- package/lib/eth/base-processor-template.js +1 -2
- package/lib/eth/base-processor-template.js.map +1 -1
- package/lib/eth/base-processor.d.ts +5 -5
- package/lib/eth/base-processor.js +5 -5
- package/lib/eth/base-processor.js.map +1 -1
- package/lib/eth/bind-options.d.ts +3 -3
- package/lib/eth/bind-options.js +3 -4
- package/lib/eth/bind-options.js.map +1 -1
- package/lib/eth/binds.d.ts +3 -3
- package/lib/eth/binds.js +1 -3
- package/lib/eth/binds.js.map +1 -1
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts +2 -4
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js +2 -2
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -1
- package/lib/eth/builtin/internal/eacaggregatorproxy-test-utils.js +5 -4
- package/lib/eth/builtin/internal/eacaggregatorproxy-test-utils.js.map +1 -1
- package/lib/eth/builtin/internal/erc1155-processor.d.ts +2 -4
- package/lib/eth/builtin/internal/erc1155-processor.js +2 -2
- package/lib/eth/builtin/internal/erc1155-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc1155-test-utils.js +5 -4
- package/lib/eth/builtin/internal/erc1155-test-utils.js.map +1 -1
- package/lib/eth/builtin/internal/erc20-processor.d.ts +2 -4
- package/lib/eth/builtin/internal/erc20-processor.js +2 -2
- package/lib/eth/builtin/internal/erc20-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc20-test-utils.js +4 -3
- package/lib/eth/builtin/internal/erc20-test-utils.js.map +1 -1
- package/lib/eth/builtin/internal/erc20bytes-processor.d.ts +2 -4
- package/lib/eth/builtin/internal/erc20bytes-processor.js +2 -2
- package/lib/eth/builtin/internal/erc20bytes-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc20bytes-test-utils.js +3 -2
- package/lib/eth/builtin/internal/erc20bytes-test-utils.js.map +1 -1
- package/lib/eth/builtin/internal/erc721-processor.d.ts +2 -4
- package/lib/eth/builtin/internal/erc721-processor.js +2 -2
- package/lib/eth/builtin/internal/erc721-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc721-test-utils.js +4 -3
- package/lib/eth/builtin/internal/erc721-test-utils.js.map +1 -1
- package/lib/eth/builtin/internal/weth9-processor.d.ts +2 -4
- package/lib/eth/builtin/internal/weth9-processor.js +2 -2
- package/lib/eth/builtin/internal/weth9-processor.js.map +1 -1
- package/lib/eth/builtin/internal/weth9-test-utils.js +5 -4
- package/lib/eth/builtin/internal/weth9-test-utils.js.map +1 -1
- package/lib/eth/codegen/ethers-sentio.js +11 -4
- package/lib/eth/codegen/ethers-sentio.js.map +1 -1
- package/lib/eth/codegen/file.js +9 -6
- package/lib/eth/codegen/file.js.map +1 -1
- package/lib/eth/context.d.ts +6 -5
- package/lib/eth/context.js +2 -2
- package/lib/eth/context.js.map +1 -1
- package/lib/eth/eth-plugin.js +7 -9
- package/lib/eth/eth-plugin.js.map +1 -1
- package/lib/eth/index.d.ts +3 -1
- package/lib/eth/index.js +3 -1
- package/lib/eth/index.js.map +1 -1
- package/lib/eth/provider.d.ts +5 -5
- package/lib/eth/provider.js +12 -14
- package/lib/eth/provider.js.map +1 -1
- package/lib/eth/provider.test.js.map +1 -1
- package/lib/move/abstract-codegen.d.ts +1 -1
- package/lib/move/abstract-codegen.js +10 -3
- package/lib/move/abstract-codegen.js.map +1 -1
- package/lib/move/chain-adapter.d.ts +1 -1
- package/lib/move/chain-adapter.js.map +1 -1
- package/lib/solana/solana-context.d.ts +4 -3
- package/lib/solana/solana-context.js +3 -2
- package/lib/solana/solana-context.js.map +1 -1
- package/lib/solana/solana-options.d.ts +2 -1
- package/lib/solana/solana-options.js.map +1 -1
- package/lib/solana/solana-processor.d.ts +2 -1
- package/lib/solana/solana-processor.js +2 -2
- package/lib/solana/solana-processor.js.map +1 -1
- package/lib/sui/context.d.ts +2 -2
- package/lib/sui/context.js +4 -5
- package/lib/sui/context.js.map +1 -1
- package/lib/sui/network.d.ts +7 -7
- package/lib/sui/network.js +6 -19
- package/lib/sui/network.js.map +1 -1
- package/lib/sui/sui-chain-adapter.d.ts +1 -1
- package/lib/sui/sui-chain-adapter.js +8 -6
- package/lib/sui/sui-chain-adapter.js.map +1 -1
- package/lib/sui/sui-plugin.js +1 -2
- package/lib/sui/sui-plugin.js.map +1 -1
- package/lib/sui/sui-processor.js +3 -3
- package/lib/sui/sui-processor.js.map +1 -1
- package/lib/testing/aptos-facet.js +2 -3
- package/lib/testing/aptos-facet.js.map +1 -1
- package/lib/testing/eth-facet.d.ts +14 -13
- package/lib/testing/eth-facet.js +17 -17
- package/lib/testing/eth-facet.js.map +1 -1
- package/lib/testing/sui-facet.js +2 -3
- package/lib/testing/sui-facet.js.map +1 -1
- package/lib/utils/dex-price.d.ts +3 -2
- package/lib/utils/dex-price.js +3 -2
- package/lib/utils/dex-price.js.map +1 -1
- package/lib/utils/erc20.test.js.map +1 -1
- package/lib/utils/price.d.ts +2 -1
- package/lib/utils/price.js.map +1 -1
- package/lib/utils/token.d.ts +3 -4
- package/lib/utils/token.js +2 -2
- package/lib/utils/token.js.map +1 -1
- package/package.json +3 -3
- package/src/aptos/api.ts +2 -2
- package/src/aptos/aptos-chain-adapter.ts +17 -15
- package/src/aptos/aptos-processor.ts +3 -3
- package/src/aptos/context.ts +6 -6
- package/src/aptos/ext/coin.ts +2 -2
- package/src/aptos/network.ts +6 -19
- package/src/core/base-context.ts +2 -1
- package/src/core/chain.ts +113 -96
- package/src/core/yaml-contract-config.ts +3 -1
- package/src/eth/account-processor.ts +7 -7
- package/src/eth/base-processor-template.ts +3 -5
- package/src/eth/base-processor.ts +9 -10
- package/src/eth/bind-options.ts +4 -6
- package/src/eth/binds.ts +5 -7
- package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +5 -5
- package/src/eth/builtin/internal/eacaggregatorproxy-test-utils.ts +17 -4
- package/src/eth/builtin/internal/erc1155-processor.ts +5 -5
- package/src/eth/builtin/internal/erc1155-test-utils.ts +5 -4
- package/src/eth/builtin/internal/erc20-processor.ts +5 -5
- package/src/eth/builtin/internal/erc20-test-utils.ts +4 -3
- package/src/eth/builtin/internal/erc20bytes-processor.ts +5 -5
- package/src/eth/builtin/internal/erc20bytes-test-utils.ts +3 -2
- package/src/eth/builtin/internal/erc721-processor.ts +5 -5
- package/src/eth/builtin/internal/erc721-test-utils.ts +4 -3
- package/src/eth/builtin/internal/weth9-processor.ts +5 -5
- package/src/eth/builtin/internal/weth9-test-utils.ts +5 -4
- package/src/eth/codegen/ethers-sentio.ts +12 -5
- package/src/eth/codegen/file.ts +9 -6
- package/src/eth/context.ts +8 -7
- package/src/eth/eth-plugin.ts +7 -10
- package/src/eth/index.ts +4 -1
- package/src/eth/provider.ts +13 -15
- package/src/move/abstract-codegen.ts +12 -3
- package/src/move/chain-adapter.ts +4 -2
- package/src/solana/solana-context.ts +12 -5
- package/src/solana/solana-options.ts +2 -1
- package/src/solana/solana-processor.ts +3 -3
- package/src/sui/context.ts +7 -7
- package/src/sui/network.ts +6 -19
- package/src/sui/sui-chain-adapter.ts +9 -6
- package/src/sui/sui-plugin.ts +1 -2
- package/src/sui/sui-processor.ts +3 -3
- package/src/testing/aptos-facet.ts +2 -3
- package/src/testing/eth-facet.ts +33 -18
- package/src/testing/sui-facet.ts +2 -3
- package/src/utils/dex-price.ts +5 -4
- package/src/utils/price.ts +2 -1
- package/src/utils/token.ts +5 -6
package/src/aptos/network.ts
CHANGED
@@ -1,25 +1,12 @@
|
|
1
|
-
import {
|
1
|
+
import { AptosChainId } from '../core/chain.js'
|
2
2
|
import { AptosClient } from 'aptos-sdk'
|
3
3
|
import { Labels } from '../core/index.js'
|
4
4
|
|
5
|
-
export
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
export function getChainId(network: AptosNetwork): string {
|
12
|
-
switch (network) {
|
13
|
-
case AptosNetwork.TEST_NET:
|
14
|
-
return CHAIN_IDS.APTOS_TESTNET
|
15
|
-
case AptosNetwork.DEV_NET:
|
16
|
-
return CHAIN_IDS.APTOS_DEVNET
|
17
|
-
}
|
18
|
-
return CHAIN_IDS.APTOS_MAINNET
|
19
|
-
}
|
20
|
-
|
21
|
-
export function getAptosChainName(network: AptosNetwork): string {
|
22
|
-
return getChainName(getChainId(network))
|
5
|
+
export type AptosNetwork = AptosChainId
|
6
|
+
export const AptosNetwork = <const>{
|
7
|
+
MAIN_NET: AptosChainId.APTOS_MAINNET,
|
8
|
+
TEST_NET: AptosChainId.APTOS_TESTNET,
|
9
|
+
DEV_NET: AptosChainId.APTOS_DEVNET,
|
23
10
|
}
|
24
11
|
|
25
12
|
export class AptosBindOptions {
|
package/src/core/base-context.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { ProcessResult, RecordMetaData, StateResult } from '@sentio/protos'
|
2
2
|
import { EventLogger } from './event-logger.js'
|
3
3
|
import { Meter, Labels } from './meter.js'
|
4
|
+
import { ChainId } from './chain.js'
|
4
5
|
|
5
6
|
export abstract class BaseContext {
|
6
7
|
meter: Meter
|
@@ -36,5 +37,5 @@ export abstract class BaseContext {
|
|
36
37
|
|
37
38
|
protected abstract getMetaDataInternal(name: string, labels: Labels): RecordMetaData
|
38
39
|
|
39
|
-
abstract getChainId():
|
40
|
+
abstract getChainId(): ChainId
|
40
41
|
}
|
package/src/core/chain.ts
CHANGED
@@ -1,107 +1,124 @@
|
|
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
|
5
|
-
KARDIA
|
6
|
-
ETHEREUM
|
7
|
-
EXPANSE
|
8
|
-
ROPSTEN
|
9
|
-
RINKEBY
|
10
|
-
GOERLI
|
11
|
-
KOTTI
|
12
|
-
UBIQ
|
13
|
-
OPTIMISM
|
14
|
-
SONGBIRD
|
15
|
-
ELASTOS
|
16
|
-
CRONOS
|
17
|
-
RSK
|
18
|
-
TELOS
|
19
|
-
XDC
|
20
|
-
CSC
|
21
|
-
ZYX
|
22
|
-
BINANCE
|
23
|
-
SYSCOIN
|
24
|
-
GOCHAIN
|
25
|
-
ETHCLASSIC
|
26
|
-
MORDOR
|
27
|
-
OKEXCHAIN
|
28
|
-
HOO
|
29
|
-
METER
|
30
|
-
TOMOCHAIN
|
31
|
-
BINANCE_TEST
|
32
|
-
XDAI
|
33
|
-
VELAS
|
34
|
-
THUNDERCORE
|
35
|
-
FUSE
|
36
|
-
HECO
|
37
|
-
POLYGON
|
38
|
-
XDAIARB
|
39
|
-
ASTOR
|
40
|
-
ENERGYWEB
|
41
|
-
FANTOM
|
42
|
-
HPB
|
43
|
-
BOBA
|
44
|
-
KUCOIN
|
45
|
-
ZKSYNC_ERA
|
46
|
-
SHIDEN
|
47
|
-
THETA
|
48
|
-
SX
|
49
|
-
CANDLE
|
50
|
-
ASTAR
|
51
|
-
CALLISTO
|
52
|
-
WANCHAIN
|
53
|
-
POLYGON_ZKEVM
|
54
|
-
METIS
|
55
|
-
OMCHAIN
|
56
|
-
MOONBEAM
|
57
|
-
MOONRIVER
|
58
|
-
MOONBASE
|
59
|
-
DEV
|
60
|
-
RONIN
|
61
|
-
KAVA
|
62
|
-
EZCHAIN
|
63
|
-
PHI
|
64
|
-
IOTEX
|
65
|
-
XLC
|
66
|
-
NAHMII
|
67
|
-
NMACTEST
|
68
|
-
KLAYTN
|
69
|
-
EVMOS
|
70
|
-
BASE_GOERLI
|
71
|
-
SMARTBCH
|
72
|
-
CRYSTALEUM
|
73
|
-
FUSION
|
74
|
-
ARBITRUM
|
75
|
-
CELO
|
76
|
-
OASIS
|
77
|
-
AVALANCHE
|
78
|
-
GODWOKEN
|
79
|
-
AKROMA
|
80
|
-
POLIS
|
81
|
-
ARBITRUM_GOERLI
|
82
|
-
SEPOLIA
|
83
|
-
AURORA
|
84
|
-
HARMONY
|
85
|
-
PALM
|
86
|
-
CURIO
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
4
|
+
export enum EthChainId {
|
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
|
+
BINANCE_TEST = '97',
|
32
|
+
XDAI = '100',
|
33
|
+
VELAS = '106',
|
34
|
+
THUNDERCORE = '108',
|
35
|
+
FUSE = '122',
|
36
|
+
HECO = '128',
|
37
|
+
POLYGON = '137',
|
38
|
+
XDAIARB = '200',
|
39
|
+
ASTOR = '212',
|
40
|
+
ENERGYWEB = '246',
|
41
|
+
FANTOM = '250',
|
42
|
+
HPB = '269',
|
43
|
+
BOBA = '288',
|
44
|
+
KUCOIN = '321',
|
45
|
+
ZKSYNC_ERA = '324',
|
46
|
+
SHIDEN = '336',
|
47
|
+
THETA = '361',
|
48
|
+
SX = '416',
|
49
|
+
CANDLE = '534',
|
50
|
+
ASTAR = '592',
|
51
|
+
CALLISTO = '820',
|
52
|
+
WANCHAIN = '888',
|
53
|
+
POLYGON_ZKEVM = '1101',
|
54
|
+
METIS = '1088',
|
55
|
+
OMCHAIN = '1246',
|
56
|
+
MOONBEAM = '1284',
|
57
|
+
MOONRIVER = '1285',
|
58
|
+
MOONBASE = '1287',
|
59
|
+
DEV = '2018',
|
60
|
+
RONIN = '2020',
|
61
|
+
KAVA = '2222',
|
62
|
+
EZCHAIN = '2612',
|
63
|
+
PHI = '4181',
|
64
|
+
IOTEX = '4689',
|
65
|
+
XLC = '5050',
|
66
|
+
NAHMII = '5551',
|
67
|
+
NMACTEST = '7777',
|
68
|
+
KLAYTN = '8217',
|
69
|
+
EVMOS = '9001',
|
70
|
+
BASE_GOERLI = '84531',
|
71
|
+
SMARTBCH = '10000',
|
72
|
+
CRYSTALEUM = '103090',
|
73
|
+
FUSION = '32659',
|
74
|
+
ARBITRUM = '42161',
|
75
|
+
CELO = '42220',
|
76
|
+
OASIS = '42262',
|
77
|
+
AVALANCHE = '43114',
|
78
|
+
GODWOKEN = '71402',
|
79
|
+
AKROMA = '200625',
|
80
|
+
POLIS = '333999',
|
81
|
+
ARBITRUM_GOERLI = '421613',
|
82
|
+
SEPOLIA = '11155111',
|
83
|
+
AURORA = '1313161554',
|
84
|
+
HARMONY = '1666600000',
|
85
|
+
PALM = '11297108109',
|
86
|
+
CURIO = '836542336838601',
|
87
|
+
}
|
88
|
+
|
89
|
+
export enum AptosChainId {
|
90
|
+
APTOS_MAINNET = 'aptos_mainnet',
|
91
|
+
APTOS_TESTNET = 'aptos_testnet',
|
92
|
+
APTOS_DEVNET = 'aptos_devnet',
|
93
|
+
}
|
94
|
+
|
95
|
+
export enum SuiChainId {
|
96
|
+
SUI_MAINNET = 'sui_mainnet',
|
97
|
+
SUI_TESTNET = 'sui_testnet',
|
98
|
+
SUI_DEVNET = 'sui_devnet',
|
99
|
+
}
|
100
|
+
|
101
|
+
export enum SolanaChainId {
|
102
|
+
SOLANA_MAINNET = 'sol_mainnet',
|
103
|
+
SOLANA_DEVNET = 'sol_devnet',
|
104
|
+
SOLANA_TESTNET = 'sol_testnet',
|
105
|
+
SOLANA_PYTH = 'sol_pyth',
|
106
|
+
}
|
107
|
+
|
108
|
+
export type ChainId = EthChainId | AptosChainId | SuiChainId | SolanaChainId
|
109
|
+
export const ChainId = {
|
110
|
+
...EthChainId,
|
111
|
+
...AptosChainId,
|
112
|
+
...SuiChainId,
|
113
|
+
...SolanaChainId,
|
97
114
|
}
|
98
115
|
|
99
116
|
export const CHAIN_MAP: Record<string, string> = {}
|
100
117
|
|
101
|
-
for (const [key, value] of Object.entries(
|
102
|
-
if (value ===
|
118
|
+
for (const [key, value] of Object.entries(ChainId)) {
|
119
|
+
if (value === ChainId.POLYGON_ZKEVM) {
|
103
120
|
CHAIN_MAP[value] = 'Polygon zkEVM'
|
104
|
-
} else if (value ===
|
121
|
+
} else if (value === ChainId.ZKSYNC_ERA) {
|
105
122
|
CHAIN_MAP[value] = 'zkSync Era'
|
106
123
|
} else {
|
107
124
|
const parts = key.split('_')
|
@@ -1,17 +1,17 @@
|
|
1
1
|
import { ERC20__factory, ERC721__factory } from './builtin/internal/index.js'
|
2
2
|
import { AddressType, EthFetchConfig, ProcessResult } from '@sentio/protos'
|
3
3
|
|
4
|
-
import {
|
4
|
+
import { PartiallyOptional, PromiseOrVoid } from '../core/index.js'
|
5
5
|
|
6
6
|
import { AccountBindOptions } from './bind-options.js'
|
7
|
-
import { TransferEvent as ERC20TransferEvent
|
8
|
-
import { TransferEvent as ERC721TransferEvent
|
7
|
+
import { ERC20Processor, TransferEvent as ERC20TransferEvent } from './builtin/erc20.js'
|
8
|
+
import { ERC721Processor, TransferEvent as ERC721TransferEvent } from './builtin/erc721.js'
|
9
9
|
import { AccountContext } from './context.js'
|
10
10
|
import { AddressOrTypeEventFilter, EventsHandler } from './base-processor.js'
|
11
11
|
import { Block, LogDescription } from 'ethers'
|
12
12
|
import { AccountProcessorState } from './account-processor-state.js'
|
13
13
|
import { formatEthData } from './eth.js'
|
14
|
-
import {
|
14
|
+
import { EthChainId } from '../core/chain.js'
|
15
15
|
|
16
16
|
const ERC20_INTERFACE = ERC20__factory.createInterface()
|
17
17
|
const ERC721_INTERFACE = ERC721__factory.createInterface()
|
@@ -29,12 +29,12 @@ export class AccountProcessor {
|
|
29
29
|
protected constructor(config: PartiallyOptional<AccountBindOptions, 'network'>) {
|
30
30
|
this.config = {
|
31
31
|
...config,
|
32
|
-
network:
|
32
|
+
network: config.network || EthChainId.ETHEREUM,
|
33
33
|
}
|
34
34
|
}
|
35
35
|
|
36
|
-
public getChainId():
|
37
|
-
return
|
36
|
+
public getChainId(): EthChainId {
|
37
|
+
return this.config.network
|
38
38
|
}
|
39
39
|
|
40
40
|
/**
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { BoundContractView, ContractContext, ContractView } from './context.js'
|
1
|
+
import { BoundContractView, ContractContext, ContractView, EthContext } from './context.js'
|
2
2
|
import { BaseContract } from 'ethers'
|
3
3
|
import { BaseProcessor } from './base-processor.js'
|
4
4
|
import { BindOptions, getOptionsSignature } from './bind-options.js'
|
@@ -8,8 +8,6 @@ import { ListStateStorage } from '@sentio/runtime'
|
|
8
8
|
import { BlockParams } from 'ethers/providers'
|
9
9
|
import { DeferredTopicFilter } from 'ethers/contract'
|
10
10
|
import { TypedEvent, TypedCallTrace } from './eth.js'
|
11
|
-
import { getNetworkFromCtxOrNetworkish } from './provider.js'
|
12
|
-
import { BaseContext } from '../core/index.js'
|
13
11
|
|
14
12
|
export class ProcessorTemplateProcessorState extends ListStateStorage<
|
15
13
|
BaseProcessorTemplate<BaseContract, BoundContractView<BaseContract, any>>
|
@@ -54,7 +52,7 @@ export abstract class BaseProcessorTemplate<
|
|
54
52
|
* @param options
|
55
53
|
* @param ctx
|
56
54
|
*/
|
57
|
-
public bind(options: BindOptions, ctx:
|
55
|
+
public bind(options: BindOptions, ctx: EthContext): void {
|
58
56
|
if (!options.network) {
|
59
57
|
options.network = ctx.getChainId()
|
60
58
|
}
|
@@ -85,7 +83,7 @@ export abstract class BaseProcessorTemplate<
|
|
85
83
|
contract: {
|
86
84
|
address: options.address,
|
87
85
|
name: options.name || '',
|
88
|
-
chainId:
|
86
|
+
chainId: options.network,
|
89
87
|
abi: '',
|
90
88
|
},
|
91
89
|
startBlock: 0n,
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import { BaseContract, DeferredTopicFilter, TransactionResponseParams } from 'ethers'
|
2
|
-
import { Network } from 'ethers/providers'
|
3
2
|
|
4
3
|
import { BoundContractView, ContractContext, ContractView, GlobalContext } from './context.js'
|
5
4
|
import {
|
@@ -15,10 +14,10 @@ import {
|
|
15
14
|
import { BindOptions } from './bind-options.js'
|
16
15
|
import { PromiseOrVoid } from '../core/promises.js'
|
17
16
|
import { ServerError, Status } from 'nice-grpc'
|
18
|
-
import { fixEmptyKey,
|
19
|
-
import { getNetworkFromCtxOrNetworkish } from './provider.js'
|
17
|
+
import { fixEmptyKey, formatEthData, RichBlock, TypedCallTrace, TypedEvent } from './eth.js'
|
20
18
|
import sha3 from 'js-sha3'
|
21
19
|
import { ListStateStorage } from '@sentio/runtime'
|
20
|
+
import { EthChainId } from '../core/chain.js'
|
22
21
|
|
23
22
|
export interface AddressOrTypeEventFilter extends DeferredTopicFilter {
|
24
23
|
addressType?: AddressType
|
@@ -51,7 +50,7 @@ export class TransactionHandler {
|
|
51
50
|
|
52
51
|
class BindInternalOptions {
|
53
52
|
address: string
|
54
|
-
network:
|
53
|
+
network: EthChainId
|
55
54
|
name: string
|
56
55
|
startBlock: bigint
|
57
56
|
endBlock?: bigint
|
@@ -77,7 +76,7 @@ export class GlobalProcessor {
|
|
77
76
|
this.config = {
|
78
77
|
address: '*',
|
79
78
|
name: config.name || 'Global',
|
80
|
-
network:
|
79
|
+
network: config.network || EthChainId.ETHEREUM,
|
81
80
|
startBlock: 0n,
|
82
81
|
}
|
83
82
|
if (config.startBlock) {
|
@@ -119,8 +118,8 @@ export class GlobalProcessor {
|
|
119
118
|
)
|
120
119
|
}
|
121
120
|
|
122
|
-
public getChainId():
|
123
|
-
return
|
121
|
+
public getChainId(): EthChainId {
|
122
|
+
return this.config.network
|
124
123
|
}
|
125
124
|
|
126
125
|
public onInterval(
|
@@ -186,7 +185,7 @@ export abstract class BaseProcessor<
|
|
186
185
|
this.config = {
|
187
186
|
address: config.address,
|
188
187
|
name: config.name || '',
|
189
|
-
network:
|
188
|
+
network: config.network || EthChainId.ETHEREUM,
|
190
189
|
startBlock: 0n,
|
191
190
|
baseLabels: config.baseLabels,
|
192
191
|
}
|
@@ -200,8 +199,8 @@ export abstract class BaseProcessor<
|
|
200
199
|
|
201
200
|
protected abstract CreateBoundContractView(): TBoundContractView
|
202
201
|
|
203
|
-
public getChainId():
|
204
|
-
return
|
202
|
+
public getChainId(): EthChainId {
|
203
|
+
return this.config.network
|
205
204
|
}
|
206
205
|
|
207
206
|
public onEvent(
|
package/src/eth/bind-options.ts
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
import {
|
2
|
-
import { getNetworkFromCtxOrNetworkish } from './provider.js'
|
1
|
+
import { EthChainId } from '../core/chain.js'
|
3
2
|
|
4
3
|
export class BindOptions {
|
5
4
|
// Contract address
|
6
5
|
address: string
|
7
6
|
// Optional, if not set, then use eth mainnet
|
8
|
-
network?:
|
7
|
+
network?: EthChainId = EthChainId.ETHEREUM
|
9
8
|
// Optional, override default contract name
|
10
9
|
name?: string
|
11
10
|
startBlock?: bigint | number
|
@@ -16,8 +15,7 @@ export class BindOptions {
|
|
16
15
|
export function getOptionsSignature(opts: BindOptions): string {
|
17
16
|
const sig = [opts.address]
|
18
17
|
if (opts.network) {
|
19
|
-
|
20
|
-
sig.push(n.chainId.toString())
|
18
|
+
sig.push(opts.network)
|
21
19
|
}
|
22
20
|
if (opts.name) {
|
23
21
|
sig.push(opts.name)
|
@@ -33,7 +31,7 @@ export function getOptionsSignature(opts: BindOptions): string {
|
|
33
31
|
|
34
32
|
export class AccountBindOptions {
|
35
33
|
address: string
|
36
|
-
network:
|
34
|
+
network: EthChainId
|
37
35
|
startBlock?: bigint | number
|
38
36
|
baseLabels?: { [key: string]: string }
|
39
37
|
}
|
package/src/eth/binds.ts
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
import { BindOptions, getOptionsSignature } from './bind-options.js'
|
2
2
|
import { ContractView } from './context.js'
|
3
3
|
import { BaseProcessor } from './base-processor.js'
|
4
|
-
import { Networkish } from 'ethers/providers'
|
5
4
|
|
6
5
|
import { BaseContract } from 'ethers'
|
7
6
|
import { MapStateStorage } from '@sentio/runtime'
|
8
|
-
import {
|
7
|
+
import { EthChainId } from '../core/chain.js'
|
9
8
|
|
10
9
|
export class ProcessorState extends MapStateStorage<BaseProcessor<any, any>> {
|
11
10
|
static INSTANCE = new ProcessorState()
|
@@ -14,9 +13,8 @@ export class ProcessorState extends MapStateStorage<BaseProcessor<any, any>> {
|
|
14
13
|
// from abiName_address_chainId => contract wrapper
|
15
14
|
const contracts = new Map<string, ContractView<BaseContract>>()
|
16
15
|
|
17
|
-
function getKey(abiName: string, address: string, network:
|
18
|
-
|
19
|
-
return [abiName, address.toLowerCase(), chainId].join('_')
|
16
|
+
function getKey(abiName: string, address: string, network: EthChainId) {
|
17
|
+
return [abiName, address.toLowerCase(), network].join('_')
|
20
18
|
}
|
21
19
|
|
22
20
|
// Dedup processor that bind multiple times
|
@@ -31,7 +29,7 @@ export function addProcessor(opts: BindOptions, processor: BaseProcessor<any, an
|
|
31
29
|
ProcessorState.INSTANCE.getOrSetValue(sig, processor)
|
32
30
|
}
|
33
31
|
|
34
|
-
export function getContractByABI(abiName: string, address: string, network:
|
32
|
+
export function getContractByABI(abiName: string, address: string, network: EthChainId) {
|
35
33
|
const key = getKey(abiName, address, network)
|
36
34
|
return contracts.get(key)
|
37
35
|
}
|
@@ -39,7 +37,7 @@ export function getContractByABI(abiName: string, address: string, network: Netw
|
|
39
37
|
export function addContractByABI(
|
40
38
|
abiName: string,
|
41
39
|
address: string,
|
42
|
-
network:
|
40
|
+
network: EthChainId,
|
43
41
|
contract: ContractView<BaseContract>
|
44
42
|
) {
|
45
43
|
const key = getKey(abiName, address, network)
|
@@ -2,7 +2,6 @@
|
|
2
2
|
/* tslint:disable */
|
3
3
|
/* eslint-disable */
|
4
4
|
import { BigNumberish, Overrides } from "ethers";
|
5
|
-
import { Networkish } from "ethers/providers";
|
6
5
|
import {
|
7
6
|
addContractByABI,
|
8
7
|
getContractByABI,
|
@@ -17,11 +16,12 @@ import {
|
|
17
16
|
ContractContext,
|
18
17
|
ContractView,
|
19
18
|
DummyProvider,
|
19
|
+
EthChainId,
|
20
20
|
TypedCallTrace,
|
21
|
-
|
21
|
+
getEthChainId,
|
22
|
+
EthContext,
|
22
23
|
EthFetchConfig,
|
23
24
|
} from "@sentio/sdk/eth";
|
24
|
-
import { BaseContext } from "@sentio/sdk";
|
25
25
|
|
26
26
|
import { EACAggregatorProxy, EACAggregatorProxy__factory } from "./index.js";
|
27
27
|
import {
|
@@ -1067,10 +1067,10 @@ export class EACAggregatorProxyProcessorTemplate extends BaseProcessorTemplate<
|
|
1067
1067
|
}
|
1068
1068
|
|
1069
1069
|
export function getEACAggregatorProxyContract(
|
1070
|
-
contextOrNetwork:
|
1070
|
+
contextOrNetwork: EthContext | EthChainId,
|
1071
1071
|
address: string
|
1072
1072
|
): EACAggregatorProxyContractView {
|
1073
|
-
const network =
|
1073
|
+
const network = getEthChainId(contextOrNetwork);
|
1074
1074
|
let contract = getContractByABI(
|
1075
1075
|
"EACAggregatorProxy",
|
1076
1076
|
address,
|
@@ -2,6 +2,7 @@
|
|
2
2
|
/* tslint:disable */
|
3
3
|
/* eslint-disable */
|
4
4
|
import { LogParams } from "ethers/providers";
|
5
|
+
import { EthChainId } from "@sentio/sdk/eth";
|
5
6
|
import {
|
6
7
|
AnswerUpdatedEventObject,
|
7
8
|
NewRoundEventObject,
|
@@ -24,7 +25,10 @@ export function mockAnswerUpdatedLog(
|
|
24
25
|
contractAddress: string,
|
25
26
|
event: AnswerUpdatedEventObject
|
26
27
|
): LogParams {
|
27
|
-
const contract = getEACAggregatorProxyContract(
|
28
|
+
const contract = getEACAggregatorProxyContract(
|
29
|
+
EthChainId.ETHEREUM,
|
30
|
+
contractAddress
|
31
|
+
);
|
28
32
|
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
29
33
|
"AnswerUpdated(int256,uint256,uint256)",
|
30
34
|
[event.current, event.roundId, event.updatedAt]
|
@@ -42,7 +46,10 @@ export function mockNewRoundLog(
|
|
42
46
|
contractAddress: string,
|
43
47
|
event: NewRoundEventObject
|
44
48
|
): LogParams {
|
45
|
-
const contract = getEACAggregatorProxyContract(
|
49
|
+
const contract = getEACAggregatorProxyContract(
|
50
|
+
EthChainId.ETHEREUM,
|
51
|
+
contractAddress
|
52
|
+
);
|
46
53
|
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
47
54
|
"NewRound(uint256,address,uint256)",
|
48
55
|
[event.roundId, event.startedBy, event.startedAt]
|
@@ -60,7 +67,10 @@ export function mockOwnershipTransferRequestedLog(
|
|
60
67
|
contractAddress: string,
|
61
68
|
event: OwnershipTransferRequestedEventObject
|
62
69
|
): LogParams {
|
63
|
-
const contract = getEACAggregatorProxyContract(
|
70
|
+
const contract = getEACAggregatorProxyContract(
|
71
|
+
EthChainId.ETHEREUM,
|
72
|
+
contractAddress
|
73
|
+
);
|
64
74
|
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
65
75
|
"OwnershipTransferRequested(address,address)",
|
66
76
|
[event.from, event.to]
|
@@ -78,7 +88,10 @@ export function mockOwnershipTransferredLog(
|
|
78
88
|
contractAddress: string,
|
79
89
|
event: OwnershipTransferredEventObject
|
80
90
|
): LogParams {
|
81
|
-
const contract = getEACAggregatorProxyContract(
|
91
|
+
const contract = getEACAggregatorProxyContract(
|
92
|
+
EthChainId.ETHEREUM,
|
93
|
+
contractAddress
|
94
|
+
);
|
82
95
|
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
83
96
|
"OwnershipTransferred(address,address)",
|
84
97
|
[event.from, event.to]
|
@@ -2,7 +2,6 @@
|
|
2
2
|
/* tslint:disable */
|
3
3
|
/* eslint-disable */
|
4
4
|
import { BigNumberish, Overrides, BytesLike } from "ethers";
|
5
|
-
import { Networkish } from "ethers/providers";
|
6
5
|
import {
|
7
6
|
addContractByABI,
|
8
7
|
getContractByABI,
|
@@ -17,11 +16,12 @@ import {
|
|
17
16
|
ContractContext,
|
18
17
|
ContractView,
|
19
18
|
DummyProvider,
|
19
|
+
EthChainId,
|
20
20
|
TypedCallTrace,
|
21
|
-
|
21
|
+
getEthChainId,
|
22
|
+
EthContext,
|
22
23
|
EthFetchConfig,
|
23
24
|
} from "@sentio/sdk/eth";
|
24
|
-
import { BaseContext } from "@sentio/sdk";
|
25
25
|
|
26
26
|
import { ERC1155, ERC1155__factory } from "./index.js";
|
27
27
|
import {
|
@@ -502,10 +502,10 @@ export class ERC1155ProcessorTemplate extends BaseProcessorTemplate<
|
|
502
502
|
}
|
503
503
|
|
504
504
|
export function getERC1155Contract(
|
505
|
-
contextOrNetwork:
|
505
|
+
contextOrNetwork: EthContext | EthChainId,
|
506
506
|
address: string
|
507
507
|
): ERC1155ContractView {
|
508
|
-
const network =
|
508
|
+
const network = getEthChainId(contextOrNetwork);
|
509
509
|
let contract = getContractByABI(
|
510
510
|
"ERC1155",
|
511
511
|
address,
|
@@ -2,6 +2,7 @@
|
|
2
2
|
/* tslint:disable */
|
3
3
|
/* eslint-disable */
|
4
4
|
import { LogParams } from "ethers/providers";
|
5
|
+
import { EthChainId } from "@sentio/sdk/eth";
|
5
6
|
import {
|
6
7
|
ApprovalForAllEventObject,
|
7
8
|
TransferBatchEventObject,
|
@@ -24,7 +25,7 @@ export function mockApprovalForAllLog(
|
|
24
25
|
contractAddress: string,
|
25
26
|
event: ApprovalForAllEventObject
|
26
27
|
): LogParams {
|
27
|
-
const contract = getERC1155Contract(
|
28
|
+
const contract = getERC1155Contract(EthChainId.ETHEREUM, contractAddress);
|
28
29
|
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
29
30
|
"ApprovalForAll(address,address,bool)",
|
30
31
|
[event.account, event.operator, event.approved]
|
@@ -42,7 +43,7 @@ export function mockTransferBatchLog(
|
|
42
43
|
contractAddress: string,
|
43
44
|
event: TransferBatchEventObject
|
44
45
|
): LogParams {
|
45
|
-
const contract = getERC1155Contract(
|
46
|
+
const contract = getERC1155Contract(EthChainId.ETHEREUM, contractAddress);
|
46
47
|
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
47
48
|
"TransferBatch(address,address,address,uint256[],uint256[])",
|
48
49
|
[event.operator, event.from, event.to, event.ids, event.values]
|
@@ -60,7 +61,7 @@ export function mockTransferSingleLog(
|
|
60
61
|
contractAddress: string,
|
61
62
|
event: TransferSingleEventObject
|
62
63
|
): LogParams {
|
63
|
-
const contract = getERC1155Contract(
|
64
|
+
const contract = getERC1155Contract(EthChainId.ETHEREUM, contractAddress);
|
64
65
|
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
65
66
|
"TransferSingle(address,address,address,uint256,uint256)",
|
66
67
|
[event.operator, event.from, event.to, event.id, event.value]
|
@@ -78,7 +79,7 @@ export function mockURILog(
|
|
78
79
|
contractAddress: string,
|
79
80
|
event: URIEventObject
|
80
81
|
): LogParams {
|
81
|
-
const contract = getERC1155Contract(
|
82
|
+
const contract = getERC1155Contract(EthChainId.ETHEREUM, contractAddress);
|
82
83
|
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
83
84
|
"URI(string,uint256)",
|
84
85
|
[event.value, event.id]
|