@rainlanguage/ui-components 0.0.1-alpha.8 → 0.0.1-alpha.80

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 (132) hide show
  1. package/dist/__fixtures__/orderDetail.d.ts +1 -1
  2. package/dist/__mocks__/MockComponent.svelte +4 -0
  3. package/dist/__mocks__/MockComponent.svelte.d.ts +3 -1
  4. package/dist/__mocks__/mockTransactionStore.d.ts +3 -21
  5. package/dist/__mocks__/mockTransactionStore.js +26 -13
  6. package/dist/__mocks__/settings.d.ts +6 -2
  7. package/dist/__mocks__/settings.js +6 -1
  8. package/dist/__mocks__/stores.d.ts +86 -19
  9. package/dist/__mocks__/stores.js +26 -17
  10. package/dist/components/ButtonVaultLink.svelte +3 -3
  11. package/dist/components/ButtonVaultLink.svelte.d.ts +1 -1
  12. package/dist/components/CheckboxMyItemsOnly.svelte +3 -2
  13. package/dist/components/CheckboxMyItemsOnly.svelte.d.ts +0 -1
  14. package/dist/components/CodeMirrorDotrain.svelte +4 -0
  15. package/dist/components/CodeMirrorDotrain.svelte.d.ts +1 -0
  16. package/dist/components/CodeMirrorRainlang.svelte +2 -2
  17. package/dist/components/CodeMirrorRainlang.svelte.d.ts +1 -1
  18. package/dist/components/Hash.svelte +3 -3
  19. package/dist/components/License.svelte +5 -4
  20. package/dist/components/ListViewOrderbookFilters.svelte +14 -13
  21. package/dist/components/ListViewOrderbookFilters.svelte.d.ts +2 -5
  22. package/dist/components/OrderOrVaultHash.svelte +10 -7
  23. package/dist/components/OrderOrVaultHash.svelte.d.ts +1 -1
  24. package/dist/components/PageHeader.svelte +20 -22
  25. package/dist/components/PageHeader.svelte.d.ts +1 -0
  26. package/dist/components/TanstackAppTable.svelte +2 -3
  27. package/dist/components/TanstackAppTable.svelte.d.ts +1 -1
  28. package/dist/components/Tooltip.svelte +8 -0
  29. package/dist/components/Tooltip.svelte.d.ts +21 -0
  30. package/dist/components/charts/OrderTradesChart.svelte +1 -1
  31. package/dist/components/charts/TanstackLightweightChartLine.svelte +5 -9
  32. package/dist/components/charts/VaultBalanceChart.svelte +1 -1
  33. package/dist/components/charts/VaultBalanceChart.svelte.d.ts +1 -1
  34. package/dist/components/charts/transformAndSortData.d.ts +24 -0
  35. package/dist/components/charts/transformAndSortData.js +111 -0
  36. package/dist/components/checkbox/CheckboxActiveOrders.svelte +11 -0
  37. package/dist/components/checkbox/CheckboxActiveOrders.svelte.d.ts +19 -0
  38. package/dist/components/deployment/ComposedRainlangModal.svelte +7 -5
  39. package/dist/components/deployment/ComposedRainlangModal.svelte.d.ts +1 -4
  40. package/dist/components/deployment/DeploymentSectionHeader.svelte +7 -4
  41. package/dist/components/deployment/DeploymentSteps.svelte +180 -155
  42. package/dist/components/deployment/DeploymentSteps.svelte.d.ts +7 -13
  43. package/dist/components/deployment/DeploymentsSection.svelte +18 -14
  44. package/dist/components/deployment/DepositInput.svelte +31 -14
  45. package/dist/components/deployment/DepositInput.svelte.d.ts +1 -2
  46. package/dist/components/deployment/FieldDefinitionInput.svelte +20 -14
  47. package/dist/components/deployment/FieldDefinitionInput.svelte.d.ts +1 -2
  48. package/dist/components/deployment/SelectToken.svelte +12 -3
  49. package/dist/components/deployment/SelectToken.svelte.d.ts +1 -2
  50. package/dist/components/deployment/StrategyPage.svelte +6 -2
  51. package/dist/components/deployment/TokenIOInput.svelte +15 -5
  52. package/dist/components/deployment/TokenIOInput.svelte.d.ts +1 -2
  53. package/dist/components/deployment/handleDeployment.d.ts +11 -0
  54. package/dist/components/deployment/handleDeployment.js +33 -0
  55. package/dist/components/detail/OrderDetail.svelte +46 -41
  56. package/dist/components/detail/OrderDetail.svelte.d.ts +11 -8
  57. package/dist/components/detail/TanstackOrderQuote.svelte +6 -6
  58. package/dist/components/detail/TanstackOrderQuote.svelte.d.ts +1 -1
  59. package/dist/components/detail/VaultDetail.svelte +29 -40
  60. package/dist/components/detail/VaultDetail.svelte.d.ts +10 -10
  61. package/dist/components/dropdown/DropdownActiveSubgraphs.svelte.d.ts +1 -1
  62. package/dist/components/icon/Refresh.svelte +2 -1
  63. package/dist/components/icon/Refresh.svelte.d.ts +1 -0
  64. package/dist/components/input/InputOrderHash.svelte +1 -1
  65. package/dist/components/input/InputRegistryUrl.svelte +2 -2
  66. package/dist/components/input/InputToken.svelte +2 -2
  67. package/dist/components/input/InputTokenAmount.svelte +1 -1
  68. package/dist/components/tables/OrderAPY.svelte +1 -1
  69. package/dist/components/tables/OrderTradesListTable.svelte +1 -1
  70. package/dist/components/tables/OrderVaultsVolTable.svelte +1 -1
  71. package/dist/components/tables/OrdersListTable.svelte +16 -18
  72. package/dist/components/tables/OrdersListTable.svelte.d.ts +0 -6
  73. package/dist/components/tables/VaultBalanceChangesTable.svelte +3 -3
  74. package/dist/components/tables/VaultsListTable.svelte +43 -52
  75. package/dist/components/tables/VaultsListTable.svelte.d.ts +3 -6
  76. package/dist/components/wallet/WalletConnect.svelte +5 -4
  77. package/dist/components/wallet/WalletConnect.svelte.d.ts +0 -1
  78. package/dist/consts.d.ts +1 -0
  79. package/dist/consts.js +1 -0
  80. package/dist/errors/DeploymentStepsError.d.ts +5 -2
  81. package/dist/errors/DeploymentStepsError.js +4 -1
  82. package/dist/hooks/useGui.d.ts +3 -0
  83. package/dist/hooks/useGui.js +11 -0
  84. package/dist/index.d.ts +12 -6
  85. package/dist/index.js +14 -5
  86. package/dist/providers/GuiProvider.svelte +8 -0
  87. package/dist/providers/GuiProvider.svelte.d.ts +21 -0
  88. package/dist/providers/wallet/WalletProvider.svelte +7 -0
  89. package/dist/providers/wallet/WalletProvider.svelte.d.ts +21 -0
  90. package/dist/providers/wallet/context.d.ts +10 -0
  91. package/dist/providers/wallet/context.js +47 -0
  92. package/dist/providers/wallet/useAccount.d.ts +8 -0
  93. package/dist/providers/wallet/useAccount.js +148 -0
  94. package/dist/queries/queryClient.d.ts +1 -1
  95. package/dist/queries/queryClient.js +3 -3
  96. package/dist/services/awaitTransactionIndexing.d.ts +163 -0
  97. package/dist/services/awaitTransactionIndexing.js +120 -0
  98. package/dist/services/handleShareChoices.d.ts +2 -2
  99. package/dist/services/handleShareChoices.js +7 -2
  100. package/dist/services/historicalOrderCharts.d.ts +1 -1
  101. package/dist/services/index.d.ts +1 -1
  102. package/dist/services/index.js +1 -1
  103. package/dist/services/registry.d.ts +6 -0
  104. package/dist/services/registry.js +156 -0
  105. package/dist/stores/transactionStore.d.ts +7 -10
  106. package/dist/stores/transactionStore.js +35 -61
  107. package/dist/storesGeneric/cachedWritableStore.d.ts +57 -0
  108. package/dist/storesGeneric/cachedWritableStore.js +93 -0
  109. package/dist/types/account.d.ts +3 -0
  110. package/dist/types/account.js +1 -0
  111. package/dist/types/appStores.d.ts +2 -2
  112. package/dist/types/modal.d.ts +1 -1
  113. package/dist/types/strategy.d.ts +1 -1
  114. package/dist/types/transaction.d.ts +3 -3
  115. package/dist/utils/constructHashLink.d.ts +23 -0
  116. package/dist/utils/constructHashLink.js +110 -0
  117. package/dist/utils/vault.d.ts +1 -1
  118. package/package.json +34 -34
  119. package/dist/components/deployment/DepositsSection.svelte +0 -8
  120. package/dist/components/deployment/DepositsSection.svelte.d.ts +0 -20
  121. package/dist/components/deployment/FieldDefinitionsSection.svelte +0 -9
  122. package/dist/components/deployment/FieldDefinitionsSection.svelte.d.ts +0 -20
  123. package/dist/components/deployment/SelectTokensSection.svelte +0 -17
  124. package/dist/components/deployment/SelectTokensSection.svelte.d.ts +0 -21
  125. package/dist/components/deployment/TokenIOSection.svelte +0 -17
  126. package/dist/components/deployment/TokenIOSection.svelte.d.ts +0 -21
  127. package/dist/components/deployment/getDeploymentTransactionArgs.d.ts +0 -17
  128. package/dist/components/deployment/getDeploymentTransactionArgs.js +0 -24
  129. package/dist/components/detail/DepositOrWithdrawButtons.svelte +0 -44
  130. package/dist/components/detail/DepositOrWithdrawButtons.svelte.d.ts +0 -26
  131. package/dist/components/dropdown/DropdownOrderStatus.svelte +0 -31
  132. package/dist/components/dropdown/DropdownOrderStatus.svelte.d.ts +0 -19
