@sentio/sdk 1.37.0-rc.6 → 1.37.0-rc.7
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/binds.d.ts +1 -1
- package/lib/binds.js +2 -2
- package/lib/binds.js.map +1 -1
- package/lib/core/account-processor.d.ts +1 -1
- package/lib/core/account-processor.js +2 -2
- package/lib/core/account-processor.js.map +1 -1
- package/lib/core/base-processor-template.d.ts +1 -1
- package/lib/core/base-processor-template.js +3 -3
- package/lib/core/base-processor-template.js.map +1 -1
- package/lib/core/core-plugin.d.ts +6 -0
- package/lib/core/core-plugin.js +37 -0
- package/lib/core/core-plugin.js.map +1 -0
- package/lib/core/eth-plugin.d.ts +5 -3
- package/lib/core/eth-plugin.js +34 -11
- package/lib/core/eth-plugin.js.map +1 -1
- package/lib/core/event-tracker.d.ts +1 -1
- package/lib/core/event-tracker.js +2 -2
- package/lib/core/event-tracker.js.map +1 -1
- package/lib/core/exporter.d.ts +1 -1
- package/lib/core/exporter.js +2 -2
- package/lib/core/exporter.js.map +1 -1
- package/lib/core/generic-processor.js +2 -2
- package/lib/core/generic-processor.js.map +1 -1
- package/lib/core/index.d.ts +1 -0
- package/lib/core/index.js +3 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/meter.d.ts +1 -1
- package/lib/core/meter.js +2 -2
- package/lib/core/meter.js.map +1 -1
- package/lib/core/sui-plugin.d.ts +4 -4
- package/lib/core/sui-plugin.js +6 -7
- package/lib/core/sui-plugin.js.map +1 -1
- package/lib/core/sui-processor.d.ts +1 -1
- package/lib/core/sui-processor.js +2 -2
- package/lib/core/sui-processor.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +4 -4
- package/lib/index.js.map +1 -1
- package/lib/testing/test-processor-server.d.ts +1 -1
- package/lib/testing/test-processor-server.js +5 -10
- package/lib/testing/test-processor-server.js.map +1 -1
- package/lib/testing/test-provider.js +2 -2
- package/lib/testing/test-provider.js.map +1 -1
- package/lib/utils/dex-price.test.js.map +1 -1
- package/lib/utils/erc20.test.js.map +1 -1
- package/lib/utils/price.js +2 -1
- package/lib/utils/price.js.map +1 -1
- package/package.json +9 -18
- package/src/binds.ts +1 -1
- package/src/core/account-processor.ts +1 -1
- package/src/core/base-processor-template.ts +1 -1
- package/src/core/core-plugin.ts +39 -0
- package/src/core/eth-plugin.ts +30 -3
- package/src/core/event-tracker.ts +1 -1
- package/src/core/exporter.ts +1 -1
- package/src/core/generic-processor.ts +1 -1
- package/src/core/index.ts +1 -0
- package/src/core/meter.ts +1 -1
- package/src/core/sui-plugin.ts +4 -6
- package/src/core/sui-processor.ts +1 -1
- package/src/index.ts +1 -1
- package/src/testing/test-processor-server.ts +2 -8
- package/src/testing/test-provider.ts +1 -2
- package/src/utils/price.ts +2 -1
- package/lib/chain-config.d.ts +0 -6
- package/lib/chain-config.js +0 -3
- package/lib/chain-config.js.map +0 -1
- package/lib/endpoints.d.ts +0 -6
- package/lib/endpoints.js +0 -11
- package/lib/endpoints.js.map +0 -1
- package/lib/loader.d.ts +0 -5
- package/lib/loader.js +0 -30
- package/lib/loader.js.map +0 -1
- package/lib/processor-runner.d.ts +0 -2
- package/lib/processor-runner.js +0 -102
- package/lib/processor-runner.js.map +0 -1
- package/lib/provider.d.ts +0 -6
- package/lib/provider.js +0 -66
- package/lib/provider.js.map +0 -1
- package/lib/service.d.ts +0 -21
- package/lib/service.js +0 -190
- package/lib/service.js.map +0 -1
- package/src/chain-config.ts +0 -6
- package/src/endpoints.ts +0 -9
- package/src/loader.ts +0 -24
- package/src/processor-runner.ts +0 -93
- package/src/provider.ts +0 -74
- package/src/service.ts +0 -197
- package/src/types/global.d.ts +0 -15
package/lib/binds.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { BindOptions } from './core/bind-options';
|
|
|
2
2
|
import { BaseProcessor, ContractView } from './core';
|
|
3
3
|
import { Networkish } from '@ethersproject/networks';
|
|
4
4
|
import { BaseContract } from 'ethers';
|
|
5
|
-
import { MapStateStorage } from '@sentio/
|
|
5
|
+
import { MapStateStorage } from '@sentio/runtime';
|
|
6
6
|
export declare class ProcessorState extends MapStateStorage<BaseProcessor<any, any>> {
|
|
7
7
|
static INSTANCE: ProcessorState;
|
|
8
8
|
}
|
package/lib/binds.js
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.addContractByABI = exports.getContractByABI = exports.addProcessor = exports.getProcessor = exports.ProcessorState = void 0;
|
|
4
4
|
const bind_options_1 = require("./core/bind-options");
|
|
5
5
|
const providers_1 = require("@ethersproject/providers");
|
|
6
|
-
const
|
|
7
|
-
class ProcessorState extends
|
|
6
|
+
const runtime_1 = require("@sentio/runtime");
|
|
7
|
+
class ProcessorState extends runtime_1.MapStateStorage {
|
|
8
8
|
static INSTANCE = new ProcessorState();
|
|
9
9
|
}
|
|
10
10
|
exports.ProcessorState = ProcessorState;
|
package/lib/binds.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binds.js","sourceRoot":"","sources":["../src/binds.ts"],"names":[],"mappings":";;;AAAA,sDAAsE;AAGtE,wDAAqD;AAErD,
|
|
1
|
+
{"version":3,"file":"binds.js","sourceRoot":"","sources":["../src/binds.ts"],"names":[],"mappings":";;;AAAA,sDAAsE;AAGtE,wDAAqD;AAErD,6CAAiD;AAEjD,MAAa,cAAe,SAAQ,yBAAwC;IAC1E,MAAM,CAAC,QAAQ,GAAG,IAAI,cAAc,EAAE,CAAA;;AADxC,wCAEC;AAED,mDAAmD;AACnD,MAAM,SAAS,GAAG,IAAI,GAAG,EAAsC,CAAA;AAE/D,SAAS,MAAM,CAAC,OAAe,EAAE,OAAe,EAAE,OAAmB;IACnE,MAAM,OAAO,GAAG,IAAA,sBAAU,EAAC,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAA;IACtD,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,EAAE,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC5D,CAAC;AAED,2CAA2C;AAC3C,SAAgB,YAAY,CAAC,IAAiB;IAC5C,MAAM,GAAG,GAAG,IAAA,kCAAmB,EAAC,IAAI,CAAC,CAAA;IACrC,OAAO,cAAc,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;AAC9C,CAAC;AAHD,oCAGC;AAED,SAAgB,YAAY,CAAC,IAAiB,EAAE,SAAkC;IAChF,MAAM,GAAG,GAAG,IAAA,kCAAmB,EAAC,IAAI,CAAC,CAAA;IAErC,cAAc,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,EAAE,SAAS,CAAC,CAAA;AACvD,CAAC;AAJD,oCAIC;AAED,SAAgB,gBAAgB,CAAC,OAAe,EAAE,OAAe,EAAE,OAAmB;IACpF,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IAC7C,OAAO,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAC3B,CAAC;AAHD,4CAGC;AAED,SAAgB,gBAAgB,CAC9B,OAAe,EACf,OAAe,EACf,OAAmB,EACnB,QAAoC;IAEpC,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IAC7C,OAAO,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;AACrC,CAAC;AARD,4CAQC","sourcesContent":["import { BindOptions, getOptionsSignature } from './core/bind-options'\nimport { BaseProcessor, ContractView } from './core'\nimport { Networkish } from '@ethersproject/networks'\nimport { getNetwork } from '@ethersproject/providers'\nimport { BaseContract } from 'ethers'\nimport { MapStateStorage } from '@sentio/runtime'\n\nexport class ProcessorState extends MapStateStorage<BaseProcessor<any, any>> {\n static INSTANCE = new ProcessorState()\n}\n\n// from abiName_address_chainId => contract wrapper\nconst contracts = new Map<string, ContractView<BaseContract>>()\n\nfunction getKey(abiName: string, address: string, network: Networkish) {\n const chainId = getNetwork(network).chainId.toString()\n return [abiName, address.toLowerCase(), chainId].join('_')\n}\n\n// Dedup processor that bind multiple times\nexport function getProcessor(opts: BindOptions) {\n const sig = getOptionsSignature(opts)\n return ProcessorState.INSTANCE.getValue(sig)\n}\n\nexport function addProcessor(opts: BindOptions, processor: BaseProcessor<any, any>) {\n const sig = getOptionsSignature(opts)\n\n ProcessorState.INSTANCE.getOrSetValue(sig, processor)\n}\n\nexport function getContractByABI(abiName: string, address: string, network: Networkish) {\n const key = getKey(abiName, address, network)\n return contracts.get(key)\n}\n\nexport function addContractByABI(\n abiName: string,\n address: string,\n network: Networkish,\n contract: ContractView<BaseContract>\n) {\n const key = getKey(abiName, address, network)\n return contracts.set(key, contract)\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ListStateStorage } from '@sentio/
|
|
1
|
+
import { ListStateStorage } from '@sentio/runtime';
|
|
2
2
|
import { AccountBindOptions } from './bind-options';
|
|
3
3
|
import { TransferEvent as ERC20TransferEvent } from '../builtin/internal/ERC20';
|
|
4
4
|
import { TransferEvent as ERC721TransferEvent } from '../builtin/internal/ERC721';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AccountProcessor = exports.AccountProcessorState = void 0;
|
|
4
|
-
const
|
|
4
|
+
const runtime_1 = require("@sentio/runtime");
|
|
5
5
|
const internal_1 = require("../builtin/internal");
|
|
6
6
|
const sdk_1 = require("@sentio/sdk");
|
|
7
7
|
const providers_1 = require("@ethersproject/providers");
|
|
8
8
|
const context_1 = require("./context");
|
|
9
|
-
class AccountProcessorState extends
|
|
9
|
+
class AccountProcessorState extends runtime_1.ListStateStorage {
|
|
10
10
|
static INSTANCE = new AccountProcessorState();
|
|
11
11
|
}
|
|
12
12
|
exports.AccountProcessorState = AccountProcessorState;
|
|
@@ -1 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AO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;oBACzB,OAAO,GAAG,CAAC,gBAAgB,EAAE,CAAA;iBAC9B;gBACD,OAAO,mBAAa,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;YACtC,CAAC;SACF,CAAC,CAAA;QAEF,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AApMD,4CAoMC","sourcesContent":["import { ListStateStorage } from '@sentio/base'\nimport { ERC20__factory, ERC721__factory } from '../builtin/internal'\nimport { AddressType, DummyProvider, ProcessResult } from '@sentio/sdk'\nimport { AccountBindOptions } from './bind-options'\nimport { getNetwork } from '@ethersproject/providers'\nimport { TransferEvent as ERC20TransferEvent } from '../builtin/internal/ERC20'\nimport { TransferEvent as ERC721TransferEvent } from '../builtin/internal/ERC721'\nimport { AccountContext } from './context'\nimport { PromiseOrVoid } from '../promise-or-void'\nimport { Event } from '@ethersproject/contracts'\nimport { BytesLike } from '@ethersproject/bytes'\nimport { AddressOrTypeEventFilter, EventsHandler } from './base-processor'\n\nexport class AccountProcessorState extends ListStateStorage<AccountProcessor> {\n static INSTANCE = new AccountProcessorState()\n}\n\nconst ERC20_CONTRACT = ERC20__factory.connect('', DummyProvider)\nconst ERC721_CONTRACT = ERC721__factory.connect('', DummyProvider)\n\nexport class AccountProcessor {\n config: AccountBindOptions\n eventHandlers: EventsHandler[] = []\n\n static bind(config: AccountBindOptions): AccountProcessor {\n const processor = new AccountProcessor(config)\n AccountProcessorState.INSTANCE.addValue(processor)\n return processor\n }\n\n protected constructor(config: AccountBindOptions) {\n this.config = config\n }\n\n public getChainId(): number {\n return getNetwork(this.config.network || 1).chainId\n }\n\n /**\n * Register custom handler function to process erc20 transfer event to this account\n * @param handler custom handler function\n * @param tokensAddresses all the erc20 token address to watch\n */\n onERC20TransferIn(\n handler: (event: ERC20TransferEvent, ctx: AccountContext) => PromiseOrVoid,\n tokensAddresses: string[] = []\n ) {\n return this.onERC20(handler, tokensAddresses, (address: string) =>\n ERC20_CONTRACT.filters.Transfer(null, this.config.address)\n )\n }\n\n /**\n * Register custom handler function to process erc20 transfer event from this account\n * @param handler custom handler function\n * @param tokensAddresses all the erc20 token address to watch\n */\n onERC20TransferOut(\n handler: (event: ERC20TransferEvent, ctx: AccountContext) => PromiseOrVoid,\n tokensAddresses: string[] = []\n ) {\n return this.onERC20(handler, tokensAddresses, (address: string) =>\n ERC20_CONTRACT.filters.Transfer(this.config.address)\n )\n }\n\n /**\n * Register custom handler function to process erc20 mint for this account\n * @param handler custom handler function\n * @param tokensAddresses all the erc20 token address to watch\n */\n onERC20Minted(\n handler: (event: ERC20TransferEvent, ctx: AccountContext) => PromiseOrVoid,\n tokensAddresses: string[] = []\n ) {\n return this.onERC20(handler, tokensAddresses, (address: string) =>\n ERC20_CONTRACT.filters.Transfer('0x0000000000000000000000000000000000000000', this.config.address)\n )\n }\n\n private onERC20(\n handler: (event: ERC20TransferEvent, ctx: AccountContext) => PromiseOrVoid,\n tokensAddresses: string[] = [],\n defaultFilter: (address: string) => AddressOrTypeEventFilter\n ) {\n return this.onERC(handler, tokensAddresses, defaultFilter, AddressType.ERC20)\n }\n\n /**\n * Register custom handler function to process ERC721 transfer event to this account\n * @param handler custom handler function\n * @param collections all the ERC721 token address to watch, if not provided then watch all ERC721\n */\n onERC721TransferIn(\n handler: (event: ERC721TransferEvent, ctx: AccountContext) => PromiseOrVoid,\n collections: string[]\n ) {\n return this.onERC721(handler, collections, (address: string) =>\n ERC721_CONTRACT.filters.Transfer(null, this.config.address)\n )\n }\n\n /**\n * Register custom handler function to process ERC721 transfer event from this account\n * @param handler custom handler function\n * @param collections all the ERC721 token address to watch, if not provided then watch all ERC721\n */\n onERC721TransferOut(\n handler: (event: ERC721TransferEvent, ctx: AccountContext) => PromiseOrVoid,\n collections: string[]\n ) {\n return this.onERC721(handler, collections, (address: string) =>\n ERC721_CONTRACT.filters.Transfer(this.config.address)\n )\n }\n\n /**\n * Register custom handler function to process ERC721 mint for this account\n * @param handler custom handler function\n * @param collections all the ERC721 token address to watch, if not provided then watch all ERC721\n */\n onERC721Minted(\n handler: (event: ERC721TransferEvent, ctx: AccountContext) => PromiseOrVoid,\n collections: string[] = []\n ) {\n return this.onERC721(handler, collections, (address: string) =>\n ERC721_CONTRACT.filters.Transfer('0x0000000000000000000000000000000000000000', this.config.address)\n )\n }\n\n private onERC721(\n handler: (event: ERC721TransferEvent, ctx: AccountContext) => PromiseOrVoid,\n collections: string[],\n defaultFilter: (address: string) => AddressOrTypeEventFilter\n ) {\n return this.onERC(handler, collections, defaultFilter, AddressType.ERC721)\n }\n\n private onERC(\n handler: (event: any, ctx: AccountContext) => PromiseOrVoid,\n contractAddresses: string[],\n defaultFilter: (address: string) => AddressOrTypeEventFilter,\n addressType: AddressType\n ) {\n const filters = []\n for (const token of contractAddresses) {\n const filter = defaultFilter(this.config.address)\n filter.address = token\n filters.push(filter)\n }\n if (!filters.length) {\n const filter = defaultFilter(this.config.address)\n filter.address = undefined\n filter.addressType = addressType\n filters.push(filter)\n }\n return this.onEvent(handler, filters)\n }\n\n protected onEvent(\n handler: (event: Event, ctx: AccountContext) => PromiseOrVoid,\n filter: AddressOrTypeEventFilter | AddressOrTypeEventFilter[]\n ) {\n const chainId = this.getChainId()\n\n let _filters: AddressOrTypeEventFilter[] = []\n\n if (Array.isArray(filter)) {\n _filters = filter\n } else {\n _filters.push(filter)\n }\n\n let hasVaildConfig = false\n for (const filter of _filters) {\n if (filter.address) {\n hasVaildConfig = true\n break\n }\n if (filter.topics && filter.topics.length) {\n hasVaildConfig = true\n break\n }\n }\n\n if (!hasVaildConfig) {\n throw Error('no valid config has been found for this account')\n }\n\n const config = this.config\n\n this.eventHandlers.push({\n filters: _filters,\n handler: async function (log) {\n const ctx = new AccountContext(chainId, config.address, undefined, log)\n // let event: Event = <Event>deepCopy(log);\n const event: Event = <Event>log\n const parsed = ERC20_CONTRACT.interface.parseLog(log)\n if (parsed) {\n event.args = parsed.args\n event.decode = (data: BytesLike, topics?: Array<any>) => {\n return ERC20_CONTRACT.interface.decodeEventLog(parsed.eventFragment, data, topics)\n }\n event.event = parsed.name\n event.eventSignature = parsed.signature\n\n // TODO fix this bug\n await handler(event, ctx)\n return ctx.getProcessResult()\n }\n return ProcessResult.fromPartial({})\n },\n })\n\n return this\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"account-processor.js","sourceRoot":"","sources":["../../src/core/account-processor.ts"],"names":[],"mappings":";;;AAAA,6CAAkD;AAClD,kDAAqE;AACrE,qCAAuE;AAEvE,wDAAqD;AAGrD,uCAA0C;AAM1C,MAAa,qBAAsB,SAAQ,0BAAkC;IAC3E,MAAM,CAAC,QAAQ,GAAG,IAAI,qBAAqB,EAAE,CAAA;;AAD/C,sDAEC;AAED,MAAM,cAAc,GAAG,yBAAc,CAAC,OAAO,CAAC,EAAE,EAAE,mBAAa,CAAC,CAAA;AAChE,MAAM,eAAe,GAAG,0BAAe,CAAC,OAAO,CAAC,EAAE,EAAE,mBAAa,CAAC,CAAA;AAElE,MAAa,gBAAgB;IAC3B,MAAM,CAAoB;IAC1B,aAAa,GAAoB,EAAE,CAAA;IAEnC,MAAM,CAAC,IAAI,CAAC,MAA0B;QACpC,MAAM,SAAS,GAAG,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAA;QAC9C,qBAAqB,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;QAClD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,YAAsB,MAA0B;QAC9C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAEM,UAAU;QACf,OAAO,IAAA,sBAAU,EAAC,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO,CAAA;IACrD,CAAC;IAED;;;;OAIG;IACH,iBAAiB,CACf,OAA0E,EAC1E,kBAA4B,EAAE;QAE9B,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,eAAe,EAAE,CAAC,OAAe,EAAE,EAAE,CACh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AC,CAAA;oBACpF,CAAC,CAAA;oBACD,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAA;oBACzB,KAAK,CAAC,cAAc,GAAG,MAAM,CAAC,SAAS,CAAA;oBAEvC,oBAAoB;oBACpB,MAAM,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;oBACzB,OAAO,GAAG,CAAC,gBAAgB,EAAE,CAAA;iBAC9B;gBACD,OAAO,mBAAa,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;YACtC,CAAC;SACF,CAAC,CAAA;QAEF,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AApMD,4CAoMC","sourcesContent":["import { ListStateStorage } from '@sentio/runtime'\nimport { ERC20__factory, ERC721__factory } from '../builtin/internal'\nimport { AddressType, DummyProvider, ProcessResult } from '@sentio/sdk'\nimport { AccountBindOptions } from './bind-options'\nimport { getNetwork } from '@ethersproject/providers'\nimport { TransferEvent as ERC20TransferEvent } from '../builtin/internal/ERC20'\nimport { TransferEvent as ERC721TransferEvent } from '../builtin/internal/ERC721'\nimport { AccountContext } from './context'\nimport { PromiseOrVoid } from '../promise-or-void'\nimport { Event } from '@ethersproject/contracts'\nimport { BytesLike } from '@ethersproject/bytes'\nimport { AddressOrTypeEventFilter, EventsHandler } from './base-processor'\n\nexport class AccountProcessorState extends ListStateStorage<AccountProcessor> {\n static INSTANCE = new AccountProcessorState()\n}\n\nconst ERC20_CONTRACT = ERC20__factory.connect('', DummyProvider)\nconst ERC721_CONTRACT = ERC721__factory.connect('', DummyProvider)\n\nexport class AccountProcessor {\n config: AccountBindOptions\n eventHandlers: EventsHandler[] = []\n\n static bind(config: AccountBindOptions): AccountProcessor {\n const processor = new AccountProcessor(config)\n AccountProcessorState.INSTANCE.addValue(processor)\n return processor\n }\n\n protected constructor(config: AccountBindOptions) {\n this.config = config\n }\n\n public getChainId(): number {\n return getNetwork(this.config.network || 1).chainId\n }\n\n /**\n * Register custom handler function to process erc20 transfer event to this account\n * @param handler custom handler function\n * @param tokensAddresses all the erc20 token address to watch\n */\n onERC20TransferIn(\n handler: (event: ERC20TransferEvent, ctx: AccountContext) => PromiseOrVoid,\n tokensAddresses: string[] = []\n ) {\n return this.onERC20(handler, tokensAddresses, (address: string) =>\n ERC20_CONTRACT.filters.Transfer(null, this.config.address)\n )\n }\n\n /**\n * Register custom handler function to process erc20 transfer event from this account\n * @param handler custom handler function\n * @param tokensAddresses all the erc20 token address to watch\n */\n onERC20TransferOut(\n handler: (event: ERC20TransferEvent, ctx: AccountContext) => PromiseOrVoid,\n tokensAddresses: string[] = []\n ) {\n return this.onERC20(handler, tokensAddresses, (address: string) =>\n ERC20_CONTRACT.filters.Transfer(this.config.address)\n )\n }\n\n /**\n * Register custom handler function to process erc20 mint for this account\n * @param handler custom handler function\n * @param tokensAddresses all the erc20 token address to watch\n */\n onERC20Minted(\n handler: (event: ERC20TransferEvent, ctx: AccountContext) => PromiseOrVoid,\n tokensAddresses: string[] = []\n ) {\n return this.onERC20(handler, tokensAddresses, (address: string) =>\n ERC20_CONTRACT.filters.Transfer('0x0000000000000000000000000000000000000000', this.config.address)\n )\n }\n\n private onERC20(\n handler: (event: ERC20TransferEvent, ctx: AccountContext) => PromiseOrVoid,\n tokensAddresses: string[] = [],\n defaultFilter: (address: string) => AddressOrTypeEventFilter\n ) {\n return this.onERC(handler, tokensAddresses, defaultFilter, AddressType.ERC20)\n }\n\n /**\n * Register custom handler function to process ERC721 transfer event to this account\n * @param handler custom handler function\n * @param collections all the ERC721 token address to watch, if not provided then watch all ERC721\n */\n onERC721TransferIn(\n handler: (event: ERC721TransferEvent, ctx: AccountContext) => PromiseOrVoid,\n collections: string[]\n ) {\n return this.onERC721(handler, collections, (address: string) =>\n ERC721_CONTRACT.filters.Transfer(null, this.config.address)\n )\n }\n\n /**\n * Register custom handler function to process ERC721 transfer event from this account\n * @param handler custom handler function\n * @param collections all the ERC721 token address to watch, if not provided then watch all ERC721\n */\n onERC721TransferOut(\n handler: (event: ERC721TransferEvent, ctx: AccountContext) => PromiseOrVoid,\n collections: string[]\n ) {\n return this.onERC721(handler, collections, (address: string) =>\n ERC721_CONTRACT.filters.Transfer(this.config.address)\n )\n }\n\n /**\n * Register custom handler function to process ERC721 mint for this account\n * @param handler custom handler function\n * @param collections all the ERC721 token address to watch, if not provided then watch all ERC721\n */\n onERC721Minted(\n handler: (event: ERC721TransferEvent, ctx: AccountContext) => PromiseOrVoid,\n collections: string[] = []\n ) {\n return this.onERC721(handler, collections, (address: string) =>\n ERC721_CONTRACT.filters.Transfer('0x0000000000000000000000000000000000000000', this.config.address)\n )\n }\n\n private onERC721(\n handler: (event: ERC721TransferEvent, ctx: AccountContext) => PromiseOrVoid,\n collections: string[],\n defaultFilter: (address: string) => AddressOrTypeEventFilter\n ) {\n return this.onERC(handler, collections, defaultFilter, AddressType.ERC721)\n }\n\n private onERC(\n handler: (event: any, ctx: AccountContext) => PromiseOrVoid,\n contractAddresses: string[],\n defaultFilter: (address: string) => AddressOrTypeEventFilter,\n addressType: AddressType\n ) {\n const filters = []\n for (const token of contractAddresses) {\n const filter = defaultFilter(this.config.address)\n filter.address = token\n filters.push(filter)\n }\n if (!filters.length) {\n const filter = defaultFilter(this.config.address)\n filter.address = undefined\n filter.addressType = addressType\n filters.push(filter)\n }\n return this.onEvent(handler, filters)\n }\n\n protected onEvent(\n handler: (event: Event, ctx: AccountContext) => PromiseOrVoid,\n filter: AddressOrTypeEventFilter | AddressOrTypeEventFilter[]\n ) {\n const chainId = this.getChainId()\n\n let _filters: AddressOrTypeEventFilter[] = []\n\n if (Array.isArray(filter)) {\n _filters = filter\n } else {\n _filters.push(filter)\n }\n\n let hasVaildConfig = false\n for (const filter of _filters) {\n if (filter.address) {\n hasVaildConfig = true\n break\n }\n if (filter.topics && filter.topics.length) {\n hasVaildConfig = true\n break\n }\n }\n\n if (!hasVaildConfig) {\n throw Error('no valid config has been found for this account')\n }\n\n const config = this.config\n\n this.eventHandlers.push({\n filters: _filters,\n handler: async function (log) {\n const ctx = new AccountContext(chainId, config.address, undefined, log)\n // let event: Event = <Event>deepCopy(log);\n const event: Event = <Event>log\n const parsed = ERC20_CONTRACT.interface.parseLog(log)\n if (parsed) {\n event.args = parsed.args\n event.decode = (data: BytesLike, topics?: Array<any>) => {\n return ERC20_CONTRACT.interface.decodeEventLog(parsed.eventFragment, data, topics)\n }\n event.event = parsed.name\n event.eventSignature = parsed.signature\n\n // TODO fix this bug\n await handler(event, ctx)\n return ctx.getProcessResult()\n }\n return ProcessResult.fromPartial({})\n },\n })\n\n return this\n }\n}\n"]}
|
|
@@ -7,7 +7,7 @@ import { BindOptions } from './bind-options';
|
|
|
7
7
|
import { HandleInterval, TemplateInstance } from '@sentio/protos';
|
|
8
8
|
import { PromiseOrVoid } from '../promise-or-void';
|
|
9
9
|
import { Trace } from './trace';
|
|
10
|
-
import { ListStateStorage } from '@sentio/
|
|
10
|
+
import { ListStateStorage } from '@sentio/runtime';
|
|
11
11
|
export declare class ProcessorTemplateProcessorState extends ListStateStorage<BaseProcessorTemplate<BaseContract, BoundContractView<BaseContract, any>>> {
|
|
12
12
|
static INSTANCE: ProcessorTemplateProcessorState;
|
|
13
13
|
}
|
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BaseProcessorTemplate = exports.TemplateInstanceState = exports.ProcessorTemplateProcessorState = void 0;
|
|
4
4
|
const bind_options_1 = require("./bind-options");
|
|
5
5
|
const providers_1 = require("@ethersproject/providers");
|
|
6
|
-
const
|
|
7
|
-
class ProcessorTemplateProcessorState extends
|
|
6
|
+
const runtime_1 = require("@sentio/runtime");
|
|
7
|
+
class ProcessorTemplateProcessorState extends runtime_1.ListStateStorage {
|
|
8
8
|
static INSTANCE = new ProcessorTemplateProcessorState();
|
|
9
9
|
}
|
|
10
10
|
exports.ProcessorTemplateProcessorState = ProcessorTemplateProcessorState;
|
|
11
|
-
class TemplateInstanceState extends
|
|
11
|
+
class TemplateInstanceState extends runtime_1.ListStateStorage {
|
|
12
12
|
static INSTANCE = new TemplateInstanceState();
|
|
13
13
|
}
|
|
14
14
|
exports.TemplateInstanceState = TemplateInstanceState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-processor-template.js","sourceRoot":"","sources":["../../src/core/base-processor-template.ts"],"names":[],"mappings":";;;AAKA,iDAAiE;AAEjE,wDAAqD;AAGrD,
|
|
1
|
+
{"version":3,"file":"base-processor-template.js","sourceRoot":"","sources":["../../src/core/base-processor-template.ts"],"names":[],"mappings":";;;AAKA,iDAAiE;AAEjE,wDAAqD;AAGrD,6CAAkD;AAElD,MAAa,+BAAgC,SAAQ,0BAEpD;IACC,MAAM,CAAC,QAAQ,GAAG,IAAI,+BAA+B,EAAE,CAAA;;AAHzD,0EAIC;AAED,MAAa,qBAAsB,SAAQ,0BAAkC;IAC3E,MAAM,CAAC,QAAQ,GAAG,IAAI,qBAAqB,EAAE,CAAA;;AAD/C,sDAEC;AAED,MAAsB,qBAAqB;IAIzC,EAAE,CAAQ;IACV,KAAK,GAAG,IAAI,GAAG,EAAU,CAAA;IACzB,aAAa,GAIP,EAAE,CAAA;IACR,aAAa,GAGP,EAAE,CAAA;IACR,aAAa,GAGP,EAAE,CAAA;IAER;QACE,IAAI,CAAC,EAAE,GAAG,+BAA+B,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC,MAAM,CAAA;QACrE,+BAA+B,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IACzD,CAAC;IAEM,IAAI,CAAC,OAAoB;QAC9B,MAAM,GAAG,GAAG,IAAA,kCAAmB,EAAC,OAAO,CAAC,CAAA;QACxC,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YACvB,OAAM;SACP;QACD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAEnB,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,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AAA;IACb,CAAC;IAEM,OAAO,CAAC,OAA6F;QAC1G,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;IACtC,CAAC;IAEM,eAAe,CACpB,OAA6F,EAC7F,aAAa,GAAG,IAAI,EACpB,qBAAqB,GAAG,IAAI;QAE5B,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,SAAS,EAAE;YACzC,cAAc,EAAE,aAAa;YAC7B,gBAAgB,EAAE,qBAAqB;SACxC,CAAC,CAAA;IACJ,CAAC;IAEM,cAAc,CACnB,OAA6F,EAC7F,qBAAqB,GAAG,EAAE,EAC1B,qBAAqB,GAAG,GAAG;QAE3B,OAAO,IAAI,CAAC,UAAU,CACpB,OAAO,EACP,EAAE,cAAc,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,EAClF,SAAS,CACV,CAAA;IACH,CAAC;IAEM,UAAU,CACf,OAA6F,EAC7F,YAAwC,EACxC,aAAyC;QAEzC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC,CAAA;QACvG,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,OAAO,CACZ,SAAiB,EACjB,OAA6F;QAE7F,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAA;QAC/C,OAAO,IAAI,CAAA;IACb,CAAC;CAGF;AAtHD,sDAsHC","sourcesContent":["import { BoundContractView, ContractContext, ContractView } from './context'\nimport { Block } from '@ethersproject/abstract-provider'\nimport { BaseContract, EventFilter } from 'ethers'\nimport { Event } from '@ethersproject/contracts'\nimport { BaseProcessor } from './base-processor'\nimport { BindOptions, getOptionsSignature } from './bind-options'\nimport { HandleInterval, TemplateInstance } from '@sentio/protos'\nimport { getNetwork } from '@ethersproject/providers'\nimport { PromiseOrVoid } from '../promise-or-void'\nimport { Trace } from './trace'\nimport { ListStateStorage } from '@sentio/runtime'\n\nexport class ProcessorTemplateProcessorState extends ListStateStorage<\n BaseProcessorTemplate<BaseContract, BoundContractView<BaseContract, any>>\n> {\n static INSTANCE = new ProcessorTemplateProcessorState()\n}\n\nexport class TemplateInstanceState extends ListStateStorage<TemplateInstance> {\n static INSTANCE = new TemplateInstanceState()\n}\n\nexport abstract class BaseProcessorTemplate<\n TContract extends BaseContract,\n TBoundContractView extends BoundContractView<TContract, ContractView<TContract>>\n> {\n id: number\n binds = new Set<string>()\n blockHandlers: {\n handler: (block: Block, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid\n blockInterval?: HandleInterval\n timeIntervalInMinutes?: HandleInterval\n }[] = []\n traceHandlers: {\n signature: string\n handler: (trace: Trace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid\n }[] = []\n eventHandlers: {\n handler: (event: Event, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid\n filter: EventFilter | EventFilter[]\n }[] = []\n\n constructor() {\n this.id = ProcessorTemplateProcessorState.INSTANCE.getValues().length\n ProcessorTemplateProcessorState.INSTANCE.addValue(this)\n }\n\n public bind(options: BindOptions) {\n const sig = getOptionsSignature(options)\n if (this.binds.has(sig)) {\n return\n }\n this.binds.add(sig)\n\n const processor = this.bindInternal(options)\n\n for (const eh of this.eventHandlers) {\n processor.onEvent(eh.handler, eh.filter)\n }\n for (const bh of this.blockHandlers) {\n processor.onInterval(bh.handler, bh.timeIntervalInMinutes, bh.blockInterval)\n }\n\n const instance: TemplateInstance = {\n templateId: this.id,\n contract: {\n address: options.address,\n name: options.name || '',\n chainId: options.network ? getNetwork(options.network).chainId.toString() : '1',\n abi: '',\n },\n startBlock: 0n,\n endBlock: 0n,\n }\n if (options.startBlock) {\n instance.startBlock = BigInt(options.startBlock)\n }\n if (options.endBlock) {\n instance.endBlock = BigInt(options.endBlock)\n }\n TemplateInstanceState.INSTANCE.addValue(instance)\n return processor\n }\n\n public onEvent(\n handler: (event: Event, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n filter: EventFilter | EventFilter[]\n ) {\n this.eventHandlers.push({\n handler: handler,\n filter: filter,\n })\n return this\n }\n\n public onBlock(handler: (block: Block, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid) {\n return this.onBlockInterval(handler)\n }\n\n public onBlockInterval(\n handler: (block: Block, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n blockInterval = 1000,\n backfillBlockInterval = 4000\n ) {\n return this.onInterval(handler, undefined, {\n recentInterval: blockInterval,\n backfillInterval: backfillBlockInterval,\n })\n }\n\n public onTimeInterval(\n handler: (block: Block, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n timeIntervalInMinutes = 60,\n backfillBlockInterval = 240\n ) {\n return this.onInterval(\n handler,\n { recentInterval: timeIntervalInMinutes, backfillInterval: backfillBlockInterval },\n undefined\n )\n }\n\n public onInterval(\n handler: (block: Block, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n timeInterval: HandleInterval | undefined,\n blockInterval: HandleInterval | undefined\n ) {\n this.blockHandlers.push({ handler, timeIntervalInMinutes: timeInterval, blockInterval: blockInterval })\n return this\n }\n\n public onTrace(\n signature: string,\n handler: (trace: Trace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid\n ) {\n this.traceHandlers.push({ signature, handler })\n return this\n }\n\n protected abstract bindInternal(options: BindOptions): BaseProcessor<TContract, TBoundContractView>\n}\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CorePlugin = void 0;
|
|
4
|
+
const runtime_1 = require("@sentio/runtime");
|
|
5
|
+
const meter_1 = require("./meter");
|
|
6
|
+
const event_tracker_1 = require("./event-tracker");
|
|
7
|
+
const exporter_1 = require("./exporter");
|
|
8
|
+
class CorePlugin extends runtime_1.Plugin {
|
|
9
|
+
name = 'CorePlugin';
|
|
10
|
+
configure(config) {
|
|
11
|
+
// part 0, prepare metrics and event tracking configs
|
|
12
|
+
for (const metric of meter_1.MetricState.INSTANCE.getValues()) {
|
|
13
|
+
config.metricConfigs.push({
|
|
14
|
+
...metric.config,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
for (const eventTracker of event_tracker_1.EventTrackerState.INSTANCE.getValues()) {
|
|
18
|
+
config.eventTrackingConfigs.push({
|
|
19
|
+
distinctAggregationByDays: eventTracker.options.distinctByDays || [],
|
|
20
|
+
eventName: eventTracker.name,
|
|
21
|
+
retentionConfig: undefined,
|
|
22
|
+
totalByDay: eventTracker.options.totalByDay || false,
|
|
23
|
+
totalPerEntity: undefined,
|
|
24
|
+
unique: eventTracker.options.unique || false,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
for (const exporter of exporter_1.ExporterState.INSTANCE.getValues()) {
|
|
28
|
+
config.exportConfigs.push({
|
|
29
|
+
name: exporter.name,
|
|
30
|
+
channel: exporter.channel,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.CorePlugin = CorePlugin;
|
|
36
|
+
runtime_1.PluginManager.INSTANCE.register(new CorePlugin());
|
|
37
|
+
//# sourceMappingURL=core-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-plugin.js","sourceRoot":"","sources":["../../src/core/core-plugin.ts"],"names":[],"mappings":";;;AAAA,6CAAuD;AAGvD,mCAAqC;AACrC,mDAAmD;AACnD,yCAA0C;AAE1C,MAAa,UAAW,SAAQ,gBAAM;IACpC,IAAI,GAAW,YAAY,CAAA;IAE3B,SAAS,CAAC,MAA6B;QACrC,qDAAqD;QACrD,KAAK,MAAM,MAAM,IAAI,mBAAW,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE;YACrD,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC;gBACxB,GAAG,MAAM,CAAC,MAAM;aACjB,CAAC,CAAA;SACH;QAED,KAAK,MAAM,YAAY,IAAI,iCAAiB,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE;YACjE,MAAM,CAAC,oBAAoB,CAAC,IAAI,CAAC;gBAC/B,yBAAyB,EAAE,YAAY,CAAC,OAAO,CAAC,cAAc,IAAI,EAAE;gBACpE,SAAS,EAAE,YAAY,CAAC,IAAI;gBAC5B,eAAe,EAAE,SAAS;gBAC1B,UAAU,EAAE,YAAY,CAAC,OAAO,CAAC,UAAU,IAAI,KAAK;gBACpD,cAAc,EAAE,SAAS;gBACzB,MAAM,EAAE,YAAY,CAAC,OAAO,CAAC,MAAM,IAAI,KAAK;aAC7C,CAAC,CAAA;SACH;QAED,KAAK,MAAM,QAAQ,IAAI,wBAAa,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE;YACzD,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC;gBACxB,IAAI,EAAE,QAAQ,CAAC,IAAI;gBACnB,OAAO,EAAE,QAAQ,CAAC,OAAO;aAC1B,CAAC,CAAA;SACH;IACH,CAAC;CACF;AA7BD,gCA6BC;AAED,uBAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,UAAU,EAAE,CAAC,CAAA","sourcesContent":["import { Plugin, PluginManager } from '@sentio/runtime'\nimport { ProcessConfigResponse } from '@sentio/protos'\n\nimport { MetricState } from './meter'\nimport { EventTrackerState } from './event-tracker'\nimport { ExporterState } from './exporter'\n\nexport class CorePlugin extends Plugin {\n name: string = 'CorePlugin'\n\n configure(config: ProcessConfigResponse): void {\n // part 0, prepare metrics and event tracking configs\n for (const metric of MetricState.INSTANCE.getValues()) {\n config.metricConfigs.push({\n ...metric.config,\n })\n }\n\n for (const eventTracker of EventTrackerState.INSTANCE.getValues()) {\n config.eventTrackingConfigs.push({\n distinctAggregationByDays: eventTracker.options.distinctByDays || [],\n eventName: eventTracker.name,\n retentionConfig: undefined,\n totalByDay: eventTracker.options.totalByDay || false,\n totalPerEntity: undefined,\n unique: eventTracker.options.unique || false,\n })\n }\n\n for (const exporter of ExporterState.INSTANCE.getValues()) {\n config.exportConfigs.push({\n name: exporter.name,\n channel: exporter.channel,\n })\n }\n }\n}\n\nPluginManager.INSTANCE.register(new CorePlugin())\n"]}
|
package/lib/core/eth-plugin.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Plugin } from '@sentio/
|
|
2
|
-
import { DataBinding, HandlerType, ProcessConfigResponse, ProcessResult } from '@sentio/protos';
|
|
3
|
-
export declare class EthPlugin
|
|
1
|
+
import { Plugin } from '@sentio/runtime';
|
|
2
|
+
import { DataBinding, HandlerType, ProcessConfigResponse, ProcessResult, StartRequest } from '@sentio/protos';
|
|
3
|
+
export declare class EthPlugin extends Plugin {
|
|
4
4
|
name: string;
|
|
5
5
|
private eventHandlers;
|
|
6
6
|
private traceHandlers;
|
|
@@ -8,6 +8,8 @@ export declare class EthPlugin implements Plugin {
|
|
|
8
8
|
configure(config: ProcessConfigResponse): void;
|
|
9
9
|
supportedHandlers: HandlerType[];
|
|
10
10
|
processBinding(request: DataBinding): Promise<ProcessResult>;
|
|
11
|
+
start(request: StartRequest): void;
|
|
12
|
+
stateDiff(config: ProcessConfigResponse): boolean;
|
|
11
13
|
processLog(request: DataBinding): Promise<ProcessResult>;
|
|
12
14
|
processTrace(binding: DataBinding): Promise<ProcessResult>;
|
|
13
15
|
processBlock(binding: DataBinding): Promise<ProcessResult>;
|
package/lib/core/eth-plugin.js
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EthPlugin = void 0;
|
|
4
|
-
const
|
|
4
|
+
const runtime_1 = require("@sentio/runtime");
|
|
5
5
|
const protos_1 = require("@sentio/protos");
|
|
6
|
-
const base_2 = require("@sentio/base");
|
|
7
6
|
const nice_grpc_1 = require("nice-grpc");
|
|
8
7
|
const binds_1 = require("../binds");
|
|
9
8
|
const account_processor_1 = require("./account-processor");
|
|
10
|
-
|
|
9
|
+
const base_processor_template_1 = require("./base-processor-template");
|
|
10
|
+
class EthPlugin extends runtime_1.Plugin {
|
|
11
11
|
name = 'EthPlugin';
|
|
12
12
|
eventHandlers = [];
|
|
13
13
|
traceHandlers = [];
|
|
14
14
|
blockHandlers = [];
|
|
15
15
|
configure(config) {
|
|
16
|
+
// This syntax is to copy values instead of using references
|
|
17
|
+
config.templateInstances = [...base_processor_template_1.TemplateInstanceState.INSTANCE.getValues()];
|
|
16
18
|
for (const processor of binds_1.ProcessorState.INSTANCE.getValues()) {
|
|
17
19
|
// If server favor incremental update this need to change
|
|
18
20
|
// Start basic config for contract
|
|
19
21
|
const chainId = processor.getChainId();
|
|
20
22
|
// this.processorsByChainId.set(chainId, processor)
|
|
21
23
|
const contractConfig = {
|
|
22
|
-
processorType:
|
|
24
|
+
processorType: runtime_1.USER_PROCESSOR,
|
|
23
25
|
contract: {
|
|
24
26
|
name: processor.config.name,
|
|
25
27
|
chainId: chainId.toString(),
|
|
@@ -150,6 +152,27 @@ class EthPlugin {
|
|
|
150
152
|
throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType);
|
|
151
153
|
}
|
|
152
154
|
}
|
|
155
|
+
start(request) {
|
|
156
|
+
for (const instance of request.templateInstances) {
|
|
157
|
+
const template = base_processor_template_1.ProcessorTemplateProcessorState.INSTANCE.getValues()[instance.templateId];
|
|
158
|
+
if (!template) {
|
|
159
|
+
throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INVALID_ARGUMENT, 'Invalid template contract:' + instance);
|
|
160
|
+
}
|
|
161
|
+
if (!instance.contract) {
|
|
162
|
+
throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INVALID_ARGUMENT, 'Contract Empty from:' + instance);
|
|
163
|
+
}
|
|
164
|
+
template.bind({
|
|
165
|
+
name: instance.contract.name,
|
|
166
|
+
address: instance.contract.address,
|
|
167
|
+
network: Number(instance.contract.chainId),
|
|
168
|
+
startBlock: instance.startBlock,
|
|
169
|
+
endBlock: instance.endBlock,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
stateDiff(config) {
|
|
174
|
+
return base_processor_template_1.TemplateInstanceState.INSTANCE.getValues().length !== config.templateInstances.length;
|
|
175
|
+
}
|
|
153
176
|
async processLog(request) {
|
|
154
177
|
if (!request.data) {
|
|
155
178
|
throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INVALID_ARGUMENT, "Log can't be null");
|
|
@@ -165,10 +188,10 @@ class EthPlugin {
|
|
|
165
188
|
for (const handlerId of request.handlerIds) {
|
|
166
189
|
const handler = this.eventHandlers[handlerId];
|
|
167
190
|
promises.push(handler(log).catch((e) => {
|
|
168
|
-
throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INTERNAL, 'error processing log: ' + JSON.stringify(log) + '\n' + (0,
|
|
191
|
+
throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INTERNAL, 'error processing log: ' + JSON.stringify(log) + '\n' + (0, runtime_1.errorString)(e));
|
|
169
192
|
}));
|
|
170
193
|
}
|
|
171
|
-
return (0,
|
|
194
|
+
return (0, runtime_1.mergeProcessResults)(await Promise.all(promises));
|
|
172
195
|
}
|
|
173
196
|
async processTrace(binding) {
|
|
174
197
|
if (!binding.data) {
|
|
@@ -184,10 +207,10 @@ class EthPlugin {
|
|
|
184
207
|
const promises = [];
|
|
185
208
|
for (const handlerId of binding.handlerIds) {
|
|
186
209
|
promises.push(this.traceHandlers[handlerId](trace).catch((e) => {
|
|
187
|
-
throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INTERNAL, 'error processing trace: ' + JSON.stringify(trace) + '\n' + (0,
|
|
210
|
+
throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INTERNAL, 'error processing trace: ' + JSON.stringify(trace) + '\n' + (0, runtime_1.errorString)(e));
|
|
188
211
|
}));
|
|
189
212
|
}
|
|
190
|
-
return (0,
|
|
213
|
+
return (0, runtime_1.mergeProcessResults)(await Promise.all(promises));
|
|
191
214
|
}
|
|
192
215
|
async processBlock(binding) {
|
|
193
216
|
if (!binding.data) {
|
|
@@ -203,12 +226,12 @@ class EthPlugin {
|
|
|
203
226
|
const promises = [];
|
|
204
227
|
for (const handlerId of binding.handlerIds) {
|
|
205
228
|
promises.push(this.blockHandlers[handlerId](block).catch((e) => {
|
|
206
|
-
throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INTERNAL, 'error processing block: ' + block.number + '\n' + (0,
|
|
229
|
+
throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INTERNAL, 'error processing block: ' + block.number + '\n' + (0, runtime_1.errorString)(e));
|
|
207
230
|
}));
|
|
208
231
|
}
|
|
209
|
-
return (0,
|
|
232
|
+
return (0, runtime_1.mergeProcessResults)(await Promise.all(promises));
|
|
210
233
|
}
|
|
211
234
|
}
|
|
212
235
|
exports.EthPlugin = EthPlugin;
|
|
213
|
-
|
|
236
|
+
runtime_1.PluginManager.INSTANCE.register(new EthPlugin());
|
|
214
237
|
//# sourceMappingURL=eth-plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eth-plugin.js","sourceRoot":"","sources":["../../src/core/eth-plugin.ts"],"names":[],"mappings":";;;AAAA,uCAAoD;AACpD,2CASuB;AACvB,uCAA+E;AAE/E,yCAA+C;AAG/C,oCAAyC;AACzC,2DAA2D;AAE3D,MAAa,SAAS;IACpB,IAAI,GAAW,WAAW,CAAA;IAElB,aAAa,GAA+C,EAAE,CAAA;IAC9D,aAAa,GAAiD,EAAE,CAAA;IAChE,aAAa,GAAiD,EAAE,CAAA;IAExE,SAAS,CAAC,MAA6B;QACrC,KAAK,MAAM,SAAS,IAAI,sBAAc,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE;YAC3D,yDAAyD;YACzD,kCAAkC;YAClC,MAAM,OAAO,GAAG,SAAS,CAAC,UAAU,EAAE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GAAG,KAAK,CAAC,MAAM,GAAG,IAAI,GAAG,IAAA,kBAAW,EAAC,CAAC,CAAC,CAAC,CAAA;YAC3G,CAAC,CAAC,CACH,CAAA;SACF;QACD,OAAO,IAAA,0BAAmB,EAAC,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;IACzD,CAAC;CACF;AArOD,8BAqOC;AAED,oBAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,SAAS,EAAE,CAAC,CAAA","sourcesContent":["import { Plugin, PluginManager } from '@sentio/base'\nimport {\n AccountConfig,\n ContractConfig,\n DataBinding,\n HandlerType,\n LogFilter,\n LogHandlerConfig,\n ProcessConfigResponse,\n ProcessResult,\n} from '@sentio/protos'\nimport { errorString, mergeProcessResults, USER_PROCESSOR } from '@sentio/base'\n\nimport { ServerError, Status } from 'nice-grpc'\nimport { Block, Log } from '@ethersproject/abstract-provider'\nimport { Trace } from '@sentio/sdk'\nimport { ProcessorState } from '../binds'\nimport { AccountProcessorState } from './account-processor'\n\nexport class EthPlugin implements Plugin {\n name: string = 'EthPlugin'\n\n private eventHandlers: ((event: Log) => Promise<ProcessResult>)[] = []\n private traceHandlers: ((trace: Trace) => Promise<ProcessResult>)[] = []\n private blockHandlers: ((block: Block) => Promise<ProcessResult>)[] = []\n\n configure(config: ProcessConfigResponse): void {\n for (const processor of ProcessorState.INSTANCE.getValues()) {\n // If server favor incremental update this need to change\n // Start basic config for contract\n const chainId = processor.getChainId()\n // this.processorsByChainId.set(chainId, processor)\n\n const contractConfig: ContractConfig = {\n processorType: USER_PROCESSOR,\n contract: {\n name: processor.config.name,\n chainId: chainId.toString(),\n address: processor.config.address,\n abi: '',\n },\n intervalConfigs: [],\n logConfigs: [],\n traceConfigs: [],\n startBlock: processor.config.startBlock,\n endBlock: 0n,\n instructionConfig: undefined,\n aptosEventConfigs: [],\n aptosCallConfigs: [],\n }\n if (processor.config.endBlock) {\n contractConfig.endBlock = processor.config.endBlock\n }\n\n // Step 1. Prepare all the block handlers\n for (const blockHandler of processor.blockHandlers) {\n const handlerId = this.blockHandlers.push(blockHandler.handler) - 1\n // TODO wrap the block handler into one\n\n contractConfig.intervalConfigs.push({\n slot: 0,\n slotInterval: blockHandler.blockInterval,\n minutes: 0,\n minutesInterval: blockHandler.timeIntervalInMinutes,\n handlerId: handlerId,\n })\n }\n\n // Step 2. Prepare all trace handlers\n for (const traceHandler of processor.traceHandlers) {\n const handlerId = this.traceHandlers.push(traceHandler.handler) - 1\n contractConfig.traceConfigs.push({\n signature: traceHandler.signature,\n handlerId: handlerId,\n })\n }\n\n // Step 3. Prepare all the event handlers\n for (const eventsHandler of processor.eventHandlers) {\n // associate id with filter\n const handlerId = this.eventHandlers.push(eventsHandler.handler) - 1\n const logConfig: LogHandlerConfig = {\n handlerId: handlerId,\n filters: [],\n }\n\n for (const filter of eventsHandler.filters) {\n if (!filter.topics) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Topic should not be null')\n }\n const logFilter: LogFilter = {\n addressType: undefined,\n address: contractConfig.contract?.address,\n topics: [],\n }\n\n for (const ts of filter.topics) {\n let hashes: string[] = []\n if (Array.isArray(ts)) {\n hashes = hashes.concat(ts)\n } else if (ts) {\n hashes.push(ts)\n }\n logFilter.topics.push({ hashes: hashes })\n }\n logConfig.filters.push(logFilter)\n }\n contractConfig.logConfigs.push(logConfig)\n }\n\n // Finish up a contract\n config.contractConfigs.push(contractConfig)\n }\n\n // part 1.b prepare EVM account processors\n for (const processor of AccountProcessorState.INSTANCE.getValues()) {\n const accountConfig: AccountConfig = {\n address: processor.config.address,\n chainId: processor.getChainId().toString(),\n startBlock: processor.config.startBlock ? BigInt(processor.config.startBlock) : 0n,\n aptosIntervalConfigs: [],\n intervalConfigs: [],\n logConfigs: [],\n }\n // TODO add interval\n for (const eventsHandler of processor.eventHandlers) {\n // associate id with filter\n const handlerId = this.eventHandlers.push(eventsHandler.handler) - 1\n const logConfig: LogHandlerConfig = {\n handlerId: handlerId,\n filters: [],\n }\n\n for (const filter of eventsHandler.filters) {\n if (!filter.topics) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Topic should not be null')\n }\n const logFilter: LogFilter = {\n addressType: filter.addressType,\n address: filter.address,\n topics: [],\n }\n\n for (const ts of filter.topics) {\n let hashes: string[] = []\n if (Array.isArray(ts)) {\n hashes = hashes.concat(ts)\n } else if (ts) {\n hashes.push(ts)\n }\n logFilter.topics.push({ hashes: hashes })\n }\n logConfig.filters.push(logFilter)\n }\n accountConfig.logConfigs.push(logConfig)\n }\n\n config.accountConfigs.push(accountConfig)\n }\n }\n\n supportedHandlers = [HandlerType.ETH_LOG, HandlerType.ETH_BLOCK, HandlerType.ETH_TRACE]\n\n processBinding(request: DataBinding): Promise<ProcessResult> {\n // return Promise.resolve(undefined);\n switch (request.handlerType) {\n case HandlerType.ETH_LOG:\n return this.processLog(request)\n case HandlerType.ETH_TRACE:\n return this.processTrace(request)\n case HandlerType.ETH_BLOCK:\n return this.processBlock(request)\n default:\n throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)\n }\n }\n\n async processLog(request: DataBinding): Promise<ProcessResult> {\n if (!request.data) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Log can't be null\")\n }\n\n const promises: Promise<ProcessResult>[] = []\n let log: Log\n if (request.data.ethLog) {\n log = request.data.ethLog.log as Log\n } else {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Log can't be null\")\n }\n\n for (const handlerId of request.handlerIds) {\n const handler = this.eventHandlers[handlerId]\n promises.push(\n handler(log).catch((e) => {\n throw new ServerError(Status.INTERNAL, 'error processing log: ' + JSON.stringify(log) + '\\n' + errorString(e))\n })\n )\n }\n return mergeProcessResults(await Promise.all(promises))\n }\n\n async processTrace(binding: DataBinding): Promise<ProcessResult> {\n if (!binding.data) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Trace can't be empty\")\n }\n let trace: Trace\n if (binding.data.ethTrace?.trace) {\n trace = binding.data.ethTrace.trace as Trace\n } else {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Trace can't be null\")\n }\n\n const promises: Promise<ProcessResult>[] = []\n\n for (const handlerId of binding.handlerIds) {\n promises.push(\n this.traceHandlers[handlerId](trace).catch((e) => {\n throw new ServerError(\n Status.INTERNAL,\n 'error processing trace: ' + JSON.stringify(trace) + '\\n' + errorString(e)\n )\n })\n )\n }\n return mergeProcessResults(await Promise.all(promises))\n }\n\n async processBlock(binding: DataBinding): Promise<ProcessResult> {\n if (!binding.data) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Block can't be empty\")\n }\n let block: Block\n if (binding.data.ethBlock?.block) {\n block = binding.data.ethBlock.block as Block\n } else {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Block can't be empty\")\n }\n\n const promises: Promise<ProcessResult>[] = []\n for (const handlerId of binding.handlerIds) {\n promises.push(\n this.blockHandlers[handlerId](block).catch((e) => {\n throw new ServerError(Status.INTERNAL, 'error processing block: ' + block.number + '\\n' + errorString(e))\n })\n )\n }\n return mergeProcessResults(await Promise.all(promises))\n }\n}\n\nPluginManager.INSTANCE.register(new EthPlugin())\n"]}
|
|
1
|
+
{"version":3,"file":"eth-plugin.js","sourceRoot":"","sources":["../../src/core/eth-plugin.ts"],"names":[],"mappings":";;;AAAA,6CAAyG;AACzG,2CAUuB;AAEvB,yCAA+C;AAG/C,oCAAyC;AACzC,2DAA2D;AAC3D,uEAAkG;AAElG,MAAa,SAAU,SAAQ,gBAAM;IACnC,IAAI,GAAW,WAAW,CAAA;IAElB,aAAa,GAA+C,EAAE,CAAA;IAC9D,aAAa,GAAiD,EAAE,CAAA;IAChE,aAAa,GAAiD,EAAE,CAAA;IAExE,SAAS,CAAC,MAA6B;QACrC,4DAA4D;QAC5D,MAAM,CAAC,iBAAiB,GAAG,CAAC,GAAG,+CAAqB,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAA;QAE1E,KAAK,MAAM,SAAS,IAAI,sBAAc,CAAC,QAAQ,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;IACzD,CAAC;CACF;AA/PD,8BA+PC;AAED,uBAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,SAAS,EAAE,CAAC,CAAA","sourcesContent":["import { Plugin, PluginManager, errorString, mergeProcessResults, USER_PROCESSOR } from '@sentio/runtime'\nimport {\n AccountConfig,\n ContractConfig,\n DataBinding,\n HandlerType,\n LogFilter,\n LogHandlerConfig,\n ProcessConfigResponse,\n ProcessResult,\n StartRequest,\n} from '@sentio/protos'\n\nimport { ServerError, Status } from 'nice-grpc'\nimport { Block, Log } from '@ethersproject/abstract-provider'\nimport { Trace } from '@sentio/sdk'\nimport { ProcessorState } from '../binds'\nimport { AccountProcessorState } from './account-processor'\nimport { ProcessorTemplateProcessorState, TemplateInstanceState } from './base-processor-template'\n\nexport class EthPlugin extends Plugin {\n name: string = 'EthPlugin'\n\n private eventHandlers: ((event: Log) => Promise<ProcessResult>)[] = []\n private traceHandlers: ((trace: Trace) => Promise<ProcessResult>)[] = []\n private blockHandlers: ((block: Block) => Promise<ProcessResult>)[] = []\n\n configure(config: ProcessConfigResponse): void {\n // This syntax is to copy values instead of using references\n config.templateInstances = [...TemplateInstanceState.INSTANCE.getValues()]\n\n for (const processor of ProcessorState.INSTANCE.getValues()) {\n // If server favor incremental update this need to change\n // Start basic config for contract\n const chainId = processor.getChainId()\n // this.processorsByChainId.set(chainId, processor)\n\n const contractConfig: ContractConfig = {\n processorType: USER_PROCESSOR,\n contract: {\n name: processor.config.name,\n chainId: chainId.toString(),\n address: processor.config.address,\n abi: '',\n },\n intervalConfigs: [],\n logConfigs: [],\n traceConfigs: [],\n startBlock: processor.config.startBlock,\n endBlock: 0n,\n instructionConfig: undefined,\n aptosEventConfigs: [],\n aptosCallConfigs: [],\n }\n if (processor.config.endBlock) {\n contractConfig.endBlock = processor.config.endBlock\n }\n\n // Step 1. Prepare all the block handlers\n for (const blockHandler of processor.blockHandlers) {\n const handlerId = this.blockHandlers.push(blockHandler.handler) - 1\n // TODO wrap the block handler into one\n\n contractConfig.intervalConfigs.push({\n slot: 0,\n slotInterval: blockHandler.blockInterval,\n minutes: 0,\n minutesInterval: blockHandler.timeIntervalInMinutes,\n handlerId: handlerId,\n })\n }\n\n // Step 2. Prepare all trace handlers\n for (const traceHandler of processor.traceHandlers) {\n const handlerId = this.traceHandlers.push(traceHandler.handler) - 1\n contractConfig.traceConfigs.push({\n signature: traceHandler.signature,\n handlerId: handlerId,\n })\n }\n\n // Step 3. Prepare all the event handlers\n for (const eventsHandler of processor.eventHandlers) {\n // associate id with filter\n const handlerId = this.eventHandlers.push(eventsHandler.handler) - 1\n const logConfig: LogHandlerConfig = {\n handlerId: handlerId,\n filters: [],\n }\n\n for (const filter of eventsHandler.filters) {\n if (!filter.topics) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Topic should not be null')\n }\n const logFilter: LogFilter = {\n addressType: undefined,\n address: contractConfig.contract?.address,\n topics: [],\n }\n\n for (const ts of filter.topics) {\n let hashes: string[] = []\n if (Array.isArray(ts)) {\n hashes = hashes.concat(ts)\n } else if (ts) {\n hashes.push(ts)\n }\n logFilter.topics.push({ hashes: hashes })\n }\n logConfig.filters.push(logFilter)\n }\n contractConfig.logConfigs.push(logConfig)\n }\n\n // Finish up a contract\n config.contractConfigs.push(contractConfig)\n }\n\n // part 1.b prepare EVM account processors\n for (const processor of AccountProcessorState.INSTANCE.getValues()) {\n const accountConfig: AccountConfig = {\n address: processor.config.address,\n chainId: processor.getChainId().toString(),\n startBlock: processor.config.startBlock ? BigInt(processor.config.startBlock) : 0n,\n aptosIntervalConfigs: [],\n intervalConfigs: [],\n logConfigs: [],\n }\n // TODO add interval\n for (const eventsHandler of processor.eventHandlers) {\n // associate id with filter\n const handlerId = this.eventHandlers.push(eventsHandler.handler) - 1\n const logConfig: LogHandlerConfig = {\n handlerId: handlerId,\n filters: [],\n }\n\n for (const filter of eventsHandler.filters) {\n if (!filter.topics) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Topic should not be null')\n }\n const logFilter: LogFilter = {\n addressType: filter.addressType,\n address: filter.address,\n topics: [],\n }\n\n for (const ts of filter.topics) {\n let hashes: string[] = []\n if (Array.isArray(ts)) {\n hashes = hashes.concat(ts)\n } else if (ts) {\n hashes.push(ts)\n }\n logFilter.topics.push({ hashes: hashes })\n }\n logConfig.filters.push(logFilter)\n }\n accountConfig.logConfigs.push(logConfig)\n }\n\n config.accountConfigs.push(accountConfig)\n }\n }\n\n supportedHandlers = [HandlerType.ETH_LOG, HandlerType.ETH_BLOCK, HandlerType.ETH_TRACE]\n\n processBinding(request: DataBinding): Promise<ProcessResult> {\n // return Promise.resolve(undefined);\n switch (request.handlerType) {\n case HandlerType.ETH_LOG:\n return this.processLog(request)\n case HandlerType.ETH_TRACE:\n return this.processTrace(request)\n case HandlerType.ETH_BLOCK:\n return this.processBlock(request)\n default:\n throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)\n }\n }\n\n start(request: StartRequest) {\n for (const instance of request.templateInstances) {\n const template = ProcessorTemplateProcessorState.INSTANCE.getValues()[instance.templateId]\n if (!template) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Invalid template contract:' + instance)\n }\n if (!instance.contract) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Contract Empty from:' + instance)\n }\n template.bind({\n name: instance.contract.name,\n address: instance.contract.address,\n network: Number(instance.contract.chainId),\n startBlock: instance.startBlock,\n endBlock: instance.endBlock,\n })\n }\n }\n\n stateDiff(config: ProcessConfigResponse): boolean {\n return TemplateInstanceState.INSTANCE.getValues().length !== config.templateInstances.length\n }\n\n async processLog(request: DataBinding): Promise<ProcessResult> {\n if (!request.data) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Log can't be null\")\n }\n\n const promises: Promise<ProcessResult>[] = []\n let log: Log\n if (request.data.ethLog) {\n log = request.data.ethLog.log as Log\n } else {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Log can't be null\")\n }\n\n for (const handlerId of request.handlerIds) {\n const handler = this.eventHandlers[handlerId]\n promises.push(\n handler(log).catch((e) => {\n throw new ServerError(Status.INTERNAL, 'error processing log: ' + JSON.stringify(log) + '\\n' + errorString(e))\n })\n )\n }\n return mergeProcessResults(await Promise.all(promises))\n }\n\n async processTrace(binding: DataBinding): Promise<ProcessResult> {\n if (!binding.data) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Trace can't be empty\")\n }\n let trace: Trace\n if (binding.data.ethTrace?.trace) {\n trace = binding.data.ethTrace.trace as Trace\n } else {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Trace can't be null\")\n }\n\n const promises: Promise<ProcessResult>[] = []\n\n for (const handlerId of binding.handlerIds) {\n promises.push(\n this.traceHandlers[handlerId](trace).catch((e) => {\n throw new ServerError(\n Status.INTERNAL,\n 'error processing trace: ' + JSON.stringify(trace) + '\\n' + errorString(e)\n )\n })\n )\n }\n return mergeProcessResults(await Promise.all(promises))\n }\n\n async processBlock(binding: DataBinding): Promise<ProcessResult> {\n if (!binding.data) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Block can't be empty\")\n }\n let block: Block\n if (binding.data.ethBlock?.block) {\n block = binding.data.ethBlock.block as Block\n } else {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Block can't be empty\")\n }\n\n const promises: Promise<ProcessResult>[] = []\n for (const handlerId of binding.handlerIds) {\n promises.push(\n this.blockHandlers[handlerId](block).catch((e) => {\n throw new ServerError(Status.INTERNAL, 'error processing block: ' + block.number + '\\n' + errorString(e))\n })\n )\n }\n return mergeProcessResults(await Promise.all(promises))\n }\n}\n\nPluginManager.INSTANCE.register(new EthPlugin())\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseContext } from './base-context';
|
|
2
2
|
import { NamedResultDescriptor } from './metadata';
|
|
3
|
-
import { MapStateStorage } from '@sentio/
|
|
3
|
+
import { MapStateStorage } from '@sentio/runtime';
|
|
4
4
|
export interface Event {
|
|
5
5
|
distinctId: string;
|
|
6
6
|
payload?: Record<string, string>;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AccountEventTracker = exports.EventTracker = exports.EventTrackerState = void 0;
|
|
4
4
|
const metadata_1 = require("./metadata");
|
|
5
|
-
const
|
|
6
|
-
class EventTrackerState extends
|
|
5
|
+
const runtime_1 = require("@sentio/runtime");
|
|
6
|
+
class EventTrackerState extends runtime_1.MapStateStorage {
|
|
7
7
|
static INSTANCE = new EventTrackerState();
|
|
8
8
|
}
|
|
9
9
|
exports.EventTrackerState = EventTrackerState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-tracker.js","sourceRoot":"","sources":["../../src/core/event-tracker.ts"],"names":[],"mappings":";;;AAEA,yCAAkD;AAClD,
|
|
1
|
+
{"version":3,"file":"event-tracker.js","sourceRoot":"","sources":["../../src/core/event-tracker.ts"],"names":[],"mappings":";;;AAEA,yCAAkD;AAClD,6CAAiD;AAgBjD,MAAa,iBAAkB,SAAQ,yBAA6B;IAClE,MAAM,CAAC,QAAQ,GAAG,IAAI,iBAAiB,EAAE,CAAA;;AAD3C,8CAEC;AAED,iDAAiD;AACjD,MAAa,YAAa,SAAQ,gCAAqB;IACrD,MAAM,CAAC,eAAe,GAAmB;QACvC,UAAU,EAAE,IAAI;QAChB,MAAM,EAAE,IAAI;KACb,CAAA;IAED,MAAM,CAAC,QAAQ,CAAC,SAAiB,EAAE,OAAwB;QACzD,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,SAAS,EAAE,EAAE,GAAG,YAAY,CAAC,eAAe,EAAE,GAAG,OAAO,EAAE,CAAC,CAAA;QAC5F,OAAO,iBAAiB,CAAC,QAAQ,CAAC,aAAa,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IACrE,CAAC;IAED,OAAO,CAAgB;IACvB,YAAsB,SAAiB,EAAE,OAAuB;QAC9D,KAAK,CAAC,SAAS,CAAC,CAAA;QAChB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,UAAU,CAAC,GAAgB,EAAE,KAAY;QACvC,MAAM,GAAG,GAAwB;YAC/B,QAAQ,EAAE,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;YACxC,gBAAgB,EAAE,KAAK,CAAC,UAAU;YAClC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YAC9B,WAAW,EAAE,SAAS;SACvB,CAAA;QACD,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC1B,CAAC;;AAzBH,oCA0BC;AAED,MAAa,mBAAoB,SAAQ,YAAY;IACnD,MAAM,CAAC,eAAe,GAAmB;QACvC,UAAU,EAAE,IAAI;QAChB,MAAM,EAAE,IAAI;QACZ,cAAc,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;KAC3B,CAAA;IAED,MAAM,CAAC,QAAQ,CAAC,SAAkB,EAAE,OAAwB;QAC1D,IAAI,SAAS,EAAE;YACb,SAAS,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;SAC1C;aAAM;YACL,SAAS,GAAG,MAAM,CAAA;SACnB;QACD,MAAM,OAAO,GAAG,IAAI,mBAAmB,CAAC,SAAS,EAAE,EAAE,GAAG,mBAAmB,CAAC,eAAe,EAAE,GAAG,OAAO,EAAE,CAAC,CAAA;QAC1G,OAAO,iBAAiB,CAAC,QAAQ,CAAC,aAAa,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IACrE,CAAC;;AAfH,kDAgBC","sourcesContent":["import { BaseContext } from './base-context'\nimport { EventTrackingResult } from '@sentio/protos'\nimport { NamedResultDescriptor } from './metadata'\nimport { MapStateStorage } from '@sentio/runtime'\n\nexport interface Event {\n // The unique identifier of main identity associate with an event\n // .e.g user id / toekn address / account address / contract address id\n //\n distinctId: string\n payload?: Record<string, string>\n}\n\nexport interface TrackerOptions {\n totalByDay?: boolean\n unique?: boolean\n distinctByDays?: number[]\n}\n\nexport class EventTrackerState extends MapStateStorage<EventTracker> {\n static INSTANCE = new EventTrackerState()\n}\n\n// Track Event with an identity associate with it\nexport class EventTracker extends NamedResultDescriptor {\n static DEFAULT_OPTIONS: TrackerOptions = {\n totalByDay: true,\n unique: true,\n }\n\n static register(eventName: string, options?: TrackerOptions) {\n const tracker = new EventTracker(eventName, { ...EventTracker.DEFAULT_OPTIONS, ...options })\n return EventTrackerState.INSTANCE.getOrSetValue(eventName, tracker)\n }\n\n options: TrackerOptions\n protected constructor(eventName: string, options: TrackerOptions) {\n super(eventName)\n this.options = options\n }\n\n trackEvent(ctx: BaseContext, event: Event) {\n const res: EventTrackingResult = {\n metadata: ctx.getMetaData(this.name, {}),\n distinctEntityId: event.distinctId,\n attributes: JSON.stringify({}),\n runtimeInfo: undefined,\n }\n ctx.res.events.push(res)\n }\n}\n\nexport class AccountEventTracker extends EventTracker {\n static DEFAULT_OPTIONS: TrackerOptions = {\n totalByDay: true,\n unique: true,\n distinctByDays: [1, 7, 30],\n }\n\n static register(eventName?: string, options?: TrackerOptions) {\n if (eventName) {\n eventName = ['user', eventName].join('_')\n } else {\n eventName = 'user'\n }\n const tracker = new AccountEventTracker(eventName, { ...AccountEventTracker.DEFAULT_OPTIONS, ...options })\n return EventTrackerState.INSTANCE.getOrSetValue(eventName, tracker)\n }\n}\n"]}
|
package/lib/core/exporter.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseContext } from './base-context';
|
|
2
2
|
import { NamedResultDescriptor } from './metadata';
|
|
3
|
-
import { MapStateStorage } from '@sentio/
|
|
3
|
+
import { MapStateStorage } from '@sentio/runtime';
|
|
4
4
|
export declare type Export = Record<string, any>;
|
|
5
5
|
export declare class ExporterState extends MapStateStorage<Exporter> {
|
|
6
6
|
static INSTANCE: ExporterState;
|
package/lib/core/exporter.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Exporter = exports.ExporterState = void 0;
|
|
4
4
|
const metadata_1 = require("./metadata");
|
|
5
|
-
const
|
|
6
|
-
class ExporterState extends
|
|
5
|
+
const runtime_1 = require("@sentio/runtime");
|
|
6
|
+
class ExporterState extends runtime_1.MapStateStorage {
|
|
7
7
|
static INSTANCE = new ExporterState();
|
|
8
8
|
}
|
|
9
9
|
exports.ExporterState = ExporterState;
|
package/lib/core/exporter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exporter.js","sourceRoot":"","sources":["../../src/core/exporter.ts"],"names":[],"mappings":";;;AAEA,yCAAkD;AAClD,
|
|
1
|
+
{"version":3,"file":"exporter.js","sourceRoot":"","sources":["../../src/core/exporter.ts"],"names":[],"mappings":";;;AAEA,yCAAkD;AAClD,6CAAiD;AAIjD,MAAa,aAAc,SAAQ,yBAAyB;IAC1D,MAAM,CAAC,QAAQ,GAAG,IAAI,aAAa,EAAE,CAAA;;AADvC,sCAEC;AAED,MAAa,QAAS,SAAQ,gCAAqB;IACjD,MAAM,CAAC,QAAQ,CAAC,IAAY,EAAE,OAAe;QAC3C,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QAC5C,OAAO,aAAa,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;IAC7D,CAAC;IAED,OAAO,CAAQ;IACf,YAAsB,IAAY,EAAE,OAAe;QACjD,KAAK,CAAC,IAAI,CAAC,CAAA;QACX,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,IAAI,CAAC,GAAgB,EAAE,IAAY;QACjC,MAAM,GAAG,GAAiB;YACxB,QAAQ,EAAE,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;YACxC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;YAC7B,WAAW,EAAE,SAAS;SACvB,CAAA;QACD,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC3B,CAAC;CACF;AApBD,4BAoBC","sourcesContent":["import { BaseContext } from './base-context'\nimport { ExportResult } from '@sentio/sdk'\nimport { NamedResultDescriptor } from './metadata'\nimport { MapStateStorage } from '@sentio/runtime'\n\nexport type Export = Record<string, any>\n\nexport class ExporterState extends MapStateStorage<Exporter> {\n static INSTANCE = new ExporterState()\n}\n\nexport class Exporter extends NamedResultDescriptor {\n static register(name: string, channel: string) {\n const exporter = new Exporter(name, channel)\n return ExporterState.INSTANCE.getOrSetValue(name, exporter)\n }\n\n channel: string\n protected constructor(name: string, channel: string) {\n super(name)\n this.channel = channel\n }\n\n emit(ctx: BaseContext, data: Export) {\n const res: ExportResult = {\n metadata: ctx.getMetaData(this.name, {}),\n payload: JSON.stringify(data),\n runtimeInfo: undefined,\n }\n ctx.res.exports.push(res)\n }\n}\n"]}
|
|
@@ -4,7 +4,7 @@ exports.GenericProcessor = void 0;
|
|
|
4
4
|
const contracts_1 = require("@ethersproject/contracts");
|
|
5
5
|
const context_1 = require("./context");
|
|
6
6
|
const base_processor_1 = require("./base-processor");
|
|
7
|
-
const
|
|
7
|
+
const runtime_1 = require("@sentio/runtime");
|
|
8
8
|
const binds_1 = require("../binds");
|
|
9
9
|
class GenericProcessor extends base_processor_1.BaseProcessor {
|
|
10
10
|
eventABI;
|
|
@@ -13,7 +13,7 @@ class GenericProcessor extends base_processor_1.BaseProcessor {
|
|
|
13
13
|
this.eventABI = eventABI;
|
|
14
14
|
}
|
|
15
15
|
CreateBoundContractView() {
|
|
16
|
-
const contract = new contracts_1.BaseContract(this.config.address, this.eventABI, (0,
|
|
16
|
+
const contract = new contracts_1.BaseContract(this.config.address, this.eventABI, (0, runtime_1.getProvider)(this.config.network));
|
|
17
17
|
return new context_1.BoundContractView(new context_1.ContractView(contract));
|
|
18
18
|
}
|
|
19
19
|
static bind(eventABI, options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generic-processor.js","sourceRoot":"","sources":["../../src/core/generic-processor.ts"],"names":[],"mappings":";;;AAAA,wDAAuD;AACvD,uCAA2D;AAE3D,qDAAgD;AAChD,
|
|
1
|
+
{"version":3,"file":"generic-processor.js","sourceRoot":"","sources":["../../src/core/generic-processor.ts"],"names":[],"mappings":";;;AAAA,wDAAuD;AACvD,uCAA2D;AAE3D,qDAAgD;AAChD,6CAA6C;AAC7C,oCAAuC;AAEvC,MAAa,gBAAiB,SAAQ,8BAGrC;IACC,QAAQ,CAAU;IAClB,YAAY,QAAkB,EAAE,OAAoB;QAClD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC1B,CAAC;IAES,uBAAuB;QAC/B,MAAM,QAAQ,GAAG,IAAI,wBAAY,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAA,qBAAW,EAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAA;QACvG,OAAO,IAAI,2BAAiB,CAAC,IAAI,sBAAY,CAAe,QAAQ,CAAC,CAAC,CAAA;IACxE,CAAC;IAEM,MAAM,CAAC,IAAI,CAAC,QAA2B,EAAE,OAAoB;QAClE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC5B,QAAQ,GAAG,CAAC,QAAQ,CAAC,CAAA;SACtB;QACD,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;YACjB,OAAO,CAAC,IAAI,GAAG,SAAS,CAAA;SACzB;QACD,MAAM,SAAS,GAAG,IAAI,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;QACzD,IAAA,oBAAY,EAAC,OAAO,EAAE,SAAS,CAAC,CAAA;QAChC,OAAO,SAAS,CAAA;IAClB,CAAC;CACF;AA1BD,4CA0BC","sourcesContent":["import { BaseContract } from '@ethersproject/contracts'\nimport { BoundContractView, ContractView } from './context'\nimport { BindOptions } from './bind-options'\nimport { BaseProcessor } from './base-processor'\nimport { getProvider } from '@sentio/runtime'\nimport { addProcessor } from '../binds'\n\nexport class GenericProcessor extends BaseProcessor<\n BaseContract,\n BoundContractView<BaseContract, ContractView<BaseContract>>\n> {\n eventABI: string[]\n constructor(eventABI: string[], options: BindOptions) {\n super(options)\n this.eventABI = eventABI\n }\n\n protected CreateBoundContractView(): BoundContractView<BaseContract, ContractView<BaseContract>> {\n const contract = new BaseContract(this.config.address, this.eventABI, getProvider(this.config.network))\n return new BoundContractView(new ContractView<BaseContract>(contract))\n }\n\n public static bind(eventABI: string[] | string, options: BindOptions): GenericProcessor {\n if (!Array.isArray(eventABI)) {\n eventABI = [eventABI]\n }\n if (!options.name) {\n options.name = 'Generic'\n }\n const processor = new GenericProcessor(eventABI, options)\n addProcessor(options, processor)\n return processor\n }\n}\n"]}
|
package/lib/core/index.d.ts
CHANGED
package/lib/core/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SuiPlugin = exports.EthPlugin = exports.SuiBindOptions = exports.SuiBaseProcessor = exports.BaseProcessorTemplate = exports.GenericProcessor = exports.BaseProcessor = exports.BindOptions = exports.toBlockTag = exports.toMetricValue = exports.toBigInteger = exports.AccountEventTracker = exports.EventTracker = exports.MetricOptions = exports.Gauge = exports.Counter = exports.GaugeBinding = exports.Meter = exports.CounterBinding = exports.BoundContractView = exports.ContractView = exports.ContractContext = exports.BigDecimal = void 0;
|
|
3
|
+
exports.CorePlugin = exports.SuiPlugin = exports.EthPlugin = exports.SuiBindOptions = exports.SuiBaseProcessor = exports.BaseProcessorTemplate = exports.GenericProcessor = exports.BaseProcessor = exports.BindOptions = exports.toBlockTag = exports.toMetricValue = exports.toBigInteger = exports.AccountEventTracker = exports.EventTracker = exports.MetricOptions = exports.Gauge = exports.Counter = exports.GaugeBinding = exports.Meter = exports.CounterBinding = exports.BoundContractView = exports.ContractView = exports.ContractContext = exports.BigDecimal = void 0;
|
|
4
4
|
var big_decimal_1 = require("./big-decimal");
|
|
5
5
|
Object.defineProperty(exports, "BigDecimal", { enumerable: true, get: function () { return big_decimal_1.BigDecimal; } });
|
|
6
6
|
var context_1 = require("./context");
|
|
@@ -36,4 +36,6 @@ var eth_plugin_1 = require("./eth-plugin");
|
|
|
36
36
|
Object.defineProperty(exports, "EthPlugin", { enumerable: true, get: function () { return eth_plugin_1.EthPlugin; } });
|
|
37
37
|
var sui_plugin_1 = require("./sui-plugin");
|
|
38
38
|
Object.defineProperty(exports, "SuiPlugin", { enumerable: true, get: function () { return sui_plugin_1.SuiPlugin; } });
|
|
39
|
+
var core_plugin_1 = require("./core-plugin");
|
|
40
|
+
Object.defineProperty(exports, "CorePlugin", { enumerable: true, get: function () { return core_plugin_1.CorePlugin; } });
|
|
39
41
|
//# sourceMappingURL=index.js.map
|
package/lib/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AAAjC,yGAAA,UAAU,OAAA;AACnB,qCAA4E;AAAnE,0GAAA,eAAe,OAAA;AAAE,uGAAA,YAAY,OAAA;AAAE,4GAAA,iBAAiB,OAAA;AACzD,iCAA4F;AAAnF,uGAAA,cAAc,OAAA;AAAE,8FAAA,KAAK,OAAA;AAAE,qGAAA,YAAY,OAAA;AAAE,gGAAA,OAAO,OAAA;AAAE,8FAAA,KAAK,OAAA;AAAE,sGAAA,aAAa,OAAA;AAC3E,iDAAmE;AAA1D,6GAAA,YAAY,OAAA;AAAE,oHAAA,mBAAmB,OAAA;AAC1C,yCAAqF;AAA5D,yGAAA,YAAY,OAAA;AAAE,0GAAA,aAAa,OAAA;AAAE,uGAAA,UAAU,OAAA;AAEhE,+CAA4C;AAAnC,2GAAA,WAAW,OAAA;AAEpB,mDAAgD;AAAvC,+GAAA,aAAa,OAAA;AACtB,yDAAsD;AAA7C,qHAAA,gBAAgB,OAAA;AACzB,qEAAiE;AAAxD,gIAAA,qBAAqB,OAAA;AAC9B,iDAAkE;AAAzD,iHAAA,gBAAgB,OAAA;AAAE,+GAAA,cAAc,OAAA;AAIzC,2CAAwC;AAA/B,uGAAA,SAAS,OAAA;AAClB,2CAAwC;AAA/B,uGAAA,SAAS,OAAA","sourcesContent":["export { BigDecimal } from './big-decimal'\nexport { ContractContext, ContractView, BoundContractView } from './context'\nexport { CounterBinding, Meter, GaugeBinding, Counter, Gauge, MetricOptions } from './meter'\nexport { EventTracker, AccountEventTracker } from './event-tracker'\nexport { type Numberish, toBigInteger, toMetricValue, toBlockTag } from './numberish'\n\nexport { BindOptions } from './bind-options'\n\nexport { BaseProcessor } from './base-processor'\nexport { GenericProcessor } from './generic-processor'\nexport { BaseProcessorTemplate } from './base-processor-template'\nexport { SuiBaseProcessor, SuiBindOptions } from './sui-processor'\n\nexport type { TypedCallTrace, Trace } from './trace'\n\nexport { EthPlugin } from './eth-plugin'\nexport { SuiPlugin } from './sui-plugin'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AAAjC,yGAAA,UAAU,OAAA;AACnB,qCAA4E;AAAnE,0GAAA,eAAe,OAAA;AAAE,uGAAA,YAAY,OAAA;AAAE,4GAAA,iBAAiB,OAAA;AACzD,iCAA4F;AAAnF,uGAAA,cAAc,OAAA;AAAE,8FAAA,KAAK,OAAA;AAAE,qGAAA,YAAY,OAAA;AAAE,gGAAA,OAAO,OAAA;AAAE,8FAAA,KAAK,OAAA;AAAE,sGAAA,aAAa,OAAA;AAC3E,iDAAmE;AAA1D,6GAAA,YAAY,OAAA;AAAE,oHAAA,mBAAmB,OAAA;AAC1C,yCAAqF;AAA5D,yGAAA,YAAY,OAAA;AAAE,0GAAA,aAAa,OAAA;AAAE,uGAAA,UAAU,OAAA;AAEhE,+CAA4C;AAAnC,2GAAA,WAAW,OAAA;AAEpB,mDAAgD;AAAvC,+GAAA,aAAa,OAAA;AACtB,yDAAsD;AAA7C,qHAAA,gBAAgB,OAAA;AACzB,qEAAiE;AAAxD,gIAAA,qBAAqB,OAAA;AAC9B,iDAAkE;AAAzD,iHAAA,gBAAgB,OAAA;AAAE,+GAAA,cAAc,OAAA;AAIzC,2CAAwC;AAA/B,uGAAA,SAAS,OAAA;AAClB,2CAAwC;AAA/B,uGAAA,SAAS,OAAA;AAClB,6CAA0C;AAAjC,yGAAA,UAAU,OAAA","sourcesContent":["export { BigDecimal } from './big-decimal'\nexport { ContractContext, ContractView, BoundContractView } from './context'\nexport { CounterBinding, Meter, GaugeBinding, Counter, Gauge, MetricOptions } from './meter'\nexport { EventTracker, AccountEventTracker } from './event-tracker'\nexport { type Numberish, toBigInteger, toMetricValue, toBlockTag } from './numberish'\n\nexport { BindOptions } from './bind-options'\n\nexport { BaseProcessor } from './base-processor'\nexport { GenericProcessor } from './generic-processor'\nexport { BaseProcessorTemplate } from './base-processor-template'\nexport { SuiBaseProcessor, SuiBindOptions } from './sui-processor'\n\nexport type { TypedCallTrace, Trace } from './trace'\n\nexport { EthPlugin } from './eth-plugin'\nexport { SuiPlugin } from './sui-plugin'\nexport { CorePlugin } from './core-plugin'\n"]}
|
package/lib/core/meter.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { BaseContext } from './base-context';
|
|
|
2
2
|
import { Numberish } from './numberish';
|
|
3
3
|
import { Labels, NamedResultDescriptor } from './metadata';
|
|
4
4
|
import { AggregationConfig, MetricConfig, MetricType } from '@sentio/protos';
|
|
5
|
-
import { MapStateStorage } from '@sentio/
|
|
5
|
+
import { MapStateStorage } from '@sentio/runtime';
|
|
6
6
|
export declare function normalizeName(name: string): string;
|
|
7
7
|
export declare function normalizeKey(name: string): string;
|
|
8
8
|
export declare function normalizeValue(name: string): string;
|