@metamask-previews/bridge-status-controller 75.2.1-preview-264a60683 → 75.3.0-preview-56ae4c857
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 +7 -3
- package/dist/bridge-status-controller.cjs +12 -32
- package/dist/bridge-status-controller.cjs.map +1 -1
- package/dist/bridge-status-controller.d.cts +6 -1
- package/dist/bridge-status-controller.d.cts.map +1 -1
- package/dist/bridge-status-controller.d.mts +6 -1
- package/dist/bridge-status-controller.d.mts.map +1 -1
- package/dist/bridge-status-controller.mjs +13 -33
- package/dist/bridge-status-controller.mjs.map +1 -1
- package/dist/utils/metrics.cjs +0 -7
- package/dist/utils/metrics.cjs.map +1 -1
- package/dist/utils/metrics.d.cts +1 -5
- package/dist/utils/metrics.d.cts.map +1 -1
- package/dist/utils/metrics.d.mts +1 -5
- package/dist/utils/metrics.d.mts.map +1 -1
- package/dist/utils/metrics.mjs +1 -8
- package/dist/utils/metrics.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,9 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
## [75.3.0]
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
11
13
|
|
|
12
|
-
-
|
|
14
|
+
- Add optional `migrationPhase` to `submitTx`, `submitIntent`, and `submitBatchSell`, used by `toQuoteMetadataV1` to convert V2 quotes. Defaults to `V1Data` (`'1'`) if omitted ([#9744](https://github.com/MetaMask/core/pull/9744))
|
|
15
|
+
- Bump `@metamask/bridge-controller` from `^79.3.1` to `^80.0.0` ([#9978](https://github.com/MetaMask/core/pull/9978))
|
|
13
16
|
|
|
14
17
|
## [75.2.1]
|
|
15
18
|
|
|
@@ -1520,7 +1523,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
1520
1523
|
|
|
1521
1524
|
- Initial release ([#5317](https://github.com/MetaMask/core/pull/5317))
|
|
1522
1525
|
|
|
1523
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@75.
|
|
1526
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@75.3.0...HEAD
|
|
1527
|
+
[75.3.0]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@75.2.1...@metamask/bridge-status-controller@75.3.0
|
|
1524
1528
|
[75.2.1]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@75.2.0...@metamask/bridge-status-controller@75.2.1
|
|
1525
1529
|
[75.2.0]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@75.1.0...@metamask/bridge-status-controller@75.2.0
|
|
1526
1530
|
[75.1.0]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@75.0.0...@metamask/bridge-status-controller@75.1.0
|
|
@@ -18,9 +18,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
exports.BridgeStatusController = void 0;
|
|
19
19
|
const bridge_controller_1 = require("@metamask/bridge-controller");
|
|
20
20
|
const bridge_controller_2 = require("@metamask/bridge-controller");
|
|
21
|
-
const bridge_controller_3 = require("@metamask/bridge-controller");
|
|
22
21
|
const polling_controller_1 = require("@metamask/polling-controller");
|
|
23
|
-
const superstruct_1 = require("@metamask/superstruct");
|
|
24
22
|
const transaction_controller_1 = require("@metamask/transaction-controller");
|
|
25
23
|
const utils_1 = require("@metamask/utils");
|
|
26
24
|
const bridge_status_controller_intent_1 = require("./bridge-status-controller.intent.cjs");
|
|
@@ -811,10 +809,11 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
811
809
|
* @param tokenSecurityTypeDestination - The security classification of the destination token, supplied by the client (e.g. from token security/scanning data). Pass `null` when no security data is available.
|
|
812
810
|
* @param batchSellTrades - Contains transaction data for the quotes, provided by the obtainGaslessBatch API
|
|
813
811
|
* @param inputPrimaryDenomination - The denomination shown as the primary source amount input at submission time.
|
|
812
|
+
* @param migrationPhase - The active migration phase for the quote response
|
|
814
813
|
* @returns The transaction meta
|
|
815
814
|
* @throws An error if transaction submission fails before it gets published
|
|
816
815
|
*/
|
|
817
|
-
this.submitTx = async (accountAddress, maybeQuoteResponses, isStxEnabled, quotesReceivedContext, location = bridge_controller_2.MetaMetricsSwapsEventSource.Unknown, abTests, activeAbTests, tokenSecurityTypeDestination, batchSellTrades, inputPrimaryDenomination) => {
|
|
816
|
+
this.submitTx = async (accountAddress, maybeQuoteResponses, isStxEnabled, quotesReceivedContext, location = bridge_controller_2.MetaMetricsSwapsEventSource.Unknown, abTests, activeAbTests, tokenSecurityTypeDestination, batchSellTrades, inputPrimaryDenomination, migrationPhase) => {
|
|
818
817
|
/**
|
|
819
818
|
* If there are multiple quote responses, we assume that they all originate from the same src chain
|
|
820
819
|
* and the same account. In this case its safe to use the first quote response's properties for
|
|
@@ -825,11 +824,14 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
825
824
|
: [maybeQuoteResponses];
|
|
826
825
|
// Convert quote responses to V1 format and preserve metadata for consistency
|
|
827
826
|
const quoteResponses = quoteResponsesV1orV2.map((quote) => {
|
|
828
|
-
if ((0,
|
|
827
|
+
if (!(0, bridge_controller_1.isQuoteResponseV2)(quote)) {
|
|
829
828
|
return quote;
|
|
830
829
|
}
|
|
831
|
-
const
|
|
832
|
-
|
|
830
|
+
const quoteMetadataV1 = (0, bridge_controller_1.toQuoteMetadataV1)(quote, migrationPhase);
|
|
831
|
+
// This coercion omits legacy metadata from the resulting V1 quote
|
|
832
|
+
const quoteResponseV1 = (0, bridge_controller_1.toQuoteResponseV1)(quote);
|
|
833
|
+
// Merge legacy-shaped metadata to V1-shaped quote response
|
|
834
|
+
return { ...quoteResponseV1, ...quoteMetadataV1 };
|
|
833
835
|
});
|
|
834
836
|
const quoteResponse = quoteResponses[0];
|
|
835
837
|
const { quote } = quoteResponse;
|
|
@@ -854,8 +856,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
854
856
|
// Emit Submitted event after submit button is clicked
|
|
855
857
|
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_2.UnifiedSwapBridgeEventName.Submitted, undefined, {
|
|
856
858
|
...preConfirmationProperties,
|
|
857
|
-
source_hash_present: false,
|
|
858
|
-
destination_hash_present: false,
|
|
859
859
|
...(inputPrimaryDenomination && {
|
|
860
860
|
input_primary_denomination: inputPrimaryDenomination,
|
|
861
861
|
}),
|
|
@@ -897,7 +897,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
897
897
|
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_2.UnifiedSwapBridgeEventName.Failed, undefined, {
|
|
898
898
|
error_message: error?.message,
|
|
899
899
|
...preConfirmationProperties,
|
|
900
|
-
...(0, bridge_controller_1.getSubmitFailureTelemetry)(error),
|
|
901
900
|
});
|
|
902
901
|
throw error;
|
|
903
902
|
}
|
|
@@ -916,13 +915,14 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
916
915
|
* @param params.inputPrimaryDenomination - The denomination shown as the primary source amount input at submission time.
|
|
917
916
|
* @param params.isStxEnabled - Whether smart transactions are enabled on the client, for example the getSmartTransactionsEnabled selector value from the extension
|
|
918
917
|
* @param params.quotesReceivedContext - The context for the QuotesReceived event
|
|
918
|
+
* @param params.migrationPhase - The active migration phase for the quote response
|
|
919
919
|
* @returns A lightweight TransactionMeta-like object for history linking
|
|
920
920
|
* @throws An error if intent or transaction submission fails before they get published
|
|
921
921
|
*/
|
|
922
922
|
this.submitIntent = async (params) => {
|
|
923
|
-
const { quoteResponse, accountAddress, location, abTests, activeAbTests, tokenSecurityTypeDestination, inputPrimaryDenomination, isStxEnabled = false, quotesReceivedContext, } = params;
|
|
923
|
+
const { quoteResponse, accountAddress, location, abTests, migrationPhase, activeAbTests, tokenSecurityTypeDestination, inputPrimaryDenomination, isStxEnabled = false, quotesReceivedContext, } = params;
|
|
924
924
|
// TODO add metrics context
|
|
925
|
-
return await this.submitTx(accountAddress, quoteResponse, isStxEnabled, quotesReceivedContext, location, abTests, activeAbTests, tokenSecurityTypeDestination, undefined, inputPrimaryDenomination);
|
|
925
|
+
return await this.submitTx(accountAddress, quoteResponse, isStxEnabled, quotesReceivedContext, location, abTests, activeAbTests, tokenSecurityTypeDestination, undefined, inputPrimaryDenomination, migrationPhase);
|
|
926
926
|
};
|
|
927
927
|
this.submitBatchSell = async (params) => {
|
|
928
928
|
/**
|
|
@@ -930,7 +930,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
930
930
|
* the original response data from the bridge-api
|
|
931
931
|
*/
|
|
932
932
|
const batchSellTrades = (0, bridge_js_1.getBatchSellTrades)(this.messenger);
|
|
933
|
-
return await this.submitTx(params.accountAddress, params.quoteResponses.filter((quoteResponse) => quoteResponse !== null), params.isStxEnabled ?? false, params.quotesReceivedContext, params.location, params.abTests, params.activeAbTests, params.tokenSecurityTypeDestination, batchSellTrades);
|
|
933
|
+
return await this.submitTx(params.accountAddress, params.quoteResponses.filter((quoteResponse) => quoteResponse !== null), params.isStxEnabled ?? false, params.quotesReceivedContext, params.location, params.abTests, params.activeAbTests, params.tokenSecurityTypeDestination, batchSellTrades, undefined, params.migrationPhase);
|
|
934
934
|
};
|
|
935
935
|
_BridgeStatusController_trackPollingStatusUpdatedEvent.set(this, (historyKey, pollingStatus) => {
|
|
936
936
|
// Track polling status updated event
|
|
@@ -1016,19 +1016,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
1016
1016
|
const transactions = (0, transaction_js_1.getTransactions)(this.messenger);
|
|
1017
1017
|
const txMeta = transactions.find((tx) => tx.id === txHistoryKey);
|
|
1018
1018
|
const approvalTxMeta = transactions.find((tx) => tx.id === approvalTxId);
|
|
1019
|
-
const failedProperties = eventProperties;
|
|
1020
|
-
const historyHashPresence = (0, bridge_controller_1.getHashPresenceProperties)(historyItem.status.srcChain.txHash, historyItem.status.destChain?.txHash);
|
|
1021
|
-
const statusFailureTelemetry = (0, bridge_controller_1.getStatusFailureTelemetry)(historyItem.status.srcChain.txHash, historyItem.status.destChain?.txHash);
|
|
1022
|
-
const failedHashPresence = {
|
|
1023
|
-
source_hash_present: historyHashPresence.source_hash_present ||
|
|
1024
|
-
Boolean(failedProperties?.source_hash_present),
|
|
1025
|
-
destination_hash_present: historyHashPresence.destination_hash_present ||
|
|
1026
|
-
Boolean(failedProperties?.destination_hash_present),
|
|
1027
|
-
};
|
|
1028
|
-
const failedPhase = (0, bridge_controller_1.promoteFailurePhase)(failedProperties?.failure_phase ?? statusFailureTelemetry.failure_phase, failedHashPresence);
|
|
1029
|
-
const failedErrorCode = failedProperties?.failure_phase === undefined
|
|
1030
|
-
? statusFailureTelemetry.error_code
|
|
1031
|
-
: (failedProperties.error_code ?? bridge_controller_1.SwapBridgeErrorCode.Unknown);
|
|
1032
1019
|
const requiredEventProperties = {
|
|
1033
1020
|
...baseProperties,
|
|
1034
1021
|
...requestParamProperties,
|
|
@@ -1038,7 +1025,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
1038
1025
|
...(0, metrics_js_1.getFinalizedTxProperties)(historyItem, txMeta, approvalTxMeta),
|
|
1039
1026
|
...(0, metrics_js_1.getPriceImpactFromQuote)(quote),
|
|
1040
1027
|
...(eventName === bridge_controller_2.UnifiedSwapBridgeEventName.Completed && {
|
|
1041
|
-
...historyHashPresence,
|
|
1042
1028
|
...(!(0, bridge_controller_2.isNonEvmChainId)(historyItem.quote.srcChainId) &&
|
|
1043
1029
|
historyItem.txMetaId && {
|
|
1044
1030
|
transaction_internal_id: historyItem.txMetaId,
|
|
@@ -1047,12 +1033,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
1047
1033
|
input_primary_denomination: historyItem.inputPrimaryDenomination,
|
|
1048
1034
|
}),
|
|
1049
1035
|
}),
|
|
1050
|
-
...(eventName === bridge_controller_2.UnifiedSwapBridgeEventName.Failed && {
|
|
1051
|
-
...statusFailureTelemetry,
|
|
1052
|
-
...failedHashPresence,
|
|
1053
|
-
failure_phase: failedPhase,
|
|
1054
|
-
error_code: failedErrorCode,
|
|
1055
|
-
}),
|
|
1056
1036
|
};
|
|
1057
1037
|
(0, bridge_js_1.trackMetricsEvent)({
|
|
1058
1038
|
messenger: this.messenger,
|