@toruslabs/ethereum-controllers 5.10.0 → 5.11.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.
|
@@ -135,6 +135,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
135
135
|
AddChainController: () => (/* reexport */ AddChainController),
|
|
136
136
|
BASE_CHAIN_ID: () => (/* reexport */ BASE_CHAIN_ID),
|
|
137
137
|
BASE_TESTNET_CHAIN_ID: () => (/* reexport */ BASE_TESTNET_CHAIN_ID),
|
|
138
|
+
BNToHex: () => (/* reexport */ BNToHex),
|
|
138
139
|
BSC_MAINNET_CHAIN_ID: () => (/* reexport */ BSC_MAINNET_CHAIN_ID),
|
|
139
140
|
BSC_TESTNET_CHAIN_ID: () => (/* reexport */ BSC_TESTNET_CHAIN_ID),
|
|
140
141
|
CELO_MAINNET_CHAIN_ID: () => (/* reexport */ CELO_MAINNET_CHAIN_ID),
|
|
@@ -236,6 +237,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
236
237
|
getEtherScanHashLink: () => (/* reexport */ getEtherScanHashLink),
|
|
237
238
|
getFinalStates: () => (/* reexport */ getFinalStates),
|
|
238
239
|
getIpfsEndpoint: () => (/* reexport */ getIpfsEndpoint),
|
|
240
|
+
hexToBn: () => (/* reexport */ hexToBn),
|
|
239
241
|
hexWEIToDecGWEI: () => (/* reexport */ hexWEIToDecGWEI),
|
|
240
242
|
idleTimeTracker: () => (/* reexport */ idleTimeTracker),
|
|
241
243
|
isAddressByChainId: () => (/* reexport */ isAddressByChainId),
|
|
@@ -1143,16 +1145,15 @@ const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
|
1143
1145
|
* Network state changes also retrigger accounts update.
|
|
1144
1146
|
*/
|
|
1145
1147
|
class AccountTrackerController extends base_controllers_namespaceObject.BaseController {
|
|
1146
|
-
constructor(
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
} = _ref;
|
|
1148
|
+
constructor({
|
|
1149
|
+
config,
|
|
1150
|
+
state,
|
|
1151
|
+
provider,
|
|
1152
|
+
blockTracker,
|
|
1153
|
+
getIdentities,
|
|
1154
|
+
onPreferencesStateChange,
|
|
1155
|
+
getCurrentChainId
|
|
1156
|
+
}) {
|
|
1156
1157
|
super({
|
|
1157
1158
|
config,
|
|
1158
1159
|
state
|
|
@@ -1305,14 +1306,8 @@ const erc1155Interface = new external_ethers_namespaceObject.Interface(erc1155Ab
|
|
|
1305
1306
|
// functions that handle normalizing of that key in txParams
|
|
1306
1307
|
|
|
1307
1308
|
const normalizers = {
|
|
1308
|
-
from:
|
|
1309
|
-
|
|
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
|
-
},
|
|
1309
|
+
from: (from, LowerCase = true) => LowerCase ? (0,util_namespaceObject.addHexPrefix)(from).toLowerCase() : (0,util_namespaceObject.addHexPrefix)(from),
|
|
1310
|
+
to: (to, LowerCase = true) => LowerCase ? (0,util_namespaceObject.addHexPrefix)(to).toLowerCase() : (0,util_namespaceObject.addHexPrefix)(to),
|
|
1316
1311
|
nonce: nonce => (0,util_namespaceObject.addHexPrefix)(nonce),
|
|
1317
1312
|
customNonceValue: nonce => (0,util_namespaceObject.addHexPrefix)(nonce),
|
|
1318
1313
|
value: value => (0,util_namespaceObject.addHexPrefix)(value),
|
|
@@ -1327,8 +1322,7 @@ const normalizers = {
|
|
|
1327
1322
|
/**
|
|
1328
1323
|
* normalizes txParams
|
|
1329
1324
|
*/
|
|
1330
|
-
function normalizeTxParameters(txParameters) {
|
|
1331
|
-
let lowerCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
1325
|
+
function normalizeTxParameters(txParameters, lowerCase = true) {
|
|
1332
1326
|
// apply only keys in the normalizers
|
|
1333
1327
|
const normalizedTxParameters = {
|
|
1334
1328
|
id: txParameters.id || (0,base_controllers_namespaceObject.randomId)(),
|
|
@@ -1446,8 +1440,7 @@ function validateRecipient(txParameters) {
|
|
|
1446
1440
|
* Validates the given tx parameters
|
|
1447
1441
|
* @throws if the tx params contains invalid fields
|
|
1448
1442
|
*/
|
|
1449
|
-
function validateTxParameters(txParams) {
|
|
1450
|
-
let eip1559Compatibility = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
1443
|
+
function validateTxParameters(txParams, eip1559Compatibility = true) {
|
|
1451
1444
|
if (!txParams || typeof txParams !== "object" || Array.isArray(txParams)) {
|
|
1452
1445
|
throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams("Invalid transaction params: must be an object.");
|
|
1453
1446
|
}
|
|
@@ -1459,8 +1452,7 @@ function validateTxParameters(txParams) {
|
|
|
1459
1452
|
}) && !eip1559Compatibility) {
|
|
1460
1453
|
throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams("Invalid transaction params: params specify an EIP-1559 transaction but the current network does not support EIP-1559");
|
|
1461
1454
|
}
|
|
1462
|
-
Object.entries(txParams).forEach(
|
|
1463
|
-
let [key, value] = _ref;
|
|
1455
|
+
Object.entries(txParams).forEach(([key, value]) => {
|
|
1464
1456
|
// validate types
|
|
1465
1457
|
switch (key) {
|
|
1466
1458
|
case "from":
|
|
@@ -1504,8 +1496,7 @@ function validateTxParameters(txParams) {
|
|
|
1504
1496
|
}
|
|
1505
1497
|
});
|
|
1506
1498
|
}
|
|
1507
|
-
function normalizeAndValidateTxParams(txParams) {
|
|
1508
|
-
let lowerCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
1499
|
+
function normalizeAndValidateTxParams(txParams, lowerCase = true) {
|
|
1509
1500
|
const normalizedTxParams = normalizeTxParameters(txParams, lowerCase);
|
|
1510
1501
|
validateTxParameters(normalizedTxParams);
|
|
1511
1502
|
return normalizedTxParams;
|
|
@@ -1632,6 +1623,12 @@ async function determineTransactionType(txParams, provider) {
|
|
|
1632
1623
|
|
|
1633
1624
|
|
|
1634
1625
|
|
|
1626
|
+
function hexToBn(hex) {
|
|
1627
|
+
return new (external_bignumber_js_default())((0,util_namespaceObject.stripHexPrefix)(hex), 16);
|
|
1628
|
+
}
|
|
1629
|
+
function BNToHex(bn) {
|
|
1630
|
+
return (0,util_namespaceObject.addHexPrefix)(bn.toString(16));
|
|
1631
|
+
}
|
|
1635
1632
|
function getEtherScanHashLink(txHash, chainId) {
|
|
1636
1633
|
if (!SUPPORTED_NETWORKS[chainId]) return "";
|
|
1637
1634
|
return `${SUPPORTED_NETWORKS[chainId].blockExplorerUrl}/tx/${txHash}`;
|
|
@@ -1851,11 +1848,10 @@ const DEFAULT_POLLING_INTERVAL = 20;
|
|
|
1851
1848
|
const DEFAULT_RETRY_TIMEOUT = 2;
|
|
1852
1849
|
const SEC = 1000;
|
|
1853
1850
|
class PollingBlockTracker extends base_controllers_namespaceObject.BaseBlockTracker {
|
|
1854
|
-
constructor(
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
} = _ref;
|
|
1851
|
+
constructor({
|
|
1852
|
+
config,
|
|
1853
|
+
state = {}
|
|
1854
|
+
}) {
|
|
1859
1855
|
if (!config.provider) {
|
|
1860
1856
|
throw new Error("PollingBlockTracker - no provider specified.");
|
|
1861
1857
|
}
|
|
@@ -1936,12 +1932,11 @@ const http_helpers_namespaceObject = require("@toruslabs/http-helpers");
|
|
|
1936
1932
|
|
|
1937
1933
|
|
|
1938
1934
|
class CurrencyController extends base_controllers_namespaceObject.BaseCurrencyController {
|
|
1939
|
-
constructor(
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
} = _ref;
|
|
1935
|
+
constructor({
|
|
1936
|
+
config,
|
|
1937
|
+
state,
|
|
1938
|
+
onNetworkChanged
|
|
1939
|
+
}) {
|
|
1945
1940
|
super({
|
|
1946
1941
|
config,
|
|
1947
1942
|
state
|
|
@@ -2113,20 +2108,19 @@ const isValidBase = base => Number.isInteger(base) && base > 1;
|
|
|
2113
2108
|
/**
|
|
2114
2109
|
* Utility method to convert a value between denominations, formats and currencies.
|
|
2115
2110
|
*/
|
|
2116
|
-
const converter =
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
} = _ref;
|
|
2111
|
+
const converter = ({
|
|
2112
|
+
value,
|
|
2113
|
+
fromNumericBase,
|
|
2114
|
+
fromDenomination,
|
|
2115
|
+
fromCurrency,
|
|
2116
|
+
toNumericBase,
|
|
2117
|
+
toDenomination,
|
|
2118
|
+
toCurrency,
|
|
2119
|
+
numberOfDecimals,
|
|
2120
|
+
conversionRate,
|
|
2121
|
+
invertConversionRate,
|
|
2122
|
+
roundDown
|
|
2123
|
+
}) => {
|
|
2130
2124
|
let convertedValue = fromNumericBase ? toBigNumber[fromNumericBase](value) : value;
|
|
2131
2125
|
if (fromDenomination) {
|
|
2132
2126
|
convertedValue = toNormalizedDenomination[fromDenomination](convertedValue);
|
|
@@ -2155,18 +2149,17 @@ const converter = _ref => {
|
|
|
2155
2149
|
}
|
|
2156
2150
|
return convertedValue;
|
|
2157
2151
|
};
|
|
2158
|
-
const conversionUtil = (value,
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
} = _ref2;
|
|
2152
|
+
const conversionUtil = (value, {
|
|
2153
|
+
fromCurrency = null,
|
|
2154
|
+
toCurrency = fromCurrency,
|
|
2155
|
+
fromNumericBase,
|
|
2156
|
+
toNumericBase,
|
|
2157
|
+
fromDenomination,
|
|
2158
|
+
toDenomination,
|
|
2159
|
+
numberOfDecimals,
|
|
2160
|
+
conversionRate,
|
|
2161
|
+
invertConversionRate
|
|
2162
|
+
}) => {
|
|
2170
2163
|
if (fromCurrency !== toCurrency && !conversionRate) {
|
|
2171
2164
|
return 0;
|
|
2172
2165
|
}
|
|
@@ -2195,8 +2188,7 @@ const getBigNumber = (value, base) => {
|
|
|
2195
2188
|
}
|
|
2196
2189
|
return new (external_bignumber_js_default())(String(value), base);
|
|
2197
2190
|
};
|
|
2198
|
-
const addCurrencies =
|
|
2199
|
-
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
2191
|
+
const addCurrencies = (a, b, options = {}) => {
|
|
2200
2192
|
const {
|
|
2201
2193
|
aBase,
|
|
2202
2194
|
bBase
|
|
@@ -2210,8 +2202,7 @@ const addCurrencies = function (a, b) {
|
|
|
2210
2202
|
value
|
|
2211
2203
|
}, conversionOptions));
|
|
2212
2204
|
};
|
|
2213
|
-
const subtractCurrencies =
|
|
2214
|
-
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
2205
|
+
const subtractCurrencies = (a, b, options = {}) => {
|
|
2215
2206
|
const {
|
|
2216
2207
|
aBase,
|
|
2217
2208
|
bBase
|
|
@@ -2225,8 +2216,7 @@ const subtractCurrencies = function (a, b) {
|
|
|
2225
2216
|
value
|
|
2226
2217
|
}, conversionOptions));
|
|
2227
2218
|
};
|
|
2228
|
-
const multiplyCurrencies =
|
|
2229
|
-
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
2219
|
+
const multiplyCurrencies = (a, b, options = {}) => {
|
|
2230
2220
|
const {
|
|
2231
2221
|
multiplicandBase,
|
|
2232
2222
|
multiplierBase
|
|
@@ -2240,44 +2230,41 @@ const multiplyCurrencies = function (a, b) {
|
|
|
2240
2230
|
value
|
|
2241
2231
|
}, conversionOptions));
|
|
2242
2232
|
};
|
|
2243
|
-
const conversionGreaterThan = (
|
|
2244
|
-
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2245
|
-
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2233
|
+
const conversionGreaterThan = (_ref, _ref2) => {
|
|
2234
|
+
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref2), _ref2));
|
|
2235
|
+
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref), _ref));
|
|
2246
2236
|
const firstValue = converter(objectSpread2_default()({}, firstProps));
|
|
2247
2237
|
const secondValue = converter(objectSpread2_default()({}, secondProps));
|
|
2248
2238
|
return firstValue.gt(secondValue);
|
|
2249
2239
|
};
|
|
2250
|
-
const conversionLessThan = (
|
|
2251
|
-
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2252
|
-
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2240
|
+
const conversionLessThan = (_ref3, _ref4) => {
|
|
2241
|
+
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref4), _ref4));
|
|
2242
|
+
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref3), _ref3));
|
|
2253
2243
|
const firstValue = converter(objectSpread2_default()({}, firstProps));
|
|
2254
2244
|
const secondValue = converter(objectSpread2_default()({}, secondProps));
|
|
2255
2245
|
return firstValue.lt(secondValue);
|
|
2256
2246
|
};
|
|
2257
|
-
const conversionMax = (
|
|
2258
|
-
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2259
|
-
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2247
|
+
const conversionMax = (_ref5, _ref6) => {
|
|
2248
|
+
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref6), _ref6));
|
|
2249
|
+
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref5), _ref5));
|
|
2260
2250
|
const firstIsGreater = conversionGreaterThan(objectSpread2_default()({}, firstProps), objectSpread2_default()({}, secondProps));
|
|
2261
2251
|
return firstIsGreater ? firstProps.value : secondProps.value;
|
|
2262
2252
|
};
|
|
2263
|
-
const conversionGTE = (
|
|
2264
|
-
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2265
|
-
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2253
|
+
const conversionGTE = (_ref7, _ref8) => {
|
|
2254
|
+
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref8), _ref8));
|
|
2255
|
+
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref7), _ref7));
|
|
2266
2256
|
const firstValue = converter(objectSpread2_default()({}, firstProps));
|
|
2267
2257
|
const secondValue = converter(objectSpread2_default()({}, secondProps));
|
|
2268
2258
|
return firstValue.isGreaterThanOrEqualTo(secondValue);
|
|
2269
2259
|
};
|
|
2270
|
-
const conversionLTE = (
|
|
2271
|
-
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2272
|
-
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(
|
|
2260
|
+
const conversionLTE = (_ref9, _ref10) => {
|
|
2261
|
+
let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref10), _ref10));
|
|
2262
|
+
let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref9), _ref9));
|
|
2273
2263
|
const firstValue = converter(objectSpread2_default()({}, firstProps));
|
|
2274
2264
|
const secondValue = converter(objectSpread2_default()({}, secondProps));
|
|
2275
2265
|
return firstValue.isLessThanOrEqualTo(secondValue);
|
|
2276
2266
|
};
|
|
2277
|
-
const toNegative =
|
|
2278
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2279
|
-
return multiplyCurrencies(n, -1, options);
|
|
2280
|
-
};
|
|
2267
|
+
const toNegative = (n, options = {}) => multiplyCurrencies(n, -1, options);
|
|
2281
2268
|
const decGWEIToHexWEI = decGWEI => {
|
|
2282
2269
|
return conversionUtil(decGWEI, {
|
|
2283
2270
|
fromNumericBase: "dec",
|
|
@@ -2447,21 +2434,20 @@ const LEGACY_GAS_PRICES_API_URL = "https://api.metaswap.codefi.network/gasPrices
|
|
|
2447
2434
|
* Returns gas prices in dec gwei
|
|
2448
2435
|
*/
|
|
2449
2436
|
class GasFeeController extends base_controllers_namespaceObject.BaseController {
|
|
2450
|
-
constructor(
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
} = _ref;
|
|
2437
|
+
constructor({
|
|
2438
|
+
config,
|
|
2439
|
+
state,
|
|
2440
|
+
getNetworkIdentifier,
|
|
2441
|
+
getProvider,
|
|
2442
|
+
fetchGasEstimates = gasUtil_fetchGasEstimates,
|
|
2443
|
+
fetchEthGasPriceEstimate = gasUtil_fetchEthGasPriceEstimate,
|
|
2444
|
+
fetchLegacyGasPriceEstimates = gasUtil_fetchLegacyGasPriceEstimates,
|
|
2445
|
+
fetchGasEstimatesViaEthFeeHistory = gasUtil_fetchGasEstimatesViaEthFeeHistory,
|
|
2446
|
+
getCurrentNetworkLegacyGasAPICompatibility,
|
|
2447
|
+
getCurrentNetworkEIP1559Compatibility,
|
|
2448
|
+
getCurrentAccountEIP1559Compatibility,
|
|
2449
|
+
onNetworkStateChange
|
|
2450
|
+
}) {
|
|
2465
2451
|
super({
|
|
2466
2452
|
config,
|
|
2467
2453
|
state
|
|
@@ -2651,11 +2637,10 @@ const eth_sig_util_namespaceObject = require("@metamask/eth-sig-util");
|
|
|
2651
2637
|
|
|
2652
2638
|
|
|
2653
2639
|
class KeyringController extends base_controllers_namespaceObject.BaseKeyringController {
|
|
2654
|
-
constructor(
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
} = _ref;
|
|
2640
|
+
constructor({
|
|
2641
|
+
config,
|
|
2642
|
+
state
|
|
2643
|
+
}) {
|
|
2659
2644
|
super({
|
|
2660
2645
|
config,
|
|
2661
2646
|
state
|
|
@@ -2765,12 +2750,11 @@ class AbstractMessageController extends base_controllers_namespaceObject.BaseCon
|
|
|
2765
2750
|
* Controller in charge of managing - storing, adding, removing, updating - Messages.
|
|
2766
2751
|
*
|
|
2767
2752
|
*/
|
|
2768
|
-
constructor(
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
} = _ref;
|
|
2753
|
+
constructor({
|
|
2754
|
+
config,
|
|
2755
|
+
state,
|
|
2756
|
+
getNetworkIdentifier
|
|
2757
|
+
}) {
|
|
2774
2758
|
super({
|
|
2775
2759
|
config,
|
|
2776
2760
|
state
|
|
@@ -3008,13 +2992,12 @@ function validateSwitchChainData(data) {
|
|
|
3008
2992
|
|
|
3009
2993
|
|
|
3010
2994
|
class AddChainController extends AbstractMessageController {
|
|
3011
|
-
constructor(
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
} = _ref;
|
|
2995
|
+
constructor({
|
|
2996
|
+
config,
|
|
2997
|
+
state,
|
|
2998
|
+
getNetworkIdentifier,
|
|
2999
|
+
addChain
|
|
3000
|
+
}) {
|
|
3018
3001
|
super({
|
|
3019
3002
|
config,
|
|
3020
3003
|
state,
|
|
@@ -3027,6 +3010,9 @@ class AddChainController extends AbstractMessageController {
|
|
|
3027
3010
|
}
|
|
3028
3011
|
async processAddChain(messageId) {
|
|
3029
3012
|
const msgObject = this.getMessage(messageId);
|
|
3013
|
+
if (!msgObject) {
|
|
3014
|
+
throw new Error("Message not found");
|
|
3015
|
+
}
|
|
3030
3016
|
try {
|
|
3031
3017
|
await this.approveMessage(messageId, msgObject.messageParams);
|
|
3032
3018
|
await this.addChain(msgObject.messageParams);
|
|
@@ -3046,10 +3032,12 @@ class AddChainController extends AbstractMessageController {
|
|
|
3046
3032
|
return this.waitForFinishStatus(messageParams, this.name);
|
|
3047
3033
|
}
|
|
3048
3034
|
async addUnapprovedMessage(messageParams, req) {
|
|
3049
|
-
validateAddChainData
|
|
3035
|
+
// set message params origin first to satisfy the eslint rule (origin won't be checked by validateAddChainData)
|
|
3036
|
+
// for "Possible race condition: `messageParams.origin` might be assigned based on an outdated state of `messageParams`"
|
|
3050
3037
|
if (req) {
|
|
3051
3038
|
messageParams.origin = req.origin;
|
|
3052
3039
|
}
|
|
3040
|
+
await validateAddChainData(messageParams);
|
|
3053
3041
|
const messageId = messageParams.id || (0,base_controllers_namespaceObject.randomId)();
|
|
3054
3042
|
const messageData = {
|
|
3055
3043
|
id: messageId,
|
|
@@ -3079,13 +3067,12 @@ class AddChainController extends AbstractMessageController {
|
|
|
3079
3067
|
|
|
3080
3068
|
|
|
3081
3069
|
class DecryptMessageController extends AbstractMessageController {
|
|
3082
|
-
constructor(
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
} = _ref;
|
|
3070
|
+
constructor({
|
|
3071
|
+
config,
|
|
3072
|
+
state,
|
|
3073
|
+
decryptMessage,
|
|
3074
|
+
getNetworkIdentifier
|
|
3075
|
+
}) {
|
|
3089
3076
|
super({
|
|
3090
3077
|
config,
|
|
3091
3078
|
state,
|
|
@@ -3098,6 +3085,9 @@ class DecryptMessageController extends AbstractMessageController {
|
|
|
3098
3085
|
}
|
|
3099
3086
|
async processDecryptMessage(messageId) {
|
|
3100
3087
|
const msgObject = this.getMessage(messageId);
|
|
3088
|
+
if (!msgObject) {
|
|
3089
|
+
throw new Error("Message not found");
|
|
3090
|
+
}
|
|
3101
3091
|
try {
|
|
3102
3092
|
const cleanMsgParams = await this.approveMessage(messageId, msgObject.messageParams);
|
|
3103
3093
|
const parsedData = parseDecryptMessageData(cleanMsgParams.data);
|
|
@@ -3152,13 +3142,12 @@ class DecryptMessageController extends AbstractMessageController {
|
|
|
3152
3142
|
|
|
3153
3143
|
|
|
3154
3144
|
class EncryptionPublicKeyController extends AbstractMessageController {
|
|
3155
|
-
constructor(
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
} = _ref;
|
|
3145
|
+
constructor({
|
|
3146
|
+
config,
|
|
3147
|
+
state,
|
|
3148
|
+
signEncryptionPublicKey,
|
|
3149
|
+
getNetworkIdentifier
|
|
3150
|
+
}) {
|
|
3162
3151
|
super({
|
|
3163
3152
|
config,
|
|
3164
3153
|
state,
|
|
@@ -3171,6 +3160,9 @@ class EncryptionPublicKeyController extends AbstractMessageController {
|
|
|
3171
3160
|
}
|
|
3172
3161
|
async processGetEncryptionPublicKey(messageId) {
|
|
3173
3162
|
const msgObject = this.getMessage(messageId);
|
|
3163
|
+
if (!msgObject) {
|
|
3164
|
+
throw new Error(`Message not found`);
|
|
3165
|
+
}
|
|
3174
3166
|
try {
|
|
3175
3167
|
const cleanMsgParams = await this.approveMessage(messageId, msgObject.messageParams);
|
|
3176
3168
|
const publicKey = this.signEncryptionPublicKey(cleanMsgParams.from);
|
|
@@ -3225,13 +3217,12 @@ class EncryptionPublicKeyController extends AbstractMessageController {
|
|
|
3225
3217
|
|
|
3226
3218
|
|
|
3227
3219
|
class MessageController extends AbstractMessageController {
|
|
3228
|
-
constructor(
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
} = _ref;
|
|
3220
|
+
constructor({
|
|
3221
|
+
config,
|
|
3222
|
+
state,
|
|
3223
|
+
signMessage,
|
|
3224
|
+
getNetworkIdentifier
|
|
3225
|
+
}) {
|
|
3235
3226
|
super({
|
|
3236
3227
|
config,
|
|
3237
3228
|
state,
|
|
@@ -3244,6 +3235,9 @@ class MessageController extends AbstractMessageController {
|
|
|
3244
3235
|
}
|
|
3245
3236
|
async processSignMessage(messageId) {
|
|
3246
3237
|
const msgObject = this.getMessage(messageId);
|
|
3238
|
+
if (!msgObject) {
|
|
3239
|
+
throw new Error(`Message not found`);
|
|
3240
|
+
}
|
|
3247
3241
|
try {
|
|
3248
3242
|
const cleanMsgParams = await this.approveMessage(messageId, msgObject.messageParams);
|
|
3249
3243
|
const rawSig = await this.signMessage(cleanMsgParams.data, cleanMsgParams.from);
|
|
@@ -3296,13 +3290,12 @@ class MessageController extends AbstractMessageController {
|
|
|
3296
3290
|
|
|
3297
3291
|
|
|
3298
3292
|
class PersonalMessageController extends AbstractMessageController {
|
|
3299
|
-
constructor(
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
} = _ref;
|
|
3293
|
+
constructor({
|
|
3294
|
+
config,
|
|
3295
|
+
state,
|
|
3296
|
+
signPersonalMessage,
|
|
3297
|
+
getNetworkIdentifier
|
|
3298
|
+
}) {
|
|
3306
3299
|
super({
|
|
3307
3300
|
config,
|
|
3308
3301
|
state,
|
|
@@ -3315,6 +3308,9 @@ class PersonalMessageController extends AbstractMessageController {
|
|
|
3315
3308
|
}
|
|
3316
3309
|
async processSignPersonalMessage(messageId) {
|
|
3317
3310
|
const msgObject = this.getMessage(messageId);
|
|
3311
|
+
if (!msgObject) {
|
|
3312
|
+
throw new Error(`Message not found`);
|
|
3313
|
+
}
|
|
3318
3314
|
try {
|
|
3319
3315
|
const cleanMsgParams = await this.approveMessage(messageId, msgObject.messageParams);
|
|
3320
3316
|
const rawSig = await this.signPersonalMessage(cleanMsgParams.data, cleanMsgParams.from);
|
|
@@ -3367,13 +3363,12 @@ class PersonalMessageController extends AbstractMessageController {
|
|
|
3367
3363
|
|
|
3368
3364
|
|
|
3369
3365
|
class SwitchChainController extends AbstractMessageController {
|
|
3370
|
-
constructor(
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
} = _ref;
|
|
3366
|
+
constructor({
|
|
3367
|
+
config,
|
|
3368
|
+
state,
|
|
3369
|
+
getNetworkIdentifier,
|
|
3370
|
+
switchChain
|
|
3371
|
+
}) {
|
|
3377
3372
|
super({
|
|
3378
3373
|
config,
|
|
3379
3374
|
state,
|
|
@@ -3386,6 +3381,9 @@ class SwitchChainController extends AbstractMessageController {
|
|
|
3386
3381
|
}
|
|
3387
3382
|
async processSwitchChain(messageId) {
|
|
3388
3383
|
const msgObject = this.getMessage(messageId);
|
|
3384
|
+
if (!msgObject) {
|
|
3385
|
+
throw new Error(`Message not found`);
|
|
3386
|
+
}
|
|
3389
3387
|
try {
|
|
3390
3388
|
await this.approveMessage(messageId, msgObject.messageParams);
|
|
3391
3389
|
this.switchChain({
|
|
@@ -3452,13 +3450,12 @@ function getMessageType(version) {
|
|
|
3452
3450
|
}
|
|
3453
3451
|
}
|
|
3454
3452
|
class TypedMessageController extends AbstractMessageController {
|
|
3455
|
-
constructor(
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
} = _ref;
|
|
3453
|
+
constructor({
|
|
3454
|
+
config,
|
|
3455
|
+
state,
|
|
3456
|
+
signTypedData,
|
|
3457
|
+
getNetworkIdentifier
|
|
3458
|
+
}) {
|
|
3462
3459
|
super({
|
|
3463
3460
|
config,
|
|
3464
3461
|
state,
|
|
@@ -3471,6 +3468,9 @@ class TypedMessageController extends AbstractMessageController {
|
|
|
3471
3468
|
}
|
|
3472
3469
|
async processSignTypedMessage(messageId) {
|
|
3473
3470
|
const msgObject = this.getMessage(messageId);
|
|
3471
|
+
if (!msgObject) {
|
|
3472
|
+
throw new Error(`Message not found`);
|
|
3473
|
+
}
|
|
3474
3474
|
try {
|
|
3475
3475
|
const cleanMsgParams = await this.approveMessage(messageId, msgObject.messageParams);
|
|
3476
3476
|
const msgData = cleanMsgParams.version === eth_sig_util_namespaceObject.SignTypedDataVersion.V1 ? cleanMsgParams.data : JSON.parse(cleanMsgParams.data);
|
|
@@ -3529,10 +3529,9 @@ class TypedMessageController extends AbstractMessageController {
|
|
|
3529
3529
|
|
|
3530
3530
|
|
|
3531
3531
|
|
|
3532
|
-
function createGetAccountsMiddleware(
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
} = _ref;
|
|
3532
|
+
function createGetAccountsMiddleware({
|
|
3533
|
+
getAccounts
|
|
3534
|
+
}) {
|
|
3536
3535
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3537
3536
|
const {
|
|
3538
3537
|
method
|
|
@@ -3543,10 +3542,9 @@ function createGetAccountsMiddleware(_ref) {
|
|
|
3543
3542
|
response.result = accounts;
|
|
3544
3543
|
});
|
|
3545
3544
|
}
|
|
3546
|
-
function createProcessTransactionMiddleware(
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
} = _ref2;
|
|
3545
|
+
function createProcessTransactionMiddleware({
|
|
3546
|
+
processTransaction
|
|
3547
|
+
}) {
|
|
3550
3548
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3551
3549
|
const {
|
|
3552
3550
|
method
|
|
@@ -3556,10 +3554,9 @@ function createProcessTransactionMiddleware(_ref2) {
|
|
|
3556
3554
|
response.result = await processTransaction(request.params, request);
|
|
3557
3555
|
});
|
|
3558
3556
|
}
|
|
3559
|
-
function createProcessEthSignMessage(
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
} = _ref3;
|
|
3557
|
+
function createProcessEthSignMessage({
|
|
3558
|
+
processEthSignMessage
|
|
3559
|
+
}) {
|
|
3563
3560
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3564
3561
|
const {
|
|
3565
3562
|
method
|
|
@@ -3581,10 +3578,9 @@ function createProcessEthSignMessage(_ref3) {
|
|
|
3581
3578
|
response.result = await processEthSignMessage(msgParams, request);
|
|
3582
3579
|
});
|
|
3583
3580
|
}
|
|
3584
|
-
function createProcessTypedMessage(
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
} = _ref4;
|
|
3581
|
+
function createProcessTypedMessage({
|
|
3582
|
+
processTypedMessage
|
|
3583
|
+
}) {
|
|
3588
3584
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3589
3585
|
const {
|
|
3590
3586
|
method
|
|
@@ -3607,10 +3603,9 @@ function createProcessTypedMessage(_ref4) {
|
|
|
3607
3603
|
response.result = await processTypedMessage(msgParams, request);
|
|
3608
3604
|
});
|
|
3609
3605
|
}
|
|
3610
|
-
function createProcessTypedMessageV3(
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
} = _ref5;
|
|
3606
|
+
function createProcessTypedMessageV3({
|
|
3607
|
+
processTypedMessageV3
|
|
3608
|
+
}) {
|
|
3614
3609
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3615
3610
|
const {
|
|
3616
3611
|
method
|
|
@@ -3633,10 +3628,9 @@ function createProcessTypedMessageV3(_ref5) {
|
|
|
3633
3628
|
response.result = await processTypedMessageV3(msgParams, request);
|
|
3634
3629
|
});
|
|
3635
3630
|
}
|
|
3636
|
-
function createProcessTypedMessageV4(
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
} = _ref6;
|
|
3631
|
+
function createProcessTypedMessageV4({
|
|
3632
|
+
processTypedMessageV4
|
|
3633
|
+
}) {
|
|
3640
3634
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3641
3635
|
const {
|
|
3642
3636
|
method
|
|
@@ -3659,10 +3653,9 @@ function createProcessTypedMessageV4(_ref6) {
|
|
|
3659
3653
|
response.result = await processTypedMessageV4(msgParams, request);
|
|
3660
3654
|
});
|
|
3661
3655
|
}
|
|
3662
|
-
function createProcessPersonalMessage(
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
} = _ref7;
|
|
3656
|
+
function createProcessPersonalMessage({
|
|
3657
|
+
processPersonalMessage
|
|
3658
|
+
}) {
|
|
3666
3659
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3667
3660
|
const {
|
|
3668
3661
|
method
|
|
@@ -3695,10 +3688,9 @@ function createProcessPersonalMessage(_ref7) {
|
|
|
3695
3688
|
response.result = await processPersonalMessage(msgParams, request);
|
|
3696
3689
|
});
|
|
3697
3690
|
}
|
|
3698
|
-
function createPendingNonceMiddleware(
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
} = _ref8;
|
|
3691
|
+
function createPendingNonceMiddleware({
|
|
3692
|
+
getPendingNonce
|
|
3693
|
+
}) {
|
|
3702
3694
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3703
3695
|
const {
|
|
3704
3696
|
params,
|
|
@@ -3760,10 +3752,9 @@ function formatTxMetaForRpcResult(txMeta) {
|
|
|
3760
3752
|
}
|
|
3761
3753
|
return formattedTxMeta;
|
|
3762
3754
|
}
|
|
3763
|
-
function createPendingTxMiddleware(
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
} = _ref9;
|
|
3755
|
+
function createPendingTxMiddleware({
|
|
3756
|
+
getPendingTransactionByHash
|
|
3757
|
+
}) {
|
|
3767
3758
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3768
3759
|
const {
|
|
3769
3760
|
params,
|
|
@@ -3779,10 +3770,9 @@ function createPendingTxMiddleware(_ref9) {
|
|
|
3779
3770
|
return undefined;
|
|
3780
3771
|
});
|
|
3781
3772
|
}
|
|
3782
|
-
function createProcessEncryptionPublicKeyMiddleware(
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
} = _ref10;
|
|
3773
|
+
function createProcessEncryptionPublicKeyMiddleware({
|
|
3774
|
+
processEncryptionPublicKey
|
|
3775
|
+
}) {
|
|
3786
3776
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3787
3777
|
const {
|
|
3788
3778
|
method
|
|
@@ -3802,10 +3792,9 @@ function createProcessEncryptionPublicKeyMiddleware(_ref10) {
|
|
|
3802
3792
|
response.result = await processEncryptionPublicKey(msgParams, request);
|
|
3803
3793
|
});
|
|
3804
3794
|
}
|
|
3805
|
-
function createProcessDecryptMessageMiddleware(
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
} = _ref11;
|
|
3795
|
+
function createProcessDecryptMessageMiddleware({
|
|
3796
|
+
processDecryptMessage
|
|
3797
|
+
}) {
|
|
3809
3798
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3810
3799
|
const {
|
|
3811
3800
|
method
|
|
@@ -3825,10 +3814,9 @@ function createProcessDecryptMessageMiddleware(_ref11) {
|
|
|
3825
3814
|
response.result = await processDecryptMessage(msgParams, request);
|
|
3826
3815
|
});
|
|
3827
3816
|
}
|
|
3828
|
-
function createProcessSwitchEthereumChain(
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
} = _ref12;
|
|
3817
|
+
function createProcessSwitchEthereumChain({
|
|
3818
|
+
processSwitchEthereumChain
|
|
3819
|
+
}) {
|
|
3832
3820
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3833
3821
|
const {
|
|
3834
3822
|
method
|
|
@@ -3845,10 +3833,9 @@ function createProcessSwitchEthereumChain(_ref12) {
|
|
|
3845
3833
|
response.result = await processSwitchEthereumChain(msgParams, request);
|
|
3846
3834
|
});
|
|
3847
3835
|
}
|
|
3848
|
-
function createProcessAddEthereumChain(
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
} = _ref13;
|
|
3836
|
+
function createProcessAddEthereumChain({
|
|
3837
|
+
processAddEthereumChain
|
|
3838
|
+
}) {
|
|
3852
3839
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3853
3840
|
const {
|
|
3854
3841
|
method
|
|
@@ -3865,10 +3852,9 @@ function createProcessAddEthereumChain(_ref13) {
|
|
|
3865
3852
|
response.result = await processAddEthereumChain(msgParams, request);
|
|
3866
3853
|
});
|
|
3867
3854
|
}
|
|
3868
|
-
function createRequestAccountsMiddleware(
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
} = _ref14;
|
|
3855
|
+
function createRequestAccountsMiddleware({
|
|
3856
|
+
requestAccounts
|
|
3857
|
+
}) {
|
|
3872
3858
|
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3873
3859
|
const {
|
|
3874
3860
|
method
|
|
@@ -4112,11 +4098,10 @@ const NetworkController_excluded = ["chainId", "rpcTarget"];
|
|
|
4112
4098
|
|
|
4113
4099
|
|
|
4114
4100
|
class NetworkController extends base_controllers_namespaceObject.BaseController {
|
|
4115
|
-
constructor(
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
} = _ref;
|
|
4101
|
+
constructor({
|
|
4102
|
+
config,
|
|
4103
|
+
state
|
|
4104
|
+
}) {
|
|
4120
4105
|
super({
|
|
4121
4106
|
config,
|
|
4122
4107
|
state
|
|
@@ -4133,7 +4118,7 @@ class NetworkController extends base_controllers_namespaceObject.BaseController
|
|
|
4133
4118
|
properties: {
|
|
4134
4119
|
EIPS_1559: undefined
|
|
4135
4120
|
},
|
|
4136
|
-
providerConfig: SUPPORTED_NETWORKS
|
|
4121
|
+
providerConfig: SUPPORTED_NETWORKS[MAINNET_CHAIN_ID]
|
|
4137
4122
|
};
|
|
4138
4123
|
|
|
4139
4124
|
// when a new network is set,
|
|
@@ -4243,11 +4228,10 @@ class NetworkController extends base_controllers_namespaceObject.BaseController
|
|
|
4243
4228
|
rpcTarget
|
|
4244
4229
|
}, rest));
|
|
4245
4230
|
}
|
|
4246
|
-
setNetworkClient(
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
} = _ref2;
|
|
4231
|
+
setNetworkClient({
|
|
4232
|
+
networkMiddleware,
|
|
4233
|
+
blockTracker
|
|
4234
|
+
}) {
|
|
4251
4235
|
const ethereumMiddleware = createEthereumMiddleware(this.baseProviderHandlers);
|
|
4252
4236
|
const engine = new openlogin_jrpc_namespaceObject.JRPCEngine();
|
|
4253
4237
|
engine.push(ethereumMiddleware);
|
|
@@ -4258,11 +4242,10 @@ class NetworkController extends base_controllers_namespaceObject.BaseController
|
|
|
4258
4242
|
blockTracker
|
|
4259
4243
|
});
|
|
4260
4244
|
}
|
|
4261
|
-
setProvider(
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
} = _ref3;
|
|
4245
|
+
setProvider({
|
|
4246
|
+
provider,
|
|
4247
|
+
blockTracker
|
|
4248
|
+
}) {
|
|
4266
4249
|
if (this.providerProxy) {
|
|
4267
4250
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
4268
4251
|
// @ts-ignore
|
|
@@ -4309,19 +4292,18 @@ class NetworkController extends base_controllers_namespaceObject.BaseController
|
|
|
4309
4292
|
|
|
4310
4293
|
|
|
4311
4294
|
class NftHandler {
|
|
4312
|
-
constructor(
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
} = _ref;
|
|
4295
|
+
constructor({
|
|
4296
|
+
chainId,
|
|
4297
|
+
contractAddress,
|
|
4298
|
+
contractImage,
|
|
4299
|
+
contractName,
|
|
4300
|
+
contractSymbol,
|
|
4301
|
+
nftStandard,
|
|
4302
|
+
provider,
|
|
4303
|
+
contractDescription,
|
|
4304
|
+
contractFallbackLogo,
|
|
4305
|
+
contractSupply
|
|
4306
|
+
}) {
|
|
4325
4307
|
defineProperty_default()(this, "contractAddress", void 0);
|
|
4326
4308
|
defineProperty_default()(this, "contractName", void 0);
|
|
4327
4309
|
defineProperty_default()(this, "contractSymbol", void 0);
|
|
@@ -4469,8 +4451,7 @@ class NftHandler {
|
|
|
4469
4451
|
const contract = new external_ethers_namespaceObject.Contract(this.contractAddress, abi, this.provider);
|
|
4470
4452
|
return contract.supportsInterface(interfaceId);
|
|
4471
4453
|
}
|
|
4472
|
-
async getCollectibleTokenURI(tokenId) {
|
|
4473
|
-
let standard = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : CONTRACT_TYPE_ERC721;
|
|
4454
|
+
async getCollectibleTokenURI(tokenId, standard = CONTRACT_TYPE_ERC721) {
|
|
4474
4455
|
const method = standard === CONTRACT_TYPE_ERC721 ? "tokenURI" : "uri";
|
|
4475
4456
|
const abi = standard === CONTRACT_TYPE_ERC721 ? erc721Abi : erc1155Abi;
|
|
4476
4457
|
const contract = new external_ethers_namespaceObject.Contract(this.contractAddress, abi, this.provider);
|
|
@@ -4492,16 +4473,15 @@ var external_deepmerge_default = /*#__PURE__*/__webpack_require__.n(external_dee
|
|
|
4492
4473
|
|
|
4493
4474
|
const DEFAULT_INTERVAL = 180 * 1000;
|
|
4494
4475
|
class NftsController extends base_controllers_namespaceObject.BaseController {
|
|
4495
|
-
constructor(
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
} = _ref;
|
|
4476
|
+
constructor({
|
|
4477
|
+
config,
|
|
4478
|
+
state,
|
|
4479
|
+
provider,
|
|
4480
|
+
getCustomNfts,
|
|
4481
|
+
getSimpleHashNfts,
|
|
4482
|
+
onPreferencesStateChange,
|
|
4483
|
+
onNetworkStateChange
|
|
4484
|
+
}) {
|
|
4505
4485
|
super({
|
|
4506
4486
|
config,
|
|
4507
4487
|
state
|
|
@@ -4699,16 +4679,15 @@ class NftsController extends base_controllers_namespaceObject.BaseController {
|
|
|
4699
4679
|
|
|
4700
4680
|
|
|
4701
4681
|
class PreferencesController extends base_controllers_namespaceObject.BasePreferencesController {
|
|
4702
|
-
constructor(
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
} = _ref;
|
|
4682
|
+
constructor({
|
|
4683
|
+
config,
|
|
4684
|
+
state,
|
|
4685
|
+
provider,
|
|
4686
|
+
signAuthMessage,
|
|
4687
|
+
getProviderConfig,
|
|
4688
|
+
setProviderConfig,
|
|
4689
|
+
validateSignMessage
|
|
4690
|
+
}) {
|
|
4712
4691
|
super({
|
|
4713
4692
|
config,
|
|
4714
4693
|
state,
|
|
@@ -4901,7 +4880,8 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
|
|
|
4901
4880
|
async refetchEtherscanTx(address) {
|
|
4902
4881
|
var _this$getAddressState3;
|
|
4903
4882
|
const selectedAddress = address || this.state.selectedAddress;
|
|
4904
|
-
|
|
4883
|
+
if (!selectedAddress) return [];
|
|
4884
|
+
const lowerCaseSelectedAddress = selectedAddress === null || selectedAddress === void 0 ? void 0 : selectedAddress.toLowerCase();
|
|
4905
4885
|
if ((_this$getAddressState3 = this.getAddressState(selectedAddress)) !== null && _this$getAddressState3 !== void 0 && _this$getAddressState3.jwtToken) {
|
|
4906
4886
|
const {
|
|
4907
4887
|
chainId
|
|
@@ -4988,10 +4968,9 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
|
|
|
4988
4968
|
}
|
|
4989
4969
|
|
|
4990
4970
|
// Custom Network methods
|
|
4991
|
-
async addCustomNetwork(
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
} = _ref2;
|
|
4971
|
+
async addCustomNetwork({
|
|
4972
|
+
network
|
|
4973
|
+
}) {
|
|
4995
4974
|
try {
|
|
4996
4975
|
const {
|
|
4997
4976
|
selectedAddress
|
|
@@ -5031,11 +5010,10 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
|
|
|
5031
5010
|
return false;
|
|
5032
5011
|
}
|
|
5033
5012
|
}
|
|
5034
|
-
async editCustomNetwork(
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
} = _ref3;
|
|
5013
|
+
async editCustomNetwork({
|
|
5014
|
+
network,
|
|
5015
|
+
id
|
|
5016
|
+
}) {
|
|
5039
5017
|
try {
|
|
5040
5018
|
const {
|
|
5041
5019
|
selectedAddress
|
|
@@ -5058,9 +5036,8 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
|
|
|
5058
5036
|
return false;
|
|
5059
5037
|
}
|
|
5060
5038
|
}
|
|
5061
|
-
getChainOptions() {
|
|
5039
|
+
getChainOptions(address = this.state.selectedAddress) {
|
|
5062
5040
|
var _identities$address$c, _identities$address;
|
|
5063
|
-
let address = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.state.selectedAddress;
|
|
5064
5041
|
const {
|
|
5065
5042
|
identities
|
|
5066
5043
|
} = this.state;
|
|
@@ -5171,14 +5148,13 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
|
|
|
5171
5148
|
|
|
5172
5149
|
|
|
5173
5150
|
class TokenHandler {
|
|
5174
|
-
constructor(
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
} = _ref;
|
|
5151
|
+
constructor({
|
|
5152
|
+
address,
|
|
5153
|
+
symbol,
|
|
5154
|
+
decimals,
|
|
5155
|
+
name,
|
|
5156
|
+
provider
|
|
5157
|
+
}) {
|
|
5182
5158
|
defineProperty_default()(this, "address", void 0);
|
|
5183
5159
|
defineProperty_default()(this, "symbol", void 0);
|
|
5184
5160
|
defineProperty_default()(this, "decimals", void 0);
|
|
@@ -5223,14 +5199,13 @@ class TokenHandler {
|
|
|
5223
5199
|
|
|
5224
5200
|
const DEFAULT_CURRENCY = "eth";
|
|
5225
5201
|
class TokenRatesController extends base_controllers_namespaceObject.BaseController {
|
|
5226
|
-
constructor(
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
} = _ref;
|
|
5202
|
+
constructor({
|
|
5203
|
+
config,
|
|
5204
|
+
state,
|
|
5205
|
+
onPreferencesStateChange,
|
|
5206
|
+
onNetworkStateChange,
|
|
5207
|
+
onTokensStateChange
|
|
5208
|
+
}) {
|
|
5234
5209
|
super({
|
|
5235
5210
|
config,
|
|
5236
5211
|
state
|
|
@@ -5351,17 +5326,16 @@ const mergeTokenArrays = (oldArray, newArray) => {
|
|
|
5351
5326
|
};
|
|
5352
5327
|
const TokensController_DEFAULT_INTERVAL = 180 * 1000;
|
|
5353
5328
|
class TokensController extends base_controllers_namespaceObject.BaseController {
|
|
5354
|
-
constructor(
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
} = _ref;
|
|
5329
|
+
constructor({
|
|
5330
|
+
config,
|
|
5331
|
+
state,
|
|
5332
|
+
provider,
|
|
5333
|
+
getCustomTokens,
|
|
5334
|
+
getEtherScanTokens,
|
|
5335
|
+
getProviderConfig,
|
|
5336
|
+
onPreferencesStateChange,
|
|
5337
|
+
onNetworkStateChange
|
|
5338
|
+
}) {
|
|
5365
5339
|
super({
|
|
5366
5340
|
config,
|
|
5367
5341
|
state
|
|
@@ -5584,13 +5558,12 @@ class TokensController extends base_controllers_namespaceObject.BaseController {
|
|
|
5584
5558
|
|
|
5585
5559
|
|
|
5586
5560
|
class NonceTracker {
|
|
5587
|
-
constructor(
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
} = _ref;
|
|
5561
|
+
constructor({
|
|
5562
|
+
provider,
|
|
5563
|
+
blockTracker,
|
|
5564
|
+
getPendingTransactions,
|
|
5565
|
+
getConfirmedTransactions
|
|
5566
|
+
}) {
|
|
5594
5567
|
defineProperty_default()(this, "provider", void 0);
|
|
5595
5568
|
defineProperty_default()(this, "blockTracker", void 0);
|
|
5596
5569
|
defineProperty_default()(this, "getPendingTransactions", void 0);
|
|
@@ -5734,15 +5707,14 @@ class NonceTracker {
|
|
|
5734
5707
|
|
|
5735
5708
|
|
|
5736
5709
|
class PendingTransactionTracker extends openlogin_jrpc_namespaceObject.SafeEventEmitter {
|
|
5737
|
-
constructor(
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
} = _ref;
|
|
5710
|
+
constructor({
|
|
5711
|
+
provider,
|
|
5712
|
+
nonceTracker,
|
|
5713
|
+
approveTransaction,
|
|
5714
|
+
publishTransaction,
|
|
5715
|
+
getPendingTransactions,
|
|
5716
|
+
getConfirmedTransactions
|
|
5717
|
+
}) {
|
|
5746
5718
|
super();
|
|
5747
5719
|
defineProperty_default()(this, "DROPPED_BUFFER_COUNT", 3);
|
|
5748
5720
|
defineProperty_default()(this, "nonceTracker", void 0);
|
|
@@ -5832,11 +5804,11 @@ class PendingTransactionTracker extends openlogin_jrpc_namespaceObject.SafeEvent
|
|
|
5832
5804
|
if (txBlockDistance <= Math.min(50, 2 ** retryCount)) return undefined;
|
|
5833
5805
|
|
|
5834
5806
|
// Only auto-submit already-signed txs:
|
|
5835
|
-
if (!("
|
|
5807
|
+
if (!("rawTransaction" in txMeta)) return this.approveTransaction(txMeta.id);
|
|
5836
5808
|
const {
|
|
5837
|
-
|
|
5809
|
+
rawTransaction
|
|
5838
5810
|
} = txMeta;
|
|
5839
|
-
const txHash = await this.publishTransaction(
|
|
5811
|
+
const txHash = await this.publishTransaction(rawTransaction);
|
|
5840
5812
|
|
|
5841
5813
|
// Increment successful tries:
|
|
5842
5814
|
this.emit(base_controllers_namespaceObject.TX_EVENTS.TX_RETRY, {
|
|
@@ -5989,8 +5961,7 @@ class TransactionGasUtil {
|
|
|
5989
5961
|
/**
|
|
5990
5962
|
Adds a gas buffer with out exceeding the block gas limit
|
|
5991
5963
|
*/
|
|
5992
|
-
addGasBuffer(initialGasLimitHex, blockGasLimitHex) {
|
|
5993
|
-
let multiplier = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1.5;
|
|
5964
|
+
addGasBuffer(initialGasLimitHex, blockGasLimitHex, multiplier = 1.5) {
|
|
5994
5965
|
const initialGasLimitBn = new external_bn_js_namespaceObject.BN((0,util_namespaceObject.stripHexPrefix)(initialGasLimitHex), 16);
|
|
5995
5966
|
const blockGasLimitBn = new external_bn_js_namespaceObject.BN((0,util_namespaceObject.stripHexPrefix)(blockGasLimitHex), 16);
|
|
5996
5967
|
const upperGasLimitBn = blockGasLimitBn.muln(0.9);
|
|
@@ -6042,10 +6013,7 @@ function keyBy(arr, key) {
|
|
|
6042
6013
|
}, {});
|
|
6043
6014
|
}
|
|
6044
6015
|
function mapValues(obj, iteratee) {
|
|
6045
|
-
return Object.fromEntries(Object.entries(obj).map(
|
|
6046
|
-
let [key, value] = _ref;
|
|
6047
|
-
return [key, iteratee(value, key)];
|
|
6048
|
-
}));
|
|
6016
|
+
return Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, iteratee(value, key)]));
|
|
6049
6017
|
}
|
|
6050
6018
|
;// CONCATENATED MODULE: external "fast-json-patch"
|
|
6051
6019
|
const external_fast_json_patch_namespaceObject = require("fast-json-patch");
|
|
@@ -6094,20 +6062,19 @@ function snapshotFromTxMeta(txMeta) {
|
|
|
6094
6062
|
|
|
6095
6063
|
|
|
6096
6064
|
class TransactionStateManager extends base_controllers_namespaceObject.BaseTransactionStateManager {
|
|
6097
|
-
constructor(
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
} = _ref;
|
|
6065
|
+
constructor({
|
|
6066
|
+
config,
|
|
6067
|
+
state,
|
|
6068
|
+
getCurrentChainId
|
|
6069
|
+
}) {
|
|
6103
6070
|
super({
|
|
6104
6071
|
config,
|
|
6105
6072
|
state,
|
|
6106
6073
|
getCurrentChainId
|
|
6107
6074
|
});
|
|
6108
6075
|
}
|
|
6109
|
-
generateTxMeta() {
|
|
6110
|
-
|
|
6076
|
+
generateTxMeta(opts = {}) {
|
|
6077
|
+
var _opts$transaction;
|
|
6111
6078
|
const chainId = this.getCurrentChainId();
|
|
6112
6079
|
if (chainId === "loading") throw new Error("Torus is having trouble connecting to the network");
|
|
6113
6080
|
let dappSuggestedGasFees = null;
|
|
@@ -6133,7 +6100,7 @@ class TransactionStateManager extends base_controllers_namespaceObject.BaseTrans
|
|
|
6133
6100
|
}
|
|
6134
6101
|
}
|
|
6135
6102
|
return objectSpread2_default()({
|
|
6136
|
-
id: opts.transaction.id || (0,base_controllers_namespaceObject.randomId)(),
|
|
6103
|
+
id: ((_opts$transaction = opts.transaction) === null || _opts$transaction === void 0 ? void 0 : _opts$transaction.id) || (0,base_controllers_namespaceObject.randomId)(),
|
|
6137
6104
|
time: Date.now(),
|
|
6138
6105
|
status: base_controllers_namespaceObject.TransactionStatus.unapproved,
|
|
6139
6106
|
loadingDefaults: true,
|
|
@@ -6217,13 +6184,12 @@ class TransactionStateManager extends base_controllers_namespaceObject.BaseTrans
|
|
|
6217
6184
|
})
|
|
6218
6185
|
});
|
|
6219
6186
|
}
|
|
6220
|
-
getTransactions(
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
6187
|
+
getTransactions({
|
|
6188
|
+
searchCriteria = {},
|
|
6189
|
+
initialList = undefined,
|
|
6190
|
+
filterToCurrentNetwork = true,
|
|
6191
|
+
limit = undefined
|
|
6192
|
+
} = {}) {
|
|
6227
6193
|
const chainId = this.getCurrentChainId();
|
|
6228
6194
|
// searchCriteria is an object that might have values that aren't predicate
|
|
6229
6195
|
// methods. When providing any other value type (string, number, etc), we
|
|
@@ -6399,20 +6365,19 @@ class TransactionStateManager extends base_controllers_namespaceObject.BaseTrans
|
|
|
6399
6365
|
|
|
6400
6366
|
|
|
6401
6367
|
class TransactionController extends TransactionStateManager {
|
|
6402
|
-
constructor(
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
} = _ref;
|
|
6368
|
+
constructor({
|
|
6369
|
+
config,
|
|
6370
|
+
state,
|
|
6371
|
+
provider,
|
|
6372
|
+
blockTracker,
|
|
6373
|
+
signEthTx,
|
|
6374
|
+
getCurrentChainId,
|
|
6375
|
+
getCurrentNetworkEIP1559Compatibility,
|
|
6376
|
+
getProviderConfig,
|
|
6377
|
+
getCurrentAccountEIP1559Compatibility,
|
|
6378
|
+
getSelectedAddress,
|
|
6379
|
+
getEIP1559GasFeeEstimates
|
|
6380
|
+
}) {
|
|
6416
6381
|
super({
|
|
6417
6382
|
config,
|
|
6418
6383
|
state,
|
|
@@ -6807,11 +6772,10 @@ class TransactionController extends TransactionStateManager {
|
|
|
6807
6772
|
this.updateTransactionInState(data.txMeta);
|
|
6808
6773
|
});
|
|
6809
6774
|
this.pendingTxTracker.on(base_controllers_namespaceObject.TX_EVENTS.TX_DROPPED, data => this.setTxStatusDropped(data.txId));
|
|
6810
|
-
this.pendingTxTracker.on(base_controllers_namespaceObject.TX_EVENTS.TX_BLOCK_UPDATE,
|
|
6811
|
-
|
|
6812
|
-
|
|
6813
|
-
|
|
6814
|
-
} = _ref2;
|
|
6775
|
+
this.pendingTxTracker.on(base_controllers_namespaceObject.TX_EVENTS.TX_BLOCK_UPDATE, ({
|
|
6776
|
+
txMeta,
|
|
6777
|
+
latestBlockNumber
|
|
6778
|
+
}) => {
|
|
6815
6779
|
if (!txMeta.firstRetryBlockNumber) {
|
|
6816
6780
|
txMeta.firstRetryBlockNumber = latestBlockNumber;
|
|
6817
6781
|
this.updateTransactionInState(txMeta);
|