@rainlanguage/ui-components 0.0.1-alpha.237 → 0.0.1-alpha.239

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 (176) hide show
  1. package/README.md +14 -6
  2. package/dist/__fixtures__/settings.yaml +18 -20
  3. package/dist/__mocks__/MockCodeMirrorEditor.svelte +17 -0
  4. package/dist/__mocks__/MockCodeMirrorEditor.svelte.d.ts +21 -0
  5. package/dist/__mocks__/MockComponent.js +1 -1
  6. package/dist/__mocks__/MockComponent.svelte +7 -3
  7. package/dist/__mocks__/MockComponent.svelte.d.ts +1 -0
  8. package/dist/__mocks__/mockWeb3Config.d.ts +1 -1
  9. package/dist/__mocks__/mockWeb3Config.js +10 -7
  10. package/dist/__mocks__/queries.js +9 -9
  11. package/dist/__mocks__/stores.d.ts +4 -4
  12. package/dist/__mocks__/stores.js +40 -40
  13. package/dist/app.css +3 -3
  14. package/dist/components/ButtonDarkMode.svelte +7 -1
  15. package/dist/components/ButtonScrub.svelte +22 -0
  16. package/dist/components/ButtonScrub.svelte.d.ts +25 -0
  17. package/dist/components/ButtonVaultLink.svelte +3 -2
  18. package/dist/components/ButtonVaultLink.svelte.d.ts +2 -2
  19. package/dist/components/CodeMirrorRainlang.svelte +19 -2
  20. package/dist/components/CodeMirrorRainlang.svelte.d.ts +2 -1
  21. package/dist/components/Hash.svelte +3 -2
  22. package/dist/components/{ListViewOrderbookFilters.svelte → ListViewRaindexFilters.svelte} +7 -7
  23. package/dist/components/{ListViewOrderbookFilters.svelte.d.ts → ListViewRaindexFilters.svelte.d.ts} +7 -7
  24. package/dist/components/LocalDbStatusBadge.svelte.d.ts +1 -1
  25. package/dist/components/LocalDbStatusCard.svelte +7 -4
  26. package/dist/components/LocalDbStatusCard.svelte.d.ts +2 -2
  27. package/dist/components/LocalDbStatusModal.svelte +16 -14
  28. package/dist/components/LocalDbStatusModal.svelte.d.ts +2 -2
  29. package/dist/components/OrderOrVaultHash.svelte +2 -2
  30. package/dist/components/OrderOrVaultHash.svelte.d.ts +2 -2
  31. package/dist/components/Sensitive.svelte +16 -0
  32. package/dist/components/Sensitive.svelte.d.ts +28 -0
  33. package/dist/components/TanstackAppTable.svelte +146 -87
  34. package/dist/components/TanstackAppTable.svelte.d.ts +1 -1
  35. package/dist/components/VaultBalanceChangeTypeFilter.svelte +1 -1
  36. package/dist/components/VaultBalanceChangeTypeFilter.svelte.d.ts +1 -1
  37. package/dist/components/VaultCard.svelte +1 -1
  38. package/dist/components/VaultCard.svelte.d.ts +1 -1
  39. package/dist/components/charts/OrderTradesChart.svelte +116 -97
  40. package/dist/components/charts/OrderTradesChart.svelte.d.ts +2 -2
  41. package/dist/components/charts/transformAndSortData.d.ts +1 -1
  42. package/dist/components/charts/transformAndSortData.js +19 -19
  43. package/dist/components/deployment/DeploymentSteps.svelte +5 -2
  44. package/dist/components/deployment/DeploymentSteps.svelte.d.ts +1 -1
  45. package/dist/components/deployment/DeploymentsSection.svelte.d.ts +1 -1
  46. package/dist/components/deployment/DepositInput.svelte +1 -1
  47. package/dist/components/deployment/DepositInput.svelte.d.ts +1 -1
  48. package/dist/components/deployment/FieldDefinitionInput.svelte +1 -1
  49. package/dist/components/deployment/FieldDefinitionInput.svelte.d.ts +1 -1
  50. package/dist/components/deployment/OrderPage.svelte.d.ts +1 -1
  51. package/dist/components/deployment/SelectToken.svelte.d.ts +1 -1
  52. package/dist/components/deployment/TokenIOInput.svelte +1 -1
  53. package/dist/components/deployment/TokenIOInput.svelte.d.ts +1 -1
  54. package/dist/components/deployment/TokenSelectionModal.svelte.d.ts +1 -1
  55. package/dist/components/detail/OrderDetail.svelte +12 -6
  56. package/dist/components/detail/OrderDetail.svelte.d.ts +2 -2
  57. package/dist/components/detail/TanstackOrderQuote.svelte +22 -0
  58. package/dist/components/detail/TanstackOrderQuote.svelte.d.ts +1 -1
  59. package/dist/components/detail/VaultDetail.svelte +12 -10
  60. package/dist/components/detail/VaultDetail.svelte.d.ts +2 -2
  61. package/dist/components/dropdown/{DropdownOrderbooksFilter.svelte → DropdownRaindexesFilter.svelte} +54 -54
  62. package/dist/components/dropdown/DropdownRaindexesFilter.svelte.d.ts +25 -0
  63. package/dist/components/dropdown/DropdownTokensFilter.svelte.d.ts +1 -1
  64. package/dist/components/icon/Refresh.svelte +2 -1
  65. package/dist/components/icon/Refresh.svelte.d.ts +1 -0
  66. package/dist/components/input/InputTokenAmount.svelte +16 -1
  67. package/dist/components/input/InputTokenAmount.svelte.d.ts +1 -1
  68. package/dist/components/tables/OrderTradesListTable.svelte +113 -98
  69. package/dist/components/tables/OrderTradesListTable.svelte.d.ts +1 -1
  70. package/dist/components/tables/OrderVaultsVolTable.svelte +1 -1
  71. package/dist/components/tables/OrderVaultsVolTable.svelte.d.ts +1 -1
  72. package/dist/components/tables/OrdersListTable.svelte +19 -17
  73. package/dist/components/tables/OrdersListTable.svelte.d.ts +1 -1
  74. package/dist/components/tables/VaultBalanceChangesTable.svelte +1 -1
  75. package/dist/components/tables/VaultBalanceChangesTable.svelte.d.ts +1 -1
  76. package/dist/components/tables/VaultsListTable.svelte +24 -21
  77. package/dist/components/tables/VaultsListTable.svelte.d.ts +2 -2
  78. package/dist/components/transactions/FixedBottomTransaction.svelte +1 -0
  79. package/dist/components/transactions/getStatusEmoji.d.ts +1 -1
  80. package/dist/components/transactions/getStatusEmoji.js +13 -13
  81. package/dist/consts.js +1 -1
  82. package/dist/errors/DeploymentStepsError.js +3 -3
  83. package/dist/errors/index.d.ts +1 -1
  84. package/dist/errors/index.js +1 -1
  85. package/dist/hooks/useLocalDb.d.ts +1 -1
  86. package/dist/hooks/useLocalDb.js +3 -3
  87. package/dist/hooks/useRaindexClient.d.ts +1 -1
  88. package/dist/hooks/useRaindexClient.js +4 -4
  89. package/dist/hooks/useRaindexOrderBuilder.d.ts +1 -1
  90. package/dist/hooks/useRaindexOrderBuilder.js +4 -4
  91. package/dist/index.d.ts +122 -114
  92. package/dist/index.js +115 -109
  93. package/dist/models/Transaction.d.ts +4 -4
  94. package/dist/models/Transaction.js +9 -9
  95. package/dist/providers/RaindexClientProvider.svelte +1 -1
  96. package/dist/providers/RaindexClientProvider.svelte.d.ts +1 -1
  97. package/dist/providers/RaindexOrderBuilderProvider.svelte +1 -1
  98. package/dist/providers/RaindexOrderBuilderProvider.svelte.d.ts +1 -1
  99. package/dist/providers/dotrainRegistry/DotrainRegistryProvider.svelte.d.ts +1 -1
  100. package/dist/providers/dotrainRegistry/context.d.ts +2 -2
  101. package/dist/providers/dotrainRegistry/context.js +13 -10
  102. package/dist/providers/dotrainRegistry/useDotrainRegistry.d.ts +1 -1
  103. package/dist/providers/dotrainRegistry/useDotrainRegistry.js +8 -8
  104. package/dist/providers/registry/RegistryManager.js +8 -7
  105. package/dist/providers/registry/context.d.ts +1 -1
  106. package/dist/providers/registry/context.js +9 -9
  107. package/dist/providers/registry/useRegistry.d.ts +1 -1
  108. package/dist/providers/registry/useRegistry.js +5 -5
  109. package/dist/providers/toasts/context.d.ts +2 -2
  110. package/dist/providers/toasts/context.js +4 -4
  111. package/dist/providers/toasts/useToasts.d.ts +1 -1
  112. package/dist/providers/toasts/useToasts.js +4 -4
  113. package/dist/providers/transactions/TransactionManager.d.ts +14 -15
  114. package/dist/providers/transactions/TransactionManager.js +107 -107
  115. package/dist/providers/transactions/context.d.ts +1 -1
  116. package/dist/providers/transactions/context.js +4 -4
  117. package/dist/providers/transactions/useTransactions.js +2 -2
  118. package/dist/providers/wallet/context.d.ts +1 -1
  119. package/dist/providers/wallet/context.js +11 -11
  120. package/dist/providers/wallet/useAccount.js +27 -27
  121. package/dist/queries/keys.js +10 -10
  122. package/dist/queries/queryClient.d.ts +1 -1
  123. package/dist/queries/queryClient.js +8 -8
  124. package/dist/services/awaitTransactionIndexing.d.ts +8 -8
  125. package/dist/services/awaitTransactionIndexing.js +10 -8
  126. package/dist/services/getExplorerLink.js +2 -2
  127. package/dist/services/handleShareChoices.d.ts +1 -1
  128. package/dist/services/handleShareChoices.js +4 -4
  129. package/dist/services/historicalOrderCharts.d.ts +2 -2
  130. package/dist/services/historicalOrderCharts.js +260 -201
  131. package/dist/services/index.d.ts +5 -3
  132. package/dist/services/index.js +3 -2
  133. package/dist/services/loadRegistryUrl.d.ts +1 -1
  134. package/dist/services/loadRegistryUrl.js +5 -5
  135. package/dist/services/pairTradesChartData.d.ts +2 -2
  136. package/dist/services/pairTradesChartData.js +28 -24
  137. package/dist/services/registry.d.ts +1 -1
  138. package/dist/services/registry.js +10 -10
  139. package/dist/services/time.d.ts +1 -1
  140. package/dist/services/time.js +35 -35
  141. package/dist/services/validateAmount.d.ts +30 -0
  142. package/dist/services/validateAmount.js +53 -0
  143. package/dist/storesGeneric/cachedWritableStore.d.ts +2 -2
  144. package/dist/storesGeneric/cachedWritableStore.js +3 -3
  145. package/dist/storesGeneric/scrub.d.ts +14 -0
  146. package/dist/storesGeneric/scrub.js +22 -0
  147. package/dist/test/matchers.d.ts +2 -2
  148. package/dist/test/matchers.js +2 -2
  149. package/dist/types/account.d.ts +2 -2
  150. package/dist/types/appStores.d.ts +3 -3
  151. package/dist/types/modal.d.ts +3 -3
  152. package/dist/types/order.d.ts +1 -1
  153. package/dist/types/toast.d.ts +2 -2
  154. package/dist/types/tokenBalance.d.ts +1 -1
  155. package/dist/types/transaction.d.ts +4 -4
  156. package/dist/utils/breadcrumbs.js +2 -2
  157. package/dist/utils/codeMirrorThemes.js +80 -74
  158. package/dist/utils/configHelpers.d.ts +1 -1
  159. package/dist/utils/configHelpers.js +6 -6
  160. package/dist/utils/constructHashLink.d.ts +3 -3
  161. package/dist/utils/constructHashLink.js +39 -37
  162. package/dist/utils/getNetworkName.js +5 -5
  163. package/dist/utils/hex.js +1 -1
  164. package/dist/utils/lightweightChartsThemes.d.ts +1 -1
  165. package/dist/utils/lightweightChartsThemes.js +11 -11
  166. package/dist/utils/localDbStatus.d.ts +26 -0
  167. package/dist/utils/localDbStatus.js +22 -0
  168. package/dist/utils/number.js +5 -3
  169. package/dist/utils/stripTrailingWhitespace.d.ts +16 -0
  170. package/dist/utils/stripTrailingWhitespace.js +22 -0
  171. package/dist/utils/tokens.d.ts +1 -1
  172. package/dist/utils/tokens.js +1 -1
  173. package/dist/utils/vaultBalanceChangeLabels.d.ts +1 -1
  174. package/dist/utils/vaultBalanceChangeLabels.js +11 -11
  175. package/package.json +89 -89
  176. package/dist/components/dropdown/DropdownOrderbooksFilter.svelte.d.ts +0 -25
