@rainlanguage/ui-components 0.0.1-alpha.21 → 0.0.1-alpha.211

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 (260) hide show
  1. package/dist/__fixtures__/settings.yaml +125 -0
  2. package/dist/__mocks__/CodeMirrorRainlang.svelte +4 -0
  3. package/dist/__mocks__/CodeMirrorRainlang.svelte.d.ts +18 -0
  4. package/dist/__mocks__/MockComponent.svelte +4 -0
  5. package/dist/__mocks__/MockComponent.svelte.d.ts +3 -1
  6. package/dist/__mocks__/stores.d.ts +47 -33
  7. package/dist/__mocks__/stores.js +61 -38
  8. package/dist/components/ButtonLoading.svelte +1 -1
  9. package/dist/components/ButtonVaultLink.svelte +11 -11
  10. package/dist/components/ButtonVaultLink.svelte.d.ts +4 -3
  11. package/dist/components/CheckboxInactiveOrdersVault.svelte +20 -0
  12. package/dist/components/CheckboxInactiveOrdersVault.svelte.d.ts +19 -0
  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 +3 -12
  19. package/dist/components/CodeMirrorRainlang.svelte.d.ts +2 -2
  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 +45 -23
  25. package/dist/components/ListViewOrderbookFilters.svelte.d.ts +27 -22
  26. package/dist/components/LocalDbStatusBadge.svelte +27 -0
  27. package/dist/components/LocalDbStatusBadge.svelte.d.ts +19 -0
  28. package/dist/components/LocalDbStatusCard.svelte +40 -0
  29. package/dist/components/LocalDbStatusCard.svelte.d.ts +20 -0
  30. package/dist/components/LocalDbStatusModal.svelte +103 -0
  31. package/dist/components/LocalDbStatusModal.svelte.d.ts +21 -0
  32. package/dist/components/OrderOrVaultHash.svelte +12 -12
  33. package/dist/components/OrderOrVaultHash.svelte.d.ts +4 -4
  34. package/dist/components/PageHeader.svelte +1 -1
  35. package/dist/components/TanstackAppTable.svelte +179 -28
  36. package/dist/components/TanstackAppTable.svelte.d.ts +14 -8
  37. package/dist/components/ToastDetail.svelte +42 -0
  38. package/dist/components/ToastDetail.svelte.d.ts +20 -0
  39. package/dist/components/Tooltip.svelte +8 -0
  40. package/dist/components/Tooltip.svelte.d.ts +21 -0
  41. package/dist/components/VaultBalanceChangeTypeFilter.svelte +23 -0
  42. package/dist/components/VaultBalanceChangeTypeFilter.svelte.d.ts +19 -0
  43. package/dist/components/VaultCard.svelte +18 -0
  44. package/dist/components/VaultCard.svelte.d.ts +19 -0
  45. package/dist/components/charts/LightweightChart.svelte +1 -1
  46. package/dist/components/charts/LightweightChart.svelte.d.ts +5 -5
  47. package/dist/components/charts/OrderTradesChart.svelte +300 -28
  48. package/dist/components/charts/OrderTradesChart.svelte.d.ts +4 -4
  49. package/dist/components/charts/TanstackLightweightChartLine.svelte +5 -9
  50. package/dist/components/charts/VaultBalanceChart.svelte +8 -26
  51. package/dist/components/charts/VaultBalanceChart.svelte.d.ts +1 -7
  52. package/dist/components/charts/transformAndSortData.d.ts +24 -0
  53. package/dist/components/charts/transformAndSortData.js +111 -0
  54. package/dist/components/checkbox/CheckboxActiveOrders.svelte +11 -0
  55. package/dist/components/checkbox/CheckboxActiveOrders.svelte.d.ts +19 -0
  56. package/dist/components/deployment/ButtonSelectOption.svelte +2 -0
  57. package/dist/components/deployment/ButtonSelectOption.svelte.d.ts +1 -0
  58. package/dist/components/deployment/ComposedRainlangModal.svelte +2 -1
  59. package/dist/components/deployment/ComposedRainlangModal.svelte.d.ts +1 -4
  60. package/dist/components/deployment/DeploymentSectionHeader.svelte +7 -4
  61. package/dist/components/deployment/DeploymentSteps.svelte +209 -216
  62. package/dist/components/deployment/DeploymentSteps.svelte.d.ts +6 -12
  63. package/dist/components/deployment/DeploymentTile.svelte +2 -2
  64. package/dist/components/deployment/DeploymentTile.svelte.d.ts +1 -1
  65. package/dist/components/deployment/DeploymentsSection.svelte +15 -22
  66. package/dist/components/deployment/DeploymentsSection.svelte.d.ts +3 -2
  67. package/dist/components/deployment/DepositInput.svelte +8 -10
  68. package/dist/components/deployment/DepositInput.svelte.d.ts +1 -2
  69. package/dist/components/deployment/DisclaimerModal.svelte +6 -7
  70. package/dist/components/deployment/FieldDefinitionInput.svelte +7 -11
  71. package/dist/components/deployment/FieldDefinitionInput.svelte.d.ts +1 -2
  72. package/dist/components/deployment/InvalidOrdersSection.svelte +17 -0
  73. package/dist/components/deployment/InvalidOrdersSection.svelte.d.ts +19 -0
  74. package/dist/components/deployment/{StrategyPage.svelte → OrderPage.svelte} +15 -24
  75. package/dist/components/deployment/OrderPage.svelte.d.ts +21 -0
  76. package/dist/components/deployment/SelectToken.svelte +125 -48
  77. package/dist/components/deployment/SelectToken.svelte.d.ts +4 -3
  78. package/dist/components/deployment/TokenBalance.svelte +19 -0
  79. package/dist/components/deployment/TokenBalance.svelte.d.ts +19 -0
  80. package/dist/components/deployment/TokenIOInput.svelte +25 -15
  81. package/dist/components/deployment/TokenIOInput.svelte.d.ts +3 -3
  82. package/dist/components/deployment/TokenSelectionModal.svelte +148 -0
  83. package/dist/components/deployment/TokenSelectionModal.svelte.d.ts +20 -0
  84. package/dist/components/deployment/{ValidStrategiesSection.svelte → ValidOrdersSection.svelte} +7 -7
  85. package/dist/components/deployment/ValidOrdersSection.svelte.d.ts +19 -0
  86. package/dist/components/deployment/VaultIdInformation.svelte +17 -0
  87. package/dist/components/deployment/VaultIdInformation.svelte.d.ts +21 -0
  88. package/dist/components/detail/OrderDetail.svelte +184 -80
  89. package/dist/components/detail/OrderDetail.svelte.d.ts +21 -15
  90. package/dist/components/detail/TanstackOrderQuote.svelte +92 -46
  91. package/dist/components/detail/TanstackOrderQuote.svelte.d.ts +14 -16
  92. package/dist/components/detail/VaultDetail.svelte +78 -77
  93. package/dist/components/detail/VaultDetail.svelte.d.ts +12 -18
  94. package/dist/components/dropdown/DropdownActiveNetworks.svelte +44 -0
  95. package/dist/components/dropdown/DropdownActiveNetworks.svelte.d.ts +19 -0
  96. package/dist/components/dropdown/DropdownCheckbox.svelte +4 -4
  97. package/dist/components/dropdown/DropdownOrderListAccounts.svelte +5 -2
  98. package/dist/components/dropdown/DropdownOrderListAccounts.svelte.d.ts +2 -3
  99. package/dist/components/dropdown/DropdownOrderbooksFilter.svelte +172 -0
  100. package/dist/components/dropdown/DropdownOrderbooksFilter.svelte.d.ts +25 -0
  101. package/dist/components/dropdown/DropdownTokensFilter.svelte +152 -0
  102. package/dist/components/dropdown/DropdownTokensFilter.svelte.d.ts +28 -0
  103. package/dist/components/icon/Refresh.svelte +2 -1
  104. package/dist/components/icon/Refresh.svelte.d.ts +1 -0
  105. package/dist/components/input/InputOrderHash.svelte +1 -1
  106. package/dist/components/input/InputOrderHash.svelte.d.ts +3 -3
  107. package/dist/components/input/InputRegistryUrl.svelte +36 -14
  108. package/dist/components/input/InputToken.svelte +2 -2
  109. package/dist/components/input/InputTokenAmount.svelte +16 -21
  110. package/dist/components/input/InputTokenAmount.svelte.d.ts +3 -3
  111. package/dist/components/tables/OrderAPY.svelte +6 -33
  112. package/dist/components/tables/OrderAPY.svelte.d.ts +1 -4
  113. package/dist/components/tables/OrderTradesListTable.svelte +84 -81
  114. package/dist/components/tables/OrderTradesListTable.svelte.d.ts +4 -4
  115. package/dist/components/tables/OrderVaultsVolTable.svelte +17 -22
  116. package/dist/components/tables/OrderVaultsVolTable.svelte.d.ts +2 -2
  117. package/dist/components/tables/OrdersListTable.svelte +200 -108
  118. package/dist/components/tables/OrdersListTable.svelte.d.ts +17 -21
  119. package/dist/components/tables/VaultBalanceChangesTable.svelte +83 -43
  120. package/dist/components/tables/VaultBalanceChangesTable.svelte.d.ts +13 -11
  121. package/dist/components/tables/VaultsListTable.svelte +268 -145
  122. package/dist/components/tables/VaultsListTable.svelte.d.ts +24 -32
  123. package/dist/components/transactions/FixedBottomTransaction.svelte +63 -0
  124. package/dist/components/transactions/FixedBottomTransaction.svelte.d.ts +16 -0
  125. package/dist/components/transactions/TransactionDetail.svelte +31 -0
  126. package/dist/components/transactions/TransactionDetail.svelte.d.ts +20 -0
  127. package/dist/components/transactions/TransactionList.svelte +17 -0
  128. package/dist/components/transactions/TransactionList.svelte.d.ts +16 -0
  129. package/dist/components/transactions/getStatusEmoji.d.ts +2 -0
  130. package/dist/components/transactions/getStatusEmoji.js +20 -0
  131. package/dist/components/wallet/WalletConnect.svelte +5 -4
  132. package/dist/components/wallet/WalletConnect.svelte.d.ts +0 -1
  133. package/dist/consts.d.ts +1 -0
  134. package/dist/consts.js +1 -0
  135. package/dist/errors/DeploymentStepsError.d.ts +8 -2
  136. package/dist/errors/DeploymentStepsError.js +7 -1
  137. package/dist/hooks/useGui.d.ts +1 -1
  138. package/dist/hooks/useGui.js +1 -1
  139. package/dist/hooks/useLocalDb.d.ts +3 -0
  140. package/dist/hooks/useLocalDb.js +10 -0
  141. package/dist/hooks/useRaindexClient.d.ts +3 -0
  142. package/dist/hooks/useRaindexClient.js +11 -0
  143. package/dist/index.d.ts +42 -19
  144. package/dist/index.js +41 -16
  145. package/dist/models/Transaction.d.ts +75 -0
  146. package/dist/models/Transaction.js +100 -0
  147. package/dist/providers/GuiProvider.svelte +1 -1
  148. package/dist/providers/GuiProvider.svelte.d.ts +1 -1
  149. package/dist/providers/LocalDbProvider.svelte +8 -0
  150. package/dist/providers/LocalDbProvider.svelte.d.ts +21 -0
  151. package/dist/providers/RaindexClientProvider.svelte +8 -0
  152. package/dist/providers/RaindexClientProvider.svelte.d.ts +21 -0
  153. package/dist/providers/dotrainRegistry/DotrainRegistryProvider.svelte +8 -0
  154. package/dist/providers/dotrainRegistry/DotrainRegistryProvider.svelte.d.ts +24 -0
  155. package/dist/providers/dotrainRegistry/context.d.ts +9 -0
  156. package/dist/providers/dotrainRegistry/context.js +40 -0
  157. package/dist/providers/dotrainRegistry/useDotrainRegistry.d.ts +5 -0
  158. package/dist/providers/dotrainRegistry/useDotrainRegistry.js +35 -0
  159. package/dist/providers/registry/RegistryManager.d.ts +65 -0
  160. package/dist/providers/registry/RegistryManager.js +133 -0
  161. package/dist/providers/registry/RegistryProvider.svelte +6 -0
  162. package/dist/providers/registry/RegistryProvider.svelte.d.ts +21 -0
  163. package/dist/providers/registry/context.d.ts +10 -0
  164. package/dist/providers/registry/context.js +46 -0
  165. package/dist/providers/registry/useRegistry.d.ts +7 -0
  166. package/dist/providers/registry/useRegistry.js +29 -0
  167. package/dist/providers/toasts/ToastProvider.svelte +17 -0
  168. package/dist/providers/toasts/ToastProvider.svelte.d.ts +18 -0
  169. package/dist/providers/toasts/context.d.ts +14 -0
  170. package/dist/providers/toasts/context.js +22 -0
  171. package/dist/providers/toasts/useToasts.d.ts +16 -0
  172. package/dist/providers/toasts/useToasts.js +63 -0
  173. package/dist/providers/transactions/TransactionManager.d.ts +235 -0
  174. package/dist/providers/transactions/TransactionManager.js +509 -0
  175. package/dist/providers/transactions/TransactionProvider.svelte +11 -0
  176. package/dist/providers/transactions/TransactionProvider.svelte.d.ts +24 -0
  177. package/dist/providers/transactions/context.d.ts +19 -0
  178. package/dist/providers/transactions/context.js +28 -0
  179. package/dist/providers/transactions/useTransactions.d.ts +13 -0
  180. package/dist/providers/transactions/useTransactions.js +18 -0
  181. package/dist/providers/wallet/WalletProvider.svelte +7 -0
  182. package/dist/providers/wallet/WalletProvider.svelte.d.ts +21 -0
  183. package/dist/providers/wallet/context.d.ts +10 -0
  184. package/dist/providers/wallet/context.js +47 -0
  185. package/dist/providers/wallet/useAccount.d.ts +8 -0
  186. package/dist/providers/wallet/useAccount.js +148 -0
  187. package/dist/queries/keys.d.ts +1 -0
  188. package/dist/queries/keys.js +1 -0
  189. package/dist/queries/queryClient.d.ts +1 -1
  190. package/dist/queries/queryClient.js +11 -6
  191. package/dist/services/awaitTransactionIndexing.d.ts +107 -0
  192. package/dist/services/awaitTransactionIndexing.js +58 -0
  193. package/dist/services/getExplorerLink.d.ts +1 -1
  194. package/dist/services/getExplorerLink.js +2 -4
  195. package/dist/services/handleShareChoices.d.ts +2 -2
  196. package/dist/services/handleShareChoices.js +7 -2
  197. package/dist/services/historicalOrderCharts.d.ts +2 -2
  198. package/dist/services/historicalOrderCharts.js +267 -333
  199. package/dist/services/index.d.ts +2 -1
  200. package/dist/services/index.js +2 -1
  201. package/dist/services/loadRegistryUrl.d.ts +2 -0
  202. package/dist/services/loadRegistryUrl.js +22 -0
  203. package/dist/services/pairTradesChartData.d.ts +47 -0
  204. package/dist/services/pairTradesChartData.js +190 -0
  205. package/dist/services/registry.d.ts +5 -5
  206. package/dist/services/registry.js +8 -208
  207. package/dist/services/time.d.ts +12 -0
  208. package/dist/services/time.js +88 -6
  209. package/dist/storesGeneric/cachedWritableStore.d.ts +57 -0
  210. package/dist/storesGeneric/cachedWritableStore.js +93 -0
  211. package/dist/types/account.d.ts +3 -0
  212. package/dist/types/appStores.d.ts +9 -14
  213. package/dist/types/modal.d.ts +26 -14
  214. package/dist/types/{strategy.d.ts → order.d.ts} +3 -3
  215. package/dist/types/order.js +1 -0
  216. package/dist/types/toast.d.ts +11 -0
  217. package/dist/types/toast.js +1 -0
  218. package/dist/types/tokenBalance.d.ts +6 -0
  219. package/dist/types/tokenBalance.js +1 -0
  220. package/dist/types/transaction.d.ts +66 -21
  221. package/dist/types/transaction.js +31 -1
  222. package/dist/utils/configHelpers.d.ts +4 -0
  223. package/dist/utils/configHelpers.js +21 -0
  224. package/dist/utils/constructHashLink.d.ts +24 -0
  225. package/dist/utils/constructHashLink.js +115 -0
  226. package/dist/utils/getNetworkName.d.ts +1 -0
  227. package/dist/utils/getNetworkName.js +13 -0
  228. package/dist/utils/number.d.ts +0 -7
  229. package/dist/utils/number.js +0 -27
  230. package/dist/utils/tokens.d.ts +2 -0
  231. package/dist/utils/tokens.js +3 -0
  232. package/dist/utils/vaultBalanceChangeLabels.d.ts +4 -0
  233. package/dist/utils/vaultBalanceChangeLabels.js +18 -0
  234. package/package.json +39 -34
  235. package/dist/__fixtures__/orderDetail.d.ts +0 -99
  236. package/dist/__fixtures__/orderDetail.js +0 -204
  237. package/dist/__fixtures__/settings-12-11-24.json +0 -160
  238. package/dist/__mocks__/mockTransactionStore.d.ts +0 -22
  239. package/dist/__mocks__/mockTransactionStore.js +0 -56
  240. package/dist/__mocks__/settings.d.ts +0 -3
  241. package/dist/__mocks__/settings.js +0 -37
  242. package/dist/components/deployment/InvalidStrategiesSection.svelte +0 -19
  243. package/dist/components/deployment/InvalidStrategiesSection.svelte.d.ts +0 -19
  244. package/dist/components/deployment/StrategyPage.svelte.d.ts +0 -19
  245. package/dist/components/deployment/ValidStrategiesSection.svelte.d.ts +0 -19
  246. package/dist/components/deployment/getDeploymentTransactionArgs.d.ts +0 -17
  247. package/dist/components/deployment/getDeploymentTransactionArgs.js +0 -28
  248. package/dist/components/detail/DepositOrWithdrawButtons.svelte +0 -44
  249. package/dist/components/detail/DepositOrWithdrawButtons.svelte.d.ts +0 -26
  250. package/dist/components/dropdown/DropdownActiveSubgraphs.svelte +0 -38
  251. package/dist/components/dropdown/DropdownActiveSubgraphs.svelte.d.ts +0 -21
  252. package/dist/components/dropdown/DropdownOrderStatus.svelte +0 -31
  253. package/dist/components/dropdown/DropdownOrderStatus.svelte.d.ts +0 -19
  254. package/dist/stores/transactionStore.d.ts +0 -98
  255. package/dist/stores/transactionStore.js +0 -303
  256. package/dist/utils/time.d.ts +0 -12
  257. package/dist/utils/time.js +0 -27
  258. package/dist/utils/vault.d.ts +0 -2
  259. package/dist/utils/vault.js +0 -29
  260. /package/dist/types/{strategy.js → account.js} +0 -0
