Skip to content

Commit 4c70b63

Browse files
committed
fix(transaction-pay-controller): fix ESLint errors — JSDoc params, type param name, unused import, unnecessary casts
1 parent 551160b commit 4c70b63

4 files changed

Lines changed: 22 additions & 23 deletions

File tree

packages/transaction-pay-controller/src/strategy/fiat/utils.test.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ describe('Fiat Utils', () => {
246246
});
247247

248248
it('returns on-chain ERC-20 amount from receipt logs', async () => {
249-
(PROVIDER_MOCK.request as jest.Mock).mockResolvedValue({
249+
PROVIDER_MOCK.request.mockResolvedValue({
250250
logs: [
251251
{
252252
address: ERC20_ADDRESS_MOCK,
@@ -283,7 +283,7 @@ describe('Fiat Utils', () => {
283283
});
284284

285285
it('falls back to cryptoAmount when receipt is null', async () => {
286-
(PROVIDER_MOCK.request as jest.Mock).mockResolvedValue(null);
286+
PROVIDER_MOCK.request.mockResolvedValue(null);
287287

288288
const result = await resolveSourceAmountRaw({
289289
messenger: resolveMessenger,
@@ -296,9 +296,7 @@ describe('Fiat Utils', () => {
296296
});
297297

298298
it('falls back to cryptoAmount when on-chain read throws', async () => {
299-
(PROVIDER_MOCK.request as jest.Mock).mockRejectedValue(
300-
new Error('Network error'),
301-
);
299+
PROVIDER_MOCK.request.mockRejectedValue(new Error('Network error'));
302300

303301
const result = await resolveSourceAmountRaw({
304302
messenger: resolveMessenger,
@@ -311,7 +309,7 @@ describe('Fiat Utils', () => {
311309
});
312310

313311
it('returns native amount from debug_traceTransaction', async () => {
314-
(PROVIDER_MOCK.request as jest.Mock).mockResolvedValue({
312+
PROVIDER_MOCK.request.mockResolvedValue({
315313
to: WALLET_ADDRESS_MOCK.toLowerCase(),
316314
value: '0x1bc16d674ec80000',
317315
calls: [],
@@ -328,7 +326,7 @@ describe('Fiat Utils', () => {
328326
});
329327

330328
it('falls back to tx.value for native when trace is unsupported', async () => {
331-
(PROVIDER_MOCK.request as jest.Mock).mockImplementation(
329+
PROVIDER_MOCK.request.mockImplementation(
332330
({ method }: { method: string }) => {
333331
if (method === 'debug_traceTransaction') {
334332
return Promise.reject(new Error('Method not found'));

packages/transaction-pay-controller/src/utils/provider.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,20 @@ export function getNetworkClientId(
8686
* Send an RPC request to the network for the specified chain.
8787
*
8888
* @param request - Request parameters.
89-
* @returns The RPC response typed as `T`.
89+
* @param request.messenger - The TransactionPayController messenger.
90+
* @param request.chainId - The chain ID to resolve.
91+
* @param request.method - The JSON-RPC method name.
92+
* @param request.params - Optional parameters for the RPC call.
93+
* @param request.options - Resolution options forwarded to {@link getNetworkClientId}.
94+
* @returns The RPC response typed as `TResponse`.
9095
*/
91-
export async function rpcRequest<T = unknown>({
96+
export async function rpcRequest<TResponse = unknown>({
9297
messenger,
9398
chainId,
9499
method,
95100
params,
96101
options,
97-
}: RpcRequestParams): Promise<T> {
102+
}: RpcRequestParams): Promise<TResponse> {
98103
const networkClientId = getNetworkClientId(messenger, chainId, options);
99104

100105
const { provider } = messenger.call(
@@ -106,5 +111,5 @@ export async function rpcRequest<T = unknown>({
106111

107112
log(method, { params, response });
108113

109-
return response as T;
114+
return response as TResponse;
110115
}

packages/transaction-pay-controller/src/utils/token.test.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ describe('Token Utils', () => {
613613

614614
describe('getLiveTokenBalance', () => {
615615
it('returns ERC-20 balance via eth_call', async () => {
616-
(PROVIDER_MOCK.request as jest.Mock).mockResolvedValue('0x4C4B40');
616+
PROVIDER_MOCK.request.mockResolvedValue('0x4C4B40');
617617

618618
const result = await getLiveTokenBalance(
619619
messenger,
@@ -644,9 +644,7 @@ describe('Token Utils', () => {
644644
});
645645

646646
it('returns native balance via eth_getBalance', async () => {
647-
(PROVIDER_MOCK.request as jest.Mock).mockResolvedValue(
648-
'0xde0b6b3a7640000',
649-
);
647+
PROVIDER_MOCK.request.mockResolvedValue('0xde0b6b3a7640000');
650648

651649
const result = await getLiveTokenBalance(
652650
messenger,
@@ -663,9 +661,7 @@ describe('Token Utils', () => {
663661
});
664662

665663
it('returns native balance for polygon native address', async () => {
666-
(PROVIDER_MOCK.request as jest.Mock).mockResolvedValue(
667-
'0x1bc16d674ec80000',
668-
);
664+
PROVIDER_MOCK.request.mockResolvedValue('0x1bc16d674ec80000');
669665

670666
const result = await getLiveTokenBalance(
671667
messenger,
@@ -682,7 +678,7 @@ describe('Token Utils', () => {
682678
});
683679

684680
it('treats native address comparison as case-insensitive', async () => {
685-
(PROVIDER_MOCK.request as jest.Mock).mockResolvedValue('0x1f4');
681+
PROVIDER_MOCK.request.mockResolvedValue('0x1f4');
686682

687683
const result = await getLiveTokenBalance(
688684
messenger,
@@ -699,7 +695,7 @@ describe('Token Utils', () => {
699695
});
700696

701697
it('uses Infura network client when Infura endpoint is available', async () => {
702-
(PROVIDER_MOCK.request as jest.Mock).mockResolvedValue('0x895440');
698+
PROVIDER_MOCK.request.mockResolvedValue('0x895440');
703699

704700
getNetworkConfigurationByChainIdMock.mockReturnValue({
705701
rpcEndpoints: [
@@ -728,7 +724,7 @@ describe('Token Utils', () => {
728724
});
729725

730726
it('falls back to default network client when no Infura endpoint is configured', async () => {
731-
(PROVIDER_MOCK.request as jest.Mock).mockResolvedValue('0x6ACFC0');
727+
PROVIDER_MOCK.request.mockResolvedValue('0x6ACFC0');
732728

733729
getNetworkConfigurationByChainIdMock.mockReturnValue({
734730
rpcEndpoints: [
@@ -756,7 +752,7 @@ describe('Token Utils', () => {
756752
});
757753

758754
it('falls back to default network client when getNetworkConfigurationByChainId throws', async () => {
759-
(PROVIDER_MOCK.request as jest.Mock).mockResolvedValue('0x2DC6C0');
755+
PROVIDER_MOCK.request.mockResolvedValue('0x2DC6C0');
760756

761757
getNetworkConfigurationByChainIdMock.mockImplementation(() => {
762758
throw new Error('Network configuration not found');

packages/transaction-pay-controller/src/utils/transaction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import type {
1818
UpdateTransactionDataCallback,
1919
} from '../types';
2020
import { getAssetsUnifyStateFeature } from './feature-flags';
21-
import { getNetworkClientId, rpcRequest } from './provider';
21+
import { rpcRequest } from './provider';
2222
import { parseRequiredTokens } from './required-tokens';
2323
import { getNativeToken } from './token';
2424

0 commit comments

Comments
 (0)