@sentio/sdk 2.50.1-rc.1 → 2.50.1-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 (66) hide show
  1. package/lib/aptos/aptos-processor.d.ts.map +1 -1
  2. package/lib/aptos/aptos-processor.js +3 -2
  3. package/lib/aptos/aptos-processor.js.map +1 -1
  4. package/lib/aptos/builtin/0x1.js +0 -1
  5. package/lib/aptos/builtin/0x1.js.map +1 -1
  6. package/lib/aptos/builtin/0x3.js +0 -1
  7. package/lib/aptos/builtin/0x3.js.map +1 -1
  8. package/lib/aptos/builtin/0x4.js +0 -1
  9. package/lib/aptos/builtin/0x4.js.map +1 -1
  10. package/lib/aptos/codegen/codegen.js +7 -3
  11. package/lib/aptos/codegen/codegen.js.map +1 -1
  12. package/lib/aptos/index.d.ts +1 -1
  13. package/lib/aptos/index.d.ts.map +1 -1
  14. package/lib/aptos/index.js +1 -1
  15. package/lib/aptos/index.js.map +1 -1
  16. package/lib/aptos/network.d.ts +4 -1
  17. package/lib/aptos/network.d.ts.map +1 -1
  18. package/lib/aptos/network.js +5 -2
  19. package/lib/aptos/network.js.map +1 -1
  20. package/lib/core/constants.d.ts +2 -0
  21. package/lib/core/constants.d.ts.map +1 -0
  22. package/lib/core/constants.js +2 -0
  23. package/lib/core/constants.js.map +1 -0
  24. package/lib/core/index.d.ts +1 -0
  25. package/lib/core/index.d.ts.map +1 -1
  26. package/lib/core/index.js +1 -0
  27. package/lib/core/index.js.map +1 -1
  28. package/lib/eth/base-processor.d.ts.map +1 -1
  29. package/lib/eth/base-processor.js +4 -3
  30. package/lib/eth/base-processor.js.map +1 -1
  31. package/lib/eth/eth.d.ts.map +1 -1
  32. package/lib/eth/eth.js +2 -1
  33. package/lib/eth/eth.js.map +1 -1
  34. package/lib/fuel/global-processor.d.ts.map +1 -1
  35. package/lib/fuel/global-processor.js +3 -2
  36. package/lib/fuel/global-processor.js.map +1 -1
  37. package/lib/sui/sui-object-processor.d.ts +12 -6
  38. package/lib/sui/sui-object-processor.d.ts.map +1 -1
  39. package/lib/sui/sui-object-processor.js +32 -4
  40. package/lib/sui/sui-object-processor.js.map +1 -1
  41. package/lib/sui/sui-plugin.d.ts.map +1 -1
  42. package/lib/sui/sui-plugin.js +9 -0
  43. package/lib/sui/sui-plugin.js.map +1 -1
  44. package/lib/sui/sui-processor.d.ts.map +1 -1
  45. package/lib/sui/sui-processor.js +5 -3
  46. package/lib/sui/sui-processor.js.map +1 -1
  47. package/lib/testing/eth-facet.d.ts.map +1 -1
  48. package/lib/testing/eth-facet.js +2 -1
  49. package/lib/testing/eth-facet.js.map +1 -1
  50. package/package.json +3 -3
  51. package/src/aptos/aptos-processor.ts +3 -3
  52. package/src/aptos/builtin/0x1.ts +0 -1
  53. package/src/aptos/builtin/0x3.ts +0 -1
  54. package/src/aptos/builtin/0x4.ts +0 -1
  55. package/src/aptos/codegen/codegen.ts +7 -7
  56. package/src/aptos/index.ts +1 -1
  57. package/src/aptos/network.ts +6 -2
  58. package/src/core/constants.ts +1 -0
  59. package/src/core/index.ts +1 -0
  60. package/src/eth/base-processor.ts +4 -3
  61. package/src/eth/eth.ts +2 -1
  62. package/src/fuel/global-processor.ts +3 -2
  63. package/src/sui/sui-object-processor.ts +79 -7
  64. package/src/sui/sui-plugin.ts +11 -0
  65. package/src/sui/sui-processor.ts +5 -4
  66. package/src/testing/eth-facet.ts +2 -1
@@ -7,7 +7,7 @@ export {
7
7
  } from './aptos-processor.js'
8
8
  export { AptosResourceProcessorTemplate } from './aptos-resource-processor-template.js'
9
9
  export { AptosContext, AptosResourcesContext } from './context.js'
