@sentio/sdk 2.7.4-rc.1 → 2.8.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/context.d.ts +2 -0
- package/lib/aptos/context.js +9 -3
- package/lib/aptos/context.js.map +1 -1
- package/lib/core/base-context.d.ts +1 -0
- package/lib/core/base-context.js.map +1 -1
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts +2 -1
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js +3 -2
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -1
- package/lib/eth/builtin/internal/eacaggregatorproxy-test-utils.js +4 -4
- package/lib/eth/builtin/internal/eacaggregatorproxy-test-utils.js.map +1 -1
- package/lib/eth/builtin/internal/erc1155-processor.d.ts +2 -1
- package/lib/eth/builtin/internal/erc1155-processor.js +3 -2
- package/lib/eth/builtin/internal/erc1155-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc1155-test-utils.js +4 -4
- package/lib/eth/builtin/internal/erc1155-test-utils.js.map +1 -1
- package/lib/eth/builtin/internal/erc20-processor.d.ts +2 -1
- package/lib/eth/builtin/internal/erc20-processor.js +3 -2
- package/lib/eth/builtin/internal/erc20-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc20-test-utils.js +3 -3
- package/lib/eth/builtin/internal/erc20-test-utils.js.map +1 -1
- package/lib/eth/builtin/internal/erc20bytes-processor.d.ts +2 -1
- package/lib/eth/builtin/internal/erc20bytes-processor.js +3 -2
- package/lib/eth/builtin/internal/erc20bytes-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc20bytes-test-utils.js +2 -2
- package/lib/eth/builtin/internal/erc20bytes-test-utils.js.map +1 -1
- package/lib/eth/builtin/internal/erc721-processor.d.ts +2 -1
- package/lib/eth/builtin/internal/erc721-processor.js +3 -2
- package/lib/eth/builtin/internal/erc721-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc721-test-utils.js +3 -3
- package/lib/eth/builtin/internal/erc721-test-utils.js.map +1 -1
- package/lib/eth/builtin/internal/weth9-processor.d.ts +2 -1
- package/lib/eth/builtin/internal/weth9-processor.js +3 -2
- package/lib/eth/builtin/internal/weth9-processor.js.map +1 -1
- package/lib/eth/builtin/internal/weth9-test-utils.js +4 -4
- package/lib/eth/builtin/internal/weth9-test-utils.js.map +1 -1
- package/lib/eth/codegen/file.js +5 -3
- package/lib/eth/codegen/file.js.map +1 -1
- package/lib/eth/context.d.ts +1 -0
- package/lib/eth/context.js +4 -1
- package/lib/eth/context.js.map +1 -1
- package/lib/eth/index.d.ts +1 -1
- package/lib/eth/index.js +1 -1
- package/lib/eth/index.js.map +1 -1
- package/lib/eth/provider.d.ts +3 -1
- package/lib/eth/provider.js +9 -2
- package/lib/eth/provider.js.map +1 -1
- package/lib/solana/solana-context.d.ts +1 -0
- package/lib/solana/solana-context.js +4 -1
- package/lib/solana/solana-context.js.map +1 -1
- package/lib/sui/context.d.ts +1 -0
- package/lib/sui/context.js +5 -2
- package/lib/sui/context.js.map +1 -1
- package/lib/utils/erc20.test.js.map +1 -1
- package/lib/utils/token.d.ts +4 -2
- package/lib/utils/token.js +5 -3
- package/lib/utils/token.js.map +1 -1
- package/package.json +4 -4
- package/src/aptos/context.ts +11 -3
- package/src/core/base-context.ts +2 -0
- package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +4 -1
- package/src/eth/builtin/internal/eacaggregatorproxy-test-utils.ts +4 -4
- package/src/eth/builtin/internal/erc1155-processor.ts +4 -1
- package/src/eth/builtin/internal/erc1155-test-utils.ts +4 -4
- package/src/eth/builtin/internal/erc20-processor.ts +4 -1
- package/src/eth/builtin/internal/erc20-test-utils.ts +3 -3
- package/src/eth/builtin/internal/erc20bytes-processor.ts +4 -1
- package/src/eth/builtin/internal/erc20bytes-test-utils.ts +2 -2
- package/src/eth/builtin/internal/erc721-processor.ts +4 -1
- package/src/eth/builtin/internal/erc721-test-utils.ts +3 -3
- package/src/eth/builtin/internal/weth9-processor.ts +4 -1
- package/src/eth/builtin/internal/weth9-test-utils.ts +4 -4
- package/src/eth/codegen/file.ts +7 -3
- package/src/eth/context.ts +5 -1
- package/src/eth/index.ts +1 -1
- package/src/eth/provider.ts +10 -2
- package/src/solana/solana-context.ts +5 -1
- package/src/sui/context.ts +6 -2
- package/src/utils/token.ts +10 -4
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"erc721-test-utils.js","sourceRoot":"","sources":["../../../../src/eth/builtin/internal/erc721-test-utils.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,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,iBAAiB,CAAC,eAAe,CAAC,CAAC;
|
1
|
+
{"version":3,"file":"erc721-test-utils.js","sourceRoot":"","sources":["../../../../src/eth/builtin/internal/erc721-test-utils.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,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,iBAAiB,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC;IACvD,MAAM,UAAU,GAAG,QAAQ,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAC9D,mCA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ent":["/* Autogenerated file. Do not edit manually. */\n/* tslint:disable */\n/* eslint-disable */\nimport { LogParams } from \"ethers/providers\";\nimport {\n ApprovalEventObject,\n ApprovalForAllEventObject,\n TransferEventObject,\n} from \"./ERC721.js\";\nimport { getERC721Contract } from \"./erc721-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 = getERC721Contract(contractAddress, 1);\n const encodedLog = contract.rawContract.interface.encodeEventLog(\n \"Approval(address,address,uint256)\",\n [event.owner, event.approved, event.tokenId]\n );\n return {\n ...mockField,\n index: 0,\n address: contractAddress,\n data: encodedLog.data,\n topics: encodedLog.topics,\n };\n}\n\nexport function mockApprovalForAllLog(\n contractAddress: string,\n event: ApprovalForAllEventObject\n): LogParams {\n const contract = getERC721Contract(contractAddress, 1);\n const encodedLog = contract.rawContract.interface.encodeEventLog(\n \"ApprovalForAll(address,address,bool)\",\n [event.owner, event.operator, event.approved]\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 = getERC721Contract(contractAddress, 1);\n const encodedLog = contract.rawContract.interface.encodeEventLog(\n \"Transfer(address,address,uint256)\",\n [event.from, event.to, event.tokenId]\n );\n return {\n ...mockField,\n index: 0,\n address: contractAddress,\n data: encodedLog.data,\n topics: encodedLog.topics,\n };\n}\n"]}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { Overrides } from "ethers";
|
2
2
|
import { Networkish } from "ethers/providers";
|
3
3
|
import { Trace, BindOptions, BaseProcessor, BaseProcessorTemplate, BoundContractView, ContractContext, ContractView, TypedCallTrace } from "@sentio/sdk/eth";
|
4
|
+
import { BaseContext } from "@sentio/sdk";
|
4
5
|
import { EthFetchConfig } from "@sentio/protos";
|
5
6
|
import { WETH9 } from "./index.js";
|
6
7
|
import { ApprovalEvent, ApprovalEventFilter, TransferEvent, TransferEventFilter, DepositEvent, DepositEventFilter, WithdrawalEvent, WithdrawalEventFilter } from "./WETH9.js";
|
@@ -108,4 +109,4 @@ export declare class WETH9ProcessorTemplate extends BaseProcessorTemplate<WETH9,
|
|
108
109
|
onEventDeposit(handler: (event: DepositEvent, ctx: WETH9Context) => void, filter?: DepositEventFilter | DepositEventFilter[], fetchConfig?: Partial<EthFetchConfig>): this;
|
109
110
|
onEventWithdrawal(handler: (event: WithdrawalEvent, ctx: WETH9Context) => void, filter?: WithdrawalEventFilter | WithdrawalEventFilter[], fetchConfig?: Partial<EthFetchConfig>): this;
|
110
111
|
}
|
111
|
-
export declare function getWETH9Contract(address: string,
|
112
|
+
export declare function getWETH9Contract(address: string, contextOrNetwork: BaseContext | Networkish): WETH9ContractView;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { addContractByABI, getContractByABI, addProcessor, getProcessor, getProvider, transformEtherError, BaseProcessor, BaseProcessorTemplate, BoundContractView, ContractView, DummyProvider, } from "@sentio/sdk/eth";
|
1
|
+
import { addContractByABI, getContractByABI, addProcessor, getProcessor, getProvider, transformEtherError, BaseProcessor, BaseProcessorTemplate, BoundContractView, ContractView, DummyProvider, getNetworkFromCtxOrNetworkish, } 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 {
|
@@ -229,7 +229,8 @@ export class WETH9ProcessorTemplate extends BaseProcessorTemplate {
|
|
229
229
|
return super.onEvent(handler, filter, fetchConfig);
|
230
230
|
}
|
231
231
|
}
|
232
|
-
export function getWETH9Contract(address,
|
232
|
+
export function getWETH9Contract(address, contextOrNetwork) {
|
233
|
+
const network = getNetworkFromCtxOrNetworkish(contextOrNetwork);
|
233
234
|
let contract = getContractByABI("WETH9", address, network);
|
234
235
|
if (!contract) {
|
235
236
|
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,EAGnB,aAAa,EACb,qBAAqB,EACrB,iBAAiB,EAEjB,YAAY,EACZ,aAAa,GAEd,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAS,cAAc,EAAE,MAAM,YAAY,CAAC;AAuFnD,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;IACH,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,SAAqB;QACrC,IAAI;YACF,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;SAC1E;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,mBAAmB,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;SACzC;IACH,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,SAAqB;QAClC,IAAI;YACF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,IAAI,EACJ,IAAI,CACL,CAAC;SACH;QACD,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,MAAO,EAAE,WAAW,CAAC,CAAC;IACtD,CAAC;IAED,cAAc,CACZ,OAAyD,EACzD,MAAkD,EAClD,WAAqC;QAErC,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,GAAG,gBAAgB,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SAC3E;QACD,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,MAAO,EAAE,WAAW,CAAC,CAAC;IACtD,CAAC;IAED,iBAAiB,CACf,OAA4D,EAC5D,MAAwD,EACxD,WAAqC;QAErC,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,GAAG,gBAAgB,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAC9D,IAAI,EACJ,IAAI,CACL,CAAC;SACH;QACD,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,MAAO,EAAE,WAAW,CAAC,CAAC;IACtD,CAAC;CACF;AAED,MAAM,UAAU,gBAAgB,CAC9B,OAAe,EACf,UAAsB,CAAC;IAEvB,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 Trace,\n BindOptions,\n BaseProcessor,\n BaseProcessorTemplate,\n BoundContractView,\n ContractContext,\n ContractView,\n DummyProvider,\n TypedCallTrace,\n} from \"@sentio/sdk/eth\";\nimport { EthFetchConfig } from \"@sentio/protos\";\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> & Trace;\n\nexport interface ApproveCallObject {\n guy: string;\n wad: bigint;\n}\n\nexport type ApproveCallTrace = TypedCallTrace<\n [string, bigint],\n ApproveCallObject\n> &\n Trace;\n\nexport interface TotalSupplyCallObject {}\n\nexport type TotalSupplyCallTrace = TypedCallTrace<[], TotalSupplyCallObject> &\n Trace;\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 Trace;\n\nexport interface WithdrawCallObject {\n wad: bigint;\n}\n\nexport type WithdrawCallTrace = TypedCallTrace<[bigint], WithdrawCallObject> &\n Trace;\n\nexport interface DecimalsCallObject {}\n\nexport type DecimalsCallTrace = TypedCallTrace<[], DecimalsCallObject> & Trace;\n\nexport interface BalanceOfCallObject {}\n\nexport type BalanceOfCallTrace = TypedCallTrace<[string], BalanceOfCallObject> &\n Trace;\n\nexport interface SymbolCallObject {}\n\nexport type SymbolCallTrace = TypedCallTrace<[], SymbolCallObject> & Trace;\n\nexport interface TransferCallObject {\n dst: string;\n wad: bigint;\n}\n\nexport type TransferCallTrace = TypedCallTrace<\n [string, bigint],\n TransferCallObject\n> &\n Trace;\n\nexport interface DepositCallObject {}\n\nexport type DepositCallTrace = TypedCallTrace<[], DepositCallObject> & Trace;\n\nexport interface AllowanceCallObject {}\n\nexport type AllowanceCallTrace = TypedCallTrace<\n [string, string],\n AllowanceCallObject\n> &\n Trace;\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, fetchConfig);\n }\n\n onCallApprove(\n handler: (call: ApproveCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x095ea7b3\", handler, fetchConfig);\n }\n\n onCallTotalSupply(\n handler: (call: TotalSupplyCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x18160ddd\", handler, fetchConfig);\n }\n\n onCallTransferFrom(\n handler: (call: TransferFromCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x23b872dd\", handler, fetchConfig);\n }\n\n onCallWithdraw(\n handler: (call: WithdrawCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x2e1a7d4d\", handler, fetchConfig);\n }\n\n onCallDecimals(\n handler: (call: DecimalsCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x313ce567\", handler, fetchConfig);\n }\n\n onCallBalanceOf(\n handler: (call: BalanceOfCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x70a08231\", handler, fetchConfig);\n }\n\n onCallSymbol(\n handler: (call: SymbolCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x95d89b41\", handler, fetchConfig);\n }\n\n onCallTransfer(\n handler: (call: TransferCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0xa9059cbb\", handler, fetchConfig);\n }\n\n onCallDeposit(\n handler: (call: DepositCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0xd0e30db0\", handler, fetchConfig);\n }\n\n onCallAllowance(\n handler: (call: AllowanceCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0xdd62ed3e\", handler, 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.address, this.config.network);\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 address: string,\n network: Networkish = 1\n): WETH9ContractView {\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":"AAKA,OAAO,EACL,gBAAgB,EAChB,gBAAgB,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AAI,EAAE,IAAI,CAAC,CAAC;SAC3E;QACD,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,MAAO,EAAE,WAAW,CAAC,CAAC;IACtD,CAAC;IAED,iBAAiB,CACf,OAA4D,EAC5D,MAAwD,EACxD,WAAqC;QAErC,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,GAAG,gBAAgB,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAC9D,IAAI,EACJ,IAAI,CACL,CAAC;SACH;QACD,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,MAAO,EAAE,WAAW,CAAC,CAAC;IACtD,CAAC;CACF;AAED,MAAM,UAAU,gBAAgB,CAC9B,OAAe,EACf,gBAA0C;IAE1C,MAAM,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 Trace,\n BindOptions,\n BaseProcessor,\n BaseProcessorTemplate,\n BoundContractView,\n ContractContext,\n ContractView,\n DummyProvider,\n TypedCallTrace,\n getNetworkFromCtxOrNetworkish,\n} from \"@sentio/sdk/eth\";\nimport { BaseContext } from \"@sentio/sdk\";\nimport { EthFetchConfig } from \"@sentio/protos\";\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> & Trace;\n\nexport interface ApproveCallObject {\n guy: string;\n wad: bigint;\n}\n\nexport type ApproveCallTrace = TypedCallTrace<\n [string, bigint],\n ApproveCallObject\n> &\n Trace;\n\nexport interface TotalSupplyCallObject {}\n\nexport type TotalSupplyCallTrace = TypedCallTrace<[], TotalSupplyCallObject> &\n Trace;\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 Trace;\n\nexport interface WithdrawCallObject {\n wad: bigint;\n}\n\nexport type WithdrawCallTrace = TypedCallTrace<[bigint], WithdrawCallObject> &\n Trace;\n\nexport interface DecimalsCallObject {}\n\nexport type DecimalsCallTrace = TypedCallTrace<[], DecimalsCallObject> & Trace;\n\nexport interface BalanceOfCallObject {}\n\nexport type BalanceOfCallTrace = TypedCallTrace<[string], BalanceOfCallObject> &\n Trace;\n\nexport interface SymbolCallObject {}\n\nexport type SymbolCallTrace = TypedCallTrace<[], SymbolCallObject> & Trace;\n\nexport interface TransferCallObject {\n dst: string;\n wad: bigint;\n}\n\nexport type TransferCallTrace = TypedCallTrace<\n [string, bigint],\n TransferCallObject\n> &\n Trace;\n\nexport interface DepositCallObject {}\n\nexport type DepositCallTrace = TypedCallTrace<[], DepositCallObject> & Trace;\n\nexport interface AllowanceCallObject {}\n\nexport type AllowanceCallTrace = TypedCallTrace<\n [string, string],\n AllowanceCallObject\n> &\n Trace;\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, fetchConfig);\n }\n\n onCallApprove(\n handler: (call: ApproveCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x095ea7b3\", handler, fetchConfig);\n }\n\n onCallTotalSupply(\n handler: (call: TotalSupplyCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x18160ddd\", handler, fetchConfig);\n }\n\n onCallTransferFrom(\n handler: (call: TransferFromCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x23b872dd\", handler, fetchConfig);\n }\n\n onCallWithdraw(\n handler: (call: WithdrawCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x2e1a7d4d\", handler, fetchConfig);\n }\n\n onCallDecimals(\n handler: (call: DecimalsCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x313ce567\", handler, fetchConfig);\n }\n\n onCallBalanceOf(\n handler: (call: BalanceOfCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x70a08231\", handler, fetchConfig);\n }\n\n onCallSymbol(\n handler: (call: SymbolCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0x95d89b41\", handler, fetchConfig);\n }\n\n onCallTransfer(\n handler: (call: TransferCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0xa9059cbb\", handler, fetchConfig);\n }\n\n onCallDeposit(\n handler: (call: DepositCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0xd0e30db0\", handler, fetchConfig);\n }\n\n onCallAllowance(\n handler: (call: AllowanceCallTrace, ctx: WETH9Context) => void,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return super.onTrace(\"0xdd62ed3e\", handler, 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.address, this.config.network);\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 address: string,\n contextOrNetwork: BaseContext | Networkish\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"]}
|
@@ -8,7 +8,7 @@ const mockField = {
|
|
8
8
|
transactionIndex: 0,
|
9
9
|
};
|
10
10
|
export function mockApprovalLog(contractAddress, event) {
|
11
|
-
const contract = getWETH9Contract(contractAddress);
|
11
|
+
const contract = getWETH9Contract(contractAddress, 1);
|
12
12
|
const encodedLog = contract.rawContract.interface.encodeEventLog("Approval(address,address,uint256)", [event.src, event.guy, event.wad]);
|
13
13
|
return {
|
14
14
|
...mockField,
|
@@ -19,7 +19,7 @@ export function mockApprovalLog(contractAddress, event) {
|
|
19
19
|
};
|
20
20
|
}
|
21
21
|
export function mockTransferLog(contractAddress, event) {
|
22
|
-
const contract = getWETH9Contract(contractAddress);
|
22
|
+
const contract = getWETH9Contract(contractAddress, 1);
|
23
23
|
const encodedLog = contract.rawContract.interface.encodeEventLog("Transfer(address,address,uint256)", [event.src, event.dst, event.wad]);
|
24
24
|
return {
|
25
25
|
...mockField,
|
@@ -30,7 +30,7 @@ export function mockTransferLog(contractAddress, event) {
|
|
30
30
|
};
|
31
31
|
}
|
32
32
|
export function mockDepositLog(contractAddress, event) {
|
33
|
-
const contract = getWETH9Contract(contractAddress);
|
33
|
+
const contract = getWETH9Contract(contractAddress, 1);
|
34
34
|
const encodedLog = contract.rawContract.interface.encodeEventLog("Deposit(address,uint256)", [event.dst, event.wad]);
|
35
35
|
return {
|
36
36
|
...mockField,
|
@@ -41,7 +41,7 @@ export function mockDepositLog(contractAddress, event) {
|
|
41
41
|
};
|
42
42
|
}
|
43
43
|
export function mockWithdrawalLog(contractAddress, event) {
|
44
|
-
const contract = getWETH9Contract(contractAddress);
|
44
|
+
const contract = getWETH9Contract(contractAddress, 1);
|
45
45
|
const encodedLog = contract.rawContract.interface.encodeEventLog("Withdrawal(address,uint256)", [event.src, event.wad]);
|
46
46
|
return {
|
47
47
|
...mockField,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"weth9-test-utils.js","sourceRoot":"","sources":["../../../../src/eth/builtin/internal/weth9-test-utils.ts"],"names":[],"mappings":"AAUA,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,CAA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O;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;AAED,MAAM,UAAU,cAAc,CAC5B,eAAuB,EACvB,KAAyB;IAEzB,MAAM,QAAQ,GAAG,gBAAgB,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC;IACtD,MAAM,UAAU,GAAG,QAAQ,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAC9D,0BAA0B,EAC1B,CAAC,KAAK,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;AAED,MAAM,UAAU,iBAAiB,CAC/B,eAAuB,EACvB,KAA4B;IAE5B,MAAM,QAAQ,GAAG,gBAAgB,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC;IACtD,MAAM,UAAU,GAAG,QAAQ,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAC9D,6BAA6B,EAC7B,CAAC,KAAK,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 {\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(contractAddress, 1);\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(contractAddress, 1);\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(contractAddress, 1);\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(contractAddress, 1);\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"]}
|
package/lib/eth/codegen/file.js
CHANGED
@@ -94,8 +94,8 @@ export class ${contract.name}ProcessorTemplate extends BaseProcessorTemplate<${c
|
|
94
94
|
.join('\n')}
|
95
95
|
}
|
96
96
|
|
97
|
-
|
98
|
-
|
97
|
+
export function get${contract.name}Contract(address: string, contextOrNetwork: BaseContext | Networkish): ${contract.name}ContractView {
|
98
|
+
const network = getNetworkFromCtxOrNetworkish(contextOrNetwork)
|
99
99
|
let contract = getContractByABI("${contract.name}", address, network) as ${contract.name}ContractView
|
100
100
|
if (!contract) {
|
101
101
|
const rawContract = ${contract.name}__factory.connect(address, getProvider(network))
|
@@ -150,8 +150,10 @@ export class ${contract.name}ProcessorTemplate extends BaseProcessorTemplate<${c
|
|
150
150
|
'ContractView',
|
151
151
|
'DummyProvider',
|
152
152
|
'TypedCallTrace',
|
153
|
+
'getNetworkFromCtxOrNetworkish',
|
153
154
|
// 'toBlockTag',
|
154
155
|
],
|
156
|
+
'@sentio/sdk': ['BaseContext'],
|
155
157
|
'@sentio/protos': ['EthFetchConfig'],
|
156
158
|
'./common.js': ['PromiseOrValue'],
|
157
159
|
'./index.js': [`${contract.name}`, `${contract.name}__factory`],
|
@@ -205,7 +207,7 @@ function generateMockEventLogFunction(event, contractName, includeArgTypes) {
|
|
205
207
|
const eventArgs = event.inputs.map((input, i) => `event.${input.name ?? `arg${i.toString()}`}`);
|
206
208
|
return `
|
207
209
|
export function mock${eventName}Log(contractAddress: string, event: ${eventName}EventObject): LogParams {
|
208
|
-
const contract = get${contractName}Contract(contractAddress)
|
210
|
+
const contract = get${contractName}Contract(contractAddress, 1)
|
209
211
|
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
210
212
|
'${getFullSignatureForEvent(event)}',
|
211
213
|
[${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,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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}.js'\n export * from './internal/${contract.name.toLowerCase()}-test-utils.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.address, this.config.network)\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\n export function get${contract.name}Contract(address: string, network: Networkish = 1): ${contract.name}ContractView {\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 // 'toBlockTag',\n ],\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(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,EAChC,wBAAwB,GACzB,MAAM,WAAW,CAAA;AAElB,OAAO,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAA;AACtF,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AACpF,OAAO,EAAE,oBAAoB,EAAE,qBAAqB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,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}.js'\n export * from './internal/${contract.name.toLowerCase()}-test-utils.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.address, this.config.network)\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(address: string, contextOrNetwork: BaseContext | Networkish): ${\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 ],\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(contractAddress, 1)\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
@@ -17,6 +17,7 @@ export declare abstract class EthContext extends BaseContext {
|
|
17
17
|
timestamp: Date;
|
18
18
|
constructor(chainId: number, address: string, timestamp?: Date, block?: BlockParams, log?: LogParams, trace?: Trace, transaction?: TransactionResponseParams, transactionReceipt?: TransactionReceiptParams);
|
19
19
|
protected abstract getContractName(): string;
|
20
|
+
getChainId(): string;
|
20
21
|
getMetaData(name: string, labels: Labels): RecordMetaData;
|
21
22
|
}
|
22
23
|
export declare class AccountContext extends EthContext {
|
package/lib/eth/context.js
CHANGED
@@ -17,7 +17,7 @@ export class EthContext extends BaseContext {
|
|
17
17
|
this.log = log;
|
18
18
|
this.block = block;
|
19
19
|
this.trace = trace;
|
20
|
-
this.address = address;
|
20
|
+
this.address = address.toLowerCase();
|
21
21
|
this.transaction = transaction;
|
22
22
|
this.transactionReceipt = transactionReceipt;
|
23
23
|
this.timestamp = timestamp || new Date(0);
|
@@ -33,6 +33,9 @@ export class EthContext extends BaseContext {
|
|
33
33
|
this.transactionHash = trace.transactionHash;
|
34
34
|
}
|
35
35
|
}
|
36
|
+
getChainId() {
|
37
|
+
return this.chainId.toString();
|
38
|
+
}
|
36
39
|
getMetaData(name, labels) {
|
37
40
|
if (this.log) {
|
38
41
|
return {
|
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;AAErD,MAAM,OAAgB,UAAW,SAAQ,WAAW;IAClD,OAAO,CAAQ;IACf,OAAO,CAAQ;IACE,GAAG,CAAY;IAChC,KAAK,CAAc;IACF,KAAK,CAAQ;IAC9B,WAAW,CAAiB;IAC5B,eAAe,CAAS;IACxB,WAAW,CAA4B;IACvC,kBAAkB,CAA2B;IAC7C,SAAS,CAAM;IAEf,YACE,OAAe,EACf,OAAe,EACf,SAAgB,EAChB,KAAmB,EACnB,GAAe,EACf,KAAa,EACb,WAAuC,EACvC,kBAA6C;QAE7C,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA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B,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;IAED,IAAI,QAAQ;QACV,IAAI,IAAI,CAAC,QAAQ,CAAC,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 './trace.js'\nimport { Labels, normalizeLabels } from '../core/index.js'\nimport { BaseContext } from '../core/base-context.js'\n\nexport abstract class EthContext extends BaseContext {\n chainId: number\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: number,\n address: string,\n timestamp?: Date,\n block?: BlockParams,\n log?: LogParams,\n trace?: Trace,\n transaction?: TransactionResponseParams,\n transactionReceipt?: TransactionReceiptParams\n ) {\n super()\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(): string {\n return this.chainId.toString()\n }\n\n getMetaData(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.toString(),\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 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: number,\n timestamp?: Date,\n block?: BlockParams,\n log?: LogParams,\n trace?: Trace,\n transaction?: TransactionResponseParams,\n transactionReceipt?: TransactionReceiptParams\n ) {\n super(chainId, view.address, timestamp, block, log, trace, transaction, transactionReceipt)\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/index.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
export { BaseProcessor } from './base-processor.js';
|
2
2
|
export { GenericProcessor } from './generic-processor.js';
|
3
3
|
export { BaseProcessorTemplate } from './base-processor-template.js';
|
4
|
-
export { getProvider, DummyProvider } from './provider.js';
|
4
|
+
export { getProvider, DummyProvider, getNetworkFromCtxOrNetworkish } from './provider.js';
|
5
5
|
export type { TypedCallTrace, Trace } from './trace.js';
|
6
6
|
export * from './eth.js';
|
7
7
|
export { BindOptions, AccountBindOptions } from './bind-options.js';
|
package/lib/eth/index.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
export { BaseProcessor } from './base-processor.js';
|
2
2
|
export { GenericProcessor } from './generic-processor.js';
|
3
3
|
export { BaseProcessorTemplate } from './base-processor-template.js';
|
4
|
-
export { getProvider, DummyProvider } from './provider.js';
|
4
|
+
export { getProvider, DummyProvider, getNetworkFromCtxOrNetworkish } from './provider.js';
|
5
5
|
export * from './eth.js';
|
6
6
|
export { BindOptions, AccountBindOptions } from './bind-options.js';
|
7
7
|
export { getProcessor, addProcessor, getContractByABI, addContractByABI } from './binds.js';
|
package/lib/eth/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/eth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/eth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAA;AAEzF,cAAc,UAAU,CAAA;AACxB,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACnE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC3F,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAE/E,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA","sourcesContent":["export { BaseProcessor } from './base-processor.js'\nexport { GenericProcessor } from './generic-processor.js'\nexport { BaseProcessorTemplate } from './base-processor-template.js'\nexport { getProvider, DummyProvider, getNetworkFromCtxOrNetworkish } from './provider.js'\nexport type { TypedCallTrace, Trace } from './trace.js'\nexport * from './eth.js'\nexport { BindOptions, AccountBindOptions } from './bind-options.js'\nexport { getProcessor, addProcessor, getContractByABI, addContractByABI } from './binds.js'\nexport { ContractContext, ContractView, BoundContractView } from './context.js'\n\nexport { EthPlugin } from './eth-plugin.js'\n"]}
|
package/lib/eth/provider.d.ts
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
import { Provider, JsonRpcProvider } from 'ethers';
|
1
|
+
import { Provider, Network, JsonRpcProvider } from 'ethers';
|
2
2
|
import { Networkish } from 'ethers/providers';
|
3
|
+
import { BaseContext } from '../core/index.js';
|
3
4
|
export declare const DummyProvider: JsonRpcProvider;
|
5
|
+
export declare function getNetworkFromCtxOrNetworkish(networkish?: BaseContext | Networkish): Network;
|
4
6
|
export declare function getProvider(networkish?: Networkish): Provider;
|
package/lib/eth/provider.js
CHANGED
@@ -1,19 +1,26 @@
|
|
1
1
|
import { Network, JsonRpcProvider } from 'ethers';
|
2
2
|
import PQueue from 'p-queue';
|
3
3
|
import { Endpoints } from '@sentio/runtime';
|
4
|
+
import { BaseContext } from '../core/index.js';
|
4
5
|
export const DummyProvider = new JsonRpcProvider('', Network.from(1));
|
5
6
|
const providers = new Map();
|
6
|
-
export function
|
7
|
+
export function getNetworkFromCtxOrNetworkish(networkish) {
|
7
8
|
if (!networkish) {
|
8
9
|
networkish = 1;
|
9
10
|
}
|
11
|
+
if (networkish instanceof BaseContext) {
|
12
|
+
networkish = networkish.getChainId();
|
13
|
+
}
|
10
14
|
if (typeof networkish === 'string') {
|
11
15
|
const id = parseInt(networkish);
|
12
16
|
if (!isNaN(id)) {
|
13
17
|
networkish = 1;
|
14
18
|
}
|
15
19
|
}
|
16
|
-
|
20
|
+
return Network.from(networkish);
|
21
|
+
}
|
22
|
+
export function getProvider(networkish) {
|
23
|
+
const network = getNetworkFromCtxOrNetworkish(networkish);
|
17
24
|
// TODO check if other key needed
|
18
25
|
const address = Endpoints.INSTANCE.chainServer.get(network.chainId.toString());
|
19
26
|
const key = network.chainId.toString() + '-' + address;
|
package/lib/eth/provider.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/eth/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAG3D,OAAO,MAAM,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/eth/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAG3D,OAAO,MAAM,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,eAAe,CAAC,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;AAErE,MAAM,SAAS,GAAG,IAAI,GAAG,EAA2B,CAAA;AAEpD,MAAM,UAAU,6BAA6B,CAAC,UAAqC;IACjF,IAAI,CAAC,UAAU,EAAE;QACf,UAAU,GAAG,CAAC,CAAA;KACf;IACD,IAAI,UAAU,YAAY,WAAW,EAAE;QACrC,UAAU,GAAG,UAAU,CAAC,UAAU,EAAE,CAAA;KACrC;IACD,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;QAClC,MAAM,EAAE,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAA;QAC/B,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE;YACd,UAAU,GAAG,CAAC,CAAA;SACf;KACF;IACD,OAAO,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;AACj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AC,GAAG,CAAC,CAAA;QACzC,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;YAC7D,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;YACpC,qFAAqF;YACrF,IAAI,KAAK,KAAK,QAAQ,EAAE;gBACtB,UAAU,CAAC,GAAG,EAAE;oBACd,IAAI,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,OAAO,EAAE;wBAC3C,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;qBAC/B;gBACH,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,CAAA;aACd;SACF;QAED,MAAM,MAAM,GAAG,MAAM,OAAO,CAAA;QAC5B,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,KAAK,CAAC,0BAA0B,CAAC,CAAA;SACxC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { Provider, Network, JsonRpcProvider } from 'ethers'\nimport { Networkish } from 'ethers/providers'\n\nimport PQueue from 'p-queue'\nimport { Endpoints } from '@sentio/runtime'\nimport { BaseContext } from '../core/index.js'\n\nexport const DummyProvider = new JsonRpcProvider('', Network.from(1))\n\nconst providers = new Map<string, JsonRpcProvider>()\n\nexport function getNetworkFromCtxOrNetworkish(networkish?: BaseContext | Networkish) {\n if (!networkish) {\n networkish = 1\n }\n if (networkish instanceof BaseContext) {\n networkish = networkish.getChainId()\n }\n if (typeof networkish === 'string') {\n const id = parseInt(networkish)\n if (!isNaN(id)) {\n networkish = 1\n }\n }\n return Network.from(networkish)\n}\n\nexport function getProvider(networkish?: Networkish): Provider {\n const network = getNetworkFromCtxOrNetworkish(networkish)\n // TODO check if other key needed\n\n const address = Endpoints.INSTANCE.chainServer.get(network.chainId.toString())\n const key = network.chainId.toString() + '-' + address\n let provider = providers.get(key)\n\n if (provider) {\n return provider\n }\n\n if (address === undefined) {\n throw Error(\n 'Provider not found for chain ' +\n network.chainId +\n ', configured chains: ' +\n [...Endpoints.INSTANCE.chainServer.keys()].join(' ')\n )\n }\n provider = new QueuedStaticJsonRpcProvider(address, Network.from(network), Endpoints.INSTANCE.concurrency)\n providers.set(network.chainId.toString(), provider)\n return provider\n}\n\nfunction getTag(prefix: string, value: any): string {\n return (\n prefix +\n ':' +\n JSON.stringify(value, (k, v) => {\n if (v == null) {\n return 'null'\n }\n if (typeof v === 'bigint') {\n return `bigint:${v.toString()}`\n }\n if (typeof v === 'string') {\n return v.toLowerCase()\n }\n\n // Sort object keys\n if (typeof v === 'object' && !Array.isArray(v)) {\n const keys = Object.keys(v)\n keys.sort()\n return keys.reduce((accum, key) => {\n accum[key] = v[key]\n return accum\n }, <any>{})\n }\n\n return v\n })\n )\n}\n\nclass QueuedStaticJsonRpcProvider extends JsonRpcProvider {\n executor: PQueue\n #performCache = new Map<string, Promise<any>>()\n\n constructor(url: string, network: Network, concurrency: number) {\n // TODO re-enable match when possible\n super(url, network, { staticNetwork: network, batchMaxCount: 1 })\n this.executor = new PQueue({ concurrency: concurrency })\n }\n\n async send(method: string, params: Array<any>): Promise<any> {\n const tag = getTag(method, params)\n const block = params[params.length - 1]\n let perform = this.#performCache.get(tag)\n if (!perform) {\n perform = this.executor.add(() => super.send(method, params))\n this.#performCache.set(tag, perform)\n // For non latest block call, we cache permanently, otherwise we cache for one minute\n if (block === 'latest') {\n setTimeout(() => {\n if (this.#performCache.get(tag) === perform) {\n this.#performCache.delete(tag)\n }\n }, 60 * 1000)\n }\n }\n\n const result = await perform\n if (!result) {\n throw Error('Unexpected null response')\n }\n return result\n }\n}\n"]}
|
@@ -5,5 +5,6 @@ export declare class SolanaContext extends BaseContext {
|
|
5
5
|
programName: string;
|
6
6
|
blockNumber: bigint;
|
7
7
|
constructor(programName: string, network: string, address: string, slot: bigint);
|
8
|
+
getChainId(): string;
|
8
9
|
getMetaData(name: string, labels: Labels): RecordMetaData;
|
9
10
|
}
|
@@ -11,6 +11,9 @@ export class SolanaContext extends BaseContext {
|
|
11
11
|
this.address = address;
|
12
12
|
this.blockNumber = slot;
|
13
13
|
}
|
14
|
+
getChainId() {
|
15
|
+
return this.network;
|
16
|
+
}
|
14
17
|
getMetaData(name, labels) {
|
15
18
|
return {
|
16
19
|
address: this.address,
|
@@ -19,7 +22,7 @@ export class SolanaContext extends BaseContext {
|
|
19
22
|
transactionIndex: 0,
|
20
23
|
transactionHash: '',
|
21
24
|
logIndex: 0,
|
22
|
-
chainId: this.
|
25
|
+
chainId: this.getChainId(),
|
23
26
|
name: name,
|
24
27
|
labels: normalizeLabels(labels),
|
25
28
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solana-context.js","sourceRoot":"","sources":["../../src/solana/solana-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAU,WAAW,EAAkB,SAAS,EAAE,MAAM,aAAa,CAAA;AAE7F,MAAM,OAAO,aAAc,SAAQ,WAAW;IAC5C,OAAO,CAAQ;IACf,OAAO,CAAQ;IACf,WAAW,CAAQ;IACnB,WAAW,CAAQ;IAEnB,YAAY,WAAmB,EAAE,OAAe,EAAE,OAAe,EAAE,IAAY;QAC7E,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,SAAS,CAAC,cAAc,CAAA;QAClD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA;IACzB,CAAC;IAED,WAAW,CAAC,IAAY,EAAE,MAAc;QACtC,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,YAAY,EAAE,IAAI,CAAC,WAAW;YAC9B,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,gBAAgB,EAAE,CAAC;YACnB,eAAe,EAAE,EAAE;YACnB,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,IAAI,CAAC,
|
1
|
+
{"version":3,"file":"solana-context.js","sourceRoot":"","sources":["../../src/solana/solana-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAU,WAAW,EAAkB,SAAS,EAAE,MAAM,aAAa,CAAA;AAE7F,MAAM,OAAO,aAAc,SAAQ,WAAW;IAC5C,OAAO,CAAQ;IACf,OAAO,CAAQ;IACf,WAAW,CAAQ;IACnB,WAAW,CAAQ;IAEnB,YAAY,WAAmB,EAAE,OAAe,EAAE,OAAe,EAAE,IAAY;QAC7E,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,SAAS,CAAC,cAAc,CAAA;QAClD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA;IACzB,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;IAED,WAAW,CAAC,IAAY,EAAE,MAAc;QACtC,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,YAAY,EAAE,IAAI,CAAC,WAAW;YAC9B,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,gBAAgB,EAAE,CAAC;YACnB,eAAe,EAAE,EAAE;YACnB,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE;YAC1B,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC;SAChC,CAAA;IACH,CAAC;CACF","sourcesContent":["import { normalizeLabels, Labels, BaseContext, RecordMetaData, CHAIN_IDS } from '@sentio/sdk'\n\nexport class SolanaContext extends BaseContext {\n network: string\n address: string\n programName: string\n blockNumber: bigint\n\n constructor(programName: string, network: string, address: string, slot: bigint) {\n super()\n this.network = network || CHAIN_IDS.SOLANA_MAINNET\n this.programName = programName\n this.address = address\n this.blockNumber = slot\n }\n\n getChainId(): string {\n return this.network\n }\n\n getMetaData(name: string, labels: Labels): RecordMetaData {\n return {\n address: this.address,\n contractName: this.programName,\n blockNumber: this.blockNumber,\n transactionIndex: 0,\n transactionHash: '', // TODO add\n logIndex: 0,\n chainId: this.getChainId(),\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n}\n"]}
|
package/lib/sui/context.d.ts
CHANGED
@@ -10,5 +10,6 @@ export declare class SuiContext extends BaseContext {
|
|
10
10
|
slot: bigint;
|
11
11
|
transaction: SuiTransactionResponse;
|
12
12
|
constructor(moduleName: string, network: SuiNetwork, address: string, timestamp: Date, slot: bigint, transaction?: SuiTransactionResponse);
|
13
|
+
getChainId(): string;
|
13
14
|
getMetaData(name: string, labels: Labels): RecordMetaData;
|
14
15
|
}
|
package/lib/sui/context.js
CHANGED
@@ -9,7 +9,7 @@ export class SuiContext extends BaseContext {
|
|
9
9
|
transaction;
|
10
10
|
constructor(moduleName, network, address, timestamp, slot, transaction) {
|
11
11
|
super();
|
12
|
-
this.address = address;
|
12
|
+
this.address = address.toLowerCase();
|
13
13
|
this.network = network;
|
14
14
|
this.moduleName = moduleName;
|
15
15
|
this.timestamp = timestamp;
|
@@ -18,6 +18,9 @@ export class SuiContext extends BaseContext {
|
|
18
18
|
this.transaction = transaction;
|
19
19
|
}
|
20
20
|
}
|
21
|
+
getChainId() {
|
22
|
+
return getChainId(this.network);
|
23
|
+
}
|
21
24
|
getMetaData(name, labels) {
|
22
25
|
return {
|
23
26
|
address: this.address,
|
@@ -26,7 +29,7 @@ export class SuiContext extends BaseContext {
|
|
26
29
|
transactionIndex: 0,
|
27
30
|
transactionHash: this.transaction?.certificate.transactionDigest || '',
|
28
31
|
logIndex: 0,
|
29
|
-
chainId: getChainId(
|
32
|
+
chainId: this.getChainId(),
|
30
33
|
name: name,
|
31
34
|
labels: normalizeLabels(labels),
|
32
35
|
};
|
package/lib/sui/context.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/sui/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACvE,OAAO,EAAc,UAAU,EAAE,MAAM,cAAc,CAAA;AAGrD,MAAM,OAAO,UAAW,SAAQ,WAAW;IACzC,OAAO,CAAQ;IACf,OAAO,CAAY;IACnB,UAAU,CAAQ;IAClB,SAAS,CAAM;IACf,IAAI,CAAQ;IACZ,WAAW,CAAwB;IAEnC,YACE,UAAkB,EAClB,OAAmB,EACnB,OAAe,EACf,SAAe,EACf,IAAY,EACZ,WAAoC;QAEpC,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/sui/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACvE,OAAO,EAAc,UAAU,EAAE,MAAM,cAAc,CAAA;AAGrD,MAAM,OAAO,UAAW,SAAQ,WAAW;IACzC,OAAO,CAAQ;IACf,OAAO,CAAY;IACnB,UAAU,CAAQ;IAClB,SAAS,CAAM;IACf,IAAI,CAAQ;IACZ,WAAW,CAAwB;IAEnC,YACE,UAAkB,EAClB,OAAmB,EACnB,OAAe,EACf,SAAe,EACf,IAAY,EACZ,WAAoC;QAEpC,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,WAAW,EAAE,CAAA;QACpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,WAAW,EAAE;YACf,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;SAC/B;IACH,CAAC;IAED,UAAU;QACR,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACjC,CAAC;IAED,WAAW,CAAC,IAAY,EAAE,MAAc;QACtC,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,YAAY,EAAE,IAAI,CAAC,UAAU;YAC7B,WAAW,EAAE,IAAI,CAAC,IAAI;YACtB,gBAAgB,EAAE,CAAC;YACnB,eAAe,EAAE,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,iBAAiB,IAAI,EAAE;YACtE,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE;YAC1B,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC;SAChC,CAAA;IACH,CAAC;CACF","sourcesContent":["import { RecordMetaData } from '@sentio/protos'\nimport { type Labels, BaseContext, normalizeLabels } from '../index.js'\nimport { SuiNetwork, getChainId } from './network.js'\nimport { SuiTransactionResponse } from '@mysten/sui.js'\n\nexport class SuiContext extends BaseContext {\n address: string\n network: SuiNetwork\n moduleName: string\n timestamp: Date\n slot: bigint\n transaction: SuiTransactionResponse\n\n constructor(\n moduleName: string,\n network: SuiNetwork,\n address: string,\n timestamp: Date,\n slot: bigint,\n transaction?: SuiTransactionResponse\n ) {\n super()\n this.address = address.toLowerCase()\n this.network = network\n this.moduleName = moduleName\n this.timestamp = timestamp\n this.slot = slot\n if (transaction) {\n this.transaction = transaction\n }\n }\n\n getChainId(): string {\n return getChainId(this.network)\n }\n\n getMetaData(name: string, labels: Labels): RecordMetaData {\n return {\n address: this.address,\n contractName: this.moduleName,\n blockNumber: this.slot,\n transactionIndex: 0,\n transactionHash: this.transaction?.certificate.transactionDigest || '', // TODO\n logIndex: 0,\n chainId: this.getChainId(),\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n}\n"]}
|