Skip to content

Commit

Permalink
Stx controller version in query params (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
dan437 authored Nov 7, 2023
1 parent 684c8d9 commit 0682c61
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/SmartTransactionsController.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import nock from 'nock';
import { NetworkState } from '@metamask/network-controller';
import { convertHexToDecimal } from '@metamask/controller-utils';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import packageJson from '../package.json';

import SmartTransactionsController, {
DEFAULT_INTERVAL,
} from './SmartTransactionsController';
Expand Down Expand Up @@ -571,7 +575,9 @@ describe('SmartTransactionsController', () => {
const submitTransactionsApiResponse =
createSubmitTransactionsApiResponse(); // It has uuid.
nock(API_BASE_URL)
.post(`/networks/${ethereumChainIdDec}/submitTransactions`)
.post(
`/networks/${ethereumChainIdDec}/submitTransactions&stxControllerVersion=${packageJson.version}`,
)
.reply(200, submitTransactionsApiResponse);

await smartTransactionsController.submitSignedTransactions({
Expand Down
1 change: 1 addition & 0 deletions src/SmartTransactionsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { BigNumber } from 'bignumber.js';
import EthQuery from '@metamask/eth-query';
import { hexlify } from '@ethersproject/bytes';
import cloneDeep from 'lodash/cloneDeep';

import {
APIType,
SmartTransaction,
Expand Down
6 changes: 5 additions & 1 deletion src/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import packageJson from '../package.json';

import * as utils from './utils';
import {
SmartTransactionMinedTx,
Expand Down Expand Up @@ -43,7 +47,7 @@ describe('src/utils.js', () => {
expect(
utils.getAPIRequestURL(APIType.SUBMIT_TRANSACTIONS, CHAIN_IDS.ETHEREUM),
).toBe(
`${API_BASE_URL}/networks/${ethereumChainIdDec}/submitTransactions`,
`${API_BASE_URL}/networks/${ethereumChainIdDec}/submitTransactions&stxControllerVersion=${packageJson.version}`,
);
});

Expand Down
7 changes: 6 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import jsonDiffer from 'fast-json-patch';
import _ from 'lodash';
import { BigNumber } from 'bignumber.js';
import { hexlify } from '@ethersproject/bytes';

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import packageJson from '../package.json';

import {
APIType,
SmartTransaction,
Expand Down Expand Up @@ -34,7 +39,7 @@ export function getAPIRequestURL(apiType: APIType, chainId: string): string {
}

case APIType.SUBMIT_TRANSACTIONS: {
return `${API_BASE_URL}/networks/${chainIdDec}/submitTransactions`;
return `${API_BASE_URL}/networks/${chainIdDec}/submitTransactions&stxControllerVersion=${packageJson.version}`;
}

case APIType.CANCEL: {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"sourceMap": true,
"strict": true,
"target": "ES2017",
"skipLibCheck": true
"skipLibCheck": true,
"resolveJsonModule": true
},
"exclude": ["./src/**/*.test.ts"],
"include": ["./src/**/*.ts"]
Expand Down

0 comments on commit 0682c61

Please sign in to comment.