@toruslabs/ethereum-controllers 5.10.1 → 6.0.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 +114 -432
- package/dist/ethereumControllers.esm.js +63 -351
- package/dist/ethereumControllers.umd.min.js +1 -1
- package/dist/ethereumControllers.umd.min.js.LICENSE.txt +7 -2
- package/dist/lib.cjs/Account/AccountTrackerController.js +160 -0
- package/dist/lib.cjs/Block/PollingBlockTracker.js +85 -0
- package/dist/lib.cjs/Currency/CurrencyController.js +111 -0
- package/dist/lib.cjs/Gas/GasFeeController.js +214 -0
- package/dist/lib.cjs/Gas/gasUtil.js +148 -0
- package/dist/lib.cjs/Keyring/KeyringController.js +93 -0
- package/dist/lib.cjs/Message/AbstractMessageController.js +107 -0
- package/dist/lib.cjs/Message/AddChainController.js +78 -0
- package/dist/lib.cjs/Message/MessageController.js +77 -0
- package/dist/lib.cjs/Message/PersonalMessageController.js +77 -0
- package/dist/lib.cjs/Message/SwitchChainController.js +78 -0
- package/dist/lib.cjs/Message/TypedMessageController.js +81 -0
- package/dist/lib.cjs/Message/utils.js +112 -0
- package/dist/lib.cjs/Network/NetworkController.js +201 -0
- package/dist/lib.cjs/Network/cacheIdentifier.js +112 -0
- package/dist/lib.cjs/Network/createEthereumMiddleware.js +302 -0
- package/dist/lib.cjs/Network/createJsonRpcClient.js +64 -0
- package/dist/lib.cjs/Nfts/NftHandler.js +180 -0
- package/dist/lib.cjs/Nfts/NftsController.js +213 -0
- package/dist/lib.cjs/Preferences/PreferencesController.js +476 -0
- package/dist/lib.cjs/Tokens/TokenHandler.js +51 -0
- package/dist/lib.cjs/Tokens/TokenRatesController.js +112 -0
- package/dist/lib.cjs/Tokens/TokensController.js +259 -0
- package/dist/lib.cjs/Transaction/NonceTracker.js +150 -0
- package/dist/lib.cjs/Transaction/PendingTransactionTracker.js +222 -0
- package/dist/lib.cjs/Transaction/TransactionController.js +515 -0
- package/dist/lib.cjs/Transaction/TransactionGasUtil.js +81 -0
- package/dist/lib.cjs/Transaction/TransactionStateHistoryHelper.js +42 -0
- package/dist/lib.cjs/Transaction/TransactionStateManager.js +296 -0
- package/dist/lib.cjs/Transaction/TransactionUtils.js +341 -0
- package/dist/lib.cjs/index.js +171 -0
- package/dist/lib.cjs/utils/abis.js +510 -0
- package/dist/lib.cjs/utils/constants.js +362 -0
- package/dist/lib.cjs/utils/contractAddresses.js +16 -0
- package/dist/lib.cjs/utils/conversionUtils.js +232 -0
- package/dist/lib.cjs/utils/helpers.js +244 -0
- package/dist/lib.cjs/utils/lodashUtils.js +25 -0
- package/dist/lib.esm/Account/AccountTrackerController.js +158 -0
- package/dist/lib.esm/Block/PollingBlockTracker.js +83 -0
- package/dist/lib.esm/Currency/CurrencyController.js +109 -0
- package/dist/lib.esm/Gas/GasFeeController.js +212 -0
- package/dist/lib.esm/Gas/gasUtil.js +141 -0
- package/dist/lib.esm/Keyring/KeyringController.js +91 -0
- package/dist/lib.esm/Message/AbstractMessageController.js +105 -0
- package/dist/lib.esm/Message/AddChainController.js +76 -0
- package/dist/lib.esm/Message/MessageController.js +75 -0
- package/dist/lib.esm/Message/PersonalMessageController.js +75 -0
- package/dist/lib.esm/Message/SwitchChainController.js +76 -0
- package/dist/lib.esm/Message/TypedMessageController.js +79 -0
- package/dist/lib.esm/Message/utils.js +105 -0
- package/dist/lib.esm/Network/NetworkController.js +199 -0
- package/dist/lib.esm/Network/cacheIdentifier.js +107 -0
- package/dist/lib.esm/Network/createEthereumMiddleware.js +289 -0
- package/dist/lib.esm/Network/createJsonRpcClient.js +60 -0
- package/dist/lib.esm/Nfts/NftHandler.js +178 -0
- package/dist/lib.esm/Nfts/NftsController.js +211 -0
- package/dist/lib.esm/Preferences/PreferencesController.js +474 -0
- package/dist/lib.esm/Tokens/TokenHandler.js +49 -0
- package/dist/lib.esm/Tokens/TokenRatesController.js +109 -0
- package/dist/lib.esm/Tokens/TokensController.js +257 -0
- package/dist/lib.esm/Transaction/NonceTracker.js +148 -0
- package/dist/lib.esm/Transaction/PendingTransactionTracker.js +220 -0
- package/dist/lib.esm/Transaction/TransactionController.js +513 -0
- package/dist/lib.esm/Transaction/TransactionGasUtil.js +79 -0
- package/dist/lib.esm/Transaction/TransactionStateHistoryHelper.js +38 -0
- package/dist/lib.esm/Transaction/TransactionStateManager.js +294 -0
- package/dist/lib.esm/Transaction/TransactionUtils.js +326 -0
- package/dist/lib.esm/index.js +33 -0
- package/dist/lib.esm/utils/abis.js +505 -0
- package/dist/lib.esm/utils/constants.js +323 -0
- package/dist/lib.esm/utils/contractAddresses.js +14 -0
- package/dist/lib.esm/utils/conversionUtils.js +218 -0
- package/dist/lib.esm/utils/helpers.js +227 -0
- package/dist/lib.esm/utils/lodashUtils.js +21 -0
- package/dist/types/Account/AccountTrackerController.d.ts +5 -5
- package/dist/types/Block/PollingBlockTracker.d.ts +1 -2
- package/dist/types/Currency/CurrencyController.d.ts +1 -1
- package/dist/types/Gas/GasFeeController.d.ts +3 -3
- package/dist/types/Gas/gasUtil.d.ts +1 -1
- package/dist/types/Keyring/KeyringController.d.ts +3 -5
- package/dist/types/Message/AbstractMessageController.d.ts +5 -6
- package/dist/types/Message/AddChainController.d.ts +4 -4
- package/dist/types/Message/MessageController.d.ts +4 -4
- package/dist/types/Message/PersonalMessageController.d.ts +4 -4
- package/dist/types/Message/SwitchChainController.d.ts +4 -4
- package/dist/types/Message/TypedMessageController.d.ts +6 -7
- package/dist/types/Message/utils.d.ts +2 -7
- package/dist/types/Network/NetworkController.d.ts +4 -4
- package/dist/types/Network/cacheIdentifier.d.ts +1 -1
- package/dist/types/Network/createEthereumMiddleware.d.ts +2 -18
- package/dist/types/Network/createJsonRpcClient.d.ts +2 -2
- package/dist/types/Nfts/NftsController.d.ts +2 -2
- package/dist/types/Preferences/PreferencesController.d.ts +4 -4
- package/dist/types/Tokens/TokensController.d.ts +3 -3
- package/dist/types/Transaction/NonceTracker.d.ts +5 -5
- package/dist/types/Transaction/PendingTransactionTracker.d.ts +5 -5
- package/dist/types/Transaction/TransactionController.d.ts +12 -12
- package/dist/types/Transaction/TransactionGasUtil.d.ts +4 -4
- package/dist/types/Transaction/TransactionStateManager.d.ts +3 -3
- package/dist/types/Transaction/TransactionUtils.d.ts +1 -1
- package/dist/types/index.d.ts +12 -14
- package/dist/types/utils/constants.d.ts +1 -5
- package/dist/types/utils/helpers.d.ts +7 -4
- package/dist/types/utils/interfaces.d.ts +43 -23
- package/package.json +22 -10
- package/dist/types/Message/DecryptMessageController.d.ts +0 -20
- package/dist/types/Message/EncryptionPublicKeyController.d.ts +0 -20
|
@@ -14,13 +14,6 @@ module.exports = require("@ethereumjs/common");
|
|
|
14
14
|
|
|
15
15
|
module.exports = require("@ethereumjs/tx");
|
|
16
16
|
|
|
17
|
-
/***/ }),
|
|
18
|
-
|
|
19
|
-
/***/ 731:
|
|
20
|
-
/***/ ((module) => {
|
|
21
|
-
|
|
22
|
-
module.exports = require("jsonschema");
|
|
23
|
-
|
|
24
17
|
/***/ })
|
|
25
18
|
|
|
26
19
|
/******/ });
|
|
@@ -131,10 +124,12 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
131
124
|
ARBITRUM_TESTNET_CHAIN_ID: () => (/* reexport */ ARBITRUM_TESTNET_CHAIN_ID),
|
|
132
125
|
AVALANCHE_MAINNET_CHAIN_ID: () => (/* reexport */ AVALANCHE_MAINNET_CHAIN_ID),
|
|
133
126
|
AVALANCHE_TESTNET_CHAIN_ID: () => (/* reexport */ AVALANCHE_TESTNET_CHAIN_ID),
|
|
134
|
-
|
|
127
|
+
AbstractMessageController: () => (/* reexport */ AbstractMessageController),
|
|
128
|
+
AccountTrackerController: () => (/* reexport */ AccountTrackerController),
|
|
135
129
|
AddChainController: () => (/* reexport */ AddChainController),
|
|
136
130
|
BASE_CHAIN_ID: () => (/* reexport */ BASE_CHAIN_ID),
|
|
137
131
|
BASE_TESTNET_CHAIN_ID: () => (/* reexport */ BASE_TESTNET_CHAIN_ID),
|
|
132
|
+
BNToHex: () => (/* reexport */ BNToHex),
|
|
138
133
|
BSC_MAINNET_CHAIN_ID: () => (/* reexport */ BSC_MAINNET_CHAIN_ID),
|
|
139
134
|
BSC_TESTNET_CHAIN_ID: () => (/* reexport */ BSC_TESTNET_CHAIN_ID),
|
|
140
135
|
CELO_MAINNET_CHAIN_ID: () => (/* reexport */ CELO_MAINNET_CHAIN_ID),
|
|
@@ -147,13 +142,11 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
147
142
|
CONTRACT_TYPE_ETH: () => (/* reexport */ CONTRACT_TYPE_ETH),
|
|
148
143
|
CurrencyController: () => (/* reexport */ CurrencyController),
|
|
149
144
|
DEFAULT_CURRENCY: () => (/* reexport */ DEFAULT_CURRENCY),
|
|
150
|
-
DecryptMessageController: () => (/* reexport */ DecryptMessageController),
|
|
151
145
|
ERC1155_INTERFACE_ID: () => (/* reexport */ ERC1155_INTERFACE_ID),
|
|
152
146
|
ERC721_ENUMERABLE_INTERFACE_ID: () => (/* reexport */ ERC721_ENUMERABLE_INTERFACE_ID),
|
|
153
147
|
ERC721_INTERFACE_ID: () => (/* reexport */ ERC721_INTERFACE_ID),
|
|
154
148
|
ERC721_METADATA_INTERFACE_ID: () => (/* reexport */ ERC721_METADATA_INTERFACE_ID),
|
|
155
149
|
ETHERSCAN_SUPPORTED_CHAINS: () => (/* reexport */ ETHERSCAN_SUPPORTED_CHAINS),
|
|
156
|
-
EncryptionPublicKeyController: () => (/* reexport */ EncryptionPublicKeyController),
|
|
157
150
|
GAS_ESTIMATE_TYPES: () => (/* reexport */ GAS_ESTIMATE_TYPES),
|
|
158
151
|
GAS_LIMITS: () => (/* reexport */ GAS_LIMITS),
|
|
159
152
|
GasFeeController: () => (/* reexport */ GasFeeController),
|
|
@@ -167,7 +160,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
167
160
|
NetworkController: () => (/* reexport */ NetworkController),
|
|
168
161
|
NftHandler: () => (/* reexport */ NftHandler),
|
|
169
162
|
NftsController: () => (/* reexport */ NftsController),
|
|
170
|
-
NonceTracker: () => (/* reexport */
|
|
163
|
+
NonceTracker: () => (/* reexport */ NonceTracker),
|
|
171
164
|
OLD_ERC721_LIST: () => (/* reexport */ OLD_ERC721_LIST),
|
|
172
165
|
OPTIMISM_MAINNET_CHAIN_ID: () => (/* reexport */ OPTIMISM_MAINNET_CHAIN_ID),
|
|
173
166
|
OPTIMISM_TESTNET_CHAIN_ID: () => (/* reexport */ OPTIMISM_TESTNET_CHAIN_ID),
|
|
@@ -175,7 +168,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
175
168
|
POLYGON_CHAIN_ID: () => (/* reexport */ POLYGON_CHAIN_ID),
|
|
176
169
|
PendingTransactionTracker: () => (/* reexport */ PendingTransactionTracker),
|
|
177
170
|
PersonalMessageController: () => (/* reexport */ PersonalMessageController),
|
|
178
|
-
PollingBlockTracker: () => (/* reexport */
|
|
171
|
+
PollingBlockTracker: () => (/* reexport */ PollingBlockTracker),
|
|
179
172
|
PreferencesController: () => (/* reexport */ PreferencesController),
|
|
180
173
|
SEPOLIA_CHAIN_ID: () => (/* reexport */ SEPOLIA_CHAIN_ID),
|
|
181
174
|
SIMPLEHASH_SUPPORTED_CHAINS: () => (/* reexport */ SIMPLEHASH_SUPPORTED_CHAINS),
|
|
@@ -207,14 +200,10 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
207
200
|
createPendingNonceMiddleware: () => (/* reexport */ createPendingNonceMiddleware),
|
|
208
201
|
createPendingTxMiddleware: () => (/* reexport */ createPendingTxMiddleware),
|
|
209
202
|
createProcessAddEthereumChain: () => (/* reexport */ createProcessAddEthereumChain),
|
|
210
|
-
createProcessDecryptMessageMiddleware: () => (/* reexport */ createProcessDecryptMessageMiddleware),
|
|
211
|
-
createProcessEncryptionPublicKeyMiddleware: () => (/* reexport */ createProcessEncryptionPublicKeyMiddleware),
|
|
212
203
|
createProcessEthSignMessage: () => (/* reexport */ createProcessEthSignMessage),
|
|
213
204
|
createProcessPersonalMessage: () => (/* reexport */ createProcessPersonalMessage),
|
|
214
205
|
createProcessSwitchEthereumChain: () => (/* reexport */ createProcessSwitchEthereumChain),
|
|
215
206
|
createProcessTransactionMiddleware: () => (/* reexport */ createProcessTransactionMiddleware),
|
|
216
|
-
createProcessTypedMessage: () => (/* reexport */ createProcessTypedMessage),
|
|
217
|
-
createProcessTypedMessageV3: () => (/* reexport */ createProcessTypedMessageV3),
|
|
218
207
|
createProcessTypedMessageV4: () => (/* reexport */ createProcessTypedMessageV4),
|
|
219
208
|
createProviderConfigMiddleware: () => (/* reexport */ createProviderConfigMiddleware),
|
|
220
209
|
createRequestAccountsMiddleware: () => (/* reexport */ createRequestAccountsMiddleware),
|
|
@@ -236,6 +225,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
236
225
|
getEtherScanHashLink: () => (/* reexport */ getEtherScanHashLink),
|
|
237
226
|
getFinalStates: () => (/* reexport */ getFinalStates),
|
|
238
227
|
getIpfsEndpoint: () => (/* reexport */ getIpfsEndpoint),
|
|
228
|
+
hexToBn: () => (/* reexport */ hexToBn),
|
|
239
229
|
hexWEIToDecGWEI: () => (/* reexport */ hexWEIToDecGWEI),
|
|
240
230
|
idleTimeTracker: () => (/* reexport */ idleTimeTracker),
|
|
241
231
|
isAddressByChainId: () => (/* reexport */ isAddressByChainId),
|
|
@@ -245,7 +235,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
245
235
|
normalizeAndValidateTxParams: () => (/* reexport */ normalizeAndValidateTxParams),
|
|
246
236
|
normalizeMessageData: () => (/* reexport */ normalizeMessageData),
|
|
247
237
|
normalizeTxParameters: () => (/* reexport */ normalizeTxParameters),
|
|
248
|
-
parseDecryptMessageData: () => (/* reexport */ parseDecryptMessageData),
|
|
249
238
|
parseStandardTokenTransactionData: () => (/* reexport */ parseStandardTokenTransactionData),
|
|
250
239
|
readAddressAsContract: () => (/* reexport */ readAddressAsContract),
|
|
251
240
|
replayHistory: () => (/* reexport */ replayHistory),
|
|
@@ -258,15 +247,12 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
258
247
|
transactionMatchesNetwork: () => (/* reexport */ transactionMatchesNetwork),
|
|
259
248
|
validateAddChainData: () => (/* reexport */ validateAddChainData),
|
|
260
249
|
validateAddress: () => (/* reexport */ validateAddress),
|
|
261
|
-
validateDecryptedMessageData: () => (/* reexport */ validateDecryptedMessageData),
|
|
262
|
-
validateEncryptionPublicKeyMessageData: () => (/* reexport */ validateEncryptionPublicKeyMessageData),
|
|
263
250
|
validateFrom: () => (/* reexport */ validateFrom),
|
|
264
251
|
validateRecipient: () => (/* reexport */ validateRecipient),
|
|
265
252
|
validateSignMessageData: () => (/* reexport */ validateSignMessageData),
|
|
266
253
|
validateSwitchChainData: () => (/* reexport */ validateSwitchChainData),
|
|
267
254
|
validateTxParameters: () => (/* reexport */ validateTxParameters),
|
|
268
|
-
|
|
269
|
-
validateTypedSignMessageDataV3V4: () => (/* reexport */ validateTypedSignMessageDataV3V4)
|
|
255
|
+
validateTypedSignMessageDataV4: () => (/* reexport */ validateTypedSignMessageDataV4)
|
|
270
256
|
});
|
|
271
257
|
|
|
272
258
|
;// CONCATENATED MODULE: external "@babel/runtime/helpers/objectSpread2"
|
|
@@ -1007,14 +993,10 @@ const METHOD_TYPES = {
|
|
|
1007
993
|
ETH_REQUEST_ACCOUNTS: "eth_requestAccounts",
|
|
1008
994
|
ETH_SEND_RAW_TRANSACTION: "eth_sendRawTransaction",
|
|
1009
995
|
ETH_SIGN: "eth_sign",
|
|
1010
|
-
ETH_SIGN_TYPED_DATA: "eth_signTypedData",
|
|
1011
|
-
ETH_SIGN_TYPED_DATA_V3: "eth_signTypedData_v3",
|
|
1012
996
|
ETH_SIGN_TYPED_DATA_V4: "eth_signTypedData_v4",
|
|
1013
997
|
PERSONAL_SIGN: "personal_sign",
|
|
1014
998
|
ETH_GET_TRANSACTION_COUNT: "eth_getTransactionCount",
|
|
1015
999
|
ETH_GET_TRANSACTION_BY_HASH: "eth_getTransactionByHash",
|
|
1016
|
-
ETH_GET_ENCRYPTION_PUBLIC_KEY: "eth_getEncryptionPublicKey",
|
|
1017
|
-
ETH_DECRYPT: "eth_decrypt",
|
|
1018
1000
|
ETH_GET_TRANSACTION_RECEIPT: "eth_getTransactionReceipt",
|
|
1019
1001
|
WATCH_ASSET: "wallet_watchAsset",
|
|
1020
1002
|
ETH_GET_BLOCK_BY_HASH: "eth_getBlockByHash",
|
|
@@ -1281,14 +1263,13 @@ class AccountTrackerController extends base_controllers_namespaceObject.BaseCont
|
|
|
1281
1263
|
}
|
|
1282
1264
|
}
|
|
1283
1265
|
}
|
|
1284
|
-
/* harmony default export */ const Account_AccountTrackerController = (AccountTrackerController);
|
|
1285
1266
|
;// CONCATENATED MODULE: external "@ethereumjs/util"
|
|
1286
1267
|
const util_namespaceObject = require("@ethereumjs/util");
|
|
1287
1268
|
;// CONCATENATED MODULE: external "bignumber.js"
|
|
1288
1269
|
const external_bignumber_js_namespaceObject = require("bignumber.js");
|
|
1289
1270
|
var external_bignumber_js_default = /*#__PURE__*/__webpack_require__.n(external_bignumber_js_namespaceObject);
|
|
1290
|
-
;// CONCATENATED MODULE: external "@
|
|
1291
|
-
const
|
|
1271
|
+
;// CONCATENATED MODULE: external "@web3auth/auth"
|
|
1272
|
+
const auth_namespaceObject = require("@web3auth/auth");
|
|
1292
1273
|
;// CONCATENATED MODULE: ./src/Transaction/TransactionUtils.ts
|
|
1293
1274
|
|
|
1294
1275
|
|
|
@@ -1371,7 +1352,7 @@ function isLegacyTransaction(transaction) {
|
|
|
1371
1352
|
*/
|
|
1372
1353
|
function ensureMutuallyExclusiveFieldsNotProvided(txParams, fieldBeingValidated, mutuallyExclusiveField) {
|
|
1373
1354
|
if (typeof txParams[mutuallyExclusiveField] !== "undefined") {
|
|
1374
|
-
throw
|
|
1355
|
+
throw auth_namespaceObject.rpcErrors.invalidParams(`Invalid transaction params: specified ${fieldBeingValidated} but also included ${mutuallyExclusiveField}, these cannot be mixed`);
|
|
1375
1356
|
}
|
|
1376
1357
|
}
|
|
1377
1358
|
|
|
@@ -1381,7 +1362,7 @@ function ensureMutuallyExclusiveFieldsNotProvided(txParams, fieldBeingValidated,
|
|
|
1381
1362
|
*/
|
|
1382
1363
|
function ensureFieldIsString(txParams, field) {
|
|
1383
1364
|
if (typeof txParams[field] !== "string") {
|
|
1384
|
-
throw
|
|
1365
|
+
throw auth_namespaceObject.rpcErrors.invalidParams(`Invalid transaction params: ${field} is not a string. got: (${txParams[field]})`);
|
|
1385
1366
|
}
|
|
1386
1367
|
}
|
|
1387
1368
|
|
|
@@ -1395,13 +1376,13 @@ function ensureProperTransactionEnvelopeTypeProvided(txParams, field) {
|
|
|
1395
1376
|
case "maxFeePerGas":
|
|
1396
1377
|
case "maxPriorityFeePerGas":
|
|
1397
1378
|
if (txParams.type && txParams.type !== TRANSACTION_ENVELOPE_TYPES.FEE_MARKET) {
|
|
1398
|
-
throw
|
|
1379
|
+
throw auth_namespaceObject.rpcErrors.invalidParams(`Invalid transaction envelope type: specified type "${txParams.type}" but ` + `including maxFeePerGas and maxPriorityFeePerGas requires type: "${TRANSACTION_ENVELOPE_TYPES.FEE_MARKET}"`);
|
|
1399
1380
|
}
|
|
1400
1381
|
break;
|
|
1401
1382
|
case "gasPrice":
|
|
1402
1383
|
default:
|
|
1403
1384
|
if (txParams.type && txParams.type === TRANSACTION_ENVELOPE_TYPES.FEE_MARKET) {
|
|
1404
|
-
throw
|
|
1385
|
+
throw auth_namespaceObject.rpcErrors.invalidParams(`Invalid transaction envelope type: specified type "${txParams.type}" but ` + "included a gasPrice instead of maxFeePerGas and maxPriorityFeePerGas");
|
|
1405
1386
|
}
|
|
1406
1387
|
}
|
|
1407
1388
|
}
|
|
@@ -1411,10 +1392,10 @@ function ensureProperTransactionEnvelopeTypeProvided(txParams, field) {
|
|
|
1411
1392
|
*/
|
|
1412
1393
|
function validateFrom(txParams) {
|
|
1413
1394
|
if (!(typeof txParams.from === "string")) {
|
|
1414
|
-
throw
|
|
1395
|
+
throw auth_namespaceObject.rpcErrors.invalidParams(`Invalid "from" address "${txParams.from}": not a string.`);
|
|
1415
1396
|
}
|
|
1416
1397
|
if (!(0,util_namespaceObject.isValidAddress)(txParams.from)) {
|
|
1417
|
-
throw
|
|
1398
|
+
throw auth_namespaceObject.rpcErrors.invalidParams('Invalid "from" address.');
|
|
1418
1399
|
}
|
|
1419
1400
|
}
|
|
1420
1401
|
|
|
@@ -1426,10 +1407,10 @@ function validateRecipient(txParameters) {
|
|
|
1426
1407
|
if (txParameters.data) {
|
|
1427
1408
|
delete txParameters.to;
|
|
1428
1409
|
} else {
|
|
1429
|
-
throw
|
|
1410
|
+
throw auth_namespaceObject.rpcErrors.invalidParams('Invalid "to" address.');
|
|
1430
1411
|
}
|
|
1431
1412
|
} else if (txParameters.to !== undefined && !(0,util_namespaceObject.isValidAddress)(txParameters.to)) {
|
|
1432
|
-
throw
|
|
1413
|
+
throw auth_namespaceObject.rpcErrors.invalidParams('Invalid "to" address.');
|
|
1433
1414
|
}
|
|
1434
1415
|
return txParameters;
|
|
1435
1416
|
}
|
|
@@ -1440,15 +1421,15 @@ function validateRecipient(txParameters) {
|
|
|
1440
1421
|
*/
|
|
1441
1422
|
function validateTxParameters(txParams, eip1559Compatibility = true) {
|
|
1442
1423
|
if (!txParams || typeof txParams !== "object" || Array.isArray(txParams)) {
|
|
1443
|
-
throw
|
|
1424
|
+
throw auth_namespaceObject.rpcErrors.invalidParams("Invalid transaction params: must be an object.");
|
|
1444
1425
|
}
|
|
1445
1426
|
if (!txParams.to && !txParams.data) {
|
|
1446
|
-
throw
|
|
1427
|
+
throw auth_namespaceObject.rpcErrors.invalidParams('Invalid transaction params: must specify "data" for contract deployments, or "to" (and optionally "data") for all other types of transactions.');
|
|
1447
1428
|
}
|
|
1448
1429
|
if (isEIP1559Transaction({
|
|
1449
1430
|
transaction: txParams
|
|
1450
1431
|
}) && !eip1559Compatibility) {
|
|
1451
|
-
throw
|
|
1432
|
+
throw auth_namespaceObject.rpcErrors.invalidParams("Invalid transaction params: params specify an EIP-1559 transaction but the current network does not support EIP-1559");
|
|
1452
1433
|
}
|
|
1453
1434
|
Object.entries(txParams).forEach(([key, value]) => {
|
|
1454
1435
|
// validate types
|
|
@@ -1478,15 +1459,15 @@ function validateTxParameters(txParams, eip1559Compatibility = true) {
|
|
|
1478
1459
|
case "value":
|
|
1479
1460
|
ensureFieldIsString(txParams, "value");
|
|
1480
1461
|
if (value.toString().includes("-")) {
|
|
1481
|
-
throw
|
|
1462
|
+
throw auth_namespaceObject.rpcErrors.invalidParams(`Invalid transaction value "${value}": not a positive number.`);
|
|
1482
1463
|
}
|
|
1483
1464
|
if (value.toString().includes(".")) {
|
|
1484
|
-
throw
|
|
1465
|
+
throw auth_namespaceObject.rpcErrors.invalidParams(`Invalid transaction value of "${value}": number must be in wei.`);
|
|
1485
1466
|
}
|
|
1486
1467
|
break;
|
|
1487
1468
|
case "chainId":
|
|
1488
1469
|
if (typeof value !== "number" && typeof value !== "string") {
|
|
1489
|
-
throw
|
|
1470
|
+
throw auth_namespaceObject.rpcErrors.invalidParams(`Invalid transaction params: ${key} is not a Number or hex string. got: (${value})`);
|
|
1490
1471
|
}
|
|
1491
1472
|
break;
|
|
1492
1473
|
default:
|
|
@@ -1621,6 +1602,12 @@ async function determineTransactionType(txParams, provider) {
|
|
|
1621
1602
|
|
|
1622
1603
|
|
|
1623
1604
|
|
|
1605
|
+
function hexToBn(hex) {
|
|
1606
|
+
return new (external_bignumber_js_default())((0,util_namespaceObject.stripHexPrefix)(hex), 16);
|
|
1607
|
+
}
|
|
1608
|
+
function BNToHex(bn) {
|
|
1609
|
+
return (0,util_namespaceObject.addHexPrefix)(bn.toString(16));
|
|
1610
|
+
}
|
|
1624
1611
|
function getEtherScanHashLink(txHash, chainId) {
|
|
1625
1612
|
if (!SUPPORTED_NETWORKS[chainId]) return "";
|
|
1626
1613
|
return `${SUPPORTED_NETWORKS[chainId].blockExplorerUrl}/tx/${txHash}`;
|
|
@@ -1913,7 +1900,6 @@ class PollingBlockTracker extends base_controllers_namespaceObject.BaseBlockTrac
|
|
|
1913
1900
|
}
|
|
1914
1901
|
}
|
|
1915
1902
|
}
|
|
1916
|
-
/* harmony default export */ const Block_PollingBlockTracker = (PollingBlockTracker);
|
|
1917
1903
|
;// CONCATENATED MODULE: external "@toruslabs/http-helpers"
|
|
1918
1904
|
const http_helpers_namespaceObject = require("@toruslabs/http-helpers");
|
|
1919
1905
|
;// CONCATENATED MODULE: ./src/Currency/CurrencyController.ts
|
|
@@ -2622,8 +2608,6 @@ class GasFeeController extends base_controllers_namespaceObject.BaseController {
|
|
|
2622
2608
|
return calculateTimeEstimate(maxPriorityFeePerGas, maxFeePerGas, this.state.gasFeeEstimates);
|
|
2623
2609
|
}
|
|
2624
2610
|
}
|
|
2625
|
-
;// CONCATENATED MODULE: external "@metamask/eth-sig-util"
|
|
2626
|
-
const eth_sig_util_namespaceObject = require("@metamask/eth-sig-util");
|
|
2627
2611
|
;// CONCATENATED MODULE: ./src/Keyring/KeyringController.ts
|
|
2628
2612
|
|
|
2629
2613
|
|
|
@@ -2689,41 +2673,22 @@ class KeyringController extends base_controllers_namespaceObject.BaseKeyringCont
|
|
|
2689
2673
|
const wallet = this._getWalletForAccount(address);
|
|
2690
2674
|
const privKey = this.getBufferPrivateKey(wallet.privateKey);
|
|
2691
2675
|
const messageSig = (0,util_namespaceObject.ecsign)(Buffer.from((0,util_namespaceObject.stripHexPrefix)(data), "hex"), privKey);
|
|
2692
|
-
const sig = (0,
|
|
2676
|
+
const sig = (0,base_controllers_namespaceObject.concatSig)(Buffer.from((0,util_namespaceObject.bigIntToBytes)(messageSig.v)), Buffer.from(messageSig.r), Buffer.from(messageSig.s));
|
|
2693
2677
|
return sig;
|
|
2694
2678
|
}
|
|
2695
|
-
|
|
2696
|
-
// For personal_sign, we need to prefix the message: ensure input is hashed and not buffer of utf-8
|
|
2697
2679
|
async signPersonalMessage(data, address) {
|
|
2698
2680
|
const wallet = this._getWalletForAccount(address);
|
|
2699
|
-
const privKey =
|
|
2700
|
-
const
|
|
2701
|
-
|
|
2702
|
-
data
|
|
2703
|
-
});
|
|
2704
|
-
return sig;
|
|
2681
|
+
const privKey = new external_ethers_namespaceObject.SigningKey((0,util_namespaceObject.addHexPrefix)(wallet.privateKey));
|
|
2682
|
+
const signature = privKey.sign((0,external_ethers_namespaceObject.hashMessage)(data)).serialized;
|
|
2683
|
+
return signature;
|
|
2705
2684
|
}
|
|
2706
2685
|
|
|
2707
2686
|
// personal_signTypedData, signs data along with the schema
|
|
2708
|
-
async signTypedData(typedData, address
|
|
2709
|
-
const wallet = this._getWalletForAccount(address);
|
|
2710
|
-
const privKey = this.getBufferPrivateKey(wallet.privateKey);
|
|
2711
|
-
return (0,eth_sig_util_namespaceObject.signTypedData)({
|
|
2712
|
-
privateKey: privKey,
|
|
2713
|
-
data: typedData,
|
|
2714
|
-
version
|
|
2715
|
-
});
|
|
2716
|
-
}
|
|
2717
|
-
signEncryptionPublicKey(address) {
|
|
2718
|
-
const wallet = this._getWalletForAccount(address);
|
|
2719
|
-
return (0,eth_sig_util_namespaceObject.getEncryptionPublicKey)((0,util_namespaceObject.stripHexPrefix)(wallet.privateKey));
|
|
2720
|
-
}
|
|
2721
|
-
decryptMessage(data, address) {
|
|
2687
|
+
async signTypedData(typedData, address) {
|
|
2722
2688
|
const wallet = this._getWalletForAccount(address);
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
});
|
|
2689
|
+
const privKey = new external_ethers_namespaceObject.SigningKey((0,util_namespaceObject.addHexPrefix)(wallet.privateKey));
|
|
2690
|
+
const signature = privKey.sign(external_ethers_namespaceObject.TypedDataEncoder.hash(typedData.domain, typedData.types, typedData.message)).serialized;
|
|
2691
|
+
return signature;
|
|
2727
2692
|
}
|
|
2728
2693
|
_getWalletForAccount(account) {
|
|
2729
2694
|
const address = account.toLowerCase();
|
|
@@ -2806,15 +2771,15 @@ class AbstractMessageController extends base_controllers_namespaceObject.BaseCon
|
|
|
2806
2771
|
return new Promise((resolve, reject) => {
|
|
2807
2772
|
const handleFinished = msg => {
|
|
2808
2773
|
if (msg.status === MessageStatus.REJECTED) {
|
|
2809
|
-
return reject(
|
|
2774
|
+
return reject(auth_namespaceObject.providerErrors.userRejectedRequest(`${messageName} Signature: User denied message signature`));
|
|
2810
2775
|
}
|
|
2811
2776
|
if (msg.status === MessageStatus.FAILED) {
|
|
2812
|
-
return reject(
|
|
2777
|
+
return reject(auth_namespaceObject.rpcErrors.internal(`${messageName} Signature: failed to sign message ${msg.error}`));
|
|
2813
2778
|
}
|
|
2814
2779
|
if (msg.status === MessageStatus.SIGNED) {
|
|
2815
2780
|
return resolve(msg.rawSig);
|
|
2816
2781
|
}
|
|
2817
|
-
return reject(
|
|
2782
|
+
return reject(auth_namespaceObject.rpcErrors.internal(`${messageName} Signature: Unknown problem: ${JSON.stringify(msgParams)}`));
|
|
2818
2783
|
};
|
|
2819
2784
|
this.once(`${msgParams.id}:finished`, handleFinished);
|
|
2820
2785
|
});
|
|
@@ -2838,7 +2803,6 @@ class AbstractMessageController extends base_controllers_namespaceObject.BaseCon
|
|
|
2838
2803
|
;// CONCATENATED MODULE: ./src/Message/utils.ts
|
|
2839
2804
|
|
|
2840
2805
|
|
|
2841
|
-
|
|
2842
2806
|
const hexRe = /^[0-9A-Fa-f]+$/gu;
|
|
2843
2807
|
function validateAddress(address, propertyName) {
|
|
2844
2808
|
if (!address || typeof address !== "string" || !(0,util_namespaceObject.isValidAddress)(address)) {
|
|
@@ -2864,19 +2828,7 @@ function normalizeMessageData(data) {
|
|
|
2864
2828
|
} catch (e) {}
|
|
2865
2829
|
return (0,util_namespaceObject.bytesToHex)(Buffer.from(data, "utf8"));
|
|
2866
2830
|
}
|
|
2867
|
-
function
|
|
2868
|
-
validateAddress(messageData.from, "from");
|
|
2869
|
-
if (!messageData.data || !Array.isArray(messageData.data)) {
|
|
2870
|
-
throw new Error(`Invalid message "data": ${messageData.data} must be a valid array.`);
|
|
2871
|
-
}
|
|
2872
|
-
try {
|
|
2873
|
-
// typedSignatureHash will throw if the data is invalid.
|
|
2874
|
-
(0,eth_sig_util_namespaceObject.typedSignatureHash)(messageData.data);
|
|
2875
|
-
} catch (e) {
|
|
2876
|
-
throw new Error(`Expected EIP712 typed data.`);
|
|
2877
|
-
}
|
|
2878
|
-
}
|
|
2879
|
-
async function validateTypedSignMessageDataV3V4(messageData, currentChainId) {
|
|
2831
|
+
async function validateTypedSignMessageDataV4(messageData, currentChainId) {
|
|
2880
2832
|
validateAddress(messageData.from, "from");
|
|
2881
2833
|
if (!messageData.data || Array.isArray(messageData.data) || typeof messageData.data !== "object" && typeof messageData.data !== "string") {
|
|
2882
2834
|
throw new Error(`Invalid message "data": Must be a valid string or object.`);
|
|
@@ -2891,13 +2843,6 @@ async function validateTypedSignMessageDataV3V4(messageData, currentChainId) {
|
|
|
2891
2843
|
throw new Error("Data must be passed as a valid JSON string.");
|
|
2892
2844
|
}
|
|
2893
2845
|
}
|
|
2894
|
-
const {
|
|
2895
|
-
validate
|
|
2896
|
-
} = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 731, 23));
|
|
2897
|
-
const validation = validate(data, eth_sig_util_namespaceObject.TYPED_MESSAGE_SCHEMA);
|
|
2898
|
-
if (validation.errors.length > 0) {
|
|
2899
|
-
throw new Error("Data must conform to EIP-712 schema. See https://git.io/fNtcx.");
|
|
2900
|
-
}
|
|
2901
2846
|
if (!currentChainId) {
|
|
2902
2847
|
throw new Error("Current chainId cannot be null or undefined.");
|
|
2903
2848
|
}
|
|
@@ -2917,23 +2862,6 @@ async function validateTypedSignMessageDataV3V4(messageData, currentChainId) {
|
|
|
2917
2862
|
}
|
|
2918
2863
|
}
|
|
2919
2864
|
}
|
|
2920
|
-
function validateEncryptionPublicKeyMessageData(messageData) {
|
|
2921
|
-
const {
|
|
2922
|
-
from
|
|
2923
|
-
} = messageData;
|
|
2924
|
-
validateAddress(from, "from");
|
|
2925
|
-
}
|
|
2926
|
-
function validateDecryptedMessageData(messageData) {
|
|
2927
|
-
const {
|
|
2928
|
-
from
|
|
2929
|
-
} = messageData;
|
|
2930
|
-
validateAddress(from, "from");
|
|
2931
|
-
}
|
|
2932
|
-
function parseDecryptMessageData(data) {
|
|
2933
|
-
const stripped = (0,util_namespaceObject.stripHexPrefix)(data);
|
|
2934
|
-
const buffer = Buffer.from(stripped, "hex");
|
|
2935
|
-
return JSON.parse(buffer.toString("utf8"));
|
|
2936
|
-
}
|
|
2937
2865
|
async function validateAddChainData(data) {
|
|
2938
2866
|
const {
|
|
2939
2867
|
chainId,
|
|
@@ -3002,6 +2930,9 @@ class AddChainController extends AbstractMessageController {
|
|
|
3002
2930
|
}
|
|
3003
2931
|
async processAddChain(messageId) {
|
|
3004
2932
|
const msgObject = this.getMessage(messageId);
|
|
2933
|
+
if (!msgObject) {
|
|
2934
|
+
throw new Error("Message not found");
|
|
2935
|
+
}
|
|
3005
2936
|
try {
|
|
3006
2937
|
await this.approveMessage(messageId, msgObject.messageParams);
|
|
3007
2938
|
await this.addChain(msgObject.messageParams);
|
|
@@ -3021,10 +2952,12 @@ class AddChainController extends AbstractMessageController {
|
|
|
3021
2952
|
return this.waitForFinishStatus(messageParams, this.name);
|
|
3022
2953
|
}
|
|
3023
2954
|
async addUnapprovedMessage(messageParams, req) {
|
|
3024
|
-
validateAddChainData
|
|
2955
|
+
// set message params origin first to satisfy the eslint rule (origin won't be checked by validateAddChainData)
|
|
2956
|
+
// for "Possible race condition: `messageParams.origin` might be assigned based on an outdated state of `messageParams`"
|
|
3025
2957
|
if (req) {
|
|
3026
2958
|
messageParams.origin = req.origin;
|
|
3027
2959
|
}
|
|
2960
|
+
await validateAddChainData(messageParams);
|
|
3028
2961
|
const messageId = messageParams.id || (0,base_controllers_namespaceObject.randomId)();
|
|
3029
2962
|
const messageData = {
|
|
3030
2963
|
id: messageId,
|
|
@@ -3044,151 +2977,6 @@ class AddChainController extends AbstractMessageController {
|
|
|
3044
2977
|
return Promise.resolve(messageParams);
|
|
3045
2978
|
}
|
|
3046
2979
|
}
|
|
3047
|
-
;// CONCATENATED MODULE: ./src/Message/DecryptMessageController.ts
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
// import { isValidAddress } from "@ethereumjs/util";
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
class DecryptMessageController extends AbstractMessageController {
|
|
3057
|
-
constructor({
|
|
3058
|
-
config,
|
|
3059
|
-
state,
|
|
3060
|
-
decryptMessage,
|
|
3061
|
-
getNetworkIdentifier
|
|
3062
|
-
}) {
|
|
3063
|
-
super({
|
|
3064
|
-
config,
|
|
3065
|
-
state,
|
|
3066
|
-
getNetworkIdentifier
|
|
3067
|
-
});
|
|
3068
|
-
defineProperty_default()(this, "name", "DecryptMessageController");
|
|
3069
|
-
defineProperty_default()(this, "decryptMessage", void 0);
|
|
3070
|
-
this.decryptMessage = decryptMessage;
|
|
3071
|
-
this.initialize();
|
|
3072
|
-
}
|
|
3073
|
-
async processDecryptMessage(messageId) {
|
|
3074
|
-
const msgObject = this.getMessage(messageId);
|
|
3075
|
-
try {
|
|
3076
|
-
const cleanMsgParams = await this.approveMessage(messageId, msgObject.messageParams);
|
|
3077
|
-
const parsedData = parseDecryptMessageData(cleanMsgParams.data);
|
|
3078
|
-
const rawSig = this.decryptMessage(parsedData, cleanMsgParams.from);
|
|
3079
|
-
this.updateMessage(objectSpread2_default()(objectSpread2_default()({}, msgObject), {}, {
|
|
3080
|
-
rawSig
|
|
3081
|
-
}));
|
|
3082
|
-
this.setMessageStatus(messageId, MessageStatus.SIGNED);
|
|
3083
|
-
return rawSig;
|
|
3084
|
-
} catch (error) {
|
|
3085
|
-
external_loglevel_default().error(error);
|
|
3086
|
-
msgObject.error = (error === null || error === void 0 ? void 0 : error.message) || (error === null || error === void 0 ? void 0 : error.toString());
|
|
3087
|
-
this.setMessageStatus(messageId, MessageStatus.FAILED);
|
|
3088
|
-
}
|
|
3089
|
-
}
|
|
3090
|
-
async addNewUnapprovedMessage(messageParams, req) {
|
|
3091
|
-
await this.addUnapprovedMessage(messageParams, req);
|
|
3092
|
-
return this.waitForFinishStatus(messageParams, this.name);
|
|
3093
|
-
}
|
|
3094
|
-
async addUnapprovedMessage(messageParams, req) {
|
|
3095
|
-
validateDecryptedMessageData(messageParams);
|
|
3096
|
-
if (req) {
|
|
3097
|
-
messageParams.origin = req.origin;
|
|
3098
|
-
}
|
|
3099
|
-
messageParams.data = normalizeMessageData(messageParams.data);
|
|
3100
|
-
const messageId = messageParams.id || (0,base_controllers_namespaceObject.randomId)();
|
|
3101
|
-
const messageData = {
|
|
3102
|
-
id: messageId,
|
|
3103
|
-
messageParams,
|
|
3104
|
-
status: MessageStatus.UNAPPROVED,
|
|
3105
|
-
time: Date.now(),
|
|
3106
|
-
type: METHOD_TYPES.ETH_DECRYPT
|
|
3107
|
-
};
|
|
3108
|
-
await this.addMessage(messageData);
|
|
3109
|
-
this.emit(MESSAGE_EVENTS.UNAPPROVED_MESSAGE, {
|
|
3110
|
-
messageData,
|
|
3111
|
-
req
|
|
3112
|
-
});
|
|
3113
|
-
return messageId;
|
|
3114
|
-
}
|
|
3115
|
-
prepMessageForSigning(messageParams) {
|
|
3116
|
-
return Promise.resolve(objectSpread2_default()({}, messageParams));
|
|
3117
|
-
}
|
|
3118
|
-
}
|
|
3119
|
-
;// CONCATENATED MODULE: ./src/Message/EncryptionPublicKeyController.ts
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
// import { isValidAddress } from "@ethereumjs/util";
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
class EncryptionPublicKeyController extends AbstractMessageController {
|
|
3129
|
-
constructor({
|
|
3130
|
-
config,
|
|
3131
|
-
state,
|
|
3132
|
-
signEncryptionPublicKey,
|
|
3133
|
-
getNetworkIdentifier
|
|
3134
|
-
}) {
|
|
3135
|
-
super({
|
|
3136
|
-
config,
|
|
3137
|
-
state,
|
|
3138
|
-
getNetworkIdentifier
|
|
3139
|
-
});
|
|
3140
|
-
defineProperty_default()(this, "name", "EncryptionPublicKeyController");
|
|
3141
|
-
defineProperty_default()(this, "signEncryptionPublicKey", void 0);
|
|
3142
|
-
this.signEncryptionPublicKey = signEncryptionPublicKey;
|
|
3143
|
-
this.initialize();
|
|
3144
|
-
}
|
|
3145
|
-
async processGetEncryptionPublicKey(messageId) {
|
|
3146
|
-
const msgObject = this.getMessage(messageId);
|
|
3147
|
-
try {
|
|
3148
|
-
const cleanMsgParams = await this.approveMessage(messageId, msgObject.messageParams);
|
|
3149
|
-
const publicKey = this.signEncryptionPublicKey(cleanMsgParams.from);
|
|
3150
|
-
this.updateMessage(objectSpread2_default()(objectSpread2_default()({}, msgObject), {}, {
|
|
3151
|
-
rawSig: publicKey
|
|
3152
|
-
}));
|
|
3153
|
-
this.setMessageStatus(messageId, MessageStatus.SIGNED);
|
|
3154
|
-
return publicKey;
|
|
3155
|
-
} catch (error) {
|
|
3156
|
-
external_loglevel_default().error(error);
|
|
3157
|
-
msgObject.error = (error === null || error === void 0 ? void 0 : error.message) || (error === null || error === void 0 ? void 0 : error.toString());
|
|
3158
|
-
this.setMessageStatus(messageId, MessageStatus.FAILED);
|
|
3159
|
-
}
|
|
3160
|
-
}
|
|
3161
|
-
async addNewUnapprovedMessage(messageParams, req) {
|
|
3162
|
-
await this.addUnapprovedMessage(messageParams, req);
|
|
3163
|
-
return this.waitForFinishStatus(messageParams, this.name);
|
|
3164
|
-
}
|
|
3165
|
-
async addUnapprovedMessage(messageParams, req) {
|
|
3166
|
-
validateEncryptionPublicKeyMessageData(messageParams);
|
|
3167
|
-
if (req) {
|
|
3168
|
-
messageParams.origin = req.origin;
|
|
3169
|
-
}
|
|
3170
|
-
const messageId = messageParams.id || (0,base_controllers_namespaceObject.randomId)();
|
|
3171
|
-
const messageData = {
|
|
3172
|
-
id: messageId,
|
|
3173
|
-
messageParams,
|
|
3174
|
-
status: MessageStatus.UNAPPROVED,
|
|
3175
|
-
time: Date.now(),
|
|
3176
|
-
type: METHOD_TYPES.ETH_GET_ENCRYPTION_PUBLIC_KEY
|
|
3177
|
-
};
|
|
3178
|
-
await this.addMessage(messageData);
|
|
3179
|
-
this.emit(MESSAGE_EVENTS.UNAPPROVED_MESSAGE, {
|
|
3180
|
-
messageData,
|
|
3181
|
-
req
|
|
3182
|
-
});
|
|
3183
|
-
return messageId;
|
|
3184
|
-
}
|
|
3185
|
-
prepMessageForSigning(messageParams) {
|
|
3186
|
-
// From should be the public key for the encryption
|
|
3187
|
-
return Promise.resolve(objectSpread2_default()(objectSpread2_default()({}, messageParams), {}, {
|
|
3188
|
-
from: messageParams.data
|
|
3189
|
-
}));
|
|
3190
|
-
}
|
|
3191
|
-
}
|
|
3192
2980
|
;// CONCATENATED MODULE: ./src/Message/MessageController.ts
|
|
3193
2981
|
|
|
3194
2982
|
|
|
@@ -3216,6 +3004,9 @@ class MessageController extends AbstractMessageController {
|
|
|
3216
3004
|
}
|
|
3217
3005
|
async processSignMessage(messageId) {
|
|
3218
3006
|
const msgObject = this.getMessage(messageId);
|
|
3007
|
+
if (!msgObject) {
|
|
3008
|
+
throw new Error(`Message not found`);
|
|
3009
|
+
}
|
|
3219
3010
|
try {
|
|
3220
3011
|
const cleanMsgParams = await this.approveMessage(messageId, msgObject.messageParams);
|
|
3221
3012
|
const rawSig = await this.signMessage(cleanMsgParams.data, cleanMsgParams.from);
|
|
@@ -3286,6 +3077,9 @@ class PersonalMessageController extends AbstractMessageController {
|
|
|
3286
3077
|
}
|
|
3287
3078
|
async processSignPersonalMessage(messageId) {
|
|
3288
3079
|
const msgObject = this.getMessage(messageId);
|
|
3080
|
+
if (!msgObject) {
|
|
3081
|
+
throw new Error(`Message not found`);
|
|
3082
|
+
}
|
|
3289
3083
|
try {
|
|
3290
3084
|
const cleanMsgParams = await this.approveMessage(messageId, msgObject.messageParams);
|
|
3291
3085
|
const rawSig = await this.signPersonalMessage(cleanMsgParams.data, cleanMsgParams.from);
|
|
@@ -3356,6 +3150,9 @@ class SwitchChainController extends AbstractMessageController {
|
|
|
3356
3150
|
}
|
|
3357
3151
|
async processSwitchChain(messageId) {
|
|
3358
3152
|
const msgObject = this.getMessage(messageId);
|
|
3153
|
+
if (!msgObject) {
|
|
3154
|
+
throw new Error(`Message not found`);
|
|
3155
|
+
}
|
|
3359
3156
|
try {
|
|
3360
3157
|
await this.approveMessage(messageId, msgObject.messageParams);
|
|
3361
3158
|
this.switchChain({
|
|
@@ -3408,19 +3205,6 @@ class SwitchChainController extends AbstractMessageController {
|
|
|
3408
3205
|
|
|
3409
3206
|
|
|
3410
3207
|
|
|
3411
|
-
|
|
3412
|
-
function getMessageType(version) {
|
|
3413
|
-
switch (version) {
|
|
3414
|
-
case eth_sig_util_namespaceObject.SignTypedDataVersion.V1:
|
|
3415
|
-
return METHOD_TYPES.ETH_SIGN_TYPED_DATA;
|
|
3416
|
-
case eth_sig_util_namespaceObject.SignTypedDataVersion.V3:
|
|
3417
|
-
return METHOD_TYPES.ETH_SIGN_TYPED_DATA_V3;
|
|
3418
|
-
case eth_sig_util_namespaceObject.SignTypedDataVersion.V4:
|
|
3419
|
-
return METHOD_TYPES.ETH_SIGN_TYPED_DATA_V4;
|
|
3420
|
-
default:
|
|
3421
|
-
return METHOD_TYPES.ETH_SIGN_TYPED_DATA;
|
|
3422
|
-
}
|
|
3423
|
-
}
|
|
3424
3208
|
class TypedMessageController extends AbstractMessageController {
|
|
3425
3209
|
constructor({
|
|
3426
3210
|
config,
|
|
@@ -3440,10 +3224,13 @@ class TypedMessageController extends AbstractMessageController {
|
|
|
3440
3224
|
}
|
|
3441
3225
|
async processSignTypedMessage(messageId) {
|
|
3442
3226
|
const msgObject = this.getMessage(messageId);
|
|
3227
|
+
if (!msgObject) {
|
|
3228
|
+
throw new Error(`Message not found`);
|
|
3229
|
+
}
|
|
3443
3230
|
try {
|
|
3444
3231
|
const cleanMsgParams = await this.approveMessage(messageId, msgObject.messageParams);
|
|
3445
|
-
const msgData =
|
|
3446
|
-
const rawSig = await this.signTypedData(msgData, cleanMsgParams.from
|
|
3232
|
+
const msgData = JSON.parse(cleanMsgParams.data);
|
|
3233
|
+
const rawSig = await this.signTypedData(msgData, cleanMsgParams.from);
|
|
3447
3234
|
this.updateMessage(objectSpread2_default()(objectSpread2_default()({}, msgObject), {}, {
|
|
3448
3235
|
rawSig
|
|
3449
3236
|
}));
|
|
@@ -3455,32 +3242,26 @@ class TypedMessageController extends AbstractMessageController {
|
|
|
3455
3242
|
this.setMessageStatus(messageId, MessageStatus.FAILED);
|
|
3456
3243
|
}
|
|
3457
3244
|
}
|
|
3458
|
-
async addNewUnapprovedMessage(messageParams, req
|
|
3459
|
-
await this.addUnapprovedMessage(messageParams, req
|
|
3245
|
+
async addNewUnapprovedMessage(messageParams, req) {
|
|
3246
|
+
await this.addUnapprovedMessage(messageParams, req);
|
|
3460
3247
|
return this.waitForFinishStatus(messageParams, this.name);
|
|
3461
3248
|
}
|
|
3462
|
-
async addUnapprovedMessage(messageParams, req
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
if (version === eth_sig_util_namespaceObject.SignTypedDataVersion.V3 || version === eth_sig_util_namespaceObject.SignTypedDataVersion.V4) {
|
|
3467
|
-
const currentChainId = this.getNetworkIdentifier();
|
|
3468
|
-
await validateTypedSignMessageDataV3V4(messageParams, currentChainId);
|
|
3469
|
-
}
|
|
3470
|
-
if (typeof messageParams.data !== "string" && (version === eth_sig_util_namespaceObject.SignTypedDataVersion.V3 || version === eth_sig_util_namespaceObject.SignTypedDataVersion.V4)) {
|
|
3249
|
+
async addUnapprovedMessage(messageParams, req) {
|
|
3250
|
+
const currentChainId = this.getNetworkIdentifier();
|
|
3251
|
+
await validateTypedSignMessageDataV4(messageParams, currentChainId);
|
|
3252
|
+
if (typeof messageParams.data !== "string") {
|
|
3471
3253
|
messageParams.data = JSON.stringify(messageParams.data);
|
|
3472
3254
|
}
|
|
3473
3255
|
if (req) {
|
|
3474
3256
|
messageParams.origin = req.origin;
|
|
3475
3257
|
}
|
|
3476
|
-
messageParams.version = version;
|
|
3477
3258
|
const messageId = messageParams.id || (0,base_controllers_namespaceObject.randomId)();
|
|
3478
3259
|
const messageData = {
|
|
3479
3260
|
id: messageId,
|
|
3480
3261
|
messageParams,
|
|
3481
3262
|
status: MessageStatus.UNAPPROVED,
|
|
3482
3263
|
time: Date.now(),
|
|
3483
|
-
type:
|
|
3264
|
+
type: METHOD_TYPES.ETH_SIGN_TYPED_DATA_V4
|
|
3484
3265
|
};
|
|
3485
3266
|
await this.addMessage(messageData);
|
|
3486
3267
|
this.emit(MESSAGE_EVENTS.UNAPPROVED_MESSAGE, {
|
|
@@ -3497,11 +3278,10 @@ class TypedMessageController extends AbstractMessageController {
|
|
|
3497
3278
|
|
|
3498
3279
|
|
|
3499
3280
|
|
|
3500
|
-
|
|
3501
3281
|
function createGetAccountsMiddleware({
|
|
3502
3282
|
getAccounts
|
|
3503
3283
|
}) {
|
|
3504
|
-
return (0,
|
|
3284
|
+
return (0,auth_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3505
3285
|
const {
|
|
3506
3286
|
method
|
|
3507
3287
|
} = request;
|
|
@@ -3514,7 +3294,7 @@ function createGetAccountsMiddleware({
|
|
|
3514
3294
|
function createProcessTransactionMiddleware({
|
|
3515
3295
|
processTransaction
|
|
3516
3296
|
}) {
|
|
3517
|
-
return (0,
|
|
3297
|
+
return (0,auth_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3518
3298
|
const {
|
|
3519
3299
|
method
|
|
3520
3300
|
} = request;
|
|
@@ -3526,7 +3306,7 @@ function createProcessTransactionMiddleware({
|
|
|
3526
3306
|
function createProcessEthSignMessage({
|
|
3527
3307
|
processEthSignMessage
|
|
3528
3308
|
}) {
|
|
3529
|
-
return (0,
|
|
3309
|
+
return (0,auth_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3530
3310
|
const {
|
|
3531
3311
|
method
|
|
3532
3312
|
} = request;
|
|
@@ -3547,60 +3327,10 @@ function createProcessEthSignMessage({
|
|
|
3547
3327
|
response.result = await processEthSignMessage(msgParams, request);
|
|
3548
3328
|
});
|
|
3549
3329
|
}
|
|
3550
|
-
function createProcessTypedMessage({
|
|
3551
|
-
processTypedMessage
|
|
3552
|
-
}) {
|
|
3553
|
-
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3554
|
-
const {
|
|
3555
|
-
method
|
|
3556
|
-
} = request;
|
|
3557
|
-
if (method !== METHOD_TYPES.ETH_SIGN_TYPED_DATA) return next();
|
|
3558
|
-
if (!processTypedMessage) throw new Error("WalletMiddleware - opts.processTypedMessage not provided");
|
|
3559
|
-
if (!(request !== null && request !== void 0 && request.params)) throw new Error("WalletMiddleware - missing params");
|
|
3560
|
-
let msgParams = request.params;
|
|
3561
|
-
if (Array.isArray(request.params)) {
|
|
3562
|
-
if (!(request.params.length === 2)) throw new Error(`WalletMiddleware - incorrect params for ${method} method. expected [typedData, address]`);
|
|
3563
|
-
const params = request.params;
|
|
3564
|
-
const message = typeof params[0] === "string" ? JSON.parse(params[0]) : params[0];
|
|
3565
|
-
const address = params[1];
|
|
3566
|
-
msgParams = {
|
|
3567
|
-
from: address,
|
|
3568
|
-
data: message,
|
|
3569
|
-
version: eth_sig_util_namespaceObject.SignTypedDataVersion.V1
|
|
3570
|
-
};
|
|
3571
|
-
}
|
|
3572
|
-
response.result = await processTypedMessage(msgParams, request);
|
|
3573
|
-
});
|
|
3574
|
-
}
|
|
3575
|
-
function createProcessTypedMessageV3({
|
|
3576
|
-
processTypedMessageV3
|
|
3577
|
-
}) {
|
|
3578
|
-
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3579
|
-
const {
|
|
3580
|
-
method
|
|
3581
|
-
} = request;
|
|
3582
|
-
if (method !== METHOD_TYPES.ETH_SIGN_TYPED_DATA_V3) return next();
|
|
3583
|
-
if (!processTypedMessageV3) throw new Error("WalletMiddleware - opts.processTypedMessageV3 is not provided");
|
|
3584
|
-
if (!(request !== null && request !== void 0 && request.params)) throw new Error("WalletMiddleware - missing params");
|
|
3585
|
-
let msgParams = request.params;
|
|
3586
|
-
if (Array.isArray(request.params)) {
|
|
3587
|
-
if (!(request.params.length === 2)) throw new Error(`WalletMiddleware - incorrect params for ${method} method. expected [address, typedData]`);
|
|
3588
|
-
const params = request.params;
|
|
3589
|
-
const address = params[0];
|
|
3590
|
-
const message = params[1];
|
|
3591
|
-
msgParams = {
|
|
3592
|
-
from: address,
|
|
3593
|
-
data: message,
|
|
3594
|
-
version: eth_sig_util_namespaceObject.SignTypedDataVersion.V3
|
|
3595
|
-
};
|
|
3596
|
-
}
|
|
3597
|
-
response.result = await processTypedMessageV3(msgParams, request);
|
|
3598
|
-
});
|
|
3599
|
-
}
|
|
3600
3330
|
function createProcessTypedMessageV4({
|
|
3601
3331
|
processTypedMessageV4
|
|
3602
3332
|
}) {
|
|
3603
|
-
return (0,
|
|
3333
|
+
return (0,auth_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3604
3334
|
const {
|
|
3605
3335
|
method
|
|
3606
3336
|
} = request;
|
|
@@ -3615,8 +3345,7 @@ function createProcessTypedMessageV4({
|
|
|
3615
3345
|
const message = params[1];
|
|
3616
3346
|
msgParams = {
|
|
3617
3347
|
from: address,
|
|
3618
|
-
data: message
|
|
3619
|
-
version: eth_sig_util_namespaceObject.SignTypedDataVersion.V4
|
|
3348
|
+
data: message
|
|
3620
3349
|
};
|
|
3621
3350
|
}
|
|
3622
3351
|
response.result = await processTypedMessageV4(msgParams, request);
|
|
@@ -3625,7 +3354,7 @@ function createProcessTypedMessageV4({
|
|
|
3625
3354
|
function createProcessPersonalMessage({
|
|
3626
3355
|
processPersonalMessage
|
|
3627
3356
|
}) {
|
|
3628
|
-
return (0,
|
|
3357
|
+
return (0,auth_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3629
3358
|
const {
|
|
3630
3359
|
method
|
|
3631
3360
|
} = request;
|
|
@@ -3660,7 +3389,7 @@ function createProcessPersonalMessage({
|
|
|
3660
3389
|
function createPendingNonceMiddleware({
|
|
3661
3390
|
getPendingNonce
|
|
3662
3391
|
}) {
|
|
3663
|
-
return (0,
|
|
3392
|
+
return (0,auth_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3664
3393
|
const {
|
|
3665
3394
|
params,
|
|
3666
3395
|
method
|
|
@@ -3724,7 +3453,7 @@ function formatTxMetaForRpcResult(txMeta) {
|
|
|
3724
3453
|
function createPendingTxMiddleware({
|
|
3725
3454
|
getPendingTransactionByHash
|
|
3726
3455
|
}) {
|
|
3727
|
-
return (0,
|
|
3456
|
+
return (0,auth_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3728
3457
|
const {
|
|
3729
3458
|
params,
|
|
3730
3459
|
method
|
|
@@ -3739,54 +3468,10 @@ function createPendingTxMiddleware({
|
|
|
3739
3468
|
return undefined;
|
|
3740
3469
|
});
|
|
3741
3470
|
}
|
|
3742
|
-
function createProcessEncryptionPublicKeyMiddleware({
|
|
3743
|
-
processEncryptionPublicKey
|
|
3744
|
-
}) {
|
|
3745
|
-
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3746
|
-
const {
|
|
3747
|
-
method
|
|
3748
|
-
} = request;
|
|
3749
|
-
if (method !== METHOD_TYPES.ETH_GET_ENCRYPTION_PUBLIC_KEY) return next();
|
|
3750
|
-
if (!processEncryptionPublicKey) throw new Error("WalletMiddleware - opts.processEncryptionPublicKey not provided");
|
|
3751
|
-
if (!(request !== null && request !== void 0 && request.params)) throw new Error("WalletMiddleware - missing params");
|
|
3752
|
-
let msgParams = request.params;
|
|
3753
|
-
if (Array.isArray(request.params)) {
|
|
3754
|
-
if (!(request.params.length === 1)) throw new Error(`WalletMiddleware - incorrect params for ${method} method. expected [address]`);
|
|
3755
|
-
const [address] = request.params;
|
|
3756
|
-
msgParams = {
|
|
3757
|
-
data: address,
|
|
3758
|
-
from: address
|
|
3759
|
-
};
|
|
3760
|
-
}
|
|
3761
|
-
response.result = await processEncryptionPublicKey(msgParams, request);
|
|
3762
|
-
});
|
|
3763
|
-
}
|
|
3764
|
-
function createProcessDecryptMessageMiddleware({
|
|
3765
|
-
processDecryptMessage
|
|
3766
|
-
}) {
|
|
3767
|
-
return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3768
|
-
const {
|
|
3769
|
-
method
|
|
3770
|
-
} = request;
|
|
3771
|
-
if (method !== METHOD_TYPES.ETH_DECRYPT) return next();
|
|
3772
|
-
if (!processDecryptMessage) throw new Error("WalletMiddleware - opts.processDecryptMessage not provided");
|
|
3773
|
-
if (!(request !== null && request !== void 0 && request.params)) throw new Error("WalletMiddleware - missing params");
|
|
3774
|
-
let msgParams = request.params;
|
|
3775
|
-
if (Array.isArray(request.params)) {
|
|
3776
|
-
if (!(request.params.length === 2)) throw new Error(`WalletMiddleware - incorrect params for ${method} method. expected [message, address]`);
|
|
3777
|
-
const [message, address] = request.params;
|
|
3778
|
-
msgParams = {
|
|
3779
|
-
data: message,
|
|
3780
|
-
from: address
|
|
3781
|
-
};
|
|
3782
|
-
}
|
|
3783
|
-
response.result = await processDecryptMessage(msgParams, request);
|
|
3784
|
-
});
|
|
3785
|
-
}
|
|
3786
3471
|
function createProcessSwitchEthereumChain({
|
|
3787
3472
|
processSwitchEthereumChain
|
|
3788
3473
|
}) {
|
|
3789
|
-
return (0,
|
|
3474
|
+
return (0,auth_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3790
3475
|
const {
|
|
3791
3476
|
method
|
|
3792
3477
|
} = request;
|
|
@@ -3805,7 +3490,7 @@ function createProcessSwitchEthereumChain({
|
|
|
3805
3490
|
function createProcessAddEthereumChain({
|
|
3806
3491
|
processAddEthereumChain
|
|
3807
3492
|
}) {
|
|
3808
|
-
return (0,
|
|
3493
|
+
return (0,auth_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3809
3494
|
const {
|
|
3810
3495
|
method
|
|
3811
3496
|
} = request;
|
|
@@ -3824,7 +3509,7 @@ function createProcessAddEthereumChain({
|
|
|
3824
3509
|
function createRequestAccountsMiddleware({
|
|
3825
3510
|
requestAccounts
|
|
3826
3511
|
}) {
|
|
3827
|
-
return (0,
|
|
3512
|
+
return (0,auth_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
|
|
3828
3513
|
const {
|
|
3829
3514
|
method
|
|
3830
3515
|
} = request;
|
|
@@ -3842,20 +3527,16 @@ function createEthereumMiddleware(providerHandlers) {
|
|
|
3842
3527
|
getAccounts,
|
|
3843
3528
|
processTransaction,
|
|
3844
3529
|
processEthSignMessage,
|
|
3845
|
-
processTypedMessage,
|
|
3846
|
-
processTypedMessageV3,
|
|
3847
3530
|
processTypedMessageV4,
|
|
3848
3531
|
processPersonalMessage,
|
|
3849
3532
|
getPendingNonce,
|
|
3850
3533
|
getPendingTransactionByHash,
|
|
3851
|
-
processEncryptionPublicKey,
|
|
3852
|
-
processDecryptMessage,
|
|
3853
3534
|
processSwitchEthereumChain,
|
|
3854
3535
|
processAddEthereumChain,
|
|
3855
3536
|
getProviderState,
|
|
3856
3537
|
version
|
|
3857
3538
|
} = providerHandlers;
|
|
3858
|
-
return (0,
|
|
3539
|
+
return (0,auth_namespaceObject.mergeMiddleware)([(0,auth_namespaceObject.createScaffoldMiddleware)({
|
|
3859
3540
|
version,
|
|
3860
3541
|
[base_controllers_namespaceObject.PROVIDER_JRPC_METHODS.GET_PROVIDER_STATE]: getProviderState
|
|
3861
3542
|
}), createRequestAccountsMiddleware({
|
|
@@ -3866,10 +3547,6 @@ function createEthereumMiddleware(providerHandlers) {
|
|
|
3866
3547
|
processTransaction
|
|
3867
3548
|
}), createProcessEthSignMessage({
|
|
3868
3549
|
processEthSignMessage
|
|
3869
|
-
}), createProcessTypedMessage({
|
|
3870
|
-
processTypedMessage
|
|
3871
|
-
}), createProcessTypedMessageV3({
|
|
3872
|
-
processTypedMessageV3
|
|
3873
3550
|
}), createProcessTypedMessageV4({
|
|
3874
3551
|
processTypedMessageV4
|
|
3875
3552
|
}), createProcessPersonalMessage({
|
|
@@ -3878,10 +3555,6 @@ function createEthereumMiddleware(providerHandlers) {
|
|
|
3878
3555
|
getPendingNonce
|
|
3879
3556
|
}), createPendingTxMiddleware({
|
|
3880
3557
|
getPendingTransactionByHash
|
|
3881
|
-
}), createProcessEncryptionPublicKeyMiddleware({
|
|
3882
|
-
processEncryptionPublicKey
|
|
3883
|
-
}), createProcessDecryptMessageMiddleware({
|
|
3884
|
-
processDecryptMessage
|
|
3885
3558
|
}), createProcessSwitchEthereumChain({
|
|
3886
3559
|
processSwitchEthereumChain
|
|
3887
3560
|
}), createProcessAddEthereumChain({
|
|
@@ -4033,14 +3706,14 @@ function createJsonRpcClient(providerConfig, networkConfig) {
|
|
|
4033
3706
|
const fetchMiddleware = (0,base_controllers_namespaceObject.createFetchMiddleware)({
|
|
4034
3707
|
rpcTarget
|
|
4035
3708
|
});
|
|
4036
|
-
const blockProvider = (0,
|
|
4037
|
-
const blockTracker = new
|
|
3709
|
+
const blockProvider = (0,auth_namespaceObject.providerFromMiddleware)(fetchMiddleware);
|
|
3710
|
+
const blockTracker = new PollingBlockTracker({
|
|
4038
3711
|
config: objectSpread2_default()(objectSpread2_default()({}, networkConfig), {}, {
|
|
4039
3712
|
provider: blockProvider
|
|
4040
3713
|
}),
|
|
4041
3714
|
state: {}
|
|
4042
3715
|
});
|
|
4043
|
-
const networkMiddleware = (0,
|
|
3716
|
+
const networkMiddleware = (0,auth_namespaceObject.mergeMiddleware)([createChainIdMiddleware(chainId), createProviderConfigMiddleware(providerConfig),
|
|
4044
3717
|
// No need for the following middlewares for web because all browser sessions are quite short lived and each session is limited to scope of a window/tab
|
|
4045
3718
|
// createBlockRefRewriteMiddleware({ blockTracker }),
|
|
4046
3719
|
// createBlockCacheMiddleware({ blockTracker }),
|
|
@@ -4087,7 +3760,7 @@ class NetworkController extends base_controllers_namespaceObject.BaseController
|
|
|
4087
3760
|
properties: {
|
|
4088
3761
|
EIPS_1559: undefined
|
|
4089
3762
|
},
|
|
4090
|
-
providerConfig: SUPPORTED_NETWORKS
|
|
3763
|
+
providerConfig: SUPPORTED_NETWORKS[MAINNET_CHAIN_ID]
|
|
4091
3764
|
};
|
|
4092
3765
|
|
|
4093
3766
|
// when a new network is set,
|
|
@@ -4202,10 +3875,10 @@ class NetworkController extends base_controllers_namespaceObject.BaseController
|
|
|
4202
3875
|
blockTracker
|
|
4203
3876
|
}) {
|
|
4204
3877
|
const ethereumMiddleware = createEthereumMiddleware(this.baseProviderHandlers);
|
|
4205
|
-
const engine = new
|
|
3878
|
+
const engine = new auth_namespaceObject.JRPCEngine();
|
|
4206
3879
|
engine.push(ethereumMiddleware);
|
|
4207
3880
|
engine.push(networkMiddleware);
|
|
4208
|
-
const provider = (0,
|
|
3881
|
+
const provider = (0,auth_namespaceObject.providerFromEngine)(engine);
|
|
4209
3882
|
this.setProvider({
|
|
4210
3883
|
provider,
|
|
4211
3884
|
blockTracker
|
|
@@ -4849,7 +4522,8 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
|
|
|
4849
4522
|
async refetchEtherscanTx(address) {
|
|
4850
4523
|
var _this$getAddressState3;
|
|
4851
4524
|
const selectedAddress = address || this.state.selectedAddress;
|
|
4852
|
-
|
|
4525
|
+
if (!selectedAddress) return [];
|
|
4526
|
+
const lowerCaseSelectedAddress = selectedAddress === null || selectedAddress === void 0 ? void 0 : selectedAddress.toLowerCase();
|
|
4853
4527
|
if ((_this$getAddressState3 = this.getAddressState(selectedAddress)) !== null && _this$getAddressState3 !== void 0 && _this$getAddressState3.jwtToken) {
|
|
4854
4528
|
const {
|
|
4855
4529
|
chainId
|
|
@@ -5667,14 +5341,13 @@ class NonceTracker {
|
|
|
5667
5341
|
};
|
|
5668
5342
|
}
|
|
5669
5343
|
}
|
|
5670
|
-
/* harmony default export */ const Transaction_NonceTracker = (NonceTracker);
|
|
5671
5344
|
;// CONCATENATED MODULE: ./src/Transaction/PendingTransactionTracker.ts
|
|
5672
5345
|
|
|
5673
5346
|
|
|
5674
5347
|
|
|
5675
5348
|
|
|
5676
5349
|
|
|
5677
|
-
class PendingTransactionTracker extends
|
|
5350
|
+
class PendingTransactionTracker extends auth_namespaceObject.SafeEventEmitter {
|
|
5678
5351
|
constructor({
|
|
5679
5352
|
provider,
|
|
5680
5353
|
nonceTracker,
|
|
@@ -5750,7 +5423,6 @@ class PendingTransactionTracker extends openlogin_jrpc_namespaceObject.SafeEvent
|
|
|
5750
5423
|
};
|
|
5751
5424
|
this.emit(base_controllers_namespaceObject.TX_EVENTS.TX_WARNING, {
|
|
5752
5425
|
txMeta,
|
|
5753
|
-
error,
|
|
5754
5426
|
txId: txMeta.id
|
|
5755
5427
|
});
|
|
5756
5428
|
}
|
|
@@ -5772,11 +5444,11 @@ class PendingTransactionTracker extends openlogin_jrpc_namespaceObject.SafeEvent
|
|
|
5772
5444
|
if (txBlockDistance <= Math.min(50, 2 ** retryCount)) return undefined;
|
|
5773
5445
|
|
|
5774
5446
|
// Only auto-submit already-signed txs:
|
|
5775
|
-
if (!("
|
|
5447
|
+
if (!("rawTransaction" in txMeta)) return this.approveTransaction(txMeta.id);
|
|
5776
5448
|
const {
|
|
5777
|
-
|
|
5449
|
+
rawTransaction
|
|
5778
5450
|
} = txMeta;
|
|
5779
|
-
const txHash = await this.publishTransaction(
|
|
5451
|
+
const txHash = await this.publishTransaction(rawTransaction);
|
|
5780
5452
|
|
|
5781
5453
|
// Increment successful tries:
|
|
5782
5454
|
this.emit(base_controllers_namespaceObject.TX_EVENTS.TX_RETRY, {
|
|
@@ -5840,7 +5512,8 @@ class PendingTransactionTracker extends openlogin_jrpc_namespaceObject.SafeEvent
|
|
|
5840
5512
|
message: "There was a problem loading this transaction."
|
|
5841
5513
|
};
|
|
5842
5514
|
this.emit(base_controllers_namespaceObject.TX_EVENTS.TX_WARNING, {
|
|
5843
|
-
txMeta
|
|
5515
|
+
txMeta,
|
|
5516
|
+
txId
|
|
5844
5517
|
});
|
|
5845
5518
|
}
|
|
5846
5519
|
if (await this._checkIfTxWasDropped(txMeta)) {
|
|
@@ -6042,6 +5715,7 @@ class TransactionStateManager extends base_controllers_namespaceObject.BaseTrans
|
|
|
6042
5715
|
});
|
|
6043
5716
|
}
|
|
6044
5717
|
generateTxMeta(opts = {}) {
|
|
5718
|
+
var _opts$transaction;
|
|
6045
5719
|
const chainId = this.getCurrentChainId();
|
|
6046
5720
|
if (chainId === "loading") throw new Error("Torus is having trouble connecting to the network");
|
|
6047
5721
|
let dappSuggestedGasFees = null;
|
|
@@ -6067,7 +5741,7 @@ class TransactionStateManager extends base_controllers_namespaceObject.BaseTrans
|
|
|
6067
5741
|
}
|
|
6068
5742
|
}
|
|
6069
5743
|
return objectSpread2_default()({
|
|
6070
|
-
id: opts.transaction.id || (0,base_controllers_namespaceObject.randomId)(),
|
|
5744
|
+
id: ((_opts$transaction = opts.transaction) === null || _opts$transaction === void 0 ? void 0 : _opts$transaction.id) || (0,base_controllers_namespaceObject.randomId)(),
|
|
6071
5745
|
time: Date.now(),
|
|
6072
5746
|
status: base_controllers_namespaceObject.TransactionStatus.unapproved,
|
|
6073
5747
|
loadingDefaults: true,
|
|
@@ -6373,7 +6047,7 @@ class TransactionController extends TransactionStateManager {
|
|
|
6373
6047
|
this.signEthTx = signEthTx;
|
|
6374
6048
|
this.provider = provider;
|
|
6375
6049
|
this.txGasUtil = new TransactionGasUtil(this.provider, this.blockTracker);
|
|
6376
|
-
this.nonceTracker = new
|
|
6050
|
+
this.nonceTracker = new NonceTracker({
|
|
6377
6051
|
provider,
|
|
6378
6052
|
blockTracker,
|
|
6379
6053
|
getConfirmedTransactions: this.getConfirmedTransactions.bind(this),
|
|
@@ -6405,15 +6079,15 @@ class TransactionController extends TransactionStateManager {
|
|
|
6405
6079
|
return new Promise((resolve, reject) => {
|
|
6406
6080
|
const handleFinished = msg => {
|
|
6407
6081
|
if (msg.status === base_controllers_namespaceObject.TransactionStatus.rejected) {
|
|
6408
|
-
return reject(
|
|
6082
|
+
return reject(auth_namespaceObject.providerErrors.userRejectedRequest(`Transaction Signature: User denied message signature`));
|
|
6409
6083
|
}
|
|
6410
6084
|
if (msg.status === base_controllers_namespaceObject.TransactionStatus.failed) {
|
|
6411
|
-
return reject(
|
|
6085
|
+
return reject(auth_namespaceObject.rpcErrors.internal(`Transaction Signature: failed to sign message ${msg.error}`));
|
|
6412
6086
|
}
|
|
6413
6087
|
if (msg.status === base_controllers_namespaceObject.TransactionStatus.submitted) {
|
|
6414
6088
|
return resolve(msg.transactionHash);
|
|
6415
6089
|
}
|
|
6416
|
-
return reject(
|
|
6090
|
+
return reject(auth_namespaceObject.rpcErrors.internal(`Transaction Signature: Unknown problem: ${JSON.stringify(txMeta.transaction)}`));
|
|
6417
6091
|
};
|
|
6418
6092
|
this.once(`${txMeta.id}:finished`, handleFinished);
|
|
6419
6093
|
});
|
|
@@ -6476,6 +6150,7 @@ class TransactionController extends TransactionStateManager {
|
|
|
6476
6150
|
const {
|
|
6477
6151
|
TransactionFactory
|
|
6478
6152
|
} = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 81, 23));
|
|
6153
|
+
// TODO: fix this when @ethereumjs/tx is updated.
|
|
6479
6154
|
const unsignedEthTx = TransactionFactory.fromTxData(txParams, {
|
|
6480
6155
|
common
|
|
6481
6156
|
});
|
|
@@ -6748,12 +6423,12 @@ class TransactionController extends TransactionStateManager {
|
|
|
6748
6423
|
this.updateTransactionInState(txMeta);
|
|
6749
6424
|
}
|
|
6750
6425
|
});
|
|
6751
|
-
this.pendingTxTracker.on(base_controllers_namespaceObject.TX_EVENTS.TX_RETRY,
|
|
6752
|
-
if (!("retryCount" in txMeta)) {
|
|
6753
|
-
txMeta.retryCount = 0;
|
|
6426
|
+
this.pendingTxTracker.on(base_controllers_namespaceObject.TX_EVENTS.TX_RETRY, data => {
|
|
6427
|
+
if (!("retryCount" in data.txMeta)) {
|
|
6428
|
+
data.txMeta.retryCount = 0;
|
|
6754
6429
|
}
|
|
6755
|
-
txMeta.retryCount += 1;
|
|
6756
|
-
this.updateTransactionInState(txMeta);
|
|
6430
|
+
data.txMeta.retryCount += 1;
|
|
6431
|
+
this.updateTransactionInState(data.txMeta);
|
|
6757
6432
|
});
|
|
6758
6433
|
this.pendingTxTracker.on(base_controllers_namespaceObject.TX_EVENTS.TX_FAILED, data => {
|
|
6759
6434
|
this.setTxStatusFailed(data.txId, data.error);
|
|
@@ -6824,9 +6499,16 @@ class TransactionController extends TransactionStateManager {
|
|
|
6824
6499
|
});
|
|
6825
6500
|
}
|
|
6826
6501
|
}
|
|
6827
|
-
;// CONCATENATED MODULE: ./src/
|
|
6502
|
+
;// CONCATENATED MODULE: ./src/utils/interfaces.ts
|
|
6503
|
+
|
|
6828
6504
|
|
|
6829
6505
|
|
|
6506
|
+
/**
|
|
6507
|
+
* Ref - https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactionreceipt
|
|
6508
|
+
*/
|
|
6509
|
+
|
|
6510
|
+
// TODO:// mark fields which will be optional.
|
|
6511
|
+
;// CONCATENATED MODULE: ./src/index.ts
|
|
6830
6512
|
|
|
6831
6513
|
|
|
6832
6514
|
|