@@ -0,0 +1,47 @@
1
+ import { getContext, setContext } from 'svelte';
2
+ import { readable } from 'svelte/store';
3
+ export const ACCOUNT_KEY = 'account_key';
4
+ /**
5
+ * Retrieves the account store directly from Svelte's context
6
+ */
7
+ export const getAccountContext = () => {
8
+ const account = getContext(ACCOUNT_KEY);
9
+ if (!account) {
10
+ throw new Error('No account was found in Svelte context. Did you forget to wrap your component with WalletProvider?');
11
+ }
12
+ return account;
13
+ };
14
+ /**
15
+ * Sets the account store in Svelte's context
16
+ */
17
+ export const setAccountContext = (account) => {
18
+ setContext(ACCOUNT_KEY, account);
19
+ };
20
+ if (import.meta.vitest) {
21
+ const { describe, it, expect, vi, beforeEach } = import.meta.vitest;
22
+ vi.mock('svelte', async (importOriginal) => ({
23
+ ...(await importOriginal()),
24
+ getContext: vi.fn()
25
+ }));
26
+ describe('getAccountContext', () => {
27
+ const mockGetContext = vi.mocked(getContext);
28
+ beforeEach(() => {
29
+ mockGetContext.mockReset();
30
+ });
31
+ it('should return the account from context when it exists', () => {
32
+ const mockAccount = readable('0x456');
33
+ mockGetContext.mockImplementation((key) => {
34
+ if (key === ACCOUNT_KEY)
35
+ return mockAccount;
36
+ return undefined;
37
+ });
38
+ const result = getAccountContext();
39
+ expect(mockGetContext).toHaveBeenCalledWith(ACCOUNT_KEY);
40
+ expect(result).toEqual(mockAccount);
41
+ });
42
+ it('should throw an error when account is not in context', () => {
43
+ mockGetContext.mockReturnValue(undefined);
44
+ expect(() => getAccountContext()).toThrow('No account was found in Svelte context. Did you forget to wrap your component with WalletProvider?');
45
+ });
46
+ });
47
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Hook to access wallet account information from context
3
+ * Must be used within a component that is a child of WalletProvider
4
+ */
5
+ export declare function useAccount(): {
6
+ account: import("../../types/account").Account;
7
+ matchesAccount: (otherAddress: string) => boolean;
8
+ };
@@ -0,0 +1,148 @@
1
+ import { get } from 'svelte/store';
2
+ import { isAddress, isAddressEqual } from 'viem';
3
+ import { getAccountContext } from './context';
4
+ import { readable } from 'svelte/store';
5
+ /**
6
+ * Hook to access wallet account information from context
7
+ * Must be used within a component that is a child of WalletProvider
8
+ */
9
+ export function useAccount() {
10
+ /**
11
+ * The account store containing the current wallet address (as a Hex string) or null if not connected.
12
+ * This is a readable Svelte store that can be subscribed to for reactive updates.
13
+ * @type {import('svelte/store').Readable<Hex | null>}
14
+ */
15
+ const account = getAccountContext();
16
+ /**
17
+ * Checks if the provided address matches the currently connected account.
18
+ * Returns false if no account is connected or if the provided address is invalid.
19
+ */
20
+ const matchesAccount = (otherAddress) => {
21
+ if (!otherAddress)
22
+ return false;
23
+ const currentAccount = get(account);
24
+ if (!currentAccount) {
25
+ return false;
26
+ }
27
+ if (isAddress(currentAccount) &&
28
+ isAddress(otherAddress) &&
29
+ isAddressEqual(currentAccount, otherAddress)) {
30
+ return true;
31
+ }
32
+ return false;
33
+ };
34
+ return {
35
+ account,
36
+ matchesAccount
37
+ };
38
+ }
39
+ if (import.meta.vitest) {
40
+ const { describe, it, expect, vi, beforeEach } = import.meta.vitest;
41
+ vi.mock('viem', async () => {
42
+ const actual = await vi.importActual('viem');
43
+ return {
44
+ ...actual,
45
+ isAddress: vi.fn(),
46
+ isAddressEqual: vi.fn()
47
+ };
48
+ });
49
+ vi.mock('./context', () => ({
50
+ getAccountContext: vi.fn()
51
+ }));
52
+ vi.mock('svelte/store', async () => {
53
+ const actual = await vi.importActual('svelte/store');
54
+ return {
55
+ ...actual,
56
+ get: vi.fn()
57
+ };
58
+ });
59
+ describe('useAccount', () => {
60
+ const mockGetAccountContext = vi.mocked(getAccountContext);
61
+ const mockGet = vi.mocked(get);
62
+ const mockIsAddress = vi.mocked(isAddress);
63
+ const mockIsAddressEqual = vi.mocked(isAddressEqual);
64
+ beforeEach(() => {
65
+ vi.clearAllMocks();
66
+ });
67
+ it('should return account wrapped in an object', () => {
68
+ const mockAccountStore = readable('0x123');
69
+ mockGetAccountContext.mockReturnValue(mockAccountStore);
70
+ const result = useAccount();
71
+ expect(mockGetAccountContext).toHaveBeenCalled();
72
+ expect(result.account).toBe(mockAccountStore);
73
+ expect(result.matchesAccount).toBeInstanceOf(Function);
74
+ });
75
+ describe('matchesAccount', () => {
76
+ const mockAccountStore = readable('0x123');
77
+ const currentAccount = '0x123';
78
+ const testAddress1 = '0x123';
79
+ const testAddress2 = '0xdef';
80
+ const invalidAddress = 'invalid';
81
+ beforeEach(() => {
82
+ mockGetAccountContext.mockReturnValue(mockAccountStore);
83
+ });
84
+ it('should return true if addresses are valid and equal', () => {
85
+ // Setup mocks
86
+ mockGet.mockReturnValue(currentAccount);
87
+ mockIsAddress.mockReturnValue(true);
88
+ mockIsAddressEqual.mockReturnValue(true);
89
+ const { matchesAccount } = useAccount();
90
+ const result = matchesAccount(testAddress1);
91
+ expect(mockGet).toHaveBeenCalledWith(mockAccountStore);
92
+ expect(mockIsAddress).toHaveBeenCalledWith(currentAccount);
93
+ expect(mockIsAddress).toHaveBeenCalledWith(testAddress1);
94
+ expect(mockIsAddressEqual).toHaveBeenCalledWith(currentAccount, testAddress1);
95
+ expect(result).toBe(true);
96
+ });
97
+ it('should return false if addresses are valid but not equal', () => {
98
+ // Setup mocks
99
+ mockGet.mockReturnValue(currentAccount);
100
+ mockIsAddress.mockReturnValue(true);
101
+ mockIsAddressEqual.mockReturnValue(false);
102
+ const { matchesAccount } = useAccount();
103
+ const result = matchesAccount(testAddress2);
104
+ expect(mockGet).toHaveBeenCalledWith(mockAccountStore);
105
+ expect(mockIsAddress).toHaveBeenCalledWith(currentAccount);
106
+ expect(mockIsAddress).toHaveBeenCalledWith(testAddress2);
107
+ expect(mockIsAddressEqual).toHaveBeenCalledWith(currentAccount, testAddress2);
108
+ expect(result).toBe(false);
109
+ });
110
+ it('should return false if current account is not set', () => {
111
+ // Setup mocks
112
+ mockGet.mockReturnValue(null);
113
+ const { matchesAccount } = useAccount();
114
+ const result = matchesAccount(testAddress1);
115
+ expect(mockGet).toHaveBeenCalledWith(mockAccountStore);
116
+ expect(mockIsAddress).not.toHaveBeenCalled();
117
+ expect(mockIsAddressEqual).not.toHaveBeenCalled();
118
+ expect(result).toBe(false);
119
+ });
120
+ it('should return false if provided address is invalid', () => {
121
+ // Setup mocks
122
+ mockGet.mockReturnValue(currentAccount);
123
+ // This is crucial: we need to ensure short-circuit evaluation works correctly
124
+ mockIsAddress.mockImplementation((address) => {
125
+ return address !== invalidAddress; // Only the invalid address returns false
126
+ });
127
+ // This should never be called due to short-circuit evaluation
128
+ mockIsAddressEqual.mockReturnValue(false);
129
+ const { matchesAccount } = useAccount();
130
+ const result = matchesAccount(invalidAddress);
131
+ expect(mockGet).toHaveBeenCalledWith(mockAccountStore);
132
+ expect(mockIsAddress).toHaveBeenCalledWith(currentAccount);
133
+ expect(mockIsAddress).toHaveBeenCalledWith(invalidAddress);
134
+ expect(mockIsAddressEqual).not.toHaveBeenCalled(); // This should now pass
135
+ expect(result).toBe(false);
136
+ });
137
+ it('should return false if provided address is null', () => {
138
+ // Setup mocks
139
+ mockGet.mockReturnValue(currentAccount);
140
+ const { matchesAccount } = useAccount();
141
+ const result = matchesAccount(null);
142
+ expect(mockIsAddress).not.toHaveBeenCalled();
143
+ expect(mockIsAddressEqual).not.toHaveBeenCalled();
144
+ expect(result).toBe(false);
145
+ });
146
+ });
147
+ });
148
+ }
@@ -7,3 +7,4 @@ export declare const QKEY_ORDER_TRADES_LIST = "orderTradesList";
7
7
  export declare const QKEY_ORDER_QUOTE = "orderQuote";
8
8
  export declare const QKEY_VAULTS_VOL_LIST = "orderVaultsVolumeList";
9
9
  export declare const QKEY_ORDER_APY = "orderApy";
10
+ export declare const QKEY_TOKENS = "tokens";
@@ -7,3 +7,4 @@ export const QKEY_ORDER_TRADES_LIST = 'orderTradesList';
7
7
  export const QKEY_ORDER_QUOTE = 'orderQuote';
8
8
  export const QKEY_VAULTS_VOL_LIST = 'orderVaultsVolumeList';
9
9
  export const QKEY_ORDER_APY = 'orderApy';
10
+ export const QKEY_TOKENS = 'tokens';
@@ -1,3 +1,3 @@
1
1
  import { QueryClient } from '@tanstack/svelte-query';
2
2
  export declare const queryClient: QueryClient;
3
- export declare const invalidateIdQuery: (queryClient: QueryClient, id: string) => Promise<void>;
3
+ export declare const invalidateTanstackQueries: (queryClient: QueryClient, queryKey: string[]) => Promise<void>;
@@ -7,10 +7,15 @@ export const queryClient = new QueryClient({
7
7
  }
8
8
  }
9
9
  });
