@sentio/sdk 1.27.10 → 1.29.0

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 (109) hide show
  1. package/lib/aptos/api.d.ts +2 -0
  2. package/lib/aptos/api.js +14 -0
  3. package/lib/aptos/api.js.map +1 -0
  4. package/lib/aptos/aptos-processor.d.ts +5 -4
  5. package/lib/aptos/aptos-processor.js +8 -9
  6. package/lib/aptos/aptos-processor.js.map +1 -1
  7. package/lib/aptos/context.d.ts +3 -2
  8. package/lib/aptos/context.js +3 -3
  9. package/lib/aptos/context.js.map +1 -1
  10. package/lib/aptos/index.d.ts +3 -2
  11. package/lib/aptos/index.js +18 -3
  12. package/lib/aptos/index.js.map +1 -1
  13. package/lib/aptos/models.d.ts +23 -0
  14. package/lib/aptos/models.js +3 -0
  15. package/lib/aptos/models.js.map +1 -0
  16. package/lib/aptos/type-registry.d.ts +21 -0
  17. package/lib/aptos/type-registry.js +156 -0
  18. package/lib/aptos/type-registry.js.map +1 -0
  19. package/lib/aptos/types.d.ts +1 -33
  20. package/lib/aptos/types.js +49 -142
  21. package/lib/aptos/types.js.map +1 -1
  22. package/lib/aptos/types.test.js.map +1 -1
  23. package/lib/aptos/utils.d.ts +0 -2
  24. package/lib/aptos/utils.js +1 -8
  25. package/lib/aptos/utils.js.map +1 -1
  26. package/lib/aptos-codegen/codegen.js +2 -1
  27. package/lib/aptos-codegen/codegen.js.map +1 -1
  28. package/lib/aptos-codegen/typegen.d.ts +0 -1
  29. package/lib/aptos-codegen/typegen.js +3 -61
  30. package/lib/aptos-codegen/typegen.js.map +1 -1
  31. package/lib/cli/upload.js +2 -1
  32. package/lib/cli/upload.js.map +1 -1
  33. package/lib/core/base-context.d.ts +12 -0
  34. package/lib/core/base-context.js +25 -0
  35. package/lib/core/base-context.js.map +1 -0
  36. package/lib/core/base-processor.d.ts +1 -2
  37. package/lib/core/base-processor.js.map +1 -1
  38. package/lib/core/context.d.ts +2 -11
  39. package/lib/core/context.js +5 -24
  40. package/lib/core/context.js.map +1 -1
  41. package/lib/core/event-tracker.d.ts +1 -1
  42. package/lib/core/event-tracker.js +2 -2
  43. package/lib/core/event-tracker.js.map +1 -1
  44. package/lib/core/exporter.d.ts +1 -1
  45. package/lib/core/exporter.js.map +1 -1
  46. package/lib/core/generic-processor.test.js.map +1 -1
  47. package/lib/core/logger.d.ts +1 -1
  48. package/lib/core/logger.js.map +1 -1
  49. package/lib/core/meter.d.ts +1 -1
  50. package/lib/core/meter.js.map +1 -1
  51. package/lib/endpoints.d.ts +6 -0
  52. package/lib/endpoints.js +11 -0
  53. package/lib/endpoints.js.map +1 -0
  54. package/lib/gen/google/protobuf/timestamp.d.ts +18 -0
  55. package/lib/gen/google/protobuf/timestamp.js +75 -0
  56. package/lib/gen/google/protobuf/timestamp.js.map +1 -0
  57. package/lib/gen/service/price/protos/price.d.ts +85 -0
  58. package/lib/gen/service/price/protos/price.js +281 -0
  59. package/lib/gen/service/price/protos/price.js.map +1 -0
  60. package/lib/processor-runner.js +6 -0
  61. package/lib/processor-runner.js.map +1 -1
  62. package/lib/processor-state.d.ts +2 -6
  63. package/lib/processor-state.js +0 -2
  64. package/lib/processor-state.js.map +1 -1
  65. package/lib/provider.js +5 -5
  66. package/lib/provider.js.map +1 -1
  67. package/lib/testing/test-processor-server.d.ts +4 -1
  68. package/lib/testing/test-processor-server.js +15 -7
  69. package/lib/testing/test-processor-server.js.map +1 -1
  70. package/lib/utils/conversion.d.ts +2 -1
  71. package/lib/utils/conversion.js +3 -3
  72. package/lib/utils/conversion.js.map +1 -1
  73. package/lib/utils/dex-price.test.js.map +1 -1
  74. package/lib/utils/erc20.test.js.map +1 -1
  75. package/lib/utils/price.d.ts +10 -0
  76. package/lib/utils/price.js +59 -0
  77. package/lib/utils/price.js.map +1 -0
  78. package/lib/utils/token.d.ts +1 -1
  79. package/lib/utils/token.js +2 -2
  80. package/lib/utils/token.js.map +1 -1
  81. package/package.json +5 -2
  82. package/src/aptos/api.ts +11 -0
  83. package/src/aptos/aptos-processor.ts +7 -10
  84. package/src/aptos/context.ts +3 -3
  85. package/src/aptos/index.ts +3 -2
  86. package/src/aptos/models.ts +34 -0
  87. package/src/aptos/type-registry.ts +187 -0
  88. package/src/aptos/types.ts +53 -199
  89. package/src/aptos/utils.ts +0 -9
  90. package/src/aptos-codegen/codegen.ts +2 -1
  91. package/src/aptos-codegen/typegen.ts +1 -67
  92. package/src/cli/upload.ts +2 -1
  93. package/src/core/base-context.ts +28 -0
  94. package/src/core/base-processor.ts +1 -2
  95. package/src/core/context.ts +2 -26
  96. package/src/core/event-tracker.ts +2 -2
  97. package/src/core/exporter.ts +1 -1
  98. package/src/core/logger.ts +1 -1
  99. package/src/core/meter.ts +1 -1
  100. package/src/endpoints.ts +9 -0
  101. package/src/gen/google/protobuf/timestamp.ts +105 -0
  102. package/src/gen/service/price/protos/price.ts +394 -0
  103. package/src/processor-runner.ts +6 -0
  104. package/src/processor-state.ts +2 -7
  105. package/src/provider.ts +5 -5
  106. package/src/testing/test-processor-server.ts +10 -6
  107. package/src/utils/conversion.ts +2 -1
  108. package/src/utils/price.ts +58 -0
  109. package/src/utils/token.ts +1 -1
