Skip to content

Commit

Permalink
Merge pull request #62 from MoonSHRD/network/ropsten
Browse files Browse the repository at this point in the history
Network/ropsten
  • Loading branch information
JackBekket committed Sep 30, 2021
2 parents 24b9a22 + ab047fa commit faa097c
Show file tree
Hide file tree
Showing 14 changed files with 1,504 additions and 270 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/
build/
package-lock.json
.idea
.idea
secret.json
19 changes: 12 additions & 7 deletions contracts/721/singleton/CurrenciesERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,19 @@ contract CurrenciesERC20 is ReentrancyGuard, Ownable {
mapping (string => CurrencyERC20_Custom) public _currencies_custom_user;


// @TODO: Investigate how to add different types of ERC20. Old type have name as public string and no getter, new type have name as private sting and getter for it.
function AddCustomCurrency(address _token_contract) public {

IERC20Metadata _currency_contract = IERC20Metadata(_token_contract);
// ERC20 _currency_contract = ERC20(_token_contract); // @todo: is it possible to use IERC20Metadata instead?
IERC20Metadata _currency_contract = IERC20Metadata(_token_contract);

// if (_currency_contract.name != '0x0')

string memory _name_c = _currency_contract.name();

string memory _name_c = _currency_contract.name(); // @note -- some contracts just have name as public string, but do not have name() function!!! see difference between 0.4.0 and 0.8.0 OZ standarts need future consideration
// uint8 _dec = _currency_contract.decimals();



address _owner_c = owner();
if(msg.sender == _owner_c) {
require(_currencies_custom[_name_c].contract_address == address(0), "AddCustomCurrency[admin]: Currency token contract with this address is already exists");
Expand Down Expand Up @@ -88,17 +92,18 @@ contract CurrenciesERC20 is ReentrancyGuard, Ownable {


_currencies_hardcoded[CurrencyERC20.USDT] = IERC20Metadata(US_Tether);
_currencies_hardcoded[CurrencyERC20.USDT] == IERC20Metadata(US_Tether);
_currencies_hardcoded[CurrencyERC20.USDC] = IERC20Metadata(US_Circle);
_currencies_hardcoded[CurrencyERC20.DAI] = IERC20Metadata(DAI);
_currencies_hardcoded[CurrencyERC20.WETH] = IERC20Metadata(W_Ethereum);
_currencies_hardcoded[CurrencyERC20.SNM] = IERC20Metadata(SONM);



AddCustomCurrency(US_Tether);
AddCustomCurrency(US_Circle);
AddCustomCurrency(DAI);
AddCustomCurrency(W_Ethereum);
// AddCustomCurrency(US_Tether);
// AddCustomCurrency(US_Circle);
// AddCustomCurrency(DAI);
// AddCustomCurrency(W_Ethereum);
AddCustomCurrency(SONM);


Expand Down
8 changes: 1 addition & 7 deletions contracts/test_erc20_tokens/DAI.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
//"SPDX-License-Identifier: MIT"




import "./TestTokenERC20.sol";

Expand All @@ -11,9 +8,6 @@ import "./TestTokenERC20.sol";

constructor(string memory name_, string memory symbol_) TestTokenERC20(name_,symbol_) {}




}


8 changes: 1 addition & 7 deletions contracts/test_erc20_tokens/SNM.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
//"SPDX-License-Identifier: MIT"




import "./TestTokenERC20.sol";

Expand All @@ -11,9 +8,6 @@ import "./TestTokenERC20.sol";

constructor(string memory name_, string memory symbol_) TestTokenERC20(name_,symbol_) {}




}


3 changes: 2 additions & 1 deletion contracts/test_erc20_tokens/TestTokenERC20.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
//"SPDX-License-Identifier: MIT"




Expand Down
3 changes: 2 additions & 1 deletion contracts/test_erc20_tokens/TestUSDT.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
//"SPDX-License-Identifier: MIT"


// this contract is exist cause we need to deploy ERC20 test tokens by truffle deployer, so we need js artifacts for that purpose (which can't be created otherway cause OZ is in node_modules)

Expand Down
4 changes: 1 addition & 3 deletions contracts/test_erc20_tokens/USDC.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
//"SPDX-License-Identifier: MIT"




import "./TestTokenERC20.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/test_erc20_tokens/WETH.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
//"SPDX-License-Identifier: MIT"



Expand Down
144 changes: 92 additions & 52 deletions migrations/2_deploy_contracts.js
Original file line number Diff line number Diff line change
@@ -1,71 +1,133 @@
//var SuperFactory = artifacts.require("./SuperFactory.sol");
//var KNS = artifacts.require("./KNS.sol");
var MasterFactory = artifacts.require("./721/singleton/MasterFactory721.sol");
//var Deposit = artifacts.require("./Deposit.sol")
// //var Deposit = artifacts.require("./Deposit.sol")
var Master = artifacts.require("./721/singleton/MSNFT.sol");
var accounts = web3.eth.getAccounts();
var limitGas = web3.eth.getBlock("latest").gasLimit;
// var limitGas = web3.eth.getBlock("latest").gasLimit;


// CurrencyERC20 contract
var Currencies = artifacts.require("./721/singleton/CurrenciesERC20.sol");

// Test dummy erc20 tokens
var USDT = artifacts.require("./test_erc20_tokens/TestUSDT.sol");
var USDC = artifacts.require("./test_erc20_tokens/USDC.sol");
var DAI = artifacts.require("./test_erc20_tokens/DAI.sol");
var WETH = artifacts.require("./test_erc20_tokens/WETH.sol");
// // Test dummy erc20 tokens
// var USDT = artifacts.require("./test_erc20_tokens/TestUSDT.sol");
// var USDC = artifacts.require("./test_erc20_tokens/USDC.sol");
// var DAI = artifacts.require("./test_erc20_tokens/DAI.sol");
// var WETH = artifacts.require("./test_erc20_tokens/WETH.sol");
var SNM = artifacts.require("./test_erc20_tokens/SNM.sol");


// Ropsten addresses
var usdt_address = web3.utils.toChecksumAddress('0x3b00ef435fa4fcff5c209a37d1f3dcff37c705ad');
var usdc_address = web3.utils.toChecksumAddress('0xeb8f08a975ab53e34d8a0330e0d34de942c95926');
var dai_address = web3.utils.toChecksumAddress('0x95b58a6bff3d14b7db2f5cb5f0ad413dc2940658');
var weth_address = web3.utils.toChecksumAddress('0xc778417e063141139fce010982780140aa0cd5ab');
const snm_address = "0x98201f86F578154e01ec683E1962578855d8320C";

//var deposit_value = '50000'; // deposit INITIAL exchange market cup (turn capital)
//var deposit_value_wei = web3.utils.toWei(deposit_value,'ether');
//var custom_gas_price =


var custom_gas_price = '1';
var custom_gas_price = '9'; // for ropsten
var wei_gas_price = web3.utils.toWei(custom_gas_price, 'gwei');
//var string_gas_price = wei_gas_price.toString;

module.exports = function(deployer, network, accounts) {

if (network == "ropsten") {
console.log(accounts);
console.log(wei_gas_price);

console.log("block gas price:");
var limitGas = web3.eth.getBlock("latest").gasLimit;
console.log(limitGas);
// console.log(string_gas_price);

/*
deployer.deploy(MasterFactory,accounts[1],{gasPrice: wei_gas_price, from:accounts[0]}).then(function() {

return;
// return deployer.deploy(SuperFactory, KNS.address,accounts[1],accounts[2],{gasPrice:'1'});
});
*/

deployer.then(async () => {
/*
await deployer.deploy(USDT,"USDT","USDT");
await deployer.deploy(USDC,"USDC","USDC");
USDC = await USDC.deployed();
await deployer.deploy(DAI,"DAI","DAI");
DAI = await DAI.deployed();
await deployer.deploy(WETH,"WETH","WETH");
WETH = await WETH.deployed();
*/
await deployer.deploy(SNM,"SONM","SNM");
SNM = await SNM.deployed();
console.log("snm dummy address:");
console.log(SNM.address);
//...
}).then(function() {

return deployer.deploy(Currencies,USDT.address,USDC.address,DAI.address,WETH.address,SNM.address, {gasPrice: wei_gas_price, from:accounts[0]});
console.log("usdt address:");
console.log(usdt_address);
console.log("weth address:");
console.log(weth_address);
return deployer.deploy(Currencies,usdt_address,usdc_address,dai_address,weth_address,SNM.address, {gasPrice: wei_gas_price, from:accounts[0]});

}).then(function(){

// return deployer.deploy(MasterFactory,accounts[1],{gasPrice: wei_gas_price, from:accounts[0]});

return deployer.deploy(Master,"MoonShardNFT","MSNFT",{gasPrice: wei_gas_price, from:accounts[0]});

}).then(function(){
console.log("Master token address:");
console.log(Master.address);
return deployer.deploy(MasterFactory,Master.address,accounts[1],Currencies.address,{gasPrice: wei_gas_price, from:accounts[0]});
return deployer.deploy(MasterFactory,Master.address,accounts[1],Currencies.address,{gasPrice: wei_gas_price, from:accounts[0]});

}).then(async () =>{
console.log ("MasterFactory address:");
console.log(MasterFactory.address);
MasterInstance = await Master.deployed();
MasterFactoryInstance = await MasterFactory.deployed();
await MasterInstance.updateFactoryAdress(MasterFactoryInstance.address);
fa = await MasterInstance.getFactoryAddress();
console.log("factory address");
console.log(fa);
return;
}).then(async () => {
return;
});

} // end of ropsten deployment



/*
if (network == "development") {
console.log(accounts);
console.log(wei_gas_price);
console.log("block gas price:");
var limitGas = web3.eth.getBlock("latest").gasLimit;
console.log(limitGas);
// console.log(string_gas_price);
deployer.then(async () => {
await deployer.deploy(USDT,"USDT","USDT");
await deployer.deploy(USDC,"USDC","USDC");
USDC = await USDC.deployed();
await deployer.deploy(DAI,"DAI","DAI");
DAI = await DAI.deployed();
await deployer.deploy(WETH,"WETH","WETH");
WETH = await WETH.deployed();
await deployer.deploy(SNM,"SONM","SNM");
SNM = await SNM.deployed();
//...
}).then(function() {
return deployer.deploy(Currencies,USDT.address,USDC.address,DAI.address,WETH.address,SNM.address, {gasPrice: wei_gas_price, from:accounts[0]});
}).then(function(){
return deployer.deploy(Master,"MoonShardNFT","MSNFT",{gasPrice: wei_gas_price, from:accounts[0]});
}).then(function(){
console.log("Master token address:");
console.log(Master.address);
return deployer.deploy(MasterFactory,Master.address,accounts[1],Currencies.address,{gasPrice: wei_gas_price, from:accounts[0]});
}).then(async () =>{
console.log ("MasterFactory address:");
console.log(MasterFactory.address);
MasterInstance = await Master.deployed();
Expand All @@ -75,33 +137,11 @@ deployer.then(async () => {
console.log("factory address");
console.log(fa);
return;
}).then(async () => {
}).then(async () => {
return;
});


/*
deployer.deploy(USDT,"USDT","USDT");
deployer.deploy(USDC,"USDC","USDC");
deployer.deploy(DAI,"DAI","DAI");
deployer.deploy(WETH,"WETH","WETH");
deployer.deploy(SNM,"SONM","SNM");
*/

/*
deployer.deploy(Currencies,USDT.address,USDC.address,DAI.address,WETH.address,SNM.address, {gasPrice: wei_gas_price, from:accounts[0]}).then(function() {
deployer.deploy(MasterFactory,accounts[1],{gasPrice: wei_gas_price, from:accounts[0]});
});
*/

/*
deployer.deploy(Ticket, {gasPrice:'1'}).then(function() {
return deployer.deploy(TicketFactory,Ticket.address,accounts[0],{gasPrice:'1'}); // parameters -- ticket address, treasure_fund address
});
deployer.deploy(Deposit,{gasPrice:'1', value:deposit_value_wei, from:accounts[2]}); //FIXME: add value sent to deposit contract
*/

});
} // end of development network migration
*/

};

0 comments on commit faa097c

Please sign in to comment.