Skip to content
Open
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
4 changes: 4 additions & 0 deletions packages/transaction-pay-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Add route-based `confirmations_pay` strategy resolution ([#8282](https://github.com/MetaMask/core/pull/8282))

## [19.0.0]

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,45 @@ describe('TransactionPayController', () => {
),
).toBe(TransactionPayStrategy.Test);
});

it('passes payment token route args into feature flag fallback', async () => {
const controller = createController();

controller.updatePaymentToken({
transactionId: TRANSACTION_ID_MOCK,
tokenAddress: TOKEN_ADDRESS_MOCK,
chainId: CHAIN_ID_MOCK,
});

const { updateTransactionData } = updatePaymentTokenMock.mock.calls[0][1];

updateTransactionData(TRANSACTION_ID_MOCK, (data) => {
data.paymentToken = {
address: TOKEN_ADDRESS_MOCK,
balanceFiat: '1',
balanceHuman: '1',
balanceRaw: '1',
balanceUsd: '1',
chainId: CHAIN_ID_MOCK,
decimals: 6,
symbol: 'USDC',
};
});

const transactionMeta = {
id: TRANSACTION_ID_MOCK,
type: 'perpsDeposit',
} as TransactionMeta;

messenger.call('TransactionPayController:getStrategy', transactionMeta);

expect(getStrategyOrderMock).toHaveBeenCalledWith(
messenger,
CHAIN_ID_MOCK,
TOKEN_ADDRESS_MOCK,
'perpsDeposit',
);
});
});

describe('transaction data update', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,18 @@ export class TransactionPayController extends BaseController<
isTransactionPayStrategy(strategy),
);

return validStrategies.length
? validStrategies
: getStrategyOrder(this.messenger);
if (validStrategies.length) {
return validStrategies;
}

const paymentToken =
this.state.transactionData[transaction.id]?.paymentToken;

return getStrategyOrder(
this.messenger,
paymentToken?.chainId,
paymentToken?.address,
transaction.type,
);
}
}
Loading
Loading