@rainlanguage/ui-components 0.0.1-alpha.13 → 0.0.1-alpha.131

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.
Files changed (188) hide show
  1. package/dist/__fixtures__/orderDetail.d.ts +1 -1
  2. package/dist/__fixtures__/settings.yaml +183 -0
  3. package/dist/__mocks__/MockComponent.svelte +4 -0
  4. package/dist/__mocks__/MockComponent.svelte.d.ts +3 -1
  5. package/dist/__mocks__/settings.d.ts +7 -3
  6. package/dist/__mocks__/settings.js +68 -33
  7. package/dist/__mocks__/stores.d.ts +94 -27
  8. package/dist/__mocks__/stores.js +45 -22
  9. package/dist/components/ButtonLoading.svelte +1 -1
  10. package/dist/components/ButtonVaultLink.svelte +3 -3
  11. package/dist/components/ButtonVaultLink.svelte.d.ts +1 -1
  12. package/dist/components/CheckboxMyItemsOnly.svelte +3 -2
  13. package/dist/components/CheckboxMyItemsOnly.svelte.d.ts +2 -3
  14. package/dist/components/CheckboxZeroBalanceVault.svelte.d.ts +2 -2
  15. package/dist/components/CodeMirrorDotrain.svelte +4 -0
  16. package/dist/components/CodeMirrorDotrain.svelte.d.ts +1 -0
  17. package/dist/components/CodeMirrorRainlang.svelte +11 -3
  18. package/dist/components/CodeMirrorRainlang.svelte.d.ts +1 -1
  19. package/dist/components/EditableSpan.svelte +3 -14
  20. package/dist/components/EditableSpan.svelte.d.ts +0 -1
  21. package/dist/components/Hash.svelte +3 -3
  22. package/dist/components/License.svelte +5 -4
  23. package/dist/components/ListViewOrderbookFilters.svelte +16 -15
  24. package/dist/components/ListViewOrderbookFilters.svelte.d.ts +9 -13
  25. package/dist/components/OrderOrVaultHash.svelte +10 -7
  26. package/dist/components/OrderOrVaultHash.svelte.d.ts +1 -1
  27. package/dist/components/PageHeader.svelte +1 -1
  28. package/dist/components/TanstackAppTable.svelte +2 -3
  29. package/dist/components/TanstackAppTable.svelte.d.ts +1 -1
  30. package/dist/components/ToastDetail.svelte +42 -0
  31. package/dist/components/ToastDetail.svelte.d.ts +20 -0
  32. package/dist/components/Tooltip.svelte +8 -0
  33. package/dist/components/Tooltip.svelte.d.ts +21 -0
  34. package/dist/components/charts/OrderTradesChart.svelte +3 -2
  35. package/dist/components/charts/TanstackLightweightChartLine.svelte +5 -9
  36. package/dist/components/charts/VaultBalanceChart.svelte +6 -6
  37. package/dist/components/charts/VaultBalanceChart.svelte.d.ts +1 -1
  38. package/dist/components/charts/transformAndSortData.d.ts +24 -0
  39. package/dist/components/charts/transformAndSortData.js +111 -0
  40. package/dist/components/checkbox/CheckboxActiveOrders.svelte +11 -0
  41. package/dist/components/checkbox/CheckboxActiveOrders.svelte.d.ts +19 -0
  42. package/dist/components/deployment/ButtonSelectOption.svelte +2 -0
  43. package/dist/components/deployment/ButtonSelectOption.svelte.d.ts +1 -0
  44. package/dist/components/deployment/ComposedRainlangModal.svelte +7 -5
  45. package/dist/components/deployment/ComposedRainlangModal.svelte.d.ts +1 -4
  46. package/dist/components/deployment/DeploymentSectionHeader.svelte +7 -4
  47. package/dist/components/deployment/DeploymentSteps.svelte +169 -185
  48. package/dist/components/deployment/DeploymentSteps.svelte.d.ts +7 -13
  49. package/dist/components/deployment/DeploymentsSection.svelte +18 -14
  50. package/dist/components/deployment/DepositInput.svelte +32 -14
  51. package/dist/components/deployment/DepositInput.svelte.d.ts +1 -2
  52. package/dist/components/deployment/DisclaimerModal.svelte +1 -0
  53. package/dist/components/deployment/FieldDefinitionInput.svelte +22 -14
  54. package/dist/components/deployment/FieldDefinitionInput.svelte.d.ts +1 -2
  55. package/dist/components/deployment/SelectToken.svelte +16 -4
  56. package/dist/components/deployment/SelectToken.svelte.d.ts +1 -2
  57. package/dist/components/deployment/StrategyPage.svelte +6 -2
  58. package/dist/components/deployment/TokenIOInput.svelte +16 -5
  59. package/dist/components/deployment/TokenIOInput.svelte.d.ts +1 -2
  60. package/dist/components/detail/OrderDetail.svelte +60 -44
  61. package/dist/components/detail/OrderDetail.svelte.d.ts +11 -8
  62. package/dist/components/detail/TanstackOrderQuote.svelte +17 -7
  63. package/dist/components/detail/TanstackOrderQuote.svelte.d.ts +1 -1
  64. package/dist/components/detail/VaultDetail.svelte +43 -43
  65. package/dist/components/detail/VaultDetail.svelte.d.ts +11 -11
  66. package/dist/components/dropdown/DropdownActiveSubgraphs.svelte +2 -2
  67. package/dist/components/dropdown/DropdownActiveSubgraphs.svelte.d.ts +4 -4
  68. package/dist/components/dropdown/DropdownOrderListAccounts.svelte +2 -1
  69. package/dist/components/dropdown/DropdownOrderListAccounts.svelte.d.ts +3 -3
  70. package/dist/components/icon/Refresh.svelte +2 -1
  71. package/dist/components/icon/Refresh.svelte.d.ts +1 -0
  72. package/dist/components/input/InputOrderHash.svelte +1 -1
  73. package/dist/components/input/InputOrderHash.svelte.d.ts +2 -2
  74. package/dist/components/input/InputRegistryUrl.svelte +36 -14
  75. package/dist/components/input/InputToken.svelte +2 -2
  76. package/dist/components/input/InputTokenAmount.svelte +1 -1
  77. package/dist/components/tables/OrderAPY.svelte +4 -9
  78. package/dist/components/tables/OrderTradesListTable.svelte +7 -3
  79. package/dist/components/tables/OrderVaultsVolTable.svelte +11 -2
  80. package/dist/components/tables/OrdersListTable.svelte +27 -31
  81. package/dist/components/tables/OrdersListTable.svelte.d.ts +2 -8
  82. package/dist/components/tables/VaultBalanceChangesTable.svelte +8 -6
  83. package/dist/components/tables/VaultsListTable.svelte +53 -67
  84. package/dist/components/tables/VaultsListTable.svelte.d.ts +12 -20
  85. package/dist/components/transactions/FixedBottomTransaction.svelte +63 -0
  86. package/dist/components/transactions/FixedBottomTransaction.svelte.d.ts +16 -0
  87. package/dist/components/transactions/TransactionDetail.svelte +31 -0
  88. package/dist/components/transactions/TransactionDetail.svelte.d.ts +20 -0
  89. package/dist/components/transactions/TransactionList.svelte +17 -0
  90. package/dist/components/transactions/TransactionList.svelte.d.ts +16 -0
  91. package/dist/components/transactions/getStatusEmoji.d.ts +2 -0
  92. package/dist/components/transactions/getStatusEmoji.js +20 -0
  93. package/dist/components/wallet/WalletConnect.svelte +5 -4
  94. package/dist/components/wallet/WalletConnect.svelte.d.ts +0 -1
  95. package/dist/consts.d.ts +1 -0
  96. package/dist/consts.js +1 -0
  97. package/dist/errors/DeploymentStepsError.d.ts +6 -2
  98. package/dist/errors/DeploymentStepsError.js +5 -1
  99. package/dist/hooks/useGui.d.ts +3 -0
  100. package/dist/hooks/useGui.js +11 -0
  101. package/dist/index.d.ts +27 -11
  102. package/dist/index.js +28 -8
  103. package/dist/models/Transaction.d.ts +80 -0
  104. package/dist/models/Transaction.js +134 -0
  105. package/dist/providers/GuiProvider.svelte +8 -0
  106. package/dist/providers/GuiProvider.svelte.d.ts +21 -0
  107. package/dist/providers/registry/RegistryManager.d.ts +65 -0
  108. package/dist/providers/registry/RegistryManager.js +133 -0
  109. package/dist/providers/registry/RegistryProvider.svelte +6 -0
  110. package/dist/providers/registry/RegistryProvider.svelte.d.ts +21 -0
  111. package/dist/providers/registry/context.d.ts +10 -0
  112. package/dist/providers/registry/context.js +46 -0
  113. package/dist/providers/registry/useRegistry.d.ts +7 -0
  114. package/dist/providers/registry/useRegistry.js +29 -0
  115. package/dist/providers/toasts/ToastProvider.svelte +17 -0
  116. package/dist/providers/toasts/ToastProvider.svelte.d.ts +18 -0
  117. package/dist/providers/toasts/context.d.ts +14 -0
  118. package/dist/providers/toasts/context.js +22 -0
  119. package/dist/providers/toasts/useToasts.d.ts +16 -0
  120. package/dist/providers/toasts/useToasts.js +63 -0
  121. package/dist/providers/transactions/TransactionManager.d.ts +183 -0
  122. package/dist/providers/transactions/TransactionManager.js +353 -0
  123. package/dist/providers/transactions/TransactionProvider.svelte +11 -0
  124. package/dist/providers/transactions/TransactionProvider.svelte.d.ts +24 -0
  125. package/dist/providers/transactions/context.d.ts +19 -0
  126. package/dist/providers/transactions/context.js +28 -0
  127. package/dist/providers/transactions/useTransactions.d.ts +13 -0
  128. package/dist/providers/transactions/useTransactions.js +18 -0
  129. package/dist/providers/wallet/WalletProvider.svelte +7 -0
  130. package/dist/providers/wallet/WalletProvider.svelte.d.ts +21 -0
  131. package/dist/providers/wallet/context.d.ts +10 -0
  132. package/dist/providers/wallet/context.js +47 -0
  133. package/dist/providers/wallet/useAccount.d.ts +8 -0
  134. package/dist/providers/wallet/useAccount.js +148 -0
  135. package/dist/queries/queryClient.d.ts +1 -1
  136. package/dist/queries/queryClient.js +11 -6
  137. package/dist/services/awaitTransactionIndexing.d.ts +100 -0
  138. package/dist/services/awaitTransactionIndexing.js +57 -0
  139. package/dist/services/handleShareChoices.d.ts +2 -2
  140. package/dist/services/handleShareChoices.js +7 -2
  141. package/dist/services/historicalOrderCharts.d.ts +1 -1
  142. package/dist/services/historicalOrderCharts.js +1 -1
  143. package/dist/services/index.d.ts +2 -1
  144. package/dist/services/index.js +2 -1
  145. package/dist/services/loadRegistryUrl.d.ts +2 -0
  146. package/dist/services/loadRegistryUrl.js +19 -0
  147. package/dist/services/registry.d.ts +6 -0
  148. package/dist/services/registry.js +33 -77
  149. package/dist/services/time.d.ts +12 -0
  150. package/dist/services/time.js +88 -6
  151. package/dist/storesGeneric/cachedWritableStore.d.ts +57 -0
  152. package/dist/storesGeneric/cachedWritableStore.js +93 -0
  153. package/dist/types/account.d.ts +3 -0
  154. package/dist/types/account.js +1 -0
  155. package/dist/types/appStores.d.ts +10 -9
  156. package/dist/types/modal.d.ts +24 -12
  157. package/dist/types/strategy.d.ts +1 -1
  158. package/dist/types/toast.d.ts +11 -0
  159. package/dist/types/toast.js +1 -0
  160. package/dist/types/transaction.d.ts +54 -15
  161. package/dist/types/transaction.js +29 -1
  162. package/dist/utils/configHelpers.d.ts +8 -0
  163. package/dist/utils/configHelpers.js +38 -0
  164. package/dist/utils/constructHashLink.d.ts +23 -0
  165. package/dist/utils/constructHashLink.js +110 -0
  166. package/dist/utils/vault.d.ts +1 -1
  167. package/package.json +34 -34
  168. package/dist/__fixtures__/settings-12-11-24.json +0 -160
  169. package/dist/__mocks__/mockTransactionStore.d.ts +0 -22
  170. package/dist/__mocks__/mockTransactionStore.js +0 -56
  171. package/dist/components/deployment/DepositsSection.svelte +0 -8
  172. package/dist/components/deployment/DepositsSection.svelte.d.ts +0 -20
  173. package/dist/components/deployment/FieldDefinitionsSection.svelte +0 -9
  174. package/dist/components/deployment/FieldDefinitionsSection.svelte.d.ts +0 -20
  175. package/dist/components/deployment/SelectTokensSection.svelte +0 -17
  176. package/dist/components/deployment/SelectTokensSection.svelte.d.ts +0 -21
  177. package/dist/components/deployment/TokenIOSection.svelte +0 -17
  178. package/dist/components/deployment/TokenIOSection.svelte.d.ts +0 -21
  179. package/dist/components/deployment/getDeploymentTransactionArgs.d.ts +0 -17
  180. package/dist/components/deployment/getDeploymentTransactionArgs.js +0 -24
  181. package/dist/components/detail/DepositOrWithdrawButtons.svelte +0 -44
  182. package/dist/components/detail/DepositOrWithdrawButtons.svelte.d.ts +0 -26
  183. package/dist/components/dropdown/DropdownOrderStatus.svelte +0 -31
  184. package/dist/components/dropdown/DropdownOrderStatus.svelte.d.ts +0 -19
  185. package/dist/stores/transactionStore.d.ts +0 -98
  186. package/dist/stores/transactionStore.js +0 -303
  187. package/dist/utils/time.d.ts +0 -12
  188. package/dist/utils/time.js +0 -27
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Manages registry URL settings, persisting values in localStorage and URL parameters
3
+ */
4
+ export class RegistryManager {
5
+ /** The default registry URL to fall back to */
6
+ defaultRegistry;
7
+ /** The currently selected registry URL */
8
+ currentRegistry;
9
+ /** Key used for localStorage and URL parameters */
10
+ static STORAGE_KEY = 'registry';
11
+ /**
12
+ * Create a new RegistryManager
13
+ * @param defaultRegistry The default registry URL to use.
14
+ */
15
+ constructor(defaultRegistry) {
16
+ this.defaultRegistry = defaultRegistry;
17
+ this.currentRegistry = this.loadRegistryFromStorageOrUrl();
18
+ }
19
+ /**
20
+ * Initialize registry from URL param or local storage
21
+ * @returns The registry URL to use
22
+ */
23
+ loadRegistryFromStorageOrUrl() {
24
+ const urlParam = this.getRegistryParamFromUrl();
25
+ if (urlParam) {
26
+ this.setRegistryToLocalStorage(urlParam);
27
+ return urlParam;
28
+ }
29
+ return this.getRegistryFromLocalStorage() ?? this.defaultRegistry;
30
+ }
31
+ /**
32
+ * Get the registry from the URL param
33
+ * @returns The registry value from URL or null if not present
34
+ * @throws Error if URL parsing fails
35
+ */
36
+ getRegistryParamFromUrl() {
37
+ try {
38
+ return new URL(window.location.href).searchParams.get(RegistryManager.STORAGE_KEY);
39
+ }
40
+ catch (error) {
41
+ throw new Error('Failed to get registry parameter: ' +
42
+ (error instanceof Error ? error.message : String(error)));
43
+ }
44
+ }
45
+ /**
46
+ * Save the registry to local storage
47
+ * @param registry The registry URL to save
48
+ * @throws Error if localStorage is not available
49
+ */
50
+ setRegistryToLocalStorage(registry) {
51
+ try {
52
+ localStorage.setItem(RegistryManager.STORAGE_KEY, registry);
53
+ }
54
+ catch (error) {
55
+ throw new Error('Failed to save to localStorage: ' +
56
+ (error instanceof Error ? error.message : String(error)));
57
+ }
58
+ }
59
+ /**
60
+ * Retrieve the registry from local storage
61
+ * @returns The stored registry URL or null if not found
62
+ * @throws Error if localStorage is not available
63
+ */
64
+ getRegistryFromLocalStorage() {
65
+ try {
66
+ return localStorage.getItem(RegistryManager.STORAGE_KEY);
67
+ }
68
+ catch (error) {
69
+ throw new Error('Failed to access localStorage: ' + (error instanceof Error ? error.message : String(error)));
70
+ }
71
+ }
72
+ /**
73
+ * Get the currently active registry
74
+ * @returns The current registry URL, falling back to default if not set
75
+ */
76
+ getCurrentRegistry() {
77
+ return this.currentRegistry ?? this.defaultRegistry;
78
+ }
79
+ /**
80
+ * Set the registry and update both localStorage and URL
81
+ * @param registry The new registry URL to set
82
+ */
83
+ setRegistry(registry) {
84
+ this.currentRegistry = registry;
85
+ this.setRegistryToLocalStorage(registry);
86
+ this.updateUrlWithRegistry();
87
+ }
88
+ /**
89
+ * Reset to the default registry, clearing both localStorage and URL param
90
+ * @throws Error if localStorage is not available
91
+ */
92
+ resetToDefault() {
93
+ this.currentRegistry = this.defaultRegistry;
94
+ try {
95
+ localStorage.removeItem(RegistryManager.STORAGE_KEY);
96
+ }
97
+ catch (error) {
98
+ throw new Error('Failed to clear registry from localStorage: ' +
99
+ (error instanceof Error ? error.message : String(error)));
100
+ }
101
+ this.updateUrlWithRegistry(null);
102
+ }
103
+ /**
104
+ * Update the URL param to reflect the current or specified registry
105
+ * @param value The registry value to set in URL, defaults to current registry
106
+ * @throws Error if URL manipulation fails
107
+ */
108
+ updateUrlWithRegistry(value = this.currentRegistry) {
109
+ try {
110
+ const url = new URL(window.location.href);
111
+ if (value) {
112
+ url.searchParams.set(RegistryManager.STORAGE_KEY, value);
113
+ }
114
+ else {
115
+ url.searchParams.delete(RegistryManager.STORAGE_KEY);
116
+ }
117
+ window.history.pushState({}, '', url.toString());
118
+ }
119
+ catch (error) {
120
+ throw new Error('Failed to update URL parameter: ' +
121
+ (error instanceof Error ? error.message : String(error)));
122
+ }
123
+ }
124
+ /**
125
+ * Check if the current registry is custom (different from the default)
126
+ * @returns True if using a non-default registry
127
+ */
128
+ isCustomRegistry() {
129
+ return (this.currentRegistry !== undefined &&
130
+ this.currentRegistry !== null &&
131
+ this.currentRegistry !== this.defaultRegistry);
132
+ }
133
+ }
@@ -0,0 +1,6 @@
1
+ <script>import { setRegistryContext } from "./context";
2
+ export let registryManager;
3
+ setRegistryContext(registryManager);
4
+ </script>
5
+
6
+ <slot />
@@ -0,0 +1,21 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { RegistryManager } from './RegistryManager';
3
+ declare const __propDef: {
4
+ props: {
5
+ registryManager: RegistryManager;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {
11
+ default: {};
12
+ };
13
+ exports?: {} | undefined;
14
+ bindings?: string | undefined;
15
+ };
16
+ export type RegistryProviderProps = typeof __propDef.props;
17
+ export type RegistryProviderEvents = typeof __propDef.events;
18
+ export type RegistryProviderSlots = typeof __propDef.slots;
19
+ export default class RegistryProvider extends SvelteComponent<RegistryProviderProps, RegistryProviderEvents, RegistryProviderSlots> {
20
+ }
21
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { RegistryManager } from './RegistryManager';
2
+ export declare const REGISTRY_KEY = "registry_key";
3
+ /**
4
+ * Retrieves the registry manager directly from Svelte's context
5
+ */
6
+ export declare const getRegistryContext: () => RegistryManager;
7
+ /**
8
+ * Sets the registry manager in Svelte's context
9
+ */
10
+ export declare const setRegistryContext: (registry: RegistryManager) => void;
@@ -0,0 +1,46 @@
1
+ import { getContext, setContext } from 'svelte';
2
+ export const REGISTRY_KEY = 'registry_key';
3
+ /**
4
+ * Retrieves the registry manager directly from Svelte's context
5
+ */
6
+ export const getRegistryContext = () => {
7
+ const registry = getContext(REGISTRY_KEY);
8
+ if (!registry) {
9
+ throw new Error('No registry manager was found in Svelte context. Did you forget to wrap your component with RegistryProvider?');
10
+ }
11
+ return registry;
12
+ };
13
+ /**
14
+ * Sets the registry manager in Svelte's context
15
+ */
16
+ export const setRegistryContext = (registry) => {
17
+ setContext(REGISTRY_KEY, registry);
18
+ };
19
+ if (import.meta.vitest) {
20
+ const { describe, it, expect, vi, beforeEach } = import.meta.vitest;
21
+ vi.mock('svelte', async (importOriginal) => ({
22
+ ...(await importOriginal()),
23
+ getContext: vi.fn()
24
+ }));
25
+ describe('getRegistryContext', () => {
26
+ const mockGetContext = vi.mocked(getContext);
27
+ beforeEach(() => {
28
+ mockGetContext.mockReset();
29
+ });
30
+ it('should return the registry from context when it exists', () => {
31
+ const mockRegistry = {};
32
+ mockGetContext.mockImplementation((key) => {
33
+ if (key === REGISTRY_KEY)
34
+ return mockRegistry;
35
+ return undefined;
36
+ });
37
+ const result = getRegistryContext();
38
+ expect(mockGetContext).toHaveBeenCalledWith(REGISTRY_KEY);
39
+ expect(result).toEqual(mockRegistry);
40
+ });
41
+ it('should throw an error when registry is not in context', () => {
42
+ mockGetContext.mockReturnValue(undefined);
43
+ expect(() => getRegistryContext()).toThrow('No registry manager was found in Svelte context. Did you forget to wrap your component with RegistryProvider?');
44
+ });
45
+ });
46
+ }
@@ -0,0 +1,7 @@
1
+ import type { RegistryManager } from './RegistryManager';
2
+ /**
3
+ * Hook to access registry manager information from context
4
+ * Must be used within a component that is a child of RegistryProvider
5
+ * @returns An object containing the registry manager
6
+ */
7
+ export declare function useRegistry(): RegistryManager;
@@ -0,0 +1,29 @@
1
+ import { getRegistryContext } from './context';
2
+ /**
3
+ * Hook to access registry manager information from context
4
+ * Must be used within a component that is a child of RegistryProvider
5
+ * @returns An object containing the registry manager
6
+ */
7
+ export function useRegistry() {
8
+ const registry = getRegistryContext();
9
+ return registry;
10
+ }
11
+ if (import.meta.vitest) {
12
+ const { describe, it, expect, vi, beforeEach } = import.meta.vitest;
13
+ vi.mock('./context', () => ({
14
+ getRegistryContext: vi.fn()
15
+ }));
16
+ describe('useRegistry', () => {
17
+ const mockGetRegistryContext = vi.mocked(getRegistryContext);
18
+ beforeEach(() => {
19
+ mockGetRegistryContext.mockReset();
20
+ });
21
+ it('should return registry', () => {
22
+ const mockRegistry = {};
23
+ mockGetRegistryContext.mockReturnValue(mockRegistry);
24
+ const result = useRegistry();
25
+ expect(mockGetRegistryContext).toHaveBeenCalled();
26
+ expect(result).toEqual(mockRegistry);
27
+ });
28
+ });
29
+ }
@@ -0,0 +1,17 @@
1
+ <script>import ToastDetail from "../../components/ToastDetail.svelte";
2
+ import { setToastsContext } from "./context";
3
+ import { writable } from "svelte/store";
4
+ import { fade } from "svelte/transition";
5
+ const toasts = writable([]);
6
+ setToastsContext(toasts);
7
+ </script>
8
+
9
+ <div class="fixed right-4 top-4 z-[100]">
10
+ {#each $toasts as toast, i}
11
+ <div out:fade data-testid="toast">
12
+ <ToastDetail {toast} {i} />
13
+ </div>
14
+ {/each}
15
+ </div>
16
+
17
+ <slot />
@@ -0,0 +1,18 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: Record<string, never>;
4
+ events: {
5
+ [evt: string]: CustomEvent<any>;
6
+ };
7
+ slots: {
8
+ default: {};
9
+ };
10
+ exports?: {} | undefined;
11
+ bindings?: string | undefined;
12
+ };
13
+ export type ToastProviderProps = typeof __propDef.props;
14
+ export type ToastProviderEvents = typeof __propDef.events;
15
+ export type ToastProviderSlots = typeof __propDef.slots;
16
+ export default class ToastProvider extends SvelteComponent<ToastProviderProps, ToastProviderEvents, ToastProviderSlots> {
17
+ }
18
+ export {};
@@ -0,0 +1,14 @@
1
+ import { type Writable } from 'svelte/store';
2
+ import type { ToastProps } from '../../types/toast';
3
+ export declare const TOASTS_KEY = "rain:ui-components:toasts";
4
+ /**
5
+ * Retrieves the toasts store from Svelte's context
6
+ */
7
+ export declare function getToastsContext(): Writable<ToastProps[]>;
8
+ /**
9
+ * Sets the toasts store in Svelte's context
10
+ *
11
+ * @param {Writable<ToastProps[]>} toasts - The writable store containing all active toast notifications
12
+ * @returns {void}
13
+ */
14
+ export declare function setToastsContext(toasts: Writable<ToastProps[]>): void;
@@ -0,0 +1,22 @@
1
+ import { getContext, setContext } from 'svelte';
2
+ import {} from 'svelte/store';
3
+ export const TOASTS_KEY = 'rain:ui-components:toasts';
4
+ /**
5
+ * Retrieves the toasts store from Svelte's context
6
+ */
7
+ export function getToastsContext() {
8
+ const toasts = getContext(TOASTS_KEY);
9
+ if (!toasts) {
10
+ throw new Error('No toasts context found. Did you forget to wrap your component with ToastProvider?');
11
+ }
12
+ return toasts;
13
+ }
14
+ /**
15
+ * Sets the toasts store in Svelte's context
16
+ *
17
+ * @param {Writable<ToastProps[]>} toasts - The writable store containing all active toast notifications
18
+ * @returns {void}
19
+ */
20
+ export function setToastsContext(toasts) {
21
+ setContext(TOASTS_KEY, toasts);
22
+ }
@@ -0,0 +1,16 @@
1
+ import type { ToastProps } from '../../types/toast';
2
+ /**
3
+ * Hook for managing toast notifications in the application.
4
+ * Provides functionality to add, remove, and access toast notifications.
5
+ *
6
+ * @returns {Object} An object containing:
7
+ * - toasts: Writable store containing all active toast notifications
8
+ * - addToast: Function to add a new toast notification
9
+ * - removeToast: Function to remove a toast notification by index
10
+ */
11
+ export declare function useToasts(): {
12
+ toasts: import("svelte/store").Writable<ToastProps[]>;
13
+ addToast: (toast: ToastProps) => void;
14
+ removeToast: (index: number) => void;
15
+ errToast: (message: string, detail?: string) => void;
16
+ };
@@ -0,0 +1,63 @@
1
+ import { getToastsContext } from './context';
2
+ /**
3
+ * Hook for managing toast notifications in the application.
4
+ * Provides functionality to add, remove, and access toast notifications.
5
+ *
6
+ * @returns {Object} An object containing:
7
+ * - toasts: Writable store containing all active toast notifications
8
+ * - addToast: Function to add a new toast notification
9
+ * - removeToast: Function to remove a toast notification by index
10
+ */
11
+ export function useToasts() {
12
+ const toasts = getToastsContext();
13
+ /**
14
+ * Removes a toast notification by its index from the toasts store
15
+ *
16
+ * @param {number} index - The index of the toast to remove
17
+ * @returns {void}
18
+ */
19
+ const removeToast = (index) => {
20
+ toasts.update((toasts) => {
21
+ if (index < 0 || index >= toasts.length) {
22
+ return toasts;
23
+ }
24
+ return toasts.filter((_, i) => i !== index);
25
+ });
26
+ };
27
+ /**
28
+ * Adds a new toast notification to the toasts store
29
+ *
30
+ * @param {ToastProps} toast - The toast configuration object containing:
31
+ * - message: The text to display in the toast
32
+ * - type: The type of toast (success, error, warning, info)
33
+ * - color: The color theme of the toast (green, red, yellow, blue)
34
+ * - links: Optional array of links to display in the toast
35
+ * @returns {void}
36
+ */
37
+ const addToast = (toast) => {
38
+ toasts.update((toasts) => {
39
+ const updatedToasts = [...toasts, toast];
40
+ return updatedToasts;
41
+ });
42
+ };
43
+ /**
44
+ * Adds a standardized error toast notification
45
+ *
46
+ * @param message - The error message to display
47
+ * @param detail - The detail of the error
48
+ */
49
+ const errToast = (message, detail) => {
50
+ addToast({
51
+ message,
52
+ detail,
53
+ type: 'error',
54
+ color: 'red'
55
+ });
56
+ };
57
+ return {
58
+ toasts,
59
+ addToast,
60
+ removeToast,
61
+ errToast
62
+ };
63
+ }
@@ -0,0 +1,183 @@
1
+ import { type Readable } from 'svelte/store';
2
+ import type { QueryClient } from '@tanstack/svelte-query';
3
+ import { type Transaction } from '../../models/Transaction';
4
+ import type { InternalTransactionArgs } from '../../types/transaction';
5
+ import type { Config } from '@wagmi/core';
6
+ import type { ToastProps } from '../../types/toast';
7
+ import { type SgVault, type SgOrder } from '@rainlanguage/orderbook';
8
+ /**
9
+ * Function type for adding toast notifications to the UI.
10
+ * @param toast - The toast notification configuration object.
11
+ * @param toast.message - The message text to display in the toast.
12
+ * @param toast.type - The type of toast notification ('success', 'error', or 'info').
13
+ * @param toast.color - The color theme of the toast.
14
+ * @param toast.links - Optional array of links to display in the toast.
15
+ */
16
+ export type AddToastFunction = (toast: Omit<ToastProps, 'id'>) => void;
17
+ /**
18
+ * Manages blockchain transactions with toast notifications and query invalidation.
19
+ * Handles transaction lifecycle, status updates, and UI feedback.
20
+ * Provides functionality for creating, tracking, and managing blockchain transactions.
21
+ */
22
+ export declare class TransactionManager {
23
+ /** Writable store tracking all active transactions. */
24
+ private transactions;
25
+ /** Query client for cache invalidation after successful transactions. */
26
+ private queryClient;
27
+ /** Function to display toast notifications in the UI. */
28
+ private addToast;
29
+ /** Wagmi configuration for blockchain interactions. */
30
+ private wagmiConfig;
31
+ /**
32
+ * Initializes a new TransactionManager instance.
33
+ * @param queryClient - Query client for cache invalidation.
34
+ * @param addToast - Function to display toast notifications.
35
+ * @param wagmiConfig - Wagmi configuration for blockchain interactions.
36
+ */
37
+ constructor(queryClient: QueryClient, addToast: AddToastFunction, wagmiConfig: Config);
38
+ /**
39
+ * Creates and initializes a new transaction for removing an order from the orderbook.
40
+ * @param args - Configuration for the remove order transaction.
41
+ * @param args.txHash - Hash of the transaction to track.
42
+ * @param args.chainId - Chain ID where the transaction is being executed.
43
+ * @param args.networkKey - Network identifier string (e.g., 'mainnet', 'arbitrum').
44
+ * @param args.queryKey - The hash of the order to be removed (used for query invalidation and UI links).
45
+ * @param args.subgraphUrl - URL of the subgraph to query for transaction status.
46
+ * @param args.entity - The `SgOrder` entity associated with this transaction.
47
+ * @returns A new Transaction instance configured for order removal.
48
+ * @example
49
+ * const tx = await manager.createRemoveOrderTransaction({
50
+ * txHash: '0x123...',
51
+ * chainId: 1,
52
+ * subgraphUrl: 'https://api.thegraph.com/subgraphs/name/...',
53
+ * networkKey: 'mainnet',
54
+ * queryKey: '0x456...', // Order hash
55
+ * entity: sgOrderInstance
56
+ * });
57
+ */
58
+ createRemoveOrderTransaction(args: InternalTransactionArgs & {
59
+ subgraphUrl: string;
60
+ entity: SgOrder;
61
+ }): Promise<Transaction>;
62
+ /**
63
+ * Creates and initializes a new transaction for withdrawing funds from a vault.
64
+ * @param args - Configuration for the withdrawal transaction.
65
+ * @param args.txHash - Hash of the transaction to track.
66
+ * @param args.chainId - Chain ID where the transaction is being executed.
67
+ * @param args.networkKey - Network identifier string.
68
+ * @param args.queryKey - The ID of the vault from which funds are withdrawn (used for query invalidation and UI links).
69
+ * @param args.subgraphUrl - URL of the subgraph to query for transaction status.
70
+ * @param args.entity - The `SgVault` entity associated with this transaction.
71
+ * @returns A new Transaction instance configured for withdrawal.
72
+ * @example
73
+ * const tx = await manager.createWithdrawTransaction({
74
+ * txHash: '0x123...',
75
+ * chainId: 1,
76
+ * subgraphUrl: 'https://api.thegraph.com/subgraphs/name/...',
77
+ * networkKey: 'mainnet',
78
+ * queryKey: '0x789...', // Vault ID
79
+ * entity: sgVaultInstance
80
+ * });
81
+ */
82
+ createWithdrawTransaction(args: InternalTransactionArgs & {
83
+ subgraphUrl: string;
84
+ entity: SgVault;
85
+ }): Promise<Transaction>;
86
+ /**
87
+ * Creates and initializes a new transaction for approving token spend.
88
+ * @param args - Configuration for the approval transaction.
89
+ * @param args.txHash - Hash of the transaction to track.
90
+ * @param args.chainId - Chain ID where the transaction is being executed.
91
+ * @param args.networkKey - Network identifier string.
92
+ * @param args.queryKey - The ID of the vault or context for which approval is made (used for query invalidation and UI links).
93
+ * @param args.tokenSymbol - The symbol of the token being approved.
94
+ * @param args.entity - The `SgVault` entity associated with this transaction. (Optional, used for approvals to pre-existing vaults).
95
+ * @returns A new Transaction instance configured for token approval.
96
+ * @example
97
+ * const tx = await manager.createApprovalTransaction({
98
+ * txHash: '0xabc...',
99
+ * chainId: 1,
100
+ * networkKey: 'mainnet',
101
+ * queryKey: '0x789...', // Vault ID
102
+ * entity: sgVaultInstance
103
+ * });
104
+ */
105
+ createApprovalTransaction(args: InternalTransactionArgs & {
106
+ entity?: SgVault;
107
+ }): Promise<Transaction>;
108
+ /**
109
+ * Creates and initializes a new transaction for depositing funds into a vault.
110
+ * @param args - Configuration for the deposit transaction.
111
+ * @param args.txHash - Hash of the transaction to track.
112
+ * @param args.chainId - Chain ID where the transaction is being executed.
113
+ * @param args.networkKey - Network identifier string.
114
+ * @param args.queryKey - The ID of the vault into which funds are deposited (used for query invalidation and UI links).
115
+ * @param args.entity - The `SgVault` entity associated with this transaction.
116
+ * @param args.amount - The amount of tokens being deposited.
117
+ * @param args.subgraphUrl - URL of the subgraph to query for transaction status.
118
+ * @returns A new Transaction instance configured for deposit.
119
+ * @example
120
+ * const tx = await manager.createDepositTransaction({
121
+ * txHash: '0xdef...',
122
+ * chainId: 1,
123
+ * subgraphUrl: 'https://api.thegraph.com/subgraphs/name/...',
124
+ * networkKey: 'mainnet',
125
+ * queryKey: '0x789...', // Vault ID
126
+ * entity: sgVaultInstance,
127
+ * amount: 1000n
128
+ * });
129
+ */
130
+ createDepositTransaction(args: InternalTransactionArgs & {
131
+ amount: bigint;
132
+ entity: SgVault;
133
+ subgraphUrl: string;
134
+ }): Promise<Transaction>;
135
+ /**
136
+ * Creates and initializes a new transaction for deploying a strategy.
137
+ * @param args - Configuration for the deployment transaction.
138
+ * @param args.txHash - Hash of the transaction to track.
139
+ * @param args.chainId - Chain ID where the transaction is being executed.
140
+ * @param args.networkKey - Network identifier string.
141
+ * @param args.queryKey - The ID of the vault into which funds are deposited (used for query invalidation and UI links).
142
+ * @param args.subgraphUrl - URL of the subgraph to query for transaction status.
143
+ * @returns A new Transaction instance configured for deposit.
144
+ * @example
145
+ * const tx = await manager.createAddOrderTransaction({
146
+ * txHash: '0xdeploytxhash',
147
+ * chainId: 1,
148
+ * networkKey: 'mainnet',
149
+ * queryKey: '0x789...', // Vault ID
150
+ * subgraphUrl: 'https://api.thegraph.com/subgraphs/name/...',
151
+ * });
152
+ */
153
+ createAddOrderTransaction(args: InternalTransactionArgs & {
154
+ subgraphUrl: string;
155
+ }): Promise<Transaction>;
156
+ /**
157
+ * Creates, initializes, and executes a new transaction instance.
158
+ * @param args - Configuration for the transaction.
159
+ * @param args.name - Name or title of the transaction.
160
+ * @param args.errorMessage - Message to display on transaction failure.
161
+ * @param args.successMessage - Message to display on transaction success.
162
+ * @param args.queryKey - Key used for query invalidation.
163
+ * @param args.toastLinks - Array of links to display in toast notifications.
164
+ * @param args.awaitSubgraphConfig - Optional configuration for awaiting subgraph indexing.
165
+ * @returns A new Transaction instance that has been initialized and started.
166
+ * @private
167
+ */
168
+ private createTransaction;
169
+ /**
170
+ * Retrieves the store containing all active transactions.
171
+ * @returns A readable store containing all active Transaction instances.
172
+ * @example
173
+ * const transactionsStore = manager.getTransactions();
174
+ * transactionsStore.subscribe(transactions => console.log(transactions));
175
+ */
176
+ getTransactions(): Readable<Transaction[]>;
177
+ /**
178
+ * Removes all transactions from the store, resetting the transaction tracking state.
179
+ * @example
180
+ * manager.clearTransactions(); // Clear all tracked transactions
181
+ */
182
+ clearTransactions(): void;
183
+ }