Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
rpc.getTransactionReceipt(r.hash, (receipt) => {
if (!receipt || receipt.error) return console.error("getTransactionReceipt error:", receipt);
console.log("contract address:", receipt.contractAddress);
contractAddresses.controller = abi.format_address(receipt.contractAddress);
// 3. bash ./deterministic_build.sh "0xactualControllerAddress"
cp.exec("bash deterministic_build.sh " + contractAddresses.controller, (err, stdout, stderr) => {
if (err) return console.error("deterministic build error:", err);
// 4. upload deps ['mutex.se', 'cash.se', 'repContract.se'] are the ones so far, then the remaining contracts
async.eachSeries(contractNames, (contractName, nextContract) => {
if (contractAddresses[contractName]) return nextContract();
console.log("uploading contractName:", contractName);
fs.readFile("../compiled/" + contractName + ".se.evm", (err, contractFile) => {
rpc.transact({
from: rpc.getCoinbase(),
data: "0x" + contractFile.toString().trim(),
send: true,
returns: "null"
}, null, noop, (r) => {
rpc.getTransactionReceipt(r.hash, (receipt) => {
if (!receipt || receipt.error) return nextContract(receipt || new Error("upload error"));
contractAddresses[contractName.charAt(0).toUpperCase() + contractName.slice(1)] = abi.format_address(receipt.contractAddress);
// 4a) do controller.setValue('contract', address) and self.controller.addToWhitelist(address) [can be in same block]
async.each([{
method: "setValue",
signature: ["int256", "int256"],
send: true,
returns: "int256",
from: rpc.getCoinbase(),
to: contractAddresses.controller,
params: [abi.short_string_to_int256(contractName), abi.format_int256(receipt.contractAddress)]
}, {
method: "addToWhitelist",
signature: ["int256"],
send: true,
returns: "int256",
from: rpc.getCoinbase(),
it(JSON.stringify(t), function () {
var localHash = makeReports.makeHash(t.salt, t.report, t.event, t.from, t.isScalar, t.isIndeterminate);
if (t.expected) {
assert.strictEqual(localHash, t.expected);
} else {
assert.strictEqual(localHash, augur.MakeReports.makeHash(abi.hex(t.salt), abi.hex(t.report), t.event, t.from));
}
});
};
it(JSON.stringify(t), function () {
var localHash = makeReports.makeHash(t.salt, t.report, t.event, t.from, t.isScalar, t.isIndeterminate);
assert.strictEqual(localHash, augur.MakeReports.makeHash(abi.hex(t.salt), abi.hex(t.report), t.event, t.from));
});
};
it(JSON.stringify(t), function () {
var shares = augur.orders.limit.sharesToTrade(t.q, t.outcome, t.alpha, t.cap, t.isBuy);
assert.notProperty(shares, "error");
var zero = augur.orders.limit.f(shares, augur.utils.toDecimal(t.q), t.outcome, augur.utils.toDecimal(t.alpha), augur.utils.toDecimal(t.cap));
assert.closeTo(zero.toNumber(), 0, 1e-12);
assert.strictEqual(abi.number(shares).toFixed(5), t.expected);
});
};
sell: function (p) {
assert.deepEqual(JSON.stringify(p), JSON.stringify({
amount: abi.fix(120, 'hex'),
price: abi.fix(.35, 'hex'),
market: '0xa1',
outcome: '1',
scalarMinMax: null,
onSent: noop,
onSuccess: noop,
onFailed: noop,
minimumTradeSize: abi.fix(MINIMUM_TRADE_SIZE, 'hex'),
isShortAsk: 0,
tradeGroupID: 0
}));
finished();
}
});
assertions: function (tx) {
assert.deepEqual(JSON.stringify(tx), JSON.stringify({
branch: '1010101',
description: 'This is a test event description',
expDate: parseInt(1500000000, 10),
minValue: abi.fix('1', "hex"),
maxValue: abi.fix('50', "hex"),
numOutcomes: '2',
resolution: 'https://iknoweverything.com'
}));
}
});
buy: function (p) {
assert.deepEqual(JSON.stringify(p), JSON.stringify({
amount: abi.fix(320, 'hex'),
price: abi.fix(0.85, 'hex'),
market: '0xa1',
outcome: '1',
scalarMinMax: null,
onSent: noop,
onSuccess: noop,
onFailed: noop,
tradeGroupID: '0x01',
minimumTradeSize: abi.fix(MINIMUM_TRADE_SIZE, 'hex'),
}));
finished();
},
});
shortAsk: function (p) {
assert.deepEqual(JSON.stringify(p), JSON.stringify({
amount: abi.fix(5, 'hex'),
price: abi.fix(0.95, 'hex'),
market: '0xa1',
outcome: '1',
scalarMinMax: null,
tradeGroupID: '0x01',
onSent: noop,
onSuccess: noop,
onFailed: noop,
minimumTradeSize: abi.fix(MINIMUM_TRADE_SIZE, 'hex'),
}));
finished();
}
});
assertions: function (tx) {
assert.deepEqual(JSON.stringify(tx), JSON.stringify({
branch: '1010101',
description: 'This is a test event description',
expDate: parseInt(1500000000, 10),
minValue: abi.fix('10', "hex"),
maxValue: abi.fix('250', "hex"),
numOutcomes: '2',
resolution: ''
}));
}
});