@rainlanguage/ui-components 0.0.1-alpha.21 → 0.0.1-alpha.211
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__fixtures__/settings.yaml +125 -0
- package/dist/__mocks__/CodeMirrorRainlang.svelte +4 -0
- package/dist/__mocks__/CodeMirrorRainlang.svelte.d.ts +18 -0
- package/dist/__mocks__/MockComponent.svelte +4 -0
- package/dist/__mocks__/MockComponent.svelte.d.ts +3 -1
- package/dist/__mocks__/stores.d.ts +47 -33
- package/dist/__mocks__/stores.js +61 -38
- package/dist/components/ButtonLoading.svelte +1 -1
- package/dist/components/ButtonVaultLink.svelte +11 -11
- package/dist/components/ButtonVaultLink.svelte.d.ts +4 -3
- package/dist/components/CheckboxInactiveOrdersVault.svelte +20 -0
- package/dist/components/CheckboxInactiveOrdersVault.svelte.d.ts +19 -0
- package/dist/components/CheckboxMyItemsOnly.svelte +3 -2
- package/dist/components/CheckboxMyItemsOnly.svelte.d.ts +2 -3
- package/dist/components/CheckboxZeroBalanceVault.svelte.d.ts +2 -2
- package/dist/components/CodeMirrorDotrain.svelte +4 -0
- package/dist/components/CodeMirrorDotrain.svelte.d.ts +1 -0
- package/dist/components/CodeMirrorRainlang.svelte +3 -12
- package/dist/components/CodeMirrorRainlang.svelte.d.ts +2 -2
- package/dist/components/EditableSpan.svelte +3 -14
- package/dist/components/EditableSpan.svelte.d.ts +0 -1
- package/dist/components/Hash.svelte +3 -3
- package/dist/components/License.svelte +5 -4
- package/dist/components/ListViewOrderbookFilters.svelte +45 -23
- package/dist/components/ListViewOrderbookFilters.svelte.d.ts +27 -22
- package/dist/components/LocalDbStatusBadge.svelte +27 -0
- package/dist/components/LocalDbStatusBadge.svelte.d.ts +19 -0
- package/dist/components/LocalDbStatusCard.svelte +40 -0
- package/dist/components/LocalDbStatusCard.svelte.d.ts +20 -0
- package/dist/components/LocalDbStatusModal.svelte +103 -0
- package/dist/components/LocalDbStatusModal.svelte.d.ts +21 -0
- package/dist/components/OrderOrVaultHash.svelte +12 -12
- package/dist/components/OrderOrVaultHash.svelte.d.ts +4 -4
- package/dist/components/PageHeader.svelte +1 -1
- package/dist/components/TanstackAppTable.svelte +179 -28
- package/dist/components/TanstackAppTable.svelte.d.ts +14 -8
- package/dist/components/ToastDetail.svelte +42 -0
- package/dist/components/ToastDetail.svelte.d.ts +20 -0
- package/dist/components/Tooltip.svelte +8 -0
- package/dist/components/Tooltip.svelte.d.ts +21 -0
- package/dist/components/VaultBalanceChangeTypeFilter.svelte +23 -0
- package/dist/components/VaultBalanceChangeTypeFilter.svelte.d.ts +19 -0
- package/dist/components/VaultCard.svelte +18 -0
- package/dist/components/VaultCard.svelte.d.ts +19 -0
- package/dist/components/charts/LightweightChart.svelte +1 -1
- package/dist/components/charts/LightweightChart.svelte.d.ts +5 -5
- package/dist/components/charts/OrderTradesChart.svelte +300 -28
- package/dist/components/charts/OrderTradesChart.svelte.d.ts +4 -4
- package/dist/components/charts/TanstackLightweightChartLine.svelte +5 -9
- package/dist/components/charts/VaultBalanceChart.svelte +8 -26
- package/dist/components/charts/VaultBalanceChart.svelte.d.ts +1 -7
- package/dist/components/charts/transformAndSortData.d.ts +24 -0
- package/dist/components/charts/transformAndSortData.js +111 -0
- package/dist/components/checkbox/CheckboxActiveOrders.svelte +11 -0
- package/dist/components/checkbox/CheckboxActiveOrders.svelte.d.ts +19 -0
- package/dist/components/deployment/ButtonSelectOption.svelte +2 -0
- package/dist/components/deployment/ButtonSelectOption.svelte.d.ts +1 -0
- package/dist/components/deployment/ComposedRainlangModal.svelte +2 -1
- package/dist/components/deployment/ComposedRainlangModal.svelte.d.ts +1 -4
- package/dist/components/deployment/DeploymentSectionHeader.svelte +7 -4
- package/dist/components/deployment/DeploymentSteps.svelte +209 -216
- package/dist/components/deployment/DeploymentSteps.svelte.d.ts +6 -12
- package/dist/components/deployment/DeploymentTile.svelte +2 -2
- package/dist/components/deployment/DeploymentTile.svelte.d.ts +1 -1
- package/dist/components/deployment/DeploymentsSection.svelte +15 -22
- package/dist/components/deployment/DeploymentsSection.svelte.d.ts +3 -2
- package/dist/components/deployment/DepositInput.svelte +8 -10
- package/dist/components/deployment/DepositInput.svelte.d.ts +1 -2
- package/dist/components/deployment/DisclaimerModal.svelte +6 -7
- package/dist/components/deployment/FieldDefinitionInput.svelte +7 -11
- package/dist/components/deployment/FieldDefinitionInput.svelte.d.ts +1 -2
- package/dist/components/deployment/InvalidOrdersSection.svelte +17 -0
- package/dist/components/deployment/InvalidOrdersSection.svelte.d.ts +19 -0
- package/dist/components/deployment/{StrategyPage.svelte → OrderPage.svelte} +15 -24
- package/dist/components/deployment/OrderPage.svelte.d.ts +21 -0
- package/dist/components/deployment/SelectToken.svelte +125 -48
- package/dist/components/deployment/SelectToken.svelte.d.ts +4 -3
- package/dist/components/deployment/TokenBalance.svelte +19 -0
- package/dist/components/deployment/TokenBalance.svelte.d.ts +19 -0
- package/dist/components/deployment/TokenIOInput.svelte +25 -15
- package/dist/components/deployment/TokenIOInput.svelte.d.ts +3 -3
- package/dist/components/deployment/TokenSelectionModal.svelte +148 -0
- package/dist/components/deployment/TokenSelectionModal.svelte.d.ts +20 -0
- package/dist/components/deployment/{ValidStrategiesSection.svelte → ValidOrdersSection.svelte} +7 -7
- package/dist/components/deployment/ValidOrdersSection.svelte.d.ts +19 -0
- package/dist/components/deployment/VaultIdInformation.svelte +17 -0
- package/dist/components/deployment/VaultIdInformation.svelte.d.ts +21 -0
- package/dist/components/detail/OrderDetail.svelte +184 -80
- package/dist/components/detail/OrderDetail.svelte.d.ts +21 -15
- package/dist/components/detail/TanstackOrderQuote.svelte +92 -46
- package/dist/components/detail/TanstackOrderQuote.svelte.d.ts +14 -16
- package/dist/components/detail/VaultDetail.svelte +78 -77
- package/dist/components/detail/VaultDetail.svelte.d.ts +12 -18
- package/dist/components/dropdown/DropdownActiveNetworks.svelte +44 -0
- package/dist/components/dropdown/DropdownActiveNetworks.svelte.d.ts +19 -0
- package/dist/components/dropdown/DropdownCheckbox.svelte +4 -4
- package/dist/components/dropdown/DropdownOrderListAccounts.svelte +5 -2
- package/dist/components/dropdown/DropdownOrderListAccounts.svelte.d.ts +2 -3
- package/dist/components/dropdown/DropdownOrderbooksFilter.svelte +172 -0
- package/dist/components/dropdown/DropdownOrderbooksFilter.svelte.d.ts +25 -0
- package/dist/components/dropdown/DropdownTokensFilter.svelte +152 -0
- package/dist/components/dropdown/DropdownTokensFilter.svelte.d.ts +28 -0
- package/dist/components/icon/Refresh.svelte +2 -1
- package/dist/components/icon/Refresh.svelte.d.ts +1 -0
- package/dist/components/input/InputOrderHash.svelte +1 -1
- package/dist/components/input/InputOrderHash.svelte.d.ts +3 -3
- package/dist/components/input/InputRegistryUrl.svelte +36 -14
- package/dist/components/input/InputToken.svelte +2 -2
- package/dist/components/input/InputTokenAmount.svelte +16 -21
- package/dist/components/input/InputTokenAmount.svelte.d.ts +3 -3
- package/dist/components/tables/OrderAPY.svelte +6 -33
- package/dist/components/tables/OrderAPY.svelte.d.ts +1 -4
- package/dist/components/tables/OrderTradesListTable.svelte +84 -81
- package/dist/components/tables/OrderTradesListTable.svelte.d.ts +4 -4
- package/dist/components/tables/OrderVaultsVolTable.svelte +17 -22
- package/dist/components/tables/OrderVaultsVolTable.svelte.d.ts +2 -2
- package/dist/components/tables/OrdersListTable.svelte +200 -108
- package/dist/components/tables/OrdersListTable.svelte.d.ts +17 -21
- package/dist/components/tables/VaultBalanceChangesTable.svelte +83 -43
- package/dist/components/tables/VaultBalanceChangesTable.svelte.d.ts +13 -11
- package/dist/components/tables/VaultsListTable.svelte +268 -145
- package/dist/components/tables/VaultsListTable.svelte.d.ts +24 -32
- package/dist/components/transactions/FixedBottomTransaction.svelte +63 -0
- package/dist/components/transactions/FixedBottomTransaction.svelte.d.ts +16 -0
- package/dist/components/transactions/TransactionDetail.svelte +31 -0
- package/dist/components/transactions/TransactionDetail.svelte.d.ts +20 -0
- package/dist/components/transactions/TransactionList.svelte +17 -0
- package/dist/components/transactions/TransactionList.svelte.d.ts +16 -0
- package/dist/components/transactions/getStatusEmoji.d.ts +2 -0
- package/dist/components/transactions/getStatusEmoji.js +20 -0
- package/dist/components/wallet/WalletConnect.svelte +5 -4
- package/dist/components/wallet/WalletConnect.svelte.d.ts +0 -1
- package/dist/consts.d.ts +1 -0
- package/dist/consts.js +1 -0
- package/dist/errors/DeploymentStepsError.d.ts +8 -2
- package/dist/errors/DeploymentStepsError.js +7 -1
- package/dist/hooks/useGui.d.ts +1 -1
- package/dist/hooks/useGui.js +1 -1
- package/dist/hooks/useLocalDb.d.ts +3 -0
- package/dist/hooks/useLocalDb.js +10 -0
- package/dist/hooks/useRaindexClient.d.ts +3 -0
- package/dist/hooks/useRaindexClient.js +11 -0
- package/dist/index.d.ts +42 -19
- package/dist/index.js +41 -16
- package/dist/models/Transaction.d.ts +75 -0
- package/dist/models/Transaction.js +100 -0
- package/dist/providers/GuiProvider.svelte +1 -1
- package/dist/providers/GuiProvider.svelte.d.ts +1 -1
- package/dist/providers/LocalDbProvider.svelte +8 -0
- package/dist/providers/LocalDbProvider.svelte.d.ts +21 -0
- package/dist/providers/RaindexClientProvider.svelte +8 -0
- package/dist/providers/RaindexClientProvider.svelte.d.ts +21 -0
- package/dist/providers/dotrainRegistry/DotrainRegistryProvider.svelte +8 -0
- package/dist/providers/dotrainRegistry/DotrainRegistryProvider.svelte.d.ts +24 -0
- package/dist/providers/dotrainRegistry/context.d.ts +9 -0
- package/dist/providers/dotrainRegistry/context.js +40 -0
- package/dist/providers/dotrainRegistry/useDotrainRegistry.d.ts +5 -0
- package/dist/providers/dotrainRegistry/useDotrainRegistry.js +35 -0
- package/dist/providers/registry/RegistryManager.d.ts +65 -0
- package/dist/providers/registry/RegistryManager.js +133 -0
- package/dist/providers/registry/RegistryProvider.svelte +6 -0
- package/dist/providers/registry/RegistryProvider.svelte.d.ts +21 -0
- package/dist/providers/registry/context.d.ts +10 -0
- package/dist/providers/registry/context.js +46 -0
- package/dist/providers/registry/useRegistry.d.ts +7 -0
- package/dist/providers/registry/useRegistry.js +29 -0
- package/dist/providers/toasts/ToastProvider.svelte +17 -0
- package/dist/providers/toasts/ToastProvider.svelte.d.ts +18 -0
- package/dist/providers/toasts/context.d.ts +14 -0
- package/dist/providers/toasts/context.js +22 -0
- package/dist/providers/toasts/useToasts.d.ts +16 -0
- package/dist/providers/toasts/useToasts.js +63 -0
- package/dist/providers/transactions/TransactionManager.d.ts +235 -0
- package/dist/providers/transactions/TransactionManager.js +509 -0
- package/dist/providers/transactions/TransactionProvider.svelte +11 -0
- package/dist/providers/transactions/TransactionProvider.svelte.d.ts +24 -0
- package/dist/providers/transactions/context.d.ts +19 -0
- package/dist/providers/transactions/context.js +28 -0
- package/dist/providers/transactions/useTransactions.d.ts +13 -0
- package/dist/providers/transactions/useTransactions.js +18 -0
- package/dist/providers/wallet/WalletProvider.svelte +7 -0
- package/dist/providers/wallet/WalletProvider.svelte.d.ts +21 -0
- package/dist/providers/wallet/context.d.ts +10 -0
- package/dist/providers/wallet/context.js +47 -0
- package/dist/providers/wallet/useAccount.d.ts +8 -0
- package/dist/providers/wallet/useAccount.js +148 -0
- package/dist/queries/keys.d.ts +1 -0
- package/dist/queries/keys.js +1 -0
- package/dist/queries/queryClient.d.ts +1 -1
- package/dist/queries/queryClient.js +11 -6
- package/dist/services/awaitTransactionIndexing.d.ts +107 -0
- package/dist/services/awaitTransactionIndexing.js +58 -0
- package/dist/services/getExplorerLink.d.ts +1 -1
- package/dist/services/getExplorerLink.js +2 -4
- package/dist/services/handleShareChoices.d.ts +2 -2
- package/dist/services/handleShareChoices.js +7 -2
- package/dist/services/historicalOrderCharts.d.ts +2 -2
- package/dist/services/historicalOrderCharts.js +267 -333
- package/dist/services/index.d.ts +2 -1
- package/dist/services/index.js +2 -1
- package/dist/services/loadRegistryUrl.d.ts +2 -0
- package/dist/services/loadRegistryUrl.js +22 -0
- package/dist/services/pairTradesChartData.d.ts +47 -0
- package/dist/services/pairTradesChartData.js +190 -0
- package/dist/services/registry.d.ts +5 -5
- package/dist/services/registry.js +8 -208
- package/dist/services/time.d.ts +12 -0
- package/dist/services/time.js +88 -6
- package/dist/storesGeneric/cachedWritableStore.d.ts +57 -0
- package/dist/storesGeneric/cachedWritableStore.js +93 -0
- package/dist/types/account.d.ts +3 -0
- package/dist/types/appStores.d.ts +9 -14
- package/dist/types/modal.d.ts +26 -14
- package/dist/types/{strategy.d.ts → order.d.ts} +3 -3
- package/dist/types/order.js +1 -0
- package/dist/types/toast.d.ts +11 -0
- package/dist/types/toast.js +1 -0
- package/dist/types/tokenBalance.d.ts +6 -0
- package/dist/types/tokenBalance.js +1 -0
- package/dist/types/transaction.d.ts +66 -21
- package/dist/types/transaction.js +31 -1
- package/dist/utils/configHelpers.d.ts +4 -0
- package/dist/utils/configHelpers.js +21 -0
- package/dist/utils/constructHashLink.d.ts +24 -0
- package/dist/utils/constructHashLink.js +115 -0
- package/dist/utils/getNetworkName.d.ts +1 -0
- package/dist/utils/getNetworkName.js +13 -0
- package/dist/utils/number.d.ts +0 -7
- package/dist/utils/number.js +0 -27
- package/dist/utils/tokens.d.ts +2 -0
- package/dist/utils/tokens.js +3 -0
- package/dist/utils/vaultBalanceChangeLabels.d.ts +4 -0
- package/dist/utils/vaultBalanceChangeLabels.js +18 -0
- package/package.json +39 -34
- package/dist/__fixtures__/orderDetail.d.ts +0 -99
- package/dist/__fixtures__/orderDetail.js +0 -204
- package/dist/__fixtures__/settings-12-11-24.json +0 -160
- package/dist/__mocks__/mockTransactionStore.d.ts +0 -22
- package/dist/__mocks__/mockTransactionStore.js +0 -56
- package/dist/__mocks__/settings.d.ts +0 -3
- package/dist/__mocks__/settings.js +0 -37
- package/dist/components/deployment/InvalidStrategiesSection.svelte +0 -19
- package/dist/components/deployment/InvalidStrategiesSection.svelte.d.ts +0 -19
- package/dist/components/deployment/StrategyPage.svelte.d.ts +0 -19
- package/dist/components/deployment/ValidStrategiesSection.svelte.d.ts +0 -19
- package/dist/components/deployment/getDeploymentTransactionArgs.d.ts +0 -17
- package/dist/components/deployment/getDeploymentTransactionArgs.js +0 -28
- package/dist/components/detail/DepositOrWithdrawButtons.svelte +0 -44
- package/dist/components/detail/DepositOrWithdrawButtons.svelte.d.ts +0 -26
- package/dist/components/dropdown/DropdownActiveSubgraphs.svelte +0 -38
- package/dist/components/dropdown/DropdownActiveSubgraphs.svelte.d.ts +0 -21
- package/dist/components/dropdown/DropdownOrderStatus.svelte +0 -31
- package/dist/components/dropdown/DropdownOrderStatus.svelte.d.ts +0 -19
- package/dist/stores/transactionStore.d.ts +0 -98
- package/dist/stores/transactionStore.js +0 -303
- package/dist/utils/time.d.ts +0 -12
- package/dist/utils/time.js +0 -27
- package/dist/utils/vault.d.ts +0 -2
- package/dist/utils/vault.js +0 -29
- /package/dist/types/{strategy.js → account.js} +0 -0
|
@@ -31,8 +31,8 @@ function toggleItem(key) {
|
|
|
31
31
|
}
|
|
32
32
|
</script>
|
|
33
33
|
|
|
34
|
-
<
|
|
35
|
-
<
|
|
34
|
+
<div class="flex flex-col items-center gap-2">
|
|
35
|
+
<Label>{label}</Label>
|
|
36
36
|
<Button
|
|
37
37
|
color="alternative"
|
|
38
38
|
class="flex w-full justify-between overflow-hidden pl-2 pr-0 text-left"
|
|
@@ -66,9 +66,9 @@ function toggleItem(key) {
|
|
|
66
66
|
checked={key in value}
|
|
67
67
|
>
|
|
68
68
|
<div class="ml-2">
|
|
69
|
-
<div class="text-sm font-medium">{
|
|
69
|
+
<div class="text-sm font-medium">{optionValue}</div>
|
|
70
70
|
{#if !onlyTitle}
|
|
71
|
-
<div class="text-xs text-gray-500">{
|
|
71
|
+
<div class="text-xs text-gray-500">{key}</div>
|
|
72
72
|
{/if}
|
|
73
73
|
</div>
|
|
74
74
|
</Checkbox>
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
<script>import DropdownCheckbox from "./DropdownCheckbox.svelte";
|
|
2
|
-
|
|
2
|
+
import { getAccountsAsOptions } from "../../utils/configHelpers";
|
|
3
|
+
import { useRaindexClient } from "../../hooks/useRaindexClient";
|
|
3
4
|
export let activeAccountsItems;
|
|
4
|
-
|
|
5
|
+
const raindexClient = useRaindexClient();
|
|
6
|
+
$: accounts = raindexClient.getAllAccounts();
|
|
7
|
+
$: options = getAccountsAsOptions(accounts.value);
|
|
5
8
|
</script>
|
|
6
9
|
|
|
7
10
|
<div data-testid="accounts-dropdown">
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type {
|
|
2
|
+
import type { AppStoresInterface } from '../../types/appStores';
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
|
-
|
|
6
|
-
activeAccountsItems: Writable<Record<string, string>> | undefined;
|
|
5
|
+
activeAccountsItems: AppStoresInterface["activeAccountsItems"];
|
|
7
6
|
};
|
|
8
7
|
events: {
|
|
9
8
|
[evt: string]: CustomEvent<any>;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
<script>import { Button, Dropdown, Label, Checkbox, Input } from "flowbite-svelte";
|
|
2
|
+
import { ChevronDownSolid, SearchSolid } from "flowbite-svelte-icons";
|
|
3
|
+
import { isEmpty } from "lodash";
|
|
4
|
+
import { getNetworkName } from "../../utils/getNetworkName";
|
|
5
|
+
import { useRaindexClient } from "../../hooks/useRaindexClient";
|
|
6
|
+
export let activeOrderbookAddresses;
|
|
7
|
+
export let selectedOrderbookAddresses;
|
|
8
|
+
export let selectedChainIds;
|
|
9
|
+
export let label = "Filter by orderbook";
|
|
10
|
+
export let allLabel = "All orderbooks";
|
|
11
|
+
export let emptyMessage = "No orderbooks available";
|
|
12
|
+
const raindexClient = useRaindexClient();
|
|
13
|
+
let filteredOrderbooks = [];
|
|
14
|
+
let searchTerm = "";
|
|
15
|
+
let selectedIndex = 0;
|
|
16
|
+
$: orderbooksResult = raindexClient.getAllOrderbooks();
|
|
17
|
+
$: orderbooksMap = orderbooksResult?.value ?? /* @__PURE__ */ new Map();
|
|
18
|
+
$: orderbooksError = orderbooksResult?.error;
|
|
19
|
+
$: availableOrderbooks = (() => {
|
|
20
|
+
const items = [];
|
|
21
|
+
orderbooksMap.forEach((cfg, key) => {
|
|
22
|
+
if (selectedChainIds.length === 0 || selectedChainIds.includes(cfg.network.chainId)) {
|
|
23
|
+
items.push({
|
|
24
|
+
key,
|
|
25
|
+
address: cfg.address,
|
|
26
|
+
label: cfg.label,
|
|
27
|
+
chainId: cfg.network.chainId
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return items;
|
|
32
|
+
})();
|
|
33
|
+
$: selectedCount = selectedOrderbookAddresses.length;
|
|
34
|
+
$: allSelected = selectedCount === availableOrderbooks.length && availableOrderbooks.length > 0;
|
|
35
|
+
$: buttonText = selectedCount === 0 ? "Select orderbooks" : allSelected ? allLabel : `${selectedCount} orderbook${selectedCount > 1 ? "s" : ""}`;
|
|
36
|
+
$: {
|
|
37
|
+
if (searchTerm.trim() === "") {
|
|
38
|
+
filteredOrderbooks = availableOrderbooks;
|
|
39
|
+
selectedIndex = 0;
|
|
40
|
+
} else {
|
|
41
|
+
const term = searchTerm.toLowerCase();
|
|
42
|
+
filteredOrderbooks = availableOrderbooks.filter(
|
|
43
|
+
(ob) => ob.label?.toLowerCase().includes(term) || ob.address?.toLowerCase().includes(term) || ob.key?.toLowerCase().includes(term)
|
|
44
|
+
);
|
|
45
|
+
selectedIndex = filteredOrderbooks.length > 0 ? 0 : -1;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
$: sortedFilteredOrderbooks = [...filteredOrderbooks].sort((a, b) => {
|
|
49
|
+
const aSelected = selectedOrderbookAddresses.some(
|
|
50
|
+
(addr) => addr.toLowerCase() === a.address.toLowerCase()
|
|
51
|
+
);
|
|
52
|
+
const bSelected = selectedOrderbookAddresses.some(
|
|
53
|
+
(addr) => addr.toLowerCase() === b.address.toLowerCase()
|
|
54
|
+
);
|
|
55
|
+
if (aSelected === bSelected) return 0;
|
|
56
|
+
return aSelected ? -1 : 1;
|
|
57
|
+
});
|
|
58
|
+
function getDisplayName(ob) {
|
|
59
|
+
const truncatedAddr = `${ob.address.slice(0, 6)}...${ob.address.slice(-4)}`;
|
|
60
|
+
return ob.label ? `${ob.label} (${truncatedAddr})` : truncatedAddr;
|
|
61
|
+
}
|
|
62
|
+
function updateSelectedOrderbooks(newSelection) {
|
|
63
|
+
activeOrderbookAddresses.set(newSelection);
|
|
64
|
+
}
|
|
65
|
+
function toggleOrderbook({ address }) {
|
|
66
|
+
if (!address) return;
|
|
67
|
+
const normalizedAddress = address.toLowerCase();
|
|
68
|
+
const isSelected = selectedOrderbookAddresses.some(
|
|
69
|
+
(addr) => addr.toLowerCase() === normalizedAddress
|
|
70
|
+
);
|
|
71
|
+
const newSelection = isSelected ? $activeOrderbookAddresses.filter((addr) => addr.toLowerCase() !== normalizedAddress) : [...$activeOrderbookAddresses, normalizedAddress];
|
|
72
|
+
updateSelectedOrderbooks(newSelection);
|
|
73
|
+
}
|
|
74
|
+
function handleKeyDown(event) {
|
|
75
|
+
if (!sortedFilteredOrderbooks.length) return;
|
|
76
|
+
switch (event.key) {
|
|
77
|
+
case "Enter":
|
|
78
|
+
event.preventDefault();
|
|
79
|
+
if (sortedFilteredOrderbooks.length > 0) {
|
|
80
|
+
const orderbookToToggle = sortedFilteredOrderbooks[selectedIndex];
|
|
81
|
+
if (orderbookToToggle) {
|
|
82
|
+
toggleOrderbook(orderbookToToggle);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
case "ArrowDown":
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
selectedIndex = Math.min(selectedIndex + 1, sortedFilteredOrderbooks.length - 1);
|
|
89
|
+
break;
|
|
90
|
+
case "ArrowUp":
|
|
91
|
+
event.preventDefault();
|
|
92
|
+
selectedIndex = Math.max(selectedIndex - 1, 0);
|
|
93
|
+
break;
|
|
94
|
+
case "Escape":
|
|
95
|
+
searchTerm = "";
|
|
96
|
+
selectedIndex = -1;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
</script>
|
|
101
|
+
|
|
102
|
+
<div class="flex flex-col gap-x-2">
|
|
103
|
+
<Label>{label}</Label>
|
|
104
|
+
<div>
|
|
105
|
+
<Button
|
|
106
|
+
color="alternative"
|
|
107
|
+
class="flex w-full justify-between overflow-hidden pl-2 pr-0 text-left"
|
|
108
|
+
data-testid="dropdown-orderbooks-filter-button"
|
|
109
|
+
aria-label="Select orderbooks to filter"
|
|
110
|
+
aria-expanded="false"
|
|
111
|
+
aria-haspopup="listbox"
|
|
112
|
+
>
|
|
113
|
+
<div class="w-[110px] overflow-hidden text-ellipsis whitespace-nowrap">
|
|
114
|
+
{buttonText}
|
|
115
|
+
</div>
|
|
116
|
+
<ChevronDownSolid class="mx-2 h-3 w-3 text-black dark:text-white" />
|
|
117
|
+
</Button>
|
|
118
|
+
|
|
119
|
+
<Dropdown
|
|
120
|
+
class="max-h-[75vh] w-full min-w-60 overflow-y-auto py-0"
|
|
121
|
+
data-testid="dropdown-orderbooks-filter"
|
|
122
|
+
>
|
|
123
|
+
{#if orderbooksError}
|
|
124
|
+
<div class="ml-2 w-full rounded-lg p-3 text-red-500">
|
|
125
|
+
Cannot load orderbooks list: {orderbooksError.readableMsg || 'Unknown error'}
|
|
126
|
+
</div>
|
|
127
|
+
{:else if isEmpty(availableOrderbooks)}
|
|
128
|
+
<div class="ml-2 w-full rounded-lg p-3">{emptyMessage}</div>
|
|
129
|
+
{:else}
|
|
130
|
+
<div class="sticky top-0 bg-white p-3 dark:bg-gray-800">
|
|
131
|
+
<Input
|
|
132
|
+
placeholder="Search orderbooks..."
|
|
133
|
+
bind:value={searchTerm}
|
|
134
|
+
autofocus
|
|
135
|
+
on:keydown={handleKeyDown}
|
|
136
|
+
data-testid="orderbooks-filter-search"
|
|
137
|
+
>
|
|
138
|
+
<SearchSolid slot="left" class="h-4 w-4 text-gray-500" />
|
|
139
|
+
</Input>
|
|
140
|
+
</div>
|
|
141
|
+
|
|
142
|
+
{#if isEmpty(filteredOrderbooks)}
|
|
143
|
+
<div class="ml-2 w-full rounded-lg p-3">No orderbooks match your search</div>
|
|
144
|
+
{:else}
|
|
145
|
+
{#each sortedFilteredOrderbooks as orderbook, index (`${orderbook.address}-${orderbook.chainId}`)}
|
|
146
|
+
<Checkbox
|
|
147
|
+
data-testid="dropdown-orderbooks-filter-option"
|
|
148
|
+
class="w-full rounded-lg p-3 hover:bg-gray-100 dark:hover:bg-gray-600 {selectedIndex ===
|
|
149
|
+
index
|
|
150
|
+
? 'bg-blue-100 dark:bg-blue-900'
|
|
151
|
+
: ''}"
|
|
152
|
+
on:click={() => toggleOrderbook(orderbook)}
|
|
153
|
+
checked={!!(
|
|
154
|
+
orderbook.address &&
|
|
155
|
+
selectedOrderbookAddresses.some(
|
|
156
|
+
(addr) => addr.toLowerCase() === orderbook.address.toLowerCase()
|
|
157
|
+
)
|
|
158
|
+
)}
|
|
159
|
+
>
|
|
160
|
+
<div class="ml-2 flex w-full">
|
|
161
|
+
<div class="flex-1 text-sm font-medium">{getDisplayName(orderbook)}</div>
|
|
162
|
+
<div class="text-xs text-gray-500">
|
|
163
|
+
{getNetworkName(orderbook.chainId)}
|
|
164
|
+
</div>
|
|
165
|
+
</div>
|
|
166
|
+
</Checkbox>
|
|
167
|
+
{/each}
|
|
168
|
+
{/if}
|
|
169
|
+
{/if}
|
|
170
|
+
</Dropdown>
|
|
171
|
+
</div>
|
|
172
|
+
</div>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { Address } from '@rainlanguage/orderbook';
|
|
3
|
+
import type { AppStoresInterface } from '../../types/appStores';
|
|
4
|
+
declare const __propDef: {
|
|
5
|
+
props: {
|
|
6
|
+
activeOrderbookAddresses: AppStoresInterface["activeOrderbookAddresses"];
|
|
7
|
+
selectedOrderbookAddresses: Address[];
|
|
8
|
+
selectedChainIds: number[];
|
|
9
|
+
label?: string;
|
|
10
|
+
allLabel?: string;
|
|
11
|
+
emptyMessage?: string;
|
|
12
|
+
};
|
|
13
|
+
events: {
|
|
14
|
+
[evt: string]: CustomEvent<any>;
|
|
15
|
+
};
|
|
16
|
+
slots: {};
|
|
17
|
+
exports?: {} | undefined;
|
|
18
|
+
bindings?: string | undefined;
|
|
19
|
+
};
|
|
20
|
+
export type DropdownOrderbooksFilterProps = typeof __propDef.props;
|
|
21
|
+
export type DropdownOrderbooksFilterEvents = typeof __propDef.events;
|
|
22
|
+
export type DropdownOrderbooksFilterSlots = typeof __propDef.slots;
|
|
23
|
+
export default class DropdownOrderbooksFilter extends SvelteComponent<DropdownOrderbooksFilterProps, DropdownOrderbooksFilterEvents, DropdownOrderbooksFilterSlots> {
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
<script>import { Button, Dropdown, Label, Checkbox, Input } from "flowbite-svelte";
|
|
2
|
+
import { ChevronDownSolid, SearchSolid } from "flowbite-svelte-icons";
|
|
3
|
+
import { isEmpty } from "lodash";
|
|
4
|
+
import { getTokenDisplayName } from "../../utils/tokens";
|
|
5
|
+
import { getNetworkName } from "../../utils/getNetworkName";
|
|
6
|
+
export let tokensQuery;
|
|
7
|
+
export let activeTokens;
|
|
8
|
+
export let selectedTokens;
|
|
9
|
+
export let label = "Filter by tokens";
|
|
10
|
+
export let allLabel = "All tokens";
|
|
11
|
+
export let emptyMessage = "No tokens available";
|
|
12
|
+
export let loadingMessage = "Loading tokens...";
|
|
13
|
+
let filteredTokens = [];
|
|
14
|
+
let searchTerm = "";
|
|
15
|
+
let selectedIndex = 0;
|
|
16
|
+
$: availableTokens = $tokensQuery?.data || [];
|
|
17
|
+
$: selectedCount = selectedTokens.length;
|
|
18
|
+
$: allSelected = selectedCount === availableTokens.length && availableTokens.length > 0;
|
|
19
|
+
$: buttonText = selectedCount === 0 ? "Select tokens" : allSelected ? allLabel : `${selectedCount} token${selectedCount > 1 ? "s" : ""}`;
|
|
20
|
+
$: {
|
|
21
|
+
let tokensToFilter = availableTokens;
|
|
22
|
+
const getKey = (token) => `${token.address}-${token.chainId}`;
|
|
23
|
+
const uniqueTokensMap = /* @__PURE__ */ new Map();
|
|
24
|
+
tokensToFilter.forEach((token) => {
|
|
25
|
+
const key = getKey(token);
|
|
26
|
+
if (token.address && !uniqueTokensMap.has(key)) {
|
|
27
|
+
uniqueTokensMap.set(key, token);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
const uniqueTokens = Array.from(uniqueTokensMap.values());
|
|
31
|
+
if (searchTerm.trim() === "") {
|
|
32
|
+
filteredTokens = uniqueTokens;
|
|
33
|
+
} else {
|
|
34
|
+
const term = searchTerm.toLowerCase();
|
|
35
|
+
filteredTokens = uniqueTokens.filter(
|
|
36
|
+
(token) => token.symbol?.toLowerCase().includes(term) || token.name?.toLowerCase().includes(term) || token.address?.toLowerCase().includes(term)
|
|
37
|
+
);
|
|
38
|
+
selectedIndex = filteredTokens.length > 0 ? 0 : -1;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
$: sortedFilteredTokens = [...filteredTokens].sort((a, b) => {
|
|
42
|
+
const aSelected = selectedTokens.includes(a.address);
|
|
43
|
+
const bSelected = selectedTokens.includes(b.address);
|
|
44
|
+
if (aSelected === bSelected) return 0;
|
|
45
|
+
return aSelected ? -1 : 1;
|
|
46
|
+
});
|
|
47
|
+
function updateSelectedTokens(newSelection) {
|
|
48
|
+
activeTokens.set(newSelection);
|
|
49
|
+
}
|
|
50
|
+
function toggleToken({ address }) {
|
|
51
|
+
if (!address) return;
|
|
52
|
+
const isSelected = selectedTokens.includes(address);
|
|
53
|
+
const newSelection = isSelected ? $activeTokens.filter((addr) => addr !== address) : [...$activeTokens, address];
|
|
54
|
+
updateSelectedTokens(newSelection);
|
|
55
|
+
}
|
|
56
|
+
function handleKeyDown(event) {
|
|
57
|
+
if (!sortedFilteredTokens.length) return;
|
|
58
|
+
switch (event.key) {
|
|
59
|
+
case "Enter":
|
|
60
|
+
event.preventDefault();
|
|
61
|
+
if (sortedFilteredTokens.length > 0) {
|
|
62
|
+
const tokenToToggle = sortedFilteredTokens[selectedIndex];
|
|
63
|
+
if (tokenToToggle) {
|
|
64
|
+
toggleToken(tokenToToggle);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
68
|
+
case "ArrowDown":
|
|
69
|
+
event.preventDefault();
|
|
70
|
+
selectedIndex = Math.min(selectedIndex + 1, sortedFilteredTokens.length - 1);
|
|
71
|
+
break;
|
|
72
|
+
case "ArrowUp":
|
|
73
|
+
event.preventDefault();
|
|
74
|
+
selectedIndex = Math.max(selectedIndex - 1, 0);
|
|
75
|
+
break;
|
|
76
|
+
case "Escape":
|
|
77
|
+
searchTerm = "";
|
|
78
|
+
selectedIndex = -1;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
</script>
|
|
83
|
+
|
|
84
|
+
<div class="flex flex-col gap-x-2">
|
|
85
|
+
<Label>{label}</Label>
|
|
86
|
+
<div>
|
|
87
|
+
<Button
|
|
88
|
+
color="alternative"
|
|
89
|
+
class="flex w-full justify-between overflow-hidden pl-2 pr-0 text-left"
|
|
90
|
+
data-testid="dropdown-tokens-filter-button"
|
|
91
|
+
aria-label="Select tokens to filter"
|
|
92
|
+
aria-expanded="false"
|
|
93
|
+
aria-haspopup="listbox"
|
|
94
|
+
>
|
|
95
|
+
<div class="w-[90px] overflow-hidden text-ellipsis whitespace-nowrap">
|
|
96
|
+
{buttonText}
|
|
97
|
+
</div>
|
|
98
|
+
<ChevronDownSolid class="mx-2 h-3 w-3 text-black dark:text-white" />
|
|
99
|
+
</Button>
|
|
100
|
+
|
|
101
|
+
<Dropdown
|
|
102
|
+
class="max-h-[75vh] w-full min-w-60 overflow-y-auto py-0"
|
|
103
|
+
data-testid="dropdown-tokens-filter"
|
|
104
|
+
>
|
|
105
|
+
{#if $tokensQuery.isLoading}
|
|
106
|
+
<div class="ml-2 w-full rounded-lg p-3">{loadingMessage}</div>
|
|
107
|
+
{:else if $tokensQuery.isError}
|
|
108
|
+
<div class="ml-2 w-full rounded-lg p-3 text-red-500">
|
|
109
|
+
Cannot load tokens list: {$tokensQuery.error?.message || 'Unknown error'}
|
|
110
|
+
</div>
|
|
111
|
+
{:else if isEmpty(availableTokens)}
|
|
112
|
+
<div class="ml-2 w-full rounded-lg p-3">{emptyMessage}</div>
|
|
113
|
+
{:else}
|
|
114
|
+
<!-- Search input -->
|
|
115
|
+
<div class="sticky top-0 bg-white p-3 dark:bg-gray-800">
|
|
116
|
+
<Input
|
|
117
|
+
placeholder="Search tokens..."
|
|
118
|
+
bind:value={searchTerm}
|
|
119
|
+
autofocus
|
|
120
|
+
on:keydown={handleKeyDown}
|
|
121
|
+
data-testid="tokens-filter-search"
|
|
122
|
+
>
|
|
123
|
+
<SearchSolid slot="left" class="h-4 w-4 text-gray-500" />
|
|
124
|
+
</Input>
|
|
125
|
+
</div>
|
|
126
|
+
|
|
127
|
+
{#if isEmpty(filteredTokens)}
|
|
128
|
+
<div class="ml-2 w-full rounded-lg p-3">No tokens match your search</div>
|
|
129
|
+
{:else}
|
|
130
|
+
{#each sortedFilteredTokens as token, index (`${token.address}-${token.chainId}`)}
|
|
131
|
+
<Checkbox
|
|
132
|
+
data-testid="dropdown-tokens-filter-option"
|
|
133
|
+
class="w-full rounded-lg p-3 hover:bg-gray-100 dark:hover:bg-gray-600 {selectedIndex ===
|
|
134
|
+
index
|
|
135
|
+
? 'bg-blue-100 dark:bg-blue-900'
|
|
136
|
+
: ''}"
|
|
137
|
+
on:click={() => toggleToken(token)}
|
|
138
|
+
checked={!!(token.address && selectedTokens.includes(token.address))}
|
|
139
|
+
>
|
|
140
|
+
<div class="ml-2 flex w-full">
|
|
141
|
+
<div class="flex-1 text-sm font-medium">{getTokenDisplayName(token)}</div>
|
|
142
|
+
<div class="text-xs text-gray-500">
|
|
143
|
+
{getNetworkName(token.chainId)}
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
</Checkbox>
|
|
147
|
+
{/each}
|
|
148
|
+
{/if}
|
|
149
|
+
{/if}
|
|
150
|
+
</Dropdown>
|
|
151
|
+
</div>
|
|
152
|
+
</div>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { Address, RaindexVaultToken } from '@rainlanguage/orderbook';
|
|
3
|
+
import type { AppStoresInterface } from '../../types/appStores';
|
|
4
|
+
import type { Readable } from 'svelte/store';
|
|
5
|
+
import type { QueryObserverResult } from '@tanstack/svelte-query';
|
|
6
|
+
declare const __propDef: {
|
|
7
|
+
props: {
|
|
8
|
+
tokensQuery: Readable<QueryObserverResult<RaindexVaultToken[], Error>>;
|
|
9
|
+
activeTokens: AppStoresInterface["activeTokens"];
|
|
10
|
+
selectedTokens: Address[];
|
|
11
|
+
label?: string;
|
|
12
|
+
allLabel?: string;
|
|
13
|
+
emptyMessage?: string;
|
|
14
|
+
loadingMessage?: string;
|
|
15
|
+
};
|
|
16
|
+
events: {
|
|
17
|
+
[evt: string]: CustomEvent<any>;
|
|
18
|
+
};
|
|
19
|
+
slots: {};
|
|
20
|
+
exports?: {} | undefined;
|
|
21
|
+
bindings?: string | undefined;
|
|
22
|
+
};
|
|
23
|
+
export type DropdownTokensFilterProps = typeof __propDef.props;
|
|
24
|
+
export type DropdownTokensFilterEvents = typeof __propDef.events;
|
|
25
|
+
export type DropdownTokensFilterSlots = typeof __propDef.slots;
|
|
26
|
+
export default class DropdownTokensFilter extends SvelteComponent<DropdownTokensFilterProps, DropdownTokensFilterEvents, DropdownTokensFilterSlots> {
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -12,10 +12,11 @@ export let size = ctx.size || "md";
|
|
|
12
12
|
export let role = ctx.role || "img";
|
|
13
13
|
export let ariaLabel = "refresh";
|
|
14
14
|
export let spin = false;
|
|
15
|
+
export let testId = "refresh-button";
|
|
15
16
|
</script>
|
|
16
17
|
|
|
17
18
|
<svg
|
|
18
|
-
data-testid=
|
|
19
|
+
data-testid={testId}
|
|
19
20
|
xmlns="http://www.w3.org/2000/svg"
|
|
20
21
|
fill="none"
|
|
21
22
|
{...$$restProps}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type {
|
|
2
|
+
import type { AppStoresInterface } from '../../types/appStores';
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
|
-
orderHash:
|
|
6
|
-
value?: string
|
|
5
|
+
orderHash: AppStoresInterface["orderHash"];
|
|
6
|
+
value?: `0x${string}`;
|
|
7
7
|
};
|
|
8
8
|
events: {
|
|
9
9
|
[evt: string]: CustomEvent<any>;
|
|
@@ -1,18 +1,40 @@
|
|
|
1
1
|
<script>import { Button, Input } from "flowbite-svelte";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { useRegistry } from "../../providers/registry/useRegistry";
|
|
3
|
+
import { loadRegistryUrl } from "../../services/loadRegistryUrl";
|
|
4
|
+
const registry = useRegistry();
|
|
5
|
+
let newRegistryUrl = registry.getCurrentRegistry();
|
|
6
|
+
let error = null;
|
|
7
|
+
let loading = false;
|
|
8
|
+
async function handleClick() {
|
|
9
|
+
loading = true;
|
|
10
|
+
error = null;
|
|
11
|
+
try {
|
|
12
|
+
if (!registry) {
|
|
13
|
+
throw new Error("Registry manager not yet available.");
|
|
14
|
+
}
|
|
15
|
+
await loadRegistryUrl(newRegistryUrl, registry);
|
|
16
|
+
} catch (err) {
|
|
17
|
+
error = err instanceof Error ? err.message : "Unknown error";
|
|
18
|
+
}
|
|
19
|
+
loading = false;
|
|
20
|
+
}
|
|
8
21
|
</script>
|
|
9
22
|
|
|
10
|
-
<div class="
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
23
|
+
<div class="flex w-full flex-col items-end gap-2">
|
|
24
|
+
<div class="flex w-full items-start gap-4" data-testid="registry-input">
|
|
25
|
+
<Input
|
|
26
|
+
id="order-url"
|
|
27
|
+
type="url"
|
|
28
|
+
placeholder="Enter URL to raw order registry file"
|
|
29
|
+
bind:value={newRegistryUrl}
|
|
30
|
+
/>
|
|
31
|
+
<Button class="w-36 text-nowrap" on:click={handleClick} disabled={loading}>
|
|
32
|
+
{loading ? 'Loading registry...' : 'Load registry URL'}
|
|
33
|
+
</Button>
|
|
34
|
+
</div>
|
|
35
|
+
<div class="h-4">
|
|
36
|
+
{#if error}
|
|
37
|
+
<p data-testid="registry-error" class="text-red-500">{error}</p>
|
|
38
|
+
{/if}
|
|
39
|
+
</div>
|
|
18
40
|
</div>
|
|
@@ -35,10 +35,10 @@ function decimalsComplete({ detail }) {
|
|
|
35
35
|
</div>
|
|
36
36
|
|
|
37
37
|
{#if !isAddressValid && address.length > 0}
|
|
38
|
-
<Helper class="mt-2 text-sm" color="red">Invalid
|
|
38
|
+
<Helper class="mt-2 text-sm" color="red">Invalid address</Helper>
|
|
39
39
|
{/if}
|
|
40
40
|
|
|
41
|
-
<Helper class="mt-2 text-sm">Token
|
|
41
|
+
<Helper class="mt-2 text-sm">Token address</Helper>
|
|
42
42
|
</div>
|
|
43
43
|
<div class="w-32 grow-0 break-all" data-testid="token-decimals-input">
|
|
44
44
|
<input
|
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
<script>import { InputAddon, Button
|
|
2
|
-
import {
|
|
3
|
-
import { parseUnits } from "viem";
|
|
1
|
+
<script>import { InputAddon, Button } from "flowbite-svelte";
|
|
2
|
+
import { Float } from "@rainlanguage/orderbook";
|
|
4
3
|
export let symbol = void 0;
|
|
5
|
-
export let decimals = 0;
|
|
6
4
|
export let maxValue = void 0;
|
|
5
|
+
export let value = Float.parse("0").value;
|
|
7
6
|
let inputValue = "";
|
|
8
|
-
export let value = 0n;
|
|
9
7
|
function handleInput(event) {
|
|
10
8
|
const input = event.target;
|
|
11
9
|
inputValue = input.value;
|
|
12
10
|
if (inputValue === "") {
|
|
13
|
-
value =
|
|
11
|
+
value = Float.parse("0").value;
|
|
14
12
|
} else {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
let parsedValue = Float.parse(inputValue);
|
|
14
|
+
if (parsedValue.error) {
|
|
15
|
+
value = Float.parse("0").value;
|
|
16
|
+
return;
|
|
19
17
|
}
|
|
18
|
+
value = parsedValue.value;
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
21
|
function fillMaxValue() {
|
|
23
22
|
if (!maxValue) return;
|
|
24
23
|
value = maxValue;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
let formattedValue = value.format().value;
|
|
25
|
+
if (!formattedValue) {
|
|
26
|
+
inputValue = "";
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
inputValue = formattedValue;
|
|
28
30
|
}
|
|
29
31
|
</script>
|
|
30
32
|
|
|
@@ -39,7 +41,7 @@ function fillMaxValue() {
|
|
|
39
41
|
/>
|
|
40
42
|
|
|
41
43
|
{#if maxValue}
|
|
42
|
-
<div class="absolute right-
|
|
44
|
+
<div class="absolute right-2 flex h-10 flex-col justify-center">
|
|
43
45
|
<Button color="blue" class="px-2 py-1" size="xs" pill on:click={fillMaxValue}>MAX</Button>
|
|
44
46
|
</div>
|
|
45
47
|
{/if}
|
|
@@ -53,11 +55,4 @@ function fillMaxValue() {
|
|
|
53
55
|
</InputAddon>
|
|
54
56
|
{/if}
|
|
55
57
|
</div>
|
|
56
|
-
{#if decimals === 0}
|
|
57
|
-
<Alert color="yellow" border class="mt-2">
|
|
58
|
-
<InfoCircleSolid slot="icon" class="h-6 w-6" />
|
|
59
|
-
This token does not specify a number of decimals. <br />You are inputting the raw integer
|
|
60
|
-
amount with 0 decimal places.
|
|
61
|
-
</Alert>
|
|
62
|
-
{/if}
|
|
63
58
|
</div>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
+
import { Float } from '@rainlanguage/orderbook';
|
|
2
3
|
declare const __propDef: {
|
|
3
4
|
props: {
|
|
4
5
|
symbol?: string | undefined;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
value?: bigint;
|
|
6
|
+
maxValue?: Float | undefined;
|
|
7
|
+
value?: Float;
|
|
8
8
|
};
|
|
9
9
|
events: {
|
|
10
10
|
[evt: string]: CustomEvent<any>;
|