@sentio/sdk 1.36.4 → 1.37.0-rc.2

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 (199) 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/builtin/solana/wormhole-processor.d.ts +0 -4
  29. package/lib/builtin/solana/wormhole-processor.js +123 -50
  30. package/lib/builtin/solana/wormhole-processor.js.map +1 -1
  31. package/lib/core/account-processor.d.ts +1 -1
  32. package/lib/core/account-processor.js +2 -2
  33. package/lib/core/account-processor.js.map +1 -1
  34. package/lib/core/base-context.d.ts +1 -1
  35. package/lib/core/base-context.js.map +1 -1
  36. package/lib/core/base-processor-template.d.ts +2 -2
  37. package/lib/core/base-processor-template.js +7 -21
  38. package/lib/core/base-processor-template.js.map +1 -1
  39. package/lib/core/base-processor.d.ts +1 -1
  40. package/lib/core/base-processor.js +6 -20
  41. package/lib/core/base-processor.js.map +1 -1
  42. package/lib/core/bind-options.d.ts +5 -6
  43. package/lib/core/bind-options.js.map +1 -1
  44. package/lib/core/context.d.ts +4 -5
  45. package/lib/core/context.js +6 -10
  46. package/lib/core/context.js.map +1 -1
  47. package/lib/core/eth-plugin.d.ts +2 -2
  48. package/lib/core/eth-plugin.js +8 -12
  49. package/lib/core/eth-plugin.js.map +1 -1
  50. package/lib/core/event-tracker.d.ts +1 -1
  51. package/lib/core/event-tracker.js +2 -2
  52. package/lib/core/event-tracker.js.map +1 -1
  53. package/lib/core/exporter.d.ts +1 -1
  54. package/lib/core/exporter.js +2 -2
  55. package/lib/core/exporter.js.map +1 -1
  56. package/lib/core/generic-processor.test.js.map +1 -1
  57. package/lib/core/index.d.ts +1 -1
  58. package/lib/core/index.js +2 -1
  59. package/lib/core/index.js.map +1 -1
  60. package/lib/core/logger.d.ts +1 -1
  61. package/lib/core/logger.js +5 -5
  62. package/lib/core/logger.js.map +1 -1
  63. package/lib/core/meter.d.ts +2 -2
  64. package/lib/core/meter.js +10 -10
  65. package/lib/core/meter.js.map +1 -1
  66. package/lib/core/numberish.d.ts +4 -4
  67. package/lib/core/numberish.js +23 -25
  68. package/lib/core/numberish.js.map +1 -1
  69. package/lib/core/numberish.test.js.map +1 -1
  70. package/lib/core/solana-context.d.ts +2 -3
  71. package/lib/core/solana-context.js.map +1 -1
  72. package/lib/core/solana-options.d.ts +2 -3
  73. package/lib/core/solana-options.js.map +1 -1
  74. package/lib/core/solana-plugin.d.ts +2 -2
  75. package/lib/core/solana-plugin.js +6 -6
  76. package/lib/core/solana-plugin.js.map +1 -1
  77. package/lib/core/solana-processor.d.ts +7 -8
  78. package/lib/core/solana-processor.js +5 -15
  79. package/lib/core/solana-processor.js.map +1 -1
  80. package/lib/core/sui-plugin.d.ts +2 -2
  81. package/lib/core/sui-plugin.js +5 -5
  82. package/lib/core/sui-plugin.js.map +1 -1
  83. package/lib/core/sui-processor.d.ts +8 -9
  84. package/lib/core/sui-processor.js +5 -15
  85. package/lib/core/sui-processor.js.map +1 -1
  86. package/lib/index.d.ts +2 -3
  87. package/lib/index.js +3 -5
  88. package/lib/index.js.map +1 -1
  89. package/lib/processor-runner.js +4 -4
  90. package/lib/processor-runner.js.map +1 -1
  91. package/lib/service.d.ts +3 -4
  92. package/lib/service.js +7 -11
  93. package/lib/service.js.map +1 -1
  94. package/lib/solana-codegen/codegen.js +16 -5
  95. package/lib/solana-codegen/codegen.js.map +1 -1
  96. package/lib/target-ethers-sentio/file.js +1 -0
  97. package/lib/target-ethers-sentio/file.js.map +1 -1
  98. package/lib/target-ethers-sentio/view-function.js +1 -1
  99. package/lib/testing/metric-utils.d.ts +1 -1
  100. package/lib/testing/metric-utils.js.map +1 -1
  101. package/lib/testing/test-processor-server.d.ts +3 -3
  102. package/lib/testing/test-processor-server.js +10 -22
  103. package/lib/testing/test-processor-server.js.map +1 -1
  104. package/lib/utils/conversion.d.ts +1 -1
  105. package/lib/utils/conversion.js.map +1 -1
  106. package/lib/utils/dex-price.test.js.map +1 -1
  107. package/lib/utils/erc20.test.js.map +1 -1
  108. package/lib/utils/price.d.ts +10 -10
  109. package/lib/utils/price.js +1 -1
  110. package/lib/utils/price.js.map +1 -1
  111. package/package.json +5 -2
  112. package/src/aptos/api.ts +1 -1
  113. package/src/aptos/aptos-plugin.ts +10 -11
  114. package/src/aptos/aptos-processor.ts +2 -2
  115. package/src/aptos/context.ts +3 -4
  116. package/src/binds.ts +1 -1
  117. package/src/builtin/internal/eacaggregatorproxy_processor.ts +19 -18
  118. package/src/builtin/internal/erc1155_processor.ts +6 -5
  119. package/src/builtin/internal/erc20_processor.ts +9 -8
  120. package/src/builtin/internal/erc20bytes_processor.ts +7 -6
  121. package/src/builtin/internal/erc721_processor.ts +10 -9
  122. package/src/builtin/internal/weth9_processor.ts +7 -6
  123. package/src/builtin/solana/wormhole-processor.ts +119 -28
  124. package/src/core/account-processor.ts +1 -1
  125. package/src/core/base-context.ts +1 -1
  126. package/src/core/base-processor-template.ts +6 -15
  127. package/src/core/base-processor.ts +4 -13
  128. package/src/core/bind-options.ts +5 -6
  129. package/src/core/context.ts +10 -11
  130. package/src/core/eth-plugin.ts +3 -4
  131. package/src/core/event-tracker.ts +2 -2
  132. package/src/core/exporter.ts +1 -1
  133. package/src/core/index.ts +1 -1
  134. package/src/core/logger.ts +1 -1
  135. package/src/core/meter.ts +2 -2
  136. package/src/core/numberish.ts +20 -21
  137. package/src/core/solana-context.ts +2 -3
  138. package/src/core/solana-options.ts +2 -4
  139. package/src/core/solana-plugin.ts +3 -3
  140. package/src/core/solana-processor.ts +10 -17
  141. package/src/core/sui-plugin.ts +3 -8
  142. package/src/core/sui-processor.ts +11 -18
  143. package/src/index.ts +3 -5
  144. package/src/processor-runner.ts +3 -3
  145. package/src/service.ts +5 -5
  146. package/src/solana-codegen/codegen.ts +20 -7
  147. package/src/target-ethers-sentio/file.ts +1 -0
  148. package/src/target-ethers-sentio/view-function.ts +1 -1
  149. package/src/testing/metric-utils.ts +1 -1
  150. package/src/testing/test-processor-server.ts +6 -16
  151. package/src/types/global.d.ts +2 -2
  152. package/src/utils/conversion.ts +1 -1
  153. package/src/utils/price.ts +1 -1
  154. package/lib/gen/builtin.d.ts +0 -6
  155. package/lib/gen/builtin.js +0 -3
  156. package/lib/gen/builtin.js.map +0 -1
  157. package/lib/gen/chainquery/protos/chainquery.d.ts +0 -400
  158. package/lib/gen/chainquery/protos/chainquery.js +0 -972
  159. package/lib/gen/chainquery/protos/chainquery.js.map +0 -1
  160. package/lib/gen/google/protobuf/empty.d.ts +0 -16
  161. package/lib/gen/google/protobuf/empty.js +0 -47
  162. package/lib/gen/google/protobuf/empty.js.map +0 -1
  163. package/lib/gen/google/protobuf/struct.d.ts +0 -73
  164. package/lib/gen/google/protobuf/struct.js +0 -371
  165. package/lib/gen/google/protobuf/struct.js.map +0 -1
  166. package/lib/gen/google/protobuf/timestamp.d.ts +0 -18
  167. package/lib/gen/google/protobuf/timestamp.js +0 -71
  168. package/lib/gen/google/protobuf/timestamp.js.map +0 -1
  169. package/lib/gen/index.d.ts +0 -2
  170. package/lib/gen/index.js +0 -19
  171. package/lib/gen/index.js.map +0 -1
  172. package/lib/gen/processor/protos/processor.d.ts +0 -826
  173. package/lib/gen/processor/protos/processor.js +0 -3988
  174. package/lib/gen/processor/protos/processor.js.map +0 -1
  175. package/lib/gen/service/price/protos/price.d.ts +0 -85
  176. package/lib/gen/service/price/protos/price.js +0 -269
  177. package/lib/gen/service/price/protos/price.js.map +0 -1
  178. package/lib/plugin.d.ts +0 -15
  179. package/lib/plugin.js +0 -32
  180. package/lib/plugin.js.map +0 -1
  181. package/lib/state/processor-state.d.ts +0 -3
  182. package/lib/state/processor-state.js +0 -8
  183. package/lib/state/processor-state.js.map +0 -1
  184. package/lib/state/state-storage.d.ts +0 -17
  185. package/lib/state/state-storage.js +0 -60
  186. package/lib/state/state-storage.js.map +0 -1
  187. package/lib/state/state-storage.test.d.ts +0 -1
  188. package/lib/state/state-storage.test.js.map +0 -1
  189. package/src/gen/builtin.ts +0 -22
  190. package/src/gen/chainquery/protos/chainquery.ts +0 -1212
  191. package/src/gen/google/protobuf/empty.ts +0 -58
  192. package/src/gen/google/protobuf/struct.ts +0 -422
  193. package/src/gen/google/protobuf/timestamp.ts +0 -85
  194. package/src/gen/index.ts +0 -3
  195. package/src/gen/processor/protos/processor.ts +0 -4619
  196. package/src/gen/service/price/protos/price.ts +0 -329
  197. package/src/plugin.ts +0 -41
  198. package/src/state/processor-state.ts +0 -3
  199. 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,10 +1,19 @@
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
- import { BN } from '@project-serum/anchor'
5
- import Long from 'long'
4
+ import { BlockTag } from '@ethersproject/providers'
6
5
 
