@sentio/sdk 2.35.1-rc.1 → 2.36.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 (46) hide show
  1. package/lib/aptos/aptos-plugin.d.ts.map +1 -1
  2. package/lib/aptos/aptos-plugin.js +30 -20
  3. package/lib/aptos/aptos-plugin.js.map +1 -1
  4. package/lib/fuel/asset-processor.d.ts +36 -0
  5. package/lib/fuel/asset-processor.d.ts.map +1 -0
  6. package/lib/fuel/asset-processor.js +85 -0
  7. package/lib/fuel/asset-processor.js.map +1 -0
  8. package/lib/fuel/base-processor.d.ts +1 -1
  9. package/lib/fuel/base-processor.d.ts.map +1 -1
  10. package/lib/fuel/base-processor.js +2 -1
  11. package/lib/fuel/base-processor.js.map +1 -1
  12. package/lib/fuel/context.js +2 -2
  13. package/lib/fuel/context.js.map +1 -1
  14. package/lib/fuel/fuel-plugin.d.ts.map +1 -1
  15. package/lib/fuel/fuel-plugin.js +17 -29
  16. package/lib/fuel/fuel-plugin.js.map +1 -1
  17. package/lib/fuel/fuel-processor.d.ts +3 -10
  18. package/lib/fuel/fuel-processor.d.ts.map +1 -1
  19. package/lib/fuel/fuel-processor.js +4 -7
  20. package/lib/fuel/fuel-processor.js.map +1 -1
  21. package/lib/fuel/index.d.ts +1 -0
  22. package/lib/fuel/index.d.ts.map +1 -1
  23. package/lib/fuel/index.js +1 -0
  24. package/lib/fuel/index.js.map +1 -1
  25. package/lib/fuel/transaction.d.ts +5 -2
  26. package/lib/fuel/transaction.d.ts.map +1 -1
  27. package/lib/fuel/transaction.js +37 -13
  28. package/lib/fuel/transaction.js.map +1 -1
  29. package/lib/fuel/types.d.ts +16 -0
  30. package/lib/fuel/types.d.ts.map +1 -0
  31. package/lib/fuel/types.js +5 -0
  32. package/lib/fuel/types.js.map +1 -0
  33. package/lib/testing/fuel-facet.d.ts.map +1 -1
  34. package/lib/testing/fuel-facet.js +13 -0
  35. package/lib/testing/fuel-facet.js.map +1 -1
  36. package/package.json +3 -3
  37. package/src/aptos/aptos-plugin.ts +38 -32
  38. package/src/fuel/asset-processor.ts +119 -0
  39. package/src/fuel/base-processor.ts +16 -11
  40. package/src/fuel/context.ts +2 -2
  41. package/src/fuel/fuel-plugin.ts +15 -32
  42. package/src/fuel/fuel-processor.ts +12 -16
  43. package/src/fuel/index.ts +2 -1
  44. package/src/fuel/transaction.ts +42 -14
  45. package/src/fuel/types.ts +18 -0
  46. package/src/testing/fuel-facet.ts +14 -0
