Skip to content

Commit

Permalink
Merge pull request #297 from tasitlabs/feature/decentraland-script-fixes
Browse files Browse the repository at this point in the history
Adjust Decentraland populate script to work on ropsten testnet
  • Loading branch information
pcowgill committed Mar 27, 2019
2 parents 1e99bca + d452ac7 commit f6e2b09
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/tasit-contracts/src/config/ropsten.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const ropsten = {
pollingInterval: 4000,
},
events: {
timeout: 2000,
timeout: 5 * 60 * 1000,
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,24 @@ 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 => {
const { error } = message;
console.log(error);
action.unsubscribe();
reject();
});

setTimeout(() => {
console.log(`Timeout reached`);
action.unsubscribe();
reject();
}, EVENTS_TIMEOUT);
Expand Down Expand Up @@ -224,14 +235,37 @@ 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 being triggered only from the confirmationListener
// See more: https://github.com/tasitlabs/TasitSDK/issues/253
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();
}, EVENTS_TIMEOUT);
});
Expand Down Expand Up @@ -302,6 +336,7 @@ const placeAssetOrders = async (estateIds, parcelIds) => {

for (let asset of assetsToSell) {
const { nftAddress, id } = asset;

await placeAssetSellOrder(nftAddress, id);
}
};
Expand All @@ -312,6 +347,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 ${assetId}`);

const action = marketplaceContract.createOrder(
nftAddress,
assetId,
Expand Down

0 comments on commit f6e2b09

Please sign in to comment.