@sentio/sdk 1.36.4 → 1.37.0-rc.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.
Files changed (192) hide show
  1. package/lib/aptos/api.d.ts +1 -1
  2. package/lib/aptos/api.js +1 -1
  3. package/lib/aptos/api.js.map +1 -1
  4. package/lib/aptos/aptos-plugin.d.ts +2 -2
  5. package/lib/aptos/aptos-plugin.js +14 -19
  6. package/lib/aptos/aptos-plugin.js.map +1 -1
  7. package/lib/aptos/aptos-processor.d.ts +2 -2
  8. package/lib/aptos/aptos-processor.js +3 -3
  9. package/lib/aptos/aptos-processor.js.map +1 -1
  10. package/lib/aptos/context.d.ts +1 -1
  11. package/lib/aptos/context.js +2 -6
  12. package/lib/aptos/context.js.map +1 -1
  13. package/lib/binds.d.ts +1 -1
  14. package/lib/binds.js +2 -2
  15. package/lib/binds.js.map +1 -1
  16. package/lib/builtin/internal/eacaggregatorproxy_processor.js +18 -18
  17. package/lib/builtin/internal/eacaggregatorproxy_processor.js.map +1 -1
  18. package/lib/builtin/internal/erc1155_processor.js +5 -5
  19. package/lib/builtin/internal/erc1155_processor.js.map +1 -1
  20. package/lib/builtin/internal/erc20_processor.js +8 -8
  21. package/lib/builtin/internal/erc20_processor.js.map +1 -1
  22. package/lib/builtin/internal/erc20bytes_processor.js +6 -6
  23. package/lib/builtin/internal/erc20bytes_processor.js.map +1 -1
  24. package/lib/builtin/internal/erc721_processor.js +9 -9
  25. package/lib/builtin/internal/erc721_processor.js.map +1 -1
  26. package/lib/builtin/internal/weth9_processor.js +6 -6
  27. package/lib/builtin/internal/weth9_processor.js.map +1 -1
  28. package/lib/core/account-processor.d.ts +1 -1
  29. package/lib/core/account-processor.js +2 -2
  30. package/lib/core/account-processor.js.map +1 -1
  31. package/lib/core/base-context.d.ts +1 -1
  32. package/lib/core/base-context.js.map +1 -1
  33. package/lib/core/base-processor-template.d.ts +2 -2
  34. package/lib/core/base-processor-template.js +7 -21
  35. package/lib/core/base-processor-template.js.map +1 -1
  36. package/lib/core/base-processor.d.ts +1 -1
  37. package/lib/core/base-processor.js +6 -20
  38. package/lib/core/base-processor.js.map +1 -1
  39. package/lib/core/bind-options.d.ts +5 -6
  40. package/lib/core/bind-options.js.map +1 -1
  41. package/lib/core/context.d.ts +4 -5
  42. package/lib/core/context.js +6 -10
  43. package/lib/core/context.js.map +1 -1
  44. package/lib/core/eth-plugin.d.ts +2 -2
  45. package/lib/core/eth-plugin.js +8 -12
  46. package/lib/core/eth-plugin.js.map +1 -1
  47. package/lib/core/event-tracker.d.ts +1 -1
  48. package/lib/core/event-tracker.js +2 -2
  49. package/lib/core/event-tracker.js.map +1 -1
  50. package/lib/core/exporter.d.ts +1 -1
  51. package/lib/core/exporter.js +2 -2
  52. package/lib/core/exporter.js.map +1 -1
  53. package/lib/core/generic-processor.test.js.map +1 -1
  54. package/lib/core/index.d.ts +1 -1
  55. package/lib/core/index.js +2 -1
  56. package/lib/core/index.js.map +1 -1
  57. package/lib/core/logger.d.ts +1 -1
  58. package/lib/core/logger.js +5 -5
  59. package/lib/core/logger.js.map +1 -1
  60. package/lib/core/meter.d.ts +2 -2
  61. package/lib/core/meter.js +10 -10
  62. package/lib/core/meter.js.map +1 -1
  63. package/lib/core/numberish.d.ts +3 -3
  64. package/lib/core/numberish.js +18 -12
  65. package/lib/core/numberish.js.map +1 -1
  66. package/lib/core/numberish.test.js.map +1 -1
  67. package/lib/core/solana-context.d.ts +2 -3
  68. package/lib/core/solana-context.js.map +1 -1
  69. package/lib/core/solana-options.d.ts +2 -3
  70. package/lib/core/solana-options.js.map +1 -1
  71. package/lib/core/solana-plugin.d.ts +2 -2
  72. package/lib/core/solana-plugin.js +6 -6
  73. package/lib/core/solana-plugin.js.map +1 -1
  74. package/lib/core/solana-processor.d.ts +7 -8
  75. package/lib/core/solana-processor.js +5 -15
  76. package/lib/core/solana-processor.js.map +1 -1
  77. package/lib/core/sui-plugin.d.ts +2 -2
  78. package/lib/core/sui-plugin.js +5 -5
  79. package/lib/core/sui-plugin.js.map +1 -1
  80. package/lib/core/sui-processor.d.ts +8 -9
  81. package/lib/core/sui-processor.js +5 -15
  82. package/lib/core/sui-processor.js.map +1 -1
  83. package/lib/index.d.ts +2 -3
  84. package/lib/index.js +3 -5
  85. package/lib/index.js.map +1 -1
  86. package/lib/processor-runner.js +4 -4
  87. package/lib/processor-runner.js.map +1 -1
  88. package/lib/service.d.ts +3 -4
  89. package/lib/service.js +7 -11
  90. package/lib/service.js.map +1 -1
  91. package/lib/target-ethers-sentio/file.js +1 -0
  92. package/lib/target-ethers-sentio/file.js.map +1 -1
  93. package/lib/target-ethers-sentio/view-function.js +1 -1
  94. package/lib/testing/metric-utils.d.ts +1 -1
  95. package/lib/testing/metric-utils.js.map +1 -1
  96. package/lib/testing/test-processor-server.d.ts +3 -3
  97. package/lib/testing/test-processor-server.js +10 -22
  98. package/lib/testing/test-processor-server.js.map +1 -1
  99. package/lib/utils/conversion.d.ts +1 -1
  100. package/lib/utils/conversion.js.map +1 -1
  101. package/lib/utils/dex-price.test.js.map +1 -1
  102. package/lib/utils/erc20.test.js.map +1 -1
  103. package/lib/utils/price.d.ts +10 -10
  104. package/lib/utils/price.js +1 -1
  105. package/lib/utils/price.js.map +1 -1
  106. package/package.json +4 -2
  107. package/src/aptos/api.ts +1 -1
  108. package/src/aptos/aptos-plugin.ts +10 -11
  109. package/src/aptos/aptos-processor.ts +2 -2
  110. package/src/aptos/context.ts +3 -4
  111. package/src/binds.ts +1 -1
  112. package/src/builtin/internal/eacaggregatorproxy_processor.ts +19 -18
  113. package/src/builtin/internal/erc1155_processor.ts +6 -5
  114. package/src/builtin/internal/erc20_processor.ts +9 -8
  115. package/src/builtin/internal/erc20bytes_processor.ts +7 -6
  116. package/src/builtin/internal/erc721_processor.ts +10 -9
  117. package/src/builtin/internal/weth9_processor.ts +7 -6
  118. package/src/core/account-processor.ts +1 -1
  119. package/src/core/base-context.ts +1 -1
  120. package/src/core/base-processor-template.ts +6 -15
  121. package/src/core/base-processor.ts +4 -13
  122. package/src/core/bind-options.ts +5 -6
  123. package/src/core/context.ts +10 -11
  124. package/src/core/eth-plugin.ts +3 -4
  125. package/src/core/event-tracker.ts +2 -2
  126. package/src/core/exporter.ts +1 -1
  127. package/src/core/index.ts +1 -1
  128. package/src/core/logger.ts +1 -1
  129. package/src/core/meter.ts +2 -2
  130. package/src/core/numberish.ts +12 -6
  131. package/src/core/solana-context.ts +2 -3
  132. package/src/core/solana-options.ts +2 -4
  133. package/src/core/solana-plugin.ts +3 -3
  134. package/src/core/solana-processor.ts +10 -17
  135. package/src/core/sui-plugin.ts +3 -8
  136. package/src/core/sui-processor.ts +11 -18
  137. package/src/index.ts +3 -5
  138. package/src/processor-runner.ts +3 -3
  139. package/src/service.ts +5 -5
  140. package/src/target-ethers-sentio/file.ts +1 -0
  141. package/src/target-ethers-sentio/view-function.ts +1 -1
  142. package/src/testing/metric-utils.ts +1 -1
  143. package/src/testing/test-processor-server.ts +6 -16
  144. package/src/types/global.d.ts +2 -2
  145. package/src/utils/conversion.ts +1 -1
  146. package/src/utils/price.ts +1 -1
  147. package/lib/gen/builtin.d.ts +0 -6
  148. package/lib/gen/builtin.js +0 -3
  149. package/lib/gen/builtin.js.map +0 -1
  150. package/lib/gen/chainquery/protos/chainquery.d.ts +0 -400
  151. package/lib/gen/chainquery/protos/chainquery.js +0 -972
  152. package/lib/gen/chainquery/protos/chainquery.js.map +0 -1
  153. package/lib/gen/google/protobuf/empty.d.ts +0 -16
  154. package/lib/gen/google/protobuf/empty.js +0 -47
  155. package/lib/gen/google/protobuf/empty.js.map +0 -1
  156. package/lib/gen/google/protobuf/struct.d.ts +0 -73
  157. package/lib/gen/google/protobuf/struct.js +0 -371
  158. package/lib/gen/google/protobuf/struct.js.map +0 -1
  159. package/lib/gen/google/protobuf/timestamp.d.ts +0 -18
  160. package/lib/gen/google/protobuf/timestamp.js +0 -71
  161. package/lib/gen/google/protobuf/timestamp.js.map +0 -1
  162. package/lib/gen/index.d.ts +0 -2
  163. package/lib/gen/index.js +0 -19
  164. package/lib/gen/index.js.map +0 -1
  165. package/lib/gen/processor/protos/processor.d.ts +0 -826
  166. package/lib/gen/processor/protos/processor.js +0 -3988
  167. package/lib/gen/processor/protos/processor.js.map +0 -1
  168. package/lib/gen/service/price/protos/price.d.ts +0 -85
  169. package/lib/gen/service/price/protos/price.js +0 -269
  170. package/lib/gen/service/price/protos/price.js.map +0 -1
  171. package/lib/plugin.d.ts +0 -15
  172. package/lib/plugin.js +0 -32
  173. package/lib/plugin.js.map +0 -1
  174. package/lib/state/processor-state.d.ts +0 -3
  175. package/lib/state/processor-state.js +0 -8
  176. package/lib/state/processor-state.js.map +0 -1
  177. package/lib/state/state-storage.d.ts +0 -17
  178. package/lib/state/state-storage.js +0 -60
  179. package/lib/state/state-storage.js.map +0 -1
  180. package/lib/state/state-storage.test.d.ts +0 -1
  181. package/lib/state/state-storage.test.js.map +0 -1
  182. package/src/gen/builtin.ts +0 -22
  183. package/src/gen/chainquery/protos/chainquery.ts +0 -1212
  184. package/src/gen/google/protobuf/empty.ts +0 -58
  185. package/src/gen/google/protobuf/struct.ts +0 -422
  186. package/src/gen/google/protobuf/timestamp.ts +0 -85
  187. package/src/gen/index.ts +0 -3
  188. package/src/gen/processor/protos/processor.ts +0 -4619
  189. package/src/gen/service/price/protos/price.ts +0 -329
  190. package/src/plugin.ts +0 -41
  191. package/src/state/processor-state.ts +0 -3
  192. package/src/state/state-storage.ts +0 -65
