Skip to content

Commit 5d3dea0

Browse files
committed
Fix ES linter warnings.
1 parent ef7caab commit 5d3dea0

11 files changed

+60
-24
lines changed

src/currency.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ export type Currency = string & {
66
readonly brand: unique symbol;
77
};
88

9-
// ignore duplicate
10-
// eslint-disable-next-line @typescript-eslint/no-redeclare
119
/** The `Currency` namespace contains predefined constants for tokens in the AlexSDK.*/
10+
// eslint-disable-next-line @typescript-eslint/no-redeclare
1211
export namespace Currency {
1312
/** Represents the `STX` token */
1413
export const STX = createCurrency('token-wstx');

src/helpers/FeeHelper.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import { unwrapResponse } from 'clarity-codegen';
22
import { readonlyCall } from '../utils/readonlyCallExecutor';
33
import type { Currency } from '../currency';
44
import type { PoolData } from '../types';
5-
import { type AMMRouteSegment, resolveAmmRoute } from '../utils/ammRouteResolver';
5+
import {
6+
type AMMRouteSegment,
7+
resolveAmmRoute,
8+
} from '../utils/ammRouteResolver';
69
import { hasLength } from '../utils/arrayHelper';
710

811
export async function getLiquidityProviderFee(

src/helpers/RateHelper.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import { unwrapResponse } from 'clarity-codegen';
22
import { readonlyCall } from '../utils/readonlyCallExecutor';
33
import type { Currency } from '../currency';
44
import type { PoolData } from '../types';
5-
import { type AMMRouteSegment, resolveAmmRoute } from '../utils/ammRouteResolver';
5+
import {
6+
type AMMRouteSegment,
7+
resolveAmmRoute,
8+
} from '../utils/ammRouteResolver';
69
import { hasLength } from '../utils/arrayHelper';
710

811
export const getYAmountFromXAmount = async (

src/helpers/RouteHelper.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import type { Currency } from '../currency';
22
import type { PoolData } from '../types';
3-
import { type AMMRouteSegment, resolveAmmRoute } from '../utils/ammRouteResolver';
3+
import {
4+
type AMMRouteSegment,
5+
resolveAmmRoute,
6+
} from '../utils/ammRouteResolver';
47

58
export async function getAllPossibleRoute(
69
from: Currency,

src/helpers/SwapHelper.ts

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ import { AlexContracts } from '../generated/smartContract/contracts_Alex';
1212
import { configs } from '../config';
1313
import type { Currency } from '../currency';
1414
import type { PoolData, TokenInfo } from '../types';
15-
import { type AMMRouteSegment, resolveAmmRoute } from '../utils/ammRouteResolver';
15+
import {
16+
type AMMRouteSegment,
17+
resolveAmmRoute,
18+
} from '../utils/ammRouteResolver';
1619
import { transferFactory } from '../utils/postConditions';
1720
import { hasLength } from '../utils/arrayHelper';
1821

@@ -38,7 +41,9 @@ const composeTx = <
3841
: never,
3942
postConditions: (FungiblePostCondition | StxPostCondition)[]
4043
): TxToBroadCast => {
41-
const functionDescriptor = AlexContracts[contractName][functionName] as OpenCallFunctionDescriptor;
44+
const functionDescriptor = AlexContracts[contractName][
45+
functionName
46+
] as OpenCallFunctionDescriptor;
4247
const clarityArgs = functionDescriptor.input.map((arg) =>
4348
arg.type.encode(args[arg.name])
4449
);
@@ -61,7 +66,8 @@ export function runSpot(
6166
mappings: TokenInfo[],
6267
customRoute?: AMMRouteSegment[]
6368
): TxToBroadCast {
64-
const ammRoute = customRoute ?? resolveAmmRoute(currencyX, currencyY, ammPools);
69+
const ammRoute =
70+
customRoute ?? resolveAmmRoute(currencyX, currencyY, ammPools);
6571
const getContractId = (currency: Currency) => {
6672
const mapping = mappings.find((x) => x.id === currency);
6773
if (!mapping) {
@@ -90,7 +96,12 @@ export function runSpot(
9096
},
9197
[
9298
transfer(stxAddress, currencyX, fromAmount),
93-
transfer(AlexVault, currencyY, minDy, FungibleConditionCode.GreaterEqual),
99+
transfer(
100+
AlexVault,
101+
currencyY,
102+
minDy,
103+
FungibleConditionCode.GreaterEqual
104+
),
94105
]
95106
);
96107
}
@@ -123,7 +134,12 @@ export function runSpot(
123134
BigInt(0),
124135
FungibleConditionCode.GreaterEqual
125136
),
126-
transfer(AlexVault, currencyY, minDy, FungibleConditionCode.GreaterEqual),
137+
transfer(
138+
AlexVault,
139+
currencyY,
140+
minDy,
141+
FungibleConditionCode.GreaterEqual
142+
),
127143
]
128144
);
129145
}
@@ -170,7 +186,12 @@ export function runSpot(
170186
BigInt(0),
171187
FungibleConditionCode.GreaterEqual
172188
),
173-
transfer(AlexVault, currencyY, minDy, FungibleConditionCode.GreaterEqual),
189+
transfer(
190+
AlexVault,
191+
currencyY,
192+
minDy,
193+
FungibleConditionCode.GreaterEqual
194+
),
174195
]
175196
);
176197
}
@@ -231,7 +252,12 @@ export function runSpot(
231252
BigInt(0),
232253
FungibleConditionCode.GreaterEqual
233254
),
234-
transfer(AlexVault, currencyY, minDy, FungibleConditionCode.GreaterEqual),
255+
transfer(
256+
AlexVault,
257+
currencyY,
258+
minDy,
259+
FungibleConditionCode.GreaterEqual
260+
),
235261
]
236262
);
237263
}