@@ -1,61 +1,80 @@
1
- <script>import { Alert } from "flowbite-svelte";
2
- import TokenIOSection from "./TokenIOSection.svelte";
3
- import DepositsSection from "./DepositsSection.svelte";
4
- import SelectTokensSection from "./SelectTokensSection.svelte";
1
+ <script>import { Alert, Button, Spinner, Toggle } from "flowbite-svelte";
2
+ import TokenIOInput from "./TokenIOInput.svelte";
5
3
  import ComposedRainlangModal from "./ComposedRainlangModal.svelte";
6
- import FieldDefinitionsSection from "./FieldDefinitionsSection.svelte";
7
- import {} from "@rainlanguage/orderbook/js_api";
8
- import WalletConnect from "../wallet/WalletConnect.svelte";
9
4
  import {
10
- DotrainOrderGui
11
- } from "@rainlanguage/orderbook/js_api";
12
- import { fade } from "svelte/transition";
13
- import { Button, Toggle, Spinner } from "flowbite-svelte";
14
- import {} from "@wagmi/core";
5
+ } from "@rainlanguage/orderbook";
6
+ import WalletConnect from "../wallet/WalletConnect.svelte";
15
7
  import {} from "svelte/store";
16
- import ShareChoicesButton from "./ShareChoicesButton.svelte";
17
8
  import { handleShareChoices } from "../../services/handleShareChoices";
