@metamask-previews/bridge-status-controller 68.1.0-preview-935b6049c → 68.1.0-preview-5d62ac60b
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 +4 -0
- package/dist/bridge-status-controller.cjs +27 -31
- package/dist/bridge-status-controller.cjs.map +1 -1
- package/dist/bridge-status-controller.d.cts.map +1 -1
- package/dist/bridge-status-controller.d.mts.map +1 -1
- package/dist/bridge-status-controller.intent.cjs +3 -6
- package/dist/bridge-status-controller.intent.cjs.map +1 -1
- package/dist/bridge-status-controller.intent.d.cts +4 -3
- package/dist/bridge-status-controller.intent.d.cts.map +1 -1
- package/dist/bridge-status-controller.intent.d.mts +4 -3
- package/dist/bridge-status-controller.intent.d.mts.map +1 -1
- package/dist/bridge-status-controller.intent.mjs +4 -7
- package/dist/bridge-status-controller.intent.mjs.map +1 -1
- package/dist/bridge-status-controller.mjs +27 -31
- package/dist/bridge-status-controller.mjs.map +1 -1
- package/dist/utils/bridge-status.cjs +2 -4
- package/dist/utils/bridge-status.cjs.map +1 -1
- package/dist/utils/bridge-status.d.cts.map +1 -1
- package/dist/utils/bridge-status.d.mts.map +1 -1
- package/dist/utils/bridge-status.mjs +2 -4
- package/dist/utils/bridge-status.mjs.map +1 -1
- package/dist/utils/intent-api.cjs +2 -2
- package/dist/utils/intent-api.cjs.map +1 -1
- package/dist/utils/intent-api.d.cts +8 -7
- package/dist/utils/intent-api.d.cts.map +1 -1
- package/dist/utils/intent-api.d.mts +8 -7
- package/dist/utils/intent-api.d.mts.map +1 -1
- package/dist/utils/intent-api.mjs +4 -4
- package/dist/utils/intent-api.mjs.map +1 -1
- package/dist/utils/validators.cjs +5 -5
- package/dist/utils/validators.cjs.map +1 -1
- package/dist/utils/validators.d.cts +5 -10
- package/dist/utils/validators.d.cts.map +1 -1
- package/dist/utils/validators.d.mts +5 -10
- package/dist/utils/validators.d.mts.map +1 -1
- package/dist/utils/validators.mjs +3 -3
- package/dist/utils/validators.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Added more unit test coverage for intents and EVM transactions. Also refactored some mocks and code blocks to improve testability ([#8186](https://github.com/MetaMask/core/pull/8186))
|
|
13
|
+
|
|
10
14
|
## [68.1.0]
|
|
11
15
|
|
|
12
16
|
### Added
|
|
@@ -246,7 +246,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
246
246
|
},
|
|
247
247
|
hasApprovalTx: Boolean(quoteResponse.approval),
|
|
248
248
|
approvalTxId,
|
|
249
|
-
isStxEnabled: isStxEnabled
|
|
249
|
+
isStxEnabled: Boolean(isStxEnabled),
|
|
250
250
|
featureId: quoteResponse.featureId,
|
|
251
251
|
location,
|
|
252
252
|
...(abTests && { abTests }),
|
|
@@ -382,9 +382,8 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
382
382
|
try {
|
|
383
383
|
let status;
|
|
384
384
|
let validationFailures = [];
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
const intentTxStatus = await __classPrivateFieldGet(this, _BridgeStatusController_intentManager, "f").getIntentTransactionStatus(bridgeTxMetaId, historyItem, __classPrivateFieldGet(this, _BridgeStatusController_clientId, "f"));
|
|
385
|
+
if (historyItem.quote.intent) {
|
|
386
|
+
const intentTxStatus = await __classPrivateFieldGet(this, _BridgeStatusController_intentManager, "f").getIntentTransactionStatus(bridgeTxMetaId, historyItem.quote.srcChainId, historyItem.quote.intent.protocol, __classPrivateFieldGet(this, _BridgeStatusController_clientId, "f"), historyItem.status.srcChain.txHash);
|
|
388
387
|
if (intentTxStatus?.bridgeStatus === null ||
|
|
389
388
|
intentTxStatus?.bridgeStatus === undefined) {
|
|
390
389
|
return;
|
|
@@ -429,7 +428,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
429
428
|
this.update((state) => {
|
|
430
429
|
state.txHistory[bridgeTxMetaId] = newBridgeHistoryItem;
|
|
431
430
|
});
|
|
432
|
-
if (
|
|
431
|
+
if (historyItem.quote.intent) {
|
|
433
432
|
__classPrivateFieldGet(this, _BridgeStatusController_intentManager, "f").syncTransactionFromIntentStatus(bridgeTxMetaId, historyItem);
|
|
434
433
|
}
|
|
435
434
|
// 5. After effects
|
|
@@ -563,7 +562,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
563
562
|
});
|
|
564
563
|
});
|
|
565
564
|
_BridgeStatusController_handleApprovalTx.set(this, async (isBridgeTx, srcChainId, approval, resetApproval, requireApproval) => {
|
|
566
|
-
if (approval) {
|
|
565
|
+
if (approval && (0, bridge_controller_1.isEvmTxData)(approval)) {
|
|
567
566
|
const approveTx = async () => {
|
|
568
567
|
await __classPrivateFieldGet(this, _BridgeStatusController_handleUSDTAllowanceReset, "f").call(this, resetApproval);
|
|
569
568
|
const approvalTxMeta = await __classPrivateFieldGet(this, _BridgeStatusController_handleEvmTransaction, "f").call(this, {
|
|
@@ -650,8 +649,8 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
650
649
|
// Convert to hex since txFee values from the quote are decimal strings
|
|
651
650
|
if (txFee) {
|
|
652
651
|
return {
|
|
653
|
-
maxFeePerGas: (0, controller_utils_1.toHex)(txFee.maxFeePerGas
|
|
654
|
-
maxPriorityFeePerGas: (0, controller_utils_1.toHex)(txFee.maxPriorityFeePerGas
|
|
652
|
+
maxFeePerGas: (0, controller_utils_1.toHex)(txFee.maxFeePerGas),
|
|
653
|
+
maxPriorityFeePerGas: (0, controller_utils_1.toHex)(txFee.maxPriorityFeePerGas),
|
|
655
654
|
gas: gas ? (0, controller_utils_1.toHex)(gas) : undefined,
|
|
656
655
|
};
|
|
657
656
|
}
|
|
@@ -755,7 +754,9 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
755
754
|
return quoteResponse.approval &&
|
|
756
755
|
(0, bridge_controller_1.isTronTrade)(quoteResponse.approval)
|
|
757
756
|
? await __classPrivateFieldGet(this, _BridgeStatusController_handleNonEvmTx, "f").call(this, quoteResponse.approval, quoteResponse, selectedAccount)
|
|
758
|
-
:
|
|
757
|
+
: /* c8 ignore start */
|
|
758
|
+
undefined;
|
|
759
|
+
/* c8 ignore end */
|
|
759
760
|
}
|
|
760
761
|
catch (error) {
|
|
761
762
|
!quoteResponse.featureId &&
|
|
@@ -789,7 +790,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
789
790
|
}
|
|
790
791
|
catch (error) {
|
|
791
792
|
!quoteResponse.featureId &&
|
|
792
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.Failed,
|
|
793
|
+
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.Failed, undefined, {
|
|
793
794
|
error_message: error?.message,
|
|
794
795
|
...preConfirmationProperties,
|
|
795
796
|
});
|
|
@@ -934,26 +935,21 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
934
935
|
const intent = (0, transaction_1.getIntentFromQuote)(quoteResponse);
|
|
935
936
|
// If backend provided an approval tx for this intent quote, submit it first (on-chain),
|
|
936
937
|
// then proceed with off-chain intent submission.
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
/* requireApproval */ false);
|
|
945
|
-
approvalTxId = approvalTxMeta?.id;
|
|
946
|
-
if (approvalTxId) {
|
|
947
|
-
await __classPrivateFieldGet(this, _BridgeStatusController_waitForTxConfirmation, "f").call(this, approvalTxId);
|
|
948
|
-
}
|
|
938
|
+
const isBridgeTx = (0, bridge_controller_1.isCrossChain)(quoteResponse.quote.srcChainId, quoteResponse.quote.destChainId);
|
|
939
|
+
const requireApproval = isHardwareAccount && __classPrivateFieldGet(this, _BridgeStatusController_clientId, "f") === types_1.BridgeClientId.MOBILE;
|
|
940
|
+
// Handle approval silently for better UX in intent flows
|
|
941
|
+
const approvalTxMeta = await __classPrivateFieldGet(this, _BridgeStatusController_handleApprovalTx, "f").call(this, isBridgeTx, quoteResponse.quote.srcChainId, quoteResponse.approval, quoteResponse.resetApproval, requireApproval);
|
|
942
|
+
const approvalTxId = approvalTxMeta?.id;
|
|
943
|
+
if (approvalTxId) {
|
|
944
|
+
await __classPrivateFieldGet(this, _BridgeStatusController_waitForTxConfirmation, "f").call(this, approvalTxId);
|
|
949
945
|
}
|
|
950
|
-
const { srcChainId
|
|
946
|
+
const { srcChainId, requestId } = quoteResponse.quote;
|
|
951
947
|
const signature = await this.messenger.call('KeyringController:signTypedMessage', {
|
|
952
948
|
from: accountAddress,
|
|
953
949
|
data: intent.typedData,
|
|
954
950
|
}, keyring_controller_1.SignTypedDataVersion.V4);
|
|
955
951
|
const submissionParams = {
|
|
956
|
-
srcChainId
|
|
952
|
+
srcChainId,
|
|
957
953
|
quoteId: requestId,
|
|
958
954
|
signature,
|
|
959
955
|
order: intent.order,
|
|
@@ -963,16 +959,17 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
963
959
|
const intentOrder = await __classPrivateFieldGet(this, _BridgeStatusController_intentManager, "f").submitIntent(submissionParams, __classPrivateFieldGet(this, _BridgeStatusController_clientId, "f"));
|
|
964
960
|
const orderUid = intentOrder.id;
|
|
965
961
|
// Determine transaction type: swap for same-chain, bridge for cross-chain
|
|
966
|
-
const
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
:
|
|
962
|
+
const transactionType = isBridgeTx
|
|
963
|
+
? /* c8 ignore start */
|
|
964
|
+
transaction_controller_1.TransactionType.bridge
|
|
965
|
+
: /* c8 ignore end */
|
|
966
|
+
transaction_controller_1.TransactionType.swap;
|
|
970
967
|
// Create actual transaction in Transaction Controller first
|
|
971
|
-
const networkClientId = this.messenger.call('NetworkController:findNetworkClientIdByChainId', (0, bridge_controller_1.formatChainIdToHex)(
|
|
968
|
+
const networkClientId = this.messenger.call('NetworkController:findNetworkClientIdByChainId', (0, bridge_controller_1.formatChainIdToHex)(srcChainId));
|
|
972
969
|
// This is a synthetic transaction whose purpose is to be able
|
|
973
970
|
// to track the order status via the history
|
|
974
971
|
const intentTransactionParams = {
|
|
975
|
-
chainId: (0, bridge_controller_1.formatChainIdToHex)(
|
|
972
|
+
chainId: (0, bridge_controller_1.formatChainIdToHex)(srcChainId),
|
|
976
973
|
from: accountAddress,
|
|
977
974
|
to: intent.settlementContract ??
|
|
978
975
|
'0x9008D19f58AAbd9eD0D60971565AA8510560ab41', // Default settlement contract
|
|
@@ -1002,7 +999,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
1002
999
|
...statusUpdatedTxMeta,
|
|
1003
1000
|
isIntentTx: true,
|
|
1004
1001
|
orderUid,
|
|
1005
|
-
intentType: isCrossChainTx ? 'bridge' : 'swap',
|
|
1006
1002
|
};
|
|
1007
1003
|
// Record in bridge history with actual transaction metadata
|
|
1008
1004
|
try {
|