@sentio/sdk 2.36.0-rc.1 → 2.36.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/fuel/asset-processor.d.ts +36 -0
- package/lib/fuel/asset-processor.d.ts.map +1 -0
- package/lib/fuel/asset-processor.js +85 -0
- package/lib/fuel/asset-processor.js.map +1 -0
- package/lib/fuel/base-processor.d.ts +1 -1
- package/lib/fuel/base-processor.d.ts.map +1 -1
- package/lib/fuel/base-processor.js +2 -1
- package/lib/fuel/base-processor.js.map +1 -1
- package/lib/fuel/context.js +2 -2
- package/lib/fuel/context.js.map +1 -1
- package/lib/fuel/fuel-plugin.d.ts.map +1 -1
- package/lib/fuel/fuel-plugin.js +17 -29
- package/lib/fuel/fuel-plugin.js.map +1 -1
- package/lib/fuel/fuel-processor.d.ts +3 -10
- package/lib/fuel/fuel-processor.d.ts.map +1 -1
- package/lib/fuel/fuel-processor.js +4 -7
- package/lib/fuel/fuel-processor.js.map +1 -1
- package/lib/fuel/index.d.ts +1 -0
- package/lib/fuel/index.d.ts.map +1 -1
- package/lib/fuel/index.js +1 -0
- package/lib/fuel/index.js.map +1 -1
- package/lib/fuel/transaction.d.ts +5 -2
- package/lib/fuel/transaction.d.ts.map +1 -1
- package/lib/fuel/transaction.js +37 -13
- package/lib/fuel/transaction.js.map +1 -1
- package/lib/fuel/types.d.ts +16 -0
- package/lib/fuel/types.d.ts.map +1 -0
- package/lib/fuel/types.js +5 -0
- package/lib/fuel/types.js.map +1 -0
- package/lib/testing/fuel-facet.d.ts.map +1 -1
- package/lib/testing/fuel-facet.js +13 -0
- package/lib/testing/fuel-facet.js.map +1 -1
- package/package.json +3 -3
- package/src/fuel/asset-processor.ts +119 -0
- package/src/fuel/base-processor.ts +16 -11
- package/src/fuel/context.ts +2 -2
- package/src/fuel/fuel-plugin.ts +15 -32
- package/src/fuel/fuel-processor.ts +12 -16
- package/src/fuel/index.ts +2 -1
- package/src/fuel/transaction.ts +42 -14
- package/src/fuel/types.ts +18 -0
- package/src/testing/fuel-facet.ts +14 -0
@@ -0,0 +1,36 @@
|
|
1
|
+
import { CallHandler, FuelBaseProcessor } from './types.js';
|
2
|
+
import { Data_FuelCall } from '@sentio/protos';
|
3
|
+
import { FuelNetwork } from './network.js';
|
4
|
+
import { FuelContext } from './context.js';
|
5
|
+
export declare class FuelAssetProcessor implements FuelBaseProcessor<FuelAssetProcessorConfig> {
|
6
|
+
readonly config: FuelAssetProcessorConfig;
|
7
|
+
callHandlers: CallHandler<Data_FuelCall>[];
|
8
|
+
private provider;
|
9
|
+
static bind(config: FuelAssetProcessorConfig): FuelAssetProcessor;
|
10
|
+
constructor(config: FuelAssetProcessorConfig);
|
11
|
+
configure(): Promise<void>;
|
12
|
+
onTransfer(filter: TransferFilter, handler: (transfers: FuelTransfer, ctx: FuelContext) => void | Promise<void>): this;
|
13
|
+
}
|
14
|
+
export type FuelAssetProcessorConfig = {
|
15
|
+
name?: string;
|
16
|
+
chainId: FuelNetwork;
|
17
|
+
startBlock?: bigint;
|
18
|
+
endBlock?: bigint;
|
19
|
+
};
|
20
|
+
export type TransferFilter = {
|
21
|
+
from?: string | string[];
|
22
|
+
to?: string | string[];
|
23
|
+
assetId?: string | string[];
|
24
|
+
};
|
25
|
+
export type FuelTransfer = {
|
26
|
+
from: {
|
27
|
+
assetId: string;
|
28
|
+
address: string;
|
29
|
+
}[];
|
30
|
+
to: {
|
31
|
+
address: string;
|
32
|
+
amount: bigint;
|
33
|
+
assetId: string;
|
34
|
+
}[];
|
35
|
+
};
|
36
|
+
//# sourceMappingURL=asset-processor.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"asset-processor.d.ts","sourceRoot":"","sources":["../../src/fuel/asset-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAsB,MAAM,YAAY,CAAA;AAC/E,OAAO,EAAE,aAAa,EAAsC,MAAM,gBAAgB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
@@ -0,0 +1,85 @@
|
|
1
|
+
import { FuelProcessorState } from './types.js';
|
2
|
+
import { getRpcEndpoint } from './network.js';
|
3
|
+
import { FuelContext } from './context.js';
|
4
|
+
import { decodeFuelTransaction } from './transaction.js';
|
5
|
+
import { InputType, OutputType, Provider } from 'fuels';
|
6
|
+
export class FuelAssetProcessor {
|
7
|
+
config;
|
8
|
+
callHandlers = [];
|
9
|
+
provider;
|
10
|
+
static bind(config) {
|
11
|
+
const processor = new FuelAssetProcessor(config);
|
12
|
+
FuelProcessorState.INSTANCE.addValue(processor);
|
13
|
+
return processor;
|
14
|
+
}
|
15
|
+
constructor(config) {
|
16
|
+
this.config = config;
|
17
|
+
}
|
18
|
+
async configure() {
|
19
|
+
const url = getRpcEndpoint(this.config.chainId);
|
20
|
+
this.provider = await Provider.create(url);
|
21
|
+
}
|
22
|
+
onTransfer(filter, handler) {
|
23
|
+
const filters = [];
|
24
|
+
const assetIds = arrayify(filter.assetId);
|
25
|
+
const froms = arrayify(filter.from);
|
26
|
+
const tos = arrayify(filter.to);
|
27
|
+
for (const assetId of assetIds) {
|
28
|
+
for (const from of froms) {
|
29
|
+
for (const to of tos) {
|
30
|
+
filters.push({
|
31
|
+
assetId: assetId,
|
32
|
+
fromAddress: from,
|
33
|
+
toAddress: to
|
34
|
+
});
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
38
|
+
const callHandler = {
|
39
|
+
handler: async (call) => {
|
40
|
+
const gqlTransaction = call.transaction;
|
41
|
+
const tx = decodeFuelTransaction(gqlTransaction, this.provider);
|
42
|
+
const ctx = new FuelContext(tx, this.config.chainId);
|
43
|
+
const transfer = {
|
44
|
+
from: [],
|
45
|
+
to: []
|
46
|
+
};
|
47
|
+
for (const input of tx.transaction.inputs || []) {
|
48
|
+
if (input.type == InputType.Coin) {
|
49
|
+
transfer.from.push({
|
50
|
+
address: input.owner,
|
51
|
+
assetId: input.assetId
|
52
|
+
});
|
53
|
+
}
|
54
|
+
}
|
55
|
+
for (const output of tx.transaction.outputs || []) {
|
56
|
+
if (output.type == OutputType.Coin) {
|
57
|
+
const value = output.amount.toString(10);
|
58
|
+
transfer.to.push({
|
59
|
+
address: output.to,
|
60
|
+
amount: BigInt(value),
|
61
|
+
assetId: output.assetId
|
62
|
+
});
|
63
|
+
}
|
64
|
+
}
|
65
|
+
await handler(transfer, ctx);
|
66
|
+
return ctx.stopAndGetResult();
|
67
|
+
},
|
68
|
+
assetConfig: {
|
69
|
+
filters
|
70
|
+
}
|
71
|
+
};
|
72
|
+
this.callHandlers.push(callHandler);
|
73
|
+
return this;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
function arrayify(value) {
|
77
|
+
if (value) {
|
78
|
+
if (Array.isArray(value)) {
|
79
|
+
return value.length > 0 ? value : [undefined];
|
80
|
+
}
|
81
|
+
return [value];
|
82
|
+
}
|
83
|
+
return [undefined];
|
84
|
+
}
|
85
|
+
//# sourceMappingURL=asset-processor.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"asset-processor.js","sourceRoot":"","sources":["../../src/fuel/asset-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAE/E,OAAO,EAAe,cAAc,EAAE,MAAM,cAAc,CAAA;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEvD,MAAM,OAAO,kBAAkB;IAUR;IATrB,YAAY,GAAiC,EAAE,CAAA;IACvC,QAAQ,CAAU;IAE1B,MAAM,CAAC,IAAI,CAAC,MAAgC;QAC1C,MAAM,SAAS,GAAG,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAA;QAChD,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;QAC/C,OAA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AAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;QAC/C,CAAC;QACD,OAAO,CAAC,KAAK,CAAC,CAAA;IAChB,CAAC;IACD,OAAO,CAAC,SAAS,CAAC,CAAA;AACpB,CAAC"}
|
@@ -4,7 +4,7 @@ import { FuelContext } from './context.js';
|
|
4
4
|
import { FuelFetchConfig } from './transaction.js';
|
5
5
|
export declare abstract class FuelAbstractProcessor extends FuelProcessor {
|
6
6
|
protected constructor(abi: JsonAbi, config?: FuelProcessorConfig);
|
7
|
-
protected onCallMethod<T extends Array<any>, R>(method: string, fn: (call: TypedCall<T, R>, ctx: FuelContext) =>
|
7
|
+
protected onCallMethod<T extends Array<any>, R>(method: string, fn: (call: TypedCall<T, R>, ctx: FuelContext) => void | Promise<void>, config: FuelFetchConfig): this;
|
8
8
|
}
|
9
9
|
export type TypedCall<T extends Array<any>, R> = {
|
10
10
|
args: T;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"base-processor.d.ts","sourceRoot":"","sources":["../../src/fuel/base-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,mBAAmB,
|
1
|
+
{"version":3,"file":"base-processor.d.ts","sourceRoot":"","sources":["../../src/fuel/base-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAY,WAAW,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAIlD,8BAAsB,qBAAsB,SAAQ,aAAa;IAC/D,SAAS,aAAa,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,mBAAmB;IAYhE,SAAS,CAAC,YAAY,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,EAC5C,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,WAAW,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EACrE,MAAM,EAAE,eAAe,GACtB,IAAI;CAaR;AAED,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI;IAC/C,IAAI,EAAE,CAAC,CAAA;IACP,WAAW,EAAE,CAAC,CAAA;CACf,CAAA"}
|
@@ -1,5 +1,6 @@
|
|
1
|
-
import { FuelProcessor
|
1
|
+
import { FuelProcessor } from './fuel-processor.js';
|
2
2
|
import { FuelChainId } from '@sentio/chain';
|
3
|
+
import { FuelProcessorState } from './types.js';
|
3
4
|
export class FuelAbstractProcessor extends FuelProcessor {
|
4
5
|
constructor(abi, config) {
|
5
6
|
if (!config) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"base-processor.js","sourceRoot":"","sources":["../../src/fuel/base-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAuB,
|
1
|
+
{"version":3,"file":"base-processor.js","sourceRoot":"","sources":["../../src/fuel/base-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAuB,MAAM,qBAAqB,CAAA;AAIxE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAE/C,MAAM,OAAgB,qBAAsB,SAAQ,aAAa;IAC/D,YAAsB,GAAY,EAAE,MAA4B;QAC9D,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,GAAG;gBACP,OAAO,EAAE,WAAW,CAAC,YAAY;gBACjC,OAAO,EAAE,EAAE;aACZ,CAAA;QACH,CAAC;QACD,MAAM,CAAC,GAAG,GAAG,GAAG,CAAA;QAChB,KAAK,CAAC,MAAM,CAAC,CAAA;QACb,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IAC5C,CAAC;IAES,YAAY,CACpB,MAAc,EACd,EAAqE,EACrE,MAAuB;QAEvB,MAAM,UAAU,GAAG,MAAM,CAAA;QACzB,MAAM,OAAO,GAAG,KAAK,EAAE,IAAc,EAAE,GAAgB,EAAE,EAAE;YACzD,MAAM,EAAE,CACN;gBACE,IAAI,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,IAAS;gBACtD,WAAW,EAAE,IAAI,CAAC,KAAU;aAC7B,EACD,GAAG,CACJ,CAAA;QACH,CAAC,CAAA;QACD,OAAO,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;IAClD,CAAC;CACF"}
|
package/lib/fuel/context.js
CHANGED
@@ -14,12 +14,12 @@ export class FuelContext extends BaseContext {
|
|
14
14
|
return {
|
15
15
|
address: this.transaction?.id || '',
|
16
16
|
contractName: this.transaction?.id || '', // TODO
|
17
|
-
blockNumber:
|
17
|
+
blockNumber: BigInt(this.transaction?.blockNumber || 0),
|
18
18
|
transactionIndex: 0,
|
19
19
|
transactionHash: this.transaction?.id || '', // TODO
|
20
20
|
chainId: this.getChainId(),
|
21
21
|
name: name,
|
22
|
-
logIndex:
|
22
|
+
logIndex: -1,
|
23
23
|
labels: normalizeLabels(labels)
|
24
24
|
};
|
25
25
|
}
|
package/lib/fuel/context.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/fuel/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAU,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAQvE,MAAM,OAAO,WAAY,SAAQ,WAAW;IAE/B;IACA;IAFX,YACW,WAAmC,EACnC,OAAgB;QAEzB,KAAK,CAAC,EAAE,CAAC,CAAA;QAHA,gBAAW,GAAX,WAAW,CAAwB;QACnC,YAAO,GAAP,OAAO,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,"file":"fuel-plugin.d.ts","sourceRoot":"","sources":["../../src/fuel/fuel-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmD,MAAM,EAAiC,MAAM,iBAAiB,CAAA;AACxH,OAAO,EAEL,aAAa,EACb,WAAW,EACX,WAAW,EACX,qBAAqB,EACrB,aAAa,EACb,YAAY,EACb,MAAM,gBAAgB,CAAA;
|
1
|
+
{"version":3,"file":"fuel-plugin.d.ts","sourceRoot":"","sources":["../../src/fuel/fuel-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmD,MAAM,EAAiC,MAAM,iBAAiB,CAAA;AACxH,OAAO,EAEL,aAAa,EACb,WAAW,EACX,WAAW,EACX,qBAAqB,EACrB,aAAa,EACb,YAAY,EACb,MAAM,gBAAgB,CAAA;AAQvB,UAAU,QAAQ;IAChB,YAAY,EAAE,CAAC,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC,EAAE,CAAA;CACnE;AAED,qBAAa,UAAW,SAAQ,MAAM;IACpC,IAAI,EAAE,MAAM,CAAe;IAC3B,QAAQ,EAAE,QAAQ,CAEjB;IAEK,SAAS,CAAC,MAAM,EAAE,qBAAqB;IA0C7C,iBAAiB,gBAA0B;IAE3C,cAAc,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;IAStD,KAAK,CAAC,OAAO,EAAE,YAAY;IAEjC,SAAS,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO;IAI3C,kBAAkB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;CAsBvE"}
|
package/lib/fuel/fuel-plugin.js
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
import { errorString, GLOBAL_CONFIG, mergeProcessResults, Plugin, PluginManager, USER_PROCESSOR } from '@sentio/runtime';
|
2
2
|
import { ContractConfig, HandlerType } from '@sentio/protos';
|
3
3
|
import { ServerError, Status } from 'nice-grpc';
|
4
|
-
import { GlobalProcessorState } from '../eth/base-processor.js';
|
5
4
|
import { TemplateInstanceState } from '../core/template.js';
|
6
|
-
import {
|
5
|
+
import { FuelAssetProcessor } from './asset-processor.js';
|
6
|
+
import { FuelProcessorState } from './types.js';
|
7
|
+
import { FuelProcessor } from './fuel-processor.js';
|
7
8
|
export class FuelPlugin extends Plugin {
|
8
9
|
name = 'FuelPlugin';
|
9
10
|
handlers = {
|
@@ -28,42 +29,29 @@ export class FuelPlugin extends Plugin {
|
|
28
29
|
});
|
29
30
|
for (const callHandler of processor.callHandlers) {
|
30
31
|
const handlerId = handlers.callHandlers.push(callHandler.handler) - 1;
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
if (processor instanceof FuelProcessor) {
|
33
|
+
const fetchConfig = {
|
34
|
+
handlerId,
|
35
|
+
filters: callHandler.fetchConfig?.filters || []
|
36
|
+
};
|
37
|
+
contractConfig.fuelCallConfigs.push(fetchConfig);
|
38
|
+
}
|
39
|
+
else if (processor instanceof FuelAssetProcessor) {
|
40
|
+
const assetConfig = callHandler.assetConfig;
|
41
|
+
contractConfig.assetConfigs.push({
|
42
|
+
filters: assetConfig?.filters || [],
|
43
|
+
handlerId
|
44
|
+
});
|
45
|
+
}
|
36
46
|
}
|
37
47
|
// Finish up a contract
|
38
48
|
config.contractConfigs.push(contractConfig);
|
39
49
|
}
|
40
|
-
for (const processor of GlobalProcessorState.INSTANCE.getValues()) {
|
41
|
-
const chainId = processor.getChainId();
|
42
|
-
const contractConfig = ContractConfig.fromPartial({
|
43
|
-
processorType: USER_PROCESSOR,
|
44
|
-
contract: {
|
45
|
-
name: processor.config.name,
|
46
|
-
chainId: chainId.toString(),
|
47
|
-
address: processor.config.address, // can only be *
|
48
|
-
abi: ''
|
49
|
-
},
|
50
|
-
startBlock: processor.config.startBlock,
|
51
|
-
endBlock: processor.config.endBlock
|
52
|
-
});
|
53
|
-
config.contractConfigs.push(contractConfig);
|
54
|
-
}
|
55
50
|
this.handlers = handlers;
|
56
51
|
}
|
57
52
|
supportedHandlers = [HandlerType.FUEL_CALL];
|
58
53
|
processBinding(request) {
|
59
|
-
// return Promise.resolve(undefined);
|
60
54
|
switch (request.handlerType) {
|
61
|
-
// case HandlerType.FUEL_LOG:
|
62
|
-
// return this.processLog(request)
|
63
|
-
// case HandlerType.FUEL_TRACE:
|
64
|
-
// return this.processTrace(request)
|
65
|
-
// case HandlerType.FUEL_BLOCK:
|
66
|
-
// return this.processBlock(request)
|
67
55
|
case HandlerType.FUEL_CALL:
|
68
56
|
return this.processTransaction(request);
|
69
57
|
default:
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fuel-plugin.js","sourceRoot":"","sources":["../../src/fuel/fuel-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACxH,OAAO,EACL,cAAc,EAGd,WAAW,EAIZ,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"fuel-plugin.js","sourceRoot":"","sources":["../../src/fuel/fuel-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACxH,OAAO,EACL,cAAc,EAGd,WAAW,EAIZ,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAE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U,EAAE,CAAC;YAC3C,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;gBACjF,MAAM,IAAI,WAAW,CACnB,MAAM,CAAC,QAAQ,EACf,gCAAgC,GAAG,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,WAAW,CAAC,GAAG,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,CACvG,CAAA;YACH,CAAC,CAAC,CAAA;YACF,IAAI,aAAa,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;gBACvC,MAAM,OAAO,CAAA;YACf,CAAC;YACD,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACxB,CAAC;QACD,OAAO,mBAAmB,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;IACzD,CAAC;CACF;AAED,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,UAAU,EAAE,CAAC,CAAA"}
|
@@ -1,13 +1,10 @@
|
|
1
|
-
import {
|
2
|
-
import { Data_FuelCall, FuelCallHandlerConfig, ProcessResult } from '@sentio/protos';
|
1
|
+
import { Data_FuelCall } from '@sentio/protos';
|
3
2
|
import { FuelCall, FuelContext } from './context.js';
|
4
3
|
import { JsonAbi } from 'fuels';
|
5
4
|
import { FuelNetwork } from './network.js';
|
6
5
|
import { FuelFetchConfig, FuelTransaction } from './transaction.js';
|
7
|
-
|
8
|
-
|
9
|
-
}
|
10
|
-
export declare class FuelProcessor {
|
6
|
+
import { CallHandler, FuelBaseProcessor } from './types.js';
|
7
|
+
export declare class FuelProcessor implements FuelBaseProcessor<FuelProcessorConfig> {
|
11
8
|
readonly config: FuelProcessorConfig;
|
12
9
|
callHandlers: CallHandler<Data_FuelCall>[];
|
13
10
|
private provider;
|
@@ -17,10 +14,6 @@ export declare class FuelProcessor {
|
|
17
14
|
onTransaction(handler: (transaction: FuelTransaction, ctx: FuelContext) => void | Promise<void>, config?: FuelFetchConfig): this;
|
18
15
|
onCall(nameFilter: string | string[], handler: (call: FuelCall, ctx: FuelContext) => void | Promise<void>, config?: FuelFetchConfig): this;
|
19
16
|
}
|
20
|
-
export type CallHandler<T> = {
|
21
|
-
handler: (call: T) => Promise<ProcessResult>;
|
22
|
-
fetchConfig: Partial<FuelCallHandlerConfig>;
|
23
|
-
};
|
24
17
|
export type FuelProcessorConfig = {
|
25
18
|
address: string;
|
26
19
|
name?: string;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fuel-processor.d.ts","sourceRoot":"","sources":["../../src/fuel/fuel-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"fuel-processor.d.ts","sourceRoot":"","sources":["../../src/fuel/fuel-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAkB,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EAAiD,OAAO,EAAY,MAAM,OAAO,CAAA;AACxF,OAAO,EAAE,WAAW,EAAkB,MAAM,cAAc,CAAA;AAC1D,OAAO,EAGL,eAAe,EACf,eAAe,EAChB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAsB,MAAM,YAAY,CAAA;AAE/E,qBAAa,aAAc,YAAW,iBAAiB,CAAC,mBAAmB,CAAC;IAW9D,QAAQ,CAAC,MAAM,EAAE,mBAAmB;IAVhD,YAAY,EAAE,WAAW,CAAC,aAAa,CAAC,EAAE,CAAK;IAE/C,OAAO,CAAC,QAAQ,CAAU;IAE1B,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,mBAAmB,GAAG,aAAa;gBAMlC,MAAM,EAAE,mBAAmB;IAE1C,SAAS;IAKR,aAAa,CAClB,OAAO,EAAE,CAAC,WAAW,EAAE,eAAe,EAAE,GAAG,EAAE,WAAW,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EACjF,MAAM,GAAE,eAA2C;IAwB9C,MAAM,CACX,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,EAC7B,OAAO,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,WAAW,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EACnE,MAAM,GAAE,eAA2C;CAoDtD;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,WAAW,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,OAAO,CAAA;CACd,CAAA"}
|
@@ -1,11 +1,8 @@
|
|
1
|
-
import { ListStateStorage } from '@sentio/runtime';
|
2
1
|
import { FuelContext } from './context.js';
|
3
2
|
import { bn, Contract, Interface, InvocationCallResult, Provider } from 'fuels';
|
4
3
|
import { getRpcEndpoint } from './network.js';
|
5
|
-
import {
|
6
|
-
|
7
|
-
static INSTANCE = new FuelProcessorState();
|
8
|
-
}
|
4
|
+
import { decodeFuelTransactionWithAbi, DEFAULT_FUEL_FETCH_CONFIG } from './transaction.js';
|
5
|
+
import { FuelProcessorState } from './types.js';
|
9
6
|
export class FuelProcessor {
|
10
7
|
config;
|
11
8
|
callHandlers = [];
|
@@ -30,7 +27,7 @@ export class FuelProcessor {
|
|
30
27
|
[this.config.address]: this.config.abi
|
31
28
|
}
|
32
29
|
: {};
|
33
|
-
const tx =
|
30
|
+
const tx = decodeFuelTransactionWithAbi(call.transaction, abiMap, this.provider);
|
34
31
|
const ctx = new FuelContext(tx, this.config.chainId);
|
35
32
|
await handler(tx, ctx);
|
36
33
|
return ctx.stopAndGetResult();
|
@@ -68,7 +65,7 @@ export class FuelProcessor {
|
|
68
65
|
handler: async (call) => {
|
69
66
|
const contract = new Contract(this.config.address, abi, this.provider);
|
70
67
|
const gqlTransaction = call.transaction;
|
71
|
-
const tx =
|
68
|
+
const tx = decodeFuelTransactionWithAbi(gqlTransaction, { [this.config.address]: abi }, this.provider);
|
72
69
|
const ctx = new FuelContext(tx, this.config.chainId);
|
73
70
|
for (const op of tx.operations) {
|
74
71
|
for (const call of op.calls || []) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fuel-processor.js","sourceRoot":"","sources":["../../src/fuel/fuel-processor.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"fuel-processor.js","sourceRoot":"","sources":["../../src/fuel/fuel-processor.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,WAAW,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,oBAAoB,EAAW,QAAQ,EAAE,MAAM,OAAO,CAAA;AACxF,OAAO,EAAe,cAAc,EAAE,MAAM,cAAc,CAAA;AAC1D,OAAO,EACL,4BAA4B,EAC5B,yBAAyB,EAG1B,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAkC,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAE/E,MAAM,OAAO,aAAa;IAWH;IAVrB,YAAY,GAAiC,EAAE,CAAA;IAEvC,QAAQ,CAAU;IAE1B,MAAM,CAAC,IAAI,CAAC,MAA2B;QACrC,MAAM,SAAS,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAA;QAC3C,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;QAC/C,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,YAAqB,MAA2B;QAA3B,WAAM,GAAN,MAAM,CAAqB;IAAG,CAAC;IAEpD,KAAK,CAAC,SAAS;QACb,MAAM,GAAG,GAAG,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QAC/C,IAAI,CAAC,Q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AAK,IAAI,EAAE,EAAE,CAAC;wBAClC,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;4BACjC,MAAM,EAAE,GAAG,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;4BAChD,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAA;4BACxD,MAAM,KAAK,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,CAAA;4BACzB,MAAM,gBAAgB,GAAG,MAAM,oBAAoB,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,EAAE,KAAK,CAAC,CAAA;4BAC3E,MAAM,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAA;wBACtC,CAAC;oBACH,CAAC;gBACH,CAAC;gBAED,OAAO,GAAG,CAAC,gBAAgB,EAAE,CAAA;YAC/B,CAAC;YACD,WAAW,EAAE;gBACX,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;aAChC;SACF,CAAA;QACD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QACnC,OAAO,IAAI,CAAA;IACb,CAAC;CACF"}
|
package/lib/fuel/index.d.ts
CHANGED
package/lib/fuel/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fuel/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,cAAc,cAAc,CAAA;AAC5B,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fuel/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,cAAc,cAAc,CAAA;AAC5B,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,YAAY,CAAA"}
|
package/lib/fuel/index.js
CHANGED
package/lib/fuel/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fuel/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,cAAc,cAAc,CAAA;AAC5B,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA"}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fuel/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,cAAc,cAAc,CAAA;AAC5B,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,YAAY,CAAA"}
|
@@ -3,6 +3,9 @@ export type FuelFetchConfig = {
|
|
3
3
|
includeFailed?: boolean;
|
4
4
|
};
|
5
5
|
export declare const DEFAULT_FUEL_FETCH_CONFIG: FuelFetchConfig;
|
6
|
-
export type FuelTransaction = TransactionSummary
|
7
|
-
|
6
|
+
export type FuelTransaction = TransactionSummary & {
|
7
|
+
blockNumber?: string;
|
8
|
+
};
|
9
|
+
export declare function decodeFuelTransaction(gqlTransaction: any, provider: Provider): FuelTransaction;
|
10
|
+
export declare function decodeFuelTransactionWithAbi(gqlTransaction: any, abiMap: AbiMap, provider: Provider): FuelTransaction;
|
8
11
|
//# sourceMappingURL=transaction.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/fuel/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EAKN,QAAQ,EAER,kBAAkB,EACnB,MAAM,OAAO,CAAA;AAEd,MAAM,MAAM,eAAe,GAAG;IAC5B,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB,CAAA;AAED,eAAO,MAAM,yBAAyB,EAAE,eAEvC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,kBAAkB,CAAA;
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/fuel/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EAKN,QAAQ,EAER,kBAAkB,EACnB,MAAM,OAAO,CAAA;AAEd,MAAM,MAAM,eAAe,GAAG;IAC5B,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB,CAAA;AAED,eAAO,MAAM,yBAAyB,EAAE,eAEvC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,kBAAkB,GAAG;IACjD,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,wBAAgB,qBAAqB,CAAC,cAAc,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,GAAG,eAAe,CAoB9F;AAED,wBAAgB,4BAA4B,CAAC,cAAc,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,eAAe,CAyBrH"}
|
package/lib/fuel/transaction.js
CHANGED
@@ -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,
|
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?.height;
|
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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
30
|
+
const blockNumber = gqlTransaction.status?.block?.header?.height;
|
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;
|
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;AAMD,MAAM,UAAU,qBAAqB,CAAC,cAAmB,EAAE,QAAkB;IAC3E,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;IACzE,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;IAChE,OAAO;QACL,GAAG,0BAA0B,CAAC;YAC5B,EAAE,EAAE,cAAc,CAAC,EAAE;YACrB,QAAQ,EAAE,EAAE;YACZ,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,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 @@
|
|
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;
|
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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,CAAC;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.36.0-rc.
|
3
|
+
"version": "2.36.0-rc.3",
|
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.36.0-rc.
|
81
|
-
"@sentio/runtime": "^2.36.0-rc.
|
80
|
+
"@sentio/protos": "2.36.0-rc.3",
|
81
|
+
"@sentio/runtime": "^2.36.0-rc.3"
|
82
82
|
},
|
83
83
|
"peerDependencies": {
|
84
84
|
"tsup": "npm:@sentio/tsup@^6.7.2"
|
@@ -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
|
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>(
|
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
|
-
|
27
|
-
|
28
|
-
|
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
|
+
}
|
package/src/fuel/context.ts
CHANGED
@@ -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:
|
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:
|
30
|
+
logIndex: -1,
|
31
31
|
labels: normalizeLabels(labels)
|
32
32
|
}
|
33
33
|
}
|
package/src/fuel/fuel-plugin.ts
CHANGED
@@ -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 {
|
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
|
-
|
49
|
-
|
50
|
-
|
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 {
|
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 {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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 =
|
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 =
|
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
package/src/fuel/transaction.ts
CHANGED
@@ -17,9 +17,33 @@ export const DEFAULT_FUEL_FETCH_CONFIG: FuelFetchConfig = {
|
|
17
17
|
includeFailed: false
|
18
18
|
}
|
19
19
|
|
20
|
-
export type FuelTransaction = TransactionSummary
|
20
|
+
export type FuelTransaction = TransactionSummary & {
|
21
|
+
blockNumber?: string
|
22
|
+
}
|
23
|
+
|
24
|
+
export function decodeFuelTransaction(gqlTransaction: any, provider: Provider): FuelTransaction {
|
25
|
+
const rawPayload = arrayify(gqlTransaction.rawPayload)
|
26
|
+
|
27
|
+
const [decodedTransaction] = new TransactionCoder().decode(rawPayload, 0)
|
28
|
+
const { gasPerByte, gasPriceFactor, maxInputs, gasCosts } = provider.getChain().consensusParameters
|
29
|
+
const blockNumber = gqlTransaction.status?.block?.header?.height
|
30
|
+
return {
|
31
|
+
...assembleTransactionSummary({
|
32
|
+
id: gqlTransaction.id,
|
33
|
+
receipts: [],
|
34
|
+
transaction: decodedTransaction,
|
35
|
+
transactionBytes: rawPayload,
|
36
|
+
gqlTransactionStatus: gqlTransaction.status,
|
37
|
+
gasPerByte: bn(gasPerByte),
|
38
|
+
gasPriceFactor: bn(gasPriceFactor),
|
39
|
+
maxInputs,
|
40
|
+
gasCosts
|
41
|
+
}),
|
42
|
+
blockNumber
|
43
|
+
}
|
44
|
+
}
|
21
45
|
|
22
|
-
export function
|
46
|
+
export function decodeFuelTransactionWithAbi(gqlTransaction: any, abiMap: AbiMap, provider: Provider): FuelTransaction {
|
23
47
|
const rawPayload = arrayify(gqlTransaction.rawPayload)
|
24
48
|
|
25
49
|
const [decodedTransaction] = new TransactionCoder().decode(rawPayload, 0)
|
@@ -27,17 +51,21 @@ export function decodeFuelTransaction(gqlTransaction: any, abiMap: AbiMap, provi
|
|
27
51
|
const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || []
|
28
52
|
|
29
53
|
const { gasPerByte, gasPriceFactor, maxInputs, gasCosts } = provider.getChain().consensusParameters
|
54
|
+
const blockNumber = gqlTransaction.status?.block?.header?.height
|
30
55
|
|
31
|
-
return
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
56
|
+
return {
|
57
|
+
...assembleTransactionSummary({
|
58
|
+
id: gqlTransaction.id,
|
59
|
+
receipts,
|
60
|
+
transaction: decodedTransaction,
|
61
|
+
transactionBytes: rawPayload,
|
62
|
+
gqlTransactionStatus: gqlTransaction.status,
|
63
|
+
gasPerByte: bn(gasPerByte),
|
64
|
+
gasPriceFactor: bn(gasPriceFactor),
|
65
|
+
abiMap,
|
66
|
+
maxInputs,
|
67
|
+
gasCosts
|
68
|
+
}),
|
69
|
+
blockNumber
|
70
|
+
}
|
43
71
|
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import { ListStateStorage } from '@sentio/runtime'
|
2
|
+
import { Data_FuelCall, FuelAssetHandlerConfig, FuelCallHandlerConfig, ProcessResult } from '@sentio/protos'
|
3
|
+
|
4
|
+
export interface FuelBaseProcessor<T> {
|
5
|
+
configure(): Promise<void>
|
6
|
+
config: T
|
7
|
+
callHandlers: CallHandler<Data_FuelCall>[]
|
8
|
+
}
|
9
|
+
|
10
|
+
export class FuelProcessorState extends ListStateStorage<FuelBaseProcessor<any>> {
|
11
|
+
static INSTANCE = new FuelProcessorState()
|
12
|
+
}
|
13
|
+
|
14
|
+
export type CallHandler<T> = {
|
15
|
+
handler: (call: T) => Promise<ProcessResult>
|
16
|
+
fetchConfig?: Partial<FuelCallHandlerConfig>
|
17
|
+
assetConfig?: Partial<FuelAssetHandlerConfig>
|
18
|
+
}
|
@@ -51,6 +51,20 @@ export class FuelFacet {
|
|
51
51
|
res.push(binding)
|
52
52
|
}
|
53
53
|
}
|
54
|
+
for (const assetConfig of config.assetConfigs) {
|
55
|
+
const binding = {
|
56
|
+
data: {
|
57
|
+
fuelCall: {
|
58
|
+
transaction,
|
59
|
+
timestamp: new Date()
|
60
|
+
}
|
61
|
+
},
|
62
|
+
handlerIds: [assetConfig.handlerId],
|
63
|
+
handlerType: HandlerType.FUEL_CALL
|
64
|
+
}
|
65
|
+
|
66
|
+
res.push(binding)
|
67
|
+
}
|
54
68
|
}
|
55
69
|
|
56
70
|
return res
|