From 12730cd8575638bc254e8ba719595c72989f13e5 Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Wed, 20 Mar 2019 20:19:14 +0000 Subject: [PATCH 01/41] DecentralandUtils refactoring --- packages/tasit-sdk/src/helpers/DecentralandUtils.js | 6 ++++-- packages/tasit-sdk/src/testHelpers/helpers.js | 8 +++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/tasit-sdk/src/helpers/DecentralandUtils.js b/packages/tasit-sdk/src/helpers/DecentralandUtils.js index b4997e0b..e121a471 100644 --- a/packages/tasit-sdk/src/helpers/DecentralandUtils.js +++ b/packages/tasit-sdk/src/helpers/DecentralandUtils.js @@ -23,7 +23,9 @@ export default class DecentralandUtils { this.#marketplace = new ethers.Contract(address, abi, this.#provider); } - getOpenSellOrders = async fromBlock => { + getAllAssetsForSale = async () => { + const fromBlock = 0; + const [ordersCreated, ordersCancelled, ordersExecuted] = await Promise.all([ this.#getCreatedSellOrders(fromBlock), this.#getCancelledSellOrders(fromBlock), @@ -45,7 +47,7 @@ export default class DecentralandUtils { ) ); - return openOrders; + return openOrders.map(order => order.values); }; #getCreatedSellOrders = async fromBlock => { diff --git a/packages/tasit-sdk/src/testHelpers/helpers.js b/packages/tasit-sdk/src/testHelpers/helpers.js index 922f2f76..f19a4f34 100644 --- a/packages/tasit-sdk/src/testHelpers/helpers.js +++ b/packages/tasit-sdk/src/testHelpers/helpers.js @@ -30,17 +30,15 @@ export const pickAssetsForSale = async () => { let estateForSale; const decentralandUtils = new DecentralandUtils(); - const { getOpenSellOrders } = decentralandUtils; + const { getAllAssetsForSale } = decentralandUtils; - const fromBlock = 0; - const openSellOrders = await getOpenSellOrders(fromBlock); + const openSellOrders = await getAllAssetsForSale(); // Note: The exact amount of land isn't predictable since we are forking from the latest block expect(openSellOrders).to.not.be.empty; // Pick two open sell orders: one for a parcel of land and one for an estate - for (let sellOrder of openSellOrders) { - const { values: order } = sellOrder; + for (let order of openSellOrders) { const { nftAddress, expiresAt } = order; const isLand = addressesAreEqual(nftAddress, LAND_PROXY_ADDRESS); From 64e2e11856cbd831adc46f4bb04002acca5d4c7b Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Wed, 20 Mar 2019 21:40:55 +0000 Subject: [PATCH 02/41] Check decentraland contracts data script --- package-lock.json | 44 +++-------- .../tasit-action/src/testHelpers/helpers.js | 6 +- .../scripts/populateDecentralandContracts.js | 11 +-- packages/tasit-sdk/package.json | 3 +- .../scripts/checkDecentralandContractsData.js | 78 +++++++++++++++++++ 5 files changed, 99 insertions(+), 43 deletions(-) create mode 100644 packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js diff --git a/package-lock.json b/package-lock.json index 3acf37b9..9183e6b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3601,8 +3601,7 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true, - "optional": true + "bundled": true }, "aproba": { "version": "1.2.0", @@ -3620,13 +3619,11 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true, - "optional": true + "bundled": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3639,18 +3636,15 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "concat-map": { "version": "0.0.1", - "bundled": true, - "optional": true + "bundled": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "core-util-is": { "version": "1.0.2", @@ -3753,8 +3747,7 @@ }, "inherits": { "version": "2.0.3", - "bundled": true, - "optional": true + "bundled": true }, "ini": { "version": "1.3.5", @@ -3764,7 +3757,6 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3777,20 +3769,17 @@ "minimatch": { "version": "3.0.4", "bundled": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true, - "optional": true + "bundled": true }, "minipass": { "version": "2.3.5", "bundled": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -3807,7 +3796,6 @@ "mkdirp": { "version": "0.5.1", "bundled": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -3880,8 +3868,7 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true, - "optional": true + "bundled": true }, "object-assign": { "version": "4.1.1", @@ -3891,7 +3878,6 @@ "once": { "version": "1.4.0", "bundled": true, - "optional": true, "requires": { "wrappy": "1" } @@ -3967,8 +3953,7 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true, - "optional": true + "bundled": true }, "safer-buffer": { "version": "2.1.2", @@ -3998,7 +3983,6 @@ "string-width": { "version": "1.0.2", "bundled": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -4016,7 +4000,6 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -4055,13 +4038,11 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true, - "optional": true + "bundled": true }, "yallist": { "version": "3.0.3", - "bundled": true, - "optional": true + "bundled": true } } }, @@ -6262,8 +6243,7 @@ "node-fetch": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.3.0.tgz", - "integrity": "sha512-MOd8pV3fxENbryESLgVIeaGKrdl+uaYhCSSVkjeOb/31/njTpcis5aWfdqgNlHIrKOLRbMnfPINPOML2CIFeXA==", - "dev": true + "integrity": "sha512-MOd8pV3fxENbryESLgVIeaGKrdl+uaYhCSSVkjeOb/31/njTpcis5aWfdqgNlHIrKOLRbMnfPINPOML2CIFeXA==" }, "node-fetch-npm": { "version": "2.0.2", diff --git a/packages/tasit-action/src/testHelpers/helpers.js b/packages/tasit-action/src/testHelpers/helpers.js index e6c5f0cc..ccabd9d0 100644 --- a/packages/tasit-action/src/testHelpers/helpers.js +++ b/packages/tasit-action/src/testHelpers/helpers.js @@ -25,6 +25,7 @@ const { bigNumberify } = ethersUtils; // See more: https://github.com/ethers-io/ethers.js/issues/228 const ZERO = 0; const ONE = bigNumberify(1).mul(WeiPerEther); +const TWO = bigNumberify(2).mul(WeiPerEther); const TEN = bigNumberify(10).mul(WeiPerEther); const ONE_HUNDRED = bigNumberify(100).mul(WeiPerEther); const ONE_THOUSAND = bigNumberify(1000).mul(WeiPerEther); @@ -33,6 +34,7 @@ const BILLION = bigNumberify(`${1e9}`).mul(WeiPerEther); const constants = { ZERO, ONE, + TWO, TEN, ONE_HUNDRED, ONE_THOUSAND, @@ -127,7 +129,7 @@ const expectMinimumEtherBalances = async (provider, addresses, balances) => { const balance = await provider.getBalance(address); const actual = bigNumberify(balance); const expected = bigNumberify(balances[index++]); - expect(actual.gte(expected)).to.be.true; + expect(actual.gte(expected), `${actual} isn't >= ${expected}`).to.be.true; } }; @@ -138,7 +140,7 @@ const expectMinimumTokenBalances = async (token, addresses, balances) => { const balance = await token.balanceOf(address); const actual = bigNumberify(balance); const expected = bigNumberify(balances[index++]); - expect(actual.gte(expected)).to.be.true; + expect(actual.gte(expected), `${actual} isn't >= ${expected}`).to.be.true; } }; diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index 63776bf3..4669d8e8 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -23,7 +23,7 @@ import fs from "fs"; import { duration } from "../../../tasit-sdk/dist/testHelpers/helpers"; -const { ONE, TEN, ONE_HUNDRED, ONE_THOUSAND } = constants; +const { ONE, TEN, ONE_HUNDRED, ONE_THOUSAND, BILLION } = constants; const createMultipleParcels = async ( landContract, @@ -203,13 +203,8 @@ let network = process.env.NETWORK; // Fund Gnosis Safe wallet with Mana tokens and ethers const provider = ProviderFactory.getProvider(); - await etherFaucet(provider, minterWallet, GNOSIS_SAFE_ADDRESS, ONE); - await erc20Faucet( - manaContract, - minterWallet, - GNOSIS_SAFE_ADDRESS, - ONE_THOUSAND - ); + await etherFaucet(provider, minterWallet, GNOSIS_SAFE_ADDRESS, TEN); + await erc20Faucet(manaContract, minterWallet, GNOSIS_SAFE_ADDRESS, BILLION); const allParcels = [ // Estate: all road adjacent parcels diff --git a/packages/tasit-sdk/package.json b/packages/tasit-sdk/package.json index bff4439c..fe1d58ab 100644 --- a/packages/tasit-sdk/package.json +++ b/packages/tasit-sdk/package.json @@ -46,6 +46,7 @@ "@babel/register": "^7.0.0", "chai": "^4.2.0", "ethers": "^4.0.27", - "mocha": "^6.0.1" + "mocha": "^6.0.1", + "node-fetch": "^2.3.0" } } diff --git a/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js b/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js new file mode 100644 index 00000000..8d048b4e --- /dev/null +++ b/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js @@ -0,0 +1,78 @@ +// +// Script used to check if the target chain has the Decentraland app pre-conditions +// +// Note: This script is using mocha for convenince but isn't a test suite to be runned by `test` script. +// Use: npx mocha src/scripts/checkDecentralandContractsData.js --require @babel/register --file src/testHelpers/mochaSetup.js --no-timeouts +// + +import { Action, ContractBasedAccount } from "../TasitSdk"; +const { ERC20 } = Action; +const { Mana } = ERC20; + +import DecentralandUtils from "../helpers/DecentralandUtils"; + +const fetch = require("node-fetch"); + +const { TWO, TEN, BILLION, WeiPerEther } = constants; + +describe("Decentraland App pre-conditions", () => { + const mana = new Mana(MANA_ADDRESS); + const gnosisSafeOwner = accounts[9]; + const decentralandUtils = new DecentralandUtils(); + const { getAllAssetsForSale } = decentralandUtils; + let assetsForSale = []; + + before("load assets for sale from blockchain", async () => { + assetsForSale = await getAllAssetsForSale(); + }); + + describe("Gnosis Safe wallet", () => { + it("should have at least ten ethers", async () => { + await expectMinimumEtherBalances(provider, [GNOSIS_SAFE_ADDRESS], [TEN]); + }); + + it("should have at least a billion MANA", async () => { + await expectMinimumTokenBalances(mana, [GNOSIS_SAFE_ADDRESS], [BILLION]); + }); + }); + + describe("Gnosis Safe wallet owner", () => { + it("should have at least ten ethers", async () => { + await expectMinimumEtherBalances(provider, [GNOSIS_SAFE_ADDRESS], [TWO]); + }); + }); + + describe("Marketplace", () => { + it("should have at least 100 assets for sale", async () => { + expect(assetsForSale.length).to.be.at.least(100); + }); + }); + + it("Assets for sale", async () => { + const minPrice = bigNumberify("10000").mul(WeiPerEther); + const maxPrice = bigNumberify("100000").mul(WeiPerEther); + + const blankImage = await fetch( + "https://api.decentraland.org/v1/estates/5/map.png" + ); + const blankImageData = (await blankImage.buffer()).toString("base64"); + + for (let asset of assetsForSale) { + const { id, assetId, nftAddress, priceInWei } = asset; + const price = bigNumberify(priceInWei); + + const isLand = addressesAreEqual(nftAddress, LAND_PROXY_ADDRESS); + const isEstate = addressesAreEqual(nftAddress, ESTATE_ADDRESS); + + expect(price.gte(minPrice), `${price} isn't >= ${minPrice}`).to.be.true; + expect(price.lte(maxPrice), `${price} isn't <= ${maxPrice}`).to.be.true; + + // Parcels always show correct image + const image = await fetch( + `https://api.decentraland.org/v1/estates/${assetId}/map.png` + ); + const imageData = (await image.buffer()).toString("base64"); + expect(imageData).not.equals(blankImageData); + } + }); +}); From 7b1ca3e29ca2f01d452ebac0eb4b9259c061bb8a Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Wed, 20 Mar 2019 21:54:30 +0000 Subject: [PATCH 03/41] Prices --- .../scripts/populateDecentralandContracts.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index 4669d8e8..28937f99 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -23,7 +23,7 @@ import fs from "fs"; import { duration } from "../../../tasit-sdk/dist/testHelpers/helpers"; -const { ONE, TEN, ONE_HUNDRED, ONE_THOUSAND, BILLION } = constants; +const { ONE, TEN, ONE_HUNDRED, ONE_THOUSAND, BILLION, WeiPerEther } = constants; const createMultipleParcels = async ( landContract, @@ -121,14 +121,22 @@ const approveMarketplace = async ( await landApproval.waitForNonceToUpdate(); }; +function getRandomInt(min, max) { + min = Math.ceil(min); + max = Math.floor(max); + return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive +} + const placeEstatesSellOrders = async ( marketplace, estateAddress, estateIds, - priceInWei, expireAt, sellerWallet ) => { + const price = getRandomInt(10, 100) + "000"; + const priceInWei = bigNumberify(price).mul(WeiPerEther); + marketplace.setWallet(sellerWallet); for (let assetId of estateIds) { const action = marketplace.createOrder( @@ -146,10 +154,12 @@ const placeParcelsSellOrders = async ( marketplace, landAddress, landIds, - priceInWei, expireAt, sellerWallet ) => { + const price = getRandomInt(10, 100) + "000"; + const priceInWei = bigNumberify(price).mul(WeiPerEther); + marketplace.setWallet(sellerWallet); for (let assetId of landIds) { const action = marketplace.createOrder( @@ -305,7 +315,6 @@ let network = process.env.NETWORK; sellerWallet ); - const priceInWei = `${ONE}`; const expireAt = Date.now() + duration.years(5); console.log("Placing estates sellorders..."); @@ -313,7 +322,6 @@ let network = process.env.NETWORK; marketplaceContract, ESTATE_ADDRESS, allEstateIds, - priceInWei, expireAt, sellerWallet ); @@ -326,7 +334,6 @@ let network = process.env.NETWORK; marketplaceContract, LAND_PROXY_ADDRESS, landIdsToSell, - priceInWei, expireAt, sellerWallet ); From b4e5c71efd657f95496b4fe9ddfd8ea1181ccae7 Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Wed, 20 Mar 2019 22:26:17 +0000 Subject: [PATCH 04/41] package-lock.json --- package-lock.json | 28 +++++++++++++++++++++------- packages/tasit-sdk/package-lock.json | 2 +- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9183e6b1..76e4a2ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3619,11 +3619,13 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true + "bundled": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3636,15 +3638,18 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "concat-map": { "version": "0.0.1", - "bundled": true + "bundled": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -3747,7 +3752,8 @@ }, "inherits": { "version": "2.0.3", - "bundled": true + "bundled": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -3757,6 +3763,7 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3769,17 +3776,20 @@ "minimatch": { "version": "3.0.4", "bundled": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true + "bundled": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -3796,6 +3806,7 @@ "mkdirp": { "version": "0.5.1", "bundled": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -3868,7 +3879,8 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true + "bundled": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -3878,6 +3890,7 @@ "once": { "version": "1.4.0", "bundled": true, + "optional": true, "requires": { "wrappy": "1" } @@ -3983,6 +3996,7 @@ "string-width": { "version": "1.0.2", "bundled": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", diff --git a/packages/tasit-sdk/package-lock.json b/packages/tasit-sdk/package-lock.json index 06a2c090..a1e61834 100644 --- a/packages/tasit-sdk/package-lock.json +++ b/packages/tasit-sdk/package-lock.json @@ -1,6 +1,6 @@ { "name": "tasit-sdk", - "version": "0.0.13", + "version": "0.0.14", "lockfileVersion": 1, "requires": true, "dependencies": { From 89c9afdcfda94250d5fb530e1e170c8a57e5c0c0 Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Thu, 21 Mar 2019 11:10:27 +0000 Subject: [PATCH 05/41] Refactoring --- .../scripts/populateDecentralandContracts.js | 102 ++++++++++-------- 1 file changed, 57 insertions(+), 45 deletions(-) diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index 28937f99..46efaa51 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -173,50 +173,8 @@ const placeParcelsSellOrders = async ( } }; -let network = process.env.NETWORK; - -(async () => { - const config = require(`../config/${network}.js`); - - // https://stats.goerli.net/ - if (network === "goerli") - gasParams = { - gasLimit: 8e6, - gasPrice: 1e10, - }; - else if (network === "development") { - network = "local"; - } - const { - LANDProxy, - EstateRegistry, - Marketplace, - GnosisSafe: GnosisSafeInfo, - MANAToken, - } = TasitContracts[network]; - const { address: MANA_ADDRESS } = MANAToken; - const { address: LAND_PROXY_ADDRESS } = LANDProxy; - const { address: ESTATE_ADDRESS } = EstateRegistry; - const { address: MARKETPLACE_ADDRESS } = Marketplace; - const { address: GNOSIS_SAFE_ADDRESS } = GnosisSafeInfo; - - ConfigLoader.setConfig(config); - - const [minterWallet, sellerWallet] = accounts; - const { address: sellerAddress } = sellerWallet; - - const manaContract = new Mana(MANA_ADDRESS); - const landContract = new Land(LAND_PROXY_ADDRESS); - const estateContract = new Estate(ESTATE_ADDRESS); - const marketplaceContract = new Decentraland(MARKETPLACE_ADDRESS); - const gnosisSafeContract = new GnosisSafe(GNOSIS_SAFE_ADDRESS); - - // Fund Gnosis Safe wallet with Mana tokens and ethers - const provider = ProviderFactory.getProvider(); - await etherFaucet(provider, minterWallet, GNOSIS_SAFE_ADDRESS, TEN); - await erc20Faucet(manaContract, minterWallet, GNOSIS_SAFE_ADDRESS, BILLION); - - const allParcels = [ +const getParcels = () => { + const parcels = [ // Estate: all road adjacent parcels { x: -30, y: -105, metadata: `` }, { x: -31, y: -105, metadata: `` }, @@ -253,7 +211,12 @@ let network = process.env.NETWORK; }, ]; - const allEstates = [ + return parcels; +}; + +const getEstates = () => { + const allParcels = getParcels(); + const estates = [ { metadata: `all road adjacent parcels`, parcels: allParcels.slice(0, 5), @@ -276,6 +239,55 @@ let network = process.env.NETWORK; }, ]; + return estates; +}; + +let network = process.env.NETWORK; + +(async () => { + const config = require(`../config/${network}.js`); + + // https://stats.goerli.net/ + if (network === "goerli") + gasParams = { + gasLimit: 8e6, + gasPrice: 1e10, + }; + else if (network === "development") { + network = "local"; + } + const { + LANDProxy, + EstateRegistry, + Marketplace, + GnosisSafe: GnosisSafeInfo, + MANAToken, + } = TasitContracts[network]; + const { address: MANA_ADDRESS } = MANAToken; + const { address: LAND_PROXY_ADDRESS } = LANDProxy; + const { address: ESTATE_ADDRESS } = EstateRegistry; + const { address: MARKETPLACE_ADDRESS } = Marketplace; + const { address: GNOSIS_SAFE_ADDRESS } = GnosisSafeInfo; + + ConfigLoader.setConfig(config); + + const [minterWallet, sellerWallet] = accounts; + const { address: sellerAddress } = sellerWallet; + + const manaContract = new Mana(MANA_ADDRESS); + const landContract = new Land(LAND_PROXY_ADDRESS); + const estateContract = new Estate(ESTATE_ADDRESS); + const marketplaceContract = new Decentraland(MARKETPLACE_ADDRESS); + const gnosisSafeContract = new GnosisSafe(GNOSIS_SAFE_ADDRESS); + + // Fund Gnosis Safe wallet with Mana tokens and ethers + const provider = ProviderFactory.getProvider(); + await etherFaucet(provider, minterWallet, GNOSIS_SAFE_ADDRESS, TEN); + await erc20Faucet(manaContract, minterWallet, GNOSIS_SAFE_ADDRESS, BILLION); + + const allParcels = getParcels(); + const allEstates = getEstates(); + try { console.log("Creating parcels..."); await createMultipleParcels( From e04dc31e02797719b8540d0a4bb553fdbe347259 Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Thu, 21 Mar 2019 11:10:51 +0000 Subject: [PATCH 06/41] node-fetch --- package-lock.json | 28 +- packages/tasit-action/package-lock.json | 1041 +---------------------- packages/tasit-action/package.json | 1 + 3 files changed, 24 insertions(+), 1046 deletions(-) diff --git a/package-lock.json b/package-lock.json index 76e4a2ce..9183e6b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3619,13 +3619,11 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true, - "optional": true + "bundled": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3638,18 +3636,15 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "concat-map": { "version": "0.0.1", - "bundled": true, - "optional": true + "bundled": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "core-util-is": { "version": "1.0.2", @@ -3752,8 +3747,7 @@ }, "inherits": { "version": "2.0.3", - "bundled": true, - "optional": true + "bundled": true }, "ini": { "version": "1.3.5", @@ -3763,7 +3757,6 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3776,20 +3769,17 @@ "minimatch": { "version": "3.0.4", "bundled": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true, - "optional": true + "bundled": true }, "minipass": { "version": "2.3.5", "bundled": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -3806,7 +3796,6 @@ "mkdirp": { "version": "0.5.1", "bundled": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -3879,8 +3868,7 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true, - "optional": true + "bundled": true }, "object-assign": { "version": "4.1.1", @@ -3890,7 +3878,6 @@ "once": { "version": "1.4.0", "bundled": true, - "optional": true, "requires": { "wrappy": "1" } @@ -3996,7 +3983,6 @@ "string-width": { "version": "1.0.2", "bundled": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", diff --git a/packages/tasit-action/package-lock.json b/packages/tasit-action/package-lock.json index 40d396ae..b0b3a013 100644 --- a/packages/tasit-action/package-lock.json +++ b/packages/tasit-action/package-lock.json @@ -1,6 +1,6 @@ { "name": "tasit-action", - "version": "0.0.9", + "version": "0.0.14", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -863,57 +863,6 @@ "to-fast-properties": "^2.0.0" } }, - "@sinonjs/commons": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.3.0.tgz", - "integrity": "sha512-j4ZwhaHmwsCb4DlDOIWnI5YyKDNMoNThsmwEpfHx6a1EpsGZ9qYLxP++LMlmBRjtGptGHFsGItJ768snllFWpA==", - "dev": true, - "requires": { - "type-detect": "4.0.8" - } - }, - "@sinonjs/formatio": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@sinonjs/formatio/-/formatio-3.1.0.tgz", - "integrity": "sha512-ZAR2bPHOl4Xg6eklUGpsdiIJ4+J1SNag1DHHrG/73Uz/nVwXqjgUtRPLoS+aVyieN9cSbc0E4LsU984tWcDyNg==", - "dev": true, - "requires": { - "@sinonjs/samsam": "^2 || ^3" - } - }, - "@sinonjs/samsam": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-3.0.2.tgz", - "integrity": "sha512-m08g4CS3J6lwRQk1pj1EO+KEVWbrbXsmi9Pw0ySmrIbcVxVaedoFgLvFsV8wHLwh01EpROVz3KvVcD1Jmks9FQ==", - "dev": true, - "requires": { - "@sinonjs/commons": "^1.0.2", - "array-from": "^2.1.1", - "lodash.get": "^4.4.2" - } - }, - "@types/node": { - "version": "10.12.18", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz", - "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==" - }, - "aes-js": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.0.0.tgz", - "integrity": "sha1-4h3xCtbCBTKVvLuNq0Cwnb6ofk0=" - }, - "ansi-colors": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.3.tgz", - "integrity": "sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw==", - "dev": true - }, - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, "ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", @@ -934,15 +883,6 @@ "normalize-path": "^2.1.1" } }, - "argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dev": true, - "requires": { - "sprintf-js": "~1.0.2" - } - }, "arr-diff": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", @@ -961,12 +901,6 @@ "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", "dev": true }, - "array-from": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/array-from/-/array-from-2.1.1.tgz", - "integrity": "sha1-z+nYwmYoudxa7MYqn12PHzUsEZU=", - "dev": true - }, "array-unique": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", @@ -1066,11 +1000,6 @@ "dev": true, "optional": true }, - "bn.js": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", - "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==" - }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -1110,17 +1039,6 @@ } } }, - "brorand": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", - "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=" - }, - "browser-stdout": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", - "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", - "dev": true - }, "browserslist": { "version": "4.3.6", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.3.6.tgz", @@ -1155,12 +1073,6 @@ "unset-value": "^1.0.0" } }, - "camelcase": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.0.0.tgz", - "integrity": "sha512-faqwZqnWxbxn+F1d399ygeamQNy3lPp/H9H6rNrqYh4FSVCtcY+3cub1MxA8o9mDd55mM8Aghuu/kuyYA6VTsA==", - "dev": true - }, "caniuse-lite": { "version": "1.0.30000923", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000923.tgz", @@ -1190,12 +1102,6 @@ "check-error": "^1.0.2" } }, - "chai-bn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/chai-bn/-/chai-bn-0.1.1.tgz", - "integrity": "sha512-e1npVXt3cQfZ6oQET9oP38vNj/4HeJ4ojeUpuC8YzhVbTJpIDqANVt7TKi7Dq9yKlHySk2FqbmiMih35iT4DYg==", - "dev": true - }, "chalk": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", @@ -1258,23 +1164,6 @@ } } }, - "cliui": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-4.1.0.tgz", - "integrity": "sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==", - "dev": true, - "requires": { - "string-width": "^2.1.1", - "strip-ansi": "^4.0.0", - "wrap-ansi": "^2.0.0" - } - }, - "code-point-at": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true - }, "collection-visit": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", @@ -1352,19 +1241,6 @@ "dev": true, "optional": true }, - "cross-spawn": { - "version": "6.0.5", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", - "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", - "dev": true, - "requires": { - "nice-try": "^1.0.4", - "path-key": "^2.0.1", - "semver": "^5.5.0", - "shebang-command": "^1.2.0", - "which": "^1.2.9" - } - }, "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -1374,12 +1250,6 @@ "ms": "2.0.0" } }, - "decamelize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", - "dev": true - }, "decode-uri-component": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", @@ -1395,15 +1265,6 @@ "type-detect": "^4.0.0" } }, - "define-properties": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", - "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", - "dev": true, - "requires": { - "object-keys": "^1.0.12" - } - }, "define-property": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", @@ -1445,119 +1306,24 @@ } } }, - "detect-file": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz", - "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=", - "dev": true - }, - "diff": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", - "dev": true - }, "electron-to-chromium": { "version": "1.3.95", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.95.tgz", "integrity": "sha512-0JZEDKOQAE05EO/4rk3vLAE+PYFI9OLCVLAS4QAq1y+Bb2y1N6MyQJz62ynzHN/y0Ka/nO5jVJcahbCEdfiXLQ==", "dev": true }, - "elliptic": { - "version": "6.3.3", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.3.3.tgz", - "integrity": "sha1-VILZZG1UvLif19mU/J4ulWiHbj8=", - "requires": { - "bn.js": "^4.4.0", - "brorand": "^1.0.1", - "hash.js": "^1.0.0", - "inherits": "^2.0.1" - } - }, - "end-of-stream": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", - "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", - "dev": true, - "requires": { - "once": "^1.4.0" - } - }, - "es-abstract": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.13.0.tgz", - "integrity": "sha512-vDZfg/ykNxQVwup/8E1BZhVzFfBxs9NqMzGcvIJrqg5k2/5Za2bWo40dK2J1pgLngZ7c+Shh8lwYtLGyrwPutg==", - "dev": true, - "requires": { - "es-to-primitive": "^1.2.0", - "function-bind": "^1.1.1", - "has": "^1.0.3", - "is-callable": "^1.1.4", - "is-regex": "^1.0.4", - "object-keys": "^1.0.12" - } - }, - "es-to-primitive": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz", - "integrity": "sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==", - "dev": true, - "requires": { - "is-callable": "^1.1.4", - "is-date-object": "^1.0.1", - "is-symbol": "^1.0.2" - } - }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true }, - "esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true - }, "esutils": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", "dev": true }, - "ethers": { - "version": "4.0.23", - "resolved": "https://registry.npmjs.org/ethers/-/ethers-4.0.23.tgz", - "integrity": "sha512-9IwYV3LuESPF2cgwF42SL2vqrwWEsA2+15WVtO2dZb1F/twARaCWb7PrgoODldj+bmwKmUv3rG9PFfBkbumPwA==", - "requires": { - "@types/node": "^10.3.2", - "aes-js": "3.0.0", - "bn.js": "^4.4.0", - "elliptic": "6.3.3", - "hash.js": "1.1.3", - "js-sha3": "0.5.7", - "scrypt-js": "2.0.4", - "setimmediate": "1.0.4", - "uuid": "2.0.1", - "xmlhttprequest": "1.8.0" - } - }, - "execa": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz", - "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==", - "dev": true, - "requires": { - "cross-spawn": "^6.0.0", - "get-stream": "^4.0.0", - "is-stream": "^1.1.0", - "npm-run-path": "^2.0.0", - "p-finally": "^1.0.0", - "signal-exit": "^3.0.0", - "strip-eof": "^1.0.0" - } - }, "expand-brackets": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", @@ -1593,15 +1359,6 @@ } } }, - "expand-tilde": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", - "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", - "dev": true, - "requires": { - "homedir-polyfill": "^1.0.1" - } - }, "extend-shallow": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", @@ -1731,46 +1488,6 @@ "locate-path": "^2.0.0" } }, - "findup-sync": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-2.0.0.tgz", - "integrity": "sha1-kyaxSIwi0aYIhlCoaQGy2akKLLw=", - "dev": true, - "requires": { - "detect-file": "^1.0.0", - "is-glob": "^3.1.0", - "micromatch": "^3.0.4", - "resolve-dir": "^1.0.1" - }, - "dependencies": { - "is-glob": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", - "dev": true, - "requires": { - "is-extglob": "^2.1.0" - } - } - } - }, - "flat": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/flat/-/flat-4.1.0.tgz", - "integrity": "sha512-Px/TiLIznH7gEDlPXcUD4KnBusa6kR6ayRUVcnEAbreRIuhkqow/mun59BuRXwoYk7ZQOLW1ZM05ilIvK38hFw==", - "dev": true, - "requires": { - "is-buffer": "~2.0.3" - }, - "dependencies": { - "is-buffer": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", - "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==", - "dev": true - } - } - }, "for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", @@ -1818,7 +1535,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -2233,7 +1951,8 @@ "safe-buffer": { "version": "5.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -2289,6 +2008,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -2332,42 +2052,23 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, - "function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true - }, - "get-caller-file": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", - "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", - "dev": true - }, "get-func-name": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", "dev": true }, - "get-stream": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", - "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", - "dev": true, - "requires": { - "pump": "^3.0.0" - } - }, "get-value": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", @@ -2411,30 +2112,6 @@ } } }, - "global-modules": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz", - "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", - "dev": true, - "requires": { - "global-prefix": "^1.0.1", - "is-windows": "^1.0.1", - "resolve-dir": "^1.0.0" - } - }, - "global-prefix": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-1.0.2.tgz", - "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=", - "dev": true, - "requires": { - "expand-tilde": "^2.0.2", - "homedir-polyfill": "^1.0.1", - "ini": "^1.3.4", - "is-windows": "^1.0.1", - "which": "^1.2.14" - } - }, "globals": { "version": "11.9.0", "resolved": "https://registry.npmjs.org/globals/-/globals-11.9.0.tgz", @@ -2447,33 +2124,12 @@ "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==", "dev": true }, - "growl": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", - "dev": true - }, - "has": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", - "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, - "requires": { - "function-bind": "^1.1.1" - } - }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true }, - "has-symbols": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", - "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=", - "dev": true - }, "has-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", @@ -2506,36 +2162,12 @@ } } }, - "hash.js": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz", - "integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==", - "requires": { - "inherits": "^2.0.3", - "minimalistic-assert": "^1.0.0" - } - }, - "he": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", - "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", - "dev": true - }, "home-or-tmp": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/home-or-tmp/-/home-or-tmp-3.0.0.tgz", "integrity": "sha1-V6j+JM8zzdUkhgoVgh3cJchmcfs=", "dev": true }, - "homedir-polyfill": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", - "integrity": "sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==", - "dev": true, - "requires": { - "parse-passwd": "^1.0.0" - } - }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -2549,12 +2181,7 @@ "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" - }, - "ini": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, "invariant": { @@ -2566,12 +2193,6 @@ "loose-envify": "^1.0.0" } }, - "invert-kv": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-2.0.0.tgz", - "integrity": "sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==", - "dev": true - }, "is-accessor-descriptor": { "version": "0.1.6", "resolved": "http://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", @@ -2608,12 +2229,6 @@ "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, - "is-callable": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", - "integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==", - "dev": true - }, "is-data-descriptor": { "version": "0.1.4", "resolved": "http://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", @@ -2634,12 +2249,6 @@ } } }, - "is-date-object": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", - "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", - "dev": true - }, "is-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", @@ -2671,12 +2280,6 @@ "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", "dev": true }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - }, "is-glob": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.0.tgz", @@ -2722,30 +2325,6 @@ "isobject": "^3.0.1" } }, - "is-regex": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", - "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", - "dev": true, - "requires": { - "has": "^1.0.1" - } - }, - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", - "dev": true - }, - "is-symbol": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz", - "integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==", - "dev": true, - "requires": { - "has-symbols": "^1.0.0" - } - }, "is-windows": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", @@ -2758,12 +2337,6 @@ "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "dev": true }, - "isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", - "dev": true - }, "isobject": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", @@ -2776,27 +2349,12 @@ "integrity": "sha512-PxfGzSs0ztShKrUYPIn5r0MtyAhYcCwmndozzpz8YObbPnD1jFxzlBGbRnX2mIu6Z13xN6+PTu05TQFnZFlzow==", "dev": true }, - "js-sha3": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", - "integrity": "sha1-DU/9gALVMzqrr0oj7tL2N0yfKOc=" - }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", "dev": true }, - "js-yaml": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz", - "integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==", - "dev": true, - "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - } - }, "jsesc": { "version": "2.5.2", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", @@ -2820,27 +2378,12 @@ } } }, - "just-extend": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.0.2.tgz", - "integrity": "sha512-FrLwOgm+iXrPV+5zDU6Jqu4gCRXbWEQg2O3SKONsWE4w7AXFRkryS53bpWdaL9cNol+AmR3AEYz6kn+o0fCPnw==", - "dev": true - }, "kind-of": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", "dev": true }, - "lcid": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/lcid/-/lcid-2.0.0.tgz", - "integrity": "sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA==", - "dev": true, - "requires": { - "invert-kv": "^2.0.0" - } - }, "locate-path": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", @@ -2864,27 +2407,6 @@ "dev": true, "optional": true }, - "lodash.get": { - "version": "4.4.2", - "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", - "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", - "dev": true - }, - "log-symbols": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", - "integrity": "sha512-VeIAFslyIerEJLXHziedo2basKbMKtTw3vfn5IzG0XTjhAVEJyNHnL2p7vc+wBDSdQuUpNw3M2u6xb9QsAY5Eg==", - "dev": true, - "requires": { - "chalk": "^2.0.1" - } - }, - "lolex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lolex/-/lolex-3.0.0.tgz", - "integrity": "sha512-hcnW80h3j2lbUfFdMArd5UPA/vxZJ+G8vobd+wg3nVEQA0EigStbYcrG030FJxL6xiDDPEkoMatV9xIh5OecQQ==", - "dev": true - }, "loose-envify": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", @@ -2903,15 +2425,6 @@ "pify": "^3.0.0" } }, - "map-age-cleaner": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz", - "integrity": "sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w==", - "dev": true, - "requires": { - "p-defer": "^1.0.0" - } - }, "map-cache": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", @@ -2927,17 +2440,6 @@ "object-visit": "^1.0.0" } }, - "mem": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/mem/-/mem-4.1.0.tgz", - "integrity": "sha512-I5u6Q1x7wxO0kdOpYBB28xueHADYps5uty/zg936CiG8NTe5sJL8EjrCuLneuDW3PlMdZBGDIn8BirEVdovZvg==", - "dev": true, - "requires": { - "map-age-cleaner": "^0.1.1", - "mimic-fn": "^1.0.0", - "p-is-promise": "^2.0.0" - } - }, "micromatch": { "version": "3.1.10", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", @@ -2959,17 +2461,6 @@ "to-regex": "^3.0.2" } }, - "mimic-fn": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", - "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", - "dev": true - }, - "minimalistic-assert": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", - "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" - }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -3015,63 +2506,6 @@ "minimist": "0.0.8" } }, - "mocha": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-6.0.1.tgz", - "integrity": "sha512-tQzCxWqxSD6Oyg5r7Ptbev0yAMD8p+Vfh4snPFuiUsWqYj0eVYTDT2DkEY307FTj0WRlIWN9rWMMAUzRmijgVQ==", - "dev": true, - "requires": { - "ansi-colors": "3.2.3", - "browser-stdout": "1.3.1", - "debug": "3.2.6", - "diff": "3.5.0", - "escape-string-regexp": "1.0.5", - "findup-sync": "2.0.0", - "glob": "7.1.3", - "growl": "1.10.5", - "he": "1.2.0", - "js-yaml": "3.12.0", - "log-symbols": "2.2.0", - "minimatch": "3.0.4", - "mkdirp": "0.5.1", - "ms": "2.1.1", - "node-environment-flags": "1.0.4", - "object.assign": "4.1.0", - "strip-json-comments": "2.0.1", - "supports-color": "6.0.0", - "which": "1.3.1", - "wide-align": "1.1.3", - "yargs": "12.0.5", - "yargs-parser": "11.1.1", - "yargs-unparser": "1.5.0" - }, - "dependencies": { - "debug": { - "version": "3.2.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", - "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - }, - "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", - "dev": true - }, - "supports-color": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.0.0.tgz", - "integrity": "sha512-on9Kwidc1IUQo+bQdhi8+Tijpo0e1SS6RoGo2guUwn5vdaxw8RXOF9Vb2ws+ihWOmh4JnCJOvaziZWP1VABaLg==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - } - } - }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -3104,42 +2538,12 @@ "to-regex": "^3.0.1" } }, - "nice-try": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", - "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", + "node-fetch": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.3.0.tgz", + "integrity": "sha512-MOd8pV3fxENbryESLgVIeaGKrdl+uaYhCSSVkjeOb/31/njTpcis5aWfdqgNlHIrKOLRbMnfPINPOML2CIFeXA==", "dev": true }, - "nise": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/nise/-/nise-1.4.8.tgz", - "integrity": "sha512-kGASVhuL4tlAV0tvA34yJYZIVihrUt/5bDwpp4tTluigxUr2bBlJeDXmivb6NuEdFkqvdv/Ybb9dm16PSKUhtw==", - "dev": true, - "requires": { - "@sinonjs/formatio": "^3.1.0", - "just-extend": "^4.0.2", - "lolex": "^2.3.2", - "path-to-regexp": "^1.7.0", - "text-encoding": "^0.6.4" - }, - "dependencies": { - "lolex": { - "version": "2.7.5", - "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.7.5.tgz", - "integrity": "sha512-l9x0+1offnKKIzYVjyXU2SiwhXDLekRzKyhnbyldPHvC7BvLPVpdNUNR2KeMAiCN2D/kLNttZgQD5WjSxuBx3Q==", - "dev": true - } - } - }, - "node-environment-flags": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/node-environment-flags/-/node-environment-flags-1.0.4.tgz", - "integrity": "sha512-M9rwCnWVLW7PX+NUWe3ejEdiLYinRpsEre9hMkU/6NS4h+EEulYaDH1gCEZ2gyXsmw+RXYDaV2JkkTNcsPDJ0Q==", - "dev": true, - "requires": { - "object.getownpropertydescriptors": "^2.0.3" - } - }, "node-modules-regexp": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/node-modules-regexp/-/node-modules-regexp-1.0.0.tgz", @@ -3160,26 +2564,10 @@ "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", "dev": true, - "optional": true, "requires": { "remove-trailing-separator": "^1.0.1" } }, - "npm-run-path": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", - "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", - "dev": true, - "requires": { - "path-key": "^2.0.0" - } - }, - "number-is-nan": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true - }, "object-copy": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", @@ -3211,12 +2599,6 @@ } } }, - "object-keys": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.0.tgz", - "integrity": "sha512-6OO5X1+2tYkNyNEx6TsCxEqFfRWaqx6EtMiSbGrw8Ob8v9Ne+Hl8rBAgLBZn5wjEz3s/s6U1WXFUFOcxxAwUpg==", - "dev": true - }, "object-visit": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", @@ -3226,28 +2608,6 @@ "isobject": "^3.0.0" } }, - "object.assign": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", - "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", - "dev": true, - "requires": { - "define-properties": "^1.1.2", - "function-bind": "^1.1.1", - "has-symbols": "^1.0.0", - "object-keys": "^1.0.11" - } - }, - "object.getownpropertydescriptors": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz", - "integrity": "sha1-h1jIRvW0B62rDyNuCYbxSwUcqhY=", - "dev": true, - "requires": { - "define-properties": "^1.1.2", - "es-abstract": "^1.5.1" - } - }, "object.pick": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", @@ -3266,17 +2626,6 @@ "wrappy": "1" } }, - "os-locale": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-3.1.0.tgz", - "integrity": "sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q==", - "dev": true, - "requires": { - "execa": "^1.0.0", - "lcid": "^2.0.0", - "mem": "^4.0.0" - } - }, "output-file-sync": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/output-file-sync/-/output-file-sync-2.0.1.tgz", @@ -3288,24 +2637,6 @@ "mkdirp": "^0.5.1" } }, - "p-defer": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-1.0.0.tgz", - "integrity": "sha1-n26xgvbJqozXQwBKfU+WsZaw+ww=", - "dev": true - }, - "p-finally": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", - "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", - "dev": true - }, - "p-is-promise": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-2.0.0.tgz", - "integrity": "sha512-pzQPhYMCAgLAKPWD2jC3Se9fEfrD9npNos0y150EeqZll7akhEgGhTW/slB6lHku8AvYGiJ+YJ5hfHKePPgFWg==", - "dev": true - }, "p-limit": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", @@ -3330,12 +2661,6 @@ "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", "dev": true }, - "parse-passwd": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", - "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", - "dev": true - }, "pascalcase": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", @@ -3361,35 +2686,12 @@ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, - "path-key": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", - "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", - "dev": true - }, "path-parse": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", "dev": true }, - "path-to-regexp": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.7.0.tgz", - "integrity": "sha1-Wf3g9DW62suhA6hOnTvGTpa5k30=", - "dev": true, - "requires": { - "isarray": "0.0.1" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - } - } - }, "pathval": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", @@ -3439,16 +2741,6 @@ "dev": true, "optional": true }, - "pump": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", - "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", - "dev": true, - "requires": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" - } - }, "readable-stream": { "version": "2.3.6", "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", @@ -3557,8 +2849,7 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", - "dev": true, - "optional": true + "dev": true }, "repeat-element": { "version": "1.1.3", @@ -3572,18 +2863,6 @@ "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", "dev": true }, - "require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", - "dev": true - }, - "require-main-filename": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", - "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", - "dev": true - }, "resolve": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.9.0.tgz", @@ -3593,16 +2872,6 @@ "path-parse": "^1.0.6" } }, - "resolve-dir": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-1.0.1.tgz", - "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=", - "dev": true, - "requires": { - "expand-tilde": "^2.0.0", - "global-modules": "^1.0.0" - } - }, "resolve-url": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", @@ -3630,23 +2899,12 @@ "ret": "~0.1.10" } }, - "scrypt-js": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-2.0.4.tgz", - "integrity": "sha512-4KsaGcPnuhtCZQCxFxN3GVYIhKFPTdLd8PLC552XwbMndtD0cjRFAhDuuydXQ0h08ZfPgzqe6EKHozpuH74iDw==" - }, "semver": { "version": "5.6.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", "dev": true }, - "set-blocking": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", - "dev": true - }, "set-value": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", @@ -3670,47 +2928,6 @@ } } }, - "setimmediate": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.4.tgz", - "integrity": "sha1-IOgd5iLUoCWIzgyNqJc8vPHTE48=" - }, - "shebang-command": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", - "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", - "dev": true, - "requires": { - "shebang-regex": "^1.0.0" - } - }, - "shebang-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", - "dev": true - }, - "signal-exit": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", - "dev": true - }, - "sinon": { - "version": "7.2.2", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-7.2.2.tgz", - "integrity": "sha512-WLagdMHiEsrRmee3jr6IIDntOF4kbI6N2pfbi8wkv50qaUQcBglkzkjtoOEbeJ2vf1EsrHhLI+5Ny8//WHdMoA==", - "dev": true, - "requires": { - "@sinonjs/commons": "^1.2.0", - "@sinonjs/formatio": "^3.1.0", - "@sinonjs/samsam": "^3.0.2", - "diff": "^3.5.0", - "lolex": "^3.0.0", - "nise": "^1.4.7", - "supports-color": "^5.5.0" - } - }, "slash": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", @@ -3876,12 +3093,6 @@ "extend-shallow": "^3.0.0" } }, - "sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", - "dev": true - }, "static-extend": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", @@ -3903,16 +3114,6 @@ } } }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - } - }, "string_decoder": { "version": "1.1.1", "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", @@ -3923,27 +3124,6 @@ "safe-buffer": "~5.1.0" } }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "^3.0.0" - } - }, - "strip-eof": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", - "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", - "dev": true - }, - "strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", - "dev": true - }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -3953,22 +3133,6 @@ "has-flag": "^3.0.0" } }, - "tasit-account": { - "version": "0.0.9", - "resolved": "https://registry.npmjs.org/tasit-account/-/tasit-account-0.0.9.tgz", - "integrity": "sha512-w6F+nYdaVL4Axvlhr64cLGa06JyU7oiehRzi8ufNjI9jaSNcVzv8wXJ1ZHE+wWkWKyUw6rX5ffm6sOkFsiw1IA==", - "dev": true, - "requires": { - "@babel/runtime": "^7.1.5", - "ethers": "^4.0.21" - } - }, - "text-encoding": { - "version": "0.6.4", - "resolved": "http://registry.npmjs.org/text-encoding/-/text-encoding-0.6.4.tgz", - "integrity": "sha1-45mpgiV6J22uQou5KEXLcb3CbRk=", - "dev": true - }, "to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", @@ -4158,184 +3322,11 @@ "dev": true, "optional": true }, - "uuid": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.1.tgz", - "integrity": "sha1-wqMN7bPlNdcsz4LjQ5QaULqFM6w=" - }, - "which": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", - "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } - }, - "which-module": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", - "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", - "dev": true - }, - "wide-align": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", - "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", - "dev": true, - "requires": { - "string-width": "^1.0.2 || 2" - } - }, - "wrap-ansi": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", - "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", - "dev": true, - "requires": { - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1" - }, - "dependencies": { - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "dev": true, - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "dev": true, - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - } - } - }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true - }, - "xmlhttprequest": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz", - "integrity": "sha1-Z/4HXFwk/vOfnWX197f+dRcZaPw=" - }, - "y18n": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", - "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", - "dev": true - }, - "yargs": { - "version": "12.0.5", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-12.0.5.tgz", - "integrity": "sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw==", - "dev": true, - "requires": { - "cliui": "^4.0.0", - "decamelize": "^1.2.0", - "find-up": "^3.0.0", - "get-caller-file": "^1.0.1", - "os-locale": "^3.0.0", - "require-directory": "^2.1.1", - "require-main-filename": "^1.0.1", - "set-blocking": "^2.0.0", - "string-width": "^2.0.0", - "which-module": "^2.0.0", - "y18n": "^3.2.1 || ^4.0.0", - "yargs-parser": "^11.1.1" - }, - "dependencies": { - "find-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", - "dev": true, - "requires": { - "locate-path": "^3.0.0" - } - }, - "locate-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", - "dev": true, - "requires": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" - } - }, - "p-limit": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.1.0.tgz", - "integrity": "sha512-NhURkNcrVB+8hNfLuysU8enY5xn2KXphsHBaC2YmRNTZRc7RWusw6apSpdEj3jo4CMb6W9nrF6tTnsJsJeyu6g==", - "dev": true, - "requires": { - "p-try": "^2.0.0" - } - }, - "p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", - "dev": true, - "requires": { - "p-limit": "^2.0.0" - } - }, - "p-try": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.0.0.tgz", - "integrity": "sha512-hMp0onDKIajHfIkdRk3P4CdCmErkYAxxDtP3Wx/4nZ3aGlau2VKh3mZpcuFkH27WQkL/3WBCPOktzA9ZOAnMQQ==", - "dev": true - } - } - }, - "yargs-parser": { - "version": "11.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-11.1.1.tgz", - "integrity": "sha512-C6kB/WJDiaxONLJQnF8ccx9SEeoTTLek8RVbaOIsrAUS8VrBEXfmeSnCZxygc+XC2sNMBIwOOnfcxiynjHsVSQ==", - "dev": true, - "requires": { - "camelcase": "^5.0.0", - "decamelize": "^1.2.0" - } - }, - "yargs-unparser": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-1.5.0.tgz", - "integrity": "sha512-HK25qidFTCVuj/D1VfNiEndpLIeJN78aqgR23nL3y4N0U/91cOAzqfHlF8n2BvoNDcZmJKin3ddNSvOxSr8flw==", - "dev": true, - "requires": { - "flat": "^4.1.0", - "lodash": "^4.17.11", - "yargs": "^12.0.5" - } } } } diff --git a/packages/tasit-action/package.json b/packages/tasit-action/package.json index 51dd0ec8..712d8954 100644 --- a/packages/tasit-action/package.json +++ b/packages/tasit-action/package.json @@ -38,6 +38,7 @@ "chai": "^4.2.0", "chai-as-promised": "^7.1.1", "mocha": "^6.0.2", + "node-fetch": "^2.3.0", "sinon": "^7.2.5", "tasit-account": "^0.0.14" } From a9523f358c19e022b34334449536a41db9e2619c Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Thu, 21 Mar 2019 11:19:59 +0000 Subject: [PATCH 07/41] Refactoring --- .../scripts/populateDecentralandContracts.js | 57 +++++++++---------- 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index 46efaa51..743ed822 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -175,30 +175,6 @@ const placeParcelsSellOrders = async ( const getParcels = () => { const parcels = [ - // Estate: all road adjacent parcels - { x: -30, y: -105, metadata: `` }, - { x: -31, y: -105, metadata: `` }, - { x: -29, y: -105, metadata: `` }, - { x: -30, y: -104, metadata: `` }, - { x: -29, y: -104, metadata: `` }, - - // Estate: Forest / university estate - { x: 3, y: 141, metadata: `` }, - { x: 2, y: 141, metadata: `` }, - - // Estate: Down-Town Bridge - { x: -39, y: 30, metadata: `` }, - { x: -39, y: 31, metadata: `` }, - - // Estate: Decentraland University Underpass - { x: -47, y: 124, metadata: `` }, - { x: -48, y: 124, metadata: `` }, - - // Estate: Villa Beau Soleil H - { x: 39, y: -114, metadata: `Letter N` }, - { x: 39, y: -113, metadata: `Letter "N"` }, - - // Unique parcels { x: -20, y: 36, metadata: `Premium Downtown,road adjacent,central area.` }, { x: -61, y: 125, metadata: `Vegas/Univeristy` }, { x: 141, y: -122, metadata: `dePeets Place 6` }, @@ -215,27 +191,41 @@ const getParcels = () => { }; const getEstates = () => { - const allParcels = getParcels(); const estates = [ { metadata: `all road adjacent parcels`, - parcels: allParcels.slice(0, 5), + parcels: [ + { x: -30, y: -105, metadata: `` }, + { x: -31, y: -105, metadata: `` }, + { x: -29, y: -105, metadata: `` }, + { x: -30, y: -104, metadata: `` }, + { x: -29, y: -104, metadata: `` }, + ], }, { metadata: `Forest / university estate`, - parcels: allParcels.slice(5, 7), + parcels: [{ x: 3, y: 141, metadata: `` }, { x: 2, y: 141, metadata: `` }], }, { metadata: `Down-Town Bridge`, - parcels: allParcels.slice(7, 9), + parcels: [ + { x: -39, y: 30, metadata: `` }, + { x: -39, y: 31, metadata: `` }, + ], }, { metadata: `Decentraland University Underpass`, - parcels: allParcels.slice(9, 11), + parcels: [ + { x: -47, y: 124, metadata: `` }, + { x: -48, y: 124, metadata: `` }, + ], }, { metadata: `Estate: Villa Beau Soleil H`, - parcels: allParcels.slice(11, 13), + parcels: [ + { x: 39, y: -114, metadata: `Letter N` }, + { x: 39, y: -113, metadata: `Letter "N"` }, + ], }, ]; @@ -285,8 +275,13 @@ let network = process.env.NETWORK; await etherFaucet(provider, minterWallet, GNOSIS_SAFE_ADDRESS, TEN); await erc20Faucet(manaContract, minterWallet, GNOSIS_SAFE_ADDRESS, BILLION); - const allParcels = getParcels(); + const uniqueParcels = getParcels(); const allEstates = getEstates(); + let allParcels = []; + allEstates.forEach( + estate => (allParcels = [...allParcels, ...estate.parcels]) + ); + allParcels = [...allParcels, ...uniqueParcels]; try { console.log("Creating parcels..."); From 26de0e73b22402bf4452b3b0c027350b5ec3c95f Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Thu, 21 Mar 2019 11:27:36 +0000 Subject: [PATCH 08/41] Refactoring --- .../scripts/populateDecentralandContracts.js | 48 +++++++++++++++---- .../scripts/checkDecentralandContractsData.js | 5 +- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index 743ed822..ebf7ab2b 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -1,6 +1,6 @@ // This script will add land parcels, estates and sell orders to the Decentraland marketplace // This data is being used to test the Decentraland demo app - +import fetch from "node-fetch"; import TasitAction from "../../../tasit-action/dist/"; const { ConfigLoader, @@ -173,8 +173,10 @@ const placeParcelsSellOrders = async ( } }; -const getParcels = () => { - const parcels = [ +let network = process.env.NETWORK; + +const getParcels = async () => { + let parcels = [ { x: -20, y: 36, metadata: `Premium Downtown,road adjacent,central area.` }, { x: -61, y: 125, metadata: `Vegas/Univeristy` }, { x: 141, y: -122, metadata: `dePeets Place 6` }, @@ -187,11 +189,24 @@ const getParcels = () => { }, ]; + // const res = await fetch( + // "https://api.decentraland.org/v1/parcels?status=open&limit=50" + // ); + // const json = await res.json(); + // const { data: jsonData } = json; + // const { parcels: parcelsFromAPI } = jsonData; + // + // parcelsFromAPI.map(parcel => { + // const { x, y, data } = parcel; + // const { name: metadata } = data; + // parcels = [...parcels, { x, y, metadata }]; + // }); + return parcels; }; -const getEstates = () => { - const estates = [ +const getEstates = async () => { + let estates = [ { metadata: `all road adjacent parcels`, parcels: [ @@ -229,11 +244,22 @@ const getEstates = () => { }, ]; + // const res = await fetch( + // "https://api.decentraland.org/v1/estates?status=open&limit=50" + // ); + // const json = await res.json(); + // const { data: jsonData } = json; + // const { estates: estatesFromAPI } = jsonData; + // + // estatesFromAPI.map(estate => { + // const { data } = estate; + // const { name: metadata, parcels } = data; + // estates = [...estates, { metadata, parcels }]; + // }); + return estates; }; -let network = process.env.NETWORK; - (async () => { const config = require(`../config/${network}.js`); @@ -275,8 +301,8 @@ let network = process.env.NETWORK; await etherFaucet(provider, minterWallet, GNOSIS_SAFE_ADDRESS, TEN); await erc20Faucet(manaContract, minterWallet, GNOSIS_SAFE_ADDRESS, BILLION); - const uniqueParcels = getParcels(); - const allEstates = getEstates(); + const uniqueParcels = await getParcels(); + const allEstates = await getEstates(); let allParcels = []; allEstates.forEach( estate => (allParcels = [...allParcels, ...estate.parcels]) @@ -294,9 +320,11 @@ let network = process.env.NETWORK; const allParcelsIds = allParcels.map(async parcel => { const { x, y } = parcel; - return await landContract.encodeTokenId(x, y); + return landContract.encodeTokenId(x, y); }); + await Promise.all(allParcelsIds); + // Update parcels with metadata console.log("Updating parcels with metadata..."); landContract.setWallet(sellerWallet); diff --git a/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js b/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js index 8d048b4e..be0dacff 100644 --- a/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js +++ b/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js @@ -72,7 +72,10 @@ describe("Decentraland App pre-conditions", () => { `https://api.decentraland.org/v1/estates/${assetId}/map.png` ); const imageData = (await image.buffer()).toString("base64"); - expect(imageData).not.equals(blankImageData); + expect( + imageData, + `The image of the estate (id: ${assetId}) is blank` + ).not.equals(blankImageData); } }); }); From 525cef9f676b3c3bcd0b4e70221580a187c83a91 Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Thu, 21 Mar 2019 12:11:35 +0000 Subject: [PATCH 09/41] More parcels --- .../scripts/populateDecentralandContracts.js | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index ebf7ab2b..0ef085e8 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -46,6 +46,7 @@ const createMultipleParcels = async ( beneficiaryAddress, gasParams ); + await assignAction.waitForNonceToUpdate(); }; @@ -189,18 +190,25 @@ const getParcels = async () => { }, ]; - // const res = await fetch( - // "https://api.decentraland.org/v1/parcels?status=open&limit=50" - // ); - // const json = await res.json(); - // const { data: jsonData } = json; - // const { parcels: parcelsFromAPI } = jsonData; - // - // parcelsFromAPI.map(parcel => { - // const { x, y, data } = parcel; - // const { name: metadata } = data; - // parcels = [...parcels, { x, y, metadata }]; - // }); + const res = await fetch( + "https://api.decentraland.org/v1/parcels?status=open&limit=50" + ); + const json = await res.json(); + const { data: jsonData } = json; + const { parcels: parcelsFromAPI } = jsonData; + + // Note: Since the current test net contract was populated with the assets above, + // this check is necessary. From a new deployment we should keep on this function + // assets only from Decentraland API + const withoutDuplicates = parcelsFromAPI.filter( + fromAPI => !parcels.find(p => p.x == fromAPI.x && p.y == fromAPI.y) + ); + + withoutDuplicates.map(parcel => { + const { x, y, data } = parcel; + const { name: metadata } = data; + parcels = [...parcels, { x, y, metadata }]; + }); return parcels; }; @@ -329,7 +337,9 @@ const getEstates = async () => { console.log("Updating parcels with metadata..."); landContract.setWallet(sellerWallet); for (let parcel of allParcels) { - const { x, y, metadata: parcelName } = parcel; + let { x, y, metadata: parcelName } = parcel; + if (!parcelName) parcelName = ""; + console.log(`Updating ${x},${y}`); const updateAction = landContract.updateLandData(x, y, parcelName); await updateAction.waitForNonceToUpdate(); } @@ -361,14 +371,11 @@ const getEstates = async () => { sellerWallet ); - // All unique parcels - const landIdsToSell = allParcelsIds.slice(13, 19); - console.log("Placing parcels sellorders..."); await placeParcelsSellOrders( marketplaceContract, LAND_PROXY_ADDRESS, - landIdsToSell, + allParcelsIds, expireAt, sellerWallet ); From ec313c6fe66adc274ef6790080eecb9aa3c151ba Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Thu, 21 Mar 2019 17:48:37 +0000 Subject: [PATCH 10/41] WIP --- packages/tasit-contracts/package.json | 2 +- .../scripts/populateDecentralandContracts.js | 40 +- .../populateDecentralandContracts_append.js | 515 ++++++++++++++++++ 3 files changed, 520 insertions(+), 37 deletions(-) create mode 100644 packages/tasit-contracts/src/scripts/populateDecentralandContracts_append.js diff --git a/packages/tasit-contracts/package.json b/packages/tasit-contracts/package.json index b0f5b82a..952e58bc 100644 --- a/packages/tasit-contracts/package.json +++ b/packages/tasit-contracts/package.json @@ -26,7 +26,7 @@ "install:3rd-parties": "./3rd-parties/run_on_all.sh install `pwd`", "compile:3rd-parties": "./3rd-parties/run_on_all.sh compile `pwd`", "clean:3rd-parties": "./3rd-parties/run_on_all.sh clean `pwd`", - "populate-contracts": "NETWORK=development npx babel-node src/scripts/populateDecentralandContracts.js" + "populate-contracts": "NETWORK=development npx babel-node src/scripts/populateDecentralandContracts.js && NETWORK=development npx babel-node src/scripts/populateDecentralandContracts_append.js" }, "bugs": { "url": "https://github.com/tasitlabs/tasitsdk/issues" diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index 0ef085e8..f8a8bbaf 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -46,7 +46,6 @@ const createMultipleParcels = async ( beneficiaryAddress, gasParams ); - await assignAction.waitForNonceToUpdate(); }; @@ -190,26 +189,6 @@ const getParcels = async () => { }, ]; - const res = await fetch( - "https://api.decentraland.org/v1/parcels?status=open&limit=50" - ); - const json = await res.json(); - const { data: jsonData } = json; - const { parcels: parcelsFromAPI } = jsonData; - - // Note: Since the current test net contract was populated with the assets above, - // this check is necessary. From a new deployment we should keep on this function - // assets only from Decentraland API - const withoutDuplicates = parcelsFromAPI.filter( - fromAPI => !parcels.find(p => p.x == fromAPI.x && p.y == fromAPI.y) - ); - - withoutDuplicates.map(parcel => { - const { x, y, data } = parcel; - const { name: metadata } = data; - parcels = [...parcels, { x, y, metadata }]; - }); - return parcels; }; @@ -252,19 +231,6 @@ const getEstates = async () => { }, ]; - // const res = await fetch( - // "https://api.decentraland.org/v1/estates?status=open&limit=50" - // ); - // const json = await res.json(); - // const { data: jsonData } = json; - // const { estates: estatesFromAPI } = jsonData; - // - // estatesFromAPI.map(estate => { - // const { data } = estate; - // const { name: metadata, parcels } = data; - // estates = [...estates, { metadata, parcels }]; - // }); - return estates; }; @@ -339,7 +305,6 @@ const getEstates = async () => { for (let parcel of allParcels) { let { x, y, metadata: parcelName } = parcel; if (!parcelName) parcelName = ""; - console.log(`Updating ${x},${y}`); const updateAction = landContract.updateLandData(x, y, parcelName); await updateAction.waitForNonceToUpdate(); } @@ -371,11 +336,14 @@ const getEstates = async () => { sellerWallet ); + // All unique parcels + const landIdsToSell = allParcelsIds.slice(13, 19); + console.log("Placing parcels sellorders..."); await placeParcelsSellOrders( marketplaceContract, LAND_PROXY_ADDRESS, - allParcelsIds, + landIdsToSell, expireAt, sellerWallet ); diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts_append.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts_append.js new file mode 100644 index 00000000..4b597ae3 --- /dev/null +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts_append.js @@ -0,0 +1,515 @@ +// This script will add land parcels, estates and sell orders to the Decentraland marketplace +// This data is being used to test the Decentraland demo app +import fetch from "node-fetch"; +import TasitAction from "../../../tasit-action/dist/"; +const { + ConfigLoader, + ERC20, + ERC721, + Marketplace: MarketplaceContracts, +} = TasitAction; +const { Mana } = ERC20; +const { Estate, Land } = ERC721; +const { Decentraland } = MarketplaceContracts; + +import ProviderFactory from "../../../tasit-action/dist/ProviderFactory"; + +import TasitContractBasedAccount from "../../../tasit-contract-based-account/dist/"; +const { GnosisSafe } = TasitContractBasedAccount; + +import TasitContracts from ".."; + +import fs from "fs"; + +import { duration } from "../../../tasit-sdk/dist/testHelpers/helpers"; + +const { ONE, TEN, ONE_HUNDRED, ONE_THOUSAND, BILLION, WeiPerEther } = constants; + +const createMultipleParcels = async ( + landContract, + parcels, + beneficiaryAddress, + contractOwnerWallet +) => { + let xArray = []; + let yArray = []; + + parcels.forEach(parcel => { + xArray.push(parcel.x); + yArray.push(parcel.y); + }); + + landContract.setWallet(contractOwnerWallet); + + for (let parcel of parcels) { + const { x, y } = parcel; + console.log(`creating parcel ${x},${y}....`); + const assignAction = landContract.assignNewParcel( + `${x}`, + `${y}`, + beneficiaryAddress, + gasParams + ); + + await assignAction.waitForNonceToUpdate(); + } + + // const assignAction = landContract.assignMultipleParcels( + // xArray, + // yArray, + // beneficiaryAddress, + // gasParams + // ); + // await assignAction.waitForNonceToUpdate(); +}; + +const createEstate = async (estateContract, landContract, estate, wallet) => { + const { metadata: estateName, parcels } = estate; + const { address: beneficiaryAddress } = wallet; + + let xArray = []; + let yArray = []; + + parcels.forEach(parcel => { + xArray.push(parcel.x); + yArray.push(parcel.y); + }); + + console.log(`creating estate.... ${xArray} - ${yArray}`); + + landContract.setWallet(wallet); + const action = landContract.createEstateWithMetadata( + xArray, + yArray, + beneficiaryAddress, + estateName, + gasParams + ); + + const estateId = await new Promise((resolve, reject) => { + estateContract.once("CreateEstate", message => { + const { data } = message; + const { args } = data; + resolve(args._estateId); + }); + }); + + await action.waitForNonceToUpdate(); + console.log("created id =", estateId); + + return estateId; +}; + +const createEstates = async (estateContract, landContract, estates, wallet) => { + const estateIds = []; + for (let estate of estates) { + const id = await createEstate(estateContract, landContract, estate, wallet); + estateIds.push(id); + } + return estateIds; +}; + +const approveMarketplace = async ( + marketplaceAddress, + landContract, + estateContract, + assetsOwnerWallet +) => { + // Set false to remove approval + const authorized = true; + + estateContract.setWallet(assetsOwnerWallet); + const estateApproval = estateContract.setApprovalForAll( + marketplaceAddress, + authorized, + gasParams + ); + await estateApproval.waitForNonceToUpdate(); + + landContract.setWallet(assetsOwnerWallet); + const landApproval = landContract.setApprovalForAll( + marketplaceAddress, + authorized, + gasParams + ); + await landApproval.waitForNonceToUpdate(); +}; + +function getRandomInt(min, max) { + min = Math.ceil(min); + max = Math.floor(max); + return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive +} + +const placeEstatesSellOrders = async ( + marketplace, + estateAddress, + estateIds, + expireAt, + sellerWallet +) => { + const price = getRandomInt(10, 100) + "000"; + const priceInWei = bigNumberify(price).mul(WeiPerEther); + + marketplace.setWallet(sellerWallet); + for (let assetId of estateIds) { + const action = marketplace.createOrder( + estateAddress, + assetId, + priceInWei, + expireAt, + gasParams + ); + await action.waitForNonceToUpdate(); + } +}; + +const placeParcelsSellOrders = async ( + marketplace, + landAddress, + landIds, + expireAt, + sellerWallet +) => { + const price = getRandomInt(10, 100) + "000"; + const priceInWei = bigNumberify(price).mul(WeiPerEther); + + marketplace.setWallet(sellerWallet); + for (let assetId of landIds) { + const action = marketplace.createOrder( + landAddress, + assetId, + priceInWei, + expireAt, + gasParams + ); + await action.waitForNonceToUpdate(); + } +}; + +let network = process.env.NETWORK; + +const getAlreadyCreatedUniqueParcels = () => { + const parcels = [ + { x: -20, y: 36, metadata: `Premium Downtown,road adjacent,central area.` }, + { x: -61, y: 125, metadata: `Vegas/Univeristy` }, + { x: 141, y: -122, metadata: `dePeets Place 6` }, + { x: -150, y: 22, metadata: `Fashion District X` }, + { x: -150, y: 23, metadata: `District X Fashion Sandwich` }, + { + x: -7, + y: -110, + metadata: `On a junction right opposite two large estates :O)`, + }, + ]; + + return parcels; +}; + +const getAlreadyCreatedParcels = () => { + const uniqueParcels = getAlreadyCreatedUniqueParcels(); + const estates = getAlreadyCreatedEstates(); + + let estatesParcels = []; + + estates.forEach( + estate => (estatesParcels = [...estatesParcels, ...estate.parcels]) + ); + + return [...estatesParcels, ...uniqueParcels]; +}; + +const getAlreadyCreatedEstates = () => { + let estates = [ + { + metadata: `all road adjacent parcels`, + parcels: [ + { x: -30, y: -105, metadata: `` }, + { x: -31, y: -105, metadata: `` }, + { x: -29, y: -105, metadata: `` }, + { x: -30, y: -104, metadata: `` }, + { x: -29, y: -104, metadata: `` }, + ], + }, + { + metadata: `Forest / university estate`, + parcels: [{ x: 3, y: 141, metadata: `` }, { x: 2, y: 141, metadata: `` }], + }, + { + metadata: `Down-Town Bridge`, + parcels: [ + { x: -39, y: 30, metadata: `` }, + { x: -39, y: 31, metadata: `` }, + ], + }, + { + metadata: `Decentraland University Underpass`, + parcels: [ + { x: -47, y: 124, metadata: `` }, + { x: -48, y: 124, metadata: `` }, + ], + }, + { + metadata: `Estate: Villa Beau Soleil H`, + parcels: [ + { x: 39, y: -114, metadata: `Letter N` }, + { x: 39, y: -113, metadata: `Letter "N"` }, + ], + }, + ]; + + return estates; +}; + +const getParcelsFromAPI = async () => { + const res = await fetch( + "https://api.decentraland.org/v1/parcels?status=open&limit=50" + ); + const json = await res.json(); + const { data: jsonData } = json; + const { parcels: parcelsFromAPI } = jsonData; + + const parcels = parcelsFromAPI.map(parcel => { + const { x, y, data } = parcel; + let { name: metadata } = data; + if (!metadata) metadata = ""; + return { x, y, metadata }; + }); + + // Note: Since the current test net contract was populated with the assets, this check is necessary. + const createdParcels = getAlreadyCreatedParcels(); + const withoutDuplicates = parcels.filter( + fromAPI => !createdParcels.find(p => p.x == fromAPI.x && p.y == fromAPI.y) + ); + + return withoutDuplicates; +}; + +const parcelsAreEqual = (p1, p2) => p1.x === p2.x && p1.y === p2.y; + +const findParcel = (parcel, listOfParcels) => { + return listOfParcels.find(p => parcelsAreEqual(p, parcel)); +}; + +// Tech-debt: Move to a functional approach +const estatesWithConflict = (estate1, estate2) => { + const { parcels: parcels1 } = estate1; + const { parcels: parcels2 } = estate2; + for (let p1 of parcels1) { + for (let p2 of parcels2) { + if (parcelsAreEqual(p1, p2)) return true; + } + } + + return false; +}; + +const estateContainsParcelFromList = (estate, listOfParcels) => { + const { parcels: estateParcels } = estate; + + for (let parcel of estateParcels) + if (findParcel(parcel, listOfParcels)) return true; + + return false; +}; + +const getEstatesFromAPI = async () => { + const res = await fetch( + "https://api.decentraland.org/v1/estates?status=open&limit=50" + ); + const json = await res.json(); + const { data: jsonData } = json; + const { estates: estatesFromAPI } = jsonData; + + let estates = estatesFromAPI.map(estate => { + const { data } = estate; + const { name: metadata, parcels } = data; + return { metadata, parcels }; + }); + + const createdParcels = getAlreadyCreatedParcels(); + estates = estates.filter( + estate => !estateContainsParcelFromList(estate, createdParcels) + ); + + const createdEstates = getAlreadyCreatedEstates(); + let withoutDuplicates = []; + for (let e1 of estates) { + for (let e2 of createdEstates) + if (!estatesWithConflict(e1, e2)) { + withoutDuplicates = [...withoutDuplicates, e1]; + break; + } + } + + return withoutDuplicates.filter(e => e.parcels.length < 10); + //return []; +}; + +(async () => { + const config = require(`../config/${network}.js`); + + // https://stats.goerli.net/ + if (network === "goerli") + gasParams = { + gasLimit: 8e6, + gasPrice: 1e10, + }; + else if (network === "development") { + network = "local"; + } + const { + LANDProxy, + EstateRegistry, + Marketplace, + GnosisSafe: GnosisSafeInfo, + MANAToken, + } = TasitContracts[network]; + const { address: MANA_ADDRESS } = MANAToken; + const { address: LAND_PROXY_ADDRESS } = LANDProxy; + const { address: ESTATE_ADDRESS } = EstateRegistry; + const { address: MARKETPLACE_ADDRESS } = Marketplace; + const { address: GNOSIS_SAFE_ADDRESS } = GnosisSafeInfo; + + ConfigLoader.setConfig(config); + + const [minterWallet, sellerWallet] = accounts; + const { address: sellerAddress } = sellerWallet; + + const manaContract = new Mana(MANA_ADDRESS); + const landContract = new Land(LAND_PROXY_ADDRESS); + const estateContract = new Estate(ESTATE_ADDRESS); + const marketplaceContract = new Decentraland(MARKETPLACE_ADDRESS); + const gnosisSafeContract = new GnosisSafe(GNOSIS_SAFE_ADDRESS); + + // Fund Gnosis Safe wallet with Mana tokens and ethers + const provider = ProviderFactory.getProvider(); + + const parcelsFromAPI = await getParcelsFromAPI(); + const estatesFromAPI = await getEstatesFromAPI(); + + let parcelsToCreate = [...parcelsFromAPI]; + //let estatesToCreate = []; + let allEstates = [...estatesFromAPI]; + + // Extract parcels from estates + estatesFromAPI.forEach(estate => { + const { parcels } = estate; + const withoutDup = parcels.filter(p => !findParcel(p, parcelsFromAPI)); + parcelsToCreate = [...parcelsToCreate, ...withoutDup]; + }); + + // const alreadyCreatedEstates = getAlreadyCreatedEstates(); + // let alreadyCreatedParcels = getAlreadyCreatedParcels(); + // + // alreadyCreatedEstates.forEach( + // estate => + // (alreadyCreatedParcels = [...alreadyCreatedParcels, ...estate.parcels]) + // ); + // const createdParcels = getAlreadyCreatedParcels(); + // console.log(`createdParcels: ${createdParcels.length}`); + // createdParcels.forEach(p => console.log(`${p.x}, ${p.y}`)); + // console.log("-----------------------------------------------"); + // console.log(`parcelsToCreate: ${parcelsToCreate.length}`); + // parcelsToCreate.forEach(p => console.log(`${p.x}, ${p.y}`)); + + // return; + //console.log(`estatesFromAPI: ${estatesFromAPI.length}`); + + // let newParcels = await getParcels(); + // const newEstates = await getEstates(); + // console.log(`newEstates: ${newEstates.length}`); + // console.log(`newParcels: ${newParcels.length}`); + + // newEstates.forEach( + // estate => (newParcels = [...newParcels, ...estate.parcels]) + // ); + // + // + // + // const estateContainsParcelFromList = (estate, listOfParcels) => { + // const { parcels: estateParcels } = estate; + // for (let parcel of estateParcels) + // if (findParcel(parcel, listOfParcels)) return true; + // + // return false; + // }; + // + // const parcelsToCreate = newParcels.filter( + // parcel => !findParcel(parcel, alreadyCreatedParcels) + // ); + // + // const estatesToCreate = newEstates.filter( + // estate => + // !estateContainsParcelFromList(estate, [ + // ...alreadyCreatedParcels, + // ...parcelsToCreate, + // ]) + // ); + + try { + console.log("Creating parcels..."); + await createMultipleParcels( + landContract, + parcelsToCreate, + sellerAddress, + minterWallet + ); + + const allParcelsIds = parcelsToCreate.map(async parcel => { + const { x, y } = parcel; + return landContract.encodeTokenId(x, y); + }); + + await Promise.all(allParcelsIds); + + // Update parcels with metadata + console.log("Updating parcels with metadata..."); + landContract.setWallet(sellerWallet); + for (let parcel of parcelsToCreate) { + let { x, y, metadata: parcelName } = parcel; + console.log(`updating parcel ${x},${y}....`); + if (!parcelName) parcelName = ""; + const updateAction = landContract.updateLandData(x, y, parcelName); + await updateAction.waitForNonceToUpdate(); + } + + console.log("Creating estates..."); + const allEstateIds = await createEstates( + estateContract, + landContract, + allEstates, + sellerWallet + ); + + console.log("Approving Marketplace..."); + await approveMarketplace( + MARKETPLACE_ADDRESS, + landContract, + estateContract, + sellerWallet + ); + + const expireAt = Date.now() + duration.years(5); + + console.log("Placing estates sellorders..."); + await placeEstatesSellOrders( + marketplaceContract, + ESTATE_ADDRESS, + allEstateIds, + expireAt, + sellerWallet + ); + + console.log("Placing parcels sellorders..."); + await placeParcelsSellOrders( + marketplaceContract, + LAND_PROXY_ADDRESS, + allParcelsIds, + expireAt, + sellerWallet + ); + } catch (err) { + console.error(err); + } +})(); From 087c96ff7444bbff098812e6e453fa5ffe46718c Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Thu, 21 Mar 2019 18:00:40 +0000 Subject: [PATCH 11/41] WIP --- package-lock.json | 28 ++++++++++++++----- .../src/GnosisSafe.test.js | 1 - 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9183e6b1..76e4a2ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3619,11 +3619,13 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true + "bundled": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3636,15 +3638,18 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "concat-map": { "version": "0.0.1", - "bundled": true + "bundled": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -3747,7 +3752,8 @@ }, "inherits": { "version": "2.0.3", - "bundled": true + "bundled": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -3757,6 +3763,7 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3769,17 +3776,20 @@ "minimatch": { "version": "3.0.4", "bundled": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true + "bundled": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -3796,6 +3806,7 @@ "mkdirp": { "version": "0.5.1", "bundled": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -3868,7 +3879,8 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true + "bundled": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -3878,6 +3890,7 @@ "once": { "version": "1.4.0", "bundled": true, + "optional": true, "requires": { "wrappy": "1" } @@ -3983,6 +3996,7 @@ "string-width": { "version": "1.0.2", "bundled": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", diff --git a/packages/tasit-contract-based-account/src/GnosisSafe.test.js b/packages/tasit-contract-based-account/src/GnosisSafe.test.js index da2e60d6..ba967aab 100644 --- a/packages/tasit-contract-based-account/src/GnosisSafe.test.js +++ b/packages/tasit-contract-based-account/src/GnosisSafe.test.js @@ -72,7 +72,6 @@ describe("GnosisSafe", () => { const action = gnosisSafe.transferEther(toAddress, ONE); await action.waitForNonceToUpdate(); - await expectExactEtherBalances(provider, [GNOSIS_SAFE_ADDRESS], [ZERO]); await expectExactEtherBalances(provider, [toAddress], [ONE]); }); From a989cfb54a12d73943ec31087e4de98f42a909c9 Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Thu, 21 Mar 2019 18:50:14 +0000 Subject: [PATCH 12/41] WIP --- packages/tasit-contracts/package.json | 2 +- .../scripts/populateDecentralandContracts.js | 421 ++++++++------ .../populateDecentralandContracts_append.js | 515 ------------------ 3 files changed, 262 insertions(+), 676 deletions(-) delete mode 100644 packages/tasit-contracts/src/scripts/populateDecentralandContracts_append.js diff --git a/packages/tasit-contracts/package.json b/packages/tasit-contracts/package.json index 952e58bc..b0f5b82a 100644 --- a/packages/tasit-contracts/package.json +++ b/packages/tasit-contracts/package.json @@ -26,7 +26,7 @@ "install:3rd-parties": "./3rd-parties/run_on_all.sh install `pwd`", "compile:3rd-parties": "./3rd-parties/run_on_all.sh compile `pwd`", "clean:3rd-parties": "./3rd-parties/run_on_all.sh clean `pwd`", - "populate-contracts": "NETWORK=development npx babel-node src/scripts/populateDecentralandContracts.js && NETWORK=development npx babel-node src/scripts/populateDecentralandContracts_append.js" + "populate-contracts": "NETWORK=development npx babel-node src/scripts/populateDecentralandContracts.js" }, "bugs": { "url": "https://github.com/tasitlabs/tasitsdk/issues" diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index f8a8bbaf..083d109f 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -25,33 +25,165 @@ import { duration } from "../../../tasit-sdk/dist/testHelpers/helpers"; const { ONE, TEN, ONE_HUNDRED, ONE_THOUSAND, BILLION, WeiPerEther } = constants; -const createMultipleParcels = async ( - landContract, - parcels, - beneficiaryAddress, - contractOwnerWallet -) => { - let xArray = []; - let yArray = []; +let network = process.env.NETWORK; - parcels.forEach(parcel => { - xArray.push(parcel.x); - yArray.push(parcel.y); +const config = require(`../config/${network}.js`); + +// https://stats.goerli.net/ +if (network === "goerli") + gasParams = { + gasLimit: 8e6, + gasPrice: 1e10, + }; +else if (network === "development") { + network = "local"; +} +const { + LANDProxy, + EstateRegistry, + Marketplace, + GnosisSafe: GnosisSafeInfo, + MANAToken, +} = TasitContracts[network]; +const { address: MANA_ADDRESS } = MANAToken; +const { address: LAND_PROXY_ADDRESS } = LANDProxy; +const { address: ESTATE_ADDRESS } = EstateRegistry; +const { address: MARKETPLACE_ADDRESS } = Marketplace; +const { address: GNOSIS_SAFE_ADDRESS } = GnosisSafeInfo; + +ConfigLoader.setConfig(config); + +const [minterWallet, sellerWallet] = accounts; +const { address: sellerAddress } = sellerWallet; + +const manaContract = new Mana(MANA_ADDRESS); +const landContract = new Land(LAND_PROXY_ADDRESS); +const estateContract = new Estate(ESTATE_ADDRESS); +const marketplaceContract = new Decentraland(MARKETPLACE_ADDRESS); +const gnosisSafeContract = new GnosisSafe(GNOSIS_SAFE_ADDRESS); + +const provider = ProviderFactory.getProvider(); + +(async () => { + // Fund Gnosis Safe wallet with Mana tokens and ethers + await etherFaucet(provider, minterWallet, GNOSIS_SAFE_ADDRESS, TEN); + await erc20Faucet(manaContract, minterWallet, GNOSIS_SAFE_ADDRESS, BILLION); + + try { + await populateDecentralandContractsWithInitialData(); + console.log("hey"); + await populateDecentralandContractsWithAdditionalData(); + } catch (err) { + console.error(err); + } +})(); + +const populateDecentralandContractsWithAdditionalData = async () => { + const parcelsFromAPI = await getParcelsFromAPI(); + const estatesFromAPI = await getEstatesFromAPI(); + + let parcelsToCreate = [...parcelsFromAPI]; + //let estatesToCreate = []; + let allEstates = [...estatesFromAPI]; + + // Extract parcels from estates + estatesFromAPI.forEach(estate => { + const { parcels } = estate; + const withoutDup = parcels.filter(p => !findParcel(p, parcelsFromAPI)); + parcelsToCreate = [...parcelsToCreate, ...withoutDup]; }); - landContract.setWallet(contractOwnerWallet); - const assignAction = landContract.assignMultipleParcels( - xArray, - yArray, - beneficiaryAddress, - gasParams + await populateDecentralandContracts(parcelsToCreate, allEstates); +}; + +const populateDecentralandContractsWithInitialData = async () => { + const uniqueParcels = getInitialParcels(); + const allEstates = getInitialEstates(); + + let allParcels = []; + allEstates.forEach( + estate => (allParcels = [...allParcels, ...estate.parcels]) ); - await assignAction.waitForNonceToUpdate(); + allParcels = [...allParcels, ...uniqueParcels]; + + await populateDecentralandContracts(allParcels, allEstates); +}; + +const populateDecentralandContracts = async (parcels, estates) => { + const allParcelsIds = await createParcels(parcels); + + await updateParcelsData(parcels); + + const allEstateIds = await createEstates(estates); + + await approveMarketplace(); + + await placeEstatesSellOrders(allEstateIds); + + // All unique parcels + const landIdsToSell = allParcelsIds.slice(13, 19); + await placeParcelsSellOrders(landIdsToSell); }; -const createEstate = async (estateContract, landContract, estate, wallet) => { +const updateParcelsData = async parcels => { + console.log("Updating parcels with metadata..."); + + landContract.setWallet(sellerWallet); + for (let parcel of parcels) { + let { x, y, metadata: parcelName } = parcel; + if (!parcelName) parcelName = ""; + const updateAction = landContract.updateLandData(x, y, parcelName); + await updateAction.waitForNonceToUpdate(); + } +}; + +const createParcels = async parcels => { + console.log("Creating parcels..."); + + landContract.setWallet(minterWallet); + + // let xArray = []; + // let yArray = []; + // + // parcels.forEach(parcel => { + // xArray.push(parcel.x); + // yArray.push(parcel.y); + // }); + // + // const assignAction = landContract.assignMultipleParcels( + // xArray, + // yArray, + // sellerAddress, + // gasParams + // ); + // await assignAction.waitForNonceToUpdate(); + + for (let parcel of parcels) { + const { x, y } = parcel; + console.log(`creating parcel ${x},${y}....`); + const assignAction = landContract.assignNewParcel( + `${x}`, + `${y}`, + sellerAddress, + gasParams + ); + + await assignAction.waitForNonceToUpdate(); + } + + const parcelsIds = parcels.map(async parcel => { + const { x, y } = parcel; + return landContract.encodeTokenId(x, y); + }); + await Promise.all(parcelsIds); + return parcelsIds; +}; + +const createEstate = async estate => { + console.log("Creating estates..."); + const { metadata: estateName, parcels } = estate; - const { address: beneficiaryAddress } = wallet; + const { address: beneficiaryAddress } = sellerWallet; let xArray = []; let yArray = []; @@ -63,7 +195,7 @@ const createEstate = async (estateContract, landContract, estate, wallet) => { console.log(`creating estate.... ${xArray} - ${yArray}`); - landContract.setWallet(wallet); + landContract.setWallet(sellerWallet); const action = landContract.createEstateWithMetadata( xArray, yArray, @@ -86,35 +218,32 @@ const createEstate = async (estateContract, landContract, estate, wallet) => { return estateId; }; -const createEstates = async (estateContract, landContract, estates, wallet) => { +const createEstates = async estates => { const estateIds = []; for (let estate of estates) { - const id = await createEstate(estateContract, landContract, estate, wallet); + const id = await createEstate(estate, sellerWallet); estateIds.push(id); } return estateIds; }; -const approveMarketplace = async ( - marketplaceAddress, - landContract, - estateContract, - assetsOwnerWallet -) => { +const approveMarketplace = async () => { + console.log("Approving Marketplace..."); + // Set false to remove approval const authorized = true; - estateContract.setWallet(assetsOwnerWallet); + estateContract.setWallet(sellerWallet); const estateApproval = estateContract.setApprovalForAll( - marketplaceAddress, + MARKETPLACE_ADDRESS, authorized, gasParams ); await estateApproval.waitForNonceToUpdate(); - landContract.setWallet(assetsOwnerWallet); + landContract.setWallet(sellerWallet); const landApproval = landContract.setApprovalForAll( - marketplaceAddress, + MARKETPLACE_ADDRESS, authorized, gasParams ); @@ -124,23 +253,20 @@ const approveMarketplace = async ( function getRandomInt(min, max) { min = Math.ceil(min); max = Math.floor(max); - return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive + return Math.floor(Math.random() * (max - min)) + min; } -const placeEstatesSellOrders = async ( - marketplace, - estateAddress, - estateIds, - expireAt, - sellerWallet -) => { +const placeEstatesSellOrders = async estateIds => { + console.log("Placing estates sellorders..."); + + const expireAt = Date.now() + duration.years(5); const price = getRandomInt(10, 100) + "000"; const priceInWei = bigNumberify(price).mul(WeiPerEther); - marketplace.setWallet(sellerWallet); + marketplaceContract.setWallet(sellerWallet); for (let assetId of estateIds) { - const action = marketplace.createOrder( - estateAddress, + const action = marketplaceContract.createOrder( + ESTATE_ADDRESS, assetId, priceInWei, expireAt, @@ -150,20 +276,17 @@ const placeEstatesSellOrders = async ( } }; -const placeParcelsSellOrders = async ( - marketplace, - landAddress, - landIds, - expireAt, - sellerWallet -) => { +const placeParcelsSellOrders = async landIds => { + console.log("Placing parcels sellorders..."); + + const expireAt = Date.now() + duration.years(5); const price = getRandomInt(10, 100) + "000"; const priceInWei = bigNumberify(price).mul(WeiPerEther); - marketplace.setWallet(sellerWallet); + marketplaceContract.setWallet(sellerWallet); for (let assetId of landIds) { - const action = marketplace.createOrder( - landAddress, + const action = marketplaceContract.createOrder( + LAND_PROXY_ADDRESS, assetId, priceInWei, expireAt, @@ -173,9 +296,7 @@ const placeParcelsSellOrders = async ( } }; -let network = process.env.NETWORK; - -const getParcels = async () => { +const getInitialParcels = () => { let parcels = [ { x: -20, y: 36, metadata: `Premium Downtown,road adjacent,central area.` }, { x: -61, y: 125, metadata: `Vegas/Univeristy` }, @@ -192,7 +313,7 @@ const getParcels = async () => { return parcels; }; -const getEstates = async () => { +const getInitialEstates = () => { let estates = [ { metadata: `all road adjacent parcels`, @@ -234,120 +355,100 @@ const getEstates = async () => { return estates; }; -(async () => { - const config = require(`../config/${network}.js`); - - // https://stats.goerli.net/ - if (network === "goerli") - gasParams = { - gasLimit: 8e6, - gasPrice: 1e10, - }; - else if (network === "development") { - network = "local"; - } - const { - LANDProxy, - EstateRegistry, - Marketplace, - GnosisSafe: GnosisSafeInfo, - MANAToken, - } = TasitContracts[network]; - const { address: MANA_ADDRESS } = MANAToken; - const { address: LAND_PROXY_ADDRESS } = LANDProxy; - const { address: ESTATE_ADDRESS } = EstateRegistry; - const { address: MARKETPLACE_ADDRESS } = Marketplace; - const { address: GNOSIS_SAFE_ADDRESS } = GnosisSafeInfo; - - ConfigLoader.setConfig(config); - - const [minterWallet, sellerWallet] = accounts; - const { address: sellerAddress } = sellerWallet; - - const manaContract = new Mana(MANA_ADDRESS); - const landContract = new Land(LAND_PROXY_ADDRESS); - const estateContract = new Estate(ESTATE_ADDRESS); - const marketplaceContract = new Decentraland(MARKETPLACE_ADDRESS); - const gnosisSafeContract = new GnosisSafe(GNOSIS_SAFE_ADDRESS); +const getAllInitialParcels = () => { + const uniqueParcels = getInitialParcels(); + const estates = getInitialEstates(); - // Fund Gnosis Safe wallet with Mana tokens and ethers - const provider = ProviderFactory.getProvider(); - await etherFaucet(provider, minterWallet, GNOSIS_SAFE_ADDRESS, TEN); - await erc20Faucet(manaContract, minterWallet, GNOSIS_SAFE_ADDRESS, BILLION); + let estatesParcels = []; - const uniqueParcels = await getParcels(); - const allEstates = await getEstates(); - let allParcels = []; - allEstates.forEach( - estate => (allParcels = [...allParcels, ...estate.parcels]) + estates.forEach( + estate => (estatesParcels = [...estatesParcels, ...estate.parcels]) ); - allParcels = [...allParcels, ...uniqueParcels]; - try { - console.log("Creating parcels..."); - await createMultipleParcels( - landContract, - allParcels, - sellerAddress, - minterWallet - ); + return [...estatesParcels, ...uniqueParcels]; +}; - const allParcelsIds = allParcels.map(async parcel => { - const { x, y } = parcel; - return landContract.encodeTokenId(x, y); - }); +const getParcelsFromAPI = async () => { + const res = await fetch( + "https://api.decentraland.org/v1/parcels?status=open&limit=100" + ); + const json = await res.json(); + const { data: jsonData } = json; + const { parcels: parcelsFromAPI } = jsonData; + + const parcels = parcelsFromAPI.map(parcel => { + const { x, y, data } = parcel; + let { name: metadata } = data; + if (!metadata) metadata = ""; + return { x, y, metadata }; + }); - await Promise.all(allParcelsIds); + // Note: Since the current test net contract was populated with the assets, this check is necessary. + const createdParcels = getAllInitialParcels(); + const withoutDuplicates = parcels.filter( + fromAPI => !createdParcels.find(p => p.x == fromAPI.x && p.y == fromAPI.y) + ); + + return withoutDuplicates; +}; + +const parcelsAreEqual = (p1, p2) => p1.x === p2.x && p1.y === p2.y; - // Update parcels with metadata - console.log("Updating parcels with metadata..."); - landContract.setWallet(sellerWallet); - for (let parcel of allParcels) { - let { x, y, metadata: parcelName } = parcel; - if (!parcelName) parcelName = ""; - const updateAction = landContract.updateLandData(x, y, parcelName); - await updateAction.waitForNonceToUpdate(); +const findParcel = (parcel, listOfParcels) => { + return listOfParcels.find(p => parcelsAreEqual(p, parcel)); +}; + +// Tech-debt: Move to a functional approach +const estatesWithConflict = (estate1, estate2) => { + const { parcels: parcels1 } = estate1; + const { parcels: parcels2 } = estate2; + for (let p1 of parcels1) { + for (let p2 of parcels2) { + if (parcelsAreEqual(p1, p2)) return true; } + } - console.log("Creating estates..."); - const allEstateIds = await createEstates( - estateContract, - landContract, - allEstates, - sellerWallet - ); + return false; +}; - console.log("Approving Marketplace..."); - await approveMarketplace( - MARKETPLACE_ADDRESS, - landContract, - estateContract, - sellerWallet - ); +const estateContainsParcelFromList = (estate, listOfParcels) => { + const { parcels: estateParcels } = estate; - const expireAt = Date.now() + duration.years(5); + for (let parcel of estateParcels) + if (findParcel(parcel, listOfParcels)) return true; - console.log("Placing estates sellorders..."); - await placeEstatesSellOrders( - marketplaceContract, - ESTATE_ADDRESS, - allEstateIds, - expireAt, - sellerWallet - ); + return false; +}; - // All unique parcels - const landIdsToSell = allParcelsIds.slice(13, 19); +const getEstatesFromAPI = async () => { + const res = await fetch( + "https://api.decentraland.org/v1/estates?status=open&limit=100" + ); + const json = await res.json(); + const { data: jsonData } = json; + const { estates: estatesFromAPI } = jsonData; + + let estates = estatesFromAPI.map(estate => { + const { data } = estate; + const { name: metadata, parcels } = data; + return { metadata, parcels }; + }); - console.log("Placing parcels sellorders..."); - await placeParcelsSellOrders( - marketplaceContract, - LAND_PROXY_ADDRESS, - landIdsToSell, - expireAt, - sellerWallet - ); - } catch (err) { - console.error(err); + const createdParcels = getAllInitialParcels(); + estates = estates.filter( + estate => !estateContainsParcelFromList(estate, createdParcels) + ); + + const createdEstates = getInitialEstates(); + let withoutDuplicates = []; + for (let e1 of estates) { + for (let e2 of createdEstates) + if (!estatesWithConflict(e1, e2)) { + withoutDuplicates = [...withoutDuplicates, e1]; + break; + } } -})(); + + return withoutDuplicates.filter(e => e.parcels.length < 10); + //return []; +}; diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts_append.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts_append.js deleted file mode 100644 index 4b597ae3..00000000 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts_append.js +++ /dev/null @@ -1,515 +0,0 @@ -// This script will add land parcels, estates and sell orders to the Decentraland marketplace -// This data is being used to test the Decentraland demo app -import fetch from "node-fetch"; -import TasitAction from "../../../tasit-action/dist/"; -const { - ConfigLoader, - ERC20, - ERC721, - Marketplace: MarketplaceContracts, -} = TasitAction; -const { Mana } = ERC20; -const { Estate, Land } = ERC721; -const { Decentraland } = MarketplaceContracts; - -import ProviderFactory from "../../../tasit-action/dist/ProviderFactory"; - -import TasitContractBasedAccount from "../../../tasit-contract-based-account/dist/"; -const { GnosisSafe } = TasitContractBasedAccount; - -import TasitContracts from ".."; - -import fs from "fs"; - -import { duration } from "../../../tasit-sdk/dist/testHelpers/helpers"; - -const { ONE, TEN, ONE_HUNDRED, ONE_THOUSAND, BILLION, WeiPerEther } = constants; - -const createMultipleParcels = async ( - landContract, - parcels, - beneficiaryAddress, - contractOwnerWallet -) => { - let xArray = []; - let yArray = []; - - parcels.forEach(parcel => { - xArray.push(parcel.x); - yArray.push(parcel.y); - }); - - landContract.setWallet(contractOwnerWallet); - - for (let parcel of parcels) { - const { x, y } = parcel; - console.log(`creating parcel ${x},${y}....`); - const assignAction = landContract.assignNewParcel( - `${x}`, - `${y}`, - beneficiaryAddress, - gasParams - ); - - await assignAction.waitForNonceToUpdate(); - } - - // const assignAction = landContract.assignMultipleParcels( - // xArray, - // yArray, - // beneficiaryAddress, - // gasParams - // ); - // await assignAction.waitForNonceToUpdate(); -}; - -const createEstate = async (estateContract, landContract, estate, wallet) => { - const { metadata: estateName, parcels } = estate; - const { address: beneficiaryAddress } = wallet; - - let xArray = []; - let yArray = []; - - parcels.forEach(parcel => { - xArray.push(parcel.x); - yArray.push(parcel.y); - }); - - console.log(`creating estate.... ${xArray} - ${yArray}`); - - landContract.setWallet(wallet); - const action = landContract.createEstateWithMetadata( - xArray, - yArray, - beneficiaryAddress, - estateName, - gasParams - ); - - const estateId = await new Promise((resolve, reject) => { - estateContract.once("CreateEstate", message => { - const { data } = message; - const { args } = data; - resolve(args._estateId); - }); - }); - - await action.waitForNonceToUpdate(); - console.log("created id =", estateId); - - return estateId; -}; - -const createEstates = async (estateContract, landContract, estates, wallet) => { - const estateIds = []; - for (let estate of estates) { - const id = await createEstate(estateContract, landContract, estate, wallet); - estateIds.push(id); - } - return estateIds; -}; - -const approveMarketplace = async ( - marketplaceAddress, - landContract, - estateContract, - assetsOwnerWallet -) => { - // Set false to remove approval - const authorized = true; - - estateContract.setWallet(assetsOwnerWallet); - const estateApproval = estateContract.setApprovalForAll( - marketplaceAddress, - authorized, - gasParams - ); - await estateApproval.waitForNonceToUpdate(); - - landContract.setWallet(assetsOwnerWallet); - const landApproval = landContract.setApprovalForAll( - marketplaceAddress, - authorized, - gasParams - ); - await landApproval.waitForNonceToUpdate(); -}; - -function getRandomInt(min, max) { - min = Math.ceil(min); - max = Math.floor(max); - return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive -} - -const placeEstatesSellOrders = async ( - marketplace, - estateAddress, - estateIds, - expireAt, - sellerWallet -) => { - const price = getRandomInt(10, 100) + "000"; - const priceInWei = bigNumberify(price).mul(WeiPerEther); - - marketplace.setWallet(sellerWallet); - for (let assetId of estateIds) { - const action = marketplace.createOrder( - estateAddress, - assetId, - priceInWei, - expireAt, - gasParams - ); - await action.waitForNonceToUpdate(); - } -}; - -const placeParcelsSellOrders = async ( - marketplace, - landAddress, - landIds, - expireAt, - sellerWallet -) => { - const price = getRandomInt(10, 100) + "000"; - const priceInWei = bigNumberify(price).mul(WeiPerEther); - - marketplace.setWallet(sellerWallet); - for (let assetId of landIds) { - const action = marketplace.createOrder( - landAddress, - assetId, - priceInWei, - expireAt, - gasParams - ); - await action.waitForNonceToUpdate(); - } -}; - -let network = process.env.NETWORK; - -const getAlreadyCreatedUniqueParcels = () => { - const parcels = [ - { x: -20, y: 36, metadata: `Premium Downtown,road adjacent,central area.` }, - { x: -61, y: 125, metadata: `Vegas/Univeristy` }, - { x: 141, y: -122, metadata: `dePeets Place 6` }, - { x: -150, y: 22, metadata: `Fashion District X` }, - { x: -150, y: 23, metadata: `District X Fashion Sandwich` }, - { - x: -7, - y: -110, - metadata: `On a junction right opposite two large estates :O)`, - }, - ]; - - return parcels; -}; - -const getAlreadyCreatedParcels = () => { - const uniqueParcels = getAlreadyCreatedUniqueParcels(); - const estates = getAlreadyCreatedEstates(); - - let estatesParcels = []; - - estates.forEach( - estate => (estatesParcels = [...estatesParcels, ...estate.parcels]) - ); - - return [...estatesParcels, ...uniqueParcels]; -}; - -const getAlreadyCreatedEstates = () => { - let estates = [ - { - metadata: `all road adjacent parcels`, - parcels: [ - { x: -30, y: -105, metadata: `` }, - { x: -31, y: -105, metadata: `` }, - { x: -29, y: -105, metadata: `` }, - { x: -30, y: -104, metadata: `` }, - { x: -29, y: -104, metadata: `` }, - ], - }, - { - metadata: `Forest / university estate`, - parcels: [{ x: 3, y: 141, metadata: `` }, { x: 2, y: 141, metadata: `` }], - }, - { - metadata: `Down-Town Bridge`, - parcels: [ - { x: -39, y: 30, metadata: `` }, - { x: -39, y: 31, metadata: `` }, - ], - }, - { - metadata: `Decentraland University Underpass`, - parcels: [ - { x: -47, y: 124, metadata: `` }, - { x: -48, y: 124, metadata: `` }, - ], - }, - { - metadata: `Estate: Villa Beau Soleil H`, - parcels: [ - { x: 39, y: -114, metadata: `Letter N` }, - { x: 39, y: -113, metadata: `Letter "N"` }, - ], - }, - ]; - - return estates; -}; - -const getParcelsFromAPI = async () => { - const res = await fetch( - "https://api.decentraland.org/v1/parcels?status=open&limit=50" - ); - const json = await res.json(); - const { data: jsonData } = json; - const { parcels: parcelsFromAPI } = jsonData; - - const parcels = parcelsFromAPI.map(parcel => { - const { x, y, data } = parcel; - let { name: metadata } = data; - if (!metadata) metadata = ""; - return { x, y, metadata }; - }); - - // Note: Since the current test net contract was populated with the assets, this check is necessary. - const createdParcels = getAlreadyCreatedParcels(); - const withoutDuplicates = parcels.filter( - fromAPI => !createdParcels.find(p => p.x == fromAPI.x && p.y == fromAPI.y) - ); - - return withoutDuplicates; -}; - -const parcelsAreEqual = (p1, p2) => p1.x === p2.x && p1.y === p2.y; - -const findParcel = (parcel, listOfParcels) => { - return listOfParcels.find(p => parcelsAreEqual(p, parcel)); -}; - -// Tech-debt: Move to a functional approach -const estatesWithConflict = (estate1, estate2) => { - const { parcels: parcels1 } = estate1; - const { parcels: parcels2 } = estate2; - for (let p1 of parcels1) { - for (let p2 of parcels2) { - if (parcelsAreEqual(p1, p2)) return true; - } - } - - return false; -}; - -const estateContainsParcelFromList = (estate, listOfParcels) => { - const { parcels: estateParcels } = estate; - - for (let parcel of estateParcels) - if (findParcel(parcel, listOfParcels)) return true; - - return false; -}; - -const getEstatesFromAPI = async () => { - const res = await fetch( - "https://api.decentraland.org/v1/estates?status=open&limit=50" - ); - const json = await res.json(); - const { data: jsonData } = json; - const { estates: estatesFromAPI } = jsonData; - - let estates = estatesFromAPI.map(estate => { - const { data } = estate; - const { name: metadata, parcels } = data; - return { metadata, parcels }; - }); - - const createdParcels = getAlreadyCreatedParcels(); - estates = estates.filter( - estate => !estateContainsParcelFromList(estate, createdParcels) - ); - - const createdEstates = getAlreadyCreatedEstates(); - let withoutDuplicates = []; - for (let e1 of estates) { - for (let e2 of createdEstates) - if (!estatesWithConflict(e1, e2)) { - withoutDuplicates = [...withoutDuplicates, e1]; - break; - } - } - - return withoutDuplicates.filter(e => e.parcels.length < 10); - //return []; -}; - -(async () => { - const config = require(`../config/${network}.js`); - - // https://stats.goerli.net/ - if (network === "goerli") - gasParams = { - gasLimit: 8e6, - gasPrice: 1e10, - }; - else if (network === "development") { - network = "local"; - } - const { - LANDProxy, - EstateRegistry, - Marketplace, - GnosisSafe: GnosisSafeInfo, - MANAToken, - } = TasitContracts[network]; - const { address: MANA_ADDRESS } = MANAToken; - const { address: LAND_PROXY_ADDRESS } = LANDProxy; - const { address: ESTATE_ADDRESS } = EstateRegistry; - const { address: MARKETPLACE_ADDRESS } = Marketplace; - const { address: GNOSIS_SAFE_ADDRESS } = GnosisSafeInfo; - - ConfigLoader.setConfig(config); - - const [minterWallet, sellerWallet] = accounts; - const { address: sellerAddress } = sellerWallet; - - const manaContract = new Mana(MANA_ADDRESS); - const landContract = new Land(LAND_PROXY_ADDRESS); - const estateContract = new Estate(ESTATE_ADDRESS); - const marketplaceContract = new Decentraland(MARKETPLACE_ADDRESS); - const gnosisSafeContract = new GnosisSafe(GNOSIS_SAFE_ADDRESS); - - // Fund Gnosis Safe wallet with Mana tokens and ethers - const provider = ProviderFactory.getProvider(); - - const parcelsFromAPI = await getParcelsFromAPI(); - const estatesFromAPI = await getEstatesFromAPI(); - - let parcelsToCreate = [...parcelsFromAPI]; - //let estatesToCreate = []; - let allEstates = [...estatesFromAPI]; - - // Extract parcels from estates - estatesFromAPI.forEach(estate => { - const { parcels } = estate; - const withoutDup = parcels.filter(p => !findParcel(p, parcelsFromAPI)); - parcelsToCreate = [...parcelsToCreate, ...withoutDup]; - }); - - // const alreadyCreatedEstates = getAlreadyCreatedEstates(); - // let alreadyCreatedParcels = getAlreadyCreatedParcels(); - // - // alreadyCreatedEstates.forEach( - // estate => - // (alreadyCreatedParcels = [...alreadyCreatedParcels, ...estate.parcels]) - // ); - // const createdParcels = getAlreadyCreatedParcels(); - // console.log(`createdParcels: ${createdParcels.length}`); - // createdParcels.forEach(p => console.log(`${p.x}, ${p.y}`)); - // console.log("-----------------------------------------------"); - // console.log(`parcelsToCreate: ${parcelsToCreate.length}`); - // parcelsToCreate.forEach(p => console.log(`${p.x}, ${p.y}`)); - - // return; - //console.log(`estatesFromAPI: ${estatesFromAPI.length}`); - - // let newParcels = await getParcels(); - // const newEstates = await getEstates(); - // console.log(`newEstates: ${newEstates.length}`); - // console.log(`newParcels: ${newParcels.length}`); - - // newEstates.forEach( - // estate => (newParcels = [...newParcels, ...estate.parcels]) - // ); - // - // - // - // const estateContainsParcelFromList = (estate, listOfParcels) => { - // const { parcels: estateParcels } = estate; - // for (let parcel of estateParcels) - // if (findParcel(parcel, listOfParcels)) return true; - // - // return false; - // }; - // - // const parcelsToCreate = newParcels.filter( - // parcel => !findParcel(parcel, alreadyCreatedParcels) - // ); - // - // const estatesToCreate = newEstates.filter( - // estate => - // !estateContainsParcelFromList(estate, [ - // ...alreadyCreatedParcels, - // ...parcelsToCreate, - // ]) - // ); - - try { - console.log("Creating parcels..."); - await createMultipleParcels( - landContract, - parcelsToCreate, - sellerAddress, - minterWallet - ); - - const allParcelsIds = parcelsToCreate.map(async parcel => { - const { x, y } = parcel; - return landContract.encodeTokenId(x, y); - }); - - await Promise.all(allParcelsIds); - - // Update parcels with metadata - console.log("Updating parcels with metadata..."); - landContract.setWallet(sellerWallet); - for (let parcel of parcelsToCreate) { - let { x, y, metadata: parcelName } = parcel; - console.log(`updating parcel ${x},${y}....`); - if (!parcelName) parcelName = ""; - const updateAction = landContract.updateLandData(x, y, parcelName); - await updateAction.waitForNonceToUpdate(); - } - - console.log("Creating estates..."); - const allEstateIds = await createEstates( - estateContract, - landContract, - allEstates, - sellerWallet - ); - - console.log("Approving Marketplace..."); - await approveMarketplace( - MARKETPLACE_ADDRESS, - landContract, - estateContract, - sellerWallet - ); - - const expireAt = Date.now() + duration.years(5); - - console.log("Placing estates sellorders..."); - await placeEstatesSellOrders( - marketplaceContract, - ESTATE_ADDRESS, - allEstateIds, - expireAt, - sellerWallet - ); - - console.log("Placing parcels sellorders..."); - await placeParcelsSellOrders( - marketplaceContract, - LAND_PROXY_ADDRESS, - allParcelsIds, - expireAt, - sellerWallet - ); - } catch (err) { - console.error(err); - } -})(); From f0b6b16ce991a1486860a95c6bbfbfe603faa550 Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Thu, 21 Mar 2019 19:52:24 +0000 Subject: [PATCH 13/41] WIP --- .../scripts/populateDecentralandContracts.js | 43 ++++++++++++++++--- .../scripts/checkDecentralandContractsData.js | 22 +++++----- 2 files changed, 49 insertions(+), 16 deletions(-) diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index 083d109f..7178c5ca 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -71,13 +71,38 @@ const provider = ProviderFactory.getProvider(); try { await populateDecentralandContractsWithInitialData(); - console.log("hey"); await populateDecentralandContractsWithAdditionalData(); } catch (err) { console.error(err); } })(); +const cancelOrdersOfAssetsWithoutImage = async estatesIds => { + const estateImage = id => + `https://api.decentraland.org/v1/estates/${id}/map.png`; + + const blankImage = await fetch(estateImage(5)); + const blankImageData = (await blankImage.buffer()).toString("base64"); + + for (let id of estatesIds) { + const image = await fetch(estateImage(id)); + const imageData = (await image.buffer()).toString("base64"); + if (imageData === blankImageData) { + console.log( + `Removing order of estate (id: ${id}) because it's with a blank image.` + ); + + marketplaceContract.setWallet(sellerWallet); + const action = marketplaceContract.cancelOrder( + ESTATE_ADDRESS, + `${id}`, + gasParams + ); + await action.waitForNonceToUpdate(); + } + } +}; + const populateDecentralandContractsWithAdditionalData = async () => { const parcelsFromAPI = await getParcelsFromAPI(); const estatesFromAPI = await getEstatesFromAPI(); @@ -94,6 +119,11 @@ const populateDecentralandContractsWithAdditionalData = async () => { }); await populateDecentralandContracts(parcelsToCreate, allEstates); + + const estatesAmount = allEstates.length + 5; + const estatesIds = [...Array(estatesAmount).keys()].map(n => n + 1); + + await cancelOrdersOfAssetsWithoutImage(estatesIds); }; const populateDecentralandContractsWithInitialData = async () => { @@ -131,9 +161,10 @@ const updateParcelsData = async parcels => { landContract.setWallet(sellerWallet); for (let parcel of parcels) { let { x, y, metadata: parcelName } = parcel; - if (!parcelName) parcelName = ""; - const updateAction = landContract.updateLandData(x, y, parcelName); - await updateAction.waitForNonceToUpdate(); + if (parcelName && parcelName !== "") { + const updateAction = landContract.updateLandData(x, y, parcelName); + await updateAction.waitForNonceToUpdate(); + } } }; @@ -370,7 +401,7 @@ const getAllInitialParcels = () => { const getParcelsFromAPI = async () => { const res = await fetch( - "https://api.decentraland.org/v1/parcels?status=open&limit=100" + "https://api.decentraland.org/v1/parcels?status=open&limit=200" ); const json = await res.json(); const { data: jsonData } = json; @@ -422,7 +453,7 @@ const estateContainsParcelFromList = (estate, listOfParcels) => { const getEstatesFromAPI = async () => { const res = await fetch( - "https://api.decentraland.org/v1/estates?status=open&limit=100" + "https://api.decentraland.org/v1/estates?status=open&limit=200" ); const json = await res.json(); const { data: jsonData } = json; diff --git a/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js b/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js index be0dacff..79b484ff 100644 --- a/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js +++ b/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js @@ -43,8 +43,8 @@ describe("Decentraland App pre-conditions", () => { }); describe("Marketplace", () => { - it("should have at least 100 assets for sale", async () => { - expect(assetsForSale.length).to.be.at.least(100); + it("should have at least 50 assets for sale", async () => { + expect(assetsForSale.length).to.be.at.least(50); }); }); @@ -68,14 +68,16 @@ describe("Decentraland App pre-conditions", () => { expect(price.lte(maxPrice), `${price} isn't <= ${maxPrice}`).to.be.true; // Parcels always show correct image - const image = await fetch( - `https://api.decentraland.org/v1/estates/${assetId}/map.png` - ); - const imageData = (await image.buffer()).toString("base64"); - expect( - imageData, - `The image of the estate (id: ${assetId}) is blank` - ).not.equals(blankImageData); + if (isEstate) { + const image = await fetch( + `https://api.decentraland.org/v1/estates/${assetId}/map.png` + ); + const imageData = (await image.buffer()).toString("base64"); + expect( + imageData, + `The image of the estate (id: ${assetId}) is blank` + ).not.equals(blankImageData); + } } }); }); From 33eb56808bcdb26675f893bec54fe32d8fbc6fc2 Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Thu, 21 Mar 2019 20:24:16 +0000 Subject: [PATCH 14/41] Refactoring --- .../scripts/populateDecentralandContracts.js | 70 +++++++++++++------ 1 file changed, 47 insertions(+), 23 deletions(-) diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index 7178c5ca..7cebc1f6 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -65,34 +65,42 @@ const gnosisSafeContract = new GnosisSafe(GNOSIS_SAFE_ADDRESS); const provider = ProviderFactory.getProvider(); (async () => { - // Fund Gnosis Safe wallet with Mana tokens and ethers - await etherFaucet(provider, minterWallet, GNOSIS_SAFE_ADDRESS, TEN); - await erc20Faucet(manaContract, minterWallet, GNOSIS_SAFE_ADDRESS, BILLION); - try { + // Fund Gnosis Safe wallet with Mana tokens and ethers + await etherFaucet(provider, minterWallet, GNOSIS_SAFE_ADDRESS, TEN); + await erc20Faucet(manaContract, minterWallet, GNOSIS_SAFE_ADDRESS, BILLION); + + // Data created by hand and previously added to the contracts await populateDecentralandContractsWithInitialData(); + + // Additional data created based on Decentraland API await populateDecentralandContractsWithAdditionalData(); } catch (err) { console.error(err); } })(); -const cancelOrdersOfAssetsWithoutImage = async estatesIds => { - const estateImage = id => - `https://api.decentraland.org/v1/estates/${id}/map.png`; +const cancelOrdersOfEstatesWithoutImage = async estatesIds => { + const getImageDataFromEstateId = async id => { + const image = await fetch( + `https://api.decentraland.org/v1/estates/${id}/map.png` + ); + const data = (await image.buffer()).toString("base64"); + return data; + }; - const blankImage = await fetch(estateImage(5)); - const blankImageData = (await blankImage.buffer()).toString("base64"); + // Note: Estate with 5 is one of the estates with blank image + const blankImageData = await getImageDataFromEstateId(5); + marketplaceContract.setWallet(sellerWallet); for (let id of estatesIds) { - const image = await fetch(estateImage(id)); - const imageData = (await image.buffer()).toString("base64"); + const imageData = await getImageDataFromEstateId(id); + if (imageData === blankImageData) { console.log( `Removing order of estate (id: ${id}) because it's with a blank image.` ); - marketplaceContract.setWallet(sellerWallet); const action = marketplaceContract.cancelOrder( ESTATE_ADDRESS, `${id}`, @@ -103,27 +111,43 @@ const cancelOrdersOfAssetsWithoutImage = async estatesIds => { } }; +const extractParcelsFromEstates = estates => { + let estatesParcels = []; + estates.forEach(estate => { + const { parcels } = estate; + estatesParcels = [...estatesParcels, ...parcels]; + }); + return estatesParcels; +}; + const populateDecentralandContractsWithAdditionalData = async () => { const parcelsFromAPI = await getParcelsFromAPI(); const estatesFromAPI = await getEstatesFromAPI(); - let parcelsToCreate = [...parcelsFromAPI]; - //let estatesToCreate = []; - let allEstates = [...estatesFromAPI]; + const estatesParcels = extractParcelsFromEstates(estatesFromAPI); + + const estatesParcelsWithoutDuplication = estatesParcels.filter( + p => !findParcel(p, parcelsFromAPI) + ); + const parcelsToCreate = [ + ...parcelsFromAPI, + ...estatesParcelsWithoutDuplication, + ]; + const estatesToCreate = [...estatesFromAPI]; // Extract parcels from estates - estatesFromAPI.forEach(estate => { - const { parcels } = estate; - const withoutDup = parcels.filter(p => !findParcel(p, parcelsFromAPI)); - parcelsToCreate = [...parcelsToCreate, ...withoutDup]; - }); + // estatesFromAPI.forEach(estate => { + // const { parcels } = estate; + // const withoutDup = parcels.filter(p => !findParcel(p, parcelsFromAPI)); + // parcelsToCreate = [...parcelsToCreate, ...withoutDup]; + // }); - await populateDecentralandContracts(parcelsToCreate, allEstates); + await populateDecentralandContracts(parcelsToCreate, estatesToCreate); - const estatesAmount = allEstates.length + 5; + const estatesAmount = estatesToCreate.length + 5; const estatesIds = [...Array(estatesAmount).keys()].map(n => n + 1); - await cancelOrdersOfAssetsWithoutImage(estatesIds); + await cancelOrdersOfEstatesWithoutImage(estatesIds); }; const populateDecentralandContractsWithInitialData = async () => { From 3f85e6dab223d7a8c330ca6ac88f52ae9a13aa13 Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Thu, 21 Mar 2019 20:58:57 +0000 Subject: [PATCH 15/41] Refactoring --- .../scripts/populateDecentralandContracts.js | 113 ++++++++---------- 1 file changed, 52 insertions(+), 61 deletions(-) diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index 7cebc1f6..b826384a 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -134,49 +134,51 @@ const populateDecentralandContractsWithAdditionalData = async () => { ...parcelsFromAPI, ...estatesParcelsWithoutDuplication, ]; + const estatesToCreate = [...estatesFromAPI]; - // Extract parcels from estates - // estatesFromAPI.forEach(estate => { - // const { parcels } = estate; - // const withoutDup = parcels.filter(p => !findParcel(p, parcelsFromAPI)); - // parcelsToCreate = [...parcelsToCreate, ...withoutDup]; - // }); await populateDecentralandContracts(parcelsToCreate, estatesToCreate); - const estatesAmount = estatesToCreate.length + 5; + const alreadyCreatedEstates = getInitialEstates(); + const estatesAmount = alreadyCreatedEstates.length + estatesToCreate.length; + + // Creating an array of all estates ids const estatesIds = [...Array(estatesAmount).keys()].map(n => n + 1); await cancelOrdersOfEstatesWithoutImage(estatesIds); }; -const populateDecentralandContractsWithInitialData = async () => { +const getAllInitialParcels = () => { const uniqueParcels = getInitialParcels(); - const allEstates = getInitialEstates(); + const estates = getInitialEstates(); - let allParcels = []; - allEstates.forEach( - estate => (allParcels = [...allParcels, ...estate.parcels]) - ); - allParcels = [...allParcels, ...uniqueParcels]; + const estatesParcels = extractParcelsFromEstates(estates); + const allParcels = [...estatesParcels, ...uniqueParcels]; + + return allParcels; +}; - await populateDecentralandContracts(allParcels, allEstates); +const populateDecentralandContractsWithInitialData = async () => { + const allParcels = getAllInitialParcels(); + const estates = getInitialEstates(); + + await populateDecentralandContracts(allParcels, estates); }; const populateDecentralandContracts = async (parcels, estates) => { - const allParcelsIds = await createParcels(parcels); + const parcelIds = await createParcels(parcels); await updateParcelsData(parcels); - const allEstateIds = await createEstates(estates); + const estateIds = await createEstates(estates); await approveMarketplace(); - await placeEstatesSellOrders(allEstateIds); + await placeEstatesSellOrders(estateIds); // All unique parcels - const landIdsToSell = allParcelsIds.slice(13, 19); - await placeParcelsSellOrders(landIdsToSell); + const parcelIdsToSell = parcelIds.slice(13, 19); + await placeParcelsSellOrders(parcelIdsToSell); }; const updateParcelsData = async parcels => { @@ -192,45 +194,45 @@ const updateParcelsData = async parcels => { } }; -const createParcels = async parcels => { +const createParcels = async allParcels => { console.log("Creating parcels..."); + const chunkArray = (myArray, chunkSize) => { + var results = []; + while (myArray.length) results.push(myArray.splice(0, chunkSize)); + return results; + }; + landContract.setWallet(minterWallet); - // let xArray = []; - // let yArray = []; - // - // parcels.forEach(parcel => { - // xArray.push(parcel.x); - // yArray.push(parcel.y); - // }); - // - // const assignAction = landContract.assignMultipleParcels( - // xArray, - // yArray, - // sellerAddress, - // gasParams - // ); - // await assignAction.waitForNonceToUpdate(); + // Note: Limiting size of each creation to avoid running out of gas + const maxAmountToCreateOnce = 25; + const parcelsBatches = chunkArray(allParcels, maxAmountToCreateOnce); + for (let parcels of parcelsBatches) { + let xArray = []; + let yArray = []; - for (let parcel of parcels) { - const { x, y } = parcel; - console.log(`creating parcel ${x},${y}....`); - const assignAction = landContract.assignNewParcel( - `${x}`, - `${y}`, + parcels.forEach(parcel => { + xArray.push(parcel.x); + yArray.push(parcel.y); + }); + + const assignAction = landContract.assignMultipleParcels( + xArray, + yArray, sellerAddress, gasParams ); - await assignAction.waitForNonceToUpdate(); } - const parcelsIds = parcels.map(async parcel => { + const parcelsIds = allParcels.map(parcel => { const { x, y } = parcel; return landContract.encodeTokenId(x, y); }); + await Promise.all(parcelsIds); + return parcelsIds; }; @@ -315,11 +317,12 @@ const placeEstatesSellOrders = async estateIds => { console.log("Placing estates sellorders..."); const expireAt = Date.now() + duration.years(5); - const price = getRandomInt(10, 100) + "000"; - const priceInWei = bigNumberify(price).mul(WeiPerEther); marketplaceContract.setWallet(sellerWallet); for (let assetId of estateIds) { + const price = getRandomInt(10, 100) + "000"; + const priceInWei = bigNumberify(price).mul(WeiPerEther); + const action = marketplaceContract.createOrder( ESTATE_ADDRESS, assetId, @@ -335,11 +338,12 @@ const placeParcelsSellOrders = async landIds => { console.log("Placing parcels sellorders..."); const expireAt = Date.now() + duration.years(5); - const price = getRandomInt(10, 100) + "000"; - const priceInWei = bigNumberify(price).mul(WeiPerEther); marketplaceContract.setWallet(sellerWallet); for (let assetId of landIds) { + const price = getRandomInt(10, 100) + "000"; + const priceInWei = bigNumberify(price).mul(WeiPerEther); + const action = marketplaceContract.createOrder( LAND_PROXY_ADDRESS, assetId, @@ -410,19 +414,6 @@ const getInitialEstates = () => { return estates; }; -const getAllInitialParcels = () => { - const uniqueParcels = getInitialParcels(); - const estates = getInitialEstates(); - - let estatesParcels = []; - - estates.forEach( - estate => (estatesParcels = [...estatesParcels, ...estate.parcels]) - ); - - return [...estatesParcels, ...uniqueParcels]; -}; - const getParcelsFromAPI = async () => { const res = await fetch( "https://api.decentraland.org/v1/parcels?status=open&limit=200" From d1e1435549cefbb02dcce4e4af5e18bf8c4e4f07 Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Thu, 21 Mar 2019 21:19:35 +0000 Subject: [PATCH 16/41] Refactoring --- .../scripts/populateDecentralandContracts.js | 88 +++++++++---------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index b826384a..e4600ed4 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -176,9 +176,7 @@ const populateDecentralandContracts = async (parcels, estates) => { await placeEstatesSellOrders(estateIds); - // All unique parcels - const parcelIdsToSell = parcelIds.slice(13, 19); - await placeParcelsSellOrders(parcelIdsToSell); + await placeParcelsSellOrders(parcelIds); }; const updateParcelsData = async parcels => { @@ -194,6 +192,17 @@ const updateParcelsData = async parcels => { } }; +const getIdsFromParcels = async parcels => { + const parcelsIds = parcels.map(parcel => { + const { x, y } = parcel; + return landContract.encodeTokenId(x, y); + }); + + await Promise.all(parcelsIds); + + return parcelsIds; +}; + const createParcels = async allParcels => { console.log("Creating parcels..."); @@ -226,19 +235,11 @@ const createParcels = async allParcels => { await assignAction.waitForNonceToUpdate(); } - const parcelsIds = allParcels.map(parcel => { - const { x, y } = parcel; - return landContract.encodeTokenId(x, y); - }); - - await Promise.all(parcelsIds); - + const parcelsIds = await getIdsFromParcels(allParcels); return parcelsIds; }; const createEstate = async estate => { - console.log("Creating estates..."); - const { metadata: estateName, parcels } = estate; const { address: beneficiaryAddress } = sellerWallet; @@ -276,6 +277,8 @@ const createEstate = async estate => { }; const createEstates = async estates => { + console.log("Creating estates..."); + const estateIds = []; for (let estate of estates) { const id = await createEstate(estate, sellerWallet); @@ -313,45 +316,42 @@ function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min)) + min; } +const placeAssesOrders = async (estatesIds, parcelsIds) => { + const estateOrders = estatesIds.map(id => { + return async () => {}; + }); +}; + const placeEstatesSellOrders = async estateIds => { console.log("Placing estates sellorders..."); - const expireAt = Date.now() + duration.years(5); - marketplaceContract.setWallet(sellerWallet); - for (let assetId of estateIds) { - const price = getRandomInt(10, 100) + "000"; - const priceInWei = bigNumberify(price).mul(WeiPerEther); - - const action = marketplaceContract.createOrder( - ESTATE_ADDRESS, - assetId, - priceInWei, - expireAt, - gasParams - ); - await action.waitForNonceToUpdate(); + for (let id of estateIds) { + await placeAssetSellOrder(ESTATE_ADDRESS, id); } }; -const placeParcelsSellOrders = async landIds => { - console.log("Placing parcels sellorders..."); - +const placeAssetSellOrder = async (nftAddress, assetId) => { + marketplaceContract.setWallet(sellerWallet); const expireAt = Date.now() + duration.years(5); + const price = getRandomInt(10, 100) + "000"; + const priceInWei = bigNumberify(price).mul(WeiPerEther); + + const action = marketplaceContract.createOrder( + nftAddress, + assetId, + priceInWei, + expireAt, + gasParams + ); + await action.waitForNonceToUpdate(); +}; - marketplaceContract.setWallet(sellerWallet); - for (let assetId of landIds) { - const price = getRandomInt(10, 100) + "000"; - const priceInWei = bigNumberify(price).mul(WeiPerEther); - - const action = marketplaceContract.createOrder( - LAND_PROXY_ADDRESS, - assetId, - priceInWei, - expireAt, - gasParams - ); - await action.waitForNonceToUpdate(); +const placeParcelsSellOrders = async parcelsIds => { + console.log("Placing parcels sellorders..."); + + for (let id of parcelsIds) { + await placeAssetSellOrder(LAND_PROXY_ADDRESS, id); } }; @@ -429,7 +429,7 @@ const getParcelsFromAPI = async () => { return { x, y, metadata }; }); - // Note: Since the current test net contract was populated with the assets, this check is necessary. + // Note: Since the current testnet contract was populated with the assets, this check is necessary. const createdParcels = getAllInitialParcels(); const withoutDuplicates = parcels.filter( fromAPI => !createdParcels.find(p => p.x == fromAPI.x && p.y == fromAPI.y) @@ -485,6 +485,7 @@ const getEstatesFromAPI = async () => { estate => !estateContainsParcelFromList(estate, createdParcels) ); + // Tech-debt: Rewrite that const createdEstates = getInitialEstates(); let withoutDuplicates = []; for (let e1 of estates) { @@ -496,5 +497,4 @@ const getEstatesFromAPI = async () => { } return withoutDuplicates.filter(e => e.parcels.length < 10); - //return []; }; From de3658c5bd766a2804bdd3ef90f240e2cdc1a18f Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Thu, 21 Mar 2019 21:54:30 +0000 Subject: [PATCH 17/41] Refactoring --- .../scripts/populateDecentralandContracts.js | 77 ++++++++----------- 1 file changed, 33 insertions(+), 44 deletions(-) diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index e4600ed4..084ebff8 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -168,15 +168,22 @@ const populateDecentralandContractsWithInitialData = async () => { const populateDecentralandContracts = async (parcels, estates) => { const parcelIds = await createParcels(parcels); + // const parcelIds = parcels.map(async parcel => { + // const { x, y } = parcel; + // return await landContract.encodeTokenId(x, y); + // }); + await updateParcelsData(parcels); const estateIds = await createEstates(estates); await approveMarketplace(); - await placeEstatesSellOrders(estateIds); + // await placeEstatesSellOrders(estateIds); + // + // await placeParcelsSellOrders(parcelIds); - await placeParcelsSellOrders(parcelIds); + await placeAssesOrders(estateIds, parcelIds); }; const updateParcelsData = async parcels => { @@ -193,42 +200,28 @@ const updateParcelsData = async parcels => { }; const getIdsFromParcels = async parcels => { - const parcelsIds = parcels.map(parcel => { + const parcelIds = parcels.map(parcel => { const { x, y } = parcel; - return landContract.encodeTokenId(x, y); + return landContract.encodeTokenId(`${x}`, `${y}`); }); - await Promise.all(parcelsIds); + await Promise.all(parcelIds); - return parcelsIds; + return parcelIds; }; +// Tech-debt: Use `assignMultipleParcels` to save gas cost. +// The number of parcels per call should be short enough to avoid out-of-gas. const createParcels = async allParcels => { console.log("Creating parcels..."); - const chunkArray = (myArray, chunkSize) => { - var results = []; - while (myArray.length) results.push(myArray.splice(0, chunkSize)); - return results; - }; - landContract.setWallet(minterWallet); - // Note: Limiting size of each creation to avoid running out of gas - const maxAmountToCreateOnce = 25; - const parcelsBatches = chunkArray(allParcels, maxAmountToCreateOnce); - for (let parcels of parcelsBatches) { - let xArray = []; - let yArray = []; - - parcels.forEach(parcel => { - xArray.push(parcel.x); - yArray.push(parcel.y); - }); - - const assignAction = landContract.assignMultipleParcels( - xArray, - yArray, + for (let parcel of allParcels) { + const { x, y } = parcel; + const assignAction = landContract.assignNewParcel( + `${x}`, + `${y}`, sellerAddress, gasParams ); @@ -316,18 +309,22 @@ function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min)) + min; } -const placeAssesOrders = async (estatesIds, parcelsIds) => { - const estateOrders = estatesIds.map(id => { - return async () => {}; +const placeAssesOrders = async (estateIds, parcelIds) => { + const shuffleArray = arr => arr.sort(() => Math.random() - 0.5); + + const estatesToSell = estateIds.map(id => { + return { nftAddress: ESTATE_ADDRESS, id }; + }); + + const parcelsToSell = parcelIds.map(id => { + return { nftAddress: LAND_PROXY_ADDRESS, id }; }); -}; -const placeEstatesSellOrders = async estateIds => { - console.log("Placing estates sellorders..."); + const assetsToSell = shuffleArray([...estatesToSell, ...parcelsToSell]); - marketplaceContract.setWallet(sellerWallet); - for (let id of estateIds) { - await placeAssetSellOrder(ESTATE_ADDRESS, id); + for (let asset of assetsToSell) { + const { nftAddress, id } = asset; + await placeAssetSellOrder(nftAddress, id); } }; @@ -347,14 +344,6 @@ const placeAssetSellOrder = async (nftAddress, assetId) => { await action.waitForNonceToUpdate(); }; -const placeParcelsSellOrders = async parcelsIds => { - console.log("Placing parcels sellorders..."); - - for (let id of parcelsIds) { - await placeAssetSellOrder(LAND_PROXY_ADDRESS, id); - } -}; - const getInitialParcels = () => { let parcels = [ { x: -20, y: 36, metadata: `Premium Downtown,road adjacent,central area.` }, From 3548651eeb283ef3b4b2c5912c58017183178a42 Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Thu, 21 Mar 2019 22:17:43 +0000 Subject: [PATCH 18/41] Refactoring --- .../scripts/populateDecentralandContracts.js | 58 +++++++++++-------- .../scripts/checkDecentralandContractsData.js | 4 +- 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index 084ebff8..b8de9567 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -73,6 +73,8 @@ const provider = ProviderFactory.getProvider(); // Data created by hand and previously added to the contracts await populateDecentralandContractsWithInitialData(); + await cancelInitialOrders(); + // Additional data created based on Decentraland API await populateDecentralandContractsWithAdditionalData(); } catch (err) { @@ -80,6 +82,26 @@ const provider = ProviderFactory.getProvider(); } })(); +const cancelInitialOrders = async () => { + const uniqueParcels = getInitialParcels(); + const estates = getInitialEstates(); + + const parcelIds = await getIdsFromParcels(uniqueParcels); + const estateIds = [...Array(estates.length).keys()].map(n => n + 1); + + for (let id of parcelIds) await cancelSellOrder(LAND_PROXY_ADDRESS, id); + for (let id of estateIds) await cancelSellOrder(ESTATE_ADDRESS, id); +}; + +const cancelSellOrder = async (nftAddress, id) => { + const action = marketplaceContract.cancelOrder( + nftAddress, + `${id}`, + gasParams + ); + await action.waitForNonceToUpdate(); +}; + const cancelOrdersOfEstatesWithoutImage = async estatesIds => { const getImageDataFromEstateId = async id => { const image = await fetch( @@ -101,12 +123,7 @@ const cancelOrdersOfEstatesWithoutImage = async estatesIds => { `Removing order of estate (id: ${id}) because it's with a blank image.` ); - const action = marketplaceContract.cancelOrder( - ESTATE_ADDRESS, - `${id}`, - gasParams - ); - await action.waitForNonceToUpdate(); + await cancelSellOrder(ESTATE_ADDRESS, id); } } }; @@ -146,6 +163,7 @@ const populateDecentralandContractsWithAdditionalData = async () => { const estatesIds = [...Array(estatesAmount).keys()].map(n => n + 1); await cancelOrdersOfEstatesWithoutImage(estatesIds); + await cancelInitialOrders(); }; const getAllInitialParcels = () => { @@ -168,21 +186,12 @@ const populateDecentralandContractsWithInitialData = async () => { const populateDecentralandContracts = async (parcels, estates) => { const parcelIds = await createParcels(parcels); - // const parcelIds = parcels.map(async parcel => { - // const { x, y } = parcel; - // return await landContract.encodeTokenId(x, y); - // }); - await updateParcelsData(parcels); const estateIds = await createEstates(estates); await approveMarketplace(); - // await placeEstatesSellOrders(estateIds); - // - // await placeParcelsSellOrders(parcelIds); - await placeAssesOrders(estateIds, parcelIds); }; @@ -200,12 +209,12 @@ const updateParcelsData = async parcels => { }; const getIdsFromParcels = async parcels => { - const parcelIds = parcels.map(parcel => { + const parcelIds = []; + for (let parcel of parcels) { const { x, y } = parcel; - return landContract.encodeTokenId(`${x}`, `${y}`); - }); - - await Promise.all(parcelIds); + const id = await landContract.encodeTokenId(`${x}`, `${y}`); + parcelIds.push(id); + } return parcelIds; }; @@ -405,7 +414,7 @@ const getInitialEstates = () => { const getParcelsFromAPI = async () => { const res = await fetch( - "https://api.decentraland.org/v1/parcels?status=open&limit=200" + "https://api.decentraland.org/v1/parcels?status=open&limit=100" ); const json = await res.json(); const { data: jsonData } = json; @@ -457,7 +466,7 @@ const estateContainsParcelFromList = (estate, listOfParcels) => { const getEstatesFromAPI = async () => { const res = await fetch( - "https://api.decentraland.org/v1/estates?status=open&limit=200" + "https://api.decentraland.org/v1/estates?status=open&limit=100" ); const json = await res.json(); const { data: jsonData } = json; @@ -485,5 +494,8 @@ const getEstatesFromAPI = async () => { } } - return withoutDuplicates.filter(e => e.parcels.length < 10); + // Keep estates with small number of parcels to avoid out-of-gas on creation + withoutDuplicates = withoutDuplicates.filter(e => e.parcels.length < 10); + + return withoutDuplicates; }; diff --git a/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js b/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js index 79b484ff..c614ad36 100644 --- a/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js +++ b/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js @@ -43,8 +43,8 @@ describe("Decentraland App pre-conditions", () => { }); describe("Marketplace", () => { - it("should have at least 50 assets for sale", async () => { - expect(assetsForSale.length).to.be.at.least(50); + it("should have at least 100 assets for sale", async () => { + expect(assetsForSale.length).to.be.at.least(100); }); }); From ef8f9c24f494d6b3ef51ce51e76025b64346c5d4 Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Thu, 21 Mar 2019 22:42:38 +0000 Subject: [PATCH 19/41] package-lock.json --- package-lock.json | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 76e4a2ce..c2575dfe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3601,7 +3601,8 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true + "bundled": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -3966,7 +3967,8 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true + "bundled": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -4014,6 +4016,7 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -4052,11 +4055,13 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true + "bundled": true, + "optional": true }, "yallist": { "version": "3.0.3", - "bundled": true + "bundled": true, + "optional": true } } }, From d1b83931bb37d62fd00920203fd3b3653b8d69a7 Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Fri, 22 Mar 2019 14:45:44 +0000 Subject: [PATCH 20/41] Adjustments --- .../scripts/populateDecentralandContracts.js | 232 ++++-------------- 1 file changed, 46 insertions(+), 186 deletions(-) diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index b8de9567..140ef796 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -64,35 +64,6 @@ const gnosisSafeContract = new GnosisSafe(GNOSIS_SAFE_ADDRESS); const provider = ProviderFactory.getProvider(); -(async () => { - try { - // Fund Gnosis Safe wallet with Mana tokens and ethers - await etherFaucet(provider, minterWallet, GNOSIS_SAFE_ADDRESS, TEN); - await erc20Faucet(manaContract, minterWallet, GNOSIS_SAFE_ADDRESS, BILLION); - - // Data created by hand and previously added to the contracts - await populateDecentralandContractsWithInitialData(); - - await cancelInitialOrders(); - - // Additional data created based on Decentraland API - await populateDecentralandContractsWithAdditionalData(); - } catch (err) { - console.error(err); - } -})(); - -const cancelInitialOrders = async () => { - const uniqueParcels = getInitialParcels(); - const estates = getInitialEstates(); - - const parcelIds = await getIdsFromParcels(uniqueParcels); - const estateIds = [...Array(estates.length).keys()].map(n => n + 1); - - for (let id of parcelIds) await cancelSellOrder(LAND_PROXY_ADDRESS, id); - for (let id of estateIds) await cancelSellOrder(ESTATE_ADDRESS, id); -}; - const cancelSellOrder = async (nftAddress, id) => { const action = marketplaceContract.cancelOrder( nftAddress, @@ -137,64 +108,6 @@ const extractParcelsFromEstates = estates => { return estatesParcels; }; -const populateDecentralandContractsWithAdditionalData = async () => { - const parcelsFromAPI = await getParcelsFromAPI(); - const estatesFromAPI = await getEstatesFromAPI(); - - const estatesParcels = extractParcelsFromEstates(estatesFromAPI); - - const estatesParcelsWithoutDuplication = estatesParcels.filter( - p => !findParcel(p, parcelsFromAPI) - ); - - const parcelsToCreate = [ - ...parcelsFromAPI, - ...estatesParcelsWithoutDuplication, - ]; - - const estatesToCreate = [...estatesFromAPI]; - - await populateDecentralandContracts(parcelsToCreate, estatesToCreate); - - const alreadyCreatedEstates = getInitialEstates(); - const estatesAmount = alreadyCreatedEstates.length + estatesToCreate.length; - - // Creating an array of all estates ids - const estatesIds = [...Array(estatesAmount).keys()].map(n => n + 1); - - await cancelOrdersOfEstatesWithoutImage(estatesIds); - await cancelInitialOrders(); -}; - -const getAllInitialParcels = () => { - const uniqueParcels = getInitialParcels(); - const estates = getInitialEstates(); - - const estatesParcels = extractParcelsFromEstates(estates); - const allParcels = [...estatesParcels, ...uniqueParcels]; - - return allParcels; -}; - -const populateDecentralandContractsWithInitialData = async () => { - const allParcels = getAllInitialParcels(); - const estates = getInitialEstates(); - - await populateDecentralandContracts(allParcels, estates); -}; - -const populateDecentralandContracts = async (parcels, estates) => { - const parcelIds = await createParcels(parcels); - - await updateParcelsData(parcels); - - const estateIds = await createEstates(estates); - - await approveMarketplace(); - - await placeAssesOrders(estateIds, parcelIds); -}; - const updateParcelsData = async parcels => { console.log("Updating parcels with metadata..."); @@ -273,7 +186,7 @@ const createEstate = async estate => { }); await action.waitForNonceToUpdate(); - console.log("created id =", estateId); + console.log(`created id ${estateId}`); return estateId; }; @@ -319,6 +232,7 @@ function getRandomInt(min, max) { } const placeAssesOrders = async (estateIds, parcelIds) => { + console.log(`Placing sell orders...`); const shuffleArray = arr => arr.sort(() => Math.random() - 0.5); const estatesToSell = estateIds.map(id => { @@ -353,65 +267,6 @@ const placeAssetSellOrder = async (nftAddress, assetId) => { await action.waitForNonceToUpdate(); }; -const getInitialParcels = () => { - let parcels = [ - { x: -20, y: 36, metadata: `Premium Downtown,road adjacent,central area.` }, - { x: -61, y: 125, metadata: `Vegas/Univeristy` }, - { x: 141, y: -122, metadata: `dePeets Place 6` }, - { x: -150, y: 22, metadata: `Fashion District X` }, - { x: -150, y: 23, metadata: `District X Fashion Sandwich` }, - { - x: -7, - y: -110, - metadata: `On a junction right opposite two large estates :O)`, - }, - ]; - - return parcels; -}; - -const getInitialEstates = () => { - let estates = [ - { - metadata: `all road adjacent parcels`, - parcels: [ - { x: -30, y: -105, metadata: `` }, - { x: -31, y: -105, metadata: `` }, - { x: -29, y: -105, metadata: `` }, - { x: -30, y: -104, metadata: `` }, - { x: -29, y: -104, metadata: `` }, - ], - }, - { - metadata: `Forest / university estate`, - parcels: [{ x: 3, y: 141, metadata: `` }, { x: 2, y: 141, metadata: `` }], - }, - { - metadata: `Down-Town Bridge`, - parcels: [ - { x: -39, y: 30, metadata: `` }, - { x: -39, y: 31, metadata: `` }, - ], - }, - { - metadata: `Decentraland University Underpass`, - parcels: [ - { x: -47, y: 124, metadata: `` }, - { x: -48, y: 124, metadata: `` }, - ], - }, - { - metadata: `Estate: Villa Beau Soleil H`, - parcels: [ - { x: 39, y: -114, metadata: `Letter N` }, - { x: 39, y: -113, metadata: `Letter "N"` }, - ], - }, - ]; - - return estates; -}; - const getParcelsFromAPI = async () => { const res = await fetch( "https://api.decentraland.org/v1/parcels?status=open&limit=100" @@ -427,13 +282,7 @@ const getParcelsFromAPI = async () => { return { x, y, metadata }; }); - // Note: Since the current testnet contract was populated with the assets, this check is necessary. - const createdParcels = getAllInitialParcels(); - const withoutDuplicates = parcels.filter( - fromAPI => !createdParcels.find(p => p.x == fromAPI.x && p.y == fromAPI.y) - ); - - return withoutDuplicates; + return parcels; }; const parcelsAreEqual = (p1, p2) => p1.x === p2.x && p1.y === p2.y; @@ -442,19 +291,6 @@ const findParcel = (parcel, listOfParcels) => { return listOfParcels.find(p => parcelsAreEqual(p, parcel)); }; -// Tech-debt: Move to a functional approach -const estatesWithConflict = (estate1, estate2) => { - const { parcels: parcels1 } = estate1; - const { parcels: parcels2 } = estate2; - for (let p1 of parcels1) { - for (let p2 of parcels2) { - if (parcelsAreEqual(p1, p2)) return true; - } - } - - return false; -}; - const estateContainsParcelFromList = (estate, listOfParcels) => { const { parcels: estateParcels } = estate; @@ -472,30 +308,54 @@ const getEstatesFromAPI = async () => { const { data: jsonData } = json; const { estates: estatesFromAPI } = jsonData; - let estates = estatesFromAPI.map(estate => { + const allEstates = estatesFromAPI.map(estate => { const { data } = estate; const { name: metadata, parcels } = data; return { metadata, parcels }; }); - const createdParcels = getAllInitialParcels(); - estates = estates.filter( - estate => !estateContainsParcelFromList(estate, createdParcels) - ); + // Keep estates with small number of parcels to avoid out-of-gas on creation + const estates = allEstates.filter(e => e.parcels.length < 10); + return estates; +}; - // Tech-debt: Rewrite that - const createdEstates = getInitialEstates(); - let withoutDuplicates = []; - for (let e1 of estates) { - for (let e2 of createdEstates) - if (!estatesWithConflict(e1, e2)) { - withoutDuplicates = [...withoutDuplicates, e1]; - break; - } - } +(async () => { + try { + // Fund Gnosis Safe wallet with Mana tokens and ethers + await etherFaucet(provider, minterWallet, GNOSIS_SAFE_ADDRESS, TEN); + await erc20Faucet(manaContract, minterWallet, GNOSIS_SAFE_ADDRESS, BILLION); - // Keep estates with small number of parcels to avoid out-of-gas on creation - withoutDuplicates = withoutDuplicates.filter(e => e.parcels.length < 10); + const parcelsFromAPI = await getParcelsFromAPI(); + const estatesFromAPI = await getEstatesFromAPI(); - return withoutDuplicates; -}; + const estatesParcels = extractParcelsFromEstates(estatesFromAPI); + + const estatesParcelsWithoutDuplication = estatesParcels.filter( + estateParcel => !findParcel(estateParcel, parcelsFromAPI) + ); + + const parcelsToCreate = [ + ...parcelsFromAPI, + ...estatesParcelsWithoutDuplication, + ]; + + const estatesToCreate = [...estatesFromAPI]; + + const parcelIds = await createParcels(parcelsToCreate); + + await updateParcelsData(parcelsToCreate); + + const estateIds = await createEstates(estatesToCreate); + + await approveMarketplace(); + + await placeAssesOrders(estateIds, parcelIds); + + // Creating an array of all estates ids + const estatesAmount = estatesToCreate.length; + const estatesIds = [...Array(estatesAmount).keys()].map(n => n + 1); + await cancelOrdersOfEstatesWithoutImage(estatesIds); + } catch (err) { + console.error(err); + } +})(); From 7f122f148214394f5cfa64de985a50681d188f2f Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Fri, 22 Mar 2019 16:29:16 +0000 Subject: [PATCH 21/41] Adjustments --- .../scripts/populateDecentralandContracts.js | 104 +++++++++++------- 1 file changed, 67 insertions(+), 37 deletions(-) diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index 140ef796..043c0d43 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -133,25 +133,49 @@ const getIdsFromParcels = async parcels => { }; // Tech-debt: Use `assignMultipleParcels` to save gas cost. -// The number of parcels per call should be short enough to avoid out-of-gas. +// The amount of parcels per call should be short enough to avoid out-of-gas. const createParcels = async allParcels => { console.log("Creating parcels..."); - landContract.setWallet(minterWallet); - + let parcelIds = []; for (let parcel of allParcels) { - const { x, y } = parcel; - const assignAction = landContract.assignNewParcel( - `${x}`, - `${y}`, - sellerAddress, - gasParams - ); - await assignAction.waitForNonceToUpdate(); + try { + const id = await createParcel(parcel); + parcelIds.push(id); + } catch (error) { + console.log("Parcel creation failed"); + } } - const parcelsIds = await getIdsFromParcels(allParcels); - return parcelsIds; + return parcelIds; +}; + +const createParcel = async parcel => { + const { x, y } = parcel; + landContract.setWallet(minterWallet); + const action = landContract.assignNewParcel( + `${x}`, + `${y}`, + sellerAddress, + gasParams + ); + + const parcelId = await new Promise((resolve, reject) => { + action.once("confirmation", async message => { + const id = await landContract.encodeTokenId(`${x}`, `${y}`); + resolve(id); + }); + + setTimeout(() => { + action.unsubscribe(); + reject(); + }, 1000); + }); + + await action.waitForNonceToUpdate(); + console.log(`created id ${parcelId}`); + + return parcelId; }; const createEstate = async estate => { @@ -183,6 +207,11 @@ const createEstate = async estate => { const { args } = data; resolve(args._estateId); }); + + setTimeout(() => { + estateContract.off("CreateEstate"); + reject(); + }, 1000); }); await action.waitForNonceToUpdate(); @@ -196,8 +225,12 @@ const createEstates = async estates => { const estateIds = []; for (let estate of estates) { - const id = await createEstate(estate, sellerWallet); - estateIds.push(id); + try { + const id = await createEstate(estate); + estateIds.push(id); + } catch (error) { + console.log("Estate creation failed"); + } } return estateIds; }; @@ -267,24 +300,6 @@ const placeAssetSellOrder = async (nftAddress, assetId) => { await action.waitForNonceToUpdate(); }; -const getParcelsFromAPI = async () => { - const res = await fetch( - "https://api.decentraland.org/v1/parcels?status=open&limit=100" - ); - const json = await res.json(); - const { data: jsonData } = json; - const { parcels: parcelsFromAPI } = jsonData; - - const parcels = parcelsFromAPI.map(parcel => { - const { x, y, data } = parcel; - let { name: metadata } = data; - if (!metadata) metadata = ""; - return { x, y, metadata }; - }); - - return parcels; -}; - const parcelsAreEqual = (p1, p2) => p1.x === p2.x && p1.y === p2.y; const findParcel = (parcel, listOfParcels) => { @@ -319,6 +334,24 @@ const getEstatesFromAPI = async () => { return estates; }; +const getParcelsFromAPI = async () => { + const res = await fetch( + "https://api.decentraland.org/v1/parcels?status=open&limit=100" + ); + const json = await res.json(); + const { data: jsonData } = json; + const { parcels: parcelsFromAPI } = jsonData; + + const parcels = parcelsFromAPI.map(parcel => { + const { x, y, data } = parcel; + let { name: metadata } = data; + if (!metadata) metadata = ""; + return { x, y, metadata }; + }); + + return parcels; +}; + (async () => { try { // Fund Gnosis Safe wallet with Mana tokens and ethers @@ -351,10 +384,7 @@ const getEstatesFromAPI = async () => { await placeAssesOrders(estateIds, parcelIds); - // Creating an array of all estates ids - const estatesAmount = estatesToCreate.length; - const estatesIds = [...Array(estatesAmount).keys()].map(n => n + 1); - await cancelOrdersOfEstatesWithoutImage(estatesIds); + await cancelOrdersOfEstatesWithoutImage(estateIds); } catch (err) { console.error(err); } From 0bc26d18ba6f9b793f4513fdd7d0cd69a220cb4c Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Fri, 22 Mar 2019 16:40:26 +0000 Subject: [PATCH 22/41] Refactoring --- .../src/scripts/populateDecentralandContracts.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index 043c0d43..23b3a22f 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -27,16 +27,22 @@ const { ONE, TEN, ONE_HUNDRED, ONE_THOUSAND, BILLION, WeiPerEther } = constants; let network = process.env.NETWORK; +let EVENTS_TIMEOUT; + const config = require(`../config/${network}.js`); // https://stats.goerli.net/ -if (network === "goerli") +if (network === "goerli") { gasParams = { gasLimit: 8e6, gasPrice: 1e10, }; -else if (network === "development") { + EVENTS_TIMEOUT = 5 * 60 * 1000; +} else if (network === "ropsten") { + EVENTS_TIMEOUT = 5 * 60 * 1000; +} else if (network === "development") { network = "local"; + EVENTS_TIMEOUT = 1000; } const { LANDProxy, @@ -169,7 +175,7 @@ const createParcel = async parcel => { setTimeout(() => { action.unsubscribe(); reject(); - }, 1000); + }, EVENTS_TIMEOUT); }); await action.waitForNonceToUpdate(); @@ -209,9 +215,9 @@ const createEstate = async estate => { }); setTimeout(() => { - estateContract.off("CreateEstate"); + estateContract.unsubscribe(); reject(); - }, 1000); + }, EVENTS_TIMEOUT); }); await action.waitForNonceToUpdate(); From c371e5e9bbccd5a7ef372f2d38871a09b0963812 Mon Sep 17 00:00:00 2001 From: Paul Cowgill Date: Fri, 22 Mar 2019 12:33:54 -0500 Subject: [PATCH 23/41] Update packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js --- .../tasit-sdk/src/scripts/checkDecentralandContractsData.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js b/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js index c614ad36..850b2656 100644 --- a/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js +++ b/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js @@ -1,7 +1,7 @@ // // Script used to check if the target chain has the Decentraland app pre-conditions // -// Note: This script is using mocha for convenince but isn't a test suite to be runned by `test` script. +// Note: This script is using mocha for convenience but isn't a test suite to be run by the `test` script. // Use: npx mocha src/scripts/checkDecentralandContractsData.js --require @babel/register --file src/testHelpers/mochaSetup.js --no-timeouts // From 64355f227526d143f12c0d2a81fd576213f1ce5e Mon Sep 17 00:00:00 2001 From: Paul Cowgill Date: Fri, 22 Mar 2019 12:34:13 -0500 Subject: [PATCH 24/41] Grammar fix --- .../src/scripts/populateDecentralandContracts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index 23b3a22f..4029dc19 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -97,7 +97,7 @@ const cancelOrdersOfEstatesWithoutImage = async estatesIds => { if (imageData === blankImageData) { console.log( - `Removing order of estate (id: ${id}) because it's with a blank image.` + `Removing order of estate (id: ${id}) because it has a blank image.` ); await cancelSellOrder(ESTATE_ADDRESS, id); From 8511391b2b3cdb6c190f7716307e69c95e7849f0 Mon Sep 17 00:00:00 2001 From: Paul Cowgill Date: Fri, 22 Mar 2019 12:34:25 -0500 Subject: [PATCH 25/41] Typo fix --- .../src/scripts/populateDecentralandContracts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index 4029dc19..27362aef 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -388,7 +388,7 @@ const getParcelsFromAPI = async () => { await approveMarketplace(); - await placeAssesOrders(estateIds, parcelIds); + await placeAssetOrders(estateIds, parcelIds); await cancelOrdersOfEstatesWithoutImage(estateIds); } catch (err) { From 03a2eb9ab1b72da54ae4388d900aaabef32c8816 Mon Sep 17 00:00:00 2001 From: Paul Cowgill Date: Fri, 22 Mar 2019 12:34:44 -0500 Subject: [PATCH 26/41] Typo fix --- .../src/scripts/populateDecentralandContracts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index 27362aef..f483a252 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -270,7 +270,7 @@ function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min)) + min; } -const placeAssesOrders = async (estateIds, parcelIds) => { +const placeAssetOrders = async (estateIds, parcelIds) => { console.log(`Placing sell orders...`); const shuffleArray = arr => arr.sort(() => Math.random() - 0.5); From 233d2e45a745fa6dd7ecf4d39d36d728d0288123 Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Mon, 25 Mar 2019 16:59:14 +0000 Subject: [PATCH 27/41] Review request --- packages/tasit-sdk/package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/tasit-sdk/package.json b/packages/tasit-sdk/package.json index fe1d58ab..bff4439c 100644 --- a/packages/tasit-sdk/package.json +++ b/packages/tasit-sdk/package.json @@ -46,7 +46,6 @@ "@babel/register": "^7.0.0", "chai": "^4.2.0", "ethers": "^4.0.27", - "mocha": "^6.0.1", - "node-fetch": "^2.3.0" + "mocha": "^6.0.1" } } From c6c0f47778adc20e3204c46efbb322768a5dfac2 Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Mon, 25 Mar 2019 17:03:45 +0000 Subject: [PATCH 28/41] Review request --- packages/tasit-sdk/package.json | 1 + packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tasit-sdk/package.json b/packages/tasit-sdk/package.json index bff4439c..8a212ae8 100644 --- a/packages/tasit-sdk/package.json +++ b/packages/tasit-sdk/package.json @@ -26,6 +26,7 @@ "test:forked-testnet": "npm run setup:forked-ropsten && npm run mocha", "test:testnet": "npm run setup:ropsten && npm run mocha", "mocha": "npx mocha src/*.test.js --require @babel/register --file src/testHelpers/mochaSetup.js --no-timeouts", + "check:decentraland-data": "npx mocha src/scripts/checkDecentralandContractsData.js --require @babel/register --file src/testHelpers/mochaSetup.js --no-timeouts", "lint": "npx prettier src/* --write" }, "bugs": { diff --git a/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js b/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js index 850b2656..6a3d0341 100644 --- a/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js +++ b/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js @@ -2,7 +2,6 @@ // Script used to check if the target chain has the Decentraland app pre-conditions // // Note: This script is using mocha for convenience but isn't a test suite to be run by the `test` script. -// Use: npx mocha src/scripts/checkDecentralandContractsData.js --require @babel/register --file src/testHelpers/mochaSetup.js --no-timeouts // import { Action, ContractBasedAccount } from "../TasitSdk"; From 97487c4b53694e50906dafdc8ed6e356bfc9254b Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Mon, 25 Mar 2019 17:05:09 +0000 Subject: [PATCH 29/41] Review request --- packages/tasit-action/src/testHelpers/helpers.js | 16 ++++++++-------- .../src/scripts/populateDecentralandContracts.js | 11 +++++++++-- .../scripts/checkDecentralandContractsData.js | 6 +++--- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/packages/tasit-action/src/testHelpers/helpers.js b/packages/tasit-action/src/testHelpers/helpers.js index ccabd9d0..4908cc14 100644 --- a/packages/tasit-action/src/testHelpers/helpers.js +++ b/packages/tasit-action/src/testHelpers/helpers.js @@ -15,7 +15,7 @@ const { constants: ethersConstants, Contract: ethersContract, } = ethers; -const { WeiPerEther } = ethersConstants; +const { WeiPerEther: WEI_PER_ETHER } = ethersConstants; const { bigNumberify } = ethersUtils; // In weis @@ -24,12 +24,12 @@ const { bigNumberify } = ethersUtils; // Scientific notation works if the number is small enough (< 1e21) to be converted to string properly // See more: https://github.com/ethers-io/ethers.js/issues/228 const ZERO = 0; -const ONE = bigNumberify(1).mul(WeiPerEther); -const TWO = bigNumberify(2).mul(WeiPerEther); -const TEN = bigNumberify(10).mul(WeiPerEther); -const ONE_HUNDRED = bigNumberify(100).mul(WeiPerEther); -const ONE_THOUSAND = bigNumberify(1000).mul(WeiPerEther); -const BILLION = bigNumberify(`${1e9}`).mul(WeiPerEther); +const ONE = bigNumberify(1).mul(WEI_PER_ETHER); +const TWO = bigNumberify(2).mul(WEI_PER_ETHER); +const TEN = bigNumberify(10).mul(WEI_PER_ETHER); +const ONE_HUNDRED = bigNumberify(100).mul(WEI_PER_ETHER); +const ONE_THOUSAND = bigNumberify(1000).mul(WEI_PER_ETHER); +const BILLION = bigNumberify(`${1e9}`).mul(WEI_PER_ETHER); const constants = { ZERO, @@ -39,7 +39,7 @@ const constants = { ONE_HUNDRED, ONE_THOUSAND, BILLION, - WeiPerEther, + WEI_PER_ETHER, }; // TODO: Go deep on gas handling. diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index f483a252..ce36bf14 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -23,7 +23,14 @@ import fs from "fs"; import { duration } from "../../../tasit-sdk/dist/testHelpers/helpers"; -const { ONE, TEN, ONE_HUNDRED, ONE_THOUSAND, BILLION, WeiPerEther } = constants; +const { + ONE, + TEN, + ONE_HUNDRED, + ONE_THOUSAND, + BILLION, + WEI_PER_ETHER, +} = constants; let network = process.env.NETWORK; @@ -294,7 +301,7 @@ const placeAssetSellOrder = async (nftAddress, assetId) => { marketplaceContract.setWallet(sellerWallet); const expireAt = Date.now() + duration.years(5); const price = getRandomInt(10, 100) + "000"; - const priceInWei = bigNumberify(price).mul(WeiPerEther); + const priceInWei = bigNumberify(price).mul(WEI_PER_ETHER); const action = marketplaceContract.createOrder( nftAddress, diff --git a/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js b/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js index 6a3d0341..de440e3b 100644 --- a/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js +++ b/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js @@ -12,7 +12,7 @@ import DecentralandUtils from "../helpers/DecentralandUtils"; const fetch = require("node-fetch"); -const { TWO, TEN, BILLION, WeiPerEther } = constants; +const { TWO, TEN, BILLION, WEI_PER_ETHER } = constants; describe("Decentraland App pre-conditions", () => { const mana = new Mana(MANA_ADDRESS); @@ -48,8 +48,8 @@ describe("Decentraland App pre-conditions", () => { }); it("Assets for sale", async () => { - const minPrice = bigNumberify("10000").mul(WeiPerEther); - const maxPrice = bigNumberify("100000").mul(WeiPerEther); + const minPrice = bigNumberify("10000").mul(WEI_PER_ETHER); + const maxPrice = bigNumberify("100000").mul(WEI_PER_ETHER); const blankImage = await fetch( "https://api.decentraland.org/v1/estates/5/map.png" From 4d78cfa8d3aeafe72637603fe797de66630efb2d Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Mon, 25 Mar 2019 17:32:46 +0000 Subject: [PATCH 30/41] Review request --- .../tasit-sdk/src/scripts/checkDecentralandContractsData.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js b/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js index de440e3b..45e271b5 100644 --- a/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js +++ b/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js @@ -16,6 +16,8 @@ const { TWO, TEN, BILLION, WEI_PER_ETHER } = constants; describe("Decentraland App pre-conditions", () => { const mana = new Mana(MANA_ADDRESS); + // Note: Since accounts[0] is being used as owner of all deployed contracts + // We are using accounts[9] for Gnosis Safe test cases to make sure that it haven't undesired extra privilege access. const gnosisSafeOwner = accounts[9]; const decentralandUtils = new DecentralandUtils(); const { getAllAssetsForSale } = decentralandUtils; From 8ef7dfd9157361d02bb988ccb7eff4568836ae7a Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Mon, 25 Mar 2019 17:34:07 +0000 Subject: [PATCH 31/41] Review request --- .../src/scripts/checkDecentralandContractsData.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js b/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js index 45e271b5..54a4bbac 100644 --- a/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js +++ b/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js @@ -38,8 +38,13 @@ describe("Decentraland App pre-conditions", () => { }); describe("Gnosis Safe wallet owner", () => { - it("should have at least ten ethers", async () => { - await expectMinimumEtherBalances(provider, [GNOSIS_SAFE_ADDRESS], [TWO]); + it("should have at least two ethers", async () => { + const { address: gnosisSafeOwnerAddress } = gnosisSafeOwner; + await expectMinimumEtherBalances( + provider, + [gnosisSafeOwnerAddress], + [TWO] + ); }); }); From b95e1764ac1cfd626c3ba61fa76984aca78d741e Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Mon, 25 Mar 2019 17:42:42 +0000 Subject: [PATCH 32/41] Review request --- packages/tasit-action/src/testHelpers/helpers.js | 14 ++++++++------ .../src/scripts/checkDecentralandContractsData.js | 9 +++++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/tasit-action/src/testHelpers/helpers.js b/packages/tasit-action/src/testHelpers/helpers.js index 4908cc14..3b750e1c 100644 --- a/packages/tasit-action/src/testHelpers/helpers.js +++ b/packages/tasit-action/src/testHelpers/helpers.js @@ -24,12 +24,13 @@ const { bigNumberify } = ethersUtils; // Scientific notation works if the number is small enough (< 1e21) to be converted to string properly // See more: https://github.com/ethers-io/ethers.js/issues/228 const ZERO = 0; -const ONE = bigNumberify(1).mul(WEI_PER_ETHER); -const TWO = bigNumberify(2).mul(WEI_PER_ETHER); -const TEN = bigNumberify(10).mul(WEI_PER_ETHER); -const ONE_HUNDRED = bigNumberify(100).mul(WEI_PER_ETHER); -const ONE_THOUSAND = bigNumberify(1000).mul(WEI_PER_ETHER); -const BILLION = bigNumberify(`${1e9}`).mul(WEI_PER_ETHER); +const TOKEN_SUBDIVISIONS = WEI_PER_ETHER; +const ONE = bigNumberify(1).mul(TOKEN_SUBDIVISIONS); +const TWO = bigNumberify(2).mul(TOKEN_SUBDIVISIONS); +const TEN = bigNumberify(10).mul(TOKEN_SUBDIVISIONS); +const ONE_HUNDRED = bigNumberify(100).mul(TOKEN_SUBDIVISIONS); +const ONE_THOUSAND = bigNumberify(1000).mul(TOKEN_SUBDIVISIONS); +const BILLION = bigNumberify(`${1e9}`).mul(TOKEN_SUBDIVISIONS); const constants = { ZERO, @@ -40,6 +41,7 @@ const constants = { ONE_THOUSAND, BILLION, WEI_PER_ETHER, + TOKEN_SUBDIVISIONS, }; // TODO: Go deep on gas handling. diff --git a/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js b/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js index 54a4bbac..bf95946f 100644 --- a/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js +++ b/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js @@ -55,8 +55,8 @@ describe("Decentraland App pre-conditions", () => { }); it("Assets for sale", async () => { - const minPrice = bigNumberify("10000").mul(WEI_PER_ETHER); - const maxPrice = bigNumberify("100000").mul(WEI_PER_ETHER); + const minPrice = bigNumberify("10000").mul(TOKEN_SUBDIVISIONS); + const maxPrice = bigNumberify("100000").mul(TOKEN_SUBDIVISIONS); const blankImage = await fetch( "https://api.decentraland.org/v1/estates/5/map.png" @@ -67,13 +67,12 @@ describe("Decentraland App pre-conditions", () => { const { id, assetId, nftAddress, priceInWei } = asset; const price = bigNumberify(priceInWei); - const isLand = addressesAreEqual(nftAddress, LAND_PROXY_ADDRESS); + const isParcel = addressesAreEqual(nftAddress, LAND_PROXY_ADDRESS); const isEstate = addressesAreEqual(nftAddress, ESTATE_ADDRESS); expect(price.gte(minPrice), `${price} isn't >= ${minPrice}`).to.be.true; expect(price.lte(maxPrice), `${price} isn't <= ${maxPrice}`).to.be.true; - // Parcels always show correct image if (isEstate) { const image = await fetch( `https://api.decentraland.org/v1/estates/${assetId}/map.png` @@ -83,6 +82,8 @@ describe("Decentraland App pre-conditions", () => { imageData, `The image of the estate (id: ${assetId}) is blank` ).not.equals(blankImageData); + } else if (isParcel) { + // Note: Parcels assets always show correct image } } }); From 0367673c7a12a8b874c481651c59eac7061c6014 Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Mon, 25 Mar 2019 17:50:37 +0000 Subject: [PATCH 33/41] Review request --- .../src/scripts/populateDecentralandContracts.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index ce36bf14..bddd9844 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -33,6 +33,13 @@ const { } = constants; let network = process.env.NETWORK; +if (!network) { + throw new Error( + `Use NETWORK env argument to choose which chain will be populated.` + ); +} else { + console.log(`Populating data to the '${network}' chain...`); +} let EVENTS_TIMEOUT; From 43dbdb8ecf580afa38006b18b307bd9a09544072 Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Mon, 25 Mar 2019 17:55:39 +0000 Subject: [PATCH 34/41] Review request --- .../src/scripts/populateDecentralandContracts.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index bddd9844..543b49d8 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -154,11 +154,11 @@ const getIdsFromParcels = async parcels => { // Tech-debt: Use `assignMultipleParcels` to save gas cost. // The amount of parcels per call should be short enough to avoid out-of-gas. -const createParcels = async allParcels => { +const createParcels = async parcels => { console.log("Creating parcels..."); let parcelIds = []; - for (let parcel of allParcels) { + for (let parcel of parcels) { try { const id = await createParcel(parcel); parcelIds.push(id); @@ -167,6 +167,8 @@ const createParcels = async allParcels => { } } + await updateParcelsData(parcels); + return parcelIds; }; @@ -396,8 +398,6 @@ const getParcelsFromAPI = async () => { const parcelIds = await createParcels(parcelsToCreate); - await updateParcelsData(parcelsToCreate); - const estateIds = await createEstates(estatesToCreate); await approveMarketplace(); From 49af57141f7ebb7d957545f0e1c0aa3206a2ae1f Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Mon, 25 Mar 2019 18:00:55 +0000 Subject: [PATCH 35/41] Review request --- .../src/scripts/populateDecentralandContracts.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index 543b49d8..59a30637 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -338,6 +338,7 @@ const estateContainsParcelFromList = (estate, listOfParcels) => { }; const getEstatesFromAPI = async () => { + // Note: In the future, we can get that same data from Decentraland contracts to move away from this point of centralization in the future const res = await fetch( "https://api.decentraland.org/v1/estates?status=open&limit=100" ); @@ -357,6 +358,7 @@ const getEstatesFromAPI = async () => { }; const getParcelsFromAPI = async () => { + // Note: In the future, we can get that same data from Decentraland contracts to move away from this point of centralization in the future const res = await fetch( "https://api.decentraland.org/v1/parcels?status=open&limit=100" ); From a9a30abcc17040ac81e684ba7a3b35bf7a7b80a2 Mon Sep 17 00:00:00 2001 From: Paul Cowgill Date: Mon, 25 Mar 2019 13:13:45 -0500 Subject: [PATCH 36/41] Grammar fix --- .../tasit-sdk/src/scripts/checkDecentralandContractsData.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js b/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js index bf95946f..e026ff21 100644 --- a/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js +++ b/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js @@ -17,7 +17,8 @@ const { TWO, TEN, BILLION, WEI_PER_ETHER } = constants; describe("Decentraland App pre-conditions", () => { const mana = new Mana(MANA_ADDRESS); // Note: Since accounts[0] is being used as owner of all deployed contracts - // We are using accounts[9] for Gnosis Safe test cases to make sure that it haven't undesired extra privilege access. + // We are using accounts[9] for Gnosis Safe test cases to make sure that it + // doesn't have undesired extra privilege access. const gnosisSafeOwner = accounts[9]; const decentralandUtils = new DecentralandUtils(); const { getAllAssetsForSale } = decentralandUtils; From b8060574d4a13bba28acab73de213468b48733cb Mon Sep 17 00:00:00 2001 From: Paul Cowgill Date: Mon, 25 Mar 2019 13:13:58 -0500 Subject: [PATCH 37/41] Grammar fix --- .../tasit-sdk/src/scripts/checkDecentralandContractsData.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js b/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js index e026ff21..f0409476 100644 --- a/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js +++ b/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js @@ -84,7 +84,7 @@ describe("Decentraland App pre-conditions", () => { `The image of the estate (id: ${assetId}) is blank` ).not.equals(blankImageData); } else if (isParcel) { - // Note: Parcels assets always show correct image + // Note: Parcel assets always show correct image } } }); From b7c67dc2900d012395d8ebdc52f31938647caa5c Mon Sep 17 00:00:00 2001 From: Paul Cowgill Date: Mon, 25 Mar 2019 13:14:29 -0500 Subject: [PATCH 38/41] Redundant phrase removal --- .../src/scripts/populateDecentralandContracts.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index 59a30637..1022f893 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -338,7 +338,8 @@ const estateContainsParcelFromList = (estate, listOfParcels) => { }; const getEstatesFromAPI = async () => { - // Note: In the future, we can get that same data from Decentraland contracts to move away from this point of centralization in the future + // Note: In the future, we can get the same data from Decentraland contracts + // to move away from this point of centralization const res = await fetch( "https://api.decentraland.org/v1/estates?status=open&limit=100" ); From 9595bd5b5c4faaa83e97c421a25df81ab2a3edc1 Mon Sep 17 00:00:00 2001 From: Paul Cowgill Date: Mon, 25 Mar 2019 13:14:46 -0500 Subject: [PATCH 39/41] Redundant phrase removal --- .../src/scripts/populateDecentralandContracts.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index 1022f893..670cfb4a 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -359,7 +359,8 @@ const getEstatesFromAPI = async () => { }; const getParcelsFromAPI = async () => { - // Note: In the future, we can get that same data from Decentraland contracts to move away from this point of centralization in the future + // Note: In the future, we can get the same data from Decentraland contracts + // to move away from this point of centralization const res = await fetch( "https://api.decentraland.org/v1/parcels?status=open&limit=100" ); From bf784d8294a190ba20f1a8cbaa842b18731b083d Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Mon, 25 Mar 2019 18:17:56 +0000 Subject: [PATCH 40/41] Review request --- .../tasit-sdk/src/scripts/checkDecentralandContractsData.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js b/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js index f0409476..0b1392e2 100644 --- a/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js +++ b/packages/tasit-sdk/src/scripts/checkDecentralandContractsData.js @@ -12,7 +12,7 @@ import DecentralandUtils from "../helpers/DecentralandUtils"; const fetch = require("node-fetch"); -const { TWO, TEN, BILLION, WEI_PER_ETHER } = constants; +const { TWO, TEN, BILLION, TOKEN_SUBDIVISIONS } = constants; describe("Decentraland App pre-conditions", () => { const mana = new Mana(MANA_ADDRESS); From 05151393680f1a02808628fdf052c273e0314738 Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Mon, 25 Mar 2019 18:27:05 +0000 Subject: [PATCH 41/41] Review request --- packages/tasit-sdk/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/tasit-sdk/package.json b/packages/tasit-sdk/package.json index 8a212ae8..fbab1638 100644 --- a/packages/tasit-sdk/package.json +++ b/packages/tasit-sdk/package.json @@ -47,6 +47,7 @@ "@babel/register": "^7.0.0", "chai": "^4.2.0", "ethers": "^4.0.27", - "mocha": "^6.0.1" + "mocha": "^6.0.1", + "node-fetch": "^2.3.0" } }