From 8ba184ffe842db2cb59e73cc14e04cfb080a63fd Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Mon, 25 Mar 2019 23:34:43 +0000 Subject: [PATCH 1/7] Script adjustmentts --- .../tasit-contracts/src/config/ropsten.js | 2 +- .../scripts/populateDecentralandContracts.js | 34 +++++++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/packages/tasit-contracts/src/config/ropsten.js b/packages/tasit-contracts/src/config/ropsten.js index fa14c650..21bc32bf 100644 --- a/packages/tasit-contracts/src/config/ropsten.js +++ b/packages/tasit-contracts/src/config/ropsten.js @@ -5,7 +5,7 @@ const ropsten = { pollingInterval: 4000, }, events: { - timeout: 2000, + timeout: 5 * 60 * 1000, }, }; diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index 670cfb4a..ec5eaed8 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -182,12 +182,20 @@ const createParcel = async parcel => { gasParams ); + console.log(`creating parcel.... ${x},${y}`); + const parcelId = await new Promise((resolve, reject) => { - action.once("confirmation", async message => { + action.on("confirmation", async message => { const id = await landContract.encodeTokenId(`${x}`, `${y}`); + action.unsubscribe(); resolve(id); }); + action.on("error", message => { + action.unsubscribe(); + reject(); + }); + setTimeout(() => { action.unsubscribe(); reject(); @@ -224,14 +232,32 @@ const createEstate = async estate => { ); const estateId = await new Promise((resolve, reject) => { - estateContract.once("CreateEstate", message => { + estateContract.on("CreateEstate", message => { const { data } = message; const { args } = data; + estateContract.unsubscribe(); resolve(args._estateId); }); + // Some error (orphan block, failed tx) events are been trigger only from the confirmationListener + // See more: https://github.com/tasitlabs/TasitSDK/issues/253 + action.on("confirmation", () => {}); + + action.on("error", message => { + estateContract.unsubscribe(); + action.unsubscribe(); + reject(); + }); + + estateContract.on("error", message => { + estateContract.unsubscribe(); + action.unsubscribe(); + reject(); + }); + setTimeout(() => { estateContract.unsubscribe(); + action.unsubscribe(); reject(); }, EVENTS_TIMEOUT); }); @@ -302,6 +328,7 @@ const placeAssetOrders = async (estateIds, parcelIds) => { for (let asset of assetsToSell) { const { nftAddress, id } = asset; + await placeAssetSellOrder(nftAddress, id); } }; @@ -312,6 +339,9 @@ const placeAssetSellOrder = async (nftAddress, assetId) => { const price = getRandomInt(10, 100) + "000"; const priceInWei = bigNumberify(price).mul(WEI_PER_ETHER); + const type = nftAddress == ESTATE_ADDRESS ? "estate" : "parcel"; + console.log(`placing sell order for the ${type} with id ${id}`); + const action = marketplaceContract.createOrder( nftAddress, assetId, From 92a92f24677733605113ca94955289525a20473b Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Tue, 26 Mar 2019 10:53:25 +0000 Subject: [PATCH 2/7] Some fixes --- .../src/scripts/populateDecentralandContracts.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index ec5eaed8..f7c0e2b5 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -146,6 +146,7 @@ const getIdsFromParcels = async parcels => { for (let parcel of parcels) { const { x, y } = parcel; const id = await landContract.encodeTokenId(`${x}`, `${y}`); + console.log(`${id}`); parcelIds.push(id); } @@ -340,7 +341,7 @@ const placeAssetSellOrder = async (nftAddress, assetId) => { const priceInWei = bigNumberify(price).mul(WEI_PER_ETHER); const type = nftAddress == ESTATE_ADDRESS ? "estate" : "parcel"; - console.log(`placing sell order for the ${type} with id ${id}`); + console.log(`placing sell order for the ${type} with id ${assetId}`); const action = marketplaceContract.createOrder( nftAddress, @@ -417,8 +418,6 @@ const getParcelsFromAPI = async () => { const parcelsFromAPI = await getParcelsFromAPI(); const estatesFromAPI = await getEstatesFromAPI(); - const estatesParcels = extractParcelsFromEstates(estatesFromAPI); - const estatesParcelsWithoutDuplication = estatesParcels.filter( estateParcel => !findParcel(estateParcel, parcelsFromAPI) ); @@ -436,6 +435,10 @@ const getParcelsFromAPI = async () => { await approveMarketplace(); + // const parcelIds = await getIdsFromParcels(parcelsToCreate); + // let estateIds = []; + // for (let i = 11; i < 90; ++i) estateIds.push(i); + await placeAssetOrders(estateIds, parcelIds); await cancelOrdersOfEstatesWithoutImage(estateIds); From 141f56ba1abbae794f1045012ee088480ebebb49 Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Tue, 26 Mar 2019 11:21:34 +0000 Subject: [PATCH 3/7] Some fixes --- .../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 f7c0e2b5..63b1870b 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -418,6 +418,8 @@ const getParcelsFromAPI = async () => { const parcelsFromAPI = await getParcelsFromAPI(); const estatesFromAPI = await getEstatesFromAPI(); + const estatesParcels = extractParcelsFromEstates(estatesFromAPI); + const estatesParcelsWithoutDuplication = estatesParcels.filter( estateParcel => !findParcel(estateParcel, parcelsFromAPI) ); From f35255dfc12eb8caaaefb2f9d01ed6e1c0ce4fb3 Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Wed, 27 Mar 2019 12:28:50 +0000 Subject: [PATCH 4/7] Some fixes --- .../src/scripts/populateDecentralandContracts.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index 63b1870b..58ebed89 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -437,10 +437,6 @@ const getParcelsFromAPI = async () => { await approveMarketplace(); - // const parcelIds = await getIdsFromParcels(parcelsToCreate); - // let estateIds = []; - // for (let i = 11; i < 90; ++i) estateIds.push(i); - await placeAssetOrders(estateIds, parcelIds); await cancelOrdersOfEstatesWithoutImage(estateIds); From 1302e12b6a3f774315f23d7d5d8a95dc32e45080 Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Wed, 27 Mar 2019 13:31:11 +0000 Subject: [PATCH 5/7] Some fixes --- .../tasit-contracts/src/scripts/populateDecentralandContracts.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index 58ebed89..bd8c2f2c 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -146,7 +146,6 @@ const getIdsFromParcels = async parcels => { for (let parcel of parcels) { const { x, y } = parcel; const id = await landContract.encodeTokenId(`${x}`, `${y}`); - console.log(`${id}`); parcelIds.push(id); } From e078c4b1b431fb90bea174eee31b06b2a6e24129 Mon Sep 17 00:00:00 2001 From: Paul Cowgill Date: Wed, 27 Mar 2019 14:54:09 +0000 Subject: [PATCH 6/7] Update packages/tasit-contracts/src/scripts/populateDecentralandContracts.js Co-Authored-By: marcelomorgado --- .../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 bd8c2f2c..7798f418 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -239,7 +239,7 @@ const createEstate = async estate => { resolve(args._estateId); }); - // Some error (orphan block, failed tx) events are been trigger only from the confirmationListener + // Some error (orphan block, failed tx) events are being triggered only from the confirmationListener // See more: https://github.com/tasitlabs/TasitSDK/issues/253 action.on("confirmation", () => {}); From d452ac7ab27b4bfa10a5a1234b85b2e1356f5907 Mon Sep 17 00:00:00 2001 From: Marcelo Morgado Date: Wed, 27 Mar 2019 14:59:11 +0000 Subject: [PATCH 7/7] Review requests --- .../src/scripts/populateDecentralandContracts.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js index 7798f418..437a8fc7 100644 --- a/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js +++ b/packages/tasit-contracts/src/scripts/populateDecentralandContracts.js @@ -192,11 +192,14 @@ const createParcel = async parcel => { }); action.on("error", message => { + const { error } = message; + console.log(error); action.unsubscribe(); reject(); }); setTimeout(() => { + console.log(`Timeout reached`); action.unsubscribe(); reject(); }, EVENTS_TIMEOUT); @@ -244,18 +247,23 @@ const createEstate = async estate => { action.on("confirmation", () => {}); action.on("error", message => { + const { error } = message; + console.log(error); estateContract.unsubscribe(); action.unsubscribe(); reject(); }); estateContract.on("error", message => { + const { error } = message; + console.log(error); estateContract.unsubscribe(); action.unsubscribe(); reject(); }); setTimeout(() => { + console.log(`Timeout reached`); estateContract.unsubscribe(); action.unsubscribe(); reject();