@@ -1,8 +1,7 @@
1
- import { RecordMetaData, ProcessResult } from '../gen'
1
+ import { RecordMetaData } from '@sentio/protos'
2
2
  import { BaseContract, EventFilter } from 'ethers'
3
3
  import { Block, Log } from '@ethersproject/abstract-provider'
4
4
  import { normalizeLabels } from './meter'
5
- import Long from 'long'
6
5
  import { Trace } from './trace'
7
6
  import { Labels } from './metadata'
8
7
  import { CHAIN_IDS } from '../utils/chain'
@@ -14,7 +13,7 @@ export abstract class EthContext extends BaseContext {
14
13
  log?: Log
15
14
  block?: Block
16
15
  trace?: Trace
17
- blockNumber: Long
16
+ blockNumber: bigint | number
18
17
  transactionHash?: string
19
18
 
20
19
  protected constructor(chainId: number, address: string, block?: Block, log?: Log, trace?: Trace) {
@@ -25,12 +24,12 @@ export abstract class EthContext extends BaseContext {
25
24
  this.trace = trace
26
25
  this.address = address
27
26
  if (log) {
28
- this.blockNumber = Long.fromNumber(log.blockNumber, true)
27
+ this.blockNumber = log.blockNumber
29
28
  this.transactionHash = log.transactionHash
30
29
  } else if (block) {
31
- this.blockNumber = Long.fromNumber(block.number, true)
30
+ this.blockNumber = block.number
32
31
  } else if (trace) {
33
- this.blockNumber = Long.fromNumber(trace.blockNumber, true)
32
+ this.blockNumber = trace.blockNumber
34
33
  this.transactionHash = trace.transactionHash
35
34
  }
36
35
  }
@@ -42,7 +41,7 @@ export abstract class EthContext extends BaseContext {
42
41
  return {
43
42
  address: this.address,
44
43
  contractName: this.getContractName(),
45
- blockNumber: this.blockNumber,
44
+ blockNumber: BigInt(this.blockNumber),
46
45
  transactionIndex: this.log.transactionIndex,
47
46
  transactionHash: this.transactionHash || '',
48
47
  logIndex: this.log.logIndex,
@@ -55,7 +54,7 @@ export abstract class EthContext extends BaseContext {
55
54
  return {
56
55
  address: this.address,
57
56
  contractName: this.getContractName(),
58
- blockNumber: this.blockNumber,
57
+ blockNumber: BigInt(this.blockNumber),
59
58
  transactionIndex: -1,
60
59
  transactionHash: '',
61
60
  logIndex: -1,
@@ -68,7 +67,7 @@ export abstract class EthContext extends BaseContext {
68
67
  return {
69
68
  address: this.address,
70
69
  contractName: this.getContractName(),
71
- blockNumber: this.blockNumber,
70
+ blockNumber: BigInt(this.blockNumber),
72
71
  transactionIndex: this.trace.transactionPosition,
73
72
  transactionHash: this.transactionHash || '',
74
73
  logIndex: -1,
@@ -159,9 +158,9 @@ export class BoundContractView<TContract extends BaseContract, TContractView ext
159
158
  export class SuiContext extends BaseContext {
160
159
  address: string
161
160
  moduleName: string
162
- blockNumber: Long
161
+ blockNumber: bigint
163
162
 
164
- constructor(address: string, slot: Long) {
163
+ constructor(address: string, slot: bigint) {
165
164
  super()
166
165
  this.address = address
167
166
  this.blockNumber = slot
@@ -1,4 +1,4 @@
1
- import { Plugin, PluginManager } from '../plugin'
1
+ import { Plugin, PluginManager } from '@sentio/base'
2
2
  import {
3
3
  AccountConfig,
4
4
  ContractConfig,
@@ -8,7 +8,7 @@ import {
8
8
  LogHandlerConfig,
9
9
  ProcessConfigResponse,
10
10
  ProcessResult,
11
- } from '../gen/processor/protos/processor'
11
+ } from '@sentio/protos'
12
12
  import { DEFAULT_MAX_BLOCK, errorString, mergeProcessResults, USER_PROCESSOR, Utf8ArrayToStr } from '../service'
13
13
 
14
14
  import { ServerError, Status } from 'nice-grpc'
@@ -16,7 +16,6 @@ import { Block, Log } from '@ethersproject/abstract-provider'
16
16
  import { Trace } from '@sentio/sdk'
17
17
  import { ProcessorState } from '../binds'
18
18
  import { AccountProcessorState } from './account-processor'
19
- import Long from 'long'
20
19
 
21
20
  export class EthPlugin implements Plugin {
22
21
  name: string = 'EthPlugin'
@@ -118,7 +117,7 @@ export class EthPlugin implements Plugin {
118
117
  const accountConfig: AccountConfig = {
119
118
  address: processor.config.address,
120
119
  chainId: processor.getChainId().toString(),
121
- startBlock: processor.config.startBlock ? Long.fromValue(processor.config.startBlock) : Long.ZERO,
120
+ startBlock: processor.config.startBlock ? BigInt(processor.config.startBlock) : 0n,
122
121
  aptosIntervalConfigs: [],
123
122
  intervalConfigs: [],
124
123
  logConfigs: [],
@@ -1,7 +1,7 @@
1
1
  import { BaseContext } from './base-context'
2
- import { EventTrackingResult } from '../gen'
2
+ import { EventTrackingResult } from '@sentio/protos'
3
3
  import { NamedResultDescriptor } from './metadata'
4
- import { MapStateStorage } from '../state/state-storage'
4
+ import { MapStateStorage } from '@sentio/base'
5
5
 
6
6
  export interface Event {
7
7
  // The unique identifier of main identity associate with an event
@@ -1,7 +1,7 @@
1
1
  import { BaseContext } from './base-context'
2
2
  import { ExportResult } from '@sentio/sdk'
3
3
  import { NamedResultDescriptor } from './metadata'
4
- import { MapStateStorage } from '../state/state-storage'
4
+ import { MapStateStorage } from '@sentio/base'
5
5
 
6
6
  export type Export = Record<string, any>
7
7
 
package/src/core/index.ts CHANGED
@@ -2,7 +2,7 @@ export { BigDecimal } from './big-decimal'
2
2
  export { ContractContext, ContractView, BoundContractView } from './context'
3
3
  export { CounterBinding, Meter, GaugeBinding, Counter, Gauge, MetricOptions } from './meter'
4
4
  export { EventTracker, AccountEventTracker } from './event-tracker'
5
- export { type Numberish, toBigInteger, toMetricValue } from './numberish'
5
+ export { type Numberish, toBigInteger, toMetricValue, toBlockTag } from './numberish'
6
6
 
7
7
  export { BindOptions } from './bind-options'
8
8
 
@@ -1,5 +1,5 @@
1
1
  import { BaseContext } from './base-context'
2
- import { LogLevel } from '../gen'
2
+ import { LogLevel } from '@sentio/protos'
3
3
  import { NamedResultDescriptor } from './metadata'
4
4
 
5
5
  export type Attributes = Record<string, any>
package/src/core/meter.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { BaseContext } from './base-context'
2
2
  import { Numberish, toMetricValue } from './numberish'
3
3
  import { Labels, NamedResultDescriptor } from './metadata'
4
- import { AggregationConfig, AggregationType, MetricConfig, MetricType } from '../gen'
5
- import { MapStateStorage } from '../state/state-storage'
4
+ import { AggregationConfig, AggregationType, MetricConfig, MetricType } from '@sentio/protos'
5
+ import { MapStateStorage } from '@sentio/base'
6
6
 
7
7
  export function normalizeName(name: string): string {
8
8
  const regex = new RegExp('![_.a-zA-Z0-9]')
@@ -1,11 +1,21 @@
1
1
  import { BigNumber } from 'ethers'
2
- import { BigInteger, MetricValue } from '../gen'
2
+ import { BigInteger, MetricValue } from '@sentio/protos'
3
3
  import { BigDecimal } from '.'
4
4
  import { BN } from '@project-serum/anchor'
5
- import Long from 'long'
5
+ import { BlockTag } from '@ethersproject/providers'
6
6
 
7
7
  export type Numberish = number | BigNumber | bigint | BigDecimal
8
8
 
9
+ export function toBlockTag(a: number | bigint): BlockTag {
10
+ if (typeof a === 'number') {
11
+ return a
12
+ }
13
+ if (a > Number.MAX_SAFE_INTEGER) {
14
+ return '0x' + a.toString(16)
15
+ }
16
+ return Number(a)
17
+ }
18
+
9
19
  export function toMetricValue(value: Numberish): MetricValue {
10
20
  if (value instanceof BigNumber) {
11
21
  return MetricValue.fromPartial({
@@ -115,7 +125,3 @@ function hexToBigInteger(hex: string, negative: boolean): BigInteger {
115
125
  data: new Uint8Array(buffer),
116
126
  }
117
127
  }
118
-
119
- export function toBigInt(v: Long): bigint {
120
- return BigInt(v.toString())
121
- }
@@ -1,5 +1,4 @@
1
1
  import { BaseContext } from './base-context'
2
- import Long from 'long'
3
2
  import { Labels } from './metadata'
4
3
  import { RecordMetaData } from '@sentio/sdk'
5
4
  import { CHAIN_IDS } from '../utils/chain'
@@ -9,9 +8,9 @@ export class SolanaContext extends BaseContext {
9
8
  network: string
10
9
  address: string
11
10
  programName: string
12
- blockNumber: Long
11
+ blockNumber: bigint
13
12
 
14
- constructor(programName: string, network: string, address: string, slot: Long) {
13
+ constructor(programName: string, network: string, address: string, slot: bigint) {
15
14
  super()
16
15
  this.network = network || CHAIN_IDS.SOLANA_MAINNET
17
16
  this.programName = programName
@@ -1,10 +1,8 @@
1
- import Long from 'long'
2
-
3
1
  export class SolanaBindOptions {
4
2
  address: string
5
3
  network?: string
6
4
  name?: string
7
- startBlock?: Long | number
8
- endBlock?: Long | number
5
+ startBlock?: bigint | number
6
+ endBlock?: bigint | number
9
7
  processInnerInstruction?: boolean
10
8
  }
@@ -1,4 +1,4 @@
1
- import { Plugin, PluginManager } from '../plugin'
1
+ import { Plugin, PluginManager } from '@sentio/base'
2
2
  import {
3
3
  ContractConfig,
4
4
  Data_SolInstruction,
@@ -6,8 +6,8 @@ import {
6
6
  HandlerType,
7
7
  ProcessConfigResponse,
8
8
  ProcessResult,
9
- } from '../gen/processor/protos/processor'
10
- import { DEFAULT_MAX_BLOCK, errorString, mergeProcessResults, USER_PROCESSOR, Utf8ArrayToStr } from '../service'
9
+ } from '@sentio/protos'
10
+ import { DEFAULT_MAX_BLOCK, mergeProcessResults, USER_PROCESSOR } from '../service'
11
11
 
12
12
  import { ServerError, Status } from 'nice-grpc'
13
13
 
@@ -1,14 +1,13 @@
1
- import { ProcessResult } from '../gen'
1
+ import { ProcessResult } from '@sentio/protos'
2
2
  import { SolanaContext } from './solana-context'
3
- import Long from 'long'
4
3
  import { Instruction } from '@project-serum/anchor'
5
4
  import { SolanaBindOptions } from './solana-options'
6
- import { ListStateStorage } from '../state/state-storage'
5
+ import { ListStateStorage } from '@sentio/base'
7
6
  import { CHAIN_IDS } from '../utils/chain'
8
7
 
9
8
  type IndexConfigure = {
10
- startSlot: Long
11
- endSlot?: Long
9
+ startSlot: bigint
10
+ endSlot?: bigint
12
11
  }
13
12
 
14
13
  export type SolanaInstructionHandler = (instruction: Instruction, ctx: SolanaContext, accounts?: string[]) => void
@@ -24,7 +23,7 @@ export class SolanaBaseProcessor {
24
23
  contractName: string
25
24
  network: string
26
25
  processInnerInstruction: boolean
27
- config: IndexConfigure = { startSlot: new Long(0) }
26
+ config: IndexConfigure = { startSlot: 0n }
28
27
  decodeInstruction: (rawInstruction: string) => Instruction | null
29
28
  fromParsedInstruction: (instruction: { type: string; info: any }) => Instruction | null
30
29
 
@@ -80,7 +79,7 @@ export class SolanaBaseProcessor {
80
79
  parsedInstruction: Instruction,
81
80
  accounts: string[],
82
81
  handler: SolanaInstructionHandler,
83
- slot: Long
82
+ slot: bigint
84
83
  ): ProcessResult {
85
84
  const ctx = new SolanaContext(this.contractName, this.network, this.address, slot)
86
85
  handler(parsedInstruction, ctx, accounts)
@@ -91,19 +90,13 @@ export class SolanaBaseProcessor {
91
90
  return this.address !== null
92
91
  }
93
92
 
94
- public startSlot(startSlot: Long | number) {
95
- if (typeof startSlot === 'number') {
96
- startSlot = Long.fromNumber(startSlot)
97
- }
98
- this.config.startSlot = startSlot
93
+ public startSlot(startSlot: bigint | number) {
94
+ this.config.startSlot = BigInt(startSlot)
99
95
  return this
100
96
  }
101
97
 
102
- public endBlock(endBlock: Long | number) {
103
- if (typeof endBlock === 'number') {
104
- endBlock = Long.fromNumber(endBlock)
105
- }
106
- this.config.endSlot = endBlock
98
+ public endBlock(endBlock: bigint | number) {
99
+ this.config.endSlot = BigInt(endBlock)
107
100
  return this
108
101
  }
109
102
  }
@@ -1,11 +1,6 @@
1
- import { Plugin, PluginManager } from '../plugin'
2
- import {
3
- ContractConfig,
4
- DataBinding,
5
- HandlerType,
6
- ProcessConfigResponse,
7
- ProcessResult,
8
- } from '../gen/processor/protos/processor'
1
+ import { Plugin, PluginManager } from '@sentio/base'
2
+ import { ContractConfig, DataBinding, HandlerType, ProcessConfigResponse, ProcessResult } from '@sentio/protos'
3
+
9
4
  import { DEFAULT_MAX_BLOCK, USER_PROCESSOR } from '../service'
10
5
 
11
6
  import { ServerError, Status } from 'nice-grpc'
@@ -1,18 +1,17 @@
1
1
  import { SuiContext } from './context'
2
- import { ProcessResult } from '../gen'
3
- import Long from 'long'
4
- import { ListStateStorage } from '../state/state-storage'
2
+ import { ProcessResult } from '@sentio/protos'
3
+ import { ListStateStorage } from '@sentio/base'
5
4
 
6
5
  type IndexConfigure = {
7
- startSeqNumber: Long
8
- endSeqNumber?: Long
6
+ startSeqNumber: bigint
7
+ endSeqNumber?: bigint
9
8
  }
10
9
 
11
10
  export class SuiBindOptions {
12
11
  address: string
13
12
  // network?: Networkish = 1
14
13
  // name?: string
15
- startBlock?: Long | number
14
+ startBlock?: bigint | number
16
15
  // endBlock?: Long | number
17
16
  }
18
17
 
@@ -23,7 +22,7 @@ export class SuiProcessorState extends ListStateStorage<SuiBaseProcessor> {
23
22
  export class SuiBaseProcessor {
24
23
  public transactionHanlder: (transaction: any, ctx: SuiContext) => void
25
24
  address: string
26
- config: IndexConfigure = { startSeqNumber: new Long(0) }
25
+ config: IndexConfigure = { startSeqNumber: 0n }
27
26
 
28
27
  constructor(name: string, options: SuiBindOptions) {
29
28
  this.address = options.address
@@ -38,7 +37,7 @@ export class SuiBaseProcessor {
38
37
  return this
39
38
  }
40
39
 
41
- public handleTransaction(txn: any, slot: Long): ProcessResult | null {
40
+ public handleTransaction(txn: any, slot: bigint): ProcessResult | null {
42
41
  const ctx = new SuiContext(this.address, slot)
43
42
 
44
43
  if (txn) {
@@ -47,19 +46,13 @@ export class SuiBaseProcessor {
47
46
  return ctx.getProcessResult()
48
47
  }
49
48
 
50
- public startSlot(startSlot: Long | number) {
51
- if (typeof startSlot === 'number') {
52
- startSlot = Long.fromNumber(startSlot)
53
- }
54
- this.config.startSeqNumber = startSlot
49
+ public startSlot(startSlot: bigint | number) {
50
+ this.config.startSeqNumber = BigInt(startSlot)
55
51
  return this
56
52
  }
57
53
 
58
- public endBlock(endBlock: Long | number) {
59
- if (typeof endBlock === 'number') {
60
- endBlock = Long.fromNumber(endBlock)
61
- }
62
- this.config.endSeqNumber = endBlock
54
+ public endBlock(endBlock: bigint | number) {
55
+ this.config.endSeqNumber = BigInt(endBlock)
63
56
  return this
64
57
  }
65
58
  }
package/src/index.ts CHANGED
@@ -1,12 +1,10 @@
1
- // export { ProcessorServiceImpl } from './service'
2
1
  export { getProvider, setProvider, DummyProvider } from './provider'
3
- export { transformEtherError } from './error'
4
- // export { ProcessorState } from './state/processor-state'
5
- export { EthersError } from './error'
2
+ export { transformEtherError, EthersError } from './error'
6
3
 
7
4
  export { getProcessor, addProcessor, getContractByABI, addContractByABI } from './binds'
8
5
 
9
- export * from './gen'
6
+ // TODO maybe remove this
7
+ export * from '@sentio/protos'
10
8
 
11
9
  export * from './core'
12
10
 
@@ -9,14 +9,14 @@ import { createServer } from 'nice-grpc'
9
9
  import { createLogger, transports, format } from 'winston'
10
10
  import { CompressionAlgorithms } from '@grpc/grpc-js/build/src/compression-algorithms'
11
11
 
12
- import { ProcessorDefinition } from './gen'
12
+ import { ProcessorDefinition } from '@sentio/protos'
13
13
  import { ProcessorServiceImpl } from './service'
14
14
  import { setProvider } from './provider'
15
- import { ProcessorState } from './state/processor-state'
15
+ import { State } from '@sentio/base'
16
16
  import { load } from './loader'
17
17
  import { Endpoints } from './endpoints'
18
18
 
19
- global.PROCESSOR_STATE = new ProcessorState()
19
+ State.reset()
20
20
  global.ENDPOINTS = new Endpoints()
21
21
 
22
22
  const optionDefinitions = [
package/src/service.ts CHANGED
@@ -10,10 +10,10 @@ import {
10
10
  ProcessorServiceImplementation,
11
11
  ProcessResult,
12
12
  StartRequest,
13
- } from './gen'
13
+ } from '@sentio/protos'
14
+
15
+ import { Empty } from '@sentio/protos/lib/google/protobuf/empty'
14
16
 
15
- import { Empty } from './gen/google/protobuf/empty'
16
- import Long from 'long'
17
17
  import { MetricState } from './core/meter'
18
18
  import { ExporterState } from './core/exporter'
19
19
  import { EventTrackerState } from './core/event-tracker'
@@ -22,12 +22,12 @@ import { ProcessorTemplateProcessorState, TemplateInstanceState } from './core/b
22
22
  // (Long.prototype as any).toBigInt = function() {
23
23
  // return BigInt(this.toString())
24
24
  // };
25
- import { PluginManager } from './plugin'
25
+ import { PluginManager } from '@sentio/base'
26
26
  ;(BigInt.prototype as any).toJSON = function () {
27
27
  return this.toString()
28
28
  }
29
29
 
30
- export const DEFAULT_MAX_BLOCK = Long.ZERO
30
+ export const DEFAULT_MAX_BLOCK = 0n
31
31
 
32
32
  export const USER_PROCESSOR = 'user_processor'
33
33
 
@@ -160,6 +160,7 @@ export function codeGenSentioFile(contract: Contract): string {
160
160
  'ContractView',
161
161
  'DummyProvider',
162
162
  'TypedCallTrace',
163
+ 'toBlockTag',
163
164
  ],
164
165
  './common': ['PromiseOrValue'],
165
166
  './index': [`${contract.name}`, `${contract.name}__factory`],
@@ -61,7 +61,7 @@ export function generateBoundViewFunction(fn: FunctionDeclaration, includeArgTyp
61
61
  try {
62
62
  if (!overrides && this.context) {
63
63
  overrides = {
64
- blockTag: this.context.blockNumber.toNumber(),
64
+ blockTag: toBlockTag(this.context.blockNumber),
65
65
  }
66
66
  }
67
67
  if (overrides) {
@@ -1,4 +1,4 @@
1
- import { MetricValue, ProcessResult } from '../gen'
1
+ import { MetricValue, ProcessResult } from '@sentio/protos'
2
2
  import { Numberish, BigDecimal } from '../core'
3
3
  import { BigNumber } from 'ethers'
4
4
 
@@ -10,16 +10,15 @@ import {
10
10
  ProcessConfigResponse,
11
11
  ProcessorServiceImplementation,
12
12
  StartRequest,
13
- } from '../gen'
13
+ } from '@sentio/protos'
14
14
  import { CallContext } from 'nice-grpc-common'
15
- import { Empty } from '../gen/google/protobuf/empty'
15
+ import { Empty } from '@sentio/protos/lib/google/protobuf/empty'
16
16
  import { ChainConfig } from '../chain-config'
17
17
  import { CHAIN_MAP } from '../utils/chain'
18
18
  import { Block, Log } from '@ethersproject/abstract-provider'
19
- import Long from 'long'
20
19
  import { getNetwork, Networkish } from '@ethersproject/providers'
21
20
  import { Endpoints } from '../endpoints'
22
- import { ProcessorState } from '../state/processor-state'
21
+ import { State } from '@sentio/base'
23
22
  import { ProcessorServiceImpl } from '../service'
24
23
  import { Trace } from '../core/trace'
25
24
  import { setProvider } from '../provider'
@@ -27,7 +26,7 @@ import { setProvider } from '../provider'
27
26
  export const TEST_CONTEXT: CallContext = <CallContext>{}
28
27
 
29
28
  export function cleanTest() {
30
- global.PROCESSOR_STATE = new ProcessorState()
29
+ State.reset()
31
30
  if (!global.ENDPOINTS) {
32
31
  global.ENDPOINTS = new Endpoints()
33
32
  }
@@ -282,11 +281,11 @@ export class TestProcessorServer implements ProcessorServiceImplementation {
282
281
  if (contract.contract?.chainId !== getNetwork(network).chainId.toString()) {
283
282
  continue
284
283
  }
285
- const longBlockNumber = Long.fromNumber(block.number)
284
+ const longBlockNumber = block.number
286
285
  if (longBlockNumber < contract.startBlock) {
287
286
  continue
288
287
  }
289
- if (contract.endBlock !== Long.ZERO && longBlockNumber >= contract.endBlock) {
288
+ if (contract.endBlock !== 0n && longBlockNumber >= contract.endBlock) {
290
289
  continue
291
290
  }
292
291
 
@@ -323,12 +322,3 @@ export class TestProcessorServer implements ProcessorServiceImplementation {
323
322
  return this.service.processBindingsStream(request, context)
324
323
  }
325
324
  }
326
-
327
- function toBytes(obj: any): Uint8Array {
328
- const logJsonStr = JSON.stringify(obj)
329
- const raw = new Uint8Array(logJsonStr.length)
330
- for (let i = 0; i < logJsonStr.length; i++) {
331
- raw[i] = logJsonStr.charCodeAt(i)
332
- }
333
- return raw
334
- }
@@ -1,8 +1,8 @@
1
- import { ProcessorState } from '../state/processor-state'
1
+ // import { State } from '../../../base/src/state'
2
2
  import { Endpoints } from "../endpoints";
3
3
 
4
4
  declare global {
5
- var PROCESSOR_STATE: ProcessorState
5
+ // var PROCESSOR_STATE: State
6
6
  var ENDPOINTS: Endpoints
7
7
  }
8
8
 
@@ -1,7 +1,7 @@
1
1
  import { BigNumber } from 'ethers'
2
2
  import { BigDecimal } from '../core/big-decimal'
3
3
  import { Numberish } from '../core'
4
- import { MetricValue } from '../gen'
4
+ import { MetricValue } from '@sentio/protos'
5
5
 
6
6
  export function toBigDecimal(n: BigNumber | bigint) {
7
7
  return new BigDecimal(n.toString())
@@ -1,4 +1,4 @@
1
- import { PriceServiceClient, PriceServiceDefinition } from '../gen/service/price/protos/price'
1
+ import { PriceServiceClient, PriceServiceDefinition } from '@sentio/protos/lib/service/price/protos/price'
2
2
  import { createChannel, createClientFactory } from 'nice-grpc'
3
3
  import { retryMiddleware, RetryOptions } from 'nice-grpc-client-middleware-retry'
4
4
 
@@ -1,6 +0,0 @@
1
- import Long from 'long';
2
- declare type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
3
- export declare type DeepPartial<T> = T extends Builtin ? T : T extends Long ? string | number | Long : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
4
- [K in keyof T]?: DeepPartial<T[K]>;
5
- } : Partial<T>;
6
- export {};
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=builtin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"builtin.js","sourceRoot":"","sources":["../../src/gen/builtin.ts"],"names":[],"mappings":"","sourcesContent":["import Long from 'long'\n\ntype Builtin =\n | Date\n | Function\n | Uint8Array\n | string\n | number\n | boolean\n | undefined;\n\nexport type DeepPartial<T> = T extends Builtin\n ? T\n : T extends Long\n ? string | number | Long\n : T extends Array<infer U>\n ? Array<DeepPartial<U>>\n : T extends ReadonlyArray<infer U>\n ? ReadonlyArray<DeepPartial<U>>\n : T extends {}\n ? { [K in keyof T]?: DeepPartial<T[K]> }\n : Partial<T>;\n"]}