Skip to content

Commit f45a5c0

Browse files
refactor: add workspace knip
1 parent e70f67e commit f45a5c0

File tree

249 files changed

+314
-4264
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

249 files changed

+314
-4264
lines changed

.github/workflows/repo:code-checks.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ jobs:
7070
- name: lint-dependency-rules
7171
run: pnpm lint:filenames
7272

73+
knip:
74+
runs-on: ubuntu-24.04
75+
steps:
76+
- uses: actions/checkout@v4
77+
- uses: ./.github/actions/provision
78+
79+
- run: pnpm build
80+
81+
- name: knip
82+
run: pnpm knip
83+
7384
test-unit:
7485
runs-on: ubuntu-latest
7586
steps:

apps/extension/src/app/common/date-utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export function todaysIsoDate() {
1616
}
1717

1818
// Convert ISO date to locale date taking into account user timezone
19+
/** @knipignore */
1920
export function isoDateToLocalDate(isoDate: string): string {
2021
return dayjs.tz(isoDate).format('YYYY-MM-DD');
2122
}

apps/extension/src/app/common/stacks-utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export function validateAddressChain(address: string, currentNetwork: NetworkCon
7676
}
7777
}
7878

79+
/** @knipignore */
7980
export function isFtNameLikeStx(name: string) {
8081
return ['stx', 'stack', 'stacks'].includes(convertUnicodeToAscii(name).toLocaleLowerCase());
8182
}

apps/extension/src/app/common/transactions/stacks/transaction.utils.spec.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

apps/extension/src/app/common/transactions/stacks/transaction.utils.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@ import {
1717
createAddress,
1818
cvToString,
1919
deserializeMemoString,
20-
deserializeTransaction,
2120
isTokenTransferPayload,
2221
serializeCV,
2322
} from '@stacks/transactions';
2423
import { BigNumber } from 'bignumber.js';
25-
import z from 'zod';
2624

2725
import { StacksTx, StacksTxStatus } from '@leather.io/models';
2826
import { getStacksContractName } from '@leather.io/stacks';
@@ -204,17 +202,6 @@ export function getSip10MemoDisplayText(payload: ContractCallPayload) {
204202
return isSome ? deserializeMemoString(serializeCV(payload.functionArgs[3])).content : null;
205203
}
206204

207-
function isValidEncodedTransaction(tx: string | Uint8Array) {
208-
const [result, error] = safeCall(() => deserializeTransaction(tx));
209-
return !!result && !error;
210-
}
211-
212-
export const hexEncodedStacksTxSchema = z
213-
.string()
214-
.refine(value => isValidEncodedTransaction(value), {
215-
message: 'Invalid hex-encoded Stacks transaction',
216-
});
217-
218205
export function getContractAddressFromContractCallPayload(payload: ContractCallPayload) {
219206
const contractAddress = addressToString(payload.contractAddress);
220207
const contractName = payload.contractName.content;

apps/extension/src/app/common/utils.spec.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

apps/extension/src/app/common/utils.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,12 @@
11
import { toUnicode } from 'punycode';
22

3-
import { KEBAB_REGEX } from '@leather.io/constants';
4-
5-
function kebabCase(str: string) {
6-
return str.replace(KEBAB_REGEX, match => '-' + match.toLowerCase());
7-
}
8-
93
export function truncateString(str: string, maxLength: number) {
104
if (str.length <= maxLength) {
115
return str;
126
}
137
return str.slice(0, maxLength) + '…';
148
}
159

16-
function getLetters(string: string, offset = 1) {
17-
return string.slice(0, offset);
18-
}
19-
20-
export function getTicker(value: string) {
21-
let name = kebabCase(value);
22-
if (name.includes('-')) {
23-
const words = name.split('-');
24-
if (words.length >= 3) {
25-
name = `${getLetters(words[0])}${getLetters(words[1])}${getLetters(words[2])}`;
26-
} else {
27-
name = `${getLetters(words[0])}${getLetters(words[1], 2)}`;
28-
}
29-
} else if (name.length >= 3) {
30-
name = `${getLetters(name, 3)}`;
31-
}
32-
return name.toUpperCase();
33-
}
34-
3510
function isUtf8(buf?: Buffer | Uint8Array): boolean {
3611
if (!buf) {
3712
return false;
@@ -140,10 +115,6 @@ export function addPortSuffix(url: string) {
140115
return port ? `:${port}` : '';
141116
}
142117

143-
export function with0x(value: string): string {
144-
return !value.startsWith('0x') ? `0x${value}` : value;
145-
}
146-
147118
export function doesBrowserSupportWebUsbApi() {
148119
return Boolean((navigator as any).usb);
149120
}

apps/extension/src/app/common/validation/forms/fee-validators.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@ import BigNumber from 'bignumber.js';
22
import { AnyObject, NumberSchema } from 'yup';
33

44
import type { Money } from '@leather.io/models';
5-
import { btcToSat, isNumber, stxToMicroStx } from '@leather.io/utils';
5+
import { isNumber, stxToMicroStx } from '@leather.io/utils';
66

77
import { formatCurrency } from '@app/common/currency-formatter';
88
import { formatInsufficientBalanceError, formatPrecisionError } from '@app/common/error-formatters';
9-
import {
10-
btcAmountPrecisionValidator,
11-
stxAmountPrecisionValidator,
12-
} from '@app/common/validation/forms/currency-validators';
9+
import { stxAmountPrecisionValidator } from '@app/common/validation/forms/currency-validators';
1310

1411
interface FeeValidatorFactoryArgs {
1512
availableBalance?: Money;
@@ -30,15 +27,6 @@ function feeValidatorFactory({
3027
});
3128
}
3229

33-
// ts-unused-exports:disable-next-line
34-
export function btcFeeValidator(availableBalance?: Money) {
35-
return feeValidatorFactory({
36-
availableBalance,
37-
unitConverter: btcToSat,
38-
validator: btcAmountPrecisionValidator,
39-
});
40-
}
41-
4230
export function stxFeeValidator(availableBalance?: Money) {
4331
return feeValidatorFactory({
4432
availableBalance,

apps/extension/src/app/common/validation/validate-tx-id.spec.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.

apps/extension/src/app/common/validation/validate-tx-id.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)