@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.
Files changed (163) hide show
  1. package/dist/__fixtures__/orderDetail.d.ts +1 -1
  2. package/dist/__mocks__/MockComponent.svelte +4 -0
  3. package/dist/__mocks__/MockComponent.svelte.d.ts +3 -1
  4. package/dist/__mocks__/mockTransactionStore.d.ts +3 -21
  5. package/dist/__mocks__/mockTransactionStore.js +26 -13
  6. package/dist/__mocks__/settings.d.ts +6 -2
  7. package/dist/__mocks__/settings.js +6 -1
  8. package/dist/__mocks__/stores.d.ts +87 -20
  9. package/dist/__mocks__/stores.js +30 -21
  10. package/dist/components/ButtonLoading.svelte +1 -1
  11. package/dist/components/ButtonVaultLink.svelte +3 -3
  12. package/dist/components/ButtonVaultLink.svelte.d.ts +1 -1
  13. package/dist/components/CheckboxMyItemsOnly.svelte +3 -2
  14. package/dist/components/CheckboxMyItemsOnly.svelte.d.ts +2 -3
  15. package/dist/components/CheckboxZeroBalanceVault.svelte.d.ts +2 -2
  16. package/dist/components/CodeMirrorDotrain.svelte +4 -0
  17. package/dist/components/CodeMirrorDotrain.svelte.d.ts +1 -0
  18. package/dist/components/CodeMirrorRainlang.svelte +12 -4
  19. package/dist/components/CodeMirrorRainlang.svelte.d.ts +1 -1
  20. package/dist/components/EditableSpan.svelte +3 -14
  21. package/dist/components/EditableSpan.svelte.d.ts +0 -1
  22. package/dist/components/Hash.svelte +3 -3
  23. package/dist/components/License.svelte +5 -4
  24. package/dist/components/ListViewOrderbookFilters.svelte +15 -14
  25. package/dist/components/ListViewOrderbookFilters.svelte.d.ts +9 -13
  26. package/dist/components/OrderOrVaultHash.svelte +10 -7
  27. package/dist/components/OrderOrVaultHash.svelte.d.ts +1 -1
  28. package/dist/components/PageHeader.svelte +20 -22
  29. package/dist/components/PageHeader.svelte.d.ts +1 -0
  30. package/dist/components/TanstackAppTable.svelte +2 -3
  31. package/dist/components/TanstackAppTable.svelte.d.ts +1 -1
  32. package/dist/components/ToastDetail.svelte +16 -0
  33. package/dist/components/ToastDetail.svelte.d.ts +19 -0
  34. package/dist/components/Tooltip.svelte +8 -0
  35. package/dist/components/Tooltip.svelte.d.ts +21 -0
  36. package/dist/components/charts/OrderTradesChart.svelte +3 -2
  37. package/dist/components/charts/TanstackLightweightChartLine.svelte +5 -9
  38. package/dist/components/charts/VaultBalanceChart.svelte +6 -6
  39. package/dist/components/charts/VaultBalanceChart.svelte.d.ts +1 -1
  40. package/dist/components/charts/transformAndSortData.d.ts +24 -0
  41. package/dist/components/charts/transformAndSortData.js +111 -0
  42. package/dist/components/checkbox/CheckboxActiveOrders.svelte +11 -0
  43. package/dist/components/checkbox/CheckboxActiveOrders.svelte.d.ts +19 -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 +181 -155
  48. package/dist/components/deployment/DeploymentSteps.svelte.d.ts +6 -13
  49. package/dist/components/deployment/DeploymentsSection.svelte +18 -14
  50. package/dist/components/deployment/DepositInput.svelte +31 -14
  51. package/dist/components/deployment/DepositInput.svelte.d.ts +1 -2
  52. package/dist/components/deployment/FieldDefinitionInput.svelte +20 -14
  53. package/dist/components/deployment/FieldDefinitionInput.svelte.d.ts +1 -2
  54. package/dist/components/deployment/SelectToken.svelte +12 -3
  55. package/dist/components/deployment/SelectToken.svelte.d.ts +1 -2
  56. package/dist/components/deployment/StrategyPage.svelte +6 -2
  57. package/dist/components/deployment/TokenIOInput.svelte +15 -5
  58. package/dist/components/deployment/TokenIOInput.svelte.d.ts +1 -2
  59. package/dist/components/deployment/handleDeployment.d.ts +11 -0
  60. package/dist/components/deployment/handleDeployment.js +33 -0
  61. package/dist/components/detail/OrderDetail.svelte +51 -44
  62. package/dist/components/detail/OrderDetail.svelte.d.ts +11 -8
  63. package/dist/components/detail/TanstackOrderQuote.svelte +11 -7
  64. package/dist/components/detail/TanstackOrderQuote.svelte.d.ts +1 -1
  65. package/dist/components/detail/VaultDetail.svelte +33 -42
  66. package/dist/components/detail/VaultDetail.svelte.d.ts +11 -11
  67. package/dist/components/dropdown/DropdownActiveSubgraphs.svelte.d.ts +4 -4
  68. package/dist/components/dropdown/DropdownOrderListAccounts.svelte.d.ts +3 -3
  69. package/dist/components/icon/Refresh.svelte +2 -1
  70. package/dist/components/icon/Refresh.svelte.d.ts +1 -0
  71. package/dist/components/input/InputOrderHash.svelte +1 -1
  72. package/dist/components/input/InputOrderHash.svelte.d.ts +2 -2
  73. package/dist/components/input/InputRegistryUrl.svelte +36 -14
  74. package/dist/components/input/InputToken.svelte +2 -2
  75. package/dist/components/input/InputTokenAmount.svelte +1 -1
  76. package/dist/components/tables/OrderAPY.svelte +4 -9
  77. package/dist/components/tables/OrderTradesListTable.svelte +7 -3
  78. package/dist/components/tables/OrderVaultsVolTable.svelte +11 -2
  79. package/dist/components/tables/OrdersListTable.svelte +24 -24
  80. package/dist/components/tables/OrdersListTable.svelte.d.ts +1 -7
  81. package/dist/components/tables/VaultBalanceChangesTable.svelte +8 -6
  82. package/dist/components/tables/VaultsListTable.svelte +48 -57
  83. package/dist/components/tables/VaultsListTable.svelte.d.ts +13 -20
  84. package/dist/components/wallet/WalletConnect.svelte +5 -4
  85. package/dist/components/wallet/WalletConnect.svelte.d.ts +0 -1
  86. package/dist/consts.d.ts +1 -0
  87. package/dist/consts.js +1 -0
  88. package/dist/errors/DeploymentStepsError.d.ts +5 -2
  89. package/dist/errors/DeploymentStepsError.js +4 -1
  90. package/dist/hooks/useGui.d.ts +3 -0
  91. package/dist/hooks/useGui.js +11 -0
  92. package/dist/index.d.ts +19 -7
  93. package/dist/index.js +21 -6
  94. package/dist/providers/GuiProvider.svelte +8 -0
  95. package/dist/providers/GuiProvider.svelte.d.ts +21 -0
  96. package/dist/providers/registry/RegistryManager.d.ts +65 -0
  97. package/dist/providers/registry/RegistryManager.js +133 -0
  98. package/dist/providers/registry/RegistryProvider.svelte +6 -0
  99. package/dist/providers/registry/RegistryProvider.svelte.d.ts +21 -0
  100. package/dist/providers/registry/context.d.ts +10 -0
  101. package/dist/providers/registry/context.js +46 -0
  102. package/dist/providers/registry/useRegistry.d.ts +7 -0
  103. package/dist/providers/registry/useRegistry.js +29 -0
  104. package/dist/providers/toasts/ToastProvider.svelte +17 -0
  105. package/dist/providers/toasts/ToastProvider.svelte.d.ts +22 -0
  106. package/dist/providers/toasts/context.d.ts +11 -0
  107. package/dist/providers/toasts/context.js +19 -0
  108. package/dist/providers/toasts/useToasts.d.ts +12 -0
  109. package/dist/providers/toasts/useToasts.js +54 -0
  110. package/dist/providers/wallet/WalletProvider.svelte +7 -0
  111. package/dist/providers/wallet/WalletProvider.svelte.d.ts +21 -0
  112. package/dist/providers/wallet/context.d.ts +10 -0
  113. package/dist/providers/wallet/context.js +47 -0
  114. package/dist/providers/wallet/useAccount.d.ts +8 -0
  115. package/dist/providers/wallet/useAccount.js +148 -0
  116. package/dist/queries/queryClient.d.ts +1 -1
  117. package/dist/queries/queryClient.js +11 -6
  118. package/dist/services/awaitTransactionIndexing.d.ts +163 -0
  119. package/dist/services/awaitTransactionIndexing.js +122 -0
  120. package/dist/services/handleShareChoices.d.ts +2 -2
  121. package/dist/services/handleShareChoices.js +7 -2
  122. package/dist/services/historicalOrderCharts.d.ts +1 -1
  123. package/dist/services/historicalOrderCharts.js +1 -1
  124. package/dist/services/index.d.ts +2 -1
  125. package/dist/services/index.js +2 -1
  126. package/dist/services/loadRegistryUrl.d.ts +2 -0
  127. package/dist/services/loadRegistryUrl.js +19 -0
  128. package/dist/services/registry.d.ts +6 -0
  129. package/dist/services/registry.js +33 -77
  130. package/dist/services/time.d.ts +12 -0
  131. package/dist/services/time.js +88 -6
  132. package/dist/stores/transactionStore.d.ts +9 -12
  133. package/dist/stores/transactionStore.js +38 -61
  134. package/dist/storesGeneric/cachedWritableStore.d.ts +57 -0
  135. package/dist/storesGeneric/cachedWritableStore.js +93 -0
  136. package/dist/types/account.d.ts +3 -0
  137. package/dist/types/account.js +1 -0
  138. package/dist/types/appStores.d.ts +5 -4
  139. package/dist/types/modal.d.ts +1 -1
  140. package/dist/types/strategy.d.ts +1 -1
  141. package/dist/types/toast.d.ts +6 -0
  142. package/dist/types/toast.js +1 -0
  143. package/dist/types/transaction.d.ts +3 -3
  144. package/dist/utils/constructHashLink.d.ts +23 -0
  145. package/dist/utils/constructHashLink.js +110 -0
  146. package/dist/utils/vault.d.ts +1 -1
  147. package/package.json +34 -34
  148. package/dist/components/deployment/DepositsSection.svelte +0 -8
  149. package/dist/components/deployment/DepositsSection.svelte.d.ts +0 -20
  150. package/dist/components/deployment/FieldDefinitionsSection.svelte +0 -9
  151. package/dist/components/deployment/FieldDefinitionsSection.svelte.d.ts +0 -20
  152. package/dist/components/deployment/SelectTokensSection.svelte +0 -17
  153. package/dist/components/deployment/SelectTokensSection.svelte.d.ts +0 -21
  154. package/dist/components/deployment/TokenIOSection.svelte +0 -17
  155. package/dist/components/deployment/TokenIOSection.svelte.d.ts +0 -21
  156. package/dist/components/deployment/getDeploymentTransactionArgs.d.ts +0 -17
  157. package/dist/components/deployment/getDeploymentTransactionArgs.js +0 -24
  158. package/dist/components/detail/DepositOrWithdrawButtons.svelte +0 -44
  159. package/dist/components/detail/DepositOrWithdrawButtons.svelte.d.ts +0 -26
  160. package/dist/components/dropdown/DropdownOrderStatus.svelte +0 -31
  161. package/dist/components/dropdown/DropdownOrderStatus.svelte.d.ts +0 -19
  162. package/dist/utils/time.d.ts +0 -12
  163. package/dist/utils/time.js +0 -27
