@seljs/runtime 1.3.0-beta.1 → 1.3.0-beta.11
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/dist/analysis/call-collector.cjs +19 -0
- package/dist/analysis/call-collector.mjs +19 -0
- package/dist/analysis/dependency-analyzer.cjs +1 -2
- package/dist/analysis/dependency-analyzer.mjs +1 -1
- package/dist/analysis/round-planner.cjs +1 -2
- package/dist/analysis/round-planner.mjs +1 -1
- package/dist/environment/builtin-contracts.cjs +22 -0
- package/dist/environment/builtin-contracts.mjs +22 -0
- package/dist/environment/client.cjs +16 -0
- package/dist/environment/client.d.cts +33 -0
- package/dist/environment/client.d.mts +33 -0
- package/dist/environment/client.mjs +16 -0
- package/dist/environment/contract-caller.cjs +13 -12
- package/dist/environment/contract-caller.mjs +13 -12
- package/dist/environment/environment.cjs +35 -10
- package/dist/environment/environment.d.cts +5 -0
- package/dist/environment/environment.d.mts +5 -0
- package/dist/environment/environment.mjs +35 -10
- package/dist/environment/index.cjs +1 -0
- package/dist/environment/index.d.mts +1 -0
- package/dist/environment/index.mjs +1 -0
- package/dist/environment/types.d.cts +4 -4
- package/dist/environment/types.d.mts +4 -4
- package/dist/errors/errors.cjs +7 -0
- package/dist/errors/errors.d.cts +7 -1
- package/dist/errors/errors.d.mts +7 -1
- package/dist/errors/errors.mjs +7 -1
- package/dist/errors/index.d.mts +1 -1
- package/dist/execution/multi-round-executor.cjs +1 -4
- package/dist/execution/multi-round-executor.mjs +1 -3
- package/dist/execution/multicall-batcher.cjs +11 -9
- package/dist/execution/multicall-batcher.mjs +11 -9
- package/dist/execution/multicall.cjs +28 -4
- package/dist/execution/multicall.mjs +26 -4
- package/dist/execution/round-executor.cjs +4 -12
- package/dist/execution/round-executor.mjs +4 -12
- package/dist/execution/types.d.cts +40 -16
- package/dist/execution/types.d.mts +40 -16
- package/dist/index.cjs +3 -0
- package/dist/index.d.cts +3 -2
- package/dist/index.d.mts +3 -2
- package/dist/index.mjs +3 -2
- package/package.json +7 -7
package/dist/errors/errors.d.mts
CHANGED
|
@@ -61,6 +61,12 @@ declare class MulticallBatchError extends SELError {
|
|
|
61
61
|
methodName?: string;
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Thrown when the provided client fails validation or is misconfigured.
|
|
66
|
+
*/
|
|
67
|
+
declare class SELClientError extends SELError {
|
|
68
|
+
readonly name = "SELClientError";
|
|
69
|
+
}
|
|
64
70
|
/**
|
|
65
71
|
* Thrown when lint rules with error severity detect violations.
|
|
66
72
|
* Contains the diagnostics that caused the failure.
|
|
@@ -72,4 +78,4 @@ declare class SELLintError extends SELError {
|
|
|
72
78
|
});
|
|
73
79
|
}
|
|
74
80
|
//#endregion
|
|
75
|
-
export { CircularDependencyError, ExecutionLimitError, MulticallBatchError, SELContractError, SELError, SELEvaluationError, SELLintError, SELParseError, SELTypeError };
|
|
81
|
+
export { CircularDependencyError, ExecutionLimitError, MulticallBatchError, SELClientError, SELContractError, SELError, SELEvaluationError, SELLintError, SELParseError, SELTypeError };
|
package/dist/errors/errors.mjs
CHANGED
|
@@ -60,6 +60,12 @@ var MulticallBatchError = class extends SELError {
|
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
62
|
/**
|
|
63
|
+
* Thrown when the provided client fails validation or is misconfigured.
|
|
64
|
+
*/
|
|
65
|
+
var SELClientError = class extends SELError {
|
|
66
|
+
name = "SELClientError";
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
63
69
|
* Thrown when lint rules with error severity detect violations.
|
|
64
70
|
* Contains the diagnostics that caused the failure.
|
|
65
71
|
*/
|
|
@@ -72,4 +78,4 @@ var SELLintError = class extends SELError {
|
|
|
72
78
|
}
|
|
73
79
|
};
|
|
74
80
|
//#endregion
|
|
75
|
-
export { CircularDependencyError, ExecutionLimitError, MulticallBatchError, SELContractError, SELError, SELEvaluationError, SELLintError, SELParseError, SELTypeError };
|
|
81
|
+
export { CircularDependencyError, ExecutionLimitError, MulticallBatchError, SELClientError, SELContractError, SELError, SELEvaluationError, SELLintError, SELParseError, SELTypeError };
|
package/dist/errors/index.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import { CircularDependencyError, ExecutionLimitError, MulticallBatchError, SELContractError, SELError, SELEvaluationError, SELLintError, SELParseError, SELTypeError } from "./errors.mjs";
|
|
1
|
+
import { CircularDependencyError, ExecutionLimitError, MulticallBatchError, SELClientError, SELContractError, SELError, SELEvaluationError, SELLintError, SELParseError, SELTypeError } from "./errors.mjs";
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
1
|
const require_debug = require("../debug.cjs");
|
|
3
2
|
const require_multicall_batcher = require("./multicall-batcher.cjs");
|
|
4
3
|
const require_result_cache = require("./result-cache.cjs");
|
|
5
4
|
const require_round_executor = require("./round-executor.cjs");
|
|
6
|
-
let viem_actions = require("viem/actions");
|
|
7
5
|
//#region src/execution/multi-round-executor.ts
|
|
8
6
|
const debug = require_debug.createLogger("execute");
|
|
9
7
|
var MultiRoundExecutor = class {
|
|
@@ -14,13 +12,12 @@ var MultiRoundExecutor = class {
|
|
|
14
12
|
this.contracts = contracts;
|
|
15
13
|
}
|
|
16
14
|
async execute(plan, variables = {}, blockNumber) {
|
|
17
|
-
const lockedBlockNumber = blockNumber ?? await
|
|
15
|
+
const lockedBlockNumber = blockNumber ?? await this.client.getBlockNumber();
|
|
18
16
|
debug("start: %d rounds, %d calls, block=%s", plan.rounds.length, plan.totalCalls, String(lockedBlockNumber));
|
|
19
17
|
const cache = new require_result_cache.ResultCache();
|
|
20
18
|
const batcher = new require_multicall_batcher.MulticallBatcher(this.client, this.multicallOptions);
|
|
21
19
|
const executor = new require_round_executor.RoundExecutor(this.contracts, cache, batcher);
|
|
22
20
|
const context = {
|
|
23
|
-
client: this.client,
|
|
24
21
|
blockNumber: lockedBlockNumber,
|
|
25
22
|
variables
|
|
26
23
|
};
|
|
@@ -2,7 +2,6 @@ import { createLogger } from "../debug.mjs";
|
|
|
2
2
|
import { MulticallBatcher } from "./multicall-batcher.mjs";
|
|
3
3
|
import { ResultCache } from "./result-cache.mjs";
|
|
4
4
|
import { RoundExecutor } from "./round-executor.mjs";
|
|
5
|
-
import { getBlockNumber } from "viem/actions";
|
|
6
5
|
//#region src/execution/multi-round-executor.ts
|
|
7
6
|
const debug = createLogger("execute");
|
|
8
7
|
var MultiRoundExecutor = class {
|
|
@@ -13,13 +12,12 @@ var MultiRoundExecutor = class {
|
|
|
13
12
|
this.contracts = contracts;
|
|
14
13
|
}
|
|
15
14
|
async execute(plan, variables = {}, blockNumber) {
|
|
16
|
-
const lockedBlockNumber = blockNumber ?? await
|
|
15
|
+
const lockedBlockNumber = blockNumber ?? await this.client.getBlockNumber();
|
|
17
16
|
debug("start: %d rounds, %d calls, block=%s", plan.rounds.length, plan.totalCalls, String(lockedBlockNumber));
|
|
18
17
|
const cache = new ResultCache();
|
|
19
18
|
const batcher = new MulticallBatcher(this.client, this.multicallOptions);
|
|
20
19
|
const executor = new RoundExecutor(this.contracts, cache, batcher);
|
|
21
20
|
const context = {
|
|
22
|
-
client: this.client,
|
|
23
21
|
blockNumber: lockedBlockNumber,
|
|
24
22
|
variables
|
|
25
23
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
-
const
|
|
2
|
+
const require_multicall = require("./multicall.cjs");
|
|
3
3
|
const require_errors = require("../errors/errors.cjs");
|
|
4
4
|
require("../errors/index.cjs");
|
|
5
|
-
const
|
|
6
|
-
let
|
|
5
|
+
const require_debug = require("../debug.cjs");
|
|
6
|
+
let ox = require("ox");
|
|
7
7
|
//#region src/execution/multicall-batcher.ts
|
|
8
8
|
const debug = require_debug.createLogger("execute:multicall");
|
|
9
9
|
var MulticallBatcher = class {
|
|
@@ -32,17 +32,19 @@ var MulticallBatcher = class {
|
|
|
32
32
|
}
|
|
33
33
|
async executeChunk(calls, blockNumber) {
|
|
34
34
|
try {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
args: [calls],
|
|
35
|
+
const data = ox.AbiFunction.encodeData(require_multicall.multicall3Function, [calls]);
|
|
36
|
+
const response = await this.client.call({
|
|
37
|
+
to: this.address,
|
|
38
|
+
data,
|
|
40
39
|
blockNumber
|
|
41
|
-
})
|
|
40
|
+
});
|
|
41
|
+
if (!response.data) throw new require_errors.MulticallBatchError("Multicall3 aggregate3 returned no data");
|
|
42
|
+
return ox.AbiFunction.decodeResult(require_multicall.multicall3Function, response.data).map((r) => ({
|
|
42
43
|
success: r.success,
|
|
43
44
|
returnData: r.returnData
|
|
44
45
|
}));
|
|
45
46
|
} catch (error) {
|
|
47
|
+
if (error instanceof require_errors.MulticallBatchError) throw error;
|
|
46
48
|
throw new require_errors.MulticallBatchError("Multicall3 aggregate3 call failed", { cause: error });
|
|
47
49
|
}
|
|
48
50
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { multicall3Function } from "./multicall.mjs";
|
|
2
2
|
import { MulticallBatchError } from "../errors/errors.mjs";
|
|
3
3
|
import "../errors/index.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { createLogger } from "../debug.mjs";
|
|
5
|
+
import { AbiFunction } from "ox";
|
|
6
6
|
//#region src/execution/multicall-batcher.ts
|
|
7
7
|
const debug = createLogger("execute:multicall");
|
|
8
8
|
var MulticallBatcher = class {
|
|
@@ -31,17 +31,19 @@ var MulticallBatcher = class {
|
|
|
31
31
|
}
|
|
32
32
|
async executeChunk(calls, blockNumber) {
|
|
33
33
|
try {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
args: [calls],
|
|
34
|
+
const data = AbiFunction.encodeData(multicall3Function, [calls]);
|
|
35
|
+
const response = await this.client.call({
|
|
36
|
+
to: this.address,
|
|
37
|
+
data,
|
|
39
38
|
blockNumber
|
|
40
|
-
})
|
|
39
|
+
});
|
|
40
|
+
if (!response.data) throw new MulticallBatchError("Multicall3 aggregate3 returned no data");
|
|
41
|
+
return AbiFunction.decodeResult(multicall3Function, response.data).map((r) => ({
|
|
41
42
|
success: r.success,
|
|
42
43
|
returnData: r.returnData
|
|
43
44
|
}));
|
|
44
45
|
} catch (error) {
|
|
46
|
+
if (error instanceof MulticallBatchError) throw error;
|
|
45
47
|
throw new MulticallBatchError("Multicall3 aggregate3 call failed", { cause: error });
|
|
46
48
|
}
|
|
47
49
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let ox = require("ox");
|
|
1
3
|
//#region src/execution/multicall.ts
|
|
2
|
-
const
|
|
3
|
-
const multicall3Abi = [{
|
|
4
|
+
const aggregate3Abi = {
|
|
4
5
|
name: "aggregate3",
|
|
5
6
|
type: "function",
|
|
6
7
|
stateMutability: "payable",
|
|
@@ -33,7 +34,30 @@ const multicall3Abi = [{
|
|
|
33
34
|
type: "bytes"
|
|
34
35
|
}]
|
|
35
36
|
}]
|
|
36
|
-
}
|
|
37
|
+
};
|
|
38
|
+
const MULTICALL3_ADDRESS = "0xcA11bde05977b3631167028862bE2a173976CA11";
|
|
39
|
+
/**
|
|
40
|
+
* Pre-parsed Multicall3 aggregate3 ABI function for ox encoding/decoding.
|
|
41
|
+
*/
|
|
42
|
+
const multicall3Function = ox.AbiFunction.from(aggregate3Abi);
|
|
43
|
+
/**
|
|
44
|
+
* Multicall3 getEthBalance ABI — returns native ETH balance for an address.
|
|
45
|
+
* Used by the sol_address.balance() accessor.
|
|
46
|
+
*/
|
|
47
|
+
const getEthBalanceAbi = {
|
|
48
|
+
name: "getEthBalance",
|
|
49
|
+
type: "function",
|
|
50
|
+
stateMutability: "view",
|
|
51
|
+
inputs: [{
|
|
52
|
+
name: "addr",
|
|
53
|
+
type: "address"
|
|
54
|
+
}],
|
|
55
|
+
outputs: [{
|
|
56
|
+
name: "balance",
|
|
57
|
+
type: "uint256"
|
|
58
|
+
}]
|
|
59
|
+
};
|
|
37
60
|
//#endregion
|
|
38
61
|
exports.MULTICALL3_ADDRESS = MULTICALL3_ADDRESS;
|
|
39
|
-
exports.
|
|
62
|
+
exports.getEthBalanceAbi = getEthBalanceAbi;
|
|
63
|
+
exports.multicall3Function = multicall3Function;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { AbiFunction } from "ox";
|
|
1
2
|
//#region src/execution/multicall.ts
|
|
2
|
-
const
|
|
3
|
-
const multicall3Abi = [{
|
|
3
|
+
const aggregate3Abi = {
|
|
4
4
|
name: "aggregate3",
|
|
5
5
|
type: "function",
|
|
6
6
|
stateMutability: "payable",
|
|
@@ -33,6 +33,28 @@ const multicall3Abi = [{
|
|
|
33
33
|
type: "bytes"
|
|
34
34
|
}]
|
|
35
35
|
}]
|
|
36
|
-
}
|
|
36
|
+
};
|
|
37
|
+
const MULTICALL3_ADDRESS = "0xcA11bde05977b3631167028862bE2a173976CA11";
|
|
38
|
+
/**
|
|
39
|
+
* Pre-parsed Multicall3 aggregate3 ABI function for ox encoding/decoding.
|
|
40
|
+
*/
|
|
41
|
+
const multicall3Function = AbiFunction.from(aggregate3Abi);
|
|
42
|
+
/**
|
|
43
|
+
* Multicall3 getEthBalance ABI — returns native ETH balance for an address.
|
|
44
|
+
* Used by the sol_address.balance() accessor.
|
|
45
|
+
*/
|
|
46
|
+
const getEthBalanceAbi = {
|
|
47
|
+
name: "getEthBalance",
|
|
48
|
+
type: "function",
|
|
49
|
+
stateMutability: "view",
|
|
50
|
+
inputs: [{
|
|
51
|
+
name: "addr",
|
|
52
|
+
type: "address"
|
|
53
|
+
}],
|
|
54
|
+
outputs: [{
|
|
55
|
+
name: "balance",
|
|
56
|
+
type: "uint256"
|
|
57
|
+
}]
|
|
58
|
+
};
|
|
37
59
|
//#endregion
|
|
38
|
-
export { MULTICALL3_ADDRESS,
|
|
60
|
+
export { MULTICALL3_ADDRESS, getEthBalanceAbi, multicall3Function };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
-
const require_debug = require("../debug.cjs");
|
|
3
2
|
const require_errors = require("../errors/errors.cjs");
|
|
4
3
|
require("../errors/index.cjs");
|
|
5
|
-
|
|
4
|
+
const require_debug = require("../debug.cjs");
|
|
5
|
+
let ox = require("ox");
|
|
6
6
|
//#region src/execution/round-executor.ts
|
|
7
7
|
const debug = require_debug.createLogger("execute:round");
|
|
8
8
|
var RoundExecutor = class {
|
|
@@ -27,11 +27,7 @@ var RoundExecutor = class {
|
|
|
27
27
|
encodedCalls.push({
|
|
28
28
|
target: contract.address,
|
|
29
29
|
allowFailure: false,
|
|
30
|
-
callData: (
|
|
31
|
-
abi: contract.abi,
|
|
32
|
-
functionName: call.method,
|
|
33
|
-
args: resolvedArgs
|
|
34
|
-
})
|
|
30
|
+
callData: ox.AbiFunction.encodeData(contract.abi, call.method, resolvedArgs)
|
|
35
31
|
});
|
|
36
32
|
}
|
|
37
33
|
} catch (error) {
|
|
@@ -54,11 +50,7 @@ var RoundExecutor = class {
|
|
|
54
50
|
contractName: call.contract,
|
|
55
51
|
methodName: call.method
|
|
56
52
|
});
|
|
57
|
-
const decoded = (
|
|
58
|
-
abi: contract.abi,
|
|
59
|
-
functionName: call.method,
|
|
60
|
-
data: result.returnData
|
|
61
|
-
});
|
|
53
|
+
const decoded = ox.AbiFunction.decodeResult(contract.abi, call.method, result.returnData);
|
|
62
54
|
debug("decoded %s.%s -> %o", call.contract, call.method, decoded);
|
|
63
55
|
this.cache.set(call.id, decoded);
|
|
64
56
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createLogger } from "../debug.mjs";
|
|
2
1
|
import { MulticallBatchError } from "../errors/errors.mjs";
|
|
3
2
|
import "../errors/index.mjs";
|
|
4
|
-
import {
|
|
3
|
+
import { createLogger } from "../debug.mjs";
|
|
4
|
+
import { AbiFunction } from "ox";
|
|
5
5
|
//#region src/execution/round-executor.ts
|
|
6
6
|
const debug = createLogger("execute:round");
|
|
7
7
|
var RoundExecutor = class {
|
|
@@ -26,11 +26,7 @@ var RoundExecutor = class {
|
|
|
26
26
|
encodedCalls.push({
|
|
27
27
|
target: contract.address,
|
|
28
28
|
allowFailure: false,
|
|
29
|
-
callData:
|
|
30
|
-
abi: contract.abi,
|
|
31
|
-
functionName: call.method,
|
|
32
|
-
args: resolvedArgs
|
|
33
|
-
})
|
|
29
|
+
callData: AbiFunction.encodeData(contract.abi, call.method, resolvedArgs)
|
|
34
30
|
});
|
|
35
31
|
}
|
|
36
32
|
} catch (error) {
|
|
@@ -53,11 +49,7 @@ var RoundExecutor = class {
|
|
|
53
49
|
contractName: call.contract,
|
|
54
50
|
methodName: call.method
|
|
55
51
|
});
|
|
56
|
-
const decoded =
|
|
57
|
-
abi: contract.abi,
|
|
58
|
-
functionName: call.method,
|
|
59
|
-
data: result.returnData
|
|
60
|
-
});
|
|
52
|
+
const decoded = AbiFunction.decodeResult(contract.abi, call.method, result.returnData);
|
|
61
53
|
debug("decoded %s.%s -> %o", call.contract, call.method, decoded);
|
|
62
54
|
this.cache.set(call.id, decoded);
|
|
63
55
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { SELClient } from "../environment/client.cjs";
|
|
1
2
|
import { SELDiagnostic } from "@seljs/checker";
|
|
2
|
-
import { PublicClient } from "viem";
|
|
3
3
|
|
|
4
4
|
//#region src/execution/types.d.ts
|
|
5
5
|
/**
|
|
@@ -7,11 +7,17 @@ import { PublicClient } from "viem";
|
|
|
7
7
|
* Contains statistics and block information from the execution run.
|
|
8
8
|
*/
|
|
9
9
|
interface ExecutionMeta {
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Number of rounds executed (topological depth)
|
|
12
|
+
*/
|
|
11
13
|
roundsExecuted: number;
|
|
12
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Total number of contract calls executed
|
|
16
|
+
*/
|
|
13
17
|
totalCalls: number;
|
|
14
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Block number at which calls were executed
|
|
20
|
+
*/
|
|
15
21
|
blockNumber: bigint;
|
|
16
22
|
}
|
|
17
23
|
/**
|
|
@@ -19,29 +25,37 @@ interface ExecutionMeta {
|
|
|
19
25
|
* Maps call IDs to their decoded results.
|
|
20
26
|
*/
|
|
21
27
|
interface ExecutionResult {
|
|
22
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Map of callId to decoded result value
|
|
30
|
+
*/
|
|
23
31
|
results: Map<string, unknown>;
|
|
24
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Execution metadata
|
|
34
|
+
*/
|
|
25
35
|
meta: ExecutionMeta;
|
|
26
36
|
}
|
|
27
37
|
/**
|
|
28
38
|
* Context passed to the executor for running contract calls.
|
|
29
|
-
* Contains the
|
|
39
|
+
* Contains the block number and variable bindings.
|
|
30
40
|
*/
|
|
31
41
|
interface ExecutionContext {
|
|
32
|
-
/**
|
|
33
|
-
|
|
34
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Block number for consistent reads across all calls
|
|
44
|
+
*/
|
|
35
45
|
blockNumber: bigint;
|
|
36
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* Variable name to value mapping from evaluate() context
|
|
48
|
+
*/
|
|
37
49
|
variables: Record<string, unknown>;
|
|
38
50
|
}
|
|
39
51
|
/**
|
|
40
52
|
* Options for the evaluate() call.
|
|
41
53
|
*/
|
|
42
54
|
interface EvaluateOptions {
|
|
43
|
-
/**
|
|
44
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Override client for this evaluation
|
|
57
|
+
*/
|
|
58
|
+
client?: SELClient;
|
|
45
59
|
}
|
|
46
60
|
/**
|
|
47
61
|
* Result of evaluating a SEL expression.
|
|
@@ -50,11 +64,21 @@ interface EvaluateOptions {
|
|
|
50
64
|
* contract calls were executed, absent for pure CEL expressions.
|
|
51
65
|
*/
|
|
52
66
|
interface EvaluateResult<T = unknown> {
|
|
53
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* The evaluated result value
|
|
69
|
+
*/
|
|
54
70
|
value: T;
|
|
55
|
-
/**
|
|
71
|
+
/**
|
|
72
|
+
* The inferred type of the expression, when available
|
|
73
|
+
*/
|
|
74
|
+
type?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Execution metadata, present when contract calls were executed
|
|
77
|
+
*/
|
|
56
78
|
meta?: ExecutionMeta;
|
|
57
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* Advisory diagnostics (warnings/info) from lint rules, when non-empty
|
|
81
|
+
*/
|
|
58
82
|
diagnostics?: SELDiagnostic[];
|
|
59
83
|
}
|
|
60
84
|
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { SELClient } from "../environment/client.mjs";
|
|
1
2
|
import { SELDiagnostic } from "@seljs/checker";
|
|
2
|
-
import { PublicClient } from "viem";
|
|
3
3
|
|
|
4
4
|
//#region src/execution/types.d.ts
|
|
5
5
|
/**
|
|
@@ -7,11 +7,17 @@ import { PublicClient } from "viem";
|
|
|
7
7
|
* Contains statistics and block information from the execution run.
|
|
8
8
|
*/
|
|
9
9
|
interface ExecutionMeta {
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Number of rounds executed (topological depth)
|
|
12
|
+
*/
|
|
11
13
|
roundsExecuted: number;
|
|
12
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Total number of contract calls executed
|
|
16
|
+
*/
|
|
13
17
|
totalCalls: number;
|
|
14
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Block number at which calls were executed
|
|
20
|
+
*/
|
|
15
21
|
blockNumber: bigint;
|
|
16
22
|
}
|
|
17
23
|
/**
|
|
@@ -19,29 +25,37 @@ interface ExecutionMeta {
|
|
|
19
25
|
* Maps call IDs to their decoded results.
|
|
20
26
|
*/
|
|
21
27
|
interface ExecutionResult {
|
|
22
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Map of callId to decoded result value
|
|
30
|
+
*/
|
|
23
31
|
results: Map<string, unknown>;
|
|
24
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Execution metadata
|
|
34
|
+
*/
|
|
25
35
|
meta: ExecutionMeta;
|
|
26
36
|
}
|
|
27
37
|
/**
|
|
28
38
|
* Context passed to the executor for running contract calls.
|
|
29
|
-
* Contains the
|
|
39
|
+
* Contains the block number and variable bindings.
|
|
30
40
|
*/
|
|
31
41
|
interface ExecutionContext {
|
|
32
|
-
/**
|
|
33
|
-
|
|
34
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Block number for consistent reads across all calls
|
|
44
|
+
*/
|
|
35
45
|
blockNumber: bigint;
|
|
36
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* Variable name to value mapping from evaluate() context
|
|
48
|
+
*/
|
|
37
49
|
variables: Record<string, unknown>;
|
|
38
50
|
}
|
|
39
51
|
/**
|
|
40
52
|
* Options for the evaluate() call.
|
|
41
53
|
*/
|
|
42
54
|
interface EvaluateOptions {
|
|
43
|
-
/**
|
|
44
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Override client for this evaluation
|
|
57
|
+
*/
|
|
58
|
+
client?: SELClient;
|
|
45
59
|
}
|
|
46
60
|
/**
|
|
47
61
|
* Result of evaluating a SEL expression.
|
|
@@ -50,11 +64,21 @@ interface EvaluateOptions {
|
|
|
50
64
|
* contract calls were executed, absent for pure CEL expressions.
|
|
51
65
|
*/
|
|
52
66
|
interface EvaluateResult<T = unknown> {
|
|
53
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* The evaluated result value
|
|
69
|
+
*/
|
|
54
70
|
value: T;
|
|
55
|
-
/**
|
|
71
|
+
/**
|
|
72
|
+
* The inferred type of the expression, when available
|
|
73
|
+
*/
|
|
74
|
+
type?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Execution metadata, present when contract calls were executed
|
|
77
|
+
*/
|
|
56
78
|
meta?: ExecutionMeta;
|
|
57
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* Advisory diagnostics (warnings/info) from lint rules, when non-empty
|
|
81
|
+
*/
|
|
58
82
|
diagnostics?: SELDiagnostic[];
|
|
59
83
|
}
|
|
60
84
|
//#endregion
|
package/dist/index.cjs
CHANGED
|
@@ -2,6 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
require("./_virtual/_rolldown/runtime.cjs");
|
|
3
3
|
const require_errors = require("./errors/errors.cjs");
|
|
4
4
|
require("./errors/index.cjs");
|
|
5
|
+
const require_client = require("./environment/client.cjs");
|
|
5
6
|
const require_environment = require("./environment/environment.cjs");
|
|
6
7
|
require("./environment/index.cjs");
|
|
7
8
|
const require_factory = require("./factory.cjs");
|
|
@@ -9,6 +10,7 @@ let _seljs_common = require("@seljs/common");
|
|
|
9
10
|
exports.CircularDependencyError = require_errors.CircularDependencyError;
|
|
10
11
|
exports.ExecutionLimitError = require_errors.ExecutionLimitError;
|
|
11
12
|
exports.MulticallBatchError = require_errors.MulticallBatchError;
|
|
13
|
+
exports.SELClientError = require_errors.SELClientError;
|
|
12
14
|
exports.SELContractError = require_errors.SELContractError;
|
|
13
15
|
exports.SELError = _seljs_common.SELError;
|
|
14
16
|
exports.SELEvaluationError = require_errors.SELEvaluationError;
|
|
@@ -17,3 +19,4 @@ exports.SELParseError = _seljs_common.SELParseError;
|
|
|
17
19
|
exports.SELRuntime = require_environment.SELRuntime;
|
|
18
20
|
exports.SELTypeError = _seljs_common.SELTypeError;
|
|
19
21
|
exports.createSEL = require_factory.createSEL;
|
|
22
|
+
exports.validateClient = require_client.validateClient;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { SELClient, validateClient } from "./environment/client.cjs";
|
|
1
2
|
import { MulticallOptions, SELLimits, SELRuntimeConfig } from "./environment/types.cjs";
|
|
2
3
|
import { EvaluateOptions, EvaluateResult, ExecutionContext, ExecutionMeta, ExecutionResult } from "./execution/types.cjs";
|
|
3
4
|
import { SELRuntime } from "./environment/environment.cjs";
|
|
4
|
-
import { CircularDependencyError, ExecutionLimitError, MulticallBatchError, SELContractError, SELError, SELEvaluationError, SELLintError, SELParseError, SELTypeError } from "./errors/errors.cjs";
|
|
5
|
+
import { CircularDependencyError, ExecutionLimitError, MulticallBatchError, SELClientError, SELContractError, SELError, SELEvaluationError, SELLintError, SELParseError, SELTypeError } from "./errors/errors.cjs";
|
|
5
6
|
import { createSEL } from "./factory.cjs";
|
|
6
7
|
import { CallArgument, CollectedCall, DependencyGraph, ExecutionPlan, ExecutionRound, GraphNode } from "./analysis/types.cjs";
|
|
7
|
-
export { CallArgument, CircularDependencyError, CollectedCall, DependencyGraph, EvaluateOptions, EvaluateResult, ExecutionContext, ExecutionLimitError, ExecutionMeta, ExecutionPlan, ExecutionResult, ExecutionRound, GraphNode, MulticallBatchError, MulticallOptions, SELContractError, SELError, SELEvaluationError, SELLimits, SELLintError, SELParseError, SELRuntime, SELRuntimeConfig, SELTypeError, createSEL };
|
|
8
|
+
export { CallArgument, CircularDependencyError, CollectedCall, DependencyGraph, EvaluateOptions, EvaluateResult, ExecutionContext, ExecutionLimitError, ExecutionMeta, ExecutionPlan, ExecutionResult, ExecutionRound, GraphNode, MulticallBatchError, MulticallOptions, SELClient, SELClientError, SELContractError, SELError, SELEvaluationError, SELLimits, SELLintError, SELParseError, SELRuntime, SELRuntimeConfig, SELTypeError, createSEL, validateClient };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { SELClient, validateClient } from "./environment/client.mjs";
|
|
1
2
|
import { MulticallOptions, SELLimits, SELRuntimeConfig } from "./environment/types.mjs";
|
|
2
3
|
import { EvaluateOptions, EvaluateResult, ExecutionContext, ExecutionMeta, ExecutionResult } from "./execution/types.mjs";
|
|
3
4
|
import { SELRuntime } from "./environment/environment.mjs";
|
|
4
|
-
import { CircularDependencyError, ExecutionLimitError, MulticallBatchError, SELContractError, SELError, SELEvaluationError, SELLintError, SELParseError, SELTypeError } from "./errors/errors.mjs";
|
|
5
|
+
import { CircularDependencyError, ExecutionLimitError, MulticallBatchError, SELClientError, SELContractError, SELError, SELEvaluationError, SELLintError, SELParseError, SELTypeError } from "./errors/errors.mjs";
|
|
5
6
|
import { createSEL } from "./factory.mjs";
|
|
6
7
|
import { CallArgument, CollectedCall, DependencyGraph, ExecutionPlan, ExecutionRound, GraphNode } from "./analysis/types.mjs";
|
|
7
|
-
export { CallArgument, CircularDependencyError, CollectedCall, DependencyGraph, EvaluateOptions, EvaluateResult, ExecutionContext, ExecutionLimitError, ExecutionMeta, ExecutionPlan, ExecutionResult, ExecutionRound, GraphNode, MulticallBatchError, MulticallOptions, SELContractError, SELError, SELEvaluationError, SELLimits, SELLintError, SELParseError, SELRuntime, SELRuntimeConfig, SELTypeError, createSEL };
|
|
8
|
+
export { CallArgument, CircularDependencyError, CollectedCall, DependencyGraph, EvaluateOptions, EvaluateResult, ExecutionContext, ExecutionLimitError, ExecutionMeta, ExecutionPlan, ExecutionResult, ExecutionRound, GraphNode, MulticallBatchError, MulticallOptions, SELClient, SELClientError, SELContractError, SELError, SELEvaluationError, SELLimits, SELLintError, SELParseError, SELRuntime, SELRuntimeConfig, SELTypeError, createSEL, validateClient };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { CircularDependencyError, ExecutionLimitError, MulticallBatchError, SELContractError, SELError, SELEvaluationError, SELLintError, SELParseError, SELTypeError } from "./errors/errors.mjs";
|
|
1
|
+
import { CircularDependencyError, ExecutionLimitError, MulticallBatchError, SELClientError, SELContractError, SELError, SELEvaluationError, SELLintError, SELParseError, SELTypeError } from "./errors/errors.mjs";
|
|
2
2
|
import "./errors/index.mjs";
|
|
3
|
+
import { validateClient } from "./environment/client.mjs";
|
|
3
4
|
import { SELRuntime } from "./environment/environment.mjs";
|
|
4
5
|
import "./environment/index.mjs";
|
|
5
6
|
import { createSEL } from "./factory.mjs";
|
|
6
|
-
export { CircularDependencyError, ExecutionLimitError, MulticallBatchError, SELContractError, SELError, SELEvaluationError, SELLintError, SELParseError, SELRuntime, SELTypeError, createSEL };
|
|
7
|
+
export { CircularDependencyError, ExecutionLimitError, MulticallBatchError, SELClientError, SELContractError, SELError, SELEvaluationError, SELLintError, SELParseError, SELRuntime, SELTypeError, createSEL, validateClient };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seljs/runtime",
|
|
3
|
-
"version": "1.3.0-beta.
|
|
3
|
+
"version": "1.3.0-beta.11",
|
|
4
4
|
"repository": {
|
|
5
5
|
"url": "https://github.com/abinnovision/seljs"
|
|
6
6
|
},
|
|
@@ -50,16 +50,16 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@marcbachmann/cel-js": "^7.5.3",
|
|
53
|
-
"@seljs/checker": "1.3.0-beta.
|
|
54
|
-
"@seljs/common": "1.3.0-beta.
|
|
55
|
-
"@seljs/env": "1.3.0-beta.
|
|
53
|
+
"@seljs/checker": "1.3.0-beta.11",
|
|
54
|
+
"@seljs/common": "1.3.0-beta.11",
|
|
55
|
+
"@seljs/env": "1.3.0-beta.11",
|
|
56
56
|
"@seljs/schema": "1.2.0",
|
|
57
|
-
"@seljs/types": "1.3.0-beta.
|
|
57
|
+
"@seljs/types": "1.3.0-beta.11",
|
|
58
58
|
"debug": "^4.4.3",
|
|
59
|
-
"
|
|
59
|
+
"ox": "^0.14.8"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@abinnovision/eslint-config-base": "^3.2.
|
|
62
|
+
"@abinnovision/eslint-config-base": "^3.2.2",
|
|
63
63
|
"@abinnovision/prettier-config": "^2.1.5",
|
|
64
64
|
"@seljs-internal/fixtures": "0.0.0",
|
|
65
65
|
"@seljs-internal/tsconfig": "^0.0.0",
|