@sentio/sdk 1.27.3 → 1.27.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/lib/processor-runner.js +2 -2
  2. package/lib/processor-runner.js.map +1 -1
  3. package/package.json +4 -4
  4. package/src/processor-runner.ts +2 -2
  5. package/lib/aptos/types.test.js +0 -19
  6. package/lib/core/generic-processor.test.js +0 -58
  7. package/lib/core/meter.test.js +0 -21
  8. package/lib/core/numberish.test.js +0 -70
  9. package/lib/tests/aptos.test.d.ts +0 -1
  10. package/lib/tests/aptos.test.js +0 -379
  11. package/lib/tests/aptos.test.js.map +0 -1
  12. package/lib/tests/codegen.test.d.ts +0 -1
  13. package/lib/tests/codegen.test.js +0 -49
  14. package/lib/tests/codegen.test.js.map +0 -1
  15. package/lib/tests/erc20-template.test.d.ts +0 -1
  16. package/lib/tests/erc20-template.test.js +0 -56
  17. package/lib/tests/erc20-template.test.js.map +0 -1
  18. package/lib/tests/erc20.d.ts +0 -1
  19. package/lib/tests/erc20.js +0 -54
  20. package/lib/tests/erc20.js.map +0 -1
  21. package/lib/tests/erc20.test.d.ts +0 -1
  22. package/lib/tests/erc20.test.js +0 -94
  23. package/lib/tests/erc20.test.js.map +0 -1
  24. package/lib/tests/error-capture.test.d.ts +0 -1
  25. package/lib/tests/error-capture.test.js +0 -76
  26. package/lib/tests/error-capture.test.js.map +0 -1
  27. package/lib/tests/logger.test.d.ts +0 -1
  28. package/lib/tests/logger.test.js +0 -40
  29. package/lib/tests/logger.test.js.map +0 -1
  30. package/lib/tests/solana.test.d.ts +0 -1
  31. package/lib/tests/solana.test.js +0 -77
  32. package/lib/tests/solana.test.js.map +0 -1
  33. package/lib/tests/souffl3.d.ts +0 -1
  34. package/lib/tests/souffl3.js +0 -49
  35. package/lib/tests/souffl3.js.map +0 -1
  36. package/lib/tests/sui.test.d.ts +0 -1
  37. package/lib/tests/sui.test.js +0 -193
  38. package/lib/tests/sui.test.js.map +0 -1
  39. package/lib/tests/types/aptos/soffl3.d.ts +0 -786
  40. package/lib/tests/types/aptos/soffl3.js +0 -559
  41. package/lib/tests/types/aptos/soffl3.js.map +0 -1
  42. package/lib/tests/types/aptos/souffle.d.ts +0 -348
  43. package/lib/tests/types/aptos/souffle.js +0 -303
  44. package/lib/tests/types/aptos/souffle.js.map +0 -1
  45. package/lib/tests/types/solana/basic_1.d.ts +0 -26
  46. package/lib/tests/types/solana/basic_1.js +0 -66
  47. package/lib/tests/types/solana/basic_1.js.map +0 -1
  48. package/lib/tests/types/solana/basic_1_processor.d.ts +0 -13
  49. package/lib/tests/types/solana/basic_1_processor.js +0 -41
  50. package/lib/tests/types/solana/basic_1_processor.js.map +0 -1
  51. package/lib/tests/wormhole-token-bridge.d.ts +0 -1
  52. package/lib/tests/wormhole-token-bridge.js +0 -22
  53. package/lib/tests/wormhole-token-bridge.js.map +0 -1
  54. package/lib/utils/dex-price.test.js +0 -22
  55. package/lib/utils/erc20.test.js +0 -23
  56. package/src/aptos/types.test.ts +0 -18
  57. package/src/aptos-codegen/typegen.test.ts +0 -44
  58. package/src/core/generic-processor.test.ts +0 -69
  59. package/src/core/meter.test.ts +0 -23
  60. package/src/core/numberish.test.ts +0 -82
  61. package/src/tests/abis/aptos/soffl3.json +0 -1411
  62. package/src/tests/abis/aptos/souffle.json +0 -389
  63. package/src/tests/abis/evm/CommitmentPool.json +0 -1034
  64. package/src/tests/abis/evm/Seaport.json +0 -2595
  65. package/src/tests/abis/evm/anyswapRouter.json +0 -490
  66. package/src/tests/abis/solana/basic_1.json +0 -62
  67. package/src/tests/aptos.test.ts +0 -402
  68. package/src/tests/codegen.test.ts +0 -29
  69. package/src/tests/erc20-template.test.ts +0 -60
  70. package/src/tests/erc20.test.ts +0 -115
  71. package/src/tests/erc20.ts +0 -60
  72. package/src/tests/error-capture.test.ts +0 -82
  73. package/src/tests/logger.test.ts +0 -46
  74. package/src/tests/solana.test.ts +0 -79
  75. package/src/tests/souffl3.ts +0 -56
  76. package/src/tests/sui.test.ts +0 -197
  77. package/src/tests/types/aptos/soffl3.ts +0 -1377
  78. package/src/tests/types/aptos/souffle.ts +0 -698
  79. package/src/tests/types/solana/basic_1.ts +0 -62
  80. package/src/tests/types/solana/basic_1_processor.ts +0 -41
  81. package/src/tests/wormhole-token-bridge.ts +0 -21
  82. package/src/types/global.d.ts +0 -5
  83. package/src/utils/dex-price.test.ts +0 -25
  84. package/src/utils/erc20.test.ts +0 -26
  85. package/templates/aptos/.gitignore +0 -107
  86. package/templates/aptos/src/processor.test.ts +0 -14
  87. package/templates/evm/.gitignore +0 -107
  88. package/templates/evm/src/processor.test.ts +0 -29
  89. package/templates/raw/.gitignore +0 -107
  90. package/templates/raw/src/processor.test.ts +0 -14
