Skip to content

Commit 7d4ca04

Browse files
refactor(abstract-utxo): drop DescriptorMap/SignerKey/sumValues from wasmUtil
Move the DescriptorMap type alias to descriptor/index.ts (the natural location), inline SignerKey at its single call site, and inline the sumValues one-liner at the two explainPsbt/parse call sites. Refs: T1-3279
1 parent d68cfc4 commit 7d4ca04

6 files changed

Lines changed: 13 additions & 7 deletions

File tree

modules/abstract-utxo/src/descriptor/descriptorWallet.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import * as t from 'io-ts';
22
import { IWallet, WalletCoinSpecific } from '@bitgo/sdk-core';
33

44
import { UtxoWallet, UtxoWalletData } from '../wallet';
5-
import type { DescriptorMap } from '../wasmUtil';
65

76
import { NamedDescriptor } from './NamedDescriptor';
87
import { DescriptorValidationPolicy, KeyTriple, toDescriptorMapValidate } from './validatePolicy';
98

9+
import type { DescriptorMap } from './index';
10+
1011
type DescriptorWalletCoinSpecific = {
1112
descriptors: NamedDescriptor[];
1213
};

modules/abstract-utxo/src/descriptor/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import type { descriptorWallet } from '@bitgo/wasm-utxo';
2+
13
export { Miniscript, Descriptor } from '@bitgo/wasm-utxo';
2-
export type { DescriptorMap } from '../wasmUtil';
4+
export type DescriptorMap = descriptorWallet.DescriptorMap;
35
export { assertDescriptorWalletAddress } from './assertDescriptorWalletAddress';
46
export {
57
NamedDescriptor,

modules/abstract-utxo/src/descriptor/validatePolicy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { EnvironmentName, Triple } from '@bitgo/sdk-core';
22
import { bip32, descriptorWallet } from '@bitgo/wasm-utxo';
33

4-
import type { DescriptorMap } from '../wasmUtil';
5-
64
import { parseDescriptor } from './builder';
75
import { hasValidSignature, NamedDescriptor, NamedDescriptorNative, toNamedDescriptorNative } from './NamedDescriptor';
86

7+
import type { DescriptorMap } from './index';
8+
99
export type KeyTriple = Triple<bip32.BIP32Interface>;
1010

1111
export interface DescriptorValidationPolicy {

modules/abstract-utxo/src/transaction/descriptor/explainPsbt.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { Psbt, descriptorWallet } from '@bitgo/wasm-utxo';
33

44
import type { TransactionExplanationDescriptor } from '../fixedScript/explainTransaction';
55
import { UtxoCoinName } from '../../names';
6-
import { sumValues } from '../../wasmUtil';
6+
7+
function sumValues(arr: { value: bigint }[]): bigint {
8+
return arr.reduce((sum, e) => sum + e.value, 0n);
9+
}
710

811
function toRecipient(output: descriptorWallet.ParsedOutput, coinName: UtxoCoinName): ITransactionRecipient {
912
const address = output.address ?? `scriptPubKey:${Buffer.from(output.script).toString('hex')}`;

modules/abstract-utxo/src/transaction/descriptor/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export type { DescriptorMap } from '../../wasmUtil';
1+
export type { DescriptorMap } from '../../descriptor';
22
export { explainPsbt } from './explainPsbt';
33
export { parse } from './parse';
44
export { parseToAmountType } from './parseToAmountType';

modules/abstract-utxo/src/transaction/descriptor/signPsbt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Psbt, descriptorWallet } from '@bitgo/wasm-utxo';
22

3-
import type { SignerKey } from '../../wasmUtil';
3+
type SignerKey = Parameters<typeof descriptorWallet.signWithKey>[1];
44

55
export class ErrorUnknownInput extends Error {
66
constructor(public vin: number) {

0 commit comments

Comments
 (0)