@@ -1,46 +1,4 @@
1
- import {
2
- Event,
3
- MoveFunction,
4
- MoveModule,
5
- MoveStruct,
6
- TransactionPayload_EntryFunctionPayload,
7
- MoveResource,
8
- } from 'aptos-sdk/src/generated'
9
- import { getMeaningfulFunctionParams, moduleQname, SPLITTER, VECTOR_STR } from './utils'
10
- import { parseMoveType } from '../aptos-codegen/typegen'
11
-
12
- export type EventInstance = Event & {
13
- version: string
14
- }
15
-
16
- export type TypedEventInstance<T> = EventInstance & {
17
- // Typed data converted from ABI
18
- // undefined if there is converting error, usually because the ABI/data
19
- // mismatch
20
- data_typed: T
21
-
22
- type_arguments: string[]
23
- }
24
-
25
- // Don't use intermedidate type to make IDE happier
26
- export type TypedEntryFunctionPayload<T extends Array<any>> = TransactionPayload_EntryFunctionPayload & {
27
- arguments_typed: T
28
- }
29
-
30
- export type TypedMoveResource<T> = MoveResource & {
31
- data_typed: T
32
- type_arguments: string[]
33
- }
34
-
35
- interface StructWithTag {
36
- type: string
37
- data: any
38
- }
39
-
40
- interface StructWithType<T> extends StructWithTag {
41
- data_typed: T
42
- type_arguments: string[]
43
- }
1
+ import { SPLITTER, VECTOR_STR } from './utils'
44
2
 
45
3
  export class TypeDescriptor {
46
4
  // type: string
@@ -124,172 +82,68 @@ export class TypeDescriptor {
124
82
  }
125
83
  }
126
84
 
