Skip to content

Commit 8b15be9

Browse files
committed
fixes #19
1 parent cd420bc commit 8b15be9

File tree

6 files changed

+67
-45
lines changed

6 files changed

+67
-45
lines changed

contracts/_utilities/BatchTxExecutor.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// SPDX-License-Identifier: GPL-3.0-or-later
22
pragma solidity 0.6.12;
33

4-
import "@openzeppelin/contracts/math/SafeMath.sol";
5-
import "@openzeppelin/contracts/access/Ownable.sol";
4+
import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol";
5+
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
66

77
/**
88
* @title BatchTxExecutor

contracts/base-chain/TokenVault.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// SPDX-License-Identifier: GPL-3.0-or-later
22
pragma solidity 0.6.12;
33

4-
import "@openzeppelin/contracts/access/Ownable.sol";
5-
import "@openzeppelin/contracts/math/SafeMath.sol";
6-
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
4+
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
5+
import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol";
6+
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
77

88
/**
99
* @title TokenVault
@@ -108,7 +108,7 @@ contract TokenVault is Ownable {
108108
/**
109109
* @notice Total token balance secured by the gateway contract.
110110
*/
111-
function totalLocked(address token) public view returns (uint256) {
111+
function totalLocked(address token) external view returns (uint256) {
112112
return IERC20(token).balanceOf(address(this));
113113
}
114114
}

contracts/base-chain/bridge-gateways/AMPLChainBridgeGateway.sol

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
// SPDX-License-Identifier: GPL-3.0-or-later
22
pragma solidity 0.6.12;
33

4-
import "@openzeppelin/contracts/access/Ownable.sol";
5-
import "@openzeppelin/contracts/math/SafeMath.sol";
6-
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
7-
import "../../_interfaces/IAmpleforthPolicy.sol";
8-
import "../../_interfaces/ITokenVault.sol";
9-
import "../../_interfaces/IBridgeGateway.sol";
4+
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
5+
import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol";
6+
7+
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
8+
import {IAmpleforthPolicy} from "../../_interfaces/IAmpleforthPolicy.sol";
9+
import {ITokenVault} from "../../_interfaces/ITokenVault.sol";
10+
import {IBridgeGateway} from "../../_interfaces/IBridgeGateway.sol";
1011

