@@ -4,21 +4,19 @@ import "openzeppelin-eth/contracts/ownership/Ownable.sol";
44
55import "./UFragmentsPolicy.sol " ;
66
7-
87/**
98 * @title Orchestrator
109 * @notice The orchestrator is the main entry point for rebase operations. It coordinates the policy
1110 * actions with external consumers.
1211 */
1312contract Orchestrator is Ownable {
14-
1513 struct Transaction {
1614 bool enabled;
1715 address destination;
1816 bytes data;
1917 }
2018
21- event TransactionFailed (address indexed destination , uint index , bytes data );
19+ event TransactionFailed (address indexed destination , uint256 index , bytes data );
2220
2321 // Stable ordering is not guaranteed.
2422 Transaction[] public transactions;
@@ -41,18 +39,15 @@ contract Orchestrator is Ownable {
4139 * If a transaction in the transaction list reverts, it is swallowed and the remaining
4240 * transactions are executed.
4341 */
44- function rebase ()
45- external
46- {
47- require (msg .sender == tx .origin ); // solhint-disable-line avoid-tx-origin
42+ function rebase () external {
43+ require (msg .sender == tx .origin ); // solhint-disable-line avoid-tx-origin
4844
4945 policy.rebase ();
5046
51- for (uint i = 0 ; i < transactions.length ; i++ ) {
47+ for (uint256 i = 0 ; i < transactions.length ; i++ ) {
5248 Transaction storage t = transactions[i];
5349 if (t.enabled) {
54- bool result =
55- externalCall (t.destination, t.data);
50+ bool result = externalCall (t.destination, t.data);
5651 if (! result) {
5752 emit TransactionFailed (t.destination, i, t.data);
5853 revert ("Transaction Failed " );
@@ -66,25 +61,15 @@ contract Orchestrator is Ownable {
6661 * @param destination Address of contract destination
6762 * @param data Transaction data payload
6863 */
69- function addTransaction (address destination , bytes data )
70- external
71- onlyOwner
72- {
73- transactions.push (Transaction ({
74- enabled: true ,
75- destination: destination,
76- data: data
77- }));
64+ function addTransaction (address destination , bytes data ) external onlyOwner {
65+ transactions.push (Transaction ({enabled: true , destination: destination, data: data}));
7866 }
7967
8068 /**
8169 * @param index Index of transaction to remove.
8270 * Transaction ordering may have changed since adding.
8371 */
84- function removeTransaction (uint index )
85- external
86- onlyOwner
87- {
72+ function removeTransaction (uint256 index ) external onlyOwner {
8873 require (index < transactions.length , "index out of bounds " );
8974
9075 if (index < transactions.length - 1 ) {
@@ -98,22 +83,15 @@ contract Orchestrator is Ownable {
9883 * @param index Index of transaction. Transaction ordering may have changed since adding.
9984 * @param enabled True for enabled, false for disabled.
10085 */
101- function setTransactionEnabled (uint index , bool enabled )
102- external
103- onlyOwner
104- {
86+ function setTransactionEnabled (uint256 index , bool enabled ) external onlyOwner {
10587 require (index < transactions.length , "index must be in range of stored tx list " );
10688 transactions[index].enabled = enabled;
10789 }
10890
10991 /**
11092 * @return Number of transactions, both enabled and disabled, in transactions list.
11193 */
112- function transactionsSize ()
113- external
114- view
115- returns (uint256 )
116- {
94+ function transactionsSize () external view returns (uint256 ) {
11795 return transactions.length ;
11896 }
11997
@@ -123,12 +101,10 @@ contract Orchestrator is Ownable {
123101 * @param data The encoded data payload.
124102 * @return True on success
125103 */
126- function externalCall (address destination , bytes data )
127- internal
128- returns (bool )
129- {
104+ function externalCall (address destination , bytes data ) internal returns (bool ) {
130105 bool result;
131- assembly { // solhint-disable-line no-inline-assembly
106+ assembly {
107+ // solhint-disable-line no-inline-assembly
132108 // "Allocate" memory for output
133109 // (0x40 is where "free memory" pointer is stored by convention)
134110 let outputAddress := mload (0x40 )
@@ -142,14 +118,12 @@ contract Orchestrator is Ownable {
142118 // + callValueTransferGas (9000) + callNewAccountGas
143119 // (25000, in case the destination address does not exist and needs creating)
144120 sub (gas, 34710 ),
145-
146-
147121 destination,
148122 0 , // transfer value in wei
149123 dataAddress,
150- mload (data), // Size of the input, in bytes. Stored in position 0 of the array.
124+ mload (data), // Size of the input, in bytes. Stored in position 0 of the array.
151125 outputAddress,
152- 0 // Output is ignored, therefore the output size is zero
126+ 0 // Output is ignored, therefore the output size is zero
153127 )
154128 }
155129 return result;
0 commit comments