@sentio/sdk 2.56.0 → 2.57.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 (45) hide show
  1. package/lib/aptos/builtin/0x1.d.ts +308 -308
  2. package/lib/aptos/builtin/0x1.d.ts.map +1 -1
  3. package/lib/aptos/builtin/0x1.js.map +1 -1
  4. package/lib/aptos/builtin/0x3.d.ts +102 -102
  5. package/lib/aptos/builtin/0x3.d.ts.map +1 -1
  6. package/lib/aptos/builtin/0x3.js.map +1 -1
  7. package/lib/aptos/builtin/0x4.d.ts +22 -22
  8. package/lib/aptos/builtin/0x4.d.ts.map +1 -1
  9. package/lib/aptos/builtin/0x4.js.map +1 -1
  10. package/lib/fuel/asset-processor.d.ts +2 -2
  11. package/lib/fuel/asset-processor.d.ts.map +1 -1
  12. package/lib/fuel/asset-processor.js.map +1 -1
  13. package/lib/fuel/fuel-plugin.d.ts +2 -2
  14. package/lib/fuel/fuel-plugin.d.ts.map +1 -1
  15. package/lib/fuel/fuel-plugin.js +19 -18
  16. package/lib/fuel/fuel-plugin.js.map +1 -1
  17. package/lib/fuel/fuel-processor.d.ts +5 -4
  18. package/lib/fuel/fuel-processor.d.ts.map +1 -1
  19. package/lib/fuel/fuel-processor.js +38 -4
  20. package/lib/fuel/fuel-processor.js.map +1 -1
  21. package/lib/fuel/types.d.ts +10 -7
  22. package/lib/fuel/types.d.ts.map +1 -1
  23. package/lib/fuel/types.js.map +1 -1
  24. package/lib/sui/builtin/0x1.d.ts +12 -12
  25. package/lib/sui/builtin/0x1.d.ts.map +1 -1
  26. package/lib/sui/builtin/0x1.js.map +1 -1
  27. package/lib/sui/builtin/0x2.d.ts +66 -66
  28. package/lib/sui/builtin/0x2.d.ts.map +1 -1
  29. package/lib/sui/builtin/0x2.js.map +1 -1
  30. package/lib/sui/builtin/0x3.d.ts +26 -26
  31. package/lib/sui/builtin/0x3.d.ts.map +1 -1
  32. package/lib/testing/fuel-facet.js +3 -3
  33. package/lib/testing/fuel-facet.js.map +1 -1
  34. package/package.json +8 -8
  35. package/src/aptos/builtin/0x1.ts +539 -579
  36. package/src/aptos/builtin/0x3.ts +177 -191
  37. package/src/aptos/builtin/0x4.ts +28 -31
  38. package/src/fuel/asset-processor.ts +5 -2
  39. package/src/fuel/fuel-plugin.ts +22 -19
  40. package/src/fuel/fuel-processor.ts +54 -7
  41. package/src/fuel/types.ts +11 -6
  42. package/src/sui/builtin/0x1.ts +12 -13
  43. package/src/sui/builtin/0x2.ts +87 -86
  44. package/src/sui/builtin/0x3.ts +65 -65
  45. package/src/testing/fuel-facet.ts +3 -3
@@ -106,10 +106,10 @@ export namespace token {
106
106
  }
107
107
  }
108
108
 
109
- export interface MutationInstance extends TypedEventInstance<Mutation> {
109
+ export type MutationInstance = TypedEventInstance<Mutation> & {
110
110
  data_decoded: Mutation;
111
111
  type_arguments: [];
112
- }
112
+ };
113
113
 
114
114
  export interface MutationEvent {
115
115
  mutated_field_name: string;
@@ -127,11 +127,10 @@ export namespace token {
127
127
  }
128
128
  }
129
129
 
130
- export interface MutationEventInstance
131
- extends TypedEventInstance<MutationEvent> {
130
+ export type MutationEventInstance = TypedEventInstance<MutationEvent> & {
132
131
  data_decoded: MutationEvent;
133
132
  type_arguments: [];
134
- }
133
+ };
135
134
 