10
- export const invalidateIdQuery = async (queryClient, id) => {
11
- await queryClient.invalidateQueries({
12
- queryKey: [id],
13
- refetchType: 'all',
14
- exact: false
15
- });
10
+ export const invalidateTanstackQueries = async (queryClient, queryKey) => {
11
+ try {
12
+ await queryClient.invalidateQueries({
13
+ queryKey,
14
+ refetchType: 'all',
15
+ exact: false
16
+ });
17
+ }
18
+ catch {
19
+ throw new Error('Failed to refresh data.');
20
+ }
16
21
  };
@@ -0,0 +1,107 @@
1
+ /**
2
+ * @module awaitTransactionIndexing
3
+ * @description Utilities for waiting for transactions to be indexed by a subgraph
4
+ */
5
+ import type { WasmEncodedResult, RaindexTransaction, RaindexOrder, Address, Hex } from '@rainlanguage/orderbook';
6
+ export type AwaitSubgraphConfig = {
7
+ chainId: number;
8
+ orderbook: Address;
9
+ txHash: Hex;
10
+ successMessage: string;
11
+ fetchEntityFn: (chainId: number, orderbook: Address, txHash: Hex) => Promise<WasmEncodedResult<RaindexTransaction | RaindexOrder[] | null | undefined>>;
12
+ isSuccess: (data: RaindexTransaction | RaindexOrder[]) => boolean;
13
+ };
14
+ /**
15
+ * Result of a subgraph indexing operation
16
+ * @template T The type of data returned by the subgraph
17
+ */
18
+ export type IndexingResult<T> = {
19
+ /**
20
+ * The successful result of the indexing operation
21
+ */
22
+ value?: {
23
+ /**
24
+ * The transaction hash
25
+ */
26
+ txHash: Hex;
27
+ /**
28
+ * Message to display on successful indexing
29
+ */
30
+ successMessage: string;
31
+ /**
32
+ * Optional order hash if available
33
+ */
34
+ orderHash?: Hex;
35
+ /**
36
+ * Optional network key
37
+ */
38
+ network?: string;
39
+ /**
40
+ * Optional data returned from the subgraph
41
+ */
42
+ data?: T;
43
+ };
44
+ /**
45
+ * Error message if indexing failed
46
+ */
47
+ error?: string;
48
+ };
49
+ /**
50
+ * Generic function to handle waiting for subgraph indexing
51
+ * Returns a promise that resolves with an object containing either value or error
52
+ *
53
+ * @template T The type of data returned by the subgraph
54
+ * @param options Configuration options for the indexing operation
55
+ * @param options.chainId Chain ID to query
56
+ * @param options.orderbook Orderbook address to query
57
+ * @param options.txHash Transaction hash to check for indexing
58
+ * @param options.successMessage Message to display on successful indexing
59
+ * @param options.maxAttempts Maximum number of attempts before timing out (default: 10)
60
+ * @param options.interval Interval between attempts in milliseconds (default: 1000)
61
+ * @param options.network Optional network identifier
62
+ * @param options.fetchEntityFn Function to fetch data from the subgraph
63
+ * @param options.isSuccess Function to determine if the fetched data indicates success
64
+ * @returns Promise resolving to an IndexingResult
65
+ */
66
+ export declare const awaitSubgraphIndexing: <T>(options: {
67
+ /**
68
+ * Chain ID to query
69
+ */
70
+ chainId: number;
71
+ /**
72
+ * Orderbook address to query
73
+ */
74
+ orderbook: Address;
75
+ /**
76
+ * Transaction hash to check for indexing
77
+ */
78
+ txHash: Hex;
79
+ /**
80
+ * Message to display on successful indexing
81
+ */
82
+ successMessage: string;
83
+ /**
84
+ * Maximum number of attempts before timing out
85
+ */
86
+ maxAttempts?: number;
87
+ /**
88
+ * Interval between attempts in milliseconds
89
+ */
90
+ interval?: number;
91
+ /**
92
+ * Optional network identifier
93
+ */
94
+ network?: string;
95
+ /**
96
+ * Function to fetch data from the subgraph
97
+ * @param chainId Chain ID to query
98
+ * @param orderbook Orderbook address to query
99
+ * @param txHash Transaction hash to query
100
+ */
101
+ fetchEntityFn: (chainId: number, orderbook: Address, txHash: Hex) => Promise<WasmEncodedResult<T | null | undefined>>;
102
+ /**
103
+ * Function to determine if the fetched data indicates success
104
+ * @param data The data returned from the subgraph
105
+ */
106
+ isSuccess: (data: T) => boolean;
107
+ }) => Promise<IndexingResult<T>>;
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @module awaitTransactionIndexing
3
+ * @description Utilities for waiting for transactions to be indexed by a subgraph
4
+ */
5
+ import { TransactionStoreErrorMessage } from '../types/transaction';
6
+ /**
7
+ * Generic function to handle waiting for subgraph indexing
8
+ * Returns a promise that resolves with an object containing either value or error
9
+ *
10
+ * @template T The type of data returned by the subgraph
11
+ * @param options Configuration options for the indexing operation
12
+ * @param options.chainId Chain ID to query
13
+ * @param options.orderbook Orderbook address to query
14
+ * @param options.txHash Transaction hash to check for indexing
15
+ * @param options.successMessage Message to display on successful indexing
16
+ * @param options.maxAttempts Maximum number of attempts before timing out (default: 10)
17
+ * @param options.interval Interval between attempts in milliseconds (default: 1000)
18
+ * @param options.network Optional network identifier
19
+ * @param options.fetchEntityFn Function to fetch data from the subgraph
20
+ * @param options.isSuccess Function to determine if the fetched data indicates success
21
+ * @returns Promise resolving to an IndexingResult
22
+ */
23
+ export const awaitSubgraphIndexing = async (options) => {
24
+ const { chainId, orderbook, txHash, successMessage, maxAttempts = 10, interval = 1000, network, fetchEntityFn, isSuccess } = options;
25
+ const checkIndexing = async (attempt) => {
26
+ try {
27
+ const data = await fetchEntityFn(chainId, orderbook, txHash);
28
+ if (data.value && isSuccess(data.value)) {
29
+ let newOrderHash;
30
+ // Extract orderHash from order data if it exists in the expected format
31
+ // This only applies to addOrder transactions
32
+ if (Array.isArray(data.value) && data.value.length > 0 && data.value[0]?.orderHash) {
33
+ newOrderHash = data.value[0].orderHash;
34
+ }
35
+ return {
36
+ value: {
37
+ txHash,
38
+ successMessage,
39
+ orderHash: newOrderHash,
40
+ network,
41
+ data: data.value
42
+ }
43
+ };
44
+ }
45
+ }
46
+ catch {
47
+ // Continue with the next attempt
48
+ }
49
+ if (attempt >= maxAttempts) {
50
+ return {
51
+ error: TransactionStoreErrorMessage.SUBGRAPH_TIMEOUT_ERROR
52
+ };
53
+ }
54
+ await new Promise((resolve) => setTimeout(resolve, interval));
55
+ return checkIndexing(attempt + 1);
56
+ };
57
+ return checkIndexing(1);
58
+ };
@@ -1 +1 @@
1
- export declare const getExplorerLink: (hash: string, chainId: number, type: "tx" | "address") => Promise<string>;
1
+ export declare const getExplorerLink: (hash: string, chainId: number, type: "tx" | "address") => string;
@@ -1,10 +1,8 @@
1
1
  import * as chains from 'viem/chains';
2
- export const getExplorerLink = async (hash, chainId, type) => {
2
+ export const getExplorerLink = (hash, chainId, type) => {
3
3
  const chain = Object.values(chains).find((chain) => chain.id === chainId);
4
4
  if (chain?.blockExplorers) {
5
5
  return chain.blockExplorers.default.url + `/${type}/${hash}`;
6
6
  }
7
- else {
8
- return '';
9
- }
7
+ return '';
10
8
  };
@@ -1,2 +1,2 @@
1
- import type { DotrainOrderGui } from '@rainlanguage/orderbook/js_api';
2
- export declare function handleShareChoices(gui: DotrainOrderGui): Promise<void>;
1
+ import type { DotrainOrderGui } from '@rainlanguage/orderbook';
2
+ export declare function handleShareChoices(gui: DotrainOrderGui, registryUrl: string): Promise<void>;
@@ -1,10 +1,15 @@
1
1
  import { page } from '$app/stores';
2
2
  import { get } from 'svelte/store';
3
- export async function handleShareChoices(gui) {
3
+ export async function handleShareChoices(gui, registryUrl) {
4
4
  // get the current url
5
5
  const url = get(page).url;
6
6
  // get the current state
7
- const state = gui?.serializeState();
7
+ const result = gui.serializeState();
8
+ if (result.error) {
9
+ throw new Error(result.error.msg);
10
+ }
11
+ const state = result.value;
8
12
  url.searchParams.set('state', state || '');
13
+ url.searchParams.set('registry', registryUrl);
9
14
  navigator.clipboard.writeText(url.toString());
10
15
  }
@@ -1,11 +1,11 @@
1
- import type { SgTrade } from '@rainlanguage/orderbook/js_api';
1
+ import type { RaindexTrade } from '@rainlanguage/orderbook';
2
2
  import type { UTCTimestamp } from 'lightweight-charts';
3
3
  export type HistoricalOrderChartData = {
4
4
  value: number;
5
5
  time: UTCTimestamp;
6
6
  color?: string;
7
7
  }[];
8
- export declare function prepareHistoricalOrderChartData(takeOrderEntities: SgTrade[], colorTheme: string): {
8
+ export declare function prepareHistoricalOrderChartData(takeOrderEntities: RaindexTrade[], colorTheme: string): {
9
9
  value: number;
10
10
  time: UTCTimestamp;
11
11
  color?: string;