@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
@@ -2,7 +2,6 @@
|
|
2
2
|
/* tslint:disable */
|
3
3
|
/* eslint-disable */
|
4
4
|
import { 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 { ERC20, ERC20__factory } from "./index.js";
|
27
27
|
import {
|
@@ -610,10 +610,10 @@ export class ERC20ProcessorTemplate extends BaseProcessorTemplate<
|
|
610
610
|
}
|
611
611
|
|
612
612
|
export function getERC20Contract(
|
613
|
-
contextOrNetwork:
|
613
|
+
contextOrNetwork: EthContext | EthChainId,
|
614
614
|
address: string
|
615
615
|
): ERC20ContractView {
|
616
|
-
const network =
|
616
|
+
const network = getEthChainId(contextOrNetwork);
|
617
617
|
let contract = getContractByABI(
|
618
618
|
"ERC20",
|
619
619
|
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
|
ApprovalEventObject,
|
7
8
|
OwnershipTransferredEventObject,
|
@@ -23,7 +24,7 @@ export function mockApprovalLog(
|
|
23
24
|
contractAddress: string,
|
24
25
|
event: ApprovalEventObject
|
25
26
|
): LogParams {
|
26
|
-
const contract = getERC20Contract(
|
27
|
+
const contract = getERC20Contract(EthChainId.ETHEREUM, contractAddress);
|
27
28
|
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
28
29
|
"Approval(address,address,uint256)",
|
29
30
|
[event.owner, event.spender, event.value]
|
@@ -41,7 +42,7 @@ export function mockOwnershipTransferredLog(
|
|
41
42
|
contractAddress: string,
|
42
43
|
event: OwnershipTransferredEventObject
|
43
44
|
): LogParams {
|
44
|
-
const contract = getERC20Contract(
|
45
|
+
const contract = getERC20Contract(EthChainId.ETHEREUM, contractAddress);
|
45
46
|
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
46
47
|
"OwnershipTransferred(address,address)",
|
47
48
|
[event.previousOwner, event.newOwner]
|
@@ -59,7 +60,7 @@ export function mockTransferLog(
|
|
59
60
|
contractAddress: string,
|
60
61
|
event: TransferEventObject
|
61
62
|
): LogParams {
|
62
|
-
const contract = getERC20Contract(
|
63
|
+
const contract = getERC20Contract(EthChainId.ETHEREUM, contractAddress);
|
63
64
|
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
64
65
|
"Transfer(address,address,uint256)",
|
65
66
|
[event.from, event.to, event.value]
|
@@ -2,7 +2,6 @@
|
|
2
2
|
/* tslint:disable */
|
3
3
|
/* eslint-disable */
|
4
4
|
import { 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 { ERC20Bytes, ERC20Bytes__factory } from "./index.js";
|
27
27
|
import {
|
@@ -412,10 +412,10 @@ export class ERC20BytesProcessorTemplate extends BaseProcessorTemplate<
|
|
412
412
|
}
|
413
413
|
|
414
414
|
export function getERC20BytesContract(
|
415
|
-
contextOrNetwork:
|
415
|
+
contextOrNetwork: EthContext | EthChainId,
|
416
416
|
address: string
|
417
417
|
): ERC20BytesContractView {
|
418
|
-
const network =
|
418
|
+
const network = getEthChainId(contextOrNetwork);
|
419
419
|
let contract = getContractByABI(
|
420
420
|
"ERC20Bytes",
|
421
421
|
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 { ApprovalEventObject, TransferEventObject } from "./ERC20Bytes.js";
|
6
7
|
import { getERC20BytesContract } from "./erc20bytes-processor.js";
|
7
8
|
const mockField = {
|
@@ -19,7 +20,7 @@ export function mockApprovalLog(
|
|
19
20
|
contractAddress: string,
|
20
21
|
event: ApprovalEventObject
|
21
22
|
): LogParams {
|
22
|
-
const contract = getERC20BytesContract(
|
23
|
+
const contract = getERC20BytesContract(EthChainId.ETHEREUM, contractAddress);
|
23
24
|
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
24
25
|
"Approval(address,address,uint256)",
|
25
26
|
[event.owner, event.spender, event.value]
|
@@ -37,7 +38,7 @@ export function mockTransferLog(
|
|
37
38
|
contractAddress: string,
|
38
39
|
event: TransferEventObject
|
39
40
|
): LogParams {
|
40
|
-
const contract = getERC20BytesContract(
|
41
|
+
const contract = getERC20BytesContract(EthChainId.ETHEREUM, contractAddress);
|
41
42
|
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
42
43
|
"Transfer(address,address,uint256)",
|
43
44
|
[event.from, event.to, event.value]
|
@@ -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 { ERC721, ERC721__factory } from "./index.js";
|
27
27
|
import {
|
@@ -627,10 +627,10 @@ export class ERC721ProcessorTemplate extends BaseProcessorTemplate<
|
|
627
627
|
}
|
628
628
|
|
629
629
|
export function getERC721Contract(
|
630
|
-
contextOrNetwork:
|
630
|
+
contextOrNetwork: EthContext | EthChainId,
|
631
631
|
address: string
|
632
632
|
): ERC721ContractView {
|
633
|
-
const network =
|
633
|
+
const network = getEthChainId(contextOrNetwork);
|
634
634
|
let contract = getContractByABI(
|
635
635
|
"ERC721",
|
636
636
|
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
|
ApprovalEventObject,
|
7
8
|
ApprovalForAllEventObject,
|
@@ -23,7 +24,7 @@ export function mockApprovalLog(
|
|
23
24
|
contractAddress: string,
|
24
25
|
event: ApprovalEventObject
|
25
26
|
): LogParams {
|
26
|
-
const contract = getERC721Contract(
|
27
|
+
const contract = getERC721Contract(EthChainId.ETHEREUM, contractAddress);
|
27
28
|
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
28
29
|
"Approval(address,address,uint256)",
|
29
30
|
[event.owner, event.approved, event.tokenId]
|
@@ -41,7 +42,7 @@ export function mockApprovalForAllLog(
|
|
41
42
|
contractAddress: string,
|
42
43
|
event: ApprovalForAllEventObject
|
43
44
|
): LogParams {
|
44
|
-
const contract = getERC721Contract(
|
45
|
+
const contract = getERC721Contract(EthChainId.ETHEREUM, contractAddress);
|
45
46
|
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
46
47
|
"ApprovalForAll(address,address,bool)",
|
47
48
|
[event.owner, event.operator, event.approved]
|
@@ -59,7 +60,7 @@ export function mockTransferLog(
|
|
59
60
|
contractAddress: string,
|
60
61
|
event: TransferEventObject
|
61
62
|
): LogParams {
|
62
|
-
const contract = getERC721Contract(
|
63
|
+
const contract = getERC721Contract(EthChainId.ETHEREUM, contractAddress);
|
63
64
|
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
64
65
|
"Transfer(address,address,uint256)",
|
65
66
|
[event.from, event.to, event.tokenId]
|
@@ -2,7 +2,6 @@
|
|
2
2
|
/* tslint:disable */
|
3
3
|
/* eslint-disable */
|
4
4
|
import { 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 { WETH9, WETH9__factory } from "./index.js";
|
27
27
|
import {
|
@@ -485,10 +485,10 @@ export class WETH9ProcessorTemplate extends BaseProcessorTemplate<
|
|
485
485
|
}
|
486
486
|
|
487
487
|
export function getWETH9Contract(
|
488
|
-
contextOrNetwork:
|
488
|
+
contextOrNetwork: EthContext | EthChainId,
|
489
489
|
address: string
|
490
490
|
): WETH9ContractView {
|
491
|
-
const network =
|
491
|
+
const network = getEthChainId(contextOrNetwork);
|
492
492
|
let contract = getContractByABI(
|
493
493
|
"WETH9",
|
494
494
|
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
|
ApprovalEventObject,
|
7
8
|
TransferEventObject,
|
@@ -24,7 +25,7 @@ export function mockApprovalLog(
|
|
24
25
|
contractAddress: string,
|
25
26
|
event: ApprovalEventObject
|
26
27
|
): LogParams {
|
27
|
-
const contract = getWETH9Contract(
|
28
|
+
const contract = getWETH9Contract(EthChainId.ETHEREUM, contractAddress);
|
28
29
|
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
29
30
|
"Approval(address,address,uint256)",
|
30
31
|
[event.src, event.guy, event.wad]
|
@@ -42,7 +43,7 @@ export function mockTransferLog(
|
|
42
43
|
contractAddress: string,
|
43
44
|
event: TransferEventObject
|
44
45
|
): LogParams {
|
45
|
-
const contract = getWETH9Contract(
|
46
|
+
const contract = getWETH9Contract(EthChainId.ETHEREUM, contractAddress);
|
46
47
|
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
47
48
|
"Transfer(address,address,uint256)",
|
48
49
|
[event.src, event.dst, event.wad]
|
@@ -60,7 +61,7 @@ export function mockDepositLog(
|
|
60
61
|
contractAddress: string,
|
61
62
|
event: DepositEventObject
|
62
63
|
): LogParams {
|
63
|
-
const contract = getWETH9Contract(
|
64
|
+
const contract = getWETH9Contract(EthChainId.ETHEREUM, contractAddress);
|
64
65
|
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
65
66
|
"Deposit(address,uint256)",
|
66
67
|
[event.dst, event.wad]
|
@@ -78,7 +79,7 @@ export function mockWithdrawalLog(
|
|
78
79
|
contractAddress: string,
|
79
80
|
event: WithdrawalEventObject
|
80
81
|
): LogParams {
|
81
|
-
const contract = getWETH9Contract(
|
82
|
+
const contract = getWETH9Contract(EthChainId.ETHEREUM, contractAddress);
|
82
83
|
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
83
84
|
"Withdrawal(address,uint256)",
|
84
85
|
[event.src, event.wad]
|
@@ -11,6 +11,7 @@ import {
|
|
11
11
|
import { dirname, join, relative } from 'path'
|
12
12
|
import { codeGenIndex, codeGenSentioFile, codeGenTestUtilsFile } from './file.js'
|
13
13
|
import { YamlContractConfig } from '../../core/yaml-contract-config.js'
|
14
|
+
import { ChainId, EthChainId } from '../../core/chain.js'
|
14
15
|
|
15
16
|
export interface SentioEthersConfig extends Config {
|
16
17
|
contractsToGenExample: YamlContractConfig[]
|
@@ -98,17 +99,23 @@ export default class EthersSentio extends Ethers.default {
|
|
98
99
|
const contractsToGenExample = (this.cfg as SentioEthersConfig).contractsToGenExample
|
99
100
|
if (contractsToGenExample.length > 0) {
|
100
101
|
const processors = this.processedABIs.map((abi) => `${abi.name}Processor`).join(',')
|
101
|
-
let exampleContent = `
|
102
|
+
let exampleContent = `
|
103
|
+
import { EthChainId } from '@sentio/sdk/eth'
|
104
|
+
import { ${processors} } from './types/eth/index.js'`
|
105
|
+
|
106
|
+
const ethChainIdValues = new Map<ChainId, string>()
|
107
|
+
for (const [key, value] of Object.entries(EthChainId)) {
|
108
|
+
ethChainIdValues.set(value, key)
|
109
|
+
}
|
102
110
|
|
103
111
|
for (const contract of contractsToGenExample) {
|
104
|
-
const
|
105
|
-
if (
|
112
|
+
const chainKey = ethChainIdValues.get(contract.chain)
|
113
|
+
if (!chainKey) {
|
106
114
|
continue
|
107
115
|
}
|
108
|
-
|
109
116
|
const content = `
|
110
117
|
|
111
|
-
${contract.name}Processor.bind({ address: '${contract.address}', network:
|
118
|
+
${contract.name}Processor.bind({ address: '${contract.address}', network: EthChainId.${chainKey} })
|
112
119
|
.onAllEvents((evt, ctx) => {
|
113
120
|
ctx.meter.Counter('event_count').add(1, { name: evt.name })
|
114
121
|
ctx.eventLogger.emit(evt.name, {
|
package/src/eth/codegen/file.ts
CHANGED
@@ -106,10 +106,10 @@ export class ${contract.name}ProcessorTemplate extends BaseProcessorTemplate<${c
|
|
106
106
|
.join('\n')}
|
107
107
|
}
|
108
108
|
|
109
|
-
export function get${contract.name}Contract(contextOrNetwork:
|
109
|
+
export function get${contract.name}Contract(contextOrNetwork: EthContext | EthChainId, address: string): ${
|
110
110
|
contract.name
|
111
111
|
}ContractView {
|
112
|
-
const network =
|
112
|
+
const network = getEthChainId(contextOrNetwork)
|
113
113
|
let contract = getContractByABI("${contract.name}", address, network) as ${contract.name}ContractView
|
114
114
|
if (!contract) {
|
115
115
|
const rawContract = ${contract.name}__factory.connect(address, getProvider(network))
|
@@ -148,7 +148,7 @@ export class ${contract.name}ProcessorTemplate extends BaseProcessorTemplate<${c
|
|
148
148
|
const imports = createImportsForUsedIdentifiers(
|
149
149
|
{
|
150
150
|
ethers: ['BigNumberish', 'Overrides', 'BytesLike'],
|
151
|
-
'ethers/providers': ['Networkish'],
|
151
|
+
// 'ethers/providers': ['Networkish'],
|
152
152
|
'@sentio/sdk/eth': [
|
153
153
|
'addContractByABI',
|
154
154
|
'getContractByABI',
|
@@ -164,12 +164,14 @@ export class ${contract.name}ProcessorTemplate extends BaseProcessorTemplate<${c
|
|
164
164
|
'ContractContext',
|
165
165
|
'ContractView',
|
166
166
|
'DummyProvider',
|
167
|
+
'EthChainId',
|
167
168
|
'TypedCallTrace',
|
168
|
-
'
|
169
|
+
'getEthChainId',
|
169
170
|
// 'toBlockTag',
|
171
|
+
'EthContext',
|
170
172
|
'EthFetchConfig',
|
171
173
|
],
|
172
|
-
'@sentio/sdk': ['BaseContext'],
|
174
|
+
// '@sentio/sdk/eth': ['BaseContext'],
|
173
175
|
// '@sentio/protos': ['EthFetchConfig'],
|
174
176
|
'./common.js': ['PromiseOrValue'],
|
175
177
|
'./index.js': [`${contract.name}`, `${contract.name}__factory`],
|
@@ -206,6 +208,7 @@ export function codeGenTestUtilsFile(contract: Contract): string {
|
|
206
208
|
|
207
209
|
const possibleImports = {
|
208
210
|
'ethers/providers': ['LogParams'],
|
211
|
+
'@sentio/sdk/eth': ['EthChainId'],
|
209
212
|
} as any
|
210
213
|
possibleImports[`./${contract.name}.js`] = Object.values(contract.events).flatMap((events) => {
|
211
214
|
if (events.length === 1) {
|
@@ -232,7 +235,7 @@ function generateMockEventLogFunction(event: EventDeclaration, contractName: str
|
|
232
235
|
|
233
236
|
return `
|
234
237
|
export function mock${eventName}Log(contractAddress: string, event: ${eventName}EventObject): LogParams {
|
235
|
-
const contract = get${contractName}Contract(
|
238
|
+
const contract = get${contractName}Contract(EthChainId.ETHEREUM, contractAddress)
|
236
239
|
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
237
240
|
'${getFullSignatureForEvent(event)}',
|
238
241
|
[${eventArgs.join(', ')}]
|
package/src/eth/context.ts
CHANGED
@@ -5,9 +5,10 @@ import { RecordMetaData } from '@sentio/protos'
|
|
5
5
|
import { Trace } from './eth.js'
|
6
6
|
import { Labels, normalizeLabels } from '../core/index.js'
|
7
7
|
import { BaseContext } from '../core/base-context.js'
|
8
|
+
import { EthChainId } from '../core/chain.js'
|
8
9
|
|
9
10
|
export abstract class EthContext extends BaseContext {
|
10
|
-
chainId:
|
11
|
+
chainId: EthChainId
|
11
12
|
address: string
|
12
13
|
private readonly log?: LogParams
|
13
14
|
block?: BlockParams
|
@@ -19,7 +20,7 @@ export abstract class EthContext extends BaseContext {
|
|
19
20
|
timestamp: Date
|
20
21
|
|
21
22
|
constructor(
|
22
|
-
chainId:
|
23
|
+
chainId: EthChainId,
|
23
24
|
address: string,
|
24
25
|
timestamp?: Date,
|
25
26
|
block?: BlockParams,
|
@@ -51,8 +52,8 @@ export abstract class EthContext extends BaseContext {
|
|
51
52
|
|
52
53
|
protected abstract getContractName(): string
|
53
54
|
|
54
|
-
getChainId():
|
55
|
-
return this.chainId
|
55
|
+
getChainId(): EthChainId {
|
56
|
+
return this.chainId
|
56
57
|
}
|
57
58
|
|
58
59
|
getMetaDataInternal(name: string, labels: Labels): RecordMetaData {
|
@@ -64,7 +65,7 @@ export abstract class EthContext extends BaseContext {
|
|
64
65
|
transactionIndex: this.log.transactionIndex,
|
65
66
|
transactionHash: this.transactionHash || '',
|
66
67
|
logIndex: this.log.index,
|
67
|
-
chainId: this.chainId
|
68
|
+
chainId: this.chainId,
|
68
69
|
name: name,
|
69
70
|
labels: normalizeLabels(labels),
|
70
71
|
}
|
@@ -110,7 +111,7 @@ export class AccountContext extends EthContext {
|
|
110
111
|
|
111
112
|
export class GlobalContext extends EthContext {
|
112
113
|
constructor(
|
113
|
-
chainId:
|
114
|
+
chainId: EthChainId,
|
114
115
|
timestamp?: Date,
|
115
116
|
block?: BlockParams,
|
116
117
|
log?: LogParams,
|
@@ -135,7 +136,7 @@ export class ContractContext<
|
|
135
136
|
constructor(
|
136
137
|
contractName: string,
|
137
138
|
view: TContractBoundView,
|
138
|
-
chainId:
|
139
|
+
chainId: EthChainId,
|
139
140
|
timestamp?: Date,
|
140
141
|
block?: BlockParams,
|
141
142
|
log?: LogParams,
|
package/src/eth/eth-plugin.ts
CHANGED
@@ -12,7 +12,6 @@ import {
|
|
12
12
|
LogHandlerConfig,
|
13
13
|
ProcessConfigResponse,
|
14
14
|
ProcessResult,
|
15
|
-
RecordMetaData,
|
16
15
|
StartRequest,
|
17
16
|
} from '@sentio/protos'
|
18
17
|
|
@@ -22,7 +21,8 @@ import { AccountProcessorState } from './account-processor-state.js'
|
|
22
21
|
import { ProcessorTemplateProcessorState, TemplateInstanceState } from './base-processor-template.js'
|
23
22
|
import { GlobalProcessorState } from './base-processor.js'
|
24
23
|
import { validateAndNormalizeAddress } from './eth.js'
|
25
|
-
import {
|
24
|
+
import { EthChainId } from '../core/chain.js'
|
25
|
+
import { EthContext } from './context.js'
|
26
26
|
|
27
27
|
interface Handlers {
|
28
28
|
eventHandlers: ((event: Data_EthLog) => Promise<ProcessResult>)[]
|
@@ -256,7 +256,7 @@ export class EthPlugin extends Plugin {
|
|
256
256
|
{
|
257
257
|
name: instance.contract.name,
|
258
258
|
address: validateAndNormalizeAddress(instance.contract.address),
|
259
|
-
network:
|
259
|
+
network: instance.contract.chainId as EthChainId,
|
260
260
|
startBlock: instance.startBlock,
|
261
261
|
endBlock: instance.endBlock,
|
262
262
|
},
|
@@ -355,15 +355,12 @@ export class EthPlugin extends Plugin {
|
|
355
355
|
|
356
356
|
PluginManager.INSTANCE.register(new EthPlugin())
|
357
357
|
|
358
|
-
class NoopContext extends
|
358
|
+
class NoopContext extends EthContext {
|
359
359
|
public constructor() {
|
360
|
-
super(
|
361
|
-
}
|
362
|
-
getChainId(): string {
|
363
|
-
return ''
|
360
|
+
super(EthChainId.ETHEREUM, '')
|
364
361
|
}
|
365
362
|
|
366
|
-
|
367
|
-
return
|
363
|
+
protected getContractName(): string {
|
364
|
+
return ''
|
368
365
|
}
|
369
366
|
}
|
package/src/eth/index.ts
CHANGED
@@ -2,7 +2,8 @@ export { BaseProcessor, GlobalProcessor } from './base-processor.js'
|
|
2
2
|
export { GenericProcessor } from './generic-processor.js'
|
3
3
|
export { BaseProcessorTemplate } from './base-processor-template.js'
|
4
4
|
export { AccountProcessor } from './account-processor.js'
|
5
|
-
export { getProvider, DummyProvider,
|
5
|
+
export { getProvider, DummyProvider, getEthChainId } from './provider.js'
|
6
|
+
export { EthContext } from './context.js'
|
6
7
|
export * from './eth.js'
|
7
8
|
export { BindOptions, AccountBindOptions } from './bind-options.js'
|
8
9
|
export { getProcessor, addProcessor, getContractByABI, addContractByABI } from './binds.js'
|
@@ -11,3 +12,5 @@ export { ContractContext, GlobalContext, ContractView, BoundContractView } from
|
|
11
12
|
export { EthPlugin } from './eth-plugin.js'
|
12
13
|
|
13
14
|
export { EthFetchConfig } from '@sentio/protos'
|
15
|
+
|
16
|
+
export { EthChainId } from '../core/chain.js'
|
package/src/eth/provider.ts
CHANGED
@@ -1,36 +1,34 @@
|
|
1
|
-
import {
|
2
|
-
import { Networkish } from 'ethers/providers'
|
1
|
+
import { JsonRpcProvider, Network, Provider } from 'ethers'
|
3
2
|
|
4
3
|
import PQueue from 'p-queue'
|
5
4
|
import { Endpoints } from '@sentio/runtime'
|
6
5
|
import { BaseContext } from '../core/index.js'
|
6
|
+
import { EthChainId } from '../core/chain.js'
|
7
|
+
import { EthContext } from './context.js'
|
7
8
|
|
8
9
|
export const DummyProvider = new JsonRpcProvider('', Network.from(1))
|
9
10
|
|
10
11
|
const providers = new Map<string, JsonRpcProvider>()
|
11
12
|
|
12
|
-
export function
|
13
|
+
export function getEthChainId(networkish?: EthContext | EthChainId): EthChainId {
|
13
14
|
if (!networkish) {
|
14
|
-
networkish =
|
15
|
+
networkish = EthChainId.ETHEREUM
|
15
16
|
}
|
16
17
|
if (networkish instanceof BaseContext) {
|
17
18
|
networkish = networkish.getChainId()
|
18
19
|
}
|
19
|
-
|
20
|
-
const id = parseInt(networkish)
|
21
|
-
if (isNaN(id)) {
|
22
|
-
throw Error('Unexpected Network')
|
23
|
-
}
|
24
|
-
networkish = id
|
25
|
-
}
|
26
|
-
return Network.from(networkish)
|
20
|
+
return networkish
|
27
21
|
}
|
28
22
|
|
29
|
-
export function getProvider(
|
30
|
-
const network = getNetworkFromCtxOrNetworkish(networkish)
|
23
|
+
export function getProvider(chainId?: EthChainId): Provider {
|
24
|
+
// const network = getNetworkFromCtxOrNetworkish(networkish)
|
25
|
+
if (!chainId) {
|
26
|
+
chainId = EthChainId.ETHEREUM
|
27
|
+
}
|
28
|
+
const network = Network.from(parseInt(chainId))
|
31
29
|
// TODO check if other key needed
|
32
30
|
|
33
|
-
const address = Endpoints.INSTANCE.chainServer.get(
|
31
|
+
const address = Endpoints.INSTANCE.chainServer.get(chainId)
|
34
32
|
const key = network.chainId.toString() + '-' + address
|
35
33
|
let provider = providers.get(key)
|
36
34
|
|
@@ -158,14 +158,21 @@ export abstract class AbstractCodegen<NetworkType, ModuleTypes, StructType> {
|
|
158
158
|
return 'MAIN_NET'
|
159
159
|
}
|
160
160
|
|
161
|
-
generateModule(module: InternalMoveModule, network: NetworkType) {
|
161
|
+
generateModule(module: InternalMoveModule, allEventStructs: Map<string, InternalMoveStruct>, network: NetworkType) {
|
162
|
+
const qname = moduleQname(module)
|
162
163
|
const functions = this.GENERATE_ON_ENTRY
|
163
164
|
? module.exposedFunctions.map((f) => this.generateOnEntryFunctions(module, f)).filter((s) => s !== '')
|
164
165
|
: []
|
165
166
|
const clientFunctions = this.GENERATE_CLIENT
|
166
167
|
? module.exposedFunctions.map((f) => this.generateClientFunctions(module, f)).filter((s) => s !== '')
|
167
168
|
: []
|
168
|
-
const eventStructs =
|
169
|
+
const eventStructs = new Map<string, InternalMoveStruct>()
|
170
|
+
for (const [type, struct] of allEventStructs.entries()) {
|
171
|
+
if (type.startsWith(qname + SPLITTER)) {
|
172
|
+
eventStructs.set(type, struct)
|
173
|
+
}
|
174
|
+
}
|
175
|
+
|
169
176
|
const eventTypes = new Set(eventStructs.keys())
|
170
177
|
const events = Array.from(eventStructs.values())
|
171
178
|
.map((e) => this.generateOnEvents(module, e))
|
@@ -554,6 +561,8 @@ export class AccountCodegen<NetworkType, ModuleType, StructType> {
|
|
554
561
|
`
|
555
562
|
}
|
556
563
|
|
564
|
+
const eventsMap: Map<string, InternalMoveStruct> = this.moduleGen.chainAdapter.getAllEventStructs(this.modules)
|
565
|
+
|
557
566
|
const source = `
|
558
567
|
/* Autogenerated file. Do not edit manually. */
|
559
568
|
/* tslint:disable */
|
@@ -565,7 +574,7 @@ export class AccountCodegen<NetworkType, ModuleType, StructType> {
|
|
565
574
|
|
566
575
|
${moduleImports.join('\n')}
|
567
576
|
|
568
|
-
${this.modules.map((m) => this.moduleGen.generateModule(m, this.config.network)).join('\n')}
|
577
|
+
${this.modules.map((m) => this.moduleGen.generateModule(m, eventsMap, this.config.network)).join('\n')}
|
569
578
|
|
570
579
|
const MODULES = JSON.parse('${JSON.stringify(this.abi)}')
|
571
580
|
|
@@ -6,8 +6,10 @@ export abstract class ChainAdapter<NetworkType, ModuleType, StructType> {
|
|
6
6
|
|
7
7
|
abstract fetchModules(account: string, network: NetworkType): Promise<ModuleType[]>
|
8
8
|
abstract toInternalModules(modules: ModuleType[]): InternalMoveModule[]
|
9
|
-
|
10
|
-
|
9
|
+
|
10
|
+
// Get all structs that represent Events
|
11
|
+
abstract getAllEventStructs(module: InternalMoveModule[]): Map<string, InternalMoveStruct>
|
12
|
+
|
11
13
|
// Get the parameters that actually have arguments in runtime
|
12
14
|
// Aptos first signer and Sui's last TxContext are no use
|
13
15
|
abstract getMeaningfulFunctionParams(params: TypeDescriptor[]): TypeDescriptor[]
|
@@ -1,20 +1,27 @@
|
|
1
|
-
import { normalizeLabels, Labels, BaseContext, RecordMetaData
|
1
|
+
import { normalizeLabels, Labels, BaseContext, RecordMetaData } from '@sentio/sdk'
|
2
|
+
import { SolanaChainId } from '../core/chain.js'
|
2
3
|
|
3
4
|
export class SolanaContext extends BaseContext {
|
4
|
-
network:
|
5
|
+
network: SolanaChainId
|
5
6
|
address: string
|
6
7
|
programName: string
|
7
8
|
blockNumber: bigint
|
8
9
|
|
9
|
-
constructor(
|
10
|
+
constructor(
|
11
|
+
programName: string,
|
12
|
+
network: SolanaChainId,
|
13
|
+
address: string,
|
14
|
+
slot: bigint,
|
15
|
+
baseLabels: Labels | undefined
|
16
|
+
) {
|
10
17
|
super(baseLabels)
|
11
|
-
this.network = network ||
|
18
|
+
this.network = network || SolanaChainId.SOLANA_MAINNET
|
12
19
|
this.programName = programName
|
13
20
|
this.address = address
|
14
21
|
this.blockNumber = slot
|
15
22
|
}
|
16
23
|
|
17
|
-
getChainId()
|
24
|
+
getChainId() {
|
18
25
|
return this.network
|
19
26
|
}
|
20
27
|
|
@@ -1,9 +1,10 @@
|
|
1
1
|
import { InstructionCoder } from './solana-processor.js'
|
2
2
|
import { Labels } from '../core/index.js'
|
3
|
+
import { SolanaChainId } from '../core/chain.js'
|
3
4
|
|
4
5
|
export class SolanaBindOptions {
|
5
6
|
address: string
|
6
|
-
network?:
|
7
|
+
network?: SolanaChainId
|
7
8
|
name?: string
|
8
9
|
startBlock?: bigint | number
|
9
10
|
endBlock?: bigint | number
|