Skip to content

Commit c0b9f4e

Browse files
OttoAllmendingerllm-git
andcommitted
feat(wasm-utxo): remove unused code and variables
Clean up test files by removing unused functions, parameters and types. Add TypeScript compiler options to detect and prevent unused code. Issue: BTC-2786 Co-authored-by: llm-git <[email protected]>
1 parent e46fc22 commit c0b9f4e

File tree

6 files changed

+6
-21
lines changed

6 files changed

+6
-21
lines changed

packages/wasm-utxo/test/address/utxolibCompat.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import {
1515
const __filename = fileURLToPath(import.meta.url);
1616
const __dirname = dirname(__filename);
1717

18-
type Triple<T> = [T, T, T];
19-
2018
type Fixture = [type: string, script: string, address: string];
2119

2220
function getCoinNameForNetwork(name: string): CoinName {

packages/wasm-utxo/test/fixedScript/parseTransactionWithWalletKeys.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ describe("parseTransactionWithWalletKeys", function () {
2727
);
2828
});
2929

30-
function hasReplayProtection(network: utxolib.Network): boolean {
31-
const mainnet = utxolib.getMainnet(network);
32-
return mainnet === utxolib.networks.bitcoincash;
33-
}
34-
3530
supportedNetworks.forEach((network) => {
3631
const networkName = utxolib.getNetworkName(network);
3732

packages/wasm-utxo/test/psbt.util.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ import * as assert from "node:assert";
22
import * as utxolib from "@bitgo/utxo-lib";
33
import { Descriptor, Psbt } from "../js/index.js";
44

5-
function toAddress(descriptor: Descriptor, network: utxolib.Network) {
6-
utxolib.address.fromOutputScript(Buffer.from(descriptor.scriptPubkey()), network);
7-
}
8-
95
export function toWrappedPsbt(psbt: utxolib.bitgo.UtxoPsbt | utxolib.Psbt | Buffer | Uint8Array) {
106
if (psbt instanceof utxolib.bitgo.UtxoPsbt || psbt instanceof utxolib.Psbt) {
117
psbt = psbt.toBuffer();

packages/wasm-utxo/test/psbtFixedScriptCompatFixtures.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export function toPsbtWithPrevOutOnly(psbt: utxolib.bitgo.UtxoPsbt) {
1818
...(witnessUtxo ? { witnessUtxo } : { nonWitnessUtxo }),
1919
});
2020
});
21-
psbt.txOutputs.forEach((output, vout) => {
21+
psbt.txOutputs.forEach((output) => {
2222
psbtCopy.addOutput(output);
2323
});
2424
return psbtCopy;

packages/wasm-utxo/test/psbtFromDescriptor.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ function toKeyWithPath(k: BIP32Interface, path = "*"): string {
1111
return k.neutered().toBase58() + "/" + path;
1212
}
1313

14-
function toKeyPlain(k: Buffer): string {
15-
return k.toString("hex");
16-
}
17-
1814
function toECPair(k: BIP32Interface): ECPairInterface {
1915
assert(k.privateKey);
2016
return ECPair.fromPrivateKey(k.privateKey);
@@ -36,8 +32,6 @@ function getKeyName(k: BIP32Interface | ECPairInterface) {
3632
);
3733
}
3834

39-
type SigningKey = BIP32Interface | ECPairInterface;
40-
4135
function describeSignDescriptor(
4236
name: string,
4337
descriptor: Descriptor,
@@ -67,7 +61,7 @@ function describeSignDescriptor(
6761
};
6862
}
6963

70-
signBip32.forEach((signSeq, i) => {
64+
signBip32.forEach((signSeq) => {
7165
it(`should sign ${signSeq.map((k) => getKeyName(k))} xprv`, function () {
7266
const wrappedPsbt = toWrappedPsbt(psbt);
7367
signSeq.forEach((key) => {
@@ -92,7 +86,7 @@ function describeSignDescriptor(
9286
});
9387
});
9488

95-
signECPair.forEach((signSeq, i) => {
89+
signECPair.forEach((signSeq) => {
9690
it(`should sign ${signSeq.map((k) => getKeyName(k))} ec pair`, function () {
9791
const wrappedPsbt = toWrappedPsbt(psbt);
9892
signSeq.forEach((key) => {

packages/wasm-utxo/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
"declaration": true,
1010
"composite": true,
1111
"rootDir": ".",
12-
"outDir": "./dist/esm"
12+
"outDir": "./dist/esm",
13+
"noUnusedLocals": true,
14+
"noUnusedParameters": true
1315
},
1416
"include": ["./js/**/*.ts", "test/**/*.ts"],
1517
"exclude": ["node_modules", "./js/wasm/**/*"]

0 commit comments

Comments
 (0)