@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.
Files changed (44) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/Endpoints.sol +2 -3
  3. package/Events.sol +1 -1
  4. package/README.md +13 -11
  5. package/annotations/Action.sol +1 -1
  6. package/annotations/Label.sol +1 -1
  7. package/annotations/Schema.sol +1 -1
  8. package/codec/Blocks.sol +39 -30
  9. package/commands/Allocate.sol +5 -8
  10. package/commands/Base.sol +29 -13
  11. package/commands/Burn.sol +5 -7
  12. package/commands/Credit.sol +5 -7
  13. package/commands/Debit.sol +5 -7
  14. package/commands/Deposit.sol +10 -14
  15. package/commands/Payout.sol +5 -8
  16. package/commands/Provision.sol +10 -14
  17. package/commands/Recover.sol +4 -6
  18. package/commands/Relay.sol +14 -21
  19. package/commands/Repay.sol +10 -14
  20. package/commands/Settle.sol +10 -14
  21. package/commands/Withdraw.sol +5 -7
  22. package/commands/admin/AllowAssets.sol +5 -7
  23. package/commands/admin/Allowance.sol +5 -7
  24. package/commands/admin/Annotate.sol +5 -7
  25. package/commands/admin/Appoint.sol +5 -7
  26. package/commands/admin/Authorize.sol +5 -7
  27. package/commands/admin/Base.sol +12 -3
  28. package/commands/admin/DenyAssets.sol +5 -7
  29. package/commands/admin/Dismiss.sol +5 -7
  30. package/commands/admin/Execute.sol +5 -7
  31. package/commands/admin/Unauthorize.sol +5 -7
  32. package/core/Calls.sol +72 -3
  33. package/core/Portal.sol +2 -2
  34. package/events/Positioned.sol +22 -0
  35. package/execution/Execution.sol +42 -0
  36. package/package.json +1 -1
  37. package/ports/Allowance.sol +22 -12
  38. package/ports/Assets.sol +99 -0
  39. package/utils/Cursors.sol +3 -3
  40. package/utils/Nodes.sol +1 -1
  41. package/utils/Utils.sol +31 -31
  42. package/events/Commander.sol +0 -19
  43. package/ports/AllowAssets.sol +0 -34
  44. package/ports/DenyAssets.sol +0 -34
@@ -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 input AMOUNT block stream.
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
- bytes32 account,
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(state, input, descriptor, 0);
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 close(exec, account);
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 input AMOUNT block stream.
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
- bytes32 account,
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(state, input, descriptor, 0);
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 close(exec, account);
92
+ return closeCommand(exec);
97
93
  }
98
94
  }
@@ -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 state BALANCE block stream.
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
- bytes32 account,
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(state, input, descriptor, 0);
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 close(exec, account);
47
+ return closeCommand(exec);
51
48
  }
52
49
  }
@@ -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 input ALLOCATION block stream.
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
- bytes32 account,
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(state, input, descriptor, 0);
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 close(exec, account);
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 input ALLOCATION block stream.
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
- bytes32 account,
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(state, input, descriptor, 0);
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 close(exec, account);
83
+ return closeCommand(exec);
88
84
  }
89
85
  }
90
86
 
@@ -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 input RECOVER block stream.
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
- bytes32 account,
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(state, input, descriptor, 0);
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 close(exec, account);
51
+ return closeCommand(exec);
54
52
  }
55
53
  }
@@ -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 funds Execution used for source value available for transport fees
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 funds
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
- bytes32 account,
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(state, input, descriptor, 1);
46
- (uint portal, uint resources, bytes calldata relayInput) = exec.unpackRelay(Lanes.Input);
47
- relay(portal, resources, account, state, relayInput, exec);
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 close(exec, account);
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 State forwarded into the destination context.
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
- bytes32 account,
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(state, input, descriptor, 1);
76
- (uint portal, uint resources, bytes calldata relayInput) = exec.unpackRelay(Lanes.Input);
77
- relay(portal, resources, account, state, relayInput, exec);
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 close(exec, account);
72
+ return closeCommand(exec);
80
73
  }
81
74
  }
@@ -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 state POSITION block stream.
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
- bytes32 account,
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(state, input, descriptor, 0);
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 close(exec, account);
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 state POSITION block stream.
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
- bytes32 account,
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(state, input, descriptor, 0);
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 close(exec, account);
77
+ return closeCommand(exec);
82
78
  }
83
79
  }
@@ -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 state POSITION block stream.
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
- bytes32 account,
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(state, input, descriptor, 0);
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 close(exec, account);
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 state POSITION block stream.
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
- bytes32 account,
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(state, input, descriptor, 0);
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 close(exec, account);
92
+ return closeCommand(exec);
97
93
  }
98
94
  }
99
95
 
@@ -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 state BALANCE block stream.
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
- bytes32 account,
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(state, input, descriptor, 0);
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 close(exec, account);
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 input ASSET block stream.
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
- bytes32 account,
31
- bytes calldata state,
32
- bytes calldata input
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 close(exec, account);
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 input ALLOWANCE block stream.
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
- bytes32 account,
35
- bytes calldata state,
36
- bytes calldata input
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 close(exec, account);
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 input ANNOTATION block stream.
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
- bytes32 account,
24
- bytes calldata state,
25
- bytes calldata input
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 close(exec, account);
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 input ACCOUNT block stream.
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
- bytes32 account,
25
- bytes calldata state,
26
- bytes calldata input
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 close(exec, account);
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 input NODE block stream.
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
- bytes32 account,
30
- bytes calldata state,
31
- bytes calldata input
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 close(exec, account);
38
+ return closeCommand(exec);
41
39
  }
42
40
  }
@@ -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
- /// @dev Restrict execution to the commander using the host's admin account.
11
- modifier onlyAdmin(bytes32 account) {
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 input ASSET block stream.
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
- bytes32 account,
31
- bytes calldata state,
32
- bytes calldata input
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 close(exec, account);
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 input ACCOUNT block stream.
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
- bytes32 account,
25
- bytes calldata state,
26
- bytes calldata input
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 close(exec, account);
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 input CALL block stream.
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
- bytes32 account,
27
- bytes calldata state,
28
- bytes calldata input
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 close(exec, account);
35
+ return closeCommand(exec);
38
36
  }
39
37
  }