Do not fill in implicit values for JSON-RPC based signers (#335).
This commit is contained in:
parent
9565c28a91
commit
2d854bd94c
@ -12,8 +12,7 @@ import { getAddress } from '../utils/address';
|
|||||||
import { BigNumber } from '../utils/bignumber';
|
import { BigNumber } from '../utils/bignumber';
|
||||||
import { hexlify, hexStripZeros } from '../utils/bytes';
|
import { hexlify, hexStripZeros } from '../utils/bytes';
|
||||||
import { getNetwork } from '../utils/networks';
|
import { getNetwork } from '../utils/networks';
|
||||||
import { checkProperties, defineReadOnly, shallowCopy } from '../utils/properties';
|
import { checkProperties, defineReadOnly, resolveProperties, shallowCopy } from '../utils/properties';
|
||||||
import { populateTransaction } from '../utils/transaction';
|
|
||||||
import { toUtf8Bytes } from '../utils/utf8';
|
import { toUtf8Bytes } from '../utils/utf8';
|
||||||
import { fetchJson, poll } from '../utils/web';
|
import { fetchJson, poll } from '../utils/web';
|
||||||
|
|
||||||
@ -104,16 +103,18 @@ export class JsonRpcSigner extends Signer {
|
|||||||
|
|
||||||
sendTransaction(transaction: TransactionRequest): Promise<TransactionResponse> {
|
sendTransaction(transaction: TransactionRequest): Promise<TransactionResponse> {
|
||||||
|
|
||||||
// Once populateTransaction resolves, the from address will be populated from getAddress
|
let fromAddress = this.getAddress().then((address) => {
|
||||||
let from: string = null;
|
if (address) { address = address.toLowerCase(); }
|
||||||
let getAddress = this.getAddress().then((address) => {
|
return address;
|
||||||
if (address) { from = address.toLowerCase(); }
|
|
||||||
return from;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return populateTransaction(transaction, this.provider, getAddress).then((tx) => {
|
return Promise.all([
|
||||||
|
resolveProperties(transaction),
|
||||||
|
fromAddress
|
||||||
|
]).then((results) => {
|
||||||
|
let tx = results[0];
|
||||||
let hexTx = JsonRpcProvider.hexlifyTransaction(tx);
|
let hexTx = JsonRpcProvider.hexlifyTransaction(tx);
|
||||||
hexTx.from = from;
|
hexTx.from = results[1];
|
||||||
return this.provider.send('eth_sendTransaction', [ hexTx ]).then((hash) => {
|
return this.provider.send('eth_sendTransaction', [ hexTx ]).then((hash) => {
|
||||||
return poll(() => {
|
return poll(() => {
|
||||||
return this.provider.getTransaction(hash).then((tx: TransactionResponse) => {
|
return this.provider.getTransaction(hash).then((tx: TransactionResponse) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user