@metamask-previews/transaction-controller 69.6.1-preview-4f4c98e → 69.6.1-preview-eb263b0ee
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/CHANGELOG.md +0 -5
- package/dist/TransactionController-method-action-types.cjs +7 -0
- package/dist/TransactionController-method-action-types.cjs.map +1 -0
- package/dist/{TransactionController-method-action-types.d.ts → TransactionController-method-action-types.d.cts} +2 -2
- package/dist/TransactionController-method-action-types.d.cts.map +1 -0
- package/dist/TransactionController-method-action-types.d.mts +413 -0
- package/dist/TransactionController-method-action-types.d.mts.map +1 -0
- package/dist/{TransactionController-method-action-types.js → TransactionController-method-action-types.mjs} +1 -1
- package/dist/TransactionController-method-action-types.mjs.map +1 -0
- package/dist/TransactionController.cjs +2444 -0
- package/dist/TransactionController.cjs.map +1 -0
- package/dist/{TransactionController.d.ts → TransactionController.d.cts} +18 -18
- package/dist/TransactionController.d.cts.map +1 -0
- package/dist/TransactionController.d.mts +751 -0
- package/dist/TransactionController.d.mts.map +1 -0
- package/dist/{TransactionController.js → TransactionController.mjs} +50 -49
- package/dist/TransactionController.mjs.map +1 -0
- package/dist/api/accounts-api.cjs +57 -0
- package/dist/api/accounts-api.cjs.map +1 -0
- package/dist/api/{accounts-api.d.ts → accounts-api.d.cts} +1 -1
- package/dist/api/accounts-api.d.cts.map +1 -0
- package/dist/api/accounts-api.d.mts +44 -0
- package/dist/api/accounts-api.d.mts.map +1 -0
- package/dist/api/{accounts-api.js → accounts-api.mjs} +5 -5
- package/dist/api/accounts-api.mjs.map +1 -0
- package/dist/api/simulation-api.cjs +116 -0
- package/dist/api/simulation-api.cjs.map +1 -0
- package/dist/api/{simulation-api.d.ts → simulation-api.d.cts} +3 -3
- package/dist/api/simulation-api.d.cts.map +1 -0
- package/dist/api/simulation-api.d.mts +196 -0
- package/dist/api/simulation-api.d.mts.map +1 -0
- package/dist/api/{simulation-api.js → simulation-api.mjs} +8 -7
- package/dist/api/simulation-api.mjs.map +1 -0
- package/dist/constants.cjs +111 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/{constants.d.ts → constants.d.cts} +37 -37
- package/dist/constants.d.cts.map +1 -0
- package/dist/constants.d.mts +78 -0
- package/dist/constants.d.mts.map +1 -0
- package/dist/{constants.js → constants.mjs} +1 -1
- package/dist/constants.mjs.map +1 -0
- package/dist/errors.cjs +37 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/{errors.d.ts → errors.d.cts} +2 -2
- package/dist/errors.d.cts.map +1 -0
- package/dist/errors.d.mts +19 -0
- package/dist/errors.d.mts.map +1 -0
- package/dist/{errors.js → errors.mjs} +2 -2
- package/dist/errors.mjs.map +1 -0
- package/dist/gas-flows/DefaultGasFeeFlow.cjs +85 -0
- package/dist/gas-flows/{DefaultGasFeeFlow.js.map → DefaultGasFeeFlow.cjs.map} +1 -1
- package/dist/gas-flows/{DefaultGasFeeFlow.d.ts → DefaultGasFeeFlow.d.cts} +2 -2
- package/dist/gas-flows/DefaultGasFeeFlow.d.cts.map +1 -0
- package/dist/gas-flows/DefaultGasFeeFlow.d.mts +10 -0
- package/dist/gas-flows/DefaultGasFeeFlow.d.mts.map +1 -0
- package/dist/gas-flows/{DefaultGasFeeFlow.js → DefaultGasFeeFlow.mjs} +6 -6
- package/dist/gas-flows/DefaultGasFeeFlow.mjs.map +1 -0
- package/dist/gas-flows/LineaGasFeeFlow.cjs +111 -0
- package/dist/gas-flows/LineaGasFeeFlow.cjs.map +1 -0
- package/dist/gas-flows/{LineaGasFeeFlow.d.ts → LineaGasFeeFlow.d.cts} +3 -3
- package/dist/gas-flows/LineaGasFeeFlow.d.cts.map +1 -0
- package/dist/gas-flows/LineaGasFeeFlow.d.mts +16 -0
- package/dist/gas-flows/LineaGasFeeFlow.d.mts.map +1 -0
- package/dist/gas-flows/{LineaGasFeeFlow.js → LineaGasFeeFlow.mjs} +7 -7
- package/dist/gas-flows/LineaGasFeeFlow.mjs.map +1 -0
- package/dist/gas-flows/MantleLayer1GasFeeFlow.cjs +66 -0
- package/dist/gas-flows/MantleLayer1GasFeeFlow.cjs.map +1 -0
- package/dist/gas-flows/{MantleLayer1GasFeeFlow.d.ts → MantleLayer1GasFeeFlow.d.cts} +5 -5
- package/dist/gas-flows/MantleLayer1GasFeeFlow.d.cts.map +1 -0
- package/dist/gas-flows/MantleLayer1GasFeeFlow.d.mts +21 -0
- package/dist/gas-flows/MantleLayer1GasFeeFlow.d.mts.map +1 -0
- package/dist/gas-flows/{MantleLayer1GasFeeFlow.js → MantleLayer1GasFeeFlow.mjs} +6 -6
- package/dist/gas-flows/MantleLayer1GasFeeFlow.mjs.map +1 -0
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.cjs +59 -0
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.cjs.map +1 -0
- package/dist/gas-flows/{OptimismLayer1GasFeeFlow.d.ts → OptimismLayer1GasFeeFlow.d.cts} +4 -4
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.cts.map +1 -0
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.mts +14 -0
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.mts.map +1 -0
- package/dist/gas-flows/{OptimismLayer1GasFeeFlow.js → OptimismLayer1GasFeeFlow.mjs} +5 -5
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.mjs.map +1 -0
- package/dist/gas-flows/OracleLayer1GasFeeFlow.cjs +201 -0
- package/dist/gas-flows/OracleLayer1GasFeeFlow.cjs.map +1 -0
- package/dist/gas-flows/{OracleLayer1GasFeeFlow.d.ts → OracleLayer1GasFeeFlow.d.cts} +5 -5
- package/dist/gas-flows/OracleLayer1GasFeeFlow.d.cts.map +1 -0
- package/dist/gas-flows/OracleLayer1GasFeeFlow.d.mts +57 -0
- package/dist/gas-flows/OracleLayer1GasFeeFlow.d.mts.map +1 -0
- package/dist/gas-flows/{OracleLayer1GasFeeFlow.js → OracleLayer1GasFeeFlow.mjs} +15 -8
- package/dist/gas-flows/OracleLayer1GasFeeFlow.mjs.map +1 -0
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.cjs +123 -0
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.cjs.map +1 -0
- package/dist/gas-flows/{RandomisedEstimationsGasFeeFlow.d.ts → RandomisedEstimationsGasFeeFlow.d.cts} +4 -4
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.d.cts.map +1 -0
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.d.mts +28 -0
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.d.mts.map +1 -0
- package/dist/gas-flows/{RandomisedEstimationsGasFeeFlow.js → RandomisedEstimationsGasFeeFlow.mjs} +8 -8
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.mjs.map +1 -0
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.cjs +24 -0
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.cjs.map +1 -0
- package/dist/gas-flows/{ScrollLayer1GasFeeFlow.d.ts → ScrollLayer1GasFeeFlow.d.cts} +5 -5
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.cts.map +1 -0
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.mts +16 -0
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.mts.map +1 -0
- package/dist/gas-flows/{ScrollLayer1GasFeeFlow.js → ScrollLayer1GasFeeFlow.mjs} +3 -3
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.mjs.map +1 -0
- package/dist/gas-flows/TestGasFeeFlow.cjs +73 -0
- package/dist/gas-flows/TestGasFeeFlow.cjs.map +1 -0
- package/dist/gas-flows/{TestGasFeeFlow.d.ts → TestGasFeeFlow.d.cts} +2 -2
- package/dist/gas-flows/TestGasFeeFlow.d.cts.map +1 -0
- package/dist/gas-flows/TestGasFeeFlow.d.mts +12 -0
- package/dist/gas-flows/TestGasFeeFlow.d.mts.map +1 -0
- package/dist/gas-flows/{TestGasFeeFlow.js → TestGasFeeFlow.mjs} +3 -3
- package/dist/gas-flows/TestGasFeeFlow.mjs.map +1 -0
- package/dist/helpers/GasFeePoller.cjs +334 -0
- package/dist/helpers/GasFeePoller.cjs.map +1 -0
- package/dist/helpers/{GasFeePoller.d.ts → GasFeePoller.d.cts} +10 -7
- package/dist/helpers/GasFeePoller.d.cts.map +1 -0
- package/dist/helpers/GasFeePoller.d.mts +66 -0
- package/dist/helpers/GasFeePoller.d.mts.map +1 -0
- package/dist/helpers/{GasFeePoller.js → GasFeePoller.mjs} +9 -9
- package/dist/helpers/GasFeePoller.mjs.map +1 -0
- package/dist/helpers/MethodDataHelper.cjs +84 -0
- package/dist/helpers/MethodDataHelper.cjs.map +1 -0
- package/dist/helpers/{MethodDataHelper.d.ts → MethodDataHelper.d.cts} +7 -4
- package/dist/helpers/MethodDataHelper.d.cts.map +1 -0
- package/dist/helpers/MethodDataHelper.d.mts +16 -0
- package/dist/helpers/MethodDataHelper.d.mts.map +1 -0
- package/dist/helpers/{MethodDataHelper.js → MethodDataHelper.mjs} +7 -7
- package/dist/helpers/MethodDataHelper.mjs.map +1 -0
- package/dist/helpers/MultichainTrackingHelper.cjs +231 -0
- package/dist/helpers/MultichainTrackingHelper.cjs.map +1 -0
- package/dist/helpers/{MultichainTrackingHelper.d.ts → MultichainTrackingHelper.d.cts} +5 -5
- package/dist/helpers/MultichainTrackingHelper.d.cts.map +1 -0
- package/dist/helpers/MultichainTrackingHelper.d.mts +56 -0
- package/dist/helpers/MultichainTrackingHelper.d.mts.map +1 -0
- package/dist/helpers/{MultichainTrackingHelper.js → MultichainTrackingHelper.mjs} +8 -8
- package/dist/helpers/MultichainTrackingHelper.mjs.map +1 -0
- package/dist/helpers/PendingTransactionTracker.cjs +407 -0
- package/dist/helpers/PendingTransactionTracker.cjs.map +1 -0
- package/dist/helpers/{PendingTransactionTracker.d.ts → PendingTransactionTracker.d.cts} +8 -5
- package/dist/helpers/PendingTransactionTracker.d.cts.map +1 -0
- package/dist/helpers/PendingTransactionTracker.d.mts +54 -0
- package/dist/helpers/PendingTransactionTracker.d.mts.map +1 -0
- package/dist/helpers/{PendingTransactionTracker.js → PendingTransactionTracker.mjs} +15 -14
- package/dist/helpers/PendingTransactionTracker.mjs.map +1 -0
- package/dist/helpers/ResimulateHelper.cjs +274 -0
- package/dist/helpers/ResimulateHelper.cjs.map +1 -0
- package/dist/helpers/{ResimulateHelper.d.ts → ResimulateHelper.d.cts} +3 -3
- package/dist/helpers/ResimulateHelper.d.cts.map +1 -0
- package/dist/helpers/ResimulateHelper.d.mts +36 -0
- package/dist/helpers/ResimulateHelper.d.mts.map +1 -0
- package/dist/helpers/{ResimulateHelper.js → ResimulateHelper.mjs} +8 -7
- package/dist/helpers/ResimulateHelper.mjs.map +1 -0
- package/dist/helpers/TransactionPoller.cjs +175 -0
- package/dist/helpers/TransactionPoller.cjs.map +1 -0
- package/dist/helpers/{TransactionPoller.d.ts → TransactionPoller.d.cts} +5 -5
- package/dist/helpers/TransactionPoller.d.cts.map +1 -0
- package/dist/helpers/TransactionPoller.d.mts +37 -0
- package/dist/helpers/TransactionPoller.d.mts.map +1 -0
- package/dist/helpers/{TransactionPoller.js → TransactionPoller.mjs} +11 -10
- package/dist/helpers/TransactionPoller.mjs.map +1 -0
- package/dist/hooks/CollectPublishHook.cjs +94 -0
- package/dist/hooks/CollectPublishHook.cjs.map +1 -0
- package/dist/hooks/{CollectPublishHook.d.ts → CollectPublishHook.d.cts} +3 -3
- package/dist/hooks/CollectPublishHook.d.cts.map +1 -0
- package/dist/hooks/CollectPublishHook.d.mts +29 -0
- package/dist/hooks/CollectPublishHook.d.mts.map +1 -0
- package/dist/hooks/{CollectPublishHook.js → CollectPublishHook.mjs} +5 -4
- package/dist/hooks/CollectPublishHook.mjs.map +1 -0
- package/dist/hooks/ExtraTransactionsPublishHook.cjs +126 -0
- package/dist/hooks/ExtraTransactionsPublishHook.cjs.map +1 -0
- package/dist/hooks/{ExtraTransactionsPublishHook.d.ts → ExtraTransactionsPublishHook.d.cts} +3 -3
- package/dist/hooks/ExtraTransactionsPublishHook.d.cts.map +1 -0
- package/dist/hooks/ExtraTransactionsPublishHook.d.mts +19 -0
- package/dist/hooks/ExtraTransactionsPublishHook.d.mts.map +1 -0
- package/dist/hooks/{ExtraTransactionsPublishHook.js → ExtraTransactionsPublishHook.mjs} +3 -3
- package/dist/hooks/ExtraTransactionsPublishHook.mjs.map +1 -0
- package/dist/hooks/SequentialPublishBatchHook.cjs +112 -0
- package/dist/hooks/SequentialPublishBatchHook.cjs.map +1 -0
- package/dist/hooks/{SequentialPublishBatchHook.d.ts → SequentialPublishBatchHook.d.cts} +4 -4
- package/dist/hooks/SequentialPublishBatchHook.d.cts.map +1 -0
- package/dist/hooks/SequentialPublishBatchHook.d.mts +22 -0
- package/dist/hooks/SequentialPublishBatchHook.d.mts.map +1 -0
- package/dist/hooks/{SequentialPublishBatchHook.js → SequentialPublishBatchHook.mjs} +4 -4
- package/dist/hooks/SequentialPublishBatchHook.mjs.map +1 -0
- package/dist/index.cjs +40 -0
- package/dist/index.cjs.map +1 -0
- package/dist/{index.d.ts → index.d.cts} +16 -16
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +16 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +12 -0
- package/dist/index.mjs.map +1 -0
- package/dist/logger.cjs +9 -0
- package/dist/logger.cjs.map +1 -0
- package/dist/{logger.d.ts → logger.d.cts} +3 -2
- package/dist/logger.d.cts.map +1 -0
- package/dist/logger.d.mts +6 -0
- package/dist/logger.d.mts.map +1 -0
- package/dist/{logger.js → logger.mjs} +2 -2
- package/dist/logger.mjs.map +1 -0
- package/dist/types.cjs +382 -0
- package/dist/types.cjs.map +1 -0
- package/dist/{types.d.ts → types.d.cts} +8 -8
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +1887 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/{types.js → types.mjs} +1 -1
- package/dist/types.mjs.map +1 -0
- package/dist/utils/balance-changes.cjs +592 -0
- package/dist/utils/balance-changes.cjs.map +1 -0
- package/dist/utils/{balance-changes.d.ts → balance-changes.d.cts} +5 -5
- package/dist/utils/balance-changes.d.cts.map +1 -0
- package/dist/utils/balance-changes.d.mts +38 -0
- package/dist/utils/balance-changes.d.mts.map +1 -0
- package/dist/utils/{balance-changes.js → balance-changes.mjs} +20 -13
- package/dist/utils/balance-changes.mjs.map +1 -0
- package/dist/utils/balance.cjs +44 -0
- package/dist/utils/balance.cjs.map +1 -0
- package/dist/utils/{balance.d.ts → balance.d.cts} +5 -5
- package/dist/utils/balance.d.cts.map +1 -0
- package/dist/utils/balance.d.mts +26 -0
- package/dist/utils/balance.d.mts.map +1 -0
- package/dist/utils/{balance.js → balance.mjs} +3 -3
- package/dist/utils/balance.mjs.map +1 -0
- package/dist/utils/batch.cjs +712 -0
- package/dist/utils/batch.cjs.map +1 -0
- package/dist/utils/{batch.d.ts → batch.d.cts} +8 -8
- package/dist/utils/batch.d.cts.map +1 -0
- package/dist/utils/batch.d.mts +58 -0
- package/dist/utils/batch.d.mts.map +1 -0
- package/dist/utils/{batch.js → batch.mjs} +18 -18
- package/dist/utils/batch.mjs.map +1 -0
- package/dist/utils/eip7702.cjs +354 -0
- package/dist/utils/eip7702.cjs.map +1 -0
- package/dist/utils/{eip7702.d.ts → eip7702.d.cts} +5 -5
- package/dist/utils/eip7702.d.cts.map +1 -0
- package/dist/utils/eip7702.d.mts +137 -0
- package/dist/utils/eip7702.d.mts.map +1 -0
- package/dist/utils/{eip7702.js → eip7702.mjs} +12 -12
- package/dist/utils/eip7702.mjs.map +1 -0
- package/dist/utils/external-transactions.cjs +36 -0
- package/dist/utils/external-transactions.cjs.map +1 -0
- package/dist/utils/{external-transactions.d.ts → external-transactions.d.cts} +2 -2
- package/dist/utils/external-transactions.d.cts.map +1 -0
- package/dist/utils/external-transactions.d.mts +10 -0
- package/dist/utils/external-transactions.d.mts.map +1 -0
- package/dist/utils/{external-transactions.js → external-transactions.mjs} +3 -3
- package/dist/utils/external-transactions.mjs.map +1 -0
- package/dist/utils/feature-flags.cjs +255 -0
- package/dist/utils/feature-flags.cjs.map +1 -0
- package/dist/utils/{feature-flags.d.ts → feature-flags.d.cts} +3 -3
- package/dist/utils/feature-flags.d.cts.map +1 -0
- package/dist/utils/feature-flags.d.mts +313 -0
- package/dist/utils/feature-flags.d.mts.map +1 -0
- package/dist/utils/{feature-flags.js → feature-flags.mjs} +5 -5
- package/dist/utils/feature-flags.mjs.map +1 -0
- package/dist/utils/first-time-interaction.cjs +69 -0
- package/dist/utils/first-time-interaction.cjs.map +1 -0
- package/dist/utils/{first-time-interaction.d.ts → first-time-interaction.d.cts} +3 -3
- package/dist/utils/first-time-interaction.d.cts.map +1 -0
- package/dist/utils/first-time-interaction.d.mts +30 -0
- package/dist/utils/first-time-interaction.d.mts.map +1 -0
- package/dist/utils/{first-time-interaction.js → first-time-interaction.mjs} +6 -6
- package/dist/utils/first-time-interaction.mjs.map +1 -0
- package/dist/utils/gas-fee-tokens.cjs +174 -0
- package/dist/utils/gas-fee-tokens.cjs.map +1 -0
- package/dist/utils/{gas-fee-tokens.d.ts → gas-fee-tokens.d.cts} +5 -5
- package/dist/utils/gas-fee-tokens.d.cts.map +1 -0
- package/dist/utils/gas-fee-tokens.d.mts +46 -0
- package/dist/utils/gas-fee-tokens.d.mts.map +1 -0
- package/dist/utils/{gas-fee-tokens.js → gas-fee-tokens.mjs} +9 -9
- package/dist/utils/gas-fee-tokens.mjs.map +1 -0
- package/dist/utils/gas-fees.cjs +424 -0
- package/dist/utils/gas-fees.cjs.map +1 -0
- package/dist/utils/{gas-fees.d.ts → gas-fees.d.cts} +5 -5
- package/dist/utils/gas-fees.d.cts.map +1 -0
- package/dist/utils/gas-fees.d.mts +57 -0
- package/dist/utils/gas-fees.d.mts.map +1 -0
- package/dist/utils/{gas-fees.js → gas-fees.mjs} +9 -9
- package/dist/utils/gas-fees.mjs.map +1 -0
- package/dist/utils/gas-flow.cjs +81 -0
- package/dist/utils/gas-flow.cjs.map +1 -0
- package/dist/utils/{gas-flow.d.ts → gas-flow.d.cts} +6 -6
- package/dist/utils/gas-flow.d.cts.map +1 -0
- package/dist/utils/gas-flow.d.mts +29 -0
- package/dist/utils/gas-flow.d.mts.map +1 -0
- package/dist/utils/{gas-flow.js → gas-flow.mjs} +3 -3
- package/dist/utils/gas-flow.mjs.map +1 -0
- package/dist/utils/gas.cjs +545 -0
- package/dist/utils/gas.cjs.map +1 -0
- package/dist/utils/{gas.d.ts → gas.d.cts} +6 -5
- package/dist/utils/gas.d.cts.map +1 -0
- package/dist/utils/gas.d.mts +116 -0
- package/dist/utils/gas.d.mts.map +1 -0
- package/dist/utils/{gas.js → gas.mjs} +11 -11
- package/dist/utils/gas.mjs.map +1 -0
- package/dist/utils/layer1-gas-fee-flow.cjs +73 -0
- package/dist/utils/layer1-gas-fee-flow.cjs.map +1 -0
- package/dist/utils/{layer1-gas-fee-flow.d.ts → layer1-gas-fee-flow.d.cts} +4 -4
- package/dist/utils/layer1-gas-fee-flow.d.cts.map +1 -0
- package/dist/utils/layer1-gas-fee-flow.d.mts +28 -0
- package/dist/utils/layer1-gas-fee-flow.d.mts.map +1 -0
- package/dist/utils/{layer1-gas-fee-flow.js → layer1-gas-fee-flow.mjs} +3 -3
- package/dist/utils/layer1-gas-fee-flow.mjs.map +1 -0
- package/dist/utils/nonce.cjs +93 -0
- package/dist/utils/nonce.cjs.map +1 -0
- package/dist/utils/{nonce.d.ts → nonce.d.cts} +3 -3
- package/dist/utils/nonce.d.cts.map +1 -0
- package/dist/utils/nonce.d.mts +26 -0
- package/dist/utils/nonce.d.mts.map +1 -0
- package/dist/utils/{nonce.js → nonce.mjs} +4 -4
- package/dist/utils/nonce.mjs.map +1 -0
- package/dist/utils/prepare.cjs +97 -0
- package/dist/utils/prepare.cjs.map +1 -0
- package/dist/utils/{prepare.d.ts → prepare.d.cts} +5 -5
- package/dist/utils/prepare.d.cts.map +1 -0
- package/dist/utils/prepare.d.mts +22 -0
- package/dist/utils/prepare.d.mts.map +1 -0
- package/dist/utils/{prepare.js → prepare.mjs} +6 -5
- package/dist/utils/prepare.mjs.map +1 -0
- package/dist/utils/provider.cjs +106 -0
- package/dist/utils/provider.cjs.map +1 -0
- package/dist/utils/{provider.d.ts → provider.d.cts} +4 -4
- package/dist/utils/provider.d.cts.map +1 -0
- package/dist/utils/provider.d.mts +65 -0
- package/dist/utils/provider.d.mts.map +1 -0
- package/dist/utils/{provider.js → provider.mjs} +3 -3
- package/dist/utils/provider.mjs.map +1 -0
- package/dist/utils/recipient.cjs +31 -0
- package/dist/utils/recipient.cjs.map +1 -0
- package/dist/utils/{recipient.d.ts → recipient.d.cts} +2 -2
- package/dist/utils/recipient.d.cts.map +1 -0
- package/dist/utils/recipient.d.mts +13 -0
- package/dist/utils/recipient.d.mts.map +1 -0
- package/dist/utils/{recipient.js → recipient.mjs} +3 -3
- package/dist/utils/recipient.mjs.map +1 -0
- package/dist/utils/retry.cjs +93 -0
- package/dist/utils/retry.cjs.map +1 -0
- package/dist/utils/{retry.d.ts → retry.d.cts} +2 -2
- package/dist/utils/retry.d.cts.map +1 -0
- package/dist/utils/retry.d.mts +11 -0
- package/dist/utils/retry.d.mts.map +1 -0
- package/dist/utils/{retry.js → retry.mjs} +3 -3
- package/dist/utils/retry.mjs.map +1 -0
- package/dist/utils/revert-reason.cjs +192 -0
- package/dist/utils/revert-reason.cjs.map +1 -0
- package/dist/utils/{revert-reason.d.ts → revert-reason.d.cts} +5 -5
- package/dist/utils/revert-reason.d.cts.map +1 -0
- package/dist/utils/revert-reason.d.mts +57 -0
- package/dist/utils/revert-reason.d.mts.map +1 -0
- package/dist/utils/{revert-reason.js → revert-reason.mjs} +4 -4
- package/dist/utils/revert-reason.mjs.map +1 -0
- package/dist/utils/signature.cjs +26 -0
- package/dist/utils/signature.cjs.map +1 -0
- package/dist/utils/{signature.d.ts → signature.d.cts} +2 -2
- package/dist/utils/signature.d.cts.map +1 -0
- package/dist/utils/signature.d.mts +11 -0
- package/dist/utils/signature.d.mts.map +1 -0
- package/dist/utils/{signature.js → signature.mjs} +3 -3
- package/dist/utils/signature.mjs.map +1 -0
- package/dist/utils/swaps.cjs +332 -0
- package/dist/utils/swaps.cjs.map +1 -0
- package/dist/utils/{swaps.d.ts → swaps.d.cts} +5 -5
- package/dist/utils/swaps.d.cts.map +1 -0
- package/dist/utils/swaps.d.mts +90 -0
- package/dist/utils/swaps.d.mts.map +1 -0
- package/dist/utils/{swaps.js → swaps.mjs} +8 -7
- package/dist/utils/swaps.mjs.map +1 -0
- package/dist/utils/transaction-type.cjs +159 -0
- package/dist/utils/transaction-type.cjs.map +1 -0
- package/dist/utils/{transaction-type.d.ts → transaction-type.d.cts} +6 -6
- package/dist/utils/transaction-type.d.cts.map +1 -0
- package/dist/utils/transaction-type.d.mts +44 -0
- package/dist/utils/transaction-type.d.mts.map +1 -0
- package/dist/utils/{transaction-type.js → transaction-type.mjs} +6 -6
- package/dist/utils/transaction-type.mjs.map +1 -0
- package/dist/utils/utils.cjs +287 -0
- package/dist/utils/utils.cjs.map +1 -0
- package/dist/utils/{utils.d.ts → utils.d.cts} +4 -4
- package/dist/utils/utils.d.cts.map +1 -0
- package/dist/utils/utils.d.mts +101 -0
- package/dist/utils/utils.d.mts.map +1 -0
- package/dist/utils/{utils.js → utils.mjs} +12 -5
- package/dist/utils/utils.mjs.map +1 -0
- package/dist/utils/validation.cjs +389 -0
- package/dist/utils/validation.cjs.map +1 -0
- package/dist/utils/{validation.d.ts → validation.d.cts} +4 -4
- package/dist/utils/validation.d.cts.map +1 -0
- package/dist/utils/validation.d.mts +66 -0
- package/dist/utils/validation.d.mts.map +1 -0
- package/dist/utils/{validation.js → validation.mjs} +8 -8
- package/dist/utils/validation.mjs.map +1 -0
- package/package.json +19 -15
- package/dist/TransactionController-method-action-types.d.ts.map +0 -1
- package/dist/TransactionController-method-action-types.js.map +0 -1
- package/dist/TransactionController.d.ts.map +0 -1
- package/dist/TransactionController.js.map +0 -1
- package/dist/api/accounts-api.d.ts.map +0 -1
- package/dist/api/accounts-api.js.map +0 -1
- package/dist/api/simulation-api.d.ts.map +0 -1
- package/dist/api/simulation-api.js.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js.map +0 -1
- package/dist/gas-flows/DefaultGasFeeFlow.d.ts.map +0 -1
- package/dist/gas-flows/LineaGasFeeFlow.d.ts.map +0 -1
- package/dist/gas-flows/LineaGasFeeFlow.js.map +0 -1
- package/dist/gas-flows/MantleLayer1GasFeeFlow.d.ts.map +0 -1
- package/dist/gas-flows/MantleLayer1GasFeeFlow.js.map +0 -1
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.ts.map +0 -1
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.js.map +0 -1
- package/dist/gas-flows/OracleLayer1GasFeeFlow.d.ts.map +0 -1
- package/dist/gas-flows/OracleLayer1GasFeeFlow.js.map +0 -1
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.d.ts.map +0 -1
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.js.map +0 -1
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.ts.map +0 -1
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.js.map +0 -1
- package/dist/gas-flows/TestGasFeeFlow.d.ts.map +0 -1
- package/dist/gas-flows/TestGasFeeFlow.js.map +0 -1
- package/dist/helpers/GasFeePoller.d.ts.map +0 -1
- package/dist/helpers/GasFeePoller.js.map +0 -1
- package/dist/helpers/MethodDataHelper.d.ts.map +0 -1
- package/dist/helpers/MethodDataHelper.js.map +0 -1
- package/dist/helpers/MultichainTrackingHelper.d.ts.map +0 -1
- package/dist/helpers/MultichainTrackingHelper.js.map +0 -1
- package/dist/helpers/PendingTransactionTracker.d.ts.map +0 -1
- package/dist/helpers/PendingTransactionTracker.js.map +0 -1
- package/dist/helpers/ResimulateHelper.d.ts.map +0 -1
- package/dist/helpers/ResimulateHelper.js.map +0 -1
- package/dist/helpers/TransactionPoller.d.ts.map +0 -1
- package/dist/helpers/TransactionPoller.js.map +0 -1
- package/dist/hooks/CollectPublishHook.d.ts.map +0 -1
- package/dist/hooks/CollectPublishHook.js.map +0 -1
- package/dist/hooks/ExtraTransactionsPublishHook.d.ts.map +0 -1
- package/dist/hooks/ExtraTransactionsPublishHook.js.map +0 -1
- package/dist/hooks/SequentialPublishBatchHook.d.ts.map +0 -1
- package/dist/hooks/SequentialPublishBatchHook.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -12
- package/dist/index.js.map +0 -1
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/balance-changes.d.ts.map +0 -1
- package/dist/utils/balance-changes.js.map +0 -1
- package/dist/utils/balance.d.ts.map +0 -1
- package/dist/utils/balance.js.map +0 -1
- package/dist/utils/batch.d.ts.map +0 -1
- package/dist/utils/batch.js.map +0 -1
- package/dist/utils/eip7702.d.ts.map +0 -1
- package/dist/utils/eip7702.js.map +0 -1
- package/dist/utils/external-transactions.d.ts.map +0 -1
- package/dist/utils/external-transactions.js.map +0 -1
- package/dist/utils/feature-flags.d.ts.map +0 -1
- package/dist/utils/feature-flags.js.map +0 -1
- package/dist/utils/first-time-interaction.d.ts.map +0 -1
- package/dist/utils/first-time-interaction.js.map +0 -1
- package/dist/utils/gas-fee-tokens.d.ts.map +0 -1
- package/dist/utils/gas-fee-tokens.js.map +0 -1
- package/dist/utils/gas-fees.d.ts.map +0 -1
- package/dist/utils/gas-fees.js.map +0 -1
- package/dist/utils/gas-flow.d.ts.map +0 -1
- package/dist/utils/gas-flow.js.map +0 -1
- package/dist/utils/gas.d.ts.map +0 -1
- package/dist/utils/gas.js.map +0 -1
- package/dist/utils/layer1-gas-fee-flow.d.ts.map +0 -1
- package/dist/utils/layer1-gas-fee-flow.js.map +0 -1
- package/dist/utils/nonce.d.ts.map +0 -1
- package/dist/utils/nonce.js.map +0 -1
- package/dist/utils/prepare.d.ts.map +0 -1
- package/dist/utils/prepare.js.map +0 -1
- package/dist/utils/provider.d.ts.map +0 -1
- package/dist/utils/provider.js.map +0 -1
- package/dist/utils/recipient.d.ts.map +0 -1
- package/dist/utils/recipient.js.map +0 -1
- package/dist/utils/retry.d.ts.map +0 -1
- package/dist/utils/retry.js.map +0 -1
- package/dist/utils/revert-reason.d.ts.map +0 -1
- package/dist/utils/revert-reason.js.map +0 -1
- package/dist/utils/signature.d.ts.map +0 -1
- package/dist/utils/signature.js.map +0 -1
- package/dist/utils/swaps.d.ts.map +0 -1
- package/dist/utils/swaps.js.map +0 -1
- package/dist/utils/transaction-type.d.ts.map +0 -1
- package/dist/utils/transaction-type.js.map +0 -1
- package/dist/utils/utils.d.ts.map +0 -1
- package/dist/utils/utils.js.map +0 -1
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/validation.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.cjs","sourceRoot":"","sources":["../../src/utils/retry.ts"],"names":[],"mappings":";;;AAAA,iEAAiE;AAEjE,2CAAwC;AAQxC;;;;;;;GAOG;AACH,SAAgB,uCAAuC,CACrD,yBAA4C,EAC5C,IAAY,EACZ,YAAqD;IAErD,MAAM,WAAW,GAAG,oBAAoB,CACtC,yBAAyB,EACzB,IAAI,EACJ,YAAY,CACb,CAAC;IAEF,MAAM,aAAa,GAAG,sBAAsB,CAC1C,yBAAyB,EACzB,IAAI,EACJ,YAAY,CACb,CAAC;IAEF,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,WAAW,GAAsB;YACrC,GAAG,yBAAyB;YAC5B,GAAG,aAAa;SACjB,CAAC;QAEF,OAAO,WAAW,CAAC,QAAQ,CAAC;QAE5B,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,IAAI,WAAW,EAAE,CAAC;QAChB,MAAM,WAAW,GAAsB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AC;IAED,OAAO,WAAW,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,KAAsB,EAAE,UAAkB;IAC7D,MAAM,YAAY,GAAG,IAAA,sCAAmB,EAAC,KAAK,CAAC,CAAC;IAChD,MAAM,aAAa,GAAG,QAAQ,CAAC,GAAG,YAAY,GAAG,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC;IAEnE,OAAO,IAAA,aAAK,EAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["import { convertHexToDecimal } from '@metamask/controller-utils';\nimport type { Hex } from '@metamask/utils';\nimport { add0x } from '@metamask/utils';\n\nimport type {\n FeeMarketEIP1559Values,\n GasPriceValue,\n TransactionParams,\n} from '../types.js';\n\n/**\n * Returns new transaction parameters with increased gas fees.\n *\n * @param originalTransactionParams - The original transaction parameters.\n * @param rate - The rate by which to increase the existing gas fee properties.\n * @param newGasValues - Optional new gas values to use instead of increased the existing values.\n * @returns The new transaction parameters with the increased gas fee properties.\n */\nexport function getTransactionParamsWithIncreasedGasFee(\n originalTransactionParams: TransactionParams,\n rate: number,\n newGasValues?: GasPriceValue | FeeMarketEIP1559Values,\n): TransactionParams {\n const newGasPrice = getIncreasedGasPrice(\n originalTransactionParams,\n rate,\n newGasValues,\n );\n\n const new1559Values = getIncreased1559Values(\n originalTransactionParams,\n rate,\n newGasValues,\n );\n\n if (new1559Values) {\n const newTxParams: TransactionParams = {\n ...originalTransactionParams,\n ...new1559Values,\n };\n\n delete newTxParams.gasPrice;\n\n return newTxParams;\n }\n\n if (newGasPrice) {\n const newTxParams: TransactionParams = {\n ...originalTransactionParams,\n gasPrice: newGasPrice,\n };\n\n delete newTxParams.maxFeePerGas;\n delete newTxParams.maxPriorityFeePerGas;\n\n return newTxParams;\n }\n\n throw new Error(\n 'Cannot increase gas fee as no current values and no new values were provided',\n );\n}\n\n/**\n * Generate the increased EIP-1559 gas properties.\n *\n * @param originalTransactionParams - The original transaction parameters.\n * @param rate - The rate by which to increase the existing gas fee properties.\n * @param newGasValues - Optional new gas values to use instead of increased the existing values.\n * @returns The new EIP-1559 gas properties.\n */\nfunction getIncreased1559Values(\n originalTransactionParams: TransactionParams,\n rate: number,\n newGasValues?: GasPriceValue | FeeMarketEIP1559Values,\n): FeeMarketEIP1559Values | undefined {\n if (\n newGasValues &&\n 'maxFeePerGas' in newGasValues &&\n 'maxPriorityFeePerGas' in newGasValues\n ) {\n return newGasValues;\n }\n\n const currentMaxFeePerGas = originalTransactionParams.maxFeePerGas as\n | Hex\n | undefined;\n\n const currentMaxPriorityFeePerGas =\n originalTransactionParams.maxPriorityFeePerGas as Hex | undefined;\n\n if (\n !currentMaxFeePerGas ||\n !currentMaxPriorityFeePerGas ||\n currentMaxFeePerGas === '0x0' ||\n currentMaxPriorityFeePerGas === '0x0'\n ) {\n return undefined;\n }\n\n const maxFeePerGas = multiplyHex(currentMaxFeePerGas, rate);\n const maxPriorityFeePerGas = multiplyHex(currentMaxPriorityFeePerGas, rate);\n\n return { maxFeePerGas, maxPriorityFeePerGas };\n}\n\n/**\n * Generate the increased gas price.\n *\n * @param originalTransactionParams - The original transaction parameters.\n * @param rate - The rate by which to increase the existing gas fee properties.\n * @param newGasValues - Optional new gas values to use instead of increased the existing values.\n * @returns The new gas price.\n */\nfunction getIncreasedGasPrice(\n originalTransactionParams: TransactionParams,\n rate: number,\n newGasValues?: GasPriceValue | FeeMarketEIP1559Values,\n): Hex | undefined {\n if (newGasValues && 'gasPrice' in newGasValues) {\n return newGasValues.gasPrice as Hex;\n }\n\n const currentGasPrice = originalTransactionParams.gasPrice as Hex | undefined;\n\n if (!currentGasPrice || currentGasPrice === '0x0') {\n return undefined;\n }\n\n return multiplyHex(currentGasPrice, rate);\n}\n\n/**\n * Multiply a hex value by a multiplier.\n *\n * @param value - The hex value to multiply.\n * @param multiplier - The multiplier.\n * @returns The multiplied hex value.\n */\nfunction multiplyHex(value: Hex | undefined, multiplier: number): Hex {\n const decimalValue = convertHexToDecimal(value);\n const decimalResult = parseInt(`${decimalValue * multiplier}`, 10);\n\n return add0x(decimalResult.toString(16));\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FeeMarketEIP1559Values, GasPriceValue, TransactionParams } from
|
|
1
|
+
import type { FeeMarketEIP1559Values, GasPriceValue, TransactionParams } from "../types.cjs";
|
|
2
2
|
/**
|
|
3
3
|
* Returns new transaction parameters with increased gas fees.
|
|
4
4
|
*
|
|
@@ -8,4 +8,4 @@ import type { FeeMarketEIP1559Values, GasPriceValue, TransactionParams } from '.
|
|
|
8
8
|
* @returns The new transaction parameters with the increased gas fee properties.
|
|
9
9
|
*/
|
|
10
10
|
export declare function getTransactionParamsWithIncreasedGasFee(originalTransactionParams: TransactionParams, rate: number, newGasValues?: GasPriceValue | FeeMarketEIP1559Values): TransactionParams;
|
|
11
|
-
//# sourceMappingURL=retry.d.
|
|
11
|
+
//# sourceMappingURL=retry.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.d.cts","sourceRoot":"","sources":["../../src/utils/retry.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,sBAAsB,EACtB,aAAa,EACb,iBAAiB,EAClB,qBAAoB;AAErB;;;;;;;GAOG;AACH,wBAAgB,uCAAuC,CACrD,yBAAyB,EAAE,iBAAiB,EAC5C,IAAI,EAAE,MAAM,EACZ,YAAY,CAAC,EAAE,aAAa,GAAG,sBAAsB,GACpD,iBAAiB,CAuCnB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FeeMarketEIP1559Values, GasPriceValue, TransactionParams } from "../types.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Returns new transaction parameters with increased gas fees.
|
|
4
|
+
*
|
|
5
|
+
* @param originalTransactionParams - The original transaction parameters.
|
|
6
|
+
* @param rate - The rate by which to increase the existing gas fee properties.
|
|
7
|
+
* @param newGasValues - Optional new gas values to use instead of increased the existing values.
|
|
8
|
+
* @returns The new transaction parameters with the increased gas fee properties.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getTransactionParamsWithIncreasedGasFee(originalTransactionParams: TransactionParams, rate: number, newGasValues?: GasPriceValue | FeeMarketEIP1559Values): TransactionParams;
|
|
11
|
+
//# sourceMappingURL=retry.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.d.mts","sourceRoot":"","sources":["../../src/utils/retry.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,sBAAsB,EACtB,aAAa,EACb,iBAAiB,EAClB,qBAAoB;AAErB;;;;;;;GAOG;AACH,wBAAgB,uCAAuC,CACrD,yBAAyB,EAAE,iBAAiB,EAC5C,IAAI,EAAE,MAAM,EACZ,YAAY,CAAC,EAAE,aAAa,GAAG,sBAAsB,GACpD,iBAAiB,CAuCnB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { convertHexToDecimal } from
|
|
2
|
-
import { add0x } from
|
|
1
|
+
import { convertHexToDecimal } from "@metamask/controller-utils";
|
|
2
|
+
import { add0x } from "@metamask/utils";
|
|
3
3
|
/**
|
|
4
4
|
* Returns new transaction parameters with increased gas fees.
|
|
5
5
|
*
|
|
@@ -86,4 +86,4 @@ function multiplyHex(value, multiplier) {
|
|
|
86
86
|
const decimalResult = parseInt(`${decimalValue * multiplier}`, 10);
|
|
87
87
|
return add0x(decimalResult.toString(16));
|
|
88
88
|
}
|
|
89
|
-
//# sourceMappingURL=retry.
|
|
89
|
+
//# sourceMappingURL=retry.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.mjs","sourceRoot":"","sources":["../../src/utils/retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,mCAAmC;AAEjE,OAAO,EAAE,KAAK,EAAE,wBAAwB;AAQxC;;;;;;;GAOG;AACH,MAAM,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AG,WAAW,CAAC,2BAA2B,EAAE,IAAI,CAAC,CAAC;IAE5E,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,CAAC;AAChD,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,oBAAoB,CAC3B,yBAA4C,EAC5C,IAAY,EACZ,YAAqD;IAErD,IAAI,YAAY,IAAI,UAAU,IAAI,YAAY,EAAE,CAAC;QAC/C,OAAO,YAAY,CAAC,QAAe,CAAC;IACtC,CAAC;IAED,MAAM,eAAe,GAAG,yBAAyB,CAAC,QAA2B,CAAC;IAE9E,IAAI,CAAC,eAAe,IAAI,eAAe,KAAK,KAAK,EAAE,CAAC;QAClD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,WAAW,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,KAAsB,EAAE,UAAkB;IAC7D,MAAM,YAAY,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAChD,MAAM,aAAa,GAAG,QAAQ,CAAC,GAAG,YAAY,GAAG,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC;IAEnE,OAAO,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["import { convertHexToDecimal } from '@metamask/controller-utils';\nimport type { Hex } from '@metamask/utils';\nimport { add0x } from '@metamask/utils';\n\nimport type {\n FeeMarketEIP1559Values,\n GasPriceValue,\n TransactionParams,\n} from '../types.js';\n\n/**\n * Returns new transaction parameters with increased gas fees.\n *\n * @param originalTransactionParams - The original transaction parameters.\n * @param rate - The rate by which to increase the existing gas fee properties.\n * @param newGasValues - Optional new gas values to use instead of increased the existing values.\n * @returns The new transaction parameters with the increased gas fee properties.\n */\nexport function getTransactionParamsWithIncreasedGasFee(\n originalTransactionParams: TransactionParams,\n rate: number,\n newGasValues?: GasPriceValue | FeeMarketEIP1559Values,\n): TransactionParams {\n const newGasPrice = getIncreasedGasPrice(\n originalTransactionParams,\n rate,\n newGasValues,\n );\n\n const new1559Values = getIncreased1559Values(\n originalTransactionParams,\n rate,\n newGasValues,\n );\n\n if (new1559Values) {\n const newTxParams: TransactionParams = {\n ...originalTransactionParams,\n ...new1559Values,\n };\n\n delete newTxParams.gasPrice;\n\n return newTxParams;\n }\n\n if (newGasPrice) {\n const newTxParams: TransactionParams = {\n ...originalTransactionParams,\n gasPrice: newGasPrice,\n };\n\n delete newTxParams.maxFeePerGas;\n delete newTxParams.maxPriorityFeePerGas;\n\n return newTxParams;\n }\n\n throw new Error(\n 'Cannot increase gas fee as no current values and no new values were provided',\n );\n}\n\n/**\n * Generate the increased EIP-1559 gas properties.\n *\n * @param originalTransactionParams - The original transaction parameters.\n * @param rate - The rate by which to increase the existing gas fee properties.\n * @param newGasValues - Optional new gas values to use instead of increased the existing values.\n * @returns The new EIP-1559 gas properties.\n */\nfunction getIncreased1559Values(\n originalTransactionParams: TransactionParams,\n rate: number,\n newGasValues?: GasPriceValue | FeeMarketEIP1559Values,\n): FeeMarketEIP1559Values | undefined {\n if (\n newGasValues &&\n 'maxFeePerGas' in newGasValues &&\n 'maxPriorityFeePerGas' in newGasValues\n ) {\n return newGasValues;\n }\n\n const currentMaxFeePerGas = originalTransactionParams.maxFeePerGas as\n | Hex\n | undefined;\n\n const currentMaxPriorityFeePerGas =\n originalTransactionParams.maxPriorityFeePerGas as Hex | undefined;\n\n if (\n !currentMaxFeePerGas ||\n !currentMaxPriorityFeePerGas ||\n currentMaxFeePerGas === '0x0' ||\n currentMaxPriorityFeePerGas === '0x0'\n ) {\n return undefined;\n }\n\n const maxFeePerGas = multiplyHex(currentMaxFeePerGas, rate);\n const maxPriorityFeePerGas = multiplyHex(currentMaxPriorityFeePerGas, rate);\n\n return { maxFeePerGas, maxPriorityFeePerGas };\n}\n\n/**\n * Generate the increased gas price.\n *\n * @param originalTransactionParams - The original transaction parameters.\n * @param rate - The rate by which to increase the existing gas fee properties.\n * @param newGasValues - Optional new gas values to use instead of increased the existing values.\n * @returns The new gas price.\n */\nfunction getIncreasedGasPrice(\n originalTransactionParams: TransactionParams,\n rate: number,\n newGasValues?: GasPriceValue | FeeMarketEIP1559Values,\n): Hex | undefined {\n if (newGasValues && 'gasPrice' in newGasValues) {\n return newGasValues.gasPrice as Hex;\n }\n\n const currentGasPrice = originalTransactionParams.gasPrice as Hex | undefined;\n\n if (!currentGasPrice || currentGasPrice === '0x0') {\n return undefined;\n }\n\n return multiplyHex(currentGasPrice, rate);\n}\n\n/**\n * Multiply a hex value by a multiplier.\n *\n * @param value - The hex value to multiply.\n * @param multiplier - The multiplier.\n * @returns The multiplied hex value.\n */\nfunction multiplyHex(value: Hex | undefined, multiplier: number): Hex {\n const decimalValue = convertHexToDecimal(value);\n const decimalResult = parseInt(`${decimalValue * multiplier}`, 10);\n\n return add0x(decimalResult.toString(16));\n}\n"]}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractRevert = exports.decodeRevert = exports.OnChainFailureError = void 0;
|
|
4
|
+
const abi_1 = require("@ethersproject/abi");
|
|
5
|
+
const logger_js_1 = require("../logger.cjs");
|
|
6
|
+
const provider_js_1 = require("./provider.cjs");
|
|
7
|
+
const log = (0, logger_js_1.createModuleLogger)(logger_js_1.projectLogger, 'revert-reason');
|
|
8
|
+
const ERROR_SELECTOR = '0x08c379a0';
|
|
9
|
+
const PANIC_SELECTOR = '0x4e487b71';
|
|
10
|
+
/**
|
|
11
|
+
* Solidity panic code descriptions.
|
|
12
|
+
*
|
|
13
|
+
* @see https://docs.soliditylang.org/en/latest/control-structures.html#panic-via-assert-and-error-via-require
|
|
14
|
+
*/
|
|
15
|
+
const PANIC_CODE_MESSAGES = {
|
|
16
|
+
'0x00': 'Generic compiler panic',
|
|
17
|
+
'0x01': 'Assertion failed',
|
|
18
|
+
'0x11': 'Arithmetic overflow or underflow',
|
|
19
|
+
'0x12': 'Division or modulo by zero',
|
|
20
|
+
'0x21': 'Invalid enum value',
|
|
21
|
+
'0x22': 'Incorrectly encoded storage byte array',
|
|
22
|
+
'0x31': 'Pop on empty array',
|
|
23
|
+
'0x32': 'Array index out of bounds',
|
|
24
|
+
'0x41': 'Memory allocation overflow',
|
|
25
|
+
'0x51': 'Call to zero-initialized function',
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Error thrown by `PendingTransactionTracker` when a transaction failed
|
|
29
|
+
* on-chain, carrying any decoded revert.
|
|
30
|
+
*/
|
|
31
|
+
class OnChainFailureError extends Error {
|
|
32
|
+
constructor(revert) {
|
|
33
|
+
const suffix = revert?.message ? `: ${revert.message}` : '';
|
|
34
|
+
super(`Transaction failed on-chain${suffix}`);
|
|
35
|
+
this.name = 'OnChainFailureError';
|
|
36
|
+
this.revert = revert;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.OnChainFailureError = OnChainFailureError;
|
|
40
|
+
/**
|
|
41
|
+
* Decode an EVM revert into a `Revert` containing both the decoded
|
|
42
|
+
* human-readable message and the original raw `data`. Accepts either a
|
|
43
|
+
* raw revert data hex string, or a thrown JSON-RPC error of the shape
|
|
44
|
+
* `{ data: Hex | { data: Hex } }`. Handles `Error(string)`,
|
|
45
|
+
* `Panic(uint256)`, and falls back to a raw `Custom error: 0x<selector>`
|
|
46
|
+
* reference for unknown custom errors.
|
|
47
|
+
*
|
|
48
|
+
* @param input - Raw revert data hex, or a thrown JSON-RPC error.
|
|
49
|
+
* @param source - Optional label included in debug logs to identify the
|
|
50
|
+
* caller (e.g. `gas`, `simulation`).
|
|
51
|
+
* @returns A `Revert` if any data was found, otherwise `undefined`.
|
|
52
|
+
*/
|
|
53
|
+
function decodeRevert(input, source) {
|
|
54
|
+
const data = toRevertDataHex(input);
|
|
55
|
+
if (!data) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
const message = decodeMessage(data);
|
|
59
|
+
const revert = {
|
|
60
|
+
...(message ? { message } : {}),
|
|
61
|
+
data,
|
|
62
|
+
};
|
|
63
|
+
logRevert(source, revert);
|
|
64
|
+
return revert;
|
|
65
|
+
}
|
|
66
|
+
exports.decodeRevert = decodeRevert;
|
|
67
|
+
/**
|
|
68
|
+
* Replay a transaction that failed on-chain via `eth_estimateGas` to
|
|
69
|
+
* recover the revert reason. `eth_estimateGas` is used instead of
|
|
70
|
+
* `eth_call` to avoid `RetryOnEmptyMiddleware`, which retries reverted
|
|
71
|
+
* `eth_call` responses 10 times and discards the original error data.
|
|
72
|
+
*
|
|
73
|
+
* Always resolves; never throws.
|
|
74
|
+
*
|
|
75
|
+
* @param input - Extraction inputs.
|
|
76
|
+
* @param input.messenger - Transaction controller messenger.
|
|
77
|
+
* @param input.networkClientId - Network client ID to replay against.
|
|
78
|
+
* @param input.txParams - Transaction parameters for the failed tx.
|
|
79
|
+
* @returns A `Revert`, or `undefined` if none could be observed.
|
|
80
|
+
*/
|
|
81
|
+
async function extractRevert({ messenger, networkClientId, txParams, }) {
|
|
82
|
+
if (!txParams?.to && !txParams?.data) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
const callParams = {};
|
|
86
|
+
if (txParams.from) {
|
|
87
|
+
callParams.from = txParams.from;
|
|
88
|
+
}
|
|
89
|
+
if (txParams.to) {
|
|
90
|
+
callParams.to = txParams.to;
|
|
91
|
+
}
|
|
92
|
+
if (txParams.data) {
|
|
93
|
+
callParams.data = txParams.data;
|
|
94
|
+
}
|
|
95
|
+
if (txParams.value) {
|
|
96
|
+
callParams.value = txParams.value;
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
await (0, provider_js_1.rpcRequest)({
|
|
100
|
+
messenger,
|
|
101
|
+
networkClientId,
|
|
102
|
+
// `eth_estimateGas` is used instead of `eth_call` to bypass
|
|
103
|
+
// `RetryOnEmptyMiddleware`, which retries reverted `eth_call`
|
|
104
|
+
// responses and discards the original revert data.
|
|
105
|
+
method: 'eth_estimateGas',
|
|
106
|
+
params: [callParams],
|
|
107
|
+
});
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
return decodeRevert(error, 'receipt');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
exports.extractRevert = extractRevert;
|
|
115
|
+
/**
|
|
116
|
+
* Coerce a `RevertInput` to a non-empty revert data hex string.
|
|
117
|
+
*
|
|
118
|
+
* @param input - Raw hex or thrown JSON-RPC error.
|
|
119
|
+
* @returns The revert data hex, or `undefined`.
|
|
120
|
+
*/
|
|
121
|
+
function toRevertDataHex(input) {
|
|
122
|
+
if (isHex(input)) {
|
|
123
|
+
return input;
|
|
124
|
+
}
|
|
125
|
+
if (typeof input !== 'object' || input === null) {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
const { data } = input;
|
|
129
|
+
if (isHex(data)) {
|
|
130
|
+
return data;
|
|
131
|
+
}
|
|
132
|
+
if (typeof data === 'object' && data !== null && isHex(data.data)) {
|
|
133
|
+
return data.data;
|
|
134
|
+
}
|
|
135
|
+
return undefined;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Type guard for non-empty `0x`-prefixed hex strings.
|
|
139
|
+
*
|
|
140
|
+
* @param value - Value to test.
|
|
141
|
+
* @returns Whether the value is a non-empty hex string.
|
|
142
|
+
*/
|
|
143
|
+
function isHex(value) {
|
|
144
|
+
return typeof value === 'string' && value.startsWith('0x') && value !== '0x';
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Decode raw revert data into a human-readable string.
|
|
148
|
+
*
|
|
149
|
+
* @param data - Raw revert data hex.
|
|
150
|
+
* @returns Decoded message, or `undefined` if undecodable.
|
|
151
|
+
*/
|
|
152
|
+
function decodeMessage(data) {
|
|
153
|
+
if (!data || data === '0x') {
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
156
|
+
if (data.length < 10) {
|
|
157
|
+
return `execution reverted (${data})`;
|
|
158
|
+
}
|
|
159
|
+
const selector = data.slice(0, 10).toLowerCase();
|
|
160
|
+
const payload = `0x${data.slice(10)}`;
|
|
161
|
+
if (selector === ERROR_SELECTOR) {
|
|
162
|
+
try {
|
|
163
|
+
const [reason] = abi_1.defaultAbiCoder.decode(['string'], payload);
|
|
164
|
+
return typeof reason === 'string' ? reason : undefined;
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
return undefined;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (selector === PANIC_SELECTOR) {
|
|
171
|
+
try {
|
|
172
|
+
const [code] = abi_1.defaultAbiCoder.decode(['uint256'], payload);
|
|
173
|
+
const codeHex = code.toHexString().toLowerCase();
|
|
174
|
+
const description = PANIC_CODE_MESSAGES[codeHex] ?? 'Unknown panic';
|
|
175
|
+
return `Panic: ${description}`;
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return `Custom error: ${selector}`;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Emit a single structured debug line for a decoded revert.
|
|
185
|
+
*
|
|
186
|
+
* @param source - Source label, when known.
|
|
187
|
+
* @param revert - Resolved Revert.
|
|
188
|
+
*/
|
|
189
|
+
function logRevert(source, revert) {
|
|
190
|
+
log('Decoded revert', source ?? 'unknown', revert);
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=revert-reason.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revert-reason.cjs","sourceRoot":"","sources":["../../src/utils/revert-reason.ts"],"names":[],"mappings":";;;AAAA,4CAAqD;AAIrD,6CAAiE;AAGjE,gDAA2C;AAE3C,MAAM,GAAG,GAAG,IAAA,8BAAkB,EAAC,yBAAa,EAAE,eAAe,CAAC,CAAC;AAE/D,MAAM,cAAc,GAAG,YAAY,CAAC;AACpC,MAAM,cAAc,GAAG,YAAY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,CAAC;IAED,IAAI,QAAQ,KAAK,cAAc,EAAE,CAAC;QAChC,IAAI,CAAC;YACH,MAAM,CAAC,IAAI,CAAC,GAAG,qBAAe,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,EAAE,OAAO,CAEzD,CAAC;YACF,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,WAAW,EAAS,CAAC;YACxD,MAAM,WAAW,GAAG,mBAAmB,CAAC,OAAO,CAAC,IAAI,eAAe,CAAC;YACpE,OAAO,UAAU,WAAW,EAAE,CAAC;QACjC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAED,OAAO,iBAAiB,QAAQ,EAAE,CAAC;AACrC,CAAC;AAED;;;;;GAKG;AACH,SAAS,SAAS,CAAC,MAA0B,EAAE,MAAc;IAC3D,GAAG,CAAC,gBAAgB,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,CAAC,CAAC;AACrD,CAAC","sourcesContent":["import { defaultAbiCoder } from '@ethersproject/abi';\nimport type { NetworkClientId } from '@metamask/network-controller';\nimport type { Hex } from '@metamask/utils';\n\nimport { createModuleLogger, projectLogger } from '../logger.js';\nimport type { TransactionControllerMessenger } from '../TransactionController.js';\nimport type { Revert, TransactionParams } from '../types.js';\nimport { rpcRequest } from './provider.js';\n\nconst log = createModuleLogger(projectLogger, 'revert-reason');\n\nconst ERROR_SELECTOR = '0x08c379a0';\nconst PANIC_SELECTOR = '0x4e487b71';\n\n/**\n * Solidity panic code descriptions.\n *\n * @see https://docs.soliditylang.org/en/latest/control-structures.html#panic-via-assert-and-error-via-require\n */\nconst PANIC_CODE_MESSAGES: Record<string, string> = {\n '0x00': 'Generic compiler panic',\n '0x01': 'Assertion failed',\n '0x11': 'Arithmetic overflow or underflow',\n '0x12': 'Division or modulo by zero',\n '0x21': 'Invalid enum value',\n '0x22': 'Incorrectly encoded storage byte array',\n '0x31': 'Pop on empty array',\n '0x32': 'Array index out of bounds',\n '0x41': 'Memory allocation overflow',\n '0x51': 'Call to zero-initialized function',\n};\n\n/**\n * Input accepted by `decodeRevert`. Either raw revert data hex, or a\n * thrown JSON-RPC error carrying the data on `data` (standard) or\n * nested `data.data` (some older node forks).\n */\ntype RevertInput =\n | Hex\n | undefined\n | { data?: Hex | { data?: Hex } | null }\n | null;\n\n/**\n * Error thrown by `PendingTransactionTracker` when a transaction failed\n * on-chain, carrying any decoded revert.\n */\nexport class OnChainFailureError extends Error {\n readonly revert?: Revert;\n\n constructor(revert?: Revert) {\n const suffix = revert?.message ? `: ${revert.message}` : '';\n super(`Transaction failed on-chain${suffix}`);\n this.name = 'OnChainFailureError';\n this.revert = revert;\n }\n}\n\n/**\n * Decode an EVM revert into a `Revert` containing both the decoded\n * human-readable message and the original raw `data`. Accepts either a\n * raw revert data hex string, or a thrown JSON-RPC error of the shape\n * `{ data: Hex | { data: Hex } }`. Handles `Error(string)`,\n * `Panic(uint256)`, and falls back to a raw `Custom error: 0x<selector>`\n * reference for unknown custom errors.\n *\n * @param input - Raw revert data hex, or a thrown JSON-RPC error.\n * @param source - Optional label included in debug logs to identify the\n * caller (e.g. `gas`, `simulation`).\n * @returns A `Revert` if any data was found, otherwise `undefined`.\n */\nexport function decodeRevert(\n input: RevertInput,\n source?: string,\n): Revert | undefined {\n const data = toRevertDataHex(input);\n if (!data) {\n return undefined;\n }\n\n const message = decodeMessage(data);\n const revert: Revert = {\n ...(message ? { message } : {}),\n data,\n };\n\n logRevert(source, revert);\n return revert;\n}\n\n/**\n * Replay a transaction that failed on-chain via `eth_estimateGas` to\n * recover the revert reason. `eth_estimateGas` is used instead of\n * `eth_call` to avoid `RetryOnEmptyMiddleware`, which retries reverted\n * `eth_call` responses 10 times and discards the original error data.\n *\n * Always resolves; never throws.\n *\n * @param input - Extraction inputs.\n * @param input.messenger - Transaction controller messenger.\n * @param input.networkClientId - Network client ID to replay against.\n * @param input.txParams - Transaction parameters for the failed tx.\n * @returns A `Revert`, or `undefined` if none could be observed.\n */\nexport async function extractRevert({\n messenger,\n networkClientId,\n txParams,\n}: {\n messenger: TransactionControllerMessenger;\n networkClientId: NetworkClientId;\n txParams: TransactionParams;\n}): Promise<Revert | undefined> {\n if (!txParams?.to && !txParams?.data) {\n return undefined;\n }\n\n const callParams: Record<string, string> = {};\n if (txParams.from) {\n callParams.from = txParams.from;\n }\n if (txParams.to) {\n callParams.to = txParams.to;\n }\n if (txParams.data) {\n callParams.data = txParams.data;\n }\n if (txParams.value) {\n callParams.value = txParams.value;\n }\n\n try {\n await rpcRequest({\n messenger,\n networkClientId,\n // `eth_estimateGas` is used instead of `eth_call` to bypass\n // `RetryOnEmptyMiddleware`, which retries reverted `eth_call`\n // responses and discards the original revert data.\n method: 'eth_estimateGas',\n params: [callParams],\n });\n return undefined;\n } catch (error: unknown) {\n return decodeRevert(error as RevertInput, 'receipt');\n }\n}\n\n/**\n * Coerce a `RevertInput` to a non-empty revert data hex string.\n *\n * @param input - Raw hex or thrown JSON-RPC error.\n * @returns The revert data hex, or `undefined`.\n */\nfunction toRevertDataHex(input: RevertInput): Hex | undefined {\n if (isHex(input)) {\n return input;\n }\n\n if (typeof input !== 'object' || input === null) {\n return undefined;\n }\n\n const { data } = input;\n if (isHex(data)) {\n return data;\n }\n\n if (typeof data === 'object' && data !== null && isHex(data.data)) {\n return data.data;\n }\n\n return undefined;\n}\n\n/**\n * Type guard for non-empty `0x`-prefixed hex strings.\n *\n * @param value - Value to test.\n * @returns Whether the value is a non-empty hex string.\n */\nfunction isHex(value: unknown): value is Hex {\n return typeof value === 'string' && value.startsWith('0x') && value !== '0x';\n}\n\n/**\n * Decode raw revert data into a human-readable string.\n *\n * @param data - Raw revert data hex.\n * @returns Decoded message, or `undefined` if undecodable.\n */\nfunction decodeMessage(data: Hex | undefined): string | undefined {\n if (!data || data === '0x') {\n return undefined;\n }\n\n if (data.length < 10) {\n return `execution reverted (${data})`;\n }\n\n const selector = data.slice(0, 10).toLowerCase();\n const payload = `0x${data.slice(10)}`;\n\n if (selector === ERROR_SELECTOR) {\n try {\n const [reason] = defaultAbiCoder.decode(['string'], payload);\n return typeof reason === 'string' ? reason : undefined;\n } catch {\n return undefined;\n }\n }\n\n if (selector === PANIC_SELECTOR) {\n try {\n const [code] = defaultAbiCoder.decode(['uint256'], payload) as [\n { toHexString: () => string },\n ];\n const codeHex = code.toHexString().toLowerCase() as Hex;\n const description = PANIC_CODE_MESSAGES[codeHex] ?? 'Unknown panic';\n return `Panic: ${description}`;\n } catch {\n return undefined;\n }\n }\n\n return `Custom error: ${selector}`;\n}\n\n/**\n * Emit a single structured debug line for a decoded revert.\n *\n * @param source - Source label, when known.\n * @param revert - Resolved Revert.\n */\nfunction logRevert(source: string | undefined, revert: Revert): void {\n log('Decoded revert', source ?? 'unknown', revert);\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { NetworkClientId } from
|
|
2
|
-
import type { Hex } from
|
|
3
|
-
import type { TransactionControllerMessenger } from
|
|
4
|
-
import type { Revert, TransactionParams } from
|
|
1
|
+
import type { NetworkClientId } from "@metamask/network-controller";
|
|
2
|
+
import type { Hex } from "@metamask/utils";
|
|
3
|
+
import type { TransactionControllerMessenger } from "../TransactionController.cjs";
|
|
4
|
+
import type { Revert, TransactionParams } from "../types.cjs";
|
|
5
5
|
/**
|
|
6
6
|
* Input accepted by `decodeRevert`. Either raw revert data hex, or a
|
|
7
7
|
* thrown JSON-RPC error carrying the data on `data` (standard) or
|
|
@@ -54,4 +54,4 @@ export declare function extractRevert({ messenger, networkClientId, txParams, }:
|
|
|
54
54
|
txParams: TransactionParams;
|
|
55
55
|
}): Promise<Revert | undefined>;
|
|
56
56
|
export {};
|
|
57
|
-
//# sourceMappingURL=revert-reason.d.
|
|
57
|
+
//# sourceMappingURL=revert-reason.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revert-reason.d.cts","sourceRoot":"","sources":["../../src/utils/revert-reason.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,qCAAqC;AACpE,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAG3C,OAAO,KAAK,EAAE,8BAA8B,EAAE,qCAAoC;AAClF,OAAO,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,qBAAoB;AA0B7D;;;;GAIG;AACH,KAAK,WAAW,GACZ,GAAG,GACH,SAAS,GACT;IAAE,IAAI,CAAC,EAAE,GAAG,GAAG;QAAE,IAAI,CAAC,EAAE,GAAG,CAAA;KAAE,GAAG,IAAI,CAAA;CAAE,GACtC,IAAI,CAAC;AAET;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;gBAEb,MAAM,CAAC,EAAE,MAAM;CAM5B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,WAAW,EAClB,MAAM,CAAC,EAAE,MAAM,GACd,MAAM,GAAG,SAAS,CAcpB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,aAAa,CAAC,EAClC,SAAS,EACT,eAAe,EACf,QAAQ,GACT,EAAE;IACD,SAAS,EAAE,8BAA8B,CAAC;IAC1C,eAAe,EAAE,eAAe,CAAC;IACjC,QAAQ,EAAE,iBAAiB,CAAC;CAC7B,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAiC9B"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { NetworkClientId } from "@metamask/network-controller";
|
|
2
|
+
import type { Hex } from "@metamask/utils";
|
|
3
|
+
import type { TransactionControllerMessenger } from "../TransactionController.mjs";
|
|
4
|
+
import type { Revert, TransactionParams } from "../types.mjs";
|
|
5
|
+
/**
|
|
6
|
+
* Input accepted by `decodeRevert`. Either raw revert data hex, or a
|
|
7
|
+
* thrown JSON-RPC error carrying the data on `data` (standard) or
|
|
8
|
+
* nested `data.data` (some older node forks).
|
|
9
|
+
*/
|
|
10
|
+
type RevertInput = Hex | undefined | {
|
|
11
|
+
data?: Hex | {
|
|
12
|
+
data?: Hex;
|
|
13
|
+
} | null;
|
|
14
|
+
} | null;
|
|
15
|
+
/**
|
|
16
|
+
* Error thrown by `PendingTransactionTracker` when a transaction failed
|
|
17
|
+
* on-chain, carrying any decoded revert.
|
|
18
|
+
*/
|
|
19
|
+
export declare class OnChainFailureError extends Error {
|
|
20
|
+
readonly revert?: Revert;
|
|
21
|
+
constructor(revert?: Revert);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Decode an EVM revert into a `Revert` containing both the decoded
|
|
25
|
+
* human-readable message and the original raw `data`. Accepts either a
|
|
26
|
+
* raw revert data hex string, or a thrown JSON-RPC error of the shape
|
|
27
|
+
* `{ data: Hex | { data: Hex } }`. Handles `Error(string)`,
|
|
28
|
+
* `Panic(uint256)`, and falls back to a raw `Custom error: 0x<selector>`
|
|
29
|
+
* reference for unknown custom errors.
|
|
30
|
+
*
|
|
31
|
+
* @param input - Raw revert data hex, or a thrown JSON-RPC error.
|
|
32
|
+
* @param source - Optional label included in debug logs to identify the
|
|
33
|
+
* caller (e.g. `gas`, `simulation`).
|
|
34
|
+
* @returns A `Revert` if any data was found, otherwise `undefined`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function decodeRevert(input: RevertInput, source?: string): Revert | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Replay a transaction that failed on-chain via `eth_estimateGas` to
|
|
39
|
+
* recover the revert reason. `eth_estimateGas` is used instead of
|
|
40
|
+
* `eth_call` to avoid `RetryOnEmptyMiddleware`, which retries reverted
|
|
41
|
+
* `eth_call` responses 10 times and discards the original error data.
|
|
42
|
+
*
|
|
43
|
+
* Always resolves; never throws.
|
|
44
|
+
*
|
|
45
|
+
* @param input - Extraction inputs.
|
|
46
|
+
* @param input.messenger - Transaction controller messenger.
|
|
47
|
+
* @param input.networkClientId - Network client ID to replay against.
|
|
48
|
+
* @param input.txParams - Transaction parameters for the failed tx.
|
|
49
|
+
* @returns A `Revert`, or `undefined` if none could be observed.
|
|
50
|
+
*/
|
|
51
|
+
export declare function extractRevert({ messenger, networkClientId, txParams, }: {
|
|
52
|
+
messenger: TransactionControllerMessenger;
|
|
53
|
+
networkClientId: NetworkClientId;
|
|
54
|
+
txParams: TransactionParams;
|
|
55
|
+
}): Promise<Revert | undefined>;
|
|
56
|
+
export {};
|
|
57
|
+
//# sourceMappingURL=revert-reason.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revert-reason.d.mts","sourceRoot":"","sources":["../../src/utils/revert-reason.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,qCAAqC;AACpE,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAG3C,OAAO,KAAK,EAAE,8BAA8B,EAAE,qCAAoC;AAClF,OAAO,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,qBAAoB;AA0B7D;;;;GAIG;AACH,KAAK,WAAW,GACZ,GAAG,GACH,SAAS,GACT;IAAE,IAAI,CAAC,EAAE,GAAG,GAAG;QAAE,IAAI,CAAC,EAAE,GAAG,CAAA;KAAE,GAAG,IAAI,CAAA;CAAE,GACtC,IAAI,CAAC;AAET;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;gBAEb,MAAM,CAAC,EAAE,MAAM;CAM5B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,WAAW,EAClB,MAAM,CAAC,EAAE,MAAM,GACd,MAAM,GAAG,SAAS,CAcpB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,aAAa,CAAC,EAClC,SAAS,EACT,eAAe,EACf,QAAQ,GACT,EAAE;IACD,SAAS,EAAE,8BAA8B,CAAC;IAC1C,eAAe,EAAE,eAAe,CAAC;IACjC,QAAQ,EAAE,iBAAiB,CAAC;CAC7B,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAiC9B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defaultAbiCoder } from
|
|
2
|
-
import { createModuleLogger, projectLogger } from
|
|
3
|
-
import { rpcRequest } from
|
|
1
|
+
import { defaultAbiCoder } from "@ethersproject/abi";
|
|
2
|
+
import { createModuleLogger, projectLogger } from "../logger.mjs";
|
|
3
|
+
import { rpcRequest } from "./provider.mjs";
|
|
4
4
|
const log = createModuleLogger(projectLogger, 'revert-reason');
|
|
5
5
|
const ERROR_SELECTOR = '0x08c379a0';
|
|
6
6
|
const PANIC_SELECTOR = '0x4e487b71';
|
|
@@ -183,4 +183,4 @@ function decodeMessage(data) {
|
|
|
183
183
|
function logRevert(source, revert) {
|
|
184
184
|
log('Decoded revert', source ?? 'unknown', revert);
|
|
185
185
|
}
|
|
186
|
-
//# sourceMappingURL=revert-reason.
|
|
186
|
+
//# sourceMappingURL=revert-reason.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revert-reason.mjs","sourceRoot":"","sources":["../../src/utils/revert-reason.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,2BAA2B;AAIrD,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,sBAAqB;AAGjE,OAAO,EAAE,UAAU,EAAE,uBAAsB;AAE3C,MAAM,GAAG,GAAG,kBAAkB,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;AAE/D,MAAM,cAAc,GAAG,YAAY,CAAC;AACpC,MAAM,cAAc,GAAG,YAAY,CAAC;AAEpC;;;;GAIG;AACH,MAAM,mBAAmB,GAA2B;IAClD,MAAM,EAAE,wBAAwB;IAChC,MAAM,EAAE,kBAAkB;IAC1B,MAAM,EAAE,kCAAkC;IAC1C,MAAM,EAAE,4BAA4B;IACpC,MAAM,EAAE,oBAAoB;IAC5B,MAAM,EAAE,wCAAwC;IAChD,MAAM,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WAAW,GAAG,mBAAmB,CAAC,OAAO,CAAC,IAAI,eAAe,CAAC;YACpE,OAAO,UAAU,WAAW,EAAE,CAAC;QACjC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAED,OAAO,iBAAiB,QAAQ,EAAE,CAAC;AACrC,CAAC;AAED;;;;;GAKG;AACH,SAAS,SAAS,CAAC,MAA0B,EAAE,MAAc;IAC3D,GAAG,CAAC,gBAAgB,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,CAAC,CAAC;AACrD,CAAC","sourcesContent":["import { defaultAbiCoder } from '@ethersproject/abi';\nimport type { NetworkClientId } from '@metamask/network-controller';\nimport type { Hex } from '@metamask/utils';\n\nimport { createModuleLogger, projectLogger } from '../logger.js';\nimport type { TransactionControllerMessenger } from '../TransactionController.js';\nimport type { Revert, TransactionParams } from '../types.js';\nimport { rpcRequest } from './provider.js';\n\nconst log = createModuleLogger(projectLogger, 'revert-reason');\n\nconst ERROR_SELECTOR = '0x08c379a0';\nconst PANIC_SELECTOR = '0x4e487b71';\n\n/**\n * Solidity panic code descriptions.\n *\n * @see https://docs.soliditylang.org/en/latest/control-structures.html#panic-via-assert-and-error-via-require\n */\nconst PANIC_CODE_MESSAGES: Record<string, string> = {\n '0x00': 'Generic compiler panic',\n '0x01': 'Assertion failed',\n '0x11': 'Arithmetic overflow or underflow',\n '0x12': 'Division or modulo by zero',\n '0x21': 'Invalid enum value',\n '0x22': 'Incorrectly encoded storage byte array',\n '0x31': 'Pop on empty array',\n '0x32': 'Array index out of bounds',\n '0x41': 'Memory allocation overflow',\n '0x51': 'Call to zero-initialized function',\n};\n\n/**\n * Input accepted by `decodeRevert`. Either raw revert data hex, or a\n * thrown JSON-RPC error carrying the data on `data` (standard) or\n * nested `data.data` (some older node forks).\n */\ntype RevertInput =\n | Hex\n | undefined\n | { data?: Hex | { data?: Hex } | null }\n | null;\n\n/**\n * Error thrown by `PendingTransactionTracker` when a transaction failed\n * on-chain, carrying any decoded revert.\n */\nexport class OnChainFailureError extends Error {\n readonly revert?: Revert;\n\n constructor(revert?: Revert) {\n const suffix = revert?.message ? `: ${revert.message}` : '';\n super(`Transaction failed on-chain${suffix}`);\n this.name = 'OnChainFailureError';\n this.revert = revert;\n }\n}\n\n/**\n * Decode an EVM revert into a `Revert` containing both the decoded\n * human-readable message and the original raw `data`. Accepts either a\n * raw revert data hex string, or a thrown JSON-RPC error of the shape\n * `{ data: Hex | { data: Hex } }`. Handles `Error(string)`,\n * `Panic(uint256)`, and falls back to a raw `Custom error: 0x<selector>`\n * reference for unknown custom errors.\n *\n * @param input - Raw revert data hex, or a thrown JSON-RPC error.\n * @param source - Optional label included in debug logs to identify the\n * caller (e.g. `gas`, `simulation`).\n * @returns A `Revert` if any data was found, otherwise `undefined`.\n */\nexport function decodeRevert(\n input: RevertInput,\n source?: string,\n): Revert | undefined {\n const data = toRevertDataHex(input);\n if (!data) {\n return undefined;\n }\n\n const message = decodeMessage(data);\n const revert: Revert = {\n ...(message ? { message } : {}),\n data,\n };\n\n logRevert(source, revert);\n return revert;\n}\n\n/**\n * Replay a transaction that failed on-chain via `eth_estimateGas` to\n * recover the revert reason. `eth_estimateGas` is used instead of\n * `eth_call` to avoid `RetryOnEmptyMiddleware`, which retries reverted\n * `eth_call` responses 10 times and discards the original error data.\n *\n * Always resolves; never throws.\n *\n * @param input - Extraction inputs.\n * @param input.messenger - Transaction controller messenger.\n * @param input.networkClientId - Network client ID to replay against.\n * @param input.txParams - Transaction parameters for the failed tx.\n * @returns A `Revert`, or `undefined` if none could be observed.\n */\nexport async function extractRevert({\n messenger,\n networkClientId,\n txParams,\n}: {\n messenger: TransactionControllerMessenger;\n networkClientId: NetworkClientId;\n txParams: TransactionParams;\n}): Promise<Revert | undefined> {\n if (!txParams?.to && !txParams?.data) {\n return undefined;\n }\n\n const callParams: Record<string, string> = {};\n if (txParams.from) {\n callParams.from = txParams.from;\n }\n if (txParams.to) {\n callParams.to = txParams.to;\n }\n if (txParams.data) {\n callParams.data = txParams.data;\n }\n if (txParams.value) {\n callParams.value = txParams.value;\n }\n\n try {\n await rpcRequest({\n messenger,\n networkClientId,\n // `eth_estimateGas` is used instead of `eth_call` to bypass\n // `RetryOnEmptyMiddleware`, which retries reverted `eth_call`\n // responses and discards the original revert data.\n method: 'eth_estimateGas',\n params: [callParams],\n });\n return undefined;\n } catch (error: unknown) {\n return decodeRevert(error as RevertInput, 'receipt');\n }\n}\n\n/**\n * Coerce a `RevertInput` to a non-empty revert data hex string.\n *\n * @param input - Raw hex or thrown JSON-RPC error.\n * @returns The revert data hex, or `undefined`.\n */\nfunction toRevertDataHex(input: RevertInput): Hex | undefined {\n if (isHex(input)) {\n return input;\n }\n\n if (typeof input !== 'object' || input === null) {\n return undefined;\n }\n\n const { data } = input;\n if (isHex(data)) {\n return data;\n }\n\n if (typeof data === 'object' && data !== null && isHex(data.data)) {\n return data.data;\n }\n\n return undefined;\n}\n\n/**\n * Type guard for non-empty `0x`-prefixed hex strings.\n *\n * @param value - Value to test.\n * @returns Whether the value is a non-empty hex string.\n */\nfunction isHex(value: unknown): value is Hex {\n return typeof value === 'string' && value.startsWith('0x') && value !== '0x';\n}\n\n/**\n * Decode raw revert data into a human-readable string.\n *\n * @param data - Raw revert data hex.\n * @returns Decoded message, or `undefined` if undecodable.\n */\nfunction decodeMessage(data: Hex | undefined): string | undefined {\n if (!data || data === '0x') {\n return undefined;\n }\n\n if (data.length < 10) {\n return `execution reverted (${data})`;\n }\n\n const selector = data.slice(0, 10).toLowerCase();\n const payload = `0x${data.slice(10)}`;\n\n if (selector === ERROR_SELECTOR) {\n try {\n const [reason] = defaultAbiCoder.decode(['string'], payload);\n return typeof reason === 'string' ? reason : undefined;\n } catch {\n return undefined;\n }\n }\n\n if (selector === PANIC_SELECTOR) {\n try {\n const [code] = defaultAbiCoder.decode(['uint256'], payload) as [\n { toHexString: () => string },\n ];\n const codeHex = code.toHexString().toLowerCase() as Hex;\n const description = PANIC_CODE_MESSAGES[codeHex] ?? 'Unknown panic';\n return `Panic: ${description}`;\n } catch {\n return undefined;\n }\n }\n\n return `Custom error: ${selector}`;\n}\n\n/**\n * Emit a single structured debug line for a decoded revert.\n *\n * @param source - Source label, when known.\n * @param revert - Resolved Revert.\n */\nfunction logRevert(source: string | undefined, revert: Revert): void {\n log('Decoded revert', source ?? 'unknown', revert);\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isValidSignature = void 0;
|
|
4
|
+
const wallet_1 = require("@ethersproject/wallet");
|
|
5
|
+
const utils_1 = require("@metamask/utils");
|
|
6
|
+
/**
|
|
7
|
+
* Verify if the signature is the specified data signed by the specified public key.
|
|
8
|
+
*
|
|
9
|
+
* @param data - The data to check.
|
|
10
|
+
* @param signature - The signature to check.
|
|
11
|
+
* @param publicKey - The public key to check.
|
|
12
|
+
* @returns True if the signature is correct, false otherwise.
|
|
13
|
+
*/
|
|
14
|
+
function isValidSignature(data, signature, publicKey) {
|
|
15
|
+
try {
|
|
16
|
+
const joinedHex = (0, utils_1.add0x)(data.map(utils_1.remove0x).join(''));
|
|
17
|
+
const dataBytes = (0, utils_1.hexToBytes)(joinedHex);
|
|
18
|
+
const actualPublicKey = (0, wallet_1.verifyMessage)(dataBytes, signature);
|
|
19
|
+
return actualPublicKey.toLowerCase() === publicKey.toLowerCase();
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.isValidSignature = isValidSignature;
|
|
26
|
+
//# sourceMappingURL=signature.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signature.cjs","sourceRoot":"","sources":["../../src/utils/signature.ts"],"names":[],"mappings":";;;AAAA,kDAAsD;AAEtD,2CAA8D;AAE9D;;;;;;;GAOG;AACH,SAAgB,gBAAgB,CAC9B,IAAW,EACX,SAAc,EACd,SAAc;IAEd,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,IAAA,aAAK,EAAC,IAAI,CAAC,GAAG,CAAC,gBAAQ,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QACrD,MAAM,SAAS,GAAG,IAAA,kBAAU,EAAC,SAAS,CAAC,CAAC;QACxC,MAAM,eAAe,GAAG,IAAA,sBAAa,EAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAE5D,OAAO,eAAe,CAAC,WAAW,EAAE,KAAK,SAAS,CAAC,WAAW,EAAE,CAAC;IACnE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAdD,4CAcC","sourcesContent":["import { verifyMessage } from '@ethersproject/wallet';\nimport type { Hex } from '@metamask/utils';\nimport { add0x, hexToBytes, remove0x } from '@metamask/utils';\n\n/**\n * Verify if the signature is the specified data signed by the specified public key.\n *\n * @param data - The data to check.\n * @param signature - The signature to check.\n * @param publicKey - The public key to check.\n * @returns True if the signature is correct, false otherwise.\n */\nexport function isValidSignature(\n data: Hex[],\n signature: Hex,\n publicKey: Hex,\n): boolean {\n try {\n const joinedHex = add0x(data.map(remove0x).join(''));\n const dataBytes = hexToBytes(joinedHex);\n const actualPublicKey = verifyMessage(dataBytes, signature);\n\n return actualPublicKey.toLowerCase() === publicKey.toLowerCase();\n } catch {\n return false;\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Hex } from
|
|
1
|
+
import type { Hex } from "@metamask/utils";
|
|
2
2
|
/**
|
|
3
3
|
* Verify if the signature is the specified data signed by the specified public key.
|
|
4
4
|
*
|
|
@@ -8,4 +8,4 @@ import type { Hex } from '@metamask/utils';
|
|
|
8
8
|
* @returns True if the signature is correct, false otherwise.
|
|
9
9
|
*/
|
|
10
10
|
export declare function isValidSignature(data: Hex[], signature: Hex, publicKey: Hex): boolean;
|
|
11
|
-
//# sourceMappingURL=signature.d.
|
|
11
|
+
//# sourceMappingURL=signature.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signature.d.cts","sourceRoot":"","sources":["../../src/utils/signature.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAG3C;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,GAAG,EAAE,EACX,SAAS,EAAE,GAAG,EACd,SAAS,EAAE,GAAG,GACb,OAAO,CAUT"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Hex } from "@metamask/utils";
|
|
2
|
+
/**
|
|
3
|
+
* Verify if the signature is the specified data signed by the specified public key.
|
|
4
|
+
*
|
|
5
|
+
* @param data - The data to check.
|
|
6
|
+
* @param signature - The signature to check.
|
|
7
|
+
* @param publicKey - The public key to check.
|
|
8
|
+
* @returns True if the signature is correct, false otherwise.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isValidSignature(data: Hex[], signature: Hex, publicKey: Hex): boolean;
|
|
11
|
+
//# sourceMappingURL=signature.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signature.d.mts","sourceRoot":"","sources":["../../src/utils/signature.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAG3C;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,GAAG,EAAE,EACX,SAAS,EAAE,GAAG,EACd,SAAS,EAAE,GAAG,GACb,OAAO,CAUT"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { verifyMessage } from
|
|
2
|
-
import { add0x, hexToBytes, remove0x } from
|
|
1
|
+
import { verifyMessage } from "@ethersproject/wallet";
|
|
2
|
+
import { add0x, hexToBytes, remove0x } from "@metamask/utils";
|
|
3
3
|
/**
|
|
4
4
|
* Verify if the signature is the specified data signed by the specified public key.
|
|
5
5
|
*
|
|
@@ -19,4 +19,4 @@ export function isValidSignature(data, signature, publicKey) {
|
|
|
19
19
|
return false;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
//# sourceMappingURL=signature.
|
|
22
|
+
//# sourceMappingURL=signature.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signature.mjs","sourceRoot":"","sources":["../../src/utils/signature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,8BAA8B;AAEtD,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,wBAAwB;AAE9D;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAAW,EACX,SAAc,EACd,SAAc;IAEd,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QACrD,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;QACxC,MAAM,eAAe,GAAG,aAAa,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAE5D,OAAO,eAAe,CAAC,WAAW,EAAE,KAAK,SAAS,CAAC,WAAW,EAAE,CAAC;IACnE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["import { verifyMessage } from '@ethersproject/wallet';\nimport type { Hex } from '@metamask/utils';\nimport { add0x, hexToBytes, remove0x } from '@metamask/utils';\n\n/**\n * Verify if the signature is the specified data signed by the specified public key.\n *\n * @param data - The data to check.\n * @param signature - The signature to check.\n * @param publicKey - The public key to check.\n * @returns True if the signature is correct, false otherwise.\n */\nexport function isValidSignature(\n data: Hex[],\n signature: Hex,\n publicKey: Hex,\n): boolean {\n try {\n const joinedHex = add0x(data.map(remove0x).join(''));\n const dataBytes = hexToBytes(joinedHex);\n const actualPublicKey = verifyMessage(dataBytes, signature);\n\n return actualPublicKey.toLowerCase() === publicKey.toLowerCase();\n } catch {\n return false;\n }\n}\n"]}
|