Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
source: "With value: Send `@tokenAmount(token, msg.value)` from `msg.sender` to `receiver`",
bindings: { token: address(ETH), receiver: address('0x8401Eb5ff34cc943f096A32EF3d5113FEbE8D4Eb') },
options: { from: '0xb4124cEB3451635DAcedd11767f004d8a28c6eE7', value: '1000000000000000000' },
}, 'With value: Send 1 ETH from 0xb4124cEB3451635DAcedd11767f004d8a28c6eE7 to 0x8401Eb5ff34cc943f096A32EF3d5113FEbE8D4Eb'],
[{
source: "Sending tx with data `msg.data` to contract at `contract`",
bindings: { contract: address('0x960b236A07cf122663c4303350609A66A7B288C0') },
options: { data: '0xabcdef'}
}, "Sending tx with data 0xabcdef to contract at 0x960b236A07cf122663c4303350609A66A7B288C0"],
// using msg.data on a helper
[{
source: "Performs a call to `@radspec(contract, msg.data)`",
bindings: { contract: address('0x960b236A07cf122663c4303350609A66A7B288C0') },
options: { data: keccak256(Object.keys(knownFunctions)[3]).slice(0,10) }
}, `Performs a call to ${Object.values(knownFunctions)[3]}`],
...comparisonCases,
...helperCases,
...dataDecodeCases
]
cases.forEach(([input, expected], index) => {
test(`${index} - ${input.source}`, async (t) => {
const { userHelpers } = input.options || {}
const actual = await evaluateRaw(
input.source,
input.bindings,
{
...input.options,
availableHelpers: { ...defaultHelpers, ...userHelpers }
constructOutputs() {
const proofOutput = {
inputNotes: this.inputNotes,
outputNotes: this.outputNotes,
publicValue: this.publicValue,
publicOwner: this.publicOwner,
challenge: this.challengeHex,
};
this.output = outputCoder.encodeProofOutput(proofOutput);
this.outputs = outputCoder.encodeProofOutputs([proofOutput]);
this.hash = outputCoder.hashProofOutput(this.output);
this.validatedProofHash = keccak256(
AbiCoder.encodeParameters(['bytes32', 'uint24', 'address'], [this.hash, proofs.JOIN_SPLIT_PROOF, this.sender]),
);
}
constructOutputs() {
const proofOutput = {
inputNotes: this.inputNotes,
outputNotes: this.outputNotes,
publicValue: this.publicValue,
publicOwner: this.publicOwner,
challenge: this.challengeHex,
};
this.output = outputCoder.encodeProofOutput(proofOutput);
this.outputs = outputCoder.encodeProofOutputs([proofOutput]);
this.hash = outputCoder.hashProofOutput(this.output);
this.validatedProofHash = keccak256(
AbiCoder.encodeParameters(['bytes32', 'uint24', 'address'], [this.hash, proofs.PUBLIC_RANGE_PROOF, this.sender]),
);
}
constructOutputs() {
this.output = '';
this.outputs = outputCoder.encodeProofOutputs([
{
inputNotes: [this.inputNotes[0]],
outputNotes: [this.outputNotes[0]],
publicValue: this.publicValue,
publicOwner: this.publicOwner,
challenge: this.challengeHex,
},
{
inputNotes: [this.outputNotes[1]],
outputNotes: [this.inputNotes[1]],
publicValue: this.publicValue,
publicOwner: this.publicOwner,
challenge: `0x${keccak256(this.challengeHex).slice(2)}`,
},
]);
this.hash = outputCoder.hashProofOutput(this.outputs);
this.validatedProofHash = keccak256(
AbiCoder.encodeParameters(['bytes32', 'uint24', 'address'], [this.hash, proofs.SWAP_PROOF, this.sender]),
);
}
function getMessageFingerprint(messageObject) {
return web3Utils.keccak256(JSON.stringify(messageObject))
}
getPinHash() {
let pin = this.pin;
for(let i = 0;i < HASHNUMBER; i++){
pin = web3Utils.keccak256(pin);
}
return pin;
}
privateKey = privateKey.substring(2);
}
var ethTx = new Transaction(transaction, transactionOptions);
ethTx.sign(Buffer.from(privateKey, 'hex'));
var validationResult = ethTx.validate(true);
if (validationResult !== '') {
throw new Error('Signer Error: ' + validationResult);
}
var rlpEncoded = ethTx.serialize().toString('hex');
var rawTransaction = '0x' + rlpEncoded;
var transactionHash = utils.keccak256(rawTransaction);
return {
messageHash: '0x' + Buffer.from(ethTx.hash(false)).toString('hex'),
v: '0x' + Buffer.from(ethTx.v).toString('hex'),
r: '0x' + Buffer.from(ethTx.r).toString('hex'),
s: '0x' + Buffer.from(ethTx.s).toString('hex'),
rawTransaction: rawTransaction,
transactionHash: transactionHash
};
} catch (e) {
callback(e);
return Promise.reject(e);
}
callback(null, result);
getPinHash() {
let noOfTimeToHash = 3;
let pin = this.pin;
for(let i = 0;i < noOfTimeToHash; i++){
pin = web3Utils.keccak256(pin);
}
return pin;
}
_getHash(fileName) {
this.hashCounter++;
return web3Utils.keccak256(`${fileName}:${this.hashCounter}`);
}