|
64 | 64 | let otherItems: any;
|
65 | 65 | let sellerInfo: SellerInfo[] = [];
|
66 | 66 | let buyerInfo: BuyerInfo[] = [];
|
| 67 | + let unknownCurrency = currency?.decimals === undefined; |
67 | 68 | let isPayee = request?.payee?.value.toLowerCase() === address?.toLowerCase();
|
68 | 69 | let unsupportedNetwork = false;
|
69 | 70 | let hexStringChain = "0x" + account?.chainId?.toString(16);
|
|
155 | 156 | }
|
156 | 157 |
|
157 | 158 | $: {
|
158 |
| - if (account && network) { |
| 159 | + if (account && network && !unknownCurrency) { |
159 | 160 | checkBalance();
|
160 | 161 | }
|
161 | 162 | }
|
|
504 | 505 | token: paymentCurrencies[0].address as `0x${string}`,
|
505 | 506 | chainId: invoiceNetworkId,
|
506 | 507 | });
|
507 |
| - ; |
508 | 508 | userBalance = balance.formatted;
|
509 | 509 | hasEnoughBalance = balance.value >= BigInt(request.expectedAmount);
|
510 | 510 | } else {
|
|
637 | 637 | <h3 class="invoice-info-payment">
|
638 | 638 | <span style="font-weight: 500;">Payment Chain:</span>
|
639 | 639 | {paymentCurrencies && paymentCurrencies.length > 0
|
640 |
| - ? paymentCurrencies[0]?.network || "-" |
| 640 | + ? paymentCurrencies[0]?.network || "Unknown" |
641 | 641 | : ""}
|
642 | 642 | </h3>
|
643 | 643 | <h3 class="invoice-info-payment">
|
644 | 644 | <span style="font-weight: 500;">Invoice Currency:</span>
|
645 |
| - {currency?.symbol || "-"} |
| 645 | + {currency?.symbol || "Unknown"} |
646 | 646 | </h3>
|
647 | 647 |
|
648 | 648 | <h3 class="invoice-info-payment">
|
649 | 649 | <span style="font-weight: 500;">Settlement Currency:</span>
|
650 | 650 | {paymentCurrencies && paymentCurrencies.length > 0
|
651 |
| - ? paymentCurrencies[0]?.symbol || "-" |
| 651 | + ? paymentCurrencies[0]?.symbol || "Unknown" |
652 | 652 | : ""}
|
653 | 653 | </h3>
|
654 | 654 |
|
|
674 | 674 | <p class="truncate description-text">{item.name || "-"}</p>
|
675 | 675 | </th>
|
676 | 676 | <td>{item.quantity || "-"}</td>
|
677 |
| - <td |
678 |
| - >{item.unitPrice |
679 |
| - ? formatUnits(item.unitPrice, currency?.decimals ?? 18) |
680 |
| - : "-"}</td |
681 |
| - > |
682 |
| - <td |
683 |
| - >{item.discount |
| 677 | + <td> |
| 678 | + {#if unknownCurrency} |
| 679 | + Unknown |
| 680 | + {:else} |
| 681 | + {item.unitPrice |
| 682 | + ? formatUnits(item.unitPrice, currency?.decimals ?? 18) |
| 683 | + : "-"} |
| 684 | + {/if} |
| 685 | + </td> |
| 686 | + <td> |
| 687 | + {item.discount |
684 | 688 | ? formatUnits(item.discount, currency?.decimals ?? 18)
|
685 |
| - : "-"}</td |
686 |
| - > |
| 689 | + : "-"} |
| 690 | + </td> |
687 | 691 | <td>{Number(item.tax.amount || "-")}</td>
|
688 |
| - <td |
689 |
| - >{truncateNumberString( |
690 |
| - formatUnits( |
691 |
| - // @ts-expect-error |
692 |
| - calculateItemTotal(item), |
693 |
| - currency?.decimals ?? 18 |
694 |
| - ), |
695 |
| - 2 |
696 |
| - )}</td |
697 |
| - > |
| 692 | + <td> |
| 693 | + {#if unknownCurrency} |
| 694 | + Unknown |
| 695 | + {:else} |
| 696 | + {truncateNumberString( |
| 697 | + formatUnits( |
| 698 | + calculateItemTotal(item), |
| 699 | + currency?.decimals ?? 18 |
| 700 | + ), |
| 701 | + 2 |
| 702 | + )} |
| 703 | + {/if} |
| 704 | + </td> |
698 | 705 | </tr>
|
699 | 706 | {/each}
|
700 | 707 | </tbody>
|
|
723 | 730 | </p>
|
724 | 731 | </th>
|
725 | 732 | <td>{item.quantity || "-"}</td>
|
726 |
| - <td |
727 |
| - >{item.unitPrice |
728 |
| - ? formatUnits(item.unitPrice, currency?.decimals ?? 18) |
729 |
| - : "-"}</td |
730 |
| - > |
731 |
| - <td |
732 |
| - >{item.discount |
| 733 | + <td> |
| 734 | + {#if unknownCurrency} |
| 735 | + Unknown |
| 736 | + {:else} |
| 737 | + {item.unitPrice |
| 738 | + ? formatUnits(item.unitPrice, currency?.decimals ?? 18) |
| 739 | + : "-"} |
| 740 | + {/if} |
| 741 | + </td> |
| 742 | + <td> |
| 743 | + {item.discount |
733 | 744 | ? formatUnits(item.discount, currency?.decimals ?? 18)
|
734 |
| - : "-"}</td |
735 |
| - > |
| 745 | + : "-"} |
| 746 | + </td> |
736 | 747 | <td>{Number(item.tax.amount || "-")}</td>
|
737 |
| - <td |
738 |
| - >{truncateNumberString( |
739 |
| - formatUnits( |
740 |
| - // @ts-expect-error |
741 |
| - calculateItemTotal(item), |
742 |
| - currency?.decimals ?? 18 |
743 |
| - ), |
744 |
| - 2 |
745 |
| - )}</td |
746 |
| - > |
| 748 | + <td> |
| 749 | + {#if unknownCurrency} |
| 750 | + Unknown |
| 751 | + {:else} |
| 752 | + {truncateNumberString( |
| 753 | + formatUnits( |
| 754 | + calculateItemTotal(item), |
| 755 | + currency?.decimals ?? 18 |
| 756 | + ), |
| 757 | + 2 |
| 758 | + )} |
| 759 | + {/if} |
| 760 | + </td> |
747 | 761 | </tr>
|
748 | 762 | {/each}</tbody
|
749 | 763 | >
|
|
832 | 846 | </div>
|
833 | 847 | {/if}
|
834 | 848 | <div class="invoice-view-actions">
|
835 |
| - {#if !isPayee && !unsupportedNetwork && !isPaid && !isRequestPayed && !isSigningTransaction} |
| 849 | + {#if !isPayee && !unsupportedNetwork && !isPaid && !isRequestPayed && !isSigningTransaction && !unknownCurrency} |
836 | 850 | {#if !hasEnoughBalance}
|
837 | 851 | <div class="balance-warning">
|
838 | 852 | Insufficient funds: {Number(userBalance).toFixed(4)}
|
|
0 commit comments