@rainlanguage/ui-components 0.0.1-alpha.24 → 0.0.1-alpha.240

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 (299) hide show
  1. package/README.md +14 -6
  2. package/dist/__fixtures__/settings.yaml +123 -0
  3. package/dist/__mocks__/CodeMirrorRainlang.svelte +4 -0
  4. package/dist/__mocks__/CodeMirrorRainlang.svelte.d.ts +18 -0
  5. package/dist/__mocks__/MockCodeMirrorEditor.svelte +17 -0
  6. package/dist/__mocks__/MockCodeMirrorEditor.svelte.d.ts +21 -0
  7. package/dist/__mocks__/MockComponent.js +1 -1
  8. package/dist/__mocks__/MockComponent.svelte +10 -2
  9. package/dist/__mocks__/MockComponent.svelte.d.ts +4 -1
  10. package/dist/__mocks__/mockWeb3Config.d.ts +1 -1
  11. package/dist/__mocks__/mockWeb3Config.js +10 -7
  12. package/dist/__mocks__/queries.js +9 -9
  13. package/dist/__mocks__/stores.d.ts +55 -45
  14. package/dist/__mocks__/stores.js +85 -68
  15. package/dist/app.css +3 -3
  16. package/dist/components/ButtonDarkMode.svelte +7 -1
  17. package/dist/components/ButtonLoading.svelte +1 -1
  18. package/dist/components/ButtonScrub.svelte +22 -0
  19. package/dist/components/ButtonScrub.svelte.d.ts +25 -0
  20. package/dist/components/ButtonVaultLink.svelte +12 -11
  21. package/dist/components/ButtonVaultLink.svelte.d.ts +4 -3
  22. package/dist/components/CheckboxInactiveOrdersVault.svelte +20 -0
  23. package/dist/components/CheckboxInactiveOrdersVault.svelte.d.ts +19 -0
  24. package/dist/components/CheckboxZeroBalanceVault.svelte.d.ts +2 -2
  25. package/dist/components/CodeMirrorDotrain.svelte +4 -0
  26. package/dist/components/CodeMirrorDotrain.svelte.d.ts +1 -0
  27. package/dist/components/CodeMirrorRainlang.svelte +20 -12
  28. package/dist/components/CodeMirrorRainlang.svelte.d.ts +3 -2
  29. package/dist/components/EditableSpan.svelte +3 -14
  30. package/dist/components/EditableSpan.svelte.d.ts +0 -1
  31. package/dist/components/Hash.svelte +6 -5
  32. package/dist/components/License.svelte +5 -4
  33. package/dist/components/ListViewRaindexFilters.svelte +64 -0
  34. package/dist/components/ListViewRaindexFilters.svelte.d.ts +32 -0
  35. package/dist/components/LocalDbStatusBadge.svelte +27 -0
  36. package/dist/components/LocalDbStatusBadge.svelte.d.ts +19 -0
  37. package/dist/components/LocalDbStatusCard.svelte +43 -0
  38. package/dist/components/LocalDbStatusCard.svelte.d.ts +20 -0
  39. package/dist/components/LocalDbStatusModal.svelte +105 -0
  40. package/dist/components/LocalDbStatusModal.svelte.d.ts +21 -0
  41. package/dist/components/OrderOrVaultHash.svelte +12 -12
  42. package/dist/components/OrderOrVaultHash.svelte.d.ts +4 -4
  43. package/dist/components/PageHeader.svelte +1 -1
  44. package/dist/components/Sensitive.svelte +16 -0
  45. package/dist/components/Sensitive.svelte.d.ts +28 -0
  46. package/dist/components/TanstackAppTable.svelte +270 -60
  47. package/dist/components/TanstackAppTable.svelte.d.ts +15 -9
  48. package/dist/components/ToastDetail.svelte +42 -0
  49. package/dist/components/ToastDetail.svelte.d.ts +20 -0
  50. package/dist/components/Tooltip.svelte +8 -0
  51. package/dist/components/Tooltip.svelte.d.ts +21 -0
  52. package/dist/components/VaultBalanceChangeTypeFilter.svelte +23 -0
  53. package/dist/components/VaultBalanceChangeTypeFilter.svelte.d.ts +19 -0
  54. package/dist/components/VaultCard.svelte +18 -0
  55. package/dist/components/VaultCard.svelte.d.ts +19 -0
  56. package/dist/components/charts/LightweightChart.svelte +1 -1
  57. package/dist/components/charts/LightweightChart.svelte.d.ts +5 -5
  58. package/dist/components/charts/OrderTradesChart.svelte +319 -28
  59. package/dist/components/charts/OrderTradesChart.svelte.d.ts +4 -4
  60. package/dist/components/charts/TanstackLightweightChartLine.svelte +5 -9
  61. package/dist/components/charts/VaultBalanceChart.svelte +8 -26
  62. package/dist/components/charts/VaultBalanceChart.svelte.d.ts +1 -7
  63. package/dist/components/charts/transformAndSortData.d.ts +24 -0
  64. package/dist/components/charts/transformAndSortData.js +111 -0
  65. package/dist/components/checkbox/CheckboxActiveOrders.svelte +11 -0
  66. package/dist/components/checkbox/CheckboxActiveOrders.svelte.d.ts +19 -0
  67. package/dist/components/deployment/ButtonSelectOption.svelte +2 -0
  68. package/dist/components/deployment/ButtonSelectOption.svelte.d.ts +1 -0
  69. package/dist/components/deployment/ComposedRainlangModal.svelte +3 -2
  70. package/dist/components/deployment/ComposedRainlangModal.svelte.d.ts +1 -4
  71. package/dist/components/deployment/DeploymentSectionHeader.svelte +7 -4
  72. package/dist/components/deployment/DeploymentSteps.svelte +196 -221
  73. package/dist/components/deployment/DeploymentSteps.svelte.d.ts +6 -12
  74. package/dist/components/deployment/DeploymentTile.svelte +2 -2
  75. package/dist/components/deployment/DeploymentTile.svelte.d.ts +1 -1
  76. package/dist/components/deployment/DeploymentsSection.svelte +15 -22
  77. package/dist/components/deployment/DeploymentsSection.svelte.d.ts +3 -2
  78. package/dist/components/deployment/DepositInput.svelte +10 -11
  79. package/dist/components/deployment/DepositInput.svelte.d.ts +2 -3
  80. package/dist/components/deployment/DisclaimerModal.svelte +6 -7
  81. package/dist/components/deployment/FieldDefinitionInput.svelte +10 -14
  82. package/dist/components/deployment/FieldDefinitionInput.svelte.d.ts +2 -3
  83. package/dist/components/deployment/InvalidOrdersSection.svelte +17 -0
  84. package/dist/components/deployment/InvalidOrdersSection.svelte.d.ts +19 -0
  85. package/dist/components/deployment/{StrategyPage.svelte → OrderPage.svelte} +15 -24
  86. package/dist/components/deployment/OrderPage.svelte.d.ts +21 -0
  87. package/dist/components/deployment/SelectToken.svelte +127 -50
  88. package/dist/components/deployment/SelectToken.svelte.d.ts +5 -4
  89. package/dist/components/deployment/TokenBalance.svelte +19 -0
  90. package/dist/components/deployment/TokenBalance.svelte.d.ts +19 -0
  91. package/dist/components/deployment/TokenIOInput.svelte +27 -17
  92. package/dist/components/deployment/TokenIOInput.svelte.d.ts +3 -3
  93. package/dist/components/deployment/TokenSelectionModal.svelte +148 -0
  94. package/dist/components/deployment/TokenSelectionModal.svelte.d.ts +20 -0
  95. package/dist/components/deployment/{ValidStrategiesSection.svelte → ValidOrdersSection.svelte} +7 -7
  96. package/dist/components/deployment/ValidOrdersSection.svelte.d.ts +19 -0
  97. package/dist/components/deployment/VaultIdInformation.svelte +17 -0
  98. package/dist/components/deployment/VaultIdInformation.svelte.d.ts +21 -0
  99. package/dist/components/detail/OrderDetail.svelte +220 -82
  100. package/dist/components/detail/OrderDetail.svelte.d.ts +21 -15
  101. package/dist/components/detail/TanstackOrderQuote.svelte +114 -46
  102. package/dist/components/detail/TanstackOrderQuote.svelte.d.ts +14 -16
  103. package/dist/components/detail/VaultDetail.svelte +82 -79
  104. package/dist/components/detail/VaultDetail.svelte.d.ts +12 -18
  105. package/dist/components/dropdown/DropdownActiveNetworks.svelte +44 -0
  106. package/dist/components/dropdown/DropdownActiveNetworks.svelte.d.ts +19 -0
  107. package/dist/components/dropdown/DropdownCheckbox.svelte +4 -4
  108. package/dist/components/dropdown/DropdownRaindexesFilter.svelte +172 -0
  109. package/dist/components/dropdown/DropdownRaindexesFilter.svelte.d.ts +25 -0
  110. package/dist/components/dropdown/DropdownTokensFilter.svelte +152 -0
  111. package/dist/components/dropdown/DropdownTokensFilter.svelte.d.ts +28 -0
  112. package/dist/components/icon/Refresh.svelte +4 -2
  113. package/dist/components/icon/Refresh.svelte.d.ts +2 -0
  114. package/dist/components/input/InputOrderHash.svelte +1 -1
  115. package/dist/components/input/InputOrderHash.svelte.d.ts +3 -3
  116. package/dist/components/input/InputOwnerFilter.svelte +48 -0
  117. package/dist/components/input/InputOwnerFilter.svelte.d.ts +19 -0
  118. package/dist/components/input/InputRegistryUrl.svelte +36 -14
  119. package/dist/components/input/InputToken.svelte +2 -2
  120. package/dist/components/input/InputTokenAmount.svelte +30 -20
  121. package/dist/components/input/InputTokenAmount.svelte.d.ts +3 -3
  122. package/dist/components/tables/OrderAPY.svelte +6 -33
  123. package/dist/components/tables/OrderAPY.svelte.d.ts +1 -4
  124. package/dist/components/tables/OrderTradesListTable.svelte +132 -124
  125. package/dist/components/tables/OrderTradesListTable.svelte.d.ts +4 -4
  126. package/dist/components/tables/OrderVaultsVolTable.svelte +17 -22
  127. package/dist/components/tables/OrderVaultsVolTable.svelte.d.ts +2 -2
  128. package/dist/components/tables/OrdersListTable.svelte +206 -115
  129. package/dist/components/tables/OrdersListTable.svelte.d.ts +18 -23
  130. package/dist/components/tables/VaultBalanceChangesTable.svelte +83 -43
  131. package/dist/components/tables/VaultBalanceChangesTable.svelte.d.ts +13 -11
  132. package/dist/components/tables/VaultsListTable.svelte +275 -150
  133. package/dist/components/tables/VaultsListTable.svelte.d.ts +24 -33
  134. package/dist/components/transactions/FixedBottomTransaction.svelte +64 -0
  135. package/dist/components/transactions/FixedBottomTransaction.svelte.d.ts +16 -0
  136. package/dist/components/transactions/TransactionDetail.svelte +31 -0
  137. package/dist/components/transactions/TransactionDetail.svelte.d.ts +20 -0
  138. package/dist/components/transactions/TransactionList.svelte +17 -0
  139. package/dist/components/transactions/TransactionList.svelte.d.ts +16 -0
  140. package/dist/components/transactions/getStatusEmoji.d.ts +2 -0
  141. package/dist/components/transactions/getStatusEmoji.js +20 -0
  142. package/dist/components/wallet/WalletConnect.svelte +5 -4
  143. package/dist/components/wallet/WalletConnect.svelte.d.ts +0 -1
  144. package/dist/consts.d.ts +1 -0
  145. package/dist/consts.js +1 -0
  146. package/dist/errors/DeploymentStepsError.d.ts +11 -5
  147. package/dist/errors/DeploymentStepsError.js +13 -7
  148. package/dist/errors/index.d.ts +1 -1
  149. package/dist/errors/index.js +1 -1
  150. package/dist/hooks/useLocalDb.d.ts +3 -0
  151. package/dist/hooks/useLocalDb.js +10 -0
  152. package/dist/hooks/useRaindexClient.d.ts +3 -0
  153. package/dist/hooks/useRaindexClient.js +11 -0
  154. package/dist/hooks/useRaindexOrderBuilder.d.ts +3 -0
  155. package/dist/hooks/useRaindexOrderBuilder.js +11 -0
  156. package/dist/index.d.ts +122 -91
  157. package/dist/index.js +118 -87
  158. package/dist/models/Transaction.d.ts +75 -0
  159. package/dist/models/Transaction.js +100 -0
  160. package/dist/providers/LocalDbProvider.svelte +8 -0
  161. package/dist/providers/LocalDbProvider.svelte.d.ts +21 -0
  162. package/dist/providers/RaindexClientProvider.svelte +8 -0
  163. package/dist/providers/RaindexClientProvider.svelte.d.ts +21 -0
  164. package/dist/providers/RaindexOrderBuilderProvider.svelte +8 -0
  165. package/dist/providers/RaindexOrderBuilderProvider.svelte.d.ts +21 -0
  166. package/dist/providers/dotrainRegistry/DotrainRegistryProvider.svelte +8 -0
  167. package/dist/providers/dotrainRegistry/DotrainRegistryProvider.svelte.d.ts +24 -0
  168. package/dist/providers/dotrainRegistry/context.d.ts +9 -0
  169. package/dist/providers/dotrainRegistry/context.js +43 -0
  170. package/dist/providers/dotrainRegistry/useDotrainRegistry.d.ts +5 -0
  171. package/dist/providers/dotrainRegistry/useDotrainRegistry.js +35 -0
  172. package/dist/providers/registry/RegistryManager.d.ts +65 -0
  173. package/dist/providers/registry/RegistryManager.js +134 -0
  174. package/dist/providers/registry/RegistryProvider.svelte +6 -0
  175. package/dist/providers/registry/RegistryProvider.svelte.d.ts +21 -0
  176. package/dist/providers/registry/context.d.ts +10 -0
  177. package/dist/providers/registry/context.js +46 -0
  178. package/dist/providers/registry/useRegistry.d.ts +7 -0
  179. package/dist/providers/registry/useRegistry.js +29 -0
  180. package/dist/providers/toasts/ToastProvider.svelte +17 -0
  181. package/dist/providers/toasts/ToastProvider.svelte.d.ts +18 -0
  182. package/dist/providers/toasts/context.d.ts +14 -0
  183. package/dist/providers/toasts/context.js +22 -0
  184. package/dist/providers/toasts/useToasts.d.ts +16 -0
  185. package/dist/providers/toasts/useToasts.js +63 -0
  186. package/dist/providers/transactions/TransactionManager.d.ts +234 -0
  187. package/dist/providers/transactions/TransactionManager.js +509 -0
  188. package/dist/providers/transactions/TransactionProvider.svelte +11 -0
  189. package/dist/providers/transactions/TransactionProvider.svelte.d.ts +24 -0
  190. package/dist/providers/transactions/context.d.ts +19 -0
  191. package/dist/providers/transactions/context.js +28 -0
  192. package/dist/providers/transactions/useTransactions.d.ts +13 -0
  193. package/dist/providers/transactions/useTransactions.js +18 -0
  194. package/dist/providers/wallet/WalletProvider.svelte +7 -0
  195. package/dist/providers/wallet/WalletProvider.svelte.d.ts +21 -0
  196. package/dist/providers/wallet/context.d.ts +10 -0
  197. package/dist/providers/wallet/context.js +47 -0
  198. package/dist/providers/wallet/useAccount.d.ts +8 -0
  199. package/dist/providers/wallet/useAccount.js +148 -0
  200. package/dist/queries/keys.d.ts +1 -0
  201. package/dist/queries/keys.js +10 -9
  202. package/dist/queries/queryClient.d.ts +2 -2
  203. package/dist/queries/queryClient.js +16 -11
  204. package/dist/services/awaitTransactionIndexing.d.ts +107 -0
  205. package/dist/services/awaitTransactionIndexing.js +60 -0
  206. package/dist/services/getExplorerLink.d.ts +1 -1
  207. package/dist/services/getExplorerLink.js +3 -5
  208. package/dist/services/handleShareChoices.d.ts +2 -2
  209. package/dist/services/handleShareChoices.js +6 -5
  210. package/dist/services/historicalOrderCharts.d.ts +3 -3
  211. package/dist/services/historicalOrderCharts.js +364 -371
  212. package/dist/services/index.d.ts +5 -2
  213. package/dist/services/index.js +3 -1
  214. package/dist/services/loadRegistryUrl.d.ts +2 -0
  215. package/dist/services/loadRegistryUrl.js +22 -0
  216. package/dist/services/pairTradesChartData.d.ts +47 -0
  217. package/dist/services/pairTradesChartData.js +194 -0
  218. package/dist/services/registry.d.ts +5 -5
  219. package/dist/services/registry.js +17 -217
  220. package/dist/services/time.d.ts +12 -0
  221. package/dist/services/time.js +88 -6
  222. package/dist/services/validateAmount.d.ts +30 -0
  223. package/dist/services/validateAmount.js +53 -0
  224. package/dist/storesGeneric/cachedWritableStore.d.ts +57 -0
  225. package/dist/storesGeneric/cachedWritableStore.js +93 -0
  226. package/dist/storesGeneric/scrub.d.ts +14 -0
  227. package/dist/storesGeneric/scrub.js +22 -0
  228. package/dist/test/matchers.d.ts +2 -2
  229. package/dist/test/matchers.js +2 -2
  230. package/dist/types/account.d.ts +3 -0
  231. package/dist/types/appStores.d.ts +9 -16
  232. package/dist/types/modal.d.ts +26 -14
  233. package/dist/types/order.d.ts +10 -0
  234. package/dist/types/order.js +1 -0
  235. package/dist/types/toast.d.ts +11 -0
  236. package/dist/types/toast.js +1 -0
  237. package/dist/types/tokenBalance.d.ts +6 -0
  238. package/dist/types/tokenBalance.js +1 -0
  239. package/dist/types/transaction.d.ts +67 -22
  240. package/dist/types/transaction.js +31 -1
  241. package/dist/utils/breadcrumbs.js +2 -2
  242. package/dist/utils/codeMirrorThemes.js +80 -74
  243. package/dist/utils/configHelpers.d.ts +4 -0
  244. package/dist/utils/configHelpers.js +21 -0
  245. package/dist/utils/constructHashLink.d.ts +24 -0
  246. package/dist/utils/constructHashLink.js +117 -0
  247. package/dist/utils/getNetworkName.d.ts +1 -0
  248. package/dist/utils/getNetworkName.js +13 -0
  249. package/dist/utils/hex.js +1 -1
  250. package/dist/utils/lightweightChartsThemes.d.ts +1 -1
  251. package/dist/utils/lightweightChartsThemes.js +11 -11
  252. package/dist/utils/localDbStatus.d.ts +26 -0
  253. package/dist/utils/localDbStatus.js +22 -0
  254. package/dist/utils/number.d.ts +0 -7
  255. package/dist/utils/number.js +5 -30
  256. package/dist/utils/stripTrailingWhitespace.d.ts +16 -0
  257. package/dist/utils/stripTrailingWhitespace.js +22 -0
  258. package/dist/utils/tokens.d.ts +2 -0
  259. package/dist/utils/tokens.js +3 -0
  260. package/dist/utils/vaultBalanceChangeLabels.d.ts +4 -0
  261. package/dist/utils/vaultBalanceChangeLabels.js +18 -0
  262. package/package.json +89 -84
  263. package/dist/__fixtures__/orderDetail.d.ts +0 -99
  264. package/dist/__fixtures__/orderDetail.js +0 -204
  265. package/dist/__fixtures__/settings-12-11-24.json +0 -160
  266. package/dist/__mocks__/mockTransactionStore.d.ts +0 -22
  267. package/dist/__mocks__/mockTransactionStore.js +0 -56
  268. package/dist/__mocks__/settings.d.ts +0 -3
  269. package/dist/__mocks__/settings.js +0 -37
  270. package/dist/components/CheckboxMyItemsOnly.svelte +0 -23
  271. package/dist/components/CheckboxMyItemsOnly.svelte.d.ts +0 -21
  272. package/dist/components/ListViewOrderbookFilters.svelte +0 -58
  273. package/dist/components/ListViewOrderbookFilters.svelte.d.ts +0 -28
  274. package/dist/components/deployment/InvalidStrategiesSection.svelte +0 -19
  275. package/dist/components/deployment/InvalidStrategiesSection.svelte.d.ts +0 -19
  276. package/dist/components/deployment/StrategyPage.svelte.d.ts +0 -19
  277. package/dist/components/deployment/ValidStrategiesSection.svelte.d.ts +0 -19
  278. package/dist/components/deployment/getDeploymentTransactionArgs.d.ts +0 -17
  279. package/dist/components/deployment/getDeploymentTransactionArgs.js +0 -28
  280. package/dist/components/detail/DepositOrWithdrawButtons.svelte +0 -44
  281. package/dist/components/detail/DepositOrWithdrawButtons.svelte.d.ts +0 -26
  282. package/dist/components/dropdown/DropdownActiveSubgraphs.svelte +0 -38
  283. package/dist/components/dropdown/DropdownActiveSubgraphs.svelte.d.ts +0 -21
  284. package/dist/components/dropdown/DropdownOrderListAccounts.svelte +0 -15
  285. package/dist/components/dropdown/DropdownOrderListAccounts.svelte.d.ts +0 -20
  286. package/dist/components/dropdown/DropdownOrderStatus.svelte +0 -31
  287. package/dist/components/dropdown/DropdownOrderStatus.svelte.d.ts +0 -19
  288. package/dist/hooks/useGui.d.ts +0 -3
  289. package/dist/hooks/useGui.js +0 -11
  290. package/dist/providers/GuiProvider.svelte +0 -8
  291. package/dist/providers/GuiProvider.svelte.d.ts +0 -21
  292. package/dist/stores/transactionStore.d.ts +0 -98
  293. package/dist/stores/transactionStore.js +0 -303
  294. package/dist/types/strategy.d.ts +0 -10
  295. package/dist/utils/time.d.ts +0 -12
  296. package/dist/utils/time.js +0 -27
  297. package/dist/utils/vault.d.ts +0 -2
  298. package/dist/utils/vault.js +0 -29
  299. /package/dist/types/{strategy.js → account.js} +0 -0
