@rainlanguage/ui-components 0.0.1-alpha.238 → 0.0.1-alpha.239
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/README.md +14 -6
- package/dist/__fixtures__/settings.yaml +18 -20
- package/dist/__mocks__/MockCodeMirrorEditor.svelte +17 -0
- package/dist/__mocks__/MockCodeMirrorEditor.svelte.d.ts +21 -0
- package/dist/__mocks__/MockComponent.js +1 -1
- package/dist/__mocks__/MockComponent.svelte +7 -3
- package/dist/__mocks__/MockComponent.svelte.d.ts +1 -0
- package/dist/__mocks__/mockWeb3Config.d.ts +1 -1
- package/dist/__mocks__/mockWeb3Config.js +10 -7
- package/dist/__mocks__/queries.js +9 -9
- package/dist/__mocks__/stores.d.ts +4 -4
- package/dist/__mocks__/stores.js +40 -40
- package/dist/app.css +3 -3
- package/dist/components/ButtonDarkMode.svelte +7 -1
- package/dist/components/ButtonScrub.svelte +22 -0
- package/dist/components/ButtonScrub.svelte.d.ts +25 -0
- package/dist/components/ButtonVaultLink.svelte +3 -2
- package/dist/components/ButtonVaultLink.svelte.d.ts +2 -2
- package/dist/components/CodeMirrorRainlang.svelte +19 -2
- package/dist/components/CodeMirrorRainlang.svelte.d.ts +2 -1
- package/dist/components/Hash.svelte +3 -2
- package/dist/components/{ListViewOrderbookFilters.svelte → ListViewRaindexFilters.svelte} +7 -7
- package/dist/components/{ListViewOrderbookFilters.svelte.d.ts → ListViewRaindexFilters.svelte.d.ts} +7 -7
- package/dist/components/LocalDbStatusBadge.svelte.d.ts +1 -1
- package/dist/components/LocalDbStatusCard.svelte +7 -4
- package/dist/components/LocalDbStatusCard.svelte.d.ts +2 -2
- package/dist/components/LocalDbStatusModal.svelte +16 -14
- package/dist/components/LocalDbStatusModal.svelte.d.ts +2 -2
- package/dist/components/OrderOrVaultHash.svelte +2 -2
- package/dist/components/OrderOrVaultHash.svelte.d.ts +2 -2
- package/dist/components/Sensitive.svelte +16 -0
- package/dist/components/Sensitive.svelte.d.ts +28 -0
- package/dist/components/TanstackAppTable.svelte +146 -87
- package/dist/components/TanstackAppTable.svelte.d.ts +1 -1
- package/dist/components/VaultBalanceChangeTypeFilter.svelte +1 -1
- package/dist/components/VaultBalanceChangeTypeFilter.svelte.d.ts +1 -1
- package/dist/components/VaultCard.svelte +1 -1
- package/dist/components/VaultCard.svelte.d.ts +1 -1
- package/dist/components/charts/OrderTradesChart.svelte +116 -97
- package/dist/components/charts/OrderTradesChart.svelte.d.ts +2 -2
- package/dist/components/charts/transformAndSortData.d.ts +1 -1
- package/dist/components/charts/transformAndSortData.js +19 -19
- package/dist/components/deployment/DeploymentSteps.svelte +5 -2
- package/dist/components/deployment/DeploymentSteps.svelte.d.ts +1 -1
- package/dist/components/deployment/DeploymentsSection.svelte.d.ts +1 -1
- package/dist/components/deployment/DepositInput.svelte +1 -1
- package/dist/components/deployment/DepositInput.svelte.d.ts +1 -1
- package/dist/components/deployment/FieldDefinitionInput.svelte +1 -1
- package/dist/components/deployment/FieldDefinitionInput.svelte.d.ts +1 -1
- package/dist/components/deployment/OrderPage.svelte.d.ts +1 -1
- package/dist/components/deployment/SelectToken.svelte.d.ts +1 -1
- package/dist/components/deployment/TokenIOInput.svelte +1 -1
- package/dist/components/deployment/TokenIOInput.svelte.d.ts +1 -1
- package/dist/components/deployment/TokenSelectionModal.svelte.d.ts +1 -1
- package/dist/components/detail/OrderDetail.svelte +12 -6
- package/dist/components/detail/OrderDetail.svelte.d.ts +2 -2
- package/dist/components/detail/TanstackOrderQuote.svelte +22 -0
- package/dist/components/detail/TanstackOrderQuote.svelte.d.ts +1 -1
- package/dist/components/detail/VaultDetail.svelte +12 -10
- package/dist/components/detail/VaultDetail.svelte.d.ts +2 -2
- package/dist/components/dropdown/{DropdownOrderbooksFilter.svelte → DropdownRaindexesFilter.svelte} +54 -54
- package/dist/components/dropdown/DropdownRaindexesFilter.svelte.d.ts +25 -0
- package/dist/components/dropdown/DropdownTokensFilter.svelte.d.ts +1 -1
- package/dist/components/icon/Refresh.svelte +2 -1
- package/dist/components/icon/Refresh.svelte.d.ts +1 -0
- package/dist/components/input/InputTokenAmount.svelte +16 -1
- package/dist/components/input/InputTokenAmount.svelte.d.ts +1 -1
- package/dist/components/tables/OrderTradesListTable.svelte +113 -98
- package/dist/components/tables/OrderTradesListTable.svelte.d.ts +1 -1
- package/dist/components/tables/OrderVaultsVolTable.svelte +1 -1
- package/dist/components/tables/OrderVaultsVolTable.svelte.d.ts +1 -1
- package/dist/components/tables/OrdersListTable.svelte +19 -17
- package/dist/components/tables/OrdersListTable.svelte.d.ts +1 -1
- package/dist/components/tables/VaultBalanceChangesTable.svelte +1 -1
- package/dist/components/tables/VaultBalanceChangesTable.svelte.d.ts +1 -1
- package/dist/components/tables/VaultsListTable.svelte +24 -21
- package/dist/components/tables/VaultsListTable.svelte.d.ts +2 -2
- package/dist/components/transactions/FixedBottomTransaction.svelte +1 -0
- package/dist/components/transactions/getStatusEmoji.d.ts +1 -1
- package/dist/components/transactions/getStatusEmoji.js +13 -13
- package/dist/consts.js +1 -1
- package/dist/errors/DeploymentStepsError.js +3 -3
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/hooks/useLocalDb.d.ts +1 -1
- package/dist/hooks/useLocalDb.js +3 -3
- package/dist/hooks/useRaindexClient.d.ts +1 -1
- package/dist/hooks/useRaindexClient.js +4 -4
- package/dist/hooks/useRaindexOrderBuilder.d.ts +1 -1
- package/dist/hooks/useRaindexOrderBuilder.js +4 -4
- package/dist/index.d.ts +122 -114
- package/dist/index.js +115 -109
- package/dist/models/Transaction.d.ts +4 -4
- package/dist/models/Transaction.js +9 -9
- package/dist/providers/RaindexClientProvider.svelte +1 -1
- package/dist/providers/RaindexClientProvider.svelte.d.ts +1 -1
- package/dist/providers/RaindexOrderBuilderProvider.svelte +1 -1
- package/dist/providers/RaindexOrderBuilderProvider.svelte.d.ts +1 -1
- package/dist/providers/dotrainRegistry/DotrainRegistryProvider.svelte.d.ts +1 -1
- package/dist/providers/dotrainRegistry/context.d.ts +2 -2
- package/dist/providers/dotrainRegistry/context.js +13 -10
- package/dist/providers/dotrainRegistry/useDotrainRegistry.d.ts +1 -1
- package/dist/providers/dotrainRegistry/useDotrainRegistry.js +8 -8
- package/dist/providers/registry/RegistryManager.js +8 -7
- package/dist/providers/registry/context.d.ts +1 -1
- package/dist/providers/registry/context.js +9 -9
- package/dist/providers/registry/useRegistry.d.ts +1 -1
- package/dist/providers/registry/useRegistry.js +5 -5
- package/dist/providers/toasts/context.d.ts +2 -2
- package/dist/providers/toasts/context.js +4 -4
- package/dist/providers/toasts/useToasts.d.ts +1 -1
- package/dist/providers/toasts/useToasts.js +4 -4
- package/dist/providers/transactions/TransactionManager.d.ts +14 -15
- package/dist/providers/transactions/TransactionManager.js +107 -107
- package/dist/providers/transactions/context.d.ts +1 -1
- package/dist/providers/transactions/context.js +4 -4
- package/dist/providers/transactions/useTransactions.js +2 -2
- package/dist/providers/wallet/context.d.ts +1 -1
- package/dist/providers/wallet/context.js +11 -11
- package/dist/providers/wallet/useAccount.js +27 -27
- package/dist/queries/keys.js +10 -10
- package/dist/queries/queryClient.d.ts +1 -1
- package/dist/queries/queryClient.js +8 -8
- package/dist/services/awaitTransactionIndexing.d.ts +8 -8
- package/dist/services/awaitTransactionIndexing.js +10 -8
- package/dist/services/getExplorerLink.js +2 -2
- package/dist/services/handleShareChoices.d.ts +1 -1
- package/dist/services/handleShareChoices.js +4 -4
- package/dist/services/historicalOrderCharts.d.ts +2 -2
- package/dist/services/historicalOrderCharts.js +260 -201
- package/dist/services/index.d.ts +5 -3
- package/dist/services/index.js +3 -2
- package/dist/services/loadRegistryUrl.d.ts +1 -1
- package/dist/services/loadRegistryUrl.js +5 -5
- package/dist/services/pairTradesChartData.d.ts +2 -2
- package/dist/services/pairTradesChartData.js +28 -24
- package/dist/services/registry.d.ts +1 -1
- package/dist/services/registry.js +10 -10
- package/dist/services/time.d.ts +1 -1
- package/dist/services/time.js +35 -35
- package/dist/services/validateAmount.d.ts +30 -0
- package/dist/services/validateAmount.js +53 -0
- package/dist/storesGeneric/cachedWritableStore.d.ts +2 -2
- package/dist/storesGeneric/cachedWritableStore.js +3 -3
- package/dist/storesGeneric/scrub.d.ts +14 -0
- package/dist/storesGeneric/scrub.js +22 -0
- package/dist/test/matchers.d.ts +2 -2
- package/dist/test/matchers.js +2 -2
- package/dist/types/account.d.ts +2 -2
- package/dist/types/appStores.d.ts +3 -3
- package/dist/types/modal.d.ts +3 -3
- package/dist/types/order.d.ts +1 -1
- package/dist/types/toast.d.ts +2 -2
- package/dist/types/tokenBalance.d.ts +1 -1
- package/dist/types/transaction.d.ts +4 -4
- package/dist/utils/breadcrumbs.js +2 -2
- package/dist/utils/codeMirrorThemes.js +80 -74
- package/dist/utils/configHelpers.d.ts +1 -1
- package/dist/utils/configHelpers.js +6 -6
- package/dist/utils/constructHashLink.d.ts +3 -3
- package/dist/utils/constructHashLink.js +39 -37
- package/dist/utils/getNetworkName.js +5 -5
- package/dist/utils/hex.js +1 -1
- package/dist/utils/lightweightChartsThemes.d.ts +1 -1
- package/dist/utils/lightweightChartsThemes.js +11 -11
- package/dist/utils/localDbStatus.d.ts +26 -0
- package/dist/utils/localDbStatus.js +22 -0
- package/dist/utils/number.js +5 -3
- package/dist/utils/stripTrailingWhitespace.d.ts +16 -0
- package/dist/utils/stripTrailingWhitespace.js +22 -0
- package/dist/utils/tokens.d.ts +1 -1
- package/dist/utils/tokens.js +1 -1
- package/dist/utils/vaultBalanceChangeLabels.d.ts +1 -1
- package/dist/utils/vaultBalanceChangeLabels.js +11 -11
- package/package.json +89 -89
- package/dist/components/dropdown/DropdownOrderbooksFilter.svelte.d.ts +0 -25
|
@@ -3,9 +3,7 @@ import VaultBalanceChangesTable from "../tables/VaultBalanceChangesTable.svelte"
|
|
|
3
3
|
import TanstackPageContentDetail from "./TanstackPageContentDetail.svelte";
|
|
4
4
|
import CardProperty from "../CardProperty.svelte";
|
|
5
5
|
import { QKEY_VAULT } from "../../queries/keys";
|
|
6
|
-
import {
|
|
7
|
-
RaindexClient
|
|
8
|
-
} from "@rainlanguage/orderbook";
|
|
6
|
+
import { RaindexClient } from "@rainlanguage/raindex";
|
|
9
7
|
import { toHex } from "viem";
|
|
10
8
|
import { createQuery } from "@tanstack/svelte-query";
|
|
11
9
|
import { onDestroy } from "svelte";
|
|
@@ -24,7 +22,7 @@ import { getExplorerLink } from "../../services/getExplorerLink";
|
|
|
24
22
|
import { useToasts } from "../../providers/toasts/useToasts";
|
|
25
23
|
import { useRaindexClient } from "../../hooks/useRaindexClient";
|
|
26
24
|
export let id;
|
|
27
|
-
export let
|
|
25
|
+
export let raindexAddress;
|
|
28
26
|
export let chainId;
|
|
29
27
|
export let onDeposit;
|
|
30
28
|
export let onWithdraw;
|
|
@@ -35,7 +33,7 @@ const raindexClient = useRaindexClient();
|
|
|
35
33
|
$: vaultDetailQuery = createQuery({
|
|
36
34
|
queryKey: [id, QKEY_VAULT + id],
|
|
37
35
|
queryFn: async () => {
|
|
38
|
-
const result = await raindexClient.getVault(chainId,
|
|
36
|
+
const result = await raindexClient.getVault(chainId, raindexAddress, id);
|
|
39
37
|
if (result.error) throw new Error(result.error.readableMsg);
|
|
40
38
|
return result.value;
|
|
41
39
|
}
|
|
@@ -69,6 +67,7 @@ const handleRefresh = async () => {
|
|
|
69
67
|
color="light"
|
|
70
68
|
size="xs"
|
|
71
69
|
data-testid="deposit-button"
|
|
70
|
+
title="Deposit to vault"
|
|
72
71
|
aria-label="Deposit to vault"
|
|
73
72
|
on:click={() => onDeposit(raindexClient, data)}
|
|
74
73
|
>
|
|
@@ -78,6 +77,7 @@ const handleRefresh = async () => {
|
|
|
78
77
|
color="light"
|
|
79
78
|
size="xs"
|
|
80
79
|
data-testid="withdraw-button"
|
|
80
|
+
title="Withdraw from vault"
|
|
81
81
|
aria-label="Withdraw from vault"
|
|
82
82
|
on:click={() => onWithdraw(raindexClient, data)}
|
|
83
83
|
>
|
|
@@ -87,6 +87,8 @@ const handleRefresh = async () => {
|
|
|
87
87
|
|
|
88
88
|
<Refresh
|
|
89
89
|
testId="top-refresh"
|
|
90
|
+
title="Refresh vault"
|
|
91
|
+
ariaLabel="Refresh vault"
|
|
90
92
|
on:click={handleRefresh}
|
|
91
93
|
spin={$vaultDetailQuery.isLoading || $vaultDetailQuery.isFetching}
|
|
92
94
|
/>
|
|
@@ -98,10 +100,10 @@ const handleRefresh = async () => {
|
|
|
98
100
|
<svelte:fragment slot="value">{toHex(data.vaultId)}</svelte:fragment>
|
|
99
101
|
</CardProperty>
|
|
100
102
|
|
|
101
|
-
<CardProperty data-testid="
|
|
102
|
-
<svelte:fragment slot="key">
|
|
103
|
+
<CardProperty data-testid="vaultDetailRaindexAddress">
|
|
104
|
+
<svelte:fragment slot="key">Raindex</svelte:fragment>
|
|
103
105
|
<svelte:fragment slot="value">
|
|
104
|
-
<Hash type={HashType.Identifier} value={data.
|
|
106
|
+
<Hash type={HashType.Identifier} value={data.raindex} />
|
|
105
107
|
</svelte:fragment>
|
|
106
108
|
</CardProperty>
|
|
107
109
|
|
|
@@ -145,7 +147,7 @@ const handleRefresh = async () => {
|
|
|
145
147
|
<p data-testid="vaultDetailOrdersAsInput" class="flex flex-wrap justify-start">
|
|
146
148
|
{#if data.ordersAsInput && data.ordersAsInput.length > 0}
|
|
147
149
|
{#each data.ordersAsInput as order}
|
|
148
|
-
<OrderOrVaultHash type="orders" orderOrVault={order} {chainId} {
|
|
150
|
+
<OrderOrVaultHash type="orders" orderOrVault={order} {chainId} {raindexAddress} />
|
|
149
151
|
{/each}
|
|
150
152
|
{:else}
|
|
151
153
|
None
|
|
@@ -160,7 +162,7 @@ const handleRefresh = async () => {
|
|
|
160
162
|
<p data-testid="vaultDetailOrdersAsOutput" class="flex flex-wrap justify-start">
|
|
161
163
|
{#if data.ordersAsOutput && data.ordersAsOutput.length > 0}
|
|
162
164
|
{#each data.ordersAsOutput as order}
|
|
163
|
-
<OrderOrVaultHash type="orders" orderOrVault={order} {chainId} {
|
|
165
|
+
<OrderOrVaultHash type="orders" orderOrVault={order} {chainId} {raindexAddress} />
|
|
164
166
|
{/each}
|
|
165
167
|
{:else}
|
|
166
168
|
None
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import { RaindexClient, type Address, type Hex, type RaindexVault } from '@rainlanguage/
|
|
2
|
+
import { RaindexClient, type Address, type Hex, type RaindexVault } from '@rainlanguage/raindex';
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
id: Hex;
|
|
6
|
-
|
|
6
|
+
raindexAddress: Address;
|
|
7
7
|
chainId: number;
|
|
8
8
|
/**
|
|
9
9
|
* Required callback function when deposit action is triggered for a vault
|
package/dist/components/dropdown/{DropdownOrderbooksFilter.svelte → DropdownRaindexesFilter.svelte}
RENAMED
|
@@ -3,22 +3,22 @@ import { ChevronDownSolid, SearchSolid } from "flowbite-svelte-icons";
|
|
|
3
3
|
import { isEmpty } from "lodash";
|
|
4
4
|
import { getNetworkName } from "../../utils/getNetworkName";
|
|
5
5
|
import { useRaindexClient } from "../../hooks/useRaindexClient";
|
|
6
|
-
export let
|
|
7
|
-
export let
|
|
6
|
+
export let activeRaindexAddresses;
|
|
7
|
+
export let selectedRaindexAddresses;
|
|
8
8
|
export let selectedChainIds;
|
|
9
|
-
export let label = "Filter by
|
|
10
|
-
export let allLabel = "All
|
|
11
|
-
export let emptyMessage = "No
|
|
9
|
+
export let label = "Filter by raindex";
|
|
10
|
+
export let allLabel = "All raindexes";
|
|
11
|
+
export let emptyMessage = "No raindexes available";
|
|
12
12
|
const raindexClient = useRaindexClient();
|
|
13
|
-
let
|
|
13
|
+
let filteredRaindexes = [];
|
|
14
14
|
let searchTerm = "";
|
|
15
15
|
let selectedIndex = 0;
|
|
16
|
-
$:
|
|
17
|
-
$:
|
|
18
|
-
$:
|
|
19
|
-
$:
|
|
16
|
+
$: raindexesResult = raindexClient.getAllRaindexes();
|
|
17
|
+
$: raindexesMap = raindexesResult?.value ?? /* @__PURE__ */ new Map();
|
|
18
|
+
$: raindexesError = raindexesResult?.error;
|
|
19
|
+
$: availableRaindexes = (() => {
|
|
20
20
|
const items = [];
|
|
21
|
-
|
|
21
|
+
raindexesMap.forEach((cfg, key) => {
|
|
22
22
|
if (selectedChainIds.length === 0 || selectedChainIds.includes(cfg.network.chainId)) {
|
|
23
23
|
items.push({
|
|
24
24
|
key,
|
|
@@ -30,62 +30,62 @@ $: availableOrderbooks = (() => {
|
|
|
30
30
|
});
|
|
31
31
|
return items;
|
|
32
32
|
})();
|
|
33
|
-
$: selectedCount =
|
|
34
|
-
$: allSelected = selectedCount ===
|
|
35
|
-
$: buttonText = selectedCount === 0 ? "Select
|
|
33
|
+
$: selectedCount = selectedRaindexAddresses.length;
|
|
34
|
+
$: allSelected = selectedCount === availableRaindexes.length && availableRaindexes.length > 0;
|
|
35
|
+
$: buttonText = selectedCount === 0 ? "Select raindexes" : allSelected ? allLabel : `${selectedCount} raindex${selectedCount > 1 ? "es" : ""}`;
|
|
36
36
|
$: {
|
|
37
37
|
if (searchTerm.trim() === "") {
|
|
38
|
-
|
|
38
|
+
filteredRaindexes = availableRaindexes;
|
|
39
39
|
selectedIndex = 0;
|
|
40
40
|
} else {
|
|
41
41
|
const term = searchTerm.toLowerCase();
|
|
42
|
-
|
|
43
|
-
(
|
|
42
|
+
filteredRaindexes = availableRaindexes.filter(
|
|
43
|
+
(raindex) => raindex.label?.toLowerCase().includes(term) || raindex.address?.toLowerCase().includes(term) || raindex.key?.toLowerCase().includes(term)
|
|
44
44
|
);
|
|
45
|
-
selectedIndex =
|
|
45
|
+
selectedIndex = filteredRaindexes.length > 0 ? 0 : -1;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
$:
|
|
49
|
-
const aSelected =
|
|
48
|
+
$: sortedFilteredRaindexes = [...filteredRaindexes].sort((a, b) => {
|
|
49
|
+
const aSelected = selectedRaindexAddresses.some(
|
|
50
50
|
(addr) => addr.toLowerCase() === a.address.toLowerCase()
|
|
51
51
|
);
|
|
52
|
-
const bSelected =
|
|
52
|
+
const bSelected = selectedRaindexAddresses.some(
|
|
53
53
|
(addr) => addr.toLowerCase() === b.address.toLowerCase()
|
|
54
54
|
);
|
|
55
55
|
if (aSelected === bSelected) return 0;
|
|
56
56
|
return aSelected ? -1 : 1;
|
|
57
57
|
});
|
|
58
|
-
function getDisplayName(
|
|
59
|
-
const truncatedAddr = `${
|
|
60
|
-
return
|
|
58
|
+
function getDisplayName(raindex) {
|
|
59
|
+
const truncatedAddr = `${raindex.address.slice(0, 6)}...${raindex.address.slice(-4)}`;
|
|
60
|
+
return raindex.label ? `${raindex.label} (${truncatedAddr})` : truncatedAddr;
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
|
|
62
|
+
function updateSelectedRaindexes(newSelection) {
|
|
63
|
+
activeRaindexAddresses.set(newSelection);
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function toggleRaindex({ address }) {
|
|
66
66
|
if (!address) return;
|
|
67
67
|
const normalizedAddress = address.toLowerCase();
|
|
68
|
-
const isSelected =
|
|
68
|
+
const isSelected = selectedRaindexAddresses.some(
|
|
69
69
|
(addr) => addr.toLowerCase() === normalizedAddress
|
|
70
70
|
);
|
|
71
|
-
const newSelection = isSelected ? $
|
|
72
|
-
|
|
71
|
+
const newSelection = isSelected ? $activeRaindexAddresses.filter((addr) => addr.toLowerCase() !== normalizedAddress) : [...$activeRaindexAddresses, normalizedAddress];
|
|
72
|
+
updateSelectedRaindexes(newSelection);
|
|
73
73
|
}
|
|
74
74
|
function handleKeyDown(event) {
|
|
75
|
-
if (!
|
|
75
|
+
if (!sortedFilteredRaindexes.length) return;
|
|
76
76
|
switch (event.key) {
|
|
77
77
|
case "Enter":
|
|
78
78
|
event.preventDefault();
|
|
79
|
-
if (
|
|
80
|
-
const
|
|
81
|
-
if (
|
|
82
|
-
|
|
79
|
+
if (sortedFilteredRaindexes.length > 0) {
|
|
80
|
+
const raindexToToggle = sortedFilteredRaindexes[selectedIndex];
|
|
81
|
+
if (raindexToToggle) {
|
|
82
|
+
toggleRaindex(raindexToToggle);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
break;
|
|
86
86
|
case "ArrowDown":
|
|
87
87
|
event.preventDefault();
|
|
88
|
-
selectedIndex = Math.min(selectedIndex + 1,
|
|
88
|
+
selectedIndex = Math.min(selectedIndex + 1, sortedFilteredRaindexes.length - 1);
|
|
89
89
|
break;
|
|
90
90
|
case "ArrowUp":
|
|
91
91
|
event.preventDefault();
|
|
@@ -105,8 +105,8 @@ function handleKeyDown(event) {
|
|
|
105
105
|
<Button
|
|
106
106
|
color="alternative"
|
|
107
107
|
class="flex w-full justify-between overflow-hidden pl-2 pr-0 text-left"
|
|
108
|
-
data-testid="dropdown-
|
|
109
|
-
aria-label="Select
|
|
108
|
+
data-testid="dropdown-raindexes-filter-button"
|
|
109
|
+
aria-label="Select raindexes to filter"
|
|
110
110
|
aria-expanded="false"
|
|
111
111
|
aria-haspopup="listbox"
|
|
112
112
|
>
|
|
@@ -118,49 +118,49 @@ function handleKeyDown(event) {
|
|
|
118
118
|
|
|
119
119
|
<Dropdown
|
|
120
120
|
class="max-h-[75vh] w-full min-w-60 overflow-y-auto py-0"
|
|
121
|
-
data-testid="dropdown-
|
|
121
|
+
data-testid="dropdown-raindexes-filter"
|
|
122
122
|
>
|
|
123
|
-
{#if
|
|
123
|
+
{#if raindexesError}
|
|
124
124
|
<div class="ml-2 w-full rounded-lg p-3 text-red-500">
|
|
125
|
-
Cannot load
|
|
125
|
+
Cannot load raindexes list: {raindexesError.readableMsg || 'Unknown error'}
|
|
126
126
|
</div>
|
|
127
|
-
{:else if isEmpty(
|
|
127
|
+
{:else if isEmpty(availableRaindexes)}
|
|
128
128
|
<div class="ml-2 w-full rounded-lg p-3">{emptyMessage}</div>
|
|
129
129
|
{:else}
|
|
130
130
|
<div class="sticky top-0 bg-white p-3 dark:bg-gray-800">
|
|
131
131
|
<Input
|
|
132
|
-
placeholder="Search
|
|
132
|
+
placeholder="Search raindexes..."
|
|
133
133
|
bind:value={searchTerm}
|
|
134
134
|
autofocus
|
|
135
135
|
on:keydown={handleKeyDown}
|
|
136
|
-
data-testid="
|
|
136
|
+
data-testid="raindexes-filter-search"
|
|
137
137
|
>
|
|
138
138
|
<SearchSolid slot="left" class="h-4 w-4 text-gray-500" />
|
|
139
139
|
</Input>
|
|
140
140
|
</div>
|
|
141
141
|
|
|
142
|
-
{#if isEmpty(
|
|
143
|
-
<div class="ml-2 w-full rounded-lg p-3">No
|
|
142
|
+
{#if isEmpty(filteredRaindexes)}
|
|
143
|
+
<div class="ml-2 w-full rounded-lg p-3">No raindexes match your search</div>
|
|
144
144
|
{:else}
|
|
145
|
-
{#each
|
|
145
|
+
{#each sortedFilteredRaindexes as raindex, index (`${raindex.address}-${raindex.chainId}`)}
|
|
146
146
|
<Checkbox
|
|
147
|
-
data-testid="dropdown-
|
|
147
|
+
data-testid="dropdown-raindexes-filter-option"
|
|
148
148
|
class="w-full rounded-lg p-3 hover:bg-gray-100 dark:hover:bg-gray-600 {selectedIndex ===
|
|
149
149
|
index
|
|
150
150
|
? 'bg-blue-100 dark:bg-blue-900'
|
|
151
151
|
: ''}"
|
|
152
|
-
on:click={() =>
|
|
152
|
+
on:click={() => toggleRaindex(raindex)}
|
|
153
153
|
checked={!!(
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
(addr) => addr.toLowerCase() ===
|
|
154
|
+
raindex.address &&
|
|
155
|
+
selectedRaindexAddresses.some(
|
|
156
|
+
(addr) => addr.toLowerCase() === raindex.address.toLowerCase()
|
|
157
157
|
)
|
|
158
158
|
)}
|
|
159
159
|
>
|
|
160
160
|
<div class="ml-2 flex w-full">
|
|
161
|
-
<div class="flex-1 text-sm font-medium">{getDisplayName(
|
|
161
|
+
<div class="flex-1 text-sm font-medium">{getDisplayName(raindex)}</div>
|
|
162
162
|
<div class="text-xs text-gray-500">
|
|
163
|
-
{getNetworkName(
|
|
163
|
+
{getNetworkName(raindex.chainId)}
|
|
164
164
|
</div>
|
|
165
165
|
</div>
|
|
166
166
|
</Checkbox>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { Address } from '@rainlanguage/raindex';
|
|
3
|
+
import type { AppStoresInterface } from '../../types/appStores';
|
|
4
|
+
declare const __propDef: {
|
|
5
|
+
props: {
|
|
6
|
+
activeRaindexAddresses: AppStoresInterface["activeRaindexAddresses"];
|
|
7
|
+
selectedRaindexAddresses: 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 DropdownRaindexesFilterProps = typeof __propDef.props;
|
|
21
|
+
export type DropdownRaindexesFilterEvents = typeof __propDef.events;
|
|
22
|
+
export type DropdownRaindexesFilterSlots = typeof __propDef.slots;
|
|
23
|
+
export default class DropdownRaindexesFilter extends SvelteComponent<DropdownRaindexesFilterProps, DropdownRaindexesFilterEvents, DropdownRaindexesFilterSlots> {
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type { Address, RaindexVaultToken } from '@rainlanguage/
|
|
2
|
+
import type { Address, RaindexVaultToken } from '@rainlanguage/raindex';
|
|
3
3
|
import type { AppStoresInterface } from '../../types/appStores';
|
|
4
4
|
import type { Readable } from 'svelte/store';
|
|
5
5
|
import type { QueryObserverResult } from '@tanstack/svelte-query';
|
|
@@ -11,6 +11,7 @@ const sizes = {
|
|
|
11
11
|
export let size = ctx.size || "md";
|
|
12
12
|
export let role = ctx.role || "img";
|
|
13
13
|
export let ariaLabel = "refresh";
|
|
14
|
+
export let title = "Refresh";
|
|
14
15
|
export let spin = false;
|
|
15
16
|
export let testId = "refresh-button";
|
|
16
17
|
</script>
|
|
@@ -19,7 +20,7 @@ export let testId = "refresh-button";
|
|
|
19
20
|
data-testid={testId}
|
|
20
21
|
xmlns="http://www.w3.org/2000/svg"
|
|
21
22
|
fill="none"
|
|
22
|
-
{...$$restProps}
|
|
23
|
+
{...{ title, ...$$restProps }}
|
|
23
24
|
class={twMerge(
|
|
24
25
|
'shrink-0 cursor-pointer outline-none',
|
|
25
26
|
sizes[size],
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
<script>import { InputAddon, Button } from "flowbite-svelte";
|
|
2
|
-
import { Float } from "@rainlanguage/
|
|
2
|
+
import { Float } from "@rainlanguage/raindex";
|
|
3
|
+
import { validateAmount } from "../../services/validateAmount";
|
|
3
4
|
export let symbol = void 0;
|
|
4
5
|
export let maxValue = void 0;
|
|
5
6
|
export let value = Float.parse("0").value;
|
|
6
7
|
let inputValue = "";
|
|
8
|
+
let decimalsError = null;
|
|
7
9
|
function handleInput(event) {
|
|
8
10
|
const input = event.target;
|
|
9
11
|
inputValue = input.value;
|
|
12
|
+
const decimalsValidation = validateAmount(inputValue);
|
|
13
|
+
decimalsError = decimalsValidation.errorMessage;
|
|
14
|
+
if (!decimalsValidation.isValid) {
|
|
15
|
+
value = Float.parse("0").value;
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
10
18
|
if (inputValue === "") {
|
|
11
19
|
value = Float.parse("0").value;
|
|
12
20
|
} else {
|
|
@@ -21,6 +29,7 @@ function handleInput(event) {
|
|
|
21
29
|
function fillMaxValue() {
|
|
22
30
|
if (!maxValue) return;
|
|
23
31
|
value = maxValue;
|
|
32
|
+
decimalsError = null;
|
|
24
33
|
let formattedValue = value.format().value;
|
|
25
34
|
if (!formattedValue) {
|
|
26
35
|
inputValue = "";
|
|
@@ -55,4 +64,10 @@ function fillMaxValue() {
|
|
|
55
64
|
</InputAddon>
|
|
56
65
|
{/if}
|
|
57
66
|
</div>
|
|
67
|
+
|
|
68
|
+
{#if decimalsError}
|
|
69
|
+
<p class="mt-1 text-sm text-red-500" data-testid="decimals-error">
|
|
70
|
+
{decimalsError}
|
|
71
|
+
</p>
|
|
72
|
+
{/if}
|
|
58
73
|
</div>
|
|
@@ -28,7 +28,10 @@ $: orderTradesQuery = createInfiniteQuery({
|
|
|
28
28
|
},
|
|
29
29
|
initialPageParam: 0,
|
|
30
30
|
getNextPageParam: (lastPage, allPages, lastPageParam) => {
|
|
31
|
-
const fetchedCount = allPages.reduce(
|
|
31
|
+
const fetchedCount = allPages.reduce(
|
|
32
|
+
(sum, p) => sum + p.trades.length,
|
|
33
|
+
0
|
|
34
|
+
);
|
|
32
35
|
return fetchedCount < Number(lastPage.totalCount) ? lastPageParam + 1 : void 0;
|
|
33
36
|
}
|
|
34
37
|
});
|
|
@@ -36,103 +39,115 @@ const AppTable = TanstackAppTable;
|
|
|
36
39
|
</script>
|
|
37
40
|
|
|
38
41
|
<AppTable
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
query={orderTradesQuery}
|
|
43
|
+
dataSelector={(page) => page.trades}
|
|
44
|
+
emptyMessage="No trades found"
|
|
45
|
+
rowHoverable={false}
|
|
46
|
+
queryKey={order.id}
|
|
44
47
|
>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
48
|
+
<svelte:fragment slot="info">
|
|
49
|
+
{#if tradesCount !== undefined}
|
|
50
|
+
<div class="px-2">{tradesCount} Trades</div>
|
|
51
|
+
{/if}
|
|
52
|
+
</svelte:fragment>
|
|
53
|
+
<svelte:fragment slot="timeFilter">
|
|
54
|
+
<TableTimeFilters bind:startTimestamp bind:endTimestamp />
|
|
55
|
+
</svelte:fragment>
|
|
56
|
+
<svelte:fragment slot="head">
|
|
57
|
+
<TableHeadCell padding="p-4" class="w-[15%]">Date</TableHeadCell>
|
|
58
|
+
<TableHeadCell padding="p-4" class="w-[20%]">Transaction</TableHeadCell>
|
|
59
|
+
<TableHeadCell padding="p-2" class="w-[18%]">Input</TableHeadCell>
|
|
60
|
+
<TableHeadCell padding="p-2" class="w-[18%]">Output</TableHeadCell>
|
|
61
|
+
<TableHeadCell padding="p-2" class="w-[25%]">IO Ratio</TableHeadCell>
|
|
62
|
+
<TableHeadCell padding="p-0" class="w-[4%]"
|
|
63
|
+
><span class="sr-only">Actions</span></TableHeadCell
|
|
64
|
+
>
|
|
65
|
+
</svelte:fragment>
|
|
61
66
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
67
|
+
<svelte:fragment slot="bodyRow" let:item>
|
|
68
|
+
{@const inputAmt = Number(item.inputVaultBalanceChange.formattedAmount)}
|
|
69
|
+
{@const outputAmt = Number(item.outputVaultBalanceChange.formattedAmount)}
|
|
70
|
+
{@const ioRatio = Math.abs(inputAmt / outputAmt)}
|
|
71
|
+
{@const oiRatio = Math.abs(outputAmt / inputAmt)}
|
|
72
|
+
{@const validRatio = Number.isFinite(ioRatio) && Number.isFinite(oiRatio)}
|
|
73
|
+
<TableBodyCell tdClass="px-4 py-2">
|
|
74
|
+
{formatTimestampSecondsAsLocal(BigInt(item.timestamp))}
|
|
75
|
+
</TableBodyCell>
|
|
76
|
+
<TableBodyCell tdClass="px-4 py-2">
|
|
77
|
+
<div class="flex flex-col gap-1 text-sm">
|
|
78
|
+
<div class="flex items-center gap-1">
|
|
79
|
+
<span class="text-gray-500 dark:text-gray-400">Sender:</span>
|
|
80
|
+
<Hash type={HashType.Wallet} value={item.transaction.from} />
|
|
81
|
+
</div>
|
|
82
|
+
<div class="flex items-center gap-1">
|
|
83
|
+
<span class="text-gray-500 dark:text-gray-400">Tx:</span>
|
|
84
|
+
<Hash type={HashType.Transaction} value={item.transaction.id} />
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
</TableBodyCell>
|
|
88
|
+
<TableBodyCell tdClass="p-2" data-testid="input">
|
|
89
|
+
<div class="flex flex-col overflow-hidden">
|
|
90
|
+
<span class="truncate font-medium"
|
|
91
|
+
>{item.inputVaultBalanceChange.token.symbol}</span
|
|
92
|
+
>
|
|
93
|
+
<span
|
|
94
|
+
id={`input-${item.id}`}
|
|
95
|
+
class="truncate text-sm text-gray-500 dark:text-gray-400"
|
|
96
|
+
>{item.inputVaultBalanceChange.formattedAmount}</span
|
|
97
|
+
>
|
|
98
|
+
<Tooltip triggeredBy={`#input-${item.id}`}>
|
|
99
|
+
{item.inputVaultBalanceChange.formattedAmount}
|
|
100
|
+
{item.inputVaultBalanceChange.token.symbol}
|
|
101
|
+
</Tooltip>
|
|
102
|
+
</div>
|
|
103
|
+
</TableBodyCell>
|
|
104
|
+
<TableBodyCell tdClass="p-2" data-testid="output">
|
|
105
|
+
<div class="flex flex-col overflow-hidden">
|
|
106
|
+
<span class="truncate font-medium"
|
|
107
|
+
>{item.outputVaultBalanceChange.token.symbol}</span
|
|
108
|
+
>
|
|
109
|
+
<span
|
|
110
|
+
id={`output-${item.id}`}
|
|
111
|
+
class="truncate text-sm text-gray-500 dark:text-gray-400"
|
|
112
|
+
>{item.outputVaultBalanceChange.formattedAmount}</span
|
|
113
|
+
>
|
|
114
|
+
<Tooltip triggeredBy={`#output-${item.id}`}>
|
|
115
|
+
{item.outputVaultBalanceChange.formattedAmount}
|
|
116
|
+
{item.outputVaultBalanceChange.token.symbol}
|
|
117
|
+
</Tooltip>
|
|
118
|
+
</div>
|
|
119
|
+
</TableBodyCell>
|
|
120
|
+
<TableBodyCell tdClass="p-2" data-testid="io-ratio">
|
|
121
|
+
<div id={`io-ratio-${item.id}`} class="truncate">
|
|
122
|
+
{#if validRatio}
|
|
123
|
+
{ioRatio}
|
|
124
|
+
<span class="text-gray-400">({oiRatio})</span>
|
|
125
|
+
{:else}
|
|
126
|
+
-
|
|
127
|
+
{/if}
|
|
128
|
+
</div>
|
|
129
|
+
<Tooltip triggeredBy={`#io-ratio-${item.id}`}>
|
|
130
|
+
{#if validRatio}
|
|
131
|
+
{ioRatio} ({oiRatio})
|
|
132
|
+
{:else}
|
|
133
|
+
-
|
|
134
|
+
{/if}
|
|
135
|
+
</Tooltip>
|
|
136
|
+
</TableBodyCell>
|
|
137
|
+
<TableBodyCell tdClass="py-2">
|
|
138
|
+
{#if rpcs && handleDebugTradeModal}
|
|
139
|
+
<button
|
|
140
|
+
data-testid="debug-trade-button"
|
|
141
|
+
class="text-gray-500 hover:text-gray-700"
|
|
142
|
+
title="Debug trade"
|
|
143
|
+
aria-label="Debug trade"
|
|
144
|
+
on:click={() => {
|
|
145
|
+
if (rpcs) handleDebugTradeModal(item.transaction.id, rpcs);
|
|
146
|
+
}}
|
|
147
|
+
>
|
|
148
|
+
<BugOutline size="xs" />
|
|
149
|
+
</button>
|
|
150
|
+
{/if}
|
|
151
|
+
</TableBodyCell>
|
|
152
|
+
</svelte:fragment>
|
|
138
153
|
</AppTable>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script>import { createInfiniteQuery } from "@tanstack/svelte-query";
|
|
2
2
|
import TanstackAppTable from "../TanstackAppTable.svelte";
|
|
3
3
|
import { QKEY_VAULTS_VOL_LIST } from "../../queries/keys";
|
|
4
|
-
import {} from "@rainlanguage/
|
|
4
|
+
import {} from "@rainlanguage/raindex";
|
|
5
5
|
import { TableBodyCell, TableHeadCell } from "flowbite-svelte";
|
|
6
6
|
import Hash, { HashType } from "../Hash.svelte";
|
|
7
7
|
import TableTimeFilters from "../charts/TableTimeFilters.svelte";
|