-
Notifications
You must be signed in to change notification settings - Fork 216
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
(Feature) Enable proxy for both strategies #1024
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
629abfc
Enable proxy at deployment
vbaranov bffb104
Merge remote-tracking branch 'origin/2.0' into proxy-finalize
vbaranov 0ce061c
Support display of QR for Proxy case
vbaranov ccafb9a
Enable Proxy
vbaranov ea7af7d
merge with 2.0
vbaranov 4599ab0
Fix: display max cap of whitelisted item at management page
vbaranov 45bc31a
Update DutchProxy ABI: getCrowdsaleUniqueBuyers method is returned back
vbaranov 4d8070d
move Proxy provider address to .env
vbaranov a650a8d
fix link from management page to crowdsale page
vbaranov b88b5bb
Handle gas estimation for buy function
vbaranov 26b286e
fix for estimatedGas for buy constant
vbaranov 8e1894f
update of Ropsten address of proxies registry
vbaranov eb5302f
whitelists max limits fix
vbaranov 4ec3c88
Update of Proxies Registry source code
vbaranov 32b69a2
Reviewer suggestions are implemented
vbaranov 6772136
Update of submodules
vbaranov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
// File: openzeppelin-solidity/contracts/ownership/Ownable.sol | ||
|
||
/** | ||
* @title Ownable | ||
* @dev The Ownable contract has an owner address, and provides basic authorization control | ||
* functions, this simplifies the implementation of "user permissions". | ||
*/ | ||
contract Ownable { | ||
address public owner; | ||
|
||
|
||
event OwnershipRenounced(address indexed previousOwner); | ||
event OwnershipTransferred( | ||
address indexed previousOwner, | ||
address indexed newOwner | ||
); | ||
|
||
|
||
/** | ||
* @dev The Ownable constructor sets the original `owner` of the contract to the sender | ||
* account. | ||
*/ | ||
constructor() public { | ||
owner = msg.sender; | ||
} | ||
|
||
/** | ||
* @dev Throws if called by any account other than the owner. | ||
*/ | ||
modifier onlyOwner() { | ||
require(msg.sender == owner); | ||
_; | ||
} | ||
|
||
/** | ||
* @dev Allows the current owner to relinquish control of the contract. | ||
*/ | ||
function renounceOwnership() public onlyOwner { | ||
emit OwnershipRenounced(owner); | ||
owner = address(0); | ||
} | ||
|
||
/** | ||
* @dev Allows the current owner to transfer control of the contract to a newOwner. | ||
* @param _newOwner The address to transfer ownership to. | ||
*/ | ||
function transferOwnership(address _newOwner) public onlyOwner { | ||
_transferOwnership(_newOwner); | ||
} | ||
|
||
/** | ||
* @dev Transfers control of the contract to a newOwner. | ||
* @param _newOwner The address to transfer ownership to. | ||
*/ | ||
function _transferOwnership(address _newOwner) internal { | ||
require(_newOwner != address(0)); | ||
emit OwnershipTransferred(owner, _newOwner); | ||
owner = _newOwner; | ||
} | ||
} | ||
|
||
// File: contracts/ProxiesRegistry.sol | ||
|
||
contract AbstractProxy { | ||
bytes32 public app_exec_id; | ||
function getAdmin() external view returns (address); | ||
} | ||
|
||
contract AbstractIdx { | ||
function getAdmin(address, bytes32) external view returns (address); | ||
} | ||
|
||
/** | ||
* Registry of Proxy smart-contracts deployed from Token Wizard 2.0. | ||
*/ | ||
contract TokenWizardProxiesRegistry is Ownable { | ||
address public abstractStorageAddr; | ||
address public mintedCappedIdxAddr; | ||
address public dutchIdxAddr; | ||
mapping (address => Crowdsale[]) private deployedCrowdsalesByUser; | ||
event Added(address indexed sender, address indexed proxyAddress, bytes32 appExecID); | ||
struct Crowdsale { | ||
address proxyAddress; | ||
bytes32 execID; | ||
} | ||
|
||
constructor ( | ||
address _abstractStorage, | ||
address _mintedCappedIdx, | ||
address _dutchIdx | ||
) public { | ||
require(_abstractStorage != address(0)); | ||
require(_mintedCappedIdx != address(0)); | ||
require(_dutchIdx != address(0)); | ||
require(_abstractStorage != _mintedCappedIdx && _abstractStorage != _dutchIdx && _mintedCappedIdx != _dutchIdx); | ||
abstractStorageAddr = _abstractStorage; | ||
mintedCappedIdxAddr = _mintedCappedIdx; | ||
dutchIdxAddr = _dutchIdx; | ||
} | ||
|
||
function changeAbstractStorage(address newAbstractStorageAddr) public onlyOwner { | ||
abstractStorageAddr = newAbstractStorageAddr; | ||
} | ||
|
||
function changeMintedCappedIdx(address newMintedCappedIdxAddr) public onlyOwner { | ||
mintedCappedIdxAddr = newMintedCappedIdxAddr; | ||
} | ||
|
||
function changeDutchIdxAddr(address newDutchIdxAddr) public onlyOwner { | ||
dutchIdxAddr = newDutchIdxAddr; | ||
} | ||
|
||
function trackCrowdsale(address proxyAddress) public { | ||
AbstractProxy proxy = AbstractProxy(proxyAddress); | ||
require(proxyAddress != address(0)); | ||
require(msg.sender == proxy.getAdmin()); | ||
bytes32 appExecID = proxy.app_exec_id(); | ||
AbstractIdx mintedCappedIdx = AbstractIdx(mintedCappedIdxAddr); | ||
AbstractIdx dutchIdx = AbstractIdx(dutchIdxAddr); | ||
require(mintedCappedIdx.getAdmin(abstractStorageAddr, appExecID) == msg.sender || dutchIdx.getAdmin(abstractStorageAddr, appExecID) == msg.sender); | ||
for (uint i = 0; i < deployedCrowdsalesByUser[msg.sender].length; i++) { | ||
require(deployedCrowdsalesByUser[msg.sender][i].proxyAddress != proxyAddress); | ||
require(deployedCrowdsalesByUser[msg.sender][i].execID != appExecID); | ||
} | ||
deployedCrowdsalesByUser[msg.sender].push(Crowdsale({proxyAddress: proxyAddress, execID: appExecID})); | ||
emit Added(msg.sender, proxyAddress, appExecID); | ||
} | ||
|
||
function countCrowdsalesForUser(address deployer) public view returns (uint) { | ||
return deployedCrowdsalesByUser[deployer].length; | ||
} | ||
|
||
function getCrowdsalesForUser(address deployer) public view returns (address[]) { | ||
address[] memory proxies = new address[](deployedCrowdsalesByUser[deployer].length); | ||
for (uint k = 0; k < deployedCrowdsalesByUser[deployer].length; k++) { | ||
proxies[k] = deployedCrowdsalesByUser[deployer][k].proxyAddress; | ||
} | ||
return proxies; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious, why in some cases you use the array lookup for the value as an alternative, and in other cases just go with the object key lookup like in?:
https://github.com/poanetwork/token-wizard/pull/1024/files#diff-5c25cfce1eba8feb7668398c93446a0bR118
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use the array lookup because Proxy getters return only arrays. In the line, that you provided, array lookup wasn't made because it was made earlier in this line:
token-wizard/src/components/crowdsale/utils.js
Line 98 in 4ec3c88