@@ -1,5 +1,6 @@
1
1
  export declare enum DeploymentStepsErrorCode {
2
- NO_GUI = "Error loading GUI",
2
+ NO_GUI_PROVIDER = "No GUI provider found.",
3
+ NO_GUI = "Error loading GUI.",
3
4
  NO_STRATEGY = "No valid strategy exists at this URL",
4
5
  NO_SELECT_TOKENS = "Error loading tokens",
5
6
  NO_TOKEN_INFO = "Error loading token information",
@@ -9,8 +10,10 @@ export declare enum DeploymentStepsErrorCode {
9
10
  NO_TOKEN_OUTPUTS = "Error loading token outputs",
10
11
  NO_GUI_DETAILS = "Error getting GUI details",
11
12
  NO_CHAIN = "Unsupported chain ID",
13
+ NO_NETWORK_KEY = "No network key found",
12
14
  SERIALIZE_ERROR = "Error serializing state",
13
- ADD_ORDER_FAILED = "Failed to add order"
15
+ ADD_ORDER_FAILED = "Failed to add order",
16
+ NO_WALLET = "No account address found"
14
17
  }
15
18
  export declare class DeploymentStepsError extends Error {
16
19
  code: DeploymentStepsErrorCode;
@@ -1,7 +1,8 @@
1
1
  import { writable } from 'svelte/store';
2
2
  export var DeploymentStepsErrorCode;
3
3
  (function (DeploymentStepsErrorCode) {
4
- DeploymentStepsErrorCode["NO_GUI"] = "Error loading GUI";
4
+ DeploymentStepsErrorCode["NO_GUI_PROVIDER"] = "No GUI provider found.";
5
+ DeploymentStepsErrorCode["NO_GUI"] = "Error loading GUI.";
5
6
  DeploymentStepsErrorCode["NO_STRATEGY"] = "No valid strategy exists at this URL";
6
7
  DeploymentStepsErrorCode["NO_SELECT_TOKENS"] = "Error loading tokens";
7
8
  DeploymentStepsErrorCode["NO_TOKEN_INFO"] = "Error loading token information";
@@ -11,8 +12,10 @@ export var DeploymentStepsErrorCode;
11
12
  DeploymentStepsErrorCode["NO_TOKEN_OUTPUTS"] = "Error loading token outputs";
12
13
  DeploymentStepsErrorCode["NO_GUI_DETAILS"] = "Error getting GUI details";
13
14
  DeploymentStepsErrorCode["NO_CHAIN"] = "Unsupported chain ID";
15
+ DeploymentStepsErrorCode["NO_NETWORK_KEY"] = "No network key found";
14
16
  DeploymentStepsErrorCode["SERIALIZE_ERROR"] = "Error serializing state";
15
17
  DeploymentStepsErrorCode["ADD_ORDER_FAILED"] = "Failed to add order";
18
+ DeploymentStepsErrorCode["NO_WALLET"] = "No account address found";
16
19
  })(DeploymentStepsErrorCode || (DeploymentStepsErrorCode = {}));
17
20
  export class DeploymentStepsError extends Error {
18
21
  code;
@@ -0,0 +1,3 @@
1
+ import { DotrainOrderGui } from '@rainlanguage/orderbook';
2
+ export declare const GUI_CONTEXT_KEY = "gui-context";
3
+ export declare function useGui(): DotrainOrderGui;
@@ -0,0 +1,11 @@
1
+ import { getContext } from 'svelte';
2
+ import { DotrainOrderGui } from '@rainlanguage/orderbook';
3
+ import { DeploymentStepsError, DeploymentStepsErrorCode } from '../errors/DeploymentStepsError';
4
+ export const GUI_CONTEXT_KEY = 'gui-context';
5
+ export function useGui() {
6
+ const gui = getContext(GUI_CONTEXT_KEY);
7
+ if (!gui) {
8
+ DeploymentStepsError.catch(null, DeploymentStepsErrorCode.NO_GUI_PROVIDER);
9
+ }
10
+ return gui;
11
+ }
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ export { default as DropdownCheckbox } from './components/dropdown/DropdownCheck
6
6
  export { default as DropdownOrderListAccounts } from './components/dropdown/DropdownOrderListAccounts.svelte';
7
7
  export { default as DropdownRadio } from './components/dropdown/DropdownRadio.svelte';
8
8
  export { default as Refresh } from './components/icon/Refresh.svelte';
9
- export { default as DropdownOrderStatus } from './components/dropdown/DropdownOrderStatus.svelte';
9
+ export { default as CheckboxActiveOrders } from './components/checkbox/CheckboxActiveOrders.svelte';
10
10
  export { default as InputOrderHash } from './components/input/InputOrderHash.svelte';
11
11
  export { default as CheckboxZeroBalanceVault } from './components/CheckboxZeroBalanceVault.svelte';
12
12
  export { default as ListViewOrderbookFilters } from './components/ListViewOrderbookFilters.svelte';
@@ -65,25 +65,37 @@ export { default as InvalidStrategiesSection } from './components/deployment/Inv
65
65
  export { default as ValidStrategiesSection } from './components/deployment/ValidStrategiesSection.svelte';
66
66
  export { default as InputRegistryUrl } from './components/input/InputRegistryUrl.svelte';
67
67
  export type { AppStoresInterface } from './types/appStores.ts';
68
- export type { ConfigSource, OrderbookConfigSource, OrderbookCfgRef } from '@rainlanguage/orderbook/js_api';
68
+ export type { ConfigSource, OrderbookConfigSource, OrderbookCfgRef } from '@rainlanguage/orderbook';
69
69
  export { TransactionStatus, TransactionErrorMessage, type TransactionState, type ExtendedApprovalCalldata } from './stores/transactionStore';
70
70
  export type { DeploymentArgs, DepositOrWithdrawArgs, OrderRemoveArgs } from './types/transaction';
71
71
  export type { DepositOrWithdrawModalProps, OrderRemoveModalProps, QuoteDebugModalHandler, DebugTradeModalHandler, DeployModalProps, DisclaimerModalProps } from './types/modal';
72
72
  export type { ValidStrategyDetail, InvalidStrategyDetail } from './types/strategy';
73
+ export type { ToastProps } from './types/toast';
73
74
  export { createResolvableQuery, createResolvableInfiniteQuery } from './__mocks__/queries';
74
- export { formatTimestampSecondsAsLocal, timestampSecondsToUTCTimestamp, promiseTimeout } from './utils/time';
75
+ export { formatTimestampSecondsAsLocal, timestampSecondsToUTCTimestamp, promiseTimeout } from './services/time';
75
76
  export { bigintStringToHex, HEX_INPUT_REGEX } from './utils/hex';
76
77
  export { vaultBalanceDisplay } from './utils/vault';
77
- export { prepareHistoricalOrderChartData } from './services/historicalOrderCharts';
78
78
  export { bigintToFloat } from './utils/number';
79
79
  export { getExplorerLink } from './services/getExplorerLink';
80
+ export { invalidateTanstackQueries } from './queries/queryClient';
80
81
  export { DEFAULT_PAGE_SIZE, DEFAULT_REFRESH_INTERVAL } from './queries/constants';
81
82
  export { QKEY_VAULTS, QKEY_VAULT, QKEY_VAULT_CHANGES, QKEY_ORDERS, QKEY_ORDER, QKEY_ORDER_TRADES_LIST, QKEY_ORDER_QUOTE, QKEY_VAULTS_VOL_LIST, QKEY_ORDER_APY } from './queries/keys';
82
83
  export { darkChartTheme, lightChartTheme } from './utils/lightweightChartsThemes';
83
84
  export { lightCodeMirrorTheme, darkCodeMirrorTheme } from './utils/codeMirrorThemes';
84
- export { mockConfigSource } from './__mocks__/settings';
85
- export { mockSettingsStore } from './__mocks__/settings';
86
85
  export { default as transactionStore } from './stores/transactionStore';
87
- export { mockTransactionStore } from './__mocks__/mockTransactionStore';
86
+ export { cachedWritableStore, cachedWritableIntOptional, cachedWritableStringOptional, cachedWritableString } from './storesGeneric/cachedWritableStore';
88
87
  export { default as logoLight } from './assets/logo-light.svg';
89
88
  export { default as logoDark } from './assets/logo-dark.svg';
89
+ export { default as GuiProvider } from './providers/GuiProvider.svelte';
90
+ export { default as WalletProvider } from './providers/wallet/WalletProvider.svelte';
91
+ export { default as RegistryProvider } from './providers/registry/RegistryProvider.svelte';
92
+ export { default as ToastProvider } from './providers/toasts/ToastProvider.svelte';
93
+ export { useGui } from './hooks/useGui';
94
+ export { useAccount } from './providers/wallet/useAccount';
95
+ export { useRegistry } from './providers/registry/useRegistry';
96
+ export { useToasts } from './providers/toasts/useToasts';
97
+ export { RegistryManager } from './providers/registry/RegistryManager';
98
+ export { mockPageStore } from './__mocks__/stores';
99
+ export { mockConfigSource } from './__mocks__/settings';
100
+ export { mockSettingsStore } from './__mocks__/settings';
101
+ export { mockTransactionStore } from './__mocks__/mockTransactionStore';
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ export { default as DropdownCheckbox } from './components/dropdown/DropdownCheck
7
7
  export { default as DropdownOrderListAccounts } from './components/dropdown/DropdownOrderListAccounts.svelte';
8
8
  export { default as DropdownRadio } from './components/dropdown/DropdownRadio.svelte';
9
9
  export { default as Refresh } from './components/icon/Refresh.svelte';
10
- export { default as DropdownOrderStatus } from './components/dropdown/DropdownOrderStatus.svelte';
10
+ export { default as CheckboxActiveOrders } from './components/checkbox/CheckboxActiveOrders.svelte';
11
11
  export { default as InputOrderHash } from './components/input/InputOrderHash.svelte';
12
12
  export { default as CheckboxZeroBalanceVault } from './components/CheckboxZeroBalanceVault.svelte';
13
13
  export { default as ListViewOrderbookFilters } from './components/ListViewOrderbookFilters.svelte';
@@ -68,22 +68,37 @@ export { default as InputRegistryUrl } from './components/input/InputRegistryUrl
68
68
  export { TransactionStatus, TransactionErrorMessage } from './stores/transactionStore';
69
69
  // Functions
70
70
  export { createResolvableQuery, createResolvableInfiniteQuery } from './__mocks__/queries';
71
- export { formatTimestampSecondsAsLocal, timestampSecondsToUTCTimestamp, promiseTimeout } from './utils/time';
71
+ export { formatTimestampSecondsAsLocal, timestampSecondsToUTCTimestamp, promiseTimeout } from './services/time';
72
72
  export { bigintStringToHex, HEX_INPUT_REGEX } from './utils/hex';
73
73
  export { vaultBalanceDisplay } from './utils/vault';
74
- export { prepareHistoricalOrderChartData } from './services/historicalOrderCharts';
75
74
  export { bigintToFloat } from './utils/number';
76
75
  export { getExplorerLink } from './services/getExplorerLink';
76
+ export { invalidateTanstackQueries } from './queries/queryClient';
77
77
  // Constants
78
78
  export { DEFAULT_PAGE_SIZE, DEFAULT_REFRESH_INTERVAL } from './queries/constants';
79
79
  export { QKEY_VAULTS, QKEY_VAULT, QKEY_VAULT_CHANGES, QKEY_ORDERS, QKEY_ORDER, QKEY_ORDER_TRADES_LIST, QKEY_ORDER_QUOTE, QKEY_VAULTS_VOL_LIST, QKEY_ORDER_APY } from './queries/keys';
80
80
  export { darkChartTheme, lightChartTheme } from './utils/lightweightChartsThemes';
81
81
  export { lightCodeMirrorTheme, darkCodeMirrorTheme } from './utils/codeMirrorThemes';
82
82
  // Stores
83
- export { mockConfigSource } from './__mocks__/settings';
84
- export { mockSettingsStore } from './__mocks__/settings';
85
83
  export { default as transactionStore } from './stores/transactionStore';
86
- export { mockTransactionStore } from './__mocks__/mockTransactionStore';
84
+ export { cachedWritableStore, cachedWritableIntOptional, cachedWritableStringOptional, cachedWritableString } from './storesGeneric/cachedWritableStore';
87
85
  // Assets
88
86
  export { default as logoLight } from './assets/logo-light.svg';
89
87
  export { default as logoDark } from './assets/logo-dark.svg';
88
+ // Providers
89
+ export { default as GuiProvider } from './providers/GuiProvider.svelte';
90
+ export { default as WalletProvider } from './providers/wallet/WalletProvider.svelte';
91
+ export { default as RegistryProvider } from './providers/registry/RegistryProvider.svelte';
92
+ export { default as ToastProvider } from './providers/toasts/ToastProvider.svelte';
93
+ // Hooks
94
+ export { useGui } from './hooks/useGui';
95
+ export { useAccount } from './providers/wallet/useAccount';
96
+ export { useRegistry } from './providers/registry/useRegistry';
97
+ export { useToasts } from './providers/toasts/useToasts';
98
+ // Classes
99
+ export { RegistryManager } from './providers/registry/RegistryManager';
100
+ // Mocks
101
+ export { mockPageStore } from './__mocks__/stores';
102
+ export { mockConfigSource } from './__mocks__/settings';
103
+ export { mockSettingsStore } from './__mocks__/settings';
104
+ export { mockTransactionStore } from './__mocks__/mockTransactionStore';
@@ -0,0 +1,8 @@
1
+ <script>import { setContext } from "svelte";
2
+ import { DotrainOrderGui } from "@rainlanguage/orderbook";
3
+ import { GUI_CONTEXT_KEY } from "../hooks/useGui";
4
+ export let gui;
5
+ setContext(GUI_CONTEXT_KEY, gui);
6
+ </script>
7
+
8
+ <slot />
@@ -0,0 +1,21 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import { DotrainOrderGui } from '@rainlanguage/orderbook';
3
+ declare const __propDef: {
4
+ props: {
5
+ gui: DotrainOrderGui;
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 GuiProviderProps = typeof __propDef.props;
17
+ export type GuiProviderEvents = typeof __propDef.events;
18
+ export type GuiProviderSlots = typeof __propDef.slots;
19
+ export default class GuiProvider extends SvelteComponent<GuiProviderProps, GuiProviderEvents, GuiProviderSlots> {
20
+ }
21
+ export {};
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Manages registry URL settings, persisting values in localStorage and URL parameters
3
+ */
4
+ export declare class RegistryManager {
5
+ /** The default registry URL to fall back to */
6
+ private defaultRegistry;
7
+ /** The currently selected registry URL */
8
+ private currentRegistry;
9
+ /** Key used for localStorage and URL parameters */
10
+ private static STORAGE_KEY;
11
+ /**
12
+ * Create a new RegistryManager
13
+ * @param defaultRegistry The default registry URL to use.
14
+ */
15
+ constructor(defaultRegistry: string);
16
+ /**
17
+ * Initialize registry from URL param or local storage
18
+ * @returns The registry URL to use
19
+ */
20
+ private loadRegistryFromStorageOrUrl;
21
+ /**
22
+ * Get the registry from the URL param
23
+ * @returns The registry value from URL or null if not present
24
+ * @throws Error if URL parsing fails
25
+ */
26
+ private getRegistryParamFromUrl;
27
+ /**
28
+ * Save the registry to local storage
29
+ * @param registry The registry URL to save
30
+ * @throws Error if localStorage is not available
31
+ */
32
+ private setRegistryToLocalStorage;
33
+ /**
34
+ * Retrieve the registry from local storage
35
+ * @returns The stored registry URL or null if not found
36
+ * @throws Error if localStorage is not available
37
+ */
38
+ private getRegistryFromLocalStorage;
39
+ /**
40
+ * Get the currently active registry
41
+ * @returns The current registry URL, falling back to default if not set
42
+ */
43
+ getCurrentRegistry(): string;
44
+ /**
45
+ * Set the registry and update both localStorage and URL
46
+ * @param registry The new registry URL to set
47
+ */
48
+ setRegistry(registry: string): void;
49
+ /**
50
+ * Reset to the default registry, clearing both localStorage and URL param
51
+ * @throws Error if localStorage is not available
52
+ */
53
+ resetToDefault(): void;
54
+ /**
55
+ * Update the URL param to reflect the current or specified registry
56
+ * @param value The registry value to set in URL, defaults to current registry
57
+ * @throws Error if URL manipulation fails
58
+ */
59
+ updateUrlWithRegistry(value?: string | null): void;
60
+ /**
61
+ * Check if the current registry is custom (different from the default)
62
+ * @returns True if using a non-default registry
63
+ */
64
+ isCustomRegistry(): boolean;
65
+ }
@@ -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
+ export let toasts = writable([]);
6
+ setToastsContext(toasts);
7
+ </script>
8
+
9
+ <div class="fixed right-4 top-4 z-[100]">
10
+ {#each $toasts as toast}
11
+ <div out:fade data-testid="toast">
12
+ <ToastDetail {toast} />
13
+ </div>
14
+ {/each}
15
+ </div>
16
+
17
+ <slot />
@@ -0,0 +1,22 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import { type Writable } from 'svelte/store';
3
+ import type { ToastProps } from '../../types/toast';
4
+ declare const __propDef: {
5
+ props: {
6
+ toasts?: Writable<ToastProps[]>;
7
+ };
8
+ events: {
9
+ [evt: string]: CustomEvent<any>;
10
+ };
11
+ slots: {
12
+ default: {};
13
+ };
14
+ exports?: {} | undefined;
15
+ bindings?: string | undefined;
16
+ };
17
+ export type ToastProviderProps = typeof __propDef.props;
18
+ export type ToastProviderEvents = typeof __propDef.events;
19
+ export type ToastProviderSlots = typeof __propDef.slots;
20
+ export default class ToastProvider extends SvelteComponent<ToastProviderProps, ToastProviderEvents, ToastProviderSlots> {
21
+ }
22
+ export {};
@@ -0,0 +1,11 @@
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
+ export declare function setToastsContext(toasts: Writable<ToastProps[]>): void;
@@ -0,0 +1,19 @@
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
+ export function setToastsContext(toasts) {
18
+ setContext(TOASTS_KEY, toasts);
19
+ }
@@ -0,0 +1,12 @@
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 An object containing the toast store and methods to manipulate toasts
7
+ */
8
+ export declare function useToasts(): {
9
+ toasts: import("svelte/store").Writable<ToastProps[]>;
10
+ addToast: (toast: ToastProps) => void;
11
+ removeToast: (index: number) => void;
12
+ };