136
135
  export interface ConcurrentTokenIdentifiers {
137
136
  index: _0x1.aggregator_v2.AggregatorSnapshot<bigint>;
@@ -570,10 +569,10 @@ export namespace collection {
570
569
  }
571
570
  }
572
571
 
573
- export interface BurnInstance extends TypedEventInstance<Burn> {
572
+ export type BurnInstance = TypedEventInstance<Burn> & {
574
573
  data_decoded: Burn;
575
574
  type_arguments: [];
576
- }
575
+ };
577
576
 
578
577
  export interface BurnEvent {
579
578
  index: bigint;
@@ -590,10 +589,10 @@ export namespace collection {
590
589
  }
591
590
  }
592
591
 
593
- export interface BurnEventInstance extends TypedEventInstance<BurnEvent> {
592
+ export type BurnEventInstance = TypedEventInstance<BurnEvent> & {
594
593
  data_decoded: BurnEvent;
595
594
  type_arguments: [];
596
- }
595
+ };
597
596
 
598
597
  export interface Collection {
599
598
  creator: MoveAddressType;
@@ -631,11 +630,11 @@ export namespace collection {
631
630
  }
632
631
  }
633
632
 
634
- export interface ConcurrentBurnEventInstance
635
- extends TypedEventInstance<ConcurrentBurnEvent> {
636
- data_decoded: ConcurrentBurnEvent;
637
- type_arguments: [];
638
- }
633
+ export type ConcurrentBurnEventInstance =
634
+ TypedEventInstance<ConcurrentBurnEvent> & {
635
+ data_decoded: ConcurrentBurnEvent;
636
+ type_arguments: [];
637
+ };
639
638
 
640
639
  export interface ConcurrentMintEvent {
641
640
  collection_addr: MoveAddressType;
@@ -655,11 +654,11 @@ export namespace collection {
655
654
  }
656
655
  }
657
656
 
658
- export interface ConcurrentMintEventInstance
659
- extends TypedEventInstance<ConcurrentMintEvent> {
660
- data_decoded: ConcurrentMintEvent;
661
- type_arguments: [];
662
- }
657
+ export type ConcurrentMintEventInstance =
658
+ TypedEventInstance<ConcurrentMintEvent> & {
659
+ data_decoded: ConcurrentMintEvent;
660
+ type_arguments: [];
661
+ };
663
662
 
664
663
  export interface FixedSupply {
665
664
  current_supply: bigint;
@@ -695,10 +694,10 @@ export namespace collection {
695
694
  }
696
695
  }
697
696
 
698
- export interface MintInstance extends TypedEventInstance<Mint> {
697
+ export type MintInstance = TypedEventInstance<Mint> & {
699
698
  data_decoded: Mint;
700
699
  type_arguments: [];
701
- }
700
+ };
702
701
 
703
702
  export interface MintEvent {
704
703
  index: bigint;
@@ -715,10 +714,10 @@ export namespace collection {
715
714
  }
716
715
  }
717
716
 
718
- export interface MintEventInstance extends TypedEventInstance<MintEvent> {
717
+ export type MintEventInstance = TypedEventInstance<MintEvent> & {
719
718
  data_decoded: MintEvent;
720
719
  type_arguments: [];
721
- }
720
+ };
722
721
 
723
722
  export interface Mutation {
724
723
  mutated_field_name: string;
@@ -737,10 +736,10 @@ export namespace collection {
737
736
  }
738
737
  }
739
738
 
740
- export interface MutationInstance extends TypedEventInstance<Mutation> {
739
+ export type MutationInstance = TypedEventInstance<Mutation> & {
741
740
  data_decoded: Mutation;
742
741
  type_arguments: [];
743
- }
742
+ };
744
743
 
745
744
  export interface MutationEvent {
746
745
  mutated_field_name: string;
@@ -756,11 +755,10 @@ export namespace collection {
756
755
  }
757
756
  }
758
757
 
759
- export interface MutationEventInstance
760
- extends TypedEventInstance<MutationEvent> {
758
+ export type MutationEventInstance = TypedEventInstance<MutationEvent> & {
761
759
  data_decoded: MutationEvent;
762
760
  type_arguments: [];
763
- }
761
+ };
764
762
 
