Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Develop into Master #34

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
e281868
Adding a backup folder called mainnet for build artifacts to separate…
Ryanmtate Sep 18, 2018
6ee38f8
Update migrations scripts to separate files
Ryanmtate Oct 22, 2018
284dbb1
Reverted back to 0.4.24;
Ryanmtate Oct 22, 2018
1333896
WIP: Adding a Stable Coin swap contract for converting trusted stable…
Ryanmtate Oct 29, 2018
2d14bb4
Adding StableSwap contract; TODO decimal normalization
Ryanmtate Oct 29, 2018
68e2272
Add fee params per asset for stable swap contract; add natspec
Ryanmtate Oct 31, 2018
641094f
Merge pull request #36 from tokenio/stable_swap
Ryanmtate Oct 31, 2018
60d3621
Deployed TokenIOStableSwap w/ unit tests checking convert method in b…
Ryanmtate Nov 2, 2018
d1abd47
Added an ERC20 contract that includes fees; Gas costs for transfers a…
Ryanmtate Nov 8, 2018
e5784e2
Bypass forceTransfer() method in library and directly update storage …
Ryanmtate Nov 15, 2018
1d5b3cc
configs update
vlad-kostanda Dec 18, 2018
8516810
Storage improvement by making it more specific
vlad-kostanda Dec 18, 2018
78ea975
breaking transfer test. need investigation
vlad-kostanda Dec 18, 2018
745bf71
minor updates to correspond to new fee parameters format
vlad-kostanda Dec 18, 2018
df3b83c
1. updates to balance storage and mappings order; 2. logging transfer…
vlad-kostanda Jan 23, 2019
fabaa99
fix issue with forceTransfer in TokenIOLib
RostyslavBortman Jan 24, 2019
c7ceb89
oprimize set params functiom, created struct in storage
RostyslavBortman Jan 25, 2019
5ed7a55
optimized transger/transfer from functions
RostyslavBortman Jan 25, 2019
04aff17
optimized transfer/transferFrom functions in TokenIOERC20FeesApply
RostyslavBortman Jan 27, 2019
baceec3
optimization fixes
RostyslavBortman Jan 27, 2019
46e3f90
add comments
RostyslavBortman Jan 28, 2019
0e7145e
add tests and delete functions
RostyslavBortman Jan 29, 2019
f55e0aa
fix code before PR
RostyslavBortman Jan 30, 2019
78b24f6
fix code before meeting
RostyslavBortman Jan 30, 2019
14069f3
fix formatting
RostyslavBortmanAdoria Feb 1, 2019
6130966
remove excess
RostyslavBortmanAdoria Feb 1, 2019
11ea966
Merge pull request #40 from adoriasoft/fees_apply
Ryanmtate Feb 4, 2019
a47f73a
apply optimization changes for all contracts
RostyslavBortmanAdoria Feb 10, 2019
6d7f470
Merge pull request #2 from adoriasoft/fees_apply_dev2
vlad-kostanda Feb 10, 2019
f21b784
fix bug with fxUSDBPSRate parameter
RostyslavBortmanAdoria Feb 10, 2019
182257d
add comments to constructor
RostyslavBortmanAdoria Feb 10, 2019
d31cbf0
fees_apply_solidityVersionMigration
RostyslavBortmanAdoria Feb 10, 2019
d4164e3
solidity version migration
RostyslavBortmanAdoria Feb 11, 2019
191b4f8
Merge pull request #3 from adoriasoft/fees_apply_solidityVersionMigra…
vlad-kostanda Feb 12, 2019
5c0d72f
add proxy
RostyslavBortmanAdoria Feb 16, 2019
ed2fb5f
adding proxies
RostyslavBortmanAdoria Feb 19, 2019
8360ce9
fix compilation errors
RostyslavBortmanAdoria Feb 19, 2019
799dc45
update proxy contract
RostyslavBortmanAdoria Feb 20, 2019
e76b813
add upgrade function
RostyslavBortmanAdoria Feb 20, 2019
e090dbb
change tests for proxies
RostyslavBortmanAdoria Feb 27, 2019
a63b9f1
fixes in proxy implementation + tests
RostyslavBortmanAdoria Mar 2, 2019
84edbde
tests added
RostyslavBortmanAdoria Mar 5, 2019
ed1dafd
Merge pull request #38 from tokenio/fees_apply
Ryanmtate Mar 6, 2019
885258a
Merge pull request #4 from adoriasoft/fees_apply_dev_proxy
RostyslavBortmanAdoria Mar 6, 2019
c8ea85d
remove excess
RostyslavBortmanAdoria Mar 6, 2019
df35f92
Merge pull request #41 from adoriasoft/fees_apply
Ryanmtate Mar 8, 2019
936e5f0
Merge pull request #44 from tokenio/fees_apply
Ryanmtate Mar 21, 2019
c6ca884
Update compiler settings
Ryanmtate Mar 21, 2019
7346eb6
Merge pull request #45 from tokenio/feature/update_compiler_settings
Ryanmtate Mar 21, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions contracts/ERC20Interface.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
pragma solidity 0.5.2;