@@ -2,22 +2,46 @@ import { arrayify, assembleTransactionSummary, bn, processGqlReceipt, Transactio
2
2
  export const DEFAULT_FUEL_FETCH_CONFIG = {
3
3
  includeFailed: false
4
4
  };
5
- export function decodeFuelTransaction(gqlTransaction, abiMap, provider) {
5
+ export function decodeFuelTransaction(gqlTransaction, provider) {
6
+ const rawPayload = arrayify(gqlTransaction.rawPayload);
7
+ const [decodedTransaction] = new TransactionCoder().decode(rawPayload, 0);
8
+ const { gasPerByte, gasPriceFactor, maxInputs, gasCosts } = provider.getChain().consensusParameters;
9
+ const blockNumber = gqlTransaction.status?.block?.header?.header;
10
+ return {
11
+ ...assembleTransactionSummary({
12
+ id: gqlTransaction.id,
13
+ receipts: [],
14
+ transaction: decodedTransaction,
15
+ transactionBytes: rawPayload,
16
+ gqlTransactionStatus: gqlTransaction.status,
17
+ gasPerByte: bn(gasPerByte),
18
+ gasPriceFactor: bn(gasPriceFactor),
19
+ maxInputs,
20
+ gasCosts
21
+ }),
22
+ blockNumber
23
+ };
24
+ }
25
+ export function decodeFuelTransactionWithAbi(gqlTransaction, abiMap, provider) {
6
26
  const rawPayload = arrayify(gqlTransaction.rawPayload);
7
27
  const [decodedTransaction] = new TransactionCoder().decode(rawPayload, 0);
8
28
  const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
9
29
  const { gasPerByte, gasPriceFactor, maxInputs, gasCosts } = provider.getChain().consensusParameters;
10
- return assembleTransactionSummary({
11
- id: gqlTransaction.id,
12
- receipts,
13
- transaction: decodedTransaction,
14
- transactionBytes: rawPayload,
15
- gqlTransactionStatus: gqlTransaction.status,
16
- gasPerByte: bn(gasPerByte),
17
- gasPriceFactor: bn(gasPriceFactor),
18
- abiMap,
19
- maxInputs,
20
- gasCosts
21
- });
30
+ const blockNumber = gqlTransaction.status?.block?.header?.header;
31
+ return {
32
+ ...assembleTransactionSummary({
33
+ id: gqlTransaction.id,
34
+ receipts,
35
+ transaction: decodedTransaction,
36
+ transactionBytes: rawPayload,
37
+ gqlTransactionStatus: gqlTransaction.status,
38
+ gasPerByte: bn(gasPerByte),
39
+ gasPriceFactor: bn(gasPriceFactor),
40
+ abiMap,
41
+ maxInputs,
42
+ gasCosts
43
+ }),
44
+ blockNumber
45
+ };
22
46
  }
23
47
  //# sourceMappingURL=transaction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/fuel/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EACR,0BAA0B,EAC1B,EAAE,EACF,iBAAiB,EAEjB,gBAAgB,EAEjB,MAAM,OAAO,CAAA;AAMd,MAAM,CAAC,MAAM,yBAAyB,GAAoB;IACxD,aAAa,EAAE,KAAK;CACrB,CAAA;AAID,MAAM,UAAU,qBAAqB,CAAC,cAAmB,EAAE,MAAc,EAAE,QAAkB;IAC3F,MAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,CAAA;IAEtD,MAAM,CAAC,kBAAkB,CAAC,GAAG,IAAI,gBAAgB,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAA;IAEzE,MAAM,QAAQ,GAAG,cAAc,CAAC,QAAQ,EAAE,GAAG,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAA;IAEtE,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC,mBAAmB,CAAA;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AC,UAAU,CAAC;YAC1B,cAAc,EAAE,EAAE,CAAC,cAAc,CAAC;YAClC,SAAS;YACT,QAAQ;SACT,CAAC;QACF,WAAW;KACZ,CAAA;AACH,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,cAAmB,EAAE,MAAc,EAAE,QAAkB;IAClG,MAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,CAAA;IAEtD,MAAM,CAAC,kBAAkB,CAAC,GAAG,IAAI,gBAAgB,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAA;IAEzE,MAAM,QAAQ,GAAG,cAAc,CAAC,QAAQ,EAAE,GAAG,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAA;IAEtE,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC,mBAAmB,CAAA;IACnG,MAAM,WAAW,GAAG,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAA;IAEhE,OAAO;QACL,GAAG,0BAA0B,CAAC;YAC5B,EAAE,EAAE,cAAc,CAAC,EAAE;YACrB,QAAQ;YACR,WAAW,EAAE,kBAAkB;YAC/B,gBAAgB,EAAE,UAAU;YAC5B,oBAAoB,EAAE,cAAc,CAAC,MAAM;YAC3C,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC;YAC1B,cAAc,EAAE,EAAE,CAAC,cAAc,CAAC;YAClC,MAAM;YACN,SAAS;YACT,QAAQ;SACT,CAAC;QACF,WAAW;KACZ,CAAA;AACH,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { ListStateStorage } from '@sentio/runtime';
2
+ import { Data_FuelCall, FuelAssetHandlerConfig, FuelCallHandlerConfig, ProcessResult } from '@sentio/protos';
3
+ export interface FuelBaseProcessor<T> {
4
+ configure(): Promise<void>;
5
+ config: T;
6
+ callHandlers: CallHandler<Data_FuelCall>[];
7
+ }
8
+ export declare class FuelProcessorState extends ListStateStorage<FuelBaseProcessor<any>> {
9
+ static INSTANCE: FuelProcessorState;
10
+ }
11
+ export type CallHandler<T> = {
12
+ handler: (call: T) => Promise<ProcessResult>;
13
+ fetchConfig?: Partial<FuelCallHandlerConfig>;
14
+ assetConfig?: Partial<FuelAssetHandlerConfig>;
15
+ };
16
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/fuel/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAE5G,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1B,MAAM,EAAE,CAAC,CAAA;IACT,YAAY,EAAE,WAAW,CAAC,aAAa,CAAC,EAAE,CAAA;CAC3C;AAED,qBAAa,kBAAmB,SAAQ,gBAAgB,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;IAC9E,MAAM,CAAC,QAAQ,qBAA2B;CAC3C;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC3B,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,aAAa,CAAC,CAAA;IAC5C,WAAW,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAA;IAC5C,WAAW,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAA;CAC9C,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { ListStateStorage } from '@sentio/runtime';
2
+ export class FuelProcessorState extends ListStateStorage {
3
+ static INSTANCE = new FuelProcessorState();
4
+ }
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/fuel/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AASlD,MAAM,OAAO,kBAAmB,SAAQ,gBAAwC;IAC9E,MAAM,CAAC,QAAQ,GAAG,IAAI,kBAAkB,EAAE,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"fuel-facet.d.ts","sourceRoot":"","sources":["../../src/testing/fuel-facet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAGhE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,qBAAa,SAAS;IACpB,MAAM,EAAE,mBAAmB,CAAA;gBAEf,MAAM,EAAE,mBAAmB;IAIvC,iBAAiB,CAAC,WAAW,EAAE,GAAG,EAAE,OAAO,GAAE,WAAkC;IAW/E,OAAO,CAAC,YAAY;CAkCrB"}
1
+ {"version":3,"file":"fuel-facet.d.ts","sourceRoot":"","sources":["../../src/testing/fuel-facet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAGhE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,qBAAa,SAAS;IACpB,MAAM,EAAE,mBAAmB,CAAA;gBAEf,MAAM,EAAE,mBAAmB;IAIvC,iBAAiB,CAAC,WAAW,EAAE,GAAG,EAAE,OAAO,GAAE,WAAkC;IAW/E,OAAO,CAAC,YAAY;CAgDrB"}
@@ -44,6 +44,19 @@ export class FuelFacet {
44
44
  res.push(binding);
45
45
  }
46
46
  }
47
+ for (const assetConfig of config.assetConfigs) {
48
+ const binding = {
49
+ data: {
50
+ fuelCall: {
51
+ transaction,
52
+ timestamp: new Date()
53
+ }
54
+ },
55
+ handlerIds: [assetConfig.handlerId],
56
+ handlerType: HandlerType.FUEL_CALL
57
+ };
58
+ res.push(binding);
59
+ }
47
60
  }
48
61
  return res;
49
62
  }
