@sentio/sdk 2.11.1-rc.3 → 2.11.1-rc.4
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.
@@ -34,7 +34,7 @@ export declare abstract class BaseProcessorTemplate<TContract extends BaseContra
|
|
34
34
|
fetchConfig?: EthFetchConfig;
|
35
35
|
}[];
|
36
36
|
constructor();
|
37
|
-
bind(options: BindOptions):
|
37
|
+
bind(options: BindOptions): void;
|
38
38
|
onEvent(handler: (event: EthEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid, filter: DeferredTopicFilter | DeferredTopicFilter[], fetchConfig?: Partial<EthFetchConfig>): this;
|
39
39
|
onBlockInterval(handler: (block: BlockParams, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid, blockInterval?: number, backfillBlockInterval?: number): this;
|
40
40
|
onTimeInterval(handler: (block: BlockParams, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid, timeIntervalInMinutes?: number, backfillBlockInterval?: number): this;
|
@@ -21,8 +21,9 @@ export class BaseProcessorTemplate {
|
|
21
21
|
ProcessorTemplateProcessorState.INSTANCE.addValue(this);
|
22
22
|
}
|
23
23
|
bind(options) {
|
24
|
-
const sig = getOptionsSignature(options);
|
24
|
+
const sig = getOptionsSignature({ address: options.address, network: options.network });
|
25
25
|
if (this.binds.has(sig)) {
|
26
|
+
console.log('Same address can be bind to one template only once');
|
26
27
|
return;
|
27
28
|
}
|
28
29
|
this.binds.add(sig);
|
@@ -54,7 +55,6 @@ export class BaseProcessorTemplate {
|
|
54
55
|
instance.endBlock = BigInt(options.endBlock);
|
55
56
|
}
|
56
57
|
TemplateInstanceState.INSTANCE.addValue(instance);
|
57
|
-
return processor;
|
58
58
|
}
|
59
59
|
onEvent(handler, filter, fetchConfig) {
|
60
60
|
this.eventHandlers.push({
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"base-processor-template.js","sourceRoot":"","sources":["../../src/eth/base-processor-template.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACpE,OAAO,EAAE,cAAc,EAAoC,MAAM,gBAAgB,CAAA;AAGjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAIlD,OAAO,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAA;AAE7D,MAAa,+BAAgC,SAAQ,gBAEpD;IACC,MAAM,CAAC,QAAQ,GAAG,IAAI,+BAA+B,EAAE,CAAA;;SAH5C,+BAA+B;AAM5C,MAAa,qBAAsB,SAAQ,gBAAkC;IAC3E,MAAM,CAAC,QAAQ,GAAG,IAAI,qBAAqB,EAAE,CAAA;;SADlC,qBAAqB;AAIlC,MAAM,OAAgB,qBAAqB;IAIzC,EAAE,CAAQ;IACV,KAAK,GAAG,IAAI,GAAG,EAAU,CAAA;IACzB,aAAa,GAIP,EAAE,CAAA;IACR,aAAa,GAIP,EAAE,CAAA;IACR,aAAa,GAIP,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,mBAAmB,CAAC,OAAO,CAAC,CAAA;
|
1
|
+
{"version":3,"file":"base-processor-template.js","sourceRoot":"","sources":["../../src/eth/base-processor-template.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACpE,OAAO,EAAE,cAAc,EAAoC,MAAM,gBAAgB,CAAA;AAGjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAIlD,OAAO,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAA;AAE7D,MAAa,+BAAgC,SAAQ,gBAEpD;IACC,MAAM,CAAC,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C,OAAO,EAAE,SAAS,EAAE;YACzC,cAAc,EAAE,aAAa;YAC7B,gBAAgB,EAAE,qBAAqB;SACxC,CAAC,CAAA;IACJ,CAAC;IAEM,cAAc,CACnB,OAAmG,EACnG,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,OAAmG,EACnG,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,EAC7F,WAAqC;QAErC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,cAAc,CAAC,WAAW,CAAC,WAAW,IAAI,EAAE,CAAC,EAAE,CAAC,CAAA;QAC3G,OAAO,IAAI,CAAA;IACb,CAAC;CAGF","sourcesContent":["import { BoundContractView, ContractContext, ContractView } from './context.js'\nimport { BaseContract } from 'ethers'\nimport { BaseProcessor } from './base-processor.js'\nimport { BindOptions, getOptionsSignature } from './bind-options.js'\nimport { EthFetchConfig, HandleInterval, TemplateInstance } from '@sentio/protos'\nimport { PromiseOrVoid } from '../promise-or-void.js'\nimport { Trace } from './trace.js'\nimport { ListStateStorage } from '@sentio/runtime'\nimport { BlockParams } from 'ethers/providers'\nimport { DeferredTopicFilter } from 'ethers/contract'\nimport { EthEvent } from './eth.js'\nimport { getNetworkFromCtxOrNetworkish } from './provider.js'\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: BlockParams, 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 fetchConfig?: EthFetchConfig\n }[] = []\n eventHandlers: {\n handler: (event: EthEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid\n filter: DeferredTopicFilter | DeferredTopicFilter[]\n fetchConfig?: EthFetchConfig\n }[] = []\n\n constructor() {\n this.id = ProcessorTemplateProcessorState.INSTANCE.getValues().length\n ProcessorTemplateProcessorState.INSTANCE.addValue(this)\n }\n\n public bind(options: BindOptions): void {\n const sig = getOptionsSignature({ address: options.address, network: options.network })\n if (this.binds.has(sig)) {\n console.log('Same address can be bind to one template only once')\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, eh.fetchConfig)\n }\n for (const th of this.traceHandlers) {\n processor.onTrace(th.signature, th.handler, th.fetchConfig)\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: getNetworkFromCtxOrNetworkish(options.network).chainId.toString(),\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 }\n\n public onEvent(\n handler: (event: EthEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n filter: DeferredTopicFilter | DeferredTopicFilter[],\n fetchConfig?: Partial<EthFetchConfig>\n ) {\n this.eventHandlers.push({\n handler: handler,\n filter: filter,\n fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {}),\n })\n return this\n }\n\n public onBlockInterval(\n handler: (block: BlockParams, 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: BlockParams, 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: BlockParams, 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 fetchConfig?: Partial<EthFetchConfig>\n ) {\n this.traceHandlers.push({ signature, handler, fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {}) })\n return this\n }\n\n protected abstract bindInternal(options: BindOptions): BaseProcessor<TContract, TBoundContractView>\n}\n"]}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sentio/sdk",
|
3
3
|
"license": "Apache-2.0",
|
4
|
-
"version": "2.11.1-rc.
|
4
|
+
"version": "2.11.1-rc.4",
|
5
5
|
"type": "module",
|
6
6
|
"scripts": {
|
7
7
|
"compile": "tsc && cp src/utils/*.csv lib/utils && cp src/tsup.config.ts lib",
|
@@ -23,8 +23,8 @@
|
|
23
23
|
"@project-serum/anchor": "^0.26.0",
|
24
24
|
"@sentio/bigdecimal": "^9.1.1-patch.3",
|
25
25
|
"@sentio/ethers-v6": "^1.0.28",
|
26
|
-
"@sentio/protos": "^2.11.1-rc.
|
27
|
-
"@sentio/runtime": "^2.11.1-rc.
|
26
|
+
"@sentio/protos": "^2.11.1-rc.4",
|
27
|
+
"@sentio/runtime": "^2.11.1-rc.4",
|
28
28
|
"@solana/web3.js": "^1.74.0",
|
29
29
|
"@types/prettier": "^2.7.2",
|
30
30
|
"aptos-sdk": "npm:aptos@^1.7.2",
|
@@ -84,5 +84,5 @@
|
|
84
84
|
"engines": {
|
85
85
|
"node": ">=16"
|
86
86
|
},
|
87
|
-
"gitHead": "
|
87
|
+
"gitHead": "020e6b9282903b6eee99735da5eb8b5d00e78eb3"
|
88
88
|
}
|
@@ -48,9 +48,10 @@ export abstract class BaseProcessorTemplate<
|
|
48
48
|
ProcessorTemplateProcessorState.INSTANCE.addValue(this)
|
49
49
|
}
|
50
50
|
|
51
|
-
public bind(options: BindOptions) {
|
52
|
-
const sig = getOptionsSignature(options)
|
51
|
+
public bind(options: BindOptions): void {
|
52
|
+
const sig = getOptionsSignature({ address: options.address, network: options.network })
|
53
53
|
if (this.binds.has(sig)) {
|
54
|
+
console.log('Same address can be bind to one template only once')
|
54
55
|
return
|
55
56
|
}
|
56
57
|
this.binds.add(sig)
|
@@ -85,7 +86,6 @@ export abstract class BaseProcessorTemplate<
|
|
85
86
|
instance.endBlock = BigInt(options.endBlock)
|
86
87
|
}
|
87
88
|
TemplateInstanceState.INSTANCE.addValue(instance)
|
88
|
-
return processor
|
89
89
|
}
|
90
90
|
|
91
91
|
public onEvent(
|