-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: cross chain swaps - tx status - BridgeStatusController (#28636)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> This PR is a collection of all the background related code from #27740 (no UI changes). It has been split up in order to make it easier to review. A follow up PR containing all the UI changes from #27740 is here: #28657 The main addition is the `BridgeStatusController` and its supporting code. If you would like to test the functionality of this PR through the UI, please do so through #27740. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28636?quickstart=1) ## **Related issues** Branched off from #27740 ## **Manual testing steps** Refer to #27740 ## **Screenshots/Recordings** Refer to #27740 ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
- Loading branch information
1 parent
dadeac9
commit 8773328
Showing
16 changed files
with
2,011 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
213 changes: 213 additions & 0 deletions
213
app/scripts/controllers/bridge-status/__snapshots__/bridge-status-controller.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,213 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`BridgeStatusController constructor rehydrates the tx history state 1`] = ` | ||
{ | ||
"0xsrcTxHash1": { | ||
"account": "0xaccount1", | ||
"estimatedProcessingTimeInSeconds": 15, | ||
"initialDestAssetBalance": undefined, | ||
"pricingData": undefined, | ||
"quote": { | ||
"bridgeId": "lifi", | ||
"bridges": [ | ||
"across", | ||
], | ||
"destAsset": { | ||
"address": "0x0000000000000000000000000000000000000000", | ||
"chainId": 10, | ||
"coinKey": "ETH", | ||
"decimals": 18, | ||
"icon": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png", | ||
"logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png", | ||
"name": "ETH", | ||
"priceUSD": "2478.63", | ||
"symbol": "ETH", | ||
}, | ||
"destChainId": 10, | ||
"destTokenAmount": "990654755978612", | ||
"feeData": { | ||
"metabridge": { | ||
"amount": "8750000000000", | ||
"asset": { | ||
"address": "0x0000000000000000000000000000000000000000", | ||
"chainId": 42161, | ||
"coinKey": "ETH", | ||
"decimals": 18, | ||
"icon": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png", | ||
"logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png", | ||
"name": "ETH", | ||
"priceUSD": "2478.7", | ||
"symbol": "ETH", | ||
}, | ||
}, | ||
}, | ||
"requestId": "197c402f-cb96-4096-9f8c-54aed84ca776", | ||
"srcAsset": { | ||
"address": "0x0000000000000000000000000000000000000000", | ||
"chainId": 42161, | ||
"coinKey": "ETH", | ||
"decimals": 18, | ||
"icon": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png", | ||
"logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png", | ||
"name": "ETH", | ||
"priceUSD": "2478.7", | ||
"symbol": "ETH", | ||
}, | ||
"srcChainId": 42161, | ||
"srcTokenAmount": "991250000000000", | ||
"steps": [ | ||
{ | ||
"action": "bridge", | ||
"destAmount": "990654755978612", | ||
"destAsset": { | ||
"address": "0x0000000000000000000000000000000000000000", | ||
"chainId": 10, | ||
"coinKey": "ETH", | ||
"decimals": 18, | ||
"icon": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png", | ||
"logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png", | ||
"name": "ETH", | ||
"priceUSD": "2478.63", | ||
"symbol": "ETH", | ||
}, | ||
"destChainId": 10, | ||
"protocol": { | ||
"displayName": "Across", | ||
"icon": "https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/bridges/acrossv2.png", | ||
"name": "across", | ||
}, | ||
"srcAmount": "991250000000000", | ||
"srcAsset": { | ||
"address": "0x0000000000000000000000000000000000000000", | ||
"chainId": 42161, | ||
"coinKey": "ETH", | ||
"decimals": 18, | ||
"icon": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png", | ||
"logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png", | ||
"name": "ETH", | ||
"priceUSD": "2478.7", | ||
"symbol": "ETH", | ||
}, | ||
"srcChainId": 42161, | ||
}, | ||
], | ||
}, | ||
"slippagePercentage": 0, | ||
"startTime": 1729964825189, | ||
"status": { | ||
"srcChain": { | ||
"chainId": 42161, | ||
"txHash": "0xsrcTxHash1", | ||
}, | ||
"status": "PENDING", | ||
}, | ||
"targetContractAddress": "0x23981fC34e69eeDFE2BD9a0a9fCb0719Fe09DbFC", | ||
}, | ||
} | ||
`; | ||
|
||
exports[`BridgeStatusController startPollingForBridgeTxStatus sets the inital tx history state 1`] = ` | ||
{ | ||
"0xsrcTxHash1": { | ||
"account": "0xaccount1", | ||
"estimatedProcessingTimeInSeconds": 15, | ||
"initialDestAssetBalance": undefined, | ||
"pricingData": undefined, | ||
"quote": { | ||
"bridgeId": "lifi", | ||
"bridges": [ | ||
"across", | ||
], | ||
"destAsset": { | ||
"address": "0x0000000000000000000000000000000000000000", | ||
"chainId": 10, | ||
"coinKey": "ETH", | ||
"decimals": 18, | ||
"icon": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png", | ||
"logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png", | ||
"name": "ETH", | ||
"priceUSD": "2478.63", | ||
"symbol": "ETH", | ||
}, | ||
"destChainId": 10, | ||
"destTokenAmount": "990654755978612", | ||
"feeData": { | ||
"metabridge": { | ||
"amount": "8750000000000", | ||
"asset": { | ||
"address": "0x0000000000000000000000000000000000000000", | ||
"chainId": 42161, | ||
"coinKey": "ETH", | ||
"decimals": 18, | ||
"icon": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png", | ||
"logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png", | ||
"name": "ETH", | ||
"priceUSD": "2478.7", | ||
"symbol": "ETH", | ||
}, | ||
}, | ||
}, | ||
"requestId": "197c402f-cb96-4096-9f8c-54aed84ca776", | ||
"srcAsset": { | ||
"address": "0x0000000000000000000000000000000000000000", | ||
"chainId": 42161, | ||
"coinKey": "ETH", | ||
"decimals": 18, | ||
"icon": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png", | ||
"logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png", | ||
"name": "ETH", | ||
"priceUSD": "2478.7", | ||
"symbol": "ETH", | ||
}, | ||
"srcChainId": 42161, | ||
"srcTokenAmount": "991250000000000", | ||
"steps": [ | ||
{ | ||
"action": "bridge", | ||
"destAmount": "990654755978612", | ||
"destAsset": { | ||
"address": "0x0000000000000000000000000000000000000000", | ||
"chainId": 10, | ||
"coinKey": "ETH", | ||
"decimals": 18, | ||
"icon": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png", | ||
"logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png", | ||
"name": "ETH", | ||
"priceUSD": "2478.63", | ||
"symbol": "ETH", | ||
}, | ||
"destChainId": 10, | ||
"protocol": { | ||
"displayName": "Across", | ||
"icon": "https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/bridges/acrossv2.png", | ||
"name": "across", | ||
}, | ||
"srcAmount": "991250000000000", | ||
"srcAsset": { | ||
"address": "0x0000000000000000000000000000000000000000", | ||
"chainId": 42161, | ||
"coinKey": "ETH", | ||
"decimals": 18, | ||
"icon": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png", | ||
"logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png", | ||
"name": "ETH", | ||
"priceUSD": "2478.7", | ||
"symbol": "ETH", | ||
}, | ||
"srcChainId": 42161, | ||
}, | ||
], | ||
}, | ||
"slippagePercentage": 0, | ||
"startTime": 1729964825189, | ||
"status": { | ||
"srcChain": { | ||
"chainId": 42161, | ||
"txHash": "0xsrcTxHash1", | ||
}, | ||
"status": "PENDING", | ||
}, | ||
"targetContractAddress": "0x23981fC34e69eeDFE2BD9a0a9fCb0719Fe09DbFC", | ||
}, | ||
} | ||
`; |
Oops, something went wrong.