18
- import { getDeploymentTransactionArgs } from "./getDeploymentTransactionArgs";
19
9
  import { DeploymentStepsError, DeploymentStepsErrorCode } from "../../errors";
20
10
  import { onMount } from "svelte";
21
- export let settings;
22
- export let dotrain;
11
+ import FieldDefinitionInput from "./FieldDefinitionInput.svelte";
12
+ import DepositInput from "./DepositInput.svelte";
13
+ import SelectToken from "./SelectToken.svelte";
14
+ import DeploymentSectionHeader from "./DeploymentSectionHeader.svelte";
15
+ import { useGui } from "../../hooks/useGui";
16
+ import { useAccount } from "../../providers/wallet/useAccount";
17
+ import { handleDeployment } from "./handleDeployment";
18
+ import {} from "../../types/transaction";
19
+ import { fade } from "svelte/transition";
20
+ import ShareChoicesButton from "./ShareChoicesButton.svelte";
23
21
  export let deployment;
24
22
  export let strategyDetail;
25
- export let gui;
26
- export let handleDeployModal;
27
- export let handleDisclaimerModal;
23
+ export let onDeploy;
24
+ export let wagmiConnected;
25
+ export let appKitModal;
26
+ export let settings;
27
+ export let registryUrl;
28
28
  let allDepositFields = [];
29
29
  let allTokenOutputs = [];
30
30
  let allFieldDefinitionsWithoutDefaults = [];
31
31
  let allFieldDefinitionsWithDefaults = [];
32
32
  let allTokensSelected = false;
33
33
  let showAdvancedOptions = false;
34
- let checkingDeployment = false;
35
34
  let allTokenInfos = [];
36
- const selectTokens = gui.getSelectTokens();
37
- const networkKey = gui.getNetworkKey();
38
- const subgraphUrl = $settings?.subgraphs?.[networkKey] ?? "";
35
+ let selectTokens = void 0;
36
+ let checkingDeployment = false;
37
+ let subgraphUrl = void 0;
38
+ const { account } = useAccount();
39
+ const gui = useGui();
39
40
  let deploymentStepsError = DeploymentStepsError.error;
40
- export let wagmiConfig;
41
- export let wagmiConnected;
42
- export let appKitModal;
43
- export let signerAddress;
44
41
  onMount(async () => {
42
+ const selectTokensResult = gui.getSelectTokens();
43
+ if (selectTokensResult.error) {
44
+ throw new Error(selectTokensResult.error.msg);
45
+ }
46
+ selectTokens = selectTokensResult.value;
47
+ const { value, error } = gui.getNetworkKey();
48
+ if (error) {
49
+ DeploymentStepsError.catch(error, DeploymentStepsErrorCode.NO_NETWORK_KEY);
50
+ } else if (value) {
51
+ subgraphUrl = $settings?.subgraphs?.[value];
52
+ }
45
53
  await areAllTokensSelected();
46
54
  });
47
55
  function getAllFieldDefinitions() {
48
56
  try {
49
- allFieldDefinitionsWithoutDefaults = gui.getAllFieldDefinitions(false);
50
- allFieldDefinitionsWithDefaults = gui.getAllFieldDefinitions(true);
57
+ const allFieldDefinitionsResult = gui.getAllFieldDefinitions(false);
58
+ if (allFieldDefinitionsResult.error) {
59
+ throw new Error(allFieldDefinitionsResult.error.msg);
60
+ }
61
+ allFieldDefinitionsWithoutDefaults = allFieldDefinitionsResult.value;
62
+ const allFieldDefinitionsWithDefaultsResult = gui.getAllFieldDefinitions(true);
63
+ if (allFieldDefinitionsWithDefaultsResult.error) {
64
+ throw new Error(allFieldDefinitionsWithDefaultsResult.error.msg);
65
+ }
66
+ allFieldDefinitionsWithDefaults = allFieldDefinitionsWithDefaultsResult.value;
51
67
  } catch (e) {
52
68
  DeploymentStepsError.catch(e, DeploymentStepsErrorCode.NO_FIELD_DEFINITIONS);
53
69
  }
54
70
  }