@@ -1,9 +1,9 @@
1
1
  export function generateBreadcrumbs(path) {
2
- const crumbs = path.split('/');
2
+ const crumbs = path.split("/");
3
3
  return crumbs
4
4
  .map((c, i) => ({
5
5
  label: c,
6
- href: crumbs.slice(0, i + 1).join('/')
6
+ href: crumbs.slice(0, i + 1).join("/"),
7
7
  }))
8
8
  .slice(1, -1);
9
9
  }
@@ -1,86 +1,92 @@
1
- import { createTheme } from 'thememirror';
2
- import { tags } from '@lezer/highlight';
1
+ import { createTheme } from "thememirror";
2
+ import { tags } from "@lezer/highlight";
3
3
  // configured to resemble vscode default light theme
4
4
  export const lightCodeMirrorTheme = createTheme({
5
- variant: 'light',
5
+ variant: "light",
6
6
  settings: {
7
- background: '#ffffff',
8
- foreground: '#001080',
9
- caret: '#000000',
10
- selection: '#add6ff',
11
- lineHighlight: '#77777740',
12
- gutterBackground: '#eeeeee',
13
- gutterForeground: '#237893'
7
+ background: "#ffffff",
8
+ foreground: "#001080",
9
+ caret: "#000000",
10
+ selection: "#add6ff",
11
+ lineHighlight: "#77777740",
12
+ gutterBackground: "#eeeeee",
13
+ gutterForeground: "#237893",
14
14
  },
15
15
  styles: [
16
- { tag: tags.comment, color: '#008001' },
17
- { tag: tags.variableName, color: '#0070c1' },
18
- { tag: [tags.string, tags.special(tags.brace)], color: '#b55b00' },
19
- { tag: tags.number, color: '#00b97b' },
20
- { tag: tags.bool, color: '#0000ff' },
21
- { tag: tags.null, color: '#0000ff' },
22
- { tag: tags.unit, color: '#0000ff' },
23
- { tag: tags.keyword, color: '#af01db' },
24
- { tag: tags.operator, color: '#000000' },
25
- { tag: tags.className, color: '#257f99' },
26
- { tag: tags.meta, color: '#0950a9' },
27
- { tag: tags.definition(tags.typeName), color: '#257f99' },
28
- { tag: tags.angleBracket, color: '#213CF1' },
29
- { tag: tags.brace, color: '#213CF1' },
30
- { tag: tags.bracket, color: '#213CF1' },
31
- { tag: tags.squareBracket, color: '#213CF1' },
32
- { tag: tags.paren, color: '#213CF1' },
33
- { tag: tags.punctuation, color: '#464646' },
34
- { tag: tags.separator, color: '#464646' },
35
- { tag: tags.typeName, color: '#257f99' },
36
- { tag: tags.tagName, color: '#800000' },
37
- { tag: tags.attributeName, color: '#eb3d36' },
38
- { tag: tags.attributeValue, color: '#444444' },
39
- { tag: tags.content, color: '#b55b00' },
40
- { tag: [tags.propertyName, tags.definition(tags.propertyName)], color: '#0469ff' },
41
- { tag: tags.labelName, color: '#4fc4ff' },
42
- { tag: tags.deleted, color: '#cc0000' }
43
- ]
16
+ { tag: tags.comment, color: "#008001" },
17
+ { tag: tags.variableName, color: "#0070c1" },
18
+ { tag: [tags.string, tags.special(tags.brace)], color: "#b55b00" },
19
+ { tag: tags.number, color: "#00b97b" },
20
+ { tag: tags.bool, color: "#0000ff" },
21
+ { tag: tags.null, color: "#0000ff" },
22
+ { tag: tags.unit, color: "#0000ff" },
23
+ { tag: tags.keyword, color: "#af01db" },
24
+ { tag: tags.operator, color: "#000000" },
25
+ { tag: tags.className, color: "#257f99" },
26
+ { tag: tags.meta, color: "#0950a9" },
27
+ { tag: tags.definition(tags.typeName), color: "#257f99" },
28
+ { tag: tags.angleBracket, color: "#213CF1" },
29
+ { tag: tags.brace, color: "#213CF1" },
30
+ { tag: tags.bracket, color: "#213CF1" },
31
+ { tag: tags.squareBracket, color: "#213CF1" },
32
+ { tag: tags.paren, color: "#213CF1" },
33
+ { tag: tags.punctuation, color: "#464646" },
34
+ { tag: tags.separator, color: "#464646" },
35
+ { tag: tags.typeName, color: "#257f99" },
36
+ { tag: tags.tagName, color: "#800000" },
37
+ { tag: tags.attributeName, color: "#eb3d36" },
38
+ { tag: tags.attributeValue, color: "#444444" },
39
+ { tag: tags.content, color: "#b55b00" },
40
+ {
41
+ tag: [tags.propertyName, tags.definition(tags.propertyName)],
42
+ color: "#0469ff",
43
+ },
44
+ { tag: tags.labelName, color: "#4fc4ff" },
45
+ { tag: tags.deleted, color: "#cc0000" },
46
+ ],
44
47
  });
