Skip to content

Commit

Permalink
Merge pull request #120 from MoonSHRD/network/rinkeby
Browse files Browse the repository at this point in the history
Network/rinkeby
  • Loading branch information
JackBekket authored Jan 21, 2022
2 parents c91ccdd + 1d0c7ef commit b995d7c
Show file tree
Hide file tree
Showing 7 changed files with 246 additions and 27,952 deletions.
25 changes: 22 additions & 3 deletions contracts/721/singleton/MetaMarketplace.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ contract MetaMarketplace {
uint256 createTime;
}

struct Receipt {
uint256 lastPriceSold;
CurrenciesERC20.CurrencyERC20 currencyUsed;
}

// MSNFT, 721Enumerable,721Metadata, erc721(common)
enum NftType {MoonShard, Enum, Meta, Common}

Expand All @@ -50,7 +55,8 @@ contract MetaMarketplace {
mapping(uint256 => SellOffer) activeSellOffers;
// Store all active buy offers and maps them to their respective token ids
mapping(uint256 => mapping(CurrenciesERC20.CurrencyERC20 => BuyOffer)) activeBuyOffers;

// Store the last price & currency item was sold for
mapping(uint256 => Receipt) lastPrice;
// Escrow for buy offers
// buyer_address => token_id => Currency => locked_funds
mapping(address => mapping(uint256 => mapping(CurrenciesERC20.CurrencyERC20=>uint256))) buyOffersEscrow;
Expand Down Expand Up @@ -240,7 +246,11 @@ contract MetaMarketplace {
// delete metainfo.activeBuyOffers[tokenId][currency_]; // if we can't move funds from buyer to seller, then buyer either don't have enough balance nor approved spending this much, so we delete this order
revert("Approved amount is lesser than (bid_price_) needed to deal");
}


// Save the price & currency used
metainfo.lastPrice[tokenId].lastPriceSold = bid_price_;
metainfo.lastPrice[tokenId].currencyUsed = currency_;

// And transfer nft_token to the buyer
token.safeTransferFrom(
seller,
Expand Down Expand Up @@ -374,7 +384,10 @@ contract MetaMarketplace {
// Tries to forward funds from this contract (which already has been locked when makeBuyOffer executed) to seller and distribute fees
require(_forwardFunds(token_contract_,tokenId,currency_, msg.sender, bid_value), "MetaMarketplace: can't forward funds to seller");


// Save the price & currency used
metainfo.lastPrice[tokenId].lastPriceSold = bid_value;
metainfo.lastPrice[tokenId].currencyUsed = currency_;

// And transfer nft token to the buyer
MSNFT token = MSNFT(token_contract_);
token.safeTransferFrom(msg.sender,currentBuyer,tokenId);
Expand Down Expand Up @@ -489,6 +502,12 @@ contract MetaMarketplace {
require(_currency_token.transfer(to_, amount_), "Can't send refund");
}

function getLastPrice(address token_contract_, uint256 _tokenId) public view returns (uint256 _lastPrice, CurrenciesERC20.CurrencyERC20 currency_ ) {
Marketplace storage metainfo = Marketplaces[token_contract_];
_lastPrice = metainfo.lastPrice[_tokenId].lastPriceSold;
currency_ = metainfo.lastPrice[_tokenId].currencyUsed;
return (_lastPrice, currency_);
}

modifier marketplaceSetted(address mplace_) {
require(Marketplaces[mplace_].initialized == true,
Expand Down
4 changes: 4 additions & 0 deletions contracts/Migrations.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ contract Migrations {
address public owner = msg.sender;
uint public last_completed_migration;

constructor() {
owner = msg.sender;
}

modifier restricted() {
require(
msg.sender == owner,
Expand Down
48 changes: 45 additions & 3 deletions migrations/1_initial_migration.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
const Migrations = artifacts.require("Migrations");
const Migrations = artifacts.require("./Migrations.sol");

module.exports = function (deployer) {
deployer.deploy(Migrations);
var custom_gas_price = '3'; // for rinkeby
var wei_gas_price = web3.utils.toWei(custom_gas_price, 'gwei');

var maxFeePerGas_custom = '100'; // for rinkeby
var maxPriorityFeePerGas_custom = '2';
var maxFeePerGas_wei = web3.utils.toWei(maxFeePerGas_custom, 'gwei');
var maxPriorityFeePerGas_wei = web3.utils.toWei(maxPriorityFeePerGas_custom, 'gwei');





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

// process.env.NETWORK = deployer.network;
// if (network == "ropsten" || network =="ropsten-fork") {
console.log(accounts);

// web3.eth.sendTransaction({to:accounts[1], from:accounts[0], value:web3.utils.toWei('500','gwei'), gasPrice:web3.utils.toWei('300','gwei')});
console.log(" maxFeePerGas:");
console.log(maxFeePerGas_wei);
console.log("max PriorityFeePerGas:");
console.log(maxPriorityFeePerGas_wei);

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

deployer.then(async () => {

return deployer.deploy(Migrations, {
// gas: '6721975',
// gasPrice: wei_gas_price,
maxFeePerGas: maxFeePerGas_wei,
maxPriorityFeePerGas: maxPriorityFeePerGas_wei,
// from: accounts[1]
});

});

// }


// deployer.deploy(Migrations);
};
31 changes: 16 additions & 15 deletions migrations/2_deploy_contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,19 @@ var dai_address = web3.utils.toChecksumAddress('0xad6d458402f60fd3bd25163575031a
var weth_address = web3.utils.toChecksumAddress('0xc778417e063141139fce010982780140aa0cd5ab');
var wbtc_address = web3.utils.toChecksumAddress('0x65058d7081fcdc3cd8727dbb7f8f9d52cefdd291');

var deposit_value = '50000'; // deposit INITIAL exchange market cup (turn capital)
var deposit_value_wei = web3.utils.toWei(deposit_value,'ether');
// @todo: remove next two lines
//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 = '9'; // for ropsten
var wei_gas_price = web3.utils.toWei(custom_gas_price, 'gwei');
//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) {
process.env.NETWORK = deployer.network;
if (network == "rinkeby") {
console.log(accounts);
console.log(wei_gas_price);
// console.log(wei_gas_price);

console.log("block gas price:");
var limitGas = web3.eth.getBlock("latest").gasLimit;
Expand Down Expand Up @@ -70,20 +71,20 @@ module.exports = function (deployer, network, accounts) {
console.log("weth address:");
console.log(weth_address);
return deployer.deploy(Currencies, usdt_address, usdc_address, dai_address, weth_address, MST.address, wbtc_address, {
gasPrice: wei_gas_price,
// gasPrice: wei_gas_price,
from: accounts[0]
});

}).then(function () {
return deployer.deploy(Master, "MoonShardNFT", "MSNFT", {
gasPrice: wei_gas_price,
// 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[0], Currencies.address, {
gasPrice: wei_gas_price,
// gasPrice: wei_gas_price,
from: accounts[0]
});

Expand All @@ -100,7 +101,7 @@ module.exports = function (deployer, network, accounts) {
}).then(async () => {

return deployer.deploy(InterfaceR, {
gasPrice: wei_gas_price,
// gasPrice: wei_gas_price,
from: accounts[0]
});
}).then(async () => {
Expand All @@ -119,7 +120,7 @@ module.exports = function (deployer, network, accounts) {
}).then(async () => {

return deployer.deploy(MetaMarket, Currencies.address, Master.address, accounts[0], {
gasPrice: wei_gas_price,
// gasPrice: wei_gas_price,
from: accounts[0]
});
}).then(async () => {
Expand Down Expand Up @@ -162,20 +163,20 @@ module.exports = function (deployer, network, accounts) {
}).then(function () {

return deployer.deploy(Currencies, USDT.address, USDC.address, DAI.address, WETH.address, MST.address, WBTC.address, {
gasPrice: wei_gas_price,
// gasPrice: wei_gas_price,
from: accounts[0]
});

}).then(function () {
return deployer.deploy(Master, "MoonShardNFT", "MSNFT", {
gasPrice: wei_gas_price,
// 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,
// gasPrice: wei_gas_price,
from: accounts[0]
});

Expand All @@ -192,7 +193,7 @@ module.exports = function (deployer, network, accounts) {
}).then(async () => {

return deployer.deploy(InterfaceR, {
gasPrice: wei_gas_price,
// gasPrice: wei_gas_price,
from: accounts[0]
});
}).then(async () => {
Expand All @@ -211,7 +212,7 @@ module.exports = function (deployer, network, accounts) {
}).then(async () => {

return deployer.deploy(MetaMarket, Currencies.address, Master.address, accounts[1], {
gasPrice: wei_gas_price,
// gasPrice: wei_gas_price,
from: accounts[0]
});
}).then(async () => {
Expand Down
Loading

0 comments on commit b995d7c

Please sign in to comment.