@sentio/sdk 3.8.0-rc.3 → 3.9.0-rc.3

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 (139) hide show
  1. package/lib/aptos/builtin/0x1.d.ts +897 -0
  2. package/lib/aptos/builtin/0x1.d.ts.map +1 -1
  3. package/lib/aptos/builtin/0x1.js +1322 -91
  4. package/lib/aptos/builtin/0x1.js.map +1 -1
  5. package/lib/aptos/builtin/0x3.js +1 -1
  6. package/lib/aptos/builtin/0x3.js.map +1 -1
  7. package/lib/aptos/builtin/0x4.d.ts +4 -4
  8. package/lib/aptos/builtin/0x4.d.ts.map +1 -1
  9. package/lib/aptos/builtin/0x4.js +16 -16
  10. package/lib/aptos/builtin/0x4.js.map +1 -1
  11. package/lib/iota/builtin/0x2.d.ts +95 -0
  12. package/lib/iota/builtin/0x2.d.ts.map +1 -1
  13. package/lib/iota/builtin/0x2.js +586 -1
  14. package/lib/iota/builtin/0x2.js.map +1 -1
  15. package/lib/sui/builtin/0x1.d.ts +382 -270
  16. package/lib/sui/builtin/0x1.d.ts.map +1 -1
  17. package/lib/sui/builtin/0x1.js +2571 -805
  18. package/lib/sui/builtin/0x1.js.map +1 -1
  19. package/lib/sui/builtin/0x2.d.ts +1013 -730
  20. package/lib/sui/builtin/0x2.d.ts.map +1 -1
  21. package/lib/sui/builtin/0x2.js +7419 -2616
  22. package/lib/sui/builtin/0x2.js.map +1 -1
  23. package/lib/sui/builtin/0x3.d.ts +297 -297
  24. package/lib/sui/builtin/0x3.d.ts.map +1 -1
  25. package/lib/sui/builtin/0x3.js +2364 -904
  26. package/lib/sui/builtin/0x3.js.map +1 -1
  27. package/lib/sui/codegen/codegen.d.ts.map +1 -1
  28. package/lib/sui/codegen/codegen.js.map +1 -1
  29. package/lib/sui/context.d.ts +10 -9
  30. package/lib/sui/context.d.ts.map +1 -1
  31. package/lib/sui/context.js.map +1 -1
  32. package/lib/sui/ext/coin.d.ts.map +1 -1
  33. package/lib/sui/ext/coin.js +1 -1
  34. package/lib/sui/ext/coin.js.map +1 -1
  35. package/lib/sui/ext/move-dex.d.ts +3 -3
  36. package/lib/sui/ext/move-dex.d.ts.map +1 -1
  37. package/lib/sui/models.d.ts +5 -4
  38. package/lib/sui/models.d.ts.map +1 -1
  39. package/lib/sui/move-coder.d.ts.map +1 -1
  40. package/lib/sui/move-coder.js +1 -0
  41. package/lib/sui/move-coder.js.map +1 -1
  42. package/lib/sui/network.d.ts +2 -2
  43. package/lib/sui/network.d.ts.map +1 -1
  44. package/lib/sui/network.js +8 -8
  45. package/lib/sui/network.js.map +1 -1
  46. package/lib/sui/sui-object-processor-template.d.ts +6 -5
  47. package/lib/sui/sui-object-processor-template.d.ts.map +1 -1
  48. package/lib/sui/sui-object-processor-template.js.map +1 -1
  49. package/lib/sui/sui-object-processor.d.ts +15 -13
  50. package/lib/sui/sui-object-processor.d.ts.map +1 -1
  51. package/lib/sui/sui-object-processor.js +4 -2
  52. package/lib/sui/sui-object-processor.js.map +1 -1
  53. package/lib/sui/sui-processor.d.ts +8 -6
  54. package/lib/sui/sui-processor.d.ts.map +1 -1
  55. package/lib/sui/sui-processor.js +6 -10
  56. package/lib/sui/sui-processor.js.map +1 -1
  57. package/lib/sui/utils.d.ts +3 -2
  58. package/lib/sui/utils.d.ts.map +1 -1
  59. package/lib/sui/utils.js +9 -9
  60. package/lib/sui/utils.js.map +1 -1
  61. package/lib/testing/sui-facet.d.ts +5 -5
  62. package/lib/testing/sui-facet.d.ts.map +1 -1
  63. package/lib/testing/sui-facet.js +5 -5
  64. package/lib/testing/sui-facet.js.map +1 -1
  65. package/package.json +23 -16
  66. package/src/aptos/abis/0x1.json +8161 -2996
  67. package/src/aptos/abis/0x3.json +140 -75
  68. package/src/aptos/abis/0x4.json +75 -52
  69. package/src/aptos/builtin/0x1.ts +2577 -58
  70. package/src/aptos/builtin/0x3.ts +1 -1
  71. package/src/aptos/builtin/0x4.ts +18 -19
  72. package/src/iota/abis/0x2.json +464 -4
  73. package/src/iota/builtin/0x2.ts +911 -77
  74. package/src/sui/abis/0x1.json +8996 -5745
  75. package/src/sui/abis/0x2.json +38135 -28859
  76. package/src/sui/abis/0x3.json +14723 -10726
  77. package/src/sui/builtin/0x1.ts +4071 -1897
  78. package/src/sui/builtin/0x2.ts +14397 -7968
  79. package/src/sui/builtin/0x3.ts +3780 -2021
  80. package/src/sui/codegen/codegen.ts +4 -5
  81. package/src/sui/context.ts +15 -16
  82. package/src/sui/ext/coin.ts +4 -2
  83. package/src/sui/ext/move-dex.ts +5 -5
  84. package/src/sui/models.ts +5 -4
  85. package/src/sui/move-coder.ts +1 -0
  86. package/src/sui/network.ts +10 -9
  87. package/src/sui/sui-object-processor-template.ts +7 -6
  88. package/src/sui/sui-object-processor.ts +29 -21
  89. package/src/sui/sui-processor.ts +27 -30
  90. package/src/sui/utils.ts +14 -17
  91. package/src/testing/sui-facet.ts +13 -13
  92. package/lib/aptos/codegen/types.test.d.ts +0 -2
  93. package/lib/aptos/codegen/types.test.d.ts.map +0 -1
  94. package/lib/aptos/codegen/types.test.js.map +0 -1
  95. package/lib/aptos/ext/coin-event.test.d.ts +0 -2
  96. package/lib/aptos/ext/coin-event.test.d.ts.map +0 -1
  97. package/lib/aptos/ext/coin-event.test.js.map +0 -1
  98. package/lib/aptos/ext/coin.test.d.ts +0 -2
  99. package/lib/aptos/ext/coin.test.d.ts.map +0 -1
  100. package/lib/aptos/ext/coin.test.js.map +0 -1
  101. package/lib/core/database-schema.test.d.ts +0 -2
  102. package/lib/core/database-schema.test.d.ts.map +0 -1
  103. package/lib/core/database-schema.test.js.map +0 -1
  104. package/lib/core/event-logger.test.d.ts +0 -2
  105. package/lib/core/event-logger.test.d.ts.map +0 -1
  106. package/lib/core/event-logger.test.js.map +0 -1
  107. package/lib/core/normalization.test.d.ts +0 -2
  108. package/lib/core/normalization.test.d.ts.map +0 -1
  109. package/lib/core/normalization.test.js.map +0 -1
  110. package/lib/core/numberish.test.d.ts +0 -2
  111. package/lib/core/numberish.test.d.ts.map +0 -1
  112. package/lib/core/numberish.test.js.map +0 -1
  113. package/lib/eth/base-processor.test.d.ts +0 -2
  114. package/lib/eth/base-processor.test.d.ts.map +0 -1
  115. package/lib/eth/base-processor.test.js.map +0 -1
  116. package/lib/eth/eth.test.d.ts +0 -2
  117. package/lib/eth/eth.test.d.ts.map +0 -1
  118. package/lib/eth/eth.test.js.map +0 -1
  119. package/lib/eth/generic-processor.test.d.ts +0 -2
  120. package/lib/eth/generic-processor.test.d.ts.map +0 -1
  121. package/lib/eth/generic-processor.test.js.map +0 -1
  122. package/lib/eth/provider.test.d.ts +0 -2
  123. package/lib/eth/provider.test.d.ts.map +0 -1
  124. package/lib/eth/provider.test.js.map +0 -1
  125. package/lib/store/convert.test.d.ts +0 -2
  126. package/lib/store/convert.test.d.ts.map +0 -1
  127. package/lib/store/convert.test.js.map +0 -1
  128. package/lib/utils/block.test.d.ts +0 -2
  129. package/lib/utils/block.test.d.ts.map +0 -1
  130. package/lib/utils/block.test.js.map +0 -1
  131. package/lib/utils/dex-price.test.d.ts +0 -2
  132. package/lib/utils/dex-price.test.d.ts.map +0 -1
  133. package/lib/utils/dex-price.test.js.map +0 -1
  134. package/lib/utils/erc20.test.d.ts +0 -2
  135. package/lib/utils/erc20.test.d.ts.map +0 -1
  136. package/lib/utils/erc20.test.js.map +0 -1
  137. package/lib/utils/price.test.d.ts +0 -2
  138. package/lib/utils/price.test.d.ts.map +0 -1
  139. package/lib/utils/price.test.js.map +0 -1
