• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

input-output-hk / lace / 9413237952

08 Feb 2024 01:46PM UTC coverage: 52.934% (-0.9%) from 53.839%
9413237952

push

github

f98d1b
rhyslbw
chore: bump version

1989 of 4673 branches covered (42.56%)

Branch coverage included in aggregate %.

4487 of 7561 relevant lines covered (59.34%)

56.03 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/packages/core/src/ui/components/DappTransaction/DappTransaction.tsx
1
/* eslint-disable sonarjs/no-duplicate-string */
2
import React from 'react';
×
3
import { ErrorPane } from '@lace/common';
×
4
import { Wallet } from '@lace/cardano';
×
5
import { DappInfo, DappInfoProps } from '../DappInfo';
×
6
import { DappTxHeader } from './DappTxHeader/DappTxHeader';
×
7
import { DappTxAsset, DappTxAssetProps } from './DappTxAsset/DappTxAsset';
×
8
import { DappTxOutput, DappTxOutputProps } from './DappTxOutput/DappTxOutput';
×
9
import styles from './DappTransaction.module.scss';
×
10
import { useTranslate } from '@src/ui/hooks';
×
11
import { TransactionFee } from '@ui/components/ActivityDetail';
×
12

13
type TransactionDetails = {
14
  fee: string;
15
  outputs: DappTxOutputProps[];
16
  type: 'Send' | 'Mint';
17
  mintedAssets?: DappTxAssetProps[];
18
  burnedAssets?: DappTxAssetProps[];
19
};
20

21
export interface DappTransactionProps {
22
  /** Transaction details such as type, amount, fee and address */
23
  transaction: TransactionDetails;
24
  /** dApp information such as logo, name and url */
25
  dappInfo: Omit<DappInfoProps, 'className'>;
26
  /** Optional error message */
27
  errorMessage?: string;
28
  fiatCurrencyCode?: string;
29
  fiatCurrencyPrice?: number;
30
  coinSymbol?: string;
31
}
32

33
export const DappTransaction = ({
×
34
  transaction: { type, outputs, fee, mintedAssets, burnedAssets },
35
  dappInfo,
36
  errorMessage,
37
  fiatCurrencyCode,
38
  fiatCurrencyPrice,
39
  coinSymbol
40
}: DappTransactionProps): React.ReactElement => {
41
  const { t } = useTranslate();
×
42
  return (
×
43
    <div>
44
      <DappInfo {...dappInfo} className={styles.dappInfo} />
45
      {errorMessage && <ErrorPane error={errorMessage} className={styles.error} />}
×
46
      <div data-testid="dapp-transaction-container" className={styles.details}>
47
        {type === 'Mint' && mintedAssets?.length > 0 && (
×
48
          <>
49
            <DappTxHeader
50
              title={t('package.core.dappTransaction.transaction')}
51
              subtitle={t('package.core.dappTransaction.mint')}
52
            />
53
            {mintedAssets.map((asset) => (
54
              <DappTxAsset key={asset.name} {...asset} />
×
55
            ))}
56
          </>
57
        )}
58
        {type === 'Mint' && burnedAssets?.length > 0 && (
×
59
          <>
60
            <DappTxHeader
61
              title={mintedAssets?.length > 0 ? undefined : t('package.core.dappTransaction.transaction')}
×
62
              subtitle={t('package.core.dappTransaction.burn')}
63
            />
64
            {burnedAssets.map((asset) => (
65
              <DappTxAsset key={asset.name} {...asset} />
×
66
            ))}
67
          </>
68
        )}
69
        {type === 'Send' && (
×
70
          <>
71
            <DappTxHeader
72
              title={t('package.core.dappTransaction.transaction')}
73
              subtitle={t('package.core.dappTransaction.send')}
74
            />
75
            {outputs.map((output) => (
76
              <DappTxOutput key={output.recipient} {...output} />
×
77
            ))}
78
          </>
79
        )}
80
        {fee && fee !== '-' && (
×
81
          <TransactionFee
82
            fee={fee}
83
            amountTransformer={(ada: string) =>
84
              `${Wallet.util.convertAdaToFiat({ ada, fiat: fiatCurrencyPrice })} ${fiatCurrencyCode}`
×
85
            }
86
            coinSymbol={coinSymbol}
87
          />
88
        )}
89
      </div>
90
    </div>
91
  );
92
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc