@sentio/sdk 2.17.1-rc.1 → 2.18.0-rc.2

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.
Files changed (40) hide show
  1. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts +17 -0
  2. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js +88 -0
  3. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -1
  4. package/lib/eth/builtin/internal/erc1155-processor.d.ts +13 -0
  5. package/lib/eth/builtin/internal/erc1155-processor.js +56 -0
  6. package/lib/eth/builtin/internal/erc1155-processor.js.map +1 -1
  7. package/lib/eth/builtin/internal/erc20-processor.d.ts +28 -1
  8. package/lib/eth/builtin/internal/erc20-processor.js +168 -0
  9. package/lib/eth/builtin/internal/erc20-processor.js.map +1 -1
  10. package/lib/eth/builtin/internal/erc20bytes-processor.d.ts +14 -1
  11. package/lib/eth/builtin/internal/erc20bytes-processor.js +56 -0
  12. package/lib/eth/builtin/internal/erc20bytes-processor.js.map +1 -1
  13. package/lib/eth/builtin/internal/erc721-processor.d.ts +17 -0
  14. package/lib/eth/builtin/internal/erc721-processor.js +88 -0
  15. package/lib/eth/builtin/internal/erc721-processor.js.map +1 -1
  16. package/lib/eth/builtin/internal/weth9-processor.d.ts +18 -1
  17. package/lib/eth/builtin/internal/weth9-processor.js +88 -0
  18. package/lib/eth/builtin/internal/weth9-processor.js.map +1 -1
  19. package/lib/eth/codegen/file.js +22 -4
  20. package/lib/eth/codegen/file.js.map +1 -1
  21. package/lib/eth/codegen/function-calls.d.ts +5 -0
  22. package/lib/eth/codegen/function-calls.js +64 -0
  23. package/lib/eth/codegen/function-calls.js.map +1 -0
  24. package/lib/eth/context.d.ts +4 -0
  25. package/lib/eth/context.js +4 -0
  26. package/lib/eth/context.js.map +1 -1
  27. package/package.json +3 -3
  28. package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +105 -0
  29. package/src/eth/builtin/internal/erc1155-processor.ts +111 -0
  30. package/src/eth/builtin/internal/erc20-processor.ts +228 -1
  31. package/src/eth/builtin/internal/erc20bytes-processor.ts +84 -1
  32. package/src/eth/builtin/internal/erc721-processor.ts +146 -0
  33. package/src/eth/builtin/internal/weth9-processor.ts +114 -1
  34. package/src/eth/codegen/file.ts +22 -4
  35. package/src/eth/codegen/function-calls.ts +78 -0
  36. package/src/eth/context.ts +7 -0
  37. package/lib/eth/codegen/view-function.d.ts +0 -5
  38. package/lib/eth/codegen/view-function.js +0 -60
  39. package/lib/eth/codegen/view-function.js.map +0 -1
  40. package/src/eth/codegen/view-function.ts +0 -71
@@ -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,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AACpF,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAChF,OAAO,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAEtF,MAAM,UAAU,YAAY,CAAC,QAAkB;IAC7C,OAAO;8BACqB,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE;8BAC3B,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE;8BAC3B,QAAQ,CAAC,IAAI;wCACH,QAAQ,CAAC,IAAI;GAClD,CAAA;AACH,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,QAAkB;IAClD,MAAM,MAAM,GAAG;IACb,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;6BAE9C,QAAQ,CAAC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,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(chainId: EthChainId, address: string): ${contract.name}ContractView {\n let contract = getContractByABI(\"${contract.name}\", address, chainId) as ${contract.name}ContractView\n if (!contract) {\n const rawContract = ${contract.name}__factory.connect(address, getProvider(chainId))\n contract = new ${contract.name}ContractView(rawContract)\n addContractByABI(\"${contract.name}\", address, chainId, contract)\n }\n return contract\n }\n \n export function get${contract.name}ContractOnContext(context: EthContext, address: string): \n ${contract.name}BoundContractView {\n const view = get${contract.name}Contract(context.getChainId(), address)\n const boundView = new ${contract.name}BoundContractView(address, view) \n boundView.context = context as any;\n return boundView;\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 'EthContext',\n 'EthFetchConfig',\n ],\n // '@sentio/sdk/eth': ['BaseContext'],\n // '@sentio/protos': ['EthFetchConfig'],\n './common.js': ['PromiseOrValue'],\n './index.js': [`${contract.name}__factory`],\n [`./${contract.name}.js`]: [`${contract.name}`, ...eventsImports, ...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"]}
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,EAAE,MAAM,oBAAoB,CAAA;AAChF,OAAO,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAEvF,MAAM,UAAU,YAAY,CAAC,QAAkB;IAC7C,OAAO;8BACqB,QAAQ,CAA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entifiers,\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 './function-calls.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 this.callStatic.contract = contract;\n }\n\n ${Object.values(contract.functions)\n .filter((f) => !reservedKeywords.has(f[0].name))\n .flatMap((fs) => generateViewFunctions(true, fs))\n .join('\\n')}\n \n callStatic = {\n contract: this.contract,\n ${Object.values(contract.functions)\n .filter((f) => !reservedKeywords.has(f[0].name))\n .flatMap((fs) => generateViewFunctions(false, fs))\n .join(',\\n')}\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 .flatMap((fs) => generateBoundViewFunctions(true, fs))\n .join('\\n')}\n \n callStatic = {\n view: this.view,\n context: this.context,\n ${Object.values(contract.functions)\n .filter((f) => !reservedKeywords.has(f[0].name))\n .flatMap((fs) => generateBoundViewFunctions(false, fs))\n .join(',\\n')}\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(chainId: EthChainId, address: string): ${contract.name}ContractView {\n let contract = getContractByABI(\"${contract.name}\", address, chainId) as ${contract.name}ContractView\n if (!contract) {\n const rawContract = ${contract.name}__factory.connect(address, getProvider(chainId))\n contract = new ${contract.name}ContractView(rawContract)\n addContractByABI(\"${contract.name}\", address, chainId, contract)\n }\n return contract\n }\n \n export function get${contract.name}ContractOnContext(context: EthContext, address: string): \n ${contract.name}BoundContractView {\n const view = get${contract.name}Contract(context.getChainId(), address)\n const boundView = new ${contract.name}BoundContractView(address, view) \n boundView.context = context as any;\n return boundView;\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 'EthContext',\n 'EthFetchConfig',\n ],\n // '@sentio/sdk/eth': ['BaseContext'],\n // '@sentio/protos': ['EthFetchConfig'],\n './common.js': ['PromiseOrValue'],\n './index.js': [`${contract.name}__factory`],\n [`./${contract.name}.js`]: [`${contract.name}`, ...eventsImports, ...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"]}
@@ -0,0 +1,5 @@
1
+ import { FunctionDeclaration } from 'typechain';
2
+ export declare function generateViewFunctions(view: boolean, functions: FunctionDeclaration[]): string[];
3
+ export declare function generateViewFunction(view: boolean, fn: FunctionDeclaration, includeArgTypes: boolean): string[];
4
+ export declare function generateBoundViewFunctions(view: boolean, functions: FunctionDeclaration[]): string[];
5
+ export declare function generateBoundViewFunction(view: boolean, fn: FunctionDeclaration, includeArgTypes: boolean): string[];
@@ -0,0 +1,64 @@
1
+ import { generateInputTypes, generateOutputTypes } from '@sentio/ethers-v6/dist/codegen/types.js';
2
+ import { getFullSignatureAsSymbolForFunction, getFullSignatureForFunction } from './types.js';
3
+ function generateReturnTypes(fn) {
4
+ // sounds like returnResultObject should be true but we need to set false to make it work
5
+ return `Promise<${generateOutputTypes({ returnResultObject: false, useStructs: true }, fn.outputs)}>`;
6
+ }
7
+ export function generateViewFunctions(view, functions) {
8
+ const includeArgTypes = functions.length !== 1;
9
+ return functions.flatMap((fn) => generateViewFunction(view, fn, includeArgTypes));
10
+ }
11
+ export function generateViewFunction(view, fn, includeArgTypes) {
12
+ const isView = fn.stateMutability === 'view' || fn.stateMutability === 'pure';
13
+ if (view !== isView) {
14
+ return [];
15
+ }
16
+ const declName = includeArgTypes ? getFullSignatureAsSymbolForFunction(fn) : fn.name;
17
+ const call = view ? '' : '.staticCall';
18
+ const func = `this.contract.getFunction("` + getFullSignatureForFunction(fn) + '")';
19
+ // if (overrides) {
20
+ // return await ${call}(${
21
+ // fn.inputs.length > 0 ? fn.inputs.map((input, index) => input.name || `arg${index}`).join(',') + ',' : ''
22
+ // } overrides)
23
+ // } else {
24
+ // return await ${call}(${fn.inputs.map((input, index) => input.name || `arg${index}`).join(',')})
25
+ // }
26
+ return [
27
+ `
28
+ async ${declName}(${generateInputTypes(fn.inputs, {
29
+ useStructs: true,
30
+ })}overrides?: Overrides): ${generateReturnTypes(fn)} {
31
+ try {
32
+ return await ${func}${call}(${fn.inputs.length > 0 ? fn.inputs.map((input, index) => input.name || `arg${index}`).join(',') + ',' : ''} overrides || {})
33
+ } catch (e) {
34
+ throw transformEtherError(e, undefined)
35
+ }
36
+ }
37
+ `,
38
+ ];
39
+ }
40
+ export function generateBoundViewFunctions(view, functions) {
41
+ const includeArgTypes = functions.length !== 1;
42
+ return functions.flatMap((fn) => generateBoundViewFunction(view, fn, includeArgTypes));
43
+ }
44
+ export function generateBoundViewFunction(view, fn, includeArgTypes) {
45
+ const isView = fn.stateMutability === 'view' || fn.stateMutability === 'pure';
46
+ if (view !== isView) {
47
+ return [];
48
+ }
49
+ const declName = includeArgTypes ? getFullSignatureAsSymbolForFunction(fn) : fn.name;
50
+ const qualifier = view ? 'view' : 'view.callStatic';
51
+ return [
52
+ `
53
+ async ${declName ?? fn.name}(${generateInputTypes(fn.inputs, {
54
+ useStructs: true,
55
+ })}overrides?: Overrides): ${generateReturnTypes(fn)} {
56
+ return await this.${qualifier}.${declName}(${fn.inputs.length > 0 ? fn.inputs.map((input, index) => input.name || `arg${index}`).join(',') + ',' : ''} {
57
+ blockTag: this.context.blockNumber,
58
+ ...overrides
59
+ })
60
+ }
61
+ `,
62
+ ];
63
+ }
64
+ //# sourceMappingURL=function-calls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"function-calls.js","sourceRoot":"","sources":["../../../src/eth/codegen/function-calls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAA;AACjG,OAAO,EAAE,mCAAmC,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAA;AAE7F,SAAS,mBAAmB,CAAC,EAAuB;IAClD,yFAAyF;IACzF,OAAO,WAAW,mBAAmB,CAAC,EAAE,kBAAkB,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAA;AACvG,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,IAAa,EAAE,SAAgC;IACnF,MAAM,eAAe,GAAG,SAAS,CAAC,MAAM,KAAK,CAAC,CAAA;IAC9C,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,oBAAoB,CAAC,IAAI,EAAE,EAAE,EAAE,eAAe,CAAC,CAAC,CAAA;AACnF,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,IAAa,EAAE,EAAuB,EAAE,eAAwB;IACnG,MAAM,MAAM,GAAG,EAAE,CAAC,eAAe,KAAK,MAAM,IAAI,EAAE,CAAC,eAAe,KAAK,MAAM,CAAA;IAC7E,IAAI,IAAI,KAAK,MAAM,EAAE;QACnB,OAAO,EAAE,CAAA;KACV;IACD,MAAM,Q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,MAAM,CAAA;IAC7E,IAAI,IAAI,KAAK,MAAM,EAAE;QACnB,OAAO,EAAE,CAAA;KACV;IACD,MAAM,QAAQ,GAAG,eAAe,CAAC,CAAC,CAAC,mCAAmC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAA;IAEpF,MAAM,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,iBAAiB,CAAA;IAEnD,OAAO;QACL;UACM,QAAQ,IAAI,EAAE,CAAC,IAAI,IAAI,kBAAkB,CAAC,EAAE,CAAC,MAAM,EAAE;YACzD,UAAU,EAAE,IAAI;SACjB,CAAC,2BAA2B,mBAAmB,CAAC,EAAE,CAAC;wBAChC,SAAS,IAAI,QAAQ,IACvC,EAAE,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,IAAI,MAAM,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,EACxG;;;;;GAKD;KACA,CAAA;AACH,CAAC","sourcesContent":["// https://github.com/dethcrypto/TypeChain/blob/015abb28bd22826611051f27e0ec96a00f9a0b61/packages/target-ethers-v5/src/codegen/functions.ts#L54\nimport { FunctionDeclaration } from 'typechain'\nimport { generateInputTypes, generateOutputTypes } from '@sentio/ethers-v6/dist/codegen/types.js'\nimport { getFullSignatureAsSymbolForFunction, getFullSignatureForFunction } from './types.js'\n\nfunction generateReturnTypes(fn: FunctionDeclaration) {\n // sounds like returnResultObject should be true but we need to set false to make it work\n return `Promise<${generateOutputTypes({ returnResultObject: false, useStructs: true }, fn.outputs)}>`\n}\n\nexport function generateViewFunctions(view: boolean, functions: FunctionDeclaration[]): string[] {\n const includeArgTypes = functions.length !== 1\n return functions.flatMap((fn) => generateViewFunction(view, fn, includeArgTypes))\n}\n\nexport function generateViewFunction(view: boolean, fn: FunctionDeclaration, includeArgTypes: boolean): string[] {\n const isView = fn.stateMutability === 'view' || fn.stateMutability === 'pure'\n if (view !== isView) {\n return []\n }\n const declName = includeArgTypes ? getFullSignatureAsSymbolForFunction(fn) : fn.name\n\n const call = view ? '' : '.staticCall'\n\n const func = `this.contract.getFunction(\"` + getFullSignatureForFunction(fn) + '\")'\n // if (overrides) {\n // return await ${call}(${\n // fn.inputs.length > 0 ? fn.inputs.map((input, index) => input.name || `arg${index}`).join(',') + ',' : ''\n // } overrides)\n // } else {\n // return await ${call}(${fn.inputs.map((input, index) => input.name || `arg${index}`).join(',')})\n // }\n return [\n `\n async ${declName}(${generateInputTypes(fn.inputs, {\n useStructs: true,\n })}overrides?: Overrides): ${generateReturnTypes(fn)} {\n try { \n return await ${func}${call}(${\n fn.inputs.length > 0 ? fn.inputs.map((input, index) => input.name || `arg${index}`).join(',') + ',' : ''\n } overrides || {})\n } catch (e) {\n throw transformEtherError(e, undefined)\n }\n }\n `,\n ]\n}\n\nexport function generateBoundViewFunctions(view: boolean, functions: FunctionDeclaration[]): string[] {\n const includeArgTypes = functions.length !== 1\n return functions.flatMap((fn) => generateBoundViewFunction(view, fn, includeArgTypes))\n}\n\nexport function generateBoundViewFunction(view: boolean, fn: FunctionDeclaration, includeArgTypes: boolean): string[] {\n const isView = fn.stateMutability === 'view' || fn.stateMutability === 'pure'\n if (view !== isView) {\n return []\n }\n const declName = includeArgTypes ? getFullSignatureAsSymbolForFunction(fn) : fn.name\n\n const qualifier = view ? 'view' : 'view.callStatic'\n\n return [\n `\n async ${declName ?? fn.name}(${generateInputTypes(fn.inputs, {\n useStructs: true,\n })}overrides?: Overrides): ${generateReturnTypes(fn)} {\n return await this.${qualifier}.${declName}(${\n fn.inputs.length > 0 ? fn.inputs.map((input, index) => input.name || `arg${index}`).join(',') + ',' : ''\n } {\n blockTag: this.context.blockNumber,\n ...overrides\n })\n }\n `,\n ]\n}\n"]}
@@ -44,6 +44,10 @@ export declare class BoundContractView<TContract extends BaseContract, TContract
44
44
  protected view: TContractView;
45
45
  readonly address: string;
46
46
  context: EthContext;
47
+ callStatic: {
48
+ context: EthContext;
49
+ view: TContractView;
50
+ };
47
51
  constructor(address: string, view: TContractView);
48
52
  get rawContract(): TContract;
49
53
  get provider(): import("ethers").Provider;
@@ -101,6 +101,9 @@ export class ContractContext extends EthContext {
101
101
  constructor(contractName, view, chainId, timestamp, block, log, trace, transaction, transactionReceipt, baseLabels) {
102
102
  super(chainId, view.address, timestamp, block, log, trace, transaction, transactionReceipt, baseLabels);
103
103
  view.context = this;
104
+ if (view.callStatic) {
105
+ view.callStatic.context = this;
106
+ }
104
107
  this.contractName = contractName;
105
108
  this.contract = view;
106
109
  }
@@ -129,6 +132,7 @@ export class BoundContractView {
129
132
  // context will be set right after context creation (in context's constructor)
130
133
  // context: ContractContext<TContract, BoundContractView<TContract, TContractView>>
131
134
  context;
135
+ callStatic;
132
136
  constructor(address, view) {
133
137
  this.address = address;
134
138
  this.view = view;
@@ -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;AAGrD,MAAM,OAAgB,UAAW,SAAQ,WAAW;IAClD,OAAO,CAAY;IACnB,OAAO,CAAQ;IACE,GAAG,CAAY;IAChC,KAAK,CAAc;IACF,KAAK,CAAQ;IAC9B,WAAW,CAAQ;IACnB,eAAe,CAAS;IACxB,WAAW,CAA4B;IACvC,kBAAkB,CAA2B;IAC7C,SAAS,CAAM;IAEf,YACE,OAAmB,EACnB,OAAe,EACf,SAAgB,EAChB,KAAmB,EACnB,GAAe,EACf,KAAa,EACb,WAAuC,EACvC,kBAA6C,EAC7C,UAAmB;QAEnB,KAAK,CAAC,UAAU,CAAC,CAAA;QACjB,IAA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5E,CAAC;CACF;AAED,MAAM,OAAO,iBAAiB;IAClB,IAAI,CAAe;IACpB,OAAO,CAAQ;IACxB,8EAA8E;IAC9E,mFAAmF;IACnF,OAAO,CAAY;IAEnB,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: 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 context: EthContext\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"]}
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,CAAQ;IACnB,eAAe,CAAS;IACxB,WAAW,CAA4B;IACvC,kBAAkB,CAA2B;IAC7C,SAAS,CAAM;IAEf,YACE,OAAmB,EACnB,OAAe,EACf,SAAgB,EAChB,KAAmB,EACnB,GAAe,EACf,KAAa,EACb,WAAuC,EACvC,kBAA6C,EAC7C,UAAmB;QAEn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C,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,mFAAmF;IACnF,OAAO,CAAY;IACnB,UAAU,CAGT;IAED,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: 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 if (view.callStatic) {\n view.callStatic.context = this\n }\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 context: EthContext\n callStatic: {\n context: EthContext\n view: TContractView\n }\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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentio/sdk",
3
- "version": "2.17.1-rc.1",
3
+ "version": "2.18.0-rc.2",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -71,8 +71,8 @@
71
71
  "typedoc": "^0.24.1",
72
72
  "utility-types": "^3.10.0",
73
73
  "yaml": "^2.2.1",
74
- "@sentio/protos": "2.17.1-rc.1",
75
- "@sentio/runtime": "^2.17.1-rc.1"
74
+ "@sentio/protos": "2.18.0-rc.2",
75
+ "@sentio/runtime": "^2.18.0-rc.2"
76
76
  },
77
77
  "peerDependencies": {
78
78
  "tsup": "npm:@sentio/tsup@^6.7.0"
@@ -193,6 +193,7 @@ const templateContract = EACAggregatorProxy__factory.connect(
193
193
  export class EACAggregatorProxyContractView extends ContractView<EACAggregatorProxy> {
194
194
  constructor(contract: EACAggregatorProxy) {
195
195
  super(contract);
196
+ this.callStatic.contract = contract;
196
197
  }
197
198
 
198
199
  async accessController(overrides?: Overrides): Promise<string> {
@@ -414,6 +415,65 @@ export class EACAggregatorProxyContractView extends ContractView<EACAggregatorPr
414
415
  throw transformEtherError(e, undefined);
415
416
  }
416
417
  }
418
+
419
+ callStatic = {
420
+ contract: this.contract,
421
+
422
+ async acceptOwnership(overrides?: Overrides): Promise<void> {
423
+ try {
424
+ return await this.contract
425
+ .getFunction("acceptOwnership()")
426
+ .staticCall(overrides || {});
427
+ } catch (e) {
428
+ throw transformEtherError(e, undefined);
429
+ }
430
+ },
431
+ async confirmAggregator(
432
+ _aggregator: string,
433
+ overrides?: Overrides
434
+ ): Promise<void> {
435
+ try {
436
+ return await this.contract
437
+ .getFunction("confirmAggregator(address)")
438
+ .staticCall(_aggregator, overrides || {});
439
+ } catch (e) {
440
+ throw transformEtherError(e, undefined);
441
+ }
442
+ },
443
+ async proposeAggregator(
444
+ _aggregator: string,
445
+ overrides?: Overrides
446
+ ): Promise<void> {
447
+ try {
448
+ return await this.contract
449
+ .getFunction("proposeAggregator(address)")
450
+ .staticCall(_aggregator, overrides || {});
451
+ } catch (e) {
452
+ throw transformEtherError(e, undefined);
453
+ }
454
+ },
455
+ async setController(
456
+ _accessController: string,
457
+ overrides?: Overrides
458
+ ): Promise<void> {
459
+ try {
460
+ return await this.contract
461
+ .getFunction("setController(address)")
462
+ .staticCall(_accessController, overrides || {});
463
+ } catch (e) {
464
+ throw transformEtherError(e, undefined);
465
+ }
466
+ },
467
+ async transferOwnership(_to: string, overrides?: Overrides): Promise<void> {
468
+ try {
469
+ return await this.contract
470
+ .getFunction("transferOwnership(address)")
471
+ .staticCall(_to, overrides || {});
472
+ } catch (e) {
473
+ throw transformEtherError(e, undefined);
474
+ }
475
+ },
476
+ };
417
477
  }
418
478
 
419
479
  export class EACAggregatorProxyBoundContractView extends BoundContractView<
@@ -596,6 +656,51 @@ export class EACAggregatorProxyBoundContractView extends BoundContractView<
596
656
  ...overrides,
597
657
  });
598
658
  }
659
+
660
+ callStatic = {
661
+ view: this.view,
662
+ context: this.context,
663
+
664
+ async acceptOwnership(overrides?: Overrides): Promise<void> {
665
+ return await this.view.callStatic.acceptOwnership({
666
+ blockTag: this.context.blockNumber,
667
+ ...overrides,
668
+ });
669
+ },
670
+ async confirmAggregator(
671
+ _aggregator: string,
672
+ overrides?: Overrides
673
+ ): Promise<void> {
674
+ return await this.view.callStatic.confirmAggregator(_aggregator, {
675
+ blockTag: this.context.blockNumber,
676
+ ...overrides,
677
+ });
678
+ },
679
+ async proposeAggregator(
680
+ _aggregator: string,
681
+ overrides?: Overrides
682
+ ): Promise<void> {
683
+ return await this.view.callStatic.proposeAggregator(_aggregator, {
684
+ blockTag: this.context.blockNumber,
685
+ ...overrides,
686
+ });
687
+ },
688
+ async setController(
689
+ _accessController: string,
690
+ overrides?: Overrides
691
+ ): Promise<void> {
692
+ return await this.view.callStatic.setController(_accessController, {
693
+ blockTag: this.context.blockNumber,
694
+ ...overrides,
695
+ });
696
+ },
697
+ async transferOwnership(_to: string, overrides?: Overrides): Promise<void> {
698
+ return await this.view.callStatic.transferOwnership(_to, {
699
+ blockTag: this.context.blockNumber,
700
+ ...overrides,
701
+ });
702
+ },
703
+ };
599
704
  }
600
705
 
601
706
  export type EACAggregatorProxyContext = ContractContext<
@@ -121,6 +121,7 @@ const templateContract = ERC1155__factory.connect("0x0", DummyProvider);
121
121
  export class ERC1155ContractView extends ContractView<ERC1155> {
122
122
  constructor(contract: ERC1155) {
123
123
  super(contract);
124
+ this.callStatic.contract = contract;
124
125
  }
125
126
 
126
127
  async balanceOf(
@@ -191,6 +192,60 @@ export class ERC1155ContractView extends ContractView<ERC1155> {
191
192
  throw transformEtherError(e, undefined);
192
193
  }
193
194
  }
195
+
196
+ callStatic = {
197
+ contract: this.contract,
198
+
199
+ async safeBatchTransferFrom(
200
+ from: string,
201
+ to: string,
202
+ ids: BigNumberish[],
203
+ amounts: BigNumberish[],
204
+ data: BytesLike,
205
+ overrides?: Overrides
206
+ ): Promise<void> {
207
+ try {
208
+ return await this.contract
209
+ .getFunction(
210
+ "safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)"
211
+ )
212
+ .staticCall(from, to, ids, amounts, data, overrides || {});
213
+ } catch (e) {
214
+ throw transformEtherError(e, undefined);
215
+ }
216
+ },
217
+ async safeTransferFrom(
218
+ from: string,
219
+ to: string,
220
+ id: BigNumberish,
221
+ amount: BigNumberish,
222
+ data: BytesLike,
223
+ overrides?: Overrides
224
+ ): Promise<void> {
225
+ try {
226
+ return await this.contract
227
+ .getFunction(
228
+ "safeTransferFrom(address,address,uint256,uint256,bytes)"
229
+ )
230
+ .staticCall(from, to, id, amount, data, overrides || {});
231
+ } catch (e) {
232
+ throw transformEtherError(e, undefined);
233
+ }
234
+ },
235
+ async setApprovalForAll(
236
+ operator: string,
237
+ approved: boolean,
238
+ overrides?: Overrides
239
+ ): Promise<void> {
240
+ try {
241
+ return await this.contract
242
+ .getFunction("setApprovalForAll(address,bool)")
243
+ .staticCall(operator, approved, overrides || {});
244
+ } catch (e) {
245
+ throw transformEtherError(e, undefined);
246
+ }
247
+ },
248
+ };
194
249
  }
195
250
 
196
251
  export class ERC1155BoundContractView extends BoundContractView<
@@ -246,6 +301,62 @@ export class ERC1155BoundContractView extends BoundContractView<
246
301
  ...overrides,
247
302
  });
248
303
  }
304
+
305
+ callStatic = {
306
+ view: this.view,
307
+ context: this.context,
308
+
309
+ async safeBatchTransferFrom(
310
+ from: string,
311
+ to: string,
312
+ ids: BigNumberish[],
313
+ amounts: BigNumberish[],
314
+ data: BytesLike,
315
+ overrides?: Overrides
316
+ ): Promise<void> {
317
+ return await this.view.callStatic.safeBatchTransferFrom(
318
+ from,
319
+ to,
320
+ ids,
321
+ amounts,
322
+ data,
323
+ {
324
+ blockTag: this.context.blockNumber,
325
+ ...overrides,
326
+ }
327
+ );
328
+ },
329
+ async safeTransferFrom(
330
+ from: string,
331
+ to: string,
332
+ id: BigNumberish,
333
+ amount: BigNumberish,
334
+ data: BytesLike,
335
+ overrides?: Overrides
336
+ ): Promise<void> {
337
+ return await this.view.callStatic.safeTransferFrom(
338
+ from,
339
+ to,
340
+ id,
341
+ amount,
342
+ data,
343
+ {
344
+ blockTag: this.context.blockNumber,
345
+ ...overrides,
346
+ }
347
+ );
348
+ },
349
+ async setApprovalForAll(
350
+ operator: string,
351
+ approved: boolean,
352
+ overrides?: Overrides
353
+ ): Promise<void> {
354
+ return await this.view.callStatic.setApprovalForAll(operator, approved, {
355
+ blockTag: this.context.blockNumber,
356
+ ...overrides,
357
+ });
358
+ },
359
+ };
249
360
  }
250
361
 
251
362
  export type ERC1155Context = ContractContext<ERC1155, ERC1155BoundContractView>;