@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,354 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAuthorizationAuthority = exports.recoverAuthorizationAuthority = exports.isAuthorizationSigned = exports.decodeAuthorizationSignature = exports.signAuthorizationList = exports.generateEIP7702BatchTransaction = exports.updateEIP7702BatchData = exports.isAccountUpgradedToEIP7702 = exports.getDelegationAddress = exports.doesChainSupportEIP7702 = exports.doesAccountSupportEIP7702 = exports.ERROR_MESSGE_PUBLIC_KEY = exports.CALLS_SIGNATURE = exports.BATCH_FUNCTION_NAME = exports.DELEGATION_PREFIX = void 0;
|
|
4
|
+
const rlp_1 = require("@ethereumjs/rlp");
|
|
5
|
+
const util_1 = require("@ethereumjs/util");
|
|
6
|
+
const abi_1 = require("@ethersproject/abi");
|
|
7
|
+
const contracts_1 = require("@ethersproject/contracts");
|
|
8
|
+
const controller_utils_1 = require("@metamask/controller-utils");
|
|
9
|
+
const utils_1 = require("@metamask/utils");
|
|
10
|
+
const keccak_1 = require("ethereum-cryptography/keccak");
|
|
11
|
+
const constants_js_1 = require("../constants.cjs");
|
|
12
|
+
const logger_js_1 = require("../logger.cjs");
|
|
13
|
+
const feature_flags_js_1 = require("./feature-flags.cjs");
|
|
14
|
+
const provider_js_1 = require("./provider.cjs");
|
|
15
|
+
exports.DELEGATION_PREFIX = '0xef0100';
|
|
16
|
+
exports.BATCH_FUNCTION_NAME = 'execute';
|
|
17
|
+
exports.CALLS_SIGNATURE = '(address,uint256,bytes)[]';
|
|
18
|
+
exports.ERROR_MESSGE_PUBLIC_KEY = 'EIP-7702 public key not specified';
|
|
19
|
+
/** EIP-7702 authorization signature magic prefix. */
|
|
20
|
+
const EIP7702_AUTHORIZATION_MAGIC = 0x05;
|
|
21
|
+
/**
|
|
22
|
+
* ERC-7579 ModeCode encoding for the ERC-7821 `execute` function.
|
|
23
|
+
*
|
|
24
|
+
* Layout: | CallType (1 byte) | ExecType (1 byte) | Unused (4 bytes) | ModeSelector (4 bytes) | ModePayload (22 bytes) |
|
|
25
|
+
*
|
|
26
|
+
* - CallType 0x01 = batch
|
|
27
|
+
* - ExecType 0x00 = default (revert on failure)
|
|
28
|
+
* - ExecType 0x01 = try (skip on failure)
|
|
29
|
+
*/
|
|
30
|
+
const ERC7579_CALL_TYPE_BATCH = '01';
|
|
31
|
+
const ERC7579_EXEC_TYPE_DEFAULT = '00';
|
|
32
|
+
const ERC7579_EXEC_TYPE_TRY = '01';
|
|
33
|
+
const log = (0, utils_1.createModuleLogger)(logger_js_1.projectLogger, 'eip-7702');
|
|
34
|
+
const KEYRING_TYPES_SUPPORTING_7702 = [
|
|
35
|
+
'HD Key Tree',
|
|
36
|
+
'Simple Key Pair',
|
|
37
|
+
'Money Keyring',
|
|
38
|
+
];
|
|
39
|
+
/**
|
|
40
|
+
* Check whether a given account's keyring supports EIP-7702 authorization
|
|
41
|
+
* signing.
|
|
42
|
+
*
|
|
43
|
+
* Looks up the account's keyring via `KeyringController:getState` and returns
|
|
44
|
+
* `true` only when the keyring type is in the supported list.
|
|
45
|
+
* Returns `false` when the keyring cannot be resolved.
|
|
46
|
+
*
|
|
47
|
+
* @param messenger - Controller messenger.
|
|
48
|
+
* @param account - The account address to check.
|
|
49
|
+
* @returns Whether the account supports EIP-7702.
|
|
50
|
+
*/
|
|
51
|
+
function doesAccountSupportEIP7702(messenger, account) {
|
|
52
|
+
const { keyrings } = messenger.call('KeyringController:getState');
|
|
53
|
+
return keyrings.some((k) => KEYRING_TYPES_SUPPORTING_7702.includes(k.type) &&
|
|
54
|
+
k.accounts.some((a) => a.toLowerCase() === account.toLowerCase()));
|
|
55
|
+
}
|
|
56
|
+
exports.doesAccountSupportEIP7702 = doesAccountSupportEIP7702;
|
|
57
|
+
/**
|
|
58
|
+
* Determine if a chain supports EIP-7702 using LaunchDarkly feature flag.
|
|
59
|
+
*
|
|
60
|
+
* @param chainId - Hexadecimal ID of the chain.
|
|
61
|
+
* @param messenger - Messenger instance.
|
|
62
|
+
* @returns True if the chain supports EIP-7702.
|
|
63
|
+
*/
|
|
64
|
+
function doesChainSupportEIP7702(chainId, messenger) {
|
|
65
|
+
const supportedChains = (0, feature_flags_js_1.getEIP7702SupportedChains)(messenger);
|
|
66
|
+
return supportedChains.some((supportedChainId) => supportedChainId.toLowerCase() === chainId.toLowerCase());
|
|
67
|
+
}
|
|
68
|
+
exports.doesChainSupportEIP7702 = doesChainSupportEIP7702;
|
|
69
|
+
/**
|
|
70
|
+
* Retrieve the delegation address for an account.
|
|
71
|
+
*
|
|
72
|
+
* @param address - The address to check.
|
|
73
|
+
* @param messenger - The TransactionController messenger.
|
|
74
|
+
* @param networkClientId - The network client ID to use.
|
|
75
|
+
* @returns The delegation address if it exists.
|
|
76
|
+
*/
|
|
77
|
+
async function getDelegationAddress(address, messenger, networkClientId) {
|
|
78
|
+
const code = (await (0, provider_js_1.rpcRequest)({
|
|
79
|
+
messenger,
|
|
80
|
+
networkClientId,
|
|
81
|
+
method: 'eth_getCode',
|
|
82
|
+
params: [address, 'latest'],
|
|
83
|
+
}));
|
|
84
|
+
const normalizedCode = (0, utils_1.add0x)(code?.toLowerCase?.() ?? '');
|
|
85
|
+
const hasDelegation = code?.length === 48 && normalizedCode.startsWith(exports.DELEGATION_PREFIX);
|
|
86
|
+
return hasDelegation
|
|
87
|
+
? (0, utils_1.add0x)(normalizedCode.slice(exports.DELEGATION_PREFIX.length))
|
|
88
|
+
: undefined;
|
|
89
|
+
}
|
|
90
|
+
exports.getDelegationAddress = getDelegationAddress;
|
|
91
|
+
/**
|
|
92
|
+
* Determine if an account has been upgraded to a supported EIP-7702 contract.
|
|
93
|
+
*
|
|
94
|
+
* @param address - The EOA address to check.
|
|
95
|
+
* @param chainId - The chain ID.
|
|
96
|
+
* @param publicKey - Public key used to validate EIP-7702 contract signatures in feature flags.
|
|
97
|
+
* @param messenger - The messenger instance.
|
|
98
|
+
* @param networkClientId - The network client ID to use.
|
|
99
|
+
* @returns An object with the results of the check.
|
|
100
|
+
*/
|
|
101
|
+
async function isAccountUpgradedToEIP7702(address, chainId, publicKey, messenger, networkClientId) {
|
|
102
|
+
const contractAddresses = (0, feature_flags_js_1.getEIP7702ContractAddresses)(chainId, messenger, publicKey);
|
|
103
|
+
const delegationAddress = await getDelegationAddress(address, messenger, networkClientId);
|
|
104
|
+
const isSupported = Boolean(delegationAddress &&
|
|
105
|
+
contractAddresses.some((contract) => contract.toLowerCase() === delegationAddress.toLowerCase()));
|
|
106
|
+
return {
|
|
107
|
+
delegationAddress,
|
|
108
|
+
isSupported,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
exports.isAccountUpgradedToEIP7702 = isAccountUpgradedToEIP7702;
|
|
112
|
+
/**
|
|
113
|
+
* Update indexed transactions in an EIP-7702 batch and regenerate its calldata.
|
|
114
|
+
*
|
|
115
|
+
* @param options - Update options.
|
|
116
|
+
* @param options.from - The sender address.
|
|
117
|
+
* @param options.transactions - The existing nested transactions.
|
|
118
|
+
* @param options.updates - Indexed calldata updates.
|
|
119
|
+
* @returns Updated nested transactions and regenerated batch calldata.
|
|
120
|
+
*/
|
|
121
|
+
function updateEIP7702BatchData({ from, transactions, updates, }) {
|
|
122
|
+
const updatesByIndex = new Map();
|
|
123
|
+
for (const { transactionIndex, transactionData } of updates) {
|
|
124
|
+
if (updatesByIndex.has(transactionIndex)) {
|
|
125
|
+
throw new Error(`Duplicate nested transaction index - ${transactionIndex}`);
|
|
126
|
+
}
|
|
127
|
+
if (!transactions[transactionIndex]) {
|
|
128
|
+
throw new Error(`Nested transaction not found with index - ${transactionIndex}`);
|
|
129
|
+
}
|
|
130
|
+
updatesByIndex.set(transactionIndex, transactionData);
|
|
131
|
+
}
|
|
132
|
+
const nestedTransactions = transactions.map((transaction, index) => {
|
|
133
|
+
const transactionData = updatesByIndex.get(index);
|
|
134
|
+
return {
|
|
135
|
+
...transaction,
|
|
136
|
+
...(transactionData === undefined ? {} : { data: transactionData }),
|
|
137
|
+
};
|
|
138
|
+
});
|
|
139
|
+
const batchTransaction = generateEIP7702BatchTransaction(from, nestedTransactions);
|
|
140
|
+
return {
|
|
141
|
+
nestedTransactions,
|
|
142
|
+
transactionData: batchTransaction.data,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
exports.updateEIP7702BatchData = updateEIP7702BatchData;
|
|
146
|
+
/**
|
|
147
|
+
* Generate an EIP-7702 batch transaction.
|
|
148
|
+
*
|
|
149
|
+
* @param from - The sender address.
|
|
150
|
+
* @param transactions - The transactions to batch.
|
|
151
|
+
* @param options - Options bag.
|
|
152
|
+
* @param options.atomic - Whether the batch should be atomic. Defaults to `true`.
|
|
153
|
+
* When `true`, uses ERC-7579 ExecType `default` and all calls revert together.
|
|
154
|
+
* When `false`, uses ERC-7579 ExecType `try` and individual calls can fail independently.
|
|
155
|
+
* @returns The batch transaction.
|
|
156
|
+
*/
|
|
157
|
+
function generateEIP7702BatchTransaction(from, transactions, options) {
|
|
158
|
+
const atomic = options?.atomic ?? true;
|
|
159
|
+
const erc7821Contract = contracts_1.Contract.getInterface(constants_js_1.ABI_IERC7821);
|
|
160
|
+
const calls = transactions.map((transaction) => {
|
|
161
|
+
const { data, to, value } = transaction;
|
|
162
|
+
return [
|
|
163
|
+
to ?? '0x0000000000000000000000000000000000000000',
|
|
164
|
+
value ?? '0x0',
|
|
165
|
+
data ?? '0x',
|
|
166
|
+
];
|
|
167
|
+
});
|
|
168
|
+
const execType = atomic ? ERC7579_EXEC_TYPE_DEFAULT : ERC7579_EXEC_TYPE_TRY;
|
|
169
|
+
const mode = `0x${ERC7579_CALL_TYPE_BATCH}${execType}`.padEnd(66, '0');
|
|
170
|
+
const callData = abi_1.defaultAbiCoder.encode([exports.CALLS_SIGNATURE], [calls]);
|
|
171
|
+
const data = erc7821Contract.encodeFunctionData(exports.BATCH_FUNCTION_NAME, [
|
|
172
|
+
mode,
|
|
173
|
+
callData,
|
|
174
|
+
]);
|
|
175
|
+
log('Transaction data', data);
|
|
176
|
+
return {
|
|
177
|
+
data,
|
|
178
|
+
to: from,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
exports.generateEIP7702BatchTransaction = generateEIP7702BatchTransaction;
|
|
182
|
+
/**
|
|
183
|
+
* Sign an authorization list.
|
|
184
|
+
*
|
|
185
|
+
* @param options - Options bag.
|
|
186
|
+
* @param options.authorizationList - The authorization list to sign.
|
|
187
|
+
* @param options.messenger - The controller messenger.
|
|
188
|
+
* @param options.transactionMeta - The transaction metadata.
|
|
189
|
+
* @returns The signed authorization list.
|
|
190
|
+
*/
|
|
191
|
+
async function signAuthorizationList({ authorizationList, messenger, transactionMeta, }) {
|
|
192
|
+
if (!authorizationList) {
|
|
193
|
+
return undefined;
|
|
194
|
+
}
|
|
195
|
+
const signedAuthorizationList = [];
|
|
196
|
+
let index = 0;
|
|
197
|
+
for (const authorization of authorizationList) {
|
|
198
|
+
const signedAuthorization = await signAuthorization(authorization, transactionMeta, messenger, index);
|
|
199
|
+
signedAuthorizationList.push(signedAuthorization);
|
|
200
|
+
index += 1;
|
|
201
|
+
}
|
|
202
|
+
return signedAuthorizationList;
|
|
203
|
+
}
|
|
204
|
+
exports.signAuthorizationList = signAuthorizationList;
|
|
205
|
+
/**
|
|
206
|
+
* Decode a 65-byte EIP-7702 authorization signature into RLP-canonical
|
|
207
|
+
* `r`, `s`, and `yParity` (no leading zero nibbles, `0x0` for zero).
|
|
208
|
+
*
|
|
209
|
+
* @param signature - The 65-byte signature.
|
|
210
|
+
* @returns The decoded authorization fields.
|
|
211
|
+
*/
|
|
212
|
+
function decodeAuthorizationSignature(signature) {
|
|
213
|
+
// eslint-disable-next-line id-length
|
|
214
|
+
const r = toCanonicalHex(signature.slice(0, 66));
|
|
215
|
+
// eslint-disable-next-line id-length
|
|
216
|
+
const s = toCanonicalHex(signature.slice(66, 130));
|
|
217
|
+
// eslint-disable-next-line id-length
|
|
218
|
+
const v = parseInt(signature.slice(130, 132), 16);
|
|
219
|
+
const yParity = toCanonicalHex((0, controller_utils_1.toHex)(v - 27 === 0 ? 0 : 1));
|
|
220
|
+
return { r, s, yParity };
|
|
221
|
+
}
|
|
222
|
+
exports.decodeAuthorizationSignature = decodeAuthorizationSignature;
|
|
223
|
+
/**
|
|
224
|
+
* Strip leading zero nibbles from a hex string to produce its RLP-canonical
|
|
225
|
+
* form. Accepts input with or without a `0x` prefix; always returns
|
|
226
|
+
* `0x`-prefixed. An all-zero input is preserved as `0x0`.
|
|
227
|
+
*
|
|
228
|
+
* @param value - Hex string with or without a `0x` prefix.
|
|
229
|
+
* @returns The canonical `0x`-prefixed hex string.
|
|
230
|
+
*/
|
|
231
|
+
function toCanonicalHex(value) {
|
|
232
|
+
const raw = value.startsWith('0x') ? value.slice(2) : value;
|
|
233
|
+
const stripped = raw.replace(/^0+/u, '');
|
|
234
|
+
return stripped.length === 0 ? '0x0' : `0x${stripped}`;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Signs an authorization.
|
|
238
|
+
*
|
|
239
|
+
* @param authorization - The authorization to sign.
|
|
240
|
+
* @param transactionMeta - The associated transaction metadata.
|
|
241
|
+
* @param messenger - The messenger to use for signing.
|
|
242
|
+
* @param index - The index of the authorization in the list.
|
|
243
|
+
* @returns The signed authorization.
|
|
244
|
+
*/
|
|
245
|
+
async function signAuthorization(authorization, transactionMeta, messenger, index) {
|
|
246
|
+
// Retain pre-signed authorizations (e.g. Money Account upgrades signed by an
|
|
247
|
+
// account other than `txParams.from`) instead of re-signing with `from`.
|
|
248
|
+
if (isAuthorizationSigned(authorization)) {
|
|
249
|
+
log('Retaining pre-signed authorization', authorization);
|
|
250
|
+
return authorization;
|
|
251
|
+
}
|
|
252
|
+
const finalAuthorization = prepareAuthorization(authorization, transactionMeta, index);
|
|
253
|
+
const { txParams } = transactionMeta;
|
|
254
|
+
const { from } = txParams;
|
|
255
|
+
const { address, chainId, nonce } = finalAuthorization;
|
|
256
|
+
const chainIdDecimal = parseInt(chainId, 16);
|
|
257
|
+
const nonceDecimal = parseInt(nonce, 16);
|
|
258
|
+
const signature = await messenger.call('KeyringController:signEip7702Authorization', {
|
|
259
|
+
chainId: chainIdDecimal,
|
|
260
|
+
contractAddress: address,
|
|
261
|
+
from,
|
|
262
|
+
nonce: nonceDecimal,
|
|
263
|
+
});
|
|
264
|
+
const { r, s, yParity } = decodeAuthorizationSignature(signature);
|
|
265
|
+
const result = {
|
|
266
|
+
address,
|
|
267
|
+
chainId,
|
|
268
|
+
nonce,
|
|
269
|
+
r,
|
|
270
|
+
s,
|
|
271
|
+
yParity,
|
|
272
|
+
};
|
|
273
|
+
log('Signed authorization', result);
|
|
274
|
+
return result;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Whether an authorization already includes a complete EIP-7702 signature.
|
|
278
|
+
*
|
|
279
|
+
* @param authorization - Authorization to check.
|
|
280
|
+
* @returns True when chainId, nonce, and signature components are all present.
|
|
281
|
+
*/
|
|
282
|
+
function isAuthorizationSigned(authorization) {
|
|
283
|
+
return Boolean(authorization.chainId &&
|
|
284
|
+
authorization.nonce !== undefined &&
|
|
285
|
+
authorization.r &&
|
|
286
|
+
authorization.s &&
|
|
287
|
+
authorization.yParity !== undefined);
|
|
288
|
+
}
|
|
289
|
+
exports.isAuthorizationSigned = isAuthorizationSigned;
|
|
290
|
+
/**
|
|
291
|
+
* Recover the authority (signer) of a fully signed EIP-7702 authorization.
|
|
292
|
+
*
|
|
293
|
+
* Per EIP-7702: `authority = ecrecover(keccak(MAGIC || rlp([chain_id, address, nonce])), y_parity, r, s)`.
|
|
294
|
+
*
|
|
295
|
+
* @param authorization - Fully signed authorization.
|
|
296
|
+
* @returns The recovered authority address, or undefined if recovery fails.
|
|
297
|
+
*/
|
|
298
|
+
function recoverAuthorizationAuthority(authorization) {
|
|
299
|
+
try {
|
|
300
|
+
const chainIdBytes = (0, util_1.bigIntToUnpaddedBytes)(BigInt(authorization.chainId));
|
|
301
|
+
const addressBytes = (0, util_1.hexToBytes)(authorization.address);
|
|
302
|
+
const nonceBytes = (0, util_1.bigIntToUnpaddedBytes)(BigInt(authorization.nonce));
|
|
303
|
+
const rlpEncoded = rlp_1.RLP.encode([chainIdBytes, addressBytes, nonceBytes]);
|
|
304
|
+
const messageHash = (0, keccak_1.keccak256)(Uint8Array.from([EIP7702_AUTHORIZATION_MAGIC, ...rlpEncoded]));
|
|
305
|
+
const publicKey = (0, util_1.ecrecover)(messageHash, BigInt(authorization.yParity), (0, util_1.bigIntToUnpaddedBytes)(BigInt(authorization.r)), (0, util_1.bigIntToUnpaddedBytes)(BigInt(authorization.s)));
|
|
306
|
+
return (0, util_1.bytesToHex)((0, util_1.pubToAddress)(publicKey));
|
|
307
|
+
}
|
|
308
|
+
catch (error) {
|
|
309
|
+
log('Failed to recover authorization authority', { authorization, error });
|
|
310
|
+
return undefined;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
exports.recoverAuthorizationAuthority = recoverAuthorizationAuthority;
|
|
314
|
+
/**
|
|
315
|
+
* Resolve which account an authorization nonce belongs to for nonce tracking.
|
|
316
|
+
*
|
|
317
|
+
* Unsigned authorizations are signed by the outer transaction sender (`from`).
|
|
318
|
+
* Signed authorizations recover their authority independently per EIP-7702.
|
|
319
|
+
*
|
|
320
|
+
* @param authorization - Authorization entry.
|
|
321
|
+
* @param transactionFrom - Outer transaction sender.
|
|
322
|
+
* @returns Authority address, or undefined when a signed auth cannot be recovered.
|
|
323
|
+
*/
|
|
324
|
+
function getAuthorizationAuthority(authorization, transactionFrom) {
|
|
325
|
+
if (!isAuthorizationSigned(authorization)) {
|
|
326
|
+
return transactionFrom;
|
|
327
|
+
}
|
|
328
|
+
return recoverAuthorizationAuthority(authorization);
|
|
329
|
+
}
|
|
330
|
+
exports.getAuthorizationAuthority = getAuthorizationAuthority;
|
|
331
|
+
/**
|
|
332
|
+
* Prepares an authorization for signing by populating the chainId and nonce.
|
|
333
|
+
*
|
|
334
|
+
* @param authorization - The authorization to prepare.
|
|
335
|
+
* @param transactionMeta - The associated transaction metadata.
|
|
336
|
+
* @param index - The index of the authorization in the list.
|
|
337
|
+
* @returns The prepared authorization.
|
|
338
|
+
*/
|
|
339
|
+
function prepareAuthorization(authorization, transactionMeta, index) {
|
|
340
|
+
const { chainId: existingChainId, nonce: existingNonce } = authorization;
|
|
341
|
+
const { txParams, chainId: transactionChainId } = transactionMeta;
|
|
342
|
+
const { nonce: transactionNonce } = txParams;
|
|
343
|
+
const chainId = existingChainId ?? transactionChainId;
|
|
344
|
+
let nonce = existingNonce;
|
|
345
|
+
nonce ?? (nonce = (0, controller_utils_1.toHex)(parseInt(transactionNonce, 16) + 1 + index));
|
|
346
|
+
const result = {
|
|
347
|
+
...authorization,
|
|
348
|
+
chainId,
|
|
349
|
+
nonce,
|
|
350
|
+
};
|
|
351
|
+
log('Prepared authorization', result);
|
|
352
|
+
return result;
|
|
353
|
+
}
|
|
354
|
+
//# sourceMappingURL=eip7702.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC;QAC3E,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAvBD,sEAuBC;AAED;;;;;;;;;GASG;AACH,SAAgB,yBAAyB,CACvC,aAA4B,EAC5B,eAAuB;IAEvB,IAAI,CAAC,qBAAqB,CAAC,aAAa,CAAC,EAAE,CAAC;QAC1C,OAAO,eAAsB,CAAC;IAChC,CAAC;IAED,OAAO,6BAA6B,CAAC,aAAa,CAAC,CAAC;AACtD,CAAC;AATD,8DASC;AAED;;;;;;;GAOG;AACH,SAAS,oBAAoB,CAC3B,aAA4B,EAC5B,eAAgC,EAChC,KAAa;IAEb,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,aAAa,CAAC;IACzE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,kBAAkB,EAAE,GAAG,eAAe,CAAC;IAClE,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,GAAG,QAAQ,CAAC;IAE7C,MAAM,OAAO,GAAG,eAAe,IAAI,kBAAkB,CAAC;IACtD,IAAI,KAAK,GAAG,aAAa,CAAC;IAE1B,KAAK,KAAL,KAAK,GAAK,IAAA,wBAAK,EAAC,QAAQ,CAAC,gBAA0B,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,EAAC;IAEtE,MAAM,MAAM,GAAG;QACb,GAAG,aAAa;QAChB,OAAO;QACP,KAAK;KACN,CAAC;IAEF,GAAG,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC;IAEtC,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { RLP } from '@ethereumjs/rlp';\nimport {\n bigIntToUnpaddedBytes,\n bytesToHex,\n ecrecover,\n hexToBytes,\n pubToAddress,\n} from '@ethereumjs/util';\nimport { defaultAbiCoder } from '@ethersproject/abi';\nimport { Contract } from '@ethersproject/contracts';\nimport { toHex } from '@metamask/controller-utils';\nimport type { NetworkClientId } from '@metamask/network-controller';\nimport { createModuleLogger, add0x } from '@metamask/utils';\nimport type { Hex } from '@metamask/utils';\nimport { keccak256 } from 'ethereum-cryptography/keccak';\n\nimport { ABI_IERC7821 } from '../constants.js';\nimport { projectLogger } from '../logger.js';\nimport type { TransactionControllerMessenger } from '../TransactionController.js';\nimport type {\n BatchTransactionParams,\n NestedTransactionUpdate,\n Authorization,\n AuthorizationList,\n TransactionMeta,\n} from '../types.js';\nimport {\n getEIP7702ContractAddresses,\n getEIP7702SupportedChains,\n} from './feature-flags.js';\nimport { rpcRequest } from './provider.js';\n\nexport const DELEGATION_PREFIX = '0xef0100';\nexport const BATCH_FUNCTION_NAME = 'execute';\nexport const CALLS_SIGNATURE = '(address,uint256,bytes)[]';\nexport const ERROR_MESSGE_PUBLIC_KEY = 'EIP-7702 public key not specified';\n\n/** EIP-7702 authorization signature magic prefix. */\nconst EIP7702_AUTHORIZATION_MAGIC = 0x05;\n\n/**\n * ERC-7579 ModeCode encoding for the ERC-7821 `execute` function.\n *\n * Layout: | CallType (1 byte) | ExecType (1 byte) | Unused (4 bytes) | ModeSelector (4 bytes) | ModePayload (22 bytes) |\n *\n * - CallType 0x01 = batch\n * - ExecType 0x00 = default (revert on failure)\n * - ExecType 0x01 = try (skip on failure)\n */\nconst ERC7579_CALL_TYPE_BATCH = '01';\nconst ERC7579_EXEC_TYPE_DEFAULT = '00';\nconst ERC7579_EXEC_TYPE_TRY = '01';\n\nconst log = createModuleLogger(projectLogger, 'eip-7702');\n\nconst KEYRING_TYPES_SUPPORTING_7702 = [\n 'HD Key Tree',\n 'Simple Key Pair',\n 'Money Keyring',\n];\n\n/**\n * Check whether a given account's keyring supports EIP-7702 authorization\n * signing.\n *\n * Looks up the account's keyring via `KeyringController:getState` and returns\n * `true` only when the keyring type is in the supported list.\n * Returns `false` when the keyring cannot be resolved.\n *\n * @param messenger - Controller messenger.\n * @param account - The account address to check.\n * @returns Whether the account supports EIP-7702.\n */\nexport function doesAccountSupportEIP7702(\n messenger: TransactionControllerMessenger,\n account: string,\n): boolean {\n const { keyrings } = messenger.call('KeyringController:getState');\n\n return keyrings.some(\n (k: { type: string; accounts: string[] }) =>\n KEYRING_TYPES_SUPPORTING_7702.includes(k.type) &&\n k.accounts.some((a: string) => a.toLowerCase() === account.toLowerCase()),\n );\n}\n\n/**\n * Determine if a chain supports EIP-7702 using LaunchDarkly feature flag.\n *\n * @param chainId - Hexadecimal ID of the chain.\n * @param messenger - Messenger instance.\n * @returns True if the chain supports EIP-7702.\n */\nexport function doesChainSupportEIP7702(\n chainId: Hex,\n messenger: TransactionControllerMessenger,\n): boolean {\n const supportedChains = getEIP7702SupportedChains(messenger);\n\n return supportedChains.some(\n (supportedChainId) =>\n supportedChainId.toLowerCase() === chainId.toLowerCase(),\n );\n}\n\n/**\n * Retrieve the delegation address for an account.\n *\n * @param address - The address to check.\n * @param messenger - The TransactionController messenger.\n * @param networkClientId - The network client ID to use.\n * @returns The delegation address if it exists.\n */\nexport async function getDelegationAddress(\n address: Hex,\n messenger: TransactionControllerMessenger,\n networkClientId: NetworkClientId,\n): Promise<Hex | undefined> {\n const code = (await rpcRequest({\n messenger,\n networkClientId,\n method: 'eth_getCode',\n params: [address, 'latest'],\n })) as string;\n const normalizedCode = add0x(code?.toLowerCase?.() ?? '');\n\n const hasDelegation =\n code?.length === 48 && normalizedCode.startsWith(DELEGATION_PREFIX);\n\n return hasDelegation\n ? add0x(normalizedCode.slice(DELEGATION_PREFIX.length))\n : undefined;\n}\n\n/**\n * Determine if an account has been upgraded to a supported EIP-7702 contract.\n *\n * @param address - The EOA address to check.\n * @param chainId - The chain ID.\n * @param publicKey - Public key used to validate EIP-7702 contract signatures in feature flags.\n * @param messenger - The messenger instance.\n * @param networkClientId - The network client ID to use.\n * @returns An object with the results of the check.\n */\nexport async function isAccountUpgradedToEIP7702(\n address: Hex,\n chainId: Hex,\n publicKey: Hex,\n messenger: TransactionControllerMessenger,\n networkClientId: NetworkClientId,\n): Promise<{\n delegationAddress: Hex | undefined;\n isSupported: boolean;\n}> {\n const contractAddresses = getEIP7702ContractAddresses(\n chainId,\n messenger,\n publicKey,\n );\n\n const delegationAddress = await getDelegationAddress(\n address,\n messenger,\n networkClientId,\n );\n\n const isSupported = Boolean(\n delegationAddress &&\n contractAddresses.some(\n (contract) => contract.toLowerCase() === delegationAddress.toLowerCase(),\n ),\n );\n\n return {\n delegationAddress,\n isSupported,\n };\n}\n\n/**\n * Update indexed transactions in an EIP-7702 batch and regenerate its calldata.\n *\n * @param options - Update options.\n * @param options.from - The sender address.\n * @param options.transactions - The existing nested transactions.\n * @param options.updates - Indexed calldata updates.\n * @returns Updated nested transactions and regenerated batch calldata.\n */\nexport function updateEIP7702BatchData({\n from,\n transactions,\n updates,\n}: {\n from: Hex;\n transactions: BatchTransactionParams[];\n updates: NestedTransactionUpdate[];\n}): {\n nestedTransactions: BatchTransactionParams[];\n transactionData: Hex;\n} {\n const updatesByIndex = new Map<number, Hex>();\n\n for (const { transactionIndex, transactionData } of updates) {\n if (updatesByIndex.has(transactionIndex)) {\n throw new Error(\n `Duplicate nested transaction index - ${transactionIndex}`,\n );\n }\n\n if (!transactions[transactionIndex]) {\n throw new Error(\n `Nested transaction not found with index - ${transactionIndex}`,\n );\n }\n\n updatesByIndex.set(transactionIndex, transactionData);\n }\n\n const nestedTransactions = transactions.map((transaction, index) => {\n const transactionData = updatesByIndex.get(index);\n\n return {\n ...transaction,\n ...(transactionData === undefined ? {} : { data: transactionData }),\n };\n });\n const batchTransaction = generateEIP7702BatchTransaction(\n from,\n nestedTransactions,\n );\n\n return {\n nestedTransactions,\n transactionData: batchTransaction.data as Hex,\n };\n}\n\n/**\n * Generate an EIP-7702 batch transaction.\n *\n * @param from - The sender address.\n * @param transactions - The transactions to batch.\n * @param options - Options bag.\n * @param options.atomic - Whether the batch should be atomic. Defaults to `true`.\n * When `true`, uses ERC-7579 ExecType `default` and all calls revert together.\n * When `false`, uses ERC-7579 ExecType `try` and individual calls can fail independently.\n * @returns The batch transaction.\n */\nexport function generateEIP7702BatchTransaction(\n from: Hex,\n transactions: BatchTransactionParams[],\n options?: { atomic?: boolean },\n): BatchTransactionParams {\n const atomic = options?.atomic ?? true;\n const erc7821Contract = Contract.getInterface(ABI_IERC7821);\n\n const calls = transactions.map((transaction) => {\n const { data, to, value } = transaction;\n\n return [\n to ?? '0x0000000000000000000000000000000000000000',\n value ?? '0x0',\n data ?? '0x',\n ];\n });\n\n const execType = atomic ? ERC7579_EXEC_TYPE_DEFAULT : ERC7579_EXEC_TYPE_TRY;\n const mode = `0x${ERC7579_CALL_TYPE_BATCH}${execType}`.padEnd(66, '0');\n\n const callData = defaultAbiCoder.encode([CALLS_SIGNATURE], [calls]);\n\n const data = erc7821Contract.encodeFunctionData(BATCH_FUNCTION_NAME, [\n mode,\n callData,\n ]) as Hex;\n\n log('Transaction data', data);\n\n return {\n data,\n to: from,\n };\n}\n\n/**\n * Sign an authorization list.\n *\n * @param options - Options bag.\n * @param options.authorizationList - The authorization list to sign.\n * @param options.messenger - The controller messenger.\n * @param options.transactionMeta - The transaction metadata.\n * @returns The signed authorization list.\n */\nexport async function signAuthorizationList({\n authorizationList,\n messenger,\n transactionMeta,\n}: {\n authorizationList?: AuthorizationList;\n messenger: TransactionControllerMessenger;\n transactionMeta: TransactionMeta;\n}): Promise<Required<AuthorizationList | undefined>> {\n if (!authorizationList) {\n return undefined;\n }\n\n const signedAuthorizationList: Required<AuthorizationList> = [];\n let index = 0;\n\n for (const authorization of authorizationList) {\n const signedAuthorization = await signAuthorization(\n authorization,\n transactionMeta,\n messenger,\n index,\n );\n\n signedAuthorizationList.push(signedAuthorization);\n index += 1;\n }\n\n return signedAuthorizationList;\n}\n\n/**\n * Decode a 65-byte EIP-7702 authorization signature into RLP-canonical\n * `r`, `s`, and `yParity` (no leading zero nibbles, `0x0` for zero).\n *\n * @param signature - The 65-byte signature.\n * @returns The decoded authorization fields.\n */\nexport function decodeAuthorizationSignature(signature: Hex): {\n r: Hex;\n s: Hex;\n yParity: Hex;\n} {\n // eslint-disable-next-line id-length\n const r = toCanonicalHex(signature.slice(0, 66));\n // eslint-disable-next-line id-length\n const s = toCanonicalHex(signature.slice(66, 130));\n // eslint-disable-next-line id-length\n const v = parseInt(signature.slice(130, 132), 16);\n const yParity = toCanonicalHex(toHex(v - 27 === 0 ? 0 : 1));\n\n return { r, s, yParity };\n}\n\n/**\n * Strip leading zero nibbles from a hex string to produce its RLP-canonical\n * form. Accepts input with or without a `0x` prefix; always returns\n * `0x`-prefixed. An all-zero input is preserved as `0x0`.\n *\n * @param value - Hex string with or without a `0x` prefix.\n * @returns The canonical `0x`-prefixed hex string.\n */\nfunction toCanonicalHex(value: string): Hex {\n const raw = value.startsWith('0x') ? value.slice(2) : value;\n const stripped = raw.replace(/^0+/u, '');\n return stripped.length === 0 ? '0x0' : `0x${stripped}`;\n}\n\n/**\n * Signs an authorization.\n *\n * @param authorization - The authorization to sign.\n * @param transactionMeta - The associated transaction metadata.\n * @param messenger - The messenger to use for signing.\n * @param index - The index of the authorization in the list.\n * @returns The signed authorization.\n */\nasync function signAuthorization(\n authorization: Authorization,\n transactionMeta: TransactionMeta,\n messenger: TransactionControllerMessenger,\n index: number,\n): Promise<Required<Authorization>> {\n // Retain pre-signed authorizations (e.g. Money Account upgrades signed by an\n // account other than `txParams.from`) instead of re-signing with `from`.\n if (isAuthorizationSigned(authorization)) {\n log('Retaining pre-signed authorization', authorization);\n return authorization;\n }\n\n const finalAuthorization = prepareAuthorization(\n authorization,\n transactionMeta,\n index,\n );\n\n const { txParams } = transactionMeta;\n const { from } = txParams;\n const { address, chainId, nonce } = finalAuthorization;\n const chainIdDecimal = parseInt(chainId, 16);\n const nonceDecimal = parseInt(nonce, 16);\n\n const signature = await messenger.call(\n 'KeyringController:signEip7702Authorization',\n {\n chainId: chainIdDecimal,\n contractAddress: address,\n from,\n nonce: nonceDecimal,\n },\n );\n\n const { r, s, yParity } = decodeAuthorizationSignature(signature as Hex);\n\n const result: Required<Authorization> = {\n address,\n chainId,\n nonce,\n r,\n s,\n yParity,\n };\n\n log('Signed authorization', result);\n\n return result;\n}\n\n/**\n * Whether an authorization already includes a complete EIP-7702 signature.\n *\n * @param authorization - Authorization to check.\n * @returns True when chainId, nonce, and signature components are all present.\n */\nexport function isAuthorizationSigned(\n authorization: Authorization,\n): authorization is Required<Authorization> {\n return Boolean(\n authorization.chainId &&\n authorization.nonce !== undefined &&\n authorization.r &&\n authorization.s &&\n authorization.yParity !== undefined,\n );\n}\n\n/**\n * Recover the authority (signer) of a fully signed EIP-7702 authorization.\n *\n * Per EIP-7702: `authority = ecrecover(keccak(MAGIC || rlp([chain_id, address, nonce])), y_parity, r, s)`.\n *\n * @param authorization - Fully signed authorization.\n * @returns The recovered authority address, or undefined if recovery fails.\n */\nexport function recoverAuthorizationAuthority(\n authorization: Required<Authorization>,\n): Hex | undefined {\n try {\n const chainIdBytes = bigIntToUnpaddedBytes(BigInt(authorization.chainId));\n const addressBytes = hexToBytes(authorization.address);\n const nonceBytes = bigIntToUnpaddedBytes(BigInt(authorization.nonce));\n const rlpEncoded = RLP.encode([chainIdBytes, addressBytes, nonceBytes]);\n const messageHash = keccak256(\n Uint8Array.from([EIP7702_AUTHORIZATION_MAGIC, ...rlpEncoded]),\n );\n const publicKey = ecrecover(\n messageHash,\n BigInt(authorization.yParity),\n bigIntToUnpaddedBytes(BigInt(authorization.r)),\n bigIntToUnpaddedBytes(BigInt(authorization.s)),\n );\n\n return bytesToHex(pubToAddress(publicKey));\n } catch (error) {\n log('Failed to recover authorization authority', { authorization, error });\n return undefined;\n }\n}\n\n/**\n * Resolve which account an authorization nonce belongs to for nonce tracking.\n *\n * Unsigned authorizations are signed by the outer transaction sender (`from`).\n * Signed authorizations recover their authority independently per EIP-7702.\n *\n * @param authorization - Authorization entry.\n * @param transactionFrom - Outer transaction sender.\n * @returns Authority address, or undefined when a signed auth cannot be recovered.\n */\nexport function getAuthorizationAuthority(\n authorization: Authorization,\n transactionFrom: string,\n): Hex | undefined {\n if (!isAuthorizationSigned(authorization)) {\n return transactionFrom as Hex;\n }\n\n return recoverAuthorizationAuthority(authorization);\n}\n\n/**\n * Prepares an authorization for signing by populating the chainId and nonce.\n *\n * @param authorization - The authorization to prepare.\n * @param transactionMeta - The associated transaction metadata.\n * @param index - The index of the authorization in the list.\n * @returns The prepared authorization.\n */\nfunction prepareAuthorization(\n authorization: Authorization,\n transactionMeta: TransactionMeta,\n index: number,\n): Authorization & { chainId: Hex; nonce: Hex } {\n const { chainId: existingChainId, nonce: existingNonce } = authorization;\n const { txParams, chainId: transactionChainId } = transactionMeta;\n const { nonce: transactionNonce } = txParams;\n\n const chainId = existingChainId ?? transactionChainId;\n let nonce = existingNonce;\n\n nonce ??= toHex(parseInt(transactionNonce as string, 16) + 1 + index);\n\n const result = {\n ...authorization,\n chainId,\n nonce,\n };\n\n log('Prepared authorization', result);\n\n return result;\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { NetworkClientId } from
|
|
2
|
-
import type { Hex } from
|
|
3
|
-
import type { TransactionControllerMessenger } from
|
|
4
|
-
import type { BatchTransactionParams, NestedTransactionUpdate, Authorization, AuthorizationList, TransactionMeta } 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 { BatchTransactionParams, NestedTransactionUpdate, Authorization, AuthorizationList, TransactionMeta } from "../types.cjs";
|
|
5
5
|
export declare const DELEGATION_PREFIX = "0xef0100";
|
|
6
6
|
export declare const BATCH_FUNCTION_NAME = "execute";
|
|
7
7
|
export declare const CALLS_SIGNATURE = "(address,uint256,bytes)[]";
|
|
@@ -134,4 +134,4 @@ export declare function recoverAuthorizationAuthority(authorization: Required<Au
|
|
|
134
134
|
* @returns Authority address, or undefined when a signed auth cannot be recovered.
|
|
135
135
|
*/
|
|
136
136
|
export declare function getAuthorizationAuthority(authorization: Authorization, transactionFrom: string): Hex | undefined;
|
|
137
|
-
//# sourceMappingURL=eip7702.d.
|
|
137
|
+
//# sourceMappingURL=eip7702.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eip7702.d.cts","sourceRoot":"","sources":["../../src/utils/eip7702.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,eAAe,EAAE,qCAAqC;AAEpE,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAK3C,OAAO,KAAK,EAAE,8BAA8B,EAAE,qCAAoC;AAClF,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACvB,aAAa,EACb,iBAAiB,EACjB,eAAe,EAChB,qBAAoB;AAOrB,eAAO,MAAM,iBAAiB,aAAa,CAAC;AAC5C,eAAO,MAAM,mBAAmB,YAAY,CAAC;AAC7C,eAAO,MAAM,eAAe,8BAA8B,CAAC;AAC3D,eAAO,MAAM,uBAAuB,sCAAsC,CAAC;AA0B3E;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,8BAA8B,EACzC,OAAO,EAAE,MAAM,GACd,OAAO,CAQT;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,GAAG,EACZ,SAAS,EAAE,8BAA8B,GACxC,OAAO,CAOT;AAED;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,GAAG,EACZ,SAAS,EAAE,8BAA8B,EACzC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAAC,GAAG,GAAG,SAAS,CAAC,CAe1B;AAED;;;;;;;;;GASG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,GAAG,EACZ,OAAO,EAAE,GAAG,EACZ,SAAS,EAAE,GAAG,EACd,SAAS,EAAE,8BAA8B,EACzC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAAC;IACT,iBAAiB,EAAE,GAAG,GAAG,SAAS,CAAC;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G;AACH,wBAAgB,yBAAyB,CACvC,aAAa,EAAE,aAAa,EAC5B,eAAe,EAAE,MAAM,GACtB,GAAG,GAAG,SAAS,CAMjB"}
|
|
@@ -0,0 +1,137 @@
|
|
|
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 { BatchTransactionParams, NestedTransactionUpdate, Authorization, AuthorizationList, TransactionMeta } from "../types.mjs";
|
|
5
|
+
export declare const DELEGATION_PREFIX = "0xef0100";
|
|
6
|
+
export declare const BATCH_FUNCTION_NAME = "execute";
|
|
7
|
+
export declare const CALLS_SIGNATURE = "(address,uint256,bytes)[]";
|
|
8
|
+
export declare const ERROR_MESSGE_PUBLIC_KEY = "EIP-7702 public key not specified";
|
|
9
|
+
/**
|
|
10
|
+
* Check whether a given account's keyring supports EIP-7702 authorization
|
|
11
|
+
* signing.
|
|
12
|
+
*
|
|
13
|
+
* Looks up the account's keyring via `KeyringController:getState` and returns
|
|
14
|
+
* `true` only when the keyring type is in the supported list.
|
|
15
|
+
* Returns `false` when the keyring cannot be resolved.
|
|
16
|
+
*
|
|
17
|
+
* @param messenger - Controller messenger.
|
|
18
|
+
* @param account - The account address to check.
|
|
19
|
+
* @returns Whether the account supports EIP-7702.
|
|
20
|
+
*/
|
|
21
|
+
export declare function doesAccountSupportEIP7702(messenger: TransactionControllerMessenger, account: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Determine if a chain supports EIP-7702 using LaunchDarkly feature flag.
|
|
24
|
+
*
|
|
25
|
+
* @param chainId - Hexadecimal ID of the chain.
|
|
26
|
+
* @param messenger - Messenger instance.
|
|
27
|
+
* @returns True if the chain supports EIP-7702.
|
|
28
|
+
*/
|
|
29
|
+
export declare function doesChainSupportEIP7702(chainId: Hex, messenger: TransactionControllerMessenger): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Retrieve the delegation address for an account.
|
|
32
|
+
*
|
|
33
|
+
* @param address - The address to check.
|
|
34
|
+
* @param messenger - The TransactionController messenger.
|
|
35
|
+
* @param networkClientId - The network client ID to use.
|
|
36
|
+
* @returns The delegation address if it exists.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getDelegationAddress(address: Hex, messenger: TransactionControllerMessenger, networkClientId: NetworkClientId): Promise<Hex | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* Determine if an account has been upgraded to a supported EIP-7702 contract.
|
|
41
|
+
*
|
|
42
|
+
* @param address - The EOA address to check.
|
|
43
|
+
* @param chainId - The chain ID.
|
|
44
|
+
* @param publicKey - Public key used to validate EIP-7702 contract signatures in feature flags.
|
|
45
|
+
* @param messenger - The messenger instance.
|
|
46
|
+
* @param networkClientId - The network client ID to use.
|
|
47
|
+
* @returns An object with the results of the check.
|
|
48
|
+
*/
|
|
49
|
+
export declare function isAccountUpgradedToEIP7702(address: Hex, chainId: Hex, publicKey: Hex, messenger: TransactionControllerMessenger, networkClientId: NetworkClientId): Promise<{
|
|
50
|
+
delegationAddress: Hex | undefined;
|
|
51
|
+
isSupported: boolean;
|
|
52
|
+
}>;
|
|
53
|
+
/**
|
|
54
|
+
* Update indexed transactions in an EIP-7702 batch and regenerate its calldata.
|
|
55
|
+
*
|
|
56
|
+
* @param options - Update options.
|
|
57
|
+
* @param options.from - The sender address.
|
|
58
|
+
* @param options.transactions - The existing nested transactions.
|
|
59
|
+
* @param options.updates - Indexed calldata updates.
|
|
60
|
+
* @returns Updated nested transactions and regenerated batch calldata.
|
|
61
|
+
*/
|
|
62
|
+
export declare function updateEIP7702BatchData({ from, transactions, updates, }: {
|
|
63
|
+
from: Hex;
|
|
64
|
+
transactions: BatchTransactionParams[];
|
|
65
|
+
updates: NestedTransactionUpdate[];
|
|
66
|
+
}): {
|
|
67
|
+
nestedTransactions: BatchTransactionParams[];
|
|
68
|
+
transactionData: Hex;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Generate an EIP-7702 batch transaction.
|
|
72
|
+
*
|
|
73
|
+
* @param from - The sender address.
|
|
74
|
+
* @param transactions - The transactions to batch.
|
|
75
|
+
* @param options - Options bag.
|
|
76
|
+
* @param options.atomic - Whether the batch should be atomic. Defaults to `true`.
|
|
77
|
+
* When `true`, uses ERC-7579 ExecType `default` and all calls revert together.
|
|
78
|
+
* When `false`, uses ERC-7579 ExecType `try` and individual calls can fail independently.
|
|
79
|
+
* @returns The batch transaction.
|
|
80
|
+
*/
|
|
81
|
+
export declare function generateEIP7702BatchTransaction(from: Hex, transactions: BatchTransactionParams[], options?: {
|
|
82
|
+
atomic?: boolean;
|
|
83
|
+
}): BatchTransactionParams;
|
|
84
|
+
/**
|
|
85
|
+
* Sign an authorization list.
|
|
86
|
+
*
|
|
87
|
+
* @param options - Options bag.
|
|
88
|
+
* @param options.authorizationList - The authorization list to sign.
|
|
89
|
+
* @param options.messenger - The controller messenger.
|
|
90
|
+
* @param options.transactionMeta - The transaction metadata.
|
|
91
|
+
* @returns The signed authorization list.
|
|
92
|
+
*/
|
|
93
|
+
export declare function signAuthorizationList({ authorizationList, messenger, transactionMeta, }: {
|
|
94
|
+
authorizationList?: AuthorizationList;
|
|
95
|
+
messenger: TransactionControllerMessenger;
|
|
96
|
+
transactionMeta: TransactionMeta;
|
|
97
|
+
}): Promise<Required<AuthorizationList | undefined>>;
|
|
98
|
+
/**
|
|
99
|
+
* Decode a 65-byte EIP-7702 authorization signature into RLP-canonical
|
|
100
|
+
* `r`, `s`, and `yParity` (no leading zero nibbles, `0x0` for zero).
|
|
101
|
+
*
|
|
102
|
+
* @param signature - The 65-byte signature.
|
|
103
|
+
* @returns The decoded authorization fields.
|
|
104
|
+
*/
|
|
105
|
+
export declare function decodeAuthorizationSignature(signature: Hex): {
|
|
106
|
+
r: Hex;
|
|
107
|
+
s: Hex;
|
|
108
|
+
yParity: Hex;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Whether an authorization already includes a complete EIP-7702 signature.
|
|
112
|
+
*
|
|
113
|
+
* @param authorization - Authorization to check.
|
|
114
|
+
* @returns True when chainId, nonce, and signature components are all present.
|
|
115
|
+
*/
|
|
116
|
+
export declare function isAuthorizationSigned(authorization: Authorization): authorization is Required<Authorization>;
|
|
117
|
+
/**
|
|
118
|
+
* Recover the authority (signer) of a fully signed EIP-7702 authorization.
|
|
119
|
+
*
|
|
120
|
+
* Per EIP-7702: `authority = ecrecover(keccak(MAGIC || rlp([chain_id, address, nonce])), y_parity, r, s)`.
|
|
121
|
+
*
|
|
122
|
+
* @param authorization - Fully signed authorization.
|
|
123
|
+
* @returns The recovered authority address, or undefined if recovery fails.
|
|
124
|
+
*/
|
|
125
|
+
export declare function recoverAuthorizationAuthority(authorization: Required<Authorization>): Hex | undefined;
|
|
126
|
+
/**
|
|
127
|
+
* Resolve which account an authorization nonce belongs to for nonce tracking.
|
|
128
|
+
*
|
|
129
|
+
* Unsigned authorizations are signed by the outer transaction sender (`from`).
|
|
130
|
+
* Signed authorizations recover their authority independently per EIP-7702.
|
|
131
|
+
*
|
|
132
|
+
* @param authorization - Authorization entry.
|
|
133
|
+
* @param transactionFrom - Outer transaction sender.
|
|
134
|
+
* @returns Authority address, or undefined when a signed auth cannot be recovered.
|
|
135
|
+
*/
|
|
136
|
+
export declare function getAuthorizationAuthority(authorization: Authorization, transactionFrom: string): Hex | undefined;
|
|
137
|
+
//# sourceMappingURL=eip7702.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eip7702.d.mts","sourceRoot":"","sources":["../../src/utils/eip7702.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,eAAe,EAAE,qCAAqC;AAEpE,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAK3C,OAAO,KAAK,EAAE,8BAA8B,EAAE,qCAAoC;AAClF,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACvB,aAAa,EACb,iBAAiB,EACjB,eAAe,EAChB,qB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AAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAC7B,sBAAsB,CA8BxB;AAED;;;;;;;;GAQG;AACH,wBAAsB,qBAAqB,CAAC,EAC1C,iBAAiB,EACjB,SAAS,EACT,eAAe,GAChB,EAAE;IACD,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,SAAS,EAAE,8BAA8B,CAAC;IAC1C,eAAe,EAAE,eAAe,CAAC;CAClC,GAAG,OAAO,CAAC,QAAQ,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAAC,CAqBnD;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,GAAG,GAAG;IAC5D,CAAC,EAAE,GAAG,CAAC;IACP,CAAC,EAAE,GAAG,CAAC;IACP,OAAO,EAAE,GAAG,CAAC;CACd,CAUA;AA4ED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,aAAa,GAC3B,aAAa,IAAI,QAAQ,CAAC,aAAa,CAAC,CAQ1C;AAED;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAC3C,aAAa,EAAE,QAAQ,CAAC,aAAa,CAAC,GACrC,GAAG,GAAG,SAAS,CAqBjB;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACvC,aAAa,EAAE,aAAa,EAC5B,eAAe,EAAE,MAAM,GACtB,GAAG,GAAG,SAAS,CAMjB"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { RLP } from
|
|
2
|
-
import { bigIntToUnpaddedBytes, bytesToHex, ecrecover, hexToBytes, pubToAddress
|
|
3
|
-
import { defaultAbiCoder } from
|
|
4
|
-
import { Contract } from
|
|
5
|
-
import { toHex } from
|
|
6
|
-
import { createModuleLogger, add0x } from
|
|
7
|
-
import { keccak256 } from
|
|
8
|
-
import { ABI_IERC7821 } from
|
|
9
|
-
import { projectLogger } from
|
|
10
|
-
import { getEIP7702ContractAddresses, getEIP7702SupportedChains
|
|
11
|
-
import { rpcRequest } from
|
|
1
|
+
import { RLP } from "@ethereumjs/rlp";
|
|
2
|
+
import { bigIntToUnpaddedBytes, bytesToHex, ecrecover, hexToBytes, pubToAddress } from "@ethereumjs/util";
|
|
3
|
+
import { defaultAbiCoder } from "@ethersproject/abi";
|
|
4
|
+
import { Contract } from "@ethersproject/contracts";
|
|
5
|
+
import { toHex } from "@metamask/controller-utils";
|
|
6
|
+
import { createModuleLogger, add0x } from "@metamask/utils";
|
|
7
|
+
import { keccak256 } from "ethereum-cryptography/keccak";
|
|
8
|
+
import { ABI_IERC7821 } from "../constants.mjs";
|
|
9
|
+
import { projectLogger } from "../logger.mjs";
|
|
10
|
+
import { getEIP7702ContractAddresses, getEIP7702SupportedChains } from "./feature-flags.mjs";
|
|
11
|
+
import { rpcRequest } from "./provider.mjs";
|
|
12
12
|
export const DELEGATION_PREFIX = '0xef0100';
|
|
13
13
|
export const BATCH_FUNCTION_NAME = 'execute';
|
|
14
14
|
export const CALLS_SIGNATURE = '(address,uint256,bytes)[]';
|
|
@@ -337,4 +337,4 @@ function prepareAuthorization(authorization, transactionMeta, index) {
|
|
|
337
337
|
log('Prepared authorization', result);
|
|
338
338
|
return result;
|
|
339
339
|
}
|
|
340
|
-
//# sourceMappingURL=eip7702.
|
|
340
|
+
//# sourceMappingURL=eip7702.mjs.map
|