forked from tornado-packages/ethers.js
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bffc557be1 | ||
|
|
09208fa8fe | ||
|
|
048c571d3d | ||
|
|
24757f1064 | ||
|
|
88f2f51266 | ||
|
|
93152ef863 | ||
|
|
09b698b0a9 |
2
_version.d.ts
vendored
2
_version.d.ts
vendored
@@ -1 +1 @@
|
||||
export declare const version = "4.0.9";
|
||||
export declare const version = "4.0.12";
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.version = "4.0.9";
|
||||
exports.version = "4.0.12";
|
||||
|
||||
@@ -655,7 +655,7 @@ var ContractFactory = /** @class */ (function () {
|
||||
errors.throwError('cannot override ' + key, errors.UNSUPPORTED_OPERATION, { operation: key });
|
||||
});
|
||||
// Make sure the call matches the constructor signature
|
||||
errors.checkArgumentCount(args.length, this.interface.deployFunction.inputs.length, 'in Contract constructor');
|
||||
errors.checkArgumentCount(args.length, this.interface.deployFunction.inputs.length, ' in Contract constructor');
|
||||
// Set the data to the bytecode + the encoded constructor arguments
|
||||
tx.data = this.interface.deployFunction.encode(this.bytecode, args);
|
||||
return tx;
|
||||
|
||||
119
dist/ethers.js
vendored
119
dist/ethers.js
vendored
@@ -1,7 +1,7 @@
|
||||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ethers = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.version = "4.0.9";
|
||||
exports.version = "4.0.12";
|
||||
|
||||
},{}],2:[function(require,module,exports){
|
||||
"use strict";
|
||||
@@ -703,7 +703,7 @@ var ContractFactory = /** @class */ (function () {
|
||||
errors.throwError('cannot override ' + key, errors.UNSUPPORTED_OPERATION, { operation: key });
|
||||
});
|
||||
// Make sure the call matches the constructor signature
|
||||
errors.checkArgumentCount(args.length, this.interface.deployFunction.inputs.length, 'in Contract constructor');
|
||||
errors.checkArgumentCount(args.length, this.interface.deployFunction.inputs.length, ' in Contract constructor');
|
||||
// Set the data to the bytecode + the encoded constructor arguments
|
||||
tx.data = this.interface.deployFunction.encode(this.bytecode, args);
|
||||
return tx;
|
||||
@@ -861,6 +861,17 @@ function setCensorship(censorship, permanent) {
|
||||
_permanentCensorErrors = !!permanent;
|
||||
}
|
||||
exports.setCensorship = setCensorship;
|
||||
function checkNormalize() {
|
||||
try {
|
||||
if (String.fromCharCode(0xe9).normalize('NFD') !== String.fromCharCode(0x65, 0x0301)) {
|
||||
throw new Error('broken');
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
throwError('platform missing String.prototype.normalize', exports.UNSUPPORTED_OPERATION, { operation: 'String.prototype.normalize' });
|
||||
}
|
||||
}
|
||||
exports.checkNormalize = checkNormalize;
|
||||
|
||||
},{"./_version":1}],6:[function(require,module,exports){
|
||||
'use strict';
|
||||
@@ -10265,11 +10276,7 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
// Events being listened to
|
||||
_this._events = [];
|
||||
_this._pollingInterval = 4000;
|
||||
// We use this to track recent emitted events; for example, if we emit a "block" of 100
|
||||
// and we get a `getBlock(100)` request which would result in null, we should retry
|
||||
// until we get a response. This provides devs with a consistent view. Similarly for
|
||||
// transaction hashes.
|
||||
_this._emitted = { block: _this._lastBlockNumber };
|
||||
_this._emitted = { block: -2 };
|
||||
_this._fastQueryDate = 0;
|
||||
return _this;
|
||||
}
|
||||
@@ -10281,28 +10288,40 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
if (blockNumber === _this._lastBlockNumber) {
|
||||
return;
|
||||
}
|
||||
if (_this._lastBlockNumber === -2) {
|
||||
_this._lastBlockNumber = blockNumber - 1;
|
||||
// First polling cycle, trigger a "block" events
|
||||
if (_this._emitted.block === -2) {
|
||||
_this._emitted.block = blockNumber - 1;
|
||||
}
|
||||
var _loop_1 = function (i) {
|
||||
if (_this._emitted.block < i) {
|
||||
_this._emitted.block = i;
|
||||
// Notify all listener for each block that has passed
|
||||
for (var i = _this._emitted.block + 1; i <= blockNumber; i++) {
|
||||
_this.emit('block', i);
|
||||
}
|
||||
// The emitted block was updated, check for obsolete events
|
||||
if (_this._emitted.block !== blockNumber) {
|
||||
_this._emitted.block = blockNumber;
|
||||
Object.keys(_this._emitted).forEach(function (key) {
|
||||
// The block event does not expire
|
||||
if (key === 'block') {
|
||||
return;
|
||||
}
|
||||
// The block we were at when we emitted this event
|
||||
var eventBlockNumber = _this._emitted[key];
|
||||
// We cannot garbage collect pending transactions or blocks here
|
||||
// They should be garbage collected by the Provider when setting
|
||||
// "pending" events
|
||||
if (eventBlockNumber === 'pending') {
|
||||
return;
|
||||
}
|
||||
// Evict any transaction hashes or block hashes over 12 blocks
|
||||
// old, since they should not return null anyways
|
||||
Object.keys(_this._emitted).forEach(function (key) {
|
||||
if (key === 'block') {
|
||||
return;
|
||||
}
|
||||
if (_this._emitted[key] > i + 12) {
|
||||
delete _this._emitted[key];
|
||||
}
|
||||
});
|
||||
}
|
||||
_this.emit('block', i);
|
||||
};
|
||||
// Notify all listener for each block that has passed
|
||||
for (var i = _this._lastBlockNumber + 1; i <= blockNumber; i++) {
|
||||
_loop_1(i);
|
||||
if (blockNumber - eventBlockNumber > 12) {
|
||||
delete _this._emitted[key];
|
||||
}
|
||||
});
|
||||
}
|
||||
// First polling cycle
|
||||
if (_this._lastBlockNumber === -2) {
|
||||
_this._lastBlockNumber = blockNumber - 1;
|
||||
}
|
||||
// Sweep balances and remove addresses we no longer have events for
|
||||
var newBalances = {};
|
||||
@@ -10328,12 +10347,12 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
newBalances[address_2] = _this._balances[address_2];
|
||||
}
|
||||
_this.getBalance(address_2, 'latest').then(function (balance) {
|
||||
var lastBalance = this._balances[address_2];
|
||||
var lastBalance = _this._balances[address_2];
|
||||
if (lastBalance && balance.eq(lastBalance)) {
|
||||
return;
|
||||
}
|
||||
this._balances[address_2] = balance;
|
||||
this.emit(address_2, balance);
|
||||
_this._balances[address_2] = balance;
|
||||
_this.emit(address_2, balance);
|
||||
return null;
|
||||
}).catch(function (error) { _this.emit('error', error); });
|
||||
break;
|
||||
@@ -10371,8 +10390,10 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
this.doPoll();
|
||||
};
|
||||
BaseProvider.prototype.resetEventsBlock = function (blockNumber) {
|
||||
this._lastBlockNumber = blockNumber;
|
||||
this._doPoll();
|
||||
this._lastBlockNumber = blockNumber - 1;
|
||||
if (this.polling) {
|
||||
this._doPoll();
|
||||
}
|
||||
};
|
||||
Object.defineProperty(BaseProvider.prototype, "network", {
|
||||
get: function () {
|
||||
@@ -10386,10 +10407,7 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
};
|
||||
Object.defineProperty(BaseProvider.prototype, "blockNumber", {
|
||||
get: function () {
|
||||
if (this._lastBlockNumber < 0) {
|
||||
return null;
|
||||
}
|
||||
return this._lastBlockNumber;
|
||||
return this._fastBlockNumber;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
@@ -10463,11 +10481,14 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
// this will be used once we move to the WebSocket or other alternatives to polling
|
||||
BaseProvider.prototype.waitForTransaction = function (transactionHash, confirmations) {
|
||||
var _this = this;
|
||||
if (!confirmations) {
|
||||
if (confirmations == null) {
|
||||
confirmations = 1;
|
||||
}
|
||||
return web_1.poll(function () {
|
||||
return _this.getTransactionReceipt(transactionHash).then(function (receipt) {
|
||||
if (confirmations === 0) {
|
||||
return receipt;
|
||||
}
|
||||
if (receipt == null || receipt.confirmations < confirmations) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -10585,10 +10606,20 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
if (hash != null && tx.hash !== hash) {
|
||||
errors.throwError('Transaction hash mismatch from Provider.sendTransaction.', errors.UNKNOWN_ERROR, { expectedHash: tx.hash, returnedHash: hash });
|
||||
}
|
||||
this._emitted['t:' + tx.hash] = 'pending';
|
||||
// @TODO: (confirmations? number, timeout? number)
|
||||
result.wait = function (confirmations) {
|
||||
// We know this transaction *must* exist (whether it gets mined is
|
||||
// another story), so setting an emitted value forces us to
|
||||
// wait even if the node returns null for the receipt
|
||||
if (confirmations !== 0) {
|
||||
_this._emitted['t:' + tx.hash] = 'pending';
|
||||
}
|
||||
return _this.waitForTransaction(tx.hash, confirmations).then(function (receipt) {
|
||||
if (receipt == null && confirmations === 0) {
|
||||
return null;
|
||||
}
|
||||
// No longer pending, allow the polling loop to garbage collect this
|
||||
_this._emitted['t:' + tx.hash] = receipt.blockNumber;
|
||||
if (receipt.status === 0) {
|
||||
errors.throwError('transaction failed', errors.CALL_EXCEPTION, {
|
||||
transactionHash: tx.hash,
|
||||
@@ -10666,7 +10697,7 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
return web_1.poll(function () {
|
||||
return _this.perform('getBlock', { blockTag: blockTag_1, includeTransactions: !!includeTransactions }).then(function (block) {
|
||||
if (block == null) {
|
||||
if (blockNumber_1 > _this._emitted.block) {
|
||||
if (blockNumber_1 <= _this._emitted.block) {
|
||||
return undefined;
|
||||
}
|
||||
return null;
|
||||
@@ -11853,6 +11884,7 @@ var JsonRpcProvider = /** @class */ (function (_super) {
|
||||
}
|
||||
var seq = Promise.resolve();
|
||||
hashes.forEach(function (hash) {
|
||||
// @TODO: This should be garbage collected at some point... How? When?
|
||||
self._emitted['t:' + hash.toLowerCase()] = 'pending';
|
||||
seq = seq.then(function () {
|
||||
return self.getTransaction(hash).then(function (tx) {
|
||||
@@ -12744,7 +12776,7 @@ var CoderArray = /** @class */ (function (_super) {
|
||||
count = value.length;
|
||||
result = uint256Coder.encode(count);
|
||||
}
|
||||
errors.checkArgumentCount(count, value.length, 'in coder array' + (this.localName ? (" " + this.localName) : ""));
|
||||
errors.checkArgumentCount(count, value.length, ' in coder array' + (this.localName ? (" " + this.localName) : ""));
|
||||
var coders = [];
|
||||
for (var i = 0; i < value.length; i++) {
|
||||
coders.push(this.coder);
|
||||
@@ -13779,6 +13811,7 @@ function mnemonicToEntropy(mnemonic, wordlist) {
|
||||
if (!wordlist) {
|
||||
wordlist = lang_en_1.langEn;
|
||||
}
|
||||
errors.checkNormalize();
|
||||
var words = wordlist.split(mnemonic);
|
||||
if ((words.length % 3) !== 0) {
|
||||
throw new Error('invalid mnemonic');
|
||||
@@ -14044,7 +14077,7 @@ var _DeployDescription = /** @class */ (function (_super) {
|
||||
value: bytecode
|
||||
});
|
||||
}
|
||||
errors.checkArgumentCount(params.length, this.inputs.length, 'in Interface constructor');
|
||||
errors.checkArgumentCount(params.length, this.inputs.length, ' in Interface constructor');
|
||||
try {
|
||||
return (bytecode + abi_coder_1.defaultAbiCoder.encode(this.inputs, params).substring(2));
|
||||
}
|
||||
@@ -14065,7 +14098,7 @@ var _FunctionDescription = /** @class */ (function (_super) {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
_FunctionDescription.prototype.encode = function (params) {
|
||||
errors.checkArgumentCount(params.length, this.inputs.length, 'in interface function ' + this.name);
|
||||
errors.checkArgumentCount(params.length, this.inputs.length, ' in interface function ' + this.name);
|
||||
try {
|
||||
return this.sighash + abi_coder_1.defaultAbiCoder.encode(this.inputs, params).substring(2);
|
||||
}
|
||||
@@ -15926,6 +15959,7 @@ exports.parseEther = parseEther;
|
||||
'use strict';
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var constants_1 = require("../constants");
|
||||
var errors_1 = require("../errors");
|
||||
var bytes_1 = require("./bytes");
|
||||
///////////////////////////////
|
||||
var UnicodeNormalizationForm;
|
||||
@@ -15941,6 +15975,7 @@ var UnicodeNormalizationForm;
|
||||
function toUtf8Bytes(str, form) {
|
||||
if (form === void 0) { form = UnicodeNormalizationForm.current; }
|
||||
if (form != UnicodeNormalizationForm.current) {
|
||||
errors_1.checkNormalize();
|
||||
str = str.normalize(form);
|
||||
}
|
||||
var result = [];
|
||||
@@ -16109,7 +16144,7 @@ function parseBytes32String(bytes) {
|
||||
}
|
||||
exports.parseBytes32String = parseBytes32String;
|
||||
|
||||
},{"../constants":3,"./bytes":62}],84:[function(require,module,exports){
|
||||
},{"../constants":3,"../errors":5,"./bytes":62}],84:[function(require,module,exports){
|
||||
'use strict';
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
|
||||
2
dist/ethers.min.js
vendored
2
dist/ethers.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/ethers.min.js.map
vendored
2
dist/ethers.min.js.map
vendored
File diff suppressed because one or more lines are too long
7
dist/ethers.types.txt
vendored
7
dist/ethers.types.txt
vendored
@@ -188,6 +188,7 @@ declare module 'ethers/errors' {
|
||||
export function checkNew(self: any, kind: any): void;
|
||||
export function checkArgumentCount(count: number, expectedCount: number, suffix?: string): void;
|
||||
export function setCensorship(censorship: boolean, permanent?: boolean): void;
|
||||
export function checkNormalize(): void;
|
||||
}
|
||||
|
||||
declare module 'ethers/providers' {
|
||||
@@ -261,7 +262,7 @@ declare module 'ethers/utils/shims' {
|
||||
}
|
||||
|
||||
declare module 'ethers/_version' {
|
||||
export const version = "4.0.9";
|
||||
export const version = "4.0.12";
|
||||
}
|
||||
|
||||
declare module 'ethers/utils/bignumber' {
|
||||
@@ -715,7 +716,9 @@ declare module 'ethers/providers/base-provider' {
|
||||
import { Transaction } from 'ethers/utils/transaction';
|
||||
import { Network, Networkish } from 'ethers/utils/networks';
|
||||
export class BaseProvider extends Provider {
|
||||
protected _emitted: any;
|
||||
protected _emitted: {
|
||||
[eventName: string]: number | 'pending';
|
||||
};
|
||||
/**
|
||||
* ready
|
||||
*
|
||||
|
||||
1
errors.d.ts
vendored
1
errors.d.ts
vendored
@@ -14,3 +14,4 @@ export declare function throwError(message: string, code: string, params: any):
|
||||
export declare function checkNew(self: any, kind: any): void;
|
||||
export declare function checkArgumentCount(count: number, expectedCount: number, suffix?: string): void;
|
||||
export declare function setCensorship(censorship: boolean, permanent?: boolean): void;
|
||||
export declare function checkNormalize(): void;
|
||||
|
||||
11
errors.js
11
errors.js
@@ -108,3 +108,14 @@ function setCensorship(censorship, permanent) {
|
||||
_permanentCensorErrors = !!permanent;
|
||||
}
|
||||
exports.setCensorship = setCensorship;
|
||||
function checkNormalize() {
|
||||
try {
|
||||
if (String.fromCharCode(0xe9).normalize('NFD') !== String.fromCharCode(0x65, 0x0301)) {
|
||||
throw new Error('broken');
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
throwError('platform missing String.prototype.normalize', exports.UNSUPPORTED_OPERATION, { operation: 'String.prototype.normalize' });
|
||||
}
|
||||
}
|
||||
exports.checkNormalize = checkNormalize;
|
||||
|
||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ethers",
|
||||
"version": "4.0.9",
|
||||
"version": "4.0.12",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ethers",
|
||||
"version": "4.0.9",
|
||||
"version": "4.0.12",
|
||||
"description": "Ethereum wallet library.",
|
||||
"main": "./index.js",
|
||||
"types": "./index.d.ts",
|
||||
|
||||
4
providers/base-provider.d.ts
vendored
4
providers/base-provider.d.ts
vendored
@@ -7,7 +7,9 @@ import { Network, Networkish } from '../utils/networks';
|
||||
export declare class BaseProvider extends Provider {
|
||||
private _network;
|
||||
private _events;
|
||||
protected _emitted: any;
|
||||
protected _emitted: {
|
||||
[eventName: string]: number | 'pending';
|
||||
};
|
||||
private _pollingInterval;
|
||||
private _poller;
|
||||
private _lastBlockNumber;
|
||||
|
||||
@@ -422,11 +422,7 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
// Events being listened to
|
||||
_this._events = [];
|
||||
_this._pollingInterval = 4000;
|
||||
// We use this to track recent emitted events; for example, if we emit a "block" of 100
|
||||
// and we get a `getBlock(100)` request which would result in null, we should retry
|
||||
// until we get a response. This provides devs with a consistent view. Similarly for
|
||||
// transaction hashes.
|
||||
_this._emitted = { block: _this._lastBlockNumber };
|
||||
_this._emitted = { block: -2 };
|
||||
_this._fastQueryDate = 0;
|
||||
return _this;
|
||||
}
|
||||
@@ -438,28 +434,40 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
if (blockNumber === _this._lastBlockNumber) {
|
||||
return;
|
||||
}
|
||||
if (_this._lastBlockNumber === -2) {
|
||||
_this._lastBlockNumber = blockNumber - 1;
|
||||
// First polling cycle, trigger a "block" events
|
||||
if (_this._emitted.block === -2) {
|
||||
_this._emitted.block = blockNumber - 1;
|
||||
}
|
||||
var _loop_1 = function (i) {
|
||||
if (_this._emitted.block < i) {
|
||||
_this._emitted.block = i;
|
||||
// Notify all listener for each block that has passed
|
||||
for (var i = _this._emitted.block + 1; i <= blockNumber; i++) {
|
||||
_this.emit('block', i);
|
||||
}
|
||||
// The emitted block was updated, check for obsolete events
|
||||
if (_this._emitted.block !== blockNumber) {
|
||||
_this._emitted.block = blockNumber;
|
||||
Object.keys(_this._emitted).forEach(function (key) {
|
||||
// The block event does not expire
|
||||
if (key === 'block') {
|
||||
return;
|
||||
}
|
||||
// The block we were at when we emitted this event
|
||||
var eventBlockNumber = _this._emitted[key];
|
||||
// We cannot garbage collect pending transactions or blocks here
|
||||
// They should be garbage collected by the Provider when setting
|
||||
// "pending" events
|
||||
if (eventBlockNumber === 'pending') {
|
||||
return;
|
||||
}
|
||||
// Evict any transaction hashes or block hashes over 12 blocks
|
||||
// old, since they should not return null anyways
|
||||
Object.keys(_this._emitted).forEach(function (key) {
|
||||
if (key === 'block') {
|
||||
return;
|
||||
}
|
||||
if (_this._emitted[key] > i + 12) {
|
||||
delete _this._emitted[key];
|
||||
}
|
||||
});
|
||||
}
|
||||
_this.emit('block', i);
|
||||
};
|
||||
// Notify all listener for each block that has passed
|
||||
for (var i = _this._lastBlockNumber + 1; i <= blockNumber; i++) {
|
||||
_loop_1(i);
|
||||
if (blockNumber - eventBlockNumber > 12) {
|
||||
delete _this._emitted[key];
|
||||
}
|
||||
});
|
||||
}
|
||||
// First polling cycle
|
||||
if (_this._lastBlockNumber === -2) {
|
||||
_this._lastBlockNumber = blockNumber - 1;
|
||||
}
|
||||
// Sweep balances and remove addresses we no longer have events for
|
||||
var newBalances = {};
|
||||
@@ -485,12 +493,12 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
newBalances[address_2] = _this._balances[address_2];
|
||||
}
|
||||
_this.getBalance(address_2, 'latest').then(function (balance) {
|
||||
var lastBalance = this._balances[address_2];
|
||||
var lastBalance = _this._balances[address_2];
|
||||
if (lastBalance && balance.eq(lastBalance)) {
|
||||
return;
|
||||
}
|
||||
this._balances[address_2] = balance;
|
||||
this.emit(address_2, balance);
|
||||
_this._balances[address_2] = balance;
|
||||
_this.emit(address_2, balance);
|
||||
return null;
|
||||
}).catch(function (error) { _this.emit('error', error); });
|
||||
break;
|
||||
@@ -528,8 +536,10 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
this.doPoll();
|
||||
};
|
||||
BaseProvider.prototype.resetEventsBlock = function (blockNumber) {
|
||||
this._lastBlockNumber = blockNumber;
|
||||
this._doPoll();
|
||||
this._lastBlockNumber = blockNumber - 1;
|
||||
if (this.polling) {
|
||||
this._doPoll();
|
||||
}
|
||||
};
|
||||
Object.defineProperty(BaseProvider.prototype, "network", {
|
||||
get: function () {
|
||||
@@ -543,10 +553,7 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
};
|
||||
Object.defineProperty(BaseProvider.prototype, "blockNumber", {
|
||||
get: function () {
|
||||
if (this._lastBlockNumber < 0) {
|
||||
return null;
|
||||
}
|
||||
return this._lastBlockNumber;
|
||||
return this._fastBlockNumber;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
@@ -620,11 +627,14 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
// this will be used once we move to the WebSocket or other alternatives to polling
|
||||
BaseProvider.prototype.waitForTransaction = function (transactionHash, confirmations) {
|
||||
var _this = this;
|
||||
if (!confirmations) {
|
||||
if (confirmations == null) {
|
||||
confirmations = 1;
|
||||
}
|
||||
return web_1.poll(function () {
|
||||
return _this.getTransactionReceipt(transactionHash).then(function (receipt) {
|
||||
if (confirmations === 0) {
|
||||
return receipt;
|
||||
}
|
||||
if (receipt == null || receipt.confirmations < confirmations) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -742,10 +752,20 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
if (hash != null && tx.hash !== hash) {
|
||||
errors.throwError('Transaction hash mismatch from Provider.sendTransaction.', errors.UNKNOWN_ERROR, { expectedHash: tx.hash, returnedHash: hash });
|
||||
}
|
||||
this._emitted['t:' + tx.hash] = 'pending';
|
||||
// @TODO: (confirmations? number, timeout? number)
|
||||
result.wait = function (confirmations) {
|
||||
// We know this transaction *must* exist (whether it gets mined is
|
||||
// another story), so setting an emitted value forces us to
|
||||
// wait even if the node returns null for the receipt
|
||||
if (confirmations !== 0) {
|
||||
_this._emitted['t:' + tx.hash] = 'pending';
|
||||
}
|
||||
return _this.waitForTransaction(tx.hash, confirmations).then(function (receipt) {
|
||||
if (receipt == null && confirmations === 0) {
|
||||
return null;
|
||||
}
|
||||
// No longer pending, allow the polling loop to garbage collect this
|
||||
_this._emitted['t:' + tx.hash] = receipt.blockNumber;
|
||||
if (receipt.status === 0) {
|
||||
errors.throwError('transaction failed', errors.CALL_EXCEPTION, {
|
||||
transactionHash: tx.hash,
|
||||
@@ -823,7 +843,7 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
return web_1.poll(function () {
|
||||
return _this.perform('getBlock', { blockTag: blockTag_1, includeTransactions: !!includeTransactions }).then(function (block) {
|
||||
if (block == null) {
|
||||
if (blockNumber_1 > _this._emitted.block) {
|
||||
if (blockNumber_1 <= _this._emitted.block) {
|
||||
return undefined;
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -308,6 +308,7 @@ var JsonRpcProvider = /** @class */ (function (_super) {
|
||||
}
|
||||
var seq = Promise.resolve();
|
||||
hashes.forEach(function (hash) {
|
||||
// @TODO: This should be garbage collected at some point... How? When?
|
||||
self._emitted['t:' + hash.toLowerCase()] = 'pending';
|
||||
seq = seq.then(function () {
|
||||
return self.getTransaction(hash).then(function (tx) {
|
||||
|
||||
@@ -1 +1 @@
|
||||
export const version = "4.0.9";
|
||||
export const version = "4.0.12";
|
||||
|
||||
@@ -799,7 +799,7 @@ export class ContractFactory {
|
||||
});
|
||||
|
||||
// Make sure the call matches the constructor signature
|
||||
errors.checkArgumentCount(args.length, this.interface.deployFunction.inputs.length, 'in Contract constructor');
|
||||
errors.checkArgumentCount(args.length, this.interface.deployFunction.inputs.length, ' in Contract constructor');
|
||||
|
||||
// Set the data to the bytecode + the encoded constructor arguments
|
||||
tx.data = this.interface.deployFunction.encode(this.bytecode, args);
|
||||
|
||||
@@ -33,10 +33,9 @@ import { ContractFunction, ContractTransaction, Event, EventFilter } from './con
|
||||
// Helper Functions
|
||||
|
||||
function getDefaultProvider(network?: utils.Network | string): providers.BaseProvider {
|
||||
return new providers.FallbackProvider([
|
||||
new providers.InfuraProvider(network),
|
||||
new providers.EtherscanProvider(network),
|
||||
]);
|
||||
let n = utils.getNetwork(network || 'homestead');
|
||||
if (!n || !n._defaultProvider) { return null; }
|
||||
return n._defaultProvider(providers);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -82,9 +82,13 @@ function arrayOf(check: CheckFunc): CheckFunc {
|
||||
});
|
||||
}
|
||||
|
||||
function checkHash(hash: any): string {
|
||||
if (typeof(hash) === 'string' && hexDataLength(hash) === 32) {
|
||||
return hash.toLowerCase();
|
||||
function checkHash(hash: any, requirePrefix?: boolean): string {
|
||||
if (typeof(hash) === 'string') {
|
||||
// geth-etc does add a "0x" prefix on receipt.root
|
||||
if (!requirePrefix && hash.substring(0, 2) !== '0x') { hash = '0x' + hash; }
|
||||
if (hexDataLength(hash) === 32) {
|
||||
return hash.toLowerCase();
|
||||
}
|
||||
}
|
||||
errors.throwError('invalid hash', errors.INVALID_ARGUMENT, { arg: 'hash', value: hash });
|
||||
return null;
|
||||
@@ -220,11 +224,15 @@ function checkTransactionResponse(transaction: any): TransactionResponse {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let result = check(formatTransaction, transaction);
|
||||
|
||||
let networkId = transaction.networkId;
|
||||
|
||||
// geth-etc returns chainId
|
||||
if (transaction.chainId != null && networkId == null && result.v == null) {
|
||||
networkId = transaction.chainId;
|
||||
}
|
||||
|
||||
if (isHexString(networkId)) {
|
||||
networkId = bigNumberify(networkId).toNumber();
|
||||
}
|
||||
@@ -475,10 +483,21 @@ export class BaseProvider extends Provider {
|
||||
private _network: Network;
|
||||
|
||||
private _events: Array<_Event>;
|
||||
protected _emitted: any;
|
||||
|
||||
// To help mitigate the eventually conssitent nature of the blockchain
|
||||
// we keep a mapping of events we emit. If we emit an event X, we expect
|
||||
// that a user should be able to query for that event in the callback,
|
||||
// if the node returns null, we stall the response until we get back a
|
||||
// meaningful value, since we may be hitting a re-org, or a node that
|
||||
// has not indexed the event yet.
|
||||
// Events:
|
||||
// - t:{hash} - Transaction hash
|
||||
// - b:{hash} - BlockHash
|
||||
// - block - The most recent emitted block
|
||||
protected _emitted: { [ eventName: string ]: number | 'pending' };
|
||||
|
||||
private _pollingInterval: number;
|
||||
private _poller: any; // @TODO: what does TypeScript thing setInterval returns?
|
||||
private _poller: any; // @TODO: what does TypeScript think setInterval returns?
|
||||
|
||||
private _lastBlockNumber: number;
|
||||
|
||||
@@ -532,11 +551,7 @@ export class BaseProvider extends Provider {
|
||||
|
||||
this._pollingInterval = 4000;
|
||||
|
||||
// We use this to track recent emitted events; for example, if we emit a "block" of 100
|
||||
// and we get a `getBlock(100)` request which would result in null, we should retry
|
||||
// until we get a response. This provides devs with a consistent view. Similarly for
|
||||
// transaction hashes.
|
||||
this._emitted = { block: this._lastBlockNumber };
|
||||
this._emitted = { block: -2 };
|
||||
|
||||
this._fastQueryDate = 0;
|
||||
}
|
||||
@@ -548,24 +563,43 @@ export class BaseProvider extends Provider {
|
||||
// If the block hasn't changed, meh.
|
||||
if (blockNumber === this._lastBlockNumber) { return; }
|
||||
|
||||
if (this._lastBlockNumber === -2) { this._lastBlockNumber = blockNumber - 1; }
|
||||
// First polling cycle, trigger a "block" events
|
||||
if (this._emitted.block === -2) {
|
||||
this._emitted.block = blockNumber - 1;
|
||||
}
|
||||
|
||||
// Notify all listener for each block that has passed
|
||||
for (let i = this._lastBlockNumber + 1; i <= blockNumber; i++) {
|
||||
if (this._emitted.block < i) {
|
||||
this._emitted.block = i;
|
||||
for (let i = (<number>this._emitted.block) + 1; i <= blockNumber; i++) {
|
||||
this.emit('block', i);
|
||||
}
|
||||
|
||||
// The emitted block was updated, check for obsolete events
|
||||
if ((<number>this._emitted.block) !== blockNumber) {
|
||||
this._emitted.block = blockNumber;
|
||||
|
||||
Object.keys(this._emitted).forEach((key) => {
|
||||
// The block event does not expire
|
||||
if (key === 'block') { return; }
|
||||
|
||||
// The block we were at when we emitted this event
|
||||
let eventBlockNumber = this._emitted[key];
|
||||
|
||||
// We cannot garbage collect pending transactions or blocks here
|
||||
// They should be garbage collected by the Provider when setting
|
||||
// "pending" events
|
||||
if (eventBlockNumber === 'pending') { return; }
|
||||
|
||||
// Evict any transaction hashes or block hashes over 12 blocks
|
||||
// old, since they should not return null anyways
|
||||
Object.keys(this._emitted).forEach((key) => {
|
||||
if (key === 'block') { return; }
|
||||
if (blockNumber - eventBlockNumber > 12) {
|
||||
delete this._emitted[key];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (this._emitted[key] > i + 12) {
|
||||
delete this._emitted[key];
|
||||
}
|
||||
});
|
||||
}
|
||||
this.emit('block', i);
|
||||
// First polling cycle
|
||||
if (this._lastBlockNumber === -2) {
|
||||
this._lastBlockNumber = blockNumber - 1;
|
||||
}
|
||||
|
||||
// Sweep balances and remove addresses we no longer have events for
|
||||
@@ -583,6 +617,7 @@ export class BaseProvider extends Provider {
|
||||
this.emit(hash, receipt);
|
||||
return null;
|
||||
}).catch((error: Error) => { this.emit('error', error); });
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -591,13 +626,15 @@ export class BaseProvider extends Provider {
|
||||
if (this._balances[address]) {
|
||||
newBalances[address] = this._balances[address];
|
||||
}
|
||||
this.getBalance(address, 'latest').then(function(balance) {
|
||||
|
||||
this.getBalance(address, 'latest').then((balance) => {
|
||||
let lastBalance = this._balances[address];
|
||||
if (lastBalance && balance.eq(lastBalance)) { return; }
|
||||
this._balances[address] = balance;
|
||||
this.emit(address, balance);
|
||||
return null;
|
||||
}).catch((error: Error) => { this.emit('error', error); });
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -630,12 +667,13 @@ export class BaseProvider extends Provider {
|
||||
|
||||
return null;
|
||||
}).catch((error: Error) => { });
|
||||
|
||||
this.doPoll();
|
||||
}
|
||||
|
||||
resetEventsBlock(blockNumber: number): void {
|
||||
this._lastBlockNumber = blockNumber;
|
||||
this._doPoll();
|
||||
this._lastBlockNumber = blockNumber - 1;
|
||||
if (this.polling) { this._doPoll(); }
|
||||
}
|
||||
|
||||
get network(): Network {
|
||||
@@ -647,8 +685,7 @@ export class BaseProvider extends Provider {
|
||||
}
|
||||
|
||||
get blockNumber(): number {
|
||||
if (this._lastBlockNumber < 0) { return null; }
|
||||
return this._lastBlockNumber;
|
||||
return this._fastBlockNumber;
|
||||
}
|
||||
|
||||
get polling(): boolean {
|
||||
@@ -719,10 +756,13 @@ export class BaseProvider extends Provider {
|
||||
// this will be used once we move to the WebSocket or other alternatives to polling
|
||||
|
||||
waitForTransaction(transactionHash: string, confirmations?: number): Promise<TransactionReceipt> {
|
||||
if (!confirmations) { confirmations = 1; }
|
||||
if (confirmations == null) { confirmations = 1; }
|
||||
return poll(() => {
|
||||
return this.getTransactionReceipt(transactionHash).then((receipt) => {
|
||||
if (receipt == null || receipt.confirmations < confirmations) { return undefined; }
|
||||
if (confirmations === 0) { return receipt; }
|
||||
if (receipt == null || receipt.confirmations < confirmations) {
|
||||
return undefined;
|
||||
}
|
||||
return receipt;
|
||||
});
|
||||
}, { onceBlock: this });
|
||||
@@ -832,11 +872,22 @@ export class BaseProvider extends Provider {
|
||||
errors.throwError('Transaction hash mismatch from Provider.sendTransaction.', errors.UNKNOWN_ERROR, { expectedHash: tx.hash, returnedHash: hash });
|
||||
}
|
||||
|
||||
this._emitted['t:' + tx.hash] = 'pending';
|
||||
|
||||
// @TODO: (confirmations? number, timeout? number)
|
||||
result.wait = (confirmations?: number) => {
|
||||
|
||||
// We know this transaction *must* exist (whether it gets mined is
|
||||
// another story), so setting an emitted value forces us to
|
||||
// wait even if the node returns null for the receipt
|
||||
if (confirmations !== 0) {
|
||||
this._emitted['t:' + tx.hash] = 'pending';
|
||||
}
|
||||
|
||||
return this.waitForTransaction(tx.hash, confirmations).then((receipt) => {
|
||||
if (receipt == null && confirmations === 0) { return null; }
|
||||
|
||||
// No longer pending, allow the polling loop to garbage collect this
|
||||
this._emitted['t:' + tx.hash] = receipt.blockNumber;
|
||||
|
||||
if (receipt.status === 0) {
|
||||
errors.throwError('transaction failed', errors.CALL_EXCEPTION, {
|
||||
transactionHash: tx.hash,
|
||||
@@ -918,7 +969,7 @@ export class BaseProvider extends Provider {
|
||||
return poll(() => {
|
||||
return this.perform('getBlock', { blockTag: blockTag, includeTransactions: !!includeTransactions }).then((block) => {
|
||||
if (block == null) {
|
||||
if (blockNumber > this._emitted.block) {
|
||||
if (blockNumber <= this._emitted.block) {
|
||||
return undefined;
|
||||
}
|
||||
return null;
|
||||
@@ -936,7 +987,7 @@ export class BaseProvider extends Provider {
|
||||
getTransaction(transactionHash: string): Promise<TransactionResponse> {
|
||||
return this.ready.then(() => {
|
||||
return resolveProperties({ transactionHash: transactionHash }).then(({ transactionHash }) => {
|
||||
let params = { transactionHash: checkHash(transactionHash) };
|
||||
let params = { transactionHash: checkHash(transactionHash, true) };
|
||||
return poll(() => {
|
||||
return this.perform('getTransaction', params).then((result) => {
|
||||
if (result == null) {
|
||||
@@ -973,7 +1024,7 @@ export class BaseProvider extends Provider {
|
||||
getTransactionReceipt(transactionHash: string): Promise<TransactionReceipt> {
|
||||
return this.ready.then(() => {
|
||||
return resolveProperties({ transactionHash: transactionHash }).then(({ transactionHash }) => {
|
||||
let params = { transactionHash: checkHash(transactionHash) };
|
||||
let params = { transactionHash: checkHash(transactionHash, true) };
|
||||
return poll(() => {
|
||||
return this.perform('getTransactionReceipt', params).then((result) => {
|
||||
if (result == null) {
|
||||
|
||||
@@ -32,7 +32,8 @@ function checkNetworks(networks: Array<Network>): boolean {
|
||||
// Matches!
|
||||
if (check.name === network.name &&
|
||||
check.chainId === network.chainId &&
|
||||
check.ensAddress === network.ensAddress) { return; }
|
||||
((check.ensAddress === network.ensAddress) ||
|
||||
(check.ensAddress == null && network.ensAddress == null))) { return; }
|
||||
|
||||
errors.throwError(
|
||||
'provider mismatch',
|
||||
|
||||
@@ -335,6 +335,7 @@ export class JsonRpcProvider extends BaseProvider {
|
||||
|
||||
var seq = Promise.resolve();
|
||||
hashes.forEach(function(hash) {
|
||||
// @TODO: This should be garbage collected at some point... How? When?
|
||||
self._emitted['t:' + hash.toLowerCase()] = 'pending';
|
||||
seq = seq.then(function() {
|
||||
return self.getTransaction(hash).then(function(tx) {
|
||||
|
||||
@@ -844,7 +844,7 @@ class CoderArray extends Coder {
|
||||
result = uint256Coder.encode(count);
|
||||
}
|
||||
|
||||
errors.checkArgumentCount(count, value.length, 'in coder array' + (this.localName? (" "+ this.localName): ""));
|
||||
errors.checkArgumentCount(count, value.length, ' in coder array' + (this.localName? (" "+ this.localName): ""));
|
||||
|
||||
var coders = [];
|
||||
for (var i = 0; i < value.length; i++) { coders.push(this.coder); }
|
||||
|
||||
@@ -103,7 +103,7 @@ class _DeployDescription extends Description implements DeployDescription {
|
||||
});
|
||||
}
|
||||
|
||||
errors.checkArgumentCount(params.length, this.inputs.length, 'in Interface constructor');
|
||||
errors.checkArgumentCount(params.length, this.inputs.length, ' in Interface constructor');
|
||||
|
||||
try {
|
||||
return (bytecode + defaultAbiCoder.encode(this.inputs, params).substring(2));
|
||||
@@ -132,7 +132,7 @@ class _FunctionDescription extends Description implements FunctionDescription {
|
||||
readonly gas: BigNumber;
|
||||
|
||||
encode(params: Array<any>): string {
|
||||
errors.checkArgumentCount(params.length, this.inputs.length, 'in interface function ' + this.name);
|
||||
errors.checkArgumentCount(params.length, this.inputs.length, ' in interface function ' + this.name);
|
||||
|
||||
try {
|
||||
return this.sighash + defaultAbiCoder.encode(this.inputs, params).substring(2);
|
||||
|
||||
@@ -7,33 +7,69 @@ export type Network = {
|
||||
name: string,
|
||||
chainId: number,
|
||||
ensAddress?: string,
|
||||
_defaultProvider?: (providers: any) => any
|
||||
}
|
||||
|
||||
export type Networkish = Network | string | number;
|
||||
|
||||
function ethDefaultProvider(network: string): (providers: any) => any {
|
||||
return function(providers: any): any {
|
||||
let providerList: Array<any> = [];
|
||||
|
||||
if (providers.InfuraProvider) {
|
||||
providerList.push(new providers.InfuraProvider(network));
|
||||
}
|
||||
|
||||
if (providers.EtherscanProvider) {
|
||||
providerList.push(new providers.EtherscanProvider(network));
|
||||
}
|
||||
|
||||
if (providerList.length === 0) { return null; }
|
||||
|
||||
if (providers.FallbackProvider) {
|
||||
return new providers.FallbackProvider(providerList);;
|
||||
}
|
||||
|
||||
return providerList[0];
|
||||
}
|
||||
}
|
||||
|
||||
function etcDefaultProvider(url: string, network: string): (providers: any) => any {
|
||||
return function(providers: any): any {
|
||||
if (providers.JsonRpcProvider) {
|
||||
return new providers.JsonRpcProvider(url, network);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
const homestead: Network = {
|
||||
chainId: 1,
|
||||
ensAddress: "0x314159265dd8dbb310642f98f50c066173c1259b",
|
||||
name: "homestead"
|
||||
name: "homestead",
|
||||
_defaultProvider: ethDefaultProvider('homestead')
|
||||
};
|
||||
|
||||
const ropsten: Network = {
|
||||
chainId: 3,
|
||||
ensAddress: "0x112234455c3a32fd11230c42e7bccd4a84e02010",
|
||||
name: "ropsten"
|
||||
name: "ropsten",
|
||||
_defaultProvider: ethDefaultProvider('ropsten')
|
||||
};
|
||||
|
||||
const networks: { [name: string]: { chainId: number, ensAddress?: string } } = {
|
||||
const networks: { [name: string]: Network } = {
|
||||
unspecified: {
|
||||
chainId: 0
|
||||
chainId: 0,
|
||||
name: 'unspecified'
|
||||
},
|
||||
|
||||
homestead: homestead,
|
||||
mainnet: homestead,
|
||||
|
||||
morden: {
|
||||
chainId: 2
|
||||
chainId: 2,
|
||||
name: 'morden'
|
||||
},
|
||||
|
||||
ropsten: ropsten,
|
||||
@@ -41,19 +77,27 @@ const networks: { [name: string]: { chainId: number, ensAddress?: string } } = {
|
||||
|
||||
rinkeby: {
|
||||
chainId: 4,
|
||||
ensAddress: "0xe7410170f87102DF0055eB195163A03B7F2Bff4A"
|
||||
ensAddress: "0xe7410170f87102DF0055eB195163A03B7F2Bff4A",
|
||||
name: 'rinkeby',
|
||||
_defaultProvider: ethDefaultProvider('rinkeby')
|
||||
},
|
||||
|
||||
kovan: {
|
||||
chainId: 42
|
||||
chainId: 42,
|
||||
name: 'kovan',
|
||||
_defaultProvider: ethDefaultProvider('kovan')
|
||||
},
|
||||
|
||||
classic: {
|
||||
chainId: 61
|
||||
chainId: 61,
|
||||
name: 'classic',
|
||||
_defaultProvider: etcDefaultProvider('https://web3.gastracker.io', 'classic')
|
||||
},
|
||||
|
||||
classicTestnet: {
|
||||
chainId: 62
|
||||
chainId: 62,
|
||||
name: 'classicTestnet',
|
||||
_defaultProvider: etcDefaultProvider('https://web3.gastracker.io/morden', 'classicTestnet')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,17 +108,18 @@ const networks: { [name: string]: { chainId: number, ensAddress?: string } } = {
|
||||
* and verifies a network is a valid Network..
|
||||
*/
|
||||
export function getNetwork(network: Networkish): Network {
|
||||
// No network (null) or unspecified (chainId = 0)
|
||||
if (!network) { return null; }
|
||||
// No network (null)
|
||||
if (network == null) { return null; }
|
||||
|
||||
if (typeof(network) === 'number') {
|
||||
for (var name in networks) {
|
||||
for (let name in networks) {
|
||||
let n = networks[name];
|
||||
if (n.chainId === network) {
|
||||
return {
|
||||
name: name,
|
||||
name: n.name,
|
||||
chainId: n.chainId,
|
||||
ensAddress: n.ensAddress
|
||||
ensAddress: (n.ensAddress || null),
|
||||
_defaultProvider: (n._defaultProvider || null)
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -89,9 +134,10 @@ export function getNetwork(network: Networkish): Network {
|
||||
let n = networks[network];
|
||||
if (n == null) { return null; }
|
||||
return {
|
||||
name: network,
|
||||
name: n.name,
|
||||
chainId: n.chainId,
|
||||
ensAddress: n.ensAddress
|
||||
ensAddress: n.ensAddress,
|
||||
_defaultProvider: (n._defaultProvider || null)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -110,10 +156,11 @@ export function getNetwork(network: Networkish): Network {
|
||||
errors.throwError('network chainId mismatch', errors.INVALID_ARGUMENT, { arg: 'network', value: network });
|
||||
}
|
||||
|
||||
// Standard Network
|
||||
// Standard Network (allow overriding the ENS address)
|
||||
return {
|
||||
name: network.name,
|
||||
chainId: n.chainId,
|
||||
ensAddress: n.ensAddress
|
||||
ensAddress: (network.ensAddress || n.ensAddress || null),
|
||||
_defaultProvider: (network._defaultProvider || n._defaultProvider || null)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -733,7 +733,7 @@ var CoderArray = /** @class */ (function (_super) {
|
||||
count = value.length;
|
||||
result = uint256Coder.encode(count);
|
||||
}
|
||||
errors.checkArgumentCount(count, value.length, 'in coder array' + (this.localName ? (" " + this.localName) : ""));
|
||||
errors.checkArgumentCount(count, value.length, ' in coder array' + (this.localName ? (" " + this.localName) : ""));
|
||||
var coders = [];
|
||||
for (var i = 0; i < value.length; i++) {
|
||||
coders.push(this.coder);
|
||||
|
||||
@@ -166,6 +166,7 @@ function mnemonicToEntropy(mnemonic, wordlist) {
|
||||
if (!wordlist) {
|
||||
wordlist = lang_en_1.langEn;
|
||||
}
|
||||
errors.checkNormalize();
|
||||
var words = wordlist.split(mnemonic);
|
||||
if ((words.length % 3) !== 0) {
|
||||
throw new Error('invalid mnemonic');
|
||||
|
||||
@@ -56,7 +56,7 @@ var _DeployDescription = /** @class */ (function (_super) {
|
||||
value: bytecode
|
||||
});
|
||||
}
|
||||
errors.checkArgumentCount(params.length, this.inputs.length, 'in Interface constructor');
|
||||
errors.checkArgumentCount(params.length, this.inputs.length, ' in Interface constructor');
|
||||
try {
|
||||
return (bytecode + abi_coder_1.defaultAbiCoder.encode(this.inputs, params).substring(2));
|
||||
}
|
||||
@@ -77,7 +77,7 @@ var _FunctionDescription = /** @class */ (function (_super) {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
_FunctionDescription.prototype.encode = function (params) {
|
||||
errors.checkArgumentCount(params.length, this.inputs.length, 'in interface function ' + this.name);
|
||||
errors.checkArgumentCount(params.length, this.inputs.length, ' in interface function ' + this.name);
|
||||
try {
|
||||
return this.sighash + abi_coder_1.defaultAbiCoder.encode(this.inputs, params).substring(2);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var constants_1 = require("../constants");
|
||||
var errors_1 = require("../errors");
|
||||
var bytes_1 = require("./bytes");
|
||||
///////////////////////////////
|
||||
var UnicodeNormalizationForm;
|
||||
@@ -16,6 +17,7 @@ var UnicodeNormalizationForm;
|
||||
function toUtf8Bytes(str, form) {
|
||||
if (form === void 0) { form = UnicodeNormalizationForm.current; }
|
||||
if (form != UnicodeNormalizationForm.current) {
|
||||
errors_1.checkNormalize();
|
||||
str = str.normalize(form);
|
||||
}
|
||||
var result = [];
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -131,9 +131,7 @@ var LangJa = /** @class */ (function (_super) {
|
||||
return wordlist.indexOf(word);
|
||||
};
|
||||
LangJa.prototype.split = function (mnemonic) {
|
||||
if (!mnemonic.normalize) {
|
||||
errors.throwError('Japanese is unsupported on this platform; missing String.prototype.normalize', errors.UNSUPPORTED_OPERATION, { operation: 'String.prototype.normalize' });
|
||||
}
|
||||
errors.checkNormalize();
|
||||
return mnemonic.split(/(?:\u3000| )+/g);
|
||||
};
|
||||
LangJa.prototype.join = function (words) {
|
||||
|
||||
Reference in New Issue
Block a user