@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
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const sdk_1 = require("@sentio/sdk");
4
- const token_1 = require("./token");
5
- const test_provider_1 = require("../testing/test-provider");
6
- describe('erc20 tests', () => {
7
- global.PROCESSOR_STATE = new sdk_1.ProcessorState();
8
- const haveProviders = (0, test_provider_1.loadTestProvidersFromEnv)('1');
9
- const testIf = haveProviders ? test : test.skip;
10
- testIf('test bytes32', async () => {
11
- const info = await (0, token_1.getERC20TokenInfo)('0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2');
12
- expect(info.decimal).toEqual(18);
13
- expect(info.symbol).toEqual('MKR');
14
- expect(info.name).toEqual('Maker');
15
- });
16
- testIf('test normal', async () => {
17
- const info = await (0, token_1.getERC20TokenInfo)('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48');
18
- expect(info.decimal).toEqual(6);
19
- expect(info.symbol).toEqual('USDC');
20
- expect(info.name).toEqual('USD Coin');
21
- });
22
- });
23
- //# sourceMappingURL=erc20.test.js.map
@@ -1,18 +0,0 @@
1
- import { TYPE_REGISTRY } from './types'
2
- import { aptos_account } from '../builtin/aptos/0x1'
3
-
4
- describe('type decode', () => {
5
- aptos_account.loadTypes(TYPE_REGISTRY)
6
- test('decode function payload', async () => {
7
- const decoded = TYPE_REGISTRY.decodeFunctionPayload(data)
8
- console.log(decoded)
9
- })
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
- }
@@ -1,44 +0,0 @@
1
- import { parseMoveType } from './typegen'
2
- import { assert } from 'chai'
3
-
4
- describe('type gen', () => {
5
- test('type gen for generic', async () => {
6
- const res = parseMoveType('x<g1<a,g2<c,d>>,b,g3<a,b>,e>')
7
-
8
- assert(res.qname === 'x')
9
- assert(res.typeArgs[0].typeArgs[1].qname === 'g2')
10
- assert(res.typeArgs[0].typeArgs[1].typeArgs[1].qname === 'd')
11
- })
12
-
13
- test('type gen for non generic', async () => {
14
- const res = parseMoveType('xyz')
15
-
16
- assert(res.qname === 'xyz')
17
- assert(res.typeArgs.length === 0)
18
- })
19
-
20
- test('test depended types', async () => {
21
- const typeString =
22
- '0x1::table_with_length::TableWithLength<T0, 0xd5f9f2b1c24faee8f07b790e570c75dfa1b7d8c1e9a60162fbd92ade03ea29e4::iterable_table::IterableValue<T0, T1>>'
23
- const res = parseMoveType(typeString)
24
-
25
- const deps = res.dependedTypes()
26
- assert(deps.length === 2)
27
- assert(
28
- deps[0] === '0xd5f9f2b1c24faee8f07b790e570c75dfa1b7d8c1e9a60162fbd92ade03ea29e4::iterable_table::IterableValue'
29
- )
30
- assert(deps[1] === '0x1::table_with_length::TableWithLength')
31
-
32
- const computedTypeString = res.getSignature()
33
- assert(computedTypeString === typeString)
34
- })
35
- // test('type type gen', async () => {
36
- //
37
- // const res = parseGenericType('x<g1<a,g2<c,d>>,b,g3<a,b>,e>')
38
- // console.log(res)
39
- //
40
- // assert(res.symbol === 'x')
41
- // assert(res.typeParams[0].typeParams[1].symbol === "g2")
42
- // assert(res.typeParams[0].typeParams[1].typeParams[1].symbol === "d")
43
- // })
44
- })
@@ -1,69 +0,0 @@
1
- // TODO move out of this package
2
-
3
- import { expect } from 'chai'
4
-
5
- import { HandlerType } from '..'
6
-
7
- import { GenericProcessor } from './generic-processor'
8
- import { TestProcessorServer, firstCounterValue } from '../testing'
9
-
10
- describe('Test Generic Processor', () => {
11
- const service = new TestProcessorServer(() => {
12
- GenericProcessor.bind(
13
- [
14
- 'event Transfer(address indexed from, address indexed to, uint256 value)',
15
- 'event Approval(address indexed from, address indexed to, uint256 value)',
16
- ],
17
- { address: '0x1E4EDE388cbc9F4b5c79681B7f94d36a11ABEBC9' }
18
- ).onAllEvents(function (log, ctx) {
19
- ctx.meter.Counter('event_num').add(1)
20
- })
21
-
22
- GenericProcessor.bind('event WalletCreated(address wallet, address owner)', {
23
- address: '0x57E037F4d2c8BEa011Ad8a9A5AF4AaEEd508650f',
24
- }).onAllEvents(function (log, ctx) {
25
- ctx.meter.Counter('wallet').add(1)
26
- })
27
- })
28
-
29
- beforeAll(async () => {
30
- await service.start()
31
- })
32
-
33
- test('check configuration', async () => {
34
- const config = await service.getConfig({})
35
- expect(config.contractConfigs).length(2)
36
- expect(config.contractConfigs?.[0].contract?.name).equals('Generic')
37
- })
38
-
39
- test('Check log dispatch', async () => {
40
- const res = await service.testLogs([logData, logData])
41
- const counters = res.result?.counters
42
- expect(counters).length(2)
43
- expect(firstCounterValue(res.result, 'event_num')).equals(1n)
44
- expect(counters?.[0].runtimeInfo?.from).equals(HandlerType.ETH_LOG)
45
- })
46
-
47
- test('Check log dispatch no buffer over rune', async () => {
48
- const logStr =
49
- '{"address":"0x57e037f4d2c8bea011ad8a9a5af4aaeed508650f","topics":["0x5b03bfed1c14a02bdeceb5fa582eb1a5765fc0bc64ca0e6af4c20afc9487f081"],"data":"0x00000000000000000000000093269483a70c68d5c5bb63aac1e8f4ac59f498800000000000000000000000000c520e51c055cf63bab075715c1b860b2e9b8e24","blockNumber":"0xc9d6d7","transactionHash":"0x208af3250499672c2f07138b9aa236153c65c78ae4341b23c2763017afdd61a2","transactionIndex":"0xf3","blockHash":"0x6e3b100c34b510049e922fbe1c1dab1b0793be3d1229b632688e6a518cdd11b6","logIndex":"0x14b","removed":false}'
50
- const res = await service.testLog(JSON.parse(logStr))
51
- console.log(JSON.stringify(res))
52
- })
53
-
54
- const logData = {
55
- blockNumber: 14213252,
56
- blockHash: '0x83d646fac9350b281def8c4c37626f9d8efc95df801287b848c719edf35cdbaf',
57
- transactionIndex: 347,
58
- removed: false,
59
- address: '0x1E4EDE388cbc9F4b5c79681B7f94d36a11ABEBC9',
60
- data: '0x00000000000000000000000000000000000000000000009a71db64810aaa0000',
61
- topics: [
62
- '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
63
- '0x0000000000000000000000000000000000000000000000000000000000000000',
64
- '0x000000000000000000000000b329e39ebefd16f40d38f07643652ce17ca5bac1',
65
- ],
66
- transactionHash: '0x93355e0cb2c3490cb8a747029ff2dc8cdbde2407025b8391398436955afae303',
67
- logIndex: 428,
68
- }
69
- })
@@ -1,23 +0,0 @@
1
- import { expect } from 'chai'
2
- import { normalizeLabels, normalizeName } from './meter'
3
-
4
- describe('meter tests', () => {
5
- test('test normalization ', async () => {
6
- expect(normalizeName('abc') === 'abc')
7
- expect(normalizeName('a-b-c') === 'a-b-c')
8
- expect(normalizeName('_a-B-1.') === '_a-B-1.')
9
-
10
- expect(normalizeName('a/b\\c\n') === 'abc')
11
- expect(normalizeName('abc abc') === 'abc_abc')
12
- expect(normalizeName('*&~') === '___')
13
-
14
- expect(normalizeName('x'.repeat(200)).length === 100)
15
- })
16
-
17
- test('test labels', async () => {
18
- const labels = { labels: '0' }
19
- const updated = normalizeLabels(labels)
20
-
21
- expect(updated['labels_']).to.eq('0')
22
- })
23
- })
@@ -1,82 +0,0 @@
1
- import { expect } from 'chai'
2
- import { toBigInteger, toMetricValue } from './numberish'
3
- import { webcrypto } from 'crypto'
4
- import { BigNumber } from 'ethers'
5
- import { performance } from 'perf_hooks'
6
- import { BigInteger } from '../gen'
7
- import { BigDecimal } from '.'
8
-
9
- // TODO add test for type conversion
10
- describe('Numberish tests', () => {
11
- const values: bigint[] = [0n, -0n, 3815372408723498172304781320847103784n, 2132n, -18708707n, 123n << 100n]
12
-
13
- test('big integer conversion correctness ', async () => {
14
- for (const v of values) {
15
- const b = toBigInteger(v)
16
- const hex1 = BigIntegerToHex(b)
17
- const hex2 = v.toString(16)
18
- expect(hex1).equals(hex2)
19
- }
20
- })
21
-
22
- test('random big integer conversion correctness ', async () => {
23
- for (let i = 0; i < 1000; i++) {
24
- const random = webcrypto.getRandomValues(new Uint8Array(256))
25
- const v = BigNumber.from(random).toBigInt()
26
- const b = toBigInteger(v)
27
-
28
- expect(BigNumber.from(b.data).eq(v)).to.equals(true)
29
- }
30
- })
31
-
32
- test.skip('random big integer performance', async () => {
33
- jest.setTimeout(100000)
34
- jest.retryTimes(3)
35
-
36
- let timer1 = 0
37
- let timer2 = 0
38
- for (let i = 0; i < 1000; i++) {
39
- // Use higher value for local debugging
40
- const random = webcrypto.getRandomValues(new Uint8Array(256))
41
- const v = BigNumber.from(random).toBigInt()
42
-
43
- let start = performance.now()
44
- toBigInteger(v)
45
- timer1 += performance.now() - start
46
-
47
- start = performance.now()
48
- v.toString(16)
49
- timer2 += performance.now() - start
50
- }
51
-
52
- console.log(timer1, timer2)
53
- expect(timer1).to.lessThan(timer2 * 3)
54
- })
55
-
56
- test('metric values', async () => {
57
- const longDec = '12.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002'
58
- expect(toMetricValue(new BigDecimal(longDec)).bigDecimal == longDec)
59
-
60
- const complexDec = '-7.350918e-428'
61
- expect(toMetricValue(new BigDecimal(complexDec)).bigDecimal == complexDec)
62
-
63
- expect(BigIntegerToBigInt(toMetricValue(new BigDecimal('100000')).bigInteger!) === 100000n)
64
- })
65
- })
66
-
67
- // Performance very bad
68
- function BigIntegerToHex(b: BigInteger): string {
69
- let res = BigNumber.from(b.data).toBigInt().toString(16)
70
- if (b.negative) {
71
- res = '-' + res
72
- }
73
- return res
74
- }
75
-
76
- function BigIntegerToBigInt(b: BigInteger): bigint {
77
- let res = BigNumber.from(b.data).toBigInt()
78
- if (b.negative) {
79
- res = -res
80
- }
81
- return res
82
- }