45
48
  // configured to resemble vscode default dark theme
46
49
  export const darkCodeMirrorTheme = createTheme({
47
- variant: 'dark',
50
+ variant: "dark",
48
51
  settings: {
49
- background: '#1e1e1e',
50
- foreground: '#d4d4d4',
51
- caret: '#d4d4d4',
52
- selection: '#ffffff',
53
- lineHighlight: '#99999940',
54
- gutterBackground: '#282828',
55
- gutterForeground: '#858585'
52
+ background: "#1e1e1e",
53
+ foreground: "#d4d4d4",
54
+ caret: "#d4d4d4",
55
+ selection: "#ffffff",
56
+ lineHighlight: "#99999940",
57
+ gutterBackground: "#282828",
58
+ gutterForeground: "#858585",
56
59
  },
57
60
  styles: [
58
- { tag: [tags.comment, tags.lineComment], color: '#6c9e57' },
59
- { tag: tags.variableName, color: '#9cdcfe' },
60
- { tag: [tags.string, tags.special(tags.brace)], color: '#ce9178' },
61
- { tag: tags.number, color: '#B6CFA9' },
62
- { tag: tags.bool, color: '#4fc4ff' },
63
- { tag: tags.null, color: '#4fc4ff' },
64
- { tag: tags.unit, color: '#608FC2' },
65
- { tag: tags.keyword, color: '#d18dcc' },
66
- { tag: tags.operator, color: '#d4d4d4' },
67
- { tag: tags.className, color: '#4dcab1' },
68
- { tag: tags.meta, color: '#608FC2' },
69
- { tag: tags.definition(tags.typeName), color: '#4fcfb5' },
70
- { tag: tags.angleBracket, color: '#F9D849' },
71
- { tag: tags.brace, color: '#F9D849' },
72
- { tag: tags.bracket, color: '#F9D849' },
73
- { tag: tags.squareBracket, color: '#F9D849' },
74
- { tag: tags.paren, color: '#F9D849' },
75
- { tag: tags.punctuation, color: '#d4d4d4' },
76
- { tag: tags.separator, color: '#d4d4d4' },
77
- { tag: tags.typeName, color: '#4ecdb4' },
78
- { tag: tags.tagName, color: '#59a3df' },
79
- { tag: tags.attributeName, color: '#ffffff' },
80
- { tag: tags.attributeValue, color: '#ffffff' },
81
- { tag: tags.content, color: '#ce9178' },
82
- { tag: [tags.propertyName, tags.definition(tags.propertyName)], color: '#608FC2' },
83
- { tag: tags.labelName, color: '#4fc4ff' },
84
- { tag: tags.deleted, color: '#c86464' }
85
- ]
61
+ { tag: [tags.comment, tags.lineComment], color: "#6c9e57" },
62
+ { tag: tags.variableName, color: "#9cdcfe" },
63
+ { tag: [tags.string, tags.special(tags.brace)], color: "#ce9178" },
64
+ { tag: tags.number, color: "#B6CFA9" },
65
+ { tag: tags.bool, color: "#4fc4ff" },
66
+ { tag: tags.null, color: "#4fc4ff" },
67
+ { tag: tags.unit, color: "#608FC2" },
68
+ { tag: tags.keyword, color: "#d18dcc" },
69
+ { tag: tags.operator, color: "#d4d4d4" },
70
+ { tag: tags.className, color: "#4dcab1" },
71
+ { tag: tags.meta, color: "#608FC2" },
72
+ { tag: tags.definition(tags.typeName), color: "#4fcfb5" },
73
+ { tag: tags.angleBracket, color: "#F9D849" },
74
+ { tag: tags.brace, color: "#F9D849" },
75
+ { tag: tags.bracket, color: "#F9D849" },
76
+ { tag: tags.squareBracket, color: "#F9D849" },
77
+ { tag: tags.paren, color: "#F9D849" },
78
+ { tag: tags.punctuation, color: "#d4d4d4" },
79
+ { tag: tags.separator, color: "#d4d4d4" },
80
+ { tag: tags.typeName, color: "#4ecdb4" },
81
+ { tag: tags.tagName, color: "#59a3df" },
82
+ { tag: tags.attributeName, color: "#ffffff" },
83
+ { tag: tags.attributeValue, color: "#ffffff" },
84
+ { tag: tags.content, color: "#ce9178" },
85
+ {
86
+ tag: [tags.propertyName, tags.definition(tags.propertyName)],
87
+ color: "#608FC2",
88
+ },
89
+ { tag: tags.labelName, color: "#4fc4ff" },
90
+ { tag: tags.deleted, color: "#c86464" },
91
+ ],
86
92
  });
