@rootzero/contracts 1.25.0 → 1.27.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 +125 -0
- package/Codec.sol +1 -2
- package/Endpoints.sol +2 -0
- package/README.md +73 -51
- package/Utils.sol +2 -1
- package/codec/Blocks.sol +276 -88
- package/codec/Buffers.sol +24 -20
- package/codec/Decoders.sol +35 -37
- package/codec/Descriptors.sol +75 -72
- package/codec/Keys.sol +5 -1
- package/codec/Schema.sol +7 -1
- package/codec/Specs.sol +19 -9
- package/codec/Writers.sol +14 -19
- package/commands/Allocate.sol +8 -7
- package/commands/Base.sol +14 -49
- package/commands/Bootstrap.sol +81 -0
- package/commands/Burn.sol +7 -7
- package/commands/Cashout.sol +86 -0
- package/commands/Credit.sol +20 -17
- package/commands/Debit.sol +25 -20
- 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 +38 -35
- package/commands/Settle.sol +26 -23
- 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 -8
- 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/Access.sol +1 -0
- package/core/Calls.sol +3 -3
- package/core/Endpoint.sol +7 -7
- package/core/Pipeline.sol +19 -23
- package/core/Settlement.sol +2 -1
- package/core/Types.sol +1 -0
- package/execution/Budget.sol +2 -3
- package/execution/Execution.sol +270 -511
- 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 +3 -3
- 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 +17 -10
- package/utils/Actions.sol +2 -0
- package/utils/Assets.sol +1 -10
- package/utils/Cursors.sol +60 -116
- package/utils/Errors.sol +56 -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
|
@@ -5,7 +5,7 @@ import {PortBase} from "./Base.sol";
|
|
|
5
5
|
import {Flags} from "../codec/Descriptors.sol";
|
|
6
6
|
import {PipeHook} from "../core/Pipeline.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
|
|
|
@@ -25,11 +25,11 @@ abstract contract PipePayablePort is PortBase, PipeHook {
|
|
|
25
25
|
/// @param data CONTEXT block stream supplied by the trusted peer.
|
|
26
26
|
/// @return Empty response bytes.
|
|
27
27
|
function portPipePayable(bytes calldata data) external payable onlyPeer returns (bytes memory) {
|
|
28
|
-
Execution memory exec = openInput(data, descriptor
|
|
28
|
+
Execution memory exec = openInput(data, descriptor);
|
|
29
29
|
uint budget = exec.drainBudget();
|
|
30
30
|
|
|
31
31
|
while (exec.more()) {
|
|
32
|
-
(bytes32 account, bytes calldata state, bytes calldata input) = exec.unpackContext(
|
|
32
|
+
(bytes32 account, bytes calldata state, bytes calldata input) = exec.unpackContext();
|
|
33
33
|
budget = pipe(account, state, input, budget);
|
|
34
34
|
}
|
|
35
35
|
|
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).
|
|
@@ -36,6 +34,7 @@ library Accounts {
|
|
|
36
34
|
}
|
|
37
35
|
|
|
38
36
|
/// @notice Return true if `account` belongs to the EVM account family.
|
|
37
|
+
/// @dev Classification only; does not require a nonzero embedded address.
|
|
39
38
|
function isEvm(bytes32 account) internal pure returns (bool) {
|
|
40
39
|
return isFamily(uint(account), Family);
|
|
41
40
|
}
|
|
@@ -46,20 +45,24 @@ library Accounts {
|
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
/// @notice Return true if `account` is an admin account.
|
|
48
|
+
/// @dev Classification only; does not require a nonzero embedded address.
|
|
49
49
|
function isAdmin(bytes32 account) internal pure returns (bool) {
|
|
50
50
|
return prefix(account) == Admin;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
/// @notice Return true if `account` is a user account.
|
|
54
|
+
/// @dev Classification only; does not require a nonzero embedded address.
|
|
54
55
|
function isUser(bytes32 account) internal pure returns (bool) {
|
|
55
56
|
return prefix(account) == User;
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
/// @notice Assert that `value` belongs to the EVM account family
|
|
59
|
+
/// @notice Assert that `value` belongs to the EVM account family, contains
|
|
60
|
+
/// a nonzero embedded address, and return it unchanged.
|
|
59
61
|
/// @param value Account identifier to validate.
|
|
60
62
|
/// @return account The same `value` if it is an EVM account.
|
|
61
63
|
function evm(bytes32 value) internal pure returns (bytes32 account) {
|
|
62
|
-
if (!
|
|
64
|
+
if (!isFamily(uint(value), Family)) revert InvalidAccount();
|
|
65
|
+
ensureAddr(address(uint160(uint(value) >> 32)));
|
|
63
66
|
return value;
|
|
64
67
|
}
|
|
65
68
|
|
|
@@ -71,19 +74,23 @@ library Accounts {
|
|
|
71
74
|
return value;
|
|
72
75
|
}
|
|
73
76
|
|
|
74
|
-
/// @notice Assert that `value` is an admin account
|
|
77
|
+
/// @notice Assert that `value` is an admin account, contains a nonzero
|
|
78
|
+
/// embedded address, and return it unchanged.
|
|
75
79
|
/// @param value Account identifier to validate.
|
|
76
80
|
/// @return account The same `value` if it is an admin account.
|
|
77
81
|
function admin(bytes32 value) internal pure returns (bytes32 account) {
|
|
78
|
-
if (
|
|
82
|
+
if (uint32(uint(value) >> 224) != Admin) revert InvalidAccount();
|
|
83
|
+
ensureAddr(address(uint160(uint(value) >> 32)));
|
|
79
84
|
return value;
|
|
80
85
|
}
|
|
81
86
|
|
|
82
|
-
/// @notice Assert that `value` is a user account
|
|
87
|
+
/// @notice Assert that `value` is a user account, contains a nonzero
|
|
88
|
+
/// embedded address, and return it unchanged.
|
|
83
89
|
/// @param value Account identifier to validate.
|
|
84
90
|
/// @return account The same `value` if it is a user account.
|
|
85
91
|
function user(bytes32 value) internal pure returns (bytes32 account) {
|
|
86
|
-
if (
|
|
92
|
+
if (uint32(uint(value) >> 224) != User) revert InvalidAccount();
|
|
93
|
+
ensureAddr(address(uint160(uint(value) >> 32)));
|
|
87
94
|
return value;
|
|
88
95
|
}
|
|
89
96
|
|
|
@@ -122,6 +129,6 @@ library Accounts {
|
|
|
122
129
|
/// @param account EVM-family account ID.
|
|
123
130
|
/// @return Embedded address (bits [191:32] of the ID).
|
|
124
131
|
function addr(bytes32 account) internal pure returns (address) {
|
|
125
|
-
return
|
|
132
|
+
return address(uint160(uint(evm(account)) >> 32));
|
|
126
133
|
}
|
|
127
134
|
}
|
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.
|