Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
before(async () => {
market = await StandardMarket.deployed();
registry = await DINRegistry.deployed();
orders = await Orders.deployed();
const registryUtils = await DINRegistryUtils.deployed();
// Register 2 new DINs to the merchant
const result = await registryUtils.selfRegisterDINs(2);
const logs = result.receipt.logs;
DIN1 = parseInt(ABI.decodeParameter("uint256", logs[0].topics[1]), 10);
DIN2 = parseInt(ABI.decodeParameter("uint256", logs[1].topics[1]), 10);
});
export function decodeAppAttributes(appAttrs: string): RPSAppAttributes {
const parameters = abi.decodeParameter(SolidityRPSCommitmentType, appAttrs);
return {
positionType: parseInt(parameters[0], 10),
stake: parameters[1],
preCommit: parameters[2],
bWeapon: parseInt(parameters[3], 10),
aWeapon: parseInt(parameters[4], 10),
salt: parameters[5],
};
}
} else {
reqBody.gas = parseInt(utils.sanitizeHex(rpc.params[0].gas), 16)
}
}
if (rpc.params[0].from) {
reqBody.caller = rpc.params[0].from
}
const res = await HTTP.post(URL, reqBody, timeout).then(HTTPPostProcessor)
if (!res) {
return rpc.makeResult(null)
} else {
if (res.reverted || res.vmError) {
if (res.data && (res.data as string).startsWith('0x08c379a0')) {
debug('VM reverted with message:', require('web3-eth-abi').decodeParameter('string', res.data.replace(/^0x08c379a0/i, '')))
} else if (res.vmError) {
debug('VM returned error:', res.vmError)
}
return rpc.makeResult(null)
} else {
return rpc.makeResult(res.data === '0x' ? '' : res.data)
}
}
})
function decodeAppAttributes(appAttrs: string): AppAttributes {
const parameters = abi.decodeParameter(SolidityRPSCommitmentType, appAttrs);
return {
positionType: parameters[0] as PositionType,
stake: parameters[1],
preCommit: parameters[2],
bWeapon: parameters[3] as Weapon,
aWeapon: parameters[4] as Weapon,
salt: parameters[5],
};
}