@toruslabs/ethereum-controllers 5.8.1 → 5.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1067,16 +1067,15 @@ const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
|
1067
1067
|
* Network state changes also retrigger accounts update.
|
|
1068
1068
|
*/
|
|
1069
1069
|
class AccountTrackerController extends base_controllers_namespaceObject.BaseController {
|
|
1070
|
-
constructor(
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
} = _ref;
|
|
1070
|
+
constructor({
|
|
1071
|
+
config,
|
|
1072
|
+
state,
|
|
1073
|
+
provider,
|
|
1074
|
+
blockTracker,
|
|
1075
|
+
getIdentities,
|
|
1076
|
+
onPreferencesStateChange,
|
|
1077
|
+
getCurrentChainId
|
|
1078
|
+
}) {
|
|
1080
1079
|
super({
|
|
1081
1080
|
config,
|
|
1082
1081
|
state
|
|
@@ -1229,14 +1228,8 @@ const erc1155Interface = new external_ethers_namespaceObject.Interface(erc1155Ab
|
|
|
1229
1228
|
// functions that handle normalizing of that key in txParams
|
|
1230
1229
|
|
|
1231
1230
|
const normalizers = {
|
|
1232
|
-
from:
|
|
1233
|
-
|
|
1234
|
-
return LowerCase ? (0,util_namespaceObject.addHexPrefix)(from).toLowerCase() : (0,util_namespaceObject.addHexPrefix)(from);
|
|
1235
|
-
},
|
|
1236
|
-
to: function (to) {
|
|
1237
|
-
let LowerCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
1238
|
-
return LowerCase ? (0,util_namespaceObject.addHexPrefix)(to).toLowerCase() : (0,util_namespaceObject.addHexPrefix)(to);
|
|
1239
|
-
},
|
|
1231
|
+
from: (from, LowerCase = true) => LowerCase ? (0,util_namespaceObject.addHexPrefix)(from).toLowerCase() : (0,util_namespaceObject.addHexPrefix)(from),
|
|
1232
|
+
to: (to, LowerCase = true) => LowerCase ? (0,util_namespaceObject.addHexPrefix)(to).toLowerCase() : (0,util_namespaceObject.addHexPrefix)(to),
|
|
1240
1233
|
nonce: nonce => (0,util_namespaceObject.addHexPrefix)(nonce),
|
|
1241
1234
|
customNonceValue: nonce => (0,util_namespaceObject.addHexPrefix)(nonce),
|
|
1242
1235
|
value: value => (0,util_namespaceObject.addHexPrefix)(value),
|
|
@@ -1251,8 +1244,7 @@ const normalizers = {
|
|
|
1251
1244
|
/**
|
|
1252
1245
|
* normalizes txParams
|
|
1253
1246
|
*/
|
|
1254
|
-
function normalizeTxParameters(txParameters) {
|
|
1255
|
-
let lowerCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
1247
|
+
function normalizeTxParameters(txParameters, lowerCase = true) {
|
|
1256
1248
|
// apply only keys in the normalizers
|
|
1257
1249
|
const normalizedTxParameters = {
|
|
1258
1250
|
id: txParameters.id || (0,base_controllers_namespaceObject.randomId)(),
|
|
@@ -1370,8 +1362,7 @@ function validateRecipient(txParameters) {
|
|
|
1370
1362
|
* Validates the given tx parameters
|
|
1371
1363
|
* @throws if the tx params contains invalid fields
|
|
1372
1364
|
*/
|
|
1373
|
-
function validateTxParameters(txParams) {
|
|
1374
|
-
let eip1559Compatibility = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
1365
|
+
function validateTxParameters(txParams, eip1559Compatibility = true) {
|
|
1375
1366
|
if (!txParams || typeof txParams !== "object" || Array.isArray(txParams)) {
|
|
1376
1367
|
throw rpc_errors_namespaceObject.rpcErrors.invalidParams("Invalid transaction params: must be an object.");
|
|
1377
1368
|
}
|
|
@@ -1383,8 +1374,7 @@ function validateTxParameters(txParams) {
|
|
|
1383
1374
|
}) && !eip1559Compatibility) {
|
|
1384
1375
|
throw rpc_errors_namespaceObject.rpcErrors.invalidParams("Invalid transaction params: params specify an EIP-1559 transaction but the current network does not support EIP-1559");
|
|
1385
1376
|
}
|
|
1386
|
-
Object.entries(txParams).forEach(
|
|
1387
|
-
let [key, value] = _ref;
|
|
1377
|
+
Object.entries(txParams).forEach(([key, value]) => {
|
|
1388
1378
|
// validate types
|
|
1389
1379
|
switch (key) {
|
|
1390
1380
|
case "from":
|
|
@@ -1428,8 +1418,7 @@ function validateTxParameters(txParams) {
|
|
|
1428
1418
|
}
|
|
1429
1419
|
});
|
|
1430
1420
|
}
|
|
1431
|
-
function normalizeAndValidateTxParams(txParams) {
|
|
1432
|
-
let lowerCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
1421
|
+
function normalizeAndValidateTxParams(txParams, lowerCase = true) {
|
|
1433
1422
|
const normalizedTxParams = normalizeTxParameters(txParams, lowerCase);
|
|
1434
1423
|
validateTxParameters(normalizedTxParams);
|
|
1435
1424
|
return normalizedTxParams;
|
|
@@ -1775,11 +1764,10 @@ const DEFAULT_POLLING_INTERVAL = 20;
|
|
|
1775
1764
|
const DEFAULT_RETRY_TIMEOUT = 2;
|
|
1776
1765
|
const SEC = 1000;
|
|
1777
1766
|
class PollingBlockTracker extends base_controllers_namespaceObject.BaseBlockTracker {
|
|
1778
|
-
constructor(
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
} = _ref;
|
|
1767
|
+
constructor({
|
|
1768
|
+
config,
|
|
1769
|
+
state = {}
|
|
1770
|
+
}) {
|
|
1783
1771
|
if (!config.provider) {
|
|
1784
1772
|
throw new Error("PollingBlockTracker - no provider specified.");
|
|
1785
1773
|
}
|
|
@@ -1860,12 +1848,11 @@ const http_helpers_namespaceObject = require("@toruslabs/http-helpers");
|
|
|
1860
1848
|
|
|
1861
1849
|
|
|
1862
1850
|
class CurrencyController extends base_controllers_namespaceObject.BaseCurrencyController {
|
|
1863
|
-
constructor(
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
} = _ref;
|
|
1851
|
+
constructor({
|
|
1852
|
+
config,
|
|
1853
|
+
state,
|
|
1854
|
+
onNetworkChanged
|
|
1855
|
+
}) {
|
|
1869
1856
|
super({
|
|
1870
1857
|
config,
|
|
1871
1858
|
state
|
|
@@ -2039,20 +2026,19 @@ const isValidBase = base => Number.isInteger(base) && base > 1;
|
|
|
2039
2026
|
/**
|
|
2040
2027
|
* Utility method to convert a value between denominations, formats and currencies.
|
|
2041
2028
|
*/
|
|
2042
|
-
const converter =
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
} = _ref;
|
|
2029
|
+
const converter = ({
|
|
2030
|
+
value,
|
|
2031
|
+
fromNumericBase,
|
|
2032
|
+
fromDenomination,
|
|
2033
|
+
fromCurrency,
|
|
2034
|
+
toNumericBase,
|
|
2035
|
+
toDenomination,
|
|
2036
|
+
toCurrency,
|
|
2037
|
+
numberOfDecimals,
|
|
2038
|
+
conversionRate,
|
|
2039
|
+
invertConversionRate,
|
|
2040
|
+
roundDown
|
|
2041
|
+
}) => {
|
|
2056
2042
|
let convertedValue = fromNumericBase ? toBigNumber[fromNumericBase](value) : value;
|
|
2057
2043
|
if (fromDenomination) {
|
|
2058
2044
|
convertedValue = toNormalizedDenomination[fromDenomination](convertedValue);
|
|
@@ -2081,18 +2067,17 @@ const converter = _ref => {
|
|
|
2081
2067
|
}
|
|
2082
2068
|
return convertedValue;
|
|
2083
2069
|
};
|
|
2084
|
-
const conversionUtil = (value,
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
} = _ref2;
|
|
2070
|
+
const conversionUtil = (value, {
|
|
2071
|
+
fromCurrency = null,
|
|
2072
|
+
toCurrency = fromCurrency,
|
|
2073
|
+
fromNumericBase,
|
|
2074
|
+
toNumericBase,
|
|
2075
|
+
fromDenomination,
|
|
2076
|
+
toDenomination,
|
|
2077
|
+
numberOfDecimals,
|
|
2078
|
+
conversionRate,
|
|
2079
|
+
invertConversionRate
|
|
2080
|
+
}) => {
|
|
2096
2081
|
if (fromCurrency !== toCurrency && !conversionRate) {
|
|
2097
2082
|
return 0;
|
|
2098
2083
|
}
|
|
@@ -2121,8 +2106,7 @@ const getBigNumber = (value, base) => {
|
|
|
2121
2106
|
}
|
|
2122
2107
|
return new (external_bignumber_js_default())(String(value), base);
|
|
2123
2108
|
};
|
|
2124
|
-
const addCurrencies =
|
|
2125
|
-
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
2109
|
+
const addCurrencies = (a, b, options = {}) => {
|
|
2126
2110
|
const {
|
|
2127
2111
|
aBase,
|
|
2128
2112
|
bBase
|
|
@@ -2136,8 +2120,7 @@ const addCurrencies = function (a, b) {
|
|
|
2136
2120
|
value
|
|
2137
2121
|
}, conversionOptions));
|
|
2138
2122
|
};
|
|
2139
|
-
const subtractCurrencies =
|
|
2140
|
-
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
2123
|
+
const subtractCurrencies = (a, b, options = {}) => {
|
|
2141
2124
|
const {
|
|
2142
2125
|
aBase,
|
|
2143
2126
|
bBase
|
|
@@ -2151,8 +2134,7 @@ const subtractCurrencies = function (a, b) {
|
|
|
2151
2134
|
value
|
|
2152
2135
|
}, conversionOptions));
|
|
2153
2136
|
};
|
|
2154
|
-
const multiplyCurrencies =
|
|
2155
|
-
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
2137
|
+
const multiplyCurrencies = (a, b, options = {}) => {
|
|
2156
2138
|
const {
|
|
2157
2139
|
multiplicandBase,
|
|
2158
2140
|
multiplierBase
|
|
@@ -2166,44 +2148,41 @@ const multiplyCurrencies = function (a, b) {
|
|
|
2166
2148
|
value
|
|
2167
2149
|
}, conversionOptions));
|
|
2168
2150
|
};
|
|
2169
|
-
const conversionGreaterThan = (
|
|
2170
|
-
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2171
|
-
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2151
|
+
const conversionGreaterThan = (_ref, _ref2) => {
|
|
2152
|
+
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref2), _ref2));
|
|
2153
|
+
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref), _ref));
|
|
2172
2154
|
const firstValue = converter(objectSpread2_default()({}, firstProps));
|
|
2173
2155
|
const secondValue = converter(objectSpread2_default()({}, secondProps));
|
|
2174
2156
|
return firstValue.gt(secondValue);
|
|
2175
2157
|
};
|
|
2176
|
-
const conversionLessThan = (
|
|
2177
|
-
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2178
|
-
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2158
|
+
const conversionLessThan = (_ref3, _ref4) => {
|
|
2159
|
+
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref4), _ref4));
|
|
2160
|
+
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref3), _ref3));
|
|
2179
2161
|
const firstValue = converter(objectSpread2_default()({}, firstProps));
|
|
2180
2162
|
const secondValue = converter(objectSpread2_default()({}, secondProps));
|
|
2181
2163
|
return firstValue.lt(secondValue);
|
|
2182
2164
|
};
|
|
2183
|
-
const conversionMax = (
|
|
2184
|
-
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2185
|
-
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2165
|
+
const conversionMax = (_ref5, _ref6) => {
|
|
2166
|
+
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref6), _ref6));
|
|
2167
|
+
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref5), _ref5));
|
|
2186
2168
|
const firstIsGreater = conversionGreaterThan(objectSpread2_default()({}, firstProps), objectSpread2_default()({}, secondProps));
|
|
2187
2169
|
return firstIsGreater ? firstProps.value : secondProps.value;
|
|
2188
2170
|
};
|
|
2189
|
-
const conversionGTE = (
|
|
2190
|
-
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2191
|
-
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2171
|
+
const conversionGTE = (_ref7, _ref8) => {
|
|
2172
|
+
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref8), _ref8));
|
|
2173
|
+
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref7), _ref7));
|
|
2192
2174
|
const firstValue = converter(objectSpread2_default()({}, firstProps));
|
|
2193
2175
|
const secondValue = converter(objectSpread2_default()({}, secondProps));
|
|
2194
2176
|
return firstValue.isGreaterThanOrEqualTo(secondValue);
|
|
2195
2177
|
};
|
|
2196
|
-
const conversionLTE = (
|
|
2197
|
-
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2198
|
-
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2178
|
+
const conversionLTE = (_ref9, _ref10) => {
|
|
2179
|
+
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref10), _ref10));
|
|
2180
|
+
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref9), _ref9));
|
|
2199
2181
|
const firstValue = converter(objectSpread2_default()({}, firstProps));
|
|
2200
2182
|
const secondValue = converter(objectSpread2_default()({}, secondProps));
|
|
2201
2183
|
return firstValue.isLessThanOrEqualTo(secondValue);
|
|
2202
2184
|
};
|
|
2203
|
-
const toNegative =
|
|
2204
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2205
|
-
return multiplyCurrencies(n, -1, options);
|
|
2206
|
-
};
|
|
2185
|
+
const toNegative = (n, options = {}) => multiplyCurrencies(n, -1, options);
|
|
2207
2186
|
const decGWEIToHexWEI = decGWEI => {
|
|
2208
2187
|
return conversionUtil(decGWEI, {
|
|
2209
2188
|
fromNumericBase: "dec",
|
|
@@ -2374,21 +2353,20 @@ const LEGACY_GAS_PRICES_API_URL = "https://api.metaswap.codefi.network/gasPrices
|
|
|
2374
2353
|
* Returns gas prices in dec gwei
|
|
2375
2354
|
*/
|
|
2376
2355
|
class GasFeeController extends base_controllers_namespaceObject.BaseController {
|
|
2377
|
-
constructor(
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
} = _ref;
|
|
2356
|
+
constructor({
|
|
2357
|
+
config,
|
|
2358
|
+
state,
|
|
2359
|
+
getNetworkIdentifier,
|
|
2360
|
+
getProvider,
|
|
2361
|
+
fetchGasEstimates = gasUtil_fetchGasEstimates,
|
|
2362
|
+
fetchEthGasPriceEstimate = gasUtil_fetchEthGasPriceEstimate,
|
|
2363
|
+
fetchLegacyGasPriceEstimates = gasUtil_fetchLegacyGasPriceEstimates,
|
|
2364
|
+
fetchGasEstimatesViaEthFeeHistory = gasUtil_fetchGasEstimatesViaEthFeeHistory,
|
|
2365
|
+
getCurrentNetworkLegacyGasAPICompatibility,
|
|
2366
|
+
getCurrentNetworkEIP1559Compatibility,
|
|
2367
|
+
getCurrentAccountEIP1559Compatibility,
|
|
2368
|
+
onNetworkStateChange
|
|
2369
|
+
}) {
|
|
2392
2370
|
super({
|
|
2393
2371
|
config,
|
|
2394
2372
|
state
|
|
@@ -2578,11 +2556,10 @@ const eth_sig_util_namespaceObject = require("@metamask/eth-sig-util");
|
|
|
2578
2556
|
|
|
2579
2557
|
|
|
2580
2558
|
class KeyringController extends base_controllers_namespaceObject.BaseKeyringController {
|
|
2581
|
-
constructor(
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
} = _ref;
|
|
2559
|
+
constructor({
|
|
2560
|
+
config,
|
|
2561
|
+
state
|
|
2562
|
+
}) {
|
|
2586
2563
|
super({
|
|
2587
2564
|
config,
|
|
2588
2565
|
state
|
|
@@ -2692,12 +2669,11 @@ class AbstractMessageController extends base_controllers_namespaceObject.BaseCon
|
|
|
2692
2669
|
* Controller in charge of managing - storing, adding, removing, updating - Messages.
|
|
2693
2670
|
*
|
|
2694
2671
|
*/
|
|
2695
|
-
constructor(
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
} = _ref;
|
|
2672
|
+
constructor({
|
|
2673
|
+
config,
|
|
2674
|
+
state,
|
|
2675
|
+
getNetworkIdentifier
|
|
2676
|
+
}) {
|
|
2701
2677
|
super({
|
|
2702
2678
|
config,
|
|
2703
2679
|
state
|
|
@@ -2935,13 +2911,12 @@ function validateSwitchChainData(data) {
|
|
|
2935
2911
|
|
|
2936
2912
|
|
|
2937
2913
|
class AddChainController extends AbstractMessageController {
|
|
2938
|
-
constructor(
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
} = _ref;
|
|
2914
|
+
constructor({
|
|
2915
|
+
config,
|
|
2916
|
+
state,
|
|
2917
|
+
getNetworkIdentifier,
|
|
2918
|
+
addChain
|
|
2919
|
+
}) {
|
|
2945
2920
|
super({
|
|
2946
2921
|
config,
|
|
2947
2922
|
state,
|
|
@@ -3006,13 +2981,12 @@ class AddChainController extends AbstractMessageController {
|
|
|
3006
2981
|
|
|
3007
2982
|
|
|
3008
2983
|
class DecryptMessageController extends AbstractMessageController {
|
|
3009
|
-
constructor(
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
} = _ref;
|
|
2984
|
+
constructor({
|
|
2985
|
+
config,
|
|
2986
|
+
state,
|
|
2987
|
+
decryptMessage,
|
|
2988
|
+
getNetworkIdentifier
|
|
2989
|
+
}) {
|
|
3016
2990
|
super({
|
|
3017
2991
|
config,
|
|
3018
2992
|
state,
|
|
@@ -3079,13 +3053,12 @@ class DecryptMessageController extends AbstractMessageController {
|
|
|
3079
3053
|
|
|
3080
3054
|
|
|
3081
3055
|
class EncryptionPublicKeyController extends AbstractMessageController {
|
|
3082
|
-
constructor(
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
} = _ref;
|
|
3056
|
+
constructor({
|
|
3057
|
+
config,
|
|
3058
|
+
state,
|
|
3059
|
+
signEncryptionPublicKey,
|
|
3060
|
+
getNetworkIdentifier
|
|
3061
|
+
}) {
|
|
3089
3062
|
super({
|
|
3090
3063
|
config,
|
|
3091
3064
|
state,
|
|
@@ -3152,13 +3125,12 @@ class EncryptionPublicKeyController extends AbstractMessageController {
|
|
|
3152
3125
|
|
|
3153
3126
|
|
|
3154
3127
|
class MessageController extends AbstractMessageController {
|
|
3155
|
-
constructor(
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
} = _ref;
|
|
3128
|
+
constructor({
|
|
3129
|
+
config,
|
|
3130
|
+
state,
|
|
3131
|
+
signMessage,
|
|
3132
|
+
getNetworkIdentifier
|
|
3133
|
+
}) {
|
|
3162
3134
|
super({
|
|
3163
3135
|
config,
|
|
3164
3136
|
state,
|
|
@@ -3223,13 +3195,12 @@ class MessageController extends AbstractMessageController {
|
|
|
3223
3195
|
|
|
3224
3196
|
|
|
3225
3197
|
class PersonalMessageController extends AbstractMessageController {
|
|
3226
|
-
constructor(
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
} = _ref;
|
|
3198
|
+
constructor({
|
|
3199
|
+
config,
|
|
3200
|
+
state,
|
|
3201
|
+
signPersonalMessage,
|
|
3202
|
+
getNetworkIdentifier
|
|
3203
|
+
}) {
|
|
3233
3204
|
super({
|
|
3234
3205
|
config,
|
|
3235
3206
|
state,
|
|
@@ -3294,13 +3265,12 @@ class PersonalMessageController extends AbstractMessageController {
|
|
|
3294
3265
|
|
|
3295
3266
|
|
|
3296
3267
|
class SwitchChainController extends AbstractMessageController {
|
|
3297
|
-
constructor(
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
} = _ref;
|
|
3268
|
+
constructor({
|
|
3269
|
+
config,
|
|
3270
|
+
state,
|
|
3271
|
+
getNetworkIdentifier,
|
|
3272
|
+
switchChain
|
|
3273
|
+
}) {
|
|
3304
3274
|
super({
|
|
3305
3275
|
config,
|
|
3306
3276
|
state,
|
|
@@ -3379,13 +3349,12 @@ function getMessageType(version) {
|
|
|
3379
3349
|
}
|
|
3380
3350
|
}
|
|
3381
3351
|
class TypedMessageController extends AbstractMessageController {
|
|
3382
|
-
constructor(
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
} = _ref;
|
|
3352
|
+
constructor({
|
|
3353
|
+
config,
|
|
3354
|
+
state,
|
|
3355
|
+
signTypedData,
|
|
3356
|
+
getNetworkIdentifier
|
|
3357
|
+
}) {
|
|
3389
3358
|
super({
|
|
3390
3359
|
config,
|
|
3391
3360
|
state,
|
|
@@ -3458,10 +3427,9 @@ const openlogin_jrpc_namespaceObject = require("@toruslabs/openlogin-jrpc");
|
|
|
3458
3427
|
|
|
3459
3428
|
|
|
3460
3429
|
|
|
3461
|
-
function createGetAccountsMiddleware(
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
} = _ref;
|
|
3430
|
+
function createGetAccountsMiddleware({
|
|
3431
|
+
getAccounts
|
|
3432
|
+
}) {
|
|
3465
3433
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3466
3434
|
const {
|
|
3467
3435
|
method
|
|
@@ -3472,10 +3440,9 @@ function createGetAccountsMiddleware(_ref) {
|
|
|
3472
3440
|
response.result = accounts;
|
|
3473
3441
|
});
|
|
3474
3442
|
}
|
|
3475
|
-
function createProcessTransactionMiddleware(
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
} = _ref2;
|
|
3443
|
+
function createProcessTransactionMiddleware({
|
|
3444
|
+
processTransaction
|
|
3445
|
+
}) {
|
|
3479
3446
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3480
3447
|
const {
|
|
3481
3448
|
method
|
|
@@ -3485,10 +3452,9 @@ function createProcessTransactionMiddleware(_ref2) {
|
|
|
3485
3452
|
response.result = await processTransaction(request.params, request);
|
|
3486
3453
|
});
|
|
3487
3454
|
}
|
|
3488
|
-
function createProcessEthSignMessage(
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
} = _ref3;
|
|
3455
|
+
function createProcessEthSignMessage({
|
|
3456
|
+
processEthSignMessage
|
|
3457
|
+
}) {
|
|
3492
3458
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3493
3459
|
const {
|
|
3494
3460
|
method
|
|
@@ -3510,10 +3476,9 @@ function createProcessEthSignMessage(_ref3) {
|
|
|
3510
3476
|
response.result = await processEthSignMessage(msgParams, request);
|
|
3511
3477
|
});
|
|
3512
3478
|
}
|
|
3513
|
-
function createProcessTypedMessage(
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
} = _ref4;
|
|
3479
|
+
function createProcessTypedMessage({
|
|
3480
|
+
processTypedMessage
|
|
3481
|
+
}) {
|
|
3517
3482
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3518
3483
|
const {
|
|
3519
3484
|
method
|
|
@@ -3536,10 +3501,9 @@ function createProcessTypedMessage(_ref4) {
|
|
|
3536
3501
|
response.result = await processTypedMessage(msgParams, request);
|
|
3537
3502
|
});
|
|
3538
3503
|
}
|
|
3539
|
-
function createProcessTypedMessageV3(
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
} = _ref5;
|
|
3504
|
+
function createProcessTypedMessageV3({
|
|
3505
|
+
processTypedMessageV3
|
|
3506
|
+
}) {
|
|
3543
3507
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3544
3508
|
const {
|
|
3545
3509
|
method
|
|
@@ -3562,10 +3526,9 @@ function createProcessTypedMessageV3(_ref5) {
|
|
|
3562
3526
|
response.result = await processTypedMessageV3(msgParams, request);
|
|
3563
3527
|
});
|
|
3564
3528
|
}
|
|
3565
|
-
function createProcessTypedMessageV4(
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
} = _ref6;
|
|
3529
|
+
function createProcessTypedMessageV4({
|
|
3530
|
+
processTypedMessageV4
|
|
3531
|
+
}) {
|
|
3569
3532
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3570
3533
|
const {
|
|
3571
3534
|
method
|
|
@@ -3588,10 +3551,9 @@ function createProcessTypedMessageV4(_ref6) {
|
|
|
3588
3551
|
response.result = await processTypedMessageV4(msgParams, request);
|
|
3589
3552
|
});
|
|
3590
3553
|
}
|
|
3591
|
-
function createProcessPersonalMessage(
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
} = _ref7;
|
|
3554
|
+
function createProcessPersonalMessage({
|
|
3555
|
+
processPersonalMessage
|
|
3556
|
+
}) {
|
|
3595
3557
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3596
3558
|
const {
|
|
3597
3559
|
method
|
|
@@ -3624,10 +3586,9 @@ function createProcessPersonalMessage(_ref7) {
|
|
|
3624
3586
|
response.result = await processPersonalMessage(msgParams, request);
|
|
3625
3587
|
});
|
|
3626
3588
|
}
|
|
3627
|
-
function createPendingNonceMiddleware(
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
} = _ref8;
|
|
3589
|
+
function createPendingNonceMiddleware({
|
|
3590
|
+
getPendingNonce
|
|
3591
|
+
}) {
|
|
3631
3592
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3632
3593
|
const {
|
|
3633
3594
|
params,
|
|
@@ -3689,10 +3650,9 @@ function formatTxMetaForRpcResult(txMeta) {
|
|
|
3689
3650
|
}
|
|
3690
3651
|
return formattedTxMeta;
|
|
3691
3652
|
}
|
|
3692
|
-
function createPendingTxMiddleware(
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
} = _ref9;
|
|
3653
|
+
function createPendingTxMiddleware({
|
|
3654
|
+
getPendingTransactionByHash
|
|
3655
|
+
}) {
|
|
3696
3656
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3697
3657
|
const {
|
|
3698
3658
|
params,
|
|
@@ -3708,10 +3668,9 @@ function createPendingTxMiddleware(_ref9) {
|
|
|
3708
3668
|
return undefined;
|
|
3709
3669
|
});
|
|
3710
3670
|
}
|
|
3711
|
-
function createProcessEncryptionPublicKeyMiddleware(
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
} = _ref10;
|
|
3671
|
+
function createProcessEncryptionPublicKeyMiddleware({
|
|
3672
|
+
processEncryptionPublicKey
|
|
3673
|
+
}) {
|
|
3715
3674
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3716
3675
|
const {
|
|
3717
3676
|
method
|
|
@@ -3731,10 +3690,9 @@ function createProcessEncryptionPublicKeyMiddleware(_ref10) {
|
|
|
3731
3690
|
response.result = await processEncryptionPublicKey(msgParams, request);
|
|
3732
3691
|
});
|
|
3733
3692
|
}
|
|
3734
|
-
function createProcessDecryptMessageMiddleware(
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
} = _ref11;
|
|
3693
|
+
function createProcessDecryptMessageMiddleware({
|
|
3694
|
+
processDecryptMessage
|
|
3695
|
+
}) {
|
|
3738
3696
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3739
3697
|
const {
|
|
3740
3698
|
method
|
|
@@ -3754,10 +3712,9 @@ function createProcessDecryptMessageMiddleware(_ref11) {
|
|
|
3754
3712
|
response.result = await processDecryptMessage(msgParams, request);
|
|
3755
3713
|
});
|
|
3756
3714
|
}
|
|
3757
|
-
function createProcessSwitchEthereumChain(
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
} = _ref12;
|
|
3715
|
+
function createProcessSwitchEthereumChain({
|
|
3716
|
+
processSwitchEthereumChain
|
|
3717
|
+
}) {
|
|
3761
3718
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3762
3719
|
const {
|
|
3763
3720
|
method
|
|
@@ -3774,10 +3731,9 @@ function createProcessSwitchEthereumChain(_ref12) {
|
|
|
3774
3731
|
response.result = await processSwitchEthereumChain(msgParams, request);
|
|
3775
3732
|
});
|
|
3776
3733
|
}
|
|
3777
|
-
function createProcessAddEthereumChain(
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
} = _ref13;
|
|
3734
|
+
function createProcessAddEthereumChain({
|
|
3735
|
+
processAddEthereumChain
|
|
3736
|
+
}) {
|
|
3781
3737
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3782
3738
|
const {
|
|
3783
3739
|
method
|
|
@@ -3794,10 +3750,9 @@ function createProcessAddEthereumChain(_ref13) {
|
|
|
3794
3750
|
response.result = await processAddEthereumChain(msgParams, request);
|
|
3795
3751
|
});
|
|
3796
3752
|
}
|
|
3797
|
-
function createRequestAccountsMiddleware(
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
} = _ref14;
|
|
3753
|
+
function createRequestAccountsMiddleware({
|
|
3754
|
+
requestAccounts
|
|
3755
|
+
}) {
|
|
3801
3756
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3802
3757
|
const {
|
|
3803
3758
|
method
|
|
@@ -4041,11 +3996,10 @@ const NetworkController_excluded = ["chainId", "rpcTarget"];
|
|
|
4041
3996
|
|
|
4042
3997
|
|
|
4043
3998
|
class NetworkController extends base_controllers_namespaceObject.BaseController {
|
|
4044
|
-
constructor(
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
} = _ref;
|
|
3999
|
+
constructor({
|
|
4000
|
+
config,
|
|
4001
|
+
state
|
|
4002
|
+
}) {
|
|
4049
4003
|
super({
|
|
4050
4004
|
config,
|
|
4051
4005
|
state
|
|
@@ -4172,11 +4126,10 @@ class NetworkController extends base_controllers_namespaceObject.BaseController
|
|
|
4172
4126
|
rpcTarget
|
|
4173
4127
|
}, rest));
|
|
4174
4128
|
}
|
|
4175
|
-
setNetworkClient(
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
} = _ref2;
|
|
4129
|
+
setNetworkClient({
|
|
4130
|
+
networkMiddleware,
|
|
4131
|
+
blockTracker
|
|
4132
|
+
}) {
|
|
4180
4133
|
const ethereumMiddleware = createEthereumMiddleware(this.baseProviderHandlers);
|
|
4181
4134
|
const engine = new openlogin_jrpc_namespaceObject.JRPCEngine();
|
|
4182
4135
|
engine.push(ethereumMiddleware);
|
|
@@ -4187,11 +4140,10 @@ class NetworkController extends base_controllers_namespaceObject.BaseController
|
|
|
4187
4140
|
blockTracker
|
|
4188
4141
|
});
|
|
4189
4142
|
}
|
|
4190
|
-
setProvider(
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
} = _ref3;
|
|
4143
|
+
setProvider({
|
|
4144
|
+
provider,
|
|
4145
|
+
blockTracker
|
|
4146
|
+
}) {
|
|
4195
4147
|
if (this.providerProxy) {
|
|
4196
4148
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
4197
4149
|
// @ts-ignore
|
|
@@ -4238,19 +4190,18 @@ class NetworkController extends base_controllers_namespaceObject.BaseController
|
|
|
4238
4190
|
|
|
4239
4191
|
|
|
4240
4192
|
class NftHandler {
|
|
4241
|
-
constructor(
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
} = _ref;
|
|
4193
|
+
constructor({
|
|
4194
|
+
chainId,
|
|
4195
|
+
contractAddress,
|
|
4196
|
+
contractImage,
|
|
4197
|
+
contractName,
|
|
4198
|
+
contractSymbol,
|
|
4199
|
+
nftStandard,
|
|
4200
|
+
provider,
|
|
4201
|
+
contractDescription,
|
|
4202
|
+
contractFallbackLogo,
|
|
4203
|
+
contractSupply
|
|
4204
|
+
}) {
|
|
4254
4205
|
defineProperty_default()(this, "contractAddress", void 0);
|
|
4255
4206
|
defineProperty_default()(this, "contractName", void 0);
|
|
4256
4207
|
defineProperty_default()(this, "contractSymbol", void 0);
|
|
@@ -4398,8 +4349,7 @@ class NftHandler {
|
|
|
4398
4349
|
const contract = new external_ethers_namespaceObject.Contract(this.contractAddress, abi, this.provider);
|
|
4399
4350
|
return contract.supportsInterface(interfaceId);
|
|
4400
4351
|
}
|
|
4401
|
-
async getCollectibleTokenURI(tokenId) {
|
|
4402
|
-
let standard = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : CONTRACT_TYPE_ERC721;
|
|
4352
|
+
async getCollectibleTokenURI(tokenId, standard = CONTRACT_TYPE_ERC721) {
|
|
4403
4353
|
const method = standard === CONTRACT_TYPE_ERC721 ? "tokenURI" : "uri";
|
|
4404
4354
|
const abi = standard === CONTRACT_TYPE_ERC721 ? erc721Abi : erc1155Abi;
|
|
4405
4355
|
const contract = new external_ethers_namespaceObject.Contract(this.contractAddress, abi, this.provider);
|
|
@@ -4418,16 +4368,15 @@ class NftHandler {
|
|
|
4418
4368
|
|
|
4419
4369
|
const DEFAULT_INTERVAL = 180 * 1000;
|
|
4420
4370
|
class NftsController extends base_controllers_namespaceObject.BaseController {
|
|
4421
|
-
constructor(
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
} = _ref;
|
|
4371
|
+
constructor({
|
|
4372
|
+
config,
|
|
4373
|
+
state,
|
|
4374
|
+
provider,
|
|
4375
|
+
getCustomNfts,
|
|
4376
|
+
getSimpleHashNfts,
|
|
4377
|
+
onPreferencesStateChange,
|
|
4378
|
+
onNetworkStateChange
|
|
4379
|
+
}) {
|
|
4431
4380
|
super({
|
|
4432
4381
|
config,
|
|
4433
4382
|
state
|
|
@@ -4625,16 +4574,15 @@ class NftsController extends base_controllers_namespaceObject.BaseController {
|
|
|
4625
4574
|
|
|
4626
4575
|
|
|
4627
4576
|
class PreferencesController extends base_controllers_namespaceObject.BasePreferencesController {
|
|
4628
|
-
constructor(
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
} = _ref;
|
|
4577
|
+
constructor({
|
|
4578
|
+
config,
|
|
4579
|
+
state,
|
|
4580
|
+
provider,
|
|
4581
|
+
signAuthMessage,
|
|
4582
|
+
getProviderConfig,
|
|
4583
|
+
setProviderConfig,
|
|
4584
|
+
validateSignMessage
|
|
4585
|
+
}) {
|
|
4638
4586
|
super({
|
|
4639
4587
|
config,
|
|
4640
4588
|
state,
|
|
@@ -4888,9 +4836,7 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
|
|
|
4888
4836
|
async addChain(network) {
|
|
4889
4837
|
const approveChainOptions = this.getChainOptions();
|
|
4890
4838
|
const providerConfig = approveChainOptions.find(x => x.chainId === network.chainId);
|
|
4891
|
-
if (providerConfig)
|
|
4892
|
-
throw new Error(`chainId ${network.chainId} already exists`);
|
|
4893
|
-
}
|
|
4839
|
+
if (providerConfig) return;
|
|
4894
4840
|
const newNetwork = {
|
|
4895
4841
|
displayName: network.chainName,
|
|
4896
4842
|
rpcTarget: network.rpcUrls[0],
|
|
@@ -4916,10 +4862,9 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
|
|
|
4916
4862
|
}
|
|
4917
4863
|
|
|
4918
4864
|
// Custom Network methods
|
|
4919
|
-
async addCustomNetwork(
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
} = _ref2;
|
|
4865
|
+
async addCustomNetwork({
|
|
4866
|
+
network
|
|
4867
|
+
}) {
|
|
4923
4868
|
try {
|
|
4924
4869
|
const {
|
|
4925
4870
|
selectedAddress
|
|
@@ -4959,11 +4904,10 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
|
|
|
4959
4904
|
return false;
|
|
4960
4905
|
}
|
|
4961
4906
|
}
|
|
4962
|
-
async editCustomNetwork(
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
} = _ref3;
|
|
4907
|
+
async editCustomNetwork({
|
|
4908
|
+
network,
|
|
4909
|
+
id
|
|
4910
|
+
}) {
|
|
4967
4911
|
try {
|
|
4968
4912
|
const {
|
|
4969
4913
|
selectedAddress
|
|
@@ -4986,9 +4930,8 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
|
|
|
4986
4930
|
return false;
|
|
4987
4931
|
}
|
|
4988
4932
|
}
|
|
4989
|
-
getChainOptions() {
|
|
4933
|
+
getChainOptions(address = this.state.selectedAddress) {
|
|
4990
4934
|
var _identities$address$c, _identities$address;
|
|
4991
|
-
let address = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.state.selectedAddress;
|
|
4992
4935
|
const {
|
|
4993
4936
|
identities
|
|
4994
4937
|
} = this.state;
|
|
@@ -5100,14 +5043,13 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
|
|
|
5100
5043
|
|
|
5101
5044
|
|
|
5102
5045
|
class TokenHandler {
|
|
5103
|
-
constructor(
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
} = _ref;
|
|
5046
|
+
constructor({
|
|
5047
|
+
address,
|
|
5048
|
+
symbol,
|
|
5049
|
+
decimals,
|
|
5050
|
+
name,
|
|
5051
|
+
provider
|
|
5052
|
+
}) {
|
|
5111
5053
|
defineProperty_default()(this, "address", void 0);
|
|
5112
5054
|
defineProperty_default()(this, "symbol", void 0);
|
|
5113
5055
|
defineProperty_default()(this, "decimals", void 0);
|
|
@@ -5152,14 +5094,13 @@ class TokenHandler {
|
|
|
5152
5094
|
|
|
5153
5095
|
const DEFAULT_CURRENCY = "eth";
|
|
5154
5096
|
class TokenRatesController extends base_controllers_namespaceObject.BaseController {
|
|
5155
|
-
constructor(
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
} = _ref;
|
|
5097
|
+
constructor({
|
|
5098
|
+
config,
|
|
5099
|
+
state,
|
|
5100
|
+
onPreferencesStateChange,
|
|
5101
|
+
onNetworkStateChange,
|
|
5102
|
+
onTokensStateChange
|
|
5103
|
+
}) {
|
|
5163
5104
|
super({
|
|
5164
5105
|
config,
|
|
5165
5106
|
state
|
|
@@ -5280,17 +5221,16 @@ const mergeTokenArrays = (oldArray, newArray) => {
|
|
|
5280
5221
|
};
|
|
5281
5222
|
const TokensController_DEFAULT_INTERVAL = 180 * 1000;
|
|
5282
5223
|
class TokensController extends base_controllers_namespaceObject.BaseController {
|
|
5283
|
-
constructor(
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
} = _ref;
|
|
5224
|
+
constructor({
|
|
5225
|
+
config,
|
|
5226
|
+
state,
|
|
5227
|
+
provider,
|
|
5228
|
+
getCustomTokens,
|
|
5229
|
+
getEtherScanTokens,
|
|
5230
|
+
getProviderConfig,
|
|
5231
|
+
onPreferencesStateChange,
|
|
5232
|
+
onNetworkStateChange
|
|
5233
|
+
}) {
|
|
5294
5234
|
super({
|
|
5295
5235
|
config,
|
|
5296
5236
|
state
|
|
@@ -5513,13 +5453,12 @@ class TokensController extends base_controllers_namespaceObject.BaseController {
|
|
|
5513
5453
|
|
|
5514
5454
|
|
|
5515
5455
|
class NonceTracker {
|
|
5516
|
-
constructor(
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
} = _ref;
|
|
5456
|
+
constructor({
|
|
5457
|
+
provider,
|
|
5458
|
+
blockTracker,
|
|
5459
|
+
getPendingTransactions,
|
|
5460
|
+
getConfirmedTransactions
|
|
5461
|
+
}) {
|
|
5523
5462
|
defineProperty_default()(this, "provider", void 0);
|
|
5524
5463
|
defineProperty_default()(this, "blockTracker", void 0);
|
|
5525
5464
|
defineProperty_default()(this, "getPendingTransactions", void 0);
|
|
@@ -5663,15 +5602,14 @@ class NonceTracker {
|
|
|
5663
5602
|
|
|
5664
5603
|
|
|
5665
5604
|
class PendingTransactionTracker extends openlogin_jrpc_namespaceObject.SafeEventEmitter {
|
|
5666
|
-
constructor(
|
|
5667
|
-
|
|
5668
|
-
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
} = _ref;
|
|
5605
|
+
constructor({
|
|
5606
|
+
provider,
|
|
5607
|
+
nonceTracker,
|
|
5608
|
+
approveTransaction,
|
|
5609
|
+
publishTransaction,
|
|
5610
|
+
getPendingTransactions,
|
|
5611
|
+
getConfirmedTransactions
|
|
5612
|
+
}) {
|
|
5675
5613
|
super();
|
|
5676
5614
|
defineProperty_default()(this, "DROPPED_BUFFER_COUNT", 3);
|
|
5677
5615
|
defineProperty_default()(this, "nonceTracker", void 0);
|
|
@@ -5922,8 +5860,7 @@ class TransactionGasUtil {
|
|
|
5922
5860
|
/**
|
|
5923
5861
|
Adds a gas buffer with out exceeding the block gas limit
|
|
5924
5862
|
*/
|
|
5925
|
-
addGasBuffer(initialGasLimitHex, blockGasLimitHex) {
|
|
5926
|
-
let multiplier = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1.5;
|
|
5863
|
+
addGasBuffer(initialGasLimitHex, blockGasLimitHex, multiplier = 1.5) {
|
|
5927
5864
|
const initialGasLimitBn = new external_bn_js_namespaceObject.BN((0,util_namespaceObject.stripHexPrefix)(initialGasLimitHex), 16);
|
|
5928
5865
|
const blockGasLimitBn = new external_bn_js_namespaceObject.BN((0,util_namespaceObject.stripHexPrefix)(blockGasLimitHex), 16);
|
|
5929
5866
|
const upperGasLimitBn = blockGasLimitBn.muln(0.9);
|
|
@@ -6004,20 +5941,18 @@ function snapshotFromTxMeta(txMeta) {
|
|
|
6004
5941
|
|
|
6005
5942
|
|
|
6006
5943
|
class TransactionStateManager extends base_controllers_namespaceObject.BaseTransactionStateManager {
|
|
6007
|
-
constructor(
|
|
6008
|
-
|
|
6009
|
-
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
} = _ref;
|
|
5944
|
+
constructor({
|
|
5945
|
+
config,
|
|
5946
|
+
state,
|
|
5947
|
+
getCurrentChainId
|
|
5948
|
+
}) {
|
|
6013
5949
|
super({
|
|
6014
5950
|
config,
|
|
6015
5951
|
state,
|
|
6016
5952
|
getCurrentChainId
|
|
6017
5953
|
});
|
|
6018
5954
|
}
|
|
6019
|
-
generateTxMeta() {
|
|
6020
|
-
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
5955
|
+
generateTxMeta(opts = {}) {
|
|
6021
5956
|
const chainId = this.getCurrentChainId();
|
|
6022
5957
|
if (chainId === "loading") throw new Error("Torus is having trouble connecting to the network");
|
|
6023
5958
|
let dappSuggestedGasFees = null;
|
|
@@ -6127,13 +6062,12 @@ class TransactionStateManager extends base_controllers_namespaceObject.BaseTrans
|
|
|
6127
6062
|
})
|
|
6128
6063
|
});
|
|
6129
6064
|
}
|
|
6130
|
-
getTransactions(
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
6065
|
+
getTransactions({
|
|
6066
|
+
searchCriteria = {},
|
|
6067
|
+
initialList = undefined,
|
|
6068
|
+
filterToCurrentNetwork = true,
|
|
6069
|
+
limit = undefined
|
|
6070
|
+
} = {}) {
|
|
6137
6071
|
const chainId = this.getCurrentChainId();
|
|
6138
6072
|
// searchCriteria is an object that might have values that aren't predicate
|
|
6139
6073
|
// methods. When providing any other value type (string, number, etc), we
|
|
@@ -6311,20 +6245,19 @@ class TransactionStateManager extends base_controllers_namespaceObject.BaseTrans
|
|
|
6311
6245
|
|
|
6312
6246
|
|
|
6313
6247
|
class TransactionController extends TransactionStateManager {
|
|
6314
|
-
constructor(
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
} = _ref;
|
|
6248
|
+
constructor({
|
|
6249
|
+
config,
|
|
6250
|
+
state,
|
|
6251
|
+
provider,
|
|
6252
|
+
blockTracker,
|
|
6253
|
+
signEthTx,
|
|
6254
|
+
getCurrentChainId,
|
|
6255
|
+
getCurrentNetworkEIP1559Compatibility,
|
|
6256
|
+
getProviderConfig,
|
|
6257
|
+
getCurrentAccountEIP1559Compatibility,
|
|
6258
|
+
getSelectedAddress,
|
|
6259
|
+
getEIP1559GasFeeEstimates
|
|
6260
|
+
}) {
|
|
6328
6261
|
super({
|
|
6329
6262
|
config,
|
|
6330
6263
|
state,
|
|
@@ -6716,11 +6649,10 @@ class TransactionController extends TransactionStateManager {
|
|
|
6716
6649
|
this.updateTransactionInState(data.txMeta);
|
|
6717
6650
|
});
|
|
6718
6651
|
this.pendingTxTracker.on(base_controllers_namespaceObject.TX_EVENTS.TX_DROPPED, data => this.setTxStatusDropped(data.txId));
|
|
6719
|
-
this.pendingTxTracker.on(base_controllers_namespaceObject.TX_EVENTS.TX_BLOCK_UPDATE,
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
} = _ref2;
|
|
6652
|
+
this.pendingTxTracker.on(base_controllers_namespaceObject.TX_EVENTS.TX_BLOCK_UPDATE, ({
|
|
6653
|
+
txMeta,
|
|
6654
|
+
latestBlockNumber
|
|
6655
|
+
}) => {
|
|
6724
6656
|
if (!txMeta.firstRetryBlockNumber) {
|
|
6725
6657
|
txMeta.firstRetryBlockNumber = latestBlockNumber;
|
|
6726
6658
|
this.updateTransactionInState(txMeta);
|