@@ -1,3 +1,10 @@
1
+ import dayjs from "dayjs";
2
+ import bigIntSupport from "dayjs/plugin/bigIntSupport";
3
+ import localizedFormat from "dayjs/plugin/localizedFormat";
4
+ import utc from "dayjs/plugin/utc";
5
+ dayjs.extend(bigIntSupport);
6
+ dayjs.extend(localizedFormat);
7
+ dayjs.extend(utc);
1
8
  export const TIME_DELTA_24_HOURS = 60 * 60 * 24;
2
9
  export const TIME_DELTA_48_HOURS = TIME_DELTA_24_HOURS * 2;
3
10
  export const TIME_DELTA_7_DAYS = TIME_DELTA_24_HOURS * 7;
@@ -6,12 +13,87 @@ export const TIME_DELTA_1_YEAR = TIME_DELTA_24_HOURS * 365;
6
13
  export function dateTimestamp(date) {
7
14
  return Math.floor(date.getTime() / 1000);
8
15
  }
16
+ export function formatTimestampSecondsAsLocal(timestampSeconds) {
17
+ return dayjs(timestampSeconds * BigInt("1000"))
18
+ .utc()
19
+ .format("L LT");
20
+ }
21
+ export function timestampSecondsToUTCTimestamp(timestampSeconds) {
22
+ return dayjs(timestampSeconds * BigInt("1000")).unix();
23
+ }
24
+ /**
25
+ * Method to put a timeout on a promise, throws the exception if promise is not settled within the time
26
+ * @param promise - The original promise
27
+ * @param time - The time in ms
28
+ * @param exception - The exception to reject with if time runs out before original promise settlement
29
+ * @returns A new promise that gets settled with initial promise settlement or rejected with exception value
30
+ * if the time runs out before the main promise settlement
31
+ */
32
+ export async function promiseTimeout(promise, time, exception) {
33
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
+ let timeout;
35
+ return Promise.race([
36
+ promise,
37
+ new Promise((_resolve, reject) => (timeout = setTimeout(reject, time, exception))),
38
+ ]).finally(() => clearTimeout(timeout));
39
+ }
9
40
  if (import.meta.vitest) {
10
- const { it, expect } = import.meta.vitest;
11
- it('should get date timestamp in seconds', () => {
12
- const date = new Date(2022, 1, 16, 17, 32, 11, 168);
13
- const result = dateTimestamp(date);
14
- const expected = Math.floor(date.getTime() / 1000);
15
- expect(result).toEqual(expected);
41
+ const { describe, it, expect, vi } = import.meta.vitest;
42
+ describe("Date and timestamp utilities", () => {
43
+ describe("formatTimestampSecondsAsLocal", () => {
44
+ it("converts timestamp to local format", () => {
45
+ const result = formatTimestampSecondsAsLocal(BigInt("1672531200")); // Jan 1, 2023 12:00 AM
46
+ expect(result).toBe("01/01/2023 12:00 AM");
47
+ });
48
+ });
49
+ describe("timestampSecondsToUTCTimestamp", () => {
50
+ it("converts bigint timestamp to UTCTimestamp", () => {
51
+ const result = timestampSecondsToUTCTimestamp(BigInt("1672531200"));
52
+ expect(result).toBe(1672531200);
53
+ });
54
+ });
55
+ });
56
+ describe("promiseTimeout", () => {
57
+ it("resolves when promise resolves before timeout", async () => {
58
+ const testValue = "test";
59
+ const promise = Promise.resolve(testValue);
60
+ const result = await promiseTimeout(promise, 100, new Error("Timeout"));
61
+ expect(result).toBe(testValue);
62
+ });
63
+ it("rejects when promise times out", async () => {
64
+ const promise = new Promise((resolve) => setTimeout(resolve, 200));
65
+ const exception = new Error("Timeout");
66
+ await expect(promiseTimeout(promise, 100, exception)).rejects.toThrow(exception);
67
+ });
68
+ it("rejects when original promise rejects", async () => {
69
+ const error = new Error("Original rejection");
70
+ const promise = Promise.reject(error);
71
+ await expect(promiseTimeout(promise, 100, new Error("Timeout"))).rejects.toThrow(error);
72
+ });
73
+ it("clears timeout after promise resolution", async () => {
74
+ vi.spyOn(global, "clearTimeout");
75
+ const promise = Promise.resolve("test");
76
+ await promiseTimeout(promise, 100, new Error("Timeout"));
77
+ expect(clearTimeout).toHaveBeenCalled();
78
+ });
79
+ it("clears timeout after promise rejection", async () => {
80
+ vi.spyOn(global, "clearTimeout");
81
+ const promise = Promise.reject(new Error("Original rejection"));
82
+ try {
83
+ await promiseTimeout(promise, 100, new Error("Timeout"));
84
+ }
85
+ catch {
86
+ // Ignore the error
87
+ }
88
+ expect(clearTimeout).toHaveBeenCalled();
89
+ });
90
+ });
91
+ describe("dateTimestamp", () => {
92
+ it("should get date timestamp in seconds", () => {
93
+ const date = new Date(2022, 1, 16, 17, 32, 11, 168);
94
+ const result = dateTimestamp(date);
95
+ const expected = Math.floor(date.getTime() / 1000);
96
+ expect(result).toEqual(expected);
97
+ });
16
98
  });
17
99
  }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * The maximum number of fractional (post-decimal-point) digits that the
3
+ * underlying `Float` decimal parser accepts without precision loss. A value
4
+ * with more than this many decimal places is rejected client-side with a
5
+ * friendly message.
6
+ */
7
+ export declare const MAX_DECIMALS = 67;
8
+ export interface AmountDecimalsValidation {
9
+ isValid: boolean;
10
+ errorMessage: string | null;
11
+ }
12
+ /**
13
+ * Counts the number of fractional digits in a plain decimal string.
14
+ *
15
+ * Returns `null` when the input is not a plain decimal number (empty, or
16
+ * containing anything other than an optional leading sign and digits around a
17
+ * single decimal point), so callers defer to the underlying parser for those
18
+ * cases.
19
+ *
20
+ * @param value The raw string entered by the user.
21
+ */
22
+ export declare function countDecimalPlaces(value: string): number | null;
23
+ /**
24
+ * Validates that a raw amount string does not exceed the maximum supported
25
+ * number of decimal places.
26
+ *
27
+ * @param value The raw string entered by the user.
28
+ * @returns Validation result with a friendly error message when invalid.
29
+ */
30
+ export declare function validateAmount(value: string): AmountDecimalsValidation;
@@ -0,0 +1,53 @@
1
+ /**
2
+ * The maximum number of fractional (post-decimal-point) digits that the
3
+ * underlying `Float` decimal parser accepts without precision loss. A value
4
+ * with more than this many decimal places is rejected client-side with a
5
+ * friendly message.
6
+ */
7
+ export const MAX_DECIMALS = 67;
8
+ /**
9
+ * Counts the number of fractional digits in a plain decimal string.
10
+ *
11
+ * Returns `null` when the input is not a plain decimal number (empty, or
12
+ * containing anything other than an optional leading sign and digits around a
13
+ * single decimal point), so callers defer to the underlying parser for those
14
+ * cases.
15
+ *
16
+ * @param value The raw string entered by the user.
17
+ */
18
+ export function countDecimalPlaces(value) {
19
+ const trimmed = value.trim();
20
+ if (trimmed === "")
21
+ return null;
22
+ // Optional sign, integer part, optional fractional part. Plain decimal only
23
+ // (no scientific notation, no thousands separators) to match the inputs the
24
+ // `Float` decimal parser accepts.
25
+ const match = /^[+-]?(\d*)(?:\.(\d*))?$/.exec(trimmed);
26
+ if (!match)
27
+ return null;
28
+ const [, integerPart, fractionalPart] = match;
29
+ // Reject strings with no digits at all (e.g. ".", "+", "-").
30
+ if ((integerPart ?? "") === "" && (fractionalPart ?? "") === "")
31
+ return null;
32
+ return (fractionalPart ?? "").length;
33
+ }
34
+ /**
35
+ * Validates that a raw amount string does not exceed the maximum supported
36
+ * number of decimal places.
37
+ *
38
+ * @param value The raw string entered by the user.
39
+ * @returns Validation result with a friendly error message when invalid.
40
+ */
41
+ export function validateAmount(value) {
42
+ const decimals = countDecimalPlaces(value);
43
+ if (decimals !== null && decimals > MAX_DECIMALS) {
44
+ return {
45
+ isValid: false,
46
+ errorMessage: `Too many decimal places. A maximum of ${MAX_DECIMALS} decimal places is allowed.`,
47
+ };
48
+ }
49
+ return {
50
+ isValid: true,
51
+ errorMessage: null,
52
+ };
53
+ }
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Creates a writable Svelte store that persists its value to localStorage.
3
+ *
4
+ * @template T - The type of the value stored in the store
5
+ * @param {string} key - The localStorage key used to store the value
6
+ * @param {T} defaultValue - The default value to use when no value is found in localStorage
7
+ * @param {function(T): string} serialize - Function to convert the store value to a string for storage
8
+ * @param {function(string): T} deserialize - Function to convert the stored string back to the original type
9
+ * @returns {import('svelte/store').Writable<T>} A writable store that automatically syncs with localStorage
10
+ *
11
+ * @example
12
+ * // Create a store for a boolean value
13
+ * const darkMode = cachedWritableStore(
14
+ * 'darkMode',
15
+ * false,
16
+ * value => JSON.stringify(value),
17
+ * str => JSON.parse(str)
18
+ * );
19
+ *
20
+ * // Create a store for a complex object
21
+ * const userPreferences = cachedWritableStore(
22
+ * 'userPrefs',
23
+ * { theme: 'light', fontSize: 14 },
24
+ * value => JSON.stringify(value),
25
+ * str => JSON.parse(str)
26
+ * );
27
+ */
28
+ export declare function cachedWritableStore<T>(key: string, defaultValue: T, serialize: (value: T) => string, deserialize: (serialized: string) => T): import("svelte/store").Writable<T>;
29
+ export declare const cachedWritableString: (key: string, defaultValue?: string) => import("svelte/store").Writable<string>;
30
+ export declare const cachedWritableInt: (key: string, defaultValue?: number) => import("svelte/store").Writable<number>;
31
+ /**
32
+ * Creates a writable store that can hold an optional value of type T and persists to localStorage.
33
+ *
34
+ * @template T - The type of the value stored
35
+ * @param {string} key - The localStorage key to use for persistence
36
+ * @param {T | undefined} defaultValue - The default value if nothing is found in localStorage
37
+ * @param {function} serialize - Function to convert the value to a string for storage
38
+ * @param {function} deserialize - Function to convert the stored string back to a value
39
+ * @returns A writable store that persists to localStorage and can hold undefined values
40
+ */
41
+ export declare const cachedWritableOptionalStore: <T>(key: string, defaultValue: T | undefined, serialize: (value: T) => string, deserialize: (serialized: string) => T) => import("svelte/store").Writable<T | undefined>;
42
+ /**
43
+ * Creates a writable store that can hold an optional number value and persists to localStorage.
44
+ *
45
+ * @param {string} key - The localStorage key to use for persistence
46
+ * @param {number | undefined} defaultValue - The default value if nothing is found in localStorage
47
+ * @returns A writable store that persists to localStorage and can hold an optional number
48
+ */
49
+ export declare const cachedWritableIntOptional: (key: string, defaultValue?: number | undefined) => import("svelte/store").Writable<number | undefined>;
50
+ /**
51
+ * Creates a writable store that can hold an optional string value and persists to localStorage.
52
+ *
53
+ * @param {string} key - The localStorage key to use for persistence
54
+ * @param {string | undefined} defaultValue - The default value if nothing is found in localStorage
55
+ * @returns A writable store that persists to localStorage and can hold an optional string
56
+ */
57
+ export declare const cachedWritableStringOptional: (key: string, defaultValue?: string | undefined) => import("svelte/store").Writable<string | undefined>;
@@ -0,0 +1,93 @@
1
+ import { writable } from "svelte/store";
2
+ /**
3
+ * Creates a writable Svelte store that persists its value to localStorage.
4
+ *
5
+ * @template T - The type of the value stored in the store
6
+ * @param {string} key - The localStorage key used to store the value
7
+ * @param {T} defaultValue - The default value to use when no value is found in localStorage
8
+ * @param {function(T): string} serialize - Function to convert the store value to a string for storage
9
+ * @param {function(string): T} deserialize - Function to convert the stored string back to the original type
10
+ * @returns {import('svelte/store').Writable<T>} A writable store that automatically syncs with localStorage
11
+ *
12
+ * @example
13
+ * // Create a store for a boolean value
14
+ * const darkMode = cachedWritableStore(
15
+ * 'darkMode',
16
+ * false,
17
+ * value => JSON.stringify(value),
18
+ * str => JSON.parse(str)
19
+ * );
20
+ *
21
+ * // Create a store for a complex object
22
+ * const userPreferences = cachedWritableStore(
23
+ * 'userPrefs',
24
+ * { theme: 'light', fontSize: 14 },
25
+ * value => JSON.stringify(value),
26
+ * str => JSON.parse(str)
27
+ * );
28
+ */
29
+ export function cachedWritableStore(key, defaultValue, serialize, deserialize) {
30
+ const getCache = () => {
31
+ try {
32
+ const cached = localStorage.getItem(key);
33
+ return cached !== null ? deserialize(cached) : defaultValue;
34
+ }
35
+ catch {
36
+ return defaultValue;
37
+ }
38
+ };
39
+ const setCache = (value) => {
40
+ try {
41
+ if (value !== undefined) {
42
+ localStorage.setItem(key, serialize(value));
43
+ }
44
+ else {
45
+ localStorage.removeItem(key);
46
+ }
47
+ }
48
+ catch {
49
+ // Silently ignore localStorage errors to allow the application to function
50
+ // without persistence in environments where localStorage is unavailable
51
+ }
52
+ };
53
+ const data = writable(getCache());
54
+ data.subscribe((value) => {
55
+ setCache(value);
56
+ });
57
+ return data;
58
+ }
59
+ export const cachedWritableString = (key, defaultValue = "") => cachedWritableStore(key, defaultValue, (v) => v, (v) => v);
60
+ export const cachedWritableInt = (key, defaultValue = 0) => cachedWritableStore(key, defaultValue, (v) => v.toString(), (v) => {
61
+ const parsed = Number.parseInt(v);
62
+ return isNaN(parsed) ? defaultValue : parsed;
63
+ });
64
+ /**
65
+ * Creates a writable store that can hold an optional value of type T and persists to localStorage.
66
+ *
67
+ * @template T - The type of the value stored
68
+ * @param {string} key - The localStorage key to use for persistence
69
+ * @param {T | undefined} defaultValue - The default value if nothing is found in localStorage
70
+ * @param {function} serialize - Function to convert the value to a string for storage
71
+ * @param {function} deserialize - Function to convert the stored string back to a value
72
+ * @returns A writable store that persists to localStorage and can hold undefined values
73
+ */
74
+ export const cachedWritableOptionalStore = (key, defaultValue = undefined, serialize, deserialize) => cachedWritableStore(key, defaultValue, (v) => (v !== undefined ? serialize(v) : ""), (v) => (v !== "" ? deserialize(v) : undefined));
75
+ /**
76
+ * Creates a writable store that can hold an optional number value and persists to localStorage.
77
+ *
78
+ * @param {string} key - The localStorage key to use for persistence
79
+ * @param {number | undefined} defaultValue - The default value if nothing is found in localStorage
80
+ * @returns A writable store that persists to localStorage and can hold an optional number
81
+ */
82
+ export const cachedWritableIntOptional = (key, defaultValue = undefined) => cachedWritableOptionalStore(key, defaultValue, (v) => v.toString(), (v) => {
83
+ const parsed = Number.parseInt(v);
84
+ return isNaN(parsed) ? (defaultValue ?? 0) : parsed;
85
+ });
86
+ /**
87
+ * Creates a writable store that can hold an optional string value and persists to localStorage.
88
+ *
89
+ * @param {string} key - The localStorage key to use for persistence
90
+ * @param {string | undefined} defaultValue - The default value if nothing is found in localStorage
91
+ * @returns A writable store that persists to localStorage and can hold an optional string
92
+ */
93
+ export const cachedWritableStringOptional = (key, defaultValue = undefined) => cachedWritableOptionalStore(key, defaultValue, (v) => v, (v) => v);
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Global "scrub" toggle used for safe screenshotting of the GUI.
3
+ *
4
+ * When `true`, every {@link Sensitive} region (which wraps all rendered
5
+ * addresses and transaction hashes via the `Hash` component) is masked with an
6
+ * opaque grey box so that sharing a screenshot does not leak addresses/hashes.
7
+ *
8
+ * This is purely presentational: it never changes any on-chain data or the
9
+ * underlying values held in memory, only how they are displayed.
10
+ *
11
+ * The value is persisted to localStorage under the `scrub` key so the masked
12
+ * state survives reloads while a user is preparing screenshots.
13
+ */
14
+ export declare const scrub: import("svelte/store").Writable<boolean>;
@@ -0,0 +1,22 @@
1
+ import { cachedWritableStore } from "./cachedWritableStore";
2
+ /**
3
+ * Global "scrub" toggle used for safe screenshotting of the GUI.
4
+ *
5
+ * When `true`, every {@link Sensitive} region (which wraps all rendered
6
+ * addresses and transaction hashes via the `Hash` component) is masked with an
7
+ * opaque grey box so that sharing a screenshot does not leak addresses/hashes.
8
+ *
9
+ * This is purely presentational: it never changes any on-chain data or the
10
+ * underlying values held in memory, only how they are displayed.
11
+ *
12
+ * The value is persisted to localStorage under the `scrub` key so the masked
13
+ * state survives reloads while a user is preparing screenshots.
14
+ */
15
+ export const scrub = cachedWritableStore("scrub", false, (value) => JSON.stringify(value), (serialized) => {
16
+ try {
17
+ return JSON.parse(serialized) === true;
18
+ }
19
+ catch {
20
+ return false;
21
+ }
22
+ });
@@ -1,6 +1,6 @@
1
- import * as matchers from '@testing-library/jest-dom/matchers';
1
+ import * as matchers from "@testing-library/jest-dom/matchers";
2
2
  export declare const expect: import("vitest").ExpectStatic;
3
- declare module 'vitest' {
3
+ declare module "vitest" {
4
4
  interface JestAssertion<T = any> extends matchers.TestingLibraryMatchers<ReturnType<typeof expect.stringContaining>, T> {
5
5
  }
6
6
  }
@@ -1,4 +1,4 @@
1
- import { expect as vitestExpect } from 'vitest';
2
- import * as matchers from '@testing-library/jest-dom/matchers';
1
+ import { expect as vitestExpect } from "vitest";
2
+ import * as matchers from "@testing-library/jest-dom/matchers";
3
3
  vitestExpect.extend(matchers);
4
4
  export const expect = vitestExpect;
@@ -0,0 +1,3 @@
1
+ import type { Readable } from "svelte/store";
2
+ import type { Hex } from "viem";
3
+ export type Account = Readable<Hex | null>;
@@ -1,19 +1,12 @@
1
- import type { Readable, Writable } from 'svelte/store';
2
- import type { ConfigSource, OrderbookConfigSource } from '@rainlanguage/orderbook/js_api';
1
+ import type { Writable } from "svelte/store";
2
+ import type { Address, Hex } from "@rainlanguage/raindex";
3
3
  export interface AppStoresInterface {
4
- settings: Writable<ConfigSource | undefined>;
5
- activeSubgraphs: Writable<Record<string, string>>;
6
- accounts: Readable<Record<string, string>>;
7
- activeAccountsItems: Writable<Record<string, string>>;
8
- activeOrderStatus: Writable<boolean | undefined>;
9
- orderHash: Writable<string>;
4
+ selectedChainIds: Writable<number[]>;
5
+ showInactiveOrders: Writable<boolean>;
6
+ orderHash: Writable<Hex>;
10
7
  hideZeroBalanceVaults: Writable<boolean>;
11
- activeNetworkRef: Writable<string | undefined>;
12
- activeOrderbookRef: Writable<string | undefined>;
13
- activeOrderbook: Readable<OrderbookConfigSource | undefined>;
14
- subgraphUrl: Readable<string | undefined>;
15
- activeAccounts: Readable<{
16
- [k: string]: string;
17
- }>;
18
- showMyItemsOnly: Writable<boolean>;
8
+ hideInactiveOrdersVaults: Writable<boolean>;
9
+ activeTokens: Writable<Address[]>;
10
+ activeRaindexAddresses: Writable<Address[]>;
11
+ ownerFilter: Writable<Address>;
19
12
  }
@@ -1,20 +1,32 @@
1
- import type { SgOrder } from '@rainlanguage/orderbook/js_api';
2
- import type { DepositOrWithdrawArgs, OrderRemoveArgs, DeploymentArgs } from './transaction';
3
- export type DepositOrWithdrawModalProps = {
1
+ import type { Float, RaindexOrder, RaindexVault } from "@rainlanguage/raindex";
2
+ import type { VaultActionArgs } from "./transaction";
3
+ import type { Hex } from "viem";
4
+ export type VaultActionModalProps = {
4
5
  open: boolean;
5
- args: DepositOrWithdrawArgs;
6
- };
7
- export type OrderRemoveModalProps = {
8
- open: boolean;
9
- args: OrderRemoveArgs;
10
- };
11
- export type DeployModalProps = {
12
- open: boolean;
13
- args: DeploymentArgs;
6
+ args: VaultActionArgs;
7
+ onSubmit: (amount: Float) => void;
14
8
  };
15
9
  export type DisclaimerModalProps = {
16
10
  open: boolean;
17
11
  onAccept: () => void;
18
12
  };
19
- export type QuoteDebugModalHandler = (order: SgOrder, rpcUrl: string, orderbook: string, inputIOIndex: number, outputIOIndex: number, pair: string, blockNumber?: number) => void;
20
- export type DebugTradeModalHandler = (hash: string, rpcUrl: string) => void;
13
+ export type TransactionConfirmationProps = {
14
+ open: boolean;
15
+ modalTitle: string;
16
+ closeOnConfirm?: boolean;
17
+ args: {
18
+ chainId: number;
19
+ toAddress: Hex;
20
+ onConfirm: (hash: Hex) => void;
21
+ entity?: RaindexOrder | RaindexVault;
22
+ calldata: string;
23
+ };
24
+ };
25
+ export type QuoteDebugModalHandler = (order: RaindexOrder, inputIOIndex: number, outputIOIndex: number, pair: string, blockNumber?: bigint) => void;
26
+ export type DebugTradeModalHandler = (hash: string, rpcUrls: string[]) => void;
27
+ export type HandleTransactionConfirmationModal = (props: TransactionConfirmationProps, options?: {
28
+ timeout?: number;
29
+ }) => Promise<{
30
+ success: boolean;
31
+ hash?: string;
32
+ }>;
@@ -0,0 +1,10 @@
1
+ import type { NameAndDescriptionCfg } from "@rainlanguage/raindex";
2
+ export type ValidOrderDetail = {
3
+ details: NameAndDescriptionCfg;
4
+ name: string;
5
+ dotrain: string;
6
+ };
7
+ export type InvalidOrderDetail = {
8
+ name: string;
9
+ error: string;
10
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ export interface ToastProps {
2
+ message: string;
3
+ detail?: string;
4
+ type: "success" | "error" | "warning" | "info";
5
+ color: "green" | "red" | "yellow" | "blue";
6
+ links?: ToastLink[];
7
+ }
8
+ export type ToastLink = {
9
+ link: string;
10
+ label: string;
11
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { AccountBalance } from "@rainlanguage/raindex";
2
+ export interface TokenBalance {
3
+ value: AccountBalance;
4
+ loading: boolean;
5
+ error: string;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,26 +1,71 @@
1
- import type { ExtendedApprovalCalldata } from '../stores/transactionStore';
2
- import type { Hex } from 'viem';
3
- import type { DepositAndAddOrderCalldataResult, SgOrder, SgVault } from '@rainlanguage/orderbook/js_api';
4
- export type DeploymentArgs = {
5
- approvals: ExtendedApprovalCalldata[];
6
- deploymentCalldata: DepositAndAddOrderCalldataResult;
7
- orderbookAddress: Hex;
8
- chainId: number;
9
- subgraphUrl: string;
10
- network: string;
1
+ import type { Hex } from "viem";
2
+ import type { RaindexVault } from "@rainlanguage/raindex";
3
+ import type { ToastLink } from "./toast";
4
+ import type { TransactionStoreState } from "../models/Transaction";
5
+ /**
6
+ * Context provided to the indexing function, allowing it to update
7
+ * transaction state and trigger callbacks without TransactionStore
8
+ * knowing the specifics of what's being indexed.
9
+ */
10
+ export type IndexingContext = {
11
+ /** Update the transaction state (status, errorDetails, links) */
12
+ updateState: (partialState: Partial<TransactionStoreState>) => void;
13
+ /** Callback to invoke on successful indexing */
14
+ onSuccess: () => void;
15
+ /** Callback to invoke on indexing failure */
16
+ onError: () => void;
17
+ /** Current toast links (useful for prepending new links) */
18
+ links: ToastLink[];
11
19
  };
12
- export type DepositOrWithdrawArgs = {
13
- vault: SgVault;
14
- onDepositOrWithdraw: () => void;
15
- action: 'deposit' | 'withdraw';
16
- chainId: number;
17
- rpcUrl: string;
18
- subgraphUrl: string;
20
+ /**
21
+ * Generic indexing function type. TransactionStore calls this function
22
+ * after the transaction receipt is confirmed, without knowing what
23
+ * type of indexing is being performed (SDK-based, subgraph, etc.).
24
+ */
25
+ export type AwaitIndexingFn = (ctx: IndexingContext) => Promise<void>;
26
+ export type VaultActionArgs = {
27
+ vault: RaindexVault;
28
+ onDeposit?: () => void;
29
+ account: Hex;
19
30
  };
20
- export type OrderRemoveArgs = {
21
- order: SgOrder;
22
- onRemove: () => void;
31
+ export declare enum TransactionName {
32
+ REMOVAL = "Order Removal",
33
+ WITHDRAWAL = "Vault Withdrawal",
34
+ WITHDRAWAL_MULTIPLE = "Vaults Withdrawal",
35
+ APPROVAL = "Token Approval",
36
+ DEPOSIT = "Vault Deposit",
37
+ TAKE_ORDER = "Take Order"
38
+ }
39
+ export declare enum TransactionStatusMessage {
40
+ IDLE = "Idle",
41
+ STARTING = "Starting transaction...",
42
+ CHECKING_ALLOWANCE = "Checking your allowance...",
43
+ PENDING_WALLET = "Waiting for wallet confirmation...",
44
+ PENDING_APPROVAL = "Approving token spend...",
45
+ PENDING_RECEIPT = "Waiting for transaction receipt...",
46
+ PENDING_DEPLOYMENT = "Deploying your order...",
47
+ PENDING_WITHDRAWAL = "Withdrawing tokens...",
48
+ PENDING_DEPOSIT = "Depositing tokens...",
49
+ PENDING_SUBGRAPH = "Awaiting transaction indexing...",
50
+ SUCCESS = "Transaction confirmed",
51
+ ERROR = "Something went wrong"
52
+ }
53
+ export declare enum TransactionStoreErrorMessage {
54
+ SWITCH_CHAIN_FAILED = "Failed to switch chain.",
55
+ SUBGRAPH_TIMEOUT_ERROR = "The subgraph took too long to respond. Your transaction may still be processing.",
56
+ SUBGRAPH_FAILED = "Failed to index transaction.",
57
+ RECEIPT_FAILED = "Failed to get transaction receipt."
58
+ }
59
+ export type InternalTransactionArgs = {
23
60
  chainId: number;
24
- orderbookAddress: Hex;
25
- subgraphUrl: string;
61
+ txHash: Hex;
62
+ queryKey: string;
63
+ };
64
+ export type TransactionArgs = InternalTransactionArgs & {
65
+ name: string;
66
+ errorMessage: string;
67
+ successMessage: string;
68
+ queryKey: string;
69
+ toastLinks: ToastLink[];
70
+ awaitIndexingFn?: AwaitIndexingFn;
26
71
  };
@@ -1 +1,31 @@
1
- export {};
1
+ export var TransactionName;
2
+ (function (TransactionName) {
3
+ TransactionName["REMOVAL"] = "Order Removal";
4
+ TransactionName["WITHDRAWAL"] = "Vault Withdrawal";
5
+ TransactionName["WITHDRAWAL_MULTIPLE"] = "Vaults Withdrawal";
6
+ TransactionName["APPROVAL"] = "Token Approval";
7
+ TransactionName["DEPOSIT"] = "Vault Deposit";
8
+ TransactionName["TAKE_ORDER"] = "Take Order";
9
+ })(TransactionName || (TransactionName = {}));
10
+ export var TransactionStatusMessage;
11
+ (function (TransactionStatusMessage) {
12
+ TransactionStatusMessage["IDLE"] = "Idle";
13
+ TransactionStatusMessage["STARTING"] = "Starting transaction...";
14
+ TransactionStatusMessage["CHECKING_ALLOWANCE"] = "Checking your allowance...";
15
+ TransactionStatusMessage["PENDING_WALLET"] = "Waiting for wallet confirmation...";
16
+ TransactionStatusMessage["PENDING_APPROVAL"] = "Approving token spend...";
17
+ TransactionStatusMessage["PENDING_RECEIPT"] = "Waiting for transaction receipt...";
18
+ TransactionStatusMessage["PENDING_DEPLOYMENT"] = "Deploying your order...";
19
+ TransactionStatusMessage["PENDING_WITHDRAWAL"] = "Withdrawing tokens...";
20
+ TransactionStatusMessage["PENDING_DEPOSIT"] = "Depositing tokens...";
21
+ TransactionStatusMessage["PENDING_SUBGRAPH"] = "Awaiting transaction indexing...";
22
+ TransactionStatusMessage["SUCCESS"] = "Transaction confirmed";
23
+ TransactionStatusMessage["ERROR"] = "Something went wrong";
24
+ })(TransactionStatusMessage || (TransactionStatusMessage = {}));
25
+ export var TransactionStoreErrorMessage;
26
+ (function (TransactionStoreErrorMessage) {
27
+ TransactionStoreErrorMessage["SWITCH_CHAIN_FAILED"] = "Failed to switch chain.";
28
+ TransactionStoreErrorMessage["SUBGRAPH_TIMEOUT_ERROR"] = "The subgraph took too long to respond. Your transaction may still be processing.";
29
+ TransactionStoreErrorMessage["SUBGRAPH_FAILED"] = "Failed to index transaction.";
30
+ TransactionStoreErrorMessage["RECEIPT_FAILED"] = "Failed to get transaction receipt.";
31
+ })(TransactionStoreErrorMessage || (TransactionStoreErrorMessage = {}));