Skip to content

Commit 3ae0b1b

Browse files
committed
fix: remove purpose from BaseWallet
1 parent 3848952 commit 3ae0b1b

Some content is hidden

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

42 files changed

+63
-114
lines changed

packages/e2e/src/factories.ts

+4-7
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import {
3131
CommunicationType,
3232
InMemoryKeyAgent,
3333
KeyAgentDependencies,
34-
KeyPurpose,
3534
Witnesser,
3635
util
3736
} from '@cardano-sdk/key-management';
@@ -281,7 +280,6 @@ export type GetWalletProps = {
281280
env: any;
282281
idx?: number;
283282
logger: Logger;
284-
purpose: KeyPurpose;
285283
name: string;
286284
polling?: PollingConfig;
287285
handlePolicyIds?: Cardano.PolicyId[];
@@ -295,7 +293,6 @@ export type GetSharedWalletProps = {
295293
env: any;
296294
logger: Logger;
297295
name: string;
298-
purpose: KeyPurpose;
299296
polling?: PollingConfig;
300297
handlePolicyIds?: Cardano.PolicyId[];
301298
stores?: storage.WalletStores;
@@ -327,7 +324,7 @@ const patchInitializeTxToRespectEpochBoundary = <T extends ObservableWallet>(
327324
* @returns an object containing the wallet and providers passed to it
328325
*/
329326
export const getWallet = async (props: GetWalletProps) => {
330-
const { env, idx, logger, name, stores, customKeyParams, keyAgent, witnesser, purpose } = props;
327+
const { env, idx, logger, name, stores, customKeyParams, keyAgent, witnesser } = props;
331328
let polling = props.polling;
332329
const providers = {
333330
addressDiscovery: await addressDiscoveryFactory.create(
@@ -384,7 +381,7 @@ export const getWallet = async (props: GetWalletProps) => {
384381
}
385382

386383
const wallet = createPersonalWallet(
387-
{ name, polling, purpose },
384+
{ name, polling },
388385
{
389386
...providers,
390387
bip32Account,
@@ -411,7 +408,7 @@ export const getWallet = async (props: GetWalletProps) => {
411408
* @returns an object containing the wallet and providers passed to it
412409
*/
413410
export const getSharedWallet = async (props: GetSharedWalletProps) => {
414-
const { env, logger, name, polling, stores, paymentScript, stakingScript, witnesser, purpose } = props;
411+
const { env, logger, name, polling, stores, paymentScript, stakingScript, witnesser } = props;
415412
const providers = {
416413
assetProvider: await assetProviderFactory.create(env.ASSET_PROVIDER, env.ASSET_PROVIDER_PARAMS, logger),
417414
chainHistoryProvider: await chainHistoryProviderFactory.create(
@@ -439,7 +436,7 @@ export const getSharedWallet = async (props: GetSharedWalletProps) => {
439436
utxoProvider: await utxoProviderFactory.create(env.UTXO_PROVIDER, env.UTXO_PROVIDER_PARAMS, logger)
440437
};
441438
const wallet = createSharedWallet(
442-
{ name, polling, purpose },
439+
{ name, polling },
443440
{
444441
...providers,
445442
logger,

packages/e2e/src/tools/multi-delegation-data-gen/utils/utils.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable no-console, max-statements, max-params, @typescript-eslint/no-floating-promises */
22
import { Cardano } from '@cardano-sdk/core';
3-
import { KeyPurpose, util } from '@cardano-sdk/key-management';
43
import { logger } from '@cardano-sdk/util-dev';
4+
import { util } from '@cardano-sdk/key-management';
55

66
import { BaseWallet } from '@cardano-sdk/wallet';
77
import { Files, Paths } from './files';
@@ -102,8 +102,7 @@ export const waitForFundingWallet = async (monitor: TerminalProgressMonitor): Pr
102102
idx: 0,
103103
logger,
104104
name: 'Funding wallet',
105-
polling: { interval: 500 },
106-
purpose: KeyPurpose.STANDARD
105+
polling: { interval: 500 }
107106
})
108107
).wallet;
109108

@@ -140,8 +139,7 @@ export const createDelegationWallet = async (monitor: TerminalProgressMonitor) =
140139
idx: 0,
141140
logger,
142141
name: 'Delegation Wallet',
143-
polling: { interval: 500 },
144-
purpose: KeyPurpose.STANDARD
142+
polling: { interval: 500 }
145143
})
146144
).wallet;
147145
};

packages/e2e/test/artillery/wallet-restoration/WalletRestoration.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ export const walletRestoration: FunctionHook<WalletVars> = async ({ vars, _uid }
100100
keyAgent,
101101
logger,
102102
name: `Test Wallet of VU with id: ${_uid}`,
103-
polling: { interval: 50 },
104-
purpose: KeyPurpose.STANDARD
103+
polling: { interval: 50 }
105104
});
106105

107106
vars.currentWallet = wallet;

packages/e2e/test/load-test-custom/wallet-init/wallet-init.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable import/imports-first */
22
import * as dotenv from 'dotenv';
33
import { BaseWallet, createPersonalWallet } from '@cardano-sdk/wallet';
4-
import { Bip32Account, KeyPurpose, util } from '@cardano-sdk/key-management';
4+
import { Bip32Account, util } from '@cardano-sdk/key-management';
55
import { Logger } from 'ts-log';
66
import {
77
MeasurementUtil,
@@ -83,7 +83,7 @@ const createWallet = async (accountIndex: number): Promise<BaseWallet> => {
8383

8484
measurementUtil.addStartMarker(MeasureTarget.wallet, accountIndex);
8585
return createPersonalWallet(
86-
{ name: `Wallet ${accountIndex}`, purpose: KeyPurpose.STANDARD },
86+
{ name: `Wallet ${accountIndex}` },
8787
{
8888
...providers,
8989
bip32Account: await Bip32Account.fromAsyncKeyAgent(keyAgent),

packages/e2e/test/load-test-custom/wallet-restoration/wallet-restoration.test.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import path from 'path';
55
dotenv.config({ path: path.join(__dirname, '../../../.env') });
66
import { BaseWallet } from '@cardano-sdk/wallet';
77
import { Cardano } from '@cardano-sdk/core';
8-
import { GroupedAddress, KeyPurpose, util } from '@cardano-sdk/key-management';
8+
import { GroupedAddress, util } from '@cardano-sdk/key-management';
99
import { Logger } from 'ts-log';
1010
import { MINUTE, createMockKeyAgent, getEnv, getWallet, waitForWalletStateSettle, walletVariables } from '../../../src';
1111
import { logger } from '@cardano-sdk/util-dev';
@@ -48,8 +48,7 @@ const initWallets = async (walletsNum: number, addresses: GroupedAddress[]): Pro
4848
keyAgent,
4949
logger,
5050
name: 'Test Wallet',
51-
polling: { interval: 50 },
52-
purpose: KeyPurpose.STANDARD
51+
polling: { interval: 50 }
5352
});
5453
wallets.push(wallet);
5554
}

packages/e2e/test/local-network/register-pool.test.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { firstValueFrom } from 'rxjs';
1616
import { logger } from '@cardano-sdk/util-dev';
1717

1818
import * as Crypto from '@cardano-sdk/crypto';
19-
import { AddressType, KeyPurpose, KeyRole } from '@cardano-sdk/key-management';
19+
import { AddressType, KeyRole } from '@cardano-sdk/key-management';
2020

2121
const env = getEnv(walletVariables);
2222

@@ -54,17 +54,15 @@ describe('local-network/register-pool', () => {
5454
idx: 0,
5555
logger,
5656
name: 'Pool Wallet 1',
57-
polling: { interval: 500 },
58-
purpose: KeyPurpose.STANDARD
57+
polling: { interval: 500 }
5958
});
6059
wallet2 = await getWallet({
6160
customKeyParams: wallet2Params,
6261
env,
6362
idx: 0,
6463
logger,
6564
name: 'Pool Wallet 2',
66-
polling: { interval: 500 },
67-
purpose: KeyPurpose.STANDARD
65+
polling: { interval: 500 }
6866
});
6967

7068
await waitForWalletStateSettle(wallet1.wallet);

packages/e2e/test/long-running/cache-invalidation.test.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as Crypto from '@cardano-sdk/crypto';
2-
import { AddressType, KeyPurpose, KeyRole } from '@cardano-sdk/key-management';
2+
import { AddressType, KeyRole } from '@cardano-sdk/key-management';
33
import { Cardano } from '@cardano-sdk/core';
44
import {
55
KeyAgentFactoryProps,
@@ -89,8 +89,7 @@ describe('cache invalidation', () => {
8989
idx: 0,
9090
logger,
9191
name: 'Pool Wallet 1',
92-
polling: { interval: 500 },
93-
purpose: KeyPurpose.STANDARD
92+
polling: { interval: 500 }
9493
});
9594

9695
await waitForWalletStateSettle(wallet1.wallet);

packages/e2e/test/long-running/multisig-wallet/multisig-delegation-rewards.test.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ describe('multi signature wallet', () => {
136136
env,
137137
logger,
138138
name: 'Faucet Wallet',
139-
polling: { interval: 50 },
140-
purpose: KeyPurpose.MULTI_SIG
139+
polling: { interval: 50 }
141140
}));
142141

143142
await walletReady(faucetWallet);

packages/e2e/test/long-running/shared-wallet-delegation-rewards.test.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { BaseWallet } from '@cardano-sdk/wallet';
22
import { Cardano, StakePoolProvider } from '@cardano-sdk/core';
3-
import { KeyPurpose } from '@cardano-sdk/key-management';
43
import { buildSharedWallets } from '../wallet_epoch_0/SharedWallet/utils';
54
import { filter, firstValueFrom, map, take } from 'rxjs';
65
import {
@@ -102,7 +101,7 @@ describe('shared wallet delegation rewards', () => {
102101
({
103102
wallet: faucetWallet,
104103
providers: { stakePoolProvider }
105-
} = await getWallet({ env, logger, name: 'Sending Wallet', purpose: KeyPurpose.MULTI_SIG }));
104+
} = await getWallet({ env, logger, name: 'Sending Wallet' }));
106105

107106
// Make sure the wallet has sufficient funds to run this test
108107
await walletReady(faucetWallet, initialFunds);

packages/e2e/test/long-running/simple-delegation-rewards.test.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { BaseWallet } from '@cardano-sdk/wallet';
22
import { Cardano, StakePoolProvider } from '@cardano-sdk/core';
3-
import { KeyPurpose } from '@cardano-sdk/key-management';
43
import {
54
TestWallet,
65
getEnv,
@@ -86,10 +85,9 @@ describe('simple delegation rewards', () => {
8685
env,
8786
logger,
8887
name: 'Sending Wallet',
89-
polling: { interval: 50 },
90-
purpose: KeyPurpose.STANDARD
88+
polling: { interval: 50 }
9189
}));
92-
({ wallet: wallet2 } = await getWallet({ env, logger, name: 'Receiving Wallet', purpose: KeyPurpose.STANDARD }));
90+
({ wallet: wallet2 } = await getWallet({ env, logger, name: 'Receiving Wallet' }));
9391

9492
await waitForWalletStateSettle(wallet1);
9593
await waitForWalletStateSettle(wallet2);

packages/e2e/test/wallet_epoch_0/PersonalWallet/byron.test.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* eslint-disable sonarjs/no-duplicate-string */
22
import { BaseWallet } from '@cardano-sdk/wallet';
33
import { Cardano } from '@cardano-sdk/core';
4-
import { KeyPurpose } from '@cardano-sdk/key-management';
54
import { createLogger } from '@cardano-sdk/util-dev';
65
import { filter, firstValueFrom, map, take } from 'rxjs';
76
import { getEnv, walletVariables } from '../../../src/environment';
@@ -15,7 +14,7 @@ describe('PersonalWallet/byron', () => {
1514
let wallet: BaseWallet;
1615

1716
beforeAll(async () => {
18-
wallet = (await getWallet({ env, idx: 0, logger, name: 'Wallet', purpose: KeyPurpose.STANDARD })).wallet;
17+
wallet = (await getWallet({ env, idx: 0, logger, name: 'Wallet' })).wallet;
1918
});
2019

2120
afterAll(() => {

packages/e2e/test/wallet_epoch_0/PersonalWallet/handle.test.ts

+4-8
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ describe('Ada handle', () => {
4444
const coins = coinsRequiredByHandleMint + 10_000_000n; // maximum number of coins to use in each transaction
4545

4646
const initPolicyId = async () => {
47-
wallet = (await getWallet({ env, idx: 0, logger, name: 'Handle Init Wallet', purpose: KeyPurpose.STANDARD }))
48-
.wallet;
47+
wallet = (await getWallet({ env, idx: 0, logger, name: 'Handle Init Wallet' })).wallet;
4948
await walletReady(wallet, coins);
5049

5150
keyAgent = await createStandaloneKeyAgent(
@@ -71,8 +70,7 @@ describe('Ada handle', () => {
7170
idx: 0,
7271
logger,
7372
name: 'Minting Wallet',
74-
polling: { interval: 50 },
75-
purpose: KeyPurpose.STANDARD
73+
polling: { interval: 50 }
7674
})
7775
).wallet;
7876
await walletReady(wallet, coins);
@@ -87,8 +85,7 @@ describe('Ada handle', () => {
8785
idx: 0,
8886
logger,
8987
name: 'Minting Wallet',
90-
polling: { interval: 50 },
91-
purpose: KeyPurpose.STANDARD
88+
polling: { interval: 50 }
9289
})
9390
).wallet;
9491
receivingWallet = (
@@ -98,8 +95,7 @@ describe('Ada handle', () => {
9895
idx: 1,
9996
logger,
10097
name: 'Receiving Wallet',
101-
polling: { interval: 50 },
102-
purpose: KeyPurpose.STANDARD
98+
polling: { interval: 50 }
10399
})
104100
).wallet;
105101
await Promise.all([walletReady(wallet, coins), walletReady(receivingWallet, 0n)]);

packages/e2e/test/wallet_epoch_0/PersonalWallet/metadata.test.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { BaseWallet, createWalletUtil } from '@cardano-sdk/wallet';
22
import { Cardano } from '@cardano-sdk/core';
3-
import { KeyPurpose } from '@cardano-sdk/key-management';
43
import { filter, firstValueFrom, map } from 'rxjs';
54
import { getEnv, getWallet, walletReady, walletVariables } from '../../../src';
65
import { isNotNil } from '@cardano-sdk/util';
@@ -13,7 +12,7 @@ describe('PersonalWallet/metadata', () => {
1312
let ownAddress: Cardano.PaymentAddress;
1413

1514
beforeAll(async () => {
16-
wallet = (await getWallet({ env, logger, name: 'Test Wallet', purpose: KeyPurpose.STANDARD })).wallet;
15+
wallet = (await getWallet({ env, logger, name: 'Test Wallet' })).wallet;
1716
ownAddress = (await firstValueFrom(wallet.addresses$))[0].address;
1817

1918
await walletReady(wallet);

packages/e2e/test/wallet_epoch_0/PersonalWallet/mint.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('PersonalWallet/mint', () => {
3030
});
3131

3232
it('can mint a token with no asset name', async () => {
33-
wallet = (await getWallet({ env, logger, name: 'Minting Wallet', purpose: KeyPurpose.STANDARD })).wallet;
33+
wallet = (await getWallet({ env, logger, name: 'Minting Wallet' })).wallet;
3434

3535
const coins = 3_000_000n;
3636
await walletReady(wallet, coins);

packages/e2e/test/wallet_epoch_0/PersonalWallet/multiAddress.test.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('PersonalWallet/multiAddress', () => {
2626
let wallet: BaseWallet;
2727

2828
beforeAll(async () => {
29-
wallet = (await getWallet({ env, idx: 0, logger, name: 'Wallet', purpose: KeyPurpose.STANDARD })).wallet;
29+
wallet = (await getWallet({ env, idx: 0, logger, name: 'Wallet' })).wallet;
3030
});
3131

3232
afterAll(() => {
@@ -108,8 +108,7 @@ describe('PersonalWallet/multiAddress', () => {
108108
idx: 0,
109109
logger,
110110
name: 'New Multi Address Wallet',
111-
polling: { interval: 500 },
112-
purpose: KeyPurpose.STANDARD
111+
polling: { interval: 500 }
113112
});
114113

115114
await walletReady(newWallet.wallet);

packages/e2e/test/wallet_epoch_0/PersonalWallet/multisignature.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('PersonalWallet/multisignature', () => {
3737
});
3838

3939
it('can create a transaction with multiple signatures to mint an asset', async () => {
40-
wallet = (await getWallet({ env, logger, name: 'Minting Wallet', purpose: KeyPurpose.MULTI_SIG })).wallet;
40+
wallet = (await getWallet({ env, logger, name: 'Minting Wallet' })).wallet;
4141

4242
const coins = 3_000_000n;
4343
await walletReady(wallet, coins);

packages/e2e/test/wallet_epoch_0/PersonalWallet/nft.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe('PersonalWallet.assets/nft', () => {
5252
const coins = 10_000_000n; // number of coins to use in each transaction
5353

5454
beforeAll(async () => {
55-
wallet = (await getWallet({ env, logger, name: 'Minting Wallet', purpose: KeyPurpose.STANDARD })).wallet;
55+
wallet = (await getWallet({ env, logger, name: 'Minting Wallet' })).wallet;
5656

5757
await walletReady(wallet, coins);
5858

packages/e2e/test/wallet_epoch_0/PersonalWallet/phase2validation.test.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { BaseWallet, FinalizeTxProps, TransactionFailure } from '@cardano-sdk/wa
22
import { Cardano, Serialization } from '@cardano-sdk/core';
33
import { HexBlob, isNotNil } from '@cardano-sdk/util';
44
import { InitializeTxProps, computeScriptDataHash } from '@cardano-sdk/tx-construction';
5-
import { KeyPurpose } from '@cardano-sdk/key-management';
65
import { createLogger } from '@cardano-sdk/util-dev';
76
import { filter, firstValueFrom, map, take } from 'rxjs';
87
import { firstValueFromTimed, getEnv, getWallet, walletReady, walletVariables } from '../../../src';
@@ -72,9 +71,7 @@ describe('PersonalWallet/phase2validation', () => {
7271
});
7372

7473
it('can detect a phase2 validation failure and emit the transaction as failed', async () => {
75-
wallet = (
76-
await getWallet({ env, logger, name: 'Minting Wallet', polling: { interval: 50 }, purpose: KeyPurpose.STANDARD })
77-
).wallet;
74+
wallet = (await getWallet({ env, logger, name: 'Minting Wallet', polling: { interval: 50 } })).wallet;
7875

7976
// Plutus script that always returns false.
8077
const alwaysFailScript: Cardano.PlutusScript = {

packages/e2e/test/wallet_epoch_0/PersonalWallet/plutusTest.test.ts

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { BaseWallet } from '@cardano-sdk/wallet';
22
import { Cardano, Serialization, UtxoProvider } from '@cardano-sdk/core';
33
import { HexBlob, isNotNil } from '@cardano-sdk/util';
4-
import { KeyPurpose } from '@cardano-sdk/key-management';
54
import { Observable, filter, firstValueFrom, interval, map, switchMap, take } from 'rxjs';
65
import { createLogger } from '@cardano-sdk/util-dev';
76
import { getEnv, getWallet, utxoProviderFactory, walletReady, walletVariables } from '../../../src';
@@ -192,9 +191,7 @@ describe('PersonalWallet/plutus', () => {
192191
});
193192

194193
it('can spend balance from a plutus script', async () => {
195-
wallet = (
196-
await getWallet({ env, logger, name: 'Spending Wallet', polling: { interval: 50 }, purpose: KeyPurpose.STANDARD })
197-
).wallet;
194+
wallet = (await getWallet({ env, logger, name: 'Spending Wallet', polling: { interval: 50 } })).wallet;
198195
// UTXO provider can be use to fetch the UTXO set from the script address.
199196
const utxoProvider = await utxoProviderFactory.create(env.UTXO_PROVIDER, env.UTXO_PROVIDER_PARAMS, logger);
200197

@@ -268,9 +265,7 @@ describe('PersonalWallet/plutus', () => {
268265
});
269266

270267
it('can spend balance from a plutus script using a reference script', async () => {
271-
wallet = (
272-
await getWallet({ env, logger, name: 'Spending Wallet', polling: { interval: 50 }, purpose: KeyPurpose.STANDARD })
273-
).wallet;
268+
wallet = (await getWallet({ env, logger, name: 'Spending Wallet', polling: { interval: 50 } })).wallet;
274269
// UTXO provider can be use to fetch the UTXO set from the script address.
275270
const utxoProvider = await utxoProviderFactory.create(env.UTXO_PROVIDER, env.UTXO_PROVIDER_PARAMS, logger);
276271

0 commit comments

Comments
 (0)