@@ -34,8 +34,8 @@ const chainsConfig = fs_extra_1.default.readJsonSync(fullPath);
34
34
  (0, provider_1.setProvider)(chainsConfig, options.concurrency, options['use-chainserver']);
35
35
  console.log('Start Server', options);
36
36
  const server = (0, nice_grpc_1.createServer)({
37
- 'grpc.max_send_message_length': 64 * 1024 * 1024,
38
- 'grpc.max_receive_message_length': 64 * 1024 * 1024,
37
+ 'grpc.max_send_message_length': 128 * 1024 * 1024,
38
+ 'grpc.max_receive_message_length': 128 * 1024 * 1024,
39
39
  'grpc.default_compression_algorithm': compression_algorithms_1.CompressionAlgorithms.gzip,
40
40
  });
41
41
  const service = new service_1.ProcessorServiceImpl(() => (0, loader_1.load)(options.target), server.shutdown);
@@ -1 +1 @@
1
- {"version":3,"file":"processor-runner.js","sourceRoot":"","sources":["../src/processor-runner.ts"],"names":[],"mappings":";;;;;;AAEA,0EAA+C;AAC/C,yCAAwC;AACxC,+BAA2C;AAC3C,uCAAgD;AAChD,yCAAwC;AAExC,gDAAuB;AACvB,wDAAyB;AACzB,uDAAkD;AAClD,qCAA+B;AAC/B,2FAAsF;AAEtF,MAAM,CAAC,eAAe,GAAG,IAAI,gCAAc,EAAE,CAAA;AAE7C,MAAM,iBAAiB,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AG,EAAE,CAAC,IAAA,aAAI,EAAC,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAA;AACrF,MAAM,CAAC,GAAG,CAAC,yBAAmB,EAAE,OAAO,CAAC,CAAA;AAExC,MAAM,CAAC,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA","sourcesContent":["#!/usr/bin/env node\n\nimport commandLineArgs from 'command-line-args'\nimport { createServer } from 'nice-grpc'\nimport { ProcessorDefinition } from './gen'\nimport { ProcessorServiceImpl } from './service'\nimport { setProvider } from './provider'\n\nimport path from 'path'\nimport fs from 'fs-extra'\nimport { ProcessorState } from './processor-state'\nimport { load } from './loader'\nimport { CompressionAlgorithms } from '@grpc/grpc-js/build/src/compression-algorithms'\n\nglobal.PROCESSOR_STATE = new ProcessorState()\n\nconst optionDefinitions = [\n { name: 'target', type: String, defaultOption: true },\n { name: 'port', alias: 'p', type: String, defaultValue: '4000' },\n { name: 'concurrency', type: Number, defaultValue: 4 },\n { name: 'use-chainserver', type: Boolean, defaultValue: false },\n {\n name: 'chains-config',\n alias: 'c',\n type: String,\n defaultValue: 'chains-config.json',\n },\n]\n\nconst options = commandLineArgs(optionDefinitions, { partial: true })\n\nconsole.log('loading', options.target)\n\nconst fullPath = path.resolve(options['chains-config'])\nconst chainsConfig = fs.readJsonSync(fullPath)\n\nsetProvider(chainsConfig, options.concurrency, options['use-chainserver'])\n\nconsole.log('Start Server', options)\n\nconst server = createServer({\n 'grpc.max_send_message_length': 64 * 1024 * 1024,\n 'grpc.max_receive_message_length': 64 * 1024 * 1024,\n 'grpc.default_compression_algorithm': CompressionAlgorithms.gzip,\n})\n\nconst service = new ProcessorServiceImpl(() => load(options.target), server.shutdown)\nserver.add(ProcessorDefinition, service)\n\nserver.listen('0.0.0.0:' + options.port)\n"]}
1
+ {"version":3,"file":"processor-runner.js","sourceRoot":"","sources":["../src/processor-runner.ts"],"names":[],"mappings":";;;;;;AAEA,0EAA+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EAAC;IAC1B,8BAA8B,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI;IACjD,iCAAiC,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI;IACpD,oCAAoC,EAAE,8CAAqB,CAAC,IAAI;CACjE,CAAC,CAAA;AAEF,MAAM,OAAO,GAAG,IAAI,8BAAoB,CAAC,GAAG,EAAE,CAAC,IAAA,aAAI,EAAC,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAA;AACrF,MAAM,CAAC,GAAG,CAAC,yBAAmB,EAAE,OAAO,CAAC,CAAA;AAExC,MAAM,CAAC,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA","sourcesContent":["#!/usr/bin/env node\n\nimport commandLineArgs from 'command-line-args'\nimport { createServer } from 'nice-grpc'\nimport { ProcessorDefinition } from './gen'\nimport { ProcessorServiceImpl } from './service'\nimport { setProvider } from './provider'\n\nimport path from 'path'\nimport fs from 'fs-extra'\nimport { ProcessorState } from './processor-state'\nimport { load } from './loader'\nimport { CompressionAlgorithms } from '@grpc/grpc-js/build/src/compression-algorithms'\n\nglobal.PROCESSOR_STATE = new ProcessorState()\n\nconst optionDefinitions = [\n { name: 'target', type: String, defaultOption: true },\n { name: 'port', alias: 'p', type: String, defaultValue: '4000' },\n { name: 'concurrency', type: Number, defaultValue: 4 },\n { name: 'use-chainserver', type: Boolean, defaultValue: false },\n {\n name: 'chains-config',\n alias: 'c',\n type: String,\n defaultValue: 'chains-config.json',\n },\n]\n\nconst options = commandLineArgs(optionDefinitions, { partial: true })\n\nconsole.log('loading', options.target)\n\nconst fullPath = path.resolve(options['chains-config'])\nconst chainsConfig = fs.readJsonSync(fullPath)\n\nsetProvider(chainsConfig, options.concurrency, options['use-chainserver'])\n\nconsole.log('Start Server', options)\n\nconst server = createServer({\n 'grpc.max_send_message_length': 128 * 1024 * 1024,\n 'grpc.max_receive_message_length': 128 * 1024 * 1024,\n 'grpc.default_compression_algorithm': CompressionAlgorithms.gzip,\n})\n\nconst service = new ProcessorServiceImpl(() => load(options.target), server.shutdown)\nserver.add(ProcessorDefinition, service)\n\nserver.listen('0.0.0.0:' + options.port)\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sentio/sdk",
3
3
  "license": "Apache-2.0",
4
- "version": "1.27.3",
4
+ "version": "1.27.4",
5
5
  "scripts": {
6
6
  "compile_target": "yarn tsc -b src/target-ethers-sentio/tsconfig.json",
7
7
  "compile": "tsc -p . && cp src/cli/webpack.config.js lib/cli && cp src/utils/*.csv lib/utils",
@@ -77,9 +77,9 @@
77
77
  "types": "./lib/index.d.ts",
78
78
  "module": "./lib/index.js",
79
79
  "files": [
80
- "lib/**/*",
81
- "src/**/*",
82
- "templates/**/*"
80
+ "{lib,src,templates}",
81
+ "!{lib,src}/tests",
82
+ "!**/*.test.{js,ts}"
83
83
  ],
84
84
  "engines": {
85
85
  "node": ">=16"
@@ -39,8 +39,8 @@ setProvider(chainsConfig, options.concurrency, options['use-chainserver'])
39
39
  console.log('Start Server', options)
40
40
 
41
41
  const server = createServer({
42
- 'grpc.max_send_message_length': 64 * 1024 * 1024,
43
- 'grpc.max_receive_message_length': 64 * 1024 * 1024,
42
+ 'grpc.max_send_message_length': 128 * 1024 * 1024,
43
+ 'grpc.max_receive_message_length': 128 * 1024 * 1024,
44
44
  'grpc.default_compression_algorithm': CompressionAlgorithms.gzip,
45
45
  })
46
46
 
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const types_1 = require("./types");
4
- const _0x1_1 = require("../builtin/aptos/0x1");
5
- describe('type decode', () => {
6
- _0x1_1.aptos_account.loadTypes(types_1.TYPE_REGISTRY);
7
- test('decode function payload', async () => {
8
- const decoded = types_1.TYPE_REGISTRY.decodeFunctionPayload(data);
9
- console.log(decoded);
10
- });
11
- });
12
- const data = {
13
- type: 'entry_function_payload',
14
- type_arguments: [],
15
- arguments: ['0xaaaf981fec16d967eb79bb51b4c6d39e75acb3482c6dabddb19ca9adbfceee80'],
16
- code: { bytecode: '' },
17
- function: '0x1::aptos_account::create_account',
18
- };
19
- //# sourceMappingURL=types.test.js.map
@@ -1,58 +0,0 @@
1
- "use strict";
2
- // TODO move out of this package
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const chai_1 = require("chai");
5
- const __1 = require("..");
6
- const generic_processor_1 = require("./generic-processor");
7
- const testing_1 = require("../testing");
8
- describe('Test Generic Processor', () => {
9
- const service = new testing_1.TestProcessorServer(() => {
10
- generic_processor_1.GenericProcessor.bind([
11
- 'event Transfer(address indexed from, address indexed to, uint256 value)',
12
- 'event Approval(address indexed from, address indexed to, uint256 value)',
13
- ], { address: '0x1E4EDE388cbc9F4b5c79681B7f94d36a11ABEBC9' }).onAllEvents(function (log, ctx) {
14
- ctx.meter.Counter('event_num').add(1);
15
- });
16
- generic_processor_1.GenericProcessor.bind('event WalletCreated(address wallet, address owner)', {
17
- address: '0x57E037F4d2c8BEa011Ad8a9A5AF4AaEEd508650f',
18
- }).onAllEvents(function (log, ctx) {
19
- ctx.meter.Counter('wallet').add(1);
20
- });
21
- });
22
- beforeAll(async () => {
23
- await service.start();
24
- });
25
- test('check configuration', async () => {
26
- const config = await service.getConfig({});
27
- (0, chai_1.expect)(config.contractConfigs).length(2);
28
- (0, chai_1.expect)(config.contractConfigs?.[0].contract?.name).equals('Generic');
29
- });
30
- test('Check log dispatch', async () => {
31
- const res = await service.testLogs([logData, logData]);
32
- const counters = res.result?.counters;
33
- (0, chai_1.expect)(counters).length(2);
34
- (0, chai_1.expect)((0, testing_1.firstCounterValue)(res.result, 'event_num')).equals(1n);
35
- (0, chai_1.expect)(counters?.[0].runtimeInfo?.from).equals(__1.HandlerType.ETH_LOG);
36
- });
37
- test('Check log dispatch no buffer over rune', async () => {
38
- const logStr = '{"address":"0x57e037f4d2c8bea011ad8a9a5af4aaeed508650f","topics":["0x5b03bfed1c14a02bdeceb5fa582eb1a5765fc0bc64ca0e6af4c20afc9487f081"],"data":"0x00000000000000000000000093269483a70c68d5c5bb63aac1e8f4ac59f498800000000000000000000000000c520e51c055cf63bab075715c1b860b2e9b8e24","blockNumber":"0xc9d6d7","transactionHash":"0x208af3250499672c2f07138b9aa236153c65c78ae4341b23c2763017afdd61a2","transactionIndex":"0xf3","blockHash":"0x6e3b100c34b510049e922fbe1c1dab1b0793be3d1229b632688e6a518cdd11b6","logIndex":"0x14b","removed":false}';
39
- const res = await service.testLog(JSON.parse(logStr));
40
- console.log(JSON.stringify(res));
41
- });
42
- const logData = {
43
- blockNumber: 14213252,
44
- blockHash: '0x83d646fac9350b281def8c4c37626f9d8efc95df801287b848c719edf35cdbaf',
45
- transactionIndex: 347,
46
- removed: false,
47
- address: '0x1E4EDE388cbc9F4b5c79681B7f94d36a11ABEBC9',
48
- data: '0x00000000000000000000000000000000000000000000009a71db64810aaa0000',
49
- topics: [
50
- '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
51
- '0x0000000000000000000000000000000000000000000000000000000000000000',
52
- '0x000000000000000000000000b329e39ebefd16f40d38f07643652ce17ca5bac1',
53
- ],
54
- transactionHash: '0x93355e0cb2c3490cb8a747029ff2dc8cdbde2407025b8391398436955afae303',
55
- logIndex: 428,
56
- };
57
- });
58
- //# sourceMappingURL=generic-processor.test.js.map
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const chai_1 = require("chai");
4
- const meter_1 = require("./meter");
5
- describe('meter tests', () => {
6
- test('test normalization ', async () => {
7
- (0, chai_1.expect)((0, meter_1.normalizeName)('abc') === 'abc');
8
- (0, chai_1.expect)((0, meter_1.normalizeName)('a-b-c') === 'a-b-c');
9
- (0, chai_1.expect)((0, meter_1.normalizeName)('_a-B-1.') === '_a-B-1.');
10
- (0, chai_1.expect)((0, meter_1.normalizeName)('a/b\\c\n') === 'abc');
11
- (0, chai_1.expect)((0, meter_1.normalizeName)('abc abc') === 'abc_abc');
12
- (0, chai_1.expect)((0, meter_1.normalizeName)('*&~') === '___');
13
- (0, chai_1.expect)((0, meter_1.normalizeName)('x'.repeat(200)).length === 100);
14
- });
15
- test('test labels', async () => {
16
- const labels = { labels: '0' };
17
- const updated = (0, meter_1.normalizeLabels)(labels);
18
- (0, chai_1.expect)(updated['labels_']).to.eq('0');
19
- });
20
- });
21
- //# sourceMappingURL=meter.test.js.map
@@ -1,70 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const chai_1 = require("chai");
4
- const numberish_1 = require("./numberish");
5
- const crypto_1 = require("crypto");
6
- const ethers_1 = require("ethers");
7
- const perf_hooks_1 = require("perf_hooks");
8
- const _1 = require(".");
9
- // TODO add test for type conversion
10
- describe('Numberish tests', () => {
11
- const values = [0n, -0n, 3815372408723498172304781320847103784n, 2132n, -18708707n, 123n << 100n];
12
- test('big integer conversion correctness ', async () => {
13
- for (const v of values) {
14
- const b = (0, numberish_1.toBigInteger)(v);
15
- const hex1 = BigIntegerToHex(b);
16
- const hex2 = v.toString(16);
17
- (0, chai_1.expect)(hex1).equals(hex2);
18
- }
19
- });
20
- test('random big integer conversion correctness ', async () => {
21
- for (let i = 0; i < 1000; i++) {
22
- const random = crypto_1.webcrypto.getRandomValues(new Uint8Array(256));
23
- const v = ethers_1.BigNumber.from(random).toBigInt();
24
- const b = (0, numberish_1.toBigInteger)(v);
25
- (0, chai_1.expect)(ethers_1.BigNumber.from(b.data).eq(v)).to.equals(true);
26
- }
27
- });
28
- test.skip('random big integer performance', async () => {
29
- jest.setTimeout(100000);
30
- jest.retryTimes(3);
31
- let timer1 = 0;
32
- let timer2 = 0;
33
- for (let i = 0; i < 1000; i++) {
34
- // Use higher value for local debugging
35
- const random = crypto_1.webcrypto.getRandomValues(new Uint8Array(256));
36
- const v = ethers_1.BigNumber.from(random).toBigInt();
37
- let start = perf_hooks_1.performance.now();
38
- (0, numberish_1.toBigInteger)(v);
39
- timer1 += perf_hooks_1.performance.now() - start;
40
- start = perf_hooks_1.performance.now();
41
- v.toString(16);
42
- timer2 += perf_hooks_1.performance.now() - start;
43
- }
44
- console.log(timer1, timer2);
45
- (0, chai_1.expect)(timer1).to.lessThan(timer2 * 3);
46
- });
47
- test('metric values', async () => {
48
- const longDec = '12.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002';
49
- (0, chai_1.expect)((0, numberish_1.toMetricValue)(new _1.BigDecimal(longDec)).bigDecimal == longDec);
50
- const complexDec = '-7.350918e-428';
51
- (0, chai_1.expect)((0, numberish_1.toMetricValue)(new _1.BigDecimal(complexDec)).bigDecimal == complexDec);
52
- (0, chai_1.expect)(BigIntegerToBigInt((0, numberish_1.toMetricValue)(new _1.BigDecimal('100000')).bigInteger) === 100000n);
53
- });
54
- });
55
- // Performance very bad
56
- function BigIntegerToHex(b) {
57
- let res = ethers_1.BigNumber.from(b.data).toBigInt().toString(16);
58
- if (b.negative) {
59
- res = '-' + res;
60
- }
61
- return res;
62
- }
63
- function BigIntegerToBigInt(b) {
64
- let res = ethers_1.BigNumber.from(b.data).toBigInt();
65
- if (b.negative) {
66
- res = -res;
67
- }
68
- return res;
69
- }
70
- //# sourceMappingURL=numberish.test.js.map
@@ -1 +0,0 @@
1
- export {};
@@ -1,379 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const chai_1 = require("chai");
4
- const util_1 = require("util");
5
- const __1 = require("..");
6
- const testing_1 = require("../testing");
7
- describe('Test Aptos Example', () => {
8
- const service = new testing_1.TestProcessorServer(() => {
9
- require('./souffl3');
10
- });
11
- beforeAll(async () => {
12
- await service.start({ templateInstances: [] });
13
- });
14
- test('check configuration ', async () => {
15
- const config = await service.getConfig({});
16
- (0, chai_1.expect)(config.contractConfigs).length(5);
17
- });
18
- test('Check souffl3 transaction dispatch', async () => {
19
- const request = {
20
- bindings: [
21
- {
22
- data: {
23
- raw: new util_1.TextEncoder().encode(JSON.stringify(testData)),
24
- },
25
- handlerId: 1,
26
- handlerType: __1.HandlerType.APT_CALL,
27
- },
28
- ],
29
- };
30
- const res = await service.processBindings(request);
31
- (0, chai_1.expect)(res.result?.counters).length(1);
32
- (0, chai_1.expect)(res.result?.gauges).length(0);
33
- (0, chai_1.expect)(res.result?.counters[0].metadata?.blockNumber.toInt()).equal(18483034);
34
- });
35
- test('Check souffl3 function call dispatch', async () => {
36
- const request = {
37
- bindings: [
38
- {
39
- data: {
40
- raw: new util_1.TextEncoder().encode(JSON.stringify(testData)),
41
- },
42
- handlerId: 0,
43
- handlerType: __1.HandlerType.APT_CALL,
44
- },
45
- ],
46
- };
47
- const res = await service.processBindings(request);
48
- (0, chai_1.expect)(res.result?.counters).length(2);
49
- (0, chai_1.expect)(res.result?.gauges).length(0);
50
- (0, chai_1.expect)(res.result?.counters[0].metadata?.blockNumber.toInt()).equal(18483034);
51
- });
52
- test('Check souffl3 event dispatch', async () => {
53
- const request = {
54
- bindings: [
55
- {
56
- data: {
57
- raw: new util_1.TextEncoder().encode(JSON.stringify({
58
- ...testData,
59
- events: [testData.events[testData.events.length - 1]],
60
- })),
61
- },
62
- handlerId: 0,
63
- handlerType: __1.HandlerType.APT_EVENT,
64
- },
65
- ],
66
- };
67
- const res = await service.processBindings(request);
68
- (0, chai_1.expect)(res.result?.counters).length(1);
69
- (0, chai_1.expect)(res.result?.gauges).length(0);
70
- (0, chai_1.expect)(res.result?.counters[0].metadata?.blockNumber.toInt()).equal(18483034);
71
- (0, chai_1.expect)(res.result?.events).length(1);
72
- });
73
- test('Check token deposit event dispatch', async () => {
74
- const request = {
75
- bindings: [
76
- {
77
- data: {
78
- raw: new util_1.TextEncoder().encode(JSON.stringify({
79
- ...testData,
80
- events: [tokenTestData],
81
- })),
82
- },
83
- handlerId: 2,
84
- handlerType: __1.HandlerType.APT_EVENT,
85
- },
86
- ],
87
- };
88
- const res = await service.processBindings(request);
89
- (0, chai_1.expect)((0, testing_1.firstCounterValue)(res.result, 'deposit')).equal(1n);
90
- (0, chai_1.expect)((0, testing_1.firstGaugeValue)(res.result, 'version')).equal(0n);
91
- });
92
- test('Check create poposal event dispatch', async () => {
93
- const request = {
94
- bindings: [
95
- {
96
- data: {
97
- raw: new util_1.TextEncoder().encode(JSON.stringify({ ...testData, events: [createProposalData] })),
98
- },
99
- handlerId: 3,
100
- handlerType: __1.HandlerType.APT_EVENT,
101
- },
102
- ],
103
- };
104
- const res = await service.processBindings(request);
105
- (0, chai_1.expect)((0, testing_1.firstGaugeValue)(res.result, 'size')).equal(2n);
106
- });
107
- test('check on timer', async () => {
108
- const request = {
109
- bindings: [
110
- {
111
- data: {
112
- raw: new util_1.TextEncoder().encode(JSON.stringify({
113
- version: '12345',
114
- resources: [
115
- {
116
- type: '0x1::coin::SupplyConfig',
117
- data: {
118
- allow_upgrades: false,
119
- },
120
- },
121
- ],
122
- })),
123
- },
124
- handlerId: 0,
125
- handlerType: __1.HandlerType.APT_RESOURCE,
126
- },
127
- ],
128
- };
129
- const res = await service.processBindings(request);
130
- (0, chai_1.expect)((0, testing_1.firstCounterValue)(res.result, 'onTimer')).equal(1n);
131
- });
132
- test('Check aptos account transaction dispatch', async () => {
133
- const request = {
134
- bindings: [
135
- {
136
- data: {
137
- raw: new util_1.TextEncoder().encode(JSON.stringify(dataCreate)),
138
- },
139
- handlerId: 3,
140
- handlerType: __1.HandlerType.APT_CALL,
141
- },
142
- ],
143
- };
144
- const res = await service.processBindings(request);
145
- (0, chai_1.expect)(res.result?.counters).length(1);
146
- });
147
- });
148
- const testData = {
149
- version: '18483034',
150
- hash: '0xbf4df6f390546a793ba9b7caff120002b3257986dbea9c697fd64acf7dfeb052',
151
- state_change_hash: '0x6063039cca5a1eb33d3986d3665fc783238579961eaa4746c41e25fa4f72aac6',
152
- event_root_hash: '0x425e39bcf994672108f83c34f637e84166af7ecedcbe26aed0dff0d62da8055d',
153
- state_checkpoint_hash: null,
154
- gas_used: '854',
155
- success: true,
156
- vm_status: 'Executed successfully',
157
- accumulator_root_hash: '0x47aa479d9e15993ea2abe04043c89186fb5da0b5eb8b5c6d18bd55d5f0c2c877',
158
- changes: [],
159
- sender: '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807',
160
- sequence_number: '30',
161
- max_gas_amount: '20000',
162
- gas_unit_price: '1',
163
- expiration_timestamp_secs: '1663144544',
164
- payload: {
165
- function: '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807::SouffleChefCampaign::pull_token_v2',
166
- type_arguments: ['0x1::aptos_coin::AptosCoin'],
167
- arguments: [
168
- '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807',
169
- '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807',
170
- 'Souffl3 BlueBerry',
171
- '1',
172
- ],
173
- type: 'entry_function_payload',
174
- },
175
- signature: {
176
- public_key: '0x6c3f579afbf8a728827385039f7604ec1d06e5c802d8f9689ee8ec9d349fedc5',
177
- signature: '0xd2db95052e774f095d924030a50c29325a17e8d69d35c748f45bb0e22eb7d3b9e47545c98bd7130fd3ef46cbedc30c9aaeaf39c2d922ee8e7d578c0b1e76f30b',
178
- type: 'ed25519_signature',
179
- },
180
- events: [
181
- {
182
- guid: {
183
- creation_number: '3',
184
- account_address: '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807',
185
- },
186
- sequence_number: '10',
187
- type: '0x1::coin::WithdrawEvent',
188
- data: {
189
- amount: '1',
190
- },
191
- },
192
- {
193
- version: '18483034',
194
- guid: {
195
- creation_number: '2',
196
- account_address: '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807',
197
- },
198
- sequence_number: '11',
199
- type: '0x1::coin::DepositEvent',
200
- data: {
201
- amount: '1',
202
- },
203
- },
204
- {
205
- guid: {
206
- creation_number: '9',
207
- account_address: '0x21d5fe032affa1c8b10d343e9ad5a5618bc13baf5ed4a674fafaa12c54f416cc',
208
- },
209
- sequence_number: '9',
210
- type: '0x3::token::CreateTokenDataEvent',
211
- data: {
212
- description: 'Souffl3 offers a one-stop marketplace for the launch, listing, and trading of NFT assets on APTOS.\nWebsite:https://souffl3.com/\nEveryone can win through our Bake Off campaign on the Aptos Testnet, rewards including Souffl3 Genesis NFT and whitelists of other collab projects, everyone is welcome to participate!',
213
- id: {
214
- collection: 'Souffl3 BlueBerry',
215
- creator: '0x21d5fe032affa1c8b10d343e9ad5a5618bc13baf5ed4a674fafaa12c54f416cc',
216
- name: 'Souffl3 BlueBerry #2',
217
- },
218
- maximum: '999999999999',
219
- mutability_config: {
220
- description: true,
221
- maximum: true,
222
- properties: true,
223
- royalty: true,
224
- uri: true,
225
- },
226
- name: 'Souffl3 BlueBerry #2',
227
- property_keys: ['author', 'point'],
228
- property_types: ['string', 'integer'],
229
- property_values: ['0x33454e4a4f59204c616273', '0x30'],
230
- royalty_payee_address: '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807',
231
- royalty_points_denominator: '100',
232
- royalty_points_numerator: '20',
233
- uri: 'https://y3x4txhvirx5zl57efzbl6dg7psaier5q35hhwuqwzjwuahrycya.arweave.net/xu_J3PVEb9yvvyFyFfhm--QEEj2G-nPakLZTagDxwLA',
234
- },
235
- },
236
- {
237
- guid: {
238
- creation_number: '2',
239
- account_address: '0x21d5fe032affa1c8b10d343e9ad5a5618bc13baf5ed4a674fafaa12c54f416cc',
240
- },
241
- sequence_number: '27',
242
- type: '0x3::token::DepositEvent',
243
- data: {
244
- amount: '1',
245
- id: {
246
- property_version: '0',
247
- token_data_id: {
248
- collection: 'Souffl3 BlueBerry',
249
- creator: '0x21d5fe032affa1c8b10d343e9ad5a5618bc13baf5ed4a674fafaa12c54f416cc',
250
- name: 'Souffl3 BlueBerry #2',
251
- },
252
- },
253
- },
254
- },
255
- {
256
- version: '18483034',
257
- guid: {
258
- creation_number: '7',
259
- account_address: '0x21d5fe032affa1c8b10d343e9ad5a5618bc13baf5ed4a674fafaa12c54f416cc',
260
- },
261
- sequence_number: '980533',
262
- type: '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807::SouffleChefCampaign::PullTokenEvent<0x1::aptos_coin::AptosCoin>',
263
- data: {
264
- receiver: '0x3a80be5daa84f2da7e07b3ec9234da48a5647f757187879c97a1fa03f31f1195',
265
- },
266
- },
267
- ],
268
- timestamp: '1663143945131218',
269
- type: 'user_transaction',
270
- };
271
- const tokenTestData = {
272
- guid: {
273
- creation_number: '4',
274
- account_address: '0x89bc80de59187f707a59ae7a4121718dafe3e6068e0509104ef7e41a56bc97db',
275
- },
276
- sequence_number: '10',
277
- type: '0x3::token::DepositEvent',
278
- data: {
279
- amount: '1',
280
- id: {
281
- property_version: '0',
282
- token_data_id: {
283
- collection: 'Topaz Troopers',
284
- creator: '0x9125e4054d884fdc7296b66e12c0d63a7baa0d88c77e8e784987c0a967c670ac',
285
- name: 'Topaz Trooper #11293',
286
- },
287
- },
288
- },
289
- };
290
- const createProposalData = {
291
- guid: {
292
- creation_number: '5',
293
- account_address: '0x1',
294
- },
295
- sequence_number: '3',
296
- type: '0x1::voting::CreateProposalEvent',
297
- data: {
298
- early_resolution_vote_threshold: {
299
- vec: ['9272156337856446330'],
300
- },
301
- execution_hash: '0x31549239ce8abdc1e9c259178614c3d44d015bd6d48635ddcfbfa4a77e7222b0',
302
- expiration_secs: '1665463839',
303
- metadata: {
304
- data: [
305
- {
306
- key: 'metadata_hash',
307
- value: '0x61633230656566373063616466363939663530353564323463356363353931396463306330656562643463303662653332346336323030313561633361653066',
308
- },
309
- {
310
- key: 'metadata_location',
311
- value: '0x68747470733a2f2f676973742e67697468756275736572636f6e74656e742e636f6d2f6d6f76656b6576696e2f30353766623134356234303836366566663863323263393166623964613931392f7261772f626162383566306637343334663030386138373831656563376663616464316163356135353438312f6769737466696c65312e747874',
312
- },
313
- ],
314
- },
315
- min_vote_threshold: '100000000000000',
316
- proposal_id: '3',
317
- },
318
- };
319
- const dataCreate = {
320
- id: '',
321
- round: '',
322
- previous_block_votes: null,
323
- proposer: '',
324
- sender: '0x88252db4dc2484cd9cedb23cd67b7b91f88940142f3eea35df7a9168d9c30896',
325
- sequence_number: '1510',
326
- payload: {
327
- type: 'entry_function_payload',
328
- type_arguments: [],
329
- arguments: ['0xd582e092190feda35a2f737123f86e33a1b592596804f40b1d539ab603a82a24'],
330
- code: { bytecode: '' },
331
- function: '0x1::aptos_account::create_account',
332
- },
333
- max_gas_amount: '2000',
334
- gas_unit_price: '100',
335
- expiration_timestamp_secs: '1666174748',
336
- secondary_signers: null,
337
- signature: {
338
- type: 'ed25519_signature',
339
- public_key: '0xfe1e11c6cb912ae998c9512d21e5781abb64fd4b8d6cfa15aeba3ee481406b64',
340
- signature: '0x98a49f348a3015702e3be33c1d2a92ea7b2726d31b27c857980493fe68cadc83fbef0839e312d6a82a9e6ca69481245fa49b6f25c0ec51660615d03e05738c03',
341
- public_keys: null,
342
- signatures: null,
343
- threshold: 0,
344
- bitmap: '',
345
- sender: { type: '', public_key: '', signature: '', public_keys: null, signatures: null, threshold: 0, bitmap: '' },
346
- secondary_signer_addresses: null,
347
- secondary_signers: null,
348
- },
349
- type: 'user_transaction',
350
- timestamp: '1666174688494614',
351
- events: [
352
- {
353
- version: '3121410',
354
- guid: {
355
- creation_number: '0',
356
- account_address: '0xd582e092190feda35a2f737123f86e33a1b592596804f40b1d539ab603a82a24',
357
- },
358
- sequence_number: '0',
359
- type: '0x1::account::CoinRegisterEvent',
360
- data: {
361
- type_info: {
362
- account_address: '0x1',
363
- module_name: '0x6170746f735f636f696e',
364
- struct_name: '0x4170746f73436f696e',
365
- },
366
- },
367
- },
368
- ],
369
- version: '3121410',
370
- hash: '0xcae7d97c9f43d90e247a366688905bc8e83ee0ad4baddbf3cc2fdda56e4d6926',
371
- state_root_hash: '',
372
- event_root_hash: '0xfa557e3bb8dff8fd3321f9a4eaa779311c9c795728355686b487b5b0adf7ce3c',
373
- gas_used: '1538',
374
- success: true,
375
- vm_status: 'Executed successfully',
376
- accumulator_root_hash: '0x7563d6ed58b011e512d53cce2bc1a70716fc6362e12fb6af8fe6d459ae71dffc',
377
- changes: null,
378
- };
379
- //# sourceMappingURL=aptos.test.js.map