UNPKG

@colony/purser-metamask

Version:

A javascript library to interact with a Metamask based Ethereum wallet

51 lines (44 loc) 1.54 kB
/* * This is just to provide a nicer function name to the injected metamask * methods that we call. * * This assumes you do detection before trying to call them. */ export var getTransaction = function getTransaction() { var _global$web3$eth; return (_global$web3$eth = global.web3.eth).getTransaction.apply(_global$web3$eth, arguments); }; /** * Sign a message. Is a wrapper for web3.personal.sign * * @method signMessage */ export var signMessage = function signMessage() { var _global$web3$eth$pers; return (_global$web3$eth$pers = global.web3.eth.personal).sign.apply(_global$web3$eth$pers, arguments); }; /** * Sign transaction. Is a wrapper for web3.eth.signTransaction * * This not only signs, but also sends the transaction, we can't have it any * other way with metamask (for the time being at least...) * * @method signTransaction */ export var signTransaction = function signTransaction() { var _global$web3$eth2; return (_global$web3$eth2 = global.web3.eth).sendTransaction.apply(_global$web3$eth2, arguments); }; /** * Verify a signed message. Is a wrapper for web3.personal.ecRecover * * This takes in a message and a signature, and tries to recover the address * that initially signed this message. You than have to compare it to the * current address. * * @method verifyMessage */ export var verifyMessage = function verifyMessage() { var _global$web3$eth$pers2; return (_global$web3$eth$pers2 = global.web3.eth.personal).ecRecover.apply(_global$web3$eth$pers2, arguments); };