Skip to content

Commit

Permalink
refactor(abstract-utxo): rename AbstractUtxoCoinWallet to UtxoWallet
Browse files Browse the repository at this point in the history
Issue: BTC-1450
  • Loading branch information
OttoAllmendinger committed Dec 13, 2024
1 parent 7cf4410 commit c590792
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 20 deletions.
6 changes: 3 additions & 3 deletions modules/abstract-utxo/src/abstractUtxoCoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ import { CustomChangeOptions } from './transaction/fixedScript';
import { toBip32Triple, UtxoKeychain, UtxoNamedKeychains } from './keychains';
import { verifyKeySignature, verifyUserPublicKey } from './verifyKey';
import { getPolicyForEnv } from './descriptor/validatePolicy';
import { AbstractUtxoCoinWallet } from './wallet';
import { UtxoWallet } from './wallet';

const debug = debugLib('bitgo:v2:utxo');

Expand Down Expand Up @@ -201,7 +201,7 @@ export interface TransactionParams extends BaseTransactionParams {
export interface ParseTransactionOptions<TNumber extends number | bigint = number> extends BaseParseTransactionOptions {
txParams: TransactionParams;
txPrebuild: TransactionPrebuild<TNumber>;
wallet: AbstractUtxoCoinWallet;
wallet: UtxoWallet;
verification?: VerificationOptions;
reqId?: IRequestTracer;
}
Expand Down Expand Up @@ -329,7 +329,7 @@ export interface VerifyTransactionOptions<TNumber extends number | bigint = numb
extends BaseVerifyTransactionOptions {
txPrebuild: TransactionPrebuild<TNumber>;
txParams: TransactionParams;
wallet: AbstractUtxoCoinWallet;
wallet: UtxoWallet;
}

export interface SignPsbtRequest {
Expand Down
6 changes: 3 additions & 3 deletions modules/abstract-utxo/src/descriptor/descriptorWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IWallet, WalletCoinSpecific } from '@bitgo/sdk-core';
import { NamedDescriptor } from './NamedDescriptor';
import { DescriptorMap } from '../core/descriptor';
import { DescriptorValidationPolicy, KeyTriple, toDescriptorMapValidate } from './validatePolicy';
import { AbstractUtxoCoinWalletData } from '../wallet';
import { UtxoWalletData } from '../wallet';

type DescriptorWalletCoinSpecific = {
descriptors: NamedDescriptor[];
Expand All @@ -16,15 +16,15 @@ function isDescriptorWalletCoinSpecific(obj: unknown): obj is DescriptorWalletCo
);
}

type DescriptorWalletData = AbstractUtxoCoinWalletData & {
type DescriptorWalletData = UtxoWalletData & {
coinSpecific: DescriptorWalletCoinSpecific;
};

interface IDescriptorWallet extends IWallet {
coinSpecific(): WalletCoinSpecific & DescriptorWalletCoinSpecific;
}

export function isDescriptorWalletData(obj: AbstractUtxoCoinWalletData): obj is DescriptorWalletData {
export function isDescriptorWalletData(obj: UtxoWalletData): obj is DescriptorWalletData {
return isDescriptorWalletCoinSpecific(obj.coinSpecific);
}

Expand Down
1 change: 1 addition & 0 deletions modules/abstract-utxo/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export * from './recovery';
export * from './replayProtection';
export * from './sign';

export { UtxoWallet } from './wallet';
export * as descriptor from './descriptor';
6 changes: 3 additions & 3 deletions modules/abstract-utxo/src/wallet.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Wallet, WalletData } from '@bitgo/sdk-core';

// parseTransactions' return type makes use of WalletData's type but with customChangeKeySignatures as required.
export interface AbstractUtxoCoinWalletData extends WalletData {
export interface UtxoWalletData extends WalletData {
customChangeKeySignatures: {
user: string;
backup: string;
bitgo: string;
};
}

export interface AbstractUtxoCoinWallet extends Wallet {
_wallet: AbstractUtxoCoinWalletData;
export interface UtxoWallet extends Wallet {
_wallet: UtxoWalletData;
}
6 changes: 3 additions & 3 deletions modules/abstract-utxo/test/descriptor/descriptorWallet.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import assert from 'assert';
import { getDescriptorMapFromWallet, isDescriptorWallet } from '../../src/descriptor';
import { AbstractUtxoCoinWallet } from '../../src/wallet';
import { UtxoWallet } from '../../src/wallet';
import { getDefaultXPubs, getDescriptorMap } from '../core/descriptor/descriptor.utils';
import { toBip32Triple } from '../../src/keychains';

describe('isDescriptorWalletData', function () {
const descriptorMap = getDescriptorMap('Wsh2Of3');
it('should return true for valid DescriptorWalletData', function () {
const wallet: AbstractUtxoCoinWallet = {
const wallet: UtxoWallet = {
coinSpecific() {
return {
descriptors: [...descriptorMap.entries()].map(([name, descriptor]) => ({
Expand All @@ -16,7 +16,7 @@ describe('isDescriptorWalletData', function () {
})),
};
},
} as unknown as AbstractUtxoCoinWallet;
} as unknown as UtxoWallet;

assert(isDescriptorWallet(wallet));
assert.strictEqual(
Expand Down
10 changes: 2 additions & 8 deletions modules/bitgo/test/v2/unit/coins/abstractUtxoCoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@ import * as sinon from 'sinon';
import { Wallet, UnexpectedAddressError, VerificationOptions } from '@bitgo/sdk-core';
import { TestBitGo } from '@bitgo/sdk-test';
import { BitGo } from '../../../../src/bitgo';
import {
AbstractUtxoCoin,
AbstractUtxoCoinWallet,
Output,
TransactionExplanation,
TransactionParams,
} from '@bitgo/abstract-utxo';
import { AbstractUtxoCoin, UtxoWallet, Output, TransactionExplanation, TransactionParams } from '@bitgo/abstract-utxo';

describe('Abstract UTXO Coin:', () => {
describe('Parse Transaction:', () => {
Expand Down Expand Up @@ -60,7 +54,7 @@ describe('Abstract UTXO Coin:', () => {
const parsedTransaction = await coin.parseTransaction({
txParams,
txPrebuild: { txHex: '' },
wallet: wallet as unknown as AbstractUtxoCoinWallet,
wallet: wallet as unknown as UtxoWallet,
verification,
});

Expand Down

0 comments on commit c590792

Please sign in to comment.