1112
/**
1213
* @title AMPLChainBridgeGateway: AMPL-ChainBridge Gateway Contract
@@ -48,7 +49,7 @@ contract AMPLChainBridgeGateway is IBridgeGateway, Ownable {
4849
* @param globalAMPLSupply AMPL ERC-20 total supply.
4950
*/
5051
function validateRebaseReport(uint256 globalAmpleforthEpoch, uint256 globalAMPLSupply)
51-
public
52+
external
5253
onlyOwner
5354
returns (bool)
5455
{
@@ -82,7 +83,7 @@ contract AMPLChainBridgeGateway is IBridgeGateway, Ownable {
8283
address recipientAddressInTargetChain,
8384
uint256 amount,
8485
uint256 globalAMPLSupply
85-
) public onlyOwner returns (bool) {
86+
) external onlyOwner returns (bool) {
8687
uint256 recordedGlobalAMPLSupply = IERC20(ampl).totalSupply();
8788

8889
require(
@@ -110,7 +111,7 @@ contract AMPLChainBridgeGateway is IBridgeGateway, Ownable {
110111
address recipient,
111112
uint256 amount,
112113
uint256 globalAMPLSupply
113-
) public onlyOwner returns (bool) {
114+
) external onlyOwner returns (bool) {
114115
uint256 recordedGlobalAMPLSupply = IERC20(ampl).totalSupply();
115116
uint256 unlockAmount = amount.mul(recordedGlobalAMPLSupply).div(globalAMPLSupply);
116117

contracts/satellite-chain/bridge-gateways/ChainBridgeXCAmpleGateway.sol

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
// SPDX-License-Identifier: GPL-3.0-or-later
22
pragma solidity 0.6.12;
33

4-
import "@openzeppelin/contracts/access/Ownable.sol";
5-
import "@openzeppelin/contracts/math/SafeMath.sol";
6-
import "../../_interfaces/IBridgeGateway.sol";
7-
import "../../_interfaces/IXCAmpleController.sol";
8-
import "../../_interfaces/IXCAmple.sol";
4+
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
5+
import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol";
6+
7+
import {IBridgeGateway} from "../../_interfaces/IBridgeGateway.sol";
8+
import {IXCAmpleController} from "../../_interfaces/IXCAmpleController.sol";
9+
import {IXCAmple} from "../../_interfaces/IXCAmple.sol";
910

1011
/**
1112
* @title ChainBridgeXCAmpleGateway

contracts/satellite-chain/xc-ampleforth/XCAmple.sol

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
// SPDX-License-Identifier: GPL-3.0-or-later
22
pragma solidity 0.6.12;
33

4-
import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol";
5-
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
6-
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
4+
import {
5+
SafeMathUpgradeable
6+
} from "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol";
7+
import {
8+
IERC20Upgradeable
9+
} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
10+
import {
11+
OwnableUpgradeable
12+
} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
713

814
/**
915
* @title XC(cross-chain)Ample ERC20 token
@@ -80,6 +86,7 @@ contract XCAmple is IERC20Upgradeable, OwnableUpgradeable {
8086

8187
/**
8288
* @dev XCAmpleController notifies this contract about a new rebase cycle.
89+
* @param epoch The rebase epoch number.
8390
* @param newGlobalAMPLSupply The new total supply of AMPL from the base chain.
8491
* @return The new total AMPL supply.
8592
*/
@@ -128,15 +135,15 @@ contract XCAmple is IERC20Upgradeable, OwnableUpgradeable {
128135
/**
129136
* @dev Returns the name of the token.
130137
*/
131-
function name() public view returns (string memory) {
138+
function name() external view returns (string memory) {
132139
return _name;
133140
}
134141

135142
/**
136143
* @dev Returns the symbol of the token, usually a shorter version of the
137144
* name.
138145
*/
139-
function symbol() public view returns (string memory) {
146+
function symbol() external view returns (string memory) {
140147
return _symbol;
141148
}
142149

@@ -149,22 +156,22 @@ contract XCAmple is IERC20Upgradeable, OwnableUpgradeable {
149156
* no way affects any of the arithmetic of the contract, including
150157
* {IERC20-balanceOf} and {IERC20-transfer}.
151158
*/
152-
function decimals() public view returns (uint8) {
159+
function decimals() external view returns (uint8) {
153160
return _decimals;
154161
}
155162

156163
/**
157164
* @return The total supply of xcAmples.
158165
*/
159-
function totalSupply() public view override returns (uint256) {
166+
function totalSupply() external view override returns (uint256) {
160167
return _totalSupply;
161168
}
162169

163170
/**
164171
* @param who The address to query.
165172
* @return The balance of the specified address.
166173
*/
167-
function balanceOf(address who) public view override returns (uint256) {
174+
function balanceOf(address who) external view override returns (uint256) {
168175
return _gonBalances[who].div(_gonsPerAMPL);
169176
}
170177

@@ -174,7 +181,12 @@ contract XCAmple is IERC20Upgradeable, OwnableUpgradeable {
174181
* @param value The amount to be transferred.
175182
* @return True on success, false otherwise.
176183
*/
177-
function transfer(address to, uint256 value) public override validRecipient(to) returns (bool) {
184+
function transfer(address to, uint256 value)
185+
external
186+
override
187+
validRecipient(to)
188+
returns (bool)
189+
{
178190
uint256 gonValue = value.mul(_gonsPerAMPL);
179191
_gonBalances[msg.sender] = _gonBalances[msg.sender].sub(gonValue);
180192
_gonBalances[to] = _gonBalances[to].add(gonValue);
@@ -188,7 +200,7 @@ contract XCAmple is IERC20Upgradeable, OwnableUpgradeable {
188200
* @param spender The address which will spend the funds.
189201
* @return The number of tokens still available for the spender.
190202
*/
191-
function allowance(address owner_, address spender) public view override returns (uint256) {
203+
function allowance(address owner_, address spender) external view override returns (uint256) {
192204
return _allowedXCAmples[owner_][spender];
193205
}
194206

@@ -202,7 +214,7 @@ contract XCAmple is IERC20Upgradeable, OwnableUpgradeable {
202214
address from,
203215
address to,
204216
uint256 value
205-
) public override validRecipient(to) returns (bool) {
217+
) external override validRecipient(to) returns (bool) {
206218
_allowedXCAmples[from][msg.sender] = _allowedXCAmples[from][msg.sender].sub(value);
207219

208220
uint256 gonValue = value.mul(_gonsPerAMPL);
@@ -224,7 +236,7 @@ contract XCAmple is IERC20Upgradeable, OwnableUpgradeable {
224236
* @param spender The address which will spend the funds.
225237
* @param value The amount of tokens to be spent.
226238
*/
227-
function approve(address spender, uint256 value) public override returns (bool) {
239+
function approve(address spender, uint256 value) external override returns (bool) {
228240
_allowedXCAmples[msg.sender][spender] = value;
229241
emit Approval(msg.sender, spender, value);
230242
return true;
@@ -237,7 +249,7 @@ contract XCAmple is IERC20Upgradeable, OwnableUpgradeable {
237249
* @param spender The address which will spend the funds.
238250
* @param addedValue The amount of tokens to increase the allowance by.
239251
*/
240-
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
252+
function increaseAllowance(address spender, uint256 addedValue) external returns (bool) {
241253
_allowedXCAmples[msg.sender][spender] = _allowedXCAmples[msg.sender][spender].add(
242254
addedValue
243255
);
@@ -251,7 +263,7 @@ contract XCAmple is IERC20Upgradeable, OwnableUpgradeable {
251263
* @param spender The address which will spend the funds.
252264
* @param subtractedValue The amount of tokens to decrease the allowance by.
253265
*/
254-
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
266+
function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool) {
255267
uint256 oldValue = _allowedXCAmples[msg.sender][spender];
256268
if (subtractedValue >= oldValue) {
257269
_allowedXCAmples[msg.sender][spender] = 0;
@@ -268,7 +280,7 @@ contract XCAmple is IERC20Upgradeable, OwnableUpgradeable {
268280
* @param who The address of the beneficiary.
269281
* @param xcAmpleAmount The amount of xcAmple tokens to be minted.
270282
*/
271-
function mint(address who, uint256 xcAmpleAmount) public onlyController validRecipient(who) {
283+
function mint(address who, uint256 xcAmpleAmount) external onlyController validRecipient(who) {
272284
uint256 gonValue = xcAmpleAmount.mul(_gonsPerAMPL);
273285
_gonBalances[who] = _gonBalances[who].add(gonValue);
274286
_totalSupply = _totalSupply.add(xcAmpleAmount);
@@ -285,7 +297,7 @@ contract XCAmple is IERC20Upgradeable, OwnableUpgradeable {
285297
* @param who The address of the beneficiary.
286298
* @param xcAmpleAmount The amount of xcAmple tokens to be burned.
287299
*/
288-
function burn(address who, uint256 xcAmpleAmount) public onlyController {
300+
function burn(address who, uint256 xcAmpleAmount) external onlyController {
289301
require(who != address(0), "XCAmple: burn address zero address");
290302

291303
uint256 gonValue = xcAmpleAmount.mul(_gonsPerAMPL);

contracts/satellite-chain/xc-ampleforth/XCAmpleController.sol

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
// SPDX-License-Identifier: GPL-3.0-or-later
22
pragma solidity 0.6.12;
33

4-
import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol";
5-
import "@openzeppelin/contracts-upgradeable/math/SignedSafeMathUpgradeable.sol";
6-
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
7-
8-
import "./UInt256Lib.sol";
9-
import "../../_interfaces/IXCAmple.sol";
10-
import "../../_interfaces/IBatchTxExecutor.sol";
4+
import {
5+
SafeMathUpgradeable
6+
} from "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol";
7+
import {
8+
SignedSafeMathUpgradeable
9+
} from "@openzeppelin/contracts-upgradeable/math/SignedSafeMathUpgradeable.sol";
10+
import {
11+
OwnableUpgradeable
12+
} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
13+
14+
import {UInt256Lib} from "./UInt256Lib.sol";
15+
import {IXCAmple} from "../../_interfaces/IXCAmple.sol";
16+
import {IBatchTxExecutor} from "../../_interfaces/IBatchTxExecutor.sol";
1117

1218
/**
1319
* @title XC(Cross-Chain)Ample Controller
@@ -151,7 +157,7 @@ contract XCAmpleController is OwnableUpgradeable {
151157
* After rebase, it notifies down-stream platforms by executing post-rebase callbacks
152158
* on the rebase relayer.
153159
*/
154-
function rebase() public {
160+
function rebase() external {
155161
// recently reported epoch needs to be more than current globalEpoch in storage
156162
require(
157163
nextGlobalAmpleforthEpoch > globalAmpleforthEpoch,
@@ -184,8 +190,10 @@ contract XCAmpleController is OwnableUpgradeable {
184190
* @dev ZOS upgradable contract initialization method.
185191
* It is called at the time of contract creation to invoke parent class initializers and
186192
* initialize the contract's state variables.
193+
* @param xcAmple_ reference to the cross-chain ample token erc-20 contract
194+
* @param globalAmpleforthEpoch_ the epoch number from monetary policy on the base chain
187195
*/
188-
function initialize(address xcAmple_, uint256 globalAmpleforthEpoch_) public initializer {
196+
function initialize(address xcAmple_, uint256 globalAmpleforthEpoch_) external initializer {
189197
__Ownable_init();
190198

191199
xcAmple = xcAmple_;

0 commit comments

Comments
 (0)