@toruslabs/ethereum-controllers 5.9.1 → 5.10.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.
- package/dist/ethereumControllers.cjs.js +514 -351
- package/dist/ethereumControllers.esm.js +401 -306
- package/dist/ethereumControllers.umd.min.js +1 -1
- package/dist/ethereumControllers.umd.min.js.LICENSE.txt +6 -10
- package/dist/types/Keyring/KeyringController.d.ts +0 -1
- package/dist/types/Message/AbstractMessageController.d.ts +1 -1
- package/dist/types/Message/utils.d.ts +2 -2
- package/dist/types/utils/interfaces.d.ts +1 -1
- package/dist/types/utils/lodashUtils.d.ts +5 -0
- package/package.json +8 -9
|
@@ -1,7 +1,53 @@
|
|
|
1
1
|
/******/ (() => { // webpackBootstrap
|
|
2
2
|
/******/ "use strict";
|
|
3
|
-
/******/
|
|
4
|
-
|
|
3
|
+
/******/ var __webpack_modules__ = ({
|
|
4
|
+
|
|
5
|
+
/***/ 652:
|
|
6
|
+
/***/ ((module) => {
|
|
7
|
+
|
|
8
|
+
module.exports = require("@ethereumjs/common");
|
|
9
|
+
|
|
10
|
+
/***/ }),
|
|
11
|
+
|
|
12
|
+
/***/ 81:
|
|
13
|
+
/***/ ((module) => {
|
|
14
|
+
|
|
15
|
+
module.exports = require("@ethereumjs/tx");
|
|
16
|
+
|
|
17
|
+
/***/ }),
|
|
18
|
+
|
|
19
|
+
/***/ 731:
|
|
20
|
+
/***/ ((module) => {
|
|
21
|
+
|
|
22
|
+
module.exports = require("jsonschema");
|
|
23
|
+
|
|
24
|
+
/***/ })
|
|
25
|
+
|
|
26
|
+
/******/ });
|
|
27
|
+
/************************************************************************/
|
|
28
|
+
/******/ // The module cache
|
|
29
|
+
/******/ var __webpack_module_cache__ = {};
|
|
30
|
+
/******/
|
|
31
|
+
/******/ // The require function
|
|
32
|
+
/******/ function __webpack_require__(moduleId) {
|
|
33
|
+
/******/ // Check if module is in cache
|
|
34
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
35
|
+
/******/ if (cachedModule !== undefined) {
|
|
36
|
+
/******/ return cachedModule.exports;
|
|
37
|
+
/******/ }
|
|
38
|
+
/******/ // Create a new module (and put it into the cache)
|
|
39
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
40
|
+
/******/ // no module.id needed
|
|
41
|
+
/******/ // no module.loaded needed
|
|
42
|
+
/******/ exports: {}
|
|
43
|
+
/******/ };
|
|
44
|
+
/******/
|
|
45
|
+
/******/ // Execute the module function
|
|
46
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
47
|
+
/******/
|
|
48
|
+
/******/ // Return the exports of the module
|
|
49
|
+
/******/ return module.exports;
|
|
50
|
+
/******/ }
|
|
5
51
|
/******/
|
|
6
52
|
/************************************************************************/
|
|
7
53
|
/******/ /* webpack/runtime/compat get default export */
|
|
@@ -16,6 +62,36 @@
|
|
|
16
62
|
/******/ };
|
|
17
63
|
/******/ })();
|
|
18
64
|
/******/
|
|
65
|
+
/******/ /* webpack/runtime/create fake namespace object */
|
|
66
|
+
/******/ (() => {
|
|
67
|
+
/******/ var getProto = Object.getPrototypeOf ? (obj) => (Object.getPrototypeOf(obj)) : (obj) => (obj.__proto__);
|
|
68
|
+
/******/ var leafPrototypes;
|
|
69
|
+
/******/ // create a fake namespace object
|
|
70
|
+
/******/ // mode & 1: value is a module id, require it
|
|
71
|
+
/******/ // mode & 2: merge all properties of value into the ns
|
|
72
|
+
/******/ // mode & 4: return value when already ns object
|
|
73
|
+
/******/ // mode & 16: return value when it's Promise-like
|
|
74
|
+
/******/ // mode & 8|1: behave like require
|
|
75
|
+
/******/ __webpack_require__.t = function(value, mode) {
|
|
76
|
+
/******/ if(mode & 1) value = this(value);
|
|
77
|
+
/******/ if(mode & 8) return value;
|
|
78
|
+
/******/ if(typeof value === 'object' && value) {
|
|
79
|
+
/******/ if((mode & 4) && value.__esModule) return value;
|
|
80
|
+
/******/ if((mode & 16) && typeof value.then === 'function') return value;
|
|
81
|
+
/******/ }
|
|
82
|
+
/******/ var ns = Object.create(null);
|
|
83
|
+
/******/ __webpack_require__.r(ns);
|
|
84
|
+
/******/ var def = {};
|
|
85
|
+
/******/ leafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)];
|
|
86
|
+
/******/ for(var current = mode & 2 && value; typeof current == 'object' && !~leafPrototypes.indexOf(current); current = getProto(current)) {
|
|
87
|
+
/******/ Object.getOwnPropertyNames(current).forEach((key) => (def[key] = () => (value[key])));
|
|
88
|
+
/******/ }
|
|
89
|
+
/******/ def['default'] = () => (value);
|
|
90
|
+
/******/ __webpack_require__.d(ns, def);
|
|
91
|
+
/******/ return ns;
|
|
92
|
+
/******/ };
|
|
93
|
+
/******/ })();
|
|
94
|
+
/******/
|
|
19
95
|
/******/ /* webpack/runtime/define property getters */
|
|
20
96
|
/******/ (() => {
|
|
21
97
|
/******/ // define getter functions for harmony exports
|
|
@@ -1067,15 +1143,16 @@ const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
|
1067
1143
|
* Network state changes also retrigger accounts update.
|
|
1068
1144
|
*/
|
|
1069
1145
|
class AccountTrackerController extends base_controllers_namespaceObject.BaseController {
|
|
1070
|
-
constructor({
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1146
|
+
constructor(_ref) {
|
|
1147
|
+
let {
|
|
1148
|
+
config,
|
|
1149
|
+
state,
|
|
1150
|
+
provider,
|
|
1151
|
+
blockTracker,
|
|
1152
|
+
getIdentities,
|
|
1153
|
+
onPreferencesStateChange,
|
|
1154
|
+
getCurrentChainId
|
|
1155
|
+
} = _ref;
|
|
1079
1156
|
super({
|
|
1080
1157
|
config,
|
|
1081
1158
|
state
|
|
@@ -1211,8 +1288,8 @@ const util_namespaceObject = require("@ethereumjs/util");
|
|
|
1211
1288
|
;// CONCATENATED MODULE: external "bignumber.js"
|
|
1212
1289
|
const external_bignumber_js_namespaceObject = require("bignumber.js");
|
|
1213
1290
|
var external_bignumber_js_default = /*#__PURE__*/__webpack_require__.n(external_bignumber_js_namespaceObject);
|
|
1214
|
-
;// CONCATENATED MODULE: external "@
|
|
1215
|
-
const
|
|
1291
|
+
;// CONCATENATED MODULE: external "@toruslabs/openlogin-jrpc"
|
|
1292
|
+
const openlogin_jrpc_namespaceObject = require("@toruslabs/openlogin-jrpc");
|
|
1216
1293
|
;// CONCATENATED MODULE: ./src/Transaction/TransactionUtils.ts
|
|
1217
1294
|
|
|
1218
1295
|
|
|
@@ -1228,8 +1305,14 @@ const erc1155Interface = new external_ethers_namespaceObject.Interface(erc1155Ab
|
|
|
1228
1305
|
// functions that handle normalizing of that key in txParams
|
|
1229
1306
|
|
|
1230
1307
|
const normalizers = {
|
|
1231
|
-
from:
|
|
1232
|
-
|
|
1308
|
+
from: function (from) {
|
|
1309
|
+
let LowerCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
1310
|
+
return LowerCase ? (0,util_namespaceObject.addHexPrefix)(from).toLowerCase() : (0,util_namespaceObject.addHexPrefix)(from);
|
|
1311
|
+
},
|
|
1312
|
+
to: function (to) {
|
|
1313
|
+
let LowerCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
1314
|
+
return LowerCase ? (0,util_namespaceObject.addHexPrefix)(to).toLowerCase() : (0,util_namespaceObject.addHexPrefix)(to);
|
|
1315
|
+
},
|
|
1233
1316
|
nonce: nonce => (0,util_namespaceObject.addHexPrefix)(nonce),
|
|
1234
1317
|
customNonceValue: nonce => (0,util_namespaceObject.addHexPrefix)(nonce),
|
|
1235
1318
|
value: value => (0,util_namespaceObject.addHexPrefix)(value),
|
|
@@ -1244,7 +1327,8 @@ const normalizers = {
|
|
|
1244
1327
|
/**
|
|
1245
1328
|
* normalizes txParams
|
|
1246
1329
|
*/
|
|
1247
|
-
function normalizeTxParameters(txParameters
|
|
1330
|
+
function normalizeTxParameters(txParameters) {
|
|
1331
|
+
let lowerCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
1248
1332
|
// apply only keys in the normalizers
|
|
1249
1333
|
const normalizedTxParameters = {
|
|
1250
1334
|
id: txParameters.id || (0,base_controllers_namespaceObject.randomId)(),
|
|
@@ -1295,7 +1379,7 @@ function isLegacyTransaction(transaction) {
|
|
|
1295
1379
|
*/
|
|
1296
1380
|
function ensureMutuallyExclusiveFieldsNotProvided(txParams, fieldBeingValidated, mutuallyExclusiveField) {
|
|
1297
1381
|
if (typeof txParams[mutuallyExclusiveField] !== "undefined") {
|
|
1298
|
-
throw
|
|
1382
|
+
throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams(`Invalid transaction params: specified ${fieldBeingValidated} but also included ${mutuallyExclusiveField}, these cannot be mixed`);
|
|
1299
1383
|
}
|
|
1300
1384
|
}
|
|
1301
1385
|
|
|
@@ -1305,7 +1389,7 @@ function ensureMutuallyExclusiveFieldsNotProvided(txParams, fieldBeingValidated,
|
|
|
1305
1389
|
*/
|
|
1306
1390
|
function ensureFieldIsString(txParams, field) {
|
|
1307
1391
|
if (typeof txParams[field] !== "string") {
|
|
1308
|
-
throw
|
|
1392
|
+
throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams(`Invalid transaction params: ${field} is not a string. got: (${txParams[field]})`);
|
|
1309
1393
|
}
|
|
1310
1394
|
}
|
|
1311
1395
|
|
|
@@ -1319,13 +1403,13 @@ function ensureProperTransactionEnvelopeTypeProvided(txParams, field) {
|
|
|
1319
1403
|
case "maxFeePerGas":
|
|
1320
1404
|
case "maxPriorityFeePerGas":
|
|
1321
1405
|
if (txParams.type && txParams.type !== TRANSACTION_ENVELOPE_TYPES.FEE_MARKET) {
|
|
1322
|
-
throw
|
|
1406
|
+
throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams(`Invalid transaction envelope type: specified type "${txParams.type}" but ` + `including maxFeePerGas and maxPriorityFeePerGas requires type: "${TRANSACTION_ENVELOPE_TYPES.FEE_MARKET}"`);
|
|
1323
1407
|
}
|
|
1324
1408
|
break;
|
|
1325
1409
|
case "gasPrice":
|
|
1326
1410
|
default:
|
|
1327
1411
|
if (txParams.type && txParams.type === TRANSACTION_ENVELOPE_TYPES.FEE_MARKET) {
|
|
1328
|
-
throw
|
|
1412
|
+
throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams(`Invalid transaction envelope type: specified type "${txParams.type}" but ` + "included a gasPrice instead of maxFeePerGas and maxPriorityFeePerGas");
|
|
1329
1413
|
}
|
|
1330
1414
|
}
|
|
1331
1415
|
}
|
|
@@ -1335,10 +1419,10 @@ function ensureProperTransactionEnvelopeTypeProvided(txParams, field) {
|
|
|
1335
1419
|
*/
|
|
1336
1420
|
function validateFrom(txParams) {
|
|
1337
1421
|
if (!(typeof txParams.from === "string")) {
|
|
1338
|
-
throw
|
|
1422
|
+
throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams(`Invalid "from" address "${txParams.from}": not a string.`);
|
|
1339
1423
|
}
|
|
1340
1424
|
if (!(0,util_namespaceObject.isValidAddress)(txParams.from)) {
|
|
1341
|
-
throw
|
|
1425
|
+
throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams('Invalid "from" address.');
|
|
1342
1426
|
}
|
|
1343
1427
|
}
|
|
1344
1428
|
|
|
@@ -1350,10 +1434,10 @@ function validateRecipient(txParameters) {
|
|
|
1350
1434
|
if (txParameters.data) {
|
|
1351
1435
|
delete txParameters.to;
|
|
1352
1436
|
} else {
|
|
1353
|
-
throw
|
|
1437
|
+
throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams('Invalid "to" address.');
|
|
1354
1438
|
}
|
|
1355
1439
|
} else if (txParameters.to !== undefined && !(0,util_namespaceObject.isValidAddress)(txParameters.to)) {
|
|
1356
|
-
throw
|
|
1440
|
+
throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams('Invalid "to" address.');
|
|
1357
1441
|
}
|
|
1358
1442
|
return txParameters;
|
|
1359
1443
|
}
|
|
@@ -1362,19 +1446,21 @@ function validateRecipient(txParameters) {
|
|
|
1362
1446
|
* Validates the given tx parameters
|
|
1363
1447
|
* @throws if the tx params contains invalid fields
|
|
1364
1448
|
*/
|
|
1365
|
-
function validateTxParameters(txParams
|
|
1449
|
+
function validateTxParameters(txParams) {
|
|
1450
|
+
let eip1559Compatibility = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
1366
1451
|
if (!txParams || typeof txParams !== "object" || Array.isArray(txParams)) {
|
|
1367
|
-
throw
|
|
1452
|
+
throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams("Invalid transaction params: must be an object.");
|
|
1368
1453
|
}
|
|
1369
1454
|
if (!txParams.to && !txParams.data) {
|
|
1370
|
-
throw
|
|
1455
|
+
throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams('Invalid transaction params: must specify "data" for contract deployments, or "to" (and optionally "data") for all other types of transactions.');
|
|
1371
1456
|
}
|
|
1372
1457
|
if (isEIP1559Transaction({
|
|
1373
1458
|
transaction: txParams
|
|
1374
1459
|
}) && !eip1559Compatibility) {
|
|
1375
|
-
throw
|
|
1460
|
+
throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams("Invalid transaction params: params specify an EIP-1559 transaction but the current network does not support EIP-1559");
|
|
1376
1461
|
}
|
|
1377
|
-
Object.entries(txParams).forEach(
|
|
1462
|
+
Object.entries(txParams).forEach(_ref => {
|
|
1463
|
+
let [key, value] = _ref;
|
|
1378
1464
|
// validate types
|
|
1379
1465
|
switch (key) {
|
|
1380
1466
|
case "from":
|
|
@@ -1402,15 +1488,15 @@ function validateTxParameters(txParams, eip1559Compatibility = true) {
|
|
|
1402
1488
|
case "value":
|
|
1403
1489
|
ensureFieldIsString(txParams, "value");
|
|
1404
1490
|
if (value.toString().includes("-")) {
|
|
1405
|
-
throw
|
|
1491
|
+
throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams(`Invalid transaction value "${value}": not a positive number.`);
|
|
1406
1492
|
}
|
|
1407
1493
|
if (value.toString().includes(".")) {
|
|
1408
|
-
throw
|
|
1494
|
+
throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams(`Invalid transaction value of "${value}": number must be in wei.`);
|
|
1409
1495
|
}
|
|
1410
1496
|
break;
|
|
1411
1497
|
case "chainId":
|
|
1412
1498
|
if (typeof value !== "number" && typeof value !== "string") {
|
|
1413
|
-
throw
|
|
1499
|
+
throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams(`Invalid transaction params: ${key} is not a Number or hex string. got: (${value})`);
|
|
1414
1500
|
}
|
|
1415
1501
|
break;
|
|
1416
1502
|
default:
|
|
@@ -1418,7 +1504,8 @@ function validateTxParameters(txParams, eip1559Compatibility = true) {
|
|
|
1418
1504
|
}
|
|
1419
1505
|
});
|
|
1420
1506
|
}
|
|
1421
|
-
function normalizeAndValidateTxParams(txParams
|
|
1507
|
+
function normalizeAndValidateTxParams(txParams) {
|
|
1508
|
+
let lowerCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
1422
1509
|
const normalizedTxParams = normalizeTxParameters(txParams, lowerCase);
|
|
1423
1510
|
validateTxParameters(normalizedTxParams);
|
|
1424
1511
|
return normalizedTxParams;
|
|
@@ -1764,10 +1851,11 @@ const DEFAULT_POLLING_INTERVAL = 20;
|
|
|
1764
1851
|
const DEFAULT_RETRY_TIMEOUT = 2;
|
|
1765
1852
|
const SEC = 1000;
|
|
1766
1853
|
class PollingBlockTracker extends base_controllers_namespaceObject.BaseBlockTracker {
|
|
1767
|
-
constructor({
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1854
|
+
constructor(_ref) {
|
|
1855
|
+
let {
|
|
1856
|
+
config,
|
|
1857
|
+
state = {}
|
|
1858
|
+
} = _ref;
|
|
1771
1859
|
if (!config.provider) {
|
|
1772
1860
|
throw new Error("PollingBlockTracker - no provider specified.");
|
|
1773
1861
|
}
|
|
@@ -1848,11 +1936,12 @@ const http_helpers_namespaceObject = require("@toruslabs/http-helpers");
|
|
|
1848
1936
|
|
|
1849
1937
|
|
|
1850
1938
|
class CurrencyController extends base_controllers_namespaceObject.BaseCurrencyController {
|
|
1851
|
-
constructor({
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1939
|
+
constructor(_ref) {
|
|
1940
|
+
let {
|
|
1941
|
+
config,
|
|
1942
|
+
state,
|
|
1943
|
+
onNetworkChanged
|
|
1944
|
+
} = _ref;
|
|
1856
1945
|
super({
|
|
1857
1946
|
config,
|
|
1858
1947
|
state
|
|
@@ -1947,8 +2036,6 @@ class CurrencyController extends base_controllers_namespaceObject.BaseCurrencyCo
|
|
|
1947
2036
|
};
|
|
1948
2037
|
}
|
|
1949
2038
|
}
|
|
1950
|
-
;// CONCATENATED MODULE: external "lodash"
|
|
1951
|
-
const external_lodash_namespaceObject = require("lodash");
|
|
1952
2039
|
;// CONCATENATED MODULE: external "@babel/runtime/helpers/objectDestructuringEmpty"
|
|
1953
2040
|
const objectDestructuringEmpty_namespaceObject = require("@babel/runtime/helpers/objectDestructuringEmpty");
|
|
1954
2041
|
var objectDestructuringEmpty_default = /*#__PURE__*/__webpack_require__.n(objectDestructuringEmpty_namespaceObject);
|
|
@@ -2026,19 +2113,20 @@ const isValidBase = base => Number.isInteger(base) && base > 1;
|
|
|
2026
2113
|
/**
|
|
2027
2114
|
* Utility method to convert a value between denominations, formats and currencies.
|
|
2028
2115
|
*/
|
|
2029
|
-
const converter =
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2116
|
+
const converter = _ref => {
|
|
2117
|
+
let {
|
|
2118
|
+
value,
|
|
2119
|
+
fromNumericBase,
|
|
2120
|
+
fromDenomination,
|
|
2121
|
+
fromCurrency,
|
|
2122
|
+
toNumericBase,
|
|
2123
|
+
toDenomination,
|
|
2124
|
+
toCurrency,
|
|
2125
|
+
numberOfDecimals,
|
|
2126
|
+
conversionRate,
|
|
2127
|
+
invertConversionRate,
|
|
2128
|
+
roundDown
|
|
2129
|
+
} = _ref;
|
|
2042
2130
|
let convertedValue = fromNumericBase ? toBigNumber[fromNumericBase](value) : value;
|
|
2043
2131
|
if (fromDenomination) {
|
|
2044
2132
|
convertedValue = toNormalizedDenomination[fromDenomination](convertedValue);
|
|
@@ -2067,17 +2155,18 @@ const converter = ({
|
|
|
2067
2155
|
}
|
|
2068
2156
|
return convertedValue;
|
|
2069
2157
|
};
|
|
2070
|
-
const conversionUtil = (value, {
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2158
|
+
const conversionUtil = (value, _ref2) => {
|
|
2159
|
+
let {
|
|
2160
|
+
fromCurrency = null,
|
|
2161
|
+
toCurrency = fromCurrency,
|
|
2162
|
+
fromNumericBase,
|
|
2163
|
+
toNumericBase,
|
|
2164
|
+
fromDenomination,
|
|
2165
|
+
toDenomination,
|
|
2166
|
+
numberOfDecimals,
|
|
2167
|
+
conversionRate,
|
|
2168
|
+
invertConversionRate
|
|
2169
|
+
} = _ref2;
|
|
2081
2170
|
if (fromCurrency !== toCurrency && !conversionRate) {
|
|
2082
2171
|
return 0;
|
|
2083
2172
|
}
|
|
@@ -2106,7 +2195,8 @@ const getBigNumber = (value, base) => {
|
|
|
2106
2195
|
}
|
|
2107
2196
|
return new (external_bignumber_js_default())(String(value), base);
|
|
2108
2197
|
};
|
|
2109
|
-
const addCurrencies = (a, b
|
|
2198
|
+
const addCurrencies = function (a, b) {
|
|
2199
|
+
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
2110
2200
|
const {
|
|
2111
2201
|
aBase,
|
|
2112
2202
|
bBase
|
|
@@ -2120,7 +2210,8 @@ const addCurrencies = (a, b, options = {}) => {
|
|
|
2120
2210
|
value
|
|
2121
2211
|
}, conversionOptions));
|
|
2122
2212
|
};
|
|
2123
|
-
const subtractCurrencies = (a, b
|
|
2213
|
+
const subtractCurrencies = function (a, b) {
|
|
2214
|
+
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
2124
2215
|
const {
|
|
2125
2216
|
aBase,
|
|
2126
2217
|
bBase
|
|
@@ -2134,7 +2225,8 @@ const subtractCurrencies = (a, b, options = {}) => {
|
|
|
2134
2225
|
value
|
|
2135
2226
|
}, conversionOptions));
|
|
2136
2227
|
};
|
|
2137
|
-
const multiplyCurrencies = (a, b
|
|
2228
|
+
const multiplyCurrencies = function (a, b) {
|
|
2229
|
+
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
2138
2230
|
const {
|
|
2139
2231
|
multiplicandBase,
|
|
2140
2232
|
multiplierBase
|
|
@@ -2148,41 +2240,44 @@ const multiplyCurrencies = (a, b, options = {}) => {
|
|
|
2148
2240
|
value
|
|
2149
2241
|
}, conversionOptions));
|
|
2150
2242
|
};
|
|
2151
|
-
const conversionGreaterThan = (
|
|
2152
|
-
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2153
|
-
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2243
|
+
const conversionGreaterThan = (_ref3, _ref4) => {
|
|
2244
|
+
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref4), _ref4));
|
|
2245
|
+
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref3), _ref3));
|
|
2154
2246
|
const firstValue = converter(objectSpread2_default()({}, firstProps));
|
|
2155
2247
|
const secondValue = converter(objectSpread2_default()({}, secondProps));
|
|
2156
2248
|
return firstValue.gt(secondValue);
|
|
2157
2249
|
};
|
|
2158
|
-
const conversionLessThan = (
|
|
2159
|
-
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2160
|
-
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2250
|
+
const conversionLessThan = (_ref5, _ref6) => {
|
|
2251
|
+
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref6), _ref6));
|
|
2252
|
+
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref5), _ref5));
|
|
2161
2253
|
const firstValue = converter(objectSpread2_default()({}, firstProps));
|
|
2162
2254
|
const secondValue = converter(objectSpread2_default()({}, secondProps));
|
|
2163
2255
|
return firstValue.lt(secondValue);
|
|
2164
2256
|
};
|
|
2165
|
-
const conversionMax = (
|
|
2166
|
-
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2167
|
-
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2257
|
+
const conversionMax = (_ref7, _ref8) => {
|
|
2258
|
+
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref8), _ref8));
|
|
2259
|
+
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref7), _ref7));
|
|
2168
2260
|
const firstIsGreater = conversionGreaterThan(objectSpread2_default()({}, firstProps), objectSpread2_default()({}, secondProps));
|
|
2169
2261
|
return firstIsGreater ? firstProps.value : secondProps.value;
|
|
2170
2262
|
};
|
|
2171
|
-
const conversionGTE = (
|
|
2172
|
-
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2173
|
-
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2263
|
+
const conversionGTE = (_ref9, _ref10) => {
|
|
2264
|
+
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref10), _ref10));
|
|
2265
|
+
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref9), _ref9));
|
|
2174
2266
|
const firstValue = converter(objectSpread2_default()({}, firstProps));
|
|
2175
2267
|
const secondValue = converter(objectSpread2_default()({}, secondProps));
|
|
2176
2268
|
return firstValue.isGreaterThanOrEqualTo(secondValue);
|
|
2177
2269
|
};
|
|
2178
|
-
const conversionLTE = (
|
|
2179
|
-
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2180
|
-
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2270
|
+
const conversionLTE = (_ref11, _ref12) => {
|
|
2271
|
+
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref12), _ref12));
|
|
2272
|
+
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref11), _ref11));
|
|
2181
2273
|
const firstValue = converter(objectSpread2_default()({}, firstProps));
|
|
2182
2274
|
const secondValue = converter(objectSpread2_default()({}, secondProps));
|
|
2183
2275
|
return firstValue.isLessThanOrEqualTo(secondValue);
|
|
2184
2276
|
};
|
|
2185
|
-
const toNegative = (n
|
|
2277
|
+
const toNegative = function (n) {
|
|
2278
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2279
|
+
return multiplyCurrencies(n, -1, options);
|
|
2280
|
+
};
|
|
2186
2281
|
const decGWEIToHexWEI = decGWEI => {
|
|
2187
2282
|
return conversionUtil(decGWEI, {
|
|
2188
2283
|
fromNumericBase: "dec",
|
|
@@ -2346,27 +2441,27 @@ function calculateTimeEstimate(maxPriorityFeePerGas, maxFeePerGas, gasFeeEstimat
|
|
|
2346
2441
|
|
|
2347
2442
|
|
|
2348
2443
|
|
|
2349
|
-
|
|
2350
2444
|
const GAS_FEE_API = "https://mock-gas-server.herokuapp.com/";
|
|
2351
2445
|
const LEGACY_GAS_PRICES_API_URL = "https://api.metaswap.codefi.network/gasPrices";
|
|
2352
2446
|
/**
|
|
2353
2447
|
* Returns gas prices in dec gwei
|
|
2354
2448
|
*/
|
|
2355
2449
|
class GasFeeController extends base_controllers_namespaceObject.BaseController {
|
|
2356
|
-
constructor({
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2450
|
+
constructor(_ref) {
|
|
2451
|
+
let {
|
|
2452
|
+
config,
|
|
2453
|
+
state,
|
|
2454
|
+
getNetworkIdentifier,
|
|
2455
|
+
getProvider,
|
|
2456
|
+
fetchGasEstimates = gasUtil_fetchGasEstimates,
|
|
2457
|
+
fetchEthGasPriceEstimate = gasUtil_fetchEthGasPriceEstimate,
|
|
2458
|
+
fetchLegacyGasPriceEstimates = gasUtil_fetchLegacyGasPriceEstimates,
|
|
2459
|
+
fetchGasEstimatesViaEthFeeHistory = gasUtil_fetchGasEstimatesViaEthFeeHistory,
|
|
2460
|
+
getCurrentNetworkLegacyGasAPICompatibility,
|
|
2461
|
+
getCurrentNetworkEIP1559Compatibility,
|
|
2462
|
+
getCurrentAccountEIP1559Compatibility,
|
|
2463
|
+
onNetworkStateChange
|
|
2464
|
+
} = _ref;
|
|
2370
2465
|
super({
|
|
2371
2466
|
config,
|
|
2372
2467
|
state
|
|
@@ -2472,7 +2567,7 @@ class GasFeeController extends base_controllers_namespaceObject.BaseController {
|
|
|
2472
2567
|
external_loglevel_default().warn(error);
|
|
2473
2568
|
isEIP1559Compatible = false;
|
|
2474
2569
|
}
|
|
2475
|
-
let newState = (0,
|
|
2570
|
+
let newState = (0,base_controllers_namespaceObject.cloneDeep)(this.defaultState);
|
|
2476
2571
|
try {
|
|
2477
2572
|
if (isEIP1559Compatible) {
|
|
2478
2573
|
let estimates;
|
|
@@ -2534,7 +2629,7 @@ class GasFeeController extends base_controllers_namespaceObject.BaseController {
|
|
|
2534
2629
|
}, this.config.interval);
|
|
2535
2630
|
}
|
|
2536
2631
|
resetState() {
|
|
2537
|
-
this.update((0,
|
|
2632
|
+
this.update((0,base_controllers_namespaceObject.cloneDeep)(this.defaultState));
|
|
2538
2633
|
}
|
|
2539
2634
|
async getEIP1559Compatibility() {
|
|
2540
2635
|
var _this$getCurrentAccou, _this$getCurrentAccou2;
|
|
@@ -2556,10 +2651,11 @@ const eth_sig_util_namespaceObject = require("@metamask/eth-sig-util");
|
|
|
2556
2651
|
|
|
2557
2652
|
|
|
2558
2653
|
class KeyringController extends base_controllers_namespaceObject.BaseKeyringController {
|
|
2559
|
-
constructor({
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2654
|
+
constructor(_ref) {
|
|
2655
|
+
let {
|
|
2656
|
+
config,
|
|
2657
|
+
state
|
|
2658
|
+
} = _ref;
|
|
2563
2659
|
super({
|
|
2564
2660
|
config,
|
|
2565
2661
|
state
|
|
@@ -2669,11 +2765,12 @@ class AbstractMessageController extends base_controllers_namespaceObject.BaseCon
|
|
|
2669
2765
|
* Controller in charge of managing - storing, adding, removing, updating - Messages.
|
|
2670
2766
|
*
|
|
2671
2767
|
*/
|
|
2672
|
-
constructor({
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2768
|
+
constructor(_ref) {
|
|
2769
|
+
let {
|
|
2770
|
+
config,
|
|
2771
|
+
state,
|
|
2772
|
+
getNetworkIdentifier
|
|
2773
|
+
} = _ref;
|
|
2677
2774
|
super({
|
|
2678
2775
|
config,
|
|
2679
2776
|
state
|
|
@@ -2733,15 +2830,15 @@ class AbstractMessageController extends base_controllers_namespaceObject.BaseCon
|
|
|
2733
2830
|
return new Promise((resolve, reject) => {
|
|
2734
2831
|
const handleFinished = msg => {
|
|
2735
2832
|
if (msg.status === MessageStatus.REJECTED) {
|
|
2736
|
-
return reject(
|
|
2833
|
+
return reject(openlogin_jrpc_namespaceObject.providerErrors.userRejectedRequest(`${messageName} Signature: User denied message signature`));
|
|
2737
2834
|
}
|
|
2738
2835
|
if (msg.status === MessageStatus.FAILED) {
|
|
2739
|
-
return reject(
|
|
2836
|
+
return reject(openlogin_jrpc_namespaceObject.rpcErrors.internal(`${messageName} Signature: failed to sign message ${msg.error}`));
|
|
2740
2837
|
}
|
|
2741
2838
|
if (msg.status === MessageStatus.SIGNED) {
|
|
2742
2839
|
return resolve(msg.rawSig);
|
|
2743
2840
|
}
|
|
2744
|
-
return reject(
|
|
2841
|
+
return reject(openlogin_jrpc_namespaceObject.rpcErrors.internal(`${messageName} Signature: Unknown problem: ${JSON.stringify(msgParams)}`));
|
|
2745
2842
|
};
|
|
2746
2843
|
this.once(`${msgParams.id}:finished`, handleFinished);
|
|
2747
2844
|
});
|
|
@@ -2762,13 +2859,10 @@ class AbstractMessageController extends base_controllers_namespaceObject.BaseCon
|
|
|
2762
2859
|
});
|
|
2763
2860
|
}
|
|
2764
2861
|
}
|
|
2765
|
-
;// CONCATENATED MODULE: external "jsonschema"
|
|
2766
|
-
const external_jsonschema_namespaceObject = require("jsonschema");
|
|
2767
2862
|
;// CONCATENATED MODULE: ./src/Message/utils.ts
|
|
2768
2863
|
|
|
2769
2864
|
|
|
2770
2865
|
|
|
2771
|
-
|
|
2772
2866
|
const hexRe = /^[0-9A-Fa-f]+$/gu;
|
|
2773
2867
|
function validateAddress(address, propertyName) {
|
|
2774
2868
|
if (!address || typeof address !== "string" || !(0,util_namespaceObject.isValidAddress)(address)) {
|
|
@@ -2806,7 +2900,7 @@ function validateTypedSignMessageDataV1(messageData) {
|
|
|
2806
2900
|
throw new Error(`Expected EIP712 typed data.`);
|
|
2807
2901
|
}
|
|
2808
2902
|
}
|
|
2809
|
-
function validateTypedSignMessageDataV3V4(messageData, currentChainId) {
|
|
2903
|
+
async function validateTypedSignMessageDataV3V4(messageData, currentChainId) {
|
|
2810
2904
|
validateAddress(messageData.from, "from");
|
|
2811
2905
|
if (!messageData.data || Array.isArray(messageData.data) || typeof messageData.data !== "object" && typeof messageData.data !== "string") {
|
|
2812
2906
|
throw new Error(`Invalid message "data": Must be a valid string or object.`);
|
|
@@ -2821,7 +2915,10 @@ function validateTypedSignMessageDataV3V4(messageData, currentChainId) {
|
|
|
2821
2915
|
throw new Error("Data must be passed as a valid JSON string.");
|
|
2822
2916
|
}
|
|
2823
2917
|
}
|
|
2824
|
-
const
|
|
2918
|
+
const {
|
|
2919
|
+
validate
|
|
2920
|
+
} = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 731, 23));
|
|
2921
|
+
const validation = validate(data, eth_sig_util_namespaceObject.TYPED_MESSAGE_SCHEMA);
|
|
2825
2922
|
if (validation.errors.length > 0) {
|
|
2826
2923
|
throw new Error("Data must conform to EIP-712 schema. See https://git.io/fNtcx.");
|
|
2827
2924
|
}
|
|
@@ -2911,12 +3008,13 @@ function validateSwitchChainData(data) {
|
|
|
2911
3008
|
|
|
2912
3009
|
|
|
2913
3010
|
class AddChainController extends AbstractMessageController {
|
|
2914
|
-
constructor({
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
3011
|
+
constructor(_ref) {
|
|
3012
|
+
let {
|
|
3013
|
+
config,
|
|
3014
|
+
state,
|
|
3015
|
+
getNetworkIdentifier,
|
|
3016
|
+
addChain
|
|
3017
|
+
} = _ref;
|
|
2920
3018
|
super({
|
|
2921
3019
|
config,
|
|
2922
3020
|
state,
|
|
@@ -2981,12 +3079,13 @@ class AddChainController extends AbstractMessageController {
|
|
|
2981
3079
|
|
|
2982
3080
|
|
|
2983
3081
|
class DecryptMessageController extends AbstractMessageController {
|
|
2984
|
-
constructor({
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
3082
|
+
constructor(_ref) {
|
|
3083
|
+
let {
|
|
3084
|
+
config,
|
|
3085
|
+
state,
|
|
3086
|
+
decryptMessage,
|
|
3087
|
+
getNetworkIdentifier
|
|
3088
|
+
} = _ref;
|
|
2990
3089
|
super({
|
|
2991
3090
|
config,
|
|
2992
3091
|
state,
|
|
@@ -3053,12 +3152,13 @@ class DecryptMessageController extends AbstractMessageController {
|
|
|
3053
3152
|
|
|
3054
3153
|
|
|
3055
3154
|
class EncryptionPublicKeyController extends AbstractMessageController {
|
|
3056
|
-
constructor({
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3155
|
+
constructor(_ref) {
|
|
3156
|
+
let {
|
|
3157
|
+
config,
|
|
3158
|
+
state,
|
|
3159
|
+
signEncryptionPublicKey,
|
|
3160
|
+
getNetworkIdentifier
|
|
3161
|
+
} = _ref;
|
|
3062
3162
|
super({
|
|
3063
3163
|
config,
|
|
3064
3164
|
state,
|
|
@@ -3125,12 +3225,13 @@ class EncryptionPublicKeyController extends AbstractMessageController {
|
|
|
3125
3225
|
|
|
3126
3226
|
|
|
3127
3227
|
class MessageController extends AbstractMessageController {
|
|
3128
|
-
constructor({
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3228
|
+
constructor(_ref) {
|
|
3229
|
+
let {
|
|
3230
|
+
config,
|
|
3231
|
+
state,
|
|
3232
|
+
signMessage,
|
|
3233
|
+
getNetworkIdentifier
|
|
3234
|
+
} = _ref;
|
|
3134
3235
|
super({
|
|
3135
3236
|
config,
|
|
3136
3237
|
state,
|
|
@@ -3195,12 +3296,13 @@ class MessageController extends AbstractMessageController {
|
|
|
3195
3296
|
|
|
3196
3297
|
|
|
3197
3298
|
class PersonalMessageController extends AbstractMessageController {
|
|
3198
|
-
constructor({
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3299
|
+
constructor(_ref) {
|
|
3300
|
+
let {
|
|
3301
|
+
config,
|
|
3302
|
+
state,
|
|
3303
|
+
signPersonalMessage,
|
|
3304
|
+
getNetworkIdentifier
|
|
3305
|
+
} = _ref;
|
|
3204
3306
|
super({
|
|
3205
3307
|
config,
|
|
3206
3308
|
state,
|
|
@@ -3265,12 +3367,13 @@ class PersonalMessageController extends AbstractMessageController {
|
|
|
3265
3367
|
|
|
3266
3368
|
|
|
3267
3369
|
class SwitchChainController extends AbstractMessageController {
|
|
3268
|
-
constructor({
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3370
|
+
constructor(_ref) {
|
|
3371
|
+
let {
|
|
3372
|
+
config,
|
|
3373
|
+
state,
|
|
3374
|
+
getNetworkIdentifier,
|
|
3375
|
+
switchChain
|
|
3376
|
+
} = _ref;
|
|
3274
3377
|
super({
|
|
3275
3378
|
config,
|
|
3276
3379
|
state,
|
|
@@ -3349,12 +3452,13 @@ function getMessageType(version) {
|
|
|
3349
3452
|
}
|
|
3350
3453
|
}
|
|
3351
3454
|
class TypedMessageController extends AbstractMessageController {
|
|
3352
|
-
constructor({
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3455
|
+
constructor(_ref) {
|
|
3456
|
+
let {
|
|
3457
|
+
config,
|
|
3458
|
+
state,
|
|
3459
|
+
signTypedData,
|
|
3460
|
+
getNetworkIdentifier
|
|
3461
|
+
} = _ref;
|
|
3358
3462
|
super({
|
|
3359
3463
|
config,
|
|
3360
3464
|
state,
|
|
@@ -3392,7 +3496,7 @@ class TypedMessageController extends AbstractMessageController {
|
|
|
3392
3496
|
}
|
|
3393
3497
|
if (version === eth_sig_util_namespaceObject.SignTypedDataVersion.V3 || version === eth_sig_util_namespaceObject.SignTypedDataVersion.V4) {
|
|
3394
3498
|
const currentChainId = this.getNetworkIdentifier();
|
|
3395
|
-
validateTypedSignMessageDataV3V4(messageParams, currentChainId);
|
|
3499
|
+
await validateTypedSignMessageDataV3V4(messageParams, currentChainId);
|
|
3396
3500
|
}
|
|
3397
3501
|
if (typeof messageParams.data !== "string" && (version === eth_sig_util_namespaceObject.SignTypedDataVersion.V3 || version === eth_sig_util_namespaceObject.SignTypedDataVersion.V4)) {
|
|
3398
3502
|
messageParams.data = JSON.stringify(messageParams.data);
|
|
@@ -3420,16 +3524,15 @@ class TypedMessageController extends AbstractMessageController {
|
|
|
3420
3524
|
return Promise.resolve(messageParams);
|
|
3421
3525
|
}
|
|
3422
3526
|
}
|
|
3423
|
-
;// CONCATENATED MODULE: external "@toruslabs/openlogin-jrpc"
|
|
3424
|
-
const openlogin_jrpc_namespaceObject = require("@toruslabs/openlogin-jrpc");
|
|
3425
3527
|
;// CONCATENATED MODULE: ./src/Network/createEthereumMiddleware.ts
|
|
3426
3528
|
|
|
3427
3529
|
|
|
3428
3530
|
|
|
3429
3531
|
|
|
3430
|
-
function createGetAccountsMiddleware({
|
|
3431
|
-
|
|
3432
|
-
|
|
3532
|
+
function createGetAccountsMiddleware(_ref) {
|
|
3533
|
+
let {
|
|
3534
|
+
getAccounts
|
|
3535
|
+
} = _ref;
|
|
3433
3536
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3434
3537
|
const {
|
|
3435
3538
|
method
|
|
@@ -3440,9 +3543,10 @@ function createGetAccountsMiddleware({
|
|
|
3440
3543
|
response.result = accounts;
|
|
3441
3544
|
});
|
|
3442
3545
|
}
|
|
3443
|
-
function createProcessTransactionMiddleware({
|
|
3444
|
-
|
|
3445
|
-
|
|
3546
|
+
function createProcessTransactionMiddleware(_ref2) {
|
|
3547
|
+
let {
|
|
3548
|
+
processTransaction
|
|
3549
|
+
} = _ref2;
|
|
3446
3550
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3447
3551
|
const {
|
|
3448
3552
|
method
|
|
@@ -3452,9 +3556,10 @@ function createProcessTransactionMiddleware({
|
|
|
3452
3556
|
response.result = await processTransaction(request.params, request);
|
|
3453
3557
|
});
|
|
3454
3558
|
}
|
|
3455
|
-
function createProcessEthSignMessage({
|
|
3456
|
-
|
|
3457
|
-
|
|
3559
|
+
function createProcessEthSignMessage(_ref3) {
|
|
3560
|
+
let {
|
|
3561
|
+
processEthSignMessage
|
|
3562
|
+
} = _ref3;
|
|
3458
3563
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3459
3564
|
const {
|
|
3460
3565
|
method
|
|
@@ -3476,9 +3581,10 @@ function createProcessEthSignMessage({
|
|
|
3476
3581
|
response.result = await processEthSignMessage(msgParams, request);
|
|
3477
3582
|
});
|
|
3478
3583
|
}
|
|
3479
|
-
function createProcessTypedMessage({
|
|
3480
|
-
|
|
3481
|
-
|
|
3584
|
+
function createProcessTypedMessage(_ref4) {
|
|
3585
|
+
let {
|
|
3586
|
+
processTypedMessage
|
|
3587
|
+
} = _ref4;
|
|
3482
3588
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3483
3589
|
const {
|
|
3484
3590
|
method
|
|
@@ -3501,9 +3607,10 @@ function createProcessTypedMessage({
|
|
|
3501
3607
|
response.result = await processTypedMessage(msgParams, request);
|
|
3502
3608
|
});
|
|
3503
3609
|
}
|
|
3504
|
-
function createProcessTypedMessageV3({
|
|
3505
|
-
|
|
3506
|
-
|
|
3610
|
+
function createProcessTypedMessageV3(_ref5) {
|
|
3611
|
+
let {
|
|
3612
|
+
processTypedMessageV3
|
|
3613
|
+
} = _ref5;
|
|
3507
3614
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3508
3615
|
const {
|
|
3509
3616
|
method
|
|
@@ -3526,9 +3633,10 @@ function createProcessTypedMessageV3({
|
|
|
3526
3633
|
response.result = await processTypedMessageV3(msgParams, request);
|
|
3527
3634
|
});
|
|
3528
3635
|
}
|
|
3529
|
-
function createProcessTypedMessageV4({
|
|
3530
|
-
|
|
3531
|
-
|
|
3636
|
+
function createProcessTypedMessageV4(_ref6) {
|
|
3637
|
+
let {
|
|
3638
|
+
processTypedMessageV4
|
|
3639
|
+
} = _ref6;
|
|
3532
3640
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3533
3641
|
const {
|
|
3534
3642
|
method
|
|
@@ -3551,9 +3659,10 @@ function createProcessTypedMessageV4({
|
|
|
3551
3659
|
response.result = await processTypedMessageV4(msgParams, request);
|
|
3552
3660
|
});
|
|
3553
3661
|
}
|
|
3554
|
-
function createProcessPersonalMessage({
|
|
3555
|
-
|
|
3556
|
-
|
|
3662
|
+
function createProcessPersonalMessage(_ref7) {
|
|
3663
|
+
let {
|
|
3664
|
+
processPersonalMessage
|
|
3665
|
+
} = _ref7;
|
|
3557
3666
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3558
3667
|
const {
|
|
3559
3668
|
method
|
|
@@ -3586,9 +3695,10 @@ function createProcessPersonalMessage({
|
|
|
3586
3695
|
response.result = await processPersonalMessage(msgParams, request);
|
|
3587
3696
|
});
|
|
3588
3697
|
}
|
|
3589
|
-
function createPendingNonceMiddleware({
|
|
3590
|
-
|
|
3591
|
-
|
|
3698
|
+
function createPendingNonceMiddleware(_ref8) {
|
|
3699
|
+
let {
|
|
3700
|
+
getPendingNonce
|
|
3701
|
+
} = _ref8;
|
|
3592
3702
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3593
3703
|
const {
|
|
3594
3704
|
params,
|
|
@@ -3650,9 +3760,10 @@ function formatTxMetaForRpcResult(txMeta) {
|
|
|
3650
3760
|
}
|
|
3651
3761
|
return formattedTxMeta;
|
|
3652
3762
|
}
|
|
3653
|
-
function createPendingTxMiddleware({
|
|
3654
|
-
|
|
3655
|
-
|
|
3763
|
+
function createPendingTxMiddleware(_ref9) {
|
|
3764
|
+
let {
|
|
3765
|
+
getPendingTransactionByHash
|
|
3766
|
+
} = _ref9;
|
|
3656
3767
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3657
3768
|
const {
|
|
3658
3769
|
params,
|
|
@@ -3668,9 +3779,10 @@ function createPendingTxMiddleware({
|
|
|
3668
3779
|
return undefined;
|
|
3669
3780
|
});
|
|
3670
3781
|
}
|
|
3671
|
-
function createProcessEncryptionPublicKeyMiddleware({
|
|
3672
|
-
|
|
3673
|
-
|
|
3782
|
+
function createProcessEncryptionPublicKeyMiddleware(_ref10) {
|
|
3783
|
+
let {
|
|
3784
|
+
processEncryptionPublicKey
|
|
3785
|
+
} = _ref10;
|
|
3674
3786
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3675
3787
|
const {
|
|
3676
3788
|
method
|
|
@@ -3690,9 +3802,10 @@ function createProcessEncryptionPublicKeyMiddleware({
|
|
|
3690
3802
|
response.result = await processEncryptionPublicKey(msgParams, request);
|
|
3691
3803
|
});
|
|
3692
3804
|
}
|
|
3693
|
-
function createProcessDecryptMessageMiddleware({
|
|
3694
|
-
|
|
3695
|
-
|
|
3805
|
+
function createProcessDecryptMessageMiddleware(_ref11) {
|
|
3806
|
+
let {
|
|
3807
|
+
processDecryptMessage
|
|
3808
|
+
} = _ref11;
|
|
3696
3809
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3697
3810
|
const {
|
|
3698
3811
|
method
|
|
@@ -3712,9 +3825,10 @@ function createProcessDecryptMessageMiddleware({
|
|
|
3712
3825
|
response.result = await processDecryptMessage(msgParams, request);
|
|
3713
3826
|
});
|
|
3714
3827
|
}
|
|
3715
|
-
function createProcessSwitchEthereumChain({
|
|
3716
|
-
|
|
3717
|
-
|
|
3828
|
+
function createProcessSwitchEthereumChain(_ref12) {
|
|
3829
|
+
let {
|
|
3830
|
+
processSwitchEthereumChain
|
|
3831
|
+
} = _ref12;
|
|
3718
3832
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3719
3833
|
const {
|
|
3720
3834
|
method
|
|
@@ -3731,9 +3845,10 @@ function createProcessSwitchEthereumChain({
|
|
|
3731
3845
|
response.result = await processSwitchEthereumChain(msgParams, request);
|
|
3732
3846
|
});
|
|
3733
3847
|
}
|
|
3734
|
-
function createProcessAddEthereumChain({
|
|
3735
|
-
|
|
3736
|
-
|
|
3848
|
+
function createProcessAddEthereumChain(_ref13) {
|
|
3849
|
+
let {
|
|
3850
|
+
processAddEthereumChain
|
|
3851
|
+
} = _ref13;
|
|
3737
3852
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3738
3853
|
const {
|
|
3739
3854
|
method
|
|
@@ -3750,9 +3865,10 @@ function createProcessAddEthereumChain({
|
|
|
3750
3865
|
response.result = await processAddEthereumChain(msgParams, request);
|
|
3751
3866
|
});
|
|
3752
3867
|
}
|
|
3753
|
-
function createRequestAccountsMiddleware({
|
|
3754
|
-
|
|
3755
|
-
|
|
3868
|
+
function createRequestAccountsMiddleware(_ref14) {
|
|
3869
|
+
let {
|
|
3870
|
+
requestAccounts
|
|
3871
|
+
} = _ref14;
|
|
3756
3872
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3757
3873
|
const {
|
|
3758
3874
|
method
|
|
@@ -3996,10 +4112,11 @@ const NetworkController_excluded = ["chainId", "rpcTarget"];
|
|
|
3996
4112
|
|
|
3997
4113
|
|
|
3998
4114
|
class NetworkController extends base_controllers_namespaceObject.BaseController {
|
|
3999
|
-
constructor({
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4115
|
+
constructor(_ref) {
|
|
4116
|
+
let {
|
|
4117
|
+
config,
|
|
4118
|
+
state
|
|
4119
|
+
} = _ref;
|
|
4003
4120
|
super({
|
|
4004
4121
|
config,
|
|
4005
4122
|
state
|
|
@@ -4126,10 +4243,11 @@ class NetworkController extends base_controllers_namespaceObject.BaseController
|
|
|
4126
4243
|
rpcTarget
|
|
4127
4244
|
}, rest));
|
|
4128
4245
|
}
|
|
4129
|
-
setNetworkClient({
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4246
|
+
setNetworkClient(_ref2) {
|
|
4247
|
+
let {
|
|
4248
|
+
networkMiddleware,
|
|
4249
|
+
blockTracker
|
|
4250
|
+
} = _ref2;
|
|
4133
4251
|
const ethereumMiddleware = createEthereumMiddleware(this.baseProviderHandlers);
|
|
4134
4252
|
const engine = new openlogin_jrpc_namespaceObject.JRPCEngine();
|
|
4135
4253
|
engine.push(ethereumMiddleware);
|
|
@@ -4140,10 +4258,11 @@ class NetworkController extends base_controllers_namespaceObject.BaseController
|
|
|
4140
4258
|
blockTracker
|
|
4141
4259
|
});
|
|
4142
4260
|
}
|
|
4143
|
-
setProvider({
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4261
|
+
setProvider(_ref3) {
|
|
4262
|
+
let {
|
|
4263
|
+
provider,
|
|
4264
|
+
blockTracker
|
|
4265
|
+
} = _ref3;
|
|
4147
4266
|
if (this.providerProxy) {
|
|
4148
4267
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
4149
4268
|
// @ts-ignore
|
|
@@ -4190,18 +4309,19 @@ class NetworkController extends base_controllers_namespaceObject.BaseController
|
|
|
4190
4309
|
|
|
4191
4310
|
|
|
4192
4311
|
class NftHandler {
|
|
4193
|
-
constructor({
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4312
|
+
constructor(_ref) {
|
|
4313
|
+
let {
|
|
4314
|
+
chainId,
|
|
4315
|
+
contractAddress,
|
|
4316
|
+
contractImage,
|
|
4317
|
+
contractName,
|
|
4318
|
+
contractSymbol,
|
|
4319
|
+
nftStandard,
|
|
4320
|
+
provider,
|
|
4321
|
+
contractDescription,
|
|
4322
|
+
contractFallbackLogo,
|
|
4323
|
+
contractSupply
|
|
4324
|
+
} = _ref;
|
|
4205
4325
|
defineProperty_default()(this, "contractAddress", void 0);
|
|
4206
4326
|
defineProperty_default()(this, "contractName", void 0);
|
|
4207
4327
|
defineProperty_default()(this, "contractSymbol", void 0);
|
|
@@ -4349,13 +4469,17 @@ class NftHandler {
|
|
|
4349
4469
|
const contract = new external_ethers_namespaceObject.Contract(this.contractAddress, abi, this.provider);
|
|
4350
4470
|
return contract.supportsInterface(interfaceId);
|
|
4351
4471
|
}
|
|
4352
|
-
async getCollectibleTokenURI(tokenId
|
|
4472
|
+
async getCollectibleTokenURI(tokenId) {
|
|
4473
|
+
let standard = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : CONTRACT_TYPE_ERC721;
|
|
4353
4474
|
const method = standard === CONTRACT_TYPE_ERC721 ? "tokenURI" : "uri";
|
|
4354
4475
|
const abi = standard === CONTRACT_TYPE_ERC721 ? erc721Abi : erc1155Abi;
|
|
4355
4476
|
const contract = new external_ethers_namespaceObject.Contract(this.contractAddress, abi, this.provider);
|
|
4356
4477
|
return contract[method](tokenId);
|
|
4357
4478
|
}
|
|
4358
4479
|
}
|
|
4480
|
+
;// CONCATENATED MODULE: external "deepmerge"
|
|
4481
|
+
const external_deepmerge_namespaceObject = require("deepmerge");
|
|
4482
|
+
var external_deepmerge_default = /*#__PURE__*/__webpack_require__.n(external_deepmerge_namespaceObject);
|
|
4359
4483
|
;// CONCATENATED MODULE: ./src/Nfts/NftsController.ts
|
|
4360
4484
|
|
|
4361
4485
|
|
|
@@ -4368,15 +4492,16 @@ class NftHandler {
|
|
|
4368
4492
|
|
|
4369
4493
|
const DEFAULT_INTERVAL = 180 * 1000;
|
|
4370
4494
|
class NftsController extends base_controllers_namespaceObject.BaseController {
|
|
4371
|
-
constructor({
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4495
|
+
constructor(_ref) {
|
|
4496
|
+
let {
|
|
4497
|
+
config,
|
|
4498
|
+
state,
|
|
4499
|
+
provider,
|
|
4500
|
+
getCustomNfts,
|
|
4501
|
+
getSimpleHashNfts,
|
|
4502
|
+
onPreferencesStateChange,
|
|
4503
|
+
onNetworkStateChange
|
|
4504
|
+
} = _ref;
|
|
4380
4505
|
super({
|
|
4381
4506
|
config,
|
|
4382
4507
|
state
|
|
@@ -4560,7 +4685,7 @@ class NftsController extends base_controllers_namespaceObject.BaseController {
|
|
|
4560
4685
|
const nonZeroTokens = promiseSettledResult.filter(x => x.status === "fulfilled").map(x => x.value);
|
|
4561
4686
|
this.update({
|
|
4562
4687
|
nfts: {
|
|
4563
|
-
[userAddress]: (
|
|
4688
|
+
[userAddress]: external_deepmerge_default()(this.userNfts, nonZeroTokens)
|
|
4564
4689
|
}
|
|
4565
4690
|
});
|
|
4566
4691
|
}
|
|
@@ -4574,15 +4699,16 @@ class NftsController extends base_controllers_namespaceObject.BaseController {
|
|
|
4574
4699
|
|
|
4575
4700
|
|
|
4576
4701
|
class PreferencesController extends base_controllers_namespaceObject.BasePreferencesController {
|
|
4577
|
-
constructor({
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4702
|
+
constructor(_ref) {
|
|
4703
|
+
let {
|
|
4704
|
+
config,
|
|
4705
|
+
state,
|
|
4706
|
+
provider,
|
|
4707
|
+
signAuthMessage,
|
|
4708
|
+
getProviderConfig,
|
|
4709
|
+
setProviderConfig,
|
|
4710
|
+
validateSignMessage
|
|
4711
|
+
} = _ref;
|
|
4586
4712
|
super({
|
|
4587
4713
|
config,
|
|
4588
4714
|
state,
|
|
@@ -4862,9 +4988,10 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
|
|
|
4862
4988
|
}
|
|
4863
4989
|
|
|
4864
4990
|
// Custom Network methods
|
|
4865
|
-
async addCustomNetwork({
|
|
4866
|
-
|
|
4867
|
-
|
|
4991
|
+
async addCustomNetwork(_ref2) {
|
|
4992
|
+
let {
|
|
4993
|
+
network
|
|
4994
|
+
} = _ref2;
|
|
4868
4995
|
try {
|
|
4869
4996
|
const {
|
|
4870
4997
|
selectedAddress
|
|
@@ -4904,10 +5031,11 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
|
|
|
4904
5031
|
return false;
|
|
4905
5032
|
}
|
|
4906
5033
|
}
|
|
4907
|
-
async editCustomNetwork({
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
5034
|
+
async editCustomNetwork(_ref3) {
|
|
5035
|
+
let {
|
|
5036
|
+
network,
|
|
5037
|
+
id
|
|
5038
|
+
} = _ref3;
|
|
4911
5039
|
try {
|
|
4912
5040
|
const {
|
|
4913
5041
|
selectedAddress
|
|
@@ -4930,8 +5058,9 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
|
|
|
4930
5058
|
return false;
|
|
4931
5059
|
}
|
|
4932
5060
|
}
|
|
4933
|
-
getChainOptions(
|
|
5061
|
+
getChainOptions() {
|
|
4934
5062
|
var _identities$address$c, _identities$address;
|
|
5063
|
+
let address = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.state.selectedAddress;
|
|
4935
5064
|
const {
|
|
4936
5065
|
identities
|
|
4937
5066
|
} = this.state;
|
|
@@ -5041,15 +5170,15 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
|
|
|
5041
5170
|
|
|
5042
5171
|
|
|
5043
5172
|
|
|
5044
|
-
|
|
5045
5173
|
class TokenHandler {
|
|
5046
|
-
constructor({
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5174
|
+
constructor(_ref) {
|
|
5175
|
+
let {
|
|
5176
|
+
address,
|
|
5177
|
+
symbol,
|
|
5178
|
+
decimals,
|
|
5179
|
+
name,
|
|
5180
|
+
provider
|
|
5181
|
+
} = _ref;
|
|
5053
5182
|
defineProperty_default()(this, "address", void 0);
|
|
5054
5183
|
defineProperty_default()(this, "symbol", void 0);
|
|
5055
5184
|
defineProperty_default()(this, "decimals", void 0);
|
|
@@ -5081,7 +5210,7 @@ class TokenHandler {
|
|
|
5081
5210
|
async getUserBalance(userAddress) {
|
|
5082
5211
|
if (!this.decimals) await this.getDecimals();
|
|
5083
5212
|
const balance = await this.contract.balanceOf(userAddress);
|
|
5084
|
-
return
|
|
5213
|
+
return balance.toString(16);
|
|
5085
5214
|
}
|
|
5086
5215
|
}
|
|
5087
5216
|
;// CONCATENATED MODULE: ./src/Tokens/TokenRatesController.ts
|
|
@@ -5094,13 +5223,14 @@ class TokenHandler {
|
|
|
5094
5223
|
|
|
5095
5224
|
const DEFAULT_CURRENCY = "eth";
|
|
5096
5225
|
class TokenRatesController extends base_controllers_namespaceObject.BaseController {
|
|
5097
|
-
constructor({
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5226
|
+
constructor(_ref) {
|
|
5227
|
+
let {
|
|
5228
|
+
config,
|
|
5229
|
+
state,
|
|
5230
|
+
onPreferencesStateChange,
|
|
5231
|
+
onNetworkStateChange,
|
|
5232
|
+
onTokensStateChange
|
|
5233
|
+
} = _ref;
|
|
5104
5234
|
super({
|
|
5105
5235
|
config,
|
|
5106
5236
|
state
|
|
@@ -5221,16 +5351,17 @@ const mergeTokenArrays = (oldArray, newArray) => {
|
|
|
5221
5351
|
};
|
|
5222
5352
|
const TokensController_DEFAULT_INTERVAL = 180 * 1000;
|
|
5223
5353
|
class TokensController extends base_controllers_namespaceObject.BaseController {
|
|
5224
|
-
constructor({
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5354
|
+
constructor(_ref) {
|
|
5355
|
+
let {
|
|
5356
|
+
config,
|
|
5357
|
+
state,
|
|
5358
|
+
provider,
|
|
5359
|
+
getCustomTokens,
|
|
5360
|
+
getEtherScanTokens,
|
|
5361
|
+
getProviderConfig,
|
|
5362
|
+
onPreferencesStateChange,
|
|
5363
|
+
onNetworkStateChange
|
|
5364
|
+
} = _ref;
|
|
5234
5365
|
super({
|
|
5235
5366
|
config,
|
|
5236
5367
|
state
|
|
@@ -5453,12 +5584,13 @@ class TokensController extends base_controllers_namespaceObject.BaseController {
|
|
|
5453
5584
|
|
|
5454
5585
|
|
|
5455
5586
|
class NonceTracker {
|
|
5456
|
-
constructor({
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5587
|
+
constructor(_ref) {
|
|
5588
|
+
let {
|
|
5589
|
+
provider,
|
|
5590
|
+
blockTracker,
|
|
5591
|
+
getPendingTransactions,
|
|
5592
|
+
getConfirmedTransactions
|
|
5593
|
+
} = _ref;
|
|
5462
5594
|
defineProperty_default()(this, "provider", void 0);
|
|
5463
5595
|
defineProperty_default()(this, "blockTracker", void 0);
|
|
5464
5596
|
defineProperty_default()(this, "getPendingTransactions", void 0);
|
|
@@ -5602,14 +5734,15 @@ class NonceTracker {
|
|
|
5602
5734
|
|
|
5603
5735
|
|
|
5604
5736
|
class PendingTransactionTracker extends openlogin_jrpc_namespaceObject.SafeEventEmitter {
|
|
5605
|
-
constructor({
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5737
|
+
constructor(_ref) {
|
|
5738
|
+
let {
|
|
5739
|
+
provider,
|
|
5740
|
+
nonceTracker,
|
|
5741
|
+
approveTransaction,
|
|
5742
|
+
publishTransaction,
|
|
5743
|
+
getPendingTransactions,
|
|
5744
|
+
getConfirmedTransactions
|
|
5745
|
+
} = _ref;
|
|
5613
5746
|
super();
|
|
5614
5747
|
defineProperty_default()(this, "DROPPED_BUFFER_COUNT", 3);
|
|
5615
5748
|
defineProperty_default()(this, "nonceTracker", void 0);
|
|
@@ -5813,10 +5946,6 @@ class PendingTransactionTracker extends openlogin_jrpc_namespaceObject.SafeEvent
|
|
|
5813
5946
|
});
|
|
5814
5947
|
}
|
|
5815
5948
|
}
|
|
5816
|
-
;// CONCATENATED MODULE: external "@ethereumjs/common"
|
|
5817
|
-
const common_namespaceObject = require("@ethereumjs/common");
|
|
5818
|
-
;// CONCATENATED MODULE: external "@ethereumjs/tx"
|
|
5819
|
-
const tx_namespaceObject = require("@ethereumjs/tx");
|
|
5820
5949
|
;// CONCATENATED MODULE: ./src/Transaction/TransactionGasUtil.ts
|
|
5821
5950
|
|
|
5822
5951
|
|
|
@@ -5860,7 +5989,8 @@ class TransactionGasUtil {
|
|
|
5860
5989
|
/**
|
|
5861
5990
|
Adds a gas buffer with out exceeding the block gas limit
|
|
5862
5991
|
*/
|
|
5863
|
-
addGasBuffer(initialGasLimitHex, blockGasLimitHex
|
|
5992
|
+
addGasBuffer(initialGasLimitHex, blockGasLimitHex) {
|
|
5993
|
+
let multiplier = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1.5;
|
|
5864
5994
|
const initialGasLimitBn = new external_bn_js_namespaceObject.BN((0,util_namespaceObject.stripHexPrefix)(initialGasLimitHex), 16);
|
|
5865
5995
|
const blockGasLimitBn = new external_bn_js_namespaceObject.BN((0,util_namespaceObject.stripHexPrefix)(blockGasLimitHex), 16);
|
|
5866
5996
|
const upperGasLimitBn = blockGasLimitBn.muln(0.9);
|
|
@@ -5878,7 +6008,7 @@ class TransactionGasUtil {
|
|
|
5878
6008
|
Estimates the tx's gas usage
|
|
5879
6009
|
*/
|
|
5880
6010
|
async estimateTxGas(txMeta) {
|
|
5881
|
-
const txParams = (0,
|
|
6011
|
+
const txParams = (0,base_controllers_namespaceObject.cloneDeep)(txMeta.transaction);
|
|
5882
6012
|
|
|
5883
6013
|
// `eth_estimateGas` can fail if the user has insufficient balance for the
|
|
5884
6014
|
// value being sent, or for the gas cost. We don't want to check their
|
|
@@ -5894,6 +6024,29 @@ class TransactionGasUtil {
|
|
|
5894
6024
|
});
|
|
5895
6025
|
}
|
|
5896
6026
|
}
|
|
6027
|
+
;// CONCATENATED MODULE: ./src/utils/lodashUtils.ts
|
|
6028
|
+
function sortBy(arr, key) {
|
|
6029
|
+
return arr.slice().sort((a, b) => {
|
|
6030
|
+
if (a[key] < b[key]) return -1;
|
|
6031
|
+
if (a[key] > b[key]) return 1;
|
|
6032
|
+
return 0;
|
|
6033
|
+
});
|
|
6034
|
+
}
|
|
6035
|
+
function keyBy(arr, key) {
|
|
6036
|
+
return arr.reduce((acc, item) => {
|
|
6037
|
+
const keyValue = item[key];
|
|
6038
|
+
if (typeof keyValue === "string" || typeof keyValue === "number") {
|
|
6039
|
+
acc[keyValue.toString()] = item;
|
|
6040
|
+
}
|
|
6041
|
+
return acc;
|
|
6042
|
+
}, {});
|
|
6043
|
+
}
|
|
6044
|
+
function mapValues(obj, iteratee) {
|
|
6045
|
+
return Object.fromEntries(Object.entries(obj).map(_ref => {
|
|
6046
|
+
let [key, value] = _ref;
|
|
6047
|
+
return [key, iteratee(value, key)];
|
|
6048
|
+
}));
|
|
6049
|
+
}
|
|
5897
6050
|
;// CONCATENATED MODULE: external "fast-json-patch"
|
|
5898
6051
|
const external_fast_json_patch_namespaceObject = require("fast-json-patch");
|
|
5899
6052
|
var external_fast_json_patch_default = /*#__PURE__*/__webpack_require__.n(external_fast_json_patch_namespaceObject);
|
|
@@ -5925,13 +6078,13 @@ function generateHistoryEntry(previousState, newState, note) {
|
|
|
5925
6078
|
Recovers previous txMeta state obj
|
|
5926
6079
|
*/
|
|
5927
6080
|
function replayHistory(_shortHistory) {
|
|
5928
|
-
const shortHistory = (0,
|
|
6081
|
+
const shortHistory = (0,base_controllers_namespaceObject.cloneDeep)(_shortHistory);
|
|
5929
6082
|
return shortHistory.reduce((val, entry) => external_fast_json_patch_default().applyPatch(val, entry).newDocument);
|
|
5930
6083
|
}
|
|
5931
6084
|
function snapshotFromTxMeta(txMeta) {
|
|
5932
6085
|
const shallow = objectSpread2_default()({}, txMeta);
|
|
5933
6086
|
delete shallow.history;
|
|
5934
|
-
return (0,
|
|
6087
|
+
return (0,base_controllers_namespaceObject.cloneDeep)(shallow);
|
|
5935
6088
|
}
|
|
5936
6089
|
|
|
5937
6090
|
;// CONCATENATED MODULE: ./src/Transaction/TransactionStateManager.ts
|
|
@@ -5941,18 +6094,20 @@ function snapshotFromTxMeta(txMeta) {
|
|
|
5941
6094
|
|
|
5942
6095
|
|
|
5943
6096
|
class TransactionStateManager extends base_controllers_namespaceObject.BaseTransactionStateManager {
|
|
5944
|
-
constructor({
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
|
|
5948
|
-
|
|
6097
|
+
constructor(_ref) {
|
|
6098
|
+
let {
|
|
6099
|
+
config,
|
|
6100
|
+
state,
|
|
6101
|
+
getCurrentChainId
|
|
6102
|
+
} = _ref;
|
|
5949
6103
|
super({
|
|
5950
6104
|
config,
|
|
5951
6105
|
state,
|
|
5952
6106
|
getCurrentChainId
|
|
5953
6107
|
});
|
|
5954
6108
|
}
|
|
5955
|
-
generateTxMeta(
|
|
6109
|
+
generateTxMeta() {
|
|
6110
|
+
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
5956
6111
|
const chainId = this.getCurrentChainId();
|
|
5957
6112
|
if (chainId === "loading") throw new Error("Torus is having trouble connecting to the network");
|
|
5958
6113
|
let dappSuggestedGasFees = null;
|
|
@@ -6056,18 +6211,19 @@ class TransactionStateManager extends base_controllers_namespaceObject.BaseTrans
|
|
|
6056
6211
|
} = this.state;
|
|
6057
6212
|
const chainId = this.getCurrentChainId();
|
|
6058
6213
|
this.update({
|
|
6059
|
-
transactions: (0,
|
|
6214
|
+
transactions: (0,base_controllers_namespaceObject.omitBy)(transactions, txMeta => {
|
|
6060
6215
|
const transactionMatch = (0,base_controllers_namespaceObject.transactionMatchesNetwork)(txMeta, chainId);
|
|
6061
6216
|
return txMeta.transaction.from === address && transactionMatch;
|
|
6062
6217
|
})
|
|
6063
6218
|
});
|
|
6064
6219
|
}
|
|
6065
|
-
getTransactions({
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
|
|
6069
|
-
|
|
6070
|
-
|
|
6220
|
+
getTransactions() {
|
|
6221
|
+
let {
|
|
6222
|
+
searchCriteria = {},
|
|
6223
|
+
initialList = undefined,
|
|
6224
|
+
filterToCurrentNetwork = true,
|
|
6225
|
+
limit = undefined
|
|
6226
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
6071
6227
|
const chainId = this.getCurrentChainId();
|
|
6072
6228
|
// searchCriteria is an object that might have values that aren't predicate
|
|
6073
6229
|
// methods. When providing any other value type (string, number, etc), we
|
|
@@ -6075,17 +6231,17 @@ class TransactionStateManager extends base_controllers_namespaceObject.BaseTrans
|
|
|
6075
6231
|
// with the provided value". To conform this object to be only methods, we
|
|
6076
6232
|
// mapValues (lodash) such that every value on the object is a method that
|
|
6077
6233
|
// returns a boolean.
|
|
6078
|
-
const predicateMethods =
|
|
6234
|
+
const predicateMethods = mapValues(searchCriteria, predicate => typeof predicate === "function" ? predicate : v => v === predicate);
|
|
6079
6235
|
|
|
6080
6236
|
// If an initial list is provided we need to change it back into an object
|
|
6081
6237
|
// first, so that it matches the shape of our state. This is done by the
|
|
6082
6238
|
// lodash keyBy method. This is the edge case for this method, typically
|
|
6083
6239
|
// initialList will be undefined.
|
|
6084
|
-
const transactionsToFilter = initialList ?
|
|
6240
|
+
const transactionsToFilter = initialList ? keyBy(initialList, "id") : this.state.transactions;
|
|
6085
6241
|
|
|
6086
6242
|
// Combine sortBy and pickBy to transform our state object into an array of
|
|
6087
6243
|
// matching transactions that are sorted by time.
|
|
6088
|
-
const filteredTransactions = (
|
|
6244
|
+
const filteredTransactions = sortBy(Object.values((0,base_controllers_namespaceObject.pickBy)(transactionsToFilter, txMeta => {
|
|
6089
6245
|
// default matchesCriteria to the value of transactionMatchesNetwork
|
|
6090
6246
|
// when filterToCurrentNetwork is true.
|
|
6091
6247
|
const transactionMatches = (0,base_controllers_namespaceObject.transactionMatchesNetwork)(txMeta, chainId);
|
|
@@ -6109,7 +6265,7 @@ class TransactionStateManager extends base_controllers_namespaceObject.BaseTrans
|
|
|
6109
6265
|
}
|
|
6110
6266
|
}
|
|
6111
6267
|
return true;
|
|
6112
|
-
}), "time");
|
|
6268
|
+
})), "time");
|
|
6113
6269
|
if (limit !== undefined) {
|
|
6114
6270
|
// We need to have all transactions of a given nonce in order to display
|
|
6115
6271
|
// necessary details in the UI. We use the size of this set to determine
|
|
@@ -6182,7 +6338,7 @@ class TransactionStateManager extends base_controllers_namespaceObject.BaseTrans
|
|
|
6182
6338
|
}
|
|
6183
6339
|
getUnapprovedTxList() {
|
|
6184
6340
|
const chainId = this.getCurrentChainId();
|
|
6185
|
-
return (0,
|
|
6341
|
+
return (0,base_controllers_namespaceObject.pickBy)(this.state.transactions, transaction => {
|
|
6186
6342
|
const transactionMatches = (0,base_controllers_namespaceObject.transactionMatchesNetwork)(transaction, chainId);
|
|
6187
6343
|
return transaction.status === base_controllers_namespaceObject.TransactionStatus.unapproved && transactionMatches;
|
|
6188
6344
|
});
|
|
@@ -6242,22 +6398,21 @@ class TransactionStateManager extends base_controllers_namespaceObject.BaseTrans
|
|
|
6242
6398
|
|
|
6243
6399
|
|
|
6244
6400
|
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
6401
|
class TransactionController extends TransactionStateManager {
|
|
6248
|
-
constructor({
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6402
|
+
constructor(_ref) {
|
|
6403
|
+
let {
|
|
6404
|
+
config,
|
|
6405
|
+
state,
|
|
6406
|
+
provider,
|
|
6407
|
+
blockTracker,
|
|
6408
|
+
signEthTx,
|
|
6409
|
+
getCurrentChainId,
|
|
6410
|
+
getCurrentNetworkEIP1559Compatibility,
|
|
6411
|
+
getProviderConfig,
|
|
6412
|
+
getCurrentAccountEIP1559Compatibility,
|
|
6413
|
+
getSelectedAddress,
|
|
6414
|
+
getEIP1559GasFeeEstimates
|
|
6415
|
+
} = _ref;
|
|
6261
6416
|
super({
|
|
6262
6417
|
config,
|
|
6263
6418
|
state,
|
|
@@ -6318,15 +6473,15 @@ class TransactionController extends TransactionStateManager {
|
|
|
6318
6473
|
return new Promise((resolve, reject) => {
|
|
6319
6474
|
const handleFinished = msg => {
|
|
6320
6475
|
if (msg.status === base_controllers_namespaceObject.TransactionStatus.rejected) {
|
|
6321
|
-
return reject(
|
|
6476
|
+
return reject(openlogin_jrpc_namespaceObject.providerErrors.userRejectedRequest(`Transaction Signature: User denied message signature`));
|
|
6322
6477
|
}
|
|
6323
6478
|
if (msg.status === base_controllers_namespaceObject.TransactionStatus.failed) {
|
|
6324
|
-
return reject(
|
|
6479
|
+
return reject(openlogin_jrpc_namespaceObject.rpcErrors.internal(`Transaction Signature: failed to sign message ${msg.error}`));
|
|
6325
6480
|
}
|
|
6326
6481
|
if (msg.status === base_controllers_namespaceObject.TransactionStatus.submitted) {
|
|
6327
6482
|
return resolve(msg.transactionHash);
|
|
6328
6483
|
}
|
|
6329
|
-
return reject(
|
|
6484
|
+
return reject(openlogin_jrpc_namespaceObject.rpcErrors.internal(`Transaction Signature: Unknown problem: ${JSON.stringify(txMeta.transaction)}`));
|
|
6330
6485
|
};
|
|
6331
6486
|
this.once(`${txMeta.id}:finished`, handleFinished);
|
|
6332
6487
|
});
|
|
@@ -6386,7 +6541,10 @@ class TransactionController extends TransactionStateManager {
|
|
|
6386
6541
|
});
|
|
6387
6542
|
const fromAddress = txParams.from;
|
|
6388
6543
|
const common = await this.getCommonConfiguration(fromAddress);
|
|
6389
|
-
const
|
|
6544
|
+
const {
|
|
6545
|
+
TransactionFactory
|
|
6546
|
+
} = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 81, 23));
|
|
6547
|
+
const unsignedEthTx = TransactionFactory.fromTxData(txParams, {
|
|
6390
6548
|
common
|
|
6391
6549
|
});
|
|
6392
6550
|
const signedEthTx = await this.signEthTx(unsignedEthTx, fromAddress);
|
|
@@ -6649,10 +6807,11 @@ class TransactionController extends TransactionStateManager {
|
|
|
6649
6807
|
this.updateTransactionInState(data.txMeta);
|
|
6650
6808
|
});
|
|
6651
6809
|
this.pendingTxTracker.on(base_controllers_namespaceObject.TX_EVENTS.TX_DROPPED, data => this.setTxStatusDropped(data.txId));
|
|
6652
|
-
this.pendingTxTracker.on(base_controllers_namespaceObject.TX_EVENTS.TX_BLOCK_UPDATE,
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6810
|
+
this.pendingTxTracker.on(base_controllers_namespaceObject.TX_EVENTS.TX_BLOCK_UPDATE, _ref2 => {
|
|
6811
|
+
let {
|
|
6812
|
+
txMeta,
|
|
6813
|
+
latestBlockNumber
|
|
6814
|
+
} = _ref2;
|
|
6656
6815
|
if (!txMeta.firstRetryBlockNumber) {
|
|
6657
6816
|
txMeta.firstRetryBlockNumber = latestBlockNumber;
|
|
6658
6817
|
this.updateTransactionInState(txMeta);
|
|
@@ -6702,8 +6861,12 @@ class TransactionController extends TransactionStateManager {
|
|
|
6702
6861
|
displayName
|
|
6703
6862
|
} = this.getProviderConfig();
|
|
6704
6863
|
const supportsEIP1559 = await this.getEIP1559Compatibility(fromAddress);
|
|
6705
|
-
const
|
|
6706
|
-
|
|
6864
|
+
const {
|
|
6865
|
+
Common,
|
|
6866
|
+
Hardfork
|
|
6867
|
+
} = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 652, 23));
|
|
6868
|
+
const hardfork = supportsEIP1559 ? Hardfork.Paris : Hardfork.Berlin;
|
|
6869
|
+
return Common.custom({
|
|
6707
6870
|
chainId: chainId === "loading" ? 0 : Number.parseInt(chainId, 16),
|
|
6708
6871
|
defaultHardfork: hardfork,
|
|
6709
6872
|
name: displayName,
|