src/utils/arrayHelper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ export function hasLength<T>(x: T[], length: 4): x is [T, T, T, T];
66
export function hasLength<T>(x: T[], length: 5): x is [T, T, T, T, T];
77
export function hasLength<T>(x: T[], length: number): boolean {
88
return x.length === length;
9-
}
9+
}

src/utils/fetchData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export async function fetchBalanceForAccount(
9090
client: {
9191
...STACKS_MAINNET.client,
9292
baseUrl: configs.READONLY_CALL_API_HOST,
93-
}
93+
},
9494
},
9595
});
9696
const amount = unwrapResponse(

src/utils/postConditions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ export const transferFactory =
3838
const nativeAmount = (amount * BigInt(scale)) / BigInt(1e8);
3939

4040
// validate sender address
41-
addressToString(parsePrincipalString(senderAddress).address)
42-
41+
addressToString(parsePrincipalString(senderAddress).address);
42+
4343
if (currency === Currency.STX) {
4444
return {
4545
type: 'stx-postcondition',
@@ -50,8 +50,8 @@ export const transferFactory =
5050
}
5151

5252
// For rebase tokens, use GreaterEqual with amount 0
53-
const finalConditionCode = mapping.isRebaseToken
54-
? FungibleConditionCode.GreaterEqual
53+
const finalConditionCode = mapping.isRebaseToken
54+
? FungibleConditionCode.GreaterEqual
5555
: conditionCode;
5656
const finalAmount = mapping.isRebaseToken ? BigInt(0) : nativeAmount;
5757

src/utils/readonlyCallExecutor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const defaultReadonlyCallExecutor: ReadonlyCallExecutor = async (options) => {
3030
client: {
3131
...STACKS_MAINNET.client,
3232
baseUrl: configs.READONLY_CALL_API_HOST,
33-
}
33+
},
3434
},
3535
});
3636
};

test/alexSDK.mock-helpers.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
dummyTokenC,
2424
DUMMY_DEPLOYER,
2525
} from './mock-data/alexSDKMockResponses';
26-
import { cvToValue, FungibleConditionCode } from '@stacks/transactions';
26+
import { cvToValue } from '@stacks/transactions';
2727

2828
const sdk = new AlexSDK();
2929

@@ -134,9 +134,7 @@ describe('AlexSDK - mock helpers', () => {
134134
expect(cvToValue(result.functionArgs[3])).toStrictEqual(dummyFactorA);
135135
expect(cvToValue(result.functionArgs[4])).toStrictEqual(dummyFactorB);
136136
expect(cvToValue(result.functionArgs[5])).toStrictEqual(amount);
137-
expect(result.postConditions[0].condition).toStrictEqual(
138-
'gte'
139-
);
137+
expect(result.postConditions[0].condition).toStrictEqual('gte');
140138
expect(result.postConditions[0].amount).toStrictEqual(BigInt(0));
141139
});
142140

0 commit comments

Comments
 (0)