@rainlanguage/ui-components 0.0.1-alpha.136 → 0.0.1-alpha.137
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/__mocks__/stores.d.ts +6 -6
- package/dist/__mocks__/stores.js +6 -6
- package/dist/components/ButtonVaultLink.svelte +9 -9
- package/dist/components/ButtonVaultLink.svelte.d.ts +4 -3
- package/dist/components/CodeMirrorRainlang.svelte +3 -20
- package/dist/components/CodeMirrorRainlang.svelte.d.ts +2 -2
- package/dist/components/ListViewOrderbookFilters.svelte +4 -4
- package/dist/components/ListViewOrderbookFilters.svelte.d.ts +1 -1
- package/dist/components/OrderOrVaultHash.svelte +4 -7
- package/dist/components/OrderOrVaultHash.svelte.d.ts +4 -4
- package/dist/components/charts/OrderTradesChart.svelte +6 -17
- package/dist/components/charts/OrderTradesChart.svelte.d.ts +2 -2
- package/dist/components/charts/VaultBalanceChart.svelte +4 -12
- package/dist/components/charts/VaultBalanceChart.svelte.d.ts +2 -4
- package/dist/components/deployment/DeploymentSteps.svelte +5 -10
- package/dist/components/deployment/DeploymentSteps.svelte.d.ts +2 -3
- package/dist/components/detail/OrderDetail.svelte +33 -37
- package/dist/components/detail/OrderDetail.svelte.d.ts +9 -11
- package/dist/components/detail/TanstackOrderQuote.svelte +8 -15
- package/dist/components/detail/TanstackOrderQuote.svelte.d.ts +3 -7
- package/dist/components/detail/VaultDetail.svelte +20 -35
- package/dist/components/detail/VaultDetail.svelte.d.ts +6 -9
- package/dist/components/dropdown/DropdownActiveNetworks.svelte +57 -0
- package/dist/components/dropdown/DropdownActiveNetworks.svelte.d.ts +21 -0
- package/dist/components/dropdown/DropdownCheckbox.svelte +2 -2
- package/dist/components/input/InputOrderHash.svelte.d.ts +1 -1
- package/dist/components/tables/OrderAPY.svelte +7 -9
- package/dist/components/tables/OrderAPY.svelte.d.ts +2 -2
- package/dist/components/tables/OrderTradesListTable.svelte +23 -30
- package/dist/components/tables/OrderTradesListTable.svelte.d.ts +4 -4
- package/dist/components/tables/OrderVaultsVolTable.svelte +7 -14
- package/dist/components/tables/OrderVaultsVolTable.svelte.d.ts +2 -2
- package/dist/components/tables/OrdersListTable.svelte +28 -41
- package/dist/components/tables/OrdersListTable.svelte.d.ts +1 -3
- package/dist/components/tables/VaultBalanceChangesTable.svelte +11 -18
- package/dist/components/tables/VaultBalanceChangesTable.svelte.d.ts +2 -2
- package/dist/components/tables/VaultsListTable.svelte +36 -60
- package/dist/components/tables/VaultsListTable.svelte.d.ts +4 -8
- package/dist/errors/DeploymentStepsError.d.ts +2 -1
- package/dist/errors/DeploymentStepsError.js +1 -0
- package/dist/hooks/useRaindexClient.d.ts +3 -0
- package/dist/hooks/useRaindexClient.js +11 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/models/Transaction.d.ts +0 -1
- package/dist/models/Transaction.js +1 -3
- package/dist/providers/RaindexClientProvider.svelte +8 -0
- package/dist/providers/RaindexClientProvider.svelte.d.ts +21 -0
- package/dist/providers/transactions/TransactionManager.d.ts +10 -27
- package/dist/providers/transactions/TransactionManager.js +28 -46
- package/dist/services/awaitTransactionIndexing.d.ts +20 -13
- package/dist/services/awaitTransactionIndexing.js +6 -5
- package/dist/services/historicalOrderCharts.d.ts +2 -2
- package/dist/services/historicalOrderCharts.js +230 -331
- package/dist/types/appStores.d.ts +4 -9
- package/dist/types/modal.d.ts +3 -3
- package/dist/types/transaction.d.ts +2 -20
- package/dist/utils/configHelpers.d.ts +1 -5
- package/dist/utils/configHelpers.js +0 -19
- package/dist/utils/constructHashLink.d.ts +5 -4
- package/dist/utils/constructHashLink.js +17 -12
- package/dist/utils/getNetworkName.d.ts +1 -0
- package/dist/utils/getNetworkName.js +13 -0
- package/dist/utils/vault.d.ts +2 -2
- package/dist/utils/vault.js +1 -1
- package/package.json +2 -2
- package/dist/__fixtures__/orderDetail.d.ts +0 -99
- package/dist/__fixtures__/orderDetail.js +0 -204
- package/dist/components/dropdown/DropdownActiveSubgraphs.svelte +0 -38
- package/dist/components/dropdown/DropdownActiveSubgraphs.svelte.d.ts +0 -21
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AccountCfg, NewConfig } from '@rainlanguage/orderbook';
|
|
2
2
|
import { type Config } from '@wagmi/core';
|
|
3
3
|
declare const initialPageState: {
|
|
4
4
|
data: {
|
|
@@ -25,11 +25,6 @@ export declare const mockSettingsStore: {
|
|
|
25
25
|
set: (this: void, value: NewConfig) => void;
|
|
26
26
|
mockSetSubscribeValue: (value: NewConfig) => void;
|
|
27
27
|
};
|
|
28
|
-
export declare const mockActiveSubgraphsStore: {
|
|
29
|
-
subscribe: (this: void, run: import("svelte/store").Subscriber<Record<string, SubgraphCfg>>, invalidate?: import("svelte/store").Invalidator<Record<string, SubgraphCfg>> | undefined) => import("svelte/store").Unsubscriber;
|
|
30
|
-
set: (this: void, value: Record<string, SubgraphCfg>) => void;
|
|
31
|
-
mockSetSubscribeValue: (value: Record<string, SubgraphCfg>) => void;
|
|
32
|
-
};
|
|
33
28
|
export declare const mockAccountsStore: {
|
|
34
29
|
subscribe: (this: void, run: import("svelte/store").Subscriber<Record<string, AccountCfg>>, invalidate?: import("svelte/store").Invalidator<Record<string, AccountCfg>> | undefined) => import("svelte/store").Unsubscriber;
|
|
35
30
|
};
|
|
@@ -95,6 +90,11 @@ export declare const mockShowMyItemsOnlyStore: {
|
|
|
95
90
|
set: (this: void, value: boolean) => void;
|
|
96
91
|
mockSetSubscribeValue: (value: boolean) => void;
|
|
97
92
|
};
|
|
93
|
+
export declare const mockSelectedChainIdsStore: {
|
|
94
|
+
subscribe: (this: void, run: import("svelte/store").Subscriber<number[]>, invalidate?: import("svelte/store").Invalidator<number[]> | undefined) => import("svelte/store").Unsubscriber;
|
|
95
|
+
set: (this: void, value: number[]) => void;
|
|
96
|
+
mockSetSubscribeValue: (value: number[]) => void;
|
|
97
|
+
};
|
|
98
98
|
export declare const mockPageStore: {
|
|
99
99
|
subscribe: (this: void, run: import("svelte/store").Subscriber<{
|
|
100
100
|
data: {
|
package/dist/__mocks__/stores.js
CHANGED
|
@@ -35,7 +35,6 @@ const initialPageState = {
|
|
|
35
35
|
};
|
|
36
36
|
const mockPageWritable = writable(initialPageState);
|
|
37
37
|
const mockSettingsWritable = writable(settingsFixture);
|
|
38
|
-
const mockActiveSubgraphsWritable = writable({});
|
|
39
38
|
const mockAccountsWritable = writable({});
|
|
40
39
|
const mockActiveAccountsItemsWritable = writable({});
|
|
41
40
|
const mockShowInactiveOrdersWritable = writable(true);
|
|
@@ -49,16 +48,12 @@ const mockChainIdWritable = writable(0);
|
|
|
49
48
|
const mockConnectedWritable = writable(true);
|
|
50
49
|
const mockWagmiConfigWritable = writable(mockWeb3Config);
|
|
51
50
|
const mockShowMyItemsOnlyWritable = writable(false);
|
|
51
|
+
const mockSelectedChainIdsWritable = writable([]);
|
|
52
52
|
export const mockSettingsStore = {
|
|
53
53
|
subscribe: mockSettingsWritable.subscribe,
|
|
54
54
|
set: mockSettingsWritable.set,
|
|
55
55
|
mockSetSubscribeValue: (value) => mockSettingsWritable.set(value)
|
|
56
56
|
};
|
|
57
|
-
export const mockActiveSubgraphsStore = {
|
|
58
|
-
subscribe: mockActiveSubgraphsWritable.subscribe,
|
|
59
|
-
set: mockActiveSubgraphsWritable.set,
|
|
60
|
-
mockSetSubscribeValue: (value) => mockActiveSubgraphsWritable.set(value)
|
|
61
|
-
};
|
|
62
57
|
export const mockAccountsStore = {
|
|
63
58
|
subscribe: mockAccountsWritable.subscribe
|
|
64
59
|
};
|
|
@@ -124,6 +119,11 @@ export const mockShowMyItemsOnlyStore = {
|
|
|
124
119
|
set: mockShowMyItemsOnlyWritable.set,
|
|
125
120
|
mockSetSubscribeValue: (value) => mockShowMyItemsOnlyWritable.set(value)
|
|
126
121
|
};
|
|
122
|
+
export const mockSelectedChainIdsStore = {
|
|
123
|
+
subscribe: mockSelectedChainIdsWritable.subscribe,
|
|
124
|
+
set: mockSelectedChainIdsWritable.set,
|
|
125
|
+
mockSetSubscribeValue: (value) => mockSelectedChainIdsWritable.set(value)
|
|
126
|
+
};
|
|
127
127
|
export const mockPageStore = {
|
|
128
128
|
subscribe: mockPageWritable.subscribe,
|
|
129
129
|
set: mockPageWritable.set,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
<script>import {
|
|
1
|
+
<script>import { formatUnits, toHex } from "viem";
|
|
2
2
|
import Tooltip from "./Tooltip.svelte";
|
|
3
|
-
import { formatUnits } from "viem";
|
|
4
3
|
export let tokenVault;
|
|
5
|
-
export let
|
|
4
|
+
export let chainId;
|
|
5
|
+
export let orderbookAddress;
|
|
6
6
|
</script>
|
|
7
7
|
|
|
8
8
|
<div
|
|
@@ -11,16 +11,16 @@ export let subgraphName;
|
|
|
11
11
|
>
|
|
12
12
|
<div class="flex flex-col items-start gap-y-2">
|
|
13
13
|
<Tooltip triggeredBy={`#token-info-${tokenVault.vaultId}`}>
|
|
14
|
-
ID: <span class="font-mono">{
|
|
14
|
+
ID: <span class="font-mono">{toHex(tokenVault.vaultId)}</span>
|
|
15
15
|
</Tooltip>
|
|
16
|
-
<a
|
|
16
|
+
<a
|
|
17
|
+
href={`/vaults/${chainId}-${orderbookAddress}-${tokenVault.id}`}
|
|
18
|
+
id={`token-info-${tokenVault.vaultId}`}
|
|
19
|
+
>
|
|
17
20
|
{tokenVault.token.name} ({tokenVault.token.symbol})
|
|
18
21
|
</a>
|
|
19
22
|
<span class="text-sm text-gray-500 dark:text-gray-400">
|
|
20
|
-
Balance: {formatUnits(
|
|
21
|
-
BigInt(tokenVault.balance),
|
|
22
|
-
parseInt(tokenVault.token.decimals || '18')
|
|
23
|
-
)}
|
|
23
|
+
Balance: {formatUnits(tokenVault.balance, Number(tokenVault.token.decimals) || 18)}
|
|
24
24
|
</span>
|
|
25
25
|
</div>
|
|
26
26
|
<div>
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Address, RaindexVault } from '@rainlanguage/orderbook';
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
|
-
tokenVault:
|
|
6
|
-
|
|
5
|
+
tokenVault: RaindexVault;
|
|
6
|
+
chainId: number;
|
|
7
|
+
orderbookAddress: Address;
|
|
7
8
|
};
|
|
8
9
|
events: {
|
|
9
10
|
[evt: string]: CustomEvent<any>;
|
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
<script>import
|
|
2
|
-
import CodeMirror from "svelte-codemirror-editor";
|
|
1
|
+
<script>import CodeMirror from "svelte-codemirror-editor";
|
|
3
2
|
import { RainlangLR } from "codemirror-rainlang";
|
|
4
3
|
export let order = void 0;
|
|
5
4
|
export let rainlangText = void 0;
|
|
6
5
|
export let codeMirrorTheme;
|
|
7
6
|
export let codeMirrorDisabled = true;
|
|
8
7
|
export let codeMirrorStyles = {};
|
|
9
|
-
let result;
|
|
10
|
-
let extendedOrder;
|
|
11
|
-
$: result = order ? extendOrder(order) : void 0;
|
|
12
|
-
$: extendedOrder = result && !result.error ? result.value : void 0;
|
|
13
|
-
$: extendOrderError = result && result.error ? result.error : void 0;
|
|
14
8
|
</script>
|
|
15
9
|
|
|
16
|
-
{#if rainlangText ||
|
|
10
|
+
{#if rainlangText || order?.rainlang}
|
|
17
11
|
<CodeMirror
|
|
18
|
-
value={rainlangText ||
|
|
12
|
+
value={rainlangText || order?.rainlang}
|
|
19
13
|
extensions={[RainlangLR]}
|
|
20
14
|
theme={codeMirrorTheme}
|
|
21
15
|
readonly={codeMirrorDisabled}
|
|
@@ -28,15 +22,4 @@ $: extendOrderError = result && result.error ? result.error : void 0;
|
|
|
28
22
|
...codeMirrorStyles
|
|
29
23
|
}}
|
|
30
24
|
/>
|
|
31
|
-
{:else if extendOrderError}
|
|
32
|
-
<div class="w-full tracking-tight text-red-600 dark:text-red-400" data-testid="rainlang-error">
|
|
33
|
-
{extendOrderError.readableMsg}
|
|
34
|
-
</div>
|
|
35
|
-
{:else if !extendedOrder?.rainlang && !rainlangText}
|
|
36
|
-
<div
|
|
37
|
-
class="w-full tracking-tight text-gray-900 dark:text-white"
|
|
38
|
-
data-testid="rainlang-not-included"
|
|
39
|
-
>
|
|
40
|
-
Rain source not included in order meta
|
|
41
|
-
</div>
|
|
42
25
|
{/if}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type {
|
|
2
|
+
import type { RaindexOrder } from '@rainlanguage/orderbook';
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
|
-
order?:
|
|
5
|
+
order?: RaindexOrder | undefined;
|
|
6
6
|
rainlangText?: string | undefined;
|
|
7
7
|
codeMirrorTheme: any;
|
|
8
8
|
codeMirrorDisabled?: boolean;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
<script generics="T">import
|
|
1
|
+
<script generics="T">import DropdownActiveNetworks from "./dropdown/DropdownActiveNetworks.svelte";
|
|
2
|
+
import { page } from "$app/stores";
|
|
2
3
|
import { isEmpty } from "lodash";
|
|
3
4
|
import { Alert } from "flowbite-svelte";
|
|
4
5
|
import Tooltip from "./Tooltip.svelte";
|
|
5
|
-
import DropdownActiveSubgraphs from "./dropdown/DropdownActiveSubgraphs.svelte";
|
|
6
6
|
import CheckboxActiveOrders from "./checkbox/CheckboxActiveOrders.svelte";
|
|
7
7
|
import DropdownOrderListAccounts from "./dropdown/DropdownOrderListAccounts.svelte";
|
|
8
8
|
import InputOrderHash from "./input/InputOrderHash.svelte";
|
|
@@ -14,7 +14,7 @@ export let accounts;
|
|
|
14
14
|
export let hideZeroBalanceVaults;
|
|
15
15
|
export let activeAccountsItems;
|
|
16
16
|
export let showMyItemsOnly;
|
|
17
|
-
export let
|
|
17
|
+
export let selectedChainIds;
|
|
18
18
|
export let showInactiveOrders;
|
|
19
19
|
export let orderHash;
|
|
20
20
|
$: isVaultsPage = $page.url.pathname === "/vaults";
|
|
@@ -54,6 +54,6 @@ const { account } = useAccount();
|
|
|
54
54
|
{#if $accounts && Object.values($accounts).length > 0}
|
|
55
55
|
<DropdownOrderListAccounts {accounts} {activeAccountsItems} />
|
|
56
56
|
{/if}
|
|
57
|
-
<
|
|
57
|
+
<DropdownActiveNetworks settings={$settings} {selectedChainIds} />
|
|
58
58
|
{/if}
|
|
59
59
|
</div>
|
|
@@ -7,7 +7,7 @@ declare class __sveltets_Render<T> {
|
|
|
7
7
|
hideZeroBalanceVaults: AppStoresInterface["hideZeroBalanceVaults"];
|
|
8
8
|
activeAccountsItems: AppStoresInterface["activeAccountsItems"];
|
|
9
9
|
showMyItemsOnly: AppStoresInterface["showMyItemsOnly"];
|
|
10
|
-
|
|
10
|
+
selectedChainIds: AppStoresInterface["selectedChainIds"];
|
|
11
11
|
showInactiveOrders: AppStoresInterface["showInactiveOrders"];
|
|
12
12
|
orderHash: AppStoresInterface["orderHash"];
|
|
13
13
|
};
|
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
} from "../utils/constructHashLink";
|
|
8
8
|
export let orderOrVault;
|
|
9
9
|
export let type;
|
|
10
|
-
export let
|
|
11
|
-
export let
|
|
10
|
+
export let chainId;
|
|
11
|
+
export let orderbookAddress;
|
|
12
12
|
$: hash = extractHash(orderOrVault);
|
|
13
13
|
$: isActive = isOrderOrVaultActive(orderOrVault);
|
|
14
|
-
$: linkPath = constructHashLink(orderOrVault, type,
|
|
14
|
+
$: linkPath = constructHashLink(orderOrVault, type, chainId, orderbookAddress);
|
|
15
15
|
</script>
|
|
16
16
|
|
|
17
17
|
<a data-testid="order-or-vault-hash" href={linkPath}>
|
|
@@ -19,9 +19,6 @@ $: linkPath = constructHashLink(orderOrVault, type, network);
|
|
|
19
19
|
class="mr-1 mt-1 px-2 py-1 text-sm"
|
|
20
20
|
color={isActive ? 'green' : 'yellow'}
|
|
21
21
|
data-testid="vault-order-input"
|
|
22
|
-
data-id={hash}
|
|
23
|
-
on:click={() => {
|
|
24
|
-
updateActiveNetworkAndOrderbook(network);
|
|
25
|
-
}}><Hash type={HashType.Identifier} value={hash} copyOnClick={false} /></Button
|
|
22
|
+
data-id={hash}><Hash type={HashType.Identifier} value={hash} copyOnClick={false} /></Button
|
|
26
23
|
>
|
|
27
24
|
</a>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Address, RaindexOrder, RaindexOrderAsIO, RaindexVault } from '@rainlanguage/orderbook';
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
|
-
orderOrVault:
|
|
5
|
+
orderOrVault: RaindexOrder | RaindexVault | RaindexOrderAsIO;
|
|
6
6
|
type: "orders" | "vaults";
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
chainId: number;
|
|
8
|
+
orderbookAddress: Address;
|
|
9
9
|
};
|
|
10
10
|
events: {
|
|
11
11
|
[evt: string]: CustomEvent<any>;
|
|
@@ -1,29 +1,18 @@
|
|
|
1
|
-
<script>import {
|
|
1
|
+
<script>import {} from "@rainlanguage/orderbook";
|
|
2
2
|
import { prepareHistoricalOrderChartData } from "../../services/historicalOrderCharts";
|
|
3
3
|
import TanstackLightweightChartLine from "./TanstackLightweightChartLine.svelte";
|
|
4
4
|
import { createQuery } from "@tanstack/svelte-query";
|
|
5
5
|
import { QKEY_ORDER_TRADES_LIST } from "../../queries/keys";
|
|
6
|
-
export let
|
|
7
|
-
export let subgraphUrl;
|
|
6
|
+
export let order;
|
|
8
7
|
export let colorTheme;
|
|
9
8
|
export let lightweightChartsTheme;
|
|
10
9
|
$: query = createQuery({
|
|
11
|
-
queryKey: [QKEY_ORDER_TRADES_LIST, id],
|
|
10
|
+
queryKey: [QKEY_ORDER_TRADES_LIST, order.id],
|
|
12
11
|
queryFn: async () => {
|
|
13
|
-
const data = await
|
|
14
|
-
|
|
15
|
-
id,
|
|
16
|
-
{
|
|
17
|
-
page: 1,
|
|
18
|
-
pageSize: 10
|
|
19
|
-
},
|
|
20
|
-
BigInt(1e3),
|
|
21
|
-
void 0
|
|
22
|
-
);
|
|
23
|
-
if (data.error) throw new Error(data.error.msg);
|
|
12
|
+
const data = await order.getTradesList(BigInt(1e3), void 0, 1);
|
|
13
|
+
if (data.error) throw new Error(data.error.readableMsg);
|
|
24
14
|
return prepareHistoricalOrderChartData(data.value, $colorTheme);
|
|
25
|
-
}
|
|
26
|
-
enabled: !!subgraphUrl
|
|
15
|
+
}
|
|
27
16
|
});
|
|
28
17
|
</script>
|
|
29
18
|
|
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
<script>import { timestampSecondsToUTCTimestamp } from "../../services/time";
|
|
2
2
|
import { bigintToFloat } from "../../utils/number";
|
|
3
3
|
import { createQuery } from "@tanstack/svelte-query";
|
|
4
|
-
import { getVaultBalanceChanges } from "@rainlanguage/orderbook";
|
|
5
4
|
import TanstackLightweightChartLine from "../charts/TanstackLightweightChartLine.svelte";
|
|
6
5
|
import { QKEY_VAULT_CHANGES } from "../../queries/keys";
|
|
7
6
|
export let vault;
|
|
8
|
-
export let id;
|
|
9
|
-
export let subgraphUrl;
|
|
10
7
|
export let lightweightChartsTheme;
|
|
11
8
|
$: query = createQuery({
|
|
12
|
-
queryKey: [id, QKEY_VAULT_CHANGES + id, QKEY_VAULT_CHANGES],
|
|
9
|
+
queryKey: [vault.id, QKEY_VAULT_CHANGES + vault.id, QKEY_VAULT_CHANGES],
|
|
13
10
|
queryFn: async () => {
|
|
14
|
-
const result = await
|
|
15
|
-
page: 1,
|
|
16
|
-
pageSize: 1e3
|
|
17
|
-
});
|
|
11
|
+
const result = await vault.getBalanceChanges(1);
|
|
18
12
|
if (result.error) throw new Error(result.error.msg);
|
|
19
13
|
return result.value;
|
|
20
|
-
}
|
|
21
|
-
enabled: !!subgraphUrl
|
|
14
|
+
}
|
|
22
15
|
});
|
|
23
16
|
const Chart = TanstackLightweightChartLine;
|
|
24
17
|
</script>
|
|
@@ -29,8 +22,7 @@ const Chart = TanstackLightweightChartLine;
|
|
|
29
22
|
priceSymbol={vault.token.symbol}
|
|
30
23
|
{query}
|
|
31
24
|
timeTransform={(d) => timestampSecondsToUTCTimestamp(BigInt(d.timestamp))}
|
|
32
|
-
valueTransform={(d) =>
|
|
33
|
-
bigintToFloat(BigInt(d.newVaultBalance), Number(vault.token.decimals ?? 0))}
|
|
25
|
+
valueTransform={(d) => bigintToFloat(d.newBalance, Number(vault.token.decimals ?? 0))}
|
|
34
26
|
emptyMessage="No deposits or withdrawals found"
|
|
35
27
|
{lightweightChartsTheme}
|
|
36
28
|
/>
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type {
|
|
2
|
+
import type { RaindexVault } from '@rainlanguage/orderbook';
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
|
-
vault:
|
|
6
|
-
id: string;
|
|
7
|
-
subgraphUrl: string;
|
|
5
|
+
vault: RaindexVault;
|
|
8
6
|
lightweightChartsTheme: any;
|
|
9
7
|
};
|
|
10
8
|
events: {
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import TokenIOInput from "./TokenIOInput.svelte";
|
|
3
3
|
import ComposedRainlangModal from "./ComposedRainlangModal.svelte";
|
|
4
4
|
import {
|
|
5
|
-
DotrainOrderGui
|
|
5
|
+
DotrainOrderGui,
|
|
6
|
+
RaindexClient
|
|
6
7
|
} from "@rainlanguage/orderbook";
|
|
7
8
|
import WalletConnect from "../wallet/WalletConnect.svelte";
|
|
8
9
|
import {} from "svelte/store";
|
|
@@ -17,12 +18,12 @@ import { useGui } from "../../hooks/useGui";
|
|
|
17
18
|
import { fade } from "svelte/transition";
|
|
18
19
|
import ShareChoicesButton from "./ShareChoicesButton.svelte";
|
|
19
20
|
import { useRegistry } from "../../providers/registry/useRegistry";
|
|
21
|
+
import { useRaindexClient } from "../../hooks/useRaindexClient";
|
|
20
22
|
export let deployment;
|
|
21
23
|
export let strategyDetail;
|
|
22
24
|
export let onDeploy;
|
|
23
25
|
export let wagmiConnected;
|
|
24
26
|
export let appKitModal;
|
|
25
|
-
export let settings;
|
|
26
27
|
export let account;
|
|
27
28
|
let allDepositFields = [];
|
|
28
29
|
let allTokenOutputs = [];
|
|
@@ -34,9 +35,9 @@ let showAdvancedOptions = false;
|
|
|
34
35
|
let allTokenInfos = [];
|
|
35
36
|
let selectTokens = void 0;
|
|
36
37
|
let checkingDeployment = false;
|
|
37
|
-
let subgraphUrl = void 0;
|
|
38
38
|
const gui = useGui();
|
|
39
39
|
const registry = useRegistry();
|
|
40
|
+
const raindexClient = useRaindexClient();
|
|
40
41
|
let deploymentStepsError = DeploymentStepsError.error;
|
|
41
42
|
onMount(async () => {
|
|
42
43
|
const selectTokensResult = gui.getSelectTokens();
|
|
@@ -44,12 +45,6 @@ onMount(async () => {
|
|
|
44
45
|
throw new Error(selectTokensResult.error.msg);
|
|
45
46
|
}
|
|
46
47
|
selectTokens = selectTokensResult.value;
|
|
47
|
-
const { value, error } = gui.getNetworkKey();
|
|
48
|
-
if (error) {
|
|
49
|
-
DeploymentStepsError.catch(error, DeploymentStepsErrorCode.NO_NETWORK_KEY);
|
|
50
|
-
} else if (value) {
|
|
51
|
-
subgraphUrl = $settings.orderbook.subgraphs[value].url;
|
|
52
|
-
}
|
|
53
48
|
await areAllTokensSelected();
|
|
54
49
|
});
|
|
55
50
|
$: if (selectTokens?.length === 0 || allTokensSelected) {
|
|
@@ -137,7 +132,7 @@ async function handleDeployButtonClick() {
|
|
|
137
132
|
return;
|
|
138
133
|
}
|
|
139
134
|
DeploymentStepsError.clear();
|
|
140
|
-
return onDeploy(
|
|
135
|
+
return onDeploy(raindexClient, gui);
|
|
141
136
|
} catch (e) {
|
|
142
137
|
DeploymentStepsError.catch(e, DeploymentStepsErrorCode.ADD_ORDER_FAILED);
|
|
143
138
|
} finally {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import { type NameAndDescriptionCfg,
|
|
2
|
+
import { type NameAndDescriptionCfg, DotrainOrderGui, RaindexClient } from '@rainlanguage/orderbook';
|
|
3
3
|
import { type Writable } from 'svelte/store';
|
|
4
4
|
import type { AppKit } from '@reown/appkit';
|
|
5
5
|
import type { Account } from '../../types/account';
|
|
@@ -11,10 +11,9 @@ declare const __propDef: {
|
|
|
11
11
|
description: string;
|
|
12
12
|
};
|
|
13
13
|
/** Strategy details containing name and description configuration */ strategyDetail: NameAndDescriptionCfg;
|
|
14
|
-
/** Handlers for deployment modals */ onDeploy: (
|
|
14
|
+
/** Handlers for deployment modals */ onDeploy: (raindexClient: RaindexClient, gui: DotrainOrderGui) => void;
|
|
15
15
|
wagmiConnected: Writable<boolean>;
|
|
16
16
|
appKitModal: Writable<AppKit>;
|
|
17
|
-
settings: Writable<NewConfig>;
|
|
18
17
|
account: Account;
|
|
19
18
|
};
|
|
20
19
|
events: {
|
|
@@ -14,7 +14,6 @@ import { createQuery, useQueryClient } from "@tanstack/svelte-query";
|
|
|
14
14
|
import { Button, TabItem, Tabs, Tooltip } from "flowbite-svelte";
|
|
15
15
|
import { onDestroy } from "svelte";
|
|
16
16
|
import OrderApy from "../tables/OrderAPY.svelte";
|
|
17
|
-
import { page } from "$app/stores";
|
|
18
17
|
import Refresh from "../icon/Refresh.svelte";
|
|
19
18
|
import { invalidateTanstackQueries } from "../../queries/queryClient";
|
|
20
19
|
import {
|
|
@@ -24,18 +23,21 @@ import {
|
|
|
24
23
|
} from "flowbite-svelte-icons";
|
|
25
24
|
import { useAccount } from "../../providers/wallet/useAccount";
|
|
26
25
|
import {
|
|
27
|
-
|
|
26
|
+
RaindexClient,
|
|
27
|
+
RaindexOrder,
|
|
28
|
+
RaindexVault
|
|
28
29
|
} from "@rainlanguage/orderbook";
|
|
29
30
|
import { useToasts } from "../../providers/toasts/useToasts";
|
|
31
|
+
import { useRaindexClient } from "../../hooks/useRaindexClient";
|
|
30
32
|
export let handleQuoteDebugModal = void 0;
|
|
31
|
-
export
|
|
33
|
+
export let handleDebugTradeModal = void 0;
|
|
32
34
|
export let colorTheme;
|
|
33
35
|
export let codeMirrorTheme;
|
|
34
36
|
export let lightweightChartsTheme;
|
|
35
37
|
export let orderbookAddress;
|
|
36
38
|
export let orderHash;
|
|
37
|
-
export let
|
|
38
|
-
export let
|
|
39
|
+
export let chainId;
|
|
40
|
+
export let rpcUrls = void 0;
|
|
39
41
|
export let onRemove;
|
|
40
42
|
export let onDeposit;
|
|
41
43
|
export let onWithdraw;
|
|
@@ -44,14 +46,14 @@ let codeMirrorStyles = {};
|
|
|
44
46
|
const queryClient = useQueryClient();
|
|
45
47
|
const { matchesAccount } = useAccount();
|
|
46
48
|
const { errToast } = useToasts();
|
|
49
|
+
const raindexClient = useRaindexClient();
|
|
47
50
|
$: orderDetailQuery = createQuery({
|
|
48
51
|
queryKey: [orderHash, QKEY_ORDER + orderHash],
|
|
49
52
|
queryFn: async () => {
|
|
50
|
-
const result = await getOrderByHash(
|
|
51
|
-
if (result.error) throw new Error(result.error.
|
|
53
|
+
const result = await raindexClient.getOrderByHash(chainId, orderbookAddress, orderHash);
|
|
54
|
+
if (result.error) throw new Error(result.error.readableMsg);
|
|
52
55
|
return result.value;
|
|
53
|
-
}
|
|
54
|
-
enabled: !!subgraphUrl
|
|
56
|
+
}
|
|
55
57
|
});
|
|
56
58
|
const interval = setInterval(async () => {
|
|
57
59
|
await invalidateTanstackQueries(queryClient, [orderHash]);
|
|
@@ -66,7 +68,6 @@ const handleRefresh = async () => {
|
|
|
66
68
|
errToast("Failed to refresh");
|
|
67
69
|
}
|
|
68
70
|
};
|
|
69
|
-
$: subgraphName = $page.url.pathname.split("/")[2]?.split("-")[0];
|
|
70
71
|
</script>
|
|
71
72
|
|
|
72
73
|
<TanstackPageContentDetail query={orderDetailQuery} emptyMessage="Order not found">
|
|
@@ -77,16 +78,16 @@ $: subgraphName = $page.url.pathname.split("/")[2]?.split("-")[0];
|
|
|
77
78
|
<div class="flex items-center gap-x-2">
|
|
78
79
|
<div class="flex gap-x-2">
|
|
79
80
|
<span class="font-light">Order</span>
|
|
80
|
-
<Hash shorten value={data.
|
|
81
|
+
<Hash shorten value={data.orderHash} />
|
|
81
82
|
</div>
|
|
82
|
-
<BadgeActive active={data.
|
|
83
|
+
<BadgeActive active={data.active} large />
|
|
83
84
|
</div>
|
|
84
85
|
|
|
85
86
|
<div class="flex items-center gap-2">
|
|
86
|
-
{#if matchesAccount(data.
|
|
87
|
-
{#if data.
|
|
87
|
+
{#if matchesAccount(data.owner)}
|
|
88
|
+
{#if data.active}
|
|
88
89
|
<Button
|
|
89
|
-
on:click={() => onRemove(data
|
|
90
|
+
on:click={() => onRemove(raindexClient, data)}
|
|
90
91
|
data-testid="remove-button"
|
|
91
92
|
aria-label="Remove order">Remove</Button
|
|
92
93
|
>
|
|
@@ -106,31 +107,32 @@ $: subgraphName = $page.url.pathname.split("/")[2]?.split("-")[0];
|
|
|
106
107
|
<CardProperty>
|
|
107
108
|
<svelte:fragment slot="key">Orderbook</svelte:fragment>
|
|
108
109
|
<svelte:fragment slot="value">
|
|
109
|
-
<Hash type={HashType.Identifier} shorten={false} value={data.
|
|
110
|
+
<Hash type={HashType.Identifier} shorten={false} value={data.orderbook} />
|
|
110
111
|
</svelte:fragment>
|
|
111
112
|
</CardProperty>
|
|
112
113
|
|
|
113
114
|
<CardProperty>
|
|
114
115
|
<svelte:fragment slot="key">Owner</svelte:fragment>
|
|
115
116
|
<svelte:fragment slot="value">
|
|
116
|
-
<Hash type={HashType.Wallet} shorten={false} value={data.
|
|
117
|
+
<Hash type={HashType.Wallet} shorten={false} value={data.owner} />
|
|
117
118
|
</svelte:fragment>
|
|
118
119
|
</CardProperty>
|
|
119
120
|
|
|
120
121
|
<CardProperty>
|
|
121
122
|
<svelte:fragment slot="key">Created</svelte:fragment>
|
|
122
123
|
<svelte:fragment slot="value">
|
|
123
|
-
{formatTimestampSecondsAsLocal(
|
|
124
|
+
{formatTimestampSecondsAsLocal(data.timestampAdded)}
|
|
124
125
|
</svelte:fragment>
|
|
125
126
|
</CardProperty>
|
|
126
127
|
|
|
127
|
-
{#each [{ key: 'Output vaults', type: '
|
|
128
|
-
{
|
|
128
|
+
{#each [{ key: 'Output vaults', type: 'output' }, { key: 'Input vaults', type: 'input' }, { key: 'Input & output vaults', type: 'inputOutput' }] as { key, type }}
|
|
129
|
+
{@const filteredVaults = data.vaults.filter((vault) => vault.vaultType === type)}
|
|
130
|
+
{#if filteredVaults.length !== 0}
|
|
129
131
|
<CardProperty>
|
|
130
132
|
<svelte:fragment slot="key"
|
|
131
133
|
><div class="flex items-center gap-x-2">
|
|
132
134
|
{key}
|
|
133
|
-
{#if type === '
|
|
135
|
+
{#if type === 'InputOutput'}
|
|
134
136
|
<InfoCircleOutline class="h-4 w-4" /><Tooltip
|
|
135
137
|
>{'These vaults can be an input or an output for this order'}</Tooltip
|
|
136
138
|
>{/if}
|
|
@@ -138,8 +140,8 @@ $: subgraphName = $page.url.pathname.split("/")[2]?.split("-")[0];
|
|
|
138
140
|
>
|
|
139
141
|
<svelte:fragment slot="value">
|
|
140
142
|
<div class="mt-2 space-y-2">
|
|
141
|
-
{#each
|
|
142
|
-
<ButtonVaultLink tokenVault={vault} {
|
|
143
|
+
{#each filteredVaults as vault}
|
|
144
|
+
<ButtonVaultLink tokenVault={vault} {chainId} {orderbookAddress}>
|
|
143
145
|
<svelte:fragment slot="buttons">
|
|
144
146
|
{#if matchesAccount(vault.owner)}
|
|
145
147
|
<div class="flex gap-1">
|
|
@@ -147,7 +149,7 @@ $: subgraphName = $page.url.pathname.split("/")[2]?.split("-")[0];
|
|
|
147
149
|
color="light"
|
|
148
150
|
size="xs"
|
|
149
151
|
data-testid="deposit-button"
|
|
150
|
-
on:click={() => onDeposit(vault)}
|
|
152
|
+
on:click={() => onDeposit(raindexClient, vault)}
|
|
151
153
|
>
|
|
152
154
|
<ArrowDownToBracketOutline size="xs" />
|
|
153
155
|
</Button>
|
|
@@ -155,7 +157,7 @@ $: subgraphName = $page.url.pathname.split("/")[2]?.split("-")[0];
|
|
|
155
157
|
color="light"
|
|
156
158
|
size="xs"
|
|
157
159
|
data-testid="withdraw-button"
|
|
158
|
-
on:click={() => onWithdraw(vault)}
|
|
160
|
+
on:click={() => onWithdraw(raindexClient, vault)}
|
|
159
161
|
>
|
|
160
162
|
<ArrowUpFromBracketOutline size="xs" />
|
|
161
163
|
</Button>
|
|
@@ -172,16 +174,10 @@ $: subgraphName = $page.url.pathname.split("/")[2]?.split("-")[0];
|
|
|
172
174
|
</div>
|
|
173
175
|
</svelte:fragment>
|
|
174
176
|
<svelte:fragment slot="chart" let:data>
|
|
175
|
-
<OrderTradesChart
|
|
177
|
+
<OrderTradesChart order={data} {lightweightChartsTheme} {colorTheme} />
|
|
176
178
|
</svelte:fragment>
|
|
177
179
|
<svelte:fragment slot="below" let:data>
|
|
178
|
-
<TanstackOrderQuote
|
|
179
|
-
id={data.order.id}
|
|
180
|
-
order={data.order}
|
|
181
|
-
{rpcUrls}
|
|
182
|
-
{orderbookAddress}
|
|
183
|
-
{handleQuoteDebugModal}
|
|
184
|
-
/>
|
|
180
|
+
<TanstackOrderQuote order={data} {handleQuoteDebugModal} />
|
|
185
181
|
<Tabs
|
|
186
182
|
style="underline"
|
|
187
183
|
contentClass="mt-4"
|
|
@@ -190,7 +186,7 @@ $: subgraphName = $page.url.pathname.split("/")[2]?.split("-")[0];
|
|
|
190
186
|
<TabItem title="Rainlang source">
|
|
191
187
|
<div class="mb-8 overflow-hidden rounded-lg border dark:border-none">
|
|
192
188
|
<CodeMirrorRainlang
|
|
193
|
-
order={data
|
|
189
|
+
order={data}
|
|
194
190
|
codeMirrorTheme={$codeMirrorTheme}
|
|
195
191
|
{codeMirrorDisabled}
|
|
196
192
|
{codeMirrorStyles}
|
|
@@ -198,13 +194,13 @@ $: subgraphName = $page.url.pathname.split("/")[2]?.split("-")[0];
|
|
|
198
194
|
</div>
|
|
199
195
|
</TabItem>
|
|
200
196
|
<TabItem open title="Trades">
|
|
201
|
-
<OrderTradesListTable
|
|
197
|
+
<OrderTradesListTable order={data} {handleDebugTradeModal} {rpcUrls} />
|
|
202
198
|
</TabItem>
|
|
203
199
|
<TabItem title="Volume">
|
|
204
|
-
<OrderVaultsVolTable
|
|
200
|
+
<OrderVaultsVolTable order={data} />
|
|
205
201
|
</TabItem>
|
|
206
202
|
<TabItem title="APY">
|
|
207
|
-
<OrderApy
|
|
203
|
+
<OrderApy order={data} />
|
|
208
204
|
</TabItem>
|
|
209
205
|
</Tabs>
|
|
210
206
|
</svelte:fragment>
|