/**
* @title ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/20
* @notice interface contract from Zeppelin token erc20;
*/
interface ERC20Interface {
function totalSupply() external view returns (uint256);

function decimals() external view returns (uint256);

function balanceOf(address who) external view returns (uint256);

function allowance(address owner, address spender)
external view returns (uint256);

function transfer(address to, uint256 value) external returns (bool);

function approve(address spender, uint256 value)
external returns (bool);

function transferFrom(address from, address to, uint256 value)
external returns (bool);

event Transfer(
address indexed from,
address indexed to,
uint256 value
);

event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
2 changes: 1 addition & 1 deletion contracts/Migrations.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.4.24;
pragma solidity 0.5.2;

contract Migrations {
address public owner;
Expand Down
2 changes: 1 addition & 1 deletion contracts/Ownable.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.4.24;
pragma solidity 0.5.2;



Expand Down
2 changes: 1 addition & 1 deletion contracts/SafeMath.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.4.24;
pragma solidity 0.5.2;


/**
Expand Down
23 changes: 16 additions & 7 deletions contracts/TokenIOAuthority.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.4.24;
pragma solidity 0.5.2;

/*
COPYRIGHT 2018 Token, Inc.
Expand Down Expand Up @@ -31,6 +31,8 @@ contract TokenIOAuthority is Ownable {
using TokenIOLib for TokenIOLib.Data;
TokenIOLib.Data lib;

address public proxyInstance;

/**
* @notice Constructor method for Authority contract
* @param _storageContract Ethereum Address of TokenIOStorage contract
Expand All @@ -48,13 +50,20 @@ contract TokenIOAuthority is Ownable {
owner[msg.sender] = true;
}

function initProxy(address _proxy) public onlyOwner {
require(_proxy != address(0));

proxyInstance = _proxy;
lib.proxyInstance = _proxy;
}

/**
* @notice Registers a firm as authorized true/false
* @param firmName Name of firm
* @param _authorized Authorization status
* @return {"success" : "Returns true if lib.setRegisteredFirm succeeds"}
*/
function setRegisteredFirm(string firmName, bool _authorized) public onlyAuthority(firmName, msg.sender) returns (bool success) {
function setRegisteredFirm(string memory firmName, bool _authorized, address sender) public onlyAuthority(firmName, sender) returns (bool success) {
/// @notice set firm registration status
require(
lib.setRegisteredFirm(firmName, _authorized),
Expand All @@ -70,7 +79,7 @@ contract TokenIOAuthority is Ownable {
* @param _authorized Authorization status
* @return {"success" : "Returns true if lib.setRegisteredAuthority succeeds"}
*/
function setRegisteredAuthority(string firmName, address authority, bool _authorized) public onlyAuthority(firmName, msg.sender) returns (bool success) {
function setRegisteredAuthority(string memory firmName, address authority, bool _authorized, address sender) public onlyAuthority(firmName, sender) returns (bool success) {
/// @notice set authority of firm to given status
require(
lib.setRegisteredAuthority(firmName, authority, _authorized),
Expand All @@ -84,7 +93,7 @@ contract TokenIOAuthority is Ownable {
* @param authority Address of authority account
* @return {"firm" : "name of firm"}
*/
function getFirmFromAuthority(address authority) public view returns (string firm) {
function getFirmFromAuthority(address authority) public view returns (string memory firm) {
return lib.getFirmFromAuthority(authority);
}

Expand All @@ -93,7 +102,7 @@ contract TokenIOAuthority is Ownable {
* @param firmName Name of firm
* @return {"status" : "Returns status of firm registration"}
*/
function isRegisteredFirm(string firmName) public view returns (bool status) {
function isRegisteredFirm(string memory firmName) public view returns (bool status) {
/// @notice check firm's registration status
return lib.isRegisteredFirm(firmName);
}
Expand All @@ -104,7 +113,7 @@ contract TokenIOAuthority is Ownable {
* @param authority Address of authority account
* @return {"registered" : "Returns status of account registration to firm"}
*/
function isRegisteredToFirm(string firmName, address authority) public view returns (bool registered) {
function isRegisteredToFirm(string memory firmName, address authority) public view returns (bool registered) {
/// @notice check if registered to firm
return lib.isRegisteredToFirm(firmName, authority);
}
Expand Down Expand Up @@ -134,7 +143,7 @@ contract TokenIOAuthority is Ownable {
}


modifier onlyAuthority(string firmName, address authority) {
modifier onlyAuthority(string memory firmName, address authority) {
/// @notice throws if not an owner authority or not registered to the given firm
require(owner[authority] || lib.isRegisteredToFirm(firmName, authority),
"Error: Transaction sender does not have permission for this operation!"
Expand Down
84 changes: 84 additions & 0 deletions contracts/TokenIOAuthorityProxy.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
pragma solidity 0.5.2;

import "./Ownable.sol";

interface TokenIOAuthorityI {
function setRegisteredFirm(string calldata firmName, bool _authorized, address sender) external returns (bool success);

function setRegisteredAuthority(string calldata firmName, address authority, bool _authorized, address sender) external returns (bool success);

function getFirmFromAuthority(address authority) external view returns (string memory firm);

function isRegisteredFirm(string calldata firmName) external view returns (bool status);

function isRegisteredToFirm(string calldata firmName, address authority) external view returns (bool registered);

function isRegisteredAuthority(address authority) external view returns (bool registered);

function setMasterFeeContract(address feeContract) external returns (bool success);
}

contract TokenIOAuthorityProxy is Ownable {

address implementationInstance;

constructor(address _tokenIOAuthorityImpl) public {
implementationInstance = _tokenIOAuthorityImpl;
}

function upgradeTo(address _newTokenIOAuthorityImpl) onlyOwner external {
require(_newTokenIOAuthorityImpl != address(0));
implementationInstance = _newTokenIOAuthorityImpl;
}

function staticCall(bytes calldata payload) external view returns(bytes memory) {
(bool res, bytes memory result) = implementationInstance.staticcall(payload);
return result;
}

function call(bytes calldata payload) external {
(bool res, bytes memory result) = implementationInstance.call(payload);
require(res);
}

function setRegisteredFirm(string memory firmName, bool _authorized) public returns (bool success) {
require(
TokenIOAuthorityI(implementationInstance).setRegisteredFirm(firmName, _authorized, msg.sender),
"Unable to execute setRegisteredFirm"
);
return true;
}

function setRegisteredAuthority(string memory firmName, address authority, bool _authorized) public returns (bool success) {
require(
TokenIOAuthorityI(implementationInstance).setRegisteredAuthority(firmName, authority, _authorized, msg.sender),
"Unable to execute setRegisteredFirm"
);
return true;
}

function getFirmFromAuthority(address authority) public view returns (string memory firm) {
return TokenIOAuthorityI(implementationInstance).getFirmFromAuthority(authority);
}

function isRegisteredFirm(string memory firmName) public view returns (bool status) {
return TokenIOAuthorityI(implementationInstance).isRegisteredFirm(firmName);
}

function isRegisteredToFirm(string memory firmName, address authority) public view returns (bool registered) {
return TokenIOAuthorityI(implementationInstance).isRegisteredToFirm(firmName, authority);
}

function isRegisteredAuthority(address authority) public view returns (bool registered) {
return TokenIOAuthorityI(implementationInstance).isRegisteredAuthority(authority);
}

function setMasterFeeContract(address feeContract) public onlyOwner returns (bool success) {
require(
TokenIOAuthorityI(implementationInstance).setMasterFeeContract(feeContract),
"Unable to execute setMasterFeeContract"
);
return true;
}

}
35 changes: 22 additions & 13 deletions contracts/TokenIOCurrencyAuthority.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.4.24;
pragma solidity 0.5.2;

import "./Ownable.sol";
import "./TokenIOStorage.sol";
Expand Down Expand Up @@ -29,6 +29,8 @@ contract TokenIOCurrencyAuthority is Ownable {
using TokenIOLib for TokenIOLib.Data;
TokenIOLib.Data lib;

address public proxyInstance;

/**
* @notice Constructor method for CurrencyAuthority contract
* @param _storageContract Address of TokenIOStorage contract
Expand All @@ -45,13 +47,20 @@ contract TokenIOCurrencyAuthority is Ownable {
owner[msg.sender] = true;
}

function initProxy(address _proxy) public onlyOwner {
require(_proxy != address(0));

proxyInstance = _proxy;
lib.proxyInstance = _proxy;
}

/**
* @notice Gets balance of sepcified account for a given currency
* @param currency Currency symbol 'USDx'
* @param account Sepcified account address
* @return { "balance": "Returns account balance"}
*/
function getTokenBalance(string currency, address account) public view returns (uint balance) {
function getTokenBalance(string memory currency, address account) public view returns (uint balance) {
return lib.getTokenBalance(currency, account);
}

Expand All @@ -60,7 +69,7 @@ contract TokenIOCurrencyAuthority is Ownable {
* @param currency Currency symbol 'USDx'
* @return { "supply": "Returns total supply of currency"}
*/
function getTokenSupply(string currency) public view returns (uint supply) {
function getTokenSupply(string memory currency) public view returns (uint supply) {
return lib.getTokenSupply(currency);
}

Expand All @@ -71,7 +80,7 @@ contract TokenIOCurrencyAuthority is Ownable {
* @param issuerFirm Name of the issuer firm with authority on account holder;
* @return { "success": "Returns true if successfully called from another contract"}
*/
function freezeAccount(address account, bool isAllowed, string issuerFirm) public onlyAuthority(issuerFirm, msg.sender) returns (bool success) {
function freezeAccount(address account, bool isAllowed, string memory issuerFirm, address sender) public onlyAuthority(issuerFirm, sender) returns (bool success) {
// @notice updates account status
// @dev !!! mutates storage state
require(
Expand All @@ -88,7 +97,7 @@ contract TokenIOCurrencyAuthority is Ownable {
* @param issuerFirm Name of the issuer firm with authority on account holder;
* @return { "success": "Returns true if successfully called from another contract"}
*/
function approveKYC(address account, bool isApproved, uint limit, string issuerFirm) public onlyAuthority(issuerFirm, msg.sender) returns (bool success) {
function approveKYC(address account, bool isApproved, uint limit, string memory issuerFirm, address sender) public onlyAuthority(issuerFirm, sender) returns (bool success) {
// @notice updates kyc approval status
// @dev !!! mutates storage state
require(
Expand Down Expand Up @@ -120,7 +129,7 @@ contract TokenIOCurrencyAuthority is Ownable {
* @param issuerFirm Name of the issuer firm with authority on account holder;
* @return { "success": "Returns true if successfully called from another contract"}
*/
function approveKYCAndDeposit(string currency, address account, uint amount, uint limit, string issuerFirm) public onlyAuthority(issuerFirm, msg.sender) returns (bool success) {
function approveKYCAndDeposit(string memory currency, address account, uint amount, uint limit, string memory issuerFirm, address sender) public onlyAuthority(issuerFirm, sender) returns (bool success) {
/// @notice updates kyc approval status
/// @dev !!! mutates storage state
require(
Expand Down Expand Up @@ -155,7 +164,7 @@ contract TokenIOCurrencyAuthority is Ownable {
* @param issuerFirm Name of the issuer firm with authority on account holder;
* @return { "success": "Returns true if successfully called from another contract"}
*/
function setAccountSpendingLimit(address account, uint limit, string issuerFirm) public onlyAuthority(issuerFirm, msg.sender) returns (bool success) {
function setAccountSpendingLimit(address account, uint limit, string memory issuerFirm, address sender) public onlyAuthority(issuerFirm, sender) returns (bool success) {
require(
lib.setAccountSpendingLimit(account, limit),
"Error: Unable to set initial spending limit for account. Please check issuerFirm and firm authority are registered"
Expand Down Expand Up @@ -189,7 +198,7 @@ contract TokenIOCurrencyAuthority is Ownable {
* @param issuerFirm Firm setting the foreign currency exchange
* @return { "success": "Returns true if successfully called from another contract"}
*/
function setFxBpsRate(string currency, uint bpsRate, string issuerFirm) public onlyAuthority(issuerFirm, msg.sender) returns (bool success) {
function setFxBpsRate(string memory currency, uint bpsRate, string memory issuerFirm, address sender) public onlyAuthority(issuerFirm, sender) returns (bool success) {
require(
lib.setFxUSDBPSRate(currency, bpsRate),
"Error: Unable to set FX USD basis points rate. Please ensure issuerFirm is authorized"
Expand All @@ -203,7 +212,7 @@ contract TokenIOCurrencyAuthority is Ownable {
* @param fxAmount Amount of foreign currency to exchange into USD
* @return {"usdAmount" : "Returns the foreign currency amount in USD"}
*/
function getFxUSDAmount(string currency, uint fxAmount) public view returns (uint usdAmount) {
function getFxUSDAmount(string memory currency, uint fxAmount) public view returns (uint usdAmount) {
return lib.getFxUSDAmount(currency, fxAmount);
}

Expand All @@ -214,7 +223,7 @@ contract TokenIOCurrencyAuthority is Ownable {
* @param issuerFirm Name of the issuer firm with authority on account holder;
* @return { "success": "Returns true if successfully called from another contract"}
*/
function approveForwardedAccount(address originalAccount, address updatedAccount, string issuerFirm) public onlyAuthority(issuerFirm, msg.sender) returns (bool success) {
function approveForwardedAccount(address originalAccount, address updatedAccount, string memory issuerFirm, address sender) public onlyAuthority(issuerFirm, sender) returns (bool success) {
// @notice updatesa forwarded account
// @dev !!! mutates storage state
require(
Expand All @@ -231,7 +240,7 @@ contract TokenIOCurrencyAuthority is Ownable {
* @param issuerFirm Name of the issuer firm with authority on account holder;
* @return { "success": "Returns true if successfully called from another contract"}
*/
function deposit(string currency, address account, uint amount, string issuerFirm) public onlyAuthority(issuerFirm, msg.sender) returns (bool success) {
function deposit(string memory currency, address account, uint amount, string memory issuerFirm, address sender) public onlyAuthority(issuerFirm, sender) returns (bool success) {
require(
lib.verifyAccount(account),
"Error: Account is not verified!"
Expand All @@ -253,7 +262,7 @@ contract TokenIOCurrencyAuthority is Ownable {
* @param issuerFirm Name of the issuer firm with authority on account holder
* @return { "success": "Returns true if successfully called from another contract"}
*/
function withdraw(string currency, address account, uint amount, string issuerFirm) public onlyAuthority(issuerFirm, msg.sender) returns (bool success) {
function withdraw(string memory currency, address account, uint amount, string memory issuerFirm, address sender) public onlyAuthority(issuerFirm, sender) returns (bool success) {
require(
lib.verifyAccount(account),
"Error: Account is not verified!"
Expand All @@ -271,7 +280,7 @@ contract TokenIOCurrencyAuthority is Ownable {
* @notice Ensure only authorized currency firms and authorities can modify protected methods
* @dev authority must be registered to an authorized firm to use protected methods
*/
modifier onlyAuthority(string firmName, address authority) {
modifier onlyAuthority(string memory firmName, address authority) {
// @notice throws if authority account is not registred to the given firm
require(
lib.isRegisteredToFirm(firmName, authority),
Expand Down
Loading