@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
@@ -3,8 +3,8 @@ import { SolanaContext } from './solana-context.js'
|
|
3
3
|
import { Instruction } from '@project-serum/anchor'
|
4
4
|
import { SolanaBindOptions } from './solana-options.js'
|
5
5
|
import { ListStateStorage } from '@sentio/runtime'
|
6
|
-
import { CHAIN_IDS } from '@sentio/sdk'
|
7
6
|
import { Labels } from '../core/index.js'
|
7
|
+
import { SolanaChainId } from '../core/chain.js'
|
8
8
|
|
9
9
|
type IndexConfigure = {
|
10
10
|
startSlot: bigint
|
@@ -27,7 +27,7 @@ export class SolanaBaseProcessor {
|
|
27
27
|
endpoint: string
|
28
28
|
contractName: string
|
29
29
|
baseLabels?: Labels
|
30
|
-
network:
|
30
|
+
network: SolanaChainId
|
31
31
|
processInnerInstruction: boolean
|
32
32
|
config: IndexConfigure = { startSlot: 0n }
|
33
33
|
instructionCoder: InstructionCoder
|
@@ -45,7 +45,7 @@ export class SolanaBaseProcessor {
|
|
45
45
|
this.address = options.address
|
46
46
|
this.contractName = options.name || ''
|
47
47
|
this.processInnerInstruction = options.processInnerInstruction || false
|
48
|
-
this.network = options.network ||
|
48
|
+
this.network = options.network || SolanaChainId.SOLANA_MAINNET
|
49
49
|
if (options.instructionCoder) {
|
50
50
|
this.instructionCoder = options.instructionCoder
|
51
51
|
}
|
package/src/sui/context.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { RecordMetaData } from '@sentio/protos'
|
2
2
|
import { type Labels, BaseContext, normalizeLabels } from '../index.js'
|
3
|
-
import { SuiNetwork
|
3
|
+
import { SuiNetwork } from './network.js'
|
4
4
|
import { SuiTransactionBlockResponse, JsonRpcProvider, Connection } from '@mysten/sui.js'
|
5
5
|
import { MoveCoder, defaultMoveCoder } from './move-coder.js'
|
6
6
|
import { Endpoints } from '@sentio/runtime'
|
@@ -39,8 +39,8 @@ export class SuiContext extends BaseContext {
|
|
39
39
|
}
|
40
40
|
}
|
41
41
|
|
42
|
-
getChainId()
|
43
|
-
return
|
42
|
+
getChainId() {
|
43
|
+
return this.network as any
|
44
44
|
}
|
45
45
|
|
46
46
|
getMetaDataInternal(name: string, labels: Labels): RecordMetaData {
|
@@ -58,7 +58,7 @@ export class SuiContext extends BaseContext {
|
|
58
58
|
}
|
59
59
|
|
60
60
|
get client(): JsonRpcProvider {
|
61
|
-
const chainServer = Endpoints.INSTANCE.chainServer.get(
|
61
|
+
const chainServer = Endpoints.INSTANCE.chainServer.get(this.network)
|
62
62
|
if (!chainServer) {
|
63
63
|
throw new ServerError(Status.INTERNAL, 'RPC endpoint not provided')
|
64
64
|
}
|
@@ -82,8 +82,8 @@ export class SuiObjectsContext extends BaseContext {
|
|
82
82
|
this.coder = defaultMoveCoder(network)
|
83
83
|
}
|
84
84
|
|
85
|
-
getChainId()
|
86
|
-
return
|
85
|
+
getChainId() {
|
86
|
+
return this.network as any
|
87
87
|
}
|
88
88
|
|
89
89
|
getMetaDataInternal(name: string, labels: Labels): RecordMetaData {
|
@@ -101,7 +101,7 @@ export class SuiObjectsContext extends BaseContext {
|
|
101
101
|
}
|
102
102
|
|
103
103
|
get client(): JsonRpcProvider {
|
104
|
-
const chainServer = Endpoints.INSTANCE.chainServer.get(
|
104
|
+
const chainServer = Endpoints.INSTANCE.chainServer.get(this.network)
|
105
105
|
if (!chainServer) {
|
106
106
|
throw new ServerError(Status.INTERNAL, 'RPC endpoint not provided')
|
107
107
|
}
|
package/src/sui/network.ts
CHANGED
@@ -1,23 +1,10 @@
|
|
1
|
-
import {
|
1
|
+
import { SuiChainId } from '../core/chain.js'
|
2
2
|
|
3
|
-
export
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
export function getChainId(network: SuiNetwork): string {
|
10
|
-
switch (network) {
|
11
|
-
case SuiNetwork.TEST_NET:
|
12
|
-
return CHAIN_IDS.SUI_TESTNET
|
13
|
-
case SuiNetwork.DEV_NET:
|
14
|
-
return CHAIN_IDS.SUI_DEVNET
|
15
|
-
}
|
16
|
-
return CHAIN_IDS.SUI_MAINNET
|
17
|
-
}
|
18
|
-
|
19
|
-
export function getSuiChainName(network: SuiNetwork): string {
|
20
|
-
return getChainName(getChainId(network))
|
3
|
+
export type SuiNetwork = SuiChainId
|
4
|
+
export const SuiNetwork = <const>{
|
5
|
+
MAIN_NET: SuiChainId.SUI_MAINNET,
|
6
|
+
TEST_NET: SuiChainId.SUI_TESTNET,
|
7
|
+
DEV_NET: SuiChainId.SUI_DEVNET,
|
21
8
|
}
|
22
9
|
|
23
10
|
export class SuiBindOptions {
|
@@ -38,14 +38,17 @@ export class SuiChainAdapter extends ChainAdapter<SuiNetwork, SuiMoveNormalizedM
|
|
38
38
|
return Object.values(modules).map(toInternalModule)
|
39
39
|
}
|
40
40
|
|
41
|
-
|
42
|
-
const qname = moduleQname(module)
|
41
|
+
getAllEventStructs(modules: InternalMoveModule[]): Map<string, InternalMoveStruct> {
|
43
42
|
const eventMap = new Map<string, InternalMoveStruct>()
|
44
43
|
|
45
|
-
for (const
|
46
|
-
const
|
47
|
-
|
48
|
-
|
44
|
+
for (const module of modules) {
|
45
|
+
const qname = moduleQname(module)
|
46
|
+
|
47
|
+
for (const struct of module.structs) {
|
48
|
+
const abilities = new Set(struct.abilities)
|
49
|
+
if (abilities.has('Drop') && abilities.has('Copy')) {
|
50
|
+
eventMap.set(qname + SPLITTER + struct.name, struct)
|
51
|
+
}
|
49
52
|
}
|
50
53
|
}
|
51
54
|
return eventMap
|
package/src/sui/sui-plugin.ts
CHANGED
@@ -16,7 +16,6 @@ import {
|
|
16
16
|
import { ServerError, Status } from 'nice-grpc'
|
17
17
|
|
18
18
|
import { SuiAccountProcessorState, SuiProcessorState } from './sui-processor.js'
|
19
|
-
import { getChainId } from './network.js'
|
20
19
|
import { validateAndNormalizeAddress } from './utils.js'
|
21
20
|
|
22
21
|
interface Handlers {
|
@@ -45,7 +44,7 @@ export class SuiPlugin extends Plugin {
|
|
45
44
|
processorType: USER_PROCESSOR,
|
46
45
|
contract: {
|
47
46
|
name: suiProcessor.moduleName,
|
48
|
-
chainId:
|
47
|
+
chainId: suiProcessor.config.network,
|
49
48
|
address: validateAndNormalizeAddress(suiProcessor.config.address),
|
50
49
|
abi: '',
|
51
50
|
},
|
package/src/sui/sui-processor.ts
CHANGED
@@ -8,7 +8,7 @@ import {
|
|
8
8
|
ProcessResult,
|
9
9
|
} from '@sentio/protos'
|
10
10
|
import { ListStateStorage, mergeProcessResults } from '@sentio/runtime'
|
11
|
-
import {
|
11
|
+
import { SuiNetwork } from './network.js'
|
12
12
|
import { ServerError, Status } from 'nice-grpc'
|
13
13
|
import { SuiContext, SuiObjectsContext } from './context.js'
|
14
14
|
import {
|
@@ -71,7 +71,7 @@ export class SuiBaseProcessor {
|
|
71
71
|
}
|
72
72
|
|
73
73
|
getChainId(): string {
|
74
|
-
return
|
74
|
+
return this.config.network
|
75
75
|
}
|
76
76
|
|
77
77
|
public onMoveEvent(
|
@@ -236,7 +236,7 @@ abstract class SuiBaseObjectsProcessor<HandlerType> {
|
|
236
236
|
}
|
237
237
|
|
238
238
|
getChainId(): string {
|
239
|
-
return
|
239
|
+
return this.config.network
|
240
240
|
}
|
241
241
|
|
242
242
|
// protected abstract transformObjects(objects: SuiMoveObject[]): SuiMoveObject[]
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import { Transaction_UserTransaction, TransactionPayload_EntryFunctionPayload } from '../aptos/index.js'
|
2
2
|
import { DataBinding, HandlerType } from '@sentio/protos'
|
3
|
-
import { getChainId } from '../aptos/network.js'
|
4
3
|
import { TestProcessorServer } from './test-processor-server.js'
|
5
4
|
import { AptosNetwork } from '@sentio/sdk/aptos'
|
6
5
|
import { parseMoveType } from '../move/types.js'
|
@@ -35,7 +34,7 @@ export class AptosFacet {
|
|
35
34
|
): DataBinding | undefined {
|
36
35
|
const payload = transaction.payload as TransactionPayload_EntryFunctionPayload
|
37
36
|
for (const config of this.server.contractConfigs) {
|
38
|
-
if (config.contract?.chainId !==
|
37
|
+
if (config.contract?.chainId !== network) {
|
39
38
|
continue
|
40
39
|
}
|
41
40
|
for (const callConfig of config.moveCallConfigs) {
|
@@ -71,7 +70,7 @@ export class AptosFacet {
|
|
71
70
|
): DataBinding | undefined {
|
72
71
|
// const allEvents = new Set(transaction.events.map(e => e.type))
|
73
72
|
for (const config of this.server.contractConfigs) {
|
74
|
-
if (config.contract?.chainId !==
|
73
|
+
if (config.contract?.chainId !== network) {
|
75
74
|
continue
|
76
75
|
}
|
77
76
|
for (const eventConfig of config.moveEventConfigs) {
|
package/src/testing/eth-facet.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
import { TestProcessorServer } from './test-processor-server.js'
|
2
2
|
import { DataBinding, HandlerType, ProcessBindingResponse } from '@sentio/protos'
|
3
3
|
import { Trace } from '../eth/eth.js'
|
4
|
-
import { BlockParams, LogParams
|
4
|
+
import { BlockParams, LogParams } from 'ethers/providers'
|
5
5
|
import { Block } from 'ethers'
|
6
|
-
import {
|
6
|
+
import { ChainId, EthChainId } from '../core/chain.js'
|
7
7
|
|
8
8
|
export class EthFacet {
|
9
9
|
server: TestProcessorServer
|
@@ -12,11 +12,11 @@ export class EthFacet {
|
|
12
12
|
this.server = server
|
13
13
|
}
|
14
14
|
|
15
|
-
testTrace(trace: Trace, network:
|
15
|
+
testTrace(trace: Trace, network: EthChainId = EthChainId.ETHEREUM): Promise<ProcessBindingResponse> {
|
16
16
|
return this.testTraces([trace], network)
|
17
17
|
}
|
18
18
|
|
19
|
-
testTraces(traces: Trace[], network:
|
19
|
+
testTraces(traces: Trace[], network: EthChainId = EthChainId.ETHEREUM): Promise<ProcessBindingResponse> {
|
20
20
|
const bindings = []
|
21
21
|
for (const trace of traces) {
|
22
22
|
const binding = this.buildTraceBinding(trace, network)
|
@@ -30,14 +30,14 @@ export class EthFacet {
|
|
30
30
|
})
|
31
31
|
}
|
32
32
|
|
33
|
-
buildTraceBinding(trace: Trace, network:
|
33
|
+
buildTraceBinding(trace: Trace, network: ChainId = EthChainId.ETHEREUM): DataBinding | undefined {
|
34
34
|
if (trace.type !== 'call' || !trace.action.input) {
|
35
35
|
throw Error('Invalid test trace: ' + JSON.stringify(trace))
|
36
36
|
}
|
37
37
|
const signature = trace.action.input.slice(0, 10)
|
38
38
|
|
39
39
|
for (const contract of this.server.contractConfigs) {
|
40
|
-
if (contract.contract?.chainId !==
|
40
|
+
if (contract.contract?.chainId !== network) {
|
41
41
|
continue
|
42
42
|
}
|
43
43
|
if (trace.action.to?.toLowerCase() !== contract.contract?.address.toLowerCase()) {
|
@@ -61,11 +61,11 @@ export class EthFacet {
|
|
61
61
|
return undefined
|
62
62
|
}
|
63
63
|
|
64
|
-
testLog(log: LogParams, network:
|
64
|
+
testLog(log: LogParams, network: EthChainId = EthChainId.ETHEREUM): Promise<ProcessBindingResponse> {
|
65
65
|
return this.testLogs([log], network)
|
66
66
|
}
|
67
67
|
|
68
|
-
testLogs(logs: LogParams[], network:
|
68
|
+
testLogs(logs: LogParams[], network: EthChainId = EthChainId.ETHEREUM): Promise<ProcessBindingResponse> {
|
69
69
|
const bindings = []
|
70
70
|
for (const log of logs) {
|
71
71
|
const binding = this.buildLogBinding(log, network)
|
@@ -79,9 +79,9 @@ export class EthFacet {
|
|
79
79
|
})
|
80
80
|
}
|
81
81
|
|
82
|
-
buildLogBinding(log: LogParams, network:
|
82
|
+
buildLogBinding(log: LogParams, network: EthChainId = EthChainId.ETHEREUM): DataBinding | undefined {
|
83
83
|
for (const contract of this.server.contractConfigs) {
|
84
|
-
if (contract.contract?.chainId !==
|
84
|
+
if (contract.contract?.chainId !== network) {
|
85
85
|
continue
|
86
86
|
}
|
87
87
|
if (log.address.toLowerCase() !== contract.contract?.address.toLowerCase()) {
|
@@ -122,11 +122,19 @@ export class EthFacet {
|
|
122
122
|
}
|
123
123
|
return undefined
|
124
124
|
}
|
125
|
-
testAccountLog(
|
125
|
+
testAccountLog(
|
126
|
+
address: string,
|
127
|
+
log: LogParams,
|
128
|
+
network: EthChainId = EthChainId.ETHEREUM
|
129
|
+
): Promise<ProcessBindingResponse> {
|
126
130
|
return this.testAccountLogs(address, [log], network)
|
127
131
|
}
|
128
132
|
|
129
|
-
testAccountLogs(
|
133
|
+
testAccountLogs(
|
134
|
+
address: string,
|
135
|
+
logs: LogParams[],
|
136
|
+
network: EthChainId = EthChainId.ETHEREUM
|
137
|
+
): Promise<ProcessBindingResponse> {
|
130
138
|
const bindings = []
|
131
139
|
for (const log of logs) {
|
132
140
|
const binding = this.buildAccountLogBinding(address, log, network)
|
@@ -140,9 +148,13 @@ export class EthFacet {
|
|
140
148
|
})
|
141
149
|
}
|
142
150
|
|
143
|
-
buildAccountLogBinding(
|
151
|
+
buildAccountLogBinding(
|
152
|
+
address: string,
|
153
|
+
log: LogParams,
|
154
|
+
network: EthChainId = EthChainId.ETHEREUM
|
155
|
+
): DataBinding | undefined {
|
144
156
|
for (const account of this.server.accountConfigs) {
|
145
|
-
if (account.chainId !==
|
157
|
+
if (account.chainId !== network) {
|
146
158
|
continue
|
147
159
|
}
|
148
160
|
if (address.toLowerCase() !== account.address.toLowerCase()) {
|
@@ -186,12 +198,12 @@ export class EthFacet {
|
|
186
198
|
|
187
199
|
testBlock(
|
188
200
|
block: Partial<BlockParams> & { number: number },
|
189
|
-
network:
|
201
|
+
network: EthChainId = EthChainId.ETHEREUM
|
190
202
|
): Promise<ProcessBindingResponse> {
|
191
203
|
return this.testBlocks([block], network)
|
192
204
|
}
|
193
205
|
|
194
|
-
testBlocks(blocks: Partial<BlockParams> & { number: number }[], network:
|
206
|
+
testBlocks(blocks: Partial<BlockParams> & { number: number }[], network: EthChainId = EthChainId.ETHEREUM) {
|
195
207
|
const bindings = []
|
196
208
|
for (const block of blocks) {
|
197
209
|
const binding = this.buildBlockBinding(block, network)
|
@@ -205,7 +217,10 @@ export class EthFacet {
|
|
205
217
|
})
|
206
218
|
}
|
207
219
|
|
208
|
-
buildBlockBinding(
|
220
|
+
buildBlockBinding(
|
221
|
+
block: Partial<Block> & { number: number },
|
222
|
+
network: EthChainId = EthChainId.ETHEREUM
|
223
|
+
): DataBinding {
|
209
224
|
const binding: DataBinding = {
|
210
225
|
data: {
|
211
226
|
ethBlock: { block },
|
@@ -214,7 +229,7 @@ export class EthFacet {
|
|
214
229
|
handlerIds: [],
|
215
230
|
}
|
216
231
|
for (const contract of this.server.contractConfigs) {
|
217
|
-
if (contract.contract?.chainId !==
|
232
|
+
if (contract.contract?.chainId !== network) {
|
218
233
|
continue
|
219
234
|
}
|
220
235
|
const longBlockNumber = block.number
|
package/src/testing/sui-facet.ts
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import { SuiTransactionBlockResponse, MoveCallSuiTransaction } from '@mysten/sui.js'
|
2
2
|
import { DataBinding, HandlerType } from '@sentio/protos'
|
3
|
-
import { getChainId } from '../sui/network.js'
|
4
3
|
import { TestProcessorServer } from './test-processor-server.js'
|
5
4
|
import { parseMoveType } from '../move/types.js'
|
6
5
|
import { SuiNetwork } from '../sui/index.js'
|
@@ -43,7 +42,7 @@ export class SuiFacet {
|
|
43
42
|
const functionType = [call.package, call.module, call.function].join(SPLITTER)
|
44
43
|
|
45
44
|
for (const config of this.server.contractConfigs) {
|
46
|
-
if (config.contract?.chainId !==
|
45
|
+
if (config.contract?.chainId !== network) {
|
47
46
|
continue
|
48
47
|
}
|
49
48
|
for (const callConfig of config.moveCallConfigs) {
|
@@ -83,7 +82,7 @@ export class SuiFacet {
|
|
83
82
|
// const allEvents = new Set(transaction.events.map(e => e.type))
|
84
83
|
|
85
84
|
for (const config of this.server.contractConfigs) {
|
86
|
-
if (config.contract?.chainId !==
|
85
|
+
if (config.contract?.chainId !== network) {
|
87
86
|
continue
|
88
87
|
}
|
89
88
|
for (const eventConfig of config.moveEventConfigs) {
|
package/src/utils/dex-price.ts
CHANGED
@@ -4,6 +4,7 @@ import { parse } from 'csv-parse/sync'
|
|
4
4
|
import { BlockTag } from 'ethers/providers'
|
5
5
|
import url from 'url'
|
6
6
|
import { scaleDown } from '../core/big-decimal.js'
|
7
|
+
import { EthChainId } from '../core/chain.js'
|
7
8
|
|
8
9
|
type OralceRecord = {
|
9
10
|
Pair: string
|
@@ -31,9 +32,9 @@ class DexPrice {
|
|
31
32
|
BTC_ORACLE_MAP = new Map<string, string>()
|
32
33
|
ASSETS_INFOS = new Map<string, number>()
|
33
34
|
|
34
|
-
readonly chainId:
|
35
|
+
readonly chainId: EthChainId
|
35
36
|
|
36
|
-
constructor(csvFileName: string, chainId:
|
37
|
+
constructor(csvFileName: string, chainId: EthChainId) {
|
37
38
|
this.chainId = chainId
|
38
39
|
const csvFilePath = url.fileURLToPath(new URL('./' + csvFileName, import.meta.url))
|
39
40
|
const fileContent = fs.readFileSync(csvFilePath, { encoding: 'utf-8' })
|
@@ -131,5 +132,5 @@ class DexPrice {
|
|
131
132
|
}
|
132
133
|
}
|
133
134
|
|
134
|
-
export const EthereumDexPrice = new DexPrice('chainlink-oracles.csv',
|
135
|
-
export const GoerliDexPrice = new DexPrice('chainlink-oracles-goerli.csv',
|
135
|
+
export const EthereumDexPrice = new DexPrice('chainlink-oracles.csv', EthChainId.ETHEREUM)
|
136
|
+
export const GoerliDexPrice = new DexPrice('chainlink-oracles-goerli.csv', EthChainId.GOERLI)
|
package/src/utils/price.ts
CHANGED
@@ -3,6 +3,7 @@ import { createChannel, createClientFactory, Status } from 'nice-grpc'
|
|
3
3
|
import { prometheusClientMiddleware } from 'nice-grpc-prometheus'
|
4
4
|
import { retryMiddleware, RetryOptions } from 'nice-grpc-client-middleware-retry'
|
5
5
|
import { Endpoints } from '@sentio/runtime'
|
6
|
+
import { ChainId } from '../core/chain.js'
|
6
7
|
|
7
8
|
export function getPriceClient(address?: string) {
|
8
9
|
if (!address) {
|
@@ -98,7 +99,7 @@ export async function getPriceByTypeOrSymbolInternal(
|
|
98
99
|
* @param options other behavior options
|
99
100
|
*/
|
100
101
|
export async function getPriceByType(
|
101
|
-
chainId:
|
102
|
+
chainId: ChainId,
|
102
103
|
coinType: string,
|
103
104
|
date: Date,
|
104
105
|
options?: PriceOptions
|
package/src/utils/token.ts
CHANGED
@@ -2,9 +2,8 @@ import { getERC20Contract } from '../eth/builtin/erc20.js'
|
|
2
2
|
import { getERC20BytesContract } from '../eth/builtin/erc20bytes.js'
|
3
3
|
import { BigDecimal, scaleDown } from '../core/big-decimal.js'
|
4
4
|
import { PromiseOrValue } from '../eth/builtin/internal/common.js'
|
5
|
-
import { decodeBytes32String
|
6
|
-
import {
|
7
|
-
import { getNetworkFromCtxOrNetworkish } from '../eth/index.js'
|
5
|
+
import { decodeBytes32String } from 'ethers'
|
6
|
+
import { EthChainId, EthContext, getEthChainId } from '../eth/index.js'
|
8
7
|
|
9
8
|
export interface TokenInfo {
|
10
9
|
symbol: string
|
@@ -33,10 +32,10 @@ async function getTokenInfoPromise(
|
|
33
32
|
}
|
34
33
|
|
35
34
|
export async function getERC20TokenInfo(
|
36
|
-
contextOrNetworkish:
|
35
|
+
contextOrNetworkish: EthContext | EthChainId,
|
37
36
|
tokenAddress: string
|
38
37
|
): Promise<TokenInfo> {
|
39
|
-
const chainId =
|
38
|
+
const chainId = getEthChainId(contextOrNetworkish)
|
40
39
|
const key = chainId + tokenAddress
|
41
40
|
const res = TOKEN_INFOS.get(key)
|
42
41
|
if (res) {
|
@@ -67,7 +66,7 @@ export async function getERC20TokenInfo(
|
|
67
66
|
}
|
68
67
|
|
69
68
|
export async function getER20NormalizedAmount(
|
70
|
-
contextOrNetworkish:
|
69
|
+
contextOrNetworkish: EthContext | EthChainId,
|
71
70
|
tokenAddress: string,
|
72
71
|
amount: bigint
|
73
72
|
): Promise<BigDecimal> {
|