@rainlanguage/ui-components 0.0.1-alpha.10 → 0.0.1-alpha.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__fixtures__/orderDetail.d.ts +1 -1
- package/dist/__mocks__/MockComponent.svelte +4 -0
- package/dist/__mocks__/MockComponent.svelte.d.ts +3 -1
- package/dist/__mocks__/mockTransactionStore.d.ts +3 -21
- package/dist/__mocks__/mockTransactionStore.js +26 -13
- package/dist/__mocks__/settings.d.ts +6 -2
- package/dist/__mocks__/settings.js +6 -1
- package/dist/__mocks__/stores.d.ts +87 -20
- package/dist/__mocks__/stores.js +30 -21
- package/dist/components/ButtonLoading.svelte +1 -1
- package/dist/components/ButtonVaultLink.svelte +3 -3
- package/dist/components/ButtonVaultLink.svelte.d.ts +1 -1
- package/dist/components/CheckboxMyItemsOnly.svelte +3 -2
- package/dist/components/CheckboxMyItemsOnly.svelte.d.ts +2 -3
- package/dist/components/CheckboxZeroBalanceVault.svelte.d.ts +2 -2
- package/dist/components/CodeMirrorDotrain.svelte +4 -0
- package/dist/components/CodeMirrorDotrain.svelte.d.ts +1 -0
- package/dist/components/CodeMirrorRainlang.svelte +12 -4
- package/dist/components/CodeMirrorRainlang.svelte.d.ts +1 -1
- package/dist/components/EditableSpan.svelte +3 -14
- package/dist/components/EditableSpan.svelte.d.ts +0 -1
- package/dist/components/Hash.svelte +3 -3
- package/dist/components/License.svelte +5 -4
- package/dist/components/ListViewOrderbookFilters.svelte +15 -14
- package/dist/components/ListViewOrderbookFilters.svelte.d.ts +9 -13
- package/dist/components/OrderOrVaultHash.svelte +10 -7
- package/dist/components/OrderOrVaultHash.svelte.d.ts +1 -1
- package/dist/components/PageHeader.svelte +20 -22
- package/dist/components/PageHeader.svelte.d.ts +1 -0
- package/dist/components/TanstackAppTable.svelte +2 -3
- package/dist/components/TanstackAppTable.svelte.d.ts +1 -1
- package/dist/components/ToastDetail.svelte +16 -0
- package/dist/components/ToastDetail.svelte.d.ts +19 -0
- package/dist/components/Tooltip.svelte +8 -0
- package/dist/components/Tooltip.svelte.d.ts +21 -0
- package/dist/components/charts/OrderTradesChart.svelte +3 -2
- package/dist/components/charts/TanstackLightweightChartLine.svelte +5 -9
- package/dist/components/charts/VaultBalanceChart.svelte +6 -6
- package/dist/components/charts/VaultBalanceChart.svelte.d.ts +1 -1
- package/dist/components/charts/transformAndSortData.d.ts +24 -0
- package/dist/components/charts/transformAndSortData.js +111 -0
- package/dist/components/checkbox/CheckboxActiveOrders.svelte +11 -0
- package/dist/components/checkbox/CheckboxActiveOrders.svelte.d.ts +19 -0
- package/dist/components/deployment/ComposedRainlangModal.svelte +7 -5
- package/dist/components/deployment/ComposedRainlangModal.svelte.d.ts +1 -4
- package/dist/components/deployment/DeploymentSectionHeader.svelte +7 -4
- package/dist/components/deployment/DeploymentSteps.svelte +181 -155
- package/dist/components/deployment/DeploymentSteps.svelte.d.ts +6 -13
- package/dist/components/deployment/DeploymentsSection.svelte +18 -14
- package/dist/components/deployment/DepositInput.svelte +31 -14
- package/dist/components/deployment/DepositInput.svelte.d.ts +1 -2
- package/dist/components/deployment/FieldDefinitionInput.svelte +20 -14
- package/dist/components/deployment/FieldDefinitionInput.svelte.d.ts +1 -2
- package/dist/components/deployment/SelectToken.svelte +12 -3
- package/dist/components/deployment/SelectToken.svelte.d.ts +1 -2
- package/dist/components/deployment/StrategyPage.svelte +6 -2
- package/dist/components/deployment/TokenIOInput.svelte +15 -5
- package/dist/components/deployment/TokenIOInput.svelte.d.ts +1 -2
- package/dist/components/deployment/handleDeployment.d.ts +11 -0
- package/dist/components/deployment/handleDeployment.js +33 -0
- package/dist/components/detail/OrderDetail.svelte +51 -44
- package/dist/components/detail/OrderDetail.svelte.d.ts +11 -8
- package/dist/components/detail/TanstackOrderQuote.svelte +11 -7
- package/dist/components/detail/TanstackOrderQuote.svelte.d.ts +1 -1
- package/dist/components/detail/VaultDetail.svelte +33 -42
- package/dist/components/detail/VaultDetail.svelte.d.ts +11 -11
- package/dist/components/dropdown/DropdownActiveSubgraphs.svelte.d.ts +4 -4
- package/dist/components/dropdown/DropdownOrderListAccounts.svelte.d.ts +3 -3
- package/dist/components/icon/Refresh.svelte +2 -1
- package/dist/components/icon/Refresh.svelte.d.ts +1 -0
- package/dist/components/input/InputOrderHash.svelte +1 -1
- package/dist/components/input/InputOrderHash.svelte.d.ts +2 -2
- package/dist/components/input/InputRegistryUrl.svelte +36 -14
- package/dist/components/input/InputToken.svelte +2 -2
- package/dist/components/input/InputTokenAmount.svelte +1 -1
- package/dist/components/tables/OrderAPY.svelte +4 -9
- package/dist/components/tables/OrderTradesListTable.svelte +7 -3
- package/dist/components/tables/OrderVaultsVolTable.svelte +11 -2
- package/dist/components/tables/OrdersListTable.svelte +24 -24
- package/dist/components/tables/OrdersListTable.svelte.d.ts +1 -7
- package/dist/components/tables/VaultBalanceChangesTable.svelte +8 -6
- package/dist/components/tables/VaultsListTable.svelte +48 -57
- package/dist/components/tables/VaultsListTable.svelte.d.ts +13 -20
- package/dist/components/wallet/WalletConnect.svelte +5 -4
- package/dist/components/wallet/WalletConnect.svelte.d.ts +0 -1
- package/dist/consts.d.ts +1 -0
- package/dist/consts.js +1 -0
- package/dist/errors/DeploymentStepsError.d.ts +5 -2
- package/dist/errors/DeploymentStepsError.js +4 -1
- package/dist/hooks/useGui.d.ts +3 -0
- package/dist/hooks/useGui.js +11 -0
- package/dist/index.d.ts +19 -7
- package/dist/index.js +21 -6
- package/dist/providers/GuiProvider.svelte +8 -0
- package/dist/providers/GuiProvider.svelte.d.ts +21 -0
- package/dist/providers/registry/RegistryManager.d.ts +65 -0
- package/dist/providers/registry/RegistryManager.js +133 -0
- package/dist/providers/registry/RegistryProvider.svelte +6 -0
- package/dist/providers/registry/RegistryProvider.svelte.d.ts +21 -0
- package/dist/providers/registry/context.d.ts +10 -0
- package/dist/providers/registry/context.js +46 -0
- package/dist/providers/registry/useRegistry.d.ts +7 -0
- package/dist/providers/registry/useRegistry.js +29 -0
- package/dist/providers/toasts/ToastProvider.svelte +17 -0
- package/dist/providers/toasts/ToastProvider.svelte.d.ts +22 -0
- package/dist/providers/toasts/context.d.ts +11 -0
- package/dist/providers/toasts/context.js +19 -0
- package/dist/providers/toasts/useToasts.d.ts +12 -0
- package/dist/providers/toasts/useToasts.js +54 -0
- package/dist/providers/wallet/WalletProvider.svelte +7 -0
- package/dist/providers/wallet/WalletProvider.svelte.d.ts +21 -0
- package/dist/providers/wallet/context.d.ts +10 -0
- package/dist/providers/wallet/context.js +47 -0
- package/dist/providers/wallet/useAccount.d.ts +8 -0
- package/dist/providers/wallet/useAccount.js +148 -0
- package/dist/queries/queryClient.d.ts +1 -1
- package/dist/queries/queryClient.js +11 -6
- package/dist/services/awaitTransactionIndexing.d.ts +163 -0
- package/dist/services/awaitTransactionIndexing.js +122 -0
- package/dist/services/handleShareChoices.d.ts +2 -2
- package/dist/services/handleShareChoices.js +7 -2
- package/dist/services/historicalOrderCharts.d.ts +1 -1
- package/dist/services/historicalOrderCharts.js +1 -1
- package/dist/services/index.d.ts +2 -1
- package/dist/services/index.js +2 -1
- package/dist/services/loadRegistryUrl.d.ts +2 -0
- package/dist/services/loadRegistryUrl.js +19 -0
- package/dist/services/registry.d.ts +6 -0
- package/dist/services/registry.js +33 -77
- package/dist/services/time.d.ts +12 -0
- package/dist/services/time.js +88 -6
- package/dist/stores/transactionStore.d.ts +9 -12
- package/dist/stores/transactionStore.js +38 -61
- package/dist/storesGeneric/cachedWritableStore.d.ts +57 -0
- package/dist/storesGeneric/cachedWritableStore.js +93 -0
- package/dist/types/account.d.ts +3 -0
- package/dist/types/account.js +1 -0
- package/dist/types/appStores.d.ts +5 -4
- package/dist/types/modal.d.ts +1 -1
- package/dist/types/strategy.d.ts +1 -1
- package/dist/types/toast.d.ts +6 -0
- package/dist/types/toast.js +1 -0
- package/dist/types/transaction.d.ts +3 -3
- package/dist/utils/constructHashLink.d.ts +23 -0
- package/dist/utils/constructHashLink.js +110 -0
- package/dist/utils/vault.d.ts +1 -1
- package/package.json +34 -34
- package/dist/components/deployment/DepositsSection.svelte +0 -8
- package/dist/components/deployment/DepositsSection.svelte.d.ts +0 -20
- package/dist/components/deployment/FieldDefinitionsSection.svelte +0 -9
- package/dist/components/deployment/FieldDefinitionsSection.svelte.d.ts +0 -20
- package/dist/components/deployment/SelectTokensSection.svelte +0 -17
- package/dist/components/deployment/SelectTokensSection.svelte.d.ts +0 -21
- package/dist/components/deployment/TokenIOSection.svelte +0 -17
- package/dist/components/deployment/TokenIOSection.svelte.d.ts +0 -21
- package/dist/components/deployment/getDeploymentTransactionArgs.d.ts +0 -17
- package/dist/components/deployment/getDeploymentTransactionArgs.js +0 -24
- package/dist/components/detail/DepositOrWithdrawButtons.svelte +0 -44
- package/dist/components/detail/DepositOrWithdrawButtons.svelte.d.ts +0 -26
- package/dist/components/dropdown/DropdownOrderStatus.svelte +0 -31
- package/dist/components/dropdown/DropdownOrderStatus.svelte.d.ts +0 -19
- package/dist/utils/time.d.ts +0 -12
- package/dist/utils/time.js +0 -27
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { writable } from 'svelte/store';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a writable Svelte store that persists its value to localStorage.
|
|
4
|
+
*
|
|
5
|
+
* @template T - The type of the value stored in the store
|
|
6
|
+
* @param {string} key - The localStorage key used to store the value
|
|
7
|
+
* @param {T} defaultValue - The default value to use when no value is found in localStorage
|
|
8
|
+
* @param {function(T): string} serialize - Function to convert the store value to a string for storage
|
|
9
|
+
* @param {function(string): T} deserialize - Function to convert the stored string back to the original type
|
|
10
|
+
* @returns {import('svelte/store').Writable<T>} A writable store that automatically syncs with localStorage
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // Create a store for a boolean value
|
|
14
|
+
* const darkMode = cachedWritableStore(
|
|
15
|
+
* 'darkMode',
|
|
16
|
+
* false,
|
|
17
|
+
* value => JSON.stringify(value),
|
|
18
|
+
* str => JSON.parse(str)
|
|
19
|
+
* );
|
|
20
|
+
*
|
|
21
|
+
* // Create a store for a complex object
|
|
22
|
+
* const userPreferences = cachedWritableStore(
|
|
23
|
+
* 'userPrefs',
|
|
24
|
+
* { theme: 'light', fontSize: 14 },
|
|
25
|
+
* value => JSON.stringify(value),
|
|
26
|
+
* str => JSON.parse(str)
|
|
27
|
+
* );
|
|
28
|
+
*/
|
|
29
|
+
export function cachedWritableStore(key, defaultValue, serialize, deserialize) {
|
|
30
|
+
const getCache = () => {
|
|
31
|
+
try {
|
|
32
|
+
const cached = localStorage.getItem(key);
|
|
33
|
+
return cached !== null ? deserialize(cached) : defaultValue;
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return defaultValue;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const setCache = (value) => {
|
|
40
|
+
try {
|
|
41
|
+
if (value !== undefined) {
|
|
42
|
+
localStorage.setItem(key, serialize(value));
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
localStorage.removeItem(key);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// Silently ignore localStorage errors to allow the application to function
|
|
50
|
+
// without persistence in environments where localStorage is unavailable
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const data = writable(getCache());
|
|
54
|
+
data.subscribe((value) => {
|
|
55
|
+
setCache(value);
|
|
56
|
+
});
|
|
57
|
+
return data;
|
|
58
|
+
}
|
|
59
|
+
export const cachedWritableString = (key, defaultValue = '') => cachedWritableStore(key, defaultValue, (v) => v, (v) => v);
|
|
60
|
+
export const cachedWritableInt = (key, defaultValue = 0) => cachedWritableStore(key, defaultValue, (v) => v.toString(), (v) => {
|
|
61
|
+
const parsed = Number.parseInt(v);
|
|
62
|
+
return isNaN(parsed) ? defaultValue : parsed;
|
|
63
|
+
});
|
|
64
|
+
/**
|
|
65
|
+
* Creates a writable store that can hold an optional value of type T and persists to localStorage.
|
|
66
|
+
*
|
|
67
|
+
* @template T - The type of the value stored
|
|
68
|
+
* @param {string} key - The localStorage key to use for persistence
|
|
69
|
+
* @param {T | undefined} defaultValue - The default value if nothing is found in localStorage
|
|
70
|
+
* @param {function} serialize - Function to convert the value to a string for storage
|
|
71
|
+
* @param {function} deserialize - Function to convert the stored string back to a value
|
|
72
|
+
* @returns A writable store that persists to localStorage and can hold undefined values
|
|
73
|
+
*/
|
|
74
|
+
export const cachedWritableOptionalStore = (key, defaultValue = undefined, serialize, deserialize) => cachedWritableStore(key, defaultValue, (v) => (v !== undefined ? serialize(v) : ''), (v) => (v !== '' ? deserialize(v) : undefined));
|
|
75
|
+
/**
|
|
76
|
+
* Creates a writable store that can hold an optional number value and persists to localStorage.
|
|
77
|
+
*
|
|
78
|
+
* @param {string} key - The localStorage key to use for persistence
|
|
79
|
+
* @param {number | undefined} defaultValue - The default value if nothing is found in localStorage
|
|
80
|
+
* @returns A writable store that persists to localStorage and can hold an optional number
|
|
81
|
+
*/
|
|
82
|
+
export const cachedWritableIntOptional = (key, defaultValue = undefined) => cachedWritableOptionalStore(key, defaultValue, (v) => v.toString(), (v) => {
|
|
83
|
+
const parsed = Number.parseInt(v);
|
|
84
|
+
return isNaN(parsed) ? (defaultValue ?? 0) : parsed;
|
|
85
|
+
});
|
|
86
|
+
/**
|
|
87
|
+
* Creates a writable store that can hold an optional string value and persists to localStorage.
|
|
88
|
+
*
|
|
89
|
+
* @param {string} key - The localStorage key to use for persistence
|
|
90
|
+
* @param {string | undefined} defaultValue - The default value if nothing is found in localStorage
|
|
91
|
+
* @returns A writable store that persists to localStorage and can hold an optional string
|
|
92
|
+
*/
|
|
93
|
+
export const cachedWritableStringOptional = (key, defaultValue = undefined) => cachedWritableOptionalStore(key, defaultValue, (v) => v, (v) => v);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Readable, Writable } from 'svelte/store';
|
|
2
|
-
import type { ConfigSource, OrderbookConfigSource } from '@rainlanguage/orderbook
|
|
2
|
+
import type { ConfigSource, OrderbookConfigSource, OrderbookCfgRef } from '@rainlanguage/orderbook';
|
|
3
3
|
export interface AppStoresInterface {
|
|
4
4
|
settings: Writable<ConfigSource | undefined>;
|
|
5
5
|
activeSubgraphs: Writable<Record<string, string>>;
|
|
6
|
-
accounts: Readable<Record<string, string
|
|
7
|
-
activeAccountsItems: Writable<Record<string, string
|
|
8
|
-
|
|
6
|
+
accounts: Readable<Record<string, string>> | undefined;
|
|
7
|
+
activeAccountsItems: Writable<Record<string, string>> | undefined;
|
|
8
|
+
showInactiveOrders: Writable<boolean>;
|
|
9
9
|
orderHash: Writable<string>;
|
|
10
10
|
hideZeroBalanceVaults: Writable<boolean>;
|
|
11
11
|
activeNetworkRef: Writable<string | undefined>;
|
|
@@ -16,4 +16,5 @@ export interface AppStoresInterface {
|
|
|
16
16
|
[k: string]: string;
|
|
17
17
|
}>;
|
|
18
18
|
showMyItemsOnly: Writable<boolean>;
|
|
19
|
+
activeNetworkOrderbooks: Readable<Record<OrderbookCfgRef, OrderbookConfigSource>>;
|
|
19
20
|
}
|
package/dist/types/modal.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SgOrder } from '@rainlanguage/orderbook
|
|
1
|
+
import type { SgOrder } from '@rainlanguage/orderbook';
|
|
2
2
|
import type { DepositOrWithdrawArgs, OrderRemoveArgs, DeploymentArgs } from './transaction';
|
|
3
3
|
export type DepositOrWithdrawModalProps = {
|
|
4
4
|
open: boolean;
|
package/dist/types/strategy.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { ExtendedApprovalCalldata } from '../stores/transactionStore';
|
|
2
|
-
import type { DepositAndAddOrderCalldataResult } from '@rainlanguage/orderbook/js_api';
|
|
3
2
|
import type { Hex } from 'viem';
|
|
4
|
-
import type { SgOrder, SgVault } from '@rainlanguage/orderbook
|
|
3
|
+
import type { DepositAndAddOrderCalldataResult, SgOrder, SgVault } from '@rainlanguage/orderbook';
|
|
5
4
|
export type DeploymentArgs = {
|
|
6
5
|
approvals: ExtendedApprovalCalldata[];
|
|
7
6
|
deploymentCalldata: DepositAndAddOrderCalldataResult;
|
|
8
7
|
orderbookAddress: Hex;
|
|
9
8
|
chainId: number;
|
|
10
|
-
subgraphUrl
|
|
9
|
+
subgraphUrl?: string;
|
|
11
10
|
network: string;
|
|
12
11
|
};
|
|
13
12
|
export type DepositOrWithdrawArgs = {
|
|
@@ -17,6 +16,7 @@ export type DepositOrWithdrawArgs = {
|
|
|
17
16
|
chainId: number;
|
|
18
17
|
rpcUrl: string;
|
|
19
18
|
subgraphUrl: string;
|
|
19
|
+
account: Hex;
|
|
20
20
|
};
|
|
21
21
|
export type OrderRemoveArgs = {
|
|
22
22
|
order: SgOrder;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SgOrder, SgOrderAsIO, SgVault } from '@rainlanguage/orderbook';
|
|
2
|
+
type OrderOrVault = SgOrder | SgOrderAsIO | SgVault;
|
|
3
|
+
/**
|
|
4
|
+
* Constructs a link path for an order or vault based on its type and network
|
|
5
|
+
* @param orderOrVault - The order or vault object
|
|
6
|
+
* @param type - The type of resource ('orders' or 'vaults')
|
|
7
|
+
* @param network - The network name
|
|
8
|
+
* @returns The constructed link path
|
|
9
|
+
*/
|
|
10
|
+
export declare function constructHashLink(orderOrVault: OrderOrVault, type: 'orders' | 'vaults', network: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Determines if an order or vault is active
|
|
13
|
+
* @param orderOrVault - The order or vault object
|
|
14
|
+
* @returns True if the order is active, false otherwise
|
|
15
|
+
*/
|
|
16
|
+
export declare function isOrderOrVaultActive(orderOrVault: OrderOrVault): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Extracts the hash value from an order or vault
|
|
19
|
+
* @param orderOrVault - The order or vault object
|
|
20
|
+
* @returns The hash value
|
|
21
|
+
*/
|
|
22
|
+
export declare function extractHash(orderOrVault: OrderOrVault): string;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import fc from 'fast-check';
|
|
2
|
+
import { test } from '@fast-check/vitest';
|
|
3
|
+
function isOrder(obj) {
|
|
4
|
+
return obj && 'orderHash' in obj;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Constructs a link path for an order or vault based on its type and network
|
|
8
|
+
* @param orderOrVault - The order or vault object
|
|
9
|
+
* @param type - The type of resource ('orders' or 'vaults')
|
|
10
|
+
* @param network - The network name
|
|
11
|
+
* @returns The constructed link path
|
|
12
|
+
*/
|
|
13
|
+
export function constructHashLink(orderOrVault, type, network) {
|
|
14
|
+
if (!orderOrVault) {
|
|
15
|
+
return `/${type}/${network}`;
|
|
16
|
+
}
|
|
17
|
+
const slug = isOrder(orderOrVault) ? orderOrVault.orderHash : orderOrVault?.id;
|
|
18
|
+
return `/${type}/${network}-${slug || ''}`;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Determines if an order or vault is active
|
|
22
|
+
* @param orderOrVault - The order or vault object
|
|
23
|
+
* @returns True if the order is active, false otherwise
|
|
24
|
+
*/
|
|
25
|
+
export function isOrderOrVaultActive(orderOrVault) {
|
|
26
|
+
const _isOrder = isOrder(orderOrVault);
|
|
27
|
+
return _isOrder ? orderOrVault.active : false;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Extracts the hash value from an order or vault
|
|
31
|
+
* @param orderOrVault - The order or vault object
|
|
32
|
+
* @returns The hash value
|
|
33
|
+
*/
|
|
34
|
+
export function extractHash(orderOrVault) {
|
|
35
|
+
const _isOrder = isOrder(orderOrVault);
|
|
36
|
+
return _isOrder ? orderOrVault.orderHash : orderOrVault?.id || '';
|
|
37
|
+
}
|
|
38
|
+
if (import.meta.vitest) {
|
|
39
|
+
const { expect, it, describe } = import.meta.vitest;
|
|
40
|
+
describe('constructHashLink', () => {
|
|
41
|
+
test.prop([
|
|
42
|
+
fc.record({
|
|
43
|
+
orderHash: fc.string(),
|
|
44
|
+
active: fc.boolean()
|
|
45
|
+
}),
|
|
46
|
+
fc.oneof(fc.constant('orders'), fc.constant('vaults')),
|
|
47
|
+
fc.string()
|
|
48
|
+
])('constructs correct link for orders', (order, type, network) => {
|
|
49
|
+
const result = constructHashLink(order, type, network);
|
|
50
|
+
expect(result).toBe(`/${type}/${network}-${order.orderHash}`);
|
|
51
|
+
});
|
|
52
|
+
test.prop([
|
|
53
|
+
fc.record({
|
|
54
|
+
id: fc.string(),
|
|
55
|
+
owner: fc.string()
|
|
56
|
+
}),
|
|
57
|
+
fc.oneof(fc.constant('orders'), fc.constant('vaults')),
|
|
58
|
+
fc.string()
|
|
59
|
+
])('constructs correct link for vaults', (vault, type, network) => {
|
|
60
|
+
const result = constructHashLink(vault, type, network);
|
|
61
|
+
expect(result).toBe(`/${type}/${network}-${vault.id}`);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
describe('isOrderOrVaultActive', () => {
|
|
65
|
+
test.prop([
|
|
66
|
+
fc.record({
|
|
67
|
+
orderHash: fc.string(),
|
|
68
|
+
active: fc.boolean()
|
|
69
|
+
})
|
|
70
|
+
])('returns correct active status for orders', (order) => {
|
|
71
|
+
const result = isOrderOrVaultActive(order);
|
|
72
|
+
expect(result).toBe(order.active);
|
|
73
|
+
});
|
|
74
|
+
test.prop([
|
|
75
|
+
fc.record({
|
|
76
|
+
id: fc.string(),
|
|
77
|
+
owner: fc.string()
|
|
78
|
+
})
|
|
79
|
+
])('returns false for vaults', (vault) => {
|
|
80
|
+
const result = isOrderOrVaultActive(vault);
|
|
81
|
+
expect(result).toBe(false);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
describe('extractHash', () => {
|
|
85
|
+
test.prop([
|
|
86
|
+
fc.record({
|
|
87
|
+
orderHash: fc.string(),
|
|
88
|
+
active: fc.boolean()
|
|
89
|
+
})
|
|
90
|
+
])('extracts hash from orders', (order) => {
|
|
91
|
+
const result = extractHash(order);
|
|
92
|
+
expect(result).toBe(order.orderHash);
|
|
93
|
+
});
|
|
94
|
+
test.prop([
|
|
95
|
+
fc.record({
|
|
96
|
+
id: fc.string(),
|
|
97
|
+
owner: fc.string()
|
|
98
|
+
})
|
|
99
|
+
])('extracts hash from vaults', (vault) => {
|
|
100
|
+
const result = extractHash(vault);
|
|
101
|
+
expect(result).toBe(vault.id);
|
|
102
|
+
});
|
|
103
|
+
it('handles undefined vault id', () => {
|
|
104
|
+
// Create a partial vault object with undefined id
|
|
105
|
+
const vault = { id: undefined };
|
|
106
|
+
const result = extractHash(vault);
|
|
107
|
+
expect(result).toBe('');
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
}
|
package/dist/utils/vault.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { SgVault } from '@rainlanguage/orderbook
|
|
1
|
+
import type { SgVault } from '@rainlanguage/orderbook';
|
|
2
2
|
export declare const vaultBalanceDisplay: (vault: SgVault) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rainlanguage/ui-components",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.100",
|
|
4
4
|
"description": "A component library for building Svelte applications to be used with Raindex.",
|
|
5
5
|
"license": "LicenseRef-DCL-1.0",
|
|
6
6
|
"author": "Rain Open Source Software Ltd",
|
|
@@ -49,38 +49,38 @@
|
|
|
49
49
|
"types": "./dist/index.d.ts",
|
|
50
50
|
"type": "module",
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@codemirror/lang-yaml": "
|
|
53
|
-
"@fontsource/dm-sans": "
|
|
54
|
-
"@imask/svelte": "
|
|
55
|
-
"@observablehq/plot": "
|
|
56
|
-
"@rainlanguage/orderbook": "0.0.1-alpha.
|
|
57
|
-
"@reown/appkit": "
|
|
58
|
-
"@reown/appkit-adapter-wagmi": "
|
|
59
|
-
"@sentry/sveltekit": "
|
|
60
|
-
"@square/svelte-store": "
|
|
61
|
-
"@sveltejs/kit": "
|
|
62
|
-
"@tanstack/svelte-query": "
|
|
63
|
-
"@wagmi/core": "
|
|
64
|
-
"@walletconnect/ethereum-provider": "
|
|
65
|
-
"@walletconnect/modal": "
|
|
66
|
-
"@web3modal/ethers5": "
|
|
67
|
-
"camelcase-keys": "
|
|
68
|
-
"codemirror-rainlang": "
|
|
69
|
-
"dayjs": "
|
|
70
|
-
"ethers": "
|
|
71
|
-
"flowbite": "
|
|
72
|
-
"flowbite-svelte": "
|
|
73
|
-
"flowbite-svelte-icons": "
|
|
74
|
-
"fuse.js": "
|
|
75
|
-
"lightweight-charts": "
|
|
76
|
-
"lodash": "
|
|
77
|
-
"svelte": "
|
|
78
|
-
"svelte-codemirror-editor": "
|
|
79
|
-
"svelte-markdown": "
|
|
80
|
-
"tailwind-merge": "
|
|
81
|
-
"thememirror": "
|
|
82
|
-
"uuid": "
|
|
83
|
-
"viem": "
|
|
84
|
-
"wagmi": "
|
|
52
|
+
"@codemirror/lang-yaml": "6.1.1",
|
|
53
|
+
"@fontsource/dm-sans": "5.1.0",
|
|
54
|
+
"@imask/svelte": "7.6.1",
|
|
55
|
+
"@observablehq/plot": "0.6.16",
|
|
56
|
+
"@rainlanguage/orderbook": "0.0.1-alpha.100",
|
|
57
|
+
"@reown/appkit": "1.6.4",
|
|
58
|
+
"@reown/appkit-adapter-wagmi": "1.6.4",
|
|
59
|
+
"@sentry/sveltekit": "7.120.0",
|
|
60
|
+
"@square/svelte-store": "1.0.18",
|
|
61
|
+
"@sveltejs/kit": "2.8.1",
|
|
62
|
+
"@tanstack/svelte-query": "5.59.20",
|
|
63
|
+
"@wagmi/core": "2.16.3",
|
|
64
|
+
"@walletconnect/ethereum-provider": "2.17.2",
|
|
65
|
+
"@walletconnect/modal": "2.7.0",
|
|
66
|
+
"@web3modal/ethers5": "4.2.3",
|
|
67
|
+
"camelcase-keys": "9.1.3",
|
|
68
|
+
"codemirror-rainlang": "3.0.13",
|
|
69
|
+
"dayjs": "1.11.13",
|
|
70
|
+
"ethers": "5.7.2",
|
|
71
|
+
"flowbite": "2.5.2",
|
|
72
|
+
"flowbite-svelte": "0.44.24",
|
|
73
|
+
"flowbite-svelte-icons": "0.4.5",
|
|
74
|
+
"fuse.js": "7.0.0",
|
|
75
|
+
"lightweight-charts": "4.2.1",
|
|
76
|
+
"lodash": "4.17.21",
|
|
77
|
+
"svelte": "4.2.19",
|
|
78
|
+
"svelte-codemirror-editor": "1.4.1",
|
|
79
|
+
"svelte-markdown": "0.4.1",
|
|
80
|
+
"tailwind-merge": "2.5.4",
|
|
81
|
+
"thememirror": "2.0.1",
|
|
82
|
+
"uuid": "9.0.1",
|
|
83
|
+
"viem": "2.24.3",
|
|
84
|
+
"wagmi": "2.14.7"
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type { DotrainOrderGui, GuiDepositCfg } from '@rainlanguage/orderbook/js_api';
|
|
3
|
-
declare const __propDef: {
|
|
4
|
-
props: {
|
|
5
|
-
allDepositFields: GuiDepositCfg[];
|
|
6
|
-
gui: DotrainOrderGui;
|
|
7
|
-
};
|
|
8
|
-
events: {
|
|
9
|
-
[evt: string]: CustomEvent<any>;
|
|
10
|
-
};
|
|
11
|
-
slots: {};
|
|
12
|
-
exports?: {} | undefined;
|
|
13
|
-
bindings?: string | undefined;
|
|
14
|
-
};
|
|
15
|
-
export type DepositsSectionProps = typeof __propDef.props;
|
|
16
|
-
export type DepositsSectionEvents = typeof __propDef.events;
|
|
17
|
-
export type DepositsSectionSlots = typeof __propDef.slots;
|
|
18
|
-
export default class DepositsSection extends SvelteComponent<DepositsSectionProps, DepositsSectionEvents, DepositsSectionSlots> {
|
|
19
|
-
}
|
|
20
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
<script>import FieldDefinitionInput from "./FieldDefinitionInput.svelte";
|
|
2
|
-
import {} from "@rainlanguage/orderbook/js_api";
|
|
3
|
-
export let allFieldDefinitions;
|
|
4
|
-
export let gui;
|
|
5
|
-
</script>
|
|
6
|
-
|
|
7
|
-
{#each allFieldDefinitions as fieldDefinition}
|
|
8
|
-
<FieldDefinitionInput {fieldDefinition} {gui} />
|
|
9
|
-
{/each}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
|
-
import { type DotrainOrderGui, type GuiFieldDefinitionCfg } from '@rainlanguage/orderbook/js_api';
|
|
3
|
-
declare const __propDef: {
|
|
4
|
-
props: {
|
|
5
|
-
allFieldDefinitions: GuiFieldDefinitionCfg[];
|
|
6
|
-
gui: DotrainOrderGui;
|
|
7
|
-
};
|
|
8
|
-
events: {
|
|
9
|
-
[evt: string]: CustomEvent<any>;
|
|
10
|
-
};
|
|
11
|
-
slots: {};
|
|
12
|
-
exports?: {} | undefined;
|
|
13
|
-
bindings?: string | undefined;
|
|
14
|
-
};
|
|
15
|
-
export type FieldDefinitionsSectionProps = typeof __propDef.props;
|
|
16
|
-
export type FieldDefinitionsSectionEvents = typeof __propDef.events;
|
|
17
|
-
export type FieldDefinitionsSectionSlots = typeof __propDef.slots;
|
|
18
|
-
export default class FieldDefinitionsSection extends SvelteComponent<FieldDefinitionsSectionProps, FieldDefinitionsSectionEvents, FieldDefinitionsSectionSlots> {
|
|
19
|
-
}
|
|
20
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<script>import DeploymentSectionHeader from "./DeploymentSectionHeader.svelte";
|
|
2
|
-
import SelectToken from "./SelectToken.svelte";
|
|
3
|
-
import { DotrainOrderGui } from "@rainlanguage/orderbook/js_api";
|
|
4
|
-
export let gui;
|
|
5
|
-
export let selectTokens;
|
|
6
|
-
export let onSelectTokenSelect;
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<div class="flex w-full flex-col gap-4">
|
|
10
|
-
<DeploymentSectionHeader
|
|
11
|
-
title="Select Tokens"
|
|
12
|
-
description="Select the tokens that you want to use in your order."
|
|
13
|
-
/>
|
|
14
|
-
{#each selectTokens as token}
|
|
15
|
-
<SelectToken {token} bind:gui {onSelectTokenSelect} />
|
|
16
|
-
{/each}
|
|
17
|
-
</div>
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
|
-
import { DotrainOrderGui, type SelectTokens } from '@rainlanguage/orderbook/js_api';
|
|
3
|
-
declare const __propDef: {
|
|
4
|
-
props: {
|
|
5
|
-
gui: DotrainOrderGui;
|
|
6
|
-
selectTokens: SelectTokens;
|
|
7
|
-
onSelectTokenSelect: () => void;
|
|
8
|
-
};
|
|
9
|
-
events: {
|
|
10
|
-
[evt: string]: CustomEvent<any>;
|
|
11
|
-
};
|
|
12
|
-
slots: {};
|
|
13
|
-
exports?: {} | undefined;
|
|
14
|
-
bindings?: string | undefined;
|
|
15
|
-
};
|
|
16
|
-
export type SelectTokensSectionProps = typeof __propDef.props;
|
|
17
|
-
export type SelectTokensSectionEvents = typeof __propDef.events;
|
|
18
|
-
export type SelectTokensSectionSlots = typeof __propDef.slots;
|
|
19
|
-
export default class SelectTokensSection extends SvelteComponent<SelectTokensSectionProps, SelectTokensSectionEvents, SelectTokensSectionSlots> {
|
|
20
|
-
}
|
|
21
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<script>import TokenIOInput from "./TokenIOInput.svelte";
|
|
2
|
-
export let allTokenInputs = [];
|
|
3
|
-
export let allTokenOutputs = [];
|
|
4
|
-
export let gui;
|
|
5
|
-
</script>
|
|
6
|
-
|
|
7
|
-
{#if allTokenInputs.length > 0}
|
|
8
|
-
{#each allTokenInputs as input, i}
|
|
9
|
-
<TokenIOInput {i} label="Input" vault={input} {gui} />
|
|
10
|
-
{/each}
|
|
11
|
-
{/if}
|
|
12
|
-
|
|
13
|
-
{#if allTokenOutputs.length > 0}
|
|
14
|
-
{#each allTokenOutputs as output, i}
|
|
15
|
-
<TokenIOInput {i} label="Output" vault={output} {gui} />
|
|
16
|
-
{/each}
|
|
17
|
-
{/if}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type { DotrainOrderGui, OrderIOCfg } from '@rainlanguage/orderbook/js_api';
|
|
3
|
-
declare const __propDef: {
|
|
4
|
-
props: {
|
|
5
|
-
allTokenInputs?: OrderIOCfg[];
|
|
6
|
-
allTokenOutputs?: OrderIOCfg[];
|
|
7
|
-
gui: DotrainOrderGui;
|
|
8
|
-
};
|
|
9
|
-
events: {
|
|
10
|
-
[evt: string]: CustomEvent<any>;
|
|
11
|
-
};
|
|
12
|
-
slots: {};
|
|
13
|
-
exports?: {} | undefined;
|
|
14
|
-
bindings?: string | undefined;
|
|
15
|
-
};
|
|
16
|
-
export type TokenIoSectionProps = typeof __propDef.props;
|
|
17
|
-
export type TokenIoSectionEvents = typeof __propDef.events;
|
|
18
|
-
export type TokenIoSectionSlots = typeof __propDef.slots;
|
|
19
|
-
export default class TokenIoSection extends SvelteComponent<TokenIoSectionProps, TokenIoSectionEvents, TokenIoSectionSlots> {
|
|
20
|
-
}
|
|
21
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Config } from '@wagmi/core';
|
|
2
|
-
import type { DepositAndAddOrderCalldataResult, DotrainOrderGui } from '@rainlanguage/orderbook/js_api';
|
|
3
|
-
import type { Hex } from 'viem';
|
|
4
|
-
import type { ExtendedApprovalCalldata } from '../../stores/transactionStore';
|
|
5
|
-
export declare enum AddOrderErrors {
|
|
6
|
-
ADD_ORDER_FAILED = "Failed to add order",
|
|
7
|
-
MISSING_GUI = "Order GUI is required",
|
|
8
|
-
MISSING_CONFIG = "Wagmi config is required",
|
|
9
|
-
NO_WALLET = "No wallet address found"
|
|
10
|
-
}
|
|
11
|
-
export interface HandleAddOrderResult {
|
|
12
|
-
approvals: ExtendedApprovalCalldata[];
|
|
13
|
-
deploymentCalldata: DepositAndAddOrderCalldataResult;
|
|
14
|
-
orderbookAddress: Hex;
|
|
15
|
-
chainId: number;
|
|
16
|
-
}
|
|
17
|
-
export declare function getDeploymentTransactionArgs(gui: DotrainOrderGui, wagmiConfig: Config | undefined): Promise<HandleAddOrderResult>;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { getAccount } from '@wagmi/core';
|
|
2
|
-
export var AddOrderErrors;
|
|
3
|
-
(function (AddOrderErrors) {
|
|
4
|
-
AddOrderErrors["ADD_ORDER_FAILED"] = "Failed to add order";
|
|
5
|
-
AddOrderErrors["MISSING_GUI"] = "Order GUI is required";
|
|
6
|
-
AddOrderErrors["MISSING_CONFIG"] = "Wagmi config is required";
|
|
7
|
-
AddOrderErrors["NO_WALLET"] = "No wallet address found";
|
|
8
|
-
})(AddOrderErrors || (AddOrderErrors = {}));
|
|
9
|
-
export async function getDeploymentTransactionArgs(gui, wagmiConfig) {
|
|
10
|
-
if (!wagmiConfig) {
|
|
11
|
-
throw new Error(AddOrderErrors.MISSING_CONFIG);
|
|
12
|
-
}
|
|
13
|
-
const { address } = getAccount(wagmiConfig);
|
|
14
|
-
if (!address) {
|
|
15
|
-
throw new Error(AddOrderErrors.NO_WALLET);
|
|
16
|
-
}
|
|
17
|
-
const { approvals, deploymentCalldata, orderbookAddress, chainId } = await gui.getDeploymentTransactionArgs(address);
|
|
18
|
-
return {
|
|
19
|
-
approvals,
|
|
20
|
-
deploymentCalldata,
|
|
21
|
-
orderbookAddress: orderbookAddress,
|
|
22
|
-
chainId
|
|
23
|
-
};
|
|
24
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
<script>import { Button } from "flowbite-svelte";
|
|
2
|
-
import { ArrowDownOutline, ArrowUpOutline } from "flowbite-svelte-icons";
|
|
3
|
-
export let handleDepositOrWithdrawModal;
|
|
4
|
-
export let vault;
|
|
5
|
-
export let chainId;
|
|
6
|
-
export let rpcUrl;
|
|
7
|
-
export let query;
|
|
8
|
-
export let subgraphUrl;
|
|
9
|
-
</script>
|
|
10
|
-
|
|
11
|
-
<Button
|
|
12
|
-
data-testid="depositOrWithdrawButton"
|
|
13
|
-
color="light"
|
|
14
|
-
size="xs"
|
|
15
|
-
on:click={() =>
|
|
16
|
-
handleDepositOrWithdrawModal({
|
|
17
|
-
open: true,
|
|
18
|
-
args: {
|
|
19
|
-
vault,
|
|
20
|
-
onDepositOrWithdraw: $query.refetch,
|
|
21
|
-
action: 'deposit',
|
|
22
|
-
chainId,
|
|
23
|
-
rpcUrl,
|
|
24
|
-
subgraphUrl
|
|
25
|
-
}
|
|
26
|
-
})}><ArrowUpOutline size="xs" /></Button
|
|
27
|
-
>
|
|
28
|
-
<Button
|
|
29
|
-
data-testid="depositOrWithdrawButton"
|
|
30
|
-
color="light"
|
|
31
|
-
size="xs"
|
|
32
|
-
on:click={() =>
|
|
33
|
-
handleDepositOrWithdrawModal({
|
|
34
|
-
open: true,
|
|
35
|
-
args: {
|
|
36
|
-
vault,
|
|
37
|
-
onDepositOrWithdraw: $query.refetch,
|
|
38
|
-
action: 'withdraw',
|
|
39
|
-
chainId,
|
|
40
|
-
rpcUrl,
|
|
41
|
-
subgraphUrl
|
|
42
|
-
}
|
|
43
|
-
})}><ArrowDownOutline size="xs" /></Button
|
|
44
|
-
>
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type { SgVault } from '@rainlanguage/orderbook/js_api';
|
|
3
|
-
import type { CreateQueryResult } from '@tanstack/svelte-query';
|
|
4
|
-
import type { DepositOrWithdrawModalProps } from '../../types/modal';
|
|
5
|
-
declare const __propDef: {
|
|
6
|
-
props: {
|
|
7
|
-
handleDepositOrWithdrawModal: (props: DepositOrWithdrawModalProps) => void;
|
|
8
|
-
vault: SgVault;
|
|
9
|
-
chainId: number;
|
|
10
|
-
rpcUrl: string;
|
|
11
|
-
query: CreateQueryResult;
|
|
12
|
-
subgraphUrl: string;
|
|
13
|
-
};
|
|
14
|
-
events: {
|
|
15
|
-
[evt: string]: CustomEvent<any>;
|
|
16
|
-
};
|
|
17
|
-
slots: {};
|
|
18
|
-
exports?: {} | undefined;
|
|
19
|
-
bindings?: string | undefined;
|
|
20
|
-
};
|
|
21
|
-
export type DepositOrWithdrawButtonsProps = typeof __propDef.props;
|
|
22
|
-
export type DepositOrWithdrawButtonsEvents = typeof __propDef.events;
|
|
23
|
-
export type DepositOrWithdrawButtonsSlots = typeof __propDef.slots;
|
|
24
|
-
export default class DepositOrWithdrawButtons extends SvelteComponent<DepositOrWithdrawButtonsProps, DepositOrWithdrawButtonsEvents, DepositOrWithdrawButtonsSlots> {
|
|
25
|
-
}
|
|
26
|
-
export {};
|