@sentio/sdk 1.11.1 → 1.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bind-options.d.ts +2 -0
- package/lib/bind-options.js +4 -1
- package/lib/bind-options.js.map +1 -1
- package/lib/context.d.ts +2 -0
- package/lib/context.js +4 -1
- package/lib/context.js.map +1 -1
- package/lib/gen/processor/protos/processor.d.ts +1 -1
- package/lib/gen/processor/protos/processor.js +15 -15
- package/lib/gen/processor/protos/processor.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +4 -1
- package/lib/index.js.map +1 -1
- package/lib/processor-state.d.ts +2 -0
- package/lib/processor-state.js +1 -0
- package/lib/processor-state.js.map +1 -1
- package/lib/service.js +48 -1
- package/lib/service.js.map +1 -1
- package/lib/sui-processor.d.ts +21 -0
- package/lib/sui-processor.js +65 -0
- package/lib/sui-processor.js.map +1 -0
- package/lib/test/sui.test.d.ts +1 -0
- package/lib/test/sui.test.js +162 -0
- package/lib/test/sui.test.js.map +1 -0
- package/lib/test/tic-tac-toe.d.ts +1 -0
- package/lib/test/tic-tac-toe.js +31 -0
- package/lib/test/tic-tac-toe.js.map +1 -0
- package/package.json +1 -1
- package/src/bind-options.ts +2 -0
- package/src/context.ts +2 -0
- package/src/gen/processor/protos/processor.ts +19 -19
- package/src/index.ts +2 -1
- package/src/processor-state.ts +3 -0
- package/src/service.ts +53 -1
- package/src/sui-processor.ts +75 -0
- package/src/test/sui.test.ts +167 -0
- package/src/test/tic-tac-toe.ts +31 -0
package/lib/index.d.ts
CHANGED
|
@@ -6,8 +6,9 @@ export { ProcessorServiceImpl } from './service';
|
|
|
6
6
|
export { Counter, Meter, Gauge } from './meter';
|
|
7
7
|
export { getProvider, setProvider, DummyProvider } from './provider';
|
|
8
8
|
export { SolanaBaseProcessor } from './solana-processor';
|
|
9
|
+
export { SuiBaseProcessor } from './sui-processor';
|
|
9
10
|
export { ContractNamer } from './contract-namer';
|
|
10
|
-
export { BindOptions, SolanaBindOptions } from './bind-options';
|
|
11
|
+
export { BindOptions, SolanaBindOptions, SuiBindOptions } from './bind-options';
|
|
11
12
|
export { transformEtherError } from './error';
|
|
12
13
|
export { ProcessorState } from './processor-state';
|
|
13
14
|
export { BigNumber as BigDecimal } from 'bignumber.js';
|
package/lib/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.SPLTokenProcessor = exports.getContractName = exports.addContractByABI = exports.getContractByABI = exports.addProcessor = exports.getProcessor = exports.EthersError = exports.BigDecimal = exports.ProcessorState = exports.transformEtherError = exports.SolanaBindOptions = exports.BindOptions = exports.ContractNamer = exports.SolanaBaseProcessor = exports.DummyProvider = exports.setProvider = exports.getProvider = exports.Gauge = exports.Meter = exports.Counter = exports.ProcessorServiceImpl = exports.SolanaContext = exports.BoundContractView = exports.ContractView = exports.Context = exports.BaseProcessorTemplate = exports.GenericProcessor = exports.BaseProcessor = void 0;
|
|
17
|
+
exports.SPLTokenProcessor = exports.getContractName = exports.addContractByABI = exports.getContractByABI = exports.addProcessor = exports.getProcessor = exports.EthersError = exports.BigDecimal = exports.ProcessorState = exports.transformEtherError = exports.SuiBindOptions = exports.SolanaBindOptions = exports.BindOptions = exports.ContractNamer = exports.SuiBaseProcessor = exports.SolanaBaseProcessor = exports.DummyProvider = exports.setProvider = exports.getProvider = exports.Gauge = exports.Meter = exports.Counter = exports.ProcessorServiceImpl = exports.SolanaContext = exports.BoundContractView = exports.ContractView = exports.Context = exports.BaseProcessorTemplate = exports.GenericProcessor = exports.BaseProcessor = void 0;
|
|
18
18
|
var base_processor_1 = require("./base-processor");
|
|
19
19
|
Object.defineProperty(exports, "BaseProcessor", { enumerable: true, get: function () { return base_processor_1.BaseProcessor; } });
|
|
20
20
|
var generic_processor_1 = require("./generic-processor");
|
|
@@ -38,11 +38,14 @@ Object.defineProperty(exports, "setProvider", { enumerable: true, get: function
|
|
|
38
38
|
Object.defineProperty(exports, "DummyProvider", { enumerable: true, get: function () { return provider_1.DummyProvider; } });
|
|
39
39
|
var solana_processor_1 = require("./solana-processor");
|
|
40
40
|
Object.defineProperty(exports, "SolanaBaseProcessor", { enumerable: true, get: function () { return solana_processor_1.SolanaBaseProcessor; } });
|
|
41
|
+
var sui_processor_1 = require("./sui-processor");
|
|
42
|
+
Object.defineProperty(exports, "SuiBaseProcessor", { enumerable: true, get: function () { return sui_processor_1.SuiBaseProcessor; } });
|
|
41
43
|
var contract_namer_1 = require("./contract-namer");
|
|
42
44
|
Object.defineProperty(exports, "ContractNamer", { enumerable: true, get: function () { return contract_namer_1.ContractNamer; } });
|
|
43
45
|
var bind_options_1 = require("./bind-options");
|
|
44
46
|
Object.defineProperty(exports, "BindOptions", { enumerable: true, get: function () { return bind_options_1.BindOptions; } });
|
|
45
47
|
Object.defineProperty(exports, "SolanaBindOptions", { enumerable: true, get: function () { return bind_options_1.SolanaBindOptions; } });
|
|
48
|
+
Object.defineProperty(exports, "SuiBindOptions", { enumerable: true, get: function () { return bind_options_1.SuiBindOptions; } });
|
|
46
49
|
var error_1 = require("./error");
|
|
47
50
|
Object.defineProperty(exports, "transformEtherError", { enumerable: true, get: function () { return error_1.transformEtherError; } });
|
|
48
51
|
var processor_state_1 = require("./processor-state");
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mDAAgD;AAAvC,+GAAA,aAAa,OAAA;AACtB,yDAAsD;AAA7C,qHAAA,gBAAgB,OAAA;AACzB,qEAAiE;AAAxD,gIAAA,qBAAqB,OAAA;AAC9B,qCAAmF;AAA1E,kGAAA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,mBAAmB,OAAA;AAC5B,qDAAkD;AAAzC,iHAAA,cAAc,OAAA;AACvB,6CAAsD;AAA7C,0GAAA,SAAS,OAAc;AAChC,iCAAqC;AAA5B,oGAAA,WAAW,OAAA;AAGpB,iCAAyG;AAAhG,qGAAA,YAAY,OAAA;AAAE,qGAAA,YAAY,OAAA;AAAE,yGAAA,gBAAgB,OAAA;AAAE,yGAAA,gBAAgB,OAAA;AAAE,wGAAA,eAAe,OAAA;AAExF,mEAAgD;AAEhD,4CAAoD;AAA3C,4GAAA,iBAAiB,OAAA","sourcesContent":["export { BaseProcessor } from './base-processor'\nexport { GenericProcessor } from './generic-processor'\nexport { BaseProcessorTemplate } from './base-processor-template'\nexport { Context, ContractView, BoundContractView, SolanaContext } from './context'\nexport { ProcessorServiceImpl } from './service'\nexport { Counter, Meter, Gauge } from './meter'\nexport { getProvider, setProvider, DummyProvider } from './provider'\nexport { SolanaBaseProcessor } from './solana-processor'\nexport { SuiBaseProcessor } from './sui-processor'\nexport { ContractNamer } from './contract-namer'\nexport { BindOptions, SolanaBindOptions, SuiBindOptions } from './bind-options'\nexport { transformEtherError } from './error'\nexport { ProcessorState } from './processor-state'\nexport { BigNumber as BigDecimal } from 'bignumber.js'\nexport { EthersError } from './error'\nexport type { TypedCallTrace } from './trace'\n\nexport { getProcessor, addProcessor, getContractByABI, addContractByABI, getContractName } from './binds'\n\nexport * from './gen/processor/protos/processor'\n\nexport { SPLTokenProcessor } from './solana/builtin'\n"]}
|
package/lib/processor-state.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { BaseProcessorTemplate } from './base-processor-template';
|
|
|
5
5
|
import { TemplateInstance } from './gen/processor/protos/processor';
|
|
6
6
|
import { Provider } from '@ethersproject/providers';
|
|
7
7
|
import { SolanaBaseProcessor } from './solana-processor';
|
|
8
|
+
import { SuiBaseProcessor } from './sui-processor';
|
|
8
9
|
export declare class ProcessorState {
|
|
9
10
|
contracts: Map<string, ContractView<BaseContract>>;
|
|
10
11
|
processors: BaseProcessor<BaseContract, BoundContractView<BaseContract, any>>[];
|
|
@@ -13,4 +14,5 @@ export declare class ProcessorState {
|
|
|
13
14
|
templates: BaseProcessorTemplate<BaseContract, BoundContractView<BaseContract, any>>[];
|
|
14
15
|
templatesInstances: TemplateInstance[];
|
|
15
16
|
solanaProcessors: SolanaBaseProcessor[];
|
|
17
|
+
suiProcessors: SuiBaseProcessor[];
|
|
16
18
|
}
|
package/lib/processor-state.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processor-state.js","sourceRoot":"","sources":["../src/processor-state.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"processor-state.js","sourceRoot":"","sources":["../src/processor-state.ts"],"names":[],"mappings":";;;AASA,MAAa,cAAc;IACzB,mDAAmD;IACnD,SAAS,GAAG,IAAI,GAAG,EAAsC,CAAA;IACzD,qBAAqB;IACrB,UAAU,GAAwE,EAAE,CAAA;IACpF,oCAAoC;IACpC,YAAY,GAAG,IAAI,GAAG,EAAmC,CAAA;IACzD,gBAAgB;IAChB,SAAS,GAAG,IAAI,GAAG,EAAoB,CAAA;IACvC,0BAA0B;IAC1B,SAAS,GAAgF,EAAE,CAAA;IAC3F,wCAAwC;IACxC,kBAAkB,GAAuB,EAAE,CAAA;IAE3C,gBAAgB,GAA0B,EAAE,CAAA;IAE5C,aAAa,GAAuB,EAAE,CAAA;CACvC;AAjBD,wCAiBC","sourcesContent":["import { BaseProcessor } from './base-processor'\nimport { BaseContract } from 'ethers'\nimport { BoundContractView, ContractView } from './context'\nimport { BaseProcessorTemplate } from './base-processor-template'\nimport { TemplateInstance } from './gen/processor/protos/processor'\nimport { Provider } from '@ethersproject/providers'\nimport { SolanaBaseProcessor } from './solana-processor'\nimport { SuiBaseProcessor } from './sui-processor'\n\nexport class ProcessorState {\n // from abiName_address_chainId => contract wrapper\n contracts = new Map<string, ContractView<BaseContract>>()\n // all evm processors\n processors: BaseProcessor<BaseContract, BoundContractView<BaseContract, any>>[] = []\n // from abiName_options to contracts\n processorMap = new Map<string, BaseProcessor<any, any>>()\n // evm providers\n providers = new Map<number, Provider>()\n // evm processor templates\n templates: BaseProcessorTemplate<BaseContract, BoundContractView<BaseContract, any>>[] = []\n // evm processor template instances spec\n templatesInstances: TemplateInstance[] = []\n\n solanaProcessors: SolanaBaseProcessor[] = []\n\n suiProcessors: SuiBaseProcessor[] = []\n}\n"]}
|
package/lib/service.js
CHANGED
|
@@ -136,6 +136,25 @@ class ProcessorServiceImpl {
|
|
|
136
136
|
};
|
|
137
137
|
this.contractConfigs.push(contractConfig);
|
|
138
138
|
}
|
|
139
|
+
// Part 3, prepare sui constractors
|
|
140
|
+
for (const suiProcessor of global.PROCESSOR_STATE.suiProcessors) {
|
|
141
|
+
const contractConfig = {
|
|
142
|
+
processorType: 'user_processor',
|
|
143
|
+
contract: {
|
|
144
|
+
name: 'sui processor',
|
|
145
|
+
chainId: 'SUI_devnet',
|
|
146
|
+
address: suiProcessor.address,
|
|
147
|
+
abi: '',
|
|
148
|
+
},
|
|
149
|
+
blockConfigs: [],
|
|
150
|
+
logConfigs: [],
|
|
151
|
+
traceConfigs: [],
|
|
152
|
+
startBlock: suiProcessor.config.startSeqNumber,
|
|
153
|
+
endBlock: DEFAULT_MAX_BLOCK,
|
|
154
|
+
instructionConfig: undefined,
|
|
155
|
+
};
|
|
156
|
+
this.contractConfigs.push(contractConfig);
|
|
157
|
+
}
|
|
139
158
|
}
|
|
140
159
|
async start(request, context) {
|
|
141
160
|
if (this.started) {
|
|
@@ -219,7 +238,35 @@ class ProcessorServiceImpl {
|
|
|
219
238
|
if (!this.started) {
|
|
220
239
|
throw new nice_grpc_1.ServerError(nice_grpc_1.Status.UNAVAILABLE, 'Service not started.');
|
|
221
240
|
}
|
|
222
|
-
|
|
241
|
+
const result = {
|
|
242
|
+
gauges: [],
|
|
243
|
+
counters: [],
|
|
244
|
+
logs: [],
|
|
245
|
+
};
|
|
246
|
+
if (global.PROCESSOR_STATE.suiProcessors) {
|
|
247
|
+
const processorPromises = [];
|
|
248
|
+
for (const txn of request.transactions) {
|
|
249
|
+
processorPromises.push(new Promise((resolve, _) => {
|
|
250
|
+
for (const processor of global.PROCESSOR_STATE.suiProcessors) {
|
|
251
|
+
const res = processor.handleTransaction(JSON.parse(new util_1.TextDecoder().decode(txn.raw)));
|
|
252
|
+
if (res) {
|
|
253
|
+
res.gauges.forEach((g) => {
|
|
254
|
+
result.gauges.push(g);
|
|
255
|
+
});
|
|
256
|
+
res.counters.forEach((c) => {
|
|
257
|
+
result.counters.push(c);
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
resolve();
|
|
262
|
+
}));
|
|
263
|
+
}
|
|
264
|
+
await Promise.all(processorPromises);
|
|
265
|
+
}
|
|
266
|
+
recordRuntimeInfo(result, processor_1.HandlerType.TRANSACTION);
|
|
267
|
+
return {
|
|
268
|
+
result,
|
|
269
|
+
};
|
|
223
270
|
}
|
|
224
271
|
async processInstructions(request, context) {
|
|
225
272
|
if (!this.started) {
|
package/lib/service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":";;;;;;AACA,yCAA4D;AAE5D,gEAuByC;AAGzC,gDAAuB;AACvB,+BAAkC;AAGlC,MAAM,iBAAiB,GAAG,cAAI,CAAC,IAAI,CAAA;AAEnC,MAAa,oBAAoB;IACvB,aAAa,GAA+C,EAAE,CAAA;IAC9D,aAAa,GAAiD,EAAE,CAAA;IAChE,aAAa,GAAiD,EAAE,CAAA;IAExE,0CAA0C;IAC1C,0FAA0F;IAC1F,qHAAqH;IAE7G,OAAO,GAAG,KAAK,CAAA;IACf,eAAe,CAAkB;IACjC,iBAAiB,CAAoB;IAC5B,MAAM,CAAY;IAElB,eAAe,CAAa;IAE7C,YAAY,MAAkB,EAAE,eAA4B;QAC1D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IA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AK,EAAE;gBACL,wBAAwB;gBACxB,KAAK,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAA;gBAClB,GAAG,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAA;gBAC9D,MAAK;YACP,KAAK,EAAE;gBACL,kCAAkC;gBAClC,KAAK,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAA;gBAClB,KAAK,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAA;gBAClB,GAAG,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;gBAC9F,MAAK;SACR;KACF;IAED,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,SAAS,iBAAiB,CAAC,OAAsB,EAAE,WAAwB;IACzE,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QAC3B,CAAC,CAAC,WAAW,GAAG;YACd,IAAI,EAAE,WAAW;SAClB,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QAC7B,CAAC,CAAC,WAAW,GAAG;YACd,IAAI,EAAE,WAAW;SAClB,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { Block, Log } from '@ethersproject/abstract-provider'\nimport { CallContext, ServerError, Status } from 'nice-grpc'\n\nimport {\n BlockBinding,\n ContractConfig,\n HandlerType,\n LogFilter,\n LogHandlerConfig,\n ProcessResult,\n ProcessBlocksRequest,\n ProcessBlocksResponse,\n ProcessConfigRequest,\n ProcessConfigResponse,\n ProcessInstructionsRequest,\n ProcessInstructionsResponse,\n ProcessLogsRequest,\n ProcessLogsResponse,\n ProcessorServiceImplementation,\n ProcessTracesRequest,\n ProcessTracesResponse,\n ProcessTransactionsRequest,\n ProcessTransactionsResponse,\n StartRequest,\n TemplateInstance,\n TraceBinding,\n} from './gen/processor/protos/processor'\n\nimport { Empty } from './gen/google/protobuf/empty'\nimport Long from 'long'\nimport { TextDecoder } from 'util'\nimport { Trace } from './trace'\n\nconst DEFAULT_MAX_BLOCK = Long.ZERO\n\nexport class ProcessorServiceImpl implements ProcessorServiceImplementation {\n private eventHandlers: ((event: Log) => Promise<ProcessResult>)[] = []\n private traceHandlers: ((trace: Trace) => Promise<ProcessResult>)[] = []\n private blockHandlers: ((block: Block) => Promise<ProcessResult>)[] = []\n\n // map from chain id to list of processors\n // private blockHandlers = new Map<string, ((block: Block) => Promise<ProcessResult>)[]>()\n // private processorsByChainId = new Map<string, BaseProcessor<BaseContract, BoundContractView<BaseContract, any>>>()\n\n private started = false\n private contractConfigs: ContractConfig[]\n private templateInstances: TemplateInstance[]\n private readonly loader: () => void\n\n private readonly shutdownHandler?: () => void\n\n constructor(loader: () => void, shutdownHandler?: () => void) {\n this.loader = loader\n this.shutdownHandler = shutdownHandler\n }\n\n async getConfig(request: ProcessConfigRequest, context: CallContext): Promise<ProcessConfigResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n return {\n // TODO project setting\n config: undefined,\n contractConfigs: this.contractConfigs,\n templateInstances: this.templateInstances,\n }\n }\n\n async configure() {\n this.eventHandlers = []\n this.templateInstances = []\n // this.processorsByChainId.clear()\n this.contractConfigs = []\n\n this.templateInstances = [...global.PROCESSOR_STATE.templatesInstances]\n\n // Part 1, prepare EVM processors\n for (const processor of global.PROCESSOR_STATE.processors) {\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 blockConfigs: [],\n logConfigs: [],\n traceConfigs: [],\n startBlock: processor.config.startBlock,\n endBlock: DEFAULT_MAX_BLOCK,\n instructionConfig: undefined,\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) - 1\n contractConfig.blockConfigs.push({\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 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 this.contractConfigs.push(contractConfig)\n }\n\n // Part 2, prepare solana constractors\n for (const solanaProcessor of global.PROCESSOR_STATE.solanaProcessors) {\n const contractConfig: ContractConfig = {\n processorType: 'user_processor',\n contract: {\n name: solanaProcessor.contractName,\n chainId: 'SOL_mainnet', // TODO set in processor\n address: solanaProcessor.address,\n abi: '',\n },\n blockConfigs: [],\n logConfigs: [],\n traceConfigs: [],\n startBlock: solanaProcessor.config.startSlot,\n endBlock: DEFAULT_MAX_BLOCK,\n instructionConfig: {\n innerInstruction: solanaProcessor.processInnerInstruction,\n parsedInstruction: solanaProcessor.fromParsedInstruction !== null,\n rawDataInstruction: solanaProcessor.decodeInstruction !== null,\n },\n }\n this.contractConfigs.push(contractConfig)\n }\n }\n\n async start(request: StartRequest, context: CallContext): Promise<Empty> {\n if (this.started) {\n return {}\n }\n\n this.loader()\n\n for (const instance of request.templateInstances) {\n const template = global.PROCESSOR_STATE.templates[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 await this.configure()\n this.started = true\n return {}\n }\n\n async stop(request: Empty, context: CallContext): Promise<Empty> {\n console.log('Server Shutting down in 5 seconds')\n if (this.shutdownHandler) {\n setTimeout(this.shutdownHandler, 5000)\n }\n return {}\n }\n\n async processLogs(request: ProcessLogsRequest, context: CallContext): Promise<ProcessLogsResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n\n const resp: ProcessResult = {\n gauges: [],\n counters: [],\n logs: [],\n }\n\n const promises: Promise<ProcessResult>[] = []\n for (const l of request.logBindings) {\n if (!l.log) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Log can't be null\")\n }\n // const jsonString = Buffer.from(l.log.raw.buffer).toString(\"utf-8\")\n // const jsonString = String.fromCharCode.apply(null, l.log.raw)\n\n try {\n const jsonString = Utf8ArrayToStr(l.log.raw)\n const log: Log = JSON.parse(jsonString)\n const handler = this.eventHandlers[l.handlerId]\n const promise = handler(log).catch((e) => {\n throw new ServerError(Status.INTERNAL, 'error processing log: ' + jsonString + '\\n' + e.toString())\n })\n\n promises.push(promise)\n } catch (e) {\n throw new ServerError(Status.INTERNAL, 'error parse log: ' + l)\n }\n }\n\n const results = await Promise.all(promises)\n for (const res of results) {\n resp.counters = resp.counters.concat(res.counters)\n resp.gauges = resp.gauges.concat(res.gauges)\n }\n\n let updated = false\n if (\n global.PROCESSOR_STATE.templatesInstances &&\n this.templateInstances.length != global.PROCESSOR_STATE.templatesInstances.length\n ) {\n await this.configure()\n updated = true\n }\n\n recordRuntimeInfo(resp, HandlerType.LOG)\n return {\n result: resp,\n configUpdated: updated,\n }\n }\n\n async processTransactions(\n request: ProcessTransactionsRequest,\n context: CallContext\n ): Promise<ProcessTransactionsResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service not started.')\n }\n\n throw new ServerError(Status.UNIMPLEMENTED, 'Processing transaction is not suppored.')\n }\n\n async processInstructions(\n request: ProcessInstructionsRequest,\n context: CallContext\n ): Promise<ProcessInstructionsResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service not started.')\n }\n\n const result: ProcessResult = {\n gauges: [],\n counters: [],\n logs: [],\n }\n\n // Only have instruction handlers for solana processors\n if (global.PROCESSOR_STATE.solanaProcessors) {\n const processorPromises: Promise<void>[] = []\n for (const instruction of request.instructions) {\n if (!instruction) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'instruction cannot be null')\n }\n\n processorPromises.push(\n new Promise((resolve, _) => {\n for (const processor of global.PROCESSOR_STATE.solanaProcessors) {\n if (processor.address === instruction.programAccountId) {\n let res: ProcessResult | null\n if (instruction.parsed) {\n res = processor.handleInstruction(JSON.parse(new TextDecoder().decode(instruction.parsed)))\n } else if (instruction.instructionData) {\n res = processor.handleInstruction(instruction.instructionData)\n } else {\n continue\n }\n if (res) {\n try {\n res.gauges.forEach((g) => {\n if (g.metadata) {\n g.metadata.blockNumber = instruction.slot\n }\n result.gauges.push(g)\n })\n res.counters.forEach((c) => {\n if (c.metadata) {\n c.metadata.blockNumber = instruction.slot\n }\n result.counters.push(c)\n })\n } catch (e) {\n console.error('error processing instruction ' + e.toString())\n }\n } else {\n console.warn(\n `Failed to decode the instruction: ${instruction.instructionData} with slot: ${instruction.slot}`\n )\n }\n }\n }\n resolve()\n })\n )\n }\n\n await Promise.all(processorPromises)\n }\n\n recordRuntimeInfo(result, HandlerType.INSTRUCTION)\n return {\n result,\n }\n }\n\n async processBlocks(request: ProcessBlocksRequest, context: CallContext): Promise<ProcessBlocksResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n\n const promises = request.blockBindings.map((binding) => this.processBlock(binding))\n const results = await Promise.all(promises)\n\n const res = ProcessResult.fromPartial({})\n\n for (const r of results) {\n res.counters = res.counters.concat(r.counters)\n res.gauges = res.gauges.concat(r.gauges)\n }\n\n recordRuntimeInfo(res, HandlerType.BLOCK)\n return {\n result: res,\n }\n }\n\n async processBlock(binding: BlockBinding): Promise<ProcessResult> {\n if (!binding.block) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Block can't be empty\")\n }\n const jsonString = Utf8ArrayToStr(binding.block.raw)\n\n const block: Block = JSON.parse(jsonString)\n\n const resp: ProcessResult = {\n gauges: [],\n counters: [],\n logs: [],\n }\n\n const promises: Promise<ProcessResult>[] = []\n for (const handlerId of binding.handlerIds) {\n const promise = this.blockHandlers[handlerId](block).catch((e) => {\n throw new ServerError(Status.INTERNAL, 'error processing block: ' + block.number + '\\n' + e.toString())\n })\n promises.push(promise)\n }\n const allRes = await Promise.all(promises)\n for (const res of allRes) {\n resp.counters = resp.counters.concat(res.counters)\n resp.gauges = resp.gauges.concat(res.gauges)\n }\n return resp\n }\n\n async processTraces(request: ProcessTracesRequest, context: CallContext): Promise<ProcessTracesResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n\n const promises = request.traceBindings.map((binding) => this.processTrace(binding))\n const results = await Promise.all(promises)\n\n const res = ProcessResult.fromPartial({})\n\n for (const r of results) {\n res.counters = res.counters.concat(r.counters)\n res.gauges = res.gauges.concat(r.gauges)\n }\n\n recordRuntimeInfo(res, HandlerType.TRACE)\n return {\n result: res,\n }\n }\n\n async processTrace(binding: TraceBinding): Promise<ProcessResult> {\n if (!binding.trace) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Trace can't be empty\")\n }\n const jsonString = Utf8ArrayToStr(binding.trace.raw)\n const trace: Trace = JSON.parse(jsonString)\n\n return this.traceHandlers[binding.handlerId](trace).catch((e) => {\n throw new ServerError(Status.INTERNAL, 'error processing trace: ' + jsonString + '\\n' + e.toString())\n })\n }\n}\n\n// https://ourcodeworld.com/articles/read/164/how-to-convert-an-uint8array-to-string-in-javascript\n/* eslint-disable */\nfunction Utf8ArrayToStr(array: Uint8Array) {\n let out, i, len, c\n let char2, char3\n\n out = ''\n len = array.length\n i = 0\n while (i < len) {\n c = array[i++]\n switch (c >> 4) {\n case 0:\n case 1:\n case 2:\n case 3:\n case 4:\n case 5:\n case 6:\n case 7:\n // 0xxxxxxx\n out += String.fromCharCode(c)\n break\n case 12:\n case 13:\n // 110x xxxx 10xx xxxx\n char2 = array[i++]\n out += String.fromCharCode(((c & 0x1f) << 6) | (char2 & 0x3f))\n break\n case 14:\n // 1110 xxxx 10xx xxxx 10xx xxxx\n char2 = array[i++]\n char3 = array[i++]\n out += String.fromCharCode(((c & 0x0f) << 12) | ((char2 & 0x3f) << 6) | ((char3 & 0x3f) << 0))\n break\n }\n }\n\n return out\n}\n\nfunction recordRuntimeInfo(results: ProcessResult, handlerType: HandlerType) {\n results.gauges.forEach((e) => {\n e.runtimeInfo = {\n from: handlerType,\n }\n })\n\n results.counters.forEach((e) => {\n e.runtimeInfo = {\n from: handlerType,\n }\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":";;;;;;AACA,yCAA4D;AAE5D,gEAuByC;AAGzC,gDAAuB;AACvB,+BAAkC;AAGlC,MAAM,iB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AC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;gBAC9F,MAAK;SACR;KACF;IAED,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,SAAS,iBAAiB,CAAC,OAAsB,EAAE,WAAwB;IACzE,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QAC3B,CAAC,CAAC,WAAW,GAAG;YACd,IAAI,EAAE,WAAW;SAClB,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QAC7B,CAAC,CAAC,WAAW,GAAG;YACd,IAAI,EAAE,WAAW;SAClB,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { Block, Log } from '@ethersproject/abstract-provider'\nimport { CallContext, ServerError, Status } from 'nice-grpc'\n\nimport {\n BlockBinding,\n ContractConfig,\n HandlerType,\n LogFilter,\n LogHandlerConfig,\n ProcessResult,\n ProcessBlocksRequest,\n ProcessBlocksResponse,\n ProcessConfigRequest,\n ProcessConfigResponse,\n ProcessInstructionsRequest,\n ProcessInstructionsResponse,\n ProcessLogsRequest,\n ProcessLogsResponse,\n ProcessorServiceImplementation,\n ProcessTracesRequest,\n ProcessTracesResponse,\n ProcessTransactionsRequest,\n ProcessTransactionsResponse,\n StartRequest,\n TemplateInstance,\n TraceBinding,\n} from './gen/processor/protos/processor'\n\nimport { Empty } from './gen/google/protobuf/empty'\nimport Long from 'long'\nimport { TextDecoder } from 'util'\nimport { Trace } from './trace'\n\nconst DEFAULT_MAX_BLOCK = Long.ZERO\n\nexport class ProcessorServiceImpl implements ProcessorServiceImplementation {\n private eventHandlers: ((event: Log) => Promise<ProcessResult>)[] = []\n private traceHandlers: ((trace: Trace) => Promise<ProcessResult>)[] = []\n private blockHandlers: ((block: Block) => Promise<ProcessResult>)[] = []\n\n // map from chain id to list of processors\n // private blockHandlers = new Map<string, ((block: Block) => Promise<ProcessResult>)[]>()\n // private processorsByChainId = new Map<string, BaseProcessor<BaseContract, BoundContractView<BaseContract, any>>>()\n\n private started = false\n private contractConfigs: ContractConfig[]\n private templateInstances: TemplateInstance[]\n private readonly loader: () => void\n\n private readonly shutdownHandler?: () => void\n\n constructor(loader: () => void, shutdownHandler?: () => void) {\n this.loader = loader\n this.shutdownHandler = shutdownHandler\n }\n\n async getConfig(request: ProcessConfigRequest, context: CallContext): Promise<ProcessConfigResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n return {\n // TODO project setting\n config: undefined,\n contractConfigs: this.contractConfigs,\n templateInstances: this.templateInstances,\n }\n }\n\n async configure() {\n this.eventHandlers = []\n this.templateInstances = []\n // this.processorsByChainId.clear()\n this.contractConfigs = []\n\n this.templateInstances = [...global.PROCESSOR_STATE.templatesInstances]\n\n // Part 1, prepare EVM processors\n for (const processor of global.PROCESSOR_STATE.processors) {\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 blockConfigs: [],\n logConfigs: [],\n traceConfigs: [],\n startBlock: processor.config.startBlock,\n endBlock: DEFAULT_MAX_BLOCK,\n instructionConfig: undefined,\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) - 1\n contractConfig.blockConfigs.push({\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 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 this.contractConfigs.push(contractConfig)\n }\n\n // Part 2, prepare solana constractors\n for (const solanaProcessor of global.PROCESSOR_STATE.solanaProcessors) {\n const contractConfig: ContractConfig = {\n processorType: 'user_processor',\n contract: {\n name: solanaProcessor.contractName,\n chainId: 'SOL_mainnet', // TODO set in processor\n address: solanaProcessor.address,\n abi: '',\n },\n blockConfigs: [],\n logConfigs: [],\n traceConfigs: [],\n startBlock: solanaProcessor.config.startSlot,\n endBlock: DEFAULT_MAX_BLOCK,\n instructionConfig: {\n innerInstruction: solanaProcessor.processInnerInstruction,\n parsedInstruction: solanaProcessor.fromParsedInstruction !== null,\n rawDataInstruction: solanaProcessor.decodeInstruction !== null,\n },\n }\n this.contractConfigs.push(contractConfig)\n }\n\n // Part 3, prepare sui constractors\n for (const suiProcessor of global.PROCESSOR_STATE.suiProcessors) {\n const contractConfig: ContractConfig = {\n processorType: 'user_processor',\n contract: {\n name: 'sui processor',\n chainId: 'SUI_devnet',\n address: suiProcessor.address,\n abi: '',\n },\n blockConfigs: [],\n logConfigs: [],\n traceConfigs: [],\n startBlock: suiProcessor.config.startSeqNumber,\n endBlock: DEFAULT_MAX_BLOCK,\n instructionConfig: undefined,\n }\n this.contractConfigs.push(contractConfig)\n }\n }\n\n async start(request: StartRequest, context: CallContext): Promise<Empty> {\n if (this.started) {\n return {}\n }\n\n this.loader()\n\n for (const instance of request.templateInstances) {\n const template = global.PROCESSOR_STATE.templates[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 await this.configure()\n this.started = true\n return {}\n }\n\n async stop(request: Empty, context: CallContext): Promise<Empty> {\n console.log('Server Shutting down in 5 seconds')\n if (this.shutdownHandler) {\n setTimeout(this.shutdownHandler, 5000)\n }\n return {}\n }\n\n async processLogs(request: ProcessLogsRequest, context: CallContext): Promise<ProcessLogsResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n\n const resp: ProcessResult = {\n gauges: [],\n counters: [],\n logs: [],\n }\n\n const promises: Promise<ProcessResult>[] = []\n for (const l of request.logBindings) {\n if (!l.log) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Log can't be null\")\n }\n // const jsonString = Buffer.from(l.log.raw.buffer).toString(\"utf-8\")\n // const jsonString = String.fromCharCode.apply(null, l.log.raw)\n\n try {\n const jsonString = Utf8ArrayToStr(l.log.raw)\n const log: Log = JSON.parse(jsonString)\n const handler = this.eventHandlers[l.handlerId]\n const promise = handler(log).catch((e) => {\n throw new ServerError(Status.INTERNAL, 'error processing log: ' + jsonString + '\\n' + e.toString())\n })\n\n promises.push(promise)\n } catch (e) {\n throw new ServerError(Status.INTERNAL, 'error parse log: ' + l)\n }\n }\n\n const results = await Promise.all(promises)\n for (const res of results) {\n resp.counters = resp.counters.concat(res.counters)\n resp.gauges = resp.gauges.concat(res.gauges)\n }\n\n let updated = false\n if (\n global.PROCESSOR_STATE.templatesInstances &&\n this.templateInstances.length != global.PROCESSOR_STATE.templatesInstances.length\n ) {\n await this.configure()\n updated = true\n }\n\n recordRuntimeInfo(resp, HandlerType.LOG)\n return {\n result: resp,\n configUpdated: updated,\n }\n }\n\n async processTransactions(\n request: ProcessTransactionsRequest,\n context: CallContext\n ): Promise<ProcessTransactionsResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service not started.')\n }\n\n const result: ProcessResult = {\n gauges: [],\n counters: [],\n logs: [],\n }\n\n if (global.PROCESSOR_STATE.suiProcessors) {\n const processorPromises: Promise<void>[] = []\n for (const txn of request.transactions) {\n processorPromises.push(\n new Promise((resolve, _) => {\n for (const processor of global.PROCESSOR_STATE.suiProcessors) {\n const res = processor.handleTransaction(JSON.parse(new TextDecoder().decode(txn.raw)))\n if (res) {\n res.gauges.forEach((g) => {\n result.gauges.push(g)\n })\n res.counters.forEach((c) => {\n result.counters.push(c)\n })\n }\n }\n resolve()\n })\n )\n }\n await Promise.all(processorPromises)\n }\n\n recordRuntimeInfo(result, HandlerType.TRANSACTION)\n return {\n result,\n }\n }\n\n async processInstructions(\n request: ProcessInstructionsRequest,\n context: CallContext\n ): Promise<ProcessInstructionsResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service not started.')\n }\n\n const result: ProcessResult = {\n gauges: [],\n counters: [],\n logs: [],\n }\n\n // Only have instruction handlers for solana processors\n if (global.PROCESSOR_STATE.solanaProcessors) {\n const processorPromises: Promise<void>[] = []\n for (const instruction of request.instructions) {\n if (!instruction) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'instruction cannot be null')\n }\n\n processorPromises.push(\n new Promise((resolve, _) => {\n for (const processor of global.PROCESSOR_STATE.solanaProcessors) {\n if (processor.address === instruction.programAccountId) {\n let res: ProcessResult | null\n if (instruction.parsed) {\n res = processor.handleInstruction(JSON.parse(new TextDecoder().decode(instruction.parsed)))\n } else if (instruction.instructionData) {\n res = processor.handleInstruction(instruction.instructionData)\n } else {\n continue\n }\n if (res) {\n try {\n res.gauges.forEach((g) => {\n if (g.metadata) {\n g.metadata.blockNumber = instruction.slot\n }\n result.gauges.push(g)\n })\n res.counters.forEach((c) => {\n if (c.metadata) {\n c.metadata.blockNumber = instruction.slot\n }\n result.counters.push(c)\n })\n } catch (e) {\n console.error('error processing instruction ' + e.toString())\n }\n } else {\n console.warn(\n `Failed to decode the instruction: ${instruction.instructionData} with slot: ${instruction.slot}`\n )\n }\n }\n }\n resolve()\n })\n )\n }\n\n await Promise.all(processorPromises)\n }\n\n recordRuntimeInfo(result, HandlerType.INSTRUCTION)\n return {\n result,\n }\n }\n\n async processBlocks(request: ProcessBlocksRequest, context: CallContext): Promise<ProcessBlocksResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n\n const promises = request.blockBindings.map((binding) => this.processBlock(binding))\n const results = await Promise.all(promises)\n\n const res = ProcessResult.fromPartial({})\n\n for (const r of results) {\n res.counters = res.counters.concat(r.counters)\n res.gauges = res.gauges.concat(r.gauges)\n }\n\n recordRuntimeInfo(res, HandlerType.BLOCK)\n return {\n result: res,\n }\n }\n\n async processBlock(binding: BlockBinding): Promise<ProcessResult> {\n if (!binding.block) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Block can't be empty\")\n }\n const jsonString = Utf8ArrayToStr(binding.block.raw)\n\n const block: Block = JSON.parse(jsonString)\n\n const resp: ProcessResult = {\n gauges: [],\n counters: [],\n logs: [],\n }\n\n const promises: Promise<ProcessResult>[] = []\n for (const handlerId of binding.handlerIds) {\n const promise = this.blockHandlers[handlerId](block).catch((e) => {\n throw new ServerError(Status.INTERNAL, 'error processing block: ' + block.number + '\\n' + e.toString())\n })\n promises.push(promise)\n }\n const allRes = await Promise.all(promises)\n for (const res of allRes) {\n resp.counters = resp.counters.concat(res.counters)\n resp.gauges = resp.gauges.concat(res.gauges)\n }\n return resp\n }\n\n async processTraces(request: ProcessTracesRequest, context: CallContext): Promise<ProcessTracesResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n\n const promises = request.traceBindings.map((binding) => this.processTrace(binding))\n const results = await Promise.all(promises)\n\n const res = ProcessResult.fromPartial({})\n\n for (const r of results) {\n res.counters = res.counters.concat(r.counters)\n res.gauges = res.gauges.concat(r.gauges)\n }\n\n recordRuntimeInfo(res, HandlerType.TRACE)\n return {\n result: res,\n }\n }\n\n async processTrace(binding: TraceBinding): Promise<ProcessResult> {\n if (!binding.trace) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Trace can't be empty\")\n }\n const jsonString = Utf8ArrayToStr(binding.trace.raw)\n const trace: Trace = JSON.parse(jsonString)\n\n return this.traceHandlers[binding.handlerId](trace).catch((e) => {\n throw new ServerError(Status.INTERNAL, 'error processing trace: ' + jsonString + '\\n' + e.toString())\n })\n }\n}\n\n// https://ourcodeworld.com/articles/read/164/how-to-convert-an-uint8array-to-string-in-javascript\n/* eslint-disable */\nfunction Utf8ArrayToStr(array: Uint8Array) {\n let out, i, len, c\n let char2, char3\n\n out = ''\n len = array.length\n i = 0\n while (i < len) {\n c = array[i++]\n switch (c >> 4) {\n case 0:\n case 1:\n case 2:\n case 3:\n case 4:\n case 5:\n case 6:\n case 7:\n // 0xxxxxxx\n out += String.fromCharCode(c)\n break\n case 12:\n case 13:\n // 110x xxxx 10xx xxxx\n char2 = array[i++]\n out += String.fromCharCode(((c & 0x1f) << 6) | (char2 & 0x3f))\n break\n case 14:\n // 1110 xxxx 10xx xxxx 10xx xxxx\n char2 = array[i++]\n char3 = array[i++]\n out += String.fromCharCode(((c & 0x0f) << 12) | ((char2 & 0x3f) << 6) | ((char3 & 0x3f) << 0))\n break\n }\n }\n\n return out\n}\n\nfunction recordRuntimeInfo(results: ProcessResult, handlerType: HandlerType) {\n results.gauges.forEach((e) => {\n e.runtimeInfo = {\n from: handlerType,\n }\n })\n\n results.counters.forEach((e) => {\n e.runtimeInfo = {\n from: handlerType,\n }\n })\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SuiBindOptions } from './bind-options';
|
|
2
|
+
import { SuiContext } from './context';
|
|
3
|
+
import { ProcessResult } from './index';
|
|
4
|
+
import Long from 'long';
|
|
5
|
+
declare type IndexConfigure = {
|
|
6
|
+
startSeqNumber: Long;
|
|
7
|
+
endSeqNumber?: Long;
|
|
8
|
+
};
|
|
9
|
+
export declare class SuiBaseProcessor {
|
|
10
|
+
transactionHanlder: (transaction: any, ctx: SuiContext) => void;
|
|
11
|
+
address: string;
|
|
12
|
+
config: IndexConfigure;
|
|
13
|
+
constructor(options: SuiBindOptions);
|
|
14
|
+
bind(options: SuiBindOptions): void;
|
|
15
|
+
onTransaction(handler: (transaction: any, ctx: SuiContext) => void): this;
|
|
16
|
+
handleTransaction(txn: any): ProcessResult | null;
|
|
17
|
+
isBind(): boolean;
|
|
18
|
+
startSlot(startSlot: Long | number): this;
|
|
19
|
+
endBlock(endBlock: Long | number): this;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SuiBaseProcessor = void 0;
|
|
7
|
+
const context_1 = require("./context");
|
|
8
|
+
const long_1 = __importDefault(require("long"));
|
|
9
|
+
class SuiBaseProcessor {
|
|
10
|
+
transactionHanlder;
|
|
11
|
+
address;
|
|
12
|
+
config = { startSeqNumber: new long_1.default(0) };
|
|
13
|
+
constructor(options) {
|
|
14
|
+
if (options) {
|
|
15
|
+
this.bind(options);
|
|
16
|
+
}
|
|
17
|
+
global.PROCESSOR_STATE.suiProcessors.push(this);
|
|
18
|
+
}
|
|
19
|
+
bind(options) {
|
|
20
|
+
this.address = options.address;
|
|
21
|
+
if (options.startBlock) {
|
|
22
|
+
this.startSlot(options.startBlock);
|
|
23
|
+
}
|
|
24
|
+
if (options.endBlock) {
|
|
25
|
+
this.endBlock(options.endBlock);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
onTransaction(handler) {
|
|
29
|
+
if (!this.isBind()) {
|
|
30
|
+
throw new Error("Processor doesn't bind to an address");
|
|
31
|
+
}
|
|
32
|
+
this.transactionHanlder = handler;
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
handleTransaction(txn) {
|
|
36
|
+
const ctx = new context_1.SuiContext(this.address);
|
|
37
|
+
if (txn) {
|
|
38
|
+
this.transactionHanlder(txn, ctx);
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
gauges: ctx.gauges,
|
|
42
|
+
counters: ctx.counters,
|
|
43
|
+
logs: [],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
isBind() {
|
|
47
|
+
return this.address !== null;
|
|
48
|
+
}
|
|
49
|
+
startSlot(startSlot) {
|
|
50
|
+
if (typeof startSlot === 'number') {
|
|
51
|
+
startSlot = long_1.default.fromNumber(startSlot);
|
|
52
|
+
}
|
|
53
|
+
this.config.startSeqNumber = startSlot;
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
endBlock(endBlock) {
|
|
57
|
+
if (typeof endBlock === 'number') {
|
|
58
|
+
endBlock = long_1.default.fromNumber(endBlock);
|
|
59
|
+
}
|
|
60
|
+
this.config.endSeqNumber = endBlock;
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.SuiBaseProcessor = SuiBaseProcessor;
|
|
65
|
+
//# sourceMappingURL=sui-processor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sui-processor.js","sourceRoot":"","sources":["../src/sui-processor.ts"],"names":[],"mappings":";;;;;;AACA,uCAAsC;AAEtC,gDAAuB;AAOvB,MAAa,gBAAgB;IACpB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I,OAAO,SAAS,KAAK,QAAQ,EAAE;YACjC,SAAS,GAAG,cAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;SACvC;QACD,IAAI,CAAC,MAAM,CAAC,cAAc,GAAG,SAAS,CAAA;QACtC,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,QAAQ,CAAC,QAAuB;QACrC,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;YAChC,QAAQ,GAAG,cAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;SACrC;QACD,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,QAAQ,CAAA;QACnC,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAhED,4CAgEC","sourcesContent":["import { SuiBindOptions } from './bind-options'\nimport { SuiContext } from './context'\nimport { ProcessResult } from './index'\nimport Long from 'long'\n\ntype IndexConfigure = {\n startSeqNumber: Long\n endSeqNumber?: Long\n}\n\nexport class SuiBaseProcessor {\n public transactionHanlder: (transaction: any, ctx: SuiContext) => void\n address: string\n config: IndexConfigure = { startSeqNumber: new Long(0) }\n\n constructor(options: SuiBindOptions) {\n if (options) {\n this.bind(options)\n }\n global.PROCESSOR_STATE.suiProcessors.push(this)\n }\n\n bind(options: SuiBindOptions) {\n this.address = options.address\n if (options.startBlock) {\n this.startSlot(options.startBlock)\n }\n if (options.endBlock) {\n this.endBlock(options.endBlock)\n }\n }\n\n public onTransaction(handler: (transaction: any, ctx: SuiContext) => void) {\n if (!this.isBind()) {\n throw new Error(\"Processor doesn't bind to an address\")\n }\n\n this.transactionHanlder = handler\n\n return this\n }\n\n public handleTransaction(txn: any): ProcessResult | null {\n const ctx = new SuiContext(this.address)\n\n if (txn) {\n this.transactionHanlder(txn, ctx)\n }\n return {\n gauges: ctx.gauges,\n counters: ctx.counters,\n logs: [],\n }\n }\n\n public isBind() {\n return this.address !== null\n }\n\n public startSlot(startSlot: Long | number) {\n if (typeof startSlot === 'number') {\n startSlot = Long.fromNumber(startSlot)\n }\n this.config.startSeqNumber = startSlot\n return this\n }\n\n public endBlock(endBlock: Long | number) {\n if (typeof endBlock === 'number') {\n endBlock = Long.fromNumber(endBlock)\n }\n this.config.endSeqNumber = endBlock\n return this\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chai_1 = require("chai");
|
|
4
|
+
const util_1 = require("util");
|
|
5
|
+
const test_processor_server_1 = require("./test-processor-server");
|
|
6
|
+
describe('Test Sui Example', () => {
|
|
7
|
+
const service = new test_processor_server_1.TestProcessorServer(() => {
|
|
8
|
+
require('./tic-tac-toe');
|
|
9
|
+
});
|
|
10
|
+
beforeAll(async () => {
|
|
11
|
+
await service.start({ templateInstances: [] });
|
|
12
|
+
});
|
|
13
|
+
test('check configuration ', async () => {
|
|
14
|
+
const config = await service.getConfig({});
|
|
15
|
+
(0, chai_1.expect)(config.contractConfigs).length(1);
|
|
16
|
+
});
|
|
17
|
+
test('Check tictactoe transaction dispatch', async () => {
|
|
18
|
+
const request = {
|
|
19
|
+
transactions: [
|
|
20
|
+
{
|
|
21
|
+
txHash: 'z3HjnnFFKAaszOi0pMSImtGMpRd2r7ljLjAjUoqs3Kw=',
|
|
22
|
+
raw: new util_1.TextEncoder().encode(JSON.stringify(testData)),
|
|
23
|
+
programAccountId: '0xb8252513f0b9efaa3e260842c4b84d8ff933522d',
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
const res = await service.processTransactions(request);
|
|
28
|
+
(0, chai_1.expect)(res.result?.counters).length(1);
|
|
29
|
+
(0, chai_1.expect)(res.result?.gauges).length(0);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
const testData = {
|
|
33
|
+
certificate: {
|
|
34
|
+
transactionDigest: 'z3HjnnFFKAaszOi0pMSImtGMpRd2r7ljLjAjUoqs3Kw=',
|
|
35
|
+
data: {
|
|
36
|
+
transactions: [
|
|
37
|
+
{
|
|
38
|
+
Call: {
|
|
39
|
+
package: {
|
|
40
|
+
objectId: '0xb8252513f0b9efaa3e260842c4b84d8ff933522d',
|
|
41
|
+
version: 1,
|
|
42
|
+
digest: 'UyeEXDb5jCLGuk/PVcqdLtbKSI3mSANB2/DxiyzXRC8=',
|
|
43
|
+
},
|
|
44
|
+
module: 'shared_tic_tac_toe',
|
|
45
|
+
function: 'place_mark',
|
|
46
|
+
arguments: ['0x8ed24078d64aa1a2a7593cba7ab64eb2016fa3d4', 2, ''],
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
sender: '0x1c270459011d19dc342751aff75b4188334438fa',
|
|
51
|
+
gasPayment: {
|
|
52
|
+
objectId: '0x018b73e6652bab0f6419fa998263b568fa0688bb',
|
|
53
|
+
version: 8,
|
|
54
|
+
digest: 'suj5fniFCh3oqu+3BQWASz5zyUl4jUWVmJFf76AwVoE=',
|
|
55
|
+
},
|
|
56
|
+
gasBudget: 1000,
|
|
57
|
+
},
|
|
58
|
+
txSignature: 'ACIBv8kDff83DOjZsrUe4RqC1BLBGZtLAwFf/3tHUWJe1F+fxtg16Kqdm85TY9IWeYhVTtQkmchROxX8g0pi/Ak48WB/fgCTwX6K9CIMWgmr+j4k7x4dPYBNizpjHvBgCQ==',
|
|
59
|
+
authSignInfo: {
|
|
60
|
+
epoch: 0,
|
|
61
|
+
signature: [
|
|
62
|
+
'o4tOmjc4jJ27NoKGEHlNDZav0rBJLDqzzsL1kGJOviPKgpLlxyFCeBHrgjAwoc4Y5M75wYgccCuiv67l1w05DQ==',
|
|
63
|
+
'B2tClnK9GYCDFg6HbO/IW7hlJkhfIXi6NoDn7s4Pyw94BjMB/v0S0ZufbLwDO/WhBwU83q+wRTanG4HRhvUuBw==',
|
|
64
|
+
'5s49bESgHvDH7/oqjuxjy9YW4xWCG4e8g6hGlZC0bTXskPdf+q6bSGglkkMpOr1B3uIlMeif1NAlRQCKsfNcCg==',
|
|
65
|
+
],
|
|
66
|
+
signers_map: [58, 48, 0, 0, 1, 0, 0, 0, 0, 0, 2, 0, 16, 0, 0, 0, 1, 0, 2, 0, 3, 0],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
effects: {
|
|
70
|
+
status: {
|
|
71
|
+
status: 'success',
|
|
72
|
+
},
|
|
73
|
+
gasUsed: {
|
|
74
|
+
computationCost: 716,
|
|
75
|
+
storageCost: 48,
|
|
76
|
+
storageRebate: 35,
|
|
77
|
+
},
|
|
78
|
+
sharedObjects: [
|
|
79
|
+
{
|
|
80
|
+
objectId: '0x8ed24078d64aa1a2a7593cba7ab64eb2016fa3d4',
|
|
81
|
+
version: 6,
|
|
82
|
+
digest: 'kY/I9fcr6rL2EbDO88MxrEmEaxAEtRxgd+lcfQnE4ww=',
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
transactionDigest: 'z3HjnnFFKAaszOi0pMSImtGMpRd2r7ljLjAjUoqs3Kw=',
|
|
86
|
+
created: [
|
|
87
|
+
{
|
|
88
|
+
owner: {
|
|
89
|
+
AddressOwner: '0x1c270459011d19dc342751aff75b4188334438fa',
|
|
90
|
+
},
|
|
91
|
+
reference: {
|
|
92
|
+
objectId: '0x2e37e03297a9d138687ffd921f8a830a6f498ec6',
|
|
93
|
+
version: 1,
|
|
94
|
+
digest: '1zZhoVoTLPRM1YpGX9EcrwPJulKcXyLrF+40rTIQ06g=',
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
mutated: [
|
|
99
|
+
{
|
|
100
|
+
owner: {
|
|
101
|
+
AddressOwner: '0x1c270459011d19dc342751aff75b4188334438fa',
|
|
102
|
+
},
|
|
103
|
+
reference: {
|
|
104
|
+
objectId: '0x018b73e6652bab0f6419fa998263b568fa0688bb',
|
|
105
|
+
version: 9,
|
|
106
|
+
digest: 'naHwWYK8vl7UBnhp40o7h7JI+cxvFF8rTIOQ4RJ4vus=',
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
owner: 'Shared',
|
|
111
|
+
reference: {
|
|
112
|
+
objectId: '0x8ed24078d64aa1a2a7593cba7ab64eb2016fa3d4',
|
|
113
|
+
version: 7,
|
|
114
|
+
digest: 's3R+lWAMGde7eqZzllafAJkoR7Em55An8gHgz7oCImw=',
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
gasObject: {
|
|
119
|
+
owner: {
|
|
120
|
+
AddressOwner: '0x1c270459011d19dc342751aff75b4188334438fa',
|
|
121
|
+
},
|
|
122
|
+
reference: {
|
|
123
|
+
objectId: '0x018b73e6652bab0f6419fa998263b568fa0688bb',
|
|
124
|
+
version: 9,
|
|
125
|
+
digest: 'naHwWYK8vl7UBnhp40o7h7JI+cxvFF8rTIOQ4RJ4vus=',
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
events: [
|
|
129
|
+
{
|
|
130
|
+
moveEvent: {
|
|
131
|
+
packageId: '0xb8252513f0b9efaa3e260842c4b84d8ff933522d',
|
|
132
|
+
transactionModule: 'shared_tic_tac_toe',
|
|
133
|
+
sender: '0x1c270459011d19dc342751aff75b4188334438fa',
|
|
134
|
+
type: '0xb8252513f0b9efaa3e260842c4b84d8ff933522d::shared_tic_tac_toe::GameEndEvent',
|
|
135
|
+
fields: {
|
|
136
|
+
game_id: '0x8ed24078d64aa1a2a7593cba7ab64eb2016fa3d4',
|
|
137
|
+
},
|
|
138
|
+
bcs: 'jtJAeNZKoaKnWTy6erZOsgFvo9Q=',
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
newObject: {
|
|
143
|
+
packageId: '0xb8252513f0b9efaa3e260842c4b84d8ff933522d',
|
|
144
|
+
transactionModule: 'shared_tic_tac_toe',
|
|
145
|
+
sender: '0x1c270459011d19dc342751aff75b4188334438fa',
|
|
146
|
+
recipient: {
|
|
147
|
+
AddressOwner: '0x1c270459011d19dc342751aff75b4188334438fa',
|
|
148
|
+
},
|
|
149
|
+
objectId: '0x2e37e03297a9d138687ffd921f8a830a6f498ec6',
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
dependencies: [
|
|
154
|
+
'UgLnWz4u9GTgAJYwR+rz+YO5TDJiZHuFjzyh9blJO2o=',
|
|
155
|
+
'lw2dyQ9J3fPeH5Lx5aiHfjxDHJENTH4910r2/Y/PQX4=',
|
|
156
|
+
'phojYeMd7C6mRxGXQFDPF10NFYMEUfBND+f8wJGKkbg=',
|
|
157
|
+
],
|
|
158
|
+
},
|
|
159
|
+
timestamp_ms: 1662996912461,
|
|
160
|
+
parsed_data: null,
|
|
161
|
+
};
|
|
162
|
+
//# sourceMappingURL=sui.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sui.test.js","sourceRoot":"","sources":["../../src/test/sui.test.ts"],"names":[],"mappings":";;AAAA,+BAA6B;AAC7B,+BAAkC;AAGlC,mEAA6D;AAE7D,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,MAAM,OAAO,GAAG,IAAI,2CAAmB,CAAC,GAAG,EAAE;QAC3C,OAAO,CAAC,eAAe,CAAC,CAAA;IAC1B,CAAC,CAAC,CAAA;IAEF,SAAS,CAAC,KAAK,IAAI,EAAE;QACnB,MAAM,OAAO,CAAC,KAAK,CAAC,EAAE,iBAAiB,EAAE,EAAE,EAAE,CAAC,CAAA;IAChD,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE;QACtC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QAC1C,IAAA,aAAM,EAAC,MAAM,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IAC1C,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,sCAAsC,EAAE,KAAK,IAAI,EAAE;Q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gBACV,MAAM,EAAE,8CAA8C;aACvD;SACF;QACD,MAAM,EAAE;YACN;gBACE,SAAS,EAAE;oBACT,SAAS,EAAE,4CAA4C;oBACvD,iBAAiB,EAAE,oBAAoB;oBACvC,MAAM,EAAE,4CAA4C;oBACpD,IAAI,EAAE,8EAA8E;oBACpF,MAAM,EAAE;wBACN,OAAO,EAAE,4CAA4C;qBACtD;oBACD,GAAG,EAAE,8BAA8B;iBACpC;aACF;YACD;gBACE,SAAS,EAAE;oBACT,SAAS,EAAE,4CAA4C;oBACvD,iBAAiB,EAAE,oBAAoB;oBACvC,MAAM,EAAE,4CAA4C;oBACpD,SAAS,EAAE;wBACT,YAAY,EAAE,4CAA4C;qBAC3D;oBACD,QAAQ,EAAE,4CAA4C;iBACvD;aACF;SACF;QACD,YAAY,EAAE;YACZ,8CAA8C;YAC9C,8CAA8C;YAC9C,8CAA8C;SAC/C;KACF;IACD,YAAY,EAAE,aAAa;IAC3B,WAAW,EAAE,IAAI;CAClB,CAAA","sourcesContent":["import { expect } from 'chai'\nimport { TextEncoder } from 'util'\nimport { ProcessTransactionsRequest } from '..'\n\nimport { TestProcessorServer } from './test-processor-server'\n\ndescribe('Test Sui Example', () => {\n const service = new TestProcessorServer(() => {\n require('./tic-tac-toe')\n })\n\n beforeAll(async () => {\n await service.start({ templateInstances: [] })\n })\n\n test('check configuration ', async () => {\n const config = await service.getConfig({})\n expect(config.contractConfigs).length(1)\n })\n\n test('Check tictactoe transaction dispatch', async () => {\n const request: ProcessTransactionsRequest = {\n transactions: [\n {\n txHash: 'z3HjnnFFKAaszOi0pMSImtGMpRd2r7ljLjAjUoqs3Kw=',\n raw: new TextEncoder().encode(JSON.stringify(testData)),\n programAccountId: '0xb8252513f0b9efaa3e260842c4b84d8ff933522d',\n },\n ],\n }\n const res = await service.processTransactions(request)\n expect(res.result?.counters).length(1)\n expect(res.result?.gauges).length(0)\n })\n})\n\nconst testData = {\n certificate: {\n transactionDigest: 'z3HjnnFFKAaszOi0pMSImtGMpRd2r7ljLjAjUoqs3Kw=',\n data: {\n transactions: [\n {\n Call: {\n package: {\n objectId: '0xb8252513f0b9efaa3e260842c4b84d8ff933522d',\n version: 1,\n digest: 'UyeEXDb5jCLGuk/PVcqdLtbKSI3mSANB2/DxiyzXRC8=',\n },\n module: 'shared_tic_tac_toe',\n function: 'place_mark',\n arguments: ['0x8ed24078d64aa1a2a7593cba7ab64eb2016fa3d4', 2, ''],\n },\n },\n ],\n sender: '0x1c270459011d19dc342751aff75b4188334438fa',\n gasPayment: {\n objectId: '0x018b73e6652bab0f6419fa998263b568fa0688bb',\n version: 8,\n digest: 'suj5fniFCh3oqu+3BQWASz5zyUl4jUWVmJFf76AwVoE=',\n },\n gasBudget: 1000,\n },\n txSignature:\n 'ACIBv8kDff83DOjZsrUe4RqC1BLBGZtLAwFf/3tHUWJe1F+fxtg16Kqdm85TY9IWeYhVTtQkmchROxX8g0pi/Ak48WB/fgCTwX6K9CIMWgmr+j4k7x4dPYBNizpjHvBgCQ==',\n authSignInfo: {\n epoch: 0,\n signature: [\n 'o4tOmjc4jJ27NoKGEHlNDZav0rBJLDqzzsL1kGJOviPKgpLlxyFCeBHrgjAwoc4Y5M75wYgccCuiv67l1w05DQ==',\n 'B2tClnK9GYCDFg6HbO/IW7hlJkhfIXi6NoDn7s4Pyw94BjMB/v0S0ZufbLwDO/WhBwU83q+wRTanG4HRhvUuBw==',\n '5s49bESgHvDH7/oqjuxjy9YW4xWCG4e8g6hGlZC0bTXskPdf+q6bSGglkkMpOr1B3uIlMeif1NAlRQCKsfNcCg==',\n ],\n signers_map: [58, 48, 0, 0, 1, 0, 0, 0, 0, 0, 2, 0, 16, 0, 0, 0, 1, 0, 2, 0, 3, 0],\n },\n },\n effects: {\n status: {\n status: 'success',\n },\n gasUsed: {\n computationCost: 716,\n storageCost: 48,\n storageRebate: 35,\n },\n sharedObjects: [\n {\n objectId: '0x8ed24078d64aa1a2a7593cba7ab64eb2016fa3d4',\n version: 6,\n digest: 'kY/I9fcr6rL2EbDO88MxrEmEaxAEtRxgd+lcfQnE4ww=',\n },\n ],\n transactionDigest: 'z3HjnnFFKAaszOi0pMSImtGMpRd2r7ljLjAjUoqs3Kw=',\n created: [\n {\n owner: {\n AddressOwner: '0x1c270459011d19dc342751aff75b4188334438fa',\n },\n reference: {\n objectId: '0x2e37e03297a9d138687ffd921f8a830a6f498ec6',\n version: 1,\n digest: '1zZhoVoTLPRM1YpGX9EcrwPJulKcXyLrF+40rTIQ06g=',\n },\n },\n ],\n mutated: [\n {\n owner: {\n AddressOwner: '0x1c270459011d19dc342751aff75b4188334438fa',\n },\n reference: {\n objectId: '0x018b73e6652bab0f6419fa998263b568fa0688bb',\n version: 9,\n digest: 'naHwWYK8vl7UBnhp40o7h7JI+cxvFF8rTIOQ4RJ4vus=',\n },\n },\n {\n owner: 'Shared',\n reference: {\n objectId: '0x8ed24078d64aa1a2a7593cba7ab64eb2016fa3d4',\n version: 7,\n digest: 's3R+lWAMGde7eqZzllafAJkoR7Em55An8gHgz7oCImw=',\n },\n },\n ],\n gasObject: {\n owner: {\n AddressOwner: '0x1c270459011d19dc342751aff75b4188334438fa',\n },\n reference: {\n objectId: '0x018b73e6652bab0f6419fa998263b568fa0688bb',\n version: 9,\n digest: 'naHwWYK8vl7UBnhp40o7h7JI+cxvFF8rTIOQ4RJ4vus=',\n },\n },\n events: [\n {\n moveEvent: {\n packageId: '0xb8252513f0b9efaa3e260842c4b84d8ff933522d',\n transactionModule: 'shared_tic_tac_toe',\n sender: '0x1c270459011d19dc342751aff75b4188334438fa',\n type: '0xb8252513f0b9efaa3e260842c4b84d8ff933522d::shared_tic_tac_toe::GameEndEvent',\n fields: {\n game_id: '0x8ed24078d64aa1a2a7593cba7ab64eb2016fa3d4',\n },\n bcs: 'jtJAeNZKoaKnWTy6erZOsgFvo9Q=',\n },\n },\n {\n newObject: {\n packageId: '0xb8252513f0b9efaa3e260842c4b84d8ff933522d',\n transactionModule: 'shared_tic_tac_toe',\n sender: '0x1c270459011d19dc342751aff75b4188334438fa',\n recipient: {\n AddressOwner: '0x1c270459011d19dc342751aff75b4188334438fa',\n },\n objectId: '0x2e37e03297a9d138687ffd921f8a830a6f498ec6',\n },\n },\n ],\n dependencies: [\n 'UgLnWz4u9GTgAJYwR+rz+YO5TDJiZHuFjzyh9blJO2o=',\n 'lw2dyQ9J3fPeH5Lx5aiHfjxDHJENTH4910r2/Y/PQX4=',\n 'phojYeMd7C6mRxGXQFDPF10NFYMEUfBND+f8wJGKkbg=',\n ],\n },\n timestamp_ms: 1662996912461,\n parsed_data: null,\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const sui_processor_1 = require("../sui-processor");
|
|
4
|
+
class TicTacToeProcessor extends sui_processor_1.SuiBaseProcessor {
|
|
5
|
+
static bind(options) {
|
|
6
|
+
if (options && !options.name) {
|
|
7
|
+
options.name = 'TicTacToe';
|
|
8
|
+
}
|
|
9
|
+
return new TicTacToeProcessor(options);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
TicTacToeProcessor.bind({
|
|
13
|
+
startBlock: 0,
|
|
14
|
+
address: '',
|
|
15
|
+
}).onTransaction((txn, ctx) => {
|
|
16
|
+
if (txn.certificate.data.transactions && txn.certificate.data.transactions.length > 0) {
|
|
17
|
+
if (txn.certificate.data.transactions[0].Call.package.objectId === '0xb8252513f0b9efaa3e260842c4b84d8ff933522d') {
|
|
18
|
+
if (txn.effects.events) {
|
|
19
|
+
txn.effects.events.forEach((event) => {
|
|
20
|
+
if (event.newObject) {
|
|
21
|
+
const owner = event.newObject.recipient.AddressOwner;
|
|
22
|
+
if (owner.toString().includes('0x1c27')) {
|
|
23
|
+
ctx.meter.Counter('win_count').add(1);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
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CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;yBACtC;qBACF;gBACH,CAAC,CAAC,CAAA;aACH;SACF;KACF;AACH,CAAC,CAAC,CAAA","sourcesContent":["import { SuiBindOptions } from '../bind-options'\nimport { SuiBaseProcessor } from '../sui-processor'\n\nclass TicTacToeProcessor extends SuiBaseProcessor {\n static bind(options: SuiBindOptions): TicTacToeProcessor {\n if (options && !options.name) {\n options.name = 'TicTacToe'\n }\n return new TicTacToeProcessor(options)\n }\n}\n\nTicTacToeProcessor.bind({\n startBlock: 0,\n address: '',\n}).onTransaction((txn, ctx) => {\n if (txn.certificate.data.transactions && txn.certificate.data.transactions.length > 0) {\n if (txn.certificate.data.transactions[0].Call.package.objectId === '0xb8252513f0b9efaa3e260842c4b84d8ff933522d') {\n if (txn.effects.events) {\n txn.effects.events.forEach((event: { newObject: { recipient: { AddressOwner: any } } }) => {\n if (event.newObject) {\n const owner = event.newObject.recipient.AddressOwner\n if ((owner.toString() as string).includes('0x1c27')) {\n ctx.meter.Counter('win_count').add(1)\n }\n }\n })\n }\n }\n }\n})\n"]}
|