@metamask-previews/transaction-controller 35.1.0-preview-7f2b7307 → 35.1.0-preview-12fc043b
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/TransactionController.js +19 -19
- package/dist/TransactionController.mjs +18 -18
- package/dist/{chunk-RXIUMVA5.js → chunk-GPS6RX64.js} +16 -1
- package/dist/chunk-GPS6RX64.js.map +1 -0
- package/dist/{chunk-5ZEJT5SN.mjs → chunk-LTPS73D7.mjs} +16 -1
- package/dist/chunk-LTPS73D7.mjs.map +1 -0
- package/dist/{chunk-3XTJMUNK.js → chunk-S3RZBMF7.js} +44 -31
- package/dist/chunk-S3RZBMF7.js.map +1 -0
- package/dist/{chunk-QV34E5FX.mjs → chunk-T3GOPPVF.mjs} +56 -43
- package/dist/chunk-T3GOPPVF.mjs.map +1 -0
- package/dist/gas-flows/DefaultGasFeeFlow.js +1 -1
- package/dist/gas-flows/DefaultGasFeeFlow.mjs +1 -1
- package/dist/gas-flows/LineaGasFeeFlow.js +1 -1
- package/dist/gas-flows/LineaGasFeeFlow.mjs +1 -1
- package/dist/index.js +22 -22
- package/dist/index.mjs +21 -21
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/TransactionController.d.ts.map +1 -1
- package/dist/types/utils/validation.d.ts.map +1 -1
- package/dist/utils/gas-fees.js +1 -1
- package/dist/utils/gas-fees.mjs +1 -1
- package/dist/utils/validation.js +2 -2
- package/dist/utils/validation.mjs +1 -1
- package/package.json +3 -3
- package/dist/chunk-3XTJMUNK.js.map +0 -1
- package/dist/chunk-5ZEJT5SN.mjs.map +0 -1
- package/dist/chunk-QV34E5FX.mjs.map +0 -1
- package/dist/chunk-RXIUMVA5.js.map +0 -1
|
@@ -4,34 +4,34 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
8
|
-
require('./chunk-RXIUMVA5.js');
|
|
9
|
-
require('./chunk-ARZHJFVG.js');
|
|
10
|
-
require('./chunk-QTKXIDGE.js');
|
|
11
|
-
require('./chunk-NYKRCWBG.js');
|
|
12
|
-
require('./chunk-WR5F34OW.js');
|
|
13
|
-
require('./chunk-YVCX6Z75.js');
|
|
14
|
-
require('./chunk-TJMQEH57.js');
|
|
15
|
-
require('./chunk-TIE3CPF7.js');
|
|
7
|
+
var _chunkS3RZBMF7js = require('./chunk-S3RZBMF7.js');
|
|
16
8
|
require('./chunk-PRUNMTRD.js');
|
|
17
9
|
require('./chunk-NNCUD3QF.js');
|
|
18
10
|
require('./chunk-KT6UAKBB.js');
|
|
19
11
|
require('./chunk-SD6CWFDF.js');
|
|
20
|
-
require('./chunk-
|
|
21
|
-
require('./chunk-6OLJWLKK.js');
|
|
12
|
+
require('./chunk-GPS6RX64.js');
|
|
22
13
|
require('./chunk-ULD4JC3Q.js');
|
|
23
14
|
require('./chunk-7LXE4KHV.js');
|
|
24
|
-
require('./chunk-C3WC4OJ3.js');
|
|
25
|
-
require('./chunk-QH2H4W3N.js');
|
|
26
|
-
require('./chunk-OZ6UB42C.js');
|
|
27
15
|
require('./chunk-V72C4MCR.js');
|
|
28
|
-
require('./chunk-
|
|
29
|
-
require('./chunk-
|
|
30
|
-
require('./chunk-
|
|
31
|
-
require('./chunk-
|
|
16
|
+
require('./chunk-TIE3CPF7.js');
|
|
17
|
+
require('./chunk-NYKRCWBG.js');
|
|
18
|
+
require('./chunk-WR5F34OW.js');
|
|
19
|
+
require('./chunk-YVCX6Z75.js');
|
|
20
|
+
require('./chunk-TJMQEH57.js');
|
|
32
21
|
require('./chunk-2EU6346V.js');
|
|
33
22
|
require('./chunk-2XKEAKQG.js');
|
|
23
|
+
require('./chunk-RHDPOIS4.js');
|
|
24
|
+
require('./chunk-6OLJWLKK.js');
|
|
25
|
+
require('./chunk-7NMV2NPM.js');
|
|
26
|
+
require('./chunk-XVYXRCRL.js');
|
|
27
|
+
require('./chunk-HMOSP33F.js');
|
|
28
|
+
require('./chunk-ARZHJFVG.js');
|
|
29
|
+
require('./chunk-QTKXIDGE.js');
|
|
30
|
+
require('./chunk-C3WC4OJ3.js');
|
|
31
|
+
require('./chunk-QH2H4W3N.js');
|
|
32
|
+
require('./chunk-OZ6UB42C.js');
|
|
34
33
|
require('./chunk-76FONEDA.js');
|
|
34
|
+
require('./chunk-UGN7PBON.js');
|
|
35
35
|
require('./chunk-S6VGOPUY.js');
|
|
36
36
|
require('./chunk-AYTU4HU5.js');
|
|
37
37
|
require('./chunk-Z4BLTVTB.js');
|
|
@@ -41,5 +41,5 @@ require('./chunk-Z4BLTVTB.js');
|
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
exports.ApprovalState =
|
|
44
|
+
exports.ApprovalState = _chunkS3RZBMF7js.ApprovalState; exports.CANCEL_RATE = _chunkS3RZBMF7js.CANCEL_RATE; exports.HARDFORK = _chunkS3RZBMF7js.HARDFORK; exports.SPEED_UP_RATE = _chunkS3RZBMF7js.SPEED_UP_RATE; exports.TransactionController = _chunkS3RZBMF7js.TransactionController;
|
|
45
45
|
//# sourceMappingURL=TransactionController.js.map
|
|
@@ -4,34 +4,34 @@ import {
|
|
|
4
4
|
HARDFORK,
|
|
5
5
|
SPEED_UP_RATE,
|
|
6
6
|
TransactionController
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-5ZEJT5SN.mjs";
|
|
9
|
-
import "./chunk-UHG2LLVV.mjs";
|
|
10
|
-
import "./chunk-H2KZOK3J.mjs";
|
|
11
|
-
import "./chunk-VEVVBHP3.mjs";
|
|
12
|
-
import "./chunk-Z4GV3YQQ.mjs";
|
|
13
|
-
import "./chunk-FG74Z3F5.mjs";
|
|
14
|
-
import "./chunk-FMRLPVFZ.mjs";
|
|
15
|
-
import "./chunk-SMC5Q6ZH.mjs";
|
|
7
|
+
} from "./chunk-T3GOPPVF.mjs";
|
|
16
8
|
import "./chunk-6DDVVUJC.mjs";
|
|
17
9
|
import "./chunk-3AVRGHUO.mjs";
|
|
18
10
|
import "./chunk-K4KOSAGM.mjs";
|
|
19
11
|
import "./chunk-KG4UW4K4.mjs";
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-4V4XIPCI.mjs";
|
|
12
|
+
import "./chunk-LTPS73D7.mjs";
|
|
22
13
|
import "./chunk-6B5BEO3R.mjs";
|
|
23
14
|
import "./chunk-FRKQ3Z2L.mjs";
|
|
24
|
-
import "./chunk-VXNPVIYL.mjs";
|
|
25
|
-
import "./chunk-GNAL5HC2.mjs";
|
|
26
|
-
import "./chunk-Q56I5ONX.mjs";
|
|
27
15
|
import "./chunk-5G6OHAXI.mjs";
|
|
28
|
-
import "./chunk-
|
|
29
|
-
import "./chunk-
|
|
30
|
-
import "./chunk-
|
|
31
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-SMC5Q6ZH.mjs";
|
|
17
|
+
import "./chunk-VEVVBHP3.mjs";
|
|
18
|
+
import "./chunk-Z4GV3YQQ.mjs";
|
|
19
|
+
import "./chunk-FG74Z3F5.mjs";
|
|
20
|
+
import "./chunk-FMRLPVFZ.mjs";
|
|
32
21
|
import "./chunk-SFFTNB2X.mjs";
|
|
33
22
|
import "./chunk-NOHEXQ7Y.mjs";
|
|
23
|
+
import "./chunk-3ZV5YEUV.mjs";
|
|
24
|
+
import "./chunk-4V4XIPCI.mjs";
|
|
25
|
+
import "./chunk-EKJXGERC.mjs";
|
|
26
|
+
import "./chunk-EGQCE3FK.mjs";
|
|
27
|
+
import "./chunk-HQSNKCXI.mjs";
|
|
28
|
+
import "./chunk-UHG2LLVV.mjs";
|
|
29
|
+
import "./chunk-H2KZOK3J.mjs";
|
|
30
|
+
import "./chunk-VXNPVIYL.mjs";
|
|
31
|
+
import "./chunk-GNAL5HC2.mjs";
|
|
32
|
+
import "./chunk-Q56I5ONX.mjs";
|
|
34
33
|
import "./chunk-JXXTNVU4.mjs";
|
|
34
|
+
import "./chunk-O6ZZVIFH.mjs";
|
|
35
35
|
import "./chunk-UQQWZT6C.mjs";
|
|
36
36
|
import "./chunk-6SJYXSF3.mjs";
|
|
37
37
|
import "./chunk-XUI43LEZ.mjs";
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var _chunkOZ6UB42Cjs = require('./chunk-OZ6UB42C.js');
|
|
4
4
|
|
|
5
|
+
|
|
6
|
+
var _chunkAYTU4HU5js = require('./chunk-AYTU4HU5.js');
|
|
7
|
+
|
|
5
8
|
// src/utils/validation.ts
|
|
6
9
|
var _abi = require('@ethersproject/abi');
|
|
7
10
|
var _controllerutils = require('@metamask/controller-utils');
|
|
@@ -26,6 +29,7 @@ async function validateTransactionOrigin(permittedAddresses, selectedAddress, fr
|
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
31
|
function validateTxParams(txParams, isEIP1559Compatible = true) {
|
|
32
|
+
validateEnvelopeType(txParams.type);
|
|
29
33
|
validateEIP1559Compatibility(txParams, isEIP1559Compatible);
|
|
30
34
|
validateParamFrom(txParams.from);
|
|
31
35
|
validateParamRecipient(txParams);
|
|
@@ -34,6 +38,17 @@ function validateTxParams(txParams, isEIP1559Compatible = true) {
|
|
|
34
38
|
validateParamChainId(txParams.chainId);
|
|
35
39
|
validateGasFeeParams(txParams);
|
|
36
40
|
}
|
|
41
|
+
function validateEnvelopeType(type) {
|
|
42
|
+
if (type && !Object.values(_chunkAYTU4HU5js.TransactionEnvelopeType).includes(
|
|
43
|
+
type
|
|
44
|
+
)) {
|
|
45
|
+
throw _rpcerrors.rpcErrors.invalidParams(
|
|
46
|
+
`Invalid transaction envelope type: "${type}". Must be one of: ${Object.values(
|
|
47
|
+
_chunkAYTU4HU5js.TransactionEnvelopeType
|
|
48
|
+
).join(", ")}`
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
37
52
|
function validateEIP1559Compatibility(txParams, isEIP1559Compatible) {
|
|
38
53
|
if (_chunkOZ6UB42Cjs.isEIP1559Transaction.call(void 0, txParams) && !isEIP1559Compatible) {
|
|
39
54
|
throw _rpcerrors.rpcErrors.invalidParams(
|
|
@@ -183,4 +198,4 @@ function ensureFieldIsString(txParams, field) {
|
|
|
183
198
|
|
|
184
199
|
|
|
185
200
|
exports.validateTransactionOrigin = validateTransactionOrigin; exports.validateTxParams = validateTxParams;
|
|
186
|
-
//# sourceMappingURL=chunk-
|
|
201
|
+
//# sourceMappingURL=chunk-GPS6RX64.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/validation.ts"],"names":[],"mappings":";;;;;;;;AAAA,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB,yBAAyB;AACnD,SAAS,gBAAgB;AACzB,SAAS,gBAAgB,iBAAiB;AAgB1C,eAAsB,0BACpB,oBACA,iBACA,MACA,QACA;AACA,MAAI,WAAW,iBAAiB;AAE9B,QAAI,SAAS,iBAAiB;AAC5B,YAAM,UAAU,SAAS;AAAA,QACvB,SAAS;AAAA,QACT,MAAM;AAAA,UACJ;AAAA,UACA,aAAa;AAAA,UACb;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AACA;AAAA,EACF;AAGA,MAAI,CAAC,mBAAmB,SAAS,IAAI,GAAG;AACtC,UAAM,eAAe,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAAA,EACxD;AACF;AASO,SAAS,iBACd,UACA,sBAAsB,MACtB;AACA,uBAAqB,SAAS,IAAI;AAClC,+BAA6B,UAAU,mBAAmB;AAC1D,oBAAkB,SAAS,IAAI;AAC/B,yBAAuB,QAAQ;AAC/B,qBAAmB,SAAS,KAAK;AACjC,oBAAkB,SAAS,IAAI;AAC/B,uBAAqB,SAAS,OAAO;AACrC,uBAAqB,QAAQ;AAC/B;AAQA,SAAS,qBAAqB,MAA0B;AACtD,MACE,QACA,CAAC,OAAO,OAAO,uBAAuB,EAAE;AAAA,IACtC;AAAA,EACF,GACA;AACA,UAAM,UAAU;AAAA,MACd,uCAAuC,IAAI,sBAAsB,OAAO;AAAA,QACtE;AAAA,MACF,EAA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AAM,UAAU;AAAA,UACd,sDAAsD,SAAS,IAAI;AAAA,QACrE;AAAA,MACF;AAAA,EACJ;AACF;AAYA,SAAS,yCACP,UACA,qBACA,wBACA;AACA,MAAI,OAAO,SAAS,sBAAsB,MAAM,aAAa;AAC3D,UAAM,UAAU;AAAA,MACd,yCAAyC,mBAAmB,sBAAsB,sBAAsB;AAAA,IAC1G;AAAA,EACF;AACF;AAUA,SAAS,oBACP,UACA,OACA;AACA,MAAI,OAAO,SAAS,KAAK,MAAM,UAAU;AACvC,UAAM,UAAU;AAAA;AAAA;AAAA,MAGd,+BAA+B,KAAK,2BAA2B,SAAS,KAAK,CAAC;AAAA,IAChF;AAAA,EACF;AACF","sourcesContent":["import { Interface } from '@ethersproject/abi';\nimport { ORIGIN_METAMASK, isValidHexAddress } from '@metamask/controller-utils';\nimport { abiERC20 } from '@metamask/metamask-eth-abis';\nimport { providerErrors, rpcErrors } from '@metamask/rpc-errors';\n\nimport { TransactionEnvelopeType, type TransactionParams } from '../types';\nimport { isEIP1559Transaction } from './utils';\n\ntype GasFieldsToValidate = 'gasPrice' | 'maxFeePerGas' | 'maxPriorityFeePerGas';\n\n/**\n * Validates whether a transaction initiated by a specific 'from' address is permitted by the origin.\n *\n * @param permittedAddresses - The permitted accounts for the given origin.\n * @param selectedAddress - The currently selected Ethereum address in the wallet.\n * @param from - The address from which the transaction is initiated.\n * @param origin - The origin or source of the transaction.\n * @throws Throws an error if the transaction is not permitted.\n */\nexport async function validateTransactionOrigin(\n permittedAddresses: string[],\n selectedAddress: string,\n from: string,\n origin: string,\n) {\n if (origin === ORIGIN_METAMASK) {\n // Ensure the 'from' address matches the currently selected address\n if (from !== selectedAddress) {\n throw rpcErrors.internal({\n message: `Internally initiated transaction is using invalid account.`,\n data: {\n origin,\n fromAddress: from,\n selectedAddress,\n },\n });\n }\n return;\n }\n\n // Check if the origin has permissions to initiate transactions from the specified address\n if (!permittedAddresses.includes(from)) {\n throw providerErrors.unauthorized({ data: { origin } });\n }\n}\n\n/**\n * Validates the transaction params for required properties and throws in\n * the event of any validation error.\n *\n * @param txParams - Transaction params object to validate.\n * @param isEIP1559Compatible - whether or not the current network supports EIP-1559 transactions.\n */\nexport function validateTxParams(\n txParams: TransactionParams,\n isEIP1559Compatible = true,\n) {\n validateEnvelopeType(txParams.type);\n validateEIP1559Compatibility(txParams, isEIP1559Compatible);\n validateParamFrom(txParams.from);\n validateParamRecipient(txParams);\n validateParamValue(txParams.value);\n validateParamData(txParams.data);\n validateParamChainId(txParams.chainId);\n validateGasFeeParams(txParams);\n}\n\n/**\n * Validates the `type` property, ensuring that if it is specified, it is a valid transaction envelope type.\n *\n * @param type - The transaction envelope type to validate.\n * @throws Throws invalid params if the type is not a valid transaction envelope type.\n */\nfunction validateEnvelopeType(type: string | undefined) {\n if (\n type &&\n !Object.values(TransactionEnvelopeType).includes(\n type as TransactionEnvelopeType,\n )\n ) {\n throw rpcErrors.invalidParams(\n `Invalid transaction envelope type: \"${type}\". Must be one of: ${Object.values(\n TransactionEnvelopeType,\n ).join(', ')}`,\n );\n }\n}\n\n/**\n * Validates EIP-1559 compatibility for transaction creation.\n *\n * @param txParams - The transaction parameters to validate.\n * @param isEIP1559Compatible - Indicates if the current network supports EIP-1559.\n * @throws Throws invalid params if the transaction specifies EIP-1559 but the network does not support it.\n */\nfunction validateEIP1559Compatibility(\n txParams: TransactionParams,\n isEIP1559Compatible: boolean,\n) {\n if (isEIP1559Transaction(txParams) && !isEIP1559Compatible) {\n throw rpcErrors.invalidParams(\n 'Invalid transaction params: params specify an EIP-1559 transaction but the current network does not support EIP-1559',\n );\n }\n}\n\n/**\n * Validates value property, ensuring it is a valid positive integer number\n * denominated in wei.\n *\n * @param value - The value to validate, expressed as a string.\n * @throws Throws an error if the value is not a valid positive integer\n * number denominated in wei.\n * - If the value contains a hyphen (-), it is considered invalid.\n * - If the value contains a decimal point (.), it is considered invalid.\n * - If the value is not a finite number, is NaN, or is not a safe integer, it is considered invalid.\n */\nfunction validateParamValue(value?: string) {\n if (value !== undefined) {\n if (value.includes('-')) {\n throw rpcErrors.invalidParams(\n `Invalid transaction value \"${value}\": not a positive number.`,\n );\n }\n\n if (value.includes('.')) {\n throw rpcErrors.invalidParams(\n `Invalid transaction value \"${value}\": number must be in wei.`,\n );\n }\n const intValue = parseInt(value, 10);\n const isValid =\n Number.isFinite(intValue) &&\n !Number.isNaN(intValue) &&\n !isNaN(Number(value)) &&\n Number.isSafeInteger(intValue);\n if (!isValid) {\n throw rpcErrors.invalidParams(\n `Invalid transaction value ${value}: number must be a valid number.`,\n );\n }\n }\n}\n\n/**\n * Validates the recipient address in a transaction's parameters.\n *\n * @param txParams - The transaction parameters object to validate.\n * @throws Throws an error if the recipient address is invalid:\n * - If the recipient address is an empty string ('0x') or undefined and the transaction contains data,\n * the \"to\" field is removed from the transaction parameters.\n * - If the recipient address is not a valid hexadecimal Ethereum address, an error is thrown.\n */\nfunction validateParamRecipient(txParams: TransactionParams) {\n if (txParams.to === '0x' || txParams.to === undefined) {\n if (txParams.data) {\n delete txParams.to;\n } else {\n throw rpcErrors.invalidParams(`Invalid \"to\" address.`);\n }\n } else if (txParams.to !== undefined && !isValidHexAddress(txParams.to)) {\n throw rpcErrors.invalidParams(`Invalid \"to\" address.`);\n }\n}\n\n/**\n * Validates the recipient address in a transaction's parameters.\n *\n * @param from - The from property to validate.\n * @throws Throws an error if the recipient address is invalid:\n * - If the recipient address is an empty string ('0x') or undefined and the transaction contains data,\n * the \"to\" field is removed from the transaction parameters.\n * - If the recipient address is not a valid hexadecimal Ethereum address, an error is thrown.\n */\nfunction validateParamFrom(from: string) {\n if (!from || typeof from !== 'string') {\n throw rpcErrors.invalidParams(\n `Invalid \"from\" address ${from}: not a string.`,\n );\n }\n if (!isValidHexAddress(from)) {\n throw rpcErrors.invalidParams('Invalid \"from\" address.');\n }\n}\n\n/**\n * Validates input data for transactions.\n *\n * @param value - The input data to validate.\n * @throws Throws invalid params if the input data is invalid.\n */\nfunction validateParamData(value?: string) {\n if (value) {\n const ERC20Interface = new Interface(abiERC20);\n try {\n ERC20Interface.parseTransaction({ data: value });\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (error.message.match(/BUFFER_OVERRUN/u)) {\n throw rpcErrors.invalidParams(\n 'Invalid transaction params: data out-of-bounds, BUFFER_OVERRUN.',\n );\n }\n }\n }\n}\n\n/**\n * Validates chainId type.\n *\n * @param chainId - The chainId to validate.\n */\nfunction validateParamChainId(chainId: number | string | undefined) {\n if (\n chainId !== undefined &&\n typeof chainId !== 'number' &&\n typeof chainId !== 'string'\n ) {\n throw rpcErrors.invalidParams(\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n `Invalid transaction params: chainId is not a Number or hex string. got: (${chainId})`,\n );\n }\n}\n\n/**\n * Validates gas values.\n *\n * @param txParams - The transaction parameters to validate.\n */\nfunction validateGasFeeParams(txParams: TransactionParams) {\n if (txParams.gasPrice) {\n ensureProperTransactionEnvelopeTypeProvided(txParams, 'gasPrice');\n ensureMutuallyExclusiveFieldsNotProvided(\n txParams,\n 'gasPrice',\n 'maxFeePerGas',\n );\n ensureMutuallyExclusiveFieldsNotProvided(\n txParams,\n 'gasPrice',\n 'maxPriorityFeePerGas',\n );\n ensureFieldIsString(txParams, 'gasPrice');\n }\n\n if (txParams.maxFeePerGas) {\n ensureProperTransactionEnvelopeTypeProvided(txParams, 'maxFeePerGas');\n ensureMutuallyExclusiveFieldsNotProvided(\n txParams,\n 'maxFeePerGas',\n 'gasPrice',\n );\n ensureFieldIsString(txParams, 'maxFeePerGas');\n }\n\n if (txParams.maxPriorityFeePerGas) {\n ensureProperTransactionEnvelopeTypeProvided(\n txParams,\n 'maxPriorityFeePerGas',\n );\n ensureMutuallyExclusiveFieldsNotProvided(\n txParams,\n 'maxPriorityFeePerGas',\n 'gasPrice',\n );\n ensureFieldIsString(txParams, 'maxPriorityFeePerGas');\n }\n}\n\n/**\n * Ensures that the provided txParams has the proper 'type' specified for the\n * given field, if it is provided. If types do not match throws an\n * invalidParams error.\n *\n * @param txParams - The transaction parameters object\n * @param field - The current field being validated\n * @throws {ethErrors.rpc.invalidParams} Throws if type does not match the\n * expectations for provided field.\n */\nfunction ensureProperTransactionEnvelopeTypeProvided(\n txParams: TransactionParams,\n field: GasFieldsToValidate,\n) {\n switch (field) {\n case 'maxFeePerGas':\n case 'maxPriorityFeePerGas':\n if (\n txParams.type &&\n txParams.type !== TransactionEnvelopeType.feeMarket\n ) {\n throw rpcErrors.invalidParams(\n `Invalid transaction envelope type: specified type \"${txParams.type}\" but including maxFeePerGas and maxPriorityFeePerGas requires type: \"${TransactionEnvelopeType.feeMarket}\"`,\n );\n }\n break;\n case 'gasPrice':\n default:\n if (\n txParams.type &&\n txParams.type === TransactionEnvelopeType.feeMarket\n ) {\n throw rpcErrors.invalidParams(\n `Invalid transaction envelope type: specified type \"${txParams.type}\" but included a gasPrice instead of maxFeePerGas and maxPriorityFeePerGas`,\n );\n }\n }\n}\n\n/**\n * Given two fields, ensure that the second field is not included in txParams,\n * and if it is throw an invalidParams error.\n *\n * @param txParams - The transaction parameters object\n * @param fieldBeingValidated - The current field being validated\n * @param mutuallyExclusiveField - The field to ensure is not provided\n * @throws {ethErrors.rpc.invalidParams} Throws if mutuallyExclusiveField is\n * present in txParams.\n */\nfunction ensureMutuallyExclusiveFieldsNotProvided(\n txParams: TransactionParams,\n fieldBeingValidated: GasFieldsToValidate,\n mutuallyExclusiveField: GasFieldsToValidate,\n) {\n if (typeof txParams[mutuallyExclusiveField] !== 'undefined') {\n throw rpcErrors.invalidParams(\n `Invalid transaction params: specified ${fieldBeingValidated} but also included ${mutuallyExclusiveField}, these cannot be mixed`,\n );\n }\n}\n\n/**\n * Ensures that the provided value for field is a string, throws an\n * invalidParams error if field is not a string.\n *\n * @param txParams - The transaction parameters object\n * @param field - The current field being validated\n * @throws {rpcErrors.invalidParams} Throws if field is not a string\n */\nfunction ensureFieldIsString(\n txParams: TransactionParams,\n field: GasFieldsToValidate,\n) {\n if (typeof txParams[field] !== 'string') {\n throw rpcErrors.invalidParams(\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n `Invalid transaction params: ${field} is not a string. got: (${txParams[field]})`,\n );\n }\n}\n"]}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isEIP1559Transaction
|
|
3
3
|
} from "./chunk-Q56I5ONX.mjs";
|
|
4
|
+
import {
|
|
5
|
+
TransactionEnvelopeType
|
|
6
|
+
} from "./chunk-6SJYXSF3.mjs";
|
|
4
7
|
|
|
5
8
|
// src/utils/validation.ts
|
|
6
9
|
import { Interface } from "@ethersproject/abi";
|
|
@@ -26,6 +29,7 @@ async function validateTransactionOrigin(permittedAddresses, selectedAddress, fr
|
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
31
|
function validateTxParams(txParams, isEIP1559Compatible = true) {
|
|
32
|
+
validateEnvelopeType(txParams.type);
|
|
29
33
|
validateEIP1559Compatibility(txParams, isEIP1559Compatible);
|
|
30
34
|
validateParamFrom(txParams.from);
|
|
31
35
|
validateParamRecipient(txParams);
|
|
@@ -34,6 +38,17 @@ function validateTxParams(txParams, isEIP1559Compatible = true) {
|
|
|
34
38
|
validateParamChainId(txParams.chainId);
|
|
35
39
|
validateGasFeeParams(txParams);
|
|
36
40
|
}
|
|
41
|
+
function validateEnvelopeType(type) {
|
|
42
|
+
if (type && !Object.values(TransactionEnvelopeType).includes(
|
|
43
|
+
type
|
|
44
|
+
)) {
|
|
45
|
+
throw rpcErrors.invalidParams(
|
|
46
|
+
`Invalid transaction envelope type: "${type}". Must be one of: ${Object.values(
|
|
47
|
+
TransactionEnvelopeType
|
|
48
|
+
).join(", ")}`
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
37
52
|
function validateEIP1559Compatibility(txParams, isEIP1559Compatible) {
|
|
38
53
|
if (isEIP1559Transaction(txParams) && !isEIP1559Compatible) {
|
|
39
54
|
throw rpcErrors.invalidParams(
|
|
@@ -183,4 +198,4 @@ export {
|
|
|
183
198
|
validateTransactionOrigin,
|
|
184
199
|
validateTxParams
|
|
185
200
|
};
|
|
186
|
-
//# sourceMappingURL=chunk-
|
|
201
|
+
//# sourceMappingURL=chunk-LTPS73D7.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/validation.ts"],"sourcesContent":["import { Interface } from '@ethersproject/abi';\nimport { ORIGIN_METAMASK, isValidHexAddress } from '@metamask/controller-utils';\nimport { abiERC20 } from '@metamask/metamask-eth-abis';\nimport { providerErrors, rpcErrors } from '@metamask/rpc-errors';\n\nimport { TransactionEnvelopeType, type TransactionParams } from '../types';\nimport { isEIP1559Transaction } from './utils';\n\ntype GasFieldsToValidate = 'gasPrice' | 'maxFeePerGas' | 'maxPriorityFeePerGas';\n\n/**\n * Validates whether a transaction initiated by a specific 'from' address is permitted by the origin.\n *\n * @param permittedAddresses - The permitted accounts for the given origin.\n * @param selectedAddress - The currently selected Ethereum address in the wallet.\n * @param from - The address from which the transaction is initiated.\n * @param origin - The origin or source of the transaction.\n * @throws Throws an error if the transaction is not permitted.\n */\nexport async function validateTransactionOrigin(\n permittedAddresses: string[],\n selectedAddress: string,\n from: string,\n origin: string,\n) {\n if (origin === ORIGIN_METAMASK) {\n // Ensure the 'from' address matches the currently selected address\n if (from !== selectedAddress) {\n throw rpcErrors.internal({\n message: `Internally initiated transaction is using invalid account.`,\n data: {\n origin,\n fromAddress: from,\n selectedAddress,\n },\n });\n }\n return;\n }\n\n // Check if the origin has permissions to initiate transactions from the specified address\n if (!permittedAddresses.includes(from)) {\n throw providerErrors.unauthorized({ data: { origin } });\n }\n}\n\n/**\n * Validates the transaction params for required properties and throws in\n * the event of any validation error.\n *\n * @param txParams - Transaction params object to validate.\n * @param isEIP1559Compatible - whether or not the current network supports EIP-1559 transactions.\n */\nexport function validateTxParams(\n txParams: TransactionParams,\n isEIP1559Compatible = true,\n) {\n validateEnvelopeType(txParams.type);\n validateEIP1559Compatibility(txParams, isEIP1559Compatible);\n validateParamFrom(txParams.from);\n validateParamRecipient(txParams);\n validateParamValue(txParams.value);\n validateParamData(txParams.data);\n validateParamChainId(txParams.chainId);\n validateGasFeeParams(txParams);\n}\n\n/**\n * Validates the `type` property, ensuring that if it is specified, it is a valid transaction envelope type.\n *\n * @param type - The transaction envelope type to validate.\n * @throws Throws invalid params if the type is not a valid transaction envelope type.\n */\nfunction validateEnvelopeType(type: string | undefined) {\n if (\n type &&\n !Object.values(TransactionEnvelopeType).includes(\n type as TransactionEnvelopeType,\n )\n ) {\n throw rpcErrors.invalidParams(\n `Invalid transaction envelope type: \"${type}\". Must be one of: ${Object.values(\n TransactionEnvelopeType,\n ).join(', ')}`,\n );\n }\n}\n\n/**\n * Validates EIP-1559 compatibility for transaction creation.\n *\n * @param txParams - The transaction parameters to validate.\n * @param isEIP1559Compatible - Indicates if the current network supports EIP-1559.\n * @throws Throws invalid params if the transaction specifies EIP-1559 but the network does not support it.\n */\nfunction validateEIP1559Compatibility(\n txParams: TransactionParams,\n isEIP1559Compatible: boolean,\n) {\n if (isEIP1559Transaction(txParams) && !isEIP1559Compatible) {\n throw rpcErrors.invalidParams(\n 'Invalid transaction params: params specify an EIP-1559 transaction but the current network does not support EIP-1559',\n );\n }\n}\n\n/**\n * Validates value property, ensuring it is a valid positive integer number\n * denominated in wei.\n *\n * @param value - The value to validate, expressed as a string.\n * @throws Throws an error if the value is not a valid positive integer\n * number denominated in wei.\n * - If the value contains a hyphen (-), it is considered invalid.\n * - If the value contains a decimal point (.), it is considered invalid.\n * - If the value is not a finite number, is NaN, or is not a safe integer, it is considered invalid.\n */\nfunction validateParamValue(value?: string) {\n if (value !== undefined) {\n if (value.includes('-')) {\n throw rpcErrors.invalidParams(\n `Invalid transaction value \"${value}\": not a positive number.`,\n );\n }\n\n if (value.includes('.')) {\n throw rpcErrors.invalidParams(\n `Invalid transaction value \"${value}\": number must be in wei.`,\n );\n }\n const intValue = parseInt(value, 10);\n const isValid =\n Number.isFinite(intValue) &&\n !Number.isNaN(intValue) &&\n !isNaN(Number(value)) &&\n Number.isSafeInteger(intValue);\n if (!isValid) {\n throw rpcErrors.invalidParams(\n `Invalid transaction value ${value}: number must be a valid number.`,\n );\n }\n }\n}\n\n/**\n * Validates the recipient address in a transaction's parameters.\n *\n * @param txParams - The transaction parameters object to validate.\n * @throws Throws an error if the recipient address is invalid:\n * - If the recipient address is an empty string ('0x') or undefined and the transaction contains data,\n * the \"to\" field is removed from the transaction parameters.\n * - If the recipient address is not a valid hexadecimal Ethereum address, an error is thrown.\n */\nfunction validateParamRecipient(txParams: TransactionParams) {\n if (txParams.to === '0x' || txParams.to === undefined) {\n if (txParams.data) {\n delete txParams.to;\n } else {\n throw rpcErrors.invalidParams(`Invalid \"to\" address.`);\n }\n } else if (txParams.to !== undefined && !isValidHexAddress(txParams.to)) {\n throw rpcErrors.invalidParams(`Invalid \"to\" address.`);\n }\n}\n\n/**\n * Validates the recipient address in a transaction's parameters.\n *\n * @param from - The from property to validate.\n * @throws Throws an error if the recipient address is invalid:\n * - If the recipient address is an empty string ('0x') or undefined and the transaction contains data,\n * the \"to\" field is removed from the transaction parameters.\n * - If the recipient address is not a valid hexadecimal Ethereum address, an error is thrown.\n */\nfunction validateParamFrom(from: string) {\n if (!from || typeof from !== 'string') {\n throw rpcErrors.invalidParams(\n `Invalid \"from\" address ${from}: not a string.`,\n );\n }\n if (!isValidHexAddress(from)) {\n throw rpcErrors.invalidParams('Invalid \"from\" address.');\n }\n}\n\n/**\n * Validates input data for transactions.\n *\n * @param value - The input data to validate.\n * @throws Throws invalid params if the input data is invalid.\n */\nfunction validateParamData(value?: string) {\n if (value) {\n const ERC20Interface = new Interface(abiERC20);\n try {\n ERC20Interface.parseTransaction({ data: value });\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (error.message.match(/BUFFER_OVERRUN/u)) {\n throw rpcErrors.invalidParams(\n 'Invalid transaction params: data out-of-bounds, BUFFER_OVERRUN.',\n );\n }\n }\n }\n}\n\n/**\n * Validates chainId type.\n *\n * @param chainId - The chainId to validate.\n */\nfunction validateParamChainId(chainId: number | string | undefined) {\n if (\n chainId !== undefined &&\n typeof chainId !== 'number' &&\n typeof chainId !== 'string'\n ) {\n throw rpcErrors.invalidParams(\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n `Invalid transaction params: chainId is not a Number or hex string. got: (${chainId})`,\n );\n }\n}\n\n/**\n * Validates gas values.\n *\n * @param txParams - The transaction parameters to validate.\n */\nfunction validateGasFeeParams(txParams: TransactionParams) {\n if (txParams.gasPrice) {\n ensureProperTransactionEnvelopeTypeProvided(txParams, 'gasPrice');\n ensureMutuallyExclusiveFieldsNotProvided(\n txParams,\n 'gasPrice',\n 'maxFeePerGas',\n );\n ensureMutuallyExclusiveFieldsNotProvided(\n txParams,\n 'gasPrice',\n 'maxPriorityFeePerGas',\n );\n ensureFieldIsString(txParams, 'gasPrice');\n }\n\n if (txParams.maxFeePerGas) {\n ensureProperTransactionEnvelopeTypeProvided(txParams, 'maxFeePerGas');\n ensureMutuallyExclusiveFieldsNotProvided(\n txParams,\n 'maxFeePerGas',\n 'gasPrice',\n );\n ensureFieldIsString(txParams, 'maxFeePerGas');\n }\n\n if (txParams.maxPriorityFeePerGas) {\n ensureProperTransactionEnvelopeTypeProvided(\n txParams,\n 'maxPriorityFeePerGas',\n );\n ensureMutuallyExclusiveFieldsNotProvided(\n txParams,\n 'maxPriorityFeePerGas',\n 'gasPrice',\n );\n ensureFieldIsString(txParams, 'maxPriorityFeePerGas');\n }\n}\n\n/**\n * Ensures that the provided txParams has the proper 'type' specified for the\n * given field, if it is provided. If types do not match throws an\n * invalidParams error.\n *\n * @param txParams - The transaction parameters object\n * @param field - The current field being validated\n * @throws {ethErrors.rpc.invalidParams} Throws if type does not match the\n * expectations for provided field.\n */\nfunction ensureProperTransactionEnvelopeTypeProvided(\n txParams: TransactionParams,\n field: GasFieldsToValidate,\n) {\n switch (field) {\n case 'maxFeePerGas':\n case 'maxPriorityFeePerGas':\n if (\n txParams.type &&\n txParams.type !== TransactionEnvelopeType.feeMarket\n ) {\n throw rpcErrors.invalidParams(\n `Invalid transaction envelope type: specified type \"${txParams.type}\" but including maxFeePerGas and maxPriorityFeePerGas requires type: \"${TransactionEnvelopeType.feeMarket}\"`,\n );\n }\n break;\n case 'gasPrice':\n default:\n if (\n txParams.type &&\n txParams.type === TransactionEnvelopeType.feeMarket\n ) {\n throw rpcErrors.invalidParams(\n `Invalid transaction envelope type: specified type \"${txParams.type}\" but included a gasPrice instead of maxFeePerGas and maxPriorityFeePerGas`,\n );\n }\n }\n}\n\n/**\n * Given two fields, ensure that the second field is not included in txParams,\n * and if it is throw an invalidParams error.\n *\n * @param txParams - The transaction parameters object\n * @param fieldBeingValidated - The current field being validated\n * @param mutuallyExclusiveField - The field to ensure is not provided\n * @throws {ethErrors.rpc.invalidParams} Throws if mutuallyExclusiveField is\n * present in txParams.\n */\nfunction ensureMutuallyExclusiveFieldsNotProvided(\n txParams: TransactionParams,\n fieldBeingValidated: GasFieldsToValidate,\n mutuallyExclusiveField: GasFieldsToValidate,\n) {\n if (typeof txParams[mutuallyExclusiveField] !== 'undefined') {\n throw rpcErrors.invalidParams(\n `Invalid transaction params: specified ${fieldBeingValidated} but also included ${mutuallyExclusiveField}, these cannot be mixed`,\n );\n }\n}\n\n/**\n * Ensures that the provided value for field is a string, throws an\n * invalidParams error if field is not a string.\n *\n * @param txParams - The transaction parameters object\n * @param field - The current field being validated\n * @throws {rpcErrors.invalidParams} Throws if field is not a string\n */\nfunction ensureFieldIsString(\n txParams: TransactionParams,\n field: GasFieldsToValidate,\n) {\n if (typeof txParams[field] !== 'string') {\n throw rpcErrors.invalidParams(\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n `Invalid transaction params: ${field} is not a string. got: (${txParams[field]})`,\n );\n }\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB,yBAAyB;AACnD,SAAS,gBAAgB;AACzB,SAAS,gBAAgB,iBAAiB;AAgB1C,eAAsB,0BACpB,oBACA,iBACA,MACA,QACA;AACA,MAAI,WAAW,iBAAiB;AAE9B,QAAI,SAAS,iBAAiB;AAC5B,YAAM,UAAU,SAAS;AAAA,QACvB,SAAS;AAAA,QACT,MAAM;AAAA,UACJ;AAAA,UACA,aAAa;AAAA,UACb;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AACA;AAAA,EACF;AAGA,MAAI,CAAC,mBAAmB,SAAS,IAAI,GAAG;AACtC,UAAM,eAAe,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAAA,EACxD;AACF;AASO,SAAS,iBACd,UACA,sBAAsB,MACtB;AACA,uBAAqB,SAAS,IAAI;AAClC,+BAA6B,UAAU,mBAAmB;AAC1D,oBAAkB,SAAS,IAAI;AAC/B,yBAAuB,QAAQ;AAC/B,qBAAmB,SAAS,KAAK;AACjC,oBAAkB,SAAS,IAAI;AAC/B,uBAAqB,SAAS,OAAO;AACrC,uBAAqB,QAAQ;AAC/B;AAQA,SAAS,qBAAqB,MAA0B;AACtD,MACE,QACA,CAAC,OAAO,OAAO,uBAAuB,EAAE;AAAA,IACtC;AAAA,EACF,GACA;AACA,UAAM,UAAU;AAAA,MACd,uCAAuC,IAAI,sBAAsB,OAAO;AAAA,QACtE;AAAA,MACF,EAAE,KAAK,IAAI,CAAC;AAAA,IACd;AAAA,EACF;AACF;AASA,SAAS,6BACP,UACA,qBACA;AACA,MAAI,qBAAqB,QAAQ,KAAK,CAAC,qBAAqB;AAC1D,UAAM,UAAU;AAAA,MACd;AAAA,IACF;AAAA,EACF;AACF;AAaA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A,MACd,yCAAyC,mBAAmB,sBAAsB,sBAAsB;AAAA,IAC1G;AAAA,EACF;AACF;AAUA,SAAS,oBACP,UACA,OACA;AACA,MAAI,OAAO,SAAS,KAAK,MAAM,UAAU;AACvC,UAAM,UAAU;AAAA;AAAA;AAAA,MAGd,+BAA+B,KAAK,2BAA2B,SAAS,KAAK,CAAC;AAAA,IAChF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,82 +1,82 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkPRUNMTRDjs = require('./chunk-PRUNMTRD.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkNNCUD3QFjs = require('./chunk-NNCUD3QF.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkSD6CWFDFjs = require('./chunk-SD6CWFDF.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var _chunkNYKRCWBGjs = require('./chunk-NYKRCWBG.js');
|
|
14
13
|
|
|
14
|
+
var _chunkGPS6RX64js = require('./chunk-GPS6RX64.js');
|
|
15
15
|
|
|
16
|
-
var _chunkWR5F34OWjs = require('./chunk-WR5F34OW.js');
|
|
17
16
|
|
|
17
|
+
var _chunkULD4JC3Qjs = require('./chunk-ULD4JC3Q.js');
|
|
18
18
|
|
|
19
|
-
var _chunkTJMQEH57js = require('./chunk-TJMQEH57.js');
|
|
20
19
|
|
|
20
|
+
var _chunk7LXE4KHVjs = require('./chunk-7LXE4KHV.js');
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
var _chunkTIE3CPF7js = require('./chunk-TIE3CPF7.js');
|
|
24
23
|
|
|
25
24
|
|
|
25
|
+
var _chunkV72C4MCRjs = require('./chunk-V72C4MCR.js');
|
|
26
26
|
|
|
27
|
-
var _chunkPRUNMTRDjs = require('./chunk-PRUNMTRD.js');
|
|
28
27
|
|
|
29
28
|
|
|
30
|
-
var
|
|
29
|
+
var _chunkTIE3CPF7js = require('./chunk-TIE3CPF7.js');
|
|
31
30
|
|
|
32
31
|
|
|
33
|
-
var
|
|
32
|
+
var _chunkNYKRCWBGjs = require('./chunk-NYKRCWBG.js');
|
|
34
33
|
|
|
35
34
|
|
|
36
|
-
var
|
|
35
|
+
var _chunkWR5F34OWjs = require('./chunk-WR5F34OW.js');
|
|
37
36
|
|
|
38
37
|
|
|
39
|
-
var
|
|
38
|
+
var _chunkTJMQEH57js = require('./chunk-TJMQEH57.js');
|
|
40
39
|
|
|
41
40
|
|
|
42
|
-
var
|
|
41
|
+
var _chunk2EU6346Vjs = require('./chunk-2EU6346V.js');
|
|
43
42
|
|
|
44
43
|
|
|
45
|
-
var _chunk7LXE4KHVjs = require('./chunk-7LXE4KHV.js');
|
|
46
44
|
|
|
45
|
+
var _chunk2XKEAKQGjs = require('./chunk-2XKEAKQG.js');
|
|
47
46
|
|
|
48
|
-
var _chunkC3WC4OJ3js = require('./chunk-C3WC4OJ3.js');
|
|
49
47
|
|
|
48
|
+
var _chunkRHDPOIS4js = require('./chunk-RHDPOIS4.js');
|
|
50
49
|
|
|
51
50
|
|
|
52
|
-
var
|
|
51
|
+
var _chunk6OLJWLKKjs = require('./chunk-6OLJWLKK.js');
|
|
53
52
|
|
|
54
53
|
|
|
54
|
+
var _chunk7NMV2NPMjs = require('./chunk-7NMV2NPM.js');
|
|
55
55
|
|
|
56
56
|
|
|
57
|
+
var _chunkARZHJFVGjs = require('./chunk-ARZHJFVG.js');
|
|
57
58
|
|
|
58
59
|
|
|
60
|
+
var _chunkQTKXIDGEjs = require('./chunk-QTKXIDGE.js');
|
|
59
61
|
|
|
60
62
|
|
|
63
|
+
var _chunkC3WC4OJ3js = require('./chunk-C3WC4OJ3.js');
|
|
61
64
|
|
|
62
65
|
|
|
63
66
|
|
|
64
|
-
var
|
|
67
|
+
var _chunkQH2H4W3Njs = require('./chunk-QH2H4W3N.js');
|
|
65
68
|
|
|
66
69
|
|
|
67
70
|
|
|
68
71
|
|
|
69
|
-
var _chunkV72C4MCRjs = require('./chunk-V72C4MCR.js');
|
|
70
72
|
|
|
71
73
|
|
|
72
|
-
var _chunk7NMV2NPMjs = require('./chunk-7NMV2NPM.js');
|
|
73
74
|
|
|
74
75
|
|
|
75
|
-
var _chunk2EU6346Vjs = require('./chunk-2EU6346V.js');
|
|
76
76
|
|
|
77
77
|
|
|
78
78
|
|
|
79
|
-
var
|
|
79
|
+
var _chunkOZ6UB42Cjs = require('./chunk-OZ6UB42C.js');
|
|
80
80
|
|
|
81
81
|
|
|
82
82
|
var _chunk76FONEDAjs = require('./chunk-76FONEDA.js');
|
|
@@ -464,9 +464,9 @@ var TransactionController = class extends _basecontroller.BaseController {
|
|
|
464
464
|
const isEIP1559Compatible = await this.getEIP1559Compatibility(
|
|
465
465
|
networkClientId
|
|
466
466
|
);
|
|
467
|
-
|
|
467
|
+
_chunkGPS6RX64js.validateTxParams.call(void 0, txParams, isEIP1559Compatible);
|
|
468
468
|
if (origin) {
|
|
469
|
-
await
|
|
469
|
+
await _chunkGPS6RX64js.validateTransactionOrigin.call(void 0,
|
|
470
470
|
await this.getPermittedAccounts(origin),
|
|
471
471
|
_chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getSelectedAccount, getSelectedAccount_fn).call(this).address,
|
|
472
472
|
txParams.from,
|
|
@@ -528,7 +528,10 @@ var TransactionController = class extends _basecontroller.BaseController {
|
|
|
528
528
|
);
|
|
529
529
|
this.addMetadata(addedTransactionMeta);
|
|
530
530
|
if (requireApproval !== false) {
|
|
531
|
-
_chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _updateSimulationData, updateSimulationData_fn).call(this, addedTransactionMeta)
|
|
531
|
+
_chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _updateSimulationData, updateSimulationData_fn).call(this, addedTransactionMeta).catch((error) => {
|
|
532
|
+
_chunkS6VGOPUYjs.projectLogger.call(void 0, "Error while updating simulation data", error);
|
|
533
|
+
throw error;
|
|
534
|
+
});
|
|
532
535
|
} else {
|
|
533
536
|
_chunkS6VGOPUYjs.projectLogger.call(void 0, "Skipping simulation as approval not required");
|
|
534
537
|
}
|
|
@@ -960,7 +963,10 @@ var TransactionController = class extends _basecontroller.BaseController {
|
|
|
960
963
|
`${controllerName}:confirmExternalTransaction - Add external transaction`
|
|
961
964
|
);
|
|
962
965
|
this.onTransactionStatusChange(updatedTransactionMeta);
|
|
963
|
-
this.updatePostBalance(updatedTransactionMeta)
|
|
966
|
+
this.updatePostBalance(updatedTransactionMeta).catch((error) => {
|
|
967
|
+
_chunkS6VGOPUYjs.projectLogger.call(void 0, "Error while updating post balance", error);
|
|
968
|
+
throw error;
|
|
969
|
+
});
|
|
964
970
|
this.messagingSystem.publish(
|
|
965
971
|
`${controllerName}:transactionConfirmed`,
|
|
966
972
|
updatedTransactionMeta
|
|
@@ -1492,6 +1498,7 @@ var TransactionController = class extends _basecontroller.BaseController {
|
|
|
1492
1498
|
this.signAbortCallbacks.delete(transactionId);
|
|
1493
1499
|
}
|
|
1494
1500
|
addMetadata(transactionMeta) {
|
|
1501
|
+
_chunkGPS6RX64js.validateTxParams.call(void 0, transactionMeta.txParams);
|
|
1495
1502
|
this.update((state) => {
|
|
1496
1503
|
state.transactions = this.trimTransactionsForState([
|
|
1497
1504
|
...state.transactions,
|
|
@@ -1500,7 +1507,7 @@ var TransactionController = class extends _basecontroller.BaseController {
|
|
|
1500
1507
|
});
|
|
1501
1508
|
}
|
|
1502
1509
|
async updateGasProperties(transactionMeta) {
|
|
1503
|
-
const isEIP1559Compatible =
|
|
1510
|
+
const isEIP1559Compatible = transactionMeta.txParams.type !== "0x0" /* legacy */ && await this.getEIP1559Compatibility(transactionMeta.networkClientId);
|
|
1504
1511
|
const { networkClientId, chainId } = transactionMeta;
|
|
1505
1512
|
const isCustomNetwork = _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _isCustomNetwork, isCustomNetwork_fn).call(this, networkClientId);
|
|
1506
1513
|
const ethQuery = _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _multichainTrackingHelper).getEthQuery({
|
|
@@ -2177,7 +2184,10 @@ var TransactionController = class extends _basecontroller.BaseController {
|
|
|
2177
2184
|
transactionMeta
|
|
2178
2185
|
);
|
|
2179
2186
|
this.onTransactionStatusChange(transactionMeta);
|
|
2180
|
-
this.updatePostBalance(transactionMeta)
|
|
2187
|
+
this.updatePostBalance(transactionMeta).catch((error) => {
|
|
2188
|
+
_chunkS6VGOPUYjs.projectLogger.call(void 0, "Error while updating post balance", error);
|
|
2189
|
+
throw error;
|
|
2190
|
+
});
|
|
2181
2191
|
}
|
|
2182
2192
|
async updatePostBalance(transactionMeta) {
|
|
2183
2193
|
try {
|
|
@@ -2248,7 +2258,7 @@ createNonceTracker_fn = function({
|
|
|
2248
2258
|
// TODO: Fix types
|
|
2249
2259
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2250
2260
|
provider,
|
|
2251
|
-
//
|
|
2261
|
+
// TODO: Fix types
|
|
2252
2262
|
blockTracker,
|
|
2253
2263
|
getPendingTransactions: _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getNonceTrackerPendingTransactions, getNonceTrackerPendingTransactions_fn).bind(
|
|
2254
2264
|
this,
|
|
@@ -2402,7 +2412,7 @@ updateTransactionInternal_fn = function({
|
|
|
2402
2412
|
transactionMeta2.txParams = _chunkOZ6UB42Cjs.normalizeTransactionParams.call(void 0,
|
|
2403
2413
|
transactionMeta2.txParams
|
|
2404
2414
|
);
|
|
2405
|
-
|
|
2415
|
+
_chunkGPS6RX64js.validateTxParams.call(void 0, transactionMeta2.txParams);
|
|
2406
2416
|
updatedTransactionParams = _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _checkIfTransactionParamsUpdated, checkIfTransactionParamsUpdated_fn).call(this, transactionMeta2);
|
|
2407
2417
|
const shouldSkipHistory = this.isHistoryDisabled || skipHistory;
|
|
2408
2418
|
if (!shouldSkipHistory) {
|
|
@@ -2447,7 +2457,10 @@ onTransactionParamsUpdated_fn = function(transactionMeta, updatedParams) {
|
|
|
2447
2457
|
(param) => updatedParams.includes(param)
|
|
2448
2458
|
)) {
|
|
2449
2459
|
_chunkS6VGOPUYjs.projectLogger.call(void 0, "Updating simulation data due to transaction parameter update");
|
|
2450
|
-
_chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _updateSimulationData, updateSimulationData_fn).call(this, transactionMeta)
|
|
2460
|
+
_chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _updateSimulationData, updateSimulationData_fn).call(this, transactionMeta).catch((error) => {
|
|
2461
|
+
_chunkS6VGOPUYjs.projectLogger.call(void 0, "Error updating simulation data", error);
|
|
2462
|
+
throw error;
|
|
2463
|
+
});
|
|
2451
2464
|
}
|
|
2452
2465
|
};
|
|
2453
2466
|
_updateSimulationData = new WeakSet();
|
|
@@ -2563,4 +2576,4 @@ getSelectedAccount_fn = function() {
|
|
|
2563
2576
|
|
|
2564
2577
|
|
|
2565
2578
|
exports.HARDFORK = HARDFORK; exports.CANCEL_RATE = CANCEL_RATE; exports.SPEED_UP_RATE = SPEED_UP_RATE; exports.ApprovalState = ApprovalState; exports.TransactionController = TransactionController;
|
|
2566
|
-
//# sourceMappingURL=chunk-
|
|
2579
|
+
//# sourceMappingURL=chunk-S3RZBMF7.js.map
|