Skip to content

Commit b43ee25

Browse files
authored
chore: Update Readme & Unknown Currency Name Fix (#263)
1 parent 3775fb9 commit b43ee25

File tree

4 files changed

+98
-21
lines changed

4 files changed

+98
-21
lines changed

packages/create-invoice-form/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,36 @@ export default function CreateInvoice() {
5353
}
5454
```
5555

56+
### Important Note on Currencies Prop
57+
58+
- The currencies prop is now optional.
59+
- If you include the currencies prop and follow the proper format, it will override the default currencies.
60+
- To use the default currencies list, simply omit the currencies prop.
61+
62+
#### Example Override for Currencies
63+
64+
If you need to customize the currencies list, ensure you follow the correct format:
65+
66+
```ts
67+
export const currencies: CurrencyTypes.CurrencyInput[] = [
68+
{
69+
symbol: "FAU",
70+
address: "0x370DE27fdb7D1Ff1e1BaA7D11c5820a324Cf623C",
71+
network: "sepolia",
72+
decimals: 18,
73+
type: RequestLogicTypes.CURRENCY.ERC20,
74+
},
75+
{
76+
symbol: "ETH",
77+
network: "sepolia",
78+
decimals: 18,
79+
type: RequestLogicTypes.CURRENCY.ETH,
80+
},
81+
];
82+
```
83+
84+
When added, this will replace the default currencies list. To retain the defaults, do not include the `currencies` prop.
85+
5686
#### [initializeRN.ts](https://github.com/RequestNetwork/invoicing-template/blob/main/utils/initializeRN.ts)
5787

5888
Initialize the `RequestNetwork` object using an Ethers `Signer` or Viem `WalletClient`.

packages/invoice-dashboard/README.md

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,36 @@ export default function InvoiceDashboardPage() {
5353
}
5454
```
5555

56+
### Important Note on Currencies Prop
57+
58+
- The currencies prop is now optional.
59+
- If you include the currencies prop and follow the proper format, it will override the default currencies.
60+
- To use the default currencies list, simply omit the currencies prop.
61+
62+
#### Example Override for Currencies
63+
64+
If you need to customize the currencies list, ensure you follow the correct format:
65+
66+
```ts
67+
export const currencies: CurrencyTypes.CurrencyInput[] = [
68+
{
69+
symbol: "FAU",
70+
address: "0x370DE27fdb7D1Ff1e1BaA7D11c5820a324Cf623C",
71+
network: "sepolia",
72+
decimals: 18,
73+
type: RequestLogicTypes.CURRENCY.ERC20,
74+
},
75+
{
76+
symbol: "ETH",
77+
network: "sepolia",
78+
decimals: 18,
79+
type: RequestLogicTypes.CURRENCY.ETH,
80+
},
81+
];
82+
```
83+
84+
When added, this will replace the default currencies list. To retain the defaults, do not include the `currencies` prop.
85+
5686
#### [initializeRN.ts](https://github.com/RequestNetwork/invoicing-template/blob/main/utils/initializeRN.ts)
5787

5888
Initialize the `RequestNetwork` object using an Ethers `Signer` or Viem `WalletClient`.
@@ -123,15 +153,15 @@ export const config: IConfig = {
123153
| Accept Request ||
124154
| Cancel Request ||
125155
| Add Stakeholder ||
126-
| Native Payment | |
127-
| Conversion Payment | |
156+
| Native Payment | |
157+
| Conversion Payment | |
128158
| Batch Payment ||
129159
| Declarative Payment ||
130160
| Swap-to-Pay Payment ||
131161
| Swap-to-Conversion Payment ||
132162
| Escrow Payment ||
133-
| Improved UI and UX | |
134-
| More Chains and Currencies | |
163+
| Improved UI and UX | |
164+
| More Chains and Currencies | |
135165
| More Configuration Options ||
136166
| Attachments ||
137167

packages/invoice-dashboard/src/lib/view-requests.svelte

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@
7676
let activeConfig = config ? config : defaultConfig;
7777
let mainColor = activeConfig.colors.main;
7878
let secondaryColor = activeConfig.colors.secondary;
79-
let account: GetAccountReturnType | undefined = wagmiConfig && getAccount(wagmiConfig);
79+
let account: GetAccountReturnType | undefined =
80+
wagmiConfig && getAccount(wagmiConfig);
8081
8182
let loading = false;
8283
let searchQuery = "";
@@ -142,8 +143,7 @@
142143
if (typeof unwatchAccount === "function") unwatchAccount();
143144
});
144145
145-
$: cipherProvider =
146-
requestNetwork?.getCipherProvider() as CipherProvider;
146+
$: cipherProvider = requestNetwork?.getCipherProvider() as CipherProvider;
147147
148148
$: {
149149
signer = account?.address;
@@ -155,7 +155,10 @@
155155
currencyManager = initializeCurrencyManager(currencies);
156156
});
157157
158-
const getRequests = async (account: GetAccountReturnType, requestNetwork: RequestNetwork | undefined | null) => {
158+
const getRequests = async (
159+
account: GetAccountReturnType,
160+
requestNetwork: RequestNetwork | undefined | null
161+
) => {
159162
if (!account?.address || !requestNetwork) return;
160163
161164
try {
@@ -385,16 +388,27 @@
385388
activeRequest = undefined;
386389
};
387390
388-
const loadRequests = async (sliderValue: string, currentAccount: GetAccountReturnType | undefined, currentRequestNetwork: RequestNetwork | undefined | null) => {
389-
if (!currentAccount?.address || !currentRequestNetwork || !cipherProvider) return;
391+
const loadRequests = async (
392+
sliderValue: string,
393+
currentAccount: GetAccountReturnType | undefined,
394+
currentRequestNetwork: RequestNetwork | undefined | null
395+
) => {
396+
if (!currentAccount?.address || !currentRequestNetwork || !cipherProvider)
397+
return;
390398
391399
loading = true;
392400
if (sliderValue === "on") {
393401
try {
394402
const signer = await getEthersSigner(wagmiConfig);
395403
if (signer && currentAccount?.address) {
396-
loadSessionSignatures = localStorage?.getItem("lit-wallet-sig") === null;
397-
await cipherProvider?.getSessionSignatures(signer, currentAccount.address, window.location.host, "Sign in to Lit Protocol through Request Network");
404+
loadSessionSignatures =
405+
localStorage?.getItem("lit-wallet-sig") === null;
406+
await cipherProvider?.getSessionSignatures(
407+
signer,
408+
currentAccount.address,
409+
window.location.host,
410+
"Sign in to Lit Protocol through Request Network"
411+
);
398412
cipherProvider?.enableDecryption(true);
399413
localStorage?.setItem("isDecryptionEnabled", JSON.stringify(true));
400414
}
@@ -413,6 +427,7 @@
413427
await getRequests(currentAccount, currentRequestNetwork);
414428
loading = false;
415429
};
430+
416431
$: loadRequests(sliderValueForDecryption, account, requestNetwork);
417432
</script>
418433

@@ -421,13 +436,12 @@
421436
style="--mainColor: {mainColor}; --secondaryColor: {secondaryColor}; "
422437
>
423438
{#if loadSessionSignatures}
424-
<Modal
425-
config={config}
426-
isOpen={true}
427-
title="Lit Protocol Signature Required"
428-
>
439+
<Modal {config} isOpen={true} title="Lit Protocol Signature Required">
429440
<div class="modal-content">
430-
<p>This signature is required only once per session and will allow you to:</p>
441+
<p>
442+
This signature is required only once per session and will allow you
443+
to:
444+
</p>
431445
<ul>
432446
<li>Access encrypted invoice details</li>
433447
</ul>
@@ -708,7 +722,10 @@
708722
<td><StatusLabel status={checkStatus(request)} /></td>
709723
<td>
710724
{#if request.paymentCurrencies.length > 0}
711-
<Network network={request.paymentCurrencies[0]?.network} />
725+
<Network
726+
network={request.paymentCurrencies[0]?.network}
727+
showLabel={true}
728+
/>
712729
{:else}
713730
<span class="text-gray-400">-</span>
714731
{/if}
@@ -1068,6 +1085,6 @@
10681085
10691086
.modal-content li {
10701087
margin-bottom: 0.5rem;
1071-
color: #4B5563;
1088+
color: #4b5563;
10721089
}
10731090
</style>

shared/icons/network/network-icon.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<div class="network-icon" aria-label={`Network: ${capitalize(network)}`}>
1313
<svelte:component this={icon} />
1414
{#if showLabel}
15-
<span>{capitalize(network)}</span>
15+
<span>{capitalize(network) || "Unknown"}</span>
1616
{/if}
1717
</div>
1818
{/if}

0 commit comments

Comments
 (0)