@rootzero/contracts 1.24.0 → 1.26.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 +140 -0
- package/Codec.sol +1 -2
- package/Core.sol +1 -1
- package/Endpoints.sol +3 -0
- package/README.md +66 -51
- package/Utils.sol +2 -1
- package/codec/Blocks.sol +354 -108
- package/codec/Buffers.sol +24 -20
- package/codec/Decoders.sol +49 -31
- package/codec/Descriptors.sol +75 -72
- package/codec/Keys.sol +5 -1
- package/codec/Schema.sol +5 -1
- package/codec/Specs.sol +19 -9
- package/codec/Writers.sol +14 -19
- package/commands/Allocate.sol +8 -7
- package/commands/Base.sol +14 -52
- package/commands/Bootstrap.sol +95 -0
- package/commands/Burn.sol +7 -7
- package/commands/Cashout.sol +85 -0
- package/commands/Credit.sol +18 -16
- package/commands/Debit.sol +22 -21
- package/commands/Deposit.sol +13 -13
- package/commands/Payout.sol +8 -8
- package/commands/Provision.sol +13 -13
- package/commands/Recover.sol +7 -7
- package/commands/Relay.sol +22 -23
- package/commands/Repay.sol +36 -34
- package/commands/Settle.sol +24 -22
- package/commands/Withdraw.sol +7 -7
- package/commands/admin/AllowAssets.sol +7 -7
- package/commands/admin/Allowance.sol +7 -7
- package/commands/admin/Annotate.sol +7 -7
- package/commands/admin/Appoint.sol +7 -7
- package/commands/admin/Authorize.sol +7 -7
- package/commands/admin/Base.sol +5 -11
- package/commands/admin/DenyAssets.sol +7 -7
- package/commands/admin/Dismiss.sol +7 -7
- package/commands/admin/Execute.sol +8 -8
- package/commands/admin/Unauthorize.sol +7 -7
- package/core/Calls.sol +3 -3
- package/core/Endpoint.sol +7 -7
- package/core/Pipeline.sol +40 -22
- package/execution/Budget.sol +24 -3
- package/execution/Execution.sol +289 -506
- package/guards/Base.sol +1 -1
- package/guards/Revoke.sol +7 -7
- package/package.json +1 -1
- package/ports/Allowance.sol +3 -3
- package/ports/Assets.sol +7 -7
- package/ports/Base.sol +1 -1
- package/ports/Credit.sol +3 -3
- package/ports/Debit.sol +3 -3
- package/ports/Dispatch.sol +3 -3
- package/ports/Pipe.sol +7 -8
- package/ports/Post.sol +3 -3
- package/ports/Redeem.sol +3 -3
- package/queries/Assets.sol +3 -3
- package/queries/Balances.sol +3 -3
- package/queries/Base.sol +1 -1
- package/utils/Accounts.sol +1 -3
- package/utils/Actions.sol +2 -0
- package/utils/Assets.sol +1 -10
- package/utils/Cursors.sol +60 -116
- package/utils/Errors.sol +50 -0
- package/utils/Ids.sol +2 -5
- package/utils/Lanes.sol +0 -2
- package/utils/Nodes.sol +1 -3
- package/utils/Utils.sol +2 -9
- package/codec/Readers.sol +0 -190
package/guards/Base.sol
CHANGED
|
@@ -27,6 +27,6 @@ abstract contract GuardBase is GuardianAccess, InputEndpointBase {
|
|
|
27
27
|
uint input
|
|
28
28
|
) internal returns (uint id, uint descriptor) {
|
|
29
29
|
id = Nodes.toGuard(name, address(this));
|
|
30
|
-
descriptor = endpoint(id, name, Specs.Empty, input, Specs.Empty, 0
|
|
30
|
+
descriptor = endpoint(id, name, Specs.Empty, input, Specs.Empty, 0);
|
|
31
31
|
}
|
|
32
32
|
}
|
package/guards/Revoke.sol
CHANGED
|
@@ -5,7 +5,7 @@ import {AllowanceHook} from "../commands/admin/Allowance.sol";
|
|
|
5
5
|
import {DenyAssetsHook} from "../commands/admin/DenyAssets.sol";
|
|
6
6
|
import {GuardBase} from "./Base.sol";
|
|
7
7
|
import {Specs} from "../Codec.sol";
|
|
8
|
-
import {Execution, Executions
|
|
8
|
+
import {Execution, Executions} from "../execution/Execution.sol";
|
|
9
9
|
using Executions for Execution;
|
|
10
10
|
|
|
11
11
|
/// @title Revoke
|
|
@@ -21,10 +21,10 @@ abstract contract Revoke is GuardBase {
|
|
|
21
21
|
|
|
22
22
|
/// @notice Revoke every NODE block in `input` as the active guardian.
|
|
23
23
|
function revoke(bytes calldata input) external onlyGuardian {
|
|
24
|
-
Execution memory exec = openInput(input, descriptor
|
|
24
|
+
Execution memory exec = openInput(input, descriptor);
|
|
25
25
|
|
|
26
26
|
while (exec.more()) {
|
|
27
|
-
uint node = exec.unpackNode(
|
|
27
|
+
uint node = exec.unpackNode();
|
|
28
28
|
setNode(node, false);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -42,10 +42,10 @@ abstract contract RevokeAllowance is GuardBase, AllowanceHook {
|
|
|
42
42
|
|
|
43
43
|
/// @notice Revoke every HOST_ASSET allowance in `input` as the active guardian.
|
|
44
44
|
function revokeAllowance(bytes calldata input) external onlyGuardian {
|
|
45
|
-
Execution memory exec = openInput(input, descriptor
|
|
45
|
+
Execution memory exec = openInput(input, descriptor);
|
|
46
46
|
|
|
47
47
|
while (exec.more()) {
|
|
48
|
-
(uint peer, bytes32 asset) = exec.unpackHostAsset(
|
|
48
|
+
(uint peer, bytes32 asset) = exec.unpackHostAsset();
|
|
49
49
|
allowance(peer, asset, 0);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -63,10 +63,10 @@ abstract contract RevokeAsset is GuardBase, DenyAssetsHook {
|
|
|
63
63
|
|
|
64
64
|
/// @notice Deny every ASSET block in `input` as the active guardian.
|
|
65
65
|
function revokeAsset(bytes calldata input) external onlyGuardian {
|
|
66
|
-
Execution memory exec = openInput(input, descriptor
|
|
66
|
+
Execution memory exec = openInput(input, descriptor);
|
|
67
67
|
|
|
68
68
|
while (exec.more()) {
|
|
69
|
-
bytes32 asset = exec.unpackAsset(
|
|
69
|
+
bytes32 asset = exec.unpackAsset();
|
|
70
70
|
denyAsset(asset);
|
|
71
71
|
}
|
|
72
72
|
}
|
package/package.json
CHANGED
package/ports/Allowance.sol
CHANGED
|
@@ -3,7 +3,7 @@ pragma solidity ^0.8.33;
|
|
|
3
3
|
|
|
4
4
|
import {PortBase} from "./Base.sol";
|
|
5
5
|
import {Specs} from "../Codec.sol";
|
|
6
|
-
import {Execution, Executions
|
|
6
|
+
import {Execution, Executions} from "../execution/Execution.sol";
|
|
7
7
|
|
|
8
8
|
using Executions for Execution;
|
|
9
9
|
|
|
@@ -33,11 +33,11 @@ abstract contract RequestAllowancePort is PortBase, RequestAllowanceHook {
|
|
|
33
33
|
/// @param data AMOUNT block stream supplied by the trusted peer.
|
|
34
34
|
/// @return Empty response bytes.
|
|
35
35
|
function portRequestAllowance(bytes calldata data) external onlyPeer returns (bytes memory) {
|
|
36
|
-
Execution memory exec = openInput(data, descriptor
|
|
36
|
+
Execution memory exec = openInput(data, descriptor);
|
|
37
37
|
uint peer = caller();
|
|
38
38
|
|
|
39
39
|
while (exec.more()) {
|
|
40
|
-
(bytes32 asset, uint amount) = exec.unpackAmount(
|
|
40
|
+
(bytes32 asset, uint amount) = exec.unpackAmount();
|
|
41
41
|
requestAllowance(peer, asset, amount);
|
|
42
42
|
}
|
|
43
43
|
|
package/ports/Assets.sol
CHANGED
|
@@ -5,7 +5,7 @@ import {PortBase} from "./Base.sol";
|
|
|
5
5
|
import {AllowAssetsHook} from "../commands/admin/AllowAssets.sol";
|
|
6
6
|
import {DenyAssetsHook} from "../commands/admin/DenyAssets.sol";
|
|
7
7
|
import {Specs} from "../Codec.sol";
|
|
8
|
-
import {Execution, Executions
|
|
8
|
+
import {Execution, Executions} from "../execution/Execution.sol";
|
|
9
9
|
|
|
10
10
|
using Executions for Execution;
|
|
11
11
|
|
|
@@ -23,10 +23,10 @@ abstract contract AllowAssetsPort is PortBase, AllowAssetsHook {
|
|
|
23
23
|
/// @param data ASSET block stream supplied by the trusted peer.
|
|
24
24
|
/// @return Empty response bytes.
|
|
25
25
|
function portAllowAssets(bytes calldata data) external onlyPeer returns (bytes memory) {
|
|
26
|
-
Execution memory exec = openInput(data, descriptor
|
|
26
|
+
Execution memory exec = openInput(data, descriptor);
|
|
27
27
|
|
|
28
28
|
while (exec.more()) {
|
|
29
|
-
bytes32 asset = exec.unpackAsset(
|
|
29
|
+
bytes32 asset = exec.unpackAsset();
|
|
30
30
|
allowAsset(asset);
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -48,10 +48,10 @@ abstract contract DenyAssetsPort is PortBase, DenyAssetsHook {
|
|
|
48
48
|
/// @param data ASSET block stream supplied by the trusted peer.
|
|
49
49
|
/// @return Empty response bytes.
|
|
50
50
|
function portDenyAssets(bytes calldata data) external onlyPeer returns (bytes memory) {
|
|
51
|
-
Execution memory exec = openInput(data, descriptor
|
|
51
|
+
Execution memory exec = openInput(data, descriptor);
|
|
52
52
|
|
|
53
53
|
while (exec.more()) {
|
|
54
|
-
bytes32 asset = exec.unpackAsset(
|
|
54
|
+
bytes32 asset = exec.unpackAsset();
|
|
55
55
|
denyAsset(asset);
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -86,11 +86,11 @@ abstract contract RequestAssetPort is PortBase, RequestAssetHook {
|
|
|
86
86
|
/// @param data AMOUNT block stream supplied by the trusted peer.
|
|
87
87
|
/// @return Empty response bytes.
|
|
88
88
|
function portRequestAsset(bytes calldata data) external onlyPeer returns (bytes memory) {
|
|
89
|
-
Execution memory exec = openInput(data, descriptor
|
|
89
|
+
Execution memory exec = openInput(data, descriptor);
|
|
90
90
|
uint peer = caller();
|
|
91
91
|
|
|
92
92
|
while (exec.more()) {
|
|
93
|
-
(bytes32 asset, uint amount) = exec.unpackAmount(
|
|
93
|
+
(bytes32 asset, uint amount) = exec.unpackAmount();
|
|
94
94
|
requestAsset(peer, asset, amount);
|
|
95
95
|
}
|
|
96
96
|
|
package/ports/Base.sol
CHANGED
|
@@ -41,7 +41,7 @@ abstract contract PortBase is NodeCalls, NodeAccess, InputEndpointBase {
|
|
|
41
41
|
uint output,
|
|
42
42
|
uint8 flags
|
|
43
43
|
) internal returns (uint id, uint descriptor) {
|
|
44
|
-
descriptor = Descriptors.create(Specs.Empty, input, output,
|
|
44
|
+
descriptor = Descriptors.create(Specs.Empty, input, output, flags);
|
|
45
45
|
return port(name, descriptor);
|
|
46
46
|
}
|
|
47
47
|
|
package/ports/Credit.sol
CHANGED
|
@@ -4,7 +4,7 @@ pragma solidity ^0.8.33;
|
|
|
4
4
|
import {PortBase} from "./Base.sol";
|
|
5
5
|
import {CreditAccountHook} from "../core/Settlement.sol";
|
|
6
6
|
import {Specs} from "../Codec.sol";
|
|
7
|
-
import {Execution, Executions
|
|
7
|
+
import {Execution, Executions} from "../execution/Execution.sol";
|
|
8
8
|
|
|
9
9
|
using Executions for Execution;
|
|
10
10
|
|
|
@@ -22,10 +22,10 @@ abstract contract CreditAccountPort is PortBase, CreditAccountHook {
|
|
|
22
22
|
/// @param data ACCOUNT_AMOUNT block stream supplied by the trusted peer.
|
|
23
23
|
/// @return Empty response bytes.
|
|
24
24
|
function portCreditAccount(bytes calldata data) external onlyPeer returns (bytes memory) {
|
|
25
|
-
Execution memory exec = openInput(data, descriptor
|
|
25
|
+
Execution memory exec = openInput(data, descriptor);
|
|
26
26
|
|
|
27
27
|
while (exec.more()) {
|
|
28
|
-
(bytes32 account, bytes32 asset, uint amount) = exec.unpackAccountAmount(
|
|
28
|
+
(bytes32 account, bytes32 asset, uint amount) = exec.unpackAccountAmount();
|
|
29
29
|
creditAccount(account, asset, amount);
|
|
30
30
|
}
|
|
31
31
|
|
package/ports/Debit.sol
CHANGED
|
@@ -4,7 +4,7 @@ pragma solidity ^0.8.33;
|
|
|
4
4
|
import {PortBase} from "./Base.sol";
|
|
5
5
|
import {DebitAccountHook} from "../core/Settlement.sol";
|
|
6
6
|
import {Specs} from "../Codec.sol";
|
|
7
|
-
import {Execution, Executions
|
|
7
|
+
import {Execution, Executions} from "../execution/Execution.sol";
|
|
8
8
|
|
|
9
9
|
using Executions for Execution;
|
|
10
10
|
|
|
@@ -22,10 +22,10 @@ abstract contract DebitAccountPort is PortBase, DebitAccountHook {
|
|
|
22
22
|
/// @param data ACCOUNT_AMOUNT block stream supplied by the trusted peer.
|
|
23
23
|
/// @return Empty response bytes.
|
|
24
24
|
function portDebitAccount(bytes calldata data) external onlyPeer returns (bytes memory) {
|
|
25
|
-
Execution memory exec = openInput(data, descriptor
|
|
25
|
+
Execution memory exec = openInput(data, descriptor);
|
|
26
26
|
|
|
27
27
|
while (exec.more()) {
|
|
28
|
-
(bytes32 account, bytes32 asset, uint amount) = exec.unpackAccountAmount(
|
|
28
|
+
(bytes32 account, bytes32 asset, uint amount) = exec.unpackAccountAmount();
|
|
29
29
|
debitAccount(account, asset, amount);
|
|
30
30
|
}
|
|
31
31
|
|
package/ports/Dispatch.sol
CHANGED
|
@@ -4,7 +4,7 @@ pragma solidity ^0.8.33;
|
|
|
4
4
|
import {PortBase} from "./Base.sol";
|
|
5
5
|
import {Flags} from "../codec/Descriptors.sol";
|
|
6
6
|
import {Specs} from "../Codec.sol";
|
|
7
|
-
import {Execution, Executions
|
|
7
|
+
import {Execution, Executions} from "../execution/Execution.sol";
|
|
8
8
|
|
|
9
9
|
using Executions for Execution;
|
|
10
10
|
|
|
@@ -36,10 +36,10 @@ abstract contract DispatchPayablePort is PortBase, DispatchPayableHook {
|
|
|
36
36
|
/// @param data DISPATCH block stream supplied by the trusted peer.
|
|
37
37
|
/// @return Empty response bytes.
|
|
38
38
|
function portDispatchPayable(bytes calldata data) external payable onlyPeer returns (bytes memory) {
|
|
39
|
-
Execution memory exec = openInput(data, descriptor
|
|
39
|
+
Execution memory exec = openInput(data, descriptor);
|
|
40
40
|
|
|
41
41
|
while (exec.more()) {
|
|
42
|
-
(uint portal, uint resources, bytes calldata payload) = exec.unpackDispatch(
|
|
42
|
+
(uint portal, uint resources, bytes calldata payload) = exec.unpackDispatch();
|
|
43
43
|
dispatchTo(portal, resources, payload, exec);
|
|
44
44
|
}
|
|
45
45
|
|
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
|
-
import {Execution, Executions
|
|
9
|
-
import {Budget} from "../execution/Budget.sol";
|
|
8
|
+
import {Execution, Executions} from "../execution/Execution.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() {
|
|
@@ -26,12 +25,12 @@ abstract contract PipePayablePort is PortBase, Pipeline {
|
|
|
26
25
|
/// @param data CONTEXT block stream supplied by the trusted peer.
|
|
27
26
|
/// @return Empty response bytes.
|
|
28
27
|
function portPipePayable(bytes calldata data) external payable onlyPeer returns (bytes memory) {
|
|
29
|
-
Execution memory exec = openInput(data, descriptor
|
|
30
|
-
|
|
28
|
+
Execution memory exec = openInput(data, descriptor);
|
|
29
|
+
uint budget = exec.drainBudget();
|
|
31
30
|
|
|
32
31
|
while (exec.more()) {
|
|
33
|
-
(bytes32 account, bytes calldata state, bytes calldata input) = exec.unpackContext(
|
|
34
|
-
pipe(account, state, input, budget);
|
|
32
|
+
(bytes32 account, bytes calldata state, bytes calldata input) = exec.unpackContext();
|
|
33
|
+
budget = pipe(account, state, input, budget);
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
return "";
|
package/ports/Post.sol
CHANGED
|
@@ -4,7 +4,7 @@ pragma solidity ^0.8.33;
|
|
|
4
4
|
import {PortBase} from "./Base.sol";
|
|
5
5
|
import {PostHook} from "../core/Settlement.sol";
|
|
6
6
|
import {Specs} from "../Codec.sol";
|
|
7
|
-
import {Execution, Executions
|
|
7
|
+
import {Execution, Executions} from "../execution/Execution.sol";
|
|
8
8
|
import {Action} from "../annotations/Action.sol";
|
|
9
9
|
import {Actions} from "../utils/Actions.sol";
|
|
10
10
|
|
|
@@ -26,10 +26,10 @@ abstract contract PostPort is PortBase, PostHook, Action {
|
|
|
26
26
|
/// @param data TRANSACTION block stream supplied by the trusted peer.
|
|
27
27
|
/// @return Empty response bytes.
|
|
28
28
|
function portPost(bytes calldata data) external onlyPeer returns (bytes memory) {
|
|
29
|
-
Execution memory exec = openInput(data, descriptor
|
|
29
|
+
Execution memory exec = openInput(data, descriptor);
|
|
30
30
|
|
|
31
31
|
while (exec.more()) {
|
|
32
|
-
(bytes32 from, bytes32 to, bytes32 asset, uint amount) = exec.unpackTransaction(
|
|
32
|
+
(bytes32 from, bytes32 to, bytes32 asset, uint amount) = exec.unpackTransaction();
|
|
33
33
|
post(from, to, asset, amount);
|
|
34
34
|
}
|
|
35
35
|
|
package/ports/Redeem.sol
CHANGED
|
@@ -3,7 +3,7 @@ pragma solidity ^0.8.33;
|
|
|
3
3
|
|
|
4
4
|
import {PortBase} from "./Base.sol";
|
|
5
5
|
import {Specs} from "../Codec.sol";
|
|
6
|
-
import {Execution, Executions
|
|
6
|
+
import {Execution, Executions} from "../execution/Execution.sol";
|
|
7
7
|
|
|
8
8
|
using Executions for Execution;
|
|
9
9
|
|
|
@@ -31,11 +31,11 @@ abstract contract RedeemBalancePort is PortBase, RedeemBalanceHook {
|
|
|
31
31
|
/// @param data BALANCE block stream supplied by the trusted peer.
|
|
32
32
|
/// @return Empty response bytes.
|
|
33
33
|
function portRedeemBalance(bytes calldata data) external onlyPeer returns (bytes memory) {
|
|
34
|
-
Execution memory exec = openInput(data, descriptor
|
|
34
|
+
Execution memory exec = openInput(data, descriptor);
|
|
35
35
|
uint peer = caller();
|
|
36
36
|
|
|
37
37
|
while (exec.more()) {
|
|
38
|
-
(bytes32 asset, uint amount) = exec.unpackBalance(
|
|
38
|
+
(bytes32 asset, uint amount) = exec.unpackBalance();
|
|
39
39
|
redeemBalance(peer, asset, amount);
|
|
40
40
|
}
|
|
41
41
|
|
package/queries/Assets.sol
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
pragma solidity ^0.8.33;
|
|
3
3
|
|
|
4
4
|
import {Specs} from "../Codec.sol";
|
|
5
|
-
import {Execution, Executions
|
|
5
|
+
import {Execution, Executions} from "../execution/Execution.sol";
|
|
6
6
|
import {QueryBase} from "./Base.sol";
|
|
7
7
|
|
|
8
8
|
using Executions for Execution;
|
|
@@ -31,10 +31,10 @@ abstract contract AssetStatus is QueryBase, AssetStatusHook {
|
|
|
31
31
|
/// @param input Block-stream input consisting of `asset { bytes32 asset }` blocks.
|
|
32
32
|
/// @return Block-stream response containing one `status { uint code }` form block per asset block.
|
|
33
33
|
function assetStatus(bytes calldata input) external view returns (bytes memory) {
|
|
34
|
-
Execution memory exec = openInput(input, descriptor
|
|
34
|
+
Execution memory exec = openInput(input, descriptor);
|
|
35
35
|
|
|
36
36
|
while (exec.more()) {
|
|
37
|
-
bytes32 asset = exec.unpackAsset(
|
|
37
|
+
bytes32 asset = exec.unpackAsset();
|
|
38
38
|
uint status = assetStatus(asset);
|
|
39
39
|
exec.outputStatus(status);
|
|
40
40
|
}
|
package/queries/Balances.sol
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
pragma solidity ^0.8.33;
|
|
3
3
|
|
|
4
4
|
import {Specs} from "../Codec.sol";
|
|
5
|
-
import {Execution, Executions
|
|
5
|
+
import {Execution, Executions} from "../execution/Execution.sol";
|
|
6
6
|
import {QueryBase} from "./Base.sol";
|
|
7
7
|
|
|
8
8
|
using Executions for Execution;
|
|
@@ -32,10 +32,10 @@ abstract contract GetBalances is QueryBase, GetBalancesHook {
|
|
|
32
32
|
/// @param input Block-stream input consisting of `accountAsset(account, asset)*`.
|
|
33
33
|
/// @return Block-stream response containing one `accountAmount(account, asset, amount)` block per input block.
|
|
34
34
|
function getBalances(bytes calldata input) external view returns (bytes memory) {
|
|
35
|
-
Execution memory exec = openInput(input, descriptor
|
|
35
|
+
Execution memory exec = openInput(input, descriptor);
|
|
36
36
|
|
|
37
37
|
while (exec.more()) {
|
|
38
|
-
(bytes32 account, bytes32 asset) = exec.unpackAccountAsset(
|
|
38
|
+
(bytes32 account, bytes32 asset) = exec.unpackAccountAsset();
|
|
39
39
|
uint amount = getBalance(account, asset);
|
|
40
40
|
exec.outputAccountAmount(account, asset, amount);
|
|
41
41
|
}
|
package/queries/Base.sol
CHANGED
|
@@ -24,7 +24,7 @@ abstract contract QueryBase is InputEndpointBase {
|
|
|
24
24
|
uint input,
|
|
25
25
|
uint output
|
|
26
26
|
) internal returns (uint id, uint descriptor) {
|
|
27
|
-
descriptor = Descriptors.create(Specs.Empty, input, output, 0
|
|
27
|
+
descriptor = Descriptors.create(Specs.Empty, input, output, 0);
|
|
28
28
|
return query(name, descriptor);
|
|
29
29
|
}
|
|
30
30
|
|
package/utils/Accounts.sol
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
pragma solidity ^0.8.33;
|
|
3
3
|
|
|
4
4
|
import {Layout} from "./Layout.sol";
|
|
5
|
+
import {InvalidAccount} from "./Errors.sol";
|
|
5
6
|
import {Ids} from "./Ids.sol";
|
|
6
7
|
import {ensureAddr, isFamily, toLocalBase, toUnspecifiedBase} from "./Utils.sol";
|
|
7
8
|
|
|
@@ -18,9 +19,6 @@ import {ensureAddr, isFamily, toLocalBase, toUnspecifiedBase} from "./Utils.sol"
|
|
|
18
19
|
///
|
|
19
20
|
/// The helpers in this library validate and deconstruct structured account IDs.
|
|
20
21
|
library Accounts {
|
|
21
|
-
/// @dev Thrown when an account ID does not belong to the EVM family.
|
|
22
|
-
error InvalidAccount();
|
|
23
|
-
|
|
24
22
|
/// @dev 24-bit family tag shared by all EVM-backed account types.
|
|
25
23
|
uint24 constant Family = (uint24(Layout.Evm) << 8) | uint24(Layout.Account);
|
|
26
24
|
/// @dev Full 4-byte type prefix for admin accounts (chain-local EVM address).
|
package/utils/Actions.sol
CHANGED
package/utils/Assets.sol
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
pragma solidity ^0.8.33;
|
|
3
3
|
|
|
4
4
|
import {Layout} from "./Layout.sol";
|
|
5
|
+
import {BadAmount, InvalidAsset, UnauthorizedAsset, ZeroAmount} from "./Errors.sol";
|
|
5
6
|
import {Ids} from "./Ids.sol";
|
|
6
7
|
import {ensureAddr, isFamily, matchesBase, toLocalBase} from "./Utils.sol";
|
|
7
8
|
|
|
@@ -20,11 +21,6 @@ import {ensureAddr, isFamily, matchesBase, toLocalBase} from "./Utils.sol";
|
|
|
20
21
|
///
|
|
21
22
|
/// All asset IDs are chain-local (include `block.chainid` in bits [223:192]).
|
|
22
23
|
library Assets {
|
|
23
|
-
/// @dev Thrown when an asset ID does not match the expected type or chain.
|
|
24
|
-
error InvalidAsset();
|
|
25
|
-
/// @dev Thrown when an asset is not authorized for the requested operation.
|
|
26
|
-
error UnauthorizedAsset();
|
|
27
|
-
|
|
28
24
|
/// @dev 24-bit family tag shared by all EVM-backed asset types.
|
|
29
25
|
uint24 constant Family = (uint24(Layout.Evm) << 8) | uint24(Layout.Asset);
|
|
30
26
|
/// @dev Full 4-byte type prefix for the native chain coin/token asset.
|
|
@@ -136,11 +132,6 @@ library Assets {
|
|
|
136
132
|
/// @title Amounts
|
|
137
133
|
/// @notice Validation helpers for token amounts.
|
|
138
134
|
library Amounts {
|
|
139
|
-
/// @dev Thrown when a required non-zero amount is zero.
|
|
140
|
-
error ZeroAmount();
|
|
141
|
-
/// @dev Thrown when an amount falls outside the allowed `[min, max]` range.
|
|
142
|
-
error BadAmount(uint amount);
|
|
143
|
-
|
|
144
135
|
/// @notice Assert that `amount` is non-zero and return it unchanged.
|
|
145
136
|
/// @param amount Amount to validate.
|
|
146
137
|
/// @return The same `amount` value if valid.
|