Skip to content

Commit 48ffccd

Browse files
authored
feat!: Override Parameter for Currencies and Payment Chains in Invoice Dashboard and Create Invoice Form (#242)
1 parent 4f2316d commit 48ffccd

File tree

5 files changed

+39
-30
lines changed

5 files changed

+39
-30
lines changed

packages/create-invoice-form/src/lib/create-invoice-form.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
totalAmount: 0,
116116
};
117117
118-
$: cipherProvider = undefined;
118+
$: cipherProvider = requestNetwork?.getCipherProvider();
119119
120120
$: {
121121
if (wagmiConfig) {

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,13 @@
152152
if (typeof unwatchAccount === "function") unwatchAccount();
153153
});
154154
155-
$: cipherProvider = undefined;
155+
$: cipherProvider =
156+
requestNetwork?.getCipherProvider() as CipherProviderTypes.ICipherProvider & {
157+
getSessionSignatures: (
158+
signer: ethers.Signer,
159+
walletAddress: `0x${string}`
160+
) => Promise<any>;
161+
};
156162
157163
$: {
158164
signer = account?.address;
@@ -355,7 +361,7 @@
355361
BigInt(request.expectedAmount),
356362
currencyInfo?.decimals ?? 18
357363
),
358-
currencySymbol: currencyInfo?.symbol,
364+
currencySymbol: currencyInfo?.symbol ?? "-",
359365
paymentCurrencies,
360366
};
361367
}

shared/icons/unkown.svelte

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<svg
2+
width="24"
3+
height="24"
4+
viewBox="0 0 12 12"
5+
enable-background="new 0 0 12 12"
6+
id="Слой_1"
7+
version="1.1"
8+
xml:space="preserve"
9+
xmlns="http://www.w3.org/2000/svg"
10+
xmlns:xlink="http://www.w3.org/1999/xlink"
11+
fill="#000000"
12+
><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g
13+
id="SVGRepo_tracerCarrier"
14+
stroke-linecap="round"
15+
stroke-linejoin="round"
16+
></g><g id="SVGRepo_iconCarrier"
17+
><path
18+
d="M6,0C2.6862793,0,0,2.6862793,0,6s2.6862793,6,6,6s6-2.6862793,6-6S9.3137207,0,6,0z M6.5,9.5h-1v-1h1V9.5z M7.2651367,6.1738281C6.7329102,6.5068359,6.5,6.6845703,6.5,7v0.5h-1V7c0-0.9023438,0.7138672-1.3486328,1.2348633-1.6738281 C7.2670898,4.9931641,7.5,4.8154297,7.5,4.5c0-0.5517578-0.4487305-1-1-1h-1c-0.5512695,0-1,0.4482422-1,1V5h-1V4.5 c0-1.1025391,0.8969727-2,2-2h1c1.1030273,0,2,0.8974609,2,2C8.5,5.4023438,7.7861328,5.8486328,7.2651367,6.1738281z"
19+
fill="#1D1D1B"
20+
></path></g
21+
></svg
22+
>

shared/utils/getNetworkIcon.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import OptimismIcon from "../icons/network/optimism.svelte";
1414
import ArbitrumIcon from "../icons/network/arbitrum.svelte";
1515
import MoonbeamIcon from "../icons/network/moonbeam.svelte";
1616
import FantomIcon from "../icons/network/fantom.svelte";
17+
import Unknown from "../icons/unkown.svelte";
1718

1819
export const getNetworkIcon = (network: string) => {
1920
const icons = {
@@ -35,5 +36,5 @@ export const getNetworkIcon = (network: string) => {
3536
moonbeam: MoonbeamIcon,
3637
};
3738

38-
return icons[network] || EthereumIcon;
39+
return icons[network] || Unknown;
3940
};

shared/utils/initCurrencyManager.ts

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -67,37 +67,17 @@ import { formattedCurrencyConversionPairs } from './currencyConversionPairs'
6767
export function initializeCurrencyManager(
6868
customCurrencies: CurrencyTypes.CurrencyInput[] = []
6969
): CurrencyManager {
70-
let currenciesToUse: any[];
71-
72-
const defaultCurrencies = CurrencyManager.getDefaultList().filter(
73-
(currency) => defaultCurrencyIds.includes(currency.id)
74-
);
75-
76-
currenciesToUse = defaultCurrencies;
77-
70+
// If customCurrencies is provided, use only those
7871
if (customCurrencies?.length > 0) {
79-
currenciesToUse.push(...customCurrencies);
72+
return new CurrencyManager(customCurrencies, {}, formattedCurrencyConversionPairs);
8073
}
8174

82-
// Filter out duplicates based on a unique identifier
83-
currenciesToUse = currenciesToUse.filter(
84-
(currency, index, self) =>
85-
index ===
86-
self.findIndex((t) => {
87-
if (currency.type === Types.RequestLogic.CURRENCY.ETH) {
88-
return t.type === currency.type && t.network === currency.network;
89-
} else if (currency.type === Types.RequestLogic.CURRENCY.ERC20) {
90-
return (
91-
t.network === currency.network &&
92-
t.address?.toLowerCase() === currency.address?.toLowerCase()
93-
);
94-
} else if (currency.type === Types.RequestLogic.CURRENCY.ISO4217) {
95-
return t.type === currency.type && t.symbol === currency.symbol;
96-
}
97-
})
75+
// Otherwise, use default currencies
76+
const defaultCurrencies = CurrencyManager.getDefaultList().filter(
77+
(currency) => defaultCurrencyIds.includes(currency.id)
9878
);
9979

100-
return new CurrencyManager(currenciesToUse, {}, formattedCurrencyConversionPairs);
80+
return new CurrencyManager(defaultCurrencies, {}, formattedCurrencyConversionPairs);
10181
}
10282

10383
export function initializeCurrencyManagerWithCurrencyIDS(

0 commit comments

Comments
 (0)