@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script>import {} from "@rainlanguage/
|
|
1
|
+
<script>import {} from "@rainlanguage/raindex";
|
|
2
2
|
import { createQuery } from "@tanstack/svelte-query";
|
|
3
3
|
import { QKEY_ORDER_TRADES_LIST } from "../../queries/keys";
|
|
4
4
|
import {
|
|
@@ -17,7 +17,13 @@ import {
|
|
|
17
17
|
TIME_DELTA_30_DAYS,
|
|
18
18
|
TIME_DELTA_1_YEAR
|
|
19
19
|
} from "../../services/time";
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
Button,
|
|
22
|
+
ButtonGroup,
|
|
23
|
+
Dropdown,
|
|
24
|
+
DropdownItem,
|
|
25
|
+
Spinner
|
|
26
|
+
} from "flowbite-svelte";
|
|
21
27
|
import { ChevronDownSolid } from "flowbite-svelte-icons";
|
|
22
28
|
import {
|
|
23
29
|
createChart,
|
|
@@ -195,7 +201,8 @@ function destroyChart() {
|
|
|
195
201
|
sellVolumeSeries = void 0;
|
|
196
202
|
}
|
|
197
203
|
}
|
|
198
|
-
$: if (chartElement && trades.length > 0 && selectedPair && !chart)
|
|
204
|
+
$: if (chartElement && trades.length > 0 && selectedPair && !chart)
|
|
205
|
+
setupChart();
|
|
199
206
|
$: if (chart && chartData) updateChartData();
|
|
200
207
|
$: if (chart && $lightweightChartsTheme) setChartOptions();
|
|
201
208
|
onMount(() => {
|
|
@@ -207,102 +214,114 @@ onDestroy(() => {
|
|
|
207
214
|
</script>
|
|
208
215
|
|
|
209
216
|
<div
|
|
210
|
-
|
|
217
|
+
class="flex h-full flex-col overflow-hidden rounded-lg border bg-gray-50 dark:border-none dark:bg-gray-700"
|
|
211
218
|
>
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
219
|
+
<div
|
|
220
|
+
class="flex w-full flex-wrap items-center justify-between gap-2 border-b p-3 dark:border-gray-700"
|
|
221
|
+
>
|
|
222
|
+
<div class="flex items-center gap-2">
|
|
223
|
+
<div
|
|
224
|
+
class="text-xl text-gray-900 dark:text-white"
|
|
225
|
+
data-testid="chart-title"
|
|
226
|
+
>
|
|
227
|
+
Trades
|
|
228
|
+
</div>
|
|
229
|
+
{#if $query?.isLoading}
|
|
230
|
+
<Spinner class="h-4 w-4" color="white" data-testid="chart-spinner" />
|
|
231
|
+
{/if}
|
|
232
|
+
</div>
|
|
221
233
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
234
|
+
<div class="flex flex-wrap items-center gap-2">
|
|
235
|
+
{#if pairs.length > 0}
|
|
236
|
+
<div class="flex items-center gap-1">
|
|
237
|
+
<Button
|
|
238
|
+
color="alternative"
|
|
239
|
+
size="xs"
|
|
240
|
+
class="flex items-center gap-1"
|
|
241
|
+
data-testid="pair-selector"
|
|
242
|
+
>
|
|
243
|
+
{pairLabel}
|
|
244
|
+
<ChevronDownSolid class="h-3 w-3" />
|
|
245
|
+
</Button>
|
|
246
|
+
<Dropdown bind:open={dropdownOpen} data-testid="pair-dropdown">
|
|
247
|
+
{#each pairs as pair, idx}
|
|
248
|
+
<DropdownItem
|
|
249
|
+
on:click={() => selectPair(idx)}
|
|
250
|
+
data-testid="pair-option-{idx}"
|
|
251
|
+
>
|
|
252
|
+
{getTokenLabel(pair.baseToken)}/{getTokenLabel(pair.quoteToken)}
|
|
253
|
+
</DropdownItem>
|
|
254
|
+
{/each}
|
|
255
|
+
</Dropdown>
|
|
256
|
+
<Button
|
|
257
|
+
color="alternative"
|
|
258
|
+
size="xs"
|
|
259
|
+
on:click={handleFlipPair}
|
|
260
|
+
title="Flip pair"
|
|
261
|
+
data-testid="flip-button"
|
|
262
|
+
>
|
|
263
|
+
<svg
|
|
264
|
+
class="h-4 w-4"
|
|
265
|
+
fill="none"
|
|
266
|
+
stroke="currentColor"
|
|
267
|
+
viewBox="0 0 24 24"
|
|
268
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
269
|
+
>
|
|
270
|
+
<path
|
|
271
|
+
stroke-linecap="round"
|
|
272
|
+
stroke-linejoin="round"
|
|
273
|
+
stroke-width="2"
|
|
274
|
+
d="M7 16V4m0 0L3 8m4-4l4 4m6 0v12m0 0l4-4m-4 4l-4-4"
|
|
275
|
+
/>
|
|
276
|
+
</svg>
|
|
277
|
+
</Button>
|
|
278
|
+
</div>
|
|
279
|
+
{/if}
|
|
265
280
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
281
|
+
{#if trades.length > 0}
|
|
282
|
+
<ButtonGroup class="bg-gray-800" data-testid="time-filters">
|
|
283
|
+
{#each TIME_OPTIONS as option}
|
|
284
|
+
<Button
|
|
285
|
+
on:click={() => (timeDelta = option.delta)}
|
|
286
|
+
color={timeDelta === option.delta ? "primary" : "alternative"}
|
|
287
|
+
size="xs"
|
|
288
|
+
class="px-2 py-1">{option.label}</Button
|
|
289
|
+
>
|
|
290
|
+
{/each}
|
|
291
|
+
</ButtonGroup>
|
|
292
|
+
{/if}
|
|
293
|
+
</div>
|
|
294
|
+
</div>
|
|
280
295
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
296
|
+
<div
|
|
297
|
+
class="relative flex w-full grow items-center justify-center bg-white dark:bg-gray-800"
|
|
298
|
+
>
|
|
299
|
+
{#if $query?.isLoading}
|
|
300
|
+
<div class="text-gray-800 dark:text-gray-400">Loading...</div>
|
|
301
|
+
{:else if $query?.isError}
|
|
302
|
+
<div class="text-red-500" data-testid="chart-error">
|
|
303
|
+
Error: {$query?.error?.message ?? "Failed to load trades"}
|
|
304
|
+
</div>
|
|
305
|
+
{:else if trades.length === 0 || !selectedPair}
|
|
306
|
+
<div class="text-gray-800 dark:text-gray-400" data-testid="chart-empty">
|
|
307
|
+
No trades found
|
|
308
|
+
</div>
|
|
309
|
+
{:else}
|
|
310
|
+
<div
|
|
311
|
+
bind:this={chartElement}
|
|
312
|
+
class="h-full w-full overflow-hidden"
|
|
313
|
+
data-testid="chart-element"
|
|
314
|
+
></div>
|
|
315
|
+
{#if chartData && chartData.pricePoints.length === 0}
|
|
316
|
+
<div
|
|
317
|
+
class="absolute inset-0 flex items-center justify-center bg-white/80 dark:bg-gray-800/80"
|
|
318
|
+
data-testid="chart-no-data"
|
|
319
|
+
>
|
|
320
|
+
<span class="text-gray-800 dark:text-gray-400"
|
|
321
|
+
>No trades found for selected pair and time range</span
|
|
322
|
+
>
|
|
323
|
+
</div>
|
|
324
|
+
{/if}
|
|
325
|
+
{/if}
|
|
326
|
+
</div>
|
|
308
327
|
</div>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type { Readable } from
|
|
3
|
-
import { type RaindexOrder } from
|
|
2
|
+
import type { Readable } from "svelte/store";
|
|
3
|
+
import { type RaindexOrder } from "@rainlanguage/raindex";
|
|
4
4
|
declare const __propDef: {
|
|
5
5
|
props: {
|
|
6
6
|
order: RaindexOrder;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sortBy } from
|
|
1
|
+
import { sortBy } from "lodash";
|
|
2
2
|
/**
|
|
3
3
|
* Filters out data points with duplicate timestamps, keeping only the first occurrence.
|
|
4
4
|
*
|
|
@@ -27,83 +27,83 @@ export const transformAndSortData = (data, options) => {
|
|
|
27
27
|
const { valueTransform, timeTransform } = options;
|
|
28
28
|
const transformedData = data.map((d) => ({
|
|
29
29
|
value: valueTransform(d),
|
|
30
|
-
time: timeTransform(d)
|
|
30
|
+
time: timeTransform(d),
|
|
31
31
|
}));
|
|
32
32
|
const sortedData = sortBy(transformedData, (d) => d.time);
|
|
33
33
|
return deduplicateByTime(sortedData);
|
|
34
34
|
};
|
|
35
35
|
if (import.meta.vitest) {
|
|
36
36
|
const { it, expect, describe } = import.meta.vitest;
|
|
37
|
-
describe(
|
|
38
|
-
it(
|
|
37
|
+
describe("deduplicateByTime", () => {
|
|
38
|
+
it("should remove entries with duplicate timestamps", () => {
|
|
39
39
|
const data = [
|
|
40
40
|
{ time: 100, value: 10 },
|
|
41
41
|
{ time: 200, value: 20 },
|
|
42
42
|
{ time: 200, value: 25 }, // Duplicate timestamp
|
|
43
|
-
{ time: 300, value: 30 }
|
|
43
|
+
{ time: 300, value: 30 },
|
|
44
44
|
];
|
|
45
45
|
const result = deduplicateByTime(data);
|
|
46
46
|
const expected = [
|
|
47
47
|
{ time: 100, value: 10 },
|
|
48
48
|
{ time: 200, value: 20 }, // First occurrence kept
|
|
49
|
-
{ time: 300, value: 30 }
|
|
49
|
+
{ time: 300, value: 30 },
|
|
50
50
|
];
|
|
51
51
|
expect(result).toEqual(expected);
|
|
52
52
|
});
|
|
53
|
-
it(
|
|
53
|
+
it("should handle multiple duplicate timestamps", () => {
|
|
54
54
|
const data = [
|
|
55
55
|
{ time: 100, value: 10 },
|
|
56
56
|
{ time: 100, value: 15 }, // Duplicate
|
|
57
57
|
{ time: 100, value: 18 }, // Duplicate
|
|
58
|
-
{ time: 200, value: 20 }
|
|
58
|
+
{ time: 200, value: 20 },
|
|
59
59
|
];
|
|
60
60
|
const result = deduplicateByTime(data);
|
|
61
61
|
const expected = [
|
|
62
62
|
{ time: 100, value: 10 }, // Only first one kept
|
|
63
|
-
{ time: 200, value: 20 }
|
|
63
|
+
{ time: 200, value: 20 },
|
|
64
64
|
];
|
|
65
65
|
expect(result).toEqual(expected);
|
|
66
66
|
});
|
|
67
|
-
it(
|
|
67
|
+
it("should return original array if no duplicates", () => {
|
|
68
68
|
const data = [
|
|
69
69
|
{ time: 100, value: 10 },
|
|
70
70
|
{ time: 200, value: 20 },
|
|
71
|
-
{ time: 300, value: 30 }
|
|
71
|
+
{ time: 300, value: 30 },
|
|
72
72
|
];
|
|
73
73
|
const result = deduplicateByTime(data);
|
|
74
74
|
expect(result).toEqual(data);
|
|
75
75
|
expect(result).not.toBe(data);
|
|
76
76
|
});
|
|
77
|
-
it(
|
|
77
|
+
it("should handle empty array", () => {
|
|
78
78
|
const data = [];
|
|
79
79
|
const result = deduplicateByTime(data);
|
|
80
80
|
expect(result).toEqual([]);
|
|
81
81
|
});
|
|
82
82
|
});
|
|
83
|
-
describe(
|
|
84
|
-
it(
|
|
83
|
+
describe("transformAndSortData", () => {
|
|
84
|
+
it("should transform, sort, and deduplicate data", () => {
|
|
85
85
|
const rawData = [
|
|
86
86
|
{ timestamp: 3000, price: 300 },
|
|
87
87
|
{ timestamp: 1000, price: 100 },
|
|
88
88
|
{ timestamp: 2000, price: 200 },
|
|
89
|
-
{ timestamp: 2000, price: 250 } // Duplicate timestamp
|
|
89
|
+
{ timestamp: 2000, price: 250 }, // Duplicate timestamp
|
|
90
90
|
];
|
|
91
91
|
const result = transformAndSortData(rawData, {
|
|
92
92
|
valueTransform: (item) => item.price,
|
|
93
|
-
timeTransform: (item) => item.timestamp
|
|
93
|
+
timeTransform: (item) => item.timestamp,
|
|
94
94
|
});
|
|
95
95
|
const expected = [
|
|
96
96
|
{ time: 1000, value: 100 },
|
|
97
97
|
{ time: 2000, value: 200 }, // First occurrence kept after sorting
|
|
98
|
-
{ time: 3000, value: 300 }
|
|
98
|
+
{ time: 3000, value: 300 },
|
|
99
99
|
];
|
|
100
100
|
expect(result).toEqual(expected);
|
|
101
101
|
});
|
|
102
|
-
it(
|
|
102
|
+
it("should handle empty data array", () => {
|
|
103
103
|
const rawData = [];
|
|
104
104
|
const result = transformAndSortData(rawData, {
|
|
105
105
|
valueTransform: (item) => item.price,
|
|
106
|
-
timeTransform: (item) => item.timestamp
|
|
106
|
+
timeTransform: (item) => item.timestamp,
|
|
107
107
|
});
|
|
108
108
|
expect(result).toEqual([]);
|
|
109
109
|
});
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
RaindexClient,
|
|
7
7
|
AccountBalance,
|
|
8
8
|
Float
|
|
9
|
-
} from "@rainlanguage/
|
|
9
|
+
} from "@rainlanguage/raindex";
|
|
10
10
|
import WalletConnect from "../wallet/WalletConnect.svelte";
|
|
11
11
|
import {} from "svelte/store";
|
|
12
12
|
import { handleShareChoices } from "../../services/handleShareChoices";
|
|
@@ -126,7 +126,10 @@ async function fetchTokenBalance(tokenInfo) {
|
|
|
126
126
|
async function getTokenInfoAndFetchBalance(key) {
|
|
127
127
|
const tokenInfoResult = await builder.getTokenInfo(key);
|
|
128
128
|
if (tokenInfoResult.error) {
|
|
129
|
-
|
|
129
|
+
const balances = tokenBalances;
|
|
130
|
+
balances.delete(key);
|
|
131
|
+
tokenBalances = balances;
|
|
132
|
+
return;
|
|
130
133
|
}
|
|
131
134
|
const tokenInfo = tokenInfoResult.value;
|
|
132
135
|
if (!tokenInfo || !tokenInfo.address) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import { type NameAndDescriptionCfg, RaindexOrderBuilder, RaindexClient } from '@rainlanguage/
|
|
2
|
+
import { type NameAndDescriptionCfg, RaindexOrderBuilder, RaindexClient } from '@rainlanguage/raindex';
|
|
3
3
|
import { type Writable } from 'svelte/store';
|
|
4
4
|
import type { AppKit } from '@reown/appkit';
|
|
5
5
|
import type { Account } from '../../types/account';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type { NameAndDescriptionCfg } from '@rainlanguage/
|
|
2
|
+
import type { NameAndDescriptionCfg } from '@rainlanguage/raindex';
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
deployments?: Map<string, NameAndDescriptionCfg> | [string, NameAndDescriptionCfg][];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>import { Input } from "flowbite-svelte";
|
|
2
2
|
import {
|
|
3
|
-
} from "@rainlanguage/
|
|
3
|
+
} from "@rainlanguage/raindex";
|
|
4
4
|
import ButtonSelectOption from "./ButtonSelectOption.svelte";
|
|
5
5
|
import DeploymentSectionHeader from "./DeploymentSectionHeader.svelte";
|
|
6
6
|
import { onMount } from "svelte";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import { type OrderBuilderFieldDefinitionCfg } from '@rainlanguage/
|
|
2
|
+
import { type OrderBuilderFieldDefinitionCfg } from '@rainlanguage/raindex';
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
fieldDefinition: OrderBuilderFieldDefinitionCfg;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type { OrderBuilderSelectTokensCfg } from '@rainlanguage/
|
|
2
|
+
import type { OrderBuilderSelectTokensCfg } from '@rainlanguage/raindex';
|
|
3
3
|
import type { TokenBalance } from '../../types/tokenBalance';
|
|
4
4
|
declare const __propDef: {
|
|
5
5
|
props: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script>import { Input } from "flowbite-svelte";
|
|
2
|
-
import {} from "@rainlanguage/
|
|
2
|
+
import {} from "@rainlanguage/raindex";
|
|
3
3
|
import { onMount } from "svelte";
|
|
4
4
|
import { useRaindexOrderBuilder } from "../../hooks/useRaindexOrderBuilder";
|
|
5
5
|
import VaultIdInformation from "./VaultIdInformation.svelte";
|
|
@@ -28,14 +28,14 @@ import {
|
|
|
28
28
|
RaindexOrder,
|
|
29
29
|
RaindexVault,
|
|
30
30
|
RaindexVaultsList
|
|
31
|
-
} from "@rainlanguage/
|
|
31
|
+
} from "@rainlanguage/raindex";
|
|
32
32
|
import { useToasts } from "../../providers/toasts/useToasts";
|
|
33
33
|
import { useRaindexClient } from "../../hooks/useRaindexClient";
|
|
34
34
|
export let handleQuoteDebugModal = void 0;
|
|
35
35
|
export let handleDebugTradeModal = void 0;
|
|
36
36
|
export let codeMirrorTheme;
|
|
37
37
|
export let lightweightChartsTheme;
|
|
38
|
-
export let
|
|
38
|
+
export let raindexAddress;
|
|
39
39
|
export let orderHash;
|
|
40
40
|
export let chainId;
|
|
41
41
|
export let rpcs = void 0;
|
|
@@ -53,7 +53,7 @@ const raindexClient = useRaindexClient();
|
|
|
53
53
|
$: orderDetailQuery = createQuery({
|
|
54
54
|
queryKey: [QKEY_ORDER, orderHash],
|
|
55
55
|
queryFn: async () => {
|
|
56
|
-
const result = await raindexClient.getOrderByHash(chainId,
|
|
56
|
+
const result = await raindexClient.getOrderByHash(chainId, raindexAddress, orderHash);
|
|
57
57
|
if (result.error) throw new Error(result.error.readableMsg);
|
|
58
58
|
return result.value;
|
|
59
59
|
}
|
|
@@ -120,6 +120,8 @@ const formatBuilderState = (builderState) => {
|
|
|
120
120
|
|
|
121
121
|
<Refresh
|
|
122
122
|
testId="top-refresh"
|
|
123
|
+
title="Refresh order"
|
|
124
|
+
ariaLabel="Refresh order"
|
|
123
125
|
on:click={handleRefresh}
|
|
124
126
|
spin={$orderDetailQuery.isLoading || $orderDetailQuery.isFetching}
|
|
125
127
|
/>
|
|
@@ -129,9 +131,9 @@ const formatBuilderState = (builderState) => {
|
|
|
129
131
|
<svelte:fragment slot="card" let:data>
|
|
130
132
|
<div class="flex flex-col gap-y-6">
|
|
131
133
|
<CardProperty>
|
|
132
|
-
<svelte:fragment slot="key">
|
|
134
|
+
<svelte:fragment slot="key">Raindex</svelte:fragment>
|
|
133
135
|
<svelte:fragment slot="value">
|
|
134
|
-
<Hash type={HashType.Identifier} shorten={false} value={data.
|
|
136
|
+
<Hash type={HashType.Identifier} shorten={false} value={data.raindex} />
|
|
135
137
|
</svelte:fragment>
|
|
136
138
|
</CardProperty>
|
|
137
139
|
|
|
@@ -223,7 +225,7 @@ const formatBuilderState = (builderState) => {
|
|
|
223
225
|
<svelte:fragment slot="value">
|
|
224
226
|
<div class="mt-2 space-y-2">
|
|
225
227
|
{#each filteredVaults as vault}
|
|
226
|
-
<ButtonVaultLink tokenVault={vault} {chainId} {
|
|
228
|
+
<ButtonVaultLink tokenVault={vault} {chainId} {raindexAddress}>
|
|
227
229
|
<svelte:fragment slot="buttons">
|
|
228
230
|
{#if matchesAccount(vault.owner)}
|
|
229
231
|
<div class="flex gap-1">
|
|
@@ -231,6 +233,8 @@ const formatBuilderState = (builderState) => {
|
|
|
231
233
|
color="light"
|
|
232
234
|
size="xs"
|
|
233
235
|
data-testid="deposit-button"
|
|
236
|
+
title="Deposit into vault"
|
|
237
|
+
aria-label="Deposit into vault"
|
|
234
238
|
on:click={() => onDeposit(raindexClient, vault)}
|
|
235
239
|
>
|
|
236
240
|
<ArrowDownToBracketOutline size="xs" />
|
|
@@ -239,6 +243,8 @@ const formatBuilderState = (builderState) => {
|
|
|
239
243
|
color="light"
|
|
240
244
|
size="xs"
|
|
241
245
|
data-testid="withdraw-button"
|
|
246
|
+
title="Withdraw from vault"
|
|
247
|
+
aria-label="Withdraw from vault"
|
|
242
248
|
on:click={() => onWithdraw(raindexClient, vault)}
|
|
243
249
|
>
|
|
244
250
|
<ArrowUpFromBracketOutline size="xs" />
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
2
|
import type { DebugTradeModalHandler, QuoteDebugModalHandler } from '../../types/modal';
|
|
3
|
-
import { RaindexClient, RaindexOrder, RaindexVault, RaindexVaultsList, type Address, type Hex } from '@rainlanguage/
|
|
3
|
+
import { RaindexClient, RaindexOrder, RaindexVault, RaindexVaultsList, type Address, type Hex } from '@rainlanguage/raindex';
|
|
4
4
|
declare const __propDef: {
|
|
5
5
|
props: {
|
|
6
6
|
handleQuoteDebugModal?: QuoteDebugModalHandler | undefined;
|
|
7
7
|
handleDebugTradeModal?: DebugTradeModalHandler | undefined;
|
|
8
8
|
codeMirrorTheme: any;
|
|
9
9
|
lightweightChartsTheme: any;
|
|
10
|
-
|
|
10
|
+
raindexAddress: Address;
|
|
11
11
|
orderHash: Hex;
|
|
12
12
|
chainId: number;
|
|
13
13
|
rpcs?: string[] | undefined;
|
|
@@ -83,16 +83,24 @@ $: orderModalArg = order;
|
|
|
83
83
|
<Refresh
|
|
84
84
|
data-testid="refresh-button"
|
|
85
85
|
class="h-8 w-5 cursor-pointer text-gray-400 dark:text-gray-400"
|
|
86
|
+
title="Refresh quotes"
|
|
87
|
+
ariaLabel="Refresh quotes"
|
|
86
88
|
on:click={refreshQuotes}
|
|
87
89
|
spin={$orderQuoteQuery.isLoading || $orderQuoteQuery.isFetching}
|
|
88
90
|
/>
|
|
89
91
|
<PauseSolid
|
|
92
|
+
data-testid="pause-refresh-button"
|
|
93
|
+
title="Pause auto-refresh"
|
|
94
|
+
ariaLabel="Pause auto-refresh"
|
|
90
95
|
class={`ml-2 h-8 w-3 cursor-pointer text-gray-400 dark:text-gray-400 ${!enabled ? 'hidden' : ''}`}
|
|
91
96
|
on:click={() => {
|
|
92
97
|
enabled = false;
|
|
93
98
|
}}
|
|
94
99
|
/>
|
|
95
100
|
<PlaySolid
|
|
101
|
+
data-testid="resume-refresh-button"
|
|
102
|
+
title="Resume auto-refresh"
|
|
103
|
+
ariaLabel="Resume auto-refresh"
|
|
96
104
|
on:click={() => {
|
|
97
105
|
enabled = true;
|
|
98
106
|
blockNumber = undefined;
|
|
@@ -125,6 +133,13 @@ $: orderModalArg = order;
|
|
|
125
133
|
<Tooltip triggeredBy={`#max-output-${index}`}>
|
|
126
134
|
{item.data.formattedMaxOutput}
|
|
127
135
|
</Tooltip>
|
|
136
|
+
{#if item.data.formattedMaxOutputAsPercentOfVault}
|
|
137
|
+
<span
|
|
138
|
+
data-testid={`max-output-percent-${index}`}
|
|
139
|
+
class="block max-w-[150px] truncate text-xs text-gray-400"
|
|
140
|
+
>{item.data.formattedMaxOutputAsPercentOfVault}% of vault</span
|
|
141
|
+
>
|
|
142
|
+
{/if}
|
|
128
143
|
</TableBodyCell>
|
|
129
144
|
<TableBodyCell>
|
|
130
145
|
<span id={`ratio-${index}`} class="block max-w-[200px] truncate"
|
|
@@ -146,6 +161,9 @@ $: orderModalArg = order;
|
|
|
146
161
|
<TableBodyCell>
|
|
147
162
|
{#if handleQuoteDebugModal}
|
|
148
163
|
<button
|
|
164
|
+
data-testid="debug-quote-button"
|
|
165
|
+
title="Debug quote"
|
|
166
|
+
aria-label="Debug quote"
|
|
149
167
|
on:click={() =>
|
|
150
168
|
handleQuoteDebugModal(
|
|
151
169
|
orderModalArg,
|
|
@@ -174,6 +192,7 @@ $: orderModalArg = order;
|
|
|
174
192
|
<button
|
|
175
193
|
type="button"
|
|
176
194
|
class="mt-0.5 rounded border border-transparent p-1 text-gray-400 transition hover:bg-gray-100 hover:text-gray-600 focus:outline-none focus:ring-2 focus:ring-blue-500 dark:text-gray-300 dark:hover:bg-gray-700 dark:hover:text-gray-100"
|
|
195
|
+
title="Copy quote error"
|
|
177
196
|
aria-label="Copy quote error"
|
|
178
197
|
on:click={() => copyQuoteError(item.error)}
|
|
179
198
|
>
|
|
@@ -190,6 +209,9 @@ $: orderModalArg = order;
|
|
|
190
209
|
<TableBodyCell>
|
|
191
210
|
{#if handleQuoteDebugModal}
|
|
192
211
|
<button
|
|
212
|
+
data-testid="debug-quote-error-button"
|
|
213
|
+
title="Debug quote"
|
|
214
|
+
aria-label="Debug quote"
|
|
193
215
|
on:click={() =>
|
|
194
216
|
handleQuoteDebugModal(
|
|
195
217
|
order,
|