@metamask-previews/transaction-controller 24.0.0-preview.eb2135e → 25.1.0-preview-da8ff5ef
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 +129 -1
- package/dist/TransactionController.js +19 -17
- package/dist/TransactionController.mjs +18 -16
- package/dist/{chunk-H4M66BA3.js → chunk-2MMWLJXS.js} +4 -4
- package/dist/{chunk-7APMBUKB.js → chunk-2MUK5JWA.js} +40 -11
- package/dist/chunk-2MUK5JWA.js.map +1 -0
- package/dist/{chunk-EQ3RRHB7.mjs → chunk-3D3SA6PY.mjs} +2 -2
- package/dist/{chunk-UM4ORJ5B.mjs → chunk-3JYZDVNJ.mjs} +5 -5
- package/dist/{chunk-FDJPXQTF.js → chunk-4S25HUCL.js} +12 -12
- package/dist/{chunk-IC233ZQS.js → chunk-5OQ373JS.js} +10 -10
- package/dist/chunk-6FF5JJVB.mjs +73 -0
- package/dist/chunk-6FF5JJVB.mjs.map +1 -0
- package/dist/{chunk-7MZ57ILQ.mjs → chunk-6KYPLIXG.mjs} +2 -2
- package/dist/{chunk-M7455RU7.js → chunk-7C6ERJJC.js} +45 -20
- package/dist/chunk-7C6ERJJC.js.map +1 -0
- package/dist/{chunk-DEKM6PVG.mjs → chunk-7XPI7KU5.mjs} +2 -2
- package/dist/{chunk-DQP6X25N.mjs → chunk-ARB3VRKV.mjs} +3 -3
- package/dist/chunk-CBKVKDFC.js +73 -0
- package/dist/chunk-CBKVKDFC.js.map +1 -0
- package/dist/{chunk-NUOBUW7C.js → chunk-CXXGL43K.js} +3 -3
- package/dist/chunk-DX4NUE4H.mjs +69 -0
- package/dist/chunk-DX4NUE4H.mjs.map +1 -0
- package/dist/{chunk-BJEESIBE.js → chunk-EXFVMWXE.js} +71 -37
- package/dist/chunk-EXFVMWXE.js.map +1 -0
- package/dist/{chunk-GKTIFXPN.js → chunk-F3CMU2DM.js} +6 -6
- package/dist/{chunk-ZJLZSFOZ.js → chunk-GGFFYP6D.js} +8 -8
- package/dist/chunk-GKCF2RYY.js +69 -0
- package/dist/chunk-GKCF2RYY.js.map +1 -0
- package/dist/{chunk-RI6MVJJN.js → chunk-ITDY6AIZ.js} +6 -1
- package/dist/chunk-ITDY6AIZ.js.map +1 -0
- package/dist/{chunk-2K7J3EY3.mjs → chunk-IZI7FQIN.mjs} +3 -3
- package/dist/{chunk-FS7FRO7B.mjs → chunk-QQKWUHXX.mjs} +5 -5
- package/dist/{chunk-JR6HDRNV.mjs → chunk-QSBIXUMB.mjs} +2 -2
- package/dist/{chunk-I5YZ7QUK.js → chunk-RBMBBUW3.js} +7 -7
- package/dist/{chunk-IUBAETUH.js → chunk-RQKICZYP.js} +3 -3
- package/dist/{chunk-DE3MZYVY.mjs → chunk-SBZB2FLU.mjs} +61 -27
- package/dist/chunk-SBZB2FLU.mjs.map +1 -0
- package/dist/{chunk-HPNXIKFY.js → chunk-TUW3M44L.js} +1 -1
- package/dist/chunk-TUW3M44L.js.map +1 -0
- package/dist/{chunk-Y734U4V6.mjs → chunk-VEREDMI2.mjs} +2 -2
- package/dist/{chunk-ZCQRDZ36.js → chunk-VHFPV3A3.js} +5 -5
- package/dist/{chunk-6MYNWYJK.mjs → chunk-WCJ7I43R.mjs} +39 -10
- package/dist/chunk-WCJ7I43R.mjs.map +1 -0
- package/dist/{chunk-DTEDYRTL.js → chunk-WXQZIUNW.js} +4 -4
- package/dist/{chunk-UKYY2RVS.mjs → chunk-XKNFL657.mjs} +2 -2
- package/dist/{chunk-LM4NUNMT.mjs → chunk-XOIPXDGX.mjs} +1 -1
- package/dist/chunk-XOIPXDGX.mjs.map +1 -0
- package/dist/{chunk-MHM5LRRF.mjs → chunk-Z3HHSD5I.mjs} +6 -1
- package/dist/chunk-Z3HHSD5I.mjs.map +1 -0
- package/dist/{chunk-C67QD5PV.mjs → chunk-Z6HYOGNR.mjs} +44 -19
- package/dist/chunk-Z6HYOGNR.mjs.map +1 -0
- package/dist/constants.js +2 -2
- package/dist/constants.mjs +1 -1
- package/dist/gas-flows/DefaultGasFeeFlow.js +7 -7
- package/dist/gas-flows/DefaultGasFeeFlow.mjs +6 -6
- package/dist/gas-flows/LineaGasFeeFlow.js +8 -8
- package/dist/gas-flows/LineaGasFeeFlow.mjs +7 -7
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.js +11 -0
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.js.map +1 -0
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.mjs +11 -0
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.mjs.map +1 -0
- package/dist/helpers/EtherscanRemoteTransactionSource.js +5 -5
- package/dist/helpers/EtherscanRemoteTransactionSource.mjs +4 -4
- package/dist/helpers/GasFeePoller.js +5 -4
- package/dist/helpers/GasFeePoller.mjs +4 -3
- package/dist/helpers/MultichainTrackingHelper.js +6 -6
- package/dist/helpers/MultichainTrackingHelper.mjs +5 -5
- package/dist/helpers/PendingTransactionTracker.js +1 -1
- package/dist/helpers/PendingTransactionTracker.mjs +1 -1
- package/dist/index.js +22 -20
- package/dist/index.mjs +21 -19
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/TransactionController.d.ts +1 -0
- package/dist/types/TransactionController.d.ts.map +1 -1
- package/dist/types/constants.d.ts +5 -0
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/gas-flows/OptimismLayer1GasFeeFlow.d.ts +10 -0
- package/dist/types/gas-flows/OptimismLayer1GasFeeFlow.d.ts.map +1 -0
- package/dist/types/helpers/GasFeePoller.d.ts +7 -3
- package/dist/types/helpers/GasFeePoller.d.ts.map +1 -1
- package/dist/types/helpers/MultichainTrackingHelper.d.ts +4 -0
- package/dist/types/helpers/MultichainTrackingHelper.d.ts.map +1 -1
- package/dist/types/types.d.ts +32 -1
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/layer1-gas-fee-flow.d.ts +23 -0
- package/dist/types/utils/layer1-gas-fee-flow.d.ts.map +1 -0
- package/dist/types.js +2 -2
- package/dist/types.mjs +1 -1
- package/dist/utils/etherscan.js +3 -3
- package/dist/utils/etherscan.mjs +2 -2
- package/dist/utils/external-transactions.js +1 -1
- package/dist/utils/external-transactions.mjs +1 -1
- package/dist/utils/gas-fees.js +6 -6
- package/dist/utils/gas-fees.mjs +5 -5
- package/dist/utils/gas-flow.js +3 -3
- package/dist/utils/gas-flow.mjs +2 -2
- package/dist/utils/gas.js +3 -3
- package/dist/utils/gas.mjs +2 -2
- package/dist/utils/layer1-gas-fee-flow.js +11 -0
- package/dist/utils/layer1-gas-fee-flow.js.map +1 -0
- package/dist/utils/layer1-gas-fee-flow.mjs +11 -0
- package/dist/utils/layer1-gas-fee-flow.mjs.map +1 -0
- package/dist/utils/simulation-api.js +3 -3
- package/dist/utils/simulation-api.mjs +2 -2
- package/dist/utils/simulation.js +5 -5
- package/dist/utils/simulation.mjs +4 -4
- package/dist/utils/swaps.js +4 -4
- package/dist/utils/swaps.mjs +3 -3
- package/dist/utils/transaction-type.js +1 -1
- package/dist/utils/transaction-type.mjs +1 -1
- package/dist/utils/utils.js +1 -1
- package/dist/utils/utils.mjs +1 -1
- package/dist/utils/validation.js +1 -1
- package/dist/utils/validation.mjs +1 -1
- package/package.json +11 -10
- package/dist/chunk-6MYNWYJK.mjs.map +0 -1
- package/dist/chunk-7APMBUKB.js.map +0 -1
- package/dist/chunk-BJEESIBE.js.map +0 -1
- package/dist/chunk-C67QD5PV.mjs.map +0 -1
- package/dist/chunk-DE3MZYVY.mjs.map +0 -1
- package/dist/chunk-HPNXIKFY.js.map +0 -1
- package/dist/chunk-LM4NUNMT.mjs.map +0 -1
- package/dist/chunk-M7455RU7.js.map +0 -1
- package/dist/chunk-MHM5LRRF.mjs.map +0 -1
- package/dist/chunk-RI6MVJJN.js.map +0 -1
- /package/dist/{chunk-H4M66BA3.js.map → chunk-2MMWLJXS.js.map} +0 -0
- /package/dist/{chunk-EQ3RRHB7.mjs.map → chunk-3D3SA6PY.mjs.map} +0 -0
- /package/dist/{chunk-UM4ORJ5B.mjs.map → chunk-3JYZDVNJ.mjs.map} +0 -0
- /package/dist/{chunk-FDJPXQTF.js.map → chunk-4S25HUCL.js.map} +0 -0
- /package/dist/{chunk-IC233ZQS.js.map → chunk-5OQ373JS.js.map} +0 -0
- /package/dist/{chunk-7MZ57ILQ.mjs.map → chunk-6KYPLIXG.mjs.map} +0 -0
- /package/dist/{chunk-DEKM6PVG.mjs.map → chunk-7XPI7KU5.mjs.map} +0 -0
- /package/dist/{chunk-DQP6X25N.mjs.map → chunk-ARB3VRKV.mjs.map} +0 -0
- /package/dist/{chunk-NUOBUW7C.js.map → chunk-CXXGL43K.js.map} +0 -0
- /package/dist/{chunk-GKTIFXPN.js.map → chunk-F3CMU2DM.js.map} +0 -0
- /package/dist/{chunk-ZJLZSFOZ.js.map → chunk-GGFFYP6D.js.map} +0 -0
- /package/dist/{chunk-2K7J3EY3.mjs.map → chunk-IZI7FQIN.mjs.map} +0 -0
- /package/dist/{chunk-FS7FRO7B.mjs.map → chunk-QQKWUHXX.mjs.map} +0 -0
- /package/dist/{chunk-JR6HDRNV.mjs.map → chunk-QSBIXUMB.mjs.map} +0 -0
- /package/dist/{chunk-I5YZ7QUK.js.map → chunk-RBMBBUW3.js.map} +0 -0
- /package/dist/{chunk-IUBAETUH.js.map → chunk-RQKICZYP.js.map} +0 -0
- /package/dist/{chunk-Y734U4V6.mjs.map → chunk-VEREDMI2.mjs.map} +0 -0
- /package/dist/{chunk-ZCQRDZ36.js.map → chunk-VHFPV3A3.js.map} +0 -0
- /package/dist/{chunk-DTEDYRTL.js.map → chunk-WXQZIUNW.js.map} +0 -0
- /package/dist/{chunk-UKYY2RVS.mjs.map → chunk-XKNFL657.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,132 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [25.1.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Support `Layer1GasFeeFlows` and add `layer1GasFee` property to `TransactionMeta` ([#3944](https://github.com/MetaMask/core/pull/3944))
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- Fix `types` field in `package.json` ([#4047](https://github.com/MetaMask/core/pull/4047))
|
|
19
|
+
|
|
20
|
+
## [25.0.0]
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
|
|
24
|
+
- **BREAKING**: Add ESM build ([#3998](https://github.com/MetaMask/core/pull/3998))
|
|
25
|
+
- It's no longer possible to import files from `./dist` directly.
|
|
26
|
+
- Add new types for TransactionController messenger actions ([#3827](https://github.com/MetaMask/core/pull/3827))
|
|
27
|
+
- `TransactionControllerActions`
|
|
28
|
+
- `TransactionControllerGetStateAction`
|
|
29
|
+
- Add new types for TransactionController messenger events ([#3827](https://github.com/MetaMask/core/pull/3827))
|
|
30
|
+
- `TransactionControllerEvents`
|
|
31
|
+
- `TransactionControllerIncomingTransactionBlockReceivedEvent`
|
|
32
|
+
- `TransactionControllerPostTransactionBalanceUpdatedEvent`
|
|
33
|
+
- `TransactionControllerSpeedupTransactionAddedEvent`
|
|
34
|
+
- `TransactionControllerStateChangeEvent`
|
|
35
|
+
- `TransactionControllerTransactionApprovedEvent`
|
|
36
|
+
- `TransactionControllerTransactionConfirmedEvent`
|
|
37
|
+
- `TransactionControllerTransactionDroppedEvent`
|
|
38
|
+
- `TransactionControllerTransactionFailedEvent`
|
|
39
|
+
- `TransactionControllerTransactionFinishedEvent`
|
|
40
|
+
- `TransactionControllerTransactionNewSwapApprovalEvent`
|
|
41
|
+
- `TransactionControllerTransactionNewSwapEvent`
|
|
42
|
+
- `TransactionControllerTransactionPublishingSkipped`
|
|
43
|
+
- `TransactionControllerTransactionRejectedEvent`
|
|
44
|
+
- `TransactionControllerTransactionStatusUpdatedEvent`
|
|
45
|
+
- `TransactionControllerTransactionSubmittedEvent`
|
|
46
|
+
- `TransactionControllerUnapprovedTransactionAddedEvent`
|
|
47
|
+
- Add optional `simulationData` property to `TransactionMeta` which will be automatically populated ([#4020](https://github.com/MetaMask/core/pull/4020))
|
|
48
|
+
- Add optional `isSimulationEnabled` constructor option to dynamically disable simulation ([#4020](https://github.com/MetaMask/core/pull/4020))
|
|
49
|
+
- Add support for Linea Sepolia (chain ID `0xe705`) ([#3995](https://github.com/MetaMask/core/pull/3995))
|
|
50
|
+
|
|
51
|
+
### Changed
|
|
52
|
+
|
|
53
|
+
- **BREAKING:** Change superclass of TransactionController from BaseController v1 to BaseController v2 ([#3827](https://github.com/MetaMask/core/pull/3827))
|
|
54
|
+
- Instead of accepting three arguments, the constructor now takes a single options argument. All of the existing options that were supported in the second argument are now a part of this options object, including `messenger`; `state` (the previous third argument) is also an option.
|
|
55
|
+
- **BREAKING:** Rename `txHistoryLimit` option to `transactionHistoryLimit` ([#3827](https://github.com/MetaMask/core/pull/3827))
|
|
56
|
+
- **BREAKING:** Switch some type definitions from `interface` to `type` ([#3827](https://github.com/MetaMask/core/pull/3827))
|
|
57
|
+
- These types are affected:
|
|
58
|
+
- `DappSuggestedGasFees`
|
|
59
|
+
- `Log`
|
|
60
|
+
- `MethodData`
|
|
61
|
+
- `TransactionControllerState` (formerly `TransactionState`)
|
|
62
|
+
- `TransactionParams`
|
|
63
|
+
- `TransactionReceipt`
|
|
64
|
+
- This is a breaking change because type aliases have different behavior from interfaces. Specifically, the `Json` type in `@metamask/utils`, which BaseController v2 controller state must conform to, is not compatible with interfaces.
|
|
65
|
+
- **BREAKING:** Align `parsedRegistryMethod` in `MethodData` type with usage ([#3827](https://github.com/MetaMask/core/pull/3827))
|
|
66
|
+
- The type of this is now `{ name: string; args: { type: string }[]; } | { name?: any; args?: any; }`, which is a `Json`-compatible version of a type found in `eth-method-registry`.
|
|
67
|
+
- **BREAKING:** Rename `TransactionState` to `TransactionControllerState` ([#3827](https://github.com/MetaMask/core/pull/3827))
|
|
68
|
+
- This change aligns this controller with other MetaMask controllers.
|
|
69
|
+
- **BREAKING:** Update allowed events for the `TransactionControllerMessenger` ([#3827](https://github.com/MetaMask/core/pull/3827))
|
|
70
|
+
- The restricted messenger must allow the following events:
|
|
71
|
+
- `TransactionController:incomingTransactionBlockReceived`
|
|
72
|
+
- `TransactionController:postTransactionBalanceUpdated`
|
|
73
|
+
- `TransactionController:speedUpTransactionAdded`
|
|
74
|
+
- `TransactionController:transactionApproved`
|
|
75
|
+
- `TransactionController:transactionConfirmed`
|
|
76
|
+
- `TransactionController:transactionDropped`
|
|
77
|
+
- `TransactionController:transactionFinished`
|
|
78
|
+
- `TransactionController:transactionFinished`
|
|
79
|
+
- `TransactionController:transactionPublishingSkipped`
|
|
80
|
+
- `TransactionController:transactionRejected`
|
|
81
|
+
- `TransactionController:transactionStatusUpdated`
|
|
82
|
+
- `TransactionController:transactionSubmitted`
|
|
83
|
+
- `TransactionController:unapprovedTransactionAdded`
|
|
84
|
+
- **BREAKING:** Update `TransactionMeta` type to be compatible with `Json` ([#3827](https://github.com/MetaMask/core/pull/3827))
|
|
85
|
+
- As dictated by BaseController v2, any types that are part of state need to be compatible with the `Json` type from `@metamask/utils`.
|
|
86
|
+
- **BREAKING:** Transform `rpc` property on transaction errors so they're JSON-encodable ([#3827](https://github.com/MetaMask/core/pull/3827))
|
|
87
|
+
- This change also results in typing this property as `Json` instead of `unknown`, avoiding a "Type instantiation is excessively deep and possibly infinite" error when resolving the `TransactionControllerState` type.
|
|
88
|
+
- **BREAKING:** Bump dependency and peer dependency on `@metamask/approval-controller` to `^6.0.0` ([#4039](https://github.com/MetaMask/core/pull/4039))
|
|
89
|
+
- **BREAKING:** Bump dependency and peer dependency on `@metamask/gas-fee-controller` to `^14.0.0` ([#4039](https://github.com/MetaMask/core/pull/4039))
|
|
90
|
+
- **BREAKING:** Bump dependency and peer dependency on `@metamask/network-controller` to `^18.0.0` ([#4039](https://github.com/MetaMask/core/pull/4039))
|
|
91
|
+
- **BREAKING:** Bump `@metamask/base-controller` to `^5.0.0` ([#4039](https://github.com/MetaMask/core/pull/4039))
|
|
92
|
+
- This version has a number of breaking changes. See the changelog for more.
|
|
93
|
+
- Add dependency on `@ethersproject/providers` `^5.7.0` ([#4020](https://github.com/MetaMask/core/pull/4020))
|
|
94
|
+
- Bump `@metamask/controller-utils` to `^9.0.0` ([#4039](https://github.com/MetaMask/core/pull/4039))
|
|
95
|
+
|
|
96
|
+
### Removed
|
|
97
|
+
|
|
98
|
+
- **BREAKING:** Remove `TransactionConfig` type ([#3827](https://github.com/MetaMask/core/pull/3827))
|
|
99
|
+
- The properties in this type have been absorbed into `TransactionControllerOptions`.
|
|
100
|
+
- **BREAKING:** Remove `hub` property from TransactionController ([#3827](https://github.com/MetaMask/core/pull/3827))
|
|
101
|
+
- TransactionController now fully makes use of its messenger object to announce various kinds of activities. Instead of subscribing to an event like this:
|
|
102
|
+
```
|
|
103
|
+
transactionController.hub.on(eventName, ...)
|
|
104
|
+
```
|
|
105
|
+
use this:
|
|
106
|
+
```
|
|
107
|
+
messenger.subscribe('TransactionController:${eventName}', ...)
|
|
108
|
+
```
|
|
109
|
+
- The complete list of renamed events are:
|
|
110
|
+
- `incomingTransactionBlock` -> `TransactionController:incomingTransactionBlockReceived`
|
|
111
|
+
- `post-transaction-balance-updated` -> `TransactionController:postTransactionBalanceUpdated`
|
|
112
|
+
- `transaction-approved` -> `TransactionController:transactionApproved`
|
|
113
|
+
- `transaction-confirmed` -> `TransactionController:transactionConfirmed`
|
|
114
|
+
- `transaction-dropped` -> `TransactionController:transactionDropped`
|
|
115
|
+
- `transaction-finished` -> `TransactionController:transactionFinished`
|
|
116
|
+
- `transaction-rejected` -> `TransactionController:transactionRejected`
|
|
117
|
+
- `transaction-status-update` -> `TransactionController:transactionStatusUpdated`
|
|
118
|
+
- `transaction-submitted` -> `TransactionController:transactionSubmitted`
|
|
119
|
+
- `unapprovedTransaction` -> `TransactionController:unapprovedTransactionAdded`
|
|
120
|
+
- Some events announced the state of specific transactions. These have been removed. Instead, subscribe to the appropriate generic event and check for a specific transaction ID in your event handler:
|
|
121
|
+
- `${transactionId}:finished` -> `TransactionController:transactionFinished`
|
|
122
|
+
- `${transactionId}:speedup` -> `TransactionController:speedUpTransactionAdded`
|
|
123
|
+
- `${transactionId}:publish-skip` -> `TransactionController:transactionPublishingSkipped`
|
|
124
|
+
|
|
125
|
+
### Fixed
|
|
126
|
+
|
|
127
|
+
- Fix various methods so that they no longer update transactions in state directly but only via `update` ([#3827](https://github.com/MetaMask/core/pull/3827))
|
|
128
|
+
- `addTransaction`
|
|
129
|
+
- `confirmExternalTransaction`
|
|
130
|
+
- `speedUpTransaction`
|
|
131
|
+
- `updateCustodialTransaction`
|
|
132
|
+
- `updateSecurityAlertResponse`
|
|
133
|
+
- `updateTransaction`
|
|
134
|
+
- Fix `handleMethodData` method to update state with an empty registry object instead of blowing up if registry could be found ([#3827](https://github.com/MetaMask/core/pull/3827))
|
|
135
|
+
|
|
10
136
|
## [24.0.0]
|
|
11
137
|
|
|
12
138
|
### Added
|
|
@@ -558,7 +684,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
558
684
|
|
|
559
685
|
All changes listed after this point were applied to this package following the monorepo conversion.
|
|
560
686
|
|
|
561
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@
|
|
687
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@25.1.0...HEAD
|
|
688
|
+
[25.1.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@25.0.0...@metamask/transaction-controller@25.1.0
|
|
689
|
+
[25.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@24.0.0...@metamask/transaction-controller@25.0.0
|
|
562
690
|
[24.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@23.1.0...@metamask/transaction-controller@24.0.0
|
|
563
691
|
[23.1.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@23.0.0...@metamask/transaction-controller@23.1.0
|
|
564
692
|
[23.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@22.0.0...@metamask/transaction-controller@23.0.0
|
|
@@ -4,30 +4,32 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkEXFVMWXEjs = require('./chunk-EXFVMWXE.js');
|
|
8
|
+
require('./chunk-HS277C77.js');
|
|
8
9
|
require('./chunk-VH47Q6TS.js');
|
|
9
|
-
require('./chunk-
|
|
10
|
+
require('./chunk-RQKICZYP.js');
|
|
10
11
|
require('./chunk-QP75SWIQ.js');
|
|
11
12
|
require('./chunk-ZNZEJDOE.js');
|
|
12
|
-
require('./chunk-
|
|
13
|
-
require('./chunk-
|
|
14
|
-
require('./chunk-
|
|
15
|
-
require('./chunk-7APMBUKB.js');
|
|
13
|
+
require('./chunk-WXQZIUNW.js');
|
|
14
|
+
require('./chunk-4S25HUCL.js');
|
|
15
|
+
require('./chunk-2MUK5JWA.js');
|
|
16
16
|
require('./chunk-DTDTOMTB.js');
|
|
17
|
-
require('./chunk-
|
|
17
|
+
require('./chunk-7C6ERJJC.js');
|
|
18
|
+
require('./chunk-F3CMU2DM.js');
|
|
18
19
|
require('./chunk-5XBULBP2.js');
|
|
20
|
+
require('./chunk-CXXGL43K.js');
|
|
19
21
|
require('./chunk-7LXE4KHV.js');
|
|
20
|
-
require('./chunk-
|
|
21
|
-
require('./chunk-
|
|
22
|
-
require('./chunk-
|
|
23
|
-
require('./chunk-
|
|
22
|
+
require('./chunk-RBMBBUW3.js');
|
|
23
|
+
require('./chunk-GGFFYP6D.js');
|
|
24
|
+
require('./chunk-VHFPV3A3.js');
|
|
25
|
+
require('./chunk-5OQ373JS.js');
|
|
24
26
|
require('./chunk-UGFBA4GV.js');
|
|
25
|
-
require('./chunk-
|
|
26
|
-
require('./chunk-
|
|
27
|
-
require('./chunk-
|
|
28
|
-
require('./chunk-
|
|
27
|
+
require('./chunk-2MMWLJXS.js');
|
|
28
|
+
require('./chunk-TUW3M44L.js');
|
|
29
|
+
require('./chunk-GKCF2RYY.js');
|
|
30
|
+
require('./chunk-CBKVKDFC.js');
|
|
31
|
+
require('./chunk-ITDY6AIZ.js');
|
|
29
32
|
require('./chunk-S6VGOPUY.js');
|
|
30
|
-
require('./chunk-HPNXIKFY.js');
|
|
31
33
|
require('./chunk-Z4BLTVTB.js');
|
|
32
34
|
|
|
33
35
|
|
|
@@ -35,5 +37,5 @@ require('./chunk-Z4BLTVTB.js');
|
|
|
35
37
|
|
|
36
38
|
|
|
37
39
|
|
|
38
|
-
exports.ApprovalState =
|
|
40
|
+
exports.ApprovalState = _chunkEXFVMWXEjs.ApprovalState; exports.CANCEL_RATE = _chunkEXFVMWXEjs.CANCEL_RATE; exports.HARDFORK = _chunkEXFVMWXEjs.HARDFORK; exports.SPEED_UP_RATE = _chunkEXFVMWXEjs.SPEED_UP_RATE; exports.TransactionController = _chunkEXFVMWXEjs.TransactionController;
|
|
39
41
|
//# sourceMappingURL=TransactionController.js.map
|
|
@@ -4,30 +4,32 @@ import {
|
|
|
4
4
|
HARDFORK,
|
|
5
5
|
SPEED_UP_RATE,
|
|
6
6
|
TransactionController
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-SBZB2FLU.mjs";
|
|
8
|
+
import "./chunk-JRBREX22.mjs";
|
|
8
9
|
import "./chunk-NM6OYEPP.mjs";
|
|
9
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-XKNFL657.mjs";
|
|
10
11
|
import "./chunk-XGRAHX6T.mjs";
|
|
11
12
|
import "./chunk-NHRBO3LU.mjs";
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-6MYNWYJK.mjs";
|
|
13
|
+
import "./chunk-QSBIXUMB.mjs";
|
|
14
|
+
import "./chunk-7XPI7KU5.mjs";
|
|
15
|
+
import "./chunk-WCJ7I43R.mjs";
|
|
16
16
|
import "./chunk-Y7ENNK7L.mjs";
|
|
17
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-Z6HYOGNR.mjs";
|
|
18
|
+
import "./chunk-IZI7FQIN.mjs";
|
|
18
19
|
import "./chunk-JRQHIBG5.mjs";
|
|
20
|
+
import "./chunk-VEREDMI2.mjs";
|
|
19
21
|
import "./chunk-FRKQ3Z2L.mjs";
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-
|
|
23
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-3JYZDVNJ.mjs";
|
|
23
|
+
import "./chunk-QQKWUHXX.mjs";
|
|
24
|
+
import "./chunk-ARB3VRKV.mjs";
|
|
25
|
+
import "./chunk-3D3SA6PY.mjs";
|
|
24
26
|
import "./chunk-J56A7UCK.mjs";
|
|
25
|
-
import "./chunk-
|
|
26
|
-
import "./chunk-
|
|
27
|
-
import "./chunk-
|
|
28
|
-
import "./chunk-
|
|
27
|
+
import "./chunk-6KYPLIXG.mjs";
|
|
28
|
+
import "./chunk-XOIPXDGX.mjs";
|
|
29
|
+
import "./chunk-DX4NUE4H.mjs";
|
|
30
|
+
import "./chunk-6FF5JJVB.mjs";
|
|
31
|
+
import "./chunk-Z3HHSD5I.mjs";
|
|
29
32
|
import "./chunk-UQQWZT6C.mjs";
|
|
30
|
-
import "./chunk-LM4NUNMT.mjs";
|
|
31
33
|
import "./chunk-XUI43LEZ.mjs";
|
|
32
34
|
export {
|
|
33
35
|
ApprovalState,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkTUW3M44Ljs = require('./chunk-TUW3M44L.js');
|
|
4
4
|
|
|
5
5
|
// src/utils/gas-flow.ts
|
|
6
6
|
var _controllerutils = require('@metamask/controller-utils');
|
|
@@ -18,7 +18,7 @@ function mergeGasFeeEstimates({
|
|
|
18
18
|
transactionGasFeeEstimates
|
|
19
19
|
}) {
|
|
20
20
|
if (gasFeeControllerEstimateType === _gasfeecontroller.GAS_ESTIMATE_TYPES.FEE_MARKET) {
|
|
21
|
-
return Object.values(
|
|
21
|
+
return Object.values(_chunkTUW3M44Ljs.GasFeeEstimateLevel).reduce(
|
|
22
22
|
(result, level) => ({
|
|
23
23
|
...result,
|
|
24
24
|
[level]: mergeFeeMarketEstimate(
|
|
@@ -30,7 +30,7 @@ function mergeGasFeeEstimates({
|
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
32
|
if (gasFeeControllerEstimateType === _gasfeecontroller.GAS_ESTIMATE_TYPES.LEGACY) {
|
|
33
|
-
return Object.values(
|
|
33
|
+
return Object.values(_chunkTUW3M44Ljs.GasFeeEstimateLevel).reduce(
|
|
34
34
|
(result, level) => ({
|
|
35
35
|
...result,
|
|
36
36
|
[level]: getLegacyEstimate(transactionGasFeeEstimates[level])
|
|
@@ -59,4 +59,4 @@ function getLegacyEstimate(transactionGasFeeEstimate) {
|
|
|
59
59
|
|
|
60
60
|
|
|
61
61
|
exports.getGasFeeFlow = getGasFeeFlow; exports.mergeGasFeeEstimates = mergeGasFeeEstimates;
|
|
62
|
-
//# sourceMappingURL=chunk-
|
|
62
|
+
//# sourceMappingURL=chunk-2MMWLJXS.js.map
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk2MMWLJXSjs = require('./chunk-2MMWLJXS.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkCBKVKDFCjs = require('./chunk-CBKVKDFC.js');
|
|
4
7
|
|
|
5
8
|
|
|
6
9
|
var _chunkS6VGOPUYjs = require('./chunk-S6VGOPUY.js');
|
|
@@ -16,7 +19,7 @@ var _utils = require('@metamask/utils');
|
|
|
16
19
|
var _events = require('events'); var _events2 = _interopRequireDefault(_events);
|
|
17
20
|
var log = _utils.createModuleLogger.call(void 0, _chunkS6VGOPUYjs.projectLogger, "gas-fee-poller");
|
|
18
21
|
var INTERVAL_MILLISECONDS = 1e4;
|
|
19
|
-
var _gasFeeFlows, _getEthQuery, _getGasFeeControllerEstimates, _getTransactions, _timeout, _running, _start, start_fn, _stop, stop_fn, _onTimeout, onTimeout_fn,
|
|
22
|
+
var _gasFeeFlows, _getEthQuery, _getGasFeeControllerEstimates, _getProvider, _getTransactions, _layer1GasFeeFlows, _timeout, _running, _start, start_fn, _stop, stop_fn, _onTimeout, onTimeout_fn, _updateTransactionGasFeeEstimates, updateTransactionGasFeeEstimates_fn, _updateTransactionSuggestedFees, updateTransactionSuggestedFees_fn, _updateTransactionLayer1GasFee, updateTransactionLayer1GasFee_fn, _getUnapprovedTransactions, getUnapprovedTransactions_fn;
|
|
20
23
|
var GasFeePoller = class {
|
|
21
24
|
/**
|
|
22
25
|
* Constructs a new instance of the GasFeePoller.
|
|
@@ -24,32 +27,41 @@ var GasFeePoller = class {
|
|
|
24
27
|
* @param options.gasFeeFlows - The gas fee flows to use to obtain suitable gas fees.
|
|
25
28
|
* @param options.getEthQuery - Callback to obtain an EthQuery instance.
|
|
26
29
|
* @param options.getGasFeeControllerEstimates - Callback to obtain the default fee estimates.
|
|
30
|
+
* @param options.getProvider - Callback to obtain a provider instance.
|
|
27
31
|
* @param options.getTransactions - Callback to obtain the transaction data.
|
|
32
|
+
* @param options.layer1GasFeeFlows - The layer 1 gas fee flows to use to obtain suitable layer 1 gas fees.
|
|
28
33
|
* @param options.onStateChange - Callback to register a listener for controller state changes.
|
|
29
34
|
*/
|
|
30
35
|
constructor({
|
|
31
36
|
gasFeeFlows,
|
|
32
37
|
getEthQuery,
|
|
33
38
|
getGasFeeControllerEstimates,
|
|
39
|
+
getProvider,
|
|
34
40
|
getTransactions,
|
|
41
|
+
layer1GasFeeFlows,
|
|
35
42
|
onStateChange
|
|
36
43
|
}) {
|
|
37
44
|
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _start);
|
|
38
45
|
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _stop);
|
|
39
46
|
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _onTimeout);
|
|
40
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this,
|
|
47
|
+
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _updateTransactionGasFeeEstimates);
|
|
41
48
|
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _updateTransactionSuggestedFees);
|
|
49
|
+
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _updateTransactionLayer1GasFee);
|
|
42
50
|
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _getUnapprovedTransactions);
|
|
43
51
|
this.hub = new (0, _events2.default)();
|
|
44
52
|
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _gasFeeFlows, void 0);
|
|
45
53
|
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _getEthQuery, void 0);
|
|
46
54
|
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _getGasFeeControllerEstimates, void 0);
|
|
55
|
+
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _getProvider, void 0);
|
|
47
56
|
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _getTransactions, void 0);
|
|
57
|
+
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _layer1GasFeeFlows, void 0);
|
|
48
58
|
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _timeout, void 0);
|
|
49
59
|
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _running, false);
|
|
50
60
|
_chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _gasFeeFlows, gasFeeFlows);
|
|
61
|
+
_chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _layer1GasFeeFlows, layer1GasFeeFlows);
|
|
51
62
|
_chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _getEthQuery, getEthQuery);
|
|
52
63
|
_chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _getGasFeeControllerEstimates, getGasFeeControllerEstimates);
|
|
64
|
+
_chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _getProvider, getProvider);
|
|
53
65
|
_chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _getTransactions, getTransactions);
|
|
54
66
|
onStateChange(() => {
|
|
55
67
|
const unapprovedTransactions = _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getUnapprovedTransactions, getUnapprovedTransactions_fn).call(this);
|
|
@@ -64,7 +76,9 @@ var GasFeePoller = class {
|
|
|
64
76
|
_gasFeeFlows = new WeakMap();
|
|
65
77
|
_getEthQuery = new WeakMap();
|
|
66
78
|
_getGasFeeControllerEstimates = new WeakMap();
|
|
79
|
+
_getProvider = new WeakMap();
|
|
67
80
|
_getTransactions = new WeakMap();
|
|
81
|
+
_layer1GasFeeFlows = new WeakMap();
|
|
68
82
|
_timeout = new WeakMap();
|
|
69
83
|
_running = new WeakMap();
|
|
70
84
|
_start = new WeakSet();
|
|
@@ -88,26 +102,27 @@ stop_fn = function() {
|
|
|
88
102
|
};
|
|
89
103
|
_onTimeout = new WeakSet();
|
|
90
104
|
onTimeout_fn = async function() {
|
|
91
|
-
await _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this,
|
|
105
|
+
await _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _updateTransactionGasFeeEstimates, updateTransactionGasFeeEstimates_fn).call(this);
|
|
92
106
|
_chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _timeout, setTimeout(() => _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _onTimeout, onTimeout_fn).call(this), INTERVAL_MILLISECONDS));
|
|
93
107
|
};
|
|
94
|
-
|
|
95
|
-
|
|
108
|
+
_updateTransactionGasFeeEstimates = new WeakSet();
|
|
109
|
+
updateTransactionGasFeeEstimates_fn = async function() {
|
|
96
110
|
const unapprovedTransactions = _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getUnapprovedTransactions, getUnapprovedTransactions_fn).call(this);
|
|
97
111
|
log("Found unapproved transactions", {
|
|
98
112
|
count: unapprovedTransactions.length
|
|
99
113
|
});
|
|
100
114
|
await Promise.all(
|
|
101
|
-
unapprovedTransactions.
|
|
102
|
-
|
|
103
|
-
|
|
115
|
+
unapprovedTransactions.flatMap((tx) => [
|
|
116
|
+
_chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _updateTransactionSuggestedFees, updateTransactionSuggestedFees_fn).call(this, tx),
|
|
117
|
+
_chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _updateTransactionLayer1GasFee, updateTransactionLayer1GasFee_fn).call(this, tx)
|
|
118
|
+
])
|
|
104
119
|
);
|
|
105
120
|
};
|
|
106
121
|
_updateTransactionSuggestedFees = new WeakSet();
|
|
107
122
|
updateTransactionSuggestedFees_fn = async function(transactionMeta) {
|
|
108
123
|
const { chainId, networkClientId } = transactionMeta;
|
|
109
124
|
const ethQuery = _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _getEthQuery).call(this, chainId, networkClientId);
|
|
110
|
-
const gasFeeFlow =
|
|
125
|
+
const gasFeeFlow = _chunk2MMWLJXSjs.getGasFeeFlow.call(void 0, transactionMeta, _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _gasFeeFlows));
|
|
111
126
|
if (!gasFeeFlow) {
|
|
112
127
|
log("No gas fee flow found", transactionMeta.id);
|
|
113
128
|
} else {
|
|
@@ -145,6 +160,20 @@ updateTransactionSuggestedFees_fn = async function(transactionMeta) {
|
|
|
145
160
|
transaction: updatedTransactionMeta.id
|
|
146
161
|
});
|
|
147
162
|
};
|
|
163
|
+
_updateTransactionLayer1GasFee = new WeakSet();
|
|
164
|
+
updateTransactionLayer1GasFee_fn = async function(transactionMeta) {
|
|
165
|
+
const { chainId, networkClientId } = transactionMeta;
|
|
166
|
+
const provider = _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _getProvider).call(this, chainId, networkClientId);
|
|
167
|
+
await _chunkCBKVKDFCjs.updateTransactionLayer1GasFee.call(void 0, {
|
|
168
|
+
provider,
|
|
169
|
+
layer1GasFeeFlows: _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _layer1GasFeeFlows),
|
|
170
|
+
transactionMeta
|
|
171
|
+
});
|
|
172
|
+
if (transactionMeta.layer1GasFee === void 0) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
this.hub.emit("transaction-updated", transactionMeta);
|
|
176
|
+
};
|
|
148
177
|
_getUnapprovedTransactions = new WeakSet();
|
|
149
178
|
getUnapprovedTransactions_fn = function() {
|
|
150
179
|
return _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _getTransactions).call(this).filter(
|
|
@@ -155,4 +184,4 @@ getUnapprovedTransactions_fn = function() {
|
|
|
155
184
|
|
|
156
185
|
|
|
157
186
|
exports.GasFeePoller = GasFeePoller;
|
|
158
|
-
//# sourceMappingURL=chunk-
|
|
187
|
+
//# sourceMappingURL=chunk-2MUK5JWA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/helpers/GasFeePoller.ts"],"names":[],"mappings":"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","sourcesContent":["import type EthQuery from '@metamask/eth-query';\nimport type { GasFeeState } from '@metamask/gas-fee-controller';\nimport type { NetworkClientId, Provider } from '@metamask/network-controller';\nimport type { Hex } from '@metamask/utils';\nimport { createModuleLogger } from '@metamask/utils';\nimport EventEmitter from 'events';\n\nimport { projectLogger } from '../logger';\nimport type {\n GasFeeEstimates,\n GasFeeFlow,\n GasFeeFlowRequest,\n Layer1GasFeeFlow,\n} from '../types';\nimport { TransactionStatus, type TransactionMeta } from '../types';\nimport { getGasFeeFlow } from '../utils/gas-flow';\nimport { updateTransactionLayer1GasFee } from '../utils/layer1-gas-fee-flow';\n\nconst log = createModuleLogger(projectLogger, 'gas-fee-poller');\n\nconst INTERVAL_MILLISECONDS = 10000;\n\n/**\n * Automatically polls and updates suggested gas fees on unapproved transactions.\n */\nexport class GasFeePoller {\n hub: EventEmitter = new EventEmitter();\n\n #gasFeeFlows: GasFeeFlow[];\n\n #getEthQuery: (chainId: Hex, networkClientId?: NetworkClientId) => EthQuery;\n\n #getGasFeeControllerEstimates: () => Promise<GasFeeState>;\n\n #getProvider: (chainId: Hex, networkClientId?: NetworkClientId) => Provider;\n\n #getTransactions: () => TransactionMeta[];\n\n #layer1GasFeeFlows: Layer1GasFeeFlow[];\n\n #timeout: ReturnType<typeof setTimeout> | undefined;\n\n #running = false;\n\n /**\n * Constructs a new instance of the GasFeePoller.\n * @param options - The options for this instance.\n * @param options.gasFeeFlows - The gas fee flows to use to obtain suitable gas fees.\n * @param options.getEthQuery - Callback to obtain an EthQuery instance.\n * @param options.getGasFeeControllerEstimates - Callback to obtain the default fee estimates.\n * @param options.getProvider - Callback to obtain a provider instance.\n * @param options.getTransactions - Callback to obtain the transaction data.\n * @param options.layer1GasFeeFlows - The layer 1 gas fee flows to use to obtain suitable layer 1 gas fees.\n * @param options.onStateChange - Callback to register a listener for controller state changes.\n */\n constructor({\n gasFeeFlows,\n getEthQuery,\n getGasFeeControllerEstimates,\n getProvider,\n getTransactions,\n layer1GasFeeFlows,\n onStateChange,\n }: {\n gasFeeFlows: GasFeeFlow[];\n getEthQuery: (chainId: Hex, networkClientId?: NetworkClientId) => EthQuery;\n getGasFeeControllerEstimates: () => Promise<GasFeeState>;\n getProvider: (chainId: Hex, networkClientId?: NetworkClientId) => Provider;\n getTransactions: () => TransactionMeta[];\n layer1GasFeeFlows: Layer1GasFeeFlow[];\n onStateChange: (listener: () => void) => void;\n }) {\n this.#gasFeeFlows = gasFeeFlows;\n this.#layer1GasFeeFlows = layer1GasFeeFlows;\n this.#getEthQuery = getEthQuery;\n this.#getGasFeeControllerEstimates = getGasFeeControllerEstimates;\n this.#getProvider = getProvider;\n this.#getTransactions = getTransactions;\n\n onStateChange(() => {\n const unapprovedTransactions = this.#getUnapprovedTransactions();\n\n if (unapprovedTransactions.length) {\n this.#start();\n } else {\n this.#stop();\n }\n });\n }\n\n #start() {\n if (this.#running) {\n return;\n }\n\n // Intentionally not awaiting since this starts the timeout chain.\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.#onTimeout();\n\n this.#running = true;\n\n log('Started polling');\n }\n\n #stop() {\n if (!this.#running) {\n return;\n }\n\n clearTimeout(this.#timeout);\n\n this.#timeout = undefined;\n this.#running = false;\n\n log('Stopped polling');\n }\n\n async #onTimeout() {\n await this.#updateTransactionGasFeeEstimates();\n\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.#timeout = setTimeout(() => this.#onTimeout(), INTERVAL_MILLISECONDS);\n }\n\n async #updateTransactionGasFeeEstimates() {\n const unapprovedTransactions = this.#getUnapprovedTransactions();\n\n log('Found unapproved transactions', {\n count: unapprovedTransactions.length,\n });\n\n await Promise.all(\n unapprovedTransactions.flatMap((tx) => [\n this.#updateTransactionSuggestedFees(tx),\n this.#updateTransactionLayer1GasFee(tx),\n ]),\n );\n }\n\n async #updateTransactionSuggestedFees(transactionMeta: TransactionMeta) {\n const { chainId, networkClientId } = transactionMeta;\n\n const ethQuery = this.#getEthQuery(chainId, networkClientId);\n const gasFeeFlow = getGasFeeFlow(transactionMeta, this.#gasFeeFlows);\n\n if (!gasFeeFlow) {\n log('No gas fee flow found', transactionMeta.id);\n } else {\n log(\n 'Found gas fee flow',\n gasFeeFlow.constructor.name,\n transactionMeta.id,\n );\n }\n\n const request: GasFeeFlowRequest = {\n ethQuery,\n getGasFeeControllerEstimates: this.#getGasFeeControllerEstimates,\n transactionMeta,\n };\n\n let gasFeeEstimates: GasFeeEstimates | undefined;\n\n if (gasFeeFlow) {\n try {\n const response = await gasFeeFlow.getGasFees(request);\n gasFeeEstimates = response.estimates;\n } catch (error) {\n log('Failed to get suggested gas fees', transactionMeta.id, error);\n }\n }\n\n if (!gasFeeEstimates && transactionMeta.gasFeeEstimatesLoaded) {\n return;\n }\n\n const updatedTransactionMeta: TransactionMeta = {\n ...transactionMeta,\n gasFeeEstimates,\n gasFeeEstimatesLoaded: true,\n };\n\n this.hub.emit('transaction-updated', updatedTransactionMeta);\n\n log('Updated suggested gas fees', {\n gasFeeEstimates: updatedTransactionMeta.gasFeeEstimates,\n transaction: updatedTransactionMeta.id,\n });\n }\n\n async #updateTransactionLayer1GasFee(transactionMeta: TransactionMeta) {\n const { chainId, networkClientId } = transactionMeta;\n const provider = this.#getProvider(chainId, networkClientId);\n\n await updateTransactionLayer1GasFee({\n provider,\n layer1GasFeeFlows: this.#layer1GasFeeFlows,\n transactionMeta,\n });\n\n if (transactionMeta.layer1GasFee === undefined) {\n return;\n }\n\n this.hub.emit('transaction-updated', transactionMeta);\n }\n\n #getUnapprovedTransactions() {\n return this.#getTransactions().filter(\n (tx) => tx.status === TransactionStatus.unapproved,\n );\n }\n}\n"]}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-J56A7UCK.mjs";
|
|
4
4
|
import {
|
|
5
5
|
CHAIN_IDS
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-Z3HHSD5I.mjs";
|
|
7
7
|
import {
|
|
8
8
|
createModuleLogger,
|
|
9
9
|
projectLogger
|
|
@@ -208,4 +208,4 @@ export {
|
|
|
208
208
|
updateSwapsTransaction,
|
|
209
209
|
updatePostTransactionBalance
|
|
210
210
|
};
|
|
211
|
-
//# sourceMappingURL=chunk-
|
|
211
|
+
//# sourceMappingURL=chunk-3D3SA6PY.mjs.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DefaultGasFeeFlow
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QQKWUHXX.mjs";
|
|
4
|
+
import {
|
|
5
|
+
GasFeeEstimateLevel
|
|
6
|
+
} from "./chunk-XOIPXDGX.mjs";
|
|
4
7
|
import {
|
|
5
8
|
projectLogger
|
|
6
9
|
} from "./chunk-UQQWZT6C.mjs";
|
|
7
|
-
import {
|
|
8
|
-
GasFeeEstimateLevel
|
|
9
|
-
} from "./chunk-LM4NUNMT.mjs";
|
|
10
10
|
import {
|
|
11
11
|
__privateAdd,
|
|
12
12
|
__privateMethod
|
|
@@ -118,4 +118,4 @@ feesToString_fn = function(fees) {
|
|
|
118
118
|
export {
|
|
119
119
|
LineaGasFeeFlow
|
|
120
120
|
};
|
|
121
|
-
//# sourceMappingURL=chunk-
|
|
121
|
+
//# sourceMappingURL=chunk-3JYZDVNJ.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkITDY6AIZjs = require('./chunk-ITDY6AIZ.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkS6VGOPUYjs = require('./chunk-S6VGOPUY.js');
|
|
@@ -12,16 +12,16 @@ var log = _utils.createModuleLogger.call(void 0, _chunkS6VGOPUYjs.projectLogger,
|
|
|
12
12
|
var RPC_METHOD = "infura_simulateTransactions";
|
|
13
13
|
var BASE_URL = "https://tx-sentinel-{0}.api.cx.metamask.io/";
|
|
14
14
|
var SUBDOMAIN_BY_CHAIN_ID = {
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[
|
|
19
|
-
[
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
24
|
-
[
|
|
15
|
+
[_chunkITDY6AIZjs.CHAIN_IDS.MAINNET]: "ethereum-mainnet",
|
|
16
|
+
[_chunkITDY6AIZjs.CHAIN_IDS.GOERLI]: "ethereum-goerli",
|
|
17
|
+
[_chunkITDY6AIZjs.CHAIN_IDS.SEPOLIA]: "ethereum-sepolia",
|
|
18
|
+
[_chunkITDY6AIZjs.CHAIN_IDS.LINEA_MAINNET]: "linea-mainnet",
|
|
19
|
+
[_chunkITDY6AIZjs.CHAIN_IDS.LINEA_GOERLI]: "linea-goerli",
|
|
20
|
+
[_chunkITDY6AIZjs.CHAIN_IDS.ARBITRUM]: "arbitrum-mainnet",
|
|
21
|
+
[_chunkITDY6AIZjs.CHAIN_IDS.AVALANCHE]: "avalanche-mainnet",
|
|
22
|
+
[_chunkITDY6AIZjs.CHAIN_IDS.OPTIMISM]: "optimism-mainnet",
|
|
23
|
+
[_chunkITDY6AIZjs.CHAIN_IDS.POLYGON]: "polygon-mainnet",
|
|
24
|
+
[_chunkITDY6AIZjs.CHAIN_IDS.BSC]: "bsc-mainnet"
|
|
25
25
|
};
|
|
26
26
|
async function simulateTransactions(chainId, request) {
|
|
27
27
|
const url = getUrl(chainId);
|
|
@@ -43,4 +43,4 @@ function getUrl(chainId) {
|
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
exports.simulateTransactions = simulateTransactions;
|
|
46
|
-
//# sourceMappingURL=chunk-
|
|
46
|
+
//# sourceMappingURL=chunk-4S25HUCL.js.map
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _chunkUGFBA4GVjs = require('./chunk-UGFBA4GV.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkITDY6AIZjs = require('./chunk-ITDY6AIZ.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
@@ -57,15 +57,15 @@ var ZKSYNC_ERA_SWAPS_TOKEN_OBJECT = {
|
|
|
57
57
|
...ETH_SWAPS_TOKEN_OBJECT
|
|
58
58
|
};
|
|
59
59
|
var SWAPS_CHAINID_DEFAULT_TOKEN_MAP = {
|
|
60
|
-
[
|
|
60
|
+
[_chunkITDY6AIZjs.CHAIN_IDS.MAINNET]: ETH_SWAPS_TOKEN_OBJECT,
|
|
61
61
|
[SWAPS_TESTNET_CHAIN_ID]: TEST_ETH_SWAPS_TOKEN_OBJECT,
|
|
62
|
-
[
|
|
63
|
-
[
|
|
64
|
-
[
|
|
65
|
-
[
|
|
66
|
-
[
|
|
67
|
-
[
|
|
68
|
-
[
|
|
62
|
+
[_chunkITDY6AIZjs.CHAIN_IDS.BSC]: BNB_SWAPS_TOKEN_OBJECT,
|
|
63
|
+
[_chunkITDY6AIZjs.CHAIN_IDS.POLYGON]: MATIC_SWAPS_TOKEN_OBJECT,
|
|
64
|
+
[_chunkITDY6AIZjs.CHAIN_IDS.GOERLI]: GOERLI_SWAPS_TOKEN_OBJECT,
|
|
65
|
+
[_chunkITDY6AIZjs.CHAIN_IDS.AVALANCHE]: AVAX_SWAPS_TOKEN_OBJECT,
|
|
66
|
+
[_chunkITDY6AIZjs.CHAIN_IDS.OPTIMISM]: OPTIMISM_SWAPS_TOKEN_OBJECT,
|
|
67
|
+
[_chunkITDY6AIZjs.CHAIN_IDS.ARBITRUM]: ARBITRUM_SWAPS_TOKEN_OBJECT,
|
|
68
|
+
[_chunkITDY6AIZjs.CHAIN_IDS.ZKSYNC_ERA]: ZKSYNC_ERA_SWAPS_TOKEN_OBJECT
|
|
69
69
|
};
|
|
70
70
|
var SWAP_TRANSACTION_TYPES = [
|
|
71
71
|
"swap" /* swap */,
|
|
@@ -208,4 +208,4 @@ function sleep(ms) {
|
|
|
208
208
|
|
|
209
209
|
|
|
210
210
|
exports.UPDATE_POST_TX_BALANCE_TIMEOUT = UPDATE_POST_TX_BALANCE_TIMEOUT; exports.UPDATE_POST_TX_BALANCE_ATTEMPTS = UPDATE_POST_TX_BALANCE_ATTEMPTS; exports.DEFAULT_TOKEN_ADDRESS = DEFAULT_TOKEN_ADDRESS; exports.SWAPS_CHAINID_DEFAULT_TOKEN_MAP = SWAPS_CHAINID_DEFAULT_TOKEN_MAP; exports.SWAP_TRANSACTION_TYPES = SWAP_TRANSACTION_TYPES; exports.updateSwapsTransaction = updateSwapsTransaction; exports.updatePostTransactionBalance = updatePostTransactionBalance;
|
|
211
|
-
//# sourceMappingURL=chunk-
|
|
211
|
+
//# sourceMappingURL=chunk-5OQ373JS.js.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import {
|
|
2
|
+
projectLogger
|
|
3
|
+
} from "./chunk-UQQWZT6C.mjs";
|
|
4
|
+
|
|
5
|
+
// src/utils/layer1-gas-fee-flow.ts
|
|
6
|
+
import { Common, Hardfork } from "@ethereumjs/common";
|
|
7
|
+
import { TransactionFactory } from "@ethereumjs/tx";
|
|
8
|
+
import { createModuleLogger } from "@metamask/utils";
|
|
9
|
+
import BN from "bn.js";
|
|
10
|
+
import { omit } from "lodash";
|
|
11
|
+
var log = createModuleLogger(projectLogger, "layer-1-gas-fee-flow");
|
|
12
|
+
async function updateTransactionLayer1GasFee(request) {
|
|
13
|
+
const layer1GasFee = await getTransactionLayer1GasFee(request);
|
|
14
|
+
if (layer1GasFee) {
|
|
15
|
+
const { transactionMeta } = request;
|
|
16
|
+
transactionMeta.layer1GasFee = layer1GasFee;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function getLayer1GasFeeFlow(transactionMeta, layer1GasFeeFlows) {
|
|
20
|
+
return layer1GasFeeFlows.find(
|
|
21
|
+
(layer1GasFeeFlow) => layer1GasFeeFlow.matchesTransaction(transactionMeta)
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
async function getTransactionLayer1GasFee({
|
|
25
|
+
layer1GasFeeFlows,
|
|
26
|
+
provider,
|
|
27
|
+
transactionMeta
|
|
28
|
+
}) {
|
|
29
|
+
const layer1GasFeeFlow = getLayer1GasFeeFlow(
|
|
30
|
+
transactionMeta,
|
|
31
|
+
layer1GasFeeFlows
|
|
32
|
+
);
|
|
33
|
+
if (!layer1GasFeeFlow) {
|
|
34
|
+
log("Layer 1 gas fee flow not found", transactionMeta.id);
|
|
35
|
+
return void 0;
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
const { layer1Fee } = await layer1GasFeeFlow.getLayer1Fee({
|
|
39
|
+
provider,
|
|
40
|
+
transactionMeta
|
|
41
|
+
});
|
|
42
|
+
return layer1Fee;
|
|
43
|
+
} catch (error) {
|
|
44
|
+
log("Failed to get layer 1 gas fee", transactionMeta.id, error);
|
|
45
|
+
return void 0;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function buildTransactionParams(transactionMeta) {
|
|
49
|
+
return {
|
|
50
|
+
...omit(transactionMeta.txParams, "gas"),
|
|
51
|
+
gasLimit: transactionMeta.txParams.gas
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function buildTransactionCommon(transactionMeta) {
|
|
55
|
+
return Common.custom({
|
|
56
|
+
chainId: new BN(transactionMeta.chainId, 16),
|
|
57
|
+
// Optimism only supports type-0 transactions; it does not support any of
|
|
58
|
+
// the newer EIPs since EIP-155. Source:
|
|
59
|
+
// <https://github.com/ethereum-optimism/optimism/blob/develop/specs/l2geth/transaction-types.md>
|
|
60
|
+
defaultHardfork: Hardfork.London
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function buildUnserializedTransaction(transactionMeta) {
|
|
64
|
+
const txParams = buildTransactionParams(transactionMeta);
|
|
65
|
+
const common = buildTransactionCommon(transactionMeta);
|
|
66
|
+
return TransactionFactory.fromTxData(txParams, { common });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export {
|
|
70
|
+
updateTransactionLayer1GasFee,
|
|
71
|
+
buildUnserializedTransaction
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=chunk-6FF5JJVB.mjs.map
|