@sentio/sdk 1.19.4 → 1.19.5

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 (98) hide show
  1. package/lib/aptos/aptos-processor.d.ts +40 -0
  2. package/lib/aptos/aptos-processor.js +126 -0
  3. package/lib/aptos/aptos-processor.js.map +1 -0
  4. package/lib/aptos/bind-options.d.ts +11 -0
  5. package/lib/aptos/bind-options.js +17 -0
  6. package/lib/aptos/bind-options.js.map +1 -0
  7. package/lib/aptos/context.d.ts +12 -0
  8. package/lib/aptos/context.js +33 -0
  9. package/lib/aptos/context.js.map +1 -0
  10. package/lib/aptos/index.d.ts +5 -0
  11. package/lib/aptos/index.js +11 -0
  12. package/lib/aptos/index.js.map +1 -0
  13. package/lib/core/base-processor-template.js.map +1 -1
  14. package/lib/core/base-processor.d.ts +1 -1
  15. package/lib/core/base-processor.js.map +1 -1
  16. package/lib/core/bind-options.d.ts +0 -2
  17. package/lib/core/bind-options.js +1 -4
  18. package/lib/core/bind-options.js.map +1 -1
  19. package/lib/core/context.d.ts +10 -10
  20. package/lib/core/context.js +65 -11
  21. package/lib/core/context.js.map +1 -1
  22. package/lib/core/index.d.ts +1 -2
  23. package/lib/core/index.js +1 -4
  24. package/lib/core/index.js.map +1 -1
  25. package/lib/core/logger.d.ts +1 -1
  26. package/lib/core/logger.js +5 -5
  27. package/lib/core/logger.js.map +1 -1
  28. package/lib/core/metadata.d.ts +1 -1
  29. package/lib/core/metadata.js +3 -79
  30. package/lib/core/metadata.js.map +1 -1
  31. package/lib/core/meter.d.ts +1 -1
  32. package/lib/core/meter.js +2 -2
  33. package/lib/core/meter.js.map +1 -1
  34. package/lib/core/numberish.d.ts +1 -1
  35. package/lib/core/numberish.js +7 -7
  36. package/lib/core/numberish.js.map +1 -1
  37. package/lib/core/numberish.test.js.map +1 -1
  38. package/lib/core/solana-processor.d.ts +1 -1
  39. package/lib/core/solana-processor.js.map +1 -1
  40. package/lib/core/sui-processor.d.ts +1 -1
  41. package/lib/core/sui-processor.js.map +1 -1
  42. package/lib/gen/index.d.ts +1 -0
  43. package/lib/gen/index.js +18 -0
  44. package/lib/gen/index.js.map +1 -0
  45. package/lib/index.d.ts +2 -1
  46. package/lib/index.js +15 -2
  47. package/lib/index.js.map +1 -1
  48. package/lib/processor-state.d.ts +2 -1
  49. package/lib/processor-state.js.map +1 -1
  50. package/lib/service.d.ts +2 -2
  51. package/lib/service.js +41 -36
  52. package/lib/service.js.map +1 -1
  53. package/lib/testing/metric-utils.d.ts +1 -1
  54. package/lib/testing/metric-utils.js +2 -2
  55. package/lib/testing/metric-utils.js.map +1 -1
  56. package/lib/testing/test-processor-server.d.ts +2 -1
  57. package/lib/testing/test-processor-server.js +11 -11
  58. package/lib/testing/test-processor-server.js.map +1 -1
  59. package/lib/testing/test-provider.js +2 -2
  60. package/lib/testing/test-provider.js.map +1 -1
  61. package/lib/tests/aptos.test.js +44 -12
  62. package/lib/tests/aptos.test.js.map +1 -1
  63. package/lib/tests/souffl3.js +16 -4
  64. package/lib/tests/souffl3.js.map +1 -1
  65. package/lib/utils/chain.d.ts +1 -0
  66. package/lib/utils/chain.js +3 -1
  67. package/lib/utils/chain.js.map +1 -1
  68. package/package.json +3 -5
  69. package/src/aptos/aptos-processor.ts +156 -0
  70. package/src/aptos/bind-options.ts +15 -0
  71. package/src/aptos/context.ts +35 -0
  72. package/src/aptos/index.ts +8 -0
  73. package/src/core/base-processor-template.ts +1 -1
  74. package/src/core/base-processor.ts +1 -1
  75. package/src/core/bind-options.ts +0 -1
  76. package/src/core/context.ts +74 -15
  77. package/src/core/index.ts +2 -2
  78. package/src/core/logger.ts +1 -1
  79. package/src/core/metadata.ts +4 -76
  80. package/src/core/meter.ts +1 -1
  81. package/src/core/numberish.test.ts +1 -1
  82. package/src/core/numberish.ts +1 -1
  83. package/src/core/solana-processor.ts +1 -1
  84. package/src/core/sui-processor.ts +1 -1
  85. package/src/gen/index.ts +1 -0
  86. package/src/index.ts +4 -1
  87. package/src/processor-state.ts +3 -1
  88. package/src/service.ts +29 -29
  89. package/src/testing/metric-utils.ts +2 -2
  90. package/src/testing/test-processor-server.ts +5 -2
  91. package/src/testing/test-provider.ts +1 -1
  92. package/src/tests/aptos.test.ts +47 -11
  93. package/src/tests/souffl3.ts +30 -12
  94. package/src/utils/chain.ts +2 -0
  95. package/lib/core/aptos-processor.d.ts +0 -41
  96. package/lib/core/aptos-processor.js +0 -125
  97. package/lib/core/aptos-processor.js.map +0 -1
  98. package/src/core/aptos-processor.ts +0 -147
