@sentio/sdk 2.8.0 → 2.9.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.
- package/lib/aptos/aptos-plugin.js +3 -6
- package/lib/aptos/aptos-plugin.js.map +1 -1
- package/lib/core/chain.d.ts +1 -0
- package/lib/core/chain.js +59 -0
- package/lib/core/chain.js.map +1 -1
- package/lib/core/event-logger.d.ts +1 -1
- package/lib/core/event-logger.js.map +1 -1
- package/lib/core/index.d.ts +1 -0
- package/lib/core/index.js.map +1 -1
- package/lib/core/partial-optional.d.ts +1 -0
- package/lib/core/partial-optional.js +2 -0
- package/lib/core/partial-optional.js.map +1 -0
- package/lib/eth/account-processor.d.ts +3 -2
- package/lib/eth/account-processor.js +6 -9
- package/lib/eth/account-processor.js.map +1 -1
- package/lib/eth/base-processor-template.js +2 -2
- package/lib/eth/base-processor-template.js.map +1 -1
- package/lib/eth/base-processor.d.ts +10 -2
- package/lib/eth/base-processor.js +10 -9
- package/lib/eth/base-processor.js.map +1 -1
- package/lib/eth/bind-options.d.ts +2 -9
- package/lib/eth/bind-options.js +3 -15
- package/lib/eth/bind-options.js.map +1 -1
- package/lib/eth/binds.js +2 -2
- package/lib/eth/binds.js.map +1 -1
- package/lib/eth/eth-plugin.js +3 -6
- package/lib/eth/eth-plugin.js.map +1 -1
- package/lib/eth/provider.js +4 -3
- package/lib/eth/provider.js.map +1 -1
- package/lib/eth/provider.test.d.ts +1 -0
- package/lib/eth/provider.test.js.map +1 -0
- package/lib/sui/context.d.ts +9 -0
- package/lib/sui/context.js +29 -0
- package/lib/sui/context.js.map +1 -1
- package/lib/sui/sui-plugin.d.ts +2 -0
- package/lib/sui/sui-plugin.js +38 -2
- package/lib/sui/sui-plugin.js.map +1 -1
- package/lib/sui/sui-processor.d.ts +21 -3
- package/lib/sui/sui-processor.js +46 -2
- package/lib/sui/sui-processor.js.map +1 -1
- package/lib/testing/eth-facet.js +5 -5
- package/lib/testing/eth-facet.js.map +1 -1
- package/lib/utils/price.d.ts +2 -2
- package/package.json +5 -5
- package/src/aptos/aptos-plugin.ts +2 -5
- package/src/core/chain.ts +54 -0
- package/src/core/event-logger.ts +1 -1
- package/src/core/index.ts +1 -0
- package/src/core/partial-optional.ts +1 -0
- package/src/eth/account-processor.ts +8 -11
- package/src/eth/base-processor-template.ts +3 -2
- package/src/eth/base-processor.ts +12 -9
- package/src/eth/bind-options.ts +4 -16
- package/src/eth/binds.ts +3 -2
- package/src/eth/eth-plugin.ts +2 -5
- package/src/eth/provider.ts +4 -3
- package/src/sui/context.ts +33 -0
- package/src/sui/sui-plugin.ts +47 -1
- package/src/sui/sui-processor.ts +85 -3
- package/src/testing/eth-facet.ts +6 -5
package/lib/testing/eth-facet.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { HandlerType } from '@sentio/protos';
|
2
|
-
import {
|
2
|
+
import { getNetworkFromCtxOrNetworkish } from '../eth/provider.js';
|
3
3
|
export class EthFacet {
|
4
4
|
server;
|
5
5
|
constructor(server) {
|
@@ -27,7 +27,7 @@ export class EthFacet {
|
|
27
27
|
}
|
28
28
|
const signature = trace.action.input.slice(0, 10);
|
29
29
|
for (const contract of this.server.contractConfigs) {
|
30
|
-
if (contract.contract?.chainId !==
|
30
|
+
if (contract.contract?.chainId !== getNetworkFromCtxOrNetworkish(network).chainId.toString()) {
|
31
31
|
continue;
|
32
32
|
}
|
33
33
|
if (trace.action.to?.toLowerCase() !== contract.contract?.address.toLowerCase()) {
|
@@ -68,7 +68,7 @@ export class EthFacet {
|
|
68
68
|
}
|
69
69
|
buildLogBinding(log, network = 1) {
|
70
70
|
for (const contract of this.server.contractConfigs) {
|
71
|
-
if (contract.contract?.chainId !==
|
71
|
+
if (contract.contract?.chainId !== getNetworkFromCtxOrNetworkish(network).chainId.toString()) {
|
72
72
|
continue;
|
73
73
|
}
|
74
74
|
if (log.address.toLowerCase() !== contract.contract?.address.toLowerCase()) {
|
@@ -126,7 +126,7 @@ export class EthFacet {
|
|
126
126
|
}
|
127
127
|
buildAccountLogBinding(address, log, network = 1) {
|
128
128
|
for (const account of this.server.accountConfigs) {
|
129
|
-
if (account.chainId !==
|
129
|
+
if (account.chainId !== getNetworkFromCtxOrNetworkish(network).chainId.toString()) {
|
130
130
|
continue;
|
131
131
|
}
|
132
132
|
if (address.toLowerCase() !== account.address.toLowerCase()) {
|
@@ -191,7 +191,7 @@ export class EthFacet {
|
|
191
191
|
handlerIds: [],
|
192
192
|
};
|
193
193
|
for (const contract of this.server.contractConfigs) {
|
194
|
-
if (contract.contract?.chainId !==
|
194
|
+
if (contract.contract?.chainId !== getNetworkFromCtxOrNetworkish(network).chainId.toString()) {
|
195
195
|
continue;
|
196
196
|
}
|
197
197
|
const longBlockNumber = block.number;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"eth-facet.js","sourceRoot":"","sources":["../../src/testing/eth-facet.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,WAAW,EAA0B,MAAM,gBAAgB,CAAA;AAEjF,OAAO,EAA0B,OAAO,EAAc,MAAM,kBAAkB,CAAA;AAG9E,MAAM,OAAO,QAAQ;IACnB,MAAM,CAAqB;IAE3B,YAAY,MAA2B;QACrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED,SAAS,CAAC,KAAY,EAAE,UAAsB,CAAC;QAC7C,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAA;IAC1C,CAAC;IAED,UAAU,CAAC,MAAe,EAAE,UAAsB,CAAC;QACjD,MAAM,QAAQ,GAAG,EAAE,CAAA;QACnB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;YAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;YACtD,IAAI,CAAC,OAAO,EAAE;gBACZ,MAAM,KAAK,CAAC,sBAAsB,GAAG,IAAI,CAAC,SAA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,QAAQ,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE;gBAC3E,SAAQ;aACT;YACD,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,CAAA;YACpC,IAAI,eAAe,GAAG,QAAQ,CAAC,UAAU,EAAE;gBACzC,SAAQ;aACT;YACD,IAAI,QAAQ,CAAC,QAAQ,KAAK,EAAE,IAAI,eAAe,IAAI,QAAQ,CAAC,QAAQ,EAAE;gBACpE,SAAQ;aACT;YAED,KAAK,MAAM,MAAM,IAAI,QAAQ,CAAC,eAAe,EAAE;gBAC7C,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;aAC1C;SACF;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;CACF","sourcesContent":["import { TestProcessorServer } from './test-processor-server.js'\nimport { DataBinding, HandlerType, ProcessBindingResponse } from '@sentio/protos'\nimport { Trace } from '../eth/trace.js'\nimport { BlockParams, LogParams, Network, Networkish } from 'ethers/providers'\nimport { Block } from 'ethers'\n\nexport class EthFacet {\n server: TestProcessorServer\n\n constructor(server: TestProcessorServer) {\n this.server = server\n }\n\n testTrace(trace: Trace, network: Networkish = 1): Promise<ProcessBindingResponse> {\n return this.testTraces([trace], network)\n }\n\n testTraces(traces: Trace[], network: Networkish = 1): Promise<ProcessBindingResponse> {\n const bindings = []\n for (const trace of traces) {\n const binding = this.buildTraceBinding(trace, network)\n if (!binding) {\n throw Error('Invalid test trace: ' + JSON.stringify(trace))\n }\n bindings.push(binding)\n }\n return this.server.processBindings({\n bindings: bindings,\n })\n }\n\n buildTraceBinding(trace: Trace, network: Networkish = 1): DataBinding | undefined {\n if (trace.type !== 'call' || !trace.action.input) {\n throw Error('Invalid test trace: ' + JSON.stringify(trace))\n }\n const signature = trace.action.input.slice(0, 10)\n\n for (const contract of this.server.contractConfigs) {\n if (contract.contract?.chainId !== Network.from(network).chainId.toString()) {\n continue\n }\n if (trace.action.to?.toLowerCase() !== contract.contract?.address.toLowerCase()) {\n continue\n }\n for (const config of contract.traceConfigs) {\n if (config.signature == signature) {\n return {\n data: {\n ethTrace: {\n trace,\n timestamp: new Date(),\n },\n },\n handlerIds: [config.handlerId],\n handlerType: HandlerType.ETH_TRACE,\n }\n }\n }\n }\n return undefined\n }\n\n testLog(log: LogParams, network: Networkish = 1): Promise<ProcessBindingResponse> {\n return this.testLogs([log], network)\n }\n\n testLogs(logs: LogParams[], network: Networkish = 1): Promise<ProcessBindingResponse> {\n const bindings = []\n for (const log of logs) {\n const binding = this.buildLogBinding(log, network)\n if (!binding) {\n throw Error('Invalid test log: ' + JSON.stringify(log))\n }\n bindings.push(binding)\n }\n return this.server.processBindings({\n bindings: bindings,\n })\n }\n\n buildLogBinding(log: LogParams, network: Networkish = 1): DataBinding | undefined {\n for (const contract of this.server.contractConfigs) {\n if (contract.contract?.chainId !== Network.from(network).chainId.toString()) {\n continue\n }\n if (log.address.toLowerCase() !== contract.contract?.address.toLowerCase()) {\n continue\n }\n for (const config of contract.logConfigs) {\n for (const filter of config.filters) {\n // if (filter.topics.length != log.topics.length) {\n // continue\n // }\n\n let match = true\n for (const topicIdx in filter.topics) {\n const logTopic = log.topics[topicIdx]\n const possibleTopic = filter.topics[topicIdx].hashes\n if (possibleTopic.length === 0) {\n // match all\n continue\n }\n if (possibleTopic.find((e) => e.toLowerCase() === logTopic.toLowerCase())) {\n // find one\n continue\n }\n match = false\n break\n }\n if (match) {\n return {\n data: {\n ethLog: { log, timestamp: new Date() },\n },\n handlerIds: [config.handlerId],\n handlerType: HandlerType.ETH_LOG,\n }\n }\n }\n }\n }\n return undefined\n }\n testAccountLog(address: string, log: LogParams, network: Networkish = 1): Promise<ProcessBindingResponse> {\n return this.testAccountLogs(address, [log], network)\n }\n\n testAccountLogs(address: string, logs: LogParams[], network: Networkish = 1): Promise<ProcessBindingResponse> {\n const bindings = []\n for (const log of logs) {\n const binding = this.buildAccountLogBinding(address, log, network)\n if (!binding) {\n throw Error('Invalid test log: ' + JSON.stringify(log))\n }\n bindings.push(binding)\n }\n return this.server.processBindings({\n bindings: bindings,\n })\n }\n\n buildAccountLogBinding(address: string, log: LogParams, network: Networkish = 1): DataBinding | undefined {\n for (const account of this.server.accountConfigs) {\n if (account.chainId !== Network.from(network).chainId.toString()) {\n continue\n }\n if (address.toLowerCase() !== account.address.toLowerCase()) {\n continue\n }\n for (const config of account.logConfigs) {\n for (const filter of config.filters) {\n // if (filter.topics.length != log.topics.length) {\n // continue\n // }\n\n let match = true\n for (const topicIdx in filter.topics) {\n const logTopic = log.topics[topicIdx]\n const possibleTopic = filter.topics[topicIdx].hashes\n if (possibleTopic.length === 0) {\n // match all\n continue\n }\n if (possibleTopic.find((e) => e.toLowerCase() === logTopic.toLowerCase())) {\n // find one\n continue\n }\n match = false\n break\n }\n if (match) {\n return {\n data: {\n ethLog: { log, timestamp: new Date() },\n },\n handlerIds: [config.handlerId],\n handlerType: HandlerType.ETH_LOG,\n }\n }\n }\n }\n }\n return undefined\n }\n\n testBlock(\n block: Partial<BlockParams> & { number: number },\n network: Networkish = 1\n ): Promise<ProcessBindingResponse> {\n return this.testBlocks([block], network)\n }\n\n testBlocks(blocks: Partial<BlockParams> & { number: number }[], network: Networkish = 1) {\n const bindings = []\n for (const block of blocks) {\n const binding = this.buildBlockBinding(block, network)\n if (!binding) {\n throw Error('Invalid test block: ' + JSON.stringify(block))\n }\n bindings.push(binding)\n }\n return this.server.processBindings({\n bindings: bindings,\n })\n }\n\n buildBlockBinding(block: Partial<Block> & { number: number }, network: Networkish = 1): DataBinding {\n const binding: DataBinding = {\n data: {\n ethBlock: { block },\n },\n handlerType: HandlerType.ETH_BLOCK,\n handlerIds: [],\n }\n for (const contract of this.server.contractConfigs) {\n if (contract.contract?.chainId !== Network.from(network).chainId.toString()) {\n continue\n }\n const longBlockNumber = block.number\n if (longBlockNumber < contract.startBlock) {\n continue\n }\n if (contract.endBlock !== 0n && longBlockNumber >= contract.endBlock) {\n continue\n }\n\n for (const config of contract.intervalConfigs) {\n binding.handlerIds.push(config.handlerId)\n }\n }\n return binding\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"eth-facet.js","sourceRoot":"","sources":["../../src/testing/eth-facet.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,WAAW,EAA0B,MAAM,gBAAgB,CAAA;AAIjF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAA;AAElE,MAAM,OAAO,QAAQ;IACnB,MAAM,CAAqB;IAE3B,YAAY,MAA2B;QACrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED,SAAS,CAAC,KAAY,EAAE,UAAsB,CAAC;QAC7C,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAA;IAC1C,CAAC;IAED,UAAU,CAAC,MAAe,EAAE,UAAsB,CAAC;QACjD,MAAM,QAAQ,GAAG,EAAE,CAAA;QACnB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;YAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;YACtD,IAAI,CAAC,OAAO,EAAE;gBACZ,MAAM,KAAK,CAAC,sBAAsB,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;aAC5D;YACD,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;SACvB;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC;YACjC,QAAQ,EAAE,QAAQ;SACnB,CAAC,CAAA;IACJ,CAAC;IAED,iBAAiB,CAAC,KAAY,EAAE,UAAsB,CAAC;QACrD,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE;YAChD,MAAM,KAAK,CAAC,sBAAsB,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK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AC,MAAM,CAAC,SAAS,CAAC,CAAA;aAC1C;SACF;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;CACF","sourcesContent":["import { TestProcessorServer } from './test-processor-server.js'\nimport { DataBinding, HandlerType, ProcessBindingResponse } from '@sentio/protos'\nimport { Trace } from '../eth/trace.js'\nimport { BlockParams, LogParams, Networkish } from 'ethers/providers'\nimport { Block } from 'ethers'\nimport { getNetworkFromCtxOrNetworkish } from '../eth/provider.js'\n\nexport class EthFacet {\n server: TestProcessorServer\n\n constructor(server: TestProcessorServer) {\n this.server = server\n }\n\n testTrace(trace: Trace, network: Networkish = 1): Promise<ProcessBindingResponse> {\n return this.testTraces([trace], network)\n }\n\n testTraces(traces: Trace[], network: Networkish = 1): Promise<ProcessBindingResponse> {\n const bindings = []\n for (const trace of traces) {\n const binding = this.buildTraceBinding(trace, network)\n if (!binding) {\n throw Error('Invalid test trace: ' + JSON.stringify(trace))\n }\n bindings.push(binding)\n }\n return this.server.processBindings({\n bindings: bindings,\n })\n }\n\n buildTraceBinding(trace: Trace, network: Networkish = 1): DataBinding | undefined {\n if (trace.type !== 'call' || !trace.action.input) {\n throw Error('Invalid test trace: ' + JSON.stringify(trace))\n }\n const signature = trace.action.input.slice(0, 10)\n\n for (const contract of this.server.contractConfigs) {\n if (contract.contract?.chainId !== getNetworkFromCtxOrNetworkish(network).chainId.toString()) {\n continue\n }\n if (trace.action.to?.toLowerCase() !== contract.contract?.address.toLowerCase()) {\n continue\n }\n for (const config of contract.traceConfigs) {\n if (config.signature == signature) {\n return {\n data: {\n ethTrace: {\n trace,\n timestamp: new Date(),\n },\n },\n handlerIds: [config.handlerId],\n handlerType: HandlerType.ETH_TRACE,\n }\n }\n }\n }\n return undefined\n }\n\n testLog(log: LogParams, network: Networkish = 1): Promise<ProcessBindingResponse> {\n return this.testLogs([log], network)\n }\n\n testLogs(logs: LogParams[], network: Networkish = 1): Promise<ProcessBindingResponse> {\n const bindings = []\n for (const log of logs) {\n const binding = this.buildLogBinding(log, network)\n if (!binding) {\n throw Error('Invalid test log: ' + JSON.stringify(log))\n }\n bindings.push(binding)\n }\n return this.server.processBindings({\n bindings: bindings,\n })\n }\n\n buildLogBinding(log: LogParams, network: Networkish = 1): DataBinding | undefined {\n for (const contract of this.server.contractConfigs) {\n if (contract.contract?.chainId !== getNetworkFromCtxOrNetworkish(network).chainId.toString()) {\n continue\n }\n if (log.address.toLowerCase() !== contract.contract?.address.toLowerCase()) {\n continue\n }\n for (const config of contract.logConfigs) {\n for (const filter of config.filters) {\n // if (filter.topics.length != log.topics.length) {\n // continue\n // }\n\n let match = true\n for (const topicIdx in filter.topics) {\n const logTopic = log.topics[topicIdx]\n const possibleTopic = filter.topics[topicIdx].hashes\n if (possibleTopic.length === 0) {\n // match all\n continue\n }\n if (possibleTopic.find((e) => e.toLowerCase() === logTopic.toLowerCase())) {\n // find one\n continue\n }\n match = false\n break\n }\n if (match) {\n return {\n data: {\n ethLog: { log, timestamp: new Date() },\n },\n handlerIds: [config.handlerId],\n handlerType: HandlerType.ETH_LOG,\n }\n }\n }\n }\n }\n return undefined\n }\n testAccountLog(address: string, log: LogParams, network: Networkish = 1): Promise<ProcessBindingResponse> {\n return this.testAccountLogs(address, [log], network)\n }\n\n testAccountLogs(address: string, logs: LogParams[], network: Networkish = 1): Promise<ProcessBindingResponse> {\n const bindings = []\n for (const log of logs) {\n const binding = this.buildAccountLogBinding(address, log, network)\n if (!binding) {\n throw Error('Invalid test log: ' + JSON.stringify(log))\n }\n bindings.push(binding)\n }\n return this.server.processBindings({\n bindings: bindings,\n })\n }\n\n buildAccountLogBinding(address: string, log: LogParams, network: Networkish = 1): DataBinding | undefined {\n for (const account of this.server.accountConfigs) {\n if (account.chainId !== getNetworkFromCtxOrNetworkish(network).chainId.toString()) {\n continue\n }\n if (address.toLowerCase() !== account.address.toLowerCase()) {\n continue\n }\n for (const config of account.logConfigs) {\n for (const filter of config.filters) {\n // if (filter.topics.length != log.topics.length) {\n // continue\n // }\n\n let match = true\n for (const topicIdx in filter.topics) {\n const logTopic = log.topics[topicIdx]\n const possibleTopic = filter.topics[topicIdx].hashes\n if (possibleTopic.length === 0) {\n // match all\n continue\n }\n if (possibleTopic.find((e) => e.toLowerCase() === logTopic.toLowerCase())) {\n // find one\n continue\n }\n match = false\n break\n }\n if (match) {\n return {\n data: {\n ethLog: { log, timestamp: new Date() },\n },\n handlerIds: [config.handlerId],\n handlerType: HandlerType.ETH_LOG,\n }\n }\n }\n }\n }\n return undefined\n }\n\n testBlock(\n block: Partial<BlockParams> & { number: number },\n network: Networkish = 1\n ): Promise<ProcessBindingResponse> {\n return this.testBlocks([block], network)\n }\n\n testBlocks(blocks: Partial<BlockParams> & { number: number }[], network: Networkish = 1) {\n const bindings = []\n for (const block of blocks) {\n const binding = this.buildBlockBinding(block, network)\n if (!binding) {\n throw Error('Invalid test block: ' + JSON.stringify(block))\n }\n bindings.push(binding)\n }\n return this.server.processBindings({\n bindings: bindings,\n })\n }\n\n buildBlockBinding(block: Partial<Block> & { number: number }, network: Networkish = 1): DataBinding {\n const binding: DataBinding = {\n data: {\n ethBlock: { block },\n },\n handlerType: HandlerType.ETH_BLOCK,\n handlerIds: [],\n }\n for (const contract of this.server.contractConfigs) {\n if (contract.contract?.chainId !== getNetworkFromCtxOrNetworkish(network).chainId.toString()) {\n continue\n }\n const longBlockNumber = block.number\n if (longBlockNumber < contract.startBlock) {\n continue\n }\n if (contract.endBlock !== 0n && longBlockNumber >= contract.endBlock) {\n continue\n }\n\n for (const config of contract.intervalConfigs) {\n binding.handlerIds.push(config.handlerId)\n }\n }\n return binding\n }\n}\n"]}
|
package/lib/utils/price.d.ts
CHANGED
@@ -133,12 +133,12 @@ export declare function getPriceClient(address?: string): import("nice-grpc").Ra
|
|
133
133
|
create(base?: {
|
134
134
|
limit?: number | undefined;
|
135
135
|
offset?: number | undefined;
|
136
|
-
|
136
|
+
searchQuery?: string | undefined;
|
137
137
|
} | undefined): import("@sentio/protos/price").ListCoinsRequest;
|
138
138
|
fromPartial(object: {
|
139
139
|
limit?: number | undefined;
|
140
140
|
offset?: number | undefined;
|
141
|
-
|
141
|
+
searchQuery?: string | undefined;
|
142
142
|
}): import("@sentio/protos/price").ListCoinsRequest;
|
143
143
|
};
|
144
144
|
readonly requestStream: false;
|
package/package.json
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sentio/sdk",
|
3
3
|
"license": "Apache-2.0",
|
4
|
-
"version": "2.
|
4
|
+
"version": "2.9.0-rc.2",
|
5
5
|
"type": "module",
|
6
6
|
"scripts": {
|
7
7
|
"compile": "tsc && cp src/utils/*.csv lib/utils && cp src/tsup.config.ts lib",
|
8
8
|
"build": "yarn gen && yarn compile",
|
9
9
|
"build_all": "yarn lerna run --scope=@sentio/sdk build --include-dependencies",
|
10
|
-
"test": "NODE_OPTIONS=--experimental-vm-modules yarn jest",
|
10
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules yarn jest --runInBand --detectOpenHandles",
|
11
11
|
"gen": "yarn gen:eth && yarn gen:aptos && yarn gen:sui && yarn gen:solana",
|
12
12
|
"gen:eth": "ts-node-esm src/eth/codegen/run.ts src/eth/abis src/eth/builtin && yarn gen:eth_test",
|
13
13
|
"gen:eth_test": "ts-node-esm src/eth/codegen/run.ts src/eth/tests/abis/eth ./src/eth/tests/types",
|
@@ -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.25",
|
26
|
-
"@sentio/protos": "^2.
|
27
|
-
"@sentio/runtime": "^2.
|
26
|
+
"@sentio/protos": "^2.9.0-rc.2",
|
27
|
+
"@sentio/runtime": "^2.9.0-rc.2",
|
28
28
|
"@solana/web3.js": "^1.73.2",
|
29
29
|
"@types/prettier": "^2.7.2",
|
30
30
|
"aptos-sdk": "npm:aptos@^1.7.1",
|
@@ -80,5 +80,5 @@
|
|
80
80
|
"engines": {
|
81
81
|
"node": ">=16"
|
82
82
|
},
|
83
|
-
"gitHead": "
|
83
|
+
"gitHead": "f22159ed1eac20a3ceed93e681822d039b47f715"
|
84
84
|
}
|
@@ -80,14 +80,11 @@ export class AptosPlugin extends Plugin {
|
|
80
80
|
}
|
81
81
|
|
82
82
|
for (const aptosProcessor of AptosAccountProcessorState.INSTANCE.getValues()) {
|
83
|
-
const accountConfig
|
83
|
+
const accountConfig = AccountConfig.fromPartial({
|
84
84
|
address: aptosProcessor.config.address,
|
85
85
|
chainId: aptosProcessor.getChainId(),
|
86
86
|
startBlock: aptosProcessor.config.startVersion,
|
87
|
-
|
88
|
-
intervalConfigs: [],
|
89
|
-
logConfigs: [],
|
90
|
-
}
|
87
|
+
})
|
91
88
|
for (const handler of aptosProcessor.resourcesHandlers) {
|
92
89
|
const handlerId = this.aptosResourceHandlers.push(handler.handler) - 1
|
93
90
|
accountConfig.aptosIntervalConfigs.push({
|
package/src/core/chain.ts
CHANGED
@@ -131,3 +131,57 @@ export function getChainType(chainId?: string | number): string {
|
|
131
131
|
}
|
132
132
|
return 'EVM'
|
133
133
|
}
|
134
|
+
|
135
|
+
export function getChainScanUrl(
|
136
|
+
chainId?: string | number,
|
137
|
+
hash?: string,
|
138
|
+
subtype?: 'block' | 'address' | 'transaction'
|
139
|
+
): string | undefined {
|
140
|
+
const chainName = getChainName(chainId)
|
141
|
+
if (chainName === 'Ethereum') {
|
142
|
+
if (subtype === 'block') {
|
143
|
+
return `https://etherscan.io/block/${hash}`
|
144
|
+
} else if (subtype === 'address') {
|
145
|
+
return `https://etherscan.io/address/${hash}`
|
146
|
+
} else {
|
147
|
+
return `https://etherscan.io/tx/${hash}`
|
148
|
+
}
|
149
|
+
}
|
150
|
+
if (chainName === 'Polygon') {
|
151
|
+
if (subtype === 'block') {
|
152
|
+
return `https://polygonscan.com/block/${hash}`
|
153
|
+
} else if (subtype === 'address') {
|
154
|
+
return `https://polygonscan.com/address/${hash}`
|
155
|
+
} else {
|
156
|
+
return `https://polygonscan.com/tx/${hash}`
|
157
|
+
}
|
158
|
+
}
|
159
|
+
if (chainName.startsWith('Aptos ')) {
|
160
|
+
if (subtype === 'block') {
|
161
|
+
return `https://explorer.aptos.io/block/${hash}`
|
162
|
+
} else if (subtype === 'address') {
|
163
|
+
return `https://explorer.aptos.io/account/${hash}`
|
164
|
+
} else {
|
165
|
+
return `https://explorer.aptos.io/txn/${hash}`
|
166
|
+
}
|
167
|
+
}
|
168
|
+
if (chainName.startsWith('Solana ')) {
|
169
|
+
if (subtype === 'block') {
|
170
|
+
return `https://explorer.solana.com/block/${hash}`
|
171
|
+
} else if (subtype === 'address') {
|
172
|
+
return `https://explorer.solana.com/address/${hash}`
|
173
|
+
} else {
|
174
|
+
return `https://explorer.solana.io/tx/${hash}`
|
175
|
+
}
|
176
|
+
}
|
177
|
+
if (chainName.startsWith('Sui ')) {
|
178
|
+
if (subtype === 'block') {
|
179
|
+
return `https://explorer.sui.io/block/${hash}`
|
180
|
+
} else if (subtype === 'address') {
|
181
|
+
return `https://explorer.sui.io/address/${hash}`
|
182
|
+
} else {
|
183
|
+
return `https://explorer.sui.io/transaction/${hash}`
|
184
|
+
}
|
185
|
+
}
|
186
|
+
return undefined
|
187
|
+
}
|
package/src/core/event-logger.ts
CHANGED
@@ -3,7 +3,7 @@ import { EventTrackingResult, LogLevel } from '@sentio/protos'
|
|
3
3
|
import { normalizeAttribute } from './normalization.js'
|
4
4
|
|
5
5
|
export interface Attribute<T> {
|
6
|
-
[key: string]: Exclude<T | number | bigint | string | LogLevel | Attribute<T> | undefined, Promise<any>>
|
6
|
+
[key: string]: Exclude<T | number | bigint | string | boolean | LogLevel | Attribute<T> | undefined, Promise<any>>
|
7
7
|
}
|
8
8
|
|
9
9
|
export interface Event<T> extends Attribute<T> {
|
package/src/core/index.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
export { BigDecimal, scaleDown } from './big-decimal.js'
|
2
|
+
export type { PartiallyOptional } from './partial-optional.js'
|
2
3
|
export { BaseContext } from './base-context.js'
|
3
4
|
export { normalizeLabels } from './normalization.js'
|
4
5
|
export { CounterBinding, Meter, type Labels, GaugeBinding, Counter, Gauge, MetricOptions } from './meter.js'
|
@@ -0,0 +1 @@
|
|
1
|
+
export type PartiallyOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>
|
@@ -2,8 +2,6 @@ import { ERC20__factory, ERC721__factory } from './builtin/internal/index.js'
|
|
2
2
|
import { AddressType, EthFetchConfig, ProcessResult } from '@sentio/protos'
|
3
3
|
import { AccountBindOptions } from './bind-options.js'
|
4
4
|
|
5
|
-
import { Network } from 'ethers/providers'
|
6
|
-
|
7
5
|
import { TransferEvent as ERC20TransferEvent, ERC20Processor } from './builtin/erc20.js'
|
8
6
|
import { TransferEvent as ERC721TransferEvent, ERC721Processor } from './builtin/erc721.js'
|
9
7
|
|
@@ -13,6 +11,8 @@ import { AddressOrTypeEventFilter, EventsHandler } from './base-processor.js'
|
|
13
11
|
import { Block, LogDescription } from 'ethers'
|
14
12
|
import { AccountProcessorState } from './account-processor-state.js'
|
15
13
|
import { formatEthData } from './eth.js'
|
14
|
+
import { getNetworkFromCtxOrNetworkish } from './provider.js'
|
15
|
+
import { PartiallyOptional } from '../core/partial-optional.js'
|
16
16
|
|
17
17
|
const ERC20_INTERFACE = ERC20__factory.createInterface()
|
18
18
|
const ERC721_INTERFACE = ERC721__factory.createInterface()
|
@@ -21,24 +21,21 @@ export class AccountProcessor {
|
|
21
21
|
config: AccountBindOptions
|
22
22
|
eventHandlers: EventsHandler[] = []
|
23
23
|
|
24
|
-
static bind(config: AccountBindOptions): AccountProcessor {
|
24
|
+
static bind(config: PartiallyOptional<AccountBindOptions, 'network'>): AccountProcessor {
|
25
25
|
const processor = new AccountProcessor(config)
|
26
26
|
AccountProcessorState.INSTANCE.addValue(processor)
|
27
27
|
return processor
|
28
28
|
}
|
29
29
|
|
30
|
-
protected constructor(config: AccountBindOptions) {
|
31
|
-
this.config =
|
32
|
-
|
33
|
-
|
34
|
-
if (Number.isFinite(asInt)) {
|
35
|
-
this.config.network = asInt
|
36
|
-
}
|
30
|
+
protected constructor(config: PartiallyOptional<AccountBindOptions, 'network'>) {
|
31
|
+
this.config = {
|
32
|
+
...config,
|
33
|
+
network: getNetworkFromCtxOrNetworkish(config.network),
|
37
34
|
}
|
38
35
|
}
|
39
36
|
|
40
37
|
public getChainId(): number {
|
41
|
-
return Number(
|
38
|
+
return Number(this.config.network.chainId)
|
42
39
|
}
|
43
40
|
|
44
41
|
/**
|
@@ -6,9 +6,10 @@ import { EthFetchConfig, HandleInterval, TemplateInstance } from '@sentio/protos
|
|
6
6
|
import { PromiseOrVoid } from '../promise-or-void.js'
|
7
7
|
import { Trace } from './trace.js'
|
8
8
|
import { ListStateStorage } from '@sentio/runtime'
|
9
|
-
import { BlockParams
|
9
|
+
import { BlockParams } from 'ethers/providers'
|
10
10
|
import { DeferredTopicFilter } from 'ethers/contract'
|
11
11
|
import { EthEvent } from './eth.js'
|
12
|
+
import { getNetworkFromCtxOrNetworkish } from './provider.js'
|
12
13
|
|
13
14
|
export class ProcessorTemplateProcessorState extends ListStateStorage<
|
14
15
|
BaseProcessorTemplate<BaseContract, BoundContractView<BaseContract, any>>
|
@@ -71,7 +72,7 @@ export abstract class BaseProcessorTemplate<
|
|
71
72
|
contract: {
|
72
73
|
address: options.address,
|
73
74
|
name: options.name || '',
|
74
|
-
chainId:
|
75
|
+
chainId: getNetworkFromCtxOrNetworkish(options.network).chainId.toString(),
|
75
76
|
abi: '',
|
76
77
|
},
|
77
78
|
startBlock: 0n,
|
@@ -11,12 +11,13 @@ import {
|
|
11
11
|
HandleInterval,
|
12
12
|
ProcessResult,
|
13
13
|
} from '@sentio/protos'
|
14
|
-
import {
|
14
|
+
import { BindOptions } from './bind-options.js'
|
15
15
|
import { PromiseOrVoid } from '../promise-or-void.js'
|
16
16
|
import { Trace } from './trace.js'
|
17
17
|
import { ServerError, Status } from 'nice-grpc'
|
18
18
|
import { decodeResult, EthEvent, formatEthData } from './eth.js'
|
19
19
|
import * as console from 'console'
|
20
|
+
import { getNetworkFromCtxOrNetworkish } from './provider.js'
|
20
21
|
|
21
22
|
export interface AddressOrTypeEventFilter extends DeferredTopicFilter {
|
22
23
|
addressType?: AddressType
|
@@ -41,6 +42,14 @@ export class BlockHandlder {
|
|
41
42
|
handler: (block: Data_EthBlock) => Promise<ProcessResult>
|
42
43
|
}
|
43
44
|
|
45
|
+
class BindInternalOptions {
|
46
|
+
address: string
|
47
|
+
network: Network
|
48
|
+
name: string
|
49
|
+
startBlock: bigint
|
50
|
+
endBlock?: bigint
|
51
|
+
}
|
52
|
+
|
44
53
|
export abstract class BaseProcessor<
|
45
54
|
TContract extends BaseContract,
|
46
55
|
TBoundContractView extends BoundContractView<TContract, ContractView<TContract>>
|
@@ -55,15 +64,9 @@ export abstract class BaseProcessor<
|
|
55
64
|
this.config = {
|
56
65
|
address: config.address,
|
57
66
|
name: config.name || '',
|
58
|
-
network: config.network
|
67
|
+
network: getNetworkFromCtxOrNetworkish(config.network),
|
59
68
|
startBlock: 0n,
|
60
69
|
}
|
61
|
-
if (typeof this.config.network === 'string') {
|
62
|
-
const asInt = parseInt(this.config.network)
|
63
|
-
if (Number.isFinite(asInt)) {
|
64
|
-
this.config.network = asInt
|
65
|
-
}
|
66
|
-
}
|
67
70
|
if (config.startBlock) {
|
68
71
|
this.config.startBlock = BigInt(config.startBlock)
|
69
72
|
}
|
@@ -75,7 +78,7 @@ export abstract class BaseProcessor<
|
|
75
78
|
protected abstract CreateBoundContractView(): TBoundContractView
|
76
79
|
|
77
80
|
public getChainId(): number {
|
78
|
-
return Number(
|
81
|
+
return Number(this.config.network.chainId)
|
79
82
|
}
|
80
83
|
|
81
84
|
public onEvent(
|
package/src/eth/bind-options.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import { Networkish, Network } from 'ethers/providers'
|
2
|
+
import { getNetworkFromCtxOrNetworkish } from './provider.js'
|
2
3
|
|
3
4
|
export class BindOptions {
|
4
5
|
// Contract address
|
@@ -14,13 +15,8 @@ export class BindOptions {
|
|
14
15
|
export function getOptionsSignature(opts: BindOptions): string {
|
15
16
|
const sig = [opts.address]
|
16
17
|
if (opts.network) {
|
17
|
-
|
18
|
-
|
19
|
-
if (Number.isFinite(asInt)) {
|
20
|
-
opts.network = asInt
|
21
|
-
}
|
22
|
-
}
|
23
|
-
sig.push(Network.from(opts.network).chainId.toString())
|
18
|
+
const n = getNetworkFromCtxOrNetworkish(opts.network)
|
19
|
+
sig.push(n.chainId.toString())
|
24
20
|
}
|
25
21
|
if (opts.name) {
|
26
22
|
sig.push(opts.name)
|
@@ -34,16 +30,8 @@ export function getOptionsSignature(opts: BindOptions): string {
|
|
34
30
|
return sig.join('_')
|
35
31
|
}
|
36
32
|
|
37
|
-
export class BindInternalOptions {
|
38
|
-
address: string
|
39
|
-
network: Networkish
|
40
|
-
name: string
|
41
|
-
startBlock: bigint
|
42
|
-
endBlock?: bigint
|
43
|
-
}
|
44
|
-
|
45
33
|
export class AccountBindOptions {
|
46
34
|
address: string
|
47
|
-
network
|
35
|
+
network: Network
|
48
36
|
startBlock?: bigint | number
|
49
37
|
}
|
package/src/eth/binds.ts
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
import { BindOptions, getOptionsSignature } from './bind-options.js'
|
2
2
|
import { ContractView } from './context.js'
|
3
3
|
import { BaseProcessor } from './base-processor.js'
|
4
|
-
import { Networkish
|
4
|
+
import { Networkish } from 'ethers/providers'
|
5
5
|
|
6
6
|
import { BaseContract } from 'ethers'
|
7
7
|
import { MapStateStorage } from '@sentio/runtime'
|
8
|
+
import { getNetworkFromCtxOrNetworkish } from './provider.js'
|
8
9
|
|
9
10
|
export class ProcessorState extends MapStateStorage<BaseProcessor<any, any>> {
|
10
11
|
static INSTANCE = new ProcessorState()
|
@@ -14,7 +15,7 @@ export class ProcessorState extends MapStateStorage<BaseProcessor<any, any>> {
|
|
14
15
|
const contracts = new Map<string, ContractView<BaseContract>>()
|
15
16
|
|
16
17
|
function getKey(abiName: string, address: string, network: Networkish) {
|
17
|
-
const chainId =
|
18
|
+
const chainId = getNetworkFromCtxOrNetworkish(network).chainId.toString()
|
18
19
|
return [abiName, address.toLowerCase(), chainId].join('_')
|
19
20
|
}
|
20
21
|
|
package/src/eth/eth-plugin.ts
CHANGED
@@ -114,14 +114,11 @@ export class EthPlugin extends Plugin {
|
|
114
114
|
|
115
115
|
// part 1.b prepare EVM account processors
|
116
116
|
for (const processor of AccountProcessorState.INSTANCE.getValues()) {
|
117
|
-
const accountConfig
|
117
|
+
const accountConfig = AccountConfig.fromPartial({
|
118
118
|
address: processor.config.address,
|
119
119
|
chainId: processor.getChainId().toString(),
|
120
120
|
startBlock: processor.config.startBlock ? BigInt(processor.config.startBlock) : 0n,
|
121
|
-
|
122
|
-
intervalConfigs: [],
|
123
|
-
logConfigs: [],
|
124
|
-
}
|
121
|
+
})
|
125
122
|
// TODO add interval
|
126
123
|
for (const eventsHandler of processor.eventHandlers) {
|
127
124
|
// associate id with filter
|
package/src/eth/provider.ts
CHANGED
@@ -18,9 +18,10 @@ export function getNetworkFromCtxOrNetworkish(networkish?: BaseContext | Network
|
|
18
18
|
}
|
19
19
|
if (typeof networkish === 'string') {
|
20
20
|
const id = parseInt(networkish)
|
21
|
-
if (
|
22
|
-
|
21
|
+
if (isNaN(id)) {
|
22
|
+
throw Error('Unexpected Network')
|
23
23
|
}
|
24
|
+
networkish = id
|
24
25
|
}
|
25
26
|
return Network.from(networkish)
|
26
27
|
}
|
@@ -45,7 +46,7 @@ export function getProvider(networkish?: Networkish): Provider {
|
|
45
46
|
[...Endpoints.INSTANCE.chainServer.keys()].join(' ')
|
46
47
|
)
|
47
48
|
}
|
48
|
-
provider = new QueuedStaticJsonRpcProvider(address,
|
49
|
+
provider = new QueuedStaticJsonRpcProvider(address, network, Endpoints.INSTANCE.concurrency)
|
49
50
|
providers.set(network.chainId.toString(), provider)
|
50
51
|
return provider
|
51
52
|
}
|
package/src/sui/context.ts
CHANGED
@@ -48,3 +48,36 @@ export class SuiContext extends BaseContext {
|
|
48
48
|
}
|
49
49
|
}
|
50
50
|
}
|
51
|
+
|
52
|
+
export class SuiObjectContext extends BaseContext {
|
53
|
+
address: string
|
54
|
+
network: SuiNetwork
|
55
|
+
slot: bigint
|
56
|
+
timestamp: Date
|
57
|
+
|
58
|
+
constructor(network: SuiNetwork, address: string, slot: bigint, timestamp: Date) {
|
59
|
+
super()
|
60
|
+
this.address = address
|
61
|
+
this.network = network
|
62
|
+
this.slot = slot
|
63
|
+
this.timestamp = timestamp
|
64
|
+
}
|
65
|
+
|
66
|
+
getChainId(): string {
|
67
|
+
return getChainId(this.network)
|
68
|
+
}
|
69
|
+
|
70
|
+
getMetaData(name: string, labels: Labels): RecordMetaData {
|
71
|
+
return {
|
72
|
+
address: this.address,
|
73
|
+
contractName: 'objects',
|
74
|
+
blockNumber: this.slot,
|
75
|
+
transactionIndex: 0,
|
76
|
+
transactionHash: '',
|
77
|
+
logIndex: 0,
|
78
|
+
chainId: this.getChainId(),
|
79
|
+
name: name,
|
80
|
+
labels: normalizeLabels(labels),
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}
|
package/src/sui/sui-plugin.ts
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
import { errorString, mergeProcessResults, Plugin, PluginManager, USER_PROCESSOR } from '@sentio/runtime'
|
2
2
|
import {
|
3
|
+
AccountConfig,
|
3
4
|
ContractConfig,
|
4
5
|
Data_SuiCall,
|
5
6
|
Data_SuiEvent,
|
7
|
+
Data_SuiObject,
|
6
8
|
DataBinding,
|
7
9
|
HandlerType,
|
8
10
|
MoveCallHandlerConfig,
|
@@ -13,7 +15,7 @@ import {
|
|
13
15
|
|
14
16
|
import { ServerError, Status } from 'nice-grpc'
|
15
17
|
|
16
|
-
import { SuiProcessorState } from './sui-processor.js'
|
18
|
+
import { SuiAccountProcessorState, SuiProcessorState } from './sui-processor.js'
|
17
19
|
import { getChainId } from './network.js'
|
18
20
|
|
19
21
|
export class SuiPlugin extends Plugin {
|
@@ -21,6 +23,7 @@ export class SuiPlugin extends Plugin {
|
|
21
23
|
|
22
24
|
private suiEventHandlers: ((event: Data_SuiEvent) => Promise<ProcessResult>)[] = []
|
23
25
|
private suiCallHandlers: ((func: Data_SuiCall) => Promise<ProcessResult>)[] = []
|
26
|
+
private suiObjectHandlers: ((object: Data_SuiObject) => Promise<ProcessResult>)[] = []
|
24
27
|
|
25
28
|
async configure(config: ProcessConfigResponse) {
|
26
29
|
for (const suiProcessor of SuiProcessorState.INSTANCE.getValues()) {
|
@@ -67,6 +70,27 @@ export class SuiPlugin extends Plugin {
|
|
67
70
|
}
|
68
71
|
config.contractConfigs.push(contractConfig)
|
69
72
|
}
|
73
|
+
|
74
|
+
for (const processor of SuiAccountProcessorState.INSTANCE.getValues()) {
|
75
|
+
const accountConfig = AccountConfig.fromPartial({
|
76
|
+
address: processor.config.address,
|
77
|
+
chainId: processor.getChainId(),
|
78
|
+
startBlock: BigInt(processor.config.startTimestamp), // TODO maybe use another field
|
79
|
+
})
|
80
|
+
for (const handler of processor.objectHandlers) {
|
81
|
+
const handlerId = this.suiObjectHandlers.push(handler.handler) - 1
|
82
|
+
accountConfig.suiIntervalConfigs.push({
|
83
|
+
intervalConfig: {
|
84
|
+
handlerId: handlerId,
|
85
|
+
minutes: 0,
|
86
|
+
minutesInterval: handler.timeIntervalInMinutes,
|
87
|
+
slot: 0,
|
88
|
+
slotInterval: handler.versionInterval,
|
89
|
+
},
|
90
|
+
})
|
91
|
+
}
|
92
|
+
config.accountConfigs.push(accountConfig)
|
93
|
+
}
|
70
94
|
}
|
71
95
|
|
72
96
|
supportedHandlers = [HandlerType.SUI_EVENT, HandlerType.SUI_CALL]
|
@@ -107,12 +131,34 @@ export class SuiPlugin extends Plugin {
|
|
107
131
|
return mergeProcessResults(await Promise.all(promises))
|
108
132
|
}
|
109
133
|
|
134
|
+
async processSuiObject(binding: DataBinding): Promise<ProcessResult> {
|
135
|
+
if (!binding.data?.suiObject) {
|
136
|
+
throw new ServerError(Status.INVALID_ARGUMENT, "Object can't be empty")
|
137
|
+
}
|
138
|
+
const object = binding.data.suiObject
|
139
|
+
|
140
|
+
const promises: Promise<ProcessResult>[] = []
|
141
|
+
for (const handlerId of binding.handlerIds) {
|
142
|
+
promises.push(
|
143
|
+
this.suiObjectHandlers[handlerId](object).catch((e) => {
|
144
|
+
throw new ServerError(
|
145
|
+
Status.INTERNAL,
|
146
|
+
'error processing object: ' + JSON.stringify(object) + '\n' + errorString(e)
|
147
|
+
)
|
148
|
+
})
|
149
|
+
)
|
150
|
+
}
|
151
|
+
return mergeProcessResults(await Promise.all(promises))
|
152
|
+
}
|
153
|
+
|
110
154
|
processBinding(request: DataBinding): Promise<ProcessResult> {
|
111
155
|
switch (request.handlerType) {
|
112
156
|
case HandlerType.SUI_EVENT:
|
113
157
|
return this.processSuiEvent(request)
|
114
158
|
case HandlerType.SUI_CALL:
|
115
159
|
return this.processSuiFunctionCall(request)
|
160
|
+
case HandlerType.SUI_OBJECT:
|
161
|
+
return this.processSuiObject(request)
|
116
162
|
default:
|
117
163
|
throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)
|
118
164
|
}
|