Fixed auto-address and signing with Metamask and Web3Provicder.
This commit is contained in:
parent
c550f2eb07
commit
c4690f9e7b
@ -11,7 +11,7 @@ Complete Ethereum wallet implementation and utilities in JavaScript.
|
|||||||
- Import and export **JSON wallets** (Geth, Parity and crowdsale) and brain wallets
|
- Import and export **JSON wallets** (Geth, Parity and crowdsale) and brain wallets
|
||||||
- Import and export BIP 39 **mnemonic phrases** (12 word backup phrases) and **HD Wallets**
|
- Import and export BIP 39 **mnemonic phrases** (12 word backup phrases) and **HD Wallets**
|
||||||
- Meta-classes create JavaScript objects from any contract ABI
|
- Meta-classes create JavaScript objects from any contract ABI
|
||||||
- Connect to Ethereum nodes over [JSON-RPC](https://github.com/ethereum/wiki/wiki/JSON-RPC), [INFURA](https://infura.io) or [Etherscan](https://etherscan.io)
|
- Connect to Ethereum nodes over [JSON-RPC](https://github.com/ethereum/wiki/wiki/JSON-RPC), [INFURA](https://infura.io), [Etherscan](https://etherscan.io), or [MetaMask](https://metamask.io)
|
||||||
- ENS names are first-class citizens; they can almost always used instead of Ethereum addresses
|
- ENS names are first-class citizens; they can almost always used instead of Ethereum addresses
|
||||||
- **Tiny** (~77kb compressed; 227kb uncompressed)
|
- **Tiny** (~77kb compressed; 227kb uncompressed)
|
||||||
- **Complete** functionality for all your Ethereum needs
|
- **Complete** functionality for all your Ethereum needs
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ethers-providers",
|
"name": "ethers-providers",
|
||||||
"version": "2.1.17",
|
"version": "2.1.18",
|
||||||
"description": "Service provider for Ethereum wallet library.",
|
"description": "Service provider for Ethereum wallet library.",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "http://github.com/ethers-io/ethers.js/issues",
|
"url": "http://github.com/ethers-io/ethers.js/issues",
|
||||||
|
@ -20,8 +20,7 @@ function Web3Signer(provider, address) {
|
|||||||
enumerable: true,
|
enumerable: true,
|
||||||
get: function() {
|
get: function() {
|
||||||
throw new Error('unsupported sync operation; use getAddress');
|
throw new Error('unsupported sync operation; use getAddress');
|
||||||
},
|
}
|
||||||
writable: false
|
|
||||||
});
|
});
|
||||||
utils.defineProperty(this, '_syncAddress', false);
|
utils.defineProperty(this, '_syncAddress', false);
|
||||||
}
|
}
|
||||||
@ -79,7 +78,19 @@ utils.defineProperty(Web3Signer.prototype, 'signMessage', function(message) {
|
|||||||
|
|
||||||
var data = ((typeof(message) === 'string') ? utils.toUtf8Bytes(message): message);
|
var data = ((typeof(message) === 'string') ? utils.toUtf8Bytes(message): message);
|
||||||
return this.getAddress().then(function(address) {
|
return this.getAddress().then(function(address) {
|
||||||
return provider.send('eth_sign', [ address, utils.hexlify(data) ]);
|
|
||||||
|
// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign
|
||||||
|
var method = 'eth_sign';
|
||||||
|
var params = [ address, utils.hexlify(data) ];
|
||||||
|
|
||||||
|
// Metamask complains about eth_sign (and on some versions hangs)
|
||||||
|
if (provider.isMetamask) {
|
||||||
|
// https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign
|
||||||
|
method = 'personal_sign';
|
||||||
|
params = [ utils.hexlify(data), address ];
|
||||||
|
}
|
||||||
|
|
||||||
|
return provider.send(method, params);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user