55
71
  async function getAllDepositFields() {
56
72
  try {
57
- let dep = gui.getCurrentDeployment();
58
- let depositFields = dep.deposits;
73
+ let result = gui.getCurrentDeployment();
74
+ if (result.error) {
75
+ throw new Error(result.error.msg);
76
+ }
77
+ let depositFields = result.value.deposits;
59
78
  allDepositFields = depositFields;
60
79
  } catch (e) {
61
80
  DeploymentStepsError.catch(e, DeploymentStepsErrorCode.NO_DEPOSITS);
@@ -64,14 +83,22 @@ async function getAllDepositFields() {
64
83
  let allTokenInputs = [];
65
84
  function getAllTokenInputs() {
66
85
  try {
67
- allTokenInputs = gui.getCurrentDeployment().deployment.order.inputs;
86
+ let result = gui.getCurrentDeployment();
87
+ if (result.error) {
88
+ throw new Error(result.error.msg);
89
+ }
90
+ allTokenInputs = result.value.deployment.order.inputs;
68
91
  } catch (e) {
69
92
  DeploymentStepsError.catch(e, DeploymentStepsErrorCode.NO_TOKEN_INPUTS);
70
93
  }
71
94
  }
72
95
  function getAllTokenOutputs() {
73
96
  try {
74
- allTokenOutputs = gui.getCurrentDeployment().deployment.order.outputs;
97
+ let result = gui.getCurrentDeployment();
98
+ if (result.error) {
99
+ throw new Error(result.error.msg);
100
+ }
101
+ allTokenOutputs = result.value.deployment.order.outputs;
75
102
  } catch (e) {
76
103
  DeploymentStepsError.catch(e, DeploymentStepsErrorCode.NO_TOKEN_OUTPUTS);
77
104
  }
@@ -91,12 +118,16 @@ async function updateFields() {
91
118
  }
92
119
  }
93
120
  async function _handleShareChoices() {
94
- await handleShareChoices(gui);
121
+ await handleShareChoices(gui, registryUrl);
95
122
  }
96
123
  async function onSelectTokenSelect() {
97
124
  await areAllTokensSelected();
98
125
  if (allTokensSelected) {
99
- let newAllTokenInfos = await gui.getAllTokenInfos();
126
+ let result = await gui.getAllTokenInfos();
127
+ if (result.error) {
128
+ throw new Error(result.error.msg);
129
+ }
130
+ let newAllTokenInfos = result.value;
100
131
  if (allTokenInfos !== newAllTokenInfos) {
101
132
  allTokenInfos = newAllTokenInfos;
102
133
  getAllDepositFields();
@@ -104,149 +135,143 @@ async function onSelectTokenSelect() {
104
135
  }
105
136
  }
106
137
  }
107
- async function handleDeployButtonClick() {
108
- DeploymentStepsError.clear();
109
- if (!allTokenOutputs) {
110
- DeploymentStepsError.catch(null, DeploymentStepsErrorCode.NO_TOKEN_OUTPUTS);
111
- return;
112
- }
113
- if (!wagmiConfig) {
114
- DeploymentStepsError.catch(null, DeploymentStepsErrorCode.NO_CHAIN);
115
- return;
138
+ const areAllTokensSelected = async () => {
139
+ try {
140
+ const areAllTokensSelectedResult = gui.areAllTokensSelected();
141
+ if (areAllTokensSelectedResult.error) {
142
+ throw new Error(areAllTokensSelectedResult.error.msg);
143
+ }
144
+ allTokensSelected = areAllTokensSelectedResult.value;
145
+ if (!allTokensSelected) return;
146
+ const getAllTokenInfosResult = await gui.getAllTokenInfos();
147
+ if (getAllTokenInfosResult.error) {
148
+ throw new Error(getAllTokenInfosResult.error.msg);
149
+ }
150
+ allTokenInfos = getAllTokenInfosResult.value;
151
+ const hasDepositsResult = gui.hasAnyDeposit();
152
+ if (hasDepositsResult.error) {
153
+ throw new Error(hasDepositsResult.error.msg);
154
+ }
155
+ const hasVaultIdsResult = gui.hasAnyVaultId();
156
+ if (hasVaultIdsResult.error) {
157
+ throw new Error(hasVaultIdsResult.error.msg);
158
+ }
159
+ if (hasDepositsResult.value || hasVaultIdsResult.value) {
160
+ showAdvancedOptions = true;
161
+ }
162
+ } catch (e) {
163
+ DeploymentStepsError.catch(e, DeploymentStepsErrorCode.NO_SELECT_TOKENS);
116
164
  }
117
- if (!networkKey) {
118
- DeploymentStepsError.catch(null, DeploymentStepsErrorCode.NO_CHAIN);
165
+ };
166
+ async function handleDeployButtonClick() {
167
+ if (checkingDeployment) {
119
168
  return;
120
169
  }
121
- let result = null;
122
170
  checkingDeployment = true;
123
171
  try {
124
- result = await getDeploymentTransactionArgs(gui, $wagmiConfig);
172
+ if (!$account) {
173
+ DeploymentStepsError.catch(
174
+ "No wallet connected",
175
+ DeploymentStepsErrorCode.ADD_ORDER_FAILED
176
+ );
177
+ return;
178
+ }
179
+ DeploymentStepsError.clear();
180
+ const deploymentArgs = await handleDeployment(gui, $account, subgraphUrl);
181
+ return await onDeploy(deploymentArgs);
125
182
  } catch (e) {
126
- checkingDeployment = false;
127
183
  DeploymentStepsError.catch(e, DeploymentStepsErrorCode.ADD_ORDER_FAILED);
128
- }
129
- if (!result) {
184
+ } finally {
130
185
  checkingDeployment = false;
131
- DeploymentStepsError.catch(null, DeploymentStepsErrorCode.ADD_ORDER_FAILED);
132
- return;
133
186
  }
134
- checkingDeployment = false;
135
- const onAccept = () => {
136
- if (!networkKey) {
137
- DeploymentStepsError.catch(null, DeploymentStepsErrorCode.NO_CHAIN);
138
- return;
139
- }
140
- handleDeployModal({
141
- open: true,
142
- args: {
143
- ...result,
144
- subgraphUrl,
145
- network: networkKey
146
- }
147
- });
148
- };
149
- handleDisclaimerModal({
150
- open: true,
151
- onAccept
152
- });
153
187
  }
154
- const areAllTokensSelected = async () => {
155
- try {
156
- allTokensSelected = gui.areAllTokensSelected();
157
- if (!allTokensSelected) return;
158
- allTokenInfos = await gui.getAllTokenInfos();
159
- const hasDeposits = gui.hasAnyDeposit();
160
- const hasVaultIds = gui.hasAnyVaultId();
161
- if (hasDeposits || hasVaultIds) {
162
- showAdvancedOptions = true;
163
- }
164
- } catch (e) {
165
- DeploymentStepsError.catch(e, DeploymentStepsErrorCode.NO_SELECT_TOKENS);
166
- }
167
- };
168
188
  </script>
169
189
 
170
190
  <div>
171
- {#if $deploymentStepsError}
172
- <Alert color="red">
173
- <p class="text-red-500">{$deploymentStepsError.code}</p>
174
- {#if $deploymentStepsError.details}
175
- <p class="text-red-500">{$deploymentStepsError.details}</p>
191
+ {#if gui}
192
+ <div class="flex max-w-3xl flex-col gap-12" in:fade>
193
+ {#if deployment}
194
+ <div class="flex max-w-2xl flex-col gap-4 text-start">
195
+ <h1 class="text-4xl font-semibold text-gray-900 lg:text-6xl dark:text-white">
196
+ {strategyDetail.name}
197
+ </h1>
198
+ <p class="text-xl text-gray-600 lg:text-2xl dark:text-gray-400">
199
+ {deployment.description}
200
+ </p>
201
+ </div>
176
202
  {/if}
177
- </Alert>
178
- {/if}
179
- {#if dotrain}
180
- {#if gui}
181
- <div class="flex max-w-3xl flex-col gap-12" in:fade>
182
- {#if deployment}
183
- <div class="flex max-w-2xl flex-col gap-4 text-start">
184
- <h1 class=" text-4xl font-semibold text-gray-900 lg:text-6xl dark:text-white">
185
- {strategyDetail.name}
186
- </h1>
187
- <p class="text-xl text-gray-600 lg:text-2xl dark:text-gray-400">
188
- {deployment.description}
189
- </p>
190
- </div>
191
- {/if}
192
203
 
193
- {#if selectTokens && selectTokens.length > 0}
194
- <SelectTokensSection {gui} {selectTokens} {onSelectTokenSelect} />
195
- {/if}
204
+ {#if selectTokens && selectTokens.length > 0}
205
+ <div class="flex w-full flex-col gap-4">
206
+ <DeploymentSectionHeader
207
+ title="Select Tokens"
208
+ description="Select the tokens that you want to use in your order."
209
+ />
210
+ {#each selectTokens as token}
211
+ <SelectToken {token} {onSelectTokenSelect} />
212
+ {/each}
213
+ </div>
214
+ {/if}
196
215
 
197
- {#if allTokensSelected || selectTokens?.length === 0}
198
- {#if allFieldDefinitionsWithoutDefaults.length > 0}
199
- <FieldDefinitionsSection
200
- allFieldDefinitions={allFieldDefinitionsWithoutDefaults}
201
- {gui}
202
- />
203
- {/if}
216
+ {#if allTokensSelected || selectTokens?.length === 0}
217
+ {#if allFieldDefinitionsWithoutDefaults.length > 0}
218
+ {#each allFieldDefinitionsWithoutDefaults as fieldDefinition}
219
+ <FieldDefinitionInput {fieldDefinition} />
220
+ {/each}
221
+ {/if}
204
222
 
205
- <Toggle bind:checked={showAdvancedOptions}>Show advanced options</Toggle>
223
+ <Toggle bind:checked={showAdvancedOptions}>Show advanced options</Toggle>
206
224
 
207
- {#if allFieldDefinitionsWithDefaults.length > 0 && showAdvancedOptions}
208
- <FieldDefinitionsSection allFieldDefinitions={allFieldDefinitionsWithDefaults} {gui} />
209
- {/if}
225
+ {#if showAdvancedOptions}
226
+ {#each allFieldDefinitionsWithDefaults as fieldDefinition}
227
+ <FieldDefinitionInput {fieldDefinition} />
228
+ {/each}
210
229
 
211
- {#if allDepositFields.length > 0 && showAdvancedOptions}
212
- <DepositsSection bind:allDepositFields {gui} />
213
- {/if}
230
+ {#each allDepositFields as deposit}
231
+ <DepositInput {deposit} />
232
+ {/each}
214
233
 
215
- {#if allTokenInputs.length > 0 && allTokenOutputs.length > 0 && showAdvancedOptions}
216
- <TokenIOSection bind:allTokenInputs bind:allTokenOutputs {gui} />
217
- {/if}
234
+ {#each allTokenOutputs as output, i}
235
+ <TokenIOInput {i} label="Output" vault={output} />
236
+ {/each}
218
237
 
219
- {#if $deploymentStepsError}
220
- <Alert color="red">
221
- <p class="text-red-500">{$deploymentStepsError.code}</p>
222
- {#if $deploymentStepsError.details}
223
- <p class="text-red-500">{$deploymentStepsError.details}</p>
224
- {/if}
225
- </Alert>
226
- {/if}
238
+ {#each allTokenInputs as input, i}
239
+ <TokenIOInput {i} label="Input" vault={input} />
240
+ {/each}
241
+ {/if}
227
242
 
228
- <div class="flex flex-wrap items-start justify-start gap-2">
229
- {#if $wagmiConnected}
230
- <Button
231
- size="lg"
232
- on:click={handleDeployButtonClick}
233
- class="bg-gradient-to-br from-blue-600 to-violet-600"
234
- >
235
- {#if checkingDeployment}
236
- <Spinner size="4" color="white" />
237
- <span class="ml-2">Checking deployment...</span>
238
- {:else}
239
- Deploy Strategy
240
- {/if}
241
- </Button>
242
- {:else}
243
- <WalletConnect {appKitModal} connected={wagmiConnected} {signerAddress} />
243
+ {#if $deploymentStepsError}
244
+ <Alert color="red">
245
+ <p class="text-red-500">{$deploymentStepsError.code}</p>
246
+ {#if $deploymentStepsError.details}
247
+ <p class="text-red-500">{$deploymentStepsError.details}</p>
244
248
  {/if}
245
- <ComposedRainlangModal {gui} />
246
- <ShareChoicesButton handleShareChoices={_handleShareChoices} />
247
- </div>
249
+ </Alert>
248
250
  {/if}
249
- </div>
250
- {/if}
251
+
252
+ <div class="flex flex-wrap items-start justify-start gap-2">
253
+ {#if $account}
254
+ <Button
255
+ data-testid="deploy-button"
256
+ size="lg"
257
+ disabled={checkingDeployment}
258
+ on:click={handleDeployButtonClick}
259
+ class="bg-gradient-to-br from-blue-600 to-violet-600"
260
+ >
261
+ {#if checkingDeployment}
262
+ <Spinner size="4" color="white" />
263
+ <span class="ml-2">Checking deployment...</span>
264
+ {:else}
265
+ Deploy Strategy
266
+ {/if}
267
+ </Button>
268
+ {:else}
269
+ <WalletConnect {appKitModal} connected={wagmiConnected} />
270
+ {/if}
271
+ <ComposedRainlangModal />
272
+ <ShareChoicesButton handleShareChoices={_handleShareChoices} />
273
+ </div>
274
+ {/if}
275
+ </div>
251
276
  {/if}
252
277
  </div>
@@ -1,27 +1,21 @@
1
1
  import { SvelteComponent } from "svelte";
2
- import { type ConfigSource } from '@rainlanguage/orderbook/js_api';
3
- import { DotrainOrderGui, type NameAndDescriptionCfg } from '@rainlanguage/orderbook/js_api';
4
- import { type Config } from '@wagmi/core';
2
+ import { type ConfigSource, type NameAndDescriptionCfg } from '@rainlanguage/orderbook';
5
3
  import { type Writable } from 'svelte/store';
6
4
  import type { AppKit } from '@reown/appkit';
7
- import type { DisclaimerModalProps, DeployModalProps } from '../../types/modal';
5
+ import { type DeploymentArgs } from '../../types/transaction';
8
6
  declare const __propDef: {
9
7
  props: {
10
- settings: Writable<ConfigSource>;
11
- dotrain: string;
12
- deployment: {
8
+ /** The deployment configuration containing key, name and description */ deployment: {
13
9
  key: string;
14
10
  name: string;
15
11
  description: string;
16
12
  };
17
- strategyDetail: NameAndDescriptionCfg;
18
- gui: DotrainOrderGui;
19
- handleDeployModal: (args: DeployModalProps) => void;
20
- handleDisclaimerModal: (args: DisclaimerModalProps) => void;
21
- wagmiConfig: Writable<Config | undefined>;
13
+ /** Strategy details containing name and description configuration */ strategyDetail: NameAndDescriptionCfg;
14
+ /** Handlers for deployment modals */ onDeploy: (deploymentArgs: DeploymentArgs) => void;
22
15
  wagmiConnected: Writable<boolean>;
23
16
  appKitModal: Writable<AppKit>;
24
- signerAddress: Writable<string | null>;
17
+ settings: Writable<ConfigSource>;
18
+ registryUrl: string;
25
19
  };
26
20
  events: {
27
21
  [evt: string]: CustomEvent<any>;
@@ -1,20 +1,24 @@
1
- <script>import { DotrainOrderGui } from "@rainlanguage/orderbook/js_api";
1
+ <script>import { DotrainOrderGui } from "@rainlanguage/orderbook";
2
2
  import DeploymentTile from "./DeploymentTile.svelte";
3
3
  export let dotrain;
4
4
  export let strategyName;
5
5
  </script>
6
6
 
7
- {#await DotrainOrderGui.getDeploymentDetails(dotrain) then deploymentsWithDetails}
8
- <div
9
- class="mr-auto grid w-full grid-cols-1 justify-items-start gap-4 md:grid-cols-2 lg:w-auto lg:grid-cols-3"
10
- >
11
- {#each deploymentsWithDetails as [key, { name, description }]}
12
- <DeploymentTile {name} {description} {key} {strategyName} />
13
- {/each}
14
- </div>
15
- {:catch error}
16
- <p class="text-red-500">Error loading deployments:</p>
17
- <p class="text-gray-500">
18
- {error instanceof Error ? error.message : 'Unknown error'}
19
- </p>
7
+ {#await DotrainOrderGui.getDeploymentDetails(dotrain) then result}
8
+ {#if result.error}
9
+ <p class="text-red-500">Error loading deployments:</p>
10
+ <p class="text-gray-500">
11
+ {result.error.msg}
12
+ </p>
13
+ {/if}
14
+
15
+ {#if result.value}
16
+ <div
17
+ class="mr-auto grid w-full grid-cols-1 justify-items-start gap-4 md:grid-cols-2 lg:w-auto lg:grid-cols-3"
18
+ >
19
+ {#each result.value as [key, { name, description }]}
20
+ <DeploymentTile {name} {description} {key} {strategyName} />
21
+ {/each}
22
+ </div>
23
+ {/if}
20
24
  {/await}
@@ -1,13 +1,12 @@
1
- <script>import {
2
- DotrainOrderGui
3
- } from "@rainlanguage/orderbook/js_api";
1
+ <script>import {} from "@rainlanguage/orderbook";
4
2
  import { Input } from "flowbite-svelte";
5
3
  import ButtonSelectOption from "./ButtonSelectOption.svelte";
6
4
  import DeploymentSectionHeader from "./DeploymentSectionHeader.svelte";
7
5
  import { CloseCircleSolid } from "flowbite-svelte-icons";
8
6
  import { onMount } from "svelte";
7
+ import { useGui } from "../../hooks/useGui";
9
8
  export let deposit;
10
- export let gui;
9
+ const gui = useGui();
11
10
  let error = "";
12
11
  let currentDeposit;
13
12
  let inputValue = "";
@@ -15,18 +14,30 @@ let tokenInfo = null;
15
14
  onMount(() => {
16
15
  setCurrentDeposit();
17
16
  });
18
- const setCurrentDeposit = async () => {
17
+ const getCurrentDeposit = () => {
18
+ const deposits = gui.getDeposits();
19
+ if (deposits.error) {
20
+ throw new Error(deposits.error.msg);
21
+ }
22
+ return deposits.value.find((d) => d.token === deposit.token?.key);
23
+ };
24
+ const setCurrentDeposit = () => {
19
25
  try {
20
- currentDeposit = gui.getDeposits().find((d) => d.token === deposit.token?.key);
26
+ currentDeposit = getCurrentDeposit();
21
27
  inputValue = currentDeposit?.amount || "";
22
- } catch {
28
+ } catch (e) {
23
29
  currentDeposit = void 0;
30
+ error = e.message ? e.message : "Error setting current deposit.";
24
31
  }
25
32
  };
26
33
  const getTokenSymbol = async () => {
27
34
  if (!deposit.token?.key) return;
28
35
  try {
29
- tokenInfo = await gui?.getTokenInfo(deposit.token?.key);
36
+ let result = await gui.getTokenInfo(deposit.token?.key);
37
+ if (result.error) {
38
+ throw new Error(result.error.msg);
39
+ }
40
+ tokenInfo = result.value;
30
41
  } catch (e) {
31
42
  const errorMessage = e.message ? e.message : "Error getting token info.";
32
43
  error = errorMessage;
@@ -35,18 +46,24 @@ const getTokenSymbol = async () => {
35
46
  function handlePresetClick(preset) {
36
47
  if (deposit.token?.key) {
37
48
  inputValue = preset;
38
- gui?.saveDeposit(deposit.token?.key, preset);
39
- gui = gui;
40
- currentDeposit = gui?.getDeposits().find((d) => d.token === deposit.token?.key);
49
+ gui.saveDeposit(deposit.token?.key, preset);
50
+ try {
51
+ currentDeposit = getCurrentDeposit();
52
+ } catch (e) {
53
+ error = e.message ? e.message : "Error handling preset click.";
54
+ }
41
55
  }
42
56
  }
43
57
  function handleInput(e) {
44
58
  if (deposit.token?.key) {
45
59
  if (e.currentTarget instanceof HTMLInputElement) {
46
60
  inputValue = e.currentTarget.value;
47
- gui?.saveDeposit(deposit.token.key, e.currentTarget.value);
48
- gui = gui;
49
- currentDeposit = gui?.getDeposits().find((d) => d.token === deposit.token?.key);
61
+ gui.saveDeposit(deposit.token.key, e.currentTarget.value);
62
+ try {
63
+ currentDeposit = getCurrentDeposit();
64
+ } catch (e2) {
65
+ error = e2.message ? e2.message : "Error handling input.";
66
+ }
50
67
  }
51
68
  }
52
69
  }
@@ -1,9 +1,8 @@
1
1
  import { SvelteComponent } from "svelte";
2
- import { DotrainOrderGui, type GuiDepositCfg } from '@rainlanguage/orderbook/js_api';
2
+ import { type GuiDepositCfg } from '@rainlanguage/orderbook';
3
3
  declare const __propDef: {
4
4
  props: {
5
5
  deposit: GuiDepositCfg;
6
- gui: DotrainOrderGui;
7
6
  };
8
7
  events: {
9
8
  [evt: string]: CustomEvent<any>;
@@ -1,17 +1,21 @@
1
1
  <script>import { Input } from "flowbite-svelte";
2
2
  import {
3
- DotrainOrderGui
4
- } from "@rainlanguage/orderbook/js_api";
3
+ } from "@rainlanguage/orderbook";
5
4
  import ButtonSelectOption from "./ButtonSelectOption.svelte";
6
5
  import DeploymentSectionHeader from "./DeploymentSectionHeader.svelte";
7
6
  import { onMount } from "svelte";
7
+ import { useGui } from "../../hooks/useGui";
8
8
  export let fieldDefinition;
9
- export let gui;
9
+ const gui = useGui();
10
10
  let currentValue;
11
11
  let inputValue = currentValue?.value ? currentValue?.value : fieldDefinition.default || null;
12
12
  onMount(() => {
13
13
  try {
14
- currentValue = gui.getFieldValue(fieldDefinition.binding);
14
+ const result = gui.getFieldValue(fieldDefinition.binding);
15
+ if (result.error) {
16
+ throw new Error(result.error.msg);
17
+ }
18
+ currentValue = result.value;
15
19
  inputValue = currentValue?.value ? currentValue?.value : fieldDefinition.default || null;
16
20
  } catch {
17
21
  currentValue = void 0;
@@ -19,19 +23,21 @@ onMount(() => {
19
23
  });
20
24
  async function handlePresetClick(preset) {
21
25
  inputValue = preset.value;
22
- gui?.saveFieldValue(fieldDefinition.binding, {
23
- isPreset: true,
24
- value: preset.id
25
- });
26
- currentValue = gui.getFieldValue(fieldDefinition.binding);
26
+ gui.saveFieldValue(fieldDefinition.binding, inputValue);
27
+ const result = gui.getFieldValue(fieldDefinition.binding);
28
+ if (result.error) {
29
+ throw new Error(result.error.msg);
30
+ }
31
+ currentValue = result.value;
27
32
  }
28
33
  async function handleCustomInputChange(value) {
29
34
  inputValue = value;
30
- gui?.saveFieldValue(fieldDefinition.binding, {
31
- isPreset: false,
32
- value
33
- });
34
- currentValue = gui.getFieldValue(fieldDefinition.binding);
35
+ gui.saveFieldValue(fieldDefinition.binding, inputValue);
36
+ const result = gui.getFieldValue(fieldDefinition.binding);
37
+ if (result.error) {
38
+ throw new Error(result.error.msg);
39
+ }
40
+ currentValue = result.value;
35
41
  }
36
42
  </script>
37
43
 
@@ -1,9 +1,8 @@
1
1
  import { SvelteComponent } from "svelte";
2
- import { DotrainOrderGui, type GuiFieldDefinitionCfg } from '@rainlanguage/orderbook/js_api';
2
+ import { type GuiFieldDefinitionCfg } from '@rainlanguage/orderbook';
3
3
  declare const __propDef: {
4
4
  props: {
5
5
  fieldDefinition: GuiFieldDefinitionCfg;
6
- gui: DotrainOrderGui;
7
6
  };
8
7
  events: {
9
8
  [evt: string]: CustomEvent<any>;