Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function encodeMock2(to, value, key) {
const bytesBuf = ['0x'];
bytesBuf.push(web3Abi.encodeParameter('address', to).substr(2 + (12 * 2)));
bytesBuf.push(web3Abi.encodeParameter('uint256', value).substr(2));
bytesBuf.push(web3Abi.encodeParameter('bytes32', key).substr(2));
return bytesBuf.join('');
}
function encodeMock2(to, value, key) {
const bytesBuf = ['0x'];
bytesBuf.push(web3Abi.encodeParameter('address', to).substr(2 + (12 * 2)));
bytesBuf.push(web3Abi.encodeParameter('uint256', value).substr(2));
bytesBuf.push(web3Abi.encodeParameter('bytes32', key).substr(2));
return bytesBuf.join('');
}
export function encodeAppAttributes(appAttrs: RPSAppAttributes): Bytes {
const { positionType, stake, preCommit, bWeapon, aWeapon, salt } = appAttrs;
return abi.encodeParameter(SolidityRPSCommitmentType, [
positionType,
stake,
preCommit,
bWeapon,
aWeapon,
salt,
]);
}
return types[primaryType].reduce((acc, { name, type }) => {
if (types[type]) {
return `${acc}${sliceKeccak256(`0x${encodeMessageData(types, type, message[name])}`)}`;
}
if (type === 'string' || type === 'bytes') {
return `${acc}${sliceKeccak256(message[name])}`;
}
if (type.includes('[')) {
return `${acc}${sliceKeccak256(AbiCoder.encodeParameter(type, message[name]))}`;
}
return `${acc}${AbiCoder.encodeParameters([type], [message[name]]).slice(2)}`;
}, sliceKeccak256(signer.encodeStruct(primaryType, types)));
};
function encodeParameter(type, value) {
assert(!_.isNil(value));
return abiEncoder.encodeParameter(type, normalizeEncodeValue(type, value));
}