127
- export class TypeRegistry {
128
- moduleMapping = new Map<string, MoveModule>()
129
- typeMapping = new Map<string, MoveStruct>()
130
- funcMapping = new Map<string, MoveFunction>()
131
-
132
- contains(account: string, name: string) {
133
- return this.moduleMapping.has(account + '::' + name)
134
- }
135
-
136
- load(module: MoveModule) {
137
- if (this.contains(module.address, module.name)) {
138
- return
139
- }
140
- this.moduleMapping.set(moduleQname(module), module)
141
-
142
- for (const struct of module.structs) {
143
- // TODO move to util
144
- const key = [module.address, module.name, struct.name].join(SPLITTER)
145
- this.typeMapping.set(key, struct)
146
- }
147
-
148
- for (const func of module.exposed_functions) {
149
- if (!func.is_entry) {
150
- continue
85
+ export function parseMoveType(type: string): TypeDescriptor {
86
+ // type = type.replace('&', '')
87
+
88
+ type = type.replaceAll('&mut ', '&')
89
+ type = type.replaceAll('mut ', '')
90
+
91
+ // TODO replace ' ' is not exactly safe, need to double check this
92
+ type = type.replaceAll(' ', '')
93
+
94
+ const stack: TypeDescriptor[] = [new TypeDescriptor('')]
95
+ let buffer = []
96
+
97
+ // xxx:asdf<g1<a,<c,d>>, b, g2<a,b>, e>
98
+ for (let i = 0; i < type.length; i++) {
99
+ const ch = type[i]
100
+ if (ch === '<') {
101
+ // const symbol = type.slice(symbolStart, i)
102
+ // symbolStart =
103
+ const symbol = buffer.join('')
104
+ buffer = []
105
+ stack[stack.length - 1].qname = symbol
106
+ stack.push(new TypeDescriptor(''))
107
+ continue
108
+ }
109
+ if (ch === '>') {
110
+ const typeParam = stack.pop()
111
+ if (!typeParam) {
112
+ throw Error('Uxpectecd stack size')
151
113
  }
152
- const key = [module.address, module.name, func.name].join(SPLITTER)
153
- this.funcMapping.set(key, func)
154
- }
155
- }
156
-
157
- getMoveStruct(type: string): MoveStruct {
158
- const struct = this.typeMapping.get(type)
159
- if (!struct) {
160
- throw new Error('Failed to load type' + type)
161
- }
162
- return struct
163
- }
164
-
165
- getMoveFunction(type: string): MoveFunction {
166
- const func = this.funcMapping.get(type)
167
- if (!func) {
168
- throw new Error('Failed to load function' + type)
169
- }
170
- return func
171
- }
172
-
173
- decode(data: any, type: TypeDescriptor): any {
174
- // process simple type
175
- if (type.qname.startsWith('&')) {
176
- return data
177
- }
178
- switch (type.qname) {
179
- case 'signer': // TODO check this
180
- case 'address':
181
- case '0x1::string::String':
182
- case 'bool':
183
- case 'u8':
184
- case 'u16':
185
- case 'u32':
186
- return data
187
- case 'u64':
188
- case 'u128':
189
- return BigInt(data)
114
+ if (buffer.length > 0) {
115
+ typeParam.qname = buffer.join('')
116
+ buffer = []
117
+ }
118
+ stack[stack.length - 1].typeArgs.push(typeParam)
119
+ continue
190
120
  }
191
-
192
- // process vector
193
- if (type.qname === VECTOR_STR) {
194
- // vector<u8> as hex string
195
- if (type.typeArgs[0].qname === 'u8') {
196
- return data
121
+ if (ch === ',') {
122
+ const typeParam = stack.pop()
123
+ if (!typeParam) {
124
+ throw Error('Uxpectecd stack size')
197
125
  }
198
-
199
- const res = []
200
- for (const entry of data) {
201
- res.push(this.decode(entry, type.typeArgs[0]))
126
+ if (buffer.length > 0) {
127
+ typeParam.qname = buffer.join('')
128
+ buffer = []
202
129
  }
203
- return res
204
- }
205
-
206
- // Process complex type
207
- const struct = this.getMoveStruct(type.qname)
208
-
209
- const typeCtx = new Map<string, TypeDescriptor>()
210
- for (const [idx, typeArg] of type.typeArgs.entries()) {
211
- typeCtx.set('T' + idx, typeArg)
212
- }
213
130
 
214
- const typedData: any = {}
215
-
216
- for (const field of struct.fields) {
217
- let filedType = parseMoveType(field.type)
218
- filedType = filedType.applyTypeArgs(typeCtx)
219
- const value = this.decode(data[field.name], filedType)
220
- typedData[field.name] = value
131
+ stack[stack.length - 1].typeArgs.push(typeParam)
132
+ // continue parse next param
133
+ stack.push(new TypeDescriptor(''))
134
+ continue
221
135
  }
222
- return typedData
223
- }
224
-
225
- decodeEvent<T>(event: Event): TypedEventInstance<T> | undefined {
226
- return this.decodedInternal<T>(event) as TypedEventInstance<T>
227
- }
228
- filterAndDecodeEvents<T>(typeQname: string, resources: Event[]): TypedEventInstance<T>[] {
229
- return this.filterAndDecodeInternal(typeQname, resources) as TypedEventInstance<T>[]
230
- }
231
- decodeResource<T>(res: MoveResource): TypedMoveResource<T> | undefined {
232
- return this.decodedInternal<T>(res)
233
- }
234
- filterAndDecodeResources<T>(typeQname: string, resources: MoveResource[]): TypedMoveResource<T>[] {
235
- return this.filterAndDecodeInternal(typeQname, resources)
236
- }
237
136
 
238
- private filterAndDecodeInternal<T>(typeQname: string, structs: StructWithTag[]): StructWithType<T>[] {
239
- if (!structs) {
240
- return []
241
- }
242
- const results: StructWithType<T>[] = []
243
- for (const resource of structs) {
244
- if (resource.type.split('<')[0] !== typeQname) {
245
- continue
246
- }
247
- const result = this.decodedInternal(resource)
248
- if (result) {
249
- results.push(result as StructWithType<T>)
250
- }
251
- }
252
- return results
137
+ buffer.push(ch)
253
138
  }
254
139
 
255
- private decodedInternal<T>(typeStruct: StructWithTag): StructWithType<T> | undefined {
256
- const registry = TYPE_REGISTRY
257
- // this.loadTypes(registry)
258
- // TODO check if module is not loaded
259
-
260
- const typeDescriptor = parseMoveType(typeStruct.type)
261
- const typeArguments = typeDescriptor.typeArgs.map((t) => t.getSignature())
262
-
263
- let dataTyped = undefined
264
- try {
265
- dataTyped = registry.decode(typeStruct.data, typeDescriptor)
266
- } catch (e) {
267
- console.error('Decoding error for ', JSON.stringify(typeStruct), e)
268
- return undefined
269
- }
270
- return { ...typeStruct, data_typed: dataTyped, type_arguments: typeArguments } as StructWithType<T>
140
+ if (buffer.length > 0) {
141
+ stack[stack.length - 1].qname = buffer.join('')
271
142
  }
272
143
 
273
- decodeFunctionPayload(payload: TransactionPayload_EntryFunctionPayload): TransactionPayload_EntryFunctionPayload {
274
- const registry = TYPE_REGISTRY
275
- // this.loadTypes(registry)
276
- const argumentsTyped: any[] = []
277
-
278
- try {
279
- const func = registry.getMoveFunction(payload.function)
280
- const params = getMeaningfulFunctionParams(func)
281
- for (const [idx, arg] of payload.arguments.entries()) {
282
- // TODO consider apply payload.type_arguments, but this might be hard since we don't code gen for them
283
- const argType = parseMoveType(params[idx])
284
- argumentsTyped.push(registry.decode(arg, argType))
285
- }
286
- } catch (e) {
287
- console.error('Decoding error for ', JSON.stringify(payload), e)
288
- return payload
289
- }
290
-
291
- return { ...payload, arguments_typed: argumentsTyped } as TypedEntryFunctionPayload<any>
144
+ const res = stack.pop()
145
+ if (!res || stack.length > 0) {
146
+ throw Error('Uxpectecd stack size')
292
147
  }
148
+ return res
293
149
  }
294
-
295
- export const TYPE_REGISTRY = new TypeRegistry()
@@ -1,8 +1,5 @@
1
1
  import { MoveFunction, MoveModule } from 'aptos-sdk/src/generated'
2
2
 
3
- import { createChannel, createClient } from 'nice-grpc'
4
- import { AptosQueryClient, AptosQueryDefinition } from '../gen/chainquery/protos/chainquery'
5
-
6
3
  export const SPLITTER = '::'
7
4
 
8
5
  export const VECTOR_STR = 'vector'
@@ -20,12 +17,6 @@ export function moduleQnameForType(type: string): [string, string] {
20
17
  return [parts[0], parts[1]]
21
18
  }
22
19
 
23
- export function getChainQueryClient(address = 'chainquery-server.chain-sync:6809'): AptosQueryClient {
24
- const channel = createChannel(address)
25
-
26
- return createClient(AptosQueryDefinition, channel)
27
- }
28
-
29
20
  export function getMeaningfulFunctionParams(func: MoveFunction): string[] {
30
21
  let params = func.params
31
22
  if (func.params[0] === '&signer') {
@@ -2,10 +2,11 @@ import fs from 'fs'
2
2
  import path from 'path'
3
3
  import prettier from 'prettier'
4
4
  import { MoveFunction, MoveModule, MoveModuleBytecode, MoveStruct } from 'aptos-sdk/src/generated'
5
- import { AccountModulesImportInfo, AccountRegister, generateType, parseMoveType } from './typegen'
5
+ import { AccountModulesImportInfo, AccountRegister, generateType } from './typegen'
6
6
  import { getMeaningfulFunctionParams, isFrameworkAccount, moduleQname, SPLITTER } from '../aptos/utils'
7
7
  import chalk from 'chalk'
8
8
  import { AptosNetwork, getChainName, getRpcClient } from '../aptos/network'
9
+ import { parseMoveType } from '../aptos/types'
9
10
 
10
11
  export async function generate(srcDir: string, outputDir: string) {
11
12
  await generateForNetwork(srcDir, outputDir, AptosNetwork.MAIN_NET)
@@ -1,5 +1,5 @@
1
1
  import { MoveModule } from 'aptos-sdk/src/generated'
2
- import { TypeDescriptor } from '../aptos/types'
2
+ import { parseMoveType, TypeDescriptor } from '../aptos/types'
3
3
  import { moduleQname, moduleQnameForType, SPLITTER, VECTOR_STR } from '../aptos/utils'
4
4
 
5
5
  function generateTypeForDescriptor(type: TypeDescriptor, currentAddress: string): string {
@@ -62,72 +62,6 @@ function generateSimpleType(type: string, currentAddress: string): string {
62
62
  return '_' + parts.join('.')
63
63
  }
64
64
 
65
- export function parseMoveType(type: string): TypeDescriptor {
66
- // type = type.replace('&', '')
67
-
68
- type = type.replaceAll('&mut ', '&')
69
- type = type.replaceAll('mut ', '')
70
-
71
- // TODO replace ' ' is not exactly safe, need to double check this
72
- type = type.replaceAll(' ', '')
73
-
74
- const stack: TypeDescriptor[] = [new TypeDescriptor('')]
75
- let buffer = []
76
-
77
- // xxx:asdf<g1<a,<c,d>>, b, g2<a,b>, e>
78
- for (let i = 0; i < type.length; i++) {
79
- const ch = type[i]
80
- if (ch === '<') {
81
- // const symbol = type.slice(symbolStart, i)
82
- // symbolStart =
83
- const symbol = buffer.join('')
84
- buffer = []
85
- stack[stack.length - 1].qname = symbol
86
- stack.push(new TypeDescriptor(''))
87
- continue
88
- }
89
- if (ch === '>') {
90
- const typeParam = stack.pop()
91
- if (!typeParam) {
92
- throw Error('Uxpectecd stack size')
93
- }
94
- if (buffer.length > 0) {
95
- typeParam.qname = buffer.join('')
96
- buffer = []
97
- }
98
- stack[stack.length - 1].typeArgs.push(typeParam)
99
- continue
100
- }
101
- if (ch === ',') {
102
- const typeParam = stack.pop()
103
- if (!typeParam) {
104
- throw Error('Uxpectecd stack size')
105
- }
106
- if (buffer.length > 0) {
107
- typeParam.qname = buffer.join('')
108
- buffer = []
109
- }
110
-
111
- stack[stack.length - 1].typeArgs.push(typeParam)
112
- // continue parse next param
113
- stack.push(new TypeDescriptor(''))
114
- continue
115
- }
116
-
117
- buffer.push(ch)
118
- }
119
-
120
- if (buffer.length > 0) {
121
- stack[stack.length - 1].qname = buffer.join('')
122
- }
123
-
124
- const res = stack.pop()
125
- if (!res || stack.length > 0) {
126
- throw Error('Uxpectecd stack size')
127
- }
128
- return res
129
- }
130
-
131
65
  // TODO ctx need to have type parameters
132
66
  export function generateType(type: string, currentAddress: string): string {
133
67
  return generateTypeForDescriptor(parseMoveType(type), currentAddress)
package/src/cli/upload.ts CHANGED
@@ -13,12 +13,13 @@ import { getCliVersion } from './utils'
13
13
 
14
14
  async function createProject(options: SentioProjectConfig, apiKey: string) {
15
15
  const url = new URL('/api/v1/projects', options.host)
16
+ const [ownerName, slug] = options.project.includes('/') ? options.project.split('/') : [undefined, options.project]
16
17
  return fetch(url, {
17
18
  method: 'POST',
18
19
  headers: {
19
20
  'api-key': apiKey,
20
21
  },
21
- body: JSON.stringify({ slug: options.project, visibility: 'PRIVATE' }),
22
+ body: JSON.stringify({ slug, ownerName, visibility: 'PRIVATE' }),
22
23
  })
23
24
  }
24
25
 
@@ -0,0 +1,28 @@
1
+ import { DataDescriptor, ProcessResult, RecordMetaData } from '../gen'
2
+ import { Logger } from './logger'
3
+ import { Labels } from './metadata'
4
+ import { Meter } from './meter'
5
+
6
+ export abstract class BaseContext {
7
+ meter: Meter
8
+ logger: Logger
9
+
10
+ res: ProcessResult = {
11
+ counters: [],
12
+ events: [],
13
+ exports: [],
14
+ gauges: [],
15
+ logs: [],
16
+ }
17
+
18
+ protected constructor() {
19
+ this.meter = new Meter(this)
20
+ this.logger = new Logger(this)
21
+ }
22
+
23
+ getProcessResult(): ProcessResult {
24
+ return this.res
25
+ }
26
+
27
+ abstract getMetaData(descriptor: DataDescriptor, labels: Labels): RecordMetaData
28
+ }
@@ -1,7 +1,6 @@
1
- import { Event } from '@ethersproject/contracts'
2
1
  import { BytesLike } from '@ethersproject/bytes'
3
2
  import { Block, Log, getNetwork } from '@ethersproject/providers'
4
- import { BaseContract, EventFilter } from '@ethersproject/contracts'
3
+ import { BaseContract, Event, EventFilter } from '@ethersproject/contracts'
5
4
  import Long from 'long'
6
5
 
7
6
  import { BoundContractView, ContractContext, ContractView } from './context'
@@ -1,36 +1,12 @@
1
1
  import { DataDescriptor, RecordMetaData, ProcessResult } from '../gen'
2
2
  import { BaseContract, EventFilter } from 'ethers'
3
3
  import { Block, Log } from '@ethersproject/abstract-provider'
4
- import { Meter, normalizeLabels } from './meter'
4
+ import { normalizeLabels } from './meter'
5
5
  import Long from 'long'
6
6
  import { Trace } from './trace'
7
- import { Logger } from './logger'
8
7
  import { Labels } from './metadata'
9
8
  import { SOL_MAINMET_ID, SUI_DEVNET_ID } from '../utils/chain'
10
-
11
- export abstract class BaseContext {
12
- meter: Meter
13
- logger: Logger
14
-
15
- res: ProcessResult = {
16
- counters: [],
17
- events: [],
18
- exports: [],
19
- gauges: [],
20
- logs: [],
21
- }
22
-
23
- protected constructor() {
24
- this.meter = new Meter(this)
25
- this.logger = new Logger(this)
26
- }
27
-
28
- getProcessResult(): ProcessResult {
29
- return this.res
30
- }
31
-
32
- abstract getMetaData(descriptor: DataDescriptor, labels: Labels): RecordMetaData
33
- }
9
+ import { BaseContext } from './base-context'
34
10
 
35
11
  export abstract class EthContext extends BaseContext {
36
12
  chainId: number
@@ -1,5 +1,5 @@
1
- import { BaseContext } from './context'
2
- import { DataDescriptor, EventTrackingResult } from '@sentio/sdk'
1
+ import { BaseContext } from './base-context'
2
+ import { DataDescriptor, EventTrackingResult } from '../gen'
3
3
 
4
4
  export interface Event {
5
5
  // The unique identifier of main identity associate with an event
@@ -1,4 +1,4 @@
1
- import { BaseContext } from './context'
1
+ import { BaseContext } from './base-context'
2
2
  import { DataDescriptor, ExportResult } from '@sentio/sdk'
3
3
 
4
4
  export type Export = Record<string, any>
@@ -1,4 +1,4 @@
1
- import { BaseContext } from './context'
1
+ import { BaseContext } from './base-context'
2
2
  import { DataDescriptor, LogLevel } from '../gen'
3
3
  import { DescriptorWithUsage } from './metadata'
4
4
 
package/src/core/meter.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BaseContext } from './context'
1
+ import { BaseContext } from './base-context'
2
2
  import { toMetricValue, Numberish } from './numberish'
3
3
  import { DescriptorWithUsage, Labels } from './metadata'
4
4
  import { DataDescriptor } from '../gen'
@@ -0,0 +1,9 @@
1
+ import { Provider } from '@ethersproject/providers'
2
+
3
+ export class Endpoints {
4
+ // evm providers
5
+ providers = new Map<number, Provider>()
6
+
7
+ chainQueryAPI = ''
8
+ priceFeedAPI = ''
9
+ }
@@ -0,0 +1,105 @@
1
+ /* eslint-disable */
2
+ import Long from "long";
3
+ import _m0 from "protobufjs/minimal";
4
+
5
+ export interface Timestamp {
6
+ seconds: Long;
7
+ nanos: number;
8
+ }
9
+
10
+ function createBaseTimestamp(): Timestamp {
11
+ return { seconds: Long.ZERO, nanos: 0 };
12
+ }
13
+
14
+ export const Timestamp = {
15
+ encode(
16
+ message: Timestamp,
17
+ writer: _m0.Writer = _m0.Writer.create()
18
+ ): _m0.Writer {
19
+ if (!message.seconds.isZero()) {
20
+ writer.uint32(8).int64(message.seconds);
21
+ }
22
+ if (message.nanos !== 0) {
23
+ writer.uint32(16).int32(message.nanos);
24
+ }
25
+ return writer;
26
+ },
27
+
28
+ decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp {
29
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
30
+ let end = length === undefined ? reader.len : reader.pos + length;
31
+ const message = createBaseTimestamp();
32
+ while (reader.pos < end) {
33
+ const tag = reader.uint32();
34
+ switch (tag >>> 3) {
35
+ case 1:
36
+ message.seconds = reader.int64() as Long;
37
+ break;
38
+ case 2:
39
+ message.nanos = reader.int32();
40
+ break;
41
+ default:
42
+ reader.skipType(tag & 7);
43
+ break;
44
+ }
45
+ }
46
+ return message;
47
+ },
48
+
49
+ fromJSON(object: any): Timestamp {
50
+ return {
51
+ seconds: isSet(object.seconds)
52
+ ? Long.fromValue(object.seconds)
53
+ : Long.ZERO,
54
+ nanos: isSet(object.nanos) ? Number(object.nanos) : 0,
55
+ };
56
+ },
57
+
58
+ toJSON(message: Timestamp): unknown {
59
+ const obj: any = {};
60
+ message.seconds !== undefined &&
61
+ (obj.seconds = (message.seconds || Long.ZERO).toString());
62
+ message.nanos !== undefined && (obj.nanos = Math.round(message.nanos));
63
+ return obj;
64
+ },
65
+
66
+ fromPartial(object: DeepPartial<Timestamp>): Timestamp {
67
+ const message = createBaseTimestamp();
68
+ message.seconds =
69
+ object.seconds !== undefined && object.seconds !== null
70
+ ? Long.fromValue(object.seconds)
71
+ : Long.ZERO;
72
+ message.nanos = object.nanos ?? 0;
73
+ return message;
74
+ },
75
+ };
76
+
77
+ type Builtin =
78
+ | Date
79
+ | Function
80
+ | Uint8Array
81
+ | string
82
+ | number
83
+ | boolean
84
+ | undefined;
85
+
86
+ type DeepPartial<T> = T extends Builtin
87
+ ? T
88
+ : T extends Long
89
+ ? string | number | Long
90
+ : T extends Array<infer U>
91
+ ? Array<DeepPartial<U>>
92
+ : T extends ReadonlyArray<infer U>
93
+ ? ReadonlyArray<DeepPartial<U>>
94
+ : T extends {}
95
+ ? { [K in keyof T]?: DeepPartial<T[K]> }
96
+ : Partial<T>;
97
+
98
+ if (_m0.util.Long !== Long) {
99
+ _m0.util.Long = Long as any;
100
+ _m0.configure();
101
+ }
102
+
103
+ function isSet(value: any): boolean {
104
+ return value !== null && value !== undefined;
105
+ }