View on GitHub
File Changes

                      
import type { CoreAddressT } from '../database/primitives/enums';
import { CoreAddressTypes } from '../database/primitives/enums';
+
import { Bech32Prefix } from '../../../../../config/stringConfig';
import { RustModule } from '../../cardanoCrypto/rustLoader';

                      
export function addressToKind(
    }
  }
}
+

                      
+
export function addressToDisplayString(
+
  address: string
+
): string {
+
  try {
+
    // Need to try parsing as a legacy address first
+
    // Since parsing as bech32 directly may give a wrong result if the address contains a 1
+
    RustModule.WalletV2.Address.from_base58(address);
+
    return address;
+
  } catch (_e1) {
+
    try {
+
      const wasmAddr = RustModule.WalletV3.Address.from_bytes(
+
        Buffer.from(address, 'hex')
+
      );
+
      return wasmAddr.to_string(Bech32Prefix.ADDRESS);
+
    } catch (_e2) {
+
      throw new Error('addressToKind failed to parse address type ' + address);
+
    }
+
  }
+
}
  stringifyError,
} from '../../../../utils/logging';
import { LOVELACES_PER_ADA } from '../../../../config/numbersConfig';
+
import { Bech32Prefix } from '../../../../config/stringConfig';
import {
  GenerateTransferTxError
} from '../../errors';
      fee: fee.dividedBy(LOVELACES_PER_ADA),
      id: Buffer.from(fragment.id().as_bytes()).toString('hex'),
      encodedTx: fragment.as_bytes(),
+
      // recall: Daedalus addresses all have to be legacy so we don't turn them to bech32
      senders: Object.keys(addressKeys),
-
      receiver: outputAddr,
+
      receiver: RustModule.WalletV3.Address.from_bytes(
+
        Buffer.from(outputAddr, 'hex')
+
      ).to_string(Bech32Prefix.ADDRESS)
    };
  } catch (error) {
    Logger.error(`daedalusTransfer::buildTransferTx ${stringifyError(error)}`);
  stringifyError,
} from '../../../../utils/logging';
import { LOVELACES_PER_ADA } from '../../../../config/numbersConfig';
+
import { Bech32Prefix } from '../../../../config/stringConfig';
+
import { addressToDisplayString } from '../../lib/storage/bridge/utils';
import {
  GenerateTransferTxError
} from '../../errors';
      true,
    );

                      
+
    const uniqueSenders = Array.from(new Set(senderUtxos.map(utxo => utxo.receiver)));
+

                      
    // return summary of transaction
    return {
      recoveredBalance: totalBalance.dividedBy(LOVELACES_PER_ADA),
      fee: fee.dividedBy(LOVELACES_PER_ADA),
      id: Buffer.from(fragment.id().as_bytes()).toString('hex'),
      encodedTx: fragment.as_bytes(),
-
      // only display unique addresses
-
      senders: Array.from(new Set(senderUtxos.map(utxo => utxo.receiver))),
-
      receiver: outputAddr,
+
      // recall: some addresses may be legacy, some may be Shelley
+
      senders: uniqueSenders.map(addr => addressToDisplayString(addr)),
+
      receiver: RustModule.WalletV3.Address.from_bytes(
+
        Buffer.from(outputAddr, 'hex')
+
      ).to_string(Bech32Prefix.ADDRESS)
    };
  } catch (error) {
    Logger.error(`transfer::buildTransferTx ${stringifyError(error)}`);
    expect(transferInfo.fee.toString()).toBe('0.155383');
    expect(transferInfo.recoveredBalance.toString()).toBe('1');
    expect(transferInfo.senders).toEqual([address]);
-
    expect(transferInfo.receiver).toBe(outAddress);
+
    expect(transferInfo.receiver).toBe(bech32Addr);

                      
    // check tx itself
    const fragment = RustModule.WalletV3.Fragment.from_bytes(transferInfo.encodedTx);
    expect(transferInfo.fee.toString()).toBe('0.155482');
    expect(transferInfo.recoveredBalance.toString()).toBe('100.0001');
    expect(transferInfo.senders).toEqual([address]);
-
    expect(transferInfo.receiver).toBe(outAddress);
+
    expect(transferInfo.receiver).toBe(bech32Addr);

                      
    // check tx itself
    const fragment = RustModule.WalletV3.Fragment.from_bytes(transferInfo.encodedTx);
import {
  ChainDerivations,
} from '../../../../config/numbersConfig';
+
import { Bech32Prefix } from '../../../../config/stringConfig';

                      
import {
  loadLovefieldDB,
    RustModule.WalletV3.AddressDiscrimination.Production
  );
  return {
-
    address: addr.to_string('addr'),
+
    address: Buffer.from(addr.as_bytes()).toString('hex'),
    addressing: {
      path: [ChainDerivations.EXTERNAL, derivationId],
      startLevel: Bip44DerivationLevels.CHAIN.level,

                      
    expect(transferInfo.fee.toString()).toBe('0.155383');
    expect(transferInfo.recoveredBalance.toString()).toBe('1');
-
    expect(transferInfo.senders).toEqual([addr1.address]);
-
    expect(transferInfo.receiver).toBe(outAddress);
+
    expect(transferInfo.senders).toEqual([
+
      RustModule.WalletV3.Address.from_bytes(
+
        Buffer.from(addr1.address, 'hex')
+
      ).to_string(Bech32Prefix.ADDRESS)
+
    ]);
+
    expect(transferInfo.receiver).toBe(bech32Addr);

                      
    // check tx itself
    const fragment = RustModule.WalletV3.Fragment.from_bytes(transferInfo.encodedTx);