@sentio/sdk 2.14.5-rc.1 → 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-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/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-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-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/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-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
@@ -1,4 +1,4 @@
|
|
1
|
-
import { addContractByABI, getContractByABI, addProcessor, getProcessor, getProvider, transformEtherError, BaseProcessor, BaseProcessorTemplate, BoundContractView, ContractView, DummyProvider,
|
1
|
+
import { addContractByABI, getContractByABI, addProcessor, getProcessor, getProvider, transformEtherError, BaseProcessor, BaseProcessorTemplate, BoundContractView, ContractView, DummyProvider, getEthChainId, } from "@sentio/sdk/eth";
|
2
2
|
import { WETH9__factory } from "./index.js";
|
3
3
|
const templateContract = WETH9__factory.connect("0x0", DummyProvider);
|
4
4
|
export class WETH9ContractView extends ContractView {
|
@@ -231,7 +231,7 @@ export class WETH9ProcessorTemplate extends BaseProcessorTemplate {
|
|
231
231
|
}
|
232
232
|
}
|
233
233
|
export function getWETH9Contract(contextOrNetwork, address) {
|
234
|
-
const network =
|
234
|
+
const network = getEthChainId(contextOrNetwork);
|
235
235
|
let contract = getContractByABI("WETH9", address, network);
|
236
236
|
if (!contract) {
|
237
237
|
const rawContract = WETH9__factory.connect(address, getProvider(network));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"weth9-processor.js","sourceRoot":"","sources":["../../../../src/eth/builtin/internal/weth9-processor.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,mBAAmB,EAEnB,aAAa,EACb,qBAAqB,EACrB,iBAAiB,EAEjB,YAAY,EACZ,aAAa,EAEb,6BAA6B,GAE9B,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAS,cAAc,EAAE,MAAM,YAAY,CAAC;AAgFnD,MAAM,gBAAgB,GAAG,cAAc,CAAC,OAAO,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;AAEtE,MAAM,OAAO,iBAAkB,SAAQ,YAAmB;IACxD,YAAY,QAAe;QACzB,KAAK,CAAC,QAAQ,CAAC,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,SAAqB;QAC9B,IAAI;YACF,OAAO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AAM,OAAO,GAAG,6BAA6B,CAAC,gBAAgB,CAAC,CAAC;IAChE,IAAI,QAAQ,GAAG,gBAAgB,CAC7B,OAAO,EACP,OAAO,EACP,OAAO,CACa,CAAC;IACvB,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;QAC1E,QAAQ,GAAG,IAAI,iBAAiB,CAAC,WAAW,CAAC,CAAC;QAC9C,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;KACvD;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["/* Autogenerated file. Do not edit manually. */\n/* tslint:disable */\n/* eslint-disable */\nimport { Overrides } from \"ethers\";\nimport { Networkish } from \"ethers/providers\";\nimport {\n addContractByABI,\n getContractByABI,\n addProcessor,\n getProcessor,\n getProvider,\n transformEtherError,\n BindOptions,\n BaseProcessor,\n BaseProcessorTemplate,\n BoundContractView,\n ContractContext,\n ContractView,\n DummyProvider,\n TypedCallTrace,\n getNetworkFromCtxOrNetworkish,\n EthFetchConfig,\n} from \"@sentio/sdk/eth\";\nimport { BaseContext } from \"@sentio/sdk\";\n\nimport { WETH9, WETH9__factory } from \"./index.js\";\nimport {\n ApprovalEvent,\n ApprovalEventFilter,\n TransferEvent,\n TransferEventFilter,\n DepositEvent,\n DepositEventFilter,\n WithdrawalEvent,\n WithdrawalEventFilter,\n} from \"./WETH9.js\";\n\nexport interface NameCallObject {}\n\nexport type NameCallTrace = TypedCallTrace<[], NameCallObject>;\n\nexport interface ApproveCallObject {\n guy: string;\n wad: bigint;\n}\n\nexport type ApproveCallTrace = TypedCallTrace<\n [string, bigint],\n ApproveCallObject\n>;\n\nexport interface TotalSupplyCallObject {}\n\nexport type TotalSupplyCallTrace = TypedCallTrace<[], TotalSupplyCallObject>;\n\nexport interface TransferFromCallObject {\n src: string;\n dst: string;\n wad: bigint;\n}\n\nexport type TransferFromCallTrace = TypedCallTrace<\n [string, string, bigint],\n TransferFromCallObject\n>;\n\nexport interface WithdrawCallObject {\n wad: bigint;\n}\n\nexport type WithdrawCallTrace = TypedCallTrace<[bigint], WithdrawCallObject>;\n\nexport interface DecimalsCallObject {}\n\nexport type DecimalsCallTrace = TypedCallTrace<[], DecimalsCallObject>;\n\nexport interface BalanceOfCallObject {}\n\nexport type BalanceOfCallTrace = TypedCallTrace<[string], BalanceOfCallObject>;\n\nexport interface SymbolCallObject {}\n\nexport type SymbolCallTrace = TypedCallTrace<[], SymbolCallObject>;\n\nexport interface TransferCallObject {\n dst: string;\n wad: bigint;\n}\n\nexport type TransferCallTrace = TypedCallTrace<\n [string, bigint],\n TransferCallObject\n>;\n\nexport interface DepositCallObject {}\n\nexport type DepositCallTrace = TypedCallTrace<[], DepositCallObject>;\n\nexport interface AllowanceCallObject {}\n\nexport type AllowanceCallTrace = TypedCallTrace<\n [string, string],\n AllowanceCallObject\n>;\n\nconst templateContract = WETH9__factory.connect(\"0x0\", DummyProvider);\n\nexport class WETH9ContractView extends ContractView<WETH9> {\n constructor(contract: WETH9) {\n super(contract);\n }\n\n async name(overrides?: Overrides): Promise<string> {\n try {\n return await this.contract.getFunction(\"name()\")(overrides || {});\n } catch (e) {\n throw transformEtherError(e, undefined);\n }\n }\n\n async totalSupply(overrides?: Overrides): Promise<bigint> {\n try {\n return await this.contract.getFunction(\"totalSupply()\")(overrides || {});\n } catch (e) {\n throw transformEtherError(e, undefined);\n }\n }\n\n async decimals(overrides?: Overrides): Promise<bigint> {\n try {\n return await this.contract.getFunction(\"decimals()\")(overrides || {});\n } catch (e) {\n throw transformEtherError(e, undefined);\n }\n }\n\n async balanceOf(arg0: string, overrides?: Overrides): Promise<bigint> {\n try {\n return await this.contract.getFunction(\"balanceOf(address)\")(\n arg0,\n overrides || {}\n );\n } catch (e) {\n throw transformEtherError(e, undefined);\n }\n }\n\n async symbol(overrides?: Overrides): Promise<string> {\n try {\n return await this.contract.getFunction(\"symbol()\")(overrides || {});\n } catch (e) {\n throw transformEtherError(e, undefined);\n }\n }\n\n async allowance(\n arg0: string,\n arg1: string,\n overrides?: Overrides\n ): Promise<bigint> {\n try {\n return await this.contract.getFunction(\"allowance(address,address)\")(\n arg0,\n arg1,\n overrides || {}\n );\n } catch (e) {\n throw transformEtherError(e, undefined);\n }\n }\n}\n\nexport class WETH9BoundContractView extends BoundContractView<\n WETH9,\n WETH9ContractView\n> {\n async name(overrides?: Overrides): Promise<string> {\n if (!overrides && this.context) {\n overrides = {\n blockTag: this.context.blockNumber,\n };\n }\n return await this.view.name(overrides || {});\n }\n\n async totalSupply(overrides?: Overrides): Promise<bigint> {\n if (!overrides && this.context) {\n overrides = {\n blockTag: this.context.blockNumber,\n };\n }\n return await this.view.totalSupply(overrides || {});\n }\n\n async decimals(overrides?: Overrides): Promise<bigint> {\n if (!overrides && this.context) {\n overrides = {\n blockTag: this.context.blockNumber,\n };\n }\n return await this.view.decimals(overrides || {});\n }\n\n async balanceOf(arg0: string, overrides?: Overrides): Promise<bigint> {\n if (!overrides && this.context) {\n overrides = {\n blockTag: this.context.blockNumber,\n };\n }\n return await this.view.balanceOf(arg0, overrides || {});\n }\n\n async symbol(overrides?: Overrides): Promise<string> {\n if (!overrides && this.context) {\n overrides = {\n blockTag: this.context.blockNumber,\n };\n }\n return await this.view.symbol(overrides || {});\n }\n\n async allowance(\n arg0: string,\n arg1: string,\n overrides?: Overrides\n ): Promise<bigint> {\n if (!overrides && this.context) {\n overrides = {\n blockTag: this.context.blockNumber,\n };\n }\n return await this.view.allowance(arg0, arg1, overrides || {});\n }\n}\n\nexport type WETH9Context = ContractContext<WETH9, WETH9BoundContractView>;\n\nexport class WETH9Processor extends BaseProcessor<\n WETH9,\n WETH9BoundContractView\n> {\n onEventApproval(\n handler: (event: ApprovalEvent, ctx: WETH9Context) => void,\n filter?: ApprovalEventFilter | ApprovalEventFilter[],\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n if (!filter) {\n filter = templateContract.filters[\"Approval(address,address,uint256)\"](\n null,\n null,\n null\n );\n }\n return super.onEvent(handler, filter!, fetchConfig);\n }\n\n onEventTransfer(\n handler: (event: TransferEvent, ctx: WETH9Context) => void,\n filter?: TransferEventFilter | TransferEventFilter[],\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n if (!filter) {\n filter = templateContract.filters[\"Transfer(address,address,uint256)\"](\n null,\n null,\n null\n );\n }\n return super.onEvent(handler, filter!, fetchConfig);\n }\n\n onEventDeposit(\n handler: (event: DepositEvent, ctx: WETH9Context) => void,\n filter?: DepositEventFilter | DepositEventFilter[],\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n if (!filter) {\n filter = templateContract.filters[\"Deposit(address,uint256)\"](null, null);\n }\n return super.onEvent(handler, filter!, fetchConfig);\n }\n\n onEventWithdrawal(\n handler: (event: WithdrawalEvent, ctx: WETH9Context) => void,\n filter?: WithdrawalEventFilter | WithdrawalEventFilter[],\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n if (!filter) {\n filter = templateContract.filters[\"Withdrawal(address,uint256)\"](\n null,\n null\n );\n }\n return super.onEvent(handler, filter!, fetchConfig);\n }\n\n onCallName(\n handler: (call: NameCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x06fdde03\", handler as any, fetchConfig);\n }\n\n onCallApprove(\n handler: (call: ApproveCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x095ea7b3\", handler as any, fetchConfig);\n }\n\n onCallTotalSupply(\n handler: (call: TotalSupplyCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x18160ddd\", handler as any, fetchConfig);\n }\n\n onCallTransferFrom(\n handler: (call: TransferFromCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x23b872dd\", handler as any, fetchConfig);\n }\n\n onCallWithdraw(\n handler: (call: WithdrawCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x2e1a7d4d\", handler as any, fetchConfig);\n }\n\n onCallDecimals(\n handler: (call: DecimalsCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x313ce567\", handler as any, fetchConfig);\n }\n\n onCallBalanceOf(\n handler: (call: BalanceOfCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x70a08231\", handler as any, fetchConfig);\n }\n\n onCallSymbol(\n handler: (call: SymbolCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x95d89b41\", handler as any, fetchConfig);\n }\n\n onCallTransfer(\n handler: (call: TransferCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0xa9059cbb\", handler as any, fetchConfig);\n }\n\n onCallDeposit(\n handler: (call: DepositCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0xd0e30db0\", handler as any, fetchConfig);\n }\n\n onCallAllowance(\n handler: (call: AllowanceCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0xdd62ed3e\", handler as any, fetchConfig);\n }\n\n public static filters = {\n Approval(src?: string | null, guy?: string | null, wad?: null) {\n return templateContract.filters[\"Approval(address,address,uint256)\"](\n src,\n guy,\n wad\n );\n },\n Transfer(src?: string | null, dst?: string | null, wad?: null) {\n return templateContract.filters[\"Transfer(address,address,uint256)\"](\n src,\n dst,\n wad\n );\n },\n Deposit(dst?: string | null, wad?: null) {\n return templateContract.filters[\"Deposit(address,uint256)\"](dst, wad);\n },\n Withdrawal(src?: string | null, wad?: null) {\n return templateContract.filters[\"Withdrawal(address,uint256)\"](src, wad);\n },\n };\n\n protected CreateBoundContractView(): WETH9BoundContractView {\n const view = getWETH9Contract(this.config.network, this.config.address);\n return new WETH9BoundContractView(this.config.address, view);\n }\n\n public static bind(options: BindOptions): WETH9Processor {\n if (!options.name) {\n options.name = \"WETH9\";\n }\n let processor = getProcessor(options) as WETH9Processor;\n if (!processor) {\n processor = new WETH9Processor(options);\n addProcessor(options, processor);\n }\n return processor;\n }\n}\n\nexport class WETH9ProcessorTemplate extends BaseProcessorTemplate<\n WETH9,\n WETH9BoundContractView\n> {\n bindInternal(options: BindOptions) {\n if (!options.name) {\n options.name = \"WETH9\";\n }\n let processor = getProcessor(options) as WETH9Processor;\n if (!processor) {\n processor = new WETH9Processor(options);\n addProcessor(options, processor);\n }\n return processor;\n }\n\n onEventApproval(\n handler: (event: ApprovalEvent, ctx: WETH9Context) => void,\n filter?: ApprovalEventFilter | ApprovalEventFilter[],\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n if (!filter) {\n filter = templateContract.filters[\"Approval(address,address,uint256)\"](\n null,\n null,\n null\n );\n }\n return super.onEvent(handler, filter!, fetchConfig);\n }\n\n onEventTransfer(\n handler: (event: TransferEvent, ctx: WETH9Context) => void,\n filter?: TransferEventFilter | TransferEventFilter[],\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n if (!filter) {\n filter = templateContract.filters[\"Transfer(address,address,uint256)\"](\n null,\n null,\n null\n );\n }\n return super.onEvent(handler, filter!, fetchConfig);\n }\n\n onEventDeposit(\n handler: (event: DepositEvent, ctx: WETH9Context) => void,\n filter?: DepositEventFilter | DepositEventFilter[],\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n if (!filter) {\n filter = templateContract.filters[\"Deposit(address,uint256)\"](null, null);\n }\n return super.onEvent(handler, filter!, fetchConfig);\n }\n\n onEventWithdrawal(\n handler: (event: WithdrawalEvent, ctx: WETH9Context) => void,\n filter?: WithdrawalEventFilter | WithdrawalEventFilter[],\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n if (!filter) {\n filter = templateContract.filters[\"Withdrawal(address,uint256)\"](\n null,\n null\n );\n }\n return super.onEvent(handler, filter!, fetchConfig);\n }\n}\n\nexport function getWETH9Contract(\n contextOrNetwork: BaseContext | Networkish,\n address: string\n): WETH9ContractView {\n const network = getNetworkFromCtxOrNetworkish(contextOrNetwork);\n let contract = getContractByABI(\n \"WETH9\",\n address,\n network\n ) as WETH9ContractView;\n if (!contract) {\n const rawContract = WETH9__factory.connect(address, getProvider(network));\n contract = new WETH9ContractView(rawContract);\n addContractByABI(\"WETH9\", address, network, contract);\n }\n return contract;\n}\n"]}
|
1
|
+
{"version":3,"file":"weth9-processor.js","sourceRoot":"","sources":["../../../../src/eth/builtin/internal/weth9-processor.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,mBAAmB,EAEnB,aAAa,EACb,qBAAqB,EACrB,iBAAiB,EAEjB,YAAY,EACZ,aAAa,EAGb,aAAa,GAGd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAS,cAAc,EAAE,MAAM,YAAY,CAAC;AAgFnD,MAAM,gBAAgB,GAAG,cAAc,CAAC,OAAO,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;AAEtE,MAAM,OAAO,iBAAkB,SAAQ,YAAmB;IACxD,YAAY,QAAe;QACzB,KAAK,CAAC,QAAQ,CAAC,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,SAAqB;QAC9B,IAAI;YACF,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;SACnE;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,mBAAmB,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;SACzC;IAC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CAAC,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;QAC1E,QAAQ,GAAG,IAAI,iBAAiB,CAAC,WAAW,CAAC,CAAC;QAC9C,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;KACvD;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["/* Autogenerated file. Do not edit manually. */\n/* tslint:disable */\n/* eslint-disable */\nimport { Overrides } from \"ethers\";\nimport {\n addContractByABI,\n getContractByABI,\n addProcessor,\n getProcessor,\n getProvider,\n transformEtherError,\n BindOptions,\n BaseProcessor,\n BaseProcessorTemplate,\n BoundContractView,\n ContractContext,\n ContractView,\n DummyProvider,\n EthChainId,\n TypedCallTrace,\n getEthChainId,\n EthContext,\n EthFetchConfig,\n} from \"@sentio/sdk/eth\";\n\nimport { WETH9, WETH9__factory } from \"./index.js\";\nimport {\n ApprovalEvent,\n ApprovalEventFilter,\n TransferEvent,\n TransferEventFilter,\n DepositEvent,\n DepositEventFilter,\n WithdrawalEvent,\n WithdrawalEventFilter,\n} from \"./WETH9.js\";\n\nexport interface NameCallObject {}\n\nexport type NameCallTrace = TypedCallTrace<[], NameCallObject>;\n\nexport interface ApproveCallObject {\n guy: string;\n wad: bigint;\n}\n\nexport type ApproveCallTrace = TypedCallTrace<\n [string, bigint],\n ApproveCallObject\n>;\n\nexport interface TotalSupplyCallObject {}\n\nexport type TotalSupplyCallTrace = TypedCallTrace<[], TotalSupplyCallObject>;\n\nexport interface TransferFromCallObject {\n src: string;\n dst: string;\n wad: bigint;\n}\n\nexport type TransferFromCallTrace = TypedCallTrace<\n [string, string, bigint],\n TransferFromCallObject\n>;\n\nexport interface WithdrawCallObject {\n wad: bigint;\n}\n\nexport type WithdrawCallTrace = TypedCallTrace<[bigint], WithdrawCallObject>;\n\nexport interface DecimalsCallObject {}\n\nexport type DecimalsCallTrace = TypedCallTrace<[], DecimalsCallObject>;\n\nexport interface BalanceOfCallObject {}\n\nexport type BalanceOfCallTrace = TypedCallTrace<[string], BalanceOfCallObject>;\n\nexport interface SymbolCallObject {}\n\nexport type SymbolCallTrace = TypedCallTrace<[], SymbolCallObject>;\n\nexport interface TransferCallObject {\n dst: string;\n wad: bigint;\n}\n\nexport type TransferCallTrace = TypedCallTrace<\n [string, bigint],\n TransferCallObject\n>;\n\nexport interface DepositCallObject {}\n\nexport type DepositCallTrace = TypedCallTrace<[], DepositCallObject>;\n\nexport interface AllowanceCallObject {}\n\nexport type AllowanceCallTrace = TypedCallTrace<\n [string, string],\n AllowanceCallObject\n>;\n\nconst templateContract = WETH9__factory.connect(\"0x0\", DummyProvider);\n\nexport class WETH9ContractView extends ContractView<WETH9> {\n constructor(contract: WETH9) {\n super(contract);\n }\n\n async name(overrides?: Overrides): Promise<string> {\n try {\n return await this.contract.getFunction(\"name()\")(overrides || {});\n } catch (e) {\n throw transformEtherError(e, undefined);\n }\n }\n\n async totalSupply(overrides?: Overrides): Promise<bigint> {\n try {\n return await this.contract.getFunction(\"totalSupply()\")(overrides || {});\n } catch (e) {\n throw transformEtherError(e, undefined);\n }\n }\n\n async decimals(overrides?: Overrides): Promise<bigint> {\n try {\n return await this.contract.getFunction(\"decimals()\")(overrides || {});\n } catch (e) {\n throw transformEtherError(e, undefined);\n }\n }\n\n async balanceOf(arg0: string, overrides?: Overrides): Promise<bigint> {\n try {\n return await this.contract.getFunction(\"balanceOf(address)\")(\n arg0,\n overrides || {}\n );\n } catch (e) {\n throw transformEtherError(e, undefined);\n }\n }\n\n async symbol(overrides?: Overrides): Promise<string> {\n try {\n return await this.contract.getFunction(\"symbol()\")(overrides || {});\n } catch (e) {\n throw transformEtherError(e, undefined);\n }\n }\n\n async allowance(\n arg0: string,\n arg1: string,\n overrides?: Overrides\n ): Promise<bigint> {\n try {\n return await this.contract.getFunction(\"allowance(address,address)\")(\n arg0,\n arg1,\n overrides || {}\n );\n } catch (e) {\n throw transformEtherError(e, undefined);\n }\n }\n}\n\nexport class WETH9BoundContractView extends BoundContractView<\n WETH9,\n WETH9ContractView\n> {\n async name(overrides?: Overrides): Promise<string> {\n if (!overrides && this.context) {\n overrides = {\n blockTag: this.context.blockNumber,\n };\n }\n return await this.view.name(overrides || {});\n }\n\n async totalSupply(overrides?: Overrides): Promise<bigint> {\n if (!overrides && this.context) {\n overrides = {\n blockTag: this.context.blockNumber,\n };\n }\n return await this.view.totalSupply(overrides || {});\n }\n\n async decimals(overrides?: Overrides): Promise<bigint> {\n if (!overrides && this.context) {\n overrides = {\n blockTag: this.context.blockNumber,\n };\n }\n return await this.view.decimals(overrides || {});\n }\n\n async balanceOf(arg0: string, overrides?: Overrides): Promise<bigint> {\n if (!overrides && this.context) {\n overrides = {\n blockTag: this.context.blockNumber,\n };\n }\n return await this.view.balanceOf(arg0, overrides || {});\n }\n\n async symbol(overrides?: Overrides): Promise<string> {\n if (!overrides && this.context) {\n overrides = {\n blockTag: this.context.blockNumber,\n };\n }\n return await this.view.symbol(overrides || {});\n }\n\n async allowance(\n arg0: string,\n arg1: string,\n overrides?: Overrides\n ): Promise<bigint> {\n if (!overrides && this.context) {\n overrides = {\n blockTag: this.context.blockNumber,\n };\n }\n return await this.view.allowance(arg0, arg1, overrides || {});\n }\n}\n\nexport type WETH9Context = ContractContext<WETH9, WETH9BoundContractView>;\n\nexport class WETH9Processor extends BaseProcessor<\n WETH9,\n WETH9BoundContractView\n> {\n onEventApproval(\n handler: (event: ApprovalEvent, ctx: WETH9Context) => void,\n filter?: ApprovalEventFilter | ApprovalEventFilter[],\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n if (!filter) {\n filter = templateContract.filters[\"Approval(address,address,uint256)\"](\n null,\n null,\n null\n );\n }\n return super.onEvent(handler, filter!, fetchConfig);\n }\n\n onEventTransfer(\n handler: (event: TransferEvent, ctx: WETH9Context) => void,\n filter?: TransferEventFilter | TransferEventFilter[],\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n if (!filter) {\n filter = templateContract.filters[\"Transfer(address,address,uint256)\"](\n null,\n null,\n null\n );\n }\n return super.onEvent(handler, filter!, fetchConfig);\n }\n\n onEventDeposit(\n handler: (event: DepositEvent, ctx: WETH9Context) => void,\n filter?: DepositEventFilter | DepositEventFilter[],\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n if (!filter) {\n filter = templateContract.filters[\"Deposit(address,uint256)\"](null, null);\n }\n return super.onEvent(handler, filter!, fetchConfig);\n }\n\n onEventWithdrawal(\n handler: (event: WithdrawalEvent, ctx: WETH9Context) => void,\n filter?: WithdrawalEventFilter | WithdrawalEventFilter[],\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n if (!filter) {\n filter = templateContract.filters[\"Withdrawal(address,uint256)\"](\n null,\n null\n );\n }\n return super.onEvent(handler, filter!, fetchConfig);\n }\n\n onCallName(\n handler: (call: NameCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x06fdde03\", handler as any, fetchConfig);\n }\n\n onCallApprove(\n handler: (call: ApproveCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x095ea7b3\", handler as any, fetchConfig);\n }\n\n onCallTotalSupply(\n handler: (call: TotalSupplyCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x18160ddd\", handler as any, fetchConfig);\n }\n\n onCallTransferFrom(\n handler: (call: TransferFromCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x23b872dd\", handler as any, fetchConfig);\n }\n\n onCallWithdraw(\n handler: (call: WithdrawCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x2e1a7d4d\", handler as any, fetchConfig);\n }\n\n onCallDecimals(\n handler: (call: DecimalsCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x313ce567\", handler as any, fetchConfig);\n }\n\n onCallBalanceOf(\n handler: (call: BalanceOfCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x70a08231\", handler as any, fetchConfig);\n }\n\n onCallSymbol(\n handler: (call: SymbolCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x95d89b41\", handler as any, fetchConfig);\n }\n\n onCallTransfer(\n handler: (call: TransferCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0xa9059cbb\", handler as any, fetchConfig);\n }\n\n onCallDeposit(\n handler: (call: DepositCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0xd0e30db0\", handler as any, fetchConfig);\n }\n\n onCallAllowance(\n handler: (call: AllowanceCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0xdd62ed3e\", handler as any, fetchConfig);\n }\n\n public static filters = {\n Approval(src?: string | null, guy?: string | null, wad?: null) {\n return templateContract.filters[\"Approval(address,address,uint256)\"](\n src,\n guy,\n wad\n );\n },\n Transfer(src?: string | null, dst?: string | null, wad?: null) {\n return templateContract.filters[\"Transfer(address,address,uint256)\"](\n src,\n dst,\n wad\n );\n },\n Deposit(dst?: string | null, wad?: null) {\n return templateContract.filters[\"Deposit(address,uint256)\"](dst, wad);\n },\n Withdrawal(src?: string | null, wad?: null) {\n return templateContract.filters[\"Withdrawal(address,uint256)\"](src, wad);\n },\n };\n\n protected CreateBoundContractView(): WETH9BoundContractView {\n const view = getWETH9Contract(this.config.network, this.config.address);\n return new WETH9BoundContractView(this.config.address, view);\n }\n\n public static bind(options: BindOptions): WETH9Processor {\n if (!options.name) {\n options.name = \"WETH9\";\n }\n let processor = getProcessor(options) as WETH9Processor;\n if (!processor) {\n processor = new WETH9Processor(options);\n addProcessor(options, processor);\n }\n return processor;\n }\n}\n\nexport class WETH9ProcessorTemplate extends BaseProcessorTemplate<\n WETH9,\n WETH9BoundContractView\n> {\n bindInternal(options: BindOptions) {\n if (!options.name) {\n options.name = \"WETH9\";\n }\n let processor = getProcessor(options) as WETH9Processor;\n if (!processor) {\n processor = new WETH9Processor(options);\n addProcessor(options, processor);\n }\n return processor;\n }\n\n onEventApproval(\n handler: (event: ApprovalEvent, ctx: WETH9Context) => void,\n filter?: ApprovalEventFilter | ApprovalEventFilter[],\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n if (!filter) {\n filter = templateContract.filters[\"Approval(address,address,uint256)\"](\n null,\n null,\n null\n );\n }\n return super.onEvent(handler, filter!, fetchConfig);\n }\n\n onEventTransfer(\n handler: (event: TransferEvent, ctx: WETH9Context) => void,\n filter?: TransferEventFilter | TransferEventFilter[],\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n if (!filter) {\n filter = templateContract.filters[\"Transfer(address,address,uint256)\"](\n null,\n null,\n null\n );\n }\n return super.onEvent(handler, filter!, fetchConfig);\n }\n\n onEventDeposit(\n handler: (event: DepositEvent, ctx: WETH9Context) => void,\n filter?: DepositEventFilter | DepositEventFilter[],\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n if (!filter) {\n filter = templateContract.filters[\"Deposit(address,uint256)\"](null, null);\n }\n return super.onEvent(handler, filter!, fetchConfig);\n }\n\n onEventWithdrawal(\n handler: (event: WithdrawalEvent, ctx: WETH9Context) => void,\n filter?: WithdrawalEventFilter | WithdrawalEventFilter[],\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n if (!filter) {\n filter = templateContract.filters[\"Withdrawal(address,uint256)\"](\n null,\n null\n );\n }\n return super.onEvent(handler, filter!, fetchConfig);\n }\n}\n\nexport function getWETH9Contract(\n contextOrNetwork: EthContext | EthChainId,\n address: string\n): WETH9ContractView {\n const network = getEthChainId(contextOrNetwork);\n let contract = getContractByABI(\n \"WETH9\",\n address,\n network\n ) as WETH9ContractView;\n if (!contract) {\n const rawContract = WETH9__factory.connect(address, getProvider(network));\n contract = new WETH9ContractView(rawContract);\n addContractByABI(\"WETH9\", address, network, contract);\n }\n return contract;\n}\n"]}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { EthChainId } from "@sentio/sdk/eth";
|
1
2
|
import { getWETH9Contract } from "./weth9-processor.js";
|
2
3
|
const mockField = {
|
3
4
|
blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
|
@@ -8,7 +9,7 @@ const mockField = {
|
|
8
9
|
transactionIndex: 0,
|
9
10
|
};
|
10
11
|
export function mockApprovalLog(contractAddress, event) {
|
11
|
-
const contract = getWETH9Contract(
|
12
|
+
const contract = getWETH9Contract(EthChainId.ETHEREUM, contractAddress);
|
12
13
|
const encodedLog = contract.rawContract.interface.encodeEventLog("Approval(address,address,uint256)", [event.src, event.guy, event.wad]);
|
13
14
|
return {
|
14
15
|
...mockField,
|
@@ -19,7 +20,7 @@ export function mockApprovalLog(contractAddress, event) {
|
|
19
20
|
};
|
20
21
|
}
|
21
22
|
export function mockTransferLog(contractAddress, event) {
|
22
|
-
const contract = getWETH9Contract(
|
23
|
+
const contract = getWETH9Contract(EthChainId.ETHEREUM, contractAddress);
|
23
24
|
const encodedLog = contract.rawContract.interface.encodeEventLog("Transfer(address,address,uint256)", [event.src, event.dst, event.wad]);
|
24
25
|
return {
|
25
26
|
...mockField,
|
@@ -30,7 +31,7 @@ export function mockTransferLog(contractAddress, event) {
|
|
30
31
|
};
|
31
32
|
}
|
32
33
|
export function mockDepositLog(contractAddress, event) {
|
33
|
-
const contract = getWETH9Contract(
|
34
|
+
const contract = getWETH9Contract(EthChainId.ETHEREUM, contractAddress);
|
34
35
|
const encodedLog = contract.rawContract.interface.encodeEventLog("Deposit(address,uint256)", [event.dst, event.wad]);
|
35
36
|
return {
|
36
37
|
...mockField,
|
@@ -41,7 +42,7 @@ export function mockDepositLog(contractAddress, event) {
|
|
41
42
|
};
|
42
43
|
}
|
43
44
|
export function mockWithdrawalLog(contractAddress, event) {
|
44
|
-
const contract = getWETH9Contract(
|
45
|
+
const contract = getWETH9Contract(EthChainId.ETHEREUM, contractAddress);
|
45
46
|
const encodedLog = contract.rawContract.interface.encodeEventLog("Withdrawal(address,uint256)", [event.src, event.wad]);
|
46
47
|
return {
|
47
48
|
...mockField,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"weth9-test-utils.js","sourceRoot":"","sources":["../../../../src/eth/builtin/internal/weth9-test-utils.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"weth9-test-utils.js","sourceRoot":"","sources":["../../../../src/eth/builtin/internal/weth9-test-utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAO7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,MAAM,SAAS,GAAG;IAChB,SAAS,EACP,oEAAoE;IACtE,WAAW,EAAE,CAAC;IACd,QAAQ,EAAE,CAAC;IACX,OAAO,EAAE,KAAK;IACd,eAAe,EACb,oEAAoE;IACtE,gBAAgB,EAAE,CAAC;CACpB,CAAC;AAEF,MAAM,UAAU,eAAe,CAC7B,eAAuB,EACvB,KAA0B;IAE1B,MAAM,QAAQ,GAAG,gBAAgB,CAAC,UAAU,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;IACxE,MAAM,UAAU,GAAG,QAAQ,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAC9D,mCAAmC,EACnC,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,CAClC,CAAC;IACF,OAAO;QACL,GAAG,SAAS;QACZ,KAAK,EAAE,CAAC;QACR,OAAO,EAAE,eAAe;QACxB,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,MAAM,E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AAK,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,CACvB,CAAC;IACF,OAAO;QACL,GAAG,SAAS;QACZ,KAAK,EAAE,CAAC;QACR,OAAO,EAAE,eAAe;QACxB,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,MAAM,EAAE,UAAU,CAAC,MAAM;KAC1B,CAAC;AACJ,CAAC","sourcesContent":["/* Autogenerated file. Do not edit manually. */\n/* tslint:disable */\n/* eslint-disable */\nimport { LogParams } from \"ethers/providers\";\nimport { EthChainId } from \"@sentio/sdk/eth\";\nimport {\n ApprovalEventObject,\n TransferEventObject,\n DepositEventObject,\n WithdrawalEventObject,\n} from \"./WETH9.js\";\nimport { getWETH9Contract } from \"./weth9-processor.js\";\nconst mockField = {\n blockHash:\n \"0x0000000000000000000000000000000000000000000000000000000000000000\",\n blockNumber: 0,\n logIndex: 0,\n removed: false,\n transactionHash:\n \"0x0000000000000000000000000000000000000000000000000000000000000000\",\n transactionIndex: 0,\n};\n\nexport function mockApprovalLog(\n contractAddress: string,\n event: ApprovalEventObject\n): LogParams {\n const contract = getWETH9Contract(EthChainId.ETHEREUM, contractAddress);\n const encodedLog = contract.rawContract.interface.encodeEventLog(\n \"Approval(address,address,uint256)\",\n [event.src, event.guy, event.wad]\n );\n return {\n ...mockField,\n index: 0,\n address: contractAddress,\n data: encodedLog.data,\n topics: encodedLog.topics,\n };\n}\n\nexport function mockTransferLog(\n contractAddress: string,\n event: TransferEventObject\n): LogParams {\n const contract = getWETH9Contract(EthChainId.ETHEREUM, contractAddress);\n const encodedLog = contract.rawContract.interface.encodeEventLog(\n \"Transfer(address,address,uint256)\",\n [event.src, event.dst, event.wad]\n );\n return {\n ...mockField,\n index: 0,\n address: contractAddress,\n data: encodedLog.data,\n topics: encodedLog.topics,\n };\n}\n\nexport function mockDepositLog(\n contractAddress: string,\n event: DepositEventObject\n): LogParams {\n const contract = getWETH9Contract(EthChainId.ETHEREUM, contractAddress);\n const encodedLog = contract.rawContract.interface.encodeEventLog(\n \"Deposit(address,uint256)\",\n [event.dst, event.wad]\n );\n return {\n ...mockField,\n index: 0,\n address: contractAddress,\n data: encodedLog.data,\n topics: encodedLog.topics,\n };\n}\n\nexport function mockWithdrawalLog(\n contractAddress: string,\n event: WithdrawalEventObject\n): LogParams {\n const contract = getWETH9Contract(EthChainId.ETHEREUM, contractAddress);\n const encodedLog = contract.rawContract.interface.encodeEventLog(\n \"Withdrawal(address,uint256)\",\n [event.src, event.wad]\n );\n return {\n ...mockField,\n index: 0,\n address: contractAddress,\n data: encodedLog.data,\n topics: encodedLog.topics,\n };\n}\n"]}
|
@@ -2,6 +2,7 @@ import Ethers from '@sentio/ethers-v6';
|
|
2
2
|
import { extractAbi, extractDocumentation, parse, shortenFullJsonFilePath, } from 'typechain';
|
3
3
|
import { dirname, join, relative } from 'path';
|
4
4
|
import { codeGenIndex, codeGenSentioFile, codeGenTestUtilsFile } from './file.js';
|
5
|
+
import { EthChainId } from '../../core/chain.js';
|
5
6
|
export default class EthersSentio extends Ethers.default {
|
6
7
|
constructor(config) {
|
7
8
|
if (!config.outDir) {
|
@@ -75,15 +76,21 @@ export default class EthersSentio extends Ethers.default {
|
|
75
76
|
const contractsToGenExample = this.cfg.contractsToGenExample;
|
76
77
|
if (contractsToGenExample.length > 0) {
|
77
78
|
const processors = this.processedABIs.map((abi) => `${abi.name}Processor`).join(',');
|
78
|
-
let exampleContent = `
|
79
|
+
let exampleContent = `
|
80
|
+
import { EthChainId } from '@sentio/sdk/eth'
|
81
|
+
import { ${processors} } from './types/eth/index.js'`;
|
82
|
+
const ethChainIdValues = new Map();
|
83
|
+
for (const [key, value] of Object.entries(EthChainId)) {
|
84
|
+
ethChainIdValues.set(value, key);
|
85
|
+
}
|
79
86
|
for (const contract of contractsToGenExample) {
|
80
|
-
const
|
81
|
-
if (
|
87
|
+
const chainKey = ethChainIdValues.get(contract.chain);
|
88
|
+
if (!chainKey) {
|
82
89
|
continue;
|
83
90
|
}
|
84
91
|
const content = `
|
85
92
|
|
86
|
-
${contract.name}Processor.bind({ address: '${contract.address}', network:
|
93
|
+
${contract.name}Processor.bind({ address: '${contract.address}', network: EthChainId.${chainKey} })
|
87
94
|
.onAllEvents((evt, ctx) => {
|
88
95
|
ctx.meter.Counter('event_count').add(1, { name: evt.name })
|
89
96
|
ctx.eventLogger.emit(evt.name, {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ethers-sentio.js","sourceRoot":"","sources":["../../../src/eth/codegen/ethers-sentio.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAA;AACtC,OAAO,EAEL,UAAU,EACV,oBAAoB,EAEpB,KAAK,EACL,uBAAuB,GAExB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;
|
1
|
+
{"version":3,"file":"ethers-sentio.js","sourceRoot":"","sources":["../../../src/eth/codegen/ethers-sentio.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAA;AACtC,OAAO,EAEL,UAAU,EACV,oBAAoB,EAEpB,KAAK,EACL,uBAAuB,GAExB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAEjF,OAAO,EAAW,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAMzD,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,MAAM,CAAC,OAAO;IACtD,YAAY,MAA0B;QACpC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YAClB,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAA;SAC/C;QACD,KAAK,CAAC,MAA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A8B,QAAQ,CAAC,OAAO,0BAA0B,QAAQ;;;;;;;;;;;;;;;;;CAiB9F,CAAA;gBACO,cAAc,IAAI,OAAO,CAAA;aAC1B;YAED,KAAK,CAAC,IAAI,CAAC;gBACT,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,0BAA0B,CAAC;gBAC/C,QAAQ,EAAE,cAAc;aACzB,CAAC,CAAA;SACH;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF;AAED,MAAM,cAAc,GAAG;;;;;;CAMtB,CAAA","sourcesContent":["import Ethers from '@sentio/ethers-v6'\nimport {\n Config,\n extractAbi,\n extractDocumentation,\n FileDescription,\n parse,\n shortenFullJsonFilePath,\n Contract,\n} from 'typechain'\nimport { dirname, join, relative } from 'path'\nimport { codeGenIndex, codeGenSentioFile, codeGenTestUtilsFile } from './file.js'\nimport { YamlContractConfig } from '../../core/yaml-contract-config.js'\nimport { ChainId, EthChainId } from '../../core/chain.js'\n\nexport interface SentioEthersConfig extends Config {\n contractsToGenExample: YamlContractConfig[]\n}\n\nexport default class EthersSentio extends Ethers.default {\n constructor(config: SentioEthersConfig) {\n if (!config.outDir) {\n throw new Error('Out put path not specificed')\n }\n super(config)\n }\n\n private processedABIs: Contract[] = []\n\n // TODO(pc): also have to override transformBinFile, transformFile\n override transformAbiOrFullJsonFile(file: FileDescription): FileDescription[] | void {\n const abi = extractAbi(file.contents)\n if (abi.length === 0) {\n return\n }\n\n const documentation = extractDocumentation(file.contents)\n\n const jsonPath = relative(this.cfg.inputDir, shortenFullJsonFilePath(file.path, this.cfg.allFiles))\n const contract = parse(abi, jsonPath, documentation)\n const files = super.transformAbiOrFullJsonFile(file)\n this.processedABIs.push(contract)\n\n if (files !== undefined) {\n // files.forEach(this.transformFilePath)\n // for (const file of files) {\n // this.transformFilePath(file)\n // }\n\n return [\n ...files,\n {\n path: join(dirname(files[0].path), `${contract.name.toLowerCase()}-processor.ts`),\n contents: codeGenSentioFile(contract),\n },\n {\n path: join(dirname(files[0].path), '..', `${contract.name.toLowerCase()}.ts`),\n contents: codeGenIndex(contract),\n },\n {\n path: join(dirname(files[0].path), `${contract.name.toLowerCase()}-test-utils.ts`),\n contents: codeGenTestUtilsFile(contract),\n },\n ]\n }\n }\n\n override afterRun() {\n const commonPath = join('internal', 'common.ts')\n const files = super.afterRun()\n for (const [idx, file] of files.entries()) {\n if (file.path.endsWith('__factory.ts')) {\n file.contents = '// @ts-nocheck\\n' + file.contents\n } else if (file.path.endsWith(join('factories', 'index.ts'))) {\n file.contents = file.contents.replaceAll(\"__factory'\", \"__factory.js'\")\n } else if (file.path.endsWith('_processor.ts')) {\n } else if (file.path.endsWith(commonPath)) {\n file.contents = COMMON_CONTENT\n }\n }\n\n let indexContent = ''\n for (const contract of this.processedABIs) {\n const content = `\n export * as ${contract.name.toLowerCase().replaceAll('-', '_')} from './${contract.name.toLowerCase()}.js'\n export { ${contract.name}Processor, ${\n contract.name\n }ProcessorTemplate } from './${contract.name.toLowerCase()}.js'\n `\n indexContent += content\n }\n files.push({\n path: join(dirname(files[0].path), '../index.ts'),\n contents: indexContent,\n })\n\n const rootDir = join(dirname(files[0].path), '../../..')\n\n const contractsToGenExample = (this.cfg as SentioEthersConfig).contractsToGenExample\n if (contractsToGenExample.length > 0) {\n const processors = this.processedABIs.map((abi) => `${abi.name}Processor`).join(',')\n let exampleContent = `\n import { EthChainId } from '@sentio/sdk/eth' \n import { ${processors} } from './types/eth/index.js'`\n\n const ethChainIdValues = new Map<ChainId, string>()\n for (const [key, value] of Object.entries(EthChainId)) {\n ethChainIdValues.set(value, key)\n }\n\n for (const contract of contractsToGenExample) {\n const chainKey = ethChainIdValues.get(contract.chain)\n if (!chainKey) {\n continue\n }\n const content = `\n\n${contract.name}Processor.bind({ address: '${contract.address}', network: EthChainId.${chainKey} })\n .onAllEvents((evt, ctx) => {\n ctx.meter.Counter('event_count').add(1, { name: evt.name })\n ctx.eventLogger.emit(evt.name, {\n ...evt.args.toObject(),\n })\n})\n .onAllTraces(function (trace, ctx) {\n const succeed = trace.error === undefined\n ctx.meter.Counter('trace_count').add(1, { name: trace.name, success: String(succeed) })\n if (succeed) {\n ctx.eventLogger.emit(trace.name, {\n distinctId: trace.action.from,\n ...trace.args.toObject(),\n })\n }\n })\n`\n exampleContent += content\n }\n\n files.push({\n path: join(rootDir, 'processor.eth.example.ts'),\n contents: exampleContent,\n })\n }\n return files\n }\n}\n\nconst COMMON_CONTENT = `/* Autogenerated file. Do not edit manually. */\n/* tslint:disable */\n/* eslint-disable */\n\nexport type { TypedEvent, TypedEventFilter } from \"@sentio/sdk/eth\"\nexport type { PromiseOrValue } from '@sentio/sdk/core'\n`\n"]}
|
package/lib/eth/codegen/file.js
CHANGED
@@ -95,8 +95,8 @@ export class ${contract.name}ProcessorTemplate extends BaseProcessorTemplate<${c
|
|
95
95
|
.join('\n')}
|
96
96
|
}
|
97
97
|
|
98
|
-
export function get${contract.name}Contract(contextOrNetwork:
|
99
|
-
const network =
|
98
|
+
export function get${contract.name}Contract(contextOrNetwork: EthContext | EthChainId, address: string): ${contract.name}ContractView {
|
99
|
+
const network = getEthChainId(contextOrNetwork)
|
100
100
|
let contract = getContractByABI("${contract.name}", address, network) as ${contract.name}ContractView
|
101
101
|
if (!contract) {
|
102
102
|
const rawContract = ${contract.name}__factory.connect(address, getProvider(network))
|
@@ -134,7 +134,7 @@ export class ${contract.name}ProcessorTemplate extends BaseProcessorTemplate<${c
|
|
134
134
|
const uniqueStructImports = [...new Set(structImports)];
|
135
135
|
const imports = createImportsForUsedIdentifiers({
|
136
136
|
ethers: ['BigNumberish', 'Overrides', 'BytesLike'],
|
137
|
-
'ethers/providers': ['Networkish'],
|
137
|
+
// 'ethers/providers': ['Networkish'],
|
138
138
|
'@sentio/sdk/eth': [
|
139
139
|
'addContractByABI',
|
140
140
|
'getContractByABI',
|
@@ -150,12 +150,14 @@ export class ${contract.name}ProcessorTemplate extends BaseProcessorTemplate<${c
|
|
150
150
|
'ContractContext',
|
151
151
|
'ContractView',
|
152
152
|
'DummyProvider',
|
153
|
+
'EthChainId',
|
153
154
|
'TypedCallTrace',
|
154
|
-
'
|
155
|
+
'getEthChainId',
|
155
156
|
// 'toBlockTag',
|
157
|
+
'EthContext',
|
156
158
|
'EthFetchConfig',
|
157
159
|
],
|
158
|
-
'@sentio/sdk': ['BaseContext'],
|
160
|
+
// '@sentio/sdk/eth': ['BaseContext'],
|
159
161
|
// '@sentio/protos': ['EthFetchConfig'],
|
160
162
|
'./common.js': ['PromiseOrValue'],
|
161
163
|
'./index.js': [`${contract.name}`, `${contract.name}__factory`],
|
@@ -188,6 +190,7 @@ export function codeGenTestUtilsFile(contract) {
|
|
188
190
|
`;
|
189
191
|
const possibleImports = {
|
190
192
|
'ethers/providers': ['LogParams'],
|
193
|
+
'@sentio/sdk/eth': ['EthChainId'],
|
191
194
|
};
|
192
195
|
possibleImports[`./${contract.name}.js`] = Object.values(contract.events).flatMap((events) => {
|
193
196
|
if (events.length === 1) {
|
@@ -209,7 +212,7 @@ function generateMockEventLogFunction(event, contractName, includeArgTypes) {
|
|
209
212
|
const eventArgs = event.inputs.map((input, i) => `event.${input.name ?? `arg${i.toString()}`}`);
|
210
213
|
return `
|
211
214
|
export function mock${eventName}Log(contractAddress: string, event: ${eventName}EventObject): LogParams {
|
212
|
-
const contract = get${contractName}Contract(
|
215
|
+
const contract = get${contractName}Contract(EthChainId.ETHEREUM, contractAddress)
|
213
216
|
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
214
217
|
'${getFullSignatureForEvent(event)}',
|
215
218
|
[${eventArgs.join(', ')}]
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../../src/eth/codegen/file.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,+BAA+B,EAE/B,gCAAgC,EAChC,wBAAwB,GACzB,MAAM,WAAW,CAAA;AAElB,OAAO,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAA;AACtF,OAAO,EAAE,qBAAqB,E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AU,CAAC,CAAA;IAElG,MAAM,OAAO,GAAG,+BAA+B,CAAC,eAAe,EAAE,MAAM,CAAC,CAAA;IAExE,OAAO,OAAO,GAAG,MAAM,CAAA;AACzB,CAAC;AAED,SAAS,4BAA4B,CAAC,KAAuB,EAAE,YAAoB,EAAE,eAAwB;IAC3G,IAAI,SAAS,GAAG,KAAK,CAAC,IAAI,CAAA;IAC1B,IAAI,eAAe,EAAE;QACnB,SAAS,GAAG,gCAAgC,CAAC,KAAK,CAAC,GAAG,GAAG,CAAA;KAC1D;IAED,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,SAAS,KAAK,CAAC,IAAI,IAAI,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAA;IAE/F,OAAO;0BACiB,SAAS,uCAAuC,SAAS;4BACvD,YAAY;;WAE7B,wBAAwB,CAAC,KAAK,CAAC;WAC/B,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;;;;;;GAU5B,CAAA;AACH,CAAC","sourcesContent":["import {\n Contract,\n createImportsForUsedIdentifiers,\n EventDeclaration,\n getFullSignatureAsSymbolForEvent,\n getFullSignatureForEvent,\n} from 'typechain'\n\nimport { reservedKeywords } from '@sentio/ethers-v6/dist/codegen/reserved-keywords.js'\nimport { codegenCallTraceTypes, generateCallHandlers } from './functions-handler.js'\nimport { generateEventFilters, generateEventHandlers } from './event-handler.js'\nimport { generateBoundViewFunctions, generateViewFunctions } from './view-function.js'\n\nexport function codeGenIndex(contract: Contract): string {\n return ` \n export * from './internal/${contract.name.toLowerCase()}-processor.js'\n export * from './internal/${contract.name.toLowerCase()}-test-utils.js'\n export * from './internal/${contract.name}.js'\n export * from './internal/factories/${contract.name}__factory.js'\n `\n}\n\nexport function codeGenSentioFile(contract: Contract): string {\n const source = `\n ${Object.values(contract.functions).map(codegenCallTraceTypes).join('\\n')}\n\n const templateContract = ${contract.name}__factory.connect(\"0x0\", DummyProvider)\n\n export class ${contract.name}ContractView extends ContractView<${contract.name}> {\n constructor (contract: ${contract.name}) {\n super(contract);\n }\n\n ${Object.values(contract.functions)\n .filter((f) => !reservedKeywords.has(f[0].name))\n .map((fs) => generateViewFunctions(fs))\n .join('\\n')}\n }\n \n export class ${contract.name}BoundContractView extends BoundContractView<${contract.name}, \n ${contract.name}ContractView> {\n ${Object.values(contract.functions)\n .filter((f) => !reservedKeywords.has(f[0].name))\n .map((fs) => generateBoundViewFunctions(fs))\n .join('\\n')}\n }\n\n export type ${contract.name}Context = ContractContext<${contract.name}, ${contract.name}BoundContractView>\n\n export class ${contract.name}Processor extends BaseProcessor<${contract.name}, ${contract.name}BoundContractView> {\n ${Object.values(contract.events)\n .map((events) => generateEventHandlers(events, contract.name))\n .join('\\n')}\n\n ${Object.values(contract.functions)\n .map((f) => generateCallHandlers(f, contract.name))\n .join('\\n')}\n\n public static filters = {\n ${Object.values(contract.events)\n .map((events) => generateEventFilters(events))\n .join(',')}\n }\n \n protected CreateBoundContractView(): ${contract.name}BoundContractView {\n const view = get${contract.name}Contract(this.config.network, this.config.address)\n return new ${contract.name}BoundContractView(this.config.address, view)\n }\n\n public static bind(options: BindOptions): ${contract.name}Processor {\n if (!options.name) {\n options.name = \"${contract.name}\"\n }\n let processor = getProcessor(options) as ${contract.name}Processor\n if (!processor) {\n processor = new ${contract.name}Processor(options)\n addProcessor(options, processor)\n }\n return processor\n }\n}\n\nexport class ${contract.name}ProcessorTemplate extends BaseProcessorTemplate<${contract.name}, ${\n contract.name\n }BoundContractView> {\n bindInternal(options: BindOptions) {\n if (!options.name) {\n options.name = \"${contract.name}\"\n }\n let processor = getProcessor(options) as ${contract.name}Processor\n if (!processor) {\n processor = new ${contract.name}Processor(options)\n addProcessor(options, processor)\n }\n return processor\n }\n\n ${Object.values(contract.events)\n .map((events) => generateEventHandlers(events, contract.name))\n .join('\\n')}\n \n ${Object.values(contract.functions)\n .map((functions) => {\n generateCallHandlers(functions, contract.name)\n })\n .join('\\n')}\n }\n\n export function get${contract.name}Contract(contextOrNetwork: BaseContext | Networkish, address: string): ${\n contract.name\n }ContractView {\n const network = getNetworkFromCtxOrNetworkish(contextOrNetwork) \n let contract = getContractByABI(\"${contract.name}\", address, network) as ${contract.name}ContractView\n if (!contract) {\n const rawContract = ${contract.name}__factory.connect(address, getProvider(network))\n contract = new ${contract.name}ContractView(rawContract)\n addContractByABI(\"${contract.name}\", address, network, contract)\n }\n return contract\n }\n `\n const eventsImports = Object.values(contract.events).flatMap((events) => {\n if (events.length === 1) {\n return [`${events[0].name}Event`, `${events[0].name}EventFilter`]\n } else {\n return events.flatMap((e) => [\n `${getFullSignatureAsSymbolForEvent(e)}_Event`,\n `${getFullSignatureAsSymbolForEvent(e)}_EventFilter`,\n ])\n }\n })\n\n const structImports = Object.values(contract.structs).flatMap((structs) => {\n return structs.flatMap((s) => {\n if (!s.structName) {\n return []\n }\n if (s.structName.namespace) {\n return [s.structName.namespace]\n } else {\n return [s.structName.identifier + 'StructOutput', s.structName.identifier + 'Struct']\n }\n })\n })\n // dedup namespace\n const uniqueStructImports = [...new Set(structImports)]\n\n const imports = createImportsForUsedIdentifiers(\n {\n ethers: ['BigNumberish', 'Overrides', 'BytesLike'],\n 'ethers/providers': ['Networkish'],\n '@sentio/sdk/eth': [\n 'addContractByABI',\n 'getContractByABI',\n 'addProcessor',\n 'getProcessor',\n 'getProvider',\n 'transformEtherError',\n 'Trace',\n 'BindOptions',\n 'BaseProcessor',\n 'BaseProcessorTemplate',\n 'BoundContractView',\n 'ContractContext',\n 'ContractView',\n 'DummyProvider',\n 'TypedCallTrace',\n 'getNetworkFromCtxOrNetworkish',\n // 'toBlockTag',\n 'EthFetchConfig',\n ],\n '@sentio/sdk': ['BaseContext'],\n // '@sentio/protos': ['EthFetchConfig'],\n './common.js': ['PromiseOrValue'],\n './index.js': [`${contract.name}`, `${contract.name}__factory`],\n [`./${contract.name}.js`]: eventsImports.concat(uniqueStructImports),\n },\n source\n )\n\n return imports + source\n}\n\nexport function codeGenTestUtilsFile(contract: Contract): string {\n const source = `\n const mockField = {\n blockHash:\n \"0x0000000000000000000000000000000000000000000000000000000000000000\",\n blockNumber: 0,\n logIndex: 0,\n removed: false,\n transactionHash:\n \"0x0000000000000000000000000000000000000000000000000000000000000000\",\n transactionIndex: 0,\n }\n ${Object.values(contract.events)\n .map((events) => {\n if (events.length === 1) {\n return generateMockEventLogFunction(events[0], contract.name, false)\n } else {\n return events.map((e) => generateMockEventLogFunction(e, contract.name, true)).join('\\n')\n }\n })\n .join('\\n')}\n `\n\n const possibleImports = {\n 'ethers/providers': ['LogParams'],\n } as any\n possibleImports[`./${contract.name}.js`] = Object.values(contract.events).flatMap((events) => {\n if (events.length === 1) {\n return `${events[0].name}EventObject`\n } else {\n return events.flatMap((e) => `${getFullSignatureAsSymbolForEvent(e)}_EventObject`)\n }\n })\n\n possibleImports[`./${contract.name.toLowerCase()}-processor.js`] = [`get${contract.name}Contract`]\n\n const imports = createImportsForUsedIdentifiers(possibleImports, source)\n\n return imports + source\n}\n\nfunction generateMockEventLogFunction(event: EventDeclaration, contractName: string, includeArgTypes: boolean): string {\n let eventName = event.name\n if (includeArgTypes) {\n eventName = getFullSignatureAsSymbolForEvent(event) + '_'\n }\n\n const eventArgs = event.inputs.map((input, i) => `event.${input.name ?? `arg${i.toString()}`}`)\n\n return `\n export function mock${eventName}Log(contractAddress: string, event: ${eventName}EventObject): LogParams {\n const contract = get${contractName}Contract(1, contractAddress)\n const encodedLog = contract.rawContract.interface.encodeEventLog(\n '${getFullSignatureForEvent(event)}',\n [${eventArgs.join(', ')}]\n )\n return {\n ...mockField,\n index: 0,\n address: contractAddress,\n data: encodedLog.data,\n topics: encodedLog.topics,\n }\n }\n `\n}\n"]}
|
1
|
+
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../../src/eth/codegen/file.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,+BAA+B,EAE/B,gCAAgC,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AAC,CAAC,CAAA;IAEF,eAAe,CAAC,KAAK,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,eAAe,CAAC,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,UAAU,CAAC,CAAA;IAElG,MAAM,OAAO,GAAG,+BAA+B,CAAC,eAAe,EAAE,MAAM,CAAC,CAAA;IAExE,OAAO,OAAO,GAAG,MAAM,CAAA;AACzB,CAAC;AAED,SAAS,4BAA4B,CAAC,KAAuB,EAAE,YAAoB,EAAE,eAAwB;IAC3G,IAAI,SAAS,GAAG,KAAK,CAAC,IAAI,CAAA;IAC1B,IAAI,eAAe,EAAE;QACnB,SAAS,GAAG,gCAAgC,CAAC,KAAK,CAAC,GAAG,GAAG,CAAA;KAC1D;IAED,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,SAAS,KAAK,CAAC,IAAI,IAAI,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAA;IAE/F,OAAO;0BACiB,SAAS,uCAAuC,SAAS;4BACvD,YAAY;;WAE7B,wBAAwB,CAAC,KAAK,CAAC;WAC/B,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;;;;;;GAU5B,CAAA;AACH,CAAC","sourcesContent":["import {\n Contract,\n createImportsForUsedIdentifiers,\n EventDeclaration,\n getFullSignatureAsSymbolForEvent,\n getFullSignatureForEvent,\n} from 'typechain'\n\nimport { reservedKeywords } from '@sentio/ethers-v6/dist/codegen/reserved-keywords.js'\nimport { codegenCallTraceTypes, generateCallHandlers } from './functions-handler.js'\nimport { generateEventFilters, generateEventHandlers } from './event-handler.js'\nimport { generateBoundViewFunctions, generateViewFunctions } from './view-function.js'\n\nexport function codeGenIndex(contract: Contract): string {\n return ` \n export * from './internal/${contract.name.toLowerCase()}-processor.js'\n export * from './internal/${contract.name.toLowerCase()}-test-utils.js'\n export * from './internal/${contract.name}.js'\n export * from './internal/factories/${contract.name}__factory.js'\n `\n}\n\nexport function codeGenSentioFile(contract: Contract): string {\n const source = `\n ${Object.values(contract.functions).map(codegenCallTraceTypes).join('\\n')}\n\n const templateContract = ${contract.name}__factory.connect(\"0x0\", DummyProvider)\n\n export class ${contract.name}ContractView extends ContractView<${contract.name}> {\n constructor (contract: ${contract.name}) {\n super(contract);\n }\n\n ${Object.values(contract.functions)\n .filter((f) => !reservedKeywords.has(f[0].name))\n .map((fs) => generateViewFunctions(fs))\n .join('\\n')}\n }\n \n export class ${contract.name}BoundContractView extends BoundContractView<${contract.name}, \n ${contract.name}ContractView> {\n ${Object.values(contract.functions)\n .filter((f) => !reservedKeywords.has(f[0].name))\n .map((fs) => generateBoundViewFunctions(fs))\n .join('\\n')}\n }\n\n export type ${contract.name}Context = ContractContext<${contract.name}, ${contract.name}BoundContractView>\n\n export class ${contract.name}Processor extends BaseProcessor<${contract.name}, ${contract.name}BoundContractView> {\n ${Object.values(contract.events)\n .map((events) => generateEventHandlers(events, contract.name))\n .join('\\n')}\n\n ${Object.values(contract.functions)\n .map((f) => generateCallHandlers(f, contract.name))\n .join('\\n')}\n\n public static filters = {\n ${Object.values(contract.events)\n .map((events) => generateEventFilters(events))\n .join(',')}\n }\n \n protected CreateBoundContractView(): ${contract.name}BoundContractView {\n const view = get${contract.name}Contract(this.config.network, this.config.address)\n return new ${contract.name}BoundContractView(this.config.address, view)\n }\n\n public static bind(options: BindOptions): ${contract.name}Processor {\n if (!options.name) {\n options.name = \"${contract.name}\"\n }\n let processor = getProcessor(options) as ${contract.name}Processor\n if (!processor) {\n processor = new ${contract.name}Processor(options)\n addProcessor(options, processor)\n }\n return processor\n }\n}\n\nexport class ${contract.name}ProcessorTemplate extends BaseProcessorTemplate<${contract.name}, ${\n contract.name\n }BoundContractView> {\n bindInternal(options: BindOptions) {\n if (!options.name) {\n options.name = \"${contract.name}\"\n }\n let processor = getProcessor(options) as ${contract.name}Processor\n if (!processor) {\n processor = new ${contract.name}Processor(options)\n addProcessor(options, processor)\n }\n return processor\n }\n\n ${Object.values(contract.events)\n .map((events) => generateEventHandlers(events, contract.name))\n .join('\\n')}\n \n ${Object.values(contract.functions)\n .map((functions) => {\n generateCallHandlers(functions, contract.name)\n })\n .join('\\n')}\n }\n\n export function get${contract.name}Contract(contextOrNetwork: EthContext | EthChainId, address: string): ${\n contract.name\n }ContractView {\n const network = getEthChainId(contextOrNetwork) \n let contract = getContractByABI(\"${contract.name}\", address, network) as ${contract.name}ContractView\n if (!contract) {\n const rawContract = ${contract.name}__factory.connect(address, getProvider(network))\n contract = new ${contract.name}ContractView(rawContract)\n addContractByABI(\"${contract.name}\", address, network, contract)\n }\n return contract\n }\n `\n const eventsImports = Object.values(contract.events).flatMap((events) => {\n if (events.length === 1) {\n return [`${events[0].name}Event`, `${events[0].name}EventFilter`]\n } else {\n return events.flatMap((e) => [\n `${getFullSignatureAsSymbolForEvent(e)}_Event`,\n `${getFullSignatureAsSymbolForEvent(e)}_EventFilter`,\n ])\n }\n })\n\n const structImports = Object.values(contract.structs).flatMap((structs) => {\n return structs.flatMap((s) => {\n if (!s.structName) {\n return []\n }\n if (s.structName.namespace) {\n return [s.structName.namespace]\n } else {\n return [s.structName.identifier + 'StructOutput', s.structName.identifier + 'Struct']\n }\n })\n })\n // dedup namespace\n const uniqueStructImports = [...new Set(structImports)]\n\n const imports = createImportsForUsedIdentifiers(\n {\n ethers: ['BigNumberish', 'Overrides', 'BytesLike'],\n // 'ethers/providers': ['Networkish'],\n '@sentio/sdk/eth': [\n 'addContractByABI',\n 'getContractByABI',\n 'addProcessor',\n 'getProcessor',\n 'getProvider',\n 'transformEtherError',\n 'Trace',\n 'BindOptions',\n 'BaseProcessor',\n 'BaseProcessorTemplate',\n 'BoundContractView',\n 'ContractContext',\n 'ContractView',\n 'DummyProvider',\n 'EthChainId',\n 'TypedCallTrace',\n 'getEthChainId',\n // 'toBlockTag',\n 'EthContext',\n 'EthFetchConfig',\n ],\n // '@sentio/sdk/eth': ['BaseContext'],\n // '@sentio/protos': ['EthFetchConfig'],\n './common.js': ['PromiseOrValue'],\n './index.js': [`${contract.name}`, `${contract.name}__factory`],\n [`./${contract.name}.js`]: eventsImports.concat(uniqueStructImports),\n },\n source\n )\n\n return imports + source\n}\n\nexport function codeGenTestUtilsFile(contract: Contract): string {\n const source = `\n const mockField = {\n blockHash:\n \"0x0000000000000000000000000000000000000000000000000000000000000000\",\n blockNumber: 0,\n logIndex: 0,\n removed: false,\n transactionHash:\n \"0x0000000000000000000000000000000000000000000000000000000000000000\",\n transactionIndex: 0,\n }\n ${Object.values(contract.events)\n .map((events) => {\n if (events.length === 1) {\n return generateMockEventLogFunction(events[0], contract.name, false)\n } else {\n return events.map((e) => generateMockEventLogFunction(e, contract.name, true)).join('\\n')\n }\n })\n .join('\\n')}\n `\n\n const possibleImports = {\n 'ethers/providers': ['LogParams'],\n '@sentio/sdk/eth': ['EthChainId'],\n } as any\n possibleImports[`./${contract.name}.js`] = Object.values(contract.events).flatMap((events) => {\n if (events.length === 1) {\n return `${events[0].name}EventObject`\n } else {\n return events.flatMap((e) => `${getFullSignatureAsSymbolForEvent(e)}_EventObject`)\n }\n })\n\n possibleImports[`./${contract.name.toLowerCase()}-processor.js`] = [`get${contract.name}Contract`]\n\n const imports = createImportsForUsedIdentifiers(possibleImports, source)\n\n return imports + source\n}\n\nfunction generateMockEventLogFunction(event: EventDeclaration, contractName: string, includeArgTypes: boolean): string {\n let eventName = event.name\n if (includeArgTypes) {\n eventName = getFullSignatureAsSymbolForEvent(event) + '_'\n }\n\n const eventArgs = event.inputs.map((input, i) => `event.${input.name ?? `arg${i.toString()}`}`)\n\n return `\n export function mock${eventName}Log(contractAddress: string, event: ${eventName}EventObject): LogParams {\n const contract = get${contractName}Contract(EthChainId.ETHEREUM, contractAddress)\n const encodedLog = contract.rawContract.interface.encodeEventLog(\n '${getFullSignatureForEvent(event)}',\n [${eventArgs.join(', ')}]\n )\n return {\n ...mockField,\n index: 0,\n address: contractAddress,\n data: encodedLog.data,\n topics: encodedLog.topics,\n }\n }\n `\n}\n"]}
|
package/lib/eth/context.d.ts
CHANGED
@@ -4,8 +4,9 @@ import { RecordMetaData } from '@sentio/protos';
|
|
4
4
|
import { Trace } from './eth.js';
|
5
5
|
import { Labels } from '../core/index.js';
|
6
6
|
import { BaseContext } from '../core/base-context.js';
|
7
|
+
import { EthChainId } from '../core/chain.js';
|
7
8
|
export declare abstract class EthContext extends BaseContext {
|
8
|
-
chainId:
|
9
|
+
chainId: EthChainId;
|
9
10
|
address: string;
|
10
11
|
private readonly log?;
|
11
12
|
block?: BlockParams;
|
@@ -15,22 +16,22 @@ export declare abstract class EthContext extends BaseContext {
|
|
15
16
|
transaction?: TransactionResponseParams;
|
16
17
|
transactionReceipt?: TransactionReceiptParams;
|
17
18
|
timestamp: Date;
|
18
|
-
constructor(chainId:
|
19
|
+
constructor(chainId: EthChainId, address: string, timestamp?: Date, block?: BlockParams, log?: LogParams, trace?: Trace, transaction?: TransactionResponseParams, transactionReceipt?: TransactionReceiptParams, baseLabels?: Labels);
|
19
20
|
protected abstract getContractName(): string;
|
20
|
-
getChainId():
|
21
|
+
getChainId(): EthChainId;
|
21
22
|
getMetaDataInternal(name: string, labels: Labels): RecordMetaData;
|
22
23
|
}
|
23
24
|
export declare class AccountContext extends EthContext {
|
24
25
|
protected getContractName(): string;
|
25
26
|
}
|
26
27
|
export declare class GlobalContext extends EthContext {
|
27
|
-
constructor(chainId:
|
28
|
+
constructor(chainId: EthChainId, timestamp?: Date, block?: BlockParams, log?: LogParams, trace?: Trace, transaction?: TransactionResponseParams, transactionReceipt?: TransactionReceiptParams);
|
28
29
|
protected getContractName(): string;
|
29
30
|
}
|
30
31
|
export declare class ContractContext<TContract extends BaseContract, TContractBoundView extends BoundContractView<TContract, ContractView<TContract>>> extends EthContext {
|
31
32
|
contract: TContractBoundView;
|
32
33
|
contractName: string;
|
33
|
-
constructor(contractName: string, view: TContractBoundView, chainId:
|
34
|
+
constructor(contractName: string, view: TContractBoundView, chainId: EthChainId, timestamp?: Date, block?: BlockParams, log?: LogParams, trace?: Trace, transaction?: TransactionResponseParams, transactionReceipt?: TransactionReceiptParams, baseLabels?: Labels);
|
34
35
|
protected getContractName(): string;
|
35
36
|
}
|
36
37
|
export declare class ContractView<TContract extends BaseContract> {
|
package/lib/eth/context.js
CHANGED
@@ -34,7 +34,7 @@ export class EthContext extends BaseContext {
|
|
34
34
|
}
|
35
35
|
}
|
36
36
|
getChainId() {
|
37
|
-
return this.chainId
|
37
|
+
return this.chainId;
|
38
38
|
}
|
39
39
|
getMetaDataInternal(name, labels) {
|
40
40
|
if (this.log) {
|
@@ -45,7 +45,7 @@ export class EthContext extends BaseContext {
|
|
45
45
|
transactionIndex: this.log.transactionIndex,
|
46
46
|
transactionHash: this.transactionHash || '',
|
47
47
|
logIndex: this.log.index,
|
48
|
-
chainId: this.chainId
|
48
|
+
chainId: this.chainId,
|
49
49
|
name: name,
|
50
50
|
labels: normalizeLabels(labels),
|
51
51
|
};
|
package/lib/eth/context.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/eth/context.ts"],"names":[],"mappings":"AAKA,OAAO,EAAU,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/eth/context.ts"],"names":[],"mappings":"AAKA,OAAO,EAAU,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAGrD,MAAM,OAAgB,UAAW,SAAQ,WAAW;IAClD,OAAO,CAAY;IACnB,OAAO,CAAQ;IACE,GAAG,CAAY;IAChC,KAAK,CAAc;IACF,KAAK,CAAQ;IAC9B,WAAW,CAAiB;IAC5B,eAAe,CAAS;IACxB,WAAW,CAA4B;IACvC,kBAAkB,CAA2B;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MAAM,EAAE,QAAQ,EAAE;YAClC,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAA;SACrC;QACD,MAAM,KAAK,CAAC,kCAAkC,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC5E,CAAC;CACF;AAED,MAAM,OAAO,iBAAiB;IAClB,IAAI,CAAe;IACpB,OAAO,CAAQ;IACxB,8EAA8E;IAC9E,OAAO,CAAyE;IAEhF,YAAY,OAAe,EAAE,IAAmB;QAC9C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAA;IAC9B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAA;IAC3B,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAA;IACtC,CAAC;CACF","sourcesContent":["import { BaseContract } from 'ethers'\nimport { LogParams, BlockParams, TransactionReceiptParams, TransactionResponseParams } from 'ethers/providers'\n\nimport { RecordMetaData } from '@sentio/protos'\nimport { Trace } from './eth.js'\nimport { Labels, normalizeLabels } from '../core/index.js'\nimport { BaseContext } from '../core/base-context.js'\nimport { EthChainId } from '../core/chain.js'\n\nexport abstract class EthContext extends BaseContext {\n chainId: EthChainId\n address: string\n private readonly log?: LogParams\n block?: BlockParams\n private readonly trace?: Trace\n blockNumber: bigint | number\n transactionHash?: string\n transaction?: TransactionResponseParams\n transactionReceipt?: TransactionReceiptParams\n timestamp: Date\n\n constructor(\n chainId: EthChainId,\n address: string,\n timestamp?: Date,\n block?: BlockParams,\n log?: LogParams,\n trace?: Trace,\n transaction?: TransactionResponseParams,\n transactionReceipt?: TransactionReceiptParams,\n baseLabels?: Labels\n ) {\n super(baseLabels)\n this.chainId = chainId\n this.log = log\n this.block = block\n this.trace = trace\n this.address = address.toLowerCase()\n this.transaction = transaction\n this.transactionReceipt = transactionReceipt\n this.timestamp = timestamp || new Date(0)\n if (log) {\n this.blockNumber = log.blockNumber\n this.transactionHash = log.transactionHash\n } else if (block) {\n this.blockNumber = block.number\n } else if (trace) {\n this.blockNumber = trace.blockNumber\n this.transactionHash = trace.transactionHash\n }\n }\n\n protected abstract getContractName(): string\n\n getChainId(): EthChainId {\n return this.chainId\n }\n\n getMetaDataInternal(name: string, labels: Labels): RecordMetaData {\n if (this.log) {\n return {\n address: this.address,\n contractName: this.getContractName(),\n blockNumber: BigInt(this.blockNumber),\n transactionIndex: this.log.transactionIndex,\n transactionHash: this.transactionHash || '',\n logIndex: this.log.index,\n chainId: this.chainId,\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n if (this.block) {\n return {\n address: this.address,\n contractName: this.getContractName(),\n blockNumber: BigInt(this.blockNumber),\n transactionIndex: -1,\n transactionHash: '',\n logIndex: -1,\n chainId: this.chainId.toString(),\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n if (this.trace) {\n return {\n address: this.address,\n contractName: this.getContractName(),\n blockNumber: BigInt(this.blockNumber),\n transactionIndex: this.trace.transactionPosition,\n transactionHash: this.transactionHash || '',\n logIndex: -1,\n chainId: this.chainId.toString(),\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n throw new Error(\"Invaid ctx argument can't happen\")\n }\n}\n\nexport class AccountContext extends EthContext {\n // constructor(chainId: number, address: string, block?: Block, log?: Log, trace?: Trace) {\n // super(chainId, address, new Date(0), block, log, trace)\n // }\n protected getContractName(): string {\n return 'account'\n }\n}\n\nexport class GlobalContext extends EthContext {\n constructor(\n chainId: EthChainId,\n timestamp?: Date,\n block?: BlockParams,\n log?: LogParams,\n trace?: Trace,\n transaction?: TransactionResponseParams,\n transactionReceipt?: TransactionReceiptParams\n ) {\n super(chainId, '*', timestamp, block, log, trace, transaction, transactionReceipt)\n }\n protected getContractName(): string {\n return '*'\n }\n}\n\nexport class ContractContext<\n TContract extends BaseContract,\n TContractBoundView extends BoundContractView<TContract, ContractView<TContract>>\n> extends EthContext {\n contract: TContractBoundView\n contractName: string\n\n constructor(\n contractName: string,\n view: TContractBoundView,\n chainId: EthChainId,\n timestamp?: Date,\n block?: BlockParams,\n log?: LogParams,\n trace?: Trace,\n transaction?: TransactionResponseParams,\n transactionReceipt?: TransactionReceiptParams,\n baseLabels?: Labels\n ) {\n super(chainId, view.address, timestamp, block, log, trace, transaction, transactionReceipt, baseLabels)\n view.context = this\n this.contractName = contractName\n this.contract = view\n }\n\n protected getContractName(): string {\n return this.contractName\n }\n}\n\nexport class ContractView<TContract extends BaseContract> {\n protected contract: TContract\n\n constructor(contract: TContract) {\n this.contract = contract\n }\n\n get rawContract() {\n return this.contract\n }\n\n get provider() {\n if (this.contract.runner?.provider) {\n return this.contract.runner.provider\n }\n throw Error(\"Can't find provider for contract\" + this.contract.toString())\n }\n}\n\nexport class BoundContractView<TContract extends BaseContract, TContractView extends ContractView<TContract>> {\n protected view: TContractView\n readonly address: string\n // context will be set right after context creation (in context's constructor)\n context: ContractContext<TContract, BoundContractView<TContract, TContractView>>\n\n constructor(address: string, view: TContractView) {\n this.address = address\n this.view = view\n }\n\n get rawContract() {\n return this.view.rawContract\n }\n\n get provider() {\n return this.view.provider\n }\n\n get filters() {\n return this.view.rawContract.filters\n }\n}\n"]}
|
package/lib/eth/eth-plugin.js
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
import { errorString, mergeProcessResults, Plugin, PluginManager, USER_PROCESSOR } from '@sentio/runtime';
|
2
|
-
import { AccountConfig, ContractConfig, HandlerType,
|
2
|
+
import { AccountConfig, ContractConfig, HandlerType, } from '@sentio/protos';
|
3
3
|
import { ServerError, Status } from 'nice-grpc';
|
4
4
|
import { ProcessorState } from './binds.js';
|
5
5
|
import { AccountProcessorState } from './account-processor-state.js';
|
6
6
|
import { ProcessorTemplateProcessorState, TemplateInstanceState } from './base-processor-template.js';
|
7
7
|
import { GlobalProcessorState } from './base-processor.js';
|
8
8
|
import { validateAndNormalizeAddress } from './eth.js';
|
9
|
-
import {
|
9
|
+
import { EthChainId } from '../core/chain.js';
|
10
|
+
import { EthContext } from './context.js';
|
10
11
|
export class EthPlugin extends Plugin {
|
11
12
|
name = 'EthPlugin';
|
12
13
|
handlers = {
|
@@ -210,7 +211,7 @@ export class EthPlugin extends Plugin {
|
|
210
211
|
template.bind({
|
211
212
|
name: instance.contract.name,
|
212
213
|
address: validateAndNormalizeAddress(instance.contract.address),
|
213
|
-
network:
|
214
|
+
network: instance.contract.chainId,
|
214
215
|
startBlock: instance.startBlock,
|
215
216
|
endBlock: instance.endBlock,
|
216
217
|
}, ctx);
|
@@ -274,15 +275,12 @@ export class EthPlugin extends Plugin {
|
|
274
275
|
}
|
275
276
|
}
|
276
277
|
PluginManager.INSTANCE.register(new EthPlugin());
|
277
|
-
class NoopContext extends
|
278
|
+
class NoopContext extends EthContext {
|
278
279
|
constructor() {
|
279
|
-
super(
|
280
|
+
super(EthChainId.ETHEREUM, '');
|
280
281
|
}
|
281
|
-
|
282
|
+
getContractName() {
|
282
283
|
return '';
|
283
284
|
}
|
284
|
-
getMetaDataInternal(name, labels) {
|
285
|
-
return RecordMetaData.create();
|
286
|
-
}
|
287
285
|
}
|
288
286
|
//# sourceMappingURL=eth-plugin.js.map
|