@rootzero/contracts 1.22.0 → 1.23.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 +68 -0
- package/Endpoints.sol +2 -3
- package/Events.sol +1 -1
- package/README.md +13 -11
- package/annotations/Action.sol +1 -1
- package/annotations/Label.sol +1 -1
- package/annotations/Schema.sol +1 -1
- package/codec/Blocks.sol +39 -30
- package/commands/Allocate.sol +5 -8
- package/commands/Base.sol +29 -13
- package/commands/Burn.sol +5 -7
- package/commands/Credit.sol +5 -7
- package/commands/Debit.sol +5 -7
- package/commands/Deposit.sol +10 -14
- package/commands/Payout.sol +5 -8
- package/commands/Provision.sol +10 -14
- package/commands/Recover.sol +4 -6
- package/commands/Relay.sol +14 -21
- package/commands/Repay.sol +10 -14
- package/commands/Settle.sol +10 -14
- package/commands/Withdraw.sol +5 -7
- package/commands/admin/AllowAssets.sol +5 -7
- package/commands/admin/Allowance.sol +5 -7
- package/commands/admin/Annotate.sol +5 -7
- package/commands/admin/Appoint.sol +5 -7
- package/commands/admin/Authorize.sol +5 -7
- package/commands/admin/Base.sol +12 -3
- package/commands/admin/DenyAssets.sol +5 -7
- package/commands/admin/Dismiss.sol +5 -7
- package/commands/admin/Execute.sol +5 -7
- package/commands/admin/Unauthorize.sol +5 -7
- package/core/Calls.sol +72 -3
- package/core/Portal.sol +2 -2
- package/events/Positioned.sol +22 -0
- package/execution/Execution.sol +42 -0
- package/package.json +1 -1
- package/ports/Allowance.sol +22 -12
- package/ports/Assets.sol +99 -0
- package/utils/Cursors.sol +3 -3
- package/utils/Nodes.sol +1 -1
- package/utils/Utils.sol +31 -31
- package/events/Commander.sol +0 -19
- package/ports/AllowAssets.sol +0 -34
- package/ports/DenyAssets.sol +0 -34
package/commands/Deposit.sol
CHANGED
|
@@ -44,23 +44,21 @@ abstract contract Deposit is CommandBase, DepositHook, Action {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/// @notice Deposit AMOUNT input blocks into the command account and output matching BALANCE blocks.
|
|
47
|
-
/// @param
|
|
47
|
+
/// @param context Command context carrying the AMOUNT input stream.
|
|
48
48
|
/// @return BALANCE block stream matching the deposited amounts.
|
|
49
49
|
/// @return Empty transaction stream.
|
|
50
50
|
function deposit(
|
|
51
|
-
|
|
52
|
-
bytes calldata state,
|
|
53
|
-
bytes calldata input
|
|
51
|
+
bytes calldata context
|
|
54
52
|
) external onlyCommand returns (bytes memory, bytes memory) {
|
|
55
|
-
Execution memory exec = openCommand(
|
|
53
|
+
Execution memory exec = openCommand(context, descriptor, 0);
|
|
56
54
|
|
|
57
55
|
while (exec.more()) {
|
|
58
56
|
(bytes32 asset, uint amount) = exec.unpackAmount(Lanes.Input);
|
|
59
|
-
deposit(account, asset, amount);
|
|
57
|
+
deposit(exec.account, asset, amount);
|
|
60
58
|
exec.outputBalance(asset, amount);
|
|
61
59
|
}
|
|
62
60
|
|
|
63
|
-
return
|
|
61
|
+
return closeCommand(exec);
|
|
64
62
|
}
|
|
65
63
|
}
|
|
66
64
|
|
|
@@ -77,22 +75,20 @@ abstract contract DepositPayable is CommandBase, DepositPayableHook, Action {
|
|
|
77
75
|
}
|
|
78
76
|
|
|
79
77
|
/// @notice Deposit AMOUNT input blocks with access to a mutable native-value budget.
|
|
80
|
-
/// @param
|
|
78
|
+
/// @param context Command context carrying the AMOUNT input stream.
|
|
81
79
|
/// @return BALANCE block stream matching the deposited amounts.
|
|
82
80
|
/// @return Remaining native value as a refund transaction stream.
|
|
83
81
|
function depositPayable(
|
|
84
|
-
|
|
85
|
-
bytes calldata state,
|
|
86
|
-
bytes calldata input
|
|
82
|
+
bytes calldata context
|
|
87
83
|
) external payable onlyCommand returns (bytes memory, bytes memory) {
|
|
88
|
-
Execution memory exec = openCommand(
|
|
84
|
+
Execution memory exec = openCommand(context, descriptor, 0);
|
|
89
85
|
|
|
90
86
|
while (exec.more()) {
|
|
91
87
|
(bytes32 asset, uint amount) = exec.unpackAmount(Lanes.Input);
|
|
92
|
-
deposit(account, asset, amount, exec);
|
|
88
|
+
deposit(exec.account, asset, amount, exec);
|
|
93
89
|
exec.outputBalance(asset, amount);
|
|
94
90
|
}
|
|
95
91
|
|
|
96
|
-
return
|
|
92
|
+
return closeCommand(exec);
|
|
97
93
|
}
|
|
98
94
|
}
|
package/commands/Payout.sol
CHANGED
|
@@ -31,22 +31,19 @@ abstract contract Payout is CommandBase, PayoutHook, Action {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/// @notice Pay out BALANCE state blocks to matching ACCOUNT input blocks.
|
|
34
|
-
/// @param
|
|
35
|
-
/// @param input Matching ACCOUNT block stream.
|
|
34
|
+
/// @param context Command context carrying BALANCE state and matching ACCOUNT input.
|
|
36
35
|
/// @return Empty output state.
|
|
37
36
|
/// @return Empty transaction stream.
|
|
38
37
|
function payout(
|
|
39
|
-
|
|
40
|
-
bytes calldata state,
|
|
41
|
-
bytes calldata input
|
|
38
|
+
bytes calldata context
|
|
42
39
|
) external onlyCommand returns (bytes memory, bytes memory) {
|
|
43
|
-
Execution memory exec = openCommand(
|
|
40
|
+
Execution memory exec = openCommand(context, descriptor, 0);
|
|
44
41
|
|
|
45
42
|
while (exec.more()) {
|
|
46
43
|
(bytes32 asset, uint amount) = exec.unpackBalance(Lanes.State);
|
|
47
|
-
payout(account, exec.unpackAccount(Lanes.Input), asset, amount);
|
|
44
|
+
payout(exec.account, exec.unpackAccount(Lanes.Input), asset, amount);
|
|
48
45
|
}
|
|
49
46
|
|
|
50
|
-
return
|
|
47
|
+
return closeCommand(exec);
|
|
51
48
|
}
|
|
52
49
|
}
|
package/commands/Provision.sol
CHANGED
|
@@ -36,23 +36,21 @@ abstract contract Provision is CommandBase, ProvisionHook {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/// @notice Provision ALLOCATION input blocks and output matching CUSTODY state blocks.
|
|
39
|
-
/// @param
|
|
39
|
+
/// @param context Command context carrying the ALLOCATION input stream.
|
|
40
40
|
/// @return CUSTODY block stream matching the provisioned allocations.
|
|
41
41
|
/// @return Empty transaction stream.
|
|
42
42
|
function provision(
|
|
43
|
-
|
|
44
|
-
bytes calldata state,
|
|
45
|
-
bytes calldata input
|
|
43
|
+
bytes calldata context
|
|
46
44
|
) external onlyCommand returns (bytes memory, bytes memory) {
|
|
47
|
-
Execution memory exec = openCommand(
|
|
45
|
+
Execution memory exec = openCommand(context, descriptor, 0);
|
|
48
46
|
|
|
49
47
|
while (exec.more()) {
|
|
50
48
|
HostAmount memory allocation = exec.unpackAllocationValue(Lanes.Input);
|
|
51
|
-
provision(account, allocation);
|
|
49
|
+
provision(exec.account, allocation);
|
|
52
50
|
exec.outputCustody(allocation);
|
|
53
51
|
}
|
|
54
52
|
|
|
55
|
-
return
|
|
53
|
+
return closeCommand(exec);
|
|
56
54
|
}
|
|
57
55
|
}
|
|
58
56
|
|
|
@@ -68,23 +66,21 @@ abstract contract ProvisionPayable is CommandBase, ProvisionPayableHook {
|
|
|
68
66
|
}
|
|
69
67
|
|
|
70
68
|
/// @notice Provision ALLOCATION input blocks with access to a mutable native-value budget.
|
|
71
|
-
/// @param
|
|
69
|
+
/// @param context Command context carrying the ALLOCATION input stream.
|
|
72
70
|
/// @return CUSTODY block stream matching the provisioned allocations.
|
|
73
71
|
/// @return Remaining native value as a refund transaction stream.
|
|
74
72
|
function provisionPayable(
|
|
75
|
-
|
|
76
|
-
bytes calldata state,
|
|
77
|
-
bytes calldata input
|
|
73
|
+
bytes calldata context
|
|
78
74
|
) external payable onlyCommand returns (bytes memory, bytes memory) {
|
|
79
|
-
Execution memory exec = openCommand(
|
|
75
|
+
Execution memory exec = openCommand(context, descriptor, 0);
|
|
80
76
|
|
|
81
77
|
while (exec.more()) {
|
|
82
78
|
HostAmount memory allocation = exec.unpackAllocationValue(Lanes.Input);
|
|
83
|
-
provision(account, allocation, exec);
|
|
79
|
+
provision(exec.account, allocation, exec);
|
|
84
80
|
exec.outputCustody(allocation);
|
|
85
81
|
}
|
|
86
82
|
|
|
87
|
-
return
|
|
83
|
+
return closeCommand(exec);
|
|
88
84
|
}
|
|
89
85
|
}
|
|
90
86
|
|
package/commands/Recover.sol
CHANGED
|
@@ -35,21 +35,19 @@ abstract contract RecoverPayable is CommandBase, RecoverPayableHook {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
/// @notice Recover each recover block in the command input.
|
|
38
|
-
/// @param
|
|
38
|
+
/// @param context Command context carrying the RECOVER input stream.
|
|
39
39
|
/// @return Empty output state.
|
|
40
40
|
/// @return Remaining native value as a refund transaction stream.
|
|
41
41
|
function recoverPayable(
|
|
42
|
-
|
|
43
|
-
bytes calldata state,
|
|
44
|
-
bytes calldata input
|
|
42
|
+
bytes calldata context
|
|
45
43
|
) external payable onlyCommand returns (bytes memory, bytes memory) {
|
|
46
|
-
Execution memory exec = openCommand(
|
|
44
|
+
Execution memory exec = openCommand(context, descriptor, 0);
|
|
47
45
|
|
|
48
46
|
while (exec.more()) {
|
|
49
47
|
(uint handler, uint resources, bytes32 key, bytes calldata witness) = exec.unpackRecover(Lanes.Input);
|
|
50
48
|
recover(handler, resources, key, witness, exec);
|
|
51
49
|
}
|
|
52
50
|
|
|
53
|
-
return
|
|
51
|
+
return closeCommand(exec);
|
|
54
52
|
}
|
|
55
53
|
}
|
package/commands/Relay.sol
CHANGED
|
@@ -13,17 +13,15 @@ abstract contract RelayPayableHook {
|
|
|
13
13
|
/// @param resources Chain-specific destination resources. EVM adapters
|
|
14
14
|
/// may interpret this as packed execution gas and destination value.
|
|
15
15
|
/// @param account Destination command account.
|
|
16
|
-
/// @param state State forwarded into the destination context.
|
|
17
16
|
/// @param input Input forwarded into the destination context.
|
|
18
|
-
/// @param
|
|
19
|
-
/// and destination resource funding.
|
|
17
|
+
/// @param exec Execution carrying the source state and value available for
|
|
18
|
+
/// transport fees and destination resource funding.
|
|
20
19
|
function relay(
|
|
21
20
|
uint portal,
|
|
22
21
|
uint resources,
|
|
23
22
|
bytes32 account,
|
|
24
|
-
bytes calldata state,
|
|
25
23
|
bytes calldata input,
|
|
26
|
-
Execution memory
|
|
24
|
+
Execution memory exec
|
|
27
25
|
) internal virtual;
|
|
28
26
|
}
|
|
29
27
|
|
|
@@ -38,15 +36,13 @@ abstract contract RelayPayable is CommandBase, RelayPayableHook {
|
|
|
38
36
|
|
|
39
37
|
/// @notice Relay one RELAY input block with the command account and empty state.
|
|
40
38
|
function relayPayable(
|
|
41
|
-
|
|
42
|
-
bytes calldata state,
|
|
43
|
-
bytes calldata input
|
|
39
|
+
bytes calldata context
|
|
44
40
|
) external payable onlyCommand returns (bytes memory, bytes memory) {
|
|
45
|
-
Execution memory exec = openCommand(
|
|
46
|
-
(uint portal, uint resources, bytes calldata
|
|
47
|
-
relay(portal, resources, account,
|
|
41
|
+
Execution memory exec = openCommand(context, descriptor, 1);
|
|
42
|
+
(uint portal, uint resources, bytes calldata input) = exec.unpackRelay(Lanes.Input);
|
|
43
|
+
relay(portal, resources, exec.account, input, exec);
|
|
48
44
|
|
|
49
|
-
return
|
|
45
|
+
return closeCommand(exec);
|
|
50
46
|
}
|
|
51
47
|
}
|
|
52
48
|
|
|
@@ -63,19 +59,16 @@ abstract contract RelayBalancePayable is CommandBase, RelayPayableHook {
|
|
|
63
59
|
}
|
|
64
60
|
|
|
65
61
|
/// @notice Relay one RELAY input block with the command account and current state.
|
|
66
|
-
/// @param state
|
|
67
|
-
/// @param input Exactly one RELAY block.
|
|
62
|
+
/// @param context Command context carrying state and exactly one RELAY input block.
|
|
68
63
|
/// @return Empty output state.
|
|
69
64
|
/// @return Remaining native value as a refund transaction stream.
|
|
70
65
|
function relayBalancePayable(
|
|
71
|
-
|
|
72
|
-
bytes calldata state,
|
|
73
|
-
bytes calldata input
|
|
66
|
+
bytes calldata context
|
|
74
67
|
) external payable onlyCommand returns (bytes memory, bytes memory) {
|
|
75
|
-
Execution memory exec = openCommand(
|
|
76
|
-
(uint portal, uint resources, bytes calldata
|
|
77
|
-
relay(portal, resources, account,
|
|
68
|
+
Execution memory exec = openCommand(context, descriptor, 1);
|
|
69
|
+
(uint portal, uint resources, bytes calldata input) = exec.unpackRelay(Lanes.Input);
|
|
70
|
+
relay(portal, resources, exec.account, input, exec);
|
|
78
71
|
|
|
79
|
-
return
|
|
72
|
+
return closeCommand(exec);
|
|
80
73
|
}
|
|
81
74
|
}
|
package/commands/Repay.sol
CHANGED
|
@@ -30,23 +30,21 @@ abstract contract Repay is CommandBase, RepayHook, Action {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
/// @notice Repay each POSITION liability and return its asset as BALANCE state.
|
|
33
|
-
/// @param
|
|
33
|
+
/// @param context Command context carrying the POSITION state stream.
|
|
34
34
|
/// @return BALANCE output state containing each released asset side.
|
|
35
35
|
/// @return Empty transaction stream.
|
|
36
36
|
function repay(
|
|
37
|
-
|
|
38
|
-
bytes calldata state,
|
|
39
|
-
bytes calldata input
|
|
37
|
+
bytes calldata context
|
|
40
38
|
) external onlyCommand returns (bytes memory, bytes memory) {
|
|
41
|
-
Execution memory exec = openCommand(
|
|
39
|
+
Execution memory exec = openCommand(context, descriptor, 0);
|
|
42
40
|
|
|
43
41
|
while (exec.more()) {
|
|
44
42
|
(bytes32 asset, uint amount, bytes32 liability, uint debt) = exec.unpackPosition(Lanes.State);
|
|
45
|
-
repay(account, liability, debt);
|
|
43
|
+
repay(exec.account, liability, debt);
|
|
46
44
|
exec.outputBalance(asset, amount);
|
|
47
45
|
}
|
|
48
46
|
|
|
49
|
-
return
|
|
47
|
+
return closeCommand(exec);
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
50
|
|
|
@@ -62,22 +60,20 @@ abstract contract RepayPayable is CommandBase, RepayPayableHook, Action {
|
|
|
62
60
|
}
|
|
63
61
|
|
|
64
62
|
/// @notice Repay each POSITION liability and return its asset as BALANCE state.
|
|
65
|
-
/// @param
|
|
63
|
+
/// @param context Command context carrying the POSITION state stream.
|
|
66
64
|
/// @return BALANCE output state containing each released asset side.
|
|
67
65
|
/// @return Remaining native value as a refund transaction stream.
|
|
68
66
|
function repayPayable(
|
|
69
|
-
|
|
70
|
-
bytes calldata state,
|
|
71
|
-
bytes calldata input
|
|
67
|
+
bytes calldata context
|
|
72
68
|
) external payable onlyCommand returns (bytes memory, bytes memory) {
|
|
73
|
-
Execution memory exec = openCommand(
|
|
69
|
+
Execution memory exec = openCommand(context, descriptor, 0);
|
|
74
70
|
|
|
75
71
|
while (exec.more()) {
|
|
76
72
|
(bytes32 asset, uint amount, bytes32 liability, uint debt) = exec.unpackPosition(Lanes.State);
|
|
77
|
-
repay(account, liability, debt, exec);
|
|
73
|
+
repay(exec.account, liability, debt, exec);
|
|
78
74
|
exec.outputBalance(asset, amount);
|
|
79
75
|
}
|
|
80
76
|
|
|
81
|
-
return
|
|
77
|
+
return closeCommand(exec);
|
|
82
78
|
}
|
|
83
79
|
}
|
package/commands/Settle.sol
CHANGED
|
@@ -47,22 +47,20 @@ abstract contract Settle is CommandBase, SettleHook, Action {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/// @notice Settle each POSITION block from the command state.
|
|
50
|
-
/// @param
|
|
50
|
+
/// @param context Command context carrying the POSITION state stream.
|
|
51
51
|
/// @return Empty output state.
|
|
52
52
|
/// @return Empty transaction stream.
|
|
53
53
|
function settle(
|
|
54
|
-
|
|
55
|
-
bytes calldata state,
|
|
56
|
-
bytes calldata input
|
|
54
|
+
bytes calldata context
|
|
57
55
|
) external onlyCommand returns (bytes memory, bytes memory) {
|
|
58
|
-
Execution memory exec = openCommand(
|
|
56
|
+
Execution memory exec = openCommand(context, descriptor, 0);
|
|
59
57
|
|
|
60
58
|
while (exec.more()) {
|
|
61
59
|
(bytes32 asset, uint amount, bytes32 liability, uint debt) = exec.unpackPosition(Lanes.State);
|
|
62
|
-
settle(account, asset, amount, liability, debt);
|
|
60
|
+
settle(exec.account, asset, amount, liability, debt);
|
|
63
61
|
}
|
|
64
62
|
|
|
65
|
-
return
|
|
63
|
+
return closeCommand(exec);
|
|
66
64
|
}
|
|
67
65
|
}
|
|
68
66
|
|
|
@@ -78,22 +76,20 @@ abstract contract SettlePayable is CommandBase, SettlePayableHook, Action {
|
|
|
78
76
|
}
|
|
79
77
|
|
|
80
78
|
/// @notice Settle each POSITION block with access to a shared native-value budget.
|
|
81
|
-
/// @param
|
|
79
|
+
/// @param context Command context carrying the POSITION state stream.
|
|
82
80
|
/// @return Empty output state.
|
|
83
81
|
/// @return Remaining native value as a refund transaction stream.
|
|
84
82
|
function settlePayable(
|
|
85
|
-
|
|
86
|
-
bytes calldata state,
|
|
87
|
-
bytes calldata input
|
|
83
|
+
bytes calldata context
|
|
88
84
|
) external payable onlyCommand returns (bytes memory, bytes memory) {
|
|
89
|
-
Execution memory exec = openCommand(
|
|
85
|
+
Execution memory exec = openCommand(context, descriptor, 0);
|
|
90
86
|
|
|
91
87
|
while (exec.more()) {
|
|
92
88
|
(bytes32 asset, uint amount, bytes32 liability, uint debt) = exec.unpackPosition(Lanes.State);
|
|
93
|
-
settle(account, asset, amount, liability, debt, exec);
|
|
89
|
+
settle(exec.account, asset, amount, liability, debt, exec);
|
|
94
90
|
}
|
|
95
91
|
|
|
96
|
-
return
|
|
92
|
+
return closeCommand(exec);
|
|
97
93
|
}
|
|
98
94
|
}
|
|
99
95
|
|
package/commands/Withdraw.sol
CHANGED
|
@@ -30,21 +30,19 @@ abstract contract Withdraw is CommandBase, WithdrawHook, Action {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
/// @notice Withdraw each BALANCE block from the command state to the command account.
|
|
33
|
-
/// @param
|
|
33
|
+
/// @param context Command context carrying the BALANCE state stream.
|
|
34
34
|
/// @return Empty output state.
|
|
35
35
|
/// @return Empty transaction stream.
|
|
36
36
|
function withdraw(
|
|
37
|
-
|
|
38
|
-
bytes calldata state,
|
|
39
|
-
bytes calldata input
|
|
37
|
+
bytes calldata context
|
|
40
38
|
) external onlyCommand returns (bytes memory, bytes memory) {
|
|
41
|
-
Execution memory exec = openCommand(
|
|
39
|
+
Execution memory exec = openCommand(context, descriptor, 0);
|
|
42
40
|
|
|
43
41
|
while (exec.more()) {
|
|
44
42
|
(bytes32 asset, uint amount) = exec.unpackBalance(Lanes.State);
|
|
45
|
-
withdraw(account, asset, amount);
|
|
43
|
+
withdraw(exec.account, asset, amount);
|
|
46
44
|
}
|
|
47
45
|
|
|
48
|
-
return
|
|
46
|
+
return closeCommand(exec);
|
|
49
47
|
}
|
|
50
48
|
}
|
|
@@ -23,22 +23,20 @@ abstract contract AllowAssets is AdminBase, AllowAssetsHook {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/// @notice Allow each ASSET block in the admin input.
|
|
26
|
-
/// @param
|
|
26
|
+
/// @param context Admin command context carrying the ASSET input stream.
|
|
27
27
|
/// @return Empty output state.
|
|
28
28
|
/// @return Empty transaction stream.
|
|
29
29
|
function allowAssets(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
) external onlyAdmin(account) returns (bytes memory, bytes memory) {
|
|
34
|
-
Execution memory exec = openCommand(state, input, descriptor, 0);
|
|
30
|
+
bytes calldata context
|
|
31
|
+
) external returns (bytes memory, bytes memory) {
|
|
32
|
+
Execution memory exec = openAdminCommand(context, descriptor, 0);
|
|
35
33
|
|
|
36
34
|
while (exec.more()) {
|
|
37
35
|
bytes32 asset = exec.unpackAsset(Lanes.Input);
|
|
38
36
|
allowAsset(asset);
|
|
39
37
|
}
|
|
40
38
|
|
|
41
|
-
return
|
|
39
|
+
return closeCommand(exec);
|
|
42
40
|
}
|
|
43
41
|
}
|
|
44
42
|
|
|
@@ -27,21 +27,19 @@ abstract contract Allowance is AdminBase, AllowanceHook {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/// @notice Apply each ALLOWANCE block in the admin input.
|
|
30
|
-
/// @param
|
|
30
|
+
/// @param context Admin command context carrying the ALLOWANCE input stream.
|
|
31
31
|
/// @return Empty output state.
|
|
32
32
|
/// @return Empty transaction stream.
|
|
33
33
|
function allowance(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
) external onlyAdmin(account) returns (bytes memory, bytes memory) {
|
|
38
|
-
Execution memory exec = openCommand(state, input, descriptor, 0);
|
|
34
|
+
bytes calldata context
|
|
35
|
+
) external returns (bytes memory, bytes memory) {
|
|
36
|
+
Execution memory exec = openAdminCommand(context, descriptor, 0);
|
|
39
37
|
|
|
40
38
|
while (exec.more()) {
|
|
41
39
|
(uint peer, bytes32 asset, uint amount) = exec.unpackAllowance(Lanes.Input);
|
|
42
40
|
allowance(peer, asset, amount);
|
|
43
41
|
}
|
|
44
42
|
|
|
45
|
-
return
|
|
43
|
+
return closeCommand(exec);
|
|
46
44
|
}
|
|
47
45
|
}
|
|
@@ -16,21 +16,19 @@ abstract contract Annotate is AdminBase {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/// @notice Publish each ANNOTATION block in the admin input.
|
|
19
|
-
/// @param
|
|
19
|
+
/// @param context Admin command context carrying the ANNOTATION input stream.
|
|
20
20
|
/// @return Empty output state.
|
|
21
21
|
/// @return Empty transaction stream.
|
|
22
22
|
function annotate(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
) external onlyAdmin(account) returns (bytes memory, bytes memory) {
|
|
27
|
-
Execution memory exec = openCommand(state, input, descriptor, 0);
|
|
23
|
+
bytes calldata context
|
|
24
|
+
) external returns (bytes memory, bytes memory) {
|
|
25
|
+
Execution memory exec = openAdminCommand(context, descriptor, 0);
|
|
28
26
|
|
|
29
27
|
while (exec.more()) {
|
|
30
28
|
(uint entity, bytes calldata data) = exec.unpackAnnotation(Lanes.Input);
|
|
31
29
|
emit Annotation(entity, data);
|
|
32
30
|
}
|
|
33
31
|
|
|
34
|
-
return
|
|
32
|
+
return closeCommand(exec);
|
|
35
33
|
}
|
|
36
34
|
}
|
|
@@ -17,21 +17,19 @@ abstract contract Appoint is GuardianAccess, AdminBase {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/// @notice Appoint each user ACCOUNT block in the admin input as a guardian.
|
|
20
|
-
/// @param
|
|
20
|
+
/// @param context Admin command context carrying the ACCOUNT input stream.
|
|
21
21
|
/// @return Empty output state.
|
|
22
22
|
/// @return Empty transaction stream.
|
|
23
23
|
function appoint(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
) external onlyAdmin(account) returns (bytes memory, bytes memory) {
|
|
28
|
-
Execution memory exec = openCommand(state, input, descriptor, 0);
|
|
24
|
+
bytes calldata context
|
|
25
|
+
) external returns (bytes memory, bytes memory) {
|
|
26
|
+
Execution memory exec = openAdminCommand(context, descriptor, 0);
|
|
29
27
|
|
|
30
28
|
while (exec.more()) {
|
|
31
29
|
bytes32 guardian = exec.unpackAccount(Lanes.Input);
|
|
32
30
|
setGuardian(guardian, true);
|
|
33
31
|
}
|
|
34
32
|
|
|
35
|
-
return
|
|
33
|
+
return closeCommand(exec);
|
|
36
34
|
}
|
|
37
35
|
}
|
|
@@ -22,21 +22,19 @@ abstract contract Authorize is AdminBase {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/// @notice Authorize each NODE block in the admin input.
|
|
25
|
-
/// @param
|
|
25
|
+
/// @param context Admin command context carrying the NODE input stream.
|
|
26
26
|
/// @return Empty output state.
|
|
27
27
|
/// @return Empty transaction stream.
|
|
28
28
|
function authorize(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
) external onlyAdmin(account) returns (bytes memory, bytes memory) {
|
|
33
|
-
Execution memory exec = openCommand(state, input, descriptor, 0);
|
|
29
|
+
bytes calldata context
|
|
30
|
+
) external returns (bytes memory, bytes memory) {
|
|
31
|
+
Execution memory exec = openAdminCommand(context, descriptor, 0);
|
|
34
32
|
|
|
35
33
|
while (exec.more()) {
|
|
36
34
|
uint node = exec.unpackNode(Lanes.Input);
|
|
37
35
|
setNode(node, true);
|
|
38
36
|
}
|
|
39
37
|
|
|
40
|
-
return
|
|
38
|
+
return closeCommand(exec);
|
|
41
39
|
}
|
|
42
40
|
}
|
package/commands/admin/Base.sol
CHANGED
|
@@ -7,9 +7,18 @@ import {NodeAccess} from "../../core/Access.sol";
|
|
|
7
7
|
/// @title AdminBase
|
|
8
8
|
/// @notice Shared base for admin commands.
|
|
9
9
|
abstract contract AdminBase is NodeAccess, CommandBase {
|
|
10
|
-
/// @
|
|
11
|
-
|
|
10
|
+
/// @notice Decode, authorize, and open one admin command context.
|
|
11
|
+
function openAdminCommand(
|
|
12
|
+
bytes calldata context,
|
|
13
|
+
uint descriptor,
|
|
14
|
+
uint batches
|
|
15
|
+
) internal view returns (Execution memory exec) {
|
|
16
|
+
bytes32 account;
|
|
17
|
+
bytes calldata state;
|
|
18
|
+
bytes calldata input;
|
|
19
|
+
(account, state, input) = unpackCommandContext(context);
|
|
12
20
|
enforceAdmin(account, msg.sender);
|
|
13
|
-
|
|
21
|
+
exec = Executions.open(state, input, descriptor, batches);
|
|
22
|
+
exec.account = account;
|
|
14
23
|
}
|
|
15
24
|
}
|
|
@@ -23,21 +23,19 @@ abstract contract DenyAssets is AdminBase, DenyAssetsHook {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/// @notice Deny each ASSET block in the admin input.
|
|
26
|
-
/// @param
|
|
26
|
+
/// @param context Admin command context carrying the ASSET input stream.
|
|
27
27
|
/// @return Empty output state.
|
|
28
28
|
/// @return Empty transaction stream.
|
|
29
29
|
function denyAssets(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
) external onlyAdmin(account) returns (bytes memory, bytes memory) {
|
|
34
|
-
Execution memory exec = openCommand(state, input, descriptor, 0);
|
|
30
|
+
bytes calldata context
|
|
31
|
+
) external returns (bytes memory, bytes memory) {
|
|
32
|
+
Execution memory exec = openAdminCommand(context, descriptor, 0);
|
|
35
33
|
|
|
36
34
|
while (exec.more()) {
|
|
37
35
|
bytes32 asset = exec.unpackAsset(Lanes.Input);
|
|
38
36
|
denyAsset(asset);
|
|
39
37
|
}
|
|
40
38
|
|
|
41
|
-
return
|
|
39
|
+
return closeCommand(exec);
|
|
42
40
|
}
|
|
43
41
|
}
|
|
@@ -17,21 +17,19 @@ abstract contract Dismiss is GuardianAccess, AdminBase {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/// @notice Dismiss each user ACCOUNT block in the admin input from guardian status.
|
|
20
|
-
/// @param
|
|
20
|
+
/// @param context Admin command context carrying the ACCOUNT input stream.
|
|
21
21
|
/// @return Empty output state.
|
|
22
22
|
/// @return Empty transaction stream.
|
|
23
23
|
function dismiss(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
) external onlyAdmin(account) returns (bytes memory, bytes memory) {
|
|
28
|
-
Execution memory exec = openCommand(state, input, descriptor, 0);
|
|
24
|
+
bytes calldata context
|
|
25
|
+
) external returns (bytes memory, bytes memory) {
|
|
26
|
+
Execution memory exec = openAdminCommand(context, descriptor, 0);
|
|
29
27
|
|
|
30
28
|
while (exec.more()) {
|
|
31
29
|
bytes32 guardian = exec.unpackAccount(Lanes.Input);
|
|
32
30
|
setGuardian(guardian, false);
|
|
33
31
|
}
|
|
34
32
|
|
|
35
|
-
return
|
|
33
|
+
return closeCommand(exec);
|
|
36
34
|
}
|
|
37
35
|
}
|
|
@@ -19,21 +19,19 @@ abstract contract ExecutePayable is RawNodeCalls, AdminBase {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/// @notice Execute each CALL block in the admin input.
|
|
22
|
-
/// @param
|
|
22
|
+
/// @param context Admin command context carrying the CALL input stream.
|
|
23
23
|
/// @return Empty output state.
|
|
24
24
|
/// @return Remaining native value as a refund transaction stream.
|
|
25
25
|
function executePayable(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
) external payable onlyAdmin(account) returns (bytes memory, bytes memory) {
|
|
30
|
-
Execution memory exec = openCommand(state, input, descriptor, 0);
|
|
26
|
+
bytes calldata context
|
|
27
|
+
) external payable returns (bytes memory, bytes memory) {
|
|
28
|
+
Execution memory exec = openAdminCommand(context, descriptor, 0);
|
|
31
29
|
|
|
32
30
|
while (exec.more()) {
|
|
33
31
|
(uint target, uint resources, bytes calldata data) = exec.unpackCall(Lanes.Input);
|
|
34
32
|
rawCall(target, exec.useResourceValue(resources), data);
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
return
|
|
35
|
+
return closeCommand(exec);
|
|
38
36
|
}
|
|
39
37
|
}
|