@@ -1,147 +0,0 @@
1
- import { AptosBindOptions } from './bind-options'
2
- import { AptosContext } from './context'
3
- import { ProcessResult } from '..'
4
- import Long from 'long'
5
-
6
- type IndexConfigure = {
7
- startSeqNumber: Long
8
- endSeqNumber?: Long
9
- }
10
-
11
- export interface AptosEventFilter {
12
- type: string
13
- }
14
- export interface AptosCallFilter {
15
- function: string
16
- typeArguments: string[] | undefined
17
- }
18
-
19
- export class AptosEventHandler {
20
- filters: AptosEventFilter[]
21
- handler: (event: any) => Promise<ProcessResult>
22
- }
23
-
24
- export class AptosCallHandler {
25
- filters: AptosCallFilter[]
26
- handler: (func: any) => Promise<ProcessResult>
27
- }
28
-
29
- export class AptosBaseProcessor {
30
- public transactionHanlder: (transaction: any, ctx: AptosContext) => void
31
- address: string
32
- name: string
33
- config: IndexConfigure = { startSeqNumber: new Long(0) }
34
- eventHandlers: AptosEventHandler[] = []
35
- callHandlers: AptosCallHandler[] = []
36
-
37
- constructor(options: AptosBindOptions) {
38
- if (options) {
39
- this.bind(options)
40
- }
41
- global.PROCESSOR_STATE.aptosProcessors.push(this)
42
- }
43
-
44
- bind(options: AptosBindOptions) {
45
- this.address = options.address
46
- this.name = options.name || this.address
47
- if (options.startBlock) {
48
- this.startSlot(options.startBlock)
49
- }
50
- if (options.endBlock) {
51
- this.endBlock(options.endBlock)
52
- }
53
- }
54
-
55
- public onTransaction(handler: (transaction: any, ctx: AptosContext) => void) {
56
- if (!this.isBind()) {
57
- throw new Error("Processor doesn't bind to an address")
58
- }
59
-
60
- this.transactionHanlder = handler
61
-
62
- return this
63
- }
64
-
65
- public onEvent(handler: (event: any, ctx: AptosContext) => void, filter: AptosEventFilter | AptosEventFilter[]) {
66
- let _filters: AptosEventFilter[] = []
67
-
68
- if (Array.isArray(filter)) {
69
- _filters = filter
70
- } else {
71
- _filters.push(filter)
72
- }
73
-
74
- this.eventHandlers.push({
75
- handler: async function (event) {
76
- const ctx = new AptosContext(this.address, event.slot)
77
- if (event) {
78
- handler(event, ctx)
79
- }
80
- return {
81
- gauges: ctx.gauges,
82
- counters: ctx.counters,
83
- logs: ctx.logs,
84
- }
85
- },
86
- filters: _filters,
87
- })
88
- }
89
-
90
- public onCall(handler: (func: any, ctx: AptosContext) => void, filter: AptosCallFilter | AptosCallFilter[]) {
91
- let _filters: AptosCallFilter[] = []
92
-
93
- if (Array.isArray(filter)) {
94
- _filters = filter
95
- } else {
96
- _filters.push(filter)
97
- }
98
-
99
- this.callHandlers.push({
100
- handler: async function (call) {
101
- const ctx = new AptosContext(this.address, call.slot)
102
- if (call) {
103
- handler(call, ctx)
104
- }
105
- return {
106
- gauges: ctx.gauges,
107
- counters: ctx.counters,
108
- logs: ctx.logs,
109
- }
110
- },
111
- filters: _filters,
112
- })
113
- }
114
-
115
- public handleTransaction(txn: any, slot: Long): ProcessResult | null {
116
- const ctx = new AptosContext(this.address, slot)
117
-
118
- if (txn) {
119
- this.transactionHanlder(txn, ctx)
120
- }
121
- return {
122
- gauges: ctx.gauges,
123
- counters: ctx.counters,
124
- logs: ctx.logs,
125
- }
126
- }
127
-
128
- public isBind() {
129
- return this.address !== null
130
- }
131
-
132
- public startSlot(startSlot: Long | number) {
133
- if (typeof startSlot === 'number') {
134
- startSlot = Long.fromNumber(startSlot)
135
- }
136
- this.config.startSeqNumber = startSlot
137
- return this
138
- }
139
-
140
- public endBlock(endBlock: Long | number) {
141
- if (typeof endBlock === 'number') {
142
- endBlock = Long.fromNumber(endBlock)
143
- }
144
- this.config.endSeqNumber = endBlock
145
- return this
146
- }
147
- }