@sentio/sdk 2.60.0-rc.4 → 2.60.0-rc.5

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 (133) hide show
  1. package/lib/iota/builtin/0x1.d.ts +817 -0
  2. package/lib/iota/builtin/0x1.d.ts.map +1 -0
  3. package/lib/iota/builtin/0x1.js +4385 -0
  4. package/lib/iota/builtin/0x1.js.map +1 -0
  5. package/lib/iota/builtin/0x2.d.ts +4529 -0
  6. package/lib/iota/builtin/0x2.d.ts.map +1 -0
  7. package/lib/iota/builtin/0x2.js +17109 -0
  8. package/lib/iota/builtin/0x2.js.map +1 -0
  9. package/lib/iota/builtin/0x3.d.ts +2293 -0
  10. package/lib/iota/builtin/0x3.d.ts.map +1 -0
  11. package/lib/iota/builtin/0x3.js +6522 -0
  12. package/lib/iota/builtin/0x3.js.map +1 -0
  13. package/lib/iota/builtin/index.d.ts +4 -0
  14. package/lib/iota/builtin/index.d.ts.map +1 -0
  15. package/lib/iota/builtin/index.js +7 -0
  16. package/lib/iota/builtin/index.js.map +1 -0
  17. package/lib/iota/codegen/codegen.d.ts +2 -0
  18. package/lib/iota/codegen/codegen.d.ts.map +1 -0
  19. package/lib/iota/codegen/codegen.js +94 -0
  20. package/lib/iota/codegen/codegen.js.map +1 -0
  21. package/lib/iota/codegen/index.d.ts +2 -0
  22. package/lib/iota/codegen/index.d.ts.map +1 -0
  23. package/lib/iota/codegen/index.js +2 -0
  24. package/lib/iota/codegen/index.js.map +1 -0
  25. package/lib/iota/codegen/run.d.ts +2 -0
  26. package/lib/iota/codegen/run.d.ts.map +1 -0
  27. package/lib/iota/codegen/run.js +12 -0
  28. package/lib/iota/codegen/run.js.map +1 -0
  29. package/lib/iota/context.d.ts +50 -0
  30. package/lib/iota/context.d.ts.map +1 -0
  31. package/lib/iota/context.js +134 -0
  32. package/lib/iota/context.js.map +1 -0
  33. package/lib/iota/ext/coin.d.ts +17 -0
  34. package/lib/iota/ext/coin.d.ts.map +1 -0
  35. package/lib/iota/ext/coin.js +532 -0
  36. package/lib/iota/ext/coin.js.map +1 -0
  37. package/lib/iota/ext/index.d.ts +3 -0
  38. package/lib/iota/ext/index.d.ts.map +1 -0
  39. package/lib/iota/ext/index.js +3 -0
  40. package/lib/iota/ext/index.js.map +1 -0
  41. package/lib/iota/ext/move-dex.d.ts +19 -0
  42. package/lib/iota/ext/move-dex.d.ts.map +1 -0
  43. package/lib/iota/ext/move-dex.js +24 -0
  44. package/lib/iota/ext/move-dex.js.map +1 -0
  45. package/lib/iota/index.d.ts +11 -0
  46. package/lib/iota/index.d.ts.map +1 -0
  47. package/lib/iota/index.js +12 -0
  48. package/lib/iota/index.js.map +1 -0
  49. package/lib/iota/iota-object-processor-template.d.ts +44 -0
  50. package/lib/iota/iota-object-processor-template.d.ts.map +1 -0
  51. package/lib/iota/iota-object-processor-template.js +171 -0
  52. package/lib/iota/iota-object-processor-template.js.map +1 -0
  53. package/lib/iota/iota-object-processor.d.ts +83 -0
  54. package/lib/iota/iota-object-processor.d.ts.map +1 -0
  55. package/lib/iota/iota-object-processor.js +193 -0
  56. package/lib/iota/iota-object-processor.js.map +1 -0
  57. package/lib/iota/iota-plugin-part.d.ts +12 -0
  58. package/lib/iota/iota-plugin-part.d.ts.map +1 -0
  59. package/lib/iota/iota-plugin-part.js +178 -0
  60. package/lib/iota/iota-plugin-part.js.map +1 -0
  61. package/lib/iota/iota-plugin.d.ts +3 -0
  62. package/lib/iota/iota-plugin.d.ts.map +1 -0
  63. package/lib/iota/iota-plugin.js +4 -0
  64. package/lib/iota/iota-plugin.js.map +1 -0
  65. package/lib/iota/iota-processor.d.ts +47 -0
  66. package/lib/iota/iota-processor.d.ts.map +1 -0
  67. package/lib/iota/iota-processor.js +223 -0
  68. package/lib/iota/iota-processor.js.map +1 -0
  69. package/lib/iota/models.d.ts +12 -0
  70. package/lib/iota/models.d.ts.map +1 -0
  71. package/lib/iota/models.js +2 -0
  72. package/lib/iota/models.js.map +1 -0
  73. package/lib/iota/move-coder.d.ts +4 -0
  74. package/lib/iota/move-coder.d.ts.map +1 -0
  75. package/lib/iota/move-coder.js +12 -0
  76. package/lib/iota/move-coder.js.map +1 -0
  77. package/lib/iota/network.d.ts +10 -0
  78. package/lib/iota/network.d.ts.map +1 -0
  79. package/lib/iota/network.js +24 -0
  80. package/lib/iota/network.js.map +1 -0
  81. package/lib/iota/utils.d.ts +3 -0
  82. package/lib/iota/utils.d.ts.map +1 -0
  83. package/lib/iota/utils.js +41 -0
  84. package/lib/iota/utils.js.map +1 -0
  85. package/lib/sui/network.d.ts.map +1 -1
  86. package/lib/sui/network.js +0 -3
  87. package/lib/sui/network.js.map +1 -1
  88. package/lib/sui/sui-plugin-part.d.ts +12 -0
  89. package/lib/sui/sui-plugin-part.d.ts.map +1 -0
  90. package/lib/sui/sui-plugin-part.js +178 -0
  91. package/lib/sui/sui-plugin-part.js.map +1 -0
  92. package/lib/sui/sui-plugin.d.ts +4 -0
  93. package/lib/sui/sui-plugin.d.ts.map +1 -1
  94. package/lib/sui/sui-plugin.js +12 -159
  95. package/lib/sui/sui-plugin.js.map +1 -1
  96. package/lib/testing/iota-facet.d.ts +14 -0
  97. package/lib/testing/iota-facet.d.ts.map +1 -0
  98. package/lib/testing/iota-facet.js +124 -0
  99. package/lib/testing/iota-facet.js.map +1 -0
  100. package/lib/testing/test-processor-server.d.ts +2 -0
  101. package/lib/testing/test-processor-server.d.ts.map +1 -1
  102. package/lib/testing/test-processor-server.js +3 -0
  103. package/lib/testing/test-processor-server.js.map +1 -1
  104. package/package.json +20 -8
  105. package/src/iota/abis/0x1.json +4213 -0
  106. package/src/iota/abis/0x2.json +26692 -0
  107. package/src/iota/abis/0x3.json +10598 -0
  108. package/src/iota/builtin/0x1.ts +6292 -0
  109. package/src/iota/builtin/0x2.ts +26198 -0
  110. package/src/iota/builtin/0x3.ts +11144 -0
  111. package/src/iota/builtin/index.ts +6 -0
  112. package/src/iota/codegen/codegen.ts +118 -0
  113. package/src/iota/codegen/index.ts +1 -0
  114. package/src/iota/codegen/run.ts +13 -0
  115. package/src/iota/context.ts +200 -0
  116. package/src/iota/ext/coin.ts +565 -0
  117. package/src/iota/ext/index.ts +2 -0
  118. package/src/iota/ext/move-dex.ts +52 -0
  119. package/src/iota/index.ts +29 -0
  120. package/src/iota/iota-object-processor-template.ts +277 -0
  121. package/src/iota/iota-object-processor.ts +386 -0
  122. package/src/iota/iota-plugin-part.ts +211 -0
  123. package/src/iota/iota-plugin.ts +2 -0
  124. package/src/iota/iota-processor.ts +339 -0
  125. package/src/iota/models.ts +14 -0
  126. package/src/iota/move-coder.ts +15 -0
  127. package/src/iota/network.ts +27 -0
  128. package/src/iota/utils.ts +52 -0
  129. package/src/sui/network.ts +0 -3
  130. package/src/sui/sui-plugin-part.ts +211 -0
  131. package/src/sui/sui-plugin.ts +12 -178
  132. package/src/testing/iota-facet.ts +143 -0
  133. package/src/testing/test-processor-server.ts +3 -0