@@ -1,9 +1,8 @@
1
- import { SuiMoveNormalizedModule, SuiEvent, SuiMoveObject } from '@mysten/sui/jsonRpc'
2
-
3
1
  import * as fs from 'fs'
4
2
  import chalk from 'chalk'
5
3
  import { InternalMoveModule, InternalMoveStruct, structQname } from '@typemove/move'
6
4
  import { SuiCodegen as BaseSuiCodegen } from '@typemove/sui/codegen'
5
+ import type { ModuleWithAddress, SuiEventInput, SuiMoveObjectInput } from '@typemove/sui'
7
6
  import path, { join } from 'path'
8
7
  import { SharedNetworkCodegen } from '../../move/shared-network-codegen.js'
9
8
  import { getRpcEndpoint, SuiNetwork } from '../network.js'
@@ -24,7 +23,7 @@ export async function codegen(
24
23
  }
25
24
 
26
25
  class SuiNetworkCodegen extends BaseSuiCodegen {
27
- moduleGenerator: SharedNetworkCodegen<SuiNetwork, SuiMoveNormalizedModule, SuiEvent | SuiMoveObject>
26
+ moduleGenerator: SharedNetworkCodegen<SuiNetwork, ModuleWithAddress, SuiEventInput | SuiMoveObjectInput>
28
27
  SYSTEM_PACKAGE = '@sentio/sdk/sui'
29
28
 
30
29
  constructor(network: SuiNetwork) {
@@ -33,8 +32,8 @@ class SuiNetworkCodegen extends BaseSuiCodegen {
33
32
  const generator = this
34
33
  this.moduleGenerator = new (class extends SharedNetworkCodegen<
35
34
  SuiNetwork,
36
- SuiMoveNormalizedModule,
37
- SuiEvent | SuiMoveObject
35
+ ModuleWithAddress,
36
+ SuiEventInput | SuiMoveObjectInput
38
37
  > {
39
38
  ADDRESS_TYPE = 'string'
40
39
  PREFIX = 'Sui'
@@ -1,22 +1,17 @@
1
1
  import { RecordMetaData } from '@sentio/protos'
2
2
  import { type Labels, normalizeLabels } from '../index.js'
3
3
  import { getClient, SuiNetwork } from './network.js'
4
- import {
5
- SuiTransactionBlockResponse,
6
- SuiEvent,
7
- SuiMoveNormalizedModule,
8
- SuiMoveObject,
9
- SuiJsonRpcClient
10
- } from '@mysten/sui/jsonRpc'
4
+ import type { GrpcTypes, SuiGrpcClient } from '@mysten/sui/grpc'
5
+ import type { ModuleWithAddress, SuiEventInput, SuiMoveObjectInput } from '@typemove/sui'
11
6
  import { MoveCoder } from './index.js'
12
7
  import { defaultMoveCoder } from './move-coder.js'
13
8
  import { MoveAccountContext, MoveContext } from '../move/index.js'
14
9
 
15
- export class SuiContext extends MoveContext<SuiNetwork, SuiMoveNormalizedModule, SuiEvent | SuiMoveObject> {
10
+ export class SuiContext extends MoveContext<SuiNetwork, ModuleWithAddress, SuiEventInput | SuiMoveObjectInput> {
16
11
  moduleName: string
17
12
  timestamp: Date
18
13
  checkpoint: bigint
19
- transaction: SuiTransactionBlockResponse
14
+ transaction: GrpcTypes.ExecutedTransaction
20
15
  eventIndex: number
21
16
  coder: MoveCoder
22
17
 
@@ -26,7 +21,7 @@ export class SuiContext extends MoveContext<SuiNetwork, SuiMoveNormalizedModule,
26
21
  address: string,
27
22
  timestamp: Date,
28
23
  checkpoint: bigint,
29
- transaction: SuiTransactionBlockResponse,
24
+ transaction: GrpcTypes.ExecutedTransaction,
30
25
  eventIndex: number,
31
26
  baseLabels: Labels | undefined
32
27
  ) {
@@ -65,12 +60,16 @@ export class SuiContext extends MoveContext<SuiNetwork, SuiMoveNormalizedModule,
65
60
  }
66
61
  }
67
62
 
68
- get client(): SuiJsonRpcClient {
63
+ get client(): SuiGrpcClient {
69
64
  return getClient(this.network)
70
65
  }
71
66
  }
72
67
 
73
- export class SuiObjectChangeContext extends MoveContext<SuiNetwork, SuiMoveNormalizedModule, SuiEvent | SuiMoveObject> {
68
+ export class SuiObjectChangeContext extends MoveContext<
69
+ SuiNetwork,
70
+ ModuleWithAddress,
71
+ SuiEventInput | SuiMoveObjectInput
72
+ > {
74
73
  timestamp: Date
75
74
  checkpoint: bigint
76
75
  coder: MoveCoder
@@ -115,7 +114,7 @@ export class SuiObjectChangeContext extends MoveContext<SuiNetwork, SuiMoveNorma
115
114
  }
116
115
  }
117
116
 
118
- get client(): SuiJsonRpcClient {
117
+ get client(): SuiGrpcClient {
119
118
  return getClient(this.network)
120
119
  }
121
120
  }
@@ -123,8 +122,8 @@ export class SuiObjectChangeContext extends MoveContext<SuiNetwork, SuiMoveNorma
123
122
  // TODO address handler should use this context
124
123
  export class SuiAddressContext extends MoveAccountContext<
125
124
  SuiNetwork,
126
- SuiMoveNormalizedModule,
127
- SuiEvent | SuiMoveObject
125
+ ModuleWithAddress,
126
+ SuiEventInput | SuiMoveObjectInput
128
127
  > {
129
128
  address: string
130
129
  network: SuiNetwork
@@ -167,7 +166,7 @@ export class SuiAddressContext extends MoveAccountContext<
167
166
  }
168
167
  }
169
168
 
170
- get client(): SuiJsonRpcClient {
169
+ get client(): SuiGrpcClient {
171
170
  return getClient(this.network)
172
171
  }
173
172
 
@@ -5,7 +5,9 @@ import { getPriceByType } from '../../utils/index.js'
5
5
  import { SuiChainId } from '@sentio/chain'
6
6
  // import { validateAndNormalizeAddress } from '../utils.js'
7
7
  import { getClient, SuiNetwork } from '../network.js'
8
- import { CoinMetadata } from '@mysten/sui/jsonRpc'
8
+ import type { SuiClientTypes } from '@mysten/sui/client'
9
+
10
+ type CoinMetadata = SuiClientTypes.CoinMetadata
9
11
 
10
12
  const WHITELISTED_COINS = new Map<string, BaseCoinInfo>()
11
13
 
@@ -96,7 +98,7 @@ export async function getCoinInfoWithFallback(type: string, network?: SuiNetwork
96
98
  let promise = COIN_METADATA_CACHE.get(key)
97
99
  if (!promise) {
98
100
  const client = getClient(network)
99
- promise = client.getCoinMetadata({ coinType: type })
101
+ promise = client.getCoinMetadata({ coinType: type }).then((r) => r.coinMetadata)
100
102
  COIN_METADATA_CACHE.set(key, promise)
101
103
  }
102
104
  const meta = await promise
@@ -1,11 +1,11 @@
1
1
  import { BigDecimal } from '@sentio/bigdecimal'
2
2
  import { calculateValueInUsd, getCoinInfo, whitelistCoins, whiteListed } from './coin.js'
3
3
  import { MoveCoinList, MoveDex, moveGetPairValue, MovePoolAdaptor, BaseCoinInfo } from '../../move/ext/index.js'
4
- import { SuiEvent, SuiMoveNormalizedModule, SuiMoveObject } from '@mysten/sui/jsonRpc'
4
+ import type { ModuleWithAddress, SuiEventInput, SuiMoveObjectInput } from '@typemove/sui'
5
5
  import { SuiNetwork } from '../network.js'
6
6
  import { SuiContext, SuiObjectContext } from '../context.js'
7
7
 
8
- export type PoolAdaptor<T> = MovePoolAdaptor<SuiMoveObject, T>
8
+ export type PoolAdaptor<T> = MovePoolAdaptor<SuiMoveObjectInput, T>
9
9
 
10
10
  export class CoinList implements MoveCoinList<BaseCoinInfo, SuiNetwork> {
11
11
  calculateValueInUsd(amount: bigint, coinInfo: BaseCoinInfo, timestamp: number): Promise<BigDecimal> {
@@ -30,9 +30,9 @@ export const SuiCoinList = new CoinList()
30
30
  export class SuiDex<T> extends MoveDex<
31
31
  BaseCoinInfo,
32
32
  SuiNetwork,
33
- SuiMoveNormalizedModule,
34
- SuiMoveObject,
35
- SuiEvent,
33
+ ModuleWithAddress,
34
+ SuiMoveObjectInput,
35
+ SuiEventInput,
36
36
  SuiContext,
37
37
  SuiObjectContext,
38
38
  T
package/src/sui/models.ts CHANGED
@@ -1,10 +1,11 @@
1
- import type { SuiEvent, MoveCallSuiTransaction, SuiMoveObject } from '@mysten/sui/jsonRpc'
1
+ import type { GrpcTypes } from '@mysten/sui/grpc'
2
+ import type { SuiEventInput, SuiMoveObjectInput } from '@typemove/sui'
2
3
  import { DecodedStruct } from '@typemove/move'
3
4
 
4
- export type TypedEventInstance<T> = DecodedStruct<SuiEvent, T>
5
- export type TypedSuiMoveObject<T> = DecodedStruct<SuiMoveObject, T>
5
+ export type TypedEventInstance<T> = DecodedStruct<SuiEventInput, T>
6
+ export type TypedSuiMoveObject<T> = DecodedStruct<SuiMoveObjectInput, T>
6
7
 
7
- export type TypedFunctionPayload<T extends Array<any>> = MoveCallSuiTransaction & {
8
+ export type TypedFunctionPayload<T extends Array<any>> = GrpcTypes.MoveCall & {
8
9
  /**
9
10
  * decoded argument data using ABI, undefined if there is decoding error, usually because the ABI/data mismatch
10
11
  */
@@ -7,6 +7,7 @@ const CODERS = new Map<SuiNetwork, MoveCoder>()
7
7
  export function defaultMoveCoder(network: SuiNetwork = SuiNetwork.MAIN_NET): MoveCoder {
8
8
  let coder = CODERS.get(network)
9
9
  if (!coder) {
10
+ // @typemove/sui v2 MoveCoder is gRPC-backed.
10
11
  coder = new MoveCoder(getClient(network))
11
12
  CODERS.set(network, coder)
12
13
  }
@@ -1,7 +1,6 @@
1
1
  import { SuiChainId } from '@sentio/chain'
2
2
  import { Endpoints } from '@sentio/runtime'
3
- // import { ServerError, Status } from 'nice-grpc'
4
- import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc'
3
+ import { SuiGrpcClient } from '@mysten/sui/grpc'
5
4
 
6
5
  export type SuiNetwork = SuiChainId
7
6
  export const SuiNetwork = <const>{
@@ -17,13 +16,15 @@ function inferNetworkFromUrl(url: string): string {
17
16
  return 'custom'
18
17
  }
19
18
 
20
- export function getClient(network: SuiNetwork): SuiJsonRpcClient {
21
- let chainServer = Endpoints.INSTANCE.chainServer.get(network)
22
- if (!chainServer) {
23
- chainServer = getRpcEndpoint(network)
24
- // throw new ServerError(Status.INTERNAL, 'RPC endpoint not provided')
25
- }
26
- return new SuiJsonRpcClient({ url: chainServer, network: inferNetworkFromUrl(chainServer) })
19
+ function endpointFor(network: SuiNetwork): string {
20
+ return Endpoints.INSTANCE.chainServer.get(network) ?? getRpcEndpoint(network)
21
+ }
22
+
23
+ // gRPC client used for the MoveCoder, generated view functions, and exposed to
24
+ // processor handlers via `ctx.client`. @typemove/sui v2 is gRPC-only.
25
+ export function getClient(network: SuiNetwork): SuiGrpcClient {
26
+ const chainServer = endpointFor(network)
27
+ return new SuiGrpcClient({ network: inferNetworkFromUrl(chainServer) as any, baseUrl: chainServer })
27
28
  }
28
29
 
29
30
  export function getRpcEndpoint(network: SuiNetwork): string {
@@ -1,7 +1,8 @@
1
1
  import { HandleInterval, MoveAccountFetchConfig, MoveFetchConfig, TemplateInstance } from '@sentio/protos'
2
2
  import { ListStateStorage, processMetrics } from '@sentio/runtime'
3
3
  import { SuiAddressContext, SuiContext, SuiObjectContext } from './context.js'
4
- import { SuiMoveObject, SuiTransactionBlockResponse } from '@mysten/sui/jsonRpc'
4
+ import type { GrpcTypes } from '@mysten/sui/grpc'
5
+ import type { SuiMoveObjectInput } from '@typemove/sui'
5
6
  import { PromiseOrVoid } from '../core/index.js'
6
7
  import {
7
8
  DEFAULT_ACCOUNT_FETCH_CONFIG,
@@ -233,13 +234,13 @@ export abstract class SuiObjectOrAddressProcessorTemplate<
233
234
  }
234
235
 
235
236
  class AddressTransactionHandler {
236
- handler: (transaction: SuiTransactionBlockResponse, ctx: SuiContext) => void
237
+ handler: (transaction: GrpcTypes.ExecutedTransaction, ctx: SuiContext) => void
237
238
  filter?: TransactionFilter
238
239
  fetchConfig?: Partial<MoveFetchConfig>
239
240
  }
240
241
 
241
242
  export class SuiAddressProcessorTemplate extends SuiObjectOrAddressProcessorTemplate<
242
- (objects: SuiMoveObject[], ctx: SuiAddressContext) => PromiseOrVoid,
243
+ (objects: SuiMoveObjectInput[], ctx: SuiAddressContext) => PromiseOrVoid,
243
244
  SuiBindOptions,
244
245
  SuiAddressProcessor
245
246
  > {
@@ -255,7 +256,7 @@ export class SuiAddressProcessorTemplate extends SuiObjectOrAddressProcessorTemp
255
256
  }
256
257
 
257
258
  onTransactionBlock(
258
- handler: (transaction: SuiTransactionBlockResponse, ctx: SuiContext) => void,
259
+ handler: (transaction: GrpcTypes.ExecutedTransaction, ctx: SuiContext) => void,
259
260
  filter?: TransactionFilter,
260
261
  fetchConfig?: Partial<MoveFetchConfig>
261
262
  ): this {
@@ -269,7 +270,7 @@ export class SuiAddressProcessorTemplate extends SuiObjectOrAddressProcessorTemp
269
270
  }
270
271
 
271
272
  export class SuiObjectProcessorTemplate extends SuiObjectOrAddressProcessorTemplate<
272
- (self: SuiMoveObject, dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid,
273
+ (self: SuiMoveObjectInput, dynamicFieldObjects: SuiMoveObjectInput[], ctx: SuiObjectContext) => PromiseOrVoid,
273
274
  SuiObjectBindOptions,
274
275
  SuiObjectProcessor
275
276
  > {
@@ -281,7 +282,7 @@ export class SuiObjectProcessorTemplate extends SuiObjectOrAddressProcessorTempl
281
282
  }
282
283
 
283
284
  export class SuiWrappedObjectProcessorTemplate extends SuiObjectOrAddressProcessorTemplate<
284
- (dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid,
285
+ (dynamicFieldObjects: SuiMoveObjectInput[], ctx: SuiObjectContext) => PromiseOrVoid,
285
286
  SuiObjectBindOptions,
286
287
  SuiWrappedObjectProcessor
287
288
  > {
@@ -11,7 +11,9 @@ import {
11
11
  import { ListStateStorage } from '@sentio/runtime'
12
12
  import { SuiNetwork } from './network.js'
13
13
  import { SuiAddressContext, SuiContext, SuiObjectChangeContext, SuiObjectContext } from './context.js'
14
- import { SuiMoveObject, SuiObjectChange, SuiTransactionBlockResponse } from '@mysten/sui/jsonRpc'
14
+ import type { SuiObjectChange } from '@mysten/sui/jsonRpc'
15
+ import type { GrpcTypes } from '@mysten/sui/grpc'
16
+ import type { SuiMoveObjectInput } from '@typemove/sui'
15
17
  import { ALL_ADDRESS, PromiseOrVoid } from '../core/index.js'
16
18
  import { configure, DEFAULT_FETCH_CONFIG, IndexConfigure, SuiBindOptions } from './sui-processor.js'
17
19
  import { CallHandler, TransactionFilter, accountTypeString, ObjectChangeHandler } from '../move/index.js'
@@ -91,12 +93,12 @@ export abstract class SuiBaseObjectOrAddressProcessor<HandlerType> {
91
93
  return this.config.network
92
94
  }
93
95
 
94
- // protected abstract transformObjects(objects: SuiMoveObject[]): SuiMoveObject[]
96
+ // protected abstract transformObjects(objects: SuiMoveObjectInput[]): SuiMoveObjectInput[]
95
97
 
96
98
  protected abstract doHandle(handler: HandlerType, data: Data_SuiObject, ctx: SuiObjectContext): Promise<any>
97
99
 
98
100
  public onInterval(
99
- handler: HandlerType, //(resources: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid,
101
+ handler: HandlerType, //(resources: SuiMoveObjectInput[], ctx: SuiObjectsContext) => PromiseOrVoid,
100
102
  timeInterval: HandleInterval | undefined,
101
103
  checkpointInterval: HandleInterval | undefined,
102
104
  type: string | undefined,
@@ -167,7 +169,7 @@ abstract class SuiBaseObjectOrAddressProcessorInternal<
167
169
  }
168
170
 
169
171
  export class SuiAddressProcessor extends SuiBaseObjectOrAddressProcessorInternal<
170
- (objects: SuiMoveObject[], ctx: SuiAddressContext) => PromiseOrVoid
172
+ (objects: SuiMoveObjectInput[], ctx: SuiAddressContext) => PromiseOrVoid
171
173
  > {
172
174
  callHandlers: CallHandler<Data_SuiCall>[] = []
173
175
 
@@ -176,15 +178,15 @@ export class SuiAddressProcessor extends SuiBaseObjectOrAddressProcessorInternal
176
178
  }
177
179
 
178
180
  protected async doHandle(
179
- handler: (objects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid,
181
+ handler: (objects: SuiMoveObjectInput[], ctx: SuiObjectContext) => PromiseOrVoid,
180
182
  data: Data_SuiObject,
181
183
  ctx: SuiObjectContext
182
184
  ) {
183
- return handler(data.rawObjects.map((o) => JSON.parse(o)) as SuiMoveObject[], ctx)
185
+ return handler(data.rawObjects.map((o) => JSON.parse(o)) as SuiMoveObjectInput[], ctx)
184
186
  }
185
187
 
186
188
  onTransactionBlock(
187
- handler: (transaction: SuiTransactionBlockResponse, ctx: SuiContext) => PromiseOrVoid,
189
+ handler: (transaction: GrpcTypes.ExecutedTransaction, ctx: SuiContext) => PromiseOrVoid,
188
190
  filter?: TransactionFilter,
189
191
  fetchConfig?: Partial<MoveFetchConfig>
190
192
  ) {
@@ -205,7 +207,7 @@ export class SuiAddressProcessor extends SuiBaseObjectOrAddressProcessorInternal
205
207
  if (!data.rawTransaction) {
206
208
  throw new ServerError(Status.INVALID_ARGUMENT, 'transaction is null')
207
209
  }
208
- const tx = JSON.parse(data.rawTransaction) as SuiTransactionBlockResponse
210
+ const tx = JSON.parse(data.rawTransaction) as GrpcTypes.ExecutedTransaction
209
211
 
210
212
  const ctx = new SuiContext(
211
213
  'object',
@@ -230,7 +232,7 @@ export class SuiAddressProcessor extends SuiBaseObjectOrAddressProcessorInternal
230
232
  }
231
233
 
232
234
  export class SuiObjectProcessor extends SuiBaseObjectOrAddressProcessorInternal<
233
- (self: SuiMoveObject, dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid
235
+ (self: SuiMoveObjectInput, dynamicFieldObjects: SuiMoveObjectInput[], ctx: SuiObjectContext) => PromiseOrVoid
234
236
  > {
235
237
  static bind(options: SuiObjectBindOptions): SuiObjectProcessor {
236
238
  return new SuiObjectProcessor({
@@ -244,7 +246,11 @@ export class SuiObjectProcessor extends SuiBaseObjectOrAddressProcessorInternal<
244
246
  }
245
247
 
246
248
  protected async doHandle(
247
- handler: (self: SuiMoveObject, dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid,
249
+ handler: (
250
+ self: SuiMoveObjectInput,
251
+ dynamicFieldObjects: SuiMoveObjectInput[],
252
+ ctx: SuiObjectContext
253
+ ) => PromiseOrVoid,
248
254
  data: Data_SuiObject,
249
255
  ctx: SuiObjectContext
250
256
  ) {
@@ -253,15 +259,15 @@ export class SuiObjectProcessor extends SuiBaseObjectOrAddressProcessorInternal<
253
259
  return
254
260
  }
255
261
  return handler(
256
- JSON.parse(data.rawSelf) as SuiMoveObject,
257
- data.rawObjects.map((o) => JSON.parse(o)) as SuiMoveObject[],
262
+ JSON.parse(data.rawSelf) as SuiMoveObjectInput,
263
+ data.rawObjects.map((o) => JSON.parse(o)) as SuiMoveObjectInput[],
258
264
  ctx
259
265
  )
260
266
  }
261
267
  }
262
268
 
263
269
  export class SuiObjectTypeProcessor<T> extends SuiBaseObjectOrAddressProcessor<
264
- (self: TypedSuiMoveObject<T>, dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid
270
+ (self: TypedSuiMoveObject<T>, dynamicFieldObjects: SuiMoveObjectInput[], ctx: SuiObjectContext) => PromiseOrVoid
265
271
  > {
266
272
  objectType: TypeDescriptor<T>
267
273
 
@@ -281,7 +287,7 @@ export class SuiObjectTypeProcessor<T> extends SuiBaseObjectOrAddressProcessor<
281
287
  protected async doHandle(
282
288
  handler: (
283
289
  self: TypedSuiMoveObject<T>,
284
- dynamicFieldObjects: SuiMoveObject[],
290
+ dynamicFieldObjects: SuiMoveObjectInput[],
285
291
  ctx: SuiObjectContext
286
292
  ) => PromiseOrVoid,
287
293
  data: Data_SuiObject,
@@ -291,8 +297,10 @@ export class SuiObjectTypeProcessor<T> extends SuiBaseObjectOrAddressProcessor<
291
297
  console.log(`Sui object not existed in ${ctx.checkpoint}, please specific a start time`)
292
298
  return
293
299
  }
294
- const object = await ctx.coder.filterAndDecodeObjects(this.objectType, [JSON.parse(data.rawSelf) as SuiMoveObject])
295
- return handler(object[0], data.rawObjects.map((o) => JSON.parse(o)) as SuiMoveObject[], ctx)
300
+ const object = await ctx.coder.filterAndDecodeObjects(this.objectType, [
301
+ JSON.parse(data.rawSelf) as SuiMoveObjectInput
302
+ ])
303
+ return handler(object[0], data.rawObjects.map((o) => JSON.parse(o)) as SuiMoveObjectInput[], ctx)
296
304
  }
297
305
 
298
306
  public onObjectChange(handler: (changes: SuiObjectChange[], ctx: SuiObjectChangeContext) => PromiseOrVoid): this {
@@ -323,7 +331,7 @@ export class SuiObjectTypeProcessor<T> extends SuiBaseObjectOrAddressProcessor<
323
331
  public onTimeInterval(
324
332
  handler: (
325
333
  self: TypedSuiMoveObject<T>,
326
- dynamicFieldObjects: SuiMoveObject[],
334
+ dynamicFieldObjects: SuiMoveObjectInput[],
327
335
  ctx: SuiObjectContext
328
336
  ) => PromiseOrVoid,
329
337
  timeIntervalInMinutes = 60,
@@ -345,7 +353,7 @@ export class SuiObjectTypeProcessor<T> extends SuiBaseObjectOrAddressProcessor<
345
353
  public onCheckpointInterval(
346
354
  handler: (
347
355
  self: TypedSuiMoveObject<T>,
348
- dynamicFieldObjects: SuiMoveObject[],
356
+ dynamicFieldObjects: SuiMoveObjectInput[],
349
357
  ctx: SuiObjectContext
350
358
  ) => PromiseOrVoid,
351
359
  checkpointInterval = 100000,
@@ -363,7 +371,7 @@ export class SuiObjectTypeProcessor<T> extends SuiBaseObjectOrAddressProcessor<
363
371
  }
364
372
 
365
373
  export class SuiWrappedObjectProcessor extends SuiBaseObjectOrAddressProcessorInternal<
366
- (dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid
374
+ (dynamicFieldObjects: SuiMoveObjectInput[], ctx: SuiObjectContext) => PromiseOrVoid
367
375
  > {
368
376
  static bind(options: SuiObjectBindOptions): SuiWrappedObjectProcessor {
369
377
  return new SuiWrappedObjectProcessor({
@@ -377,10 +385,10 @@ export class SuiWrappedObjectProcessor extends SuiBaseObjectOrAddressProcessorIn
377
385
  }
378
386
 
379
387
  protected async doHandle(
380
- handler: (dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid,
388
+ handler: (dynamicFieldObjects: SuiMoveObjectInput[], ctx: SuiObjectContext) => PromiseOrVoid,
381
389
  data: Data_SuiObject,
382
390
  ctx: SuiObjectContext
383
391
  ) {
384
- return handler(data.rawObjects.map((o) => JSON.parse(o)) as SuiMoveObject[], ctx)
392
+ return handler(data.rawObjects.map((o) => JSON.parse(o)) as SuiMoveObjectInput[], ctx)
385
393
  }
386
394
  }
@@ -3,7 +3,9 @@ import { ListStateStorage } from '@sentio/runtime'
3
3
  import { SuiNetwork } from './network.js'
4
4
  import { ServerError, Status } from 'nice-grpc'
5
5
  import { SuiContext, SuiObjectChangeContext } from './context.js'
6
- import { MoveCallSuiTransaction, SuiEvent, SuiTransactionBlockResponse, SuiObjectChange } from '@mysten/sui/jsonRpc'
6
+ import type { SuiObjectChange } from '@mysten/sui/jsonRpc'
7
+ import type { GrpcTypes } from '@mysten/sui/grpc'
8
+ import type { SuiEventInput } from '@typemove/sui'
7
9
  import {
8
10
  accountAddressString,
9
11
  CallHandler,
@@ -14,7 +16,7 @@ import {
14
16
  SPLITTER,
15
17
  TransactionFilter
16
18
  } from '../move/index.js'
17
- import { getMoveCalls } from './utils.js'
19
+ import { getMoveCalls, getProgrammableTransaction } from './utils.js'
18
20
  import { defaultMoveCoder, MoveCoder } from './index.js'
19
21
  import { ALL_ADDRESS, Labels, PromiseOrVoid } from '../core/index.js'
20
22
  import { Required } from 'utility-types'
@@ -75,9 +77,9 @@ export class SuiBaseProcessor {
75
77
  }
76
78
 
77
79
  protected onMoveEvent(
78
- handler: (event: SuiEvent, ctx: SuiContext) => PromiseOrVoid,
80
+ handler: (event: SuiEventInput, ctx: SuiContext) => PromiseOrVoid,
79
81
  filter: EventFilter | EventFilter[],
80
- handlerOptions?: HandlerOptions<MoveFetchConfig, SuiEvent>
82
+ handlerOptions?: HandlerOptions<MoveFetchConfig, SuiEventInput>
81
83
  ): SuiBaseProcessor {
82
84
  let _filters: EventFilter[] = []
83
85
  const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...handlerOptions })
@@ -99,13 +101,11 @@ export class SuiBaseProcessor {
99
101
  if (!data.rawTransaction) {
100
102
  throw new ServerError(Status.INVALID_ARGUMENT, 'event is null')
101
103
  }
102
- const txn = JSON.parse(data.rawTransaction) as SuiTransactionBlockResponse
103
- if (txn.events == null) {
104
- txn.events = []
105
- }
104
+ const txn = JSON.parse(data.rawTransaction) as GrpcTypes.ExecutedTransaction
106
105
 
107
- const evt = JSON.parse(data.rawEvent) as SuiEvent
108
- const idx = Number(evt.id.eventSeq) || 0
106
+ const evt = JSON.parse(data.rawEvent) as SuiEventInput
107
+ // gRPC events carry no sequence; index is resolved by the runtime.
108
+ const idx = 0
109
109
 
110
110
  const ctx = new SuiContext(
111
111
  processor.moduleName,
@@ -129,7 +129,7 @@ export class SuiBaseProcessor {
129
129
  const p = handlerOptions?.partitionKey
130
130
  if (!p) return undefined
131
131
  if (typeof p === 'function') {
132
- const evt = JSON.parse(data.rawEvent) as SuiEvent
132
+ const evt = JSON.parse(data.rawEvent) as SuiEventInput
133
133
  const decoded = await processor.coder.decodeEvent<any>(evt)
134
134
  return p(decoded || evt)
135
135
  }
@@ -140,9 +140,9 @@ export class SuiBaseProcessor {
140
140
  }
141
141
 
142
142
  protected onEntryFunctionCall(
143
- handler: (call: MoveCallSuiTransaction, ctx: SuiContext) => PromiseOrVoid,
143
+ handler: (call: GrpcTypes.MoveCall, ctx: SuiContext) => PromiseOrVoid,
144
144
  filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[],
145
- handlerOptions?: HandlerOptions<MoveFetchConfig, MoveCallSuiTransaction>
145
+ handlerOptions?: HandlerOptions<MoveFetchConfig, GrpcTypes.MoveCall>
146
146
  ): SuiBaseProcessor {
147
147
  let _filters: FunctionNameAndCallFilter[] = []
148
148
  const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...handlerOptions })
@@ -162,7 +162,7 @@ export class SuiBaseProcessor {
162
162
  if (!data.rawTransaction) {
163
163
  throw new ServerError(Status.INVALID_ARGUMENT, 'call is null')
164
164
  }
165
- const tx = JSON.parse(data.rawTransaction) as SuiTransactionBlockResponse
165
+ const tx = JSON.parse(data.rawTransaction) as GrpcTypes.ExecutedTransaction
166
166
 
167
167
  const ctx = new SuiContext(
168
168
  processor.moduleName,
@@ -175,15 +175,12 @@ export class SuiBaseProcessor {
175
175
  processor.config.baseLabels
176
176
  )
177
177
  if (tx) {
178
- const calls: MoveCallSuiTransaction[] = getMoveCalls(tx)
179
- const txKind = tx.transaction?.data?.transaction
180
- if (!txKind) {
178
+ const calls = getMoveCalls(tx)
179
+ const programmableTx = getProgrammableTransaction(tx)
180
+ if (!programmableTx) {
181
181
  throw new ServerError(Status.INVALID_ARGUMENT, 'Unexpected getTransactionKind get empty')
182
182
  }
183
183
 
184
- // getProgrammableTransaction(txKind)
185
- const programmableTx = txKind.kind === 'ProgrammableTransaction' ? txKind : undefined
186
-
187
184
  // TODO potential pass index
188
185
  for (const call of calls) {
189
186
  const functionType = [call.module, call.function].join(SPLITTER)
@@ -192,7 +189,7 @@ export class SuiBaseProcessor {
192
189
  }
193
190
 
194
191
  // TODO maybe do in parallel
195
- const decoded = await processor.coder.decodeFunctionPayload(call, programmableTx?.inputs || [])
192
+ const decoded = await processor.coder.decodeFunctionPayload(call, programmableTx.inputs)
196
193
  await handler(decoded, ctx)
197
194
  }
198
195
  }
@@ -204,8 +201,8 @@ export class SuiBaseProcessor {
204
201
  const p = handlerOptions?.partitionKey
205
202
  if (!p) return undefined
206
203
  if (typeof p === 'function') {
207
- const tx = JSON.parse(data.rawTransaction) as SuiTransactionBlockResponse
208
- const calls: MoveCallSuiTransaction[] = getMoveCalls(tx)
204
+ const tx = JSON.parse(data.rawTransaction) as GrpcTypes.ExecutedTransaction
205
+ const calls = getMoveCalls(tx)
209
206
  // For simplicity, use the first call for partitioning
210
207
  if (calls.length > 0) {
211
208
  return p(calls[0])
@@ -219,17 +216,17 @@ export class SuiBaseProcessor {
219
216
  }
220
217
 
221
218
  onEvent(
222
- handler: (event: SuiEvent, ctx: SuiContext) => void,
223
- handlerOptions?: HandlerOptions<MoveFetchConfig, SuiEvent>
219
+ handler: (event: SuiEventInput, ctx: SuiContext) => void,
220
+ handlerOptions?: HandlerOptions<MoveFetchConfig, SuiEventInput>
224
221
  ): this {
225
222
  this.onMoveEvent(handler, { type: '' }, handlerOptions)
226
223
  return this
227
224
  }
228
225
 
229
226
  onTransactionBlock(
230
- handler: (transaction: SuiTransactionBlockResponse, ctx: SuiContext) => PromiseOrVoid,
227
+ handler: (transaction: GrpcTypes.ExecutedTransaction, ctx: SuiContext) => PromiseOrVoid,
231
228
  filter?: TransactionFilter,
232
- handlerOptions?: HandlerOptions<MoveFetchConfig, SuiTransactionBlockResponse>
229
+ handlerOptions?: HandlerOptions<MoveFetchConfig, GrpcTypes.ExecutedTransaction>
233
230
  ): this {
234
231
  const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...handlerOptions })
235
232
 
@@ -241,7 +238,7 @@ export class SuiBaseProcessor {
241
238
  if (!data.rawTransaction) {
242
239
  throw new ServerError(Status.INVALID_ARGUMENT, 'transaction is null')
243
240
  }
244
- const tx = JSON.parse(data.rawTransaction) as SuiTransactionBlockResponse
241
+ const tx = JSON.parse(data.rawTransaction) as GrpcTypes.ExecutedTransaction
245
242
 
246
243
  const ctx = new SuiContext(
247
244
  processor.moduleName,
@@ -264,7 +261,7 @@ export class SuiBaseProcessor {
264
261
  const p = handlerOptions?.partitionKey
265
262
  if (!p) return undefined
266
263
  if (typeof p === 'function') {
267
- const tx = JSON.parse(data.rawTransaction) as SuiTransactionBlockResponse
264
+ const tx = JSON.parse(data.rawTransaction) as GrpcTypes.ExecutedTransaction
268
265
  return p(tx)
269
266
  }
270
267
  return p
@@ -313,7 +310,7 @@ export class SuiGlobalProcessor extends SuiBaseProcessor {
313
310
  return new SuiGlobalProcessor(ALL_ADDRESS, { ...options, address: ALL_ADDRESS })
314
311
  }
315
312
  onTransactionBlock(
316
- handler: (transaction: SuiTransactionBlockResponse, ctx: SuiContext) => void,
313
+ handler: (transaction: GrpcTypes.ExecutedTransaction, ctx: SuiContext) => void,
317
314
  filter: TransactionFilter,
318
315
  fetchConfig?: Partial<MoveFetchConfig>
319
316
  ): this {
package/src/sui/utils.ts CHANGED
@@ -1,26 +1,23 @@
1
- import {
2
- SuiTransactionBlockResponse,
3
- MoveCallSuiTransaction,
4
- ProgrammableTransaction,
5
- SuiTransaction
6
- } from '@mysten/sui/jsonRpc'
1
+ import type { GrpcTypes } from '@mysten/sui/grpc'
7
2
  import { accountTypeString } from '@typemove/move'
8
3
 
9
- export function getMoveCalls(txBlock: SuiTransactionBlockResponse) {
10
- const txKind = txBlock.transaction?.data.transaction
11
- if (!txKind) {
12
- return []
13
- }
14
- const programmableTx: ProgrammableTransaction | undefined =
15
- txKind.kind === 'ProgrammableTransaction' ? txKind : undefined
4
+ export function getProgrammableTransaction(
5
+ txBlock: GrpcTypes.ExecutedTransaction
6
+ ): GrpcTypes.ProgrammableTransaction | undefined {
7
+ const data = txBlock.transaction?.kind?.data
8
+ return data?.oneofKind === 'programmableTransaction' ? data.programmableTransaction : undefined
9
+ }
10
+
11
+ export function getMoveCalls(txBlock: GrpcTypes.ExecutedTransaction): GrpcTypes.MoveCall[] {
12
+ const programmableTx = getProgrammableTransaction(txBlock)
16
13
  if (!programmableTx) {
17
14
  return []
18
15
  }
19
16
 
20
- return programmableTx.transactions.flatMap((tx: SuiTransaction) => {
21
- if ('MoveCall' in tx) {
22
- const call = tx.MoveCall as MoveCallSuiTransaction
23
- call.package = accountTypeString(call.package)
17
+ return programmableTx.commands.flatMap((cmd) => {
18
+ if (cmd.command.oneofKind === 'moveCall') {
19
+ const call = cmd.command.moveCall
20
+ call.package = accountTypeString(call.package ?? '')
24
21
 
25
22
  return [call]
26
23
  }