Skip to content

Commit 0682c61

Browse files
authored
Stx controller version in query params (#227)
1 parent 684c8d9 commit 0682c61

5 files changed

+21
-4
lines changed

src/SmartTransactionsController.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import nock from 'nock';
22
import { NetworkState } from '@metamask/network-controller';
33
import { convertHexToDecimal } from '@metamask/controller-utils';
4+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
5+
// @ts-ignore
6+
import packageJson from '../package.json';
7+
48
import SmartTransactionsController, {
59
DEFAULT_INTERVAL,
610
} from './SmartTransactionsController';
@@ -571,7 +575,9 @@ describe('SmartTransactionsController', () => {
571575
const submitTransactionsApiResponse =
572576
createSubmitTransactionsApiResponse(); // It has uuid.
573577
nock(API_BASE_URL)
574-
.post(`/networks/${ethereumChainIdDec}/submitTransactions`)
578+
.post(
579+
`/networks/${ethereumChainIdDec}/submitTransactions&stxControllerVersion=${packageJson.version}`,
580+
)
575581
.reply(200, submitTransactionsApiResponse);
576582

577583
await smartTransactionsController.submitSignedTransactions({

src/SmartTransactionsController.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { BigNumber } from 'bignumber.js';
1010
import EthQuery from '@metamask/eth-query';
1111
import { hexlify } from '@ethersproject/bytes';
1212
import cloneDeep from 'lodash/cloneDeep';
13+
1314
import {
1415
APIType,
1516
SmartTransaction,

src/utils.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
2+
// @ts-ignore
3+
import packageJson from '../package.json';
4+
15
import * as utils from './utils';
26
import {
37
SmartTransactionMinedTx,
@@ -43,7 +47,7 @@ describe('src/utils.js', () => {
4347
expect(
4448
utils.getAPIRequestURL(APIType.SUBMIT_TRANSACTIONS, CHAIN_IDS.ETHEREUM),
4549
).toBe(
46-
`${API_BASE_URL}/networks/${ethereumChainIdDec}/submitTransactions`,
50+
`${API_BASE_URL}/networks/${ethereumChainIdDec}/submitTransactions&stxControllerVersion=${packageJson.version}`,
4751
);
4852
});
4953

src/utils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import jsonDiffer from 'fast-json-patch';
22
import _ from 'lodash';
33
import { BigNumber } from 'bignumber.js';
44
import { hexlify } from '@ethersproject/bytes';
5+
6+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
7+
// @ts-ignore
8+
import packageJson from '../package.json';
9+
510
import {
611
APIType,
712
SmartTransaction,
@@ -34,7 +39,7 @@ export function getAPIRequestURL(apiType: APIType, chainId: string): string {
3439
}
3540

3641
case APIType.SUBMIT_TRANSACTIONS: {
37-
return `${API_BASE_URL}/networks/${chainIdDec}/submitTransactions`;
42+
return `${API_BASE_URL}/networks/${chainIdDec}/submitTransactions&stxControllerVersion=${packageJson.version}`;
3843
}
3944

4045
case APIType.CANCEL: {

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"sourceMap": true,
1212
"strict": true,
1313
"target": "ES2017",
14-
"skipLibCheck": true
14+
"skipLibCheck": true,
15+
"resolveJsonModule": true
1516
},
1617
"exclude": ["./src/**/*.test.ts"],
1718
"include": ["./src/**/*.ts"]

0 commit comments

Comments
 (0)