Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const result = await promisify<{ result: string, error: Error }>(
this.web3.currentProvider, 'sendAsync'
)({
method: 'eth_signTypedData',
params: [params, this.channel.account],
from: this.channel.account
});
if (result.error)
throw result.error;
sign = result.result;
} catch (err) {
if (err.message && err.message.includes('User denied')) {
throw err;
}
console.log('Error on signTypedData', err);
const hash = typedSignatureHash(params);
// ask for signing of the hash
sign = await this.signMessage(hash);
}
//debug
const recovered = recoverTypedSignature({ data: params, sig: sign });
console.log('signTypedData =', sign, recovered);
proof.sign = sign;
// return signed message
if (proof.balance === this.channel.proof.balance) {
this.setChannel(Object.assign(
{},
this.channel,
{ proof, next_proof: proof }
));
let returnData = {}
returnData.signature = result.result
// ensure that the signature matches
const recoveredAddress = ethUtil.toChecksumAddress(ethSigUtil.recoverTypedSignature({
data: typedData,
sig: returnData.signature
}))
if (ethUtil.toChecksumAddress(recoveredAddress) !== from) {
return reject(Error(
`The returned signature '${returnData.signature}' originated from '${recoveredAddress}', not '${from}'.`
))
}
returnData.from = from
returnData.messageHash = ethSigUtil.typedSignatureHash(typedData)
const signature = ethUtil.fromRpcSig(returnData.signature)
returnData.r = ethUtil.addHexPrefix(Buffer.from(signature.r).toString('hex'))
returnData.s = ethUtil.addHexPrefix(Buffer.from(signature.s).toString('hex'))
returnData.v = signature.v
resolve(returnData)
})
})
var Voting = artifacts.require("./Voting.sol");
var ECRecovery = artifacts.require("./ECRecovery.sol");
const sigUtil = require("eth-sig-util")
var alice_vote_hash = sigUtil.typedSignatureHash([{ type: 'string', name: 'Message', value: "Vote for Alice"}])
var bob_vote_hash = sigUtil.typedSignatureHash([{ type: 'string', name: 'Message', value: "Vote for Bob"}])
var carol_vote_hash = sigUtil.typedSignatureHash([{ type: 'string', name: 'Message', value: "Vote for Carol"}])
module.exports = function(deployer) {
deployer.deploy(ECRecovery);
deployer.link(ECRecovery, Voting);
deployer.deploy(Voting, ['Alice', 'Bob', 'Carol'], [alice_vote_hash, bob_vote_hash, carol_vote_hash]);
};
export function validateTypedSignMessageDataV1(messageData: TypedMessageParams) {
if (!messageData.from || typeof messageData.from !== 'string' || !isValidAddress(messageData.from)) {
throw new Error(`Invalid "from" address: ${messageData.from} must be a valid string.`);
}
if (!messageData.data || !Array.isArray(messageData.data)) {
throw new Error(`Invalid message "data": ${messageData.data} must be a valid array.`);
}
try {
sigUtil.typedSignatureHash(messageData.data);
} catch (e) {
throw new Error(`Expected EIP712 typed data.`);
}
}
var fravollSolidityPatternsRandomnessRandomness = artifacts.require("./fravoll/solidity-patterns/Randomness/Randomness.sol");
var fravollSolidityPatternsEternalStorageEternalStorage = artifacts.require("./fravoll/solidity-patterns/EternalStorage/EternalStorage.sol");
var fravollSolidityPatternsEmergencyStopEmergencyStop = artifacts.require("./fravoll/solidity-patterns/EmergencyStop/EmergencyStop.sol");
var fravollSolidityPatternsChecksEffectsInteractionChecksEffectsInteractions = artifacts.require("./fravoll/solidity-patterns/ChecksEffectsInteraction/ChecksEffectsInteractions.sol");
var fravollSolidityPatternsTightVariablePackingTightVariablePacking = artifacts.require("./fravoll/solidity-patterns/TightVariablePacking/StructPackingExample.sol");
var fravollSolidityPatternsTightVariablePackingCheapStructPackingExample = artifacts.require("./fravoll/solidity-patterns/TightVariablePacking/CheapStructPackingExample.sol");
var fravollSolidityPatternsTightVariablePackingExpensiveStructPackingExample = artifacts.require("./fravoll/solidity-patterns/TightVariablePacking/ExpensiveStructPackingExample.sol");
var fravollSolidityPatternsOracleoracle = artifacts.require("./fravoll/solidity-patterns/Oracle/Oracle.sol");
var fravollSolidityPatternsStateMachineStateMachine = artifacts.require("./fravoll/solidity-patterns/StateMachine/StateMachine.sol");
var fravollSolidityPatternsMemoryArrayBuildingMemoryArrayBuildingCheap = artifacts.require("./fravoll/solidity-patterns/MemoryArrayBuilding/MemoryArrayBuildingCheap.sol");
var fravollSolidityPatternsMemoryArrayBuildingMemoryArrayBuildingExpensive = artifacts.require("./fravoll/solidity-patterns/MemoryArrayBuilding/MemoryArrayBuildingExpensive.sol");
var fravollSolidityPatternsMemoryArrayBuildingMemoryArrayBuilding = artifacts.require("./fravoll/solidity-patterns/MemoryArrayBuilding/MemoryArrayBuilding.sol");
const sigUtil = require("eth-sig-util")
var alice_vote_hash = sigUtil.typedSignatureHash([{ type: 'string', name: 'Message', value: "Vote for Alice" }])
var bob_vote_hash = sigUtil.typedSignatureHash([{ type: 'string', name: 'Message', value: "Vote for Bob" }])
var carol_vote_hash = sigUtil.typedSignatureHash([{ type: 'string', name: 'Message', value: "Vote for Carol" }])
module.exports = function (deployer) {
deployer.deploy(maheshmurthyEthereumVotingDappECRecovery);
deployer.link(maheshmurthyEthereumVotingDappECRecovery, maheshmurthyEthereumVotingDappVoting);
deployer.deploy(maheshmurthyEthereumVotingDappVoting, ['Alice', 'Bob', 'Carol'], [alice_vote_hash, bob_vote_hash, carol_vote_hash]);
deployer.deploy(willitscaleLearningSolidityTutorial28SolidityAddressBook);
deployer.deploy(willitscaleLearningSolidityTutorial21ConvertLib);
deployer.link(willitscaleLearningSolidityTutorial21ConvertLib, willitscaleLearningSolidityTutorial21MetaCoin);
deployer.deploy(willitscaleLearningSolidityTutorial21MetaCoin);
deployer.deploy(willitscaleLearningSolidityTutorial22SafeMath);
deployer.link(willitscaleLearningSolidityTutorial22SafeMath, willitscaleLearningSolidityTutorial22MyToken);
deployer.deploy(willitscaleLearningSolidityTutorial22Addresses);
var fravollSolidityPatternsEternalStorageEternalStorage = artifacts.require("./fravoll/solidity-patterns/EternalStorage/EternalStorage.sol");
var fravollSolidityPatternsEmergencyStopEmergencyStop = artifacts.require("./fravoll/solidity-patterns/EmergencyStop/EmergencyStop.sol");
var fravollSolidityPatternsChecksEffectsInteractionChecksEffectsInteractions = artifacts.require("./fravoll/solidity-patterns/ChecksEffectsInteraction/ChecksEffectsInteractions.sol");
var fravollSolidityPatternsTightVariablePackingTightVariablePacking = artifacts.require("./fravoll/solidity-patterns/TightVariablePacking/StructPackingExample.sol");
var fravollSolidityPatternsTightVariablePackingCheapStructPackingExample = artifacts.require("./fravoll/solidity-patterns/TightVariablePacking/CheapStructPackingExample.sol");
var fravollSolidityPatternsTightVariablePackingExpensiveStructPackingExample = artifacts.require("./fravoll/solidity-patterns/TightVariablePacking/ExpensiveStructPackingExample.sol");
var fravollSolidityPatternsOracleoracle = artifacts.require("./fravoll/solidity-patterns/Oracle/Oracle.sol");
var fravollSolidityPatternsStateMachineStateMachine = artifacts.require("./fravoll/solidity-patterns/StateMachine/StateMachine.sol");
var fravollSolidityPatternsMemoryArrayBuildingMemoryArrayBuildingCheap = artifacts.require("./fravoll/solidity-patterns/MemoryArrayBuilding/MemoryArrayBuildingCheap.sol");
var fravollSolidityPatternsMemoryArrayBuildingMemoryArrayBuildingExpensive = artifacts.require("./fravoll/solidity-patterns/MemoryArrayBuilding/MemoryArrayBuildingExpensive.sol");
var fravollSolidityPatternsMemoryArrayBuildingMemoryArrayBuilding = artifacts.require("./fravoll/solidity-patterns/MemoryArrayBuilding/MemoryArrayBuilding.sol");
const sigUtil = require("eth-sig-util")
var alice_vote_hash = sigUtil.typedSignatureHash([{ type: 'string', name: 'Message', value: "Vote for Alice" }])
var bob_vote_hash = sigUtil.typedSignatureHash([{ type: 'string', name: 'Message', value: "Vote for Bob" }])
var carol_vote_hash = sigUtil.typedSignatureHash([{ type: 'string', name: 'Message', value: "Vote for Carol" }])
module.exports = function (deployer) {
deployer.deploy(maheshmurthyEthereumVotingDappECRecovery);
deployer.link(maheshmurthyEthereumVotingDappECRecovery, maheshmurthyEthereumVotingDappVoting);
deployer.deploy(maheshmurthyEthereumVotingDappVoting, ['Alice', 'Bob', 'Carol'], [alice_vote_hash, bob_vote_hash, carol_vote_hash]);
deployer.deploy(willitscaleLearningSolidityTutorial28SolidityAddressBook);
deployer.deploy(willitscaleLearningSolidityTutorial21ConvertLib);
deployer.link(willitscaleLearningSolidityTutorial21ConvertLib, willitscaleLearningSolidityTutorial21MetaCoin);
deployer.deploy(willitscaleLearningSolidityTutorial21MetaCoin);
deployer.deploy(willitscaleLearningSolidityTutorial22SafeMath);
deployer.link(willitscaleLearningSolidityTutorial22SafeMath, willitscaleLearningSolidityTutorial22MyToken);
deployer.deploy(willitscaleLearningSolidityTutorial22Addresses);
deployer.link(willitscaleLearningSolidityTutorial22Addresses, willitscaleLearningSolidityTutorial22MyToken);
var Voting = artifacts.require("./Voting.sol");
var ECRecovery = artifacts.require("./ECRecovery.sol");
const sigUtil = require("eth-sig-util")
var alice_vote_hash = sigUtil.typedSignatureHash([{ type: 'string', name: 'Message', value: "Vote for Alice"}])
var bob_vote_hash = sigUtil.typedSignatureHash([{ type: 'string', name: 'Message', value: "Vote for Bob"}])
var carol_vote_hash = sigUtil.typedSignatureHash([{ type: 'string', name: 'Message', value: "Vote for Carol"}])
module.exports = function(deployer) {
deployer.deploy(ECRecovery);
deployer.link(ECRecovery, Voting);
deployer.deploy(Voting, ['Alice', 'Bob', 'Carol'], [alice_vote_hash, bob_vote_hash, carol_vote_hash]);
};
var Voting = artifacts.require("./Voting.sol");
var ECRecovery = artifacts.require("./ECRecovery.sol");
const sigUtil = require("eth-sig-util")
var alice_vote_hash = sigUtil.typedSignatureHash([{ type: 'string', name: 'Message', value: "Vote for Alice"}])
var bob_vote_hash = sigUtil.typedSignatureHash([{ type: 'string', name: 'Message', value: "Vote for Bob"}])
var carol_vote_hash = sigUtil.typedSignatureHash([{ type: 'string', name: 'Message', value: "Vote for Carol"}])
module.exports = function(deployer) {
deployer.deploy(ECRecovery);
deployer.link(ECRecovery, Voting);
deployer.deploy(Voting, ['Alice', 'Bob', 'Carol'], [alice_vote_hash, bob_vote_hash, carol_vote_hash]);
};