Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/bridge-status-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Bump `@metamask/bridge-controller` dependency to `^11.0.0` ([#5525](https://github.com/MetaMask/core/pull/5525))
- **BREAKING:** Change controller to fetch multichain address instead of EVM ([#5554](https://github.com/MetaMask/core/pull/5540))

## [10.0.0]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ const getMessengerMock = ({
} = {}) =>
({
call: jest.fn((method: string) => {
if (method === 'AccountsController:getSelectedAccount') {
if (method === 'AccountsController:getSelectedMultichainAccount') {
return { address: account };
} else if (method === 'NetworkController:findNetworkClientIdByChainId') {
return 'networkClientId';
Expand Down Expand Up @@ -572,7 +572,7 @@ describe('BridgeStatusController', () => {

const messengerMock = {
call: jest.fn((method: string) => {
if (method === 'AccountsController:getSelectedAccount') {
if (method === 'AccountsController:getSelectedMultichainAccount') {
return { address: '0xaccount1' };
} else if (
method === 'NetworkController:findNetworkClientIdByChainId'
Expand Down Expand Up @@ -730,7 +730,7 @@ describe('BridgeStatusController', () => {

const messengerMock = {
call: jest.fn((method: string) => {
if (method === 'AccountsController:getSelectedAccount') {
if (method === 'AccountsController:getSelectedMultichainAccount') {
return { address: '0xaccount1' };
} else if (
method === 'NetworkController:findNetworkClientIdByChainId'
Expand Down Expand Up @@ -812,18 +812,18 @@ describe('BridgeStatusController', () => {
// Setup
jest.useFakeTimers();

let getSelectedAccountCalledTimes = 0;
let getSelectedMultichainAccountCalledTimes = 0;
const messengerMock = {
call: jest.fn((method: string) => {
if (method === 'AccountsController:getSelectedAccount') {
if (method === 'AccountsController:getSelectedMultichainAccount') {
let account;

if (getSelectedAccountCalledTimes === 0) {
if (getSelectedMultichainAccountCalledTimes === 0) {
account = '0xaccount1';
} else {
account = '0xaccount2';
}
getSelectedAccountCalledTimes += 1;
getSelectedMultichainAccountCalledTimes += 1;
return { address: account };
} else if (
method === 'NetworkController:findNetworkClientIdByChainId'
Expand Down Expand Up @@ -905,7 +905,7 @@ describe('BridgeStatusController', () => {
jest.useFakeTimers();
const messengerMock = {
call: jest.fn((method: string) => {
if (method === 'AccountsController:getSelectedAccount') {
if (method === 'AccountsController:getSelectedMultichainAccount') {
return { address: '0xaccount1' };
} else if (
method === 'NetworkController:findNetworkClientIdByChainId'
Expand Down Expand Up @@ -1001,7 +1001,7 @@ describe('BridgeStatusController', () => {
jest.useFakeTimers();
const messengerMock = {
call: jest.fn((method: string) => {
if (method === 'AccountsController:getSelectedAccount') {
if (method === 'AccountsController:getSelectedMultichainAccount') {
return { address: '0xaccount1' };
} else if (
method === 'NetworkController:findNetworkClientIdByChainId'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ export class BridgeStatusController extends StaticIntervalPollingController<Brid
initialDestAssetBalance,
targetContractAddress,
} = startPollingForBridgeTxStatusArgs;
const { address: account } = this.#getSelectedAccount();

const accountAddress = this.#getMultichainSelectedAccountAddress();
// Write all non-status fields to state so we can reference the quote in Activity list without the Bridge API
// We know it's in progress but not the exact status yet
const txHistoryItem = {
Expand All @@ -195,7 +194,7 @@ export class BridgeStatusController extends StaticIntervalPollingController<Brid
},
initialDestAssetBalance,
targetContractAddress,
account,
account: accountAddress,
status: {
// We always have a PENDING status when we start polling for a tx, don't need the Bridge API for that
// Also we know the bare minimum fields for status at this point in time
Expand Down Expand Up @@ -223,8 +222,12 @@ export class BridgeStatusController extends StaticIntervalPollingController<Brid
await this.#fetchBridgeTxStatus(pollingInput);
};

#getSelectedAccount() {
return this.messagingSystem.call('AccountsController:getSelectedAccount');
#getMultichainSelectedAccountAddress() {
return (
this.messagingSystem.call(
'AccountsController:getSelectedMultichainAccount',
)?.address ?? ''
);
}

readonly #fetchBridgeTxStatus = async ({
Expand Down
4 changes: 2 additions & 2 deletions packages/bridge-status-controller/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AccountsControllerGetSelectedAccountAction } from '@metamask/accounts-controller';
import type { AccountsControllerGetSelectedMultichainAccountAction } from '@metamask/accounts-controller';
import type {
ControllerGetStateAction,
ControllerStateChangeEvent,
Expand Down Expand Up @@ -310,7 +310,7 @@ type AllowedActions =
| NetworkControllerFindNetworkClientIdByChainIdAction
| NetworkControllerGetStateAction
| NetworkControllerGetNetworkClientByIdAction
| AccountsControllerGetSelectedAccountAction
| AccountsControllerGetSelectedMultichainAccountAction
| TransactionControllerGetStateAction;

/**
Expand Down
Loading