@toruslabs/ethereum-controllers 5.9.0 → 5.9.2
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 +96 -20
- package/dist/ethereumControllers.esm.js +14 -7
- package/dist/ethereumControllers.umd.min.js +1 -1
- package/dist/ethereumControllers.umd.min.js.LICENSE.txt +6 -10
- 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/package.json +3 -3
|
@@ -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
|
|
@@ -2762,13 +2838,10 @@ class AbstractMessageController extends base_controllers_namespaceObject.BaseCon
|
|
|
2762
2838
|
});
|
|
2763
2839
|
}
|
|
2764
2840
|
}
|
|
2765
|
-
;// CONCATENATED MODULE: external "jsonschema"
|
|
2766
|
-
const external_jsonschema_namespaceObject = require("jsonschema");
|
|
2767
2841
|
;// CONCATENATED MODULE: ./src/Message/utils.ts
|
|
2768
2842
|
|
|
2769
2843
|
|
|
2770
2844
|
|
|
2771
|
-
|
|
2772
2845
|
const hexRe = /^[0-9A-Fa-f]+$/gu;
|
|
2773
2846
|
function validateAddress(address, propertyName) {
|
|
2774
2847
|
if (!address || typeof address !== "string" || !(0,util_namespaceObject.isValidAddress)(address)) {
|
|
@@ -2806,7 +2879,7 @@ function validateTypedSignMessageDataV1(messageData) {
|
|
|
2806
2879
|
throw new Error(`Expected EIP712 typed data.`);
|
|
2807
2880
|
}
|
|
2808
2881
|
}
|
|
2809
|
-
function validateTypedSignMessageDataV3V4(messageData, currentChainId) {
|
|
2882
|
+
async function validateTypedSignMessageDataV3V4(messageData, currentChainId) {
|
|
2810
2883
|
validateAddress(messageData.from, "from");
|
|
2811
2884
|
if (!messageData.data || Array.isArray(messageData.data) || typeof messageData.data !== "object" && typeof messageData.data !== "string") {
|
|
2812
2885
|
throw new Error(`Invalid message "data": Must be a valid string or object.`);
|
|
@@ -2821,7 +2894,10 @@ function validateTypedSignMessageDataV3V4(messageData, currentChainId) {
|
|
|
2821
2894
|
throw new Error("Data must be passed as a valid JSON string.");
|
|
2822
2895
|
}
|
|
2823
2896
|
}
|
|
2824
|
-
const
|
|
2897
|
+
const {
|
|
2898
|
+
validate
|
|
2899
|
+
} = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 731, 23));
|
|
2900
|
+
const validation = validate(data, eth_sig_util_namespaceObject.TYPED_MESSAGE_SCHEMA);
|
|
2825
2901
|
if (validation.errors.length > 0) {
|
|
2826
2902
|
throw new Error("Data must conform to EIP-712 schema. See https://git.io/fNtcx.");
|
|
2827
2903
|
}
|
|
@@ -3392,7 +3468,7 @@ class TypedMessageController extends AbstractMessageController {
|
|
|
3392
3468
|
}
|
|
3393
3469
|
if (version === eth_sig_util_namespaceObject.SignTypedDataVersion.V3 || version === eth_sig_util_namespaceObject.SignTypedDataVersion.V4) {
|
|
3394
3470
|
const currentChainId = this.getNetworkIdentifier();
|
|
3395
|
-
validateTypedSignMessageDataV3V4(messageParams, currentChainId);
|
|
3471
|
+
await validateTypedSignMessageDataV3V4(messageParams, currentChainId);
|
|
3396
3472
|
}
|
|
3397
3473
|
if (typeof messageParams.data !== "string" && (version === eth_sig_util_namespaceObject.SignTypedDataVersion.V3 || version === eth_sig_util_namespaceObject.SignTypedDataVersion.V4)) {
|
|
3398
3474
|
messageParams.data = JSON.stringify(messageParams.data);
|
|
@@ -4717,7 +4793,7 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
|
|
|
4717
4793
|
}
|
|
4718
4794
|
return false;
|
|
4719
4795
|
} catch (error) {
|
|
4720
|
-
if (base_controllers_namespaceObject.isUnauthorizedError) {
|
|
4796
|
+
if ((0,base_controllers_namespaceObject.isUnauthorizedError)(error)) {
|
|
4721
4797
|
throw error;
|
|
4722
4798
|
}
|
|
4723
4799
|
external_loglevel_default().error(error);
|
|
@@ -5041,7 +5117,6 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
|
|
|
5041
5117
|
|
|
5042
5118
|
|
|
5043
5119
|
|
|
5044
|
-
|
|
5045
5120
|
class TokenHandler {
|
|
5046
5121
|
constructor({
|
|
5047
5122
|
address,
|
|
@@ -5081,7 +5156,7 @@ class TokenHandler {
|
|
|
5081
5156
|
async getUserBalance(userAddress) {
|
|
5082
5157
|
if (!this.decimals) await this.getDecimals();
|
|
5083
5158
|
const balance = await this.contract.balanceOf(userAddress);
|
|
5084
|
-
return
|
|
5159
|
+
return balance.toString(16);
|
|
5085
5160
|
}
|
|
5086
5161
|
}
|
|
5087
5162
|
;// CONCATENATED MODULE: ./src/Tokens/TokenRatesController.ts
|
|
@@ -5813,10 +5888,6 @@ class PendingTransactionTracker extends openlogin_jrpc_namespaceObject.SafeEvent
|
|
|
5813
5888
|
});
|
|
5814
5889
|
}
|
|
5815
5890
|
}
|
|
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
5891
|
;// CONCATENATED MODULE: ./src/Transaction/TransactionGasUtil.ts
|
|
5821
5892
|
|
|
5822
5893
|
|
|
@@ -6242,8 +6313,6 @@ class TransactionStateManager extends base_controllers_namespaceObject.BaseTrans
|
|
|
6242
6313
|
|
|
6243
6314
|
|
|
6244
6315
|
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
6316
|
class TransactionController extends TransactionStateManager {
|
|
6248
6317
|
constructor({
|
|
6249
6318
|
config,
|
|
@@ -6386,7 +6455,10 @@ class TransactionController extends TransactionStateManager {
|
|
|
6386
6455
|
});
|
|
6387
6456
|
const fromAddress = txParams.from;
|
|
6388
6457
|
const common = await this.getCommonConfiguration(fromAddress);
|
|
6389
|
-
const
|
|
6458
|
+
const {
|
|
6459
|
+
TransactionFactory
|
|
6460
|
+
} = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 81, 23));
|
|
6461
|
+
const unsignedEthTx = TransactionFactory.fromTxData(txParams, {
|
|
6390
6462
|
common
|
|
6391
6463
|
});
|
|
6392
6464
|
const signedEthTx = await this.signEthTx(unsignedEthTx, fromAddress);
|
|
@@ -6702,8 +6774,12 @@ class TransactionController extends TransactionStateManager {
|
|
|
6702
6774
|
displayName
|
|
6703
6775
|
} = this.getProviderConfig();
|
|
6704
6776
|
const supportsEIP1559 = await this.getEIP1559Compatibility(fromAddress);
|
|
6705
|
-
const
|
|
6706
|
-
|
|
6777
|
+
const {
|
|
6778
|
+
Common,
|
|
6779
|
+
Hardfork
|
|
6780
|
+
} = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 652, 23));
|
|
6781
|
+
const hardfork = supportsEIP1559 ? Hardfork.Paris : Hardfork.Berlin;
|
|
6782
|
+
return Common.custom({
|
|
6707
6783
|
chainId: chainId === "loading" ? 0 : Number.parseInt(chainId, 16),
|
|
6708
6784
|
defaultHardfork: hardfork,
|
|
6709
6785
|
name: displayName,
|
|
@@ -13,11 +13,8 @@ import _objectDestructuringEmpty from '@babel/runtime/helpers/objectDestructurin
|
|
|
13
13
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
14
14
|
import BN, { BN as BN$1 } from 'bn.js';
|
|
15
15
|
import { concatSig, personalSign, signTypedData, getEncryptionPublicKey, decrypt, typedSignatureHash, TYPED_MESSAGE_SCHEMA, SignTypedDataVersion } from '@metamask/eth-sig-util';
|
|
16
|
-
import { validate } from 'jsonschema';
|
|
17
16
|
import { createAsyncMiddleware, mergeMiddleware, createScaffoldMiddleware, providerFromMiddleware, JRPCEngine, providerFromEngine, SafeEventEmitter } from '@toruslabs/openlogin-jrpc';
|
|
18
17
|
import stringify from 'fast-safe-stringify';
|
|
19
|
-
import { Hardfork, Common } from '@ethereumjs/common';
|
|
20
|
-
import { TransactionFactory } from '@ethereumjs/tx';
|
|
21
18
|
import jsonDiffer from 'fast-json-patch';
|
|
22
19
|
|
|
23
20
|
const erc20Abi = [{
|
|
@@ -2503,7 +2500,7 @@ function validateTypedSignMessageDataV1(messageData) {
|
|
|
2503
2500
|
throw new Error(`Expected EIP712 typed data.`);
|
|
2504
2501
|
}
|
|
2505
2502
|
}
|
|
2506
|
-
function validateTypedSignMessageDataV3V4(messageData, currentChainId) {
|
|
2503
|
+
async function validateTypedSignMessageDataV3V4(messageData, currentChainId) {
|
|
2507
2504
|
validateAddress(messageData.from, "from");
|
|
2508
2505
|
if (!messageData.data || Array.isArray(messageData.data) || typeof messageData.data !== "object" && typeof messageData.data !== "string") {
|
|
2509
2506
|
throw new Error(`Invalid message "data": Must be a valid string or object.`);
|
|
@@ -2518,6 +2515,9 @@ function validateTypedSignMessageDataV3V4(messageData, currentChainId) {
|
|
|
2518
2515
|
throw new Error("Data must be passed as a valid JSON string.");
|
|
2519
2516
|
}
|
|
2520
2517
|
}
|
|
2518
|
+
const {
|
|
2519
|
+
validate
|
|
2520
|
+
} = await import('jsonschema');
|
|
2521
2521
|
const validation = validate(data, TYPED_MESSAGE_SCHEMA);
|
|
2522
2522
|
if (validation.errors.length > 0) {
|
|
2523
2523
|
throw new Error("Data must conform to EIP-712 schema. See https://git.io/fNtcx.");
|
|
@@ -3037,7 +3037,7 @@ class TypedMessageController extends AbstractMessageController {
|
|
|
3037
3037
|
}
|
|
3038
3038
|
if (version === SignTypedDataVersion.V3 || version === SignTypedDataVersion.V4) {
|
|
3039
3039
|
const currentChainId = this.getNetworkIdentifier();
|
|
3040
|
-
validateTypedSignMessageDataV3V4(messageParams, currentChainId);
|
|
3040
|
+
await validateTypedSignMessageDataV3V4(messageParams, currentChainId);
|
|
3041
3041
|
}
|
|
3042
3042
|
if (typeof messageParams.data !== "string" && (version === SignTypedDataVersion.V3 || version === SignTypedDataVersion.V4)) {
|
|
3043
3043
|
messageParams.data = JSON.stringify(messageParams.data);
|
|
@@ -4313,7 +4313,7 @@ class PreferencesController extends BasePreferencesController {
|
|
|
4313
4313
|
}
|
|
4314
4314
|
return false;
|
|
4315
4315
|
} catch (error) {
|
|
4316
|
-
if (isUnauthorizedError) {
|
|
4316
|
+
if (isUnauthorizedError(error)) {
|
|
4317
4317
|
throw error;
|
|
4318
4318
|
}
|
|
4319
4319
|
log.error(error);
|
|
@@ -4672,7 +4672,7 @@ class TokenHandler {
|
|
|
4672
4672
|
async getUserBalance(userAddress) {
|
|
4673
4673
|
if (!this.decimals) await this.getDecimals();
|
|
4674
4674
|
const balance = await this.contract.balanceOf(userAddress);
|
|
4675
|
-
return
|
|
4675
|
+
return balance.toString(16);
|
|
4676
4676
|
}
|
|
4677
4677
|
}
|
|
4678
4678
|
|
|
@@ -5910,6 +5910,9 @@ class TransactionController extends TransactionStateManager {
|
|
|
5910
5910
|
});
|
|
5911
5911
|
const fromAddress = txParams.from;
|
|
5912
5912
|
const common = await this.getCommonConfiguration(fromAddress);
|
|
5913
|
+
const {
|
|
5914
|
+
TransactionFactory
|
|
5915
|
+
} = await import('@ethereumjs/tx');
|
|
5913
5916
|
const unsignedEthTx = TransactionFactory.fromTxData(txParams, {
|
|
5914
5917
|
common
|
|
5915
5918
|
});
|
|
@@ -6226,6 +6229,10 @@ class TransactionController extends TransactionStateManager {
|
|
|
6226
6229
|
displayName
|
|
6227
6230
|
} = this.getProviderConfig();
|
|
6228
6231
|
const supportsEIP1559 = await this.getEIP1559Compatibility(fromAddress);
|
|
6232
|
+
const {
|
|
6233
|
+
Common,
|
|
6234
|
+
Hardfork
|
|
6235
|
+
} = await import('@ethereumjs/common');
|
|
6229
6236
|
const hardfork = supportsEIP1559 ? Hardfork.Paris : Hardfork.Berlin;
|
|
6230
6237
|
return Common.custom({
|
|
6231
6238
|
chainId: chainId === "loading" ? 0 : Number.parseInt(chainId, 16),
|