765
763
  export interface SetMaxSupply {
766
764
  collection: _0x1.object$.Object<collection.Collection>;
@@ -778,11 +776,10 @@ export namespace collection {
778
776
  }
779
777
  }
780
778
 
781
- export interface SetMaxSupplyInstance
782
- extends TypedEventInstance<SetMaxSupply> {
779
+ export type SetMaxSupplyInstance = TypedEventInstance<SetMaxSupply> & {
783
780
  data_decoded: SetMaxSupply;
784
781
  type_arguments: [];
785
- }
782
+ };
786
783
 
787
784
  export interface UnlimitedSupply {
788
785
  current_supply: bigint;
@@ -1,5 +1,5 @@
1
1
  import { CallHandler, FuelBaseProcessor, FuelProcessorState } from './types.js'
2
- import { Data_FuelTransaction, FuelAssetHandlerConfig_AssetFilter } from '@sentio/protos'
2
+ import { Data_FuelReceipt, Data_FuelTransaction, FuelAssetHandlerConfig_AssetFilter } from '@sentio/protos'
3
3
  import { FuelNetwork, getProvider } from './network.js'
4
4
  import { FuelContext } from './context.js'
5
5
  import { decodeFuelTransaction } from './transaction.js'
@@ -8,7 +8,7 @@ import { getOptionsSignature } from './fuel-processor.js'
8
8
  import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
9
9
 
10
10
  export class FuelAssetProcessor implements FuelBaseProcessor<FuelAssetProcessorConfig> {
11
- txHandlers: CallHandler<Data_FuelTransaction>[] = []
11
+ txHandlers: CallHandler<Data_FuelTransaction | Data_FuelReceipt>[] = []
12
12
  blockHandlers = []
13
13
  private provider: Provider
14
14
 
@@ -112,8 +112,11 @@ export type FuelAssetProcessorConfig = {
112
112
  }
113
113
 
114
114
  export type TransferFilter = {
115
+ // The account address that is sending the asset
115
116
  from?: string | string[]
117
+ // The account address that is receiving the asset
116
118
  to?: string | string[]
119
+ // The asset id of the asset being transferred
117
120
  assetId?: string | string[]
118
121
  }
119
122
 
@@ -21,7 +21,7 @@ import { FuelGlobalProcessor } from './global-processor.js'
21
21
  interface Handlers {
22
22
  transactionHandlers: ((trace: Data_FuelTransaction) => Promise<ProcessResult>)[]
23
23
  blockHandlers: ((block: Data_FuelBlock) => Promise<ProcessResult>)[]
24
- logHandlers: ((log: Data_FuelReceipt) => Promise<ProcessResult>)[]
24
+ receiptHandlers: ((log: Data_FuelReceipt) => Promise<ProcessResult>)[]
25
25
  }
26
26
 
27
27
  export class FuelPlugin extends Plugin {
@@ -29,27 +29,28 @@ export class FuelPlugin extends Plugin {
29
29
  handlers: Handlers = {
30
30
  transactionHandlers: [],
31
31
  blockHandlers: [],
32
- logHandlers: []
32
+ receiptHandlers: []
33
33
  }
34
34
 
35
35
  async configure(config: ProcessConfigResponse) {
36
36
  const handlers: Handlers = {
37
37
  transactionHandlers: [],
38
38
  blockHandlers: [],
39
- logHandlers: []
39
+ receiptHandlers: []
40
40
  }
41
41
 
42
42
  for (const processor of FuelProcessorState.INSTANCE.getValues()) {
43
+ const processorConfig = processor.config
43
44
  const contractConfig = ContractConfig.fromPartial({
44
45
  processorType: USER_PROCESSOR,
45
46
  contract: {
46
- name: processor.config.name,
47
- chainId: processor.config.chainId.toString(),
48
- address: processor.config.address || '*',
47
+ name: processorConfig.name,
48
+ chainId: processorConfig.chainId.toString(),
49
+ address: processorConfig.address || '*',
49
50
  abi: ''
50
51
  },
51
- startBlock: processor.config.startBlock,
52
- endBlock: processor.config.endBlock
52
+ startBlock: processorConfig.startBlock,
53
+ endBlock: processorConfig.endBlock
53
54
  })
54
55
  for (const txHandler of processor.txHandlers) {
55
56
  const handlerId = handlers.transactionHandlers.push(txHandler.handler) - 1
@@ -79,12 +80,12 @@ export class FuelPlugin extends Plugin {
79
80
  }
80
81
  }
81
82
 
82
- for (const logHandler of processor.logHandlers ?? []) {
83
- const handlerId = handlers.logHandlers.push(logHandler.handler) - 1
84
- const handlerName = logHandler.handlerName
83
+ for (const receiptHandler of processor.receiptHandlers ?? []) {
84
+ const handlerId = handlers.receiptHandlers.push(receiptHandler.handler) - 1
85
+ const handlerName = receiptHandler.handlerName
85
86
  if (processor instanceof FuelProcessor) {
86
- contractConfig.fuelLogConfigs.push({
87
- logIds: logHandler.logConfig?.logIds || [],
87
+ contractConfig.fuelReceiptConfigs.push({
88
+ ...receiptHandler.receiptConfig,
88
89
  handlerId,
89
90
  handlerName
90
91
  })
@@ -123,7 +124,7 @@ export class FuelPlugin extends Plugin {
123
124
  case HandlerType.FUEL_TRANSACTION:
124
125
  return this.processTransaction(request)
125
126
  case HandlerType.FUEL_RECEIPT:
126
- return this.processLog(request)
127
+ return this.processReceipt(request)
127
128
  case HandlerType.FUEL_BLOCK:
128
129
  return this.processBlock(request)
129
130
  default:
@@ -145,19 +146,20 @@ export class FuelPlugin extends Plugin {
145
146
  return TemplateInstanceState.INSTANCE.getValues().length !== config.templateInstances.length
146
147
  }
147
148
 
148
- async processLog(binding: DataBinding): Promise<ProcessResult> {
149
- if (!binding.data?.fuelLog?.transaction) {
149
+ async processReceipt(binding: DataBinding): Promise<ProcessResult> {
150
+ const receipt = binding?.data?.fuelLog
151
+
152
+ if (!receipt?.transaction) {
150
153
  throw new ServerError(Status.INVALID_ARGUMENT, "transaction can't be null")
151
154
  }
152
- const log = binding.data.fuelLog
153
155
 
154
156
  const promises: Promise<ProcessResult>[] = []
155
157
 
156
158
  for (const handlerId of binding.handlerIds) {
157
- const promise = this.handlers.logHandlers[handlerId](log).catch((e) => {
159
+ const promise = this.handlers.receiptHandlers[handlerId](receipt).catch((e) => {
158
160
  throw new ServerError(
159
161
  Status.INTERNAL,
160
- 'error processing transaction: ' + JSON.stringify(log) + '\n' + errorString(e)
162
+ 'error processing transaction: ' + JSON.stringify(receipt) + '\n' + errorString(e)
161
163
  )
162
164
  })
163
165
  if (GLOBAL_CONFIG.execution.sequential) {
@@ -167,6 +169,7 @@ export class FuelPlugin extends Plugin {
167
169
  }
168
170
  return mergeProcessResults(await Promise.all(promises))
169
171
  }
172
+
170
173
  async processTransaction(binding: DataBinding): Promise<ProcessResult> {
171
174
  if (!binding.data?.fuelTransaction?.transaction) {
172
175
  throw new ServerError(Status.INVALID_ARGUMENT, "transaction can't be null")
@@ -7,7 +7,7 @@ import {
7
7
  ProcessResult
8
8
  } from '@sentio/protos'
9
9
  import { FuelCall, FuelContext, FuelContractContext } from './context.js'
10
- import { bn, Contract, Interface, JsonAbi, Provider } from 'fuels'
10
+ import { bn, Contract, Interface, JsonAbi, Provider, ReceiptTransfer, ReceiptTransferOut } from 'fuels'
11
11
  import { FuelNetwork, getProvider } from './network.js'
12
12
  import {
13
13
  decodeFuelTransaction,
@@ -19,12 +19,13 @@ import {
19
19
  import {
20
20
  BlockHandler,
21
21
  CallHandler,
22
+ ContractTransferFilter,
22
23
  FuelBaseProcessor,
23
24
  FuelBlock,
24
25
  FuelLog,
25
26
  FuelProcessorState,
26
27
  FuelTransaction,
27
- LogHandler
28
+ ReceiptHandler
28
29
  } from './types.js'
29
30
  import { PromiseOrVoid } from '../core/index.js'
30
31
  import { ServerError, Status } from 'nice-grpc'
@@ -33,7 +34,7 @@ import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
33
34
  export class FuelProcessor<TContract extends Contract> implements FuelBaseProcessor<FuelProcessorConfig> {
34
35
  txHandlers: CallHandler<Data_FuelTransaction>[] = []
35
36
  blockHandlers: BlockHandler[] = []
36
- logHandlers: LogHandler<Data_FuelReceipt>[] = []
37
+ receiptHandlers: ReceiptHandler[] = []
37
38
 
38
39
  private provider: Provider
39
40
  private contract: TContract
@@ -214,11 +215,57 @@ export class FuelProcessor<TContract extends Contract> implements FuelBaseProces
214
215
 
215
216
  return ProcessResult.fromPartial({})
216
217
  },
217
- logConfig: {
218
- logIds: Array.from(logIds)
218
+ receiptConfig: {
219
+ log: {
220
+ logIds: Array.from(logIds)
221
+ }
219
222
  }
220
- }
221
- this.logHandlers.push(logHandler)
223
+ } as ReceiptHandler
224
+ this.receiptHandlers.push(logHandler)
225
+ return this
226
+ }
227
+
228
+ /*
229
+ * handle 'Transfer' and 'TransferOut' receipt for a specific contract id
230
+ */
231
+ public onTransfer(
232
+ filter: ContractTransferFilter,
233
+ handler: (transfer: ReceiptTransfer | ReceiptTransferOut, ctx: FuelContractContext<TContract>) => PromiseOrVoid
234
+ ) {
235
+ const { from, to, assetId } = filter
236
+ const h = {
237
+ handlerName: getHandlerName(),
238
+ handler: async ({ transaction, receiptIndex, timestamp }: Data_FuelReceipt) => {
239
+ try {
240
+ const tx = decodeFuelTransaction(transaction, this.provider)
241
+ const index = Number(receiptIndex)
242
+ const receipt = tx.receipts[index] as ReceiptTransfer | ReceiptTransferOut
243
+ const ctx = new FuelContractContext(
244
+ this.config.chainId,
245
+ this.contract,
246
+ this.config.address,
247
+ this.config.name ?? this.config.address,
248
+ timestamp || new Date(0),
249
+ tx,
250
+ null
251
+ )
252
+ ctx.setLogIndex(index)
253
+ await handler(receipt, ctx)
254
+ } catch (e) {
255
+ console.error(e)
256
+ }
257
+
258
+ return ProcessResult.fromPartial({})
259
+ },
260
+ receiptConfig: {
261
+ transfer: {
262
+ from,
263
+ to,
264
+ assetId
265
+ }
266
+ }
267
+ } as ReceiptHandler
268
+ this.receiptHandlers.push(h)
222
269
  return this
223
270
  }
224
271
 
package/src/fuel/types.ts CHANGED
@@ -5,6 +5,7 @@ import {
5
5
  Data_FuelTransaction,
6
6
  FuelAssetHandlerConfig,
7
7
  FuelCallHandlerConfig,
8
+ FuelReceiptHandlerConfig,
8
9
  HandleInterval,
9
10
  OnIntervalConfig,
10
11
  ProcessResult
@@ -16,7 +17,7 @@ export interface FuelBaseProcessor<T> {
16
17
  config: T
17
18
  txHandlers: CallHandler<Data_FuelTransaction>[]
18
19
  blockHandlers: BlockHandler[]
19
- logHandlers?: LogHandler<Data_FuelReceipt>[]
20
+ receiptHandlers?: ReceiptHandler[]
20
21
  }
21
22
 
22
23
  export class FuelProcessorState extends MapStateStorage<FuelBaseProcessor<any>> {
@@ -30,12 +31,10 @@ export type CallHandler<T> = {
30
31
  assetConfig?: Partial<FuelAssetHandlerConfig>
31
32
  }
32
33
 
33
- export type LogHandler<T> = {
34
+ export type ReceiptHandler = {
34
35
  handlerName: string
35
- handler: (call: T) => Promise<ProcessResult>
36
- logConfig?: {
37
- logIds: string[]
38
- }
36
+ handler: (receipt: Data_FuelReceipt) => Promise<ProcessResult>
37
+ receiptConfig?: Partial<FuelReceiptHandlerConfig>
39
38
  }
40
39
 
41
40
  export type BlockHandler = {
@@ -59,3 +58,9 @@ export type FuelTransaction = TransactionSummary & {
59
58
  }
60
59
 
61
60
  export type FuelBlock = Omit<Block, 'transactionIds'>
61
+
62
+ export type ContractTransferFilter = {
63
+ assetId?: string
64
+ from?: string
65
+ to?: string
66
+ }
@@ -745,10 +745,10 @@ export namespace bit_vector {
745
745
  }
746
746
  }
747
747
 
748
- export interface BitVectorInstance extends TypedEventInstance<BitVector> {
748
+ export type BitVectorInstance = TypedEventInstance<BitVector> & {
749
749
  data_decoded: BitVector;
750
750
  type_arguments: [];
751
- }
751
+ };
752
752
 
753
753
  export namespace builder {
754
754
  export function isIndexSet(
@@ -1082,11 +1082,10 @@ export namespace fixed_point32 {
1082
1082
  }
1083
1083
  }
1084
1084
 
1085
- export interface FixedPoint32Instance
1086
- extends TypedEventInstance<FixedPoint32> {
1085
+ export type FixedPoint32Instance = TypedEventInstance<FixedPoint32> & {
1087
1086
  data_decoded: FixedPoint32;
1088
1087
  type_arguments: [];
1089
- }
1088
+ };
1090
1089
 
1091
1090
  export namespace builder {
1092
1091
  export function createFromRational(
@@ -2015,10 +2014,10 @@ export namespace string$ {
2015
2014
  }
2016
2015
  }
2017
2016
 
2018
- export interface StringInstance extends TypedEventInstance<String> {
2017
+ export type StringInstance = TypedEventInstance<String> & {
2019
2018
  data_decoded: String;
2020
2019
  type_arguments: [];
2021
- }
2020
+ };
2022
2021
 
2023
2022
  export namespace builder {
2024
2023
  export function append(
@@ -2516,10 +2515,10 @@ export namespace type_name {
2516
2515
  }
2517
2516
  }
2518
2517
 
2519
- export interface TypeNameInstance extends TypedEventInstance<TypeName> {
2518
+ export type TypeNameInstance = TypedEventInstance<TypeName> & {
2520
2519
  data_decoded: TypeName;
2521
2520
  type_arguments: [];
2522
- }
2521
+ };
2523
2522
 
2524
2523
  export namespace builder {
2525
2524
  export function borrowString(
@@ -4580,10 +4579,10 @@ export namespace uq32_32 {
4580
4579
  }
4581
4580
  }
4582
4581
 
4583
- export interface UQ32_32Instance extends TypedEventInstance<UQ32_32> {
4582
+ export type UQ32_32Instance = TypedEventInstance<UQ32_32> & {
4584
4583
  data_decoded: UQ32_32;
4585
4584
  type_arguments: [];
4586
- }
4585
+ };
4587
4586
 
4588
4587
  export namespace builder {
4589
4588
  export function add(
@@ -5089,10 +5088,10 @@ export namespace uq64_64 {
5089
5088
  }
5090
5089
  }
5091
5090
 
5092
- export interface UQ64_64Instance extends TypedEventInstance<UQ64_64> {
5091
+ export type UQ64_64Instance = TypedEventInstance<UQ64_64> & {
5093
5092
  data_decoded: UQ64_64;
5094
5093
  type_arguments: [];
5095
- }
5094
+ };
5096
5095
 
5097
5096
  export namespace builder {
5098
5097
  export function add(