Skip to content

Commit fa68385

Browse files
committed
Updated dist files.
1 parent d54609a commit fa68385

19 files changed

+231
-165
lines changed

_version.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export declare const version = "4.0.6";
1+
export declare const version = "4.0.7";

_version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
exports.version = "4.0.6";
3+
exports.version = "4.0.7";

dist/ethers.js

Lines changed: 106 additions & 79 deletions
Large diffs are not rendered by default.

dist/ethers.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ethers.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ethers.types.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,11 @@ declare module 'ethers/utils' {
219219
import { keccak256 as solidityKeccak256, pack as solidityPack, sha256 as soliditySha256 } from 'ethers/utils/solidity';
220220
import { randomBytes } from 'ethers/utils/random-bytes';
221221
import { getNetwork } from 'ethers/utils/networks';
222-
import { deepCopy, defineReadOnly, resolveProperties, shallowCopy } from 'ethers/utils/properties';
222+
import { checkProperties, deepCopy, defineReadOnly, resolveProperties, shallowCopy } from 'ethers/utils/properties';
223223
import * as RLP from 'ethers/utils/rlp';
224224
import { computeAddress, computePublicKey, recoverAddress, recoverPublicKey, verifyMessage } from 'ethers/utils/secp256k1';
225225
import { SigningKey } from 'ethers/utils/signing-key';
226+
import { populateTransaction } from 'ethers/utils/transaction';
226227
import { parse as parseTransaction, serialize as serializeTransaction } from 'ethers/utils/transaction';
227228
import { formatBytes32String, parseBytes32String, toUtf8Bytes, toUtf8String } from 'ethers/utils/utf8';
228229
import { commify, formatEther, parseEther, formatUnits, parseUnits } from 'ethers/utils/units';
@@ -238,7 +239,7 @@ declare module 'ethers/utils' {
238239
import { ConnectionInfo, OnceBlockable, PollOptions } from 'ethers/utils/web';
239240
import { EncryptOptions, ProgressCallback } from 'ethers/utils/secret-storage';
240241
import { Wordlist } from 'ethers/utils/wordlist';
241-
export { AbiCoder, defaultAbiCoder, formatSignature, formatParamType, parseSignature, parseParamType, RLP, fetchJson, getNetwork, deepCopy, defineReadOnly, resolveProperties, shallowCopy, arrayify, concat, padZeros, stripZeros, HDNode, SigningKey, Interface, base64, BigNumber, bigNumberify, hexlify, hexStripZeros, hexZeroPad, hexDataLength, hexDataSlice, toUtf8Bytes, toUtf8String, formatBytes32String, parseBytes32String, hashMessage, namehash, id, getAddress, getIcapAddress, getContractAddress, formatEther, parseEther, formatUnits, parseUnits, commify, keccak256, sha256, randomBytes, solidityPack, solidityKeccak256, soliditySha256, splitSignature, joinSignature, parseTransaction, serializeTransaction, getJsonWalletAddress, computeAddress, computePublicKey, recoverAddress, recoverPublicKey, verifyMessage, SupportedAlgorithms, UnicodeNormalizationForm, CoerceFunc, EventFragment, FunctionFragment, ParamType, BigNumberish, Arrayish, Hexable, Signature, Indexed, DeployDescription, EventDescription, FunctionDescription, LogDescription, TransactionDescription, Network, Networkish, Transaction, UnsignedTransaction, ConnectionInfo, OnceBlockable, PollOptions, EncryptOptions, ProgressCallback, Wordlist, };
242+
export { AbiCoder, defaultAbiCoder, formatSignature, formatParamType, parseSignature, parseParamType, RLP, fetchJson, getNetwork, checkProperties, deepCopy, defineReadOnly, resolveProperties, shallowCopy, arrayify, concat, padZeros, stripZeros, HDNode, SigningKey, Interface, base64, BigNumber, bigNumberify, hexlify, hexStripZeros, hexZeroPad, hexDataLength, hexDataSlice, toUtf8Bytes, toUtf8String, formatBytes32String, parseBytes32String, hashMessage, namehash, id, getAddress, getIcapAddress, getContractAddress, formatEther, parseEther, formatUnits, parseUnits, commify, keccak256, sha256, randomBytes, solidityPack, solidityKeccak256, soliditySha256, splitSignature, joinSignature, parseTransaction, populateTransaction, serializeTransaction, getJsonWalletAddress, computeAddress, computePublicKey, recoverAddress, recoverPublicKey, verifyMessage, SupportedAlgorithms, UnicodeNormalizationForm, CoerceFunc, EventFragment, FunctionFragment, ParamType, BigNumberish, Arrayish, Hexable, Signature, Indexed, DeployDescription, EventDescription, FunctionDescription, LogDescription, TransactionDescription, Network, Networkish, Transaction, UnsignedTransaction, ConnectionInfo, OnceBlockable, PollOptions, EncryptOptions, ProgressCallback, Wordlist, };
242243
}
243244

244245
declare module 'ethers/wordlists' {
@@ -260,7 +261,7 @@ declare module 'ethers/utils/shims' {
260261
}
261262

262263
declare module 'ethers/_version' {
263-
export const version = "4.0.6";
264+
export const version = "4.0.7";
264265
}
265266

266267
declare module 'ethers/utils/bignumber' {
@@ -412,6 +413,7 @@ declare module 'ethers/utils/transaction' {
412413
import { BigNumber } from 'ethers/utils/bignumber';
413414
import { Arrayish, Signature } from 'ethers/utils/bytes';
414415
import { BigNumberish } from 'ethers/utils/bignumber';
416+
import { Provider } from 'ethers/providers/abstract-provider';
415417
export type UnsignedTransaction = {
416418
to?: string;
417419
nonce?: number;
@@ -437,6 +439,7 @@ declare module 'ethers/utils/transaction' {
437439
}
438440
export function serialize(transaction: UnsignedTransaction, signature?: Arrayish | Signature): string;
439441
export function parse(rawTransaction: Arrayish): Transaction;
442+
export function populateTransaction(transaction: any, provider: Provider, from: string | Promise<string>): Promise<Transaction>;
440443
}
441444

442445
declare module 'ethers/providers/abstract-provider' {
@@ -936,6 +939,9 @@ declare module 'ethers/utils/properties' {
936939
export function setType(object: any, type: string): void;
937940
export function isType(object: any, type: string): boolean;
938941
export function resolveProperties(object: any): Promise<any>;
942+
export function checkProperties(object: any, properties: {
943+
[name: string]: boolean;
944+
}): void;
939945
export function shallowCopy(object: any): any;
940946
export function deepCopy(object: any, frozen?: boolean): any;
941947
export function inheritable(parent: any): (child: any) => void;

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ethers",
3-
"version": "4.0.6",
3+
"version": "4.0.7",
44
"description": "Ethereum wallet library.",
55
"main": "./index.js",
66
"types": "./index.d.ts",

providers/base-provider.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,9 @@ var BaseProvider = /** @class */ (function (_super) {
10951095
result = true;
10961096
return !(event.once);
10971097
});
1098+
if (this.listenerCount() === 0) {
1099+
this.polling = false;
1100+
}
10981101
return result;
10991102
};
11001103
BaseProvider.prototype.listenerCount = function (eventName) {

providers/json-rpc-provider.js

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
2020
// See: https://github.com/ethereum/wiki/wiki/JSON-RPC
2121
var base_provider_1 = require("./base-provider");
2222
var abstract_signer_1 = require("../abstract-signer");
23+
var errors = __importStar(require("../errors"));
2324
var address_1 = require("../utils/address");
2425
var bytes_1 = require("../utils/bytes");
2526
var networks_1 = require("../utils/networks");
2627
var properties_1 = require("../utils/properties");
28+
var transaction_1 = require("../utils/transaction");
2729
var utf8_1 = require("../utils/utf8");
2830
var web_1 = require("../utils/web");
29-
var errors = __importStar(require("../errors"));
3031
function timer(timeout) {
3132
return new Promise(function (resolve) {
3233
setTimeout(function () {
@@ -77,14 +78,6 @@ var JsonRpcSigner = /** @class */ (function (_super) {
7778
}
7879
return _this;
7980
}
80-
/* May add back in the future; for now it is considered confusing. :)
81-
get address(): string {
82-
if (!this._address) {
83-
errors.throwError('no sync sync address available; use getAddress', errors.UNSUPPORTED_OPERATION, { operation: 'address' });
84-
}
85-
return this._address
86-
}
87-
*/
8881
JsonRpcSigner.prototype.getAddress = function () {
8982
var _this = this;
9083
if (this._address) {
@@ -106,20 +99,18 @@ var JsonRpcSigner = /** @class */ (function (_super) {
10699
};
107100
JsonRpcSigner.prototype.sendTransaction = function (transaction) {
108101
var _this = this;
109-
var tx = properties_1.shallowCopy(transaction);
110-
if (tx.from == null) {
111-
tx.from = this.getAddress().then(function (address) {
112-
if (!address) {
113-
return null;
114-
}
115-
return address.toLowerCase();
116-
});
117-
}
118-
if (transaction.gasLimit == null) {
119-
tx.gasLimit = this.provider.estimateGas(tx);
120-
}
121-
return properties_1.resolveProperties(tx).then(function (tx) {
122-
return _this.provider.send('eth_sendTransaction', [JsonRpcProvider.hexlifyTransaction(tx)]).then(function (hash) {
102+
// Once populateTransaction resolves, the from address will be populated from getAddress
103+
var from = null;
104+
var getAddress = this.getAddress().then(function (address) {
105+
if (address) {
106+
from = address.toLowerCase();
107+
}
108+
return from;
109+
});
110+
return transaction_1.populateTransaction(transaction, this.provider, getAddress).then(function (tx) {
111+
var hexTx = JsonRpcProvider.hexlifyTransaction(tx);
112+
hexTx.from = from;
113+
return _this.provider.send('eth_sendTransaction', [hexTx]).then(function (hash) {
123114
return web_1.poll(function () {
124115
return _this.provider.getTransaction(hash).then(function (tx) {
125116
if (tx === null) {
@@ -342,20 +333,18 @@ var JsonRpcProvider = /** @class */ (function (_super) {
342333
// NOTE: This allows a TransactionRequest, but all values should be resolved
343334
// before this is called
344335
JsonRpcProvider.hexlifyTransaction = function (transaction, allowExtra) {
345-
if (!allowExtra) {
346-
allowExtra = {};
347-
}
348-
for (var key in transaction) {
349-
if (!allowedTransactionKeys[key] && !allowExtra[key]) {
350-
errors.throwError('invalid key - ' + key, errors.INVALID_ARGUMENT, {
351-
argument: 'transaction',
352-
value: transaction,
353-
key: key
354-
});
336+
// Check only allowed properties are given
337+
var allowed = properties_1.shallowCopy(allowedTransactionKeys);
338+
if (allowExtra) {
339+
for (var key in allowExtra) {
340+
if (allowExtra[key]) {
341+
allowed[key] = true;
342+
}
355343
}
356344
}
345+
properties_1.checkProperties(transaction, allowed);
357346
var result = {};
358-
// Some nodes (INFURA ropsten; INFURA mainnet is fine) don't like extra zeros.
347+
// Some nodes (INFURA ropsten; INFURA mainnet is fine) don't like leading zeros.
359348
['gasLimit', 'gasPrice', 'nonce', 'value'].forEach(function (key) {
360349
if (transaction[key] == null) {
361350
return;

0 commit comments

Comments
 (0)