@@ -1,4 +1,4 @@
1
- import type { AccountCfg } from '@rainlanguage/orderbook';
1
+ import type { AccountCfg } from "@rainlanguage/raindex";
2
2
  export declare function getAccountsAsOptions(accounts?: Map<string, AccountCfg>): {
3
3
  [k: string]: string;
4
4
  };
@@ -5,16 +5,16 @@ export function getAccountsAsOptions(accounts) {
5
5
  }
6
6
  if (import.meta.vitest) {
7
7
  const { expect, it, describe } = import.meta.vitest;
8
- describe('getAccountsAsOptions', () => {
9
- it('should return the correct accounts as options', () => {
8
+ describe("getAccountsAsOptions", () => {
9
+ it("should return the correct accounts as options", () => {
10
10
  const accounts = new Map([
11
- ['account1', { address: '0x1234567890abcdef', key: 'account1' }],
12
- ['account2', { address: '0xabcdef1234567890', key: 'account2' }]
11
+ ["account1", { address: "0x1234567890abcdef", key: "account1" }],
12
+ ["account2", { address: "0xabcdef1234567890", key: "account2" }],
13
13
  ]);
14
14
  const result = getAccountsAsOptions(accounts);
15
15
  expect(result).toEqual({
16
- account1: '0x1234567890abcdef',
17
- account2: '0xabcdef1234567890'
16
+ account1: "0x1234567890abcdef",
17
+ account2: "0xabcdef1234567890",
18
18
  });
19
19
  });
20
20
  });
@@ -1,14 +1,14 @@
1
- import type { Address, RaindexOrder, RaindexOrderAsIO, RaindexVault } from '@rainlanguage/orderbook';
1
+ import type { Address, RaindexOrder, RaindexOrderAsIO, RaindexVault } from "@rainlanguage/raindex";
2
2
  type OrderOrVault = RaindexOrder | RaindexOrderAsIO | RaindexVault;
3
3
  /**
4
4
  * Constructs a link path for an order or vault based on its type and network
5
5
  * @param orderOrVault - The order or vault object
6
6
  * @param type - The type of resource ('orders' or 'vaults')
7
7
  * @param chainId - The chain id
8
- * @param orderbookAddress - The orderbook address
8
+ * @param raindexAddress - The raindex address
9
9
  * @returns The constructed link path
10
10
  */
11
- export declare function constructHashLink(orderOrVault: OrderOrVault, type: 'orders' | 'vaults', chainId: number, orderbookAddress: Address): string;
11
+ export declare function constructHashLink(orderOrVault: OrderOrVault, type: "orders" | "vaults", chainId: number, raindexAddress: Address): string;
12
12
  /**
13
13
  * Determines if an order or vault is active
14
14
  * @param orderOrVault - The order or vault object
@@ -1,22 +1,24 @@
1
- import fc from 'fast-check';
2
- import { test } from '@fast-check/vitest';
1
+ import fc from "fast-check";
2
+ import { test } from "@fast-check/vitest";
3
3
  function isOrder(obj) {
4
- return obj && 'orderHash' in obj;
4
+ return obj && "orderHash" in obj;
5
5
  }
6
6
  /**
7
7
  * Constructs a link path for an order or vault based on its type and network
8
8
  * @param orderOrVault - The order or vault object
9
9
  * @param type - The type of resource ('orders' or 'vaults')
10
10
  * @param chainId - The chain id
11
- * @param orderbookAddress - The orderbook address
11
+ * @param raindexAddress - The raindex address
12
12
  * @returns The constructed link path
13
13
  */
14
- export function constructHashLink(orderOrVault, type, chainId, orderbookAddress) {
14
+ export function constructHashLink(orderOrVault, type, chainId, raindexAddress) {
15
15
  if (!orderOrVault) {
16
16
  return `/${type}`;
17
17
  }
18
- const slug = isOrder(orderOrVault) ? orderOrVault.orderHash : orderOrVault.id;
19
- return `/${type}/${chainId}-${orderbookAddress}-${slug}`;
18
+ const slug = isOrder(orderOrVault)
19
+ ? orderOrVault.orderHash
20
+ : orderOrVault.id;
21
+ return `/${type}/${chainId}-${raindexAddress}-${slug}`;
20
22
  }
21
23
  /**
22
24
  * Determines if an order or vault is active
@@ -36,80 +38,80 @@ export function extractHash(orderOrVault) {
36
38
  const _isOrder = isOrder(orderOrVault);
37
39
  return _isOrder
38
40
  ? orderOrVault.orderHash
39
- : orderOrVault?.id || '';
41
+ : orderOrVault?.id || "";
40
42
  }
41
43
  if (import.meta.vitest) {
42
44
  const { expect, it, describe } = import.meta.vitest;
43
- describe('constructHashLink', () => {
45
+ describe("constructHashLink", () => {
44
46
  test.prop([
45
47
  fc.record({
46
48
  orderHash: fc.string(),
47
- active: fc.boolean()
49
+ active: fc.boolean(),
48
50
  }),
49
- fc.oneof(fc.constant('orders'), fc.constant('vaults')),
51
+ fc.oneof(fc.constant("orders"), fc.constant("vaults")),
50
52
  fc.integer(),
51
- fc.string()
52
- ])('constructs correct link for orders', (order, type, chainId, orderbookAddress) => {
53
- const result = constructHashLink(order, type, chainId, orderbookAddress);
54
- expect(result).toBe(`/${type}/${chainId}-${orderbookAddress}-${order.orderHash}`);
53
+ fc.string(),
54
+ ])("constructs correct link for orders", (order, type, chainId, raindexAddress) => {
55
+ const result = constructHashLink(order, type, chainId, raindexAddress);
56
+ expect(result).toBe(`/${type}/${chainId}-${raindexAddress}-${order.orderHash}`);
55
57
  });
56
58
  test.prop([
57
59
  fc.record({
58
60
  id: fc.string(),
59
- owner: fc.string()
61
+ owner: fc.string(),
60
62
  }),
61
- fc.oneof(fc.constant('orders'), fc.constant('vaults')),
63
+ fc.oneof(fc.constant("orders"), fc.constant("vaults")),
62
64
  fc.integer(),
63
- fc.string()
64
- ])('constructs correct link for vaults', (vault, type, chainId, orderbookAddress) => {
65
- const result = constructHashLink(vault, type, chainId, orderbookAddress);
66
- expect(result).toBe(`/${type}/${chainId}-${orderbookAddress}-${vault.id}`);
65
+ fc.string(),
66
+ ])("constructs correct link for vaults", (vault, type, chainId, raindexAddress) => {
67
+ const result = constructHashLink(vault, type, chainId, raindexAddress);
68
+ expect(result).toBe(`/${type}/${chainId}-${raindexAddress}-${vault.id}`);
67
69
  });
68
70
  });
69
- describe('isOrderOrVaultActive', () => {
71
+ describe("isOrderOrVaultActive", () => {
70
72
  test.prop([
71
73
  fc.record({
72
74
  orderHash: fc.string(),
73
- active: fc.boolean()
74
- })
75
- ])('returns correct active status for orders', (order) => {
75
+ active: fc.boolean(),
76
+ }),
77
+ ])("returns correct active status for orders", (order) => {
76
78
  const result = isOrderOrVaultActive(order);
77
79
  expect(result).toBe(order.active);
78
80
  });
79
81
  test.prop([
80
82
  fc.record({
81
83
  id: fc.string(),
82
- owner: fc.string()
83
- })
84
- ])('returns false for vaults', (vault) => {
84
+ owner: fc.string(),
85
+ }),
86
+ ])("returns false for vaults", (vault) => {
85
87
  const result = isOrderOrVaultActive(vault);
86
88
  expect(result).toBe(false);
87
89
  });
88
90
  });
89
- describe('extractHash', () => {
91
+ describe("extractHash", () => {
90
92
  test.prop([
91
93
  fc.record({
92
94
  orderHash: fc.string(),
93
- active: fc.boolean()
94
- })
95
- ])('extracts hash from orders', (order) => {
95
+ active: fc.boolean(),
96
+ }),
97
+ ])("extracts hash from orders", (order) => {
96
98
  const result = extractHash(order);
97
99
  expect(result).toBe(order.orderHash);
98
100
  });
99
101
  test.prop([
100
102
  fc.record({
101
103
  id: fc.string(),
102
- owner: fc.string()
103
- })
104
- ])('extracts hash from vaults', (vault) => {
104
+ owner: fc.string(),
105
+ }),
106
+ ])("extracts hash from vaults", (vault) => {
105
107
  const result = extractHash(vault);
106
108
  expect(result).toBe(vault.id);
107
109
  });
108
- it('handles undefined vault id', () => {
110
+ it("handles undefined vault id", () => {
109
111
  // Create a partial vault object with undefined id
110
112
  const vault = { id: undefined };
111
113
  const result = extractHash(vault);
112
- expect(result).toBe('');
114
+ expect(result).toBe("");
113
115
  });
114
116
  });
115
117
  }
@@ -1,13 +1,13 @@
1
- import * as chains from 'viem/chains';
1
+ import * as chains from "viem/chains";
2
2
  export function getNetworkName(chainId) {
3
3
  const chain = Object.values(chains).find((chain) => chain.id === chainId);
4
4
  return chain?.name;
5
5
  }
6
6
  if (import.meta.vitest) {
7
- describe('getNetworkName', () => {
8
- it('should return the network name for a given chain id', () => {
9
- expect(getNetworkName(1)).toBe('Ethereum');
10
- expect(getNetworkName(137)).toBe('Polygon');
7
+ describe("getNetworkName", () => {
8
+ it("should return the network name for a given chain id", () => {
9
+ expect(getNetworkName(1)).toBe("Ethereum");
10
+ expect(getNetworkName(137)).toBe("Polygon");
11
11
  });
12
12
  });
13
13
  }
package/dist/utils/hex.js CHANGED
@@ -1,3 +1,3 @@
1
- import { toHex } from 'viem';
1
+ import { toHex } from "viem";
2
2
  export const HEX_INPUT_REGEX = /^(0x)?([0-9a-f]+)?$/;
3
3
  export const bigintStringToHex = (val) => toHex(BigInt(val));
@@ -1,4 +1,4 @@
1
- import { ColorType } from 'lightweight-charts';
1
+ import { ColorType } from "lightweight-charts";
2
2
  export interface ChartTheme {
3
3
  layout: {
4
4
  textColor: string;
@@ -1,21 +1,21 @@
1
- import { ColorType } from 'lightweight-charts';
1
+ import { ColorType } from "lightweight-charts";
2
2
  export const darkChartTheme = {
3
3
  layout: {
4
- textColor: 'white',
5
- background: { type: ColorType.Solid, color: 'transparent' }
4
+ textColor: "white",
5
+ background: { type: ColorType.Solid, color: "transparent" },
6
6
  },
7
7
  grid: {
8
- vertLines: { color: '#484848' },
9
- horzLines: { color: '#484848' }
10
- }
8
+ vertLines: { color: "#484848" },
9
+ horzLines: { color: "#484848" },
10
+ },
11
11
  };
12
12
  export const lightChartTheme = {
13
13
  layout: {
14
- textColor: 'black',
15
- background: { type: ColorType.Solid, color: 'transparent' }
14
+ textColor: "black",
15
+ background: { type: ColorType.Solid, color: "transparent" },
16
16
  },
17
17
  grid: {
18
- vertLines: { color: '#ECECEC' },
19
- horzLines: { color: '#ECECEC' }
20
- }
18
+ vertLines: { color: "#ECECEC" },
19
+ horzLines: { color: "#ECECEC" },
20
+ },
21
21
  };
@@ -0,0 +1,26 @@
1
+ import type { LocalDbStatus } from "@rainlanguage/raindex";
2
+ /**
3
+ * The minimal shape required to aggregate a top-level localdb status: anything
4
+ * carrying a per-chain/per-raindex {@link LocalDbStatus} and an optional error
5
+ * message (e.g. `NetworkSyncStatus` or `RaindexSyncStatus`).
6
+ */
7
+ export interface AggregableSyncStatus {
8
+ status: LocalDbStatus;
9
+ error?: string;
10
+ }
11
+ /**
12
+ * Collapses many per-chain / per-raindex sync statuses into the single
13
+ * top-level localdb status shown in the sidebar badge.
14
+ *
15
+ * Priority is `failure` > `syncing` > `active`:
16
+ * - If any status is `failure`, the result is `failure` (carrying that
17
+ * status's error).
18
+ * - Else if any status is `syncing`, the result is `syncing`.
19
+ * - Else the result is `active`.
20
+ *
21
+ * An empty input (nothing configured) is treated as `active`.
22
+ */
23
+ export declare function aggregateLocalDbStatus(statuses: AggregableSyncStatus[]): {
24
+ status: LocalDbStatus;
25
+ error: string | undefined;
26
+ };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Collapses many per-chain / per-raindex sync statuses into the single
3
+ * top-level localdb status shown in the sidebar badge.
4
+ *
5
+ * Priority is `failure` > `syncing` > `active`:
6
+ * - If any status is `failure`, the result is `failure` (carrying that
7
+ * status's error).
8
+ * - Else if any status is `syncing`, the result is `syncing`.
9
+ * - Else the result is `active`.
10
+ *
11
+ * An empty input (nothing configured) is treated as `active`.
12
+ */
13
+ export function aggregateLocalDbStatus(statuses) {
14
+ const failure = statuses.find((s) => s.status === "failure");
15
+ if (failure) {
16
+ return { status: "failure", error: failure.error };
17
+ }
18
+ if (statuses.some((s) => s.status === "syncing")) {
19
+ return { status: "syncing", error: undefined };
20
+ }
21
+ return { status: "active", error: undefined };
22
+ }
@@ -1,4 +1,4 @@
1
- import { formatUnits } from 'viem';
1
+ import { formatUnits } from "viem";
2
2
  /**
3
3
  * Converts a bigint string value to a percentage with optionally given number of decimal points
4
4
  * @param value - The bigint string value
@@ -6,9 +6,11 @@ import { formatUnits } from 'viem';
6
6
  * @param decimalPoint - (optional) The number of digits to keep after "." in final result, defaults to valueDecimals
7
7
  */
8
8
  export function bigintStringToPercentage(value, valueDecimals, finalDecimalsDigits) {
9
- const finalDecimals = typeof finalDecimalsDigits !== 'undefined' ? finalDecimalsDigits : valueDecimals;
9
+ const finalDecimals = typeof finalDecimalsDigits !== "undefined"
10
+ ? finalDecimalsDigits
11
+ : valueDecimals;
10
12
  let valueString = formatUnits(BigInt(value) * 100n, valueDecimals);
11
- const index = valueString.indexOf('.');
13
+ const index = valueString.indexOf(".");
12
14
  if (index > -1) {
13
15
  valueString = valueString.substring(0, finalDecimals === 0 ? index : index + finalDecimals + 1);
14
16
  }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Removes trailing whitespace from rainlang/dotrain editor text, mirroring the
3
+ * "delete trailing whitespace on save" behaviour of common code editors.
4
+ *
5
+ * - Trailing spaces and tabs are removed from the end of every line.
6
+ * - Line breaks between content are preserved (`\r\n` is normalised to `\n`).
7
+ * - Internal blank lines are preserved (only their trailing whitespace is
8
+ * stripped) so deliberate spacing in the source is kept.
9
+ * - Trailing blank lines and a trailing newline at the very end of the text are
10
+ * removed, so the saved text never ends in dangling whitespace.
11
+ * - Leading whitespace (indentation) is never touched.
12
+ *
13
+ * @param text - The editor contents to normalise.
14
+ * @returns The text with trailing whitespace stripped.
15
+ */
16
+ export declare function stripTrailingWhitespace(text: string): string;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Removes trailing whitespace from rainlang/dotrain editor text, mirroring the
3
+ * "delete trailing whitespace on save" behaviour of common code editors.
4
+ *
5
+ * - Trailing spaces and tabs are removed from the end of every line.
6
+ * - Line breaks between content are preserved (`\r\n` is normalised to `\n`).
7
+ * - Internal blank lines are preserved (only their trailing whitespace is
8
+ * stripped) so deliberate spacing in the source is kept.
9
+ * - Trailing blank lines and a trailing newline at the very end of the text are
10
+ * removed, so the saved text never ends in dangling whitespace.
11
+ * - Leading whitespace (indentation) is never touched.
12
+ *
13
+ * @param text - The editor contents to normalise.
14
+ * @returns The text with trailing whitespace stripped.
15
+ */
16
+ export function stripTrailingWhitespace(text) {
17
+ return text
18
+ .split(/\r\n|\r|\n/)
19
+ .map((line) => line.replace(/[ \t]+$/, ""))
20
+ .join("\n")
21
+ .replace(/\n+$/, "");
22
+ }
@@ -1,2 +1,2 @@
1
- import type { RaindexVaultToken } from '@rainlanguage/orderbook';
1
+ import type { RaindexVaultToken } from "@rainlanguage/raindex";
2
2
  export declare function getTokenDisplayName(token: RaindexVaultToken): string;
@@ -1,3 +1,3 @@
1
1
  export function getTokenDisplayName(token) {
2
- return token.symbol || token.name || 'Unknown Token';
2
+ return token.symbol || token.name || "Unknown Token";
3
3
  }
@@ -1,4 +1,4 @@
1
- import type { RaindexVaultBalanceChangeType, VaultBalanceChangeFilter } from '@rainlanguage/orderbook';
1
+ import type { RaindexVaultBalanceChangeType, VaultBalanceChangeFilter } from "@rainlanguage/raindex";
2
2
  export declare const VAULT_BALANCE_CHANGE_LABELS: Record<RaindexVaultBalanceChangeType, string>;
3
3
  export declare const VAULT_BALANCE_CHANGE_FILTER_LABELS: Record<VaultBalanceChangeFilter, string>;
4
4
  export declare function labelForVaultBalanceChangeType(type: RaindexVaultBalanceChangeType): string;
@@ -1,17 +1,17 @@
1
1
  export const VAULT_BALANCE_CHANGE_LABELS = {
2
- deposit: 'Deposit',
3
- withdrawal: 'Withdrawal',
4
- takeOrder: 'Take order',
5
- clear: 'Clear',
6
- clearBounty: 'Clear Bounty',
7
- unknown: 'Unknown'
2
+ deposit: "Deposit",
3
+ withdrawal: "Withdrawal",
4
+ takeOrder: "Take order",
5
+ clear: "Clear",
6
+ clearBounty: "Clear Bounty",
7
+ unknown: "Unknown",
8
8
  };
9
9
  export const VAULT_BALANCE_CHANGE_FILTER_LABELS = {
10
- deposit: 'Deposit',
11
- withdrawal: 'Withdrawal',
12
- takeOrder: 'Take order',
13
- clear: 'Clear',
14
- clearBounty: 'Clear Bounty'
10
+ deposit: "Deposit",
11
+ withdrawal: "Withdrawal",
12
+ takeOrder: "Take order",
13
+ clear: "Clear",
14
+ clearBounty: "Clear Bounty",
15
15
  };
16
16
  export function labelForVaultBalanceChangeType(type) {
17
17
  return VAULT_BALANCE_CHANGE_LABELS[type] ?? type;