7
- export type Numberish = number | BigNumber | bigint | BigDecimal
6
+ export type Numberish = number | BigNumber | bigint | BigDecimal | string
7
+
8
+ export function toBlockTag(a: number | bigint): BlockTag {
9
+ if (typeof a === 'number') {
10
+ return a
11
+ }
12
+ if (a > Number.MAX_SAFE_INTEGER) {
13
+ return '0x' + a.toString(16)
14
+ }
15
+ return Number(a)
16
+ }
8
17
 
9
18
  export function toMetricValue(value: Numberish): MetricValue {
10
19
  if (value instanceof BigNumber) {
@@ -31,9 +40,9 @@ export function toMetricValue(value: Numberish): MetricValue {
31
40
  })
32
41
  }
33
42
  }
34
- if (BN.isBN(value)) {
43
+ if (typeof value === 'string') {
35
44
  return MetricValue.fromPartial({
36
- bigInteger: bnToBigInteger(value),
45
+ bigDecimal: value,
37
46
  })
38
47
  }
39
48
  if (typeof value === 'bigint' || Number.isInteger(value)) {
@@ -64,14 +73,6 @@ function bigDecimalToBigInteger(a: BigDecimal): BigInteger {
64
73
  return hexToBigInteger(a.toString(16), negative)
65
74
  }
66
75
 
67
- function bnToBigInteger(a: BN): BigInteger {
68
- const negative = a.isNeg()
69
- if (negative) {
70
- a = a.abs()
71
- }
72
- return hexToBigInteger(a.toString(16), negative)
73
- }
74
-
75
76
  function intToBigInteger(a: bigint | number): BigInteger {
76
77
  const negative = a < 0
77
78
  if (negative) {
@@ -84,12 +85,14 @@ export function toBigInteger(a: Numberish): BigInteger {
84
85
  if (a instanceof BigDecimal) {
85
86
  return bigDecimalToBigInteger(a)
86
87
  }
87
- if (a instanceof BN) {
88
- return bnToBigInteger(a)
89
- }
88
+
90
89
  if (a instanceof BigNumber) {
91
90
  return intToBigInteger(a.toBigInt())
92
91
  }
92
+ if (typeof a === 'string') {
93
+ return intToBigInteger(BigInt(a))
94
+ }
95
+
93
96
  return intToBigInteger(a)
94
97
 
95
98
  // Following code is actually very slow
@@ -115,7 +118,3 @@ function hexToBigInteger(hex: string, negative: boolean): BigInteger {
115
118
  data: new Uint8Array(buffer),
116
119
  }
117
120
  }
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
 
@@ -32,7 +32,7 @@ function codeGenSolanaIdlProcessor(idlObj: any): string {
32
32
  const idlName = idlObj.name
33
33
  const idlNamePascalCase = toPascalCase(idlName)
34
34
  const instructions: any[] = idlObj.instructions
35
- return `import { BorshInstructionCoder, Instruction, Idl, BN } from '@project-serum/anchor'
35
+ return `import { BorshInstructionCoder, Instruction, Idl } from '@project-serum/anchor'
36
36
  import { SolanaBaseProcessor, SolanaContext, SolanaBindOptions } from "@sentio/sdk"
37
37
  import { ${idlName}_idl } from "./${idlName}"
38
38
  import bs58 from 'bs58'
@@ -59,14 +59,15 @@ export class ${idlNamePascalCase}Processor extends SolanaBaseProcessor {
59
59
 
60
60
  function codeGenSolanaInstruction(idlName: string, ins: any): string {
61
61
  const instructionName = ins.name
62
- const argsTypeString = codeGenInstructionArgs(ins.args)
63
62
  return `
64
- on${
65
- instructionName.charAt(0).toUpperCase() + instructionName.slice(1)
66
- }(handler: (args: ${argsTypeString}, accounts: string[], ctx: SolanaContext) => void): ${idlName}Processor {
63
+ on${instructionName.charAt(0).toUpperCase() + instructionName.slice(1)}(handler: (args: ${codeGenInstructionArgsType(
64
+ ins.args
65
+ )}, accounts: string[], ctx: SolanaContext) => void): ${idlName}Processor {
67
66
  this.onInstruction('${instructionName}', (ins: Instruction, ctx, accounts: string[]) => {
67
+ const origin = ins.data as any
68
+ const data = ${codeGenInstructionArgs(ins.args)}
68
69
  if (ins) {
69
- handler(ins.data as ${argsTypeString}, accounts, ctx)
70
+ handler(data, accounts, ctx)
70
71
  }
71
72
  })
72
73
  return this
@@ -75,6 +76,18 @@ function codeGenSolanaInstruction(idlName: string, ins: any): string {
75
76
  }
76
77
 
77
78
  function codeGenInstructionArgs(args: { name: string; type: string }[]): string {
79
+ return `{ ${args.map((arg) => codeGenInstructionArg(arg.name, arg.type)).join(', ')} }`
80
+ }
81
+
82
+ function codeGenInstructionArg(name: string, type: string): string {
83
+ const mType = mapType(type)
84
+ if (mType === 'bigint') {
85
+ return `${name}: BigInt(origin.${name}.toString())`
86
+ }
87
+ return `${name}: origin.${name} as ${mType}`
88
+ }
89
+
90
+ function codeGenInstructionArgsType(args: { name: string; type: string }[]): string {
78
91
  return `{ ${args.map((arg) => arg.name + ': ' + mapType(arg.type)).join(', ')} }`
79
92
  }
80
93
 
@@ -100,7 +113,7 @@ function mapType(tpe: string): string {
100
113
  case 'i64':
101
114
  case 'u128':
102
115
  case 'i128':
103
- return 'BN'
116
+ return 'bigint'
104
117
  default:
105
118
  return 'any'
106
119
  }
@@ -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