@@ -1 +1 @@
1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AAC;QACH,CAAC;QAED,OAAO,GAAG,CAAA;IACZ,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentio/sdk",
3
- "version": "2.35.1-rc.1",
3
+ "version": "2.36.0-rc.2",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -77,8 +77,8 @@
77
77
  "typedoc": "^0.25.7",
78
78
  "utility-types": "^3.11.0",
79
79
  "yaml": "^2.3.4",
80
- "@sentio/protos": "2.35.1-rc.1",
81
- "@sentio/runtime": "^2.35.1-rc.1"
80
+ "@sentio/protos": "2.36.0-rc.2",
81
+ "@sentio/runtime": "^2.36.0-rc.2"
82
82
  },
83
83
  "peerDependencies": {
84
84
  "tsup": "npm:@sentio/tsup@^6.7.2"
@@ -1,4 +1,4 @@
1
- import { errorString, mergeProcessResults, Plugin, PluginManager, USER_PROCESSOR } from '@sentio/runtime'
1
+ import { errorString, GLOBAL_CONFIG, mergeProcessResults, Plugin, PluginManager, USER_PROCESSOR } from '@sentio/runtime'
2
2
  import {
3
3
  AccountConfig,
4
4
  ContractConfig,
@@ -12,7 +12,7 @@ import {
12
12
  MoveOwnerType,
13
13
  ProcessConfigResponse,
14
14
  ProcessResult,
15
- StartRequest,
15
+ StartRequest
16
16
  } from '@sentio/protos'
17
17
 
18
18
  import { ServerError, Status } from 'nice-grpc'
@@ -24,7 +24,7 @@ import { AptosChainId } from '@sentio/chain'
24
24
  import { AptosResourcesContext } from './context.js'
25
25
  import {
26
26
  AptosResourceProcessorTemplate,
27
- AptosResourceProcessorTemplateState,
27
+ AptosResourceProcessorTemplateState
28
28
  } from './aptos-resource-processor-template.js'
29
29
  import { AptosNetwork } from './network.js'
30
30
 
@@ -38,7 +38,7 @@ export class AptosPlugin extends Plugin {
38
38
  handlers: Handlers = {
39
39
  aptosEventHandlers: [],
40
40
  aptosCallHandlers: [],
41
- aptosResourceHandlers: [],
41
+ aptosResourceHandlers: []
42
42
  }
43
43
 
44
44
  async start(request: StartRequest) {
@@ -57,7 +57,7 @@ export class AptosPlugin extends Plugin {
57
57
  {
58
58
  address: instance.contract?.address || '',
59
59
  network: <AptosNetwork>instance.contract?.chainId || AptosNetwork.MAIN_NET,
60
- startVersion: instance.startBlock || 0n,
60
+ startVersion: instance.startBlock || 0n
61
61
  },
62
62
  NoopContext
63
63
  )
@@ -68,7 +68,7 @@ export class AptosPlugin extends Plugin {
68
68
  const handlers: Handlers = {
69
69
  aptosEventHandlers: [],
70
70
  aptosCallHandlers: [],
71
- aptosResourceHandlers: [],
71
+ aptosResourceHandlers: []
72
72
  }
73
73
  for (const aptosProcessor of AptosProcessorState.INSTANCE.getValues()) {
74
74
  const contractConfig = ContractConfig.fromPartial({
@@ -77,9 +77,9 @@ export class AptosPlugin extends Plugin {
77
77
  name: aptosProcessor.moduleName,
78
78
  chainId: aptosProcessor.getChainId(),
79
79
  address: aptosProcessor.config.address,
80
- abi: '',
80
+ abi: ''
81
81
  },
82
- startBlock: aptosProcessor.config.startVersion,
82
+ startBlock: aptosProcessor.config.startVersion
83
83
  })
84
84
  // 1. Prepare event handlers
85
85
  for (const handler of aptosProcessor.eventHandlers) {
@@ -88,11 +88,11 @@ export class AptosPlugin extends Plugin {
88
88
  filters: handler.filters.map((f) => {
89
89
  return {
90
90
  type: f.type,
91
- account: f.account || '',
91
+ account: f.account || ''
92
92
  }
93
93
  }),
94
94
  fetchConfig: handler.fetchConfig,
95
- handlerId,
95
+ handlerId
96
96
  }
97
97
  contractConfig.moveEventConfigs.push(eventHandlerConfig)
98
98
  }
@@ -107,11 +107,11 @@ export class AptosPlugin extends Plugin {
107
107
  typeArguments: filter.typeArguments || [],
108
108
  withTypeArguments: !!filter.typeArguments,
109
109
  includeFailed: filter.includeFailed || false,
110
- publicKeyPrefix: filter.publicKeyPrefix || '',
110
+ publicKeyPrefix: filter.publicKeyPrefix || ''
111
111
  }
112
112
  }),
113
113
  fetchConfig: handler.fetchConfig,
114
- handlerId,
114
+ handlerId
115
115
  }
116
116
  contractConfig.moveCallConfigs.push(functionHandlerConfig)
117
117
  }
@@ -122,7 +122,7 @@ export class AptosPlugin extends Plugin {
122
122
  const accountConfig = AccountConfig.fromPartial({
123
123
  address: aptosProcessor.config.address,
124
124
  chainId: aptosProcessor.getChainId(),
125
- startBlock: aptosProcessor.config.startVersion,
125
+ startBlock: aptosProcessor.config.startVersion
126
126
  })
127
127
  for (const handler of aptosProcessor.resourcesHandlers) {
128
128
  const handlerId = handlers.aptosResourceHandlers.push(handler.handler) - 1
@@ -133,11 +133,11 @@ export class AptosPlugin extends Plugin {
133
133
  minutesInterval: handler.timeIntervalInMinutes,
134
134
  slot: 0,
135
135
  slotInterval: handler.versionInterval,
136
- fetchConfig: undefined,
136
+ fetchConfig: undefined
137
137
  },
138
138
  type: handler.type || '',
139
139
  ownerType: MoveOwnerType.ADDRESS,
140
- fetchConfig: undefined,
140
+ fetchConfig: undefined
141
141
  })
142
142
  }
143
143
  config.accountConfigs.push(accountConfig)
@@ -168,15 +168,16 @@ export class AptosPlugin extends Plugin {
168
168
  const event = binding.data.aptEvent
169
169
 
170
170
  for (const handlerId of binding.handlerIds) {
171
- // only support aptos event for now
172
- promises.push(
173
- this.handlers.aptosEventHandlers[handlerId](event).catch((e) => {
174
- throw new ServerError(
175
- Status.INTERNAL,
176
- 'error processing event: ' + JSON.stringify(event) + '\n' + errorString(e)
177
- )
178
- })
179
- )
171
+ const promise = this.handlers.aptosEventHandlers[handlerId](event).catch((e) => {
172
+ throw new ServerError(
173
+ Status.INTERNAL,
174
+ 'error processing event: ' + JSON.stringify(event) + '\n' + errorString(e)
175
+ )
176
+ })
177
+ if (GLOBAL_CONFIG.execution.sequential) {
178
+ await promise
179
+ }
180
+ promises.push(promise)
180
181
  }
181
182
  return mergeProcessResults(await Promise.all(promises))
182
183
  }
@@ -189,14 +190,16 @@ export class AptosPlugin extends Plugin {
189
190
 
190
191
  const promises: Promise<ProcessResult>[] = []
191
192
  for (const handlerId of binding.handlerIds) {
192
- promises.push(
193
- this.handlers.aptosResourceHandlers[handlerId](resource).catch((e) => {
194
- throw new ServerError(
195
- Status.INTERNAL,
196
- 'error processing resource: ' + JSON.stringify(resource) + '\n' + errorString(e)
197
- )
198
- })
199
- )
193
+ const promise = this.handlers.aptosResourceHandlers[handlerId](resource).catch((e) => {
194
+ throw new ServerError(
195
+ Status.INTERNAL,
196
+ 'error processing resource: ' + JSON.stringify(resource) + '\n' + errorString(e)
197
+ )
198
+ })
199
+ if (GLOBAL_CONFIG.execution.sequential) {
200
+ await promise
201
+ }
202
+ promises.push(promise)
200
203
  }
201
204
  return mergeProcessResults(await Promise.all(promises))
202
205
  }
@@ -213,6 +216,9 @@ export class AptosPlugin extends Plugin {
213
216
  const promise = this.handlers.aptosCallHandlers[handlerId](call).catch((e) => {
214
217
  throw new ServerError(Status.INTERNAL, 'error processing call: ' + JSON.stringify(call) + '\n' + errorString(e))
215
218
  })
219
+ if (GLOBAL_CONFIG.execution.sequential) {
220
+ await promise
221
+ }
216
222
  promises.push(promise)
217
223
  }
218
224
  return mergeProcessResults(await Promise.all(promises))
@@ -0,0 +1,119 @@
1
+ import { CallHandler, FuelBaseProcessor, FuelProcessorState } from './types.js'
2
+ import { Data_FuelCall, FuelAssetHandlerConfig_AssetFilter } from '@sentio/protos'
3
+ import { FuelNetwork, getRpcEndpoint } from './network.js'
4
+ import { FuelContext } from './context.js'
5
+ import { decodeFuelTransaction } from './transaction.js'
6
+ import { InputType, OutputType, Provider } from 'fuels'
7
+
8
+ export class FuelAssetProcessor implements FuelBaseProcessor<FuelAssetProcessorConfig> {
9
+ callHandlers: CallHandler<Data_FuelCall>[] = []
10
+ private provider: Provider
11
+
12
+ static bind(config: FuelAssetProcessorConfig): FuelAssetProcessor {
13
+ const processor = new FuelAssetProcessor(config)
14
+ FuelProcessorState.INSTANCE.addValue(processor)
15
+ return processor
16
+ }
17
+
18
+ constructor(readonly config: FuelAssetProcessorConfig) {}
19
+
20
+ async configure(): Promise<void> {
21
+ const url = getRpcEndpoint(this.config.chainId)
22
+ this.provider = await Provider.create(url)
23
+ }
24
+
25
+ onTransfer(filter: TransferFilter, handler: (transfers: FuelTransfer, ctx: FuelContext) => void | Promise<void>) {
26
+ const filters: FuelAssetHandlerConfig_AssetFilter[] = []
27
+
28
+ const assetIds = arrayify(filter.assetId)
29
+ const froms = arrayify(filter.from)
30
+ const tos = arrayify(filter.to)
31
+
32
+ for (const assetId of assetIds) {
33
+ for (const from of froms) {
34
+ for (const to of tos) {
35
+ filters.push({
36
+ assetId: assetId,
37
+ fromAddress: from,
38
+ toAddress: to
39
+ })
40
+ }
41
+ }
42
+ }
43
+
44
+ const callHandler = {
45
+ handler: async (call: Data_FuelCall) => {
46
+ const gqlTransaction = call.transaction
47
+ const tx = decodeFuelTransaction(gqlTransaction, this.provider)
48
+
49
+ const ctx = new FuelContext(tx, this.config.chainId)
50
+ const transfer: FuelTransfer = {
51
+ from: [],
52
+ to: []
53
+ }
54
+ for (const input of tx.transaction.inputs || []) {
55
+ if (input.type == InputType.Coin) {
56
+ transfer.from.push({
57
+ address: input.owner,
58
+ assetId: input.assetId
59
+ })
60
+ }
61
+ }
62
+
63
+ for (const output of tx.transaction.outputs || []) {
64
+ if (output.type == OutputType.Coin) {
65
+ const value = output.amount.toString(10)
66
+ transfer.to.push({
67
+ address: output.to,
68
+ amount: BigInt(value),
69
+ assetId: output.assetId
70
+ })
71
+ }
72
+ }
73
+
74
+ await handler(transfer, ctx)
75
+ return ctx.stopAndGetResult()
76
+ },
77
+ assetConfig: {
78
+ filters
79
+ }
80
+ }
81
+ this.callHandlers.push(callHandler)
82
+ return this
83
+ }
84
+ }
85
+
86
+ export type FuelAssetProcessorConfig = {
87
+ name?: string
88
+ chainId: FuelNetwork
89
+ startBlock?: bigint
90
+ endBlock?: bigint
91
+ }
92
+
93
+ export type TransferFilter = {
94
+ from?: string | string[]
95
+ to?: string | string[]
96
+ assetId?: string | string[]
97
+ }
98
+
99
+ export type FuelTransfer = {
100
+ from: {
101
+ assetId: string
102
+ address: string
103
+ }[]
104
+ to: {
105
+ address: string
106
+ amount: bigint
107
+ assetId: string
108
+ }[]
109
+ }
110
+
111
+ function arrayify(value?: string | string[]): Array<string | undefined> {
112
+ if (value) {
113
+ if (Array.isArray(value)) {
114
+ return value.length > 0 ? value : [undefined]
115
+ }
116
+ return [value]
117
+ }
118
+ return [undefined]
119
+ }
@@ -1,12 +1,11 @@
1
- import { FuelProcessor, FuelProcessorConfig, FuelProcessorState } from './fuel-processor.js'
1
+ import { FuelProcessor, FuelProcessorConfig } from './fuel-processor.js'
2
2
  import { JsonAbi } from 'fuels'
3
3
  import { FuelCall, FuelContext } from './context.js'
4
4
  import { FuelFetchConfig } from './transaction.js'
5
5
  import { FuelChainId } from '@sentio/chain'
6
-
6
+ import { FuelProcessorState } from './types.js'
7
7
 
8
8
  export abstract class FuelAbstractProcessor extends FuelProcessor {
9
-
10
9
  protected constructor(abi: JsonAbi, config?: FuelProcessorConfig) {
11
10
  if (!config) {
12
11
  config = {
@@ -19,20 +18,26 @@ export abstract class FuelAbstractProcessor extends FuelProcessor {
19
18
  FuelProcessorState.INSTANCE.addValue(this)
20
19
  }
21
20
 
22
- protected onCallMethod<T extends Array<any>, R>(method: string, fn: (call: TypedCall<T, R>, ctx: FuelContext) => (void | Promise<void>), config: FuelFetchConfig): this {
21
+ protected onCallMethod<T extends Array<any>, R>(
22
+ method: string,
23
+ fn: (call: TypedCall<T, R>, ctx: FuelContext) => void | Promise<void>,
24
+ config: FuelFetchConfig
25
+ ): this {
23
26
  const nameFilter = method
24
- const handler =async (call: FuelCall, ctx: FuelContext) => {
25
- await fn({
26
- args: call.functionScopes[0].getCallConfig().args as T,
27
- returnValue: call.value as R
28
- }, ctx)
27
+ const handler = async (call: FuelCall, ctx: FuelContext) => {
28
+ await fn(
29
+ {
30
+ args: call.functionScopes[0].getCallConfig().args as T,
31
+ returnValue: call.value as R
32
+ },
33
+ ctx
34
+ )
29
35
  }
30
36
  return super.onCall(nameFilter, handler, config)
31
37
  }
32
-
33
38
  }
34
39
 
35
40
  export type TypedCall<T extends Array<any>, R> = {
36
41
  args: T
37
42
  returnValue: R
38
- }
43
+ }
@@ -22,12 +22,12 @@ export class FuelContext extends BaseContext {
22
22
  return {
23
23
  address: this.transaction?.id || '',
24
24
  contractName: this.transaction?.id || '', // TODO
25
- blockNumber: 0n,
25
+ blockNumber: BigInt(this.transaction?.blockNumber || 0),
26
26
  transactionIndex: 0,
27
27
  transactionHash: this.transaction?.id || '', // TODO
28
28
  chainId: this.getChainId(),
29
29
  name: name,
30
- logIndex: 0,
30
+ logIndex: -1,
31
31
  labels: normalizeLabels(labels)
32
32
  }
33
33
  }
@@ -10,9 +10,10 @@ import {
10
10
  } from '@sentio/protos'
11
11
 
12
12
  import { ServerError, Status } from 'nice-grpc'
13
- import { GlobalProcessorState } from '../eth/base-processor.js'
14
13
  import { TemplateInstanceState } from '../core/template.js'
15
- import { FuelProcessorState } from './fuel-processor.js'
14
+ import { FuelAssetProcessor } from './asset-processor.js'
15
+ import { FuelProcessorState } from './types.js'
16
+ import { FuelProcessor } from './fuel-processor.js'
16
17
 
17
18
  interface Handlers {
18
19
  callHandlers: ((trace: Data_FuelCall) => Promise<ProcessResult>)[]
@@ -42,52 +43,34 @@ export class FuelPlugin extends Plugin {
42
43
  startBlock: processor.config.startBlock,
43
44
  endBlock: processor.config.endBlock
44
45
  })
45
-
46
46
  for (const callHandler of processor.callHandlers) {
47
47
  const handlerId = handlers.callHandlers.push(callHandler.handler) - 1
48
- const fetchConfig = {
49
- handlerId,
50
- filters: callHandler.fetchConfig.filters || []
48
+ if (processor instanceof FuelProcessor) {
49
+ const fetchConfig = {
50
+ handlerId,
51
+ filters: callHandler.fetchConfig?.filters || []
52
+ }
53
+ contractConfig.fuelCallConfigs.push(fetchConfig)
54
+ } else if (processor instanceof FuelAssetProcessor) {
55
+ const assetConfig = callHandler.assetConfig
56
+ contractConfig.assetConfigs.push({
57
+ filters: assetConfig?.filters || [],
58
+ handlerId
59
+ })
51
60
  }
52
- contractConfig.fuelCallConfigs.push(fetchConfig)
53
61
  }
54
62
 
55
63
  // Finish up a contract
56
64
  config.contractConfigs.push(contractConfig)
57
65
  }
58
66
 
59
- for (const processor of GlobalProcessorState.INSTANCE.getValues()) {
60
- const chainId = processor.getChainId()
61
-
62
- const contractConfig = ContractConfig.fromPartial({
63
- processorType: USER_PROCESSOR,
64
- contract: {
65
- name: processor.config.name,
66
- chainId: chainId.toString(),
67
- address: processor.config.address, // can only be *
68
- abi: ''
69
- },
70
- startBlock: processor.config.startBlock,
71
- endBlock: processor.config.endBlock
72
- })
73
-
74
- config.contractConfigs.push(contractConfig)
75
- }
76
-
77
67
  this.handlers = handlers
78
68
  }
79
69
 
80
70
  supportedHandlers = [HandlerType.FUEL_CALL]
81
71
 
82
72
  processBinding(request: DataBinding): Promise<ProcessResult> {
83
- // return Promise.resolve(undefined);
84
73
  switch (request.handlerType) {
85
- // case HandlerType.FUEL_LOG:
86
- // return this.processLog(request)
87
- // case HandlerType.FUEL_TRACE:
88
- // return this.processTrace(request)
89
- // case HandlerType.FUEL_BLOCK:
90
- // return this.processBlock(request)
91
74
  case HandlerType.FUEL_CALL:
92
75
  return this.processTransaction(request)
93
76
  default:
@@ -1,15 +1,16 @@
1
- import { ListStateStorage } from '@sentio/runtime'
2
- import { Data_FuelCall, FuelCallFilter, FuelCallHandlerConfig, ProcessResult } from '@sentio/protos'
1
+ import { Data_FuelCall, FuelCallFilter } from '@sentio/protos'
3
2
  import { FuelCall, FuelContext } from './context.js'
4
3
  import { bn, Contract, Interface, InvocationCallResult, JsonAbi, Provider } from 'fuels'
5
4
  import { FuelNetwork, getRpcEndpoint } from './network.js'
6
- import { decodeFuelTransaction, DEFAULT_FUEL_FETCH_CONFIG, FuelFetchConfig, FuelTransaction } from './transaction.js'
7
-
8
- export class FuelProcessorState extends ListStateStorage<FuelProcessor> {
9
- static INSTANCE = new FuelProcessorState()
10
- }
11
-
12
- export class FuelProcessor {
5
+ import {
6
+ decodeFuelTransactionWithAbi,
7
+ DEFAULT_FUEL_FETCH_CONFIG,
8
+ FuelFetchConfig,
9
+ FuelTransaction
10
+ } from './transaction.js'
11
+ import { CallHandler, FuelBaseProcessor, FuelProcessorState } from './types.js'
12
+
13
+ export class FuelProcessor implements FuelBaseProcessor<FuelProcessorConfig> {
13
14
  callHandlers: CallHandler<Data_FuelCall>[] = []
14
15
 
15
16
  private provider: Provider
@@ -38,7 +39,7 @@ export class FuelProcessor {
38
39
  [this.config.address]: this.config.abi
39
40
  }
40
41
  : {}
41
- const tx = decodeFuelTransaction(call.transaction, abiMap, this.provider)
42
+ const tx = decodeFuelTransactionWithAbi(call.transaction, abiMap, this.provider)
42
43
 
43
44
  const ctx = new FuelContext(tx, this.config.chainId)
44
45
  await handler(tx, ctx)
@@ -84,7 +85,7 @@ export class FuelProcessor {
84
85
  handler: async (call: Data_FuelCall) => {
85
86
  const contract = new Contract(this.config.address, abi, this.provider)
86
87
  const gqlTransaction = call.transaction
87
- const tx = decodeFuelTransaction(gqlTransaction, { [this.config.address]: abi }, this.provider)
88
+ const tx = decodeFuelTransactionWithAbi(gqlTransaction, { [this.config.address]: abi }, this.provider)
88
89
 
89
90
  const ctx = new FuelContext(tx, this.config.chainId)
90
91
  for (const op of tx.operations) {
@@ -110,11 +111,6 @@ export class FuelProcessor {
110
111
  }
111
112
  }
112
113
 
113
- export type CallHandler<T> = {
114
- handler: (call: T) => Promise<ProcessResult>
115
- fetchConfig: Partial<FuelCallHandlerConfig>
116
- }
117
-
118
114
  export type FuelProcessorConfig = {
119
115
  address: string
120
116
  name?: string
package/src/fuel/index.ts CHANGED
@@ -3,4 +3,5 @@ export * from './context.js'
3
3
  export * from './fuel-processor.js'
4
4
  export * from './network.js'
5
5
  export * from './transaction.js'
6
- export * from './base-processor.js'
6
+ export * from './base-processor.js'
7
+ export * from './types.js'