Skip to content

Commit 22bdacc

Browse files
committed
stage changes as js
1 parent c1d8edd commit 22bdacc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+12657
-26191
lines changed

.coveralls.yml

Lines changed: 0 additions & 2 deletions
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 67 deletions
This file was deleted.

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,10 @@ scDebugLog
7272
coverage.json
7373
coverage/
7474
coverageEnv/
75+
76+
node_modules
77+
78+
#Buidler files
79+
cache
80+
artifacts
81+
.openzeppelin

.prettierrc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"semi": false,
3+
"trailingComma": "all",
4+
"singleQuote": true,
5+
"bracketSpacing": true,
6+
"printWidth": 80,
7+
"overrides": [
8+
{
9+
"files": "*.sol",
10+
"options": {
11+
"printWidth": 100,
12+
"tabWidth": 4,
13+
"useTabs": false,
14+
"singleQuote": false,
15+
"bracketSpacing": false,
16+
"explicitTypes": "always"
17+
}
18+
}
19+
]
20+
}

.solcover.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
const _require = require('app-root-path').require;
2-
const config = _require('/truffle.js').networks.testrpcCoverage;
3-
41
module.exports = {
5-
host: config.host,
6-
network_id: config.network_id,
7-
port: config.port,
8-
gas: config.gas,
9-
gasPrice: config.gasPrice,
10-
norpc: true,
11-
testCommand: 'npx truffle test ./test/unit/*.js',
12-
compileCommand: 'npx truffle compile',
13-
skipFiles: ['mocks'],
14-
copyPackages: ['openzeppelin-eth'],
15-
};
2+
skipFiles: ['mocks'],
3+
}

.solhint.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"extends": "default",
3-
"rules": {
4-
"not-rely-on-time": [false],
5-
"no-simple-event-func-name": [false],
6-
"indent": ["warn", 4],
7-
"max-line-length": ["error", 100]
8-
}
2+
"extends": "solhint:default",
3+
"plugins": ["prettier"],
4+
"rules": {
5+
"prettier/prettier": "error",
6+
"not-rely-on-time": "off",
7+
"max-line-length": ["error", 100]
8+
}
99
}

.travis.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,15 @@ dist: trusty
22
sudo: required
33
language: node_js
44
node_js:
5-
- "8"
5+
- '12'
66
cache:
77
directories:
88
- node_modules
9-
- $(npm config get prefix)/bin/ganache-cli
10-
before_install:
11-
- npm install -g npm@6.4.1 # Locking npm to 6.4.1
12-
- npm install -g npx
139
script:
14-
- ./scripts/setup-ci.sh
15-
- npm run lint
16-
- npm run test
17-
- npm run coverage
10+
- yarn format
11+
- yarn lint
12+
- yarn test
13+
- yarn coverage
1814
after_success:
1915
- cat coverage/lcov.info | npx coveralls
2016
notifications:

README.md

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Ampleforth (code name uFragments) is a decentralized elastic supply protocol. It
77
This repository is a collection of [smart contracts](http://ampleforth.org/docs) that implement the Ampleforth protocol on the Ethereum blockchain.
88

99
The official mainnet addresses are:
10+
1011
- ERC-20 Token: [0xD46bA6D942050d489DBd938a2C909A5d5039A161](https://etherscan.io/token/0xd46ba6d942050d489dbd938a2c909a5d5039a161)
1112
- Supply Policy: [0x1B228a749077b8e307C5856cE62Ef35d96Dca2ea](https://etherscan.io/address/0x1b228a749077b8e307c5856ce62ef35d96dca2ea)
1213
- Orchestrator: [0x6fb00a180781e75f87e2b690af0196baa77c7e7c](https://etherscan.io/address/0x6fb00a180781e75f87e2b690af0196baa77c7e7c)
@@ -21,32 +22,24 @@ The official mainnet addresses are:
2122
- [Contribute](#contribute)
2223
- [License](#license)
2324

24-
2525
## Install
2626

2727
```bash
2828
# Install project dependencies
29-
npm install
30-
31-
# Install ethereum local blockchain(s) and associated dependencies
32-
npx setup-local-chains
29+
yarn
3330
```
3431

3532
## Testing
3633

37-
``` bash
38-
# You can use the following command to start a local blockchain instance
39-
npx start-chain [ganacheUnitTest|gethUnitTest]
40-
41-
# Run all unit tests
42-
npm test
43-
44-
# Run unit tests in isolation
45-
npx truffle --network ganacheUnitTest test test/unit/uFragments.js
34+
```bash
35+
# Run all unit tests (compatible with node v12+)
36+
yarn test
4637
```
4738

4839
## Testnets
40+
4941
There is a testnet deployment on Rinkeby. It rebases hourly using real market data.
42+
5043
- ERC-20 Token: [0x027dbcA046ca156De9622cD1e2D907d375e53aa7](https://rinkeby.etherscan.io/token/0x027dbcA046ca156De9622cD1e2D907d375e53aa7)
5144
- Supply Policy: [0x1D2771AFC894107c4edc072e3bd15Cb7F1BCC007](https://rinkeby.etherscan.io/address/0x1D2771AFC894107c4edc072e3bd15Cb7F1BCC007)
5245
- Orchestrator: [0xF473604Be74A69a6bB4ebED33A91a291f6C5b5DE](https://rinkeby.etherscan.io/address/0xF473604Be74A69a6bB4ebED33A91a291f6C5b5DE)
@@ -59,12 +52,15 @@ To report bugs within this package, create an issue in this repository.
5952
For security issues, please contact dev-support@ampleforth.org.
6053
When submitting code ensure that it is free of lint errors and has 100% test coverage.
6154

62-
``` bash
55+
```bash
6356
# Lint code
64-
npm run lint
57+
yarn lint
58+
59+
# Format code
60+
yarn format
6561

66-
# View code coverage
67-
npm run coverage
62+
# Run solidity coverage report (compatible with node v12)
63+
yarn coverage
6864
```
6965

7066
## License

buidler.config.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { usePlugin, BuidlerConfig } from '@nomiclabs/buidler/config'
2+
3+
usePlugin('@nomiclabs/buidler-ethers')
4+
usePlugin('@nomiclabs/buidler-waffle')
5+
usePlugin('@openzeppelin/buidler-upgrades')
6+
usePlugin('solidity-coverage')
7+
8+
require('./scripts/deploy')
9+
10+
export default {
11+
solc: {
12+
version: '0.4.24',
13+
},
14+
mocha: {
15+
timeout: 100000,
16+
},
17+
} as BuidlerConfig

contracts/Orchestrator.sol

Lines changed: 15 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,19 @@ import "openzeppelin-eth/contracts/ownership/Ownable.sol";
44

55
import "./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
*/
1312
contract 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

Comments
 (0)