@@ -0,0 +1,178 @@
1
+ import { USER_PROCESSOR } from '@sentio/runtime';
2
+ import { AccountConfig, ContractConfig, HandlerType } from '@sentio/protos';
3
+ import { IotaProcessorState } from './iota-processor.js';
4
+ import { IotaAccountProcessorState, IotaAddressProcessor } from './iota-object-processor.js';
5
+ import { initCoinList } from './ext/coin.js';
6
+ import { SuiChainId } from '@sentio/chain';
7
+ import { IotaAccountProcessorTemplateState } from './iota-object-processor-template.js';
8
+ import { IotaNetwork } from './network.js';
9
+ import { IotaContext } from './context.js';
10
+ export class IotaPluginPart {
11
+ handlerRegister;
12
+ partitionManager;
13
+ constructor(handlerRegister, partitionManager) {
14
+ this.handlerRegister = handlerRegister;
15
+ this.partitionManager = partitionManager;
16
+ }
17
+ async start(request) {
18
+ await initCoinList();
19
+ console.log('total instances:', request.templateInstances.length);
20
+ const allowedChainIds = new Set([SuiChainId.IOTA_MAINNET, SuiChainId.IOTA_TESTNET]);
21
+ for (const instance of request.templateInstances) {
22
+ if (!allowedChainIds.has(instance.contract?.chainId || '')) {
23
+ continue;
24
+ }
25
+ console.log('start template instance', instance.templateId);
26
+ const template = IotaAccountProcessorTemplateState.INSTANCE.getValues()[instance.templateId];
27
+ template.bind({
28
+ address: instance.contract?.address || '',
29
+ objectId: instance.contract?.address || '',
30
+ network: instance.contract?.chainId || IotaNetwork.MAIN_NET,
31
+ startCheckpoint: instance.startBlock || 0n,
32
+ endCheckpoint: instance.endBlock || 0n,
33
+ baseLabels: instance.baseLabels
34
+ }, NoopContext);
35
+ }
36
+ }
37
+ async init(config) {
38
+ for (const state of [IotaProcessorState.INSTANCE, IotaAccountProcessorState.INSTANCE]) {
39
+ for (const suiProcessor of state.getValues()) {
40
+ config.chainIds.push(suiProcessor.config.network);
41
+ }
42
+ }
43
+ }
44
+ async configure(config, forChainId) {
45
+ // this.handlerRegister.clear(forChainId as any)
46
+ for (const suiProcessor of IotaProcessorState.INSTANCE.getValues()) {
47
+ const chainId = suiProcessor.config.network;
48
+ if (forChainId !== undefined && forChainId !== chainId.toString()) {
49
+ continue;
50
+ }
51
+ const contractConfig = ContractConfig.fromPartial({
52
+ transactionConfig: [],
53
+ processorType: USER_PROCESSOR,
54
+ contract: {
55
+ name: suiProcessor.moduleName,
56
+ chainId: suiProcessor.config.network,
57
+ address: suiProcessor.config.address,
58
+ abi: ''
59
+ },
60
+ startBlock: suiProcessor.config.startCheckpoint,
61
+ endBlock: suiProcessor.config.endCheckpoint
62
+ });
63
+ for (const handler of suiProcessor.eventHandlers) {
64
+ const handlerId = this.handlerRegister.register(handler.handler, chainId);
65
+ this.partitionManager.registerPartitionHandler(HandlerType.SUI_EVENT, handlerId, handler.partitionHandler);
66
+ const eventHandlerConfig = {
67
+ filters: handler.filters.map((f) => {
68
+ return {
69
+ type: f.type,
70
+ account: f.account || '',
71
+ eventAccount: f.eventAccount || ''
72
+ };
73
+ }),
74
+ fetchConfig: handler.fetchConfig,
75
+ handlerId,
76
+ handlerName: handler.handlerName
77
+ };
78
+ contractConfig.moveEventConfigs.push(eventHandlerConfig);
79
+ }
80
+ for (const handler of suiProcessor.callHandlers) {
81
+ const handlerId = this.handlerRegister.register(handler.handler, chainId);
82
+ this.partitionManager.registerPartitionHandler(HandlerType.SUI_CALL, handlerId, handler.partitionHandler);
83
+ const functionHandlerConfig = {
84
+ filters: handler.filters.map((filter) => {
85
+ return {
86
+ function: filter.function,
87
+ typeArguments: filter.typeArguments || [],
88
+ withTypeArguments: !!filter.typeArguments,
89
+ includeFailed: filter.includeFailed || false,
90
+ publicKeyPrefix: filter.publicKeyPrefix || '',
91
+ fromAndToAddress: filter.fromAndToAddress
92
+ };
93
+ }),
94
+ fetchConfig: handler.fetchConfig,
95
+ handlerId,
96
+ handlerName: handler.handlerName
97
+ };
98
+ contractConfig.moveCallConfigs.push(functionHandlerConfig);
99
+ }
100
+ // deprecated, use objectType processor instead
101
+ for (const handler of suiProcessor.objectChangeHandlers) {
102
+ const handlerId = this.handlerRegister.register(handler.handler, chainId);
103
+ const objectChangeHandler = {
104
+ type: handler.type,
105
+ handlerId,
106
+ handlerName: handler.handlerName,
107
+ includeDeleted: false
108
+ };
109
+ contractConfig.moveResourceChangeConfigs.push(objectChangeHandler);
110
+ }
111
+ config.contractConfigs.push(contractConfig);
112
+ }
113
+ for (const processor of IotaAccountProcessorState.INSTANCE.getValues()) {
114
+ const chainId = processor.getChainId();
115
+ if (forChainId !== undefined && forChainId !== chainId.toString()) {
116
+ continue;
117
+ }
118
+ const accountConfig = AccountConfig.fromPartial({
119
+ address: processor.config.address,
120
+ chainId: processor.getChainId(),
121
+ startBlock: processor.config.startCheckpoint, // TODO maybe use another field
122
+ endBlock: processor.config.endCheckpoint
123
+ });
124
+ for (const handler of processor.objectChangeHandlers) {
125
+ const handlerId = this.handlerRegister.register(handler.handler, chainId);
126
+ const objectChangeHandler = {
127
+ type: handler.type,
128
+ handlerId,
129
+ handlerName: handler.handlerName,
130
+ includeDeleted: false
131
+ };
132
+ accountConfig.moveResourceChangeConfigs.push(objectChangeHandler);
133
+ }
134
+ for (const handler of processor.objectHandlers) {
135
+ const handlerId = this.handlerRegister.register(handler.handler, chainId);
136
+ accountConfig.moveIntervalConfigs.push({
137
+ intervalConfig: {
138
+ handlerId: handlerId,
139
+ handlerName: handler.handlerName,
140
+ minutes: 0,
141
+ minutesInterval: handler.timeIntervalInMinutes,
142
+ slot: 0,
143
+ slotInterval: handler.checkPointInterval,
144
+ fetchConfig: undefined
145
+ },
146
+ type: handler.type || '',
147
+ ownerType: processor.ownerType,
148
+ resourceFetchConfig: handler.fetchConfig,
149
+ fetchConfig: undefined
150
+ });
151
+ }
152
+ if (processor instanceof IotaAddressProcessor) {
153
+ for (const handler of processor.callHandlers) {
154
+ const handlerId = this.handlerRegister.register(handler.handler, chainId);
155
+ const functionHandlerConfig = {
156
+ filters: handler.filters.map((filter) => {
157
+ return {
158
+ function: filter.function,
159
+ typeArguments: filter.typeArguments || [],
160
+ withTypeArguments: !!filter.typeArguments,
161
+ includeFailed: filter.includeFailed || false,
162
+ publicKeyPrefix: filter.publicKeyPrefix || '',
163
+ fromAndToAddress: filter.fromAndToAddress
164
+ };
165
+ }),
166
+ fetchConfig: handler.fetchConfig,
167
+ handlerId,
168
+ handlerName: handler.handlerName
169
+ };
170
+ accountConfig.moveCallConfigs.push(functionHandlerConfig);
171
+ }
172
+ }
173
+ config.accountConfigs.push(accountConfig);
174
+ }
175
+ }
176
+ }
177
+ const NoopContext = new IotaContext('', SuiChainId.IOTA_MAINNET, '', new Date(), 0n, {}, 0, {});
178
+ //# sourceMappingURL=iota-plugin-part.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iota-plugin-part.js","sourceRoot":"","sources":["../../src/iota/iota-plugin-part.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EACL,aAAa,EACb,cAAc,EACd,WAAW,EAOZ,MAAM,gBAAgB,CAAA;AAKvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CA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+ export declare class IotaPlugin {
2
+ }
3
+ //# sourceMappingURL=iota-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iota-plugin.d.ts","sourceRoot":"","sources":["../../src/iota/iota-plugin.ts"],"names":[],"mappings":"AACA,qBAAa,UAAU;CAAG"}
@@ -0,0 +1,4 @@
1
+ // real plugin is in src/sui/sui-plugin.ts
2
+ export class IotaPlugin {
3
+ }
4
+ //# sourceMappingURL=iota-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iota-plugin.js","sourceRoot":"","sources":["../../src/iota/iota-plugin.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,MAAM,OAAO,UAAU;CAAG"}
@@ -0,0 +1,47 @@
1
+ import { Data_SuiCall, Data_SuiEvent, Data_SuiObjectChange, MoveFetchConfig } from '@sentio/protos';
2
+ import { ListStateStorage } from '@sentio/runtime';
3
+ import { IotaNetwork } from './network.js';
4
+ import { IotaContext, IotaObjectChangeContext } from './context.js';
5
+ import { MoveCallIotaTransaction, IotaEvent, IotaTransactionBlockResponse, IotaObjectChange } from '@iota/iota-sdk/client';
6
+ import { CallHandler, EventFilter, EventHandler, FunctionNameAndCallFilter, ObjectChangeHandler, TransactionFilter } from '../move/index.js';
7
+ import { MoveCoder } from './index.js';
8
+ import { Labels, PromiseOrVoid } from '../core/index.js';
9
+ import { Required } from 'utility-types';
10
+ import { HandlerOptions } from './models.js';
11
+ export declare const DEFAULT_FETCH_CONFIG: MoveFetchConfig;
12
+ export type IndexConfigure = Required<IotaBindOptions, 'startCheckpoint' | 'network'>;
13
+ export declare function configure(options: IotaBindOptions): IndexConfigure;
14
+ export interface IotaBindOptions {
15
+ address: string;
16
+ network?: IotaNetwork;
17
+ startCheckpoint?: bigint;
18
+ endCheckpoint?: bigint;
19
+ baseLabels?: Labels;
20
+ }
21
+ export declare class IotaProcessorState extends ListStateStorage<IotaBaseProcessor> {
22
+ static INSTANCE: IotaProcessorState;
23
+ }
24
+ export declare class IotaBaseProcessor {
25
+ readonly moduleName: string;
26
+ config: IndexConfigure;
27
+ eventHandlers: EventHandler<Data_SuiEvent>[];
28
+ callHandlers: CallHandler<Data_SuiCall>[];
29
+ objectChangeHandlers: ObjectChangeHandler<Data_SuiObjectChange>[];
30
+ coder: MoveCoder;
31
+ constructor(name: string, options: IotaBindOptions);
32
+ getChainId(): string;
33
+ protected onMoveEvent(handler: (event: IotaEvent, ctx: IotaContext) => PromiseOrVoid, filter: EventFilter | EventFilter[], handlerOptions?: HandlerOptions<MoveFetchConfig, IotaEvent>): IotaBaseProcessor;
34
+ protected onEntryFunctionCall(handler: (call: MoveCallIotaTransaction, ctx: IotaContext) => PromiseOrVoid, filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[], handlerOptions?: HandlerOptions<MoveFetchConfig, MoveCallIotaTransaction>): IotaBaseProcessor;
35
+ onEvent(handler: (event: IotaEvent, ctx: IotaContext) => void, handlerOptions?: HandlerOptions<MoveFetchConfig, IotaEvent>): this;
36
+ onTransactionBlock(handler: (transaction: IotaTransactionBlockResponse, ctx: IotaContext) => PromiseOrVoid, filter?: TransactionFilter, handlerOptions?: HandlerOptions<MoveFetchConfig, IotaTransactionBlockResponse>): this;
37
+ protected onObjectChange(handler: (changes: IotaObjectChange[], ctx: IotaObjectChangeContext) => PromiseOrVoid, type: string): this;
38
+ }
39
+ export declare class IotaModulesProcessor extends IotaBaseProcessor {
40
+ static bind(options: IotaBindOptions): IotaModulesProcessor;
41
+ }
42
+ export declare class IotaGlobalProcessor extends IotaBaseProcessor {
43
+ static bind(options: Omit<IotaBindOptions, 'address'>): IotaGlobalProcessor;
44
+ onTransactionBlock(handler: (transaction: IotaTransactionBlockResponse, ctx: IotaContext) => void, filter: TransactionFilter, fetchConfig?: Partial<MoveFetchConfig>): this;
45
+ onObjectChange(handler: (changes: IotaObjectChange[], ctx: IotaObjectChangeContext) => void, type: string): this;
46
+ }
47
+ //# sourceMappingURL=iota-processor.d.ts.map
@@ -0,0 +1 @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,SAAS,CAAC,cAAc,CACtB,OAAO,EAAE,CAAC,OAAO,EAAE,gBAAgB,EAAE,EAAE,GAAG,EAAE,uBAAuB,KAAK,aAAa,EACrF,IAAI,EAAE,MAAM,GACX,IAAI;CAwBR;AAED,qBAAa,oBAAqB,SAAQ,iBAAiB;IACzD,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,eAAe,GAAG,oBAAoB;CAG5D;AAED,qBAAa,mBAAoB,SAAQ,iBAAiB;IACxD,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,SAAS,CAAC,GAAG,mBAAmB;IAG3E,kBAAkB,CAChB,OAAO,EAAE,CAAC,WAAW,EAAE,4BAA4B,EAAE,GAAG,EAAE,WAAW,KAAK,IAAI,EAC9E,MAAM,EAAE,iBAAiB,EACzB,WAAW,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,GACrC,IAAI;IASA,cAAc,CACnB,OAAO,EAAE,CAAC,OAAO,EAAE,gBAAgB,EAAE,EAAE,GAAG,EAAE,uBAAuB,KAAK,IAAI,EAC5E,IAAI,EAAE,MAAM,GACX,IAAI;CAGR"}
@@ -0,0 +1,223 @@
1
+ import { MoveFetchConfig } from '@sentio/protos';
2
+ import { ListStateStorage } from '@sentio/runtime';
3
+ import { IotaNetwork } from './network.js';
4
+ import { ServerError, Status } from 'nice-grpc';
5
+ import { IotaContext, IotaObjectChangeContext } from './context.js';
6
+ import { accountAddressString, SPLITTER } from '../move/index.js';
7
+ import { getMoveCalls } from './utils.js';
8
+ import { defaultMoveCoder } from './index.js';
9
+ import { ALL_ADDRESS } from '../core/index.js';
10
+ import { getHandlerName, proxyProcessor } from '../utils/metrics.js';
11
+ export const DEFAULT_FETCH_CONFIG = {
12
+ resourceChanges: false,
13
+ allEvents: true,
14
+ inputs: true
15
+ };
16
+ export function configure(options) {
17
+ return {
18
+ startCheckpoint: options.startCheckpoint || 0n,
19
+ endCheckpoint: options.endCheckpoint,
20
+ address: options.address === ALL_ADDRESS ? ALL_ADDRESS : accountAddressString(options.address),
21
+ network: options.network || IotaNetwork.MAIN_NET,
22
+ baseLabels: options.baseLabels
23
+ };
24
+ }
25
+ export class IotaProcessorState extends ListStateStorage {
26
+ static INSTANCE = new IotaProcessorState();
27
+ }
28
+ export class IotaBaseProcessor {
29
+ moduleName;
30
+ config;
31
+ eventHandlers = [];
32
+ callHandlers = [];
33
+ objectChangeHandlers = [];
34
+ coder;
35
+ constructor(name, options) {
36
+ this.moduleName = name;
37
+ this.config = configure(options);
38
+ IotaProcessorState.INSTANCE.addValue(this);
39
+ this.coder = defaultMoveCoder(this.config.network);
40
+ return proxyProcessor(this);
41
+ }
42
+ getChainId() {
43
+ return this.config.network;
44
+ }
45
+ onMoveEvent(handler, filter, handlerOptions) {
46
+ let _filters = [];
47
+ const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...handlerOptions });
48
+ if (Array.isArray(filter)) {
49
+ _filters = filter;
50
+ }
51
+ else {
52
+ _filters.push(filter);
53
+ }
54
+ // const address = this.config.address
55
+ // const moduleName = this.moduleName
56
+ const processor = this;
57
+ this.eventHandlers.push({
58
+ handlerName: getHandlerName(),
59
+ handler: async function (data) {
60
+ if (!data.rawTransaction) {
61
+ throw new ServerError(Status.INVALID_ARGUMENT, 'event is null');
62
+ }
63
+ const txn = JSON.parse(data.rawTransaction);
64
+ if (txn.events == null) {
65
+ txn.events = [];
66
+ }
67
+ const evt = JSON.parse(data.rawEvent);
68
+ const idx = Number(evt.id.eventSeq) || 0;
69
+ const ctx = new IotaContext(processor.moduleName, processor.config.network, processor.config.address, data.timestamp || new Date(0), data.slot, txn, idx, processor.config.baseLabels);
70
+ const decoded = await processor.coder.decodeEvent(evt);
71
+ await handler(decoded || evt, ctx);
72
+ return ctx.stopAndGetResult();
73
+ },
74
+ filters: _filters,
75
+ fetchConfig: _fetchConfig,
76
+ partitionHandler: async (data) => {
77
+ const p = handlerOptions?.partitionKey;
78
+ if (!p)
79
+ return undefined;
80
+ if (typeof p === 'function') {
81
+ const evt = JSON.parse(data.rawEvent);
82
+ const decoded = await processor.coder.decodeEvent(evt);
83
+ return p(decoded || evt);
84
+ }
85
+ return p;
86
+ }
87
+ });
88
+ return this;
89
+ }
90
+ onEntryFunctionCall(handler, filter, handlerOptions) {
91
+ let _filters = [];
92
+ const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...handlerOptions });
93
+ if (Array.isArray(filter)) {
94
+ _filters = filter;
95
+ }
96
+ else {
97
+ _filters.push(filter);
98
+ }
99
+ const processor = this;
100
+ const allFunctionType = new Set(_filters.map((f) => f.function));
101
+ this.callHandlers.push({
102
+ handlerName: getHandlerName(),
103
+ handler: async function (data) {
104
+ if (!data.rawTransaction) {
105
+ throw new ServerError(Status.INVALID_ARGUMENT, 'call is null');
106
+ }
107
+ const tx = JSON.parse(data.rawTransaction);
108
+ const ctx = new IotaContext(processor.moduleName, processor.config.network, processor.config.address, data.timestamp || new Date(0), data.slot, tx, 0, processor.config.baseLabels);
109
+ if (tx) {
110
+ const calls = getMoveCalls(tx);
111
+ const txKind = tx.transaction?.data?.transaction;
112
+ if (!txKind) {
113
+ throw new ServerError(Status.INVALID_ARGUMENT, 'Unexpected getTransactionKind get empty');
114
+ }
115
+ // getProgrammableTransaction(txKind)
116
+ const programmableTx = txKind.kind === 'ProgrammableTransaction' ? txKind : undefined;
117
+ // TODO potential pass index
118
+ for (const call of calls) {
119
+ const functionType = [call.module, call.function].join(SPLITTER);
120
+ if (!allFunctionType.has(functionType)) {
121
+ continue;
122
+ }
123
+ // TODO maybe do in parallel
124
+ const decoded = await processor.coder.decodeFunctionPayload(call, programmableTx?.inputs || []);
125
+ await handler(decoded, ctx);
126
+ }
127
+ }
128
+ return ctx.stopAndGetResult();
129
+ },
130
+ filters: _filters,
131
+ fetchConfig: _fetchConfig,
132
+ partitionHandler: async (data) => {
133
+ const p = handlerOptions?.partitionKey;
134
+ if (!p)
135
+ return undefined;
136
+ if (typeof p === 'function') {
137
+ const tx = JSON.parse(data.rawTransaction);
138
+ const calls = getMoveCalls(tx);
139
+ // For simplicity, use the first call for partitioning
140
+ if (calls.length > 0) {
141
+ return p(calls[0]);
142
+ }
143
+ return undefined;
144
+ }
145
+ return p;
146
+ }
147
+ });
148
+ return this;
149
+ }
150
+ onEvent(handler, handlerOptions) {
151
+ this.onMoveEvent(handler, { type: '' }, handlerOptions);
152
+ return this;
153
+ }
154
+ onTransactionBlock(handler, filter, handlerOptions) {
155
+ const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...handlerOptions });
156
+ const processor = this;
157
+ this.callHandlers.push({
158
+ handlerName: getHandlerName(),
159
+ handler: async function (data) {
160
+ if (!data.rawTransaction) {
161
+ throw new ServerError(Status.INVALID_ARGUMENT, 'transaction is null');
162
+ }
163
+ const tx = JSON.parse(data.rawTransaction);
164
+ const ctx = new IotaContext(processor.moduleName, processor.config.network, processor.config.address, data.timestamp || new Date(0), data.slot, tx, 0, processor.config.baseLabels);
165
+ if (tx) {
166
+ await handler(tx, ctx);
167
+ }
168
+ return ctx.stopAndGetResult();
169
+ },
170
+ filters: [{ ...filter, function: '' }],
171
+ fetchConfig: _fetchConfig,
172
+ partitionHandler: async (data) => {
173
+ const p = handlerOptions?.partitionKey;
174
+ if (!p)
175
+ return undefined;
176
+ if (typeof p === 'function') {
177
+ const tx = JSON.parse(data.rawTransaction);
178
+ return p(tx);
179
+ }
180
+ return p;
181
+ }
182
+ });
183
+ return this;
184
+ }
185
+ onObjectChange(handler, type) {
186
+ if (this.config.network === IotaNetwork.TEST_NET) {
187
+ throw new ServerError(Status.INVALID_ARGUMENT, 'object change not supported in testnet');
188
+ }
189
+ const processor = this;
190
+ this.objectChangeHandlers.push({
191
+ handlerName: getHandlerName(),
192
+ handler: async function (data) {
193
+ const ctx = new IotaObjectChangeContext(processor.config.network, processor.config.address, data.timestamp || new Date(0), data.slot, data.txDigest, processor.config.baseLabels);
194
+ await handler(data.rawChanges.map((r) => JSON.parse(r)), ctx);
195
+ return ctx.stopAndGetResult();
196
+ },
197
+ type
198
+ });
199
+ return this;
200
+ }
201
+ }
202
+ export class IotaModulesProcessor extends IotaBaseProcessor {
203
+ static bind(options) {
204
+ return new IotaModulesProcessor(ALL_ADDRESS, options);
205
+ }
206
+ }
207
+ export class IotaGlobalProcessor extends IotaBaseProcessor {
208
+ static bind(options) {
209
+ return new IotaGlobalProcessor(ALL_ADDRESS, { ...options, address: ALL_ADDRESS });
210
+ }
211
+ onTransactionBlock(handler, filter, fetchConfig) {
212
+ // TODO enable more strict check
213
+ // if (!filter.publicKeyPrefix || filter.publicKeyPrefix.length < 2) {
214
+ // throw new ServerError(Status.INVALID_ARGUMENT, 'restriction too low for global processor')
215
+ // }
216
+ return super.onTransactionBlock(handler, filter, fetchConfig);
217
+ }
218
+ // deprecated,, use object type processor
219
+ onObjectChange(handler, type) {
220
+ return super.onObjectChange(handler, type);
221
+ }
222
+ }
223
+ //# sourceMappingURL=iota-processor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iota-processor.js","sourceRoot":"","sources":["../../src/iota/iota-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqD,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACnG,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAOnE,OAAO,EACL,oBAAoB,EAMpB,QAAQ,EAET,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAa,MAAM,YAAY,CAAA;AACxD,OAAO,EAAE,WAAW,EAAyB,MAAM,kBA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AAC,CAAC,CAAuB,EAAE,GAAG,CAAC,CAAA;gBACnF,OAAO,GAAG,CAAC,gBAAgB,EAAE,CAAA;YAC/B,CAAC;YACD,IAAI;SACL,CAAC,CAAA;QAEF,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAED,MAAM,OAAO,oBAAqB,SAAQ,iBAAiB;IACzD,MAAM,CAAC,IAAI,CAAC,OAAwB;QAClC,OAAO,IAAI,oBAAoB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;IACvD,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,iBAAiB;IACxD,MAAM,CAAC,IAAI,CAAC,OAAyC;QACnD,OAAO,IAAI,mBAAmB,CAAC,WAAW,EAAE,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAA;IACnF,CAAC;IACD,kBAAkB,CAChB,OAA8E,EAC9E,MAAyB,EACzB,WAAsC;QAEtC,gCAAgC;QAChC,sEAAsE;QACtE,+FAA+F;QAC/F,IAAI;QACJ,OAAO,KAAK,CAAC,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAA;IAC/D,CAAC;IAED,yCAAyC;IAClC,cAAc,CACnB,OAA4E,EAC5E,IAAY;QAEZ,OAAO,KAAK,CAAC,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;IAC5C,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ import type { IotaEvent, MoveCallIotaTransaction, IotaMoveObject } from '@iota/iota-sdk/client';
2
+ import { DecodedStruct } from '@typemove/move';
3
+ export type TypedEventInstance<T> = DecodedStruct<IotaEvent, T>;
4
+ export type TypedIotaMoveObject<T> = DecodedStruct<IotaMoveObject, T>;
5
+ export type TypedFunctionPayload<T extends Array<any>> = MoveCallIotaTransaction & {
6
+ /**
7
+ * decoded argument data using ABI, undefined if there is decoding error, usually because the ABI/data mismatch
8
+ */
9
+ arguments_decoded: T;
10
+ };
11
+ export type { PartitionHandler, HandlerOptions } from '../core/index.js';
12
+ //# sourceMappingURL=models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/iota/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC/F,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAE9C,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,aAAa,CAAC,SAAS,EAAE,CAAC,CAAC,CAAA;AAC/D,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,aAAa,CAAC,cAAc,EAAE,CAAC,CAAC,CAAA;AAErE,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,IAAI,uBAAuB,GAAG;IACjF;;OAEG;IACH,iBAAiB,EAAE,CAAC,CAAA;CACrB,CAAA;AAED,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/iota/models.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import { MoveCoder } from '@typemove/iota';
2
+ import { IotaNetwork } from './network.js';
3
+ export declare function defaultMoveCoder(network?: IotaNetwork): MoveCoder;
4
+ //# sourceMappingURL=move-coder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"move-coder.d.ts","sourceRoot":"","sources":["../../src/iota/move-coder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,OAAO,EAAa,WAAW,EAAE,MAAM,cAAc,CAAA;AAIrD,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,WAAkC,GAAG,SAAS,CAQvF"}
@@ -0,0 +1,12 @@
1
+ import { MoveCoder } from '@typemove/iota';
2
+ import { getClient, IotaNetwork } from './network.js';
3
+ const CODERS = new Map();
4
+ export function defaultMoveCoder(network = IotaNetwork.MAIN_NET) {
5
+ let coder = CODERS.get(network);
6
+ if (!coder) {
7
+ coder = new MoveCoder(getClient(network));
8
+ CODERS.set(network, coder);
9
+ }
10
+ return coder;
11
+ }
12
+ //# sourceMappingURL=move-coder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"move-coder.js","sourceRoot":"","sources":["../../src/iota/move-coder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAErD,MAAM,MAAM,GAAG,IAAI,GAAG,EAA0B,CAAA;AAEhD,MAAM,UAAU,gBAAgB,CAAC,UAAuB,WAAW,CAAC,QAAQ;IAC1E,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IAC/B,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,KAAK,GAAG,IAAI,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;QACzC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAC5B,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { SuiChainId } from '@sentio/chain';
2
+ import { IotaClient } from '@iota/iota-sdk/client';
3
+ export type IotaNetwork = SuiChainId;
4
+ export declare const IotaNetwork: {
5
+ readonly MAIN_NET: SuiChainId.IOTA_MAINNET;
6
+ readonly TEST_NET: SuiChainId.IOTA_TESTNET;
7
+ };
8
+ export declare function getClient(network: IotaNetwork): IotaClient;
9
+ export declare function getRpcEndpoint(network: IotaNetwork): string;
10
+ //# sourceMappingURL=network.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../src/iota/network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAG1C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAElD,MAAM,MAAM,WAAW,GAAG,UAAU,CAAA;AACpC,eAAO,MAAM,WAAW;;;CAGvB,CAAA;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,WAAW,GAAG,UAAU,CAO1D;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAM3D"}
@@ -0,0 +1,24 @@
1
+ import { SuiChainId } from '@sentio/chain';
2
+ import { Endpoints } from '@sentio/runtime';
3
+ // import { ServerError, Status } from 'nice-grpc'
4
+ import { IotaClient } from '@iota/iota-sdk/client';
5
+ export const IotaNetwork = {
6
+ MAIN_NET: SuiChainId.IOTA_MAINNET,
7
+ TEST_NET: SuiChainId.IOTA_TESTNET
8
+ };
9
+ export function getClient(network) {
10
+ let chainServer = Endpoints.INSTANCE.chainServer.get(network);
11
+ if (!chainServer) {
12
+ chainServer = getRpcEndpoint(network);
13
+ // throw new ServerError(Status.INTERNAL, 'RPC endpoint not provided')
14
+ }
15
+ return new IotaClient({ url: chainServer });
16
+ }
17
+ export function getRpcEndpoint(network) {
18
+ switch (network) {
19
+ case IotaNetwork.TEST_NET:
20
+ return 'https://api.testnet.iota.cafe/';
21
+ }
22
+ return 'https://api.mainnet.iota.cafe/';
23
+ }
24
+ //# sourceMappingURL=network.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network.js","sourceRoot":"","sources":["../../src/iota/network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,kDAAkD;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAGlD,MAAM,CAAC,MAAM,WAAW,GAAU;IAChC,QAAQ,EAAE,UAAU,CAAC,YAAY;IACjC,QAAQ,EAAE,UAAU,CAAC,YAAY;CAClC,CAAA;AAED,MAAM,UAAU,SAAS,CAAC,OAAoB;IAC5C,IAAI,WAAW,GAAG,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IAC7D,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,WAAW,GAAG,cAAc,CAAC,OAAO,CAAC,CAAA;QACrC,sEAAsE;IACxE,CAAC;IACD,OAAO,IAAI,UAAU,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC,CAAA;AAC7C,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,OAAoB;IACjD,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,WAAW,CAAC,QAAQ;YACvB,OAAO,gCAAgC,CAAA;IAC3C,CAAC;IACD,OAAO,gCAAgC,CAAA;AACzC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { IotaTransactionBlockResponse, MoveCallIotaTransaction } from '@iota/iota-sdk/client';
2
+ export declare function getMoveCalls(txBlock: IotaTransactionBlockResponse): MoveCallIotaTransaction[];
3
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/iota/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,uBAAuB,EAGxB,MAAM,uBAAuB,CAAA;AAG9B,wBAAgB,YAAY,CAAC,OAAO,EAAE,4BAA4B,6BAoBjE"}