10
- export { AptosBindOptions, AptosNetwork } from './network.js'
10
+ export { AptosBindOptions, AptosNetwork, MovementNetwork } from './network.js'
11
11
  export { type ResourceChange } from '@typemove/aptos'
12
12
  export * from './api.js'
13
13
 
@@ -9,10 +9,14 @@ export const AptosNetwork = <const>{
9
9
  TEST_NET: AptosChainId.APTOS_TESTNET,
10
10
  // DEV_NET: AptosChainId.APTOS_DEVNET,
11
11
  MOVEMENT_MAIN_NET: AptosChainId.APTOS_MOVEMENT_MAINNET,
12
- MOVEMENT_TEST_NET: AptosChainId.APTOS_MOVEMENT_TESTNET,
13
12
  MOVEMENT_PORTO: AptosChainId.APTOS_MOVEMENT_PORTO
14
13
  }
15
14
 
15
+ export const MovementNetwork = <const>{
16
+ MAIN_NET: AptosChainId.APTOS_MOVEMENT_MAINNET,
17
+ PORTO: AptosChainId.APTOS_MOVEMENT_PORTO
18
+ }
19
+
16
20
  export class AptosBindOptions {
17
21
  address: string
18
22
  network?: AptosNetwork = AptosNetwork.MAIN_NET
@@ -27,7 +31,7 @@ export function getRpcEndpoint(network: AptosNetwork): string {
27
31
  return 'https://mainnet.aptoslabs.com/v1'
28
32
  case AptosNetwork.TEST_NET:
29
33
  return 'https://testnet.aptoslabs.com/v1'
30
- case AptosNetwork.MOVEMENT_TEST_NET:
34
+ case AptosChainId.APTOS_MOVEMENT_TESTNET:
31
35
  return 'https://aptos.testnet.suzuka.movementlabs.xyz/v1'
32
36
  case AptosNetwork.MOVEMENT_MAIN_NET:
33
37
  return 'https://mainnet.movementnetwork.xyz/v1'
@@ -0,0 +1 @@
1
+ export const ALL_ADDRESS = '*'
package/src/core/index.ts CHANGED
@@ -11,3 +11,4 @@ export { type Numberish, toBigInteger, toMetricValue } from './numberish.js'
11
11
 
12
12
  export { CorePlugin } from './core-plugin.js'
13
13
  export { DatabaseSchema } from './database-schema.js'
14
+ export * from './constants.js'
@@ -22,6 +22,7 @@ import sha3 from 'js-sha3'
22
22
  import { ListStateStorage, metricsStorage } from '@sentio/runtime'
23
23
  import { EthChainId } from '@sentio/chain'
24
24
  import { handlersProxy } from '../utils/metrics.js'
25
+ import { ALL_ADDRESS } from '../core/index.js'
25
26
 
26
27
  export interface AddressOrTypeEventFilter extends DeferredTopicFilter {
27
28
  addressType?: AddressType
@@ -85,7 +86,7 @@ export class GlobalProcessor {
85
86
 
86
87
  constructor(config: Omit<BindOptions, 'address'>) {
87
88
  this.config = {
88
- address: '*',
89
+ address: ALL_ADDRESS,
89
90
  name: config.name || 'Global',
90
91
  network: config.network || EthChainId.ETHEREUM,
91
92
  startBlock: 0n
@@ -180,7 +181,7 @@ export class GlobalProcessor {
180
181
 
181
182
  const ctx = new GlobalContext(
182
183
  chainId,
183
- '*',
184
+ ALL_ADDRESS,
184
185
  new Date(block.timestamp * 1000),
185
186
  block,
186
187
  undefined,
@@ -201,7 +202,7 @@ export class GlobalProcessor {
201
202
 
202
203
  const ctx = new GlobalContext(
203
204
  chainId,
204
- '*',
205
+ ALL_ADDRESS,
205
206
  new Date(block.timestamp * 1000),
206
207
  block,
207
208
  undefined,
package/src/eth/eth.ts CHANGED
@@ -27,6 +27,7 @@ import { ContractContext } from './context.js'
27
27
  import { getAddress } from 'ethers/address'
28
28
  import { getBigInt, getNumber, hexlify } from 'ethers/utils'
29
29
  import { EthCallContext, EthCallParam } from '@sentio/protos'
30
+ import { ALL_ADDRESS } from '../core/index.js'
30
31
 
31
32
  export interface IResult {
32
33
  /**
@@ -271,7 +272,7 @@ export function isNullAddress(address: string) {
271
272
  }
272
273
 
273
274
  export function validateAndNormalizeAddress(address: string): string {
274
- if (address === '*') {
275
+ if (address === ALL_ADDRESS) {
275
276
  return address
276
277
  }
277
278
  const normalizedAddress = getAddress(address)
@@ -6,6 +6,7 @@ import { decodeFuelTransaction, DEFAULT_FUEL_FETCH_CONFIG, FuelFetchConfig } fro
6
6
  import { FuelContext } from './context.js'
7
7
  import { FuelProcessorConfig, getOptionsSignature } from './fuel-processor.js'
8
8
  import { mergeProcessResults } from '@sentio/runtime'
9
+ import { ALL_ADDRESS } from '../core/index.js'
9
10
 
10
11
  type GlobalFuelProcessorConfig = Omit<FuelProcessorConfig, 'address' | 'abi'>
11
12
 
@@ -21,7 +22,7 @@ export class FuelGlobalProcessor implements FuelBaseProcessor<GlobalFuelProcesso
21
22
  'global_' +
22
23
  getOptionsSignature({
23
24
  ...config,
24
- address: '*'
25
+ address: ALL_ADDRESS
25
26
  })
26
27
  FuelProcessorState.INSTANCE.getOrSetValue(sig, processor)
27
28
  return processor
@@ -48,7 +49,7 @@ export class FuelGlobalProcessor implements FuelBaseProcessor<GlobalFuelProcesso
48
49
  }
49
50
  const ctx = new FuelContext(
50
51
  this.config.chainId,
51
- '*',
52
+ ALL_ADDRESS,
52
53
  this.config.name ?? '*',
53
54
  call.timestamp || new Date(0),
54
55
  tx,
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  Data_SuiCall,
3
3
  Data_SuiObject,
4
+ Data_SuiObjectChange,
4
5
  HandleInterval,
5
6
  MoveAccountFetchConfig,
6
7
  MoveFetchConfig,
@@ -9,11 +10,11 @@ import {
9
10
  } from '@sentio/protos'
10
11
  import { ListStateStorage } from '@sentio/runtime'
11
12
  import { SuiNetwork } from './network.js'
12
- import { SuiAddressContext, SuiContext, SuiObjectContext } from './context.js'
13
- import { SuiMoveObject, SuiTransactionBlockResponse } from '@mysten/sui/client'
14
- import { PromiseOrVoid } from '../core/index.js'
13
+ import { SuiAddressContext, SuiContext, SuiObjectChangeContext, SuiObjectContext } from './context.js'
14
+ import { SuiMoveObject, SuiObjectChange, SuiTransactionBlockResponse } from '@mysten/sui/client'
15
+ import { ALL_ADDRESS, PromiseOrVoid } from '../core/index.js'
15
16
  import { configure, DEFAULT_FETCH_CONFIG, IndexConfigure, SuiBindOptions } from './sui-processor.js'
16
- import { CallHandler, TransactionFilter, accountTypeString } from '../move/index.js'
17
+ import { CallHandler, TransactionFilter, accountTypeString, ObjectChangeHandler } from '../move/index.js'
17
18
  import { ServerError, Status } from 'nice-grpc'
18
19
  import { TypeDescriptor } from '@typemove/move'
19
20
  import { TypedSuiMoveObject } from './models.js'
@@ -58,6 +59,7 @@ export abstract class SuiBaseObjectOrAddressProcessor<HandlerType> {
58
59
  templateId: number | undefined
59
60
 
60
61
  objectHandlers: ObjectHandler[] = []
62
+ objectChangeHandlers: ObjectChangeHandler<Data_SuiObjectChange>[] = []
61
63
 
62
64
  // static bind(options: SuiObjectsBindOptions): SuiBaseObjectsProcessor<any> {
63
65
  // return new SuiBaseObjectsProcessor(options)
@@ -113,7 +115,11 @@ export abstract class SuiBaseObjectOrAddressProcessor<HandlerType> {
113
115
  })
114
116
  return this
115
117
  }
118
+ }
116
119
 
120
+ abstract class SuiBaseObjectOrAddressProcessorInternal<
121
+ HandlerType
122
+ > extends SuiBaseObjectOrAddressProcessor<HandlerType> {
117
123
  public onTimeInterval(
118
124
  handler: HandlerType,
119
125
  timeIntervalInMinutes = 60,
@@ -150,7 +156,7 @@ export abstract class SuiBaseObjectOrAddressProcessor<HandlerType> {
150
156
  }
151
157
  }
152
158
 
153
- export class SuiAddressProcessor extends SuiBaseObjectOrAddressProcessor<
159
+ export class SuiAddressProcessor extends SuiBaseObjectOrAddressProcessorInternal<
154
160
  (objects: SuiMoveObject[], ctx: SuiAddressContext) => PromiseOrVoid
155
161
  > {
156
162
  callHandlers: CallHandler<Data_SuiCall>[] = []
@@ -212,7 +218,7 @@ export class SuiAddressProcessor extends SuiBaseObjectOrAddressProcessor<
212
218
  }
213
219
  }
214
220
 
215
- export class SuiObjectProcessor extends SuiBaseObjectOrAddressProcessor<
221
+ export class SuiObjectProcessor extends SuiBaseObjectOrAddressProcessorInternal<
216
222
  (self: SuiMoveObject, dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid
217
223
  > {
218
224
  static bind(options: SuiObjectBindOptions): SuiObjectProcessor {
@@ -242,9 +248,10 @@ export class SuiObjectTypeProcessor<T> extends SuiBaseObjectOrAddressProcessor<
242
248
  (self: TypedSuiMoveObject<T>, dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid
243
249
  > {
244
250
  objectType: TypeDescriptor<T>
251
+
245
252
  static bind<T>(options: SuiObjectTypeBindOptions<T>): SuiObjectTypeProcessor<T> {
246
253
  const processor = new SuiObjectTypeProcessor<T>({
247
- address: options.objectType.qname,
254
+ address: ALL_ADDRESS, // current only support on all address
248
255
  network: options.network,
249
256
  startCheckpoint: options.startCheckpoint,
250
257
  ownerType: MoveOwnerType.TYPE,
@@ -270,6 +277,71 @@ export class SuiObjectTypeProcessor<T> extends SuiBaseObjectOrAddressProcessor<
270
277
  const object = await ctx.coder.filterAndDecodeObjects(this.objectType, [data.self as SuiMoveObject])
271
278
  return handler(object[0], data.objects as SuiMoveObject[], ctx)
272
279
  }
280
+
281
+ public onObjectChange(handler: (changes: SuiObjectChange[], ctx: SuiObjectChangeContext) => void): this {
282
+ if (this.config.network === SuiNetwork.TEST_NET) {
283
+ throw new ServerError(Status.INVALID_ARGUMENT, 'object change not supported in testnet')
284
+ }
285
+ const processor = this
286
+ this.objectChangeHandlers.push({
287
+ handler: async function (data: Data_SuiObjectChange) {
288
+ const ctx = new SuiObjectChangeContext(
289
+ processor.config.network,
290
+ processor.config.address,
291
+ data.timestamp || new Date(0),
292
+ data.slot,
293
+ data.txDigest,
294
+ processor.config.baseLabels
295
+ )
296
+ await handler(data.changes as SuiObjectChange[], ctx)
297
+ return ctx.stopAndGetResult()
298
+ },
299
+ type: this.objectType.qname
300
+ })
301
+
302
+ return this
303
+ }
304
+
305
+ public onTimeInterval(
306
+ handler: (
307
+ self: TypedSuiMoveObject<T>,
308
+ dynamicFieldObjects: SuiMoveObject[],
309
+ ctx: SuiObjectContext
310
+ ) => PromiseOrVoid,
311
+ timeIntervalInMinutes = 60,
312
+ backfillTimeIntervalInMinutes = 240,
313
+ fetchConfig?: Partial<MoveAccountFetchConfig>
314
+ ): this {
315
+ return this.onInterval(
316
+ handler,
317
+ {
318
+ recentInterval: timeIntervalInMinutes,
319
+ backfillInterval: backfillTimeIntervalInMinutes
320
+ },
321
+ undefined,
322
+ this.objectType.qname,
323
+ fetchConfig
324
+ )
325
+ }
326
+
327
+ public onCheckpointInterval(
328
+ handler: (
329
+ self: TypedSuiMoveObject<T>,
330
+ dynamicFieldObjects: SuiMoveObject[],
331
+ ctx: SuiObjectContext
332
+ ) => PromiseOrVoid,
333
+ checkpointInterval = 100000,
334
+ backfillCheckpointInterval = 400000,
335
+ fetchConfig?: Partial<MoveAccountFetchConfig>
336
+ ): this {
337
+ return this.onInterval(
338
+ handler,
339
+ undefined,
340
+ { recentInterval: checkpointInterval, backfillInterval: backfillCheckpointInterval },
341
+ this.objectType.qname,
342
+ fetchConfig
343
+ )
344
+ }
273
345
  }
274
346
 
275
347
  export class SuiWrappedObjectProcessor extends SuiBaseObjectOrAddressProcessor<
@@ -122,6 +122,7 @@ export class SuiPlugin extends Plugin {
122
122
  }
123
123
  contractConfig.moveCallConfigs.push(functionHandlerConfig)
124
124
  }
125
+ // deprecated, use objectType processor instead
125
126
  for (const handler of suiProcessor.objectChangeHandlers) {
126
127
  const handlerId = handlers.suiObjectChangeHandlers.push(handler.handler) - 1
127
128
  const objectChangeHandler: MoveResourceChangeConfig = {
@@ -141,6 +142,16 @@ export class SuiPlugin extends Plugin {
141
142
  })
142
143
  for (const handler of processor.objectHandlers) {
143
144
  const handlerId = handlers.suiObjectHandlers.push(handler.handler) - 1
145
+
146
+ for (const handler of processor.objectChangeHandlers) {
147
+ const handlerId = handlers.suiObjectChangeHandlers.push(handler.handler) - 1
148
+ const objectChangeHandler: MoveResourceChangeConfig = {
149
+ type: handler.type,
150
+ handlerId
151
+ }
152
+ accountConfig.moveResourceChangeConfigs.push(objectChangeHandler)
153
+ }
154
+
144
155
  accountConfig.moveIntervalConfigs.push({
145
156
  intervalConfig: {
146
157
  handlerId: handlerId,
@@ -17,7 +17,7 @@ import {
17
17
  } from '../move/index.js'
18
18
  import { getMoveCalls } from './utils.js'
19
19
  import { defaultMoveCoder, MoveCoder } from './index.js'
20
- import { Labels } from '../core/index.js'
20
+ import { ALL_ADDRESS, Labels } from '../core/index.js'
21
21
  import { Required } from 'utility-types'
22
22
 
23
23
  export const DEFAULT_FETCH_CONFIG: MoveFetchConfig = {
@@ -31,7 +31,7 @@ export type IndexConfigure = Required<SuiBindOptions, 'startCheckpoint' | 'netwo
31
31
  export function configure(options: SuiBindOptions): IndexConfigure {
32
32
  return {
33
33
  startCheckpoint: options.startCheckpoint || 0n,
34
- address: options.address === '*' ? '*' : accountAddressString(options.address),
34
+ address: options.address === ALL_ADDRESS ? ALL_ADDRESS : accountAddressString(options.address),
35
35
  network: options.network || SuiNetwork.MAIN_NET,
36
36
  baseLabels: options.baseLabels
37
37
  }
@@ -271,13 +271,13 @@ export class SuiBaseProcessor {
271
271
 
272
272
  export class SuiModulesProcessor extends SuiBaseProcessor {
273
273
  static bind(options: SuiBindOptions): SuiModulesProcessor {
274
- return new SuiModulesProcessor('*', options)
274
+ return new SuiModulesProcessor(ALL_ADDRESS, options)
275
275
  }
276
276
  }
277
277
 
278
278
  export class SuiGlobalProcessor extends SuiBaseProcessor {
279
279
  static bind(options: Omit<SuiBindOptions, 'address'>): SuiGlobalProcessor {
280
- return new SuiGlobalProcessor('*', { ...options, address: '*' })
280
+ return new SuiGlobalProcessor(ALL_ADDRESS, { ...options, address: ALL_ADDRESS })
281
281
  }
282
282
  onTransactionBlock(
283
283
  handler: (transaction: SuiTransactionBlockResponse, ctx: SuiContext) => void,
@@ -291,6 +291,7 @@ export class SuiGlobalProcessor extends SuiBaseProcessor {
291
291
  return super.onTransactionBlock(handler, filter, fetchConfig)
292
292
  }
293
293
 
294
+ // deprecated,, use object type processor
294
295
  public onObjectChange(
295
296
  handler: (changes: SuiObjectChange[], ctx: SuiObjectChangeContext) => void,
296
297
  type: string
@@ -3,6 +3,7 @@ import { DataBinding, HandlerType, ProcessBindingResponse } from '@sentio/protos
3
3
  import { Trace } from '../eth/eth.js'
4
4
  import { BlockParams, LogParams } from 'ethers/providers'
5
5
  import { ChainId, EthChainId } from '@sentio/chain'
6
+ import { ALL_ADDRESS } from '../index.js'
6
7
 
7
8
  export class EthFacet {
8
9
  server: TestProcessorServer
@@ -41,7 +42,7 @@ export class EthFacet {
41
42
  }
42
43
  if (
43
44
  trace.action.to?.toLowerCase() !== contract.contract?.address.toLowerCase() &&
44
- contract.contract?.address !== '*'
45
+ contract.contract?.address !== ALL_ADDRESS
45
46
  ) {
46
47
  continue
47
48
  }