@sentio/sdk 2.60.3 → 2.61.0-rc.10

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 (71) hide show
  1. package/lib/aptos/builtin/0x1.d.ts +125 -0
  2. package/lib/aptos/builtin/0x1.d.ts.map +1 -1
  3. package/lib/aptos/builtin/0x1.js +150 -6
  4. package/lib/aptos/builtin/0x1.js.map +1 -1
  5. package/lib/aptos/builtin/0x3.d.ts +10 -0
  6. package/lib/aptos/builtin/0x3.d.ts.map +1 -1
  7. package/lib/aptos/builtin/0x3.js +8 -0
  8. package/lib/aptos/builtin/0x3.js.map +1 -1
  9. package/lib/aptos/builtin/0x4.d.ts +40 -0
  10. package/lib/aptos/builtin/0x4.d.ts.map +1 -1
  11. package/lib/aptos/builtin/0x4.js +48 -2
  12. package/lib/aptos/builtin/0x4.js.map +1 -1
  13. package/lib/aptos/codegen/codegen.js +7 -12
  14. package/lib/aptos/codegen/codegen.js.map +1 -1
  15. package/lib/aptos/ext/coin-event.test.js.map +1 -1
  16. package/lib/aptos/network.d.ts +2 -2
  17. package/lib/aptos/network.d.ts.map +1 -1
  18. package/lib/aptos/network.js +22 -15
  19. package/lib/aptos/network.js.map +1 -1
  20. package/lib/core/core-plugin.d.ts.map +1 -1
  21. package/lib/core/core-plugin.js +4 -11
  22. package/lib/core/core-plugin.js.map +1 -1
  23. package/lib/core/database-schema.d.ts +1 -0
  24. package/lib/core/database-schema.d.ts.map +1 -1
  25. package/lib/core/database-schema.js +30 -0
  26. package/lib/core/database-schema.js.map +1 -1
  27. package/lib/core/database-schema.test.d.ts +2 -0
  28. package/lib/core/database-schema.test.d.ts.map +1 -0
  29. package/lib/core/database-schema.test.js.map +1 -0
  30. package/lib/fuel/transaction.d.ts.map +1 -1
  31. package/lib/fuel/transaction.js +23 -8
  32. package/lib/fuel/transaction.js.map +1 -1
  33. package/lib/iota/codegen/codegen.js +2 -5
  34. package/lib/iota/codegen/codegen.js.map +1 -1
  35. package/lib/iota/iota-plugin.d.ts +1 -0
  36. package/lib/iota/iota-plugin.d.ts.map +1 -1
  37. package/lib/iota/iota-plugin.js +1 -0
  38. package/lib/iota/iota-plugin.js.map +1 -1
  39. package/lib/sui/builtin/0x1.d.ts +72 -107
  40. package/lib/sui/builtin/0x1.d.ts.map +1 -1
  41. package/lib/sui/builtin/0x1.js +53 -1
  42. package/lib/sui/builtin/0x1.js.map +1 -1
  43. package/lib/sui/builtin/0x2.d.ts +610 -807
  44. package/lib/sui/builtin/0x2.d.ts.map +1 -1
  45. package/lib/sui/builtin/0x2.js +158 -2
  46. package/lib/sui/builtin/0x2.js.map +1 -1
  47. package/lib/sui/builtin/0x3.d.ts +290 -362
  48. package/lib/sui/builtin/0x3.d.ts.map +1 -1
  49. package/lib/sui/builtin/0x3.js +105 -1
  50. package/lib/sui/builtin/0x3.js.map +1 -1
  51. package/lib/sui/codegen/codegen.js +2 -5
  52. package/lib/sui/codegen/codegen.js.map +1 -1
  53. package/package.json +11 -11
  54. package/src/aptos/abis/0x1.json +47 -3
  55. package/src/aptos/builtin/0x1.ts +520 -1
  56. package/src/aptos/builtin/0x3.ts +46 -0
  57. package/src/aptos/builtin/0x4.ts +151 -0
  58. package/src/aptos/codegen/codegen.ts +7 -13
  59. package/src/aptos/network.ts +22 -14
  60. package/src/core/core-plugin.ts +4 -11
  61. package/src/core/database-schema.ts +29 -0
  62. package/src/fuel/transaction.ts +30 -9
  63. package/src/iota/codegen/codegen.ts +2 -5
  64. package/src/iota/iota-plugin.ts +2 -0
  65. package/src/sui/abis/0x1.json +52 -0
  66. package/src/sui/abis/0x2.json +134 -2
  67. package/src/sui/abis/0x3.json +180 -0
  68. package/src/sui/builtin/0x1.ts +143 -110
  69. package/src/sui/builtin/0x2.ts +796 -808
  70. package/src/sui/builtin/0x3.ts +422 -363
  71. package/src/sui/codegen/codegen.ts +2 -5
