From 42874633de6069510efdc57323f61140d22ed203 Mon Sep 17 00:00:00 2001 From: Angel Castillo Date: Thu, 2 Mar 2023 00:18:36 +0800 Subject: [PATCH] refactor!: core type for address string reprensetation 'Address' renamed to PaymentAddress --- .../test/Utxo/utxoHttpProvider.test.ts | 2 +- .../DbSyncChainHistory/mappers.ts | 4 +-- .../ChainHistory/DbSyncChainHistory/types.ts | 2 +- .../Utxo/DbSyncUtxoProvider/UtxoBuilder.ts | 2 +- .../src/Utxo/DbSyncUtxoProvider/mappers.ts | 2 +- .../ChainHistoryHttpService.test.ts | 14 +++++----- .../mappers.test.ts | 20 +++++++------- .../ChainHistory/fixtures/FixtureBuilder.ts | 14 +++++----- .../test/Utxo/DbUtxoProvider/mappers.test.ts | 8 +++--- .../test/Utxo/UtxoHttpService.test.ts | 2 +- .../test/Utxo/fixtures/FixtureBuilder.ts | 4 +-- .../cardano-services/test/data-mocks/tx.ts | 4 +-- packages/core/src/CML/address.ts | 4 +-- packages/core/src/CML/cmlToCore/cmlToCore.ts | 2 +- packages/core/src/Cardano/types/Address.ts | 16 ++++++------ packages/core/src/Cardano/types/Utxo.ts | 6 ++--- packages/core/src/Cardano/util/address.ts | 10 +++---- .../Provider/ChainHistoryProvider/types.ts | 4 +-- .../core/src/Provider/UtxoProvider/types.ts | 2 +- packages/core/src/util/txInspector.ts | 16 ++++++------ packages/core/test/CML/address.test.ts | 10 +++---- packages/core/test/CML/coreToCml.test.ts | 2 +- packages/core/test/CML/testData.ts | 14 +++++----- .../core/test/Cardano/types/Address.test.ts | 20 +++++++------- .../core/test/Cardano/util/address.test.ts | 21 +++++++-------- packages/core/test/util/txInspector.test.ts | 6 ++--- .../dapp-connector/src/WalletApi/types.ts | 2 +- .../test/WalletApi/Cip30Wallet.test.ts | 2 +- packages/dapp-connector/test/testWallet.ts | 4 +-- .../wallet-restoration/WalletRestoration.ts | 2 +- .../test/load-testing/tx-submit-load.test.ts | 4 +-- .../wallet/SingleAddressWallet/byron.test.ts | 2 +- .../SingleAddressWallet/metadata.test.ts | 2 +- .../wallet/SingleAddressWallet/nft.test.ts | 2 +- .../web-extension/extension/stubWalletApi.ts | 8 +++--- .../src/RoundRobinRandomImprove/change.ts | 2 +- packages/key-management/src/KeyAgentBase.ts | 2 +- .../key-management/src/cip8/cip30signData.ts | 6 ++--- packages/key-management/src/types.ts | 2 +- .../test/cip8/cip30signData.test.ts | 4 +-- .../test/restoreKeyAgent.test.ts | 6 ++--- .../test/util/ownSignaturePaths.test.ts | 6 ++--- packages/ogmios/src/ogmiosToCore/tx.ts | 2 +- .../selectionConstraints.test.ts | 2 +- packages/tx-construction/test/testData.ts | 24 ++++++++--------- .../util-dev/src/createStubUtxoProvider.ts | 16 ++++++------ packages/util-dev/src/txTestUtil.ts | 6 ++--- .../Transaction/createTransactionInternals.ts | 2 +- .../wallet/src/TxBuilder/OutputBuilder.ts | 2 +- packages/wallet/src/TxBuilder/types.ts | 2 +- packages/wallet/src/cip30.ts | 8 +++--- .../src/services/TransactionsTracker.ts | 6 ++--- packages/wallet/src/services/UtxoTracker.ts | 4 +-- packages/wallet/src/services/WalletUtil.ts | 2 +- .../test/SingleAddressWallet/methods.test.ts | 4 +-- .../test/SingleAddressWallet/rollback.test.ts | 2 +- .../createTransactionInternals.test.ts | 4 +-- .../test/hardware/LedgerKeyAgent.test.ts | 4 +-- .../test/hardware/TrezorKeyAgent.test.ts | 4 +-- .../wallet/test/integration/buildTx.test.ts | 6 ++--- .../test/integration/cip30mapping.test.ts | 6 ++--- .../integration/txChainingBalance.test.ts | 2 +- .../test/mocks/mockChainHistoryProvider.ts | 14 +++++----- packages/wallet/test/mocks/mockData.ts | 8 +++--- .../wallet/test/mocks/mockUtxoProvider.ts | 26 +++++++++---------- .../TrackedUtxoProvider.test.ts | 2 +- .../wallet/test/services/WalletUtil.test.ts | 4 +-- .../wallet/test/services/util/equals.test.ts | 4 +-- 68 files changed, 218 insertions(+), 215 deletions(-) diff --git a/packages/cardano-services-client/test/Utxo/utxoHttpProvider.test.ts b/packages/cardano-services-client/test/Utxo/utxoHttpProvider.test.ts index 43e7046745d..3d206ac9344 100644 --- a/packages/cardano-services-client/test/Utxo/utxoHttpProvider.test.ts +++ b/packages/cardano-services-client/test/Utxo/utxoHttpProvider.test.ts @@ -47,7 +47,7 @@ describe('utxoHttpProvider', () => { await expect( provider.utxoByAddresses({ addresses: [ - Cardano.Address( + Cardano.PaymentAddress( 'addr_test1qretqkqqvc4dax3482tpjdazrfl8exey274m3mzch3dv8lu476aeq3kd8q8splpsswcfmv4y370e8r76rc8lnnhte49qqyjmtc' ) ] diff --git a/packages/cardano-services/src/ChainHistory/DbSyncChainHistory/mappers.ts b/packages/cardano-services/src/ChainHistory/DbSyncChainHistory/mappers.ts index 6d1c64ed7f3..e7d8dcc44c8 100644 --- a/packages/cardano-services/src/ChainHistory/DbSyncChainHistory/mappers.ts +++ b/packages/cardano-services/src/ChainHistory/DbSyncChainHistory/mappers.ts @@ -67,7 +67,7 @@ export const mapTxIn = (txIn: TxInput): Cardano.HydratedTxIn => ({ }); export const mapTxInModel = (txInModel: TxInputModel): TxInput => ({ - address: txInModel.address as unknown as Cardano.Address, + address: txInModel.address as unknown as Cardano.PaymentAddress, id: txInModel.id, index: txInModel.index, txInputId: txInModel.tx_input_id.toString('hex') as unknown as Cardano.TransactionId, @@ -83,7 +83,7 @@ export const mapTxOut = (txOut: TxOutput): Cardano.TxOut => ({ }); export const mapTxOutModel = (txOutModel: TxOutputModel, assets?: Cardano.TokenMap): TxOutput => ({ - address: txOutModel.address as unknown as Cardano.Address, + address: txOutModel.address as unknown as Cardano.PaymentAddress, datumHash: txOutModel.datum ? (txOutModel.datum.toString('hex') as unknown as Hash32ByteBase16) : undefined, index: txOutModel.index, txId: txOutModel.tx_id.toString('hex') as unknown as Cardano.TransactionId, diff --git a/packages/cardano-services/src/ChainHistory/DbSyncChainHistory/types.ts b/packages/cardano-services/src/ChainHistory/DbSyncChainHistory/types.ts index 49ed0b2951f..ed50cb9e10b 100644 --- a/packages/cardano-services/src/ChainHistory/DbSyncChainHistory/types.ts +++ b/packages/cardano-services/src/ChainHistory/DbSyncChainHistory/types.ts @@ -53,7 +53,7 @@ export interface TxInputModel { } export interface TxInput { - address: Cardano.Address; + address: Cardano.PaymentAddress; id: string; index: number; txInputId: Cardano.TransactionId; diff --git a/packages/cardano-services/src/Utxo/DbSyncUtxoProvider/UtxoBuilder.ts b/packages/cardano-services/src/Utxo/DbSyncUtxoProvider/UtxoBuilder.ts index 5d6fa71cada..c2258823de0 100644 --- a/packages/cardano-services/src/Utxo/DbSyncUtxoProvider/UtxoBuilder.ts +++ b/packages/cardano-services/src/Utxo/DbSyncUtxoProvider/UtxoBuilder.ts @@ -12,7 +12,7 @@ export class UtxoBuilder { this.#db = db; this.#logger = logger; } - public async utxoByAddresses(addresses: Cardano.Address[]): Promise { + public async utxoByAddresses(addresses: Cardano.PaymentAddress[]): Promise { this.#logger.debug('About to find utxos of addresses ', addresses); const result: QueryResult = await this.#db.query(findUtxosByAddresses, [addresses]); return result.rows.length > 0 ? utxosToCore(result.rows) : []; diff --git a/packages/cardano-services/src/Utxo/DbSyncUtxoProvider/mappers.ts b/packages/cardano-services/src/Utxo/DbSyncUtxoProvider/mappers.ts index 2951a8d8b9b..9beea3a4a5a 100644 --- a/packages/cardano-services/src/Utxo/DbSyncUtxoProvider/mappers.ts +++ b/packages/cardano-services/src/Utxo/DbSyncUtxoProvider/mappers.ts @@ -76,7 +76,7 @@ export const utxosToCore = (utxosModels: UtxoModel[]): Cardano.Utxo[] => { } utxos.set(utxoId, [txIn, txOut]); } else { - const address = current.address as unknown as Cardano.Address; + const address = current.address as unknown as Cardano.PaymentAddress; const txOut: Cardano.TxOut = { address, value: { diff --git a/packages/cardano-services/test/ChainHistory/ChainHistoryHttpService.test.ts b/packages/cardano-services/test/ChainHistory/ChainHistoryHttpService.test.ts index b5f870382e7..613a9102399 100644 --- a/packages/cardano-services/test/ChainHistory/ChainHistoryHttpService.test.ts +++ b/packages/cardano-services/test/ChainHistory/ChainHistoryHttpService.test.ts @@ -389,11 +389,11 @@ describe('ChainHistoryHttpService', () => { const response = await provider.transactionsByAddresses({ addresses, pagination }); expect(response.pageResults.length).toEqual(5); - expect(() => Cardano.Address(addresses[0] as unknown as string)).not.toThrow(); + expect(() => Cardano.PaymentAddress(addresses[0] as unknown as string)).not.toThrow(); }); it('does not include transactions not found', async () => { - const unknownAddress = Cardano.Address( + const unknownAddress = Cardano.PaymentAddress( 'addr_test1qrrmuxkfgytnf2lhlx2qhg8uz276747cnduyqpjutqac4qydra7fr0rzkg800zmk29x6tg92yqp7mnvmt42ruqgg5vjsncz9rt' ); const response = await provider.transactionsByAddresses({ @@ -425,7 +425,7 @@ describe('ChainHistoryHttpService', () => { expect(response.totalResultCount).toEqual(txInRangeCount); expect(lowerBound).toBeGreaterThanOrEqual(10); - expect(() => Cardano.Address([...addresses][0] as unknown as string)).not.toThrow(); + expect(() => Cardano.PaymentAddress([...addresses][0] as unknown as string)).not.toThrow(); for (const tx of response.pageResults) expect(tx.blockHeader).toMatchShapeOf(DataMocks.Tx.blockHeader); }); @@ -507,8 +507,8 @@ describe('ChainHistoryHttpService', () => { describe('finds transactions of given addresses', () => { it('finds transactions with address within inputs', async () => { - const genesisAddresses: Cardano.Address[] = await fixtureBuilder.getDistinctAddresses(3); - const addresses: Cardano.Address[] = [genesisAddresses[0]]; + const genesisAddresses: Cardano.PaymentAddress[] = await fixtureBuilder.getDistinctAddresses(3); + const addresses: Cardano.PaymentAddress[] = [genesisAddresses[0]]; const response = await provider.transactionsByAddresses({ addresses, pagination: { limit: 5, startAt: 0 } }); expect(response.pageResults.length).toBeGreaterThan(0); expect( @@ -518,8 +518,8 @@ describe('ChainHistoryHttpService', () => { }); it('finds transactions with address within outputs', async () => { - const addresses: Cardano.Address[] = await fixtureBuilder.getGenesisAddresses(); - expect(() => Cardano.Address(addresses[0] as unknown as string)).not.toThrow(); + const addresses: Cardano.PaymentAddress[] = await fixtureBuilder.getGenesisAddresses(); + expect(() => Cardano.PaymentAddress(addresses[0] as unknown as string)).not.toThrow(); const firstPageResponse = await provider.transactionsByAddresses({ addresses, diff --git a/packages/cardano-services/test/ChainHistory/DbSyncChainHistoryProvider/mappers.test.ts b/packages/cardano-services/test/ChainHistory/DbSyncChainHistoryProvider/mappers.test.ts index 4539237bd57..ca2c66f5324 100644 --- a/packages/cardano-services/test/ChainHistory/DbSyncChainHistoryProvider/mappers.test.ts +++ b/packages/cardano-services/test/ChainHistory/DbSyncChainHistoryProvider/mappers.test.ts @@ -49,7 +49,7 @@ const baseCertModel: CertificateModel = { }; const txInput: TxInput = { - address: Cardano.Address(address), + address: Cardano.PaymentAddress(address), id: '1', index: 1, txInputId: Cardano.TransactionId(transactionHash), @@ -65,7 +65,7 @@ const txInputModel: TxInputModel = { }; const txOutput: TxOutput = { - address: Cardano.Address(address), + address: Cardano.PaymentAddress(address), datumHash: Hash32ByteBase16(hash32ByteBase16), index: 1, txId: Cardano.TransactionId(transactionHash), @@ -300,9 +300,11 @@ describe('chain history mappers', () => { }); describe('mapTxAlonzo', () => { const inputs: Cardano.HydratedTxIn[] = [ - { address: Cardano.Address(address), index: 1, txId: Cardano.TransactionId(transactionHash) } + { address: Cardano.PaymentAddress(address), index: 1, txId: Cardano.TransactionId(transactionHash) } + ]; + const outputs: Cardano.TxOut[] = [ + { address: Cardano.PaymentAddress(address), value: { assets, coins: 20_000_000n } } ]; - const outputs: Cardano.TxOut[] = [{ address: Cardano.Address(address), value: { assets, coins: 20_000_000n } }]; const redeemers: Cardano.Redeemer[] = [ { data: HexBlob(hash28ByteBase16), @@ -367,7 +369,7 @@ describe('chain history mappers', () => { test('map txInputModel to TxInput', () => { const result = mappers.mapTxInModel(txInputModel); expect(result).toEqual({ - address: Cardano.Address(txInputModel.address), + address: Cardano.PaymentAddress(txInputModel.address), id: txInputModel.id, index: txInputModel.index, txInputId: Cardano.TransactionId(transactionHash), @@ -379,7 +381,7 @@ describe('chain history mappers', () => { test('map TxInput to Cardano.HydratedTxIn', () => { const result = mappers.mapTxIn(txInput); expect(result).toEqual({ - address: Cardano.Address(address), + address: Cardano.PaymentAddress(address), index: 1, txId: Cardano.TransactionId(sourceTransactionHash) }); @@ -389,7 +391,7 @@ describe('chain history mappers', () => { test('map TxOutputModel with assets to TxOutput', () => { const result = mappers.mapTxOutModel(txOutModel, assets); expect(result).toEqual({ - address: Cardano.Address(address), + address: Cardano.PaymentAddress(address), datumHash: Hash32ByteBase16(hash32ByteBase16), index: 1, txId: Cardano.TransactionId(transactionHash), @@ -399,7 +401,7 @@ describe('chain history mappers', () => { test('map TxOutputModel with no assets to TxOutput', () => { const result = mappers.mapTxOutModel(txOutModel); expect(result).toEqual({ - address: Cardano.Address(address), + address: Cardano.PaymentAddress(address), datumHash: Hash32ByteBase16(hash32ByteBase16), index: 1, txId: Cardano.TransactionId(transactionHash), @@ -409,7 +411,7 @@ describe('chain history mappers', () => { test('map TxOutputModel with nulls to TxOutput', () => { const result = mappers.mapTxOutModel({ ...txOutModel, datum: null }); expect(result).toEqual({ - address: Cardano.Address(address), + address: Cardano.PaymentAddress(address), index: 1, txId: Cardano.TransactionId(transactionHash), value: { coins: 20_000_000n } diff --git a/packages/cardano-services/test/ChainHistory/fixtures/FixtureBuilder.ts b/packages/cardano-services/test/ChainHistory/fixtures/FixtureBuilder.ts index 68c4b7f4fcc..c5537199dd2 100644 --- a/packages/cardano-services/test/ChainHistory/fixtures/FixtureBuilder.ts +++ b/packages/cardano-services/test/ChainHistory/fixtures/FixtureBuilder.ts @@ -21,7 +21,7 @@ export enum TxWith { } export type AddressesInBlockRange = { - addresses: Set; + addresses: Set; blockRange: Range; txInRangeCount: number; }; @@ -43,7 +43,7 @@ export class ChainHistoryFixtureBuilder { const upperBound = blockRange?.upperBound ?? DB_MAX_SAFE_INTEGER; const txIds = new Set(); const addressesInBlockRange = { - addresses: new Set(), + addresses: new Set(), blockRange: { lowerBound: Cardano.BlockNo(DB_MAX_SAFE_INTEGER), upperBound: Cardano.BlockNo(0) }, txInRangeCount: 0 }; @@ -62,7 +62,7 @@ export class ChainHistoryFixtureBuilder { for (const { address } of results.rows) { if (addressesInBlockRange.addresses.size >= desiredQty) break; - addressesInBlockRange.addresses.add(address as unknown as Cardano.Address); + addressesInBlockRange.addresses.add(address as unknown as Cardano.PaymentAddress); } if (results.rows.length < desiredQty) { @@ -70,7 +70,7 @@ export class ChainHistoryFixtureBuilder { } for (const { address, block_no, tx_id } of results.rows) { - if (addressesInBlockRange.addresses.has(address as unknown as Cardano.Address)) { + if (addressesInBlockRange.addresses.has(address as unknown as Cardano.PaymentAddress)) { txIds.add(tx_id); addressesInBlockRange.blockRange.lowerBound = Cardano.BlockNo( Math.min(addressesInBlockRange.blockRange.lowerBound, block_no) @@ -144,10 +144,10 @@ export class ChainHistoryFixtureBuilder { public async getGenesisAddresses() { this.#logger.debug('About to fetch genesis addresses'); const result: QueryResult<{ address: string }> = await this.#db.query(Queries.genesisUtxoAddresses); - return result.rows.map(({ address }) => address as unknown as Cardano.Address); + return result.rows.map(({ address }) => address as unknown as Cardano.PaymentAddress); } - public async getDistinctAddresses(desiredQty: number): Promise { + public async getDistinctAddresses(desiredQty: number): Promise { this.#logger.debug(`About to fetch up to the last ${desiredQty} distinct addresses`); const result: QueryResult<{ address: string }> = await this.#db.query(Queries.latestDistinctAddresses, [ desiredQty @@ -158,6 +158,6 @@ export class ChainHistoryFixtureBuilder { } else if (resultsQty < desiredQty) { this.#logger.warn(`${desiredQty} distinct addresses desired, only ${resultsQty} results found`); } - return result.rows.map(({ address }) => address as unknown as Cardano.Address); + return result.rows.map(({ address }) => address as unknown as Cardano.PaymentAddress); } } diff --git a/packages/cardano-services/test/Utxo/DbUtxoProvider/mappers.test.ts b/packages/cardano-services/test/Utxo/DbUtxoProvider/mappers.test.ts index d76690da414..620a83f863c 100644 --- a/packages/cardano-services/test/Utxo/DbUtxoProvider/mappers.test.ts +++ b/packages/cardano-services/test/Utxo/DbUtxoProvider/mappers.test.ts @@ -19,14 +19,14 @@ describe('utxosToCore', () => { expect(utxosToCore(someFetchedUtxos)).toEqual([ [ { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qpcnmvyjmxmsm75f747u566gw7ewz4mesdw7yl278uf9r3f5l7d7dpx2ymfwlm3e56flupga8yamjr2kwdt7dw77ktyqqtx2r7' ), index: 1, txId: Cardano.TransactionId('8fd14baca91c674fafae59701b7dc0eda1266202ec8445bad3244bd8669a7fb5') }, { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qpcnmvyjmxmsm75f747u566gw7ewz4mesdw7yl278uf9r3f5l7d7dpx2ymfwlm3e56flupga8yamjr2kwdt7dw77ktyqqtx2r7' ), value: { @@ -52,14 +52,14 @@ describe('utxosToCore', () => { ).toEqual([ [ { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qpcnmvyjmxmsm75f747u566gw7ewz4mesdw7yl278uf9r3f5l7d7dpx2ymfwlm3e56flupga8yamjr2kwdt7dw77ktyqqtx2r7' ), index: 1, txId: Cardano.TransactionId('8fd14baca91c674fafae59701b7dc0eda1266202ec8445bad3244bd8669a7fb5') }, { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qpcnmvyjmxmsm75f747u566gw7ewz4mesdw7yl278uf9r3f5l7d7dpx2ymfwlm3e56flupga8yamjr2kwdt7dw77ktyqqtx2r7' ), value: { diff --git a/packages/cardano-services/test/Utxo/UtxoHttpService.test.ts b/packages/cardano-services/test/Utxo/UtxoHttpService.test.ts index 73e9e393f27..b15de77d13f 100644 --- a/packages/cardano-services/test/Utxo/UtxoHttpService.test.ts +++ b/packages/cardano-services/test/Utxo/UtxoHttpService.test.ts @@ -178,7 +178,7 @@ describe('UtxoHttpService', () => { expect(res.length).toBeGreaterThan(0); expect(res[0]).toMatchShapeOf([DataMocks.Tx.input, DataMocks.Tx.output]); - expect(() => Cardano.Address(addresses[0] as unknown as string)).not.toThrow(); + expect(() => Cardano.PaymentAddress(addresses[0] as unknown as string)).not.toThrow(); }); it('return UTxO with inline datum', async () => { diff --git a/packages/cardano-services/test/Utxo/fixtures/FixtureBuilder.ts b/packages/cardano-services/test/Utxo/fixtures/FixtureBuilder.ts index f77c506d211..3c7d7f5ab34 100644 --- a/packages/cardano-services/test/Utxo/fixtures/FixtureBuilder.ts +++ b/packages/cardano-services/test/Utxo/fixtures/FixtureBuilder.ts @@ -22,7 +22,7 @@ export class UtxoFixtureBuilder { public async getAddresses( desiredQty: number, options?: { with?: AddressWith[]; scriptType?: string } - ): Promise { + ): Promise { this.#logger.debug(`About to fetch up to ${desiredQty} addresses`); let result: QueryResult<{ address: string }>; @@ -54,6 +54,6 @@ export class UtxoFixtureBuilder { this.#logger.warn(`${desiredQty} distinct addresses desired, only ${resultsQty} results found`); } - return result!.rows.map(({ address }) => address as unknown as Cardano.Address); + return result!.rows.map(({ address }) => address as unknown as Cardano.PaymentAddress); } } diff --git a/packages/cardano-services/test/data-mocks/tx.ts b/packages/cardano-services/test/data-mocks/tx.ts index b2be3da3638..5066fbfc146 100644 --- a/packages/cardano-services/test/data-mocks/tx.ts +++ b/packages/cardano-services/test/data-mocks/tx.ts @@ -15,7 +15,7 @@ export const valueWithAssets: Cardano.Value = { }; export const txOutBase: Omit = { - address: Cardano.Address('addr_test1wrsexavz37208qda7mwwu4k7hcpg26cz0ce86f5e9kul3hqzlh22t') + address: Cardano.PaymentAddress('addr_test1wrsexavz37208qda7mwwu4k7hcpg26cz0ce86f5e9kul3hqzlh22t') }; export const txOutBaseWithDatum: Omit = { @@ -28,7 +28,7 @@ export const txOutWithCoinOnly: Cardano.TxOut = { ...txOutBase, value: valueWith export const txOutWithAssets: Cardano.TxOut = { ...txOutBase, value: valueWithAssets }; export const txIn: Cardano.HydratedTxIn = { - address: Cardano.Address('addr_test1wrsexavz37208qda7mwwu4k7hcpg26cz0ce86f5e9kul3hqzlh22t'), + address: Cardano.PaymentAddress('addr_test1wrsexavz37208qda7mwwu4k7hcpg26cz0ce86f5e9kul3hqzlh22t'), index: 0, txId: Cardano.TransactionId('cefd2fcf657e5e5d6c35975f4e052f427819391b153ebb16ad8aa107ba5a3819') }; diff --git a/packages/core/src/CML/address.ts b/packages/core/src/CML/address.ts index 9e586d5d8ee..9f09a4288aa 100644 --- a/packages/core/src/CML/address.ts +++ b/packages/core/src/CML/address.ts @@ -1,10 +1,10 @@ import * as Crypto from '@cardano-sdk/crypto'; -import { Address, NetworkId, RewardAccount } from '../Cardano'; import { CML } from './CML'; +import { NetworkId, PaymentAddress, RewardAccount } from '../Cardano'; import { parseCmlAddress } from './parseCmlAddress'; import { usingAutoFree } from '@cardano-sdk/util'; -export const addressNetworkId = (address: RewardAccount | Address): NetworkId => +export const addressNetworkId = (address: RewardAccount | PaymentAddress): NetworkId => usingAutoFree((scope) => parseCmlAddress(scope, address)!.network_id()); export const createRewardAccount = (stakeKeyHash: Crypto.Ed25519KeyHashHex, networkId: NetworkId) => diff --git a/packages/core/src/CML/cmlToCore/cmlToCore.ts b/packages/core/src/CML/cmlToCore/cmlToCore.ts index 7d362dca8aa..de9e5ed6080 100644 --- a/packages/core/src/CML/cmlToCore/cmlToCore.ts +++ b/packages/core/src/CML/cmlToCore/cmlToCore.ts @@ -187,7 +187,7 @@ export const txOut = (output: CML.TransactionOutput): Cardano.TxOut => const address = byronAddress ? byronAddress.to_base58() : cmlAddress.to_bech32(); return { - address: Cardano.Address(address), + address: Cardano.PaymentAddress(address), datum: inlineDatum ? bytesToHex(inlineDatum) : undefined, datumHash: dataHashBytes ? Crypto.Hash32ByteBase16.fromHexBlob(bytesToHex(dataHashBytes)) : undefined, scriptReference: scriptRef ? getCoreScript(scope, scope.manage(scriptRef.script())) : undefined, diff --git a/packages/core/src/Cardano/types/Address.ts b/packages/core/src/Cardano/types/Address.ts index 9f00581fe31..5475c4218cc 100644 --- a/packages/core/src/Cardano/types/Address.ts +++ b/packages/core/src/Cardano/types/Address.ts @@ -11,10 +11,10 @@ import { isAddress } from '../util/address'; /** * mainnet or testnet address (Shelley as bech32 string, Byron as base58-encoded string) */ -export type Address = OpaqueString<'Address'>; +export type PaymentAddress = OpaqueString<'Address'>; /** - * @param {string} value mainnet or testnet address + * @param {string} address mainnet or testnet address * @throws InvalidStringError */ @@ -28,19 +28,19 @@ const isRewardAccount = (address: string) => { }; /** - * Transform a `value` into `Cardano.Address`, - * Resulting Address will be base58 in case of Byron era or bech32 in case of Shelley era or newer. + * Transform a `value` into `Cardano.PaymentAddress`, + * Resulting PaymentAddress will be base58 in case of Byron era or bech32 in case of Shelley era or newer. * * @param value bech32 string, base58 string or hex-encoded bytes address. * @throws {InvalidStringError} if value is invalid */ -export const Address = (value: string): Address => { +export const PaymentAddress = (value: string): PaymentAddress => { if (isAddress(value)) { if (isRewardAccount(value)) { throw new InvalidStringError(value, 'Address type can only be used for payment addresses'); } - return value as unknown as Address; + return value as unknown as PaymentAddress; } try { @@ -51,10 +51,10 @@ export const Address = (value: string): Address => { return usingAutoFree((scope) => { try { - return Address(scope.manage(CML.ByronAddress.from_bytes(Buffer.from(value, 'hex'))).to_base58()); + return PaymentAddress(scope.manage(CML.ByronAddress.from_bytes(Buffer.from(value, 'hex'))).to_base58()); } catch { try { - return Address(scope.manage(CML.Address.from_bytes(Buffer.from(value, 'hex'))).to_bech32()); + return PaymentAddress(scope.manage(CML.Address.from_bytes(Buffer.from(value, 'hex'))).to_bech32()); } catch { throw new InvalidStringError(value, 'Invalid payment address'); } diff --git a/packages/core/src/Cardano/types/Utxo.ts b/packages/core/src/Cardano/types/Utxo.ts index a92c5b55a29..e638993f691 100644 --- a/packages/core/src/Cardano/types/Utxo.ts +++ b/packages/core/src/Cardano/types/Utxo.ts @@ -1,5 +1,5 @@ -import { Address } from './Address'; import { Datum, DatumHash, Script } from './Script'; +import { PaymentAddress } from './Address'; import { TransactionId } from './Transaction'; import { Value } from './Value'; @@ -9,11 +9,11 @@ export interface TxIn { } export interface HydratedTxIn extends TxIn { - address: Address; + address: PaymentAddress; } export interface TxOut { - address: Address; + address: PaymentAddress; value: Value; /** diff --git a/packages/core/src/Cardano/util/address.ts b/packages/core/src/Cardano/util/address.ts index 7e90a0d303f..b648d826d17 100644 --- a/packages/core/src/Cardano/util/address.ts +++ b/packages/core/src/Cardano/util/address.ts @@ -1,5 +1,5 @@ -import { Address, HydratedTx, HydratedTxIn, TxIn } from '../types'; import { CML } from '../../CML/CML'; +import { HydratedTx, HydratedTxIn, PaymentAddress, TxIn } from '../types'; /** * Validate input as a Cardano Address from all Cardano eras and networks @@ -10,8 +10,8 @@ export const isAddress = (input: string): boolean => CML.Address.is_valid(input) * Checks that an object containing an address (e.g., output, input) is within a set of provided addresses */ export const isAddressWithin = - (addresses: Address[]) => - ({ address }: { address: Address }): boolean => + (addresses: PaymentAddress[]) => + ({ address }: { address: PaymentAddress }): boolean => addresses.includes(address!); /** @@ -20,14 +20,14 @@ export const isAddressWithin = * * @returns {HydratedTxIn[]} array of inputs that contain any of the addresses */ -export const inputsWithAddresses = (tx: HydratedTx, ownAddresses: Address[]): HydratedTxIn[] => +export const inputsWithAddresses = (tx: HydratedTx, ownAddresses: PaymentAddress[]): HydratedTxIn[] => tx.body.inputs.filter(isAddressWithin(ownAddresses)); /** * @param txIn transaction input to resolve address from * @returns input owner address */ -export type ResolveInputAddress = (txIn: TxIn) => Promise
; +export type ResolveInputAddress = (txIn: TxIn) => Promise; export interface InputResolver { resolveInputAddress: ResolveInputAddress; diff --git a/packages/core/src/Provider/ChainHistoryProvider/types.ts b/packages/core/src/Provider/ChainHistoryProvider/types.ts index fbdd7c08a7d..01daac640c2 100644 --- a/packages/core/src/Provider/ChainHistoryProvider/types.ts +++ b/packages/core/src/Provider/ChainHistoryProvider/types.ts @@ -2,7 +2,7 @@ import { Cardano, Paginated, PaginationArgs, Provider, Range } from '../..'; export type TransactionsByAddressesArgs = { - addresses: Cardano.Address[]; + addresses: Cardano.PaymentAddress[]; pagination: PaginationArgs; blockRange?: Range; }; @@ -14,7 +14,7 @@ export interface ChainHistoryProvider extends Provider { * Gets the transactions involving the provided addresses. * It's also possible to provide a block number to only look for transactions since that block inclusive * - * @param {Cardano.Address[]} addresses array of addresses + * @param {Cardano.PaymentAddress[]} addresses array of addresses * @param {Cardano.PaginationArgs} [pagination] pagination args * @param {Range} [blockRange] transactions in specified block ranges (lower and upper bounds inclusive) * @returns {Cardano.HydratedTx[]} an array of transactions involving the addresses diff --git a/packages/core/src/Provider/UtxoProvider/types.ts b/packages/core/src/Provider/UtxoProvider/types.ts index 02aab586a5b..dc029f023f6 100644 --- a/packages/core/src/Provider/UtxoProvider/types.ts +++ b/packages/core/src/Provider/UtxoProvider/types.ts @@ -3,7 +3,7 @@ import Cardano, { Provider } from '../..'; export interface UtxoByAddressesArgs { - addresses: Cardano.Address[]; + addresses: Cardano.PaymentAddress[]; } export interface UtxoProvider extends Provider { diff --git a/packages/core/src/util/txInspector.ts b/packages/core/src/util/txInspector.ts index 7d5a0daa2c8..361f44a9233 100644 --- a/packages/core/src/util/txInspector.ts +++ b/packages/core/src/util/txInspector.ts @@ -1,5 +1,4 @@ import { - Address, AssetFingerprint, AssetName, Certificate, @@ -8,6 +7,7 @@ import { HydratedTxIn, Lovelace, Metadatum, + PaymentAddress, PolicyId, PoolRegistrationCertificate, PoolRetirementCertificate, @@ -60,15 +60,15 @@ export type MetadataInspection = Metadatum; // Inspector types interface SentInspectorArgs { - addresses?: Address[]; + addresses?: PaymentAddress[]; rewardAccounts?: RewardAccount[]; } export type SentInspector = (args: SentInspectorArgs) => Inspector; export type TotalAddressInputsValueInspector = ( - ownAddresses: Address[], + ownAddresses: PaymentAddress[], getHistoricalTxs: () => HydratedTx[] ) => Inspector; -export type SendReceiveValueInspector = (ownAddresses: Address[]) => Inspector; +export type SendReceiveValueInspector = (ownAddresses: PaymentAddress[]) => Inspector; export type DelegationInspector = Inspector; export type StakeKeyRegistrationInspector = Inspector; export type WithdrawalInspector = Inspector; @@ -85,7 +85,7 @@ export type PoolRetirementInspector = Inspector; * Inspects a transaction for values (coins + assets) in inputs * containing any of the provided addresses. * - * @param {Address[]} ownAddresses own wallet's addresses + * @param {PaymentAddress[]} ownAddresses own wallet's addresses * @param {() => HydratedTx[]} getHistoricalTxs wallet's historical transactions * @returns {Value} total value in inputs */ @@ -103,7 +103,7 @@ export const totalAddressInputsValueInspector: TotalAddressInputsValueInspector * Inspects a transaction for values (coins + assets) in outputs * containing any of the provided addresses. * - * @param {Address[]} ownAddresses own wallet's addresses + * @param {PaymentAddress[]} ownAddresses own wallet's addresses * @returns {Value} total value in outputs */ export const totalAddressOutputsValueInspector: SendReceiveValueInspector = (ownAddresses) => (tx) => { @@ -151,7 +151,7 @@ export const sentInspector: SentInspector = /** * Inspects a transaction for net value (coins + assets) sent by the provided addresses. * - * @param {Address[]} ownAddresses own wallet's addresses + * @param {PaymentAddress[]} ownAddresses own wallet's addresses * @param historicalTxs A list of historical transaction * @returns {Value} net value sent */ @@ -172,7 +172,7 @@ export const valueSentInspector: TotalAddressInputsValueInspector = (ownAddresse /** * Inspects a transaction for net value (coins + assets) received by the provided addresses. * - * @param {Address[]} ownAddresses own wallet's addresses + * @param {PaymentAddress[]} ownAddresses own wallet's addresses * @param historicalTxs A list of historical transaction * @returns {Value} net value received */ diff --git a/packages/core/test/CML/address.test.ts b/packages/core/test/CML/address.test.ts index e533c77188a..ef8fe7a4d06 100644 --- a/packages/core/test/CML/address.test.ts +++ b/packages/core/test/CML/address.test.ts @@ -4,9 +4,9 @@ import { Cardano, addressNetworkId, createRewardAccount } from '../../src'; describe('address', () => { describe('addressNetworkId', () => { it('parses testnet address', () => { - expect(addressNetworkId(Cardano.Address('addr_test1wrsexavz37208qda7mwwu4k7hcpg26cz0ce86f5e9kul3hqzlh22t'))).toBe( - Cardano.NetworkId.Testnet - ); + expect( + addressNetworkId(Cardano.PaymentAddress('addr_test1wrsexavz37208qda7mwwu4k7hcpg26cz0ce86f5e9kul3hqzlh22t')) + ).toBe(Cardano.NetworkId.Testnet); }); it('parses testnet reward account', () => { @@ -18,7 +18,7 @@ describe('address', () => { it('parses mainnet address', () => { expect( addressNetworkId( - Cardano.Address( + Cardano.PaymentAddress( 'addr1qx52knza2h5x090n4a5r7yraz3pwcamk9ppvuh7e26nfks7pnmhxqavtqy02zezklh27jt9r6z62sav3mugappdc7xnskxy2pn' ) ) @@ -34,7 +34,7 @@ describe('address', () => { it('parses mainnet byron address', () => { expect( addressNetworkId( - Cardano.Address( + Cardano.PaymentAddress( 'DdzFFzCqrht4PWfBGtmrQz4x1GkZHYLVGbK7aaBkjWxujxzz3L5GxCgPiTsks5RjUr3yX9KvwKjNJBt7ZzPCmS3fUQrGeRvo9Y1YBQKQ' ) ) diff --git a/packages/core/test/CML/coreToCml.test.ts b/packages/core/test/CML/coreToCml.test.ts index c4c88bcff56..62180efaf08 100644 --- a/packages/core/test/CML/coreToCml.test.ts +++ b/packages/core/test/CML/coreToCml.test.ts @@ -22,7 +22,7 @@ import { const txOutByron = { ...txOut, - address: Cardano.Address( + address: Cardano.PaymentAddress( 'DdzFFzCqrhsw3prhfMFDNFowbzUku3QmrMwarfjUbWXRisodn97R436SHc1rimp4MhPNmbdYb1aTdqtGSJixMVMi5MkArDQJ6Sc1n3Ez' ) }; diff --git a/packages/core/test/CML/testData.ts b/packages/core/test/CML/testData.ts index 15a43593bb6..2d8124f2832 100644 --- a/packages/core/test/CML/testData.ts +++ b/packages/core/test/CML/testData.ts @@ -88,21 +88,21 @@ export const txIn = { }; export const txInWithAddress: Cardano.HydratedTxIn = { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp' ), ...txIn }; export const txOut: Cardano.TxOut = { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp' ), value: valueWithAssets }; export const invalidBabbageTxOut: Cardano.TxOut = { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp' ), datum: HexBlob('187b'), @@ -112,7 +112,7 @@ export const invalidBabbageTxOut: Cardano.TxOut = { }; export const babbageTxOutWithDatumHash: Cardano.TxOut = { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp' ), datumHash: Crypto.Hash32ByteBase16('0f3abbc8fc19c2e61bab6059bf8a466e6e754833a08a62a6c56fe0e78f19d9d5'), @@ -121,7 +121,7 @@ export const babbageTxOutWithDatumHash: Cardano.TxOut = { }; export const babbageTxOutWithInlineDatum: Cardano.TxOut = { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp' ), datum: HexBlob('187b'), @@ -130,12 +130,12 @@ export const babbageTxOutWithInlineDatum: Cardano.TxOut = { }; export const txOutWithByron: Cardano.TxOut = { - address: Cardano.Address('5oP9ib6ym3Xc2XrPGC6S7AaJeHYBCmLjt98bnjKR58xXDhSDgLHr8tht3apMDXf2Mg'), + address: Cardano.PaymentAddress('5oP9ib6ym3Xc2XrPGC6S7AaJeHYBCmLjt98bnjKR58xXDhSDgLHr8tht3apMDXf2Mg'), value: valueWithAssets }; export const txOutWithDatum: Cardano.TxOut = { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp' ), datumHash: Crypto.Hash32ByteBase16('4c94610a582b748b8db506abb45ccd48d0d4934942daa87d191645b947a547a7'), diff --git a/packages/core/test/Cardano/types/Address.test.ts b/packages/core/test/Cardano/types/Address.test.ts index dfc00b7286b..b8ec57d6a78 100644 --- a/packages/core/test/Cardano/types/Address.test.ts +++ b/packages/core/test/Cardano/types/Address.test.ts @@ -13,7 +13,7 @@ const addressUtilMock = jest.requireMock('../../../src/Cardano/util/address'); describe('Cardano/types/Address', () => { it('Address() accepts a valid mainnet grouped address and is implemented using "isAddress" util', () => { expect(() => - Cardano.Address( + Cardano.PaymentAddress( 'addr1qx52knza2h5x090n4a5r7yraz3pwcamk9ppvuh7e26nfks7pnmhxqavtqy02zezklh27jt9r6z62sav3mugappdc7xnskxy2pn' ) ).not.toThrow(); @@ -24,35 +24,37 @@ describe('Cardano/types/Address', () => { it('Address() accepts a valid testnet grouped address', () => { expect(() => - Cardano.Address( + Cardano.PaymentAddress( 'addr_test1qqydn46r6mhge0kfpqmt36m6q43knzsd9ga32n96m89px3nuzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475qypp3m9' ) ).not.toThrow(); }); it('Address() accepts a valid mainnet single address', () => { - expect(() => Cardano.Address('addr1vy36kffjf87vzkuyqc5g0ys3fe3pez5zvqg9r5z9q9kfrkg2cs093')).not.toThrow(); + expect(() => Cardano.PaymentAddress('addr1vy36kffjf87vzkuyqc5g0ys3fe3pez5zvqg9r5z9q9kfrkg2cs093')).not.toThrow(); }); it('Address() accepts a valid testnet single address', () => { - expect(() => Cardano.Address('addr_test1vrdkagyspkmt96k6z87rnt9dzzy8mlcex7awjymm8wx434q837u24')).not.toThrow(); + expect(() => + Cardano.PaymentAddress('addr_test1vrdkagyspkmt96k6z87rnt9dzzy8mlcex7awjymm8wx434q837u24') + ).not.toThrow(); }); it('Address() accepts a valid Daedalus Byron address', () => { expect(() => - Cardano.Address( + Cardano.PaymentAddress( 'DdzFFzCqrht4PWfBGtmrQz4x1GkZHYLVGbK7aaBkjWxujxzz3L5GxCgPiTsks5RjUr3yX9KvwKjNJBt7ZzPCmS3fUQrGeRvo9Y1YBQKQ' ) ).not.toThrow(); }); it('Address() accepts a valid Yoroi Byron address', () => { - expect(() => Cardano.Address('Ae2tdPwUPEZKkyZinWnudbNtHQddCyc6bCwLVoQx4GfH1NvwztGRpRkewTe')).not.toThrow(); + expect(() => Cardano.PaymentAddress('Ae2tdPwUPEZKkyZinWnudbNtHQddCyc6bCwLVoQx4GfH1NvwztGRpRkewTe')).not.toThrow(); }); it('Address() throws error when stake address', () => { - expect(() => Cardano.Address('stake_test1ur676rnu57m272uvflhm8ahgu8xk980vxg382zye2wpxnjs2dnddx')).toThrowError( - InvalidStringError - ); + expect(() => + Cardano.PaymentAddress('stake_test1ur676rnu57m272uvflhm8ahgu8xk980vxg382zye2wpxnjs2dnddx') + ).toThrowError(InvalidStringError); }); }); diff --git a/packages/core/test/Cardano/util/address.test.ts b/packages/core/test/Cardano/util/address.test.ts index 9208bab0531..146caf32245 100644 --- a/packages/core/test/Cardano/util/address.test.ts +++ b/packages/core/test/Cardano/util/address.test.ts @@ -1,5 +1,4 @@ import * as parseCmlAddress from '../../../src/CML/parseCmlAddress'; -import { Address } from '../../../src/Cardano'; import { Cardano } from '../../../src'; describe('Cardano.util.address', () => { @@ -9,10 +8,10 @@ describe('Cardano.util.address', () => { describe('util', () => { const addresses = [ - Cardano.Address( + Cardano.PaymentAddress( 'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp' ), - Cardano.Address( + Cardano.PaymentAddress( 'addr_test1qpfhhfy2qgls50r9u4yh0l7z67xpg0a5rrhkmvzcuqrd0znuzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475q9gw0lz' ) ]; @@ -52,7 +51,7 @@ describe('Cardano.util.address', () => { // eslint-disable-next-line max-len '009493315cd92eb5d8c4304e67b7e16ae36d61d34502694657811a2c8e32c728d3861e164cab28cb8f006448139c8f1740ffb8e7aa9e5232dc'; - expect(Address(hexAddr)).toEqual(expectedBech32Addr); + expect(Cardano.PaymentAddress(hexAddr)).toEqual(expectedBech32Addr); }); it('can return the base58 byron address', () => { @@ -64,20 +63,20 @@ describe('Cardano.util.address', () => { // eslint-disable-next-line max-len '82d818584983581c7e9ee4a9527dea9091e2d580edd6716888c42f75d96276290f98fe0ba201581e581c0cdf39b531d1ac0963cbd183f63e43d895d16a9c567c95e1056e28bd02451a4170cb17001a53249b67'; - expect(Address(hexAddr)).toEqual(expectedBase58Addr); + expect(Cardano.PaymentAddress(hexAddr)).toEqual(expectedBase58Addr); }); it('throws if address is invalid', () => { // Valid address but it is a reward address - expect(() => Address('stake_test1up7pvfq8zn4quy45r2g572290p9vf99mr9tn7r9xrgy2l2qdsf58d')).toThrowError( - 'Address type can only be used for payment addresses' - ); + expect(() => + Cardano.PaymentAddress('stake_test1up7pvfq8zn4quy45r2g572290p9vf99mr9tn7r9xrgy2l2qdsf58d') + ).toThrowError('Address type can only be used for payment addresses'); // Does not match any of the supported formats - expect(() => Address('nonHex$string')).toThrowError( + expect(() => Cardano.PaymentAddress('nonHex$string')).toThrowError( 'Expected payment address as bech32, base58 or hex-encoded bytes' ); // Hex string but it's not an address - expect(() => Address('deadbeef')).toThrowError('Invalid payment address'); + expect(() => Cardano.PaymentAddress('deadbeef')).toThrowError('Invalid payment address'); }); }); @@ -90,7 +89,7 @@ describe('Cardano.util.address', () => { }); it('returns false if address is not within provided addresses', () => { - const address = Cardano.Address( + const address = Cardano.PaymentAddress( 'addr_test1qq585l3hyxgj3nas2v3xymd23vvartfhceme6gv98aaeg9muzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475q2g7k3g' ); expect(Cardano.util.isAddressWithin(addresses)({ address })).toBe(false); diff --git a/packages/core/test/util/txInspector.test.ts b/packages/core/test/util/txInspector.test.ts index 05c94a88861..bcee548ae3a 100644 --- a/packages/core/test/util/txInspector.test.ts +++ b/packages/core/test/util/txInspector.test.ts @@ -1,6 +1,5 @@ import * as AssetIds from '../AssetId'; import { - Address, AssetFingerprint, AssetId, AssetName, @@ -12,6 +11,7 @@ import { HydratedTx, HydratedTxIn, NativeScriptKind, + PaymentAddress, PolicyId, PoolId, PoolRegistrationCertificate, @@ -51,10 +51,10 @@ import { jsonToMetadatum } from '../../src/util/metadatum'; // eslint-disable-next-line max-statements describe('txInspector', () => { - const sendingAddress = Address( + const sendingAddress = PaymentAddress( 'addr_test1qq585l3hyxgj3nas2v3xymd23vvartfhceme6gv98aaeg9muzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475q2g7k3g' ); - const receivingAddress = Address( + const receivingAddress = PaymentAddress( 'addr_test1qpfhhfy2qgls50r9u4yh0l7z67xpg0a5rrhkmvzcuqrd0znuzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475q9gw0lz' ); const rewardAccount = RewardAccount('stake_test1up7pvfq8zn4quy45r2g572290p9vf99mr9tn7r9xrgy2l2qdsf58d'); diff --git a/packages/dapp-connector/src/WalletApi/types.ts b/packages/dapp-connector/src/WalletApi/types.ts index b74df090c45..2f5b83e53ff 100644 --- a/packages/dapp-connector/src/WalletApi/types.ts +++ b/packages/dapp-connector/src/WalletApi/types.ts @@ -144,7 +144,7 @@ export type SignTx = (tx: Cbor, partialSign?: Boolean) => Promise; * @throws ApiError * @throws DataSignError */ -export type SignData = (addr: Cardano.Address | Bytes, payload: Bytes) => Promise; +export type SignData = (addr: Cardano.PaymentAddress | Bytes, payload: Bytes) => Promise; /** * As wallets should already have this ability, we allow dApps to request that a transaction be sent through it. diff --git a/packages/dapp-connector/test/WalletApi/Cip30Wallet.test.ts b/packages/dapp-connector/test/WalletApi/Cip30Wallet.test.ts index a4b3bc21c79..3edb3ddcd98 100644 --- a/packages/dapp-connector/test/WalletApi/Cip30Wallet.test.ts +++ b/packages/dapp-connector/test/WalletApi/Cip30Wallet.test.ts @@ -127,7 +127,7 @@ describe('Wallet', () => { expect(typeof api.signData).toBe('function'); const signedData = await api.signData( - Cardano.Address('addr_test1vrfxjeunkc9xu8rpnhgkluptaq0rm8kyxh8m3q9vtcetjwshvpnsm'), + Cardano.PaymentAddress('addr_test1vrfxjeunkc9xu8rpnhgkluptaq0rm8kyxh8m3q9vtcetjwshvpnsm'), Buffer.from('').toString('hex') ); expect(signedData).toEqual({}); diff --git a/packages/dapp-connector/test/testWallet.ts b/packages/dapp-connector/test/testWallet.ts index 68d0c3db57f..bed7fc6c254 100644 --- a/packages/dapp-connector/test/testWallet.ts +++ b/packages/dapp-connector/test/testWallet.ts @@ -17,12 +17,12 @@ export const api = { .utxo(scope, [ [ { - address: Cardano.Address('addr_test1vr8nl4u0u6fmtfnawx2rxfz95dy7m46t6dhzdftp2uha87syeufdg'), + address: Cardano.PaymentAddress('addr_test1vr8nl4u0u6fmtfnawx2rxfz95dy7m46t6dhzdftp2uha87syeufdg'), index: 0, txId: Cardano.TransactionId('886206542d63b23a047864021fbfccf291d78e47c1e59bd4c75fbc67b248c5e8') }, { - address: Cardano.Address( + address: Cardano.PaymentAddress( // eslint-disable-next-line max-len 'addr_test1qra788mu4sg8kwd93ns9nfdh3k4ufxwg4xhz2r3n064tzfgxu2hyfhlkwuxupa9d5085eunq2qywy7hvmvej456flkns6cy45x' ), diff --git a/packages/e2e/test/artillery/wallet-restoration/WalletRestoration.ts b/packages/e2e/test/artillery/wallet-restoration/WalletRestoration.ts index 23ac53077d6..233cfa822a5 100644 --- a/packages/e2e/test/artillery/wallet-restoration/WalletRestoration.ts +++ b/packages/e2e/test/artillery/wallet-restoration/WalletRestoration.ts @@ -20,7 +20,7 @@ const SHORTAGE_OF_WALLETS_FOUND_ERROR_MESSAGE = 'Addresses found from db are les const mapToGroupedAddress = (addrModel: AddressesModel): GroupedAddress => ({ accountIndex: 0, - address: Cardano.Address(addrModel.address), + address: Cardano.PaymentAddress(addrModel.address), index: 0, networkId: addrModel.address.startsWith('addr_test') ? Cardano.NetworkId.Testnet : Cardano.NetworkId.Mainnet, rewardAccount: Cardano.RewardAccount(addrModel.stake_address), diff --git a/packages/e2e/test/load-testing/tx-submit-load.test.ts b/packages/e2e/test/load-testing/tx-submit-load.test.ts index 7a6eff4e2b9..149d8ba228e 100644 --- a/packages/e2e/test/load-testing/tx-submit-load.test.ts +++ b/packages/e2e/test/load-testing/tx-submit-load.test.ts @@ -36,7 +36,7 @@ interface TestReport extends TestOptions { } interface TestWallet { - address: Cardano.Address; + address: Cardano.PaymentAddress; coins: bigint; wallet: ObservableWallet; } @@ -166,7 +166,7 @@ describe('load', () => { const fragmentWhenRequired = async (options: TestOptions) => { await refreshWallets(); - const toRefill: Cardano.Address[] = []; + const toRefill: Cardano.PaymentAddress[] = []; const { wallet } = testWallets[0]; for (let i = 0; i < env.TRANSACTIONS_NUMBER; ++i) diff --git a/packages/e2e/test/wallet/SingleAddressWallet/byron.test.ts b/packages/e2e/test/wallet/SingleAddressWallet/byron.test.ts index 5f89563e340..4fdd10aa946 100644 --- a/packages/e2e/test/wallet/SingleAddressWallet/byron.test.ts +++ b/packages/e2e/test/wallet/SingleAddressWallet/byron.test.ts @@ -30,7 +30,7 @@ describe('SingleAddressWallet/byron', () => { const txOutput = txBuilder .buildOutput() - .address(Cardano.Address('5oP9ib6ym3Xc2XrPGC6S7AaJeHYBCmLjt98bnjKR58xXDhSDgLHr8tht3apMDXf2Mg')) + .address(Cardano.PaymentAddress('5oP9ib6ym3Xc2XrPGC6S7AaJeHYBCmLjt98bnjKR58xXDhSDgLHr8tht3apMDXf2Mg')) .coin(3_000_000n) .toTxOut(); diff --git a/packages/e2e/test/wallet/SingleAddressWallet/metadata.test.ts b/packages/e2e/test/wallet/SingleAddressWallet/metadata.test.ts index 7ddb6dc9d57..1847b7975db 100644 --- a/packages/e2e/test/wallet/SingleAddressWallet/metadata.test.ts +++ b/packages/e2e/test/wallet/SingleAddressWallet/metadata.test.ts @@ -10,7 +10,7 @@ const env = getEnv(walletVariables); describe('SingleAddressWallet/metadata', () => { let wallet: SingleAddressWallet; - let ownAddress: Cardano.Address; + let ownAddress: Cardano.PaymentAddress; beforeAll(async () => { wallet = (await getWallet({ env, logger, name: 'Test Wallet' })).wallet; diff --git a/packages/e2e/test/wallet/SingleAddressWallet/nft.test.ts b/packages/e2e/test/wallet/SingleAddressWallet/nft.test.ts index b3fcda3f94a..d3b6117479e 100644 --- a/packages/e2e/test/wallet/SingleAddressWallet/nft.test.ts +++ b/packages/e2e/test/wallet/SingleAddressWallet/nft.test.ts @@ -22,7 +22,7 @@ describe('SingleAddressWallet.assets/nft', () => { let assetIds: Cardano.AssetId[]; let fingerprints: Cardano.AssetFingerprint[]; const assetNames = ['4e46542d66696c6573', '4e46542d303031', '4e46542d303032']; - let walletAddress: Cardano.Address; + let walletAddress: Cardano.PaymentAddress; beforeAll(async () => { wallet = (await getWallet({ env, idx: 0, logger, name: 'Minting Wallet', polling: { interval: 50 } })).wallet; diff --git a/packages/e2e/test/web-extension/extension/stubWalletApi.ts b/packages/e2e/test/web-extension/extension/stubWalletApi.ts index 77bdd0607bb..7173c11d26d 100644 --- a/packages/e2e/test/web-extension/extension/stubWalletApi.ts +++ b/packages/e2e/test/web-extension/extension/stubWalletApi.ts @@ -13,12 +13,12 @@ export const stubWalletApi: WalletApi = { mapUtxos([ [ { - address: Cardano.Address('addr_test1vr8nl4u0u6fmtfnawx2rxfz95dy7m46t6dhzdftp2uha87syeufdg'), + address: Cardano.PaymentAddress('addr_test1vr8nl4u0u6fmtfnawx2rxfz95dy7m46t6dhzdftp2uha87syeufdg'), index: 1, txId: Cardano.TransactionId('886206542d63b23a047864021fbfccf291d78e47c1e59bd4c75fbc67b248c5e8') }, { - address: Cardano.Address( + address: Cardano.PaymentAddress( // eslint-disable-next-line max-len 'addr_test1qra788mu4sg8kwd93ns9nfdh3k4ufxwg4xhz2r3n064tzfgxu2hyfhlkwuxupa9d5085eunq2qywy7hvmvej456flkns6cy45x' ), @@ -36,12 +36,12 @@ export const stubWalletApi: WalletApi = { mapUtxos([ [ { - address: Cardano.Address('addr_test1vr8nl4u0u6fmtfnawx2rxfz95dy7m46t6dhzdftp2uha87syeufdg'), + address: Cardano.PaymentAddress('addr_test1vr8nl4u0u6fmtfnawx2rxfz95dy7m46t6dhzdftp2uha87syeufdg'), index: 0, txId: Cardano.TransactionId('886206542d63b23a047864021fbfccf291d78e47c1e59bd4c75fbc67b248c5e8') }, { - address: Cardano.Address( + address: Cardano.PaymentAddress( // eslint-disable-next-line max-len 'addr_test1qra788mu4sg8kwd93ns9nfdh3k4ufxwg4xhz2r3n064tzfgxu2hyfhlkwuxupa9d5085eunq2qywy7hvmvej456flkns6cy45x' ), diff --git a/packages/input-selection/src/RoundRobinRandomImprove/change.ts b/packages/input-selection/src/RoundRobinRandomImprove/change.ts index b408cf0ee7b..21486b8ed1b 100644 --- a/packages/input-selection/src/RoundRobinRandomImprove/change.ts +++ b/packages/input-selection/src/RoundRobinRandomImprove/change.ts @@ -8,7 +8,7 @@ import pick from 'lodash/pick'; type EstimateTxFeeWithOriginalOutputs = (utxo: Cardano.Utxo[], change: Cardano.Value[]) => Promise; -const stubMaxSizeAddress = Cardano.Address( +const stubMaxSizeAddress = Cardano.PaymentAddress( 'addr_test1qqydn46r6mhge0kfpqmt36m6q43knzsd9ga32n96m89px3nuzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475qypp3m9' ); diff --git a/packages/key-management/src/KeyAgentBase.ts b/packages/key-management/src/KeyAgentBase.ts index 7cf4d37e0aa..afa35440e75 100644 --- a/packages/key-management/src/KeyAgentBase.ts +++ b/packages/key-management/src/KeyAgentBase.ts @@ -99,7 +99,7 @@ export abstract class KeyAgentBase implements KeyAgent { ); return { accountIndex: this.accountIndex, - address: Cardano.Address(address.to_bech32()), + address: Cardano.PaymentAddress(address.to_bech32()), index, networkId: this.chainId.networkId, rewardAccount: Cardano.RewardAccount(rewardAccount.to_bech32()), diff --git a/packages/key-management/src/cip8/cip30signData.ts b/packages/key-management/src/cip8/cip30signData.ts index c7155fa1d0a..48742bcb06d 100644 --- a/packages/key-management/src/cip8/cip30signData.ts +++ b/packages/key-management/src/cip8/cip30signData.ts @@ -23,7 +23,7 @@ import { firstValueFrom } from 'rxjs'; export interface Cip30SignDataRequest { keyAgent: AsyncKeyAgent; - signWith: Cardano.Address | Cardano.RewardAccount; + signWith: Cardano.PaymentAddress | Cardano.RewardAccount; payload: HexBlob; } @@ -39,7 +39,7 @@ export class Cip30DataSignError extends ComposableError +const getAddressBytes = (signWith: Cardano.PaymentAddress | Cardano.RewardAccount) => usingAutoFree((scope) => { const cslAddress = parseCmlAddress(scope, signWith); if (!cslAddress) { @@ -48,7 +48,7 @@ const getAddressBytes = (signWith: Cardano.Address | Cardano.RewardAccount) => return cslAddress.to_bytes(); }); -const getDerivationPath = async (signWith: Cardano.Address | Cardano.RewardAccount, keyAgent: AsyncKeyAgent) => { +const getDerivationPath = async (signWith: Cardano.PaymentAddress | Cardano.RewardAccount, keyAgent: AsyncKeyAgent) => { const isRewardAccount = signWith.startsWith('stake'); if (isRewardAccount) { return STAKE_KEY_DERIVATION_PATH; diff --git a/packages/key-management/src/types.ts b/packages/key-management/src/types.ts index fd42d239d17..6deb5033b21 100644 --- a/packages/key-management/src/types.ts +++ b/packages/key-management/src/types.ts @@ -78,7 +78,7 @@ export interface GroupedAddress { index: number; networkId: Cardano.NetworkId; accountIndex: number; - address: Cardano.Address; + address: Cardano.PaymentAddress; rewardAccount: Cardano.RewardAccount; stakeKeyDerivationPath?: AccountKeyDerivationPath; } diff --git a/packages/key-management/test/cip8/cip30signData.test.ts b/packages/key-management/test/cip8/cip30signData.test.ts index f1b2e32a4eb..31a3ac3373b 100644 --- a/packages/key-management/test/cip8/cip30signData.test.ts +++ b/packages/key-management/test/cip8/cip30signData.test.ts @@ -18,7 +18,7 @@ describe('cip30signData', () => { address = await asyncKeyAgent.deriveAddress(addressDerivationPath); }); - const signAndDecode = async (signWith: Cardano.Address | Cardano.RewardAccount) => { + const signAndDecode = async (signWith: Cardano.PaymentAddress | Cardano.RewardAccount) => { const dataSignature = await cip8.cip30signData({ keyAgent: asyncKeyAgent, payload: HexBlob('abc123'), @@ -37,7 +37,7 @@ describe('cip30signData', () => { }; // eslint-disable-next-line unicorn/consistent-function-scoping - const testAddressHeader = (signedData: SigStructure, signWith: Cardano.RewardAccount | Cardano.Address) => { + const testAddressHeader = (signedData: SigStructure, signWith: Cardano.RewardAccount | Cardano.PaymentAddress) => { const addressHeader = signedData.body_protected().deserialized_headers().header(CoseLabel.address)!; // Subject to change (cbor vs raw bytes argument), PR open: https://github.com/cardano-foundation/CIPs/pull/148 diff --git a/packages/key-management/test/restoreKeyAgent.test.ts b/packages/key-management/test/restoreKeyAgent.test.ts index b00ef503ea8..514c1f4ad51 100644 --- a/packages/key-management/test/restoreKeyAgent.test.ts +++ b/packages/key-management/test/restoreKeyAgent.test.ts @@ -33,7 +33,7 @@ describe('KeyManagement/restoreKeyAgent', () => { 87, 78, 204, 222, 109, 3, 239, 117 ]; - const address = Cardano.Address( + const address = Cardano.PaymentAddress( 'addr1qx52knza2h5x090n4a5r7yraz3pwcamk9ppvuh7e26nfks7pnmhxqavtqy02zezklh27jt9r6z62sav3mugappdc7xnskxy2pn' ); @@ -128,7 +128,7 @@ describe('KeyManagement/restoreKeyAgent', () => { knownAddresses: [ { accountIndex: 0, - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr1qx52knza2h5x090n4a5r7yraz3pwcamk9ppvuh7e26nfks7pnmhxqavtqy02zezklh27jt9r6z62sav3mugappdc7xnskxy2pn' ), index: 0, @@ -158,7 +158,7 @@ describe('KeyManagement/restoreKeyAgent', () => { knownAddresses: [ { accountIndex: 0, - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr1qx52knza2h5x090n4a5r7yraz3pwcamk9ppvuh7e26nfks7pnmhxqavtqy02zezklh27jt9r6z62sav3mugappdc7xnskxy2pn' ), index: 0, diff --git a/packages/key-management/test/util/ownSignaturePaths.test.ts b/packages/key-management/test/util/ownSignaturePaths.test.ts index 3f07d588371..f2c257420ed 100644 --- a/packages/key-management/test/util/ownSignaturePaths.test.ts +++ b/packages/key-management/test/util/ownSignaturePaths.test.ts @@ -7,7 +7,7 @@ export const stakeKeyPath = { }; const createGroupedAddress = ( - address: Cardano.Address, + address: Cardano.PaymentAddress, rewardAccount: Cardano.RewardAccount, type: AddressType, index: number, @@ -25,10 +25,10 @@ const createGroupedAddress = ( describe('KeyManagement.util.ownSignaturePaths', () => { const ownRewardAccount = Cardano.RewardAccount('stake_test1uqfu74w3wh4gfzu8m6e7j987h4lq9r3t7ef5gaw497uu85qsqfy27'); const otherRewardAccount = Cardano.RewardAccount('stake_test1uqrw9tjymlm8wrwq7jk68n6v7fs9qz8z0tkdkve26dylmfc2ux2hj'); - const address1 = Cardano.Address( + const address1 = Cardano.PaymentAddress( 'addr_test1qra788mu4sg8kwd93ns9nfdh3k4ufxwg4xhz2r3n064tzfgxu2hyfhlkwuxupa9d5085eunq2qywy7hvmvej456flkns6cy45x' ); - const address2 = Cardano.Address( + const address2 = Cardano.PaymentAddress( 'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp' ); diff --git a/packages/ogmios/src/ogmiosToCore/tx.ts b/packages/ogmios/src/ogmiosToCore/tx.ts index e4dfbedcc28..64c4f9c9031 100644 --- a/packages/ogmios/src/ogmiosToCore/tx.ts +++ b/packages/ogmios/src/ogmiosToCore/tx.ts @@ -262,7 +262,7 @@ const mapDatumHash = (datum: Schema.TxOut['datumHash']) => { }; const mapTxOut = (txOut: Schema.TxOut): Cardano.TxOut => ({ - address: Cardano.Address(txOut.address), + address: Cardano.PaymentAddress(txOut.address), datum: mapInlineDatum(txOut.datum), datumHash: mapDatumHash(txOut.datumHash), scriptReference: txOut.script ? mapScript(txOut.script) : undefined, diff --git a/packages/tx-construction/test/input-selection/selectionConstraints.test.ts b/packages/tx-construction/test/input-selection/selectionConstraints.test.ts index 4dc6fed7762..bbd4784dba4 100644 --- a/packages/tx-construction/test/input-selection/selectionConstraints.test.ts +++ b/packages/tx-construction/test/input-selection/selectionConstraints.test.ts @@ -65,7 +65,7 @@ describe('defaultSelectionConstraints', () => { const constraints = defaultSelectionConstraints({ protocolParameters } as DefaultSelectionConstraintsProps); - const address = Cardano.Address( + const address = Cardano.PaymentAddress( 'addr_test1qqydn46r6mhge0kfpqmt36m6q43knzsd9ga32n96m89px3nuzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475qypp3m9' ); const minCoinWithAssets = constraints.computeMinimumCoinQuantity({ address, value: { assets, coins: 0n } }); diff --git a/packages/tx-construction/test/testData.ts b/packages/tx-construction/test/testData.ts index 910182d66db..0e0b8ee2ae0 100644 --- a/packages/tx-construction/test/testData.ts +++ b/packages/tx-construction/test/testData.ts @@ -67,7 +67,7 @@ export const txIn = { }; export const txOut: Cardano.TxOut = { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp' ), value: valueWithAssets @@ -298,7 +298,7 @@ export const getBigBabbageTx = async () => { }; export const noMultiasset = { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp' ), value: { @@ -309,7 +309,7 @@ export const noMultiasset = { export const noMultiassetMinAda = 969_750n; export const onePolicyOne0CharAsset = { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp' ), value: { @@ -321,7 +321,7 @@ export const onePolicyOne0CharAsset = { export const onePolicyOne0CharAssetMinAda = 1_120_600n; export const onePolicyOne1CharAsset = { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp' ), value: { @@ -333,7 +333,7 @@ export const onePolicyOne1CharAsset = { export const onePolicyOne1CharAssetMinAda = 1_124_910n; export const onePolicyThree1CharAsset = { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp' ), value: { @@ -349,7 +349,7 @@ export const onePolicyThree1CharAsset = { export const onePolicyThree1CharAssetMinAda = 1_150_770n; export const twoPoliciesOne0CharAsset = { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp' ), value: { @@ -364,7 +364,7 @@ export const twoPoliciesOne0CharAsset = { export const twoPoliciesOne0CharAssetMinAda = 1_262_830n; export const twoPoliciesOne1CharAsset = { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp' ), value: { @@ -379,7 +379,7 @@ export const twoPoliciesOne1CharAsset = { export const twoPoliciesOne1CharAssetMinAda = 1_271_450n; export const onePolicyOne0CharAssetDatumHash = { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp' ), datumHash: Crypto.Hash32ByteBase16('0f3abbc8fc19c2e61bab6059bf8a466e6e754833a08a62a6c56fe0e78f19d9d5'), @@ -392,7 +392,7 @@ export const onePolicyOne0CharAssetDatumHash = { export const onePolicyOne0CharAssetDatumHashMinAda = 1_267_140n; export const threePolicyThree32CharAssetDatumHash = { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp' ), datumHash: Crypto.Hash32ByteBase16('0f3abbc8fc19c2e61bab6059bf8a466e6e754833a08a62a6c56fe0e78f19d9d5'), @@ -427,7 +427,7 @@ export const threePolicyThree32CharAssetDatumHash = { export const threePolicyThree32CharAssetDatumHashMinAda = 1_409_370n; export const twoPolicyOne0CharAssetDatumHash = { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp' ), datumHash: Crypto.Hash32ByteBase16('0f3abbc8fc19c2e61bab6059bf8a466e6e754833a08a62a6c56fe0e78f19d9d5'), @@ -443,7 +443,7 @@ export const twoPolicyOne0CharAssetDatumHash = { export const twoPolicyOne0CharAssetDatumHashMinAda = 1_409_370n; export const twoPolicyOne0CharAssetDatum = { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp' ), datum: HexBlob('187b'), @@ -459,7 +459,7 @@ export const twoPolicyOne0CharAssetDatum = { export const twoPolicyOne0CharAssetDatumMinAda = 1_305_930n; export const twoPolicyOne0CharAssetDatumAndScriptReference = { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp' ), datum: HexBlob('187b'), diff --git a/packages/util-dev/src/createStubUtxoProvider.ts b/packages/util-dev/src/createStubUtxoProvider.ts index 0e51cde62c2..70e76283b16 100644 --- a/packages/util-dev/src/createStubUtxoProvider.ts +++ b/packages/util-dev/src/createStubUtxoProvider.ts @@ -4,14 +4,14 @@ import delay from 'delay'; export const somePartialUtxos: Cardano.Utxo[] = [ [ { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qr4m502gr9hnaxac5mxjln22jwavf7pcjmh9sw7fujdvgvj9ef6afquphwg7tj4mmm548m3t50hxfyygjuu222kx96eshcathg' ), index: 0, txId: Cardano.TransactionId('8fd14baca91c674fafae59701b7dc0eda1266202ec8445bad3244bd8669a7fb5') }, { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qr4m502gr9hnaxac5mxjln22jwavf7pcjmh9sw7fujdvgvj9ef6afquphwg7tj4mmm548m3t50hxfyygjuu222kx96eshcathg' ), value: { @@ -21,14 +21,14 @@ export const somePartialUtxos: Cardano.Utxo[] = [ ], [ { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp' ), index: 0, txId: Cardano.TransactionId('a62624fdc47e8b774ddff11a9a56cae5fa9b072975af87bf0a0583fca0e345f4') }, { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp' ), value: { @@ -38,14 +38,14 @@ export const somePartialUtxos: Cardano.Utxo[] = [ ], [ { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qr4m502gr9hnaxac5mxjln22jwavf7pcjmh9sw7fujdvgvj9ef6afquphwg7tj4mmm548m3t50hxfyygjuu222kx96eshcathg' ), index: 0, txId: Cardano.TransactionId('3d4cd09885d39673125c3a15f8acb45d92fde137f9effe7a5131f6cc7241d960') }, { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qr4m502gr9hnaxac5mxjln22jwavf7pcjmh9sw7fujdvgvj9ef6afquphwg7tj4mmm548m3t50hxfyygjuu222kx96eshcathg' ), value: { @@ -55,14 +55,14 @@ export const somePartialUtxos: Cardano.Utxo[] = [ ], [ { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qpcnmvyjmxmsm75f747u566gw7ewz4mesdw7yl278uf9r3f5l7d7dpx2ymfwlm3e56flupga8yamjr2kwdt7dw77ktyqqtx2r7' ), index: 0, txId: Cardano.TransactionId('19251f57476d7af2777252270413c01383d9503110a68b4fde1a239c119c4f5d') }, { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qpcnmvyjmxmsm75f747u566gw7ewz4mesdw7yl278uf9r3f5l7d7dpx2ymfwlm3e56flupga8yamjr2kwdt7dw77ktyqqtx2r7' ), value: { diff --git a/packages/util-dev/src/txTestUtil.ts b/packages/util-dev/src/txTestUtil.ts index 6ec53106466..046012245d0 100644 --- a/packages/util-dev/src/txTestUtil.ts +++ b/packages/util-dev/src/txTestUtil.ts @@ -4,17 +4,17 @@ export const createTxInput = (() => { let defaultIndex = 0; return ( txId = Cardano.TransactionId('6804edf9712d2b619edb6ac86861fe93a730693183a262b165fcc1ba1bc99cad'), - address = Cardano.Address('addr1vy36kffjf87vzkuyqc5g0ys3fe3pez5zvqg9r5z9q9kfrkg2cs093'), + address = Cardano.PaymentAddress('addr1vy36kffjf87vzkuyqc5g0ys3fe3pez5zvqg9r5z9q9kfrkg2cs093'), index = defaultIndex++ ) => ({ address, index, txId }); })(); export const createUnspentTxOutput = ( value: Cardano.Value, - address = Cardano.Address('addr1vy36kffjf87vzkuyqc5g0ys3fe3pez5zvqg9r5z9q9kfrkg2cs093') + address = Cardano.PaymentAddress('addr1vy36kffjf87vzkuyqc5g0ys3fe3pez5zvqg9r5z9q9kfrkg2cs093') ): Cardano.Utxo => [createTxInput(), { address, value }]; export const createOutput = ( value: Cardano.Value, - address = Cardano.Address('addr1vyeljkh3vr4h9s3lyxe7g2meushk3m4nwyzdgtlg96e6mrgg8fnle') + address = Cardano.PaymentAddress('addr1vyeljkh3vr4h9s3lyxe7g2meushk3m4nwyzdgtlg96e6mrgg8fnle') ): Cardano.TxOut => ({ address, value }); diff --git a/packages/wallet/src/Transaction/createTransactionInternals.ts b/packages/wallet/src/Transaction/createTransactionInternals.ts index 1679dfb679e..315b0145372 100644 --- a/packages/wallet/src/Transaction/createTransactionInternals.ts +++ b/packages/wallet/src/Transaction/createTransactionInternals.ts @@ -4,7 +4,7 @@ import { SelectionResult } from '@cardano-sdk/input-selection'; import { usingAutoFree } from '@cardano-sdk/util'; export type CreateTxInternalsProps = { - changeAddress: Cardano.Address; + changeAddress: Cardano.PaymentAddress; inputSelection: SelectionResult['selection']; validityInterval: Cardano.ValidityInterval; certificates?: Cardano.Certificate[]; diff --git a/packages/wallet/src/TxBuilder/OutputBuilder.ts b/packages/wallet/src/TxBuilder/OutputBuilder.ts index 7730b455701..aa91028798d 100644 --- a/packages/wallet/src/TxBuilder/OutputBuilder.ts +++ b/packages/wallet/src/TxBuilder/OutputBuilder.ts @@ -87,7 +87,7 @@ export class ObservableWalletTxOutputBuilder implements OutputBuilder { return this.assets(assets); } - address(address: Cardano.Address): OutputBuilder { + address(address: Cardano.PaymentAddress): OutputBuilder { this.#partialOutput = { ...this.#partialOutput, address }; return this; } diff --git a/packages/wallet/src/TxBuilder/types.ts b/packages/wallet/src/TxBuilder/types.ts index 7d7eb770c43..55dfe1721fb 100644 --- a/packages/wallet/src/TxBuilder/types.ts +++ b/packages/wallet/src/TxBuilder/types.ts @@ -103,7 +103,7 @@ export interface OutputBuilder { */ asset(assetId: Cardano.AssetId, quantity: bigint): OutputBuilder; /** Sets transaction output `address` field. */ - address(address: Cardano.Address): OutputBuilder; + address(address: Cardano.PaymentAddress): OutputBuilder; /** Sets transaction output `datum` field. */ datum(datum: Hash32ByteBase16): OutputBuilder; /** diff --git a/packages/wallet/src/cip30.ts b/packages/wallet/src/cip30.ts index a53f31b5f1e..3d754796e1a 100644 --- a/packages/wallet/src/cip30.ts +++ b/packages/wallet/src/cip30.ts @@ -32,7 +32,7 @@ export enum Cip30ConfirmationCallbackType { export type SignDataCallbackParams = { type: Cip30ConfirmationCallbackType.SignData; data: { - addr: Cardano.Address; + addr: Cardano.PaymentAddress; payload: HexBlob; }; }; @@ -82,7 +82,7 @@ const compareUtxos = (utxo: Cardano.Utxo, comparedTo: Cardano.Utxo) => { return 0; }; -const cardanoAddressToCbor = (address: Cardano.Address | Cardano.RewardAccount): Cbor => +const cardanoAddressToCbor = (address: Cardano.PaymentAddress | Cardano.RewardAccount): Cbor => usingAutoFree((scope) => { const cmlAddr = parseCmlAddress(scope, address); if (!cmlAddr) { @@ -255,10 +255,10 @@ export const createWalletApi = ( scope.dispose(); return cbor; }, - signData: async (addr: Cardano.Address | Bytes, payload: Bytes): Promise => { + signData: async (addr: Cardano.PaymentAddress | Bytes, payload: Bytes): Promise => { logger.debug('signData'); const hexBlobPayload = HexBlob(payload); - const signWith = Cardano.Address(addr); + const signWith = Cardano.PaymentAddress(addr); const shouldProceed = await confirmationCallback({ data: { diff --git a/packages/wallet/src/services/TransactionsTracker.ts b/packages/wallet/src/services/TransactionsTracker.ts index 429f03e9b5e..6ed93582459 100644 --- a/packages/wallet/src/services/TransactionsTracker.ts +++ b/packages/wallet/src/services/TransactionsTracker.ts @@ -39,7 +39,7 @@ import unionBy from 'lodash/unionBy'; export interface TransactionsTrackerProps { chainHistoryProvider: ChainHistoryProvider; - addresses$: Observable; + addresses$: Observable; tip$: Observable; retryBackoffConfig: RetryBackoffConfig; transactionsHistoryStore: OrderedCollectionStore; @@ -61,7 +61,7 @@ export interface TransactionsTrackerInternals { export interface TransactionsTrackerInternalsProps { chainHistoryProvider: ChainHistoryProvider; - addresses$: Observable; + addresses$: Observable; retryBackoffConfig: RetryBackoffConfig; tipBlockHeight$: Observable; store: OrderedCollectionStore; @@ -74,7 +74,7 @@ export const PAGE_SIZE = 25; const allTransactionsByAddresses = async ( chainHistoryProvider: ChainHistoryProvider, - { addresses, blockRange }: { addresses: Cardano.Address[]; blockRange: Range } + { addresses, blockRange }: { addresses: Cardano.PaymentAddress[]; blockRange: Range } ): Promise => { let startAt = 0; let response: Cardano.HydratedTx[] = []; diff --git a/packages/wallet/src/services/UtxoTracker.ts b/packages/wallet/src/services/UtxoTracker.ts index 981f2c54756..7f59853aded 100644 --- a/packages/wallet/src/services/UtxoTracker.ts +++ b/packages/wallet/src/services/UtxoTracker.ts @@ -8,7 +8,7 @@ import { WalletStores } from '../persistence'; export interface UtxoTrackerProps { utxoProvider: UtxoProvider; - addresses$: Observable; + addresses$: Observable; stores: Pick; transactionsInFlight$: Observable; tipBlockHeight$: Observable; @@ -24,7 +24,7 @@ export interface UtxoTrackerInternals { export const createUtxoProvider = ( utxoProvider: UtxoProvider, - addresses$: Observable, + addresses$: Observable, tipBlockHeight$: Observable, retryBackoffConfig: RetryBackoffConfig, onFatalError?: (value: unknown) => void diff --git a/packages/wallet/src/services/WalletUtil.ts b/packages/wallet/src/services/WalletUtil.ts index a0e78040b62..b16444b6e2b 100644 --- a/packages/wallet/src/services/WalletUtil.ts +++ b/packages/wallet/src/services/WalletUtil.ts @@ -58,7 +58,7 @@ export const createOutputValidator = ({ protocolParameters$ }: OutputValidatorCo protocolParameters?: ProtocolParametersRequiredByOutputValidator ): Promise => { const { coinsPerUtxoByte, maxValueSize } = protocolParameters || (await firstValueFrom(protocolParameters$)); - const stubMaxSizeAddress = Cardano.Address( + const stubMaxSizeAddress = Cardano.PaymentAddress( 'addr_test1qqydn46r6mhge0kfpqmt36m6q43knzsd9ga32n96m89px3nuzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475qypp3m9' ); const stubTxOut: Cardano.TxOut = { address: stubMaxSizeAddress, value }; diff --git a/packages/wallet/test/SingleAddressWallet/methods.test.ts b/packages/wallet/test/SingleAddressWallet/methods.test.ts index f1372ebf739..2b04d42e717 100644 --- a/packages/wallet/test/SingleAddressWallet/methods.test.ts +++ b/packages/wallet/test/SingleAddressWallet/methods.test.ts @@ -18,13 +18,13 @@ const serializedForeignTx = const outputs = [ { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qpu5vlrf4xkxv2qpwngf6cjhtw542ayty80v8dyr49rf5ewvxwdrt70qlcpeeagscasafhffqsxy36t90ldv06wqrk2qum8x5w' ), value: { coins: 11_111_111n } }, { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp' ), value: { diff --git a/packages/wallet/test/SingleAddressWallet/rollback.test.ts b/packages/wallet/test/SingleAddressWallet/rollback.test.ts index 4dafa7081d0..fab74a7455e 100644 --- a/packages/wallet/test/SingleAddressWallet/rollback.test.ts +++ b/packages/wallet/test/SingleAddressWallet/rollback.test.ts @@ -83,7 +83,7 @@ const createWallet = async (stores: WalletStores, providers: Providers, pollingC }; const txOut: Cardano.TxOut = { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp' ), value: { diff --git a/packages/wallet/test/Transaction/createTransactionInternals.test.ts b/packages/wallet/test/Transaction/createTransactionInternals.test.ts index a51db8da983..dbef89b869d 100644 --- a/packages/wallet/test/Transaction/createTransactionInternals.test.ts +++ b/packages/wallet/test/Transaction/createTransactionInternals.test.ts @@ -6,7 +6,7 @@ import { SelectionConstraints } from '../../../input-selection/test/util'; import { SelectionSkeleton, roundRobinRandomImprove } from '@cardano-sdk/input-selection'; import { mockNetworkInfoProvider, utxo } from '../mocks'; -const address = Cardano.Address( +const address = Cardano.PaymentAddress( 'addr_test1qq585l3hyxgj3nas2v3xymd23vvartfhceme6gv98aaeg9muzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475q2g7k3g' ); @@ -35,7 +35,7 @@ describe('Transaction.createTransactionInternals', () => { const ledgerTip = await provider.ledgerTip(); const overrides = props(result.selection); return await createTransactionInternals({ - changeAddress: Cardano.Address( + changeAddress: Cardano.PaymentAddress( 'addr_test1qqydn46r6mhge0kfpqmt36m6q43knzsd9ga32n96m89px3nuzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475qypp3m9' ), validityInterval: { diff --git a/packages/wallet/test/hardware/LedgerKeyAgent.test.ts b/packages/wallet/test/hardware/LedgerKeyAgent.test.ts index 5eef2a8199a..66225e84fb4 100644 --- a/packages/wallet/test/hardware/LedgerKeyAgent.test.ts +++ b/packages/wallet/test/hardware/LedgerKeyAgent.test.ts @@ -102,13 +102,13 @@ describe('LedgerKeyAgent', () => { describe('signTransaction', () => { const outputs = [ { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qpu5vlrf4xkxv2qpwngf6cjhtw542ayty80v8dyr49rf5ewvxwdrt70qlcpeeagscasafhffqsxy36t90ldv06wqrk2qum8x5w' ), value: { coins: 11_111_111n } }, { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp' ), value: { diff --git a/packages/wallet/test/hardware/TrezorKeyAgent.test.ts b/packages/wallet/test/hardware/TrezorKeyAgent.test.ts index d409d72dd95..42831bc792b 100644 --- a/packages/wallet/test/hardware/TrezorKeyAgent.test.ts +++ b/packages/wallet/test/hardware/TrezorKeyAgent.test.ts @@ -118,13 +118,13 @@ describe('TrezorKeyAgent', () => { test('sign tx', async () => { const outputs = [ { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qpu5vlrf4xkxv2qpwngf6cjhtw542ayty80v8dyr49rf5ewvxwdrt70qlcpeeagscasafhffqsxy36t90ldv06wqrk2qum8x5w' ), value: { coins: 11_111_111n } }, { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp' ), value: { diff --git a/packages/wallet/test/integration/buildTx.test.ts b/packages/wallet/test/integration/buildTx.test.ts index 4f01bca6831..8c344ad3201 100644 --- a/packages/wallet/test/integration/buildTx.test.ts +++ b/packages/wallet/test/integration/buildTx.test.ts @@ -191,7 +191,7 @@ describe('buildTx', () => { let assetId: Cardano.AssetId; let assetQuantity: bigint; let assets: Cardano.TokenMap; - let address: Cardano.Address; + let address: Cardano.PaymentAddress; let datumHash: Crypto.Hash32ByteBase16; let output1Coin: bigint; let output2Base: Cardano.TxOut; @@ -200,7 +200,7 @@ describe('buildTx', () => { assetId = Cardano.AssetId('1ec85dcee27f2d90ec1f9a1e4ce74a667dc9be8b184463223f9c960150584c'); assetQuantity = 100n; assets = new Map([[assetId, assetQuantity]]); - address = Cardano.Address('addr_test1vr8nl4u0u6fmtfnawx2rxfz95dy7m46t6dhzdftp2uha87syeufdg'); + address = Cardano.PaymentAddress('addr_test1vr8nl4u0u6fmtfnawx2rxfz95dy7m46t6dhzdftp2uha87syeufdg'); datumHash = Crypto.Hash32ByteBase16('3e33018e8293d319ef5b3ac72366dd28006bd315b715f7e7cfcbd3004129b80d'); output1Coin = 10_000_000n; output2Base = mocks.utxo[0][1]; @@ -339,7 +339,7 @@ describe('buildTx', () => { }); it('certificates are added to tx.body on build', async () => { - const address = Cardano.Address('addr_test1vr8nl4u0u6fmtfnawx2rxfz95dy7m46t6dhzdftp2uha87syeufdg'); + const address = Cardano.PaymentAddress('addr_test1vr8nl4u0u6fmtfnawx2rxfz95dy7m46t6dhzdftp2uha87syeufdg'); txBuilder.delegate(poolId); const maybeValidTxOut = await txBuilder.buildOutput().address(address).coin(10_000_000n).build(); assertTxOutIsValid(maybeValidTxOut); diff --git a/packages/wallet/test/integration/cip30mapping.test.ts b/packages/wallet/test/integration/cip30mapping.test.ts index 082f464359c..99c3e58d97b 100644 --- a/packages/wallet/test/integration/cip30mapping.test.ts +++ b/packages/wallet/test/integration/cip30mapping.test.ts @@ -38,7 +38,7 @@ describe('cip30', () => { const simpleTxProps: InitializeTxProps = { outputs: new Set([ { - address: Cardano.Address( + address: Cardano.PaymentAddress( // eslint-disable-next-line max-len 'addr_test1qpu5vlrf4xkxv2qpwngf6cjhtw542ayty80v8dyr49rf5ewvxwdrt70qlcpeeagscasafhffqsxy36t90ldv06wqrk2qum8x5w' ), @@ -223,7 +223,7 @@ describe('cip30', () => { test('api.getUsedAddresses', async () => { const cipUsedAddressess = await api.getUsedAddresses(); const [{ address: walletAddress }] = await firstValueFrom(wallet.addresses$); - expect(cipUsedAddressess.map((cipAddr) => Cardano.Address(cipAddr))).toEqual([walletAddress]); + expect(cipUsedAddressess.map((cipAddr) => Cardano.PaymentAddress(cipAddr))).toEqual([walletAddress]); }); test('api.getUnusedAddresses', async () => { @@ -234,7 +234,7 @@ describe('cip30', () => { test('api.getChangeAddress', async () => { const cipChangeAddress = await api.getChangeAddress(); const [{ address: walletAddress }] = await firstValueFrom(wallet.addresses$); - expect(Cardano.Address(cipChangeAddress)).toEqual(walletAddress); + expect(Cardano.PaymentAddress(cipChangeAddress)).toEqual(walletAddress); }); test('api.getRewardAddresses', async () => { diff --git a/packages/wallet/test/integration/txChainingBalance.test.ts b/packages/wallet/test/integration/txChainingBalance.test.ts index 54cd8e81965..05937c6be57 100644 --- a/packages/wallet/test/integration/txChainingBalance.test.ts +++ b/packages/wallet/test/integration/txChainingBalance.test.ts @@ -17,7 +17,7 @@ describe('integration/txChainingBalance', () => { const balanceBefore = await firstValueFrom(wallet.balance.utxo.available$); const outputCoins = utxo[0][1].value.coins + 1n; // will always select at least 2 utxo with mock utxo set const output: Cardano.TxOut = { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qzs0umu0s2ammmpw0hea0w2crtcymdjvvlqngpgqy76gpfnuzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475qp3y3vz' ), value: { diff --git a/packages/wallet/test/mocks/mockChainHistoryProvider.ts b/packages/wallet/test/mocks/mockChainHistoryProvider.ts index 1c667c32886..ead734e38e2 100644 --- a/packages/wallet/test/mocks/mockChainHistoryProvider.ts +++ b/packages/wallet/test/mocks/mockChainHistoryProvider.ts @@ -9,7 +9,7 @@ export const getRandomTxId = () => .map(() => Math.floor(Math.random() * 16).toString(16)) .join(''); -const address = Cardano.Address( +const address = Cardano.PaymentAddress( 'addr_test1qq585l3hyxgj3nas2v3xymd23vvartfhceme6gv98aaeg9muzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475q2g7k3g' ); @@ -68,7 +68,7 @@ export const queryTransactionsResult: Paginated = { fee: 200_000n, inputs: [ { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qq585l3hyxgj3nas2v3xymd23vvartfhceme6gv98aaeg9muzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475q2g7k3g' ), index: 0, @@ -77,19 +77,19 @@ export const queryTransactionsResult: Paginated = { ], outputs: [ { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qpfhhfy2qgls50r9u4yh0l7z67xpg0a5rrhkmvzcuqrd0znuzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475q9gw0lz' ), value: { coins: 5_000_000n } }, { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qplfzem2xsc29wxysf8wkdqrm4s4mmncd40qnjq9sk84l3tuzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475q52ukj5' ), value: { coins: 5_000_000n } }, { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qqydn46r6mhge0kfpqmt36m6q43knzsd9ga32n96m89px3nuzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475qypp3m9' ), value: { coins: 9_825_963n } @@ -115,7 +115,7 @@ export const queryTransactionsResult: Paginated = { fee: 123n, inputs: [ { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qpfhhfy2qgls50r9u4yh0l7z67xpg0a5rrhkmvzcuqrd0znuzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475q9gw0lz' ), index: 0, @@ -124,7 +124,7 @@ export const queryTransactionsResult: Paginated = { ], outputs: [ { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qq585l3hyxgj3nas2v3xymd23vvartfhceme6gv98aaeg9muzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475q2g7k3g' ), value: { coins: 5_000_000n } diff --git a/packages/wallet/test/mocks/mockData.ts b/packages/wallet/test/mocks/mockData.ts index 4090fccdc50..f303632cf1f 100644 --- a/packages/wallet/test/mocks/mockData.ts +++ b/packages/wallet/test/mocks/mockData.ts @@ -78,14 +78,14 @@ export const rewardAccountBalance2 = rewardAccountBalance + 1n; export const utxosWithLowCoins: Cardano.Utxo[] = [ [ { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qzs0umu0s2ammmpw0hea0w2crtcymdjvvlqngpgqy76gpfnuzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475qp3y3vz' ), index: 1, txId: Cardano.TransactionId('c7c0973c6bbf1a04a9f306da7814b4fa564db649bf48b0bd93c273bd03143547') }, { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qq585l3hyxgj3nas2v3xymd23vvartfhceme6gv98aaeg9muzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475q2g7k3g' ), value: { @@ -95,14 +95,14 @@ export const utxosWithLowCoins: Cardano.Utxo[] = [ ], [ { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qzs0umu0s2ammmpw0hea0w2crtcymdjvvlqngpgqy76gpfnuzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475qp3y3vz' ), index: 2, txId: Cardano.TransactionId('c7c0973c6bbf1a04a9f306da7814b4fa564db649bf48b0bd93c273bd03143547') }, { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qq585l3hyxgj3nas2v3xymd23vvartfhceme6gv98aaeg9muzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475q2g7k3g' ), value: { diff --git a/packages/wallet/test/mocks/mockUtxoProvider.ts b/packages/wallet/test/mocks/mockUtxoProvider.ts index 821158dc0a7..92277090b0b 100644 --- a/packages/wallet/test/mocks/mockUtxoProvider.ts +++ b/packages/wallet/test/mocks/mockUtxoProvider.ts @@ -5,14 +5,14 @@ import delay from 'delay'; export const utxo: Cardano.Utxo[] = [ [ { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qq585l3hyxgj3nas2v3xymd23vvartfhceme6gv98aaeg9muzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475q2g7k3g' ), index: 1, txId: Cardano.TransactionId('bb217abaca60fc0ca68c1555eca6a96d2478547818ae76ce6836133f3cc546e0') }, { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qq585l3hyxgj3nas2v3xymd23vvartfhceme6gv98aaeg9muzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475q2g7k3g' ), value: { @@ -26,14 +26,14 @@ export const utxo: Cardano.Utxo[] = [ ], [ { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qzs0umu0s2ammmpw0hea0w2crtcymdjvvlqngpgqy76gpfnuzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475qp3y3vz' ), index: 0, txId: Cardano.TransactionId('c7c0973c6bbf1a04a9f306da7814b4fa564db649bf48b0bd93c273bd03143547') }, { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qq585l3hyxgj3nas2v3xymd23vvartfhceme6gv98aaeg9muzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475q2g7k3g' ), value: { @@ -44,14 +44,14 @@ export const utxo: Cardano.Utxo[] = [ ], [ { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qzs0umu0s2ammmpw0hea0w2crtcymdjvvlqngpgqy76gpfnuzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475qp3y3vz' ), index: 1, txId: Cardano.TransactionId('c7c0973c6bbf1a04a9f306da7814b4fa564db649bf48b0bd93c273bd03143547') }, { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qq585l3hyxgj3nas2v3xymd23vvartfhceme6gv98aaeg9muzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475q2g7k3g' ), value: { @@ -61,14 +61,14 @@ export const utxo: Cardano.Utxo[] = [ ], [ { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qzs0umu0s2ammmpw0hea0w2crtcymdjvvlqngpgqy76gpfnuzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475qp3y3vz' ), index: 2, txId: Cardano.TransactionId('c7c0973c6bbf1a04a9f306da7814b4fa564db649bf48b0bd93c273bd03143547') }, { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qq585l3hyxgj3nas2v3xymd23vvartfhceme6gv98aaeg9muzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475q2g7k3g' ), value: { @@ -78,14 +78,14 @@ export const utxo: Cardano.Utxo[] = [ ], [ { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qzs0umu0s2ammmpw0hea0w2crtcymdjvvlqngpgqy76gpfnuzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475qp3y3vz' ), index: 3, txId: Cardano.TransactionId('c7c0973c6bbf1a04a9f306da7814b4fa564db649bf48b0bd93c273bd03143547') }, { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qq585l3hyxgj3nas2v3xymd23vvartfhceme6gv98aaeg9muzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475q2g7k3g' ), value: { @@ -95,14 +95,14 @@ export const utxo: Cardano.Utxo[] = [ ], [ { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qq585l3hyxgj3nas2v3xymd23vvartfhceme6gv98aaeg9muzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475q2g7k3g' ), index: 2, txId: Cardano.TransactionId('ea1517b8c36fea3148df9aa1f49bbee66ff59a5092331a67bd8b3c427e1d79d7') }, { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qq585l3hyxgj3nas2v3xymd23vvartfhceme6gv98aaeg9muzcjqw982pcftgx53fu5527z2cj2tkx2h8ux2vxsg475q2g7k3g' ), value: { @@ -127,7 +127,7 @@ export const mockUtxoProvider = ({ address, utxoSet = utxo }: { - address?: Cardano.Address; + address?: Cardano.PaymentAddress; utxoSet?: Cardano.Utxo[]; } = {}): UtxoProvider => ({ healthCheck: jest.fn().mockResolvedValue({ ok: true }), diff --git a/packages/wallet/test/services/ProviderTracker/TrackedUtxoProvider.test.ts b/packages/wallet/test/services/ProviderTracker/TrackedUtxoProvider.test.ts index 0cdd023ce19..19383bd3ee3 100644 --- a/packages/wallet/test/services/ProviderTracker/TrackedUtxoProvider.test.ts +++ b/packages/wallet/test/services/ProviderTracker/TrackedUtxoProvider.test.ts @@ -51,7 +51,7 @@ describe('TrackedStakePoolProvider', () => { (provider) => provider.utxoByAddresses({ addresses: [ - Cardano.Address( + Cardano.PaymentAddress( // eslint-disable-next-line max-len 'addr_test1qpcnmvyjmxmsm75f747u566gw7ewz4mesdw7yl278uf9r3f5l7d7dpx2ymfwlm3e56flupga8yamjr2kwdt7dw77ktyqqtx2r7' ) diff --git a/packages/wallet/test/services/WalletUtil.test.ts b/packages/wallet/test/services/WalletUtil.test.ts index 1784d5cc67b..1b71f28db78 100644 --- a/packages/wallet/test/services/WalletUtil.test.ts +++ b/packages/wallet/test/services/WalletUtil.test.ts @@ -58,14 +58,14 @@ describe('WalletUtil', () => { const utxo: Cardano.Utxo[] = [ [ { - address: Cardano.Address( + address: Cardano.PaymentAddress( 'addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp' ), index: 0, txId: Cardano.TransactionId('0f3abbc8fc19c2e61bab6059bf8a466e6e754833a08a62a6c56fe0e78f19d9d5') }, { - address: Cardano.Address('addr_test1vr8nl4u0u6fmtfnawx2rxfz95dy7m46t6dhzdftp2uha87syeufdg'), + address: Cardano.PaymentAddress('addr_test1vr8nl4u0u6fmtfnawx2rxfz95dy7m46t6dhzdftp2uha87syeufdg'), value: { coins: 50_000_000n } } ] diff --git a/packages/wallet/test/services/util/equals.test.ts b/packages/wallet/test/services/util/equals.test.ts index 964dc7258e5..2839f7869cb 100644 --- a/packages/wallet/test/services/util/equals.test.ts +++ b/packages/wallet/test/services/util/equals.test.ts @@ -67,8 +67,8 @@ describe('equals', () => { }); test('groupedAddressesEquals compares address', () => { - const addresses1 = [{ address: 'a' as unknown as Cardano.Address } as GroupedAddress]; - const addresses2 = [{ address: 'b' as unknown as Cardano.Address } as GroupedAddress]; + const addresses1 = [{ address: 'a' as unknown as Cardano.PaymentAddress } as GroupedAddress]; + const addresses2 = [{ address: 'b' as unknown as Cardano.PaymentAddress } as GroupedAddress]; expect(groupedAddressesEquals(addresses1, [...addresses1.map((addr) => ({ ...addr }))])).toBe(true); expect(groupedAddressesEquals(addresses1, addresses2)).toBe(false); });