@rootzero/contracts 1.23.0 → 1.25.0
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/CHANGELOG.md +78 -0
- package/Codec.sol +1 -1
- package/Commands.sol +1 -1
- package/Core.sol +3 -3
- package/Endpoints.sol +9 -1
- package/README.md +35 -24
- package/Utils.sol +1 -1
- package/annotations/Schema.sol +1 -7
- package/codec/Blocks.sol +153 -24
- package/codec/Decoders.sol +42 -5
- package/codec/Descriptors.sol +3 -1
- package/codec/Keys.sol +2 -0
- package/codec/Readers.sol +12 -0
- package/codec/Schema.sol +5 -4
- package/codec/Specs.sol +3 -0
- package/codec/Writers.sol +12 -1
- package/commands/Base.sol +1 -4
- package/commands/Debit.sol +2 -5
- package/commands/Repay.sol +110 -10
- package/commands/admin/Base.sol +1 -4
- package/core/Access.sol +8 -0
- package/core/Pipeline.sol +26 -7
- package/core/Types.sol +8 -0
- package/execution/Budget.sol +22 -0
- package/execution/Execution.sol +48 -4
- package/package.json +1 -1
- package/ports/Pipe.sol +4 -5
- package/utils/Utils.sol +10 -0
package/ports/Pipe.sol
CHANGED
|
@@ -3,17 +3,16 @@ pragma solidity ^0.8.33;
|
|
|
3
3
|
|
|
4
4
|
import {PortBase} from "./Base.sol";
|
|
5
5
|
import {Flags} from "../codec/Descriptors.sol";
|
|
6
|
-
import {
|
|
6
|
+
import {PipeHook} from "../core/Pipeline.sol";
|
|
7
7
|
import {Specs} from "../Codec.sol";
|
|
8
8
|
import {Execution, Executions, Lanes} from "../execution/Execution.sol";
|
|
9
|
-
import {Budget} from "../execution/Budget.sol";
|
|
10
9
|
|
|
11
10
|
using Executions for Execution;
|
|
12
11
|
|
|
13
12
|
/// @title PipePayablePort
|
|
14
13
|
/// @notice Port that consumes CONTEXT blocks and executes each input as a step stream.
|
|
15
14
|
/// Each context's input bytes are passed to the shared pipeline.
|
|
16
|
-
abstract contract PipePayablePort is PortBase,
|
|
15
|
+
abstract contract PipePayablePort is PortBase, PipeHook {
|
|
17
16
|
uint private immutable descriptor;
|
|
18
17
|
|
|
19
18
|
constructor() {
|
|
@@ -27,11 +26,11 @@ abstract contract PipePayablePort is PortBase, Pipeline {
|
|
|
27
26
|
/// @return Empty response bytes.
|
|
28
27
|
function portPipePayable(bytes calldata data) external payable onlyPeer returns (bytes memory) {
|
|
29
28
|
Execution memory exec = openInput(data, descriptor, 0);
|
|
30
|
-
|
|
29
|
+
uint budget = exec.drainBudget();
|
|
31
30
|
|
|
32
31
|
while (exec.more()) {
|
|
33
32
|
(bytes32 account, bytes calldata state, bytes calldata input) = exec.unpackContext(Lanes.Input);
|
|
34
|
-
pipe(account, state, input, budget);
|
|
33
|
+
budget = pipe(account, state, input, budget);
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
return "";
|
package/utils/Utils.sol
CHANGED
|
@@ -10,6 +10,8 @@ error ValueOverflow();
|
|
|
10
10
|
error NotDivisible();
|
|
11
11
|
/// @dev Thrown when an ID claims to carry an address but the embedded address is zero.
|
|
12
12
|
error ZeroAddress();
|
|
13
|
+
/// @dev Thrown when an address does not contain deployed bytecode.
|
|
14
|
+
error InvalidContract();
|
|
13
15
|
|
|
14
16
|
/// @notice Assert that `value` fits in uint8 and return it as uint8.
|
|
15
17
|
function max8(uint value) pure returns (uint8) {
|
|
@@ -146,6 +148,14 @@ function ensureAddr(address addr) pure returns (address) {
|
|
|
146
148
|
return addr;
|
|
147
149
|
}
|
|
148
150
|
|
|
151
|
+
/// @notice Assert that `target` contains deployed bytecode and return it unchanged.
|
|
152
|
+
/// @dev Rejects EOAs, zero and future deployment addresses, contracts currently
|
|
153
|
+
/// under construction, and precompiles whose code length is zero.
|
|
154
|
+
function ensureContract(address target) view returns (address) {
|
|
155
|
+
if (target.code.length == 0) revert InvalidContract();
|
|
156
|
+
return target;
|
|
157
|
+
}
|
|
158
|
+
|
|
149
159
|
/// @notice Convert a signed integer to its 32-byte two's-complement representation.
|
|
150
160
|
function intToBytes32(int value) pure returns (bytes32) {
|
|
151
161
|
return bytes32(uint(value));
|