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
2 changes: 1 addition & 1 deletion eslint-suppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2073,7 +2073,7 @@
"count": 4
},
"no-restricted-syntax": {
"count": 4
"count": 3
}
},
"packages/smart-transactions-controller/src/featureFlags/feature-flags.ts": {
Expand Down
4 changes: 4 additions & 0 deletions packages/smart-transactions-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Bump `@metamask/remote-feature-flag-controller` from `^6.0.0` to `^6.1.0` ([#9980](https://github.com/MetaMask/core/pull/9980))

### Removed

- Remove `API_BASE_URL` export and STX migration feature flags (`stxMigrationGetFees`, `stxMigrationSubmitTransactions`, `stxMigrationCancel`, `stxMigrationBatchStatus`) — all API calls now always route to the sentinel API ([#9996](https://github.com/MetaMask/core/pull/9996))

## [25.1.1]

### Changed
Expand Down
6 changes: 3 additions & 3 deletions packages/smart-transactions-controller/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ module.exports = merge(baseConfig, {
coverageThreshold: {
global: {
branches: 87.88,
functions: 97.32,
lines: 95.35,
statements: 95.33,
functions: 97.27,
lines: 95.23,
statements: 95.22,
},
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
getFakeProvider,
} from '../tests/helpers.js';
import {
API_BASE_URL,
SENTINEL_API_BASE_URL_MAP,
SmartTransactionsTraceName,
} from './constants.js';
Expand Down Expand Up @@ -1096,8 +1095,8 @@ describe('SmartTransactionsController', () => {
const tradeTx = createUnsignedTransaction(ethereumChainIdDec);
const approvalTx = createUnsignedTransaction(ethereumChainIdDec);
const getFeesApiResponse = createGetFeesApiResponse();
nock(API_BASE_URL)
.post(`/networks/${ethereumChainIdDec}/getFees`)
nock(SENTINEL_API_BASE_URL_MAP[ethereumChainIdDec])
.post(`/v1/networks/${ethereumChainIdDec}/getFees`)
.reply(200, getFeesApiResponse);

const fees = await controller.getFees(tradeTx, approvalTx);
Expand All @@ -1123,8 +1122,8 @@ describe('SmartTransactionsController', () => {
const tradeTx = createUnsignedTransaction(ethereumChainIdDec);
const approvalTx = createUnsignedTransaction(ethereumChainIdDec);
const getFeesApiResponse = createGetFeesApiResponse();
nock(API_BASE_URL)
.post(`/networks/${ethereumChainIdDec}/getFees`)
nock(SENTINEL_API_BASE_URL_MAP[ethereumChainIdDec])
.post(`/v1/networks/${ethereumChainIdDec}/getFees`)
.reply(200, getFeesApiResponse);

const fees = await controller.getFees(tradeTx, approvalTx);
Expand All @@ -1142,8 +1141,8 @@ describe('SmartTransactionsController', () => {
createUnsignedTransaction(ethereumChainIdDec);
tradeTx.nonce = undefined;
const getFeesApiResponse = createGetFeesApiResponse();
nock(API_BASE_URL)
.post(`/networks/${ethereumChainIdDec}/getFees`)
nock(SENTINEL_API_BASE_URL_MAP[ethereumChainIdDec])
.post(`/v1/networks/${ethereumChainIdDec}/getFees`)
.reply(200, getFeesApiResponse);

const fees = await controller.getFees(tradeTx);
Expand All @@ -1159,8 +1158,8 @@ describe('SmartTransactionsController', () => {
const tradeTx = createUnsignedTransaction(sepoliaChainIdDec);
const approvalTx = createUnsignedTransaction(sepoliaChainIdDec);
const getFeesApiResponse = createGetFeesApiResponse();
nock(API_BASE_URL)
.post(`/networks/${sepoliaChainIdDec}/getFees`)
nock(SENTINEL_API_BASE_URL_MAP[sepoliaChainIdDec])
.post(`/v1/networks/${sepoliaChainIdDec}/getFees`)
.reply(200, getFeesApiResponse);

expect(
Expand Down Expand Up @@ -1203,9 +1202,9 @@ describe('SmartTransactionsController', () => {
const signedCanceledTransaction = createSignedCanceledTransaction();
const submitTransactionsApiResponse =
createSubmitTransactionsApiResponse(); // It has uuid.
nock(API_BASE_URL)
nock(SENTINEL_API_BASE_URL_MAP[ethereumChainIdDec])
.post(
`/networks/${ethereumChainIdDec}/submitTransactions?stxControllerVersion=${packageJson.version}`,
`/v1/networks/${ethereumChainIdDec}/submitTransactions?stxControllerVersion=${packageJson.version}`,
)
.reply(200, submitTransactionsApiResponse);

Expand Down Expand Up @@ -1248,16 +1247,16 @@ describe('SmartTransactionsController', () => {
createSubmitTransactionsApiResponse();

// First API mock for the case without nonce
nock(API_BASE_URL)
nock(SENTINEL_API_BASE_URL_MAP[ethereumChainIdDec])
.post(
`/networks/${ethereumChainIdDec}/submitTransactions?stxControllerVersion=${packageJson.version}`,
`/v1/networks/${ethereumChainIdDec}/submitTransactions?stxControllerVersion=${packageJson.version}`,
)
.reply(200, submitTransactionsApiResponse);

// Second API mock for the case with nonce
nock(API_BASE_URL)
nock(SENTINEL_API_BASE_URL_MAP[ethereumChainIdDec])
.post(
`/networks/${ethereumChainIdDec}/submitTransactions?stxControllerVersion=${packageJson.version}`,
`/v1/networks/${ethereumChainIdDec}/submitTransactions?stxControllerVersion=${packageJson.version}`,
)
.reply(200, submitTransactionsApiResponse);

Expand Down Expand Up @@ -1313,9 +1312,9 @@ describe('SmartTransactionsController', () => {
const signedTransaction = createSignedTransaction();
const submitTransactionsApiResponse =
createSubmitTransactionsApiResponse();
nock(API_BASE_URL)
nock(SENTINEL_API_BASE_URL_MAP[ethereumChainIdDec])
.post(
`/networks/${ethereumChainIdDec}/submitTransactions?stxControllerVersion=${packageJson.version}`,
`/v1/networks/${ethereumChainIdDec}/submitTransactions?stxControllerVersion=${packageJson.version}`,
)
.reply(200, submitTransactionsApiResponse);

Expand Down Expand Up @@ -1368,9 +1367,9 @@ describe('SmartTransactionsController', () => {
const signedTransaction = createSignedTransaction();
const submitTransactionsApiResponse =
createSubmitTransactionsApiResponse();
nock(API_BASE_URL)
nock(SENTINEL_API_BASE_URL_MAP[ethereumChainIdDec])
.post(
`/networks/${ethereumChainIdDec}/submitTransactions?stxControllerVersion=${packageJson.version}`,
`/v1/networks/${ethereumChainIdDec}/submitTransactions?stxControllerVersion=${packageJson.version}`,
)
.reply(200, submitTransactionsApiResponse);

Expand Down Expand Up @@ -1407,9 +1406,9 @@ describe('SmartTransactionsController', () => {
const signedTransaction2 = createSignedTransaction();
const submitTransactionsApiResponse =
createSubmitTransactionsApiResponse(); // It has uuid.
nock(API_BASE_URL)
nock(SENTINEL_API_BASE_URL_MAP[ethereumChainIdDec])
.post(
`/networks/${ethereumChainIdDec}/submitTransactions?stxControllerVersion=${packageJson.version}`,
`/v1/networks/${ethereumChainIdDec}/submitTransactions?stxControllerVersion=${packageJson.version}`,
)
.reply(200, submitTransactionsApiResponse);

Expand Down Expand Up @@ -1447,9 +1446,9 @@ describe('SmartTransactionsController', () => {

// Verify that the request body has empty rawCancelTxs array when signedCanceledTransactions is omitted
let requestBody: any;
nock(API_BASE_URL)
nock(SENTINEL_API_BASE_URL_MAP[ethereumChainIdDec])
.post(
`/networks/${ethereumChainIdDec}/submitTransactions?stxControllerVersion=${packageJson.version}`,
`/v1/networks/${ethereumChainIdDec}/submitTransactions?stxControllerVersion=${packageJson.version}`,
(body) => {
requestBody = body;
return true;
Expand Down Expand Up @@ -1485,9 +1484,9 @@ describe('SmartTransactionsController', () => {
];

let requestBody: any;
nock(API_BASE_URL)
nock(SENTINEL_API_BASE_URL_MAP[ethereumChainIdDec])
.post(
`/networks/${ethereumChainIdDec}/submitTransactions?stxControllerVersion=${packageJson.version}`,
`/v1/networks/${ethereumChainIdDec}/submitTransactions?stxControllerVersion=${packageJson.version}`,
(body) => {
requestBody = body;
return true;
Expand Down Expand Up @@ -1516,9 +1515,9 @@ describe('SmartTransactionsController', () => {
createSubmitTransactionsApiResponse();

let requestBody: any;
nock(API_BASE_URL)
nock(SENTINEL_API_BASE_URL_MAP[ethereumChainIdDec])
.post(
`/networks/${ethereumChainIdDec}/submitTransactions?stxControllerVersion=${packageJson.version}`,
`/v1/networks/${ethereumChainIdDec}/submitTransactions?stxControllerVersion=${packageJson.version}`,
(body) => {
requestBody = body;
return true;
Expand All @@ -1544,9 +1543,9 @@ describe('SmartTransactionsController', () => {
const submitTransactionsApiResponse =
createSubmitTransactionsApiResponse();

nock(API_BASE_URL)
nock(SENTINEL_API_BASE_URL_MAP[ethereumChainIdDec])
.post(
`/networks/${ethereumChainIdDec}/submitTransactions?stxControllerVersion=${packageJson.version}`,
`/v1/networks/${ethereumChainIdDec}/submitTransactions?stxControllerVersion=${packageJson.version}`,
)
.reply(200, submitTransactionsApiResponse);

Expand Down Expand Up @@ -1582,8 +1581,8 @@ describe('SmartTransactionsController', () => {
const uuids = ['uuid1'];
const pendingBatchStatusApiResponse =
createPendingBatchStatusApiResponse();
nock(API_BASE_URL)
.get(`/networks/${ethereumChainIdDec}/batchStatus?uuids=uuid1`)
nock(SENTINEL_API_BASE_URL_MAP[ethereumChainIdDec])
.get(`/v1/networks/${ethereumChainIdDec}/batchStatus?uuids=uuid1`)
.reply(200, pendingBatchStatusApiResponse);

const params = uuids.map((uuid) => ({
Expand Down Expand Up @@ -1646,8 +1645,8 @@ describe('SmartTransactionsController', () => {
const uuids = ['uuid2'];
const successBatchStatusApiResponse =
createSuccessBatchStatusApiResponse();
nock(API_BASE_URL)
.get(`/networks/${ethereumChainIdDec}/batchStatus?uuids=uuid2`)
nock(SENTINEL_API_BASE_URL_MAP[ethereumChainIdDec])
.get(`/v1/networks/${ethereumChainIdDec}/batchStatus?uuids=uuid2`)
.reply(200, successBatchStatusApiResponse);

const params = uuids.map((uuid) => ({
Expand Down Expand Up @@ -2150,8 +2149,8 @@ describe('SmartTransactionsController', () => {
describe('cancelSmartTransaction', () => {
it('sends POST call to Transactions API', async () => {
await withController(async ({ controller }) => {
const apiCall = nock(API_BASE_URL)
.post(`/networks/${ethereumChainIdDec}/cancel`)
const apiCall = nock(SENTINEL_API_BASE_URL_MAP[ethereumChainIdDec])
.post(`/v1/networks/${ethereumChainIdDec}/cancel`)
.reply(200, { message: 'successful' });

await controller.cancelSmartTransaction('uuid1');
Expand All @@ -2167,8 +2166,8 @@ describe('SmartTransactionsController', () => {
bearerToken,
},
async ({ controller }) => {
const apiCall = nock(API_BASE_URL)
.post(`/networks/${ethereumChainIdDec}/cancel`)
const apiCall = nock(SENTINEL_API_BASE_URL_MAP[ethereumChainIdDec])
.post(`/v1/networks/${ethereumChainIdDec}/cancel`)
.matchHeader('Authorization', `Bearer ${bearerToken}`)
.reply(200, { message: 'successful' });

Expand Down Expand Up @@ -2414,7 +2413,7 @@ describe('SmartTransactionsController', () => {

expect(handleFetchSpy).toHaveBeenNthCalledWith(
1,
`${API_BASE_URL}/networks/${convertHexToDecimal(
`${SENTINEL_API_BASE_URL_MAP[ethereumChainIdDec]}/v1/networks/${convertHexToDecimal(
ChainId.mainnet,
)}/batchStatus?uuids=uuid1`,
fetchHeaders,
Expand All @@ -2424,7 +2423,7 @@ describe('SmartTransactionsController', () => {

expect(handleFetchSpy).toHaveBeenNthCalledWith(
2,
`${API_BASE_URL}/networks/${convertHexToDecimal(
`${SENTINEL_API_BASE_URL_MAP[ethereumChainIdDec]}/v1/networks/${convertHexToDecimal(
ChainId.mainnet,
)}/batchStatus?uuids=uuid1`,
fetchHeaders,
Expand All @@ -2435,7 +2434,7 @@ describe('SmartTransactionsController', () => {

expect(handleFetchSpy).toHaveBeenNthCalledWith(
3,
`${API_BASE_URL}/networks/${convertHexToDecimal(
`${SENTINEL_API_BASE_URL_MAP[sepoliaChainIdDec]}/v1/networks/${convertHexToDecimal(
ChainId.sepolia,
)}/batchStatus?uuids=uuid2`,
fetchHeaders,
Expand All @@ -2445,7 +2444,7 @@ describe('SmartTransactionsController', () => {

expect(handleFetchSpy).toHaveBeenNthCalledWith(
5,
`${API_BASE_URL}/networks/${convertHexToDecimal(
`${SENTINEL_API_BASE_URL_MAP[sepoliaChainIdDec]}/v1/networks/${convertHexToDecimal(
ChainId.sepolia,
)}/batchStatus?uuids=uuid2`,
fetchHeaders,
Expand All @@ -2462,15 +2461,15 @@ describe('SmartTransactionsController', () => {
// check that the mainnet polling has stopped while the sepolia polling continues
expect(handleFetchSpy).toHaveBeenNthCalledWith(
6,
`${API_BASE_URL}/networks/${convertHexToDecimal(
`${SENTINEL_API_BASE_URL_MAP[sepoliaChainIdDec]}/v1/networks/${convertHexToDecimal(
ChainId.sepolia,
)}/batchStatus?uuids=uuid2`,
fetchHeaders,
);

expect(handleFetchSpy).toHaveBeenNthCalledWith(
7,
`${API_BASE_URL}/networks/${convertHexToDecimal(
`${SENTINEL_API_BASE_URL_MAP[sepoliaChainIdDec]}/v1/networks/${convertHexToDecimal(
ChainId.sepolia,
)}/batchStatus?uuids=uuid2`,
fetchHeaders,
Expand Down Expand Up @@ -2897,9 +2896,8 @@ describe('SmartTransactionsController', () => {
},
},
async ({ controller }) => {
const apiUrl = API_BASE_URL;
nock(apiUrl)
.post(`/networks/${ethereumChainIdDec}/getFees`)
nock(SENTINEL_API_BASE_URL_MAP[ethereumChainIdDec])
.post(`/v1/networks/${ethereumChainIdDec}/getFees`)
.reply(200, createGetFeesApiResponse());

const tradeTx = createUnsignedTransaction(ethereumChainIdDec);
Expand All @@ -2923,10 +2921,9 @@ describe('SmartTransactionsController', () => {
},
},
async ({ controller }) => {
const apiUrl = API_BASE_URL;
nock(apiUrl)
nock(SENTINEL_API_BASE_URL_MAP[ethereumChainIdDec])
.post(
`/networks/${ethereumChainIdDec}/submitTransactions?stxControllerVersion=${packageJson.version}`,
`/v1/networks/${ethereumChainIdDec}/submitTransactions?stxControllerVersion=${packageJson.version}`,
)
.reply(200, createSubmitTransactionsApiResponse());

Expand Down Expand Up @@ -2958,9 +2955,8 @@ describe('SmartTransactionsController', () => {
},
},
async ({ controller }) => {
const apiUrl = API_BASE_URL;
nock(apiUrl)
.post(`/networks/${ethereumChainIdDec}/cancel`)
nock(SENTINEL_API_BASE_URL_MAP[ethereumChainIdDec])
.post(`/v1/networks/${ethereumChainIdDec}/cancel`)
.reply(200, {});

await controller.cancelSmartTransaction('uuid1');
Expand Down Expand Up @@ -3007,10 +3003,9 @@ describe('SmartTransactionsController', () => {
},
},
async ({ controller }) => {
const apiUrl = API_BASE_URL;
const expectedResponse = createGetFeesApiResponse();
nock(apiUrl)
.post(`/networks/${ethereumChainIdDec}/getFees`)
nock(SENTINEL_API_BASE_URL_MAP[ethereumChainIdDec])
.post(`/v1/networks/${ethereumChainIdDec}/getFees`)
.reply(200, expectedResponse);

const tradeTx = createUnsignedTransaction(ethereumChainIdDec);
Expand Down
Loading