@@ -544,6 +544,22 @@ export class token extends AptosBaseProcessor {
544
544
  );
545
545
  return this;
546
546
  }
547
+
548
+ onEventWithdrawCapability(
549
+ func: (event: token.WithdrawCapabilityInstance, ctx: AptosContext) => void,
550
+ handlerOptions?: HandlerOptions<
551
+ MoveFetchConfig,
552
+ token.WithdrawCapabilityInstance
553
+ >,
554
+ eventFilter?: Omit<EventFilter, "type" | "account">,
555
+ ): token {
556
+ this.onMoveEvent(
557
+ func,
558
+ { ...(eventFilter ?? {}), type: "token::WithdrawCapability" },
559
+ handlerOptions,
560
+ );
561
+ return this;
562
+ }
547
563
  }
548
564
 
549
565
  export namespace token {
@@ -1219,6 +1235,12 @@ export namespace token {
1219
1235
  }
1220
1236
  }
1221
1237
 
1238
+ export type WithdrawCapabilityInstance =
1239
+ TypedEventInstance<WithdrawCapability> & {
1240
+ data_decoded: WithdrawCapability;
1241
+ type_arguments: [];
1242
+ };
1243
+
1222
1244
  export namespace entry {
1223
1245
  export async function burn(
1224
1246
  client: Aptos,
@@ -1740,6 +1762,25 @@ export class token_coin_swap extends AptosBaseProcessor {
1740
1762
  return this;
1741
1763
  }
1742
1764
 
1765
+ onEventTokenCoinSwap(
1766
+ func: (
1767
+ event: token_coin_swap.TokenCoinSwapInstance,
1768
+ ctx: AptosContext,
1769
+ ) => void,
1770
+ handlerOptions?: HandlerOptions<
1771
+ MoveFetchConfig,
1772
+ token_coin_swap.TokenCoinSwapInstance
1773
+ >,
1774
+ eventFilter?: Omit<EventFilter, "type" | "account">,
1775
+ ): token_coin_swap {
1776
+ this.onMoveEvent(
1777
+ func,
1778
+ { ...(eventFilter ?? {}), type: "token_coin_swap::TokenCoinSwap" },
1779
+ handlerOptions,
1780
+ );
1781
+ return this;
1782
+ }
1783
+
1743
1784
  onEventTokenListingEvent(
1744
1785
  func: (
1745
1786
  event: token_coin_swap.TokenListingEventInstance,
@@ -1799,6 +1840,11 @@ export namespace token_coin_swap {
1799
1840
  }
1800
1841
  }
1801
1842
 
1843
+ export type TokenCoinSwapInstance = TypedEventInstance<TokenCoinSwap<any>> & {
1844
+ data_decoded: TokenCoinSwap<any>;
1845
+ type_arguments: [string];
1846
+ };
1847
+
1802
1848
  export interface TokenEscrow {
1803
1849
  token: token.Token;
1804
1850
  locked_until_secs: bigint;
@@ -44,6 +44,32 @@ export class token extends AptosBaseProcessor {
44
44
  return new token({ ...token.DEFAULT_OPTIONS, ...options });
45
45
  }
46
46
 
47
+ onEventBurnRef(
48
+ func: (event: token.BurnRefInstance, ctx: AptosContext) => void,
49
+ handlerOptions?: HandlerOptions<MoveFetchConfig, token.BurnRefInstance>,
50
+ eventFilter?: Omit<EventFilter, "type" | "account">,
51
+ ): token {
52
+ this.onMoveEvent(
53
+ func,
54
+ { ...(eventFilter ?? {}), type: "token::BurnRef" },
55
+ handlerOptions,
56
+ );
57
+ return this;
58
+ }
59
+
60
+ onEventMutatorRef(
61
+ func: (event: token.MutatorRefInstance, ctx: AptosContext) => void,
62
+ handlerOptions?: HandlerOptions<MoveFetchConfig, token.MutatorRefInstance>,
63
+ eventFilter?: Omit<EventFilter, "type" | "account">,
64
+ ): token {
65
+ this.onMoveEvent(
66
+ func,
67
+ { ...(eventFilter ?? {}), type: "token::MutatorRef" },
68
+ handlerOptions,
69
+ );
70
+ return this;
71
+ }
72
+
47
73
  onEventMutation(
48
74
  func: (event: token.MutationInstance, ctx: AptosContext) => void,
49
75
  handlerOptions?: HandlerOptions<MoveFetchConfig, token.MutationInstance>,
@@ -90,6 +116,11 @@ export namespace token {
90
116
  }
91
117
  }
92
118
 
119
+ export type BurnRefInstance = TypedEventInstance<BurnRef> & {
120
+ data_decoded: BurnRef;
121
+ type_arguments: [];
122
+ };
123
+
93
124
  export interface MutatorRef {
94
125
  self: MoveAddressType;
95
126
  }
@@ -104,6 +135,11 @@ export namespace token {
104
135
  }
105
136
  }
106
137
 
138
+ export type MutatorRefInstance = TypedEventInstance<MutatorRef> & {
139
+ data_decoded: MutatorRef;
140
+ type_arguments: [];
141
+ };
142
+
107
143
  export interface Mutation {
108
144
  token_address: MoveAddressType;
109
145
  mutated_field_name: string;
@@ -400,6 +436,36 @@ export namespace token {
400
436
  }
401
437
  }
402
438
 
439
+ export class royalty extends AptosBaseProcessor {
440
+ constructor(options: AptosBindOptions) {
441
+ super("royalty", options);
442
+ }
443
+ static DEFAULT_OPTIONS: AptosBindOptions = {
444
+ address: "0x4",
445
+ network: AptosNetwork.MAIN_NET,
446
+ };
447
+
448
+ static bind(options: Partial<AptosBindOptions> = {}): royalty {
449
+ return new royalty({ ...royalty.DEFAULT_OPTIONS, ...options });
450
+ }
451
+
452
+ onEventMutatorRef(
453
+ func: (event: royalty.MutatorRefInstance, ctx: AptosContext) => void,
454
+ handlerOptions?: HandlerOptions<
455
+ MoveFetchConfig,
456
+ royalty.MutatorRefInstance
457
+ >,
458
+ eventFilter?: Omit<EventFilter, "type" | "account">,
459
+ ): royalty {
460
+ this.onMoveEvent(
461
+ func,
462
+ { ...(eventFilter ?? {}), type: "royalty::MutatorRef" },
463
+ handlerOptions,
464
+ );
465
+ return this;
466
+ }
467
+ }
468
+
403
469
  export namespace royalty {
404
470
  export interface MutatorRef {
405
471
  inner: _0x1.object$.ExtendRef;
@@ -415,6 +481,11 @@ export namespace royalty {
415
481
  }
416
482
  }
417
483
 
484
+ export type MutatorRefInstance = TypedEventInstance<MutatorRef> & {
485
+ data_decoded: MutatorRef;
486
+ type_arguments: [];
487
+ };
488
+
418
489
  export interface Royalty {
419
490
  numerator: bigint;
420
491
  denominator: bigint;
@@ -448,6 +519,22 @@ export class collection extends AptosBaseProcessor {
448
519
  return new collection({ ...collection.DEFAULT_OPTIONS, ...options });
449
520
  }
450
521
 
522
+ onEventMutatorRef(
523
+ func: (event: collection.MutatorRefInstance, ctx: AptosContext) => void,
524
+ handlerOptions?: HandlerOptions<
525
+ MoveFetchConfig,
526
+ collection.MutatorRefInstance
527
+ >,
528
+ eventFilter?: Omit<EventFilter, "type" | "account">,
529
+ ): collection {
530
+ this.onMoveEvent(
531
+ func,
532
+ { ...(eventFilter ?? {}), type: "collection::MutatorRef" },
533
+ handlerOptions,
534
+ );
535
+ return this;
536
+ }
537
+
451
538
  onEventBurn(
452
539
  func: (event: collection.BurnInstance, ctx: AptosContext) => void,
453
540
  handlerOptions?: HandlerOptions<MoveFetchConfig, collection.BurnInstance>,
@@ -625,6 +712,11 @@ export namespace collection {
625
712
  }
626
713
  }
627
714
 
715
+ export type MutatorRefInstance = TypedEventInstance<MutatorRef> & {
716
+ data_decoded: MutatorRef;
717
+ type_arguments: [];
718
+ };
719
+
628
720
  export interface Burn {
629
721
  collection: MoveAddressType;
630
722
  index: bigint;
@@ -2148,6 +2240,55 @@ export namespace aptos_token {
2148
2240
  }
2149
2241
  }
2150
2242
 
2243
+ export class property_map extends AptosBaseProcessor {
2244
+ constructor(options: AptosBindOptions) {
2245
+ super("property_map", options);
2246
+ }
2247
+ static DEFAULT_OPTIONS: AptosBindOptions = {
2248
+ address: "0x4",
2249
+ network: AptosNetwork.MAIN_NET,
2250
+ };
2251
+
2252
+ static bind(options: Partial<AptosBindOptions> = {}): property_map {
2253
+ return new property_map({ ...property_map.DEFAULT_OPTIONS, ...options });
2254
+ }
2255
+
2256
+ onEventMutatorRef(
2257
+ func: (event: property_map.MutatorRefInstance, ctx: AptosContext) => void,
2258
+ handlerOptions?: HandlerOptions<
2259
+ MoveFetchConfig,
2260
+ property_map.MutatorRefInstance
2261
+ >,
2262
+ eventFilter?: Omit<EventFilter, "type" | "account">,
2263
+ ): property_map {
2264
+ this.onMoveEvent(
2265
+ func,
2266
+ { ...(eventFilter ?? {}), type: "property_map::MutatorRef" },
2267
+ handlerOptions,
2268
+ );
2269
+ return this;
2270
+ }
2271
+
2272
+ onEventPropertyValue(
2273
+ func: (
2274
+ event: property_map.PropertyValueInstance,
2275
+ ctx: AptosContext,
2276
+ ) => void,
2277
+ handlerOptions?: HandlerOptions<
2278
+ MoveFetchConfig,
2279
+ property_map.PropertyValueInstance
2280
+ >,
2281
+ eventFilter?: Omit<EventFilter, "type" | "account">,
2282
+ ): property_map {
2283
+ this.onMoveEvent(
2284
+ func,
2285
+ { ...(eventFilter ?? {}), type: "property_map::PropertyValue" },
2286
+ handlerOptions,
2287
+ );
2288
+ return this;
2289
+ }
2290
+ }
2291
+
2151
2292
  export namespace property_map {
2152
2293
  export interface MutatorRef {
2153
2294
  self: MoveAddressType;
@@ -2163,6 +2304,11 @@ export namespace property_map {
2163
2304
  }
2164
2305
  }
2165
2306
 
2307
+ export type MutatorRefInstance = TypedEventInstance<MutatorRef> & {
2308
+ data_decoded: MutatorRef;
2309
+ type_arguments: [];
2310
+ };
2311
+
2166
2312
  export interface PropertyMap {
2167
2313
  inner: _0x1.simple_map.SimpleMap<string, property_map.PropertyValue>;
2168
2314
  }
@@ -2192,6 +2338,11 @@ export namespace property_map {
2192
2338
  }
2193
2339
  }
2194
2340
 
2341
+ export type PropertyValueInstance = TypedEventInstance<PropertyValue> & {
2342
+ data_decoded: PropertyValue;
2343
+ type_arguments: [];
2344
+ };
2345
+
2195
2346
  export namespace entry {}
2196
2347
  export namespace view {}
2197
2348
  }
@@ -3,7 +3,7 @@ import chalk from 'chalk'
3
3
  import path, { join } from 'path'
4
4
  import { AptosCodegen as BaseAptosCodegen } from '@typemove/aptos/codegen'
5
5
  import { InternalMoveModule, InternalMoveStruct, normalizeToJSName, camel, upperFirst } from '@typemove/move'
6
- import { AptosNetwork, getRpcEndpoint } from '../network.js'
6
+ import { AptosNetwork, getRpcConfig } from '../network.js'
7
7
  import { Event, MoveModuleBytecode, MoveResource } from '@aptos-labs/ts-sdk'
8
8
  import { SharedNetworkCodegen } from '../../move/shared-network-codegen.js'
9
9
  import { recursiveCodegen } from '../../core/codegen.js'
@@ -27,7 +27,7 @@ class AptosNetworkCodegen extends BaseAptosCodegen {
27
27
  SYSTEM_PACKAGE = '@sentio/sdk/aptos'
28
28
 
29
29
  constructor(network: AptosNetwork, useViewJson = false) {
30
- const endpoint = getRpcEndpoint(network)
30
+ const endpoint = getRpcConfig(network)
31
31
  super(endpoint, useViewJson)
32
32
  const generator = this
33
33
 
@@ -134,21 +134,15 @@ class InitiaAptosNetworkCodegen extends AptosNetworkCodegen {
134
134
  }
135
135
  }
136
136
 
137
- const MAINNET_CODEGEN = new AptosNetworkCodegen(AptosNetwork.MAIN_NET)
138
- const TESTNET_CODEGEN = new AptosNetworkCodegen(AptosNetwork.TEST_NET)
139
- const MOVEMENT_MAINNET_CODEGEN = new AptosNetworkCodegen(AptosNetwork.MOVEMENT_MAIN_NET)
140
- const MOVEMENT_TESTNET_CODEGEN = new AptosNetworkCodegen(AptosNetwork.MOVEMENT_TEST_NET)
141
- const ECHELON_CODEGEN = new InitiaAptosNetworkCodegen(AptosNetwork.INITIA_ECHELON)
142
-
143
137
  class AptosCodegen {
144
138
  async generate(srcDir: string, outputDir: string, builtin = false): Promise<number> {
145
139
  let numFiles = 0
146
140
  const generators: [string, AptosNetworkCodegen][] = [
147
- ['', MAINNET_CODEGEN],
148
- ['testnet', TESTNET_CODEGEN],
149
- ['movement-mainnet', MOVEMENT_MAINNET_CODEGEN],
150
- ['movement-testnet', MOVEMENT_TESTNET_CODEGEN],
151
- ['initia-echelon', ECHELON_CODEGEN]
141
+ ['', new AptosNetworkCodegen(AptosNetwork.MAIN_NET)],
142
+ ['testnet', new AptosNetworkCodegen(AptosNetwork.TEST_NET)],
143
+ ['movement-mainnet', new AptosNetworkCodegen(AptosNetwork.MOVEMENT_MAIN_NET)],
144
+ ['movement-testnet', new AptosNetworkCodegen(AptosNetwork.MOVEMENT_TEST_NET)],
145
+ ['initia-echelon', new InitiaAptosNetworkCodegen(AptosNetwork.INITIA_ECHELON)]
152
146
  ]
153
147
 
154
148
  for (const [network, gen] of generators) {
@@ -1,5 +1,5 @@
1
1
  import { AptosChainId } from '@sentio/chain'
2
- import { Aptos, AptosConfig } from '@aptos-labs/ts-sdk'
2
+ import { Aptos, AptosConfig, Network } from '@aptos-labs/ts-sdk'
3
3
  import { Labels } from '../core/index.js'
4
4
  import { Endpoints } from '@sentio/runtime'
5
5
  import { RichAptosClient } from './api.js'
@@ -29,28 +29,36 @@ export class AptosBindOptions {
29
29
  baseLabels?: Labels
30
30
  }
31
31
 
32
- export function getRpcEndpoint(network: AptosNetwork): string {
32
+ export function getRpcConfig(network: AptosNetwork, fullnode?: string | undefined): AptosConfig {
33
33
  switch (network) {
34
34
  case AptosNetwork.MAIN_NET:
35
- return 'https://mainnet.aptoslabs.com/v1'
35
+ return new AptosConfig({ network: Network.MAINNET, fullnode: fullnode ?? 'https://mainnet.aptoslabs.com/v1' })
36
36
  case AptosNetwork.TEST_NET:
37
- return 'https://testnet.aptoslabs.com/v1'
37
+ return new AptosConfig({ network: Network.TESTNET, fullnode: fullnode ?? 'https://testnet.aptoslabs.com/v1' })
38
38
  case AptosNetwork.MOVEMENT_MAIN_NET:
39
- return 'https://mainnet.movementnetwork.xyz/v1'
39
+ return new AptosConfig({
40
+ network: Network.CUSTOM,
41
+ fullnode: fullnode ?? 'https://mainnet.movementnetwork.xyz/v1'
42
+ })
40
43
  case AptosNetwork.MOVEMENT_TEST_NET:
41
- return 'https://aptos.testnet.bardock.movementlabs.xyz/v1'
44
+ return new AptosConfig({
45
+ network: Network.CUSTOM,
46
+ fullnode: fullnode ?? 'https://aptos.testnet.bardock.movementlabs.xyz/v1'
47
+ })
42
48
  case AptosNetwork.INITIA_ECHELON:
43
- return 'https://rpc.sentio.xyz/initia-aptos/v1'
49
+ return new AptosConfig({
50
+ network: Network.CUSTOM,
51
+ fullnode: fullnode ?? 'https://rpc.sentio.xyz/initia-aptos/v1'
52
+ })
44
53
  }
45
54
  }
46
55
 
47
56
  export function getClient(network: AptosNetwork): RichAptosClient {
48
- let chainServer = Endpoints.INSTANCE.chainServer.get(network)
49
- if (!chainServer) {
50
- chainServer = getRpcEndpoint(network)
51
- // throw new ServerError(Status.INTERNAL, 'RPC endpoint not provided')
52
- } else {
53
- chainServer = chainServer + '/v1'
57
+ let fullnode = Endpoints.INSTANCE.chainServer.get(network)
58
+ if (fullnode) {
59
+ if (!fullnode.endsWith('/v1')) {
60
+ fullnode = fullnode + '/v1'
61
+ }
54
62
  }
55
- return new RichAptosClient(new AptosConfig({ fullnode: chainServer }))
63
+ return new RichAptosClient(getRpcConfig(network, fullnode))
56
64
  }
@@ -5,7 +5,7 @@ import { MetricState, MetricStateNew } from './meter.js'
5
5
  import { ExporterState } from './exporter.js'
6
6
  import { TemplateInstanceState } from './template.js'
7
7
  import { EventLoggerState } from './event-logger.js'
8
- import { DatabaseSchemaState } from './database-schema.js'
8
+ import { DatabaseSchemaState, mergeSchemas } from './database-schema.js'
9
9
 
10
10
  export class CorePlugin extends Plugin {
11
11
  name: string = 'CorePlugin'
@@ -46,17 +46,10 @@ export class CorePlugin extends Plugin {
46
46
  }
47
47
 
48
48
  if (DatabaseSchemaState.INSTANCE.getValues().length > 0) {
49
+ const schemas = DatabaseSchemaState.INSTANCE.getValues()
50
+ const mergedSources = mergeSchemas(schemas)
49
51
  config.dbSchema = {
50
- gqlSchema: DatabaseSchemaState.INSTANCE.getValues()
51
- .map((e) => e.source)
52
- .join('\n\n')
53
- }
54
- }
55
- if (DatabaseSchemaState.INSTANCE.getValues().length > 0) {
56
- config.dbSchema = {
57
- gqlSchema: DatabaseSchemaState.INSTANCE.getValues()
58
- .map((e) => e.source)
59
- .join('\n\n')
52
+ gqlSchema: mergedSources
60
53
  }
61
54
  }
62
55
  }
@@ -1,5 +1,7 @@
1
1
  import { ListStateStorage } from '@sentio/runtime'
2
2
  import { EntityClass } from '../store/index.js'
3
+ import { isInterfaceType, isObjectType, isScalarType, parse, printType } from 'graphql/index.js'
4
+ import { buildSchema } from '../store/schema.js'
3
5
 
4
6
  type Schema = {
5
7
  source: string
@@ -25,3 +27,30 @@ export class DatabaseSchema {
25
27
  return undefined
26
28
  }
27
29
  }
30
+
31
+ export function mergeSchemas(schemas: Schema[]) {
32
+ let ret = ''
33
+ const types: Record<string, any> = {}
34
+ for (const schema of schemas) {
35
+ const gqlSchema = buildSchema(parse(schema.source))
36
+ for (const type of Object.values(gqlSchema.getTypeMap())) {
37
+ if (isScalarType(type) || type.name.startsWith('__')) {
38
+ continue
39
+ }
40
+ if (types[type.name]) {
41
+ console.warn(`Type ${type.name} is already registered, you have duplicate definitions in multiple schemas.`)
42
+ } else if (isObjectType(type) || isInterfaceType(type)) {
43
+ types[type.name] = type
44
+ type.description = null
45
+ for (const field of Object.values(type.getFields())) {
46
+ field.description = null
47
+ }
48
+ ret += printType(type) + '\n'
49
+ } else {
50
+ types[type.name] = type
51
+ ret += printType(type) + '\n'
52
+ }
53
+ }
54
+ }
55
+ return ret
56
+ }
@@ -36,8 +36,15 @@ function findSenderFromInputs(inputs: Input[] | undefined, baseAssetId: string):
36
36
  export async function decodeFuelTransaction(gqlTransaction: any, provider: Provider): Promise<FuelTransaction> {
37
37
  const rawPayload = arrayify(gqlTransaction.rawPayload)
38
38
  const receipts = gqlTransaction?.status.receipts?.map(deserializeReceipt) || []
39
-
40
- const [decodedTransaction] = new TransactionCoder().decode(rawPayload, 0)
39
+ let decodedTransaction: any
40
+ try {
41
+ const [d] = new TransactionCoder().decode(rawPayload, 0)
42
+ decodedTransaction = d
43
+ } catch (e) {
44
+ // If the transaction cannot be decoded, we log the payload in hex and rethrow it
45
+ console.error('Failed to decode transaction payload:', e, 'payload', Buffer.from(rawPayload).toString('hex'))
46
+ throw e
47
+ }
41
48
  const { gasCosts, feeParameters, txParameters, baseAssetId } = (await provider.getChain()).consensusParameters
42
49
  const blockNumber = gqlTransaction.status?.block?.header?.height
43
50
  const { gasPriceFactor, gasPerByte } = feeParameters
@@ -67,14 +74,28 @@ export async function decodeFuelTransaction(gqlTransaction: any, provider: Provi
67
74
  }
68
75
 
69
76
  export function decodeLog(receipt: any | undefined, abi: JsonAbi) {
70
- if (receipt && (receipt.type === ReceiptType.LogData || receipt.type === ReceiptType.Log)) {
71
- const interfaceToUse = new Interface(abi)
72
- const data = receipt.type === ReceiptType.Log ? new BigNumberCoder('u64').encode(receipt.val0) : receipt.data
73
- const logId: string = receipt.rb.toString()
74
- const [decodedLog] = interfaceToUse.decodeLog(data, logId)
75
- return { logId, data: decodedLog }
77
+ try {
78
+ if (receipt && (receipt.type === ReceiptType.LogData || receipt.type === ReceiptType.Log)) {
79
+ const interfaceToUse = new Interface(abi)
80
+ const data = receipt.type === ReceiptType.Log ? new BigNumberCoder('u64').encode(receipt.val0) : receipt.data
81
+ const logId: string = receipt.rb.toString()
82
+ const [decodedLog] = interfaceToUse.decodeLog(data, logId)
83
+ return { logId, data: decodedLog }
84
+ }
85
+ return null
86
+ } catch (e) {
87
+ console.error(
88
+ 'Failed to decode log',
89
+ e,
90
+ 'Please make sure you provide the correct abi.',
91
+ e,
92
+ 'receipt',
93
+ receipt,
94
+ 'abi',
95
+ abi
96
+ )
97
+ throw e
76
98
  }
77
- return null
78
99
  }
79
100
 
80
101
  export async function decodeFuelTransactionWithAbi(
@@ -92,16 +92,13 @@ class IotaNetworkCodegen extends BaseIotaCodegen {
92
92
  return this.moduleGenerator.generateLoadAll(isSystem)
93
93
  }
94
94
  }
95
- //
96
- const MAINNET_CODEGEN = new IotaNetworkCodegen(IotaNetwork.MAIN_NET)
97
- const TESTNET_CODEGEN = new IotaNetworkCodegen(IotaNetwork.TEST_NET)
98
95
 
99
96
  class IotaCodegen {
100
97
  async generate(srcDir: string, outputDir: string, builtin = false): Promise<number> {
101
98
  let numFiles = 0
102
99
  const generators: [string, IotaNetworkCodegen][] = [
103
- ['', MAINNET_CODEGEN],
104
- ['testnet', TESTNET_CODEGEN]
100
+ ['', new IotaNetworkCodegen(IotaNetwork.MAIN_NET)],
101
+ ['testnet', new IotaNetworkCodegen(IotaNetwork.TEST_NET)]
105
102
  ]
106
103
 
107
104
  for (const [network, gen] of generators) {
@@ -1,2 +1,4 @@
1
1
  // real plugin is in src/sui/sui-plugin.ts
2
+ import '@sentio/sdk/sui'
3
+
2
4
  export class IotaPlugin {}
@@ -4171,6 +4171,32 @@
4171
4171
  }
4172
4172
  ]
4173
4173
  },
4174
+ "skip": {
4175
+ "visibility": "Public",
4176
+ "isEntry": false,
4177
+ "typeParameters": [
4178
+ {
4179
+ "abilities": [
4180
+ "Drop"
4181
+ ]
4182
+ }
4183
+ ],
4184
+ "parameters": [
4185
+ {
4186
+ "Vector": {
4187
+ "TypeParameter": 0
4188
+ }
4189
+ },
4190
+ "U64"
4191
+ ],
4192
+ "return": [
4193
+ {
4194
+ "Vector": {
4195
+ "TypeParameter": 0
4196
+ }
4197
+ }
4198
+ ]
4199
+ },
4174
4200
  "swap": {
4175
4201
  "visibility": "Public",
4176
4202
  "isEntry": false,
@@ -4215,6 +4241,32 @@
4215
4241
  "TypeParameter": 0
4216
4242
  }
4217
4243
  ]
4244
+ },
4245
+ "take": {
4246
+ "visibility": "Public",
4247
+ "isEntry": false,
4248
+ "typeParameters": [
4249
+ {
4250
+ "abilities": [
4251
+ "Drop"
4252
+ ]
4253
+ }
4254
+ ],
4255
+ "parameters": [
4256
+ {
4257
+ "Vector": {
4258
+ "TypeParameter": 0
4259
+ }
4260
+ },
4261
+ "U64"
4262
+ ],
4263
+ "return": [
4264
+ {
4265
+ "Vector": {
4266
+ "TypeParameter": 0
4267
+ }
4268
+ }
4269
+ ]
4218
4270
  }
4219
4271
  }
4220
4272
  }