Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
assert.isBelow(txMined.receipt.gasUsed, constants.AMOUNT_GAS_PROVIDED, "should not use all gas");
txMined = await aIexecHubInstance.createApp("R Clifford Attractors", 0, constants.DAPP_PARAMS_EXAMPLE, {
from: appProvider
});
appAddress = await aAppHubInstance.getApp(appProvider, 1);
aAppInstance = await App.at(appAddress);
//Create ask Marker Orders
// ==================================================================
commonOrder.category = 1;
commonOrder.trust = 0;
commonOrder.value = 100;
// ==================================================================
poolOrder.volume = 1
poolOrder.workerpool = aWorkerPoolInstance.address;
poolOrder.salt = web3utils.randomHex(32);
// ------------------------------------------------------------------
poolOrder.hash = Extensions.poolOrderHashing(
aMarketplaceInstance.address,
commonOrder.category,
commonOrder.trust,
commonOrder.value,
poolOrder.volume,
poolOrder.workerpool,
poolOrder.salt
);
poolOrder.sig = Extensions.signHash(scheduleProvider, poolOrder.hash)
// ==================================================================
userOrder.app = aAppInstance.address;
userOrder.dataset = '0x0000000000000000000000000000000000000000';
userOrder.callback = '0x0000000000000000000000000000000000000000';
userOrder.beneficiary = iExecCloudUser;
assert.isBelow(txMined.receipt.gasUsed, constants.AMOUNT_GAS_PROVIDED, "should not use all gas");
txMined = await aIexecHubInstance.createApp("R Clifford Attractors", 0, constants.DAPP_PARAMS_EXAMPLE, {
from: appProvider
});
appAddress = await aAppHubInstance.getApp(appProvider, 1);
aAppInstance = await App.at(appAddress);
//Create ask Marker Orders
// ==================================================================
commonOrder.category = 1;
commonOrder.trust = 0;
commonOrder.value = 100;
// ==================================================================
poolOrder.volume = 1
poolOrder.workerpool = aWorkerPoolInstance.address;
poolOrder.salt = web3utils.randomHex(32);
// ------------------------------------------------------------------
poolOrder.hash = Extensions.poolOrderHashing(
aMarketplaceInstance.address,
commonOrder.category,
commonOrder.trust,
commonOrder.value,
poolOrder.volume,
poolOrder.workerpool,
poolOrder.salt
);
poolOrder.sig = Extensions.signHash(scheduleProvider, poolOrder.hash)
// ==================================================================
userOrder.app = aAppInstance.address;
userOrder.dataset = '0x0000000000000000000000000000000000000000';
userOrder.callback = '0x0000000000000000000000000000000000000000';
userOrder.beneficiary = iExecCloudUser;
const newNetworkRevision = networkRevision + 1;
console.log(`deriving seed with revision ${newNetworkRevision}`);
const networkSeed = await attemptNetworkSeedDerivation({
urbitWallet,
wallet,
authMnemonic,
details: _details,
revision: newNetworkRevision,
});
if (Just.hasInstance(networkSeed)) {
return networkSeed.value;
}
randomSeed.current = randomSeed.current || randomHex(32); // 32 bytes
setNdNetworkSeed(randomSeed.current);
return randomSeed.current;
}
},
[_details, authMnemonic, networkRevision, urbitWallet, wallet]
from, addrs, values, maxReward, claimedReward,
nonce, signature, { from: accounts[1] },
);
console.log(`transferMultipleDelegated, count = ${addrs.length}, first time gas used = ${callResult.receipt.gasUsed}`);
nonce = web3Utils.randomHex(32);
signature =
signTransferMultipleDelegated(like.address, addrs, values, maxReward, nonce, privKey);
callResult = await like.transferMultipleDelegated(
from, addrs, values, maxReward, claimedReward,
nonce, signature, { from: accounts[1] },
);
console.log(`transferMultipleDelegated, count = ${addrs.length}, second time gas used = ${callResult.receipt.gasUsed}`);
addrs = [9].map(i => accounts[i]);
values = [9].map(n => coinsToCoinUnits(n * 100));
nonce = web3Utils.randomHex(32);
signature =
signTransferMultipleDelegated(like.address, addrs, values, maxReward, nonce, privKey);
callResult = await like.transferMultipleDelegated(
from, addrs, values, maxReward, claimedReward,
nonce, signature, { from: accounts[1] },
);
console.log(`transferMultipleDelegated, count = ${addrs.length}, first time gas used = ${callResult.receipt.gasUsed}`);
nonce = web3Utils.randomHex(32);
signature =
signTransferMultipleDelegated(like.address, addrs, values, maxReward, nonce, privKey);
callResult = await like.transferMultipleDelegated(
from, addrs, values, maxReward, claimedReward,
nonce, signature, { from: accounts[1] },
);
console.log(`transferMultipleDelegated, count = ${addrs.length}, second time gas used = ${callResult.receipt.gasUsed}`);
});
from, to, value, data, maxReward, claimedReward,
nonce, signature, { from: caller },
);
}, 'should forbid transferring with different data from signature');
nonce = web3Utils.randomHex(32);
signature =
signTransferAndCallDelegated(like.address, to, value, data, maxReward.add(1), nonce, privKey);
await utils.assertSolidityThrow(async () => {
await like.transferAndCallDelegated(
from, to, value, data, maxReward, claimedReward,
nonce, signature, { from: caller },
);
}, 'should forbid transferring with different maxReward from signature');
nonce = web3Utils.randomHex(32);
signature =
signTransferAndCallDelegated(like.address, to, value, data, maxReward, nonce, privKey);
await utils.assertSolidityThrow(async () => {
await like.transferAndCallDelegated(
from, to, value, data, maxReward, claimedReward,
web3Utils.randomHex(32), signature, { from: caller },
);
}, 'should forbid transferring with different nonce from signature');
nonce = web3Utils.randomHex(32);
signature = signTransferAndCallDelegated(
like.address, to, value, data, maxReward,
nonce, Accounts[1].secretKey,
);
await utils.assertSolidityThrow(async () => {
await like.transferAndCallDelegated(
);
}, 'should forbid transferring with different nonce from signature');
nonce = web3Utils.randomHex(32);
signature = signTransferAndCallDelegated(
like.address, to, value, data, maxReward,
nonce, Accounts[1].secretKey,
);
await utils.assertSolidityThrow(async () => {
await like.transferAndCallDelegated(
from, to, value, data, maxReward, claimedReward,
nonce, signature, { from: caller },
);
}, 'should forbid transferring with wrong signing key');
signature = web3Utils.randomHex(65);
await utils.assertSolidityThrow(async () => {
await like.transferAndCallDelegated(
from, to, value, data, maxReward, claimedReward,
nonce, signature, { from: caller },
);
}, 'should forbid transferring with random signature');
nonce = web3Utils.randomHex(32);
signature =
signTransferAndCallDelegated(like.address, to, value, data, maxReward, nonce, privKey);
await like.transferAndCallDelegated(
from, to, value, data, maxReward, claimedReward,
nonce, signature, { from: caller },
);
});
generateRandomInt(size) {
return utils.toBN(utils.randomHex(parseInt(size, 10) / 8)).toString();
}
var minPayoutWalletBalance = poolConfig.payoutWalletMinimum; //this is in token-satoshis
if(minPayoutWalletBalance == null)
{
minPayoutWalletBalance = 1000*100000000;
}
var payoutWalletAddress = this.getPaymentAccount().address;
var mintingWalletAddress = this.getMintingAccount().address;
var payoutWalletBalance = await this.getTokenBalanceOf(payoutWalletAddress)
var mintingWalletBalance = await this.getTokenBalanceOf(mintingWalletAddress)
var balancePaymentId = web3Utils.randomHex(32);
if( payoutWalletBalance < minPayoutWalletBalance
&& mintingWalletBalance >= minPayoutWalletBalance )
{
//queue a new transfer from the minting wallet to the payout wallet
await this.queueTokenTransfer('minting', payoutWalletAddress, minPayoutWalletBalance, balancePaymentId)
}
var self = this;
setTimeout(function(){ self.transferMinimumTokensToPayoutWallet()}, 5*60*1000) //every five minutes
generateRandomAddress() {
return utils.randomHex(20);
}
}