@rainlanguage/ui-components 0.0.1-alpha.17 → 0.0.1-alpha.19

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.
@@ -1,6 +1,5 @@
1
1
  <script>import { Alert } from "flowbite-svelte";
2
- import TokenIOSection from "./TokenIOSection.svelte";
3
- import DepositsSection from "./DepositsSection.svelte";
2
+ import TokenIOInput from "./TokenIOInput.svelte";
4
3
  import ComposedRainlangModal from "./ComposedRainlangModal.svelte";
5
4
  import FieldDefinitionsSection from "./FieldDefinitionsSection.svelte";
6
5
  import {} from "@rainlanguage/orderbook/js_api";
@@ -16,6 +15,7 @@ import { handleShareChoices } from "../../services/handleShareChoices";
16
15
  import { getDeploymentTransactionArgs } from "./getDeploymentTransactionArgs";
17
16
  import { DeploymentStepsError, DeploymentStepsErrorCode } from "../../errors";
18
17
  import { onMount } from "svelte";
18
+ import DepositInput from "./DepositInput.svelte";
19
19
  import SelectToken from "./SelectToken.svelte";
20
20
  import DeploymentSectionHeader from "./DeploymentSectionHeader.svelte";
21
21
  import { useGui } from "../../hooks/useGui";
@@ -47,8 +47,16 @@ onMount(async () => {
47
47
  });
48
48
  function getAllFieldDefinitions() {
49
49
  try {
50
- allFieldDefinitionsWithoutDefaults = gui.getAllFieldDefinitions(false);
51
- allFieldDefinitionsWithDefaults = gui.getAllFieldDefinitions(true);
50
+ const allFieldDefinitionsResult = gui.getAllFieldDefinitions(false);
51
+ if (allFieldDefinitionsResult.error) {
52
+ throw new Error(allFieldDefinitionsResult.error.msg);
53
+ }
54
+ allFieldDefinitionsWithoutDefaults = allFieldDefinitionsResult.value;
55
+ const allFieldDefinitionsWithDefaultsResult = gui.getAllFieldDefinitions(true);
56
+ if (allFieldDefinitionsWithDefaultsResult.error) {
57
+ throw new Error(allFieldDefinitionsWithDefaultsResult.error.msg);
58
+ }
59
+ allFieldDefinitionsWithDefaults = allFieldDefinitionsWithDefaultsResult.value;
52
60
  } catch (e) {
53
61
  DeploymentStepsError.catch(e, DeploymentStepsErrorCode.NO_FIELD_DEFINITIONS);
54
62
  }
@@ -236,12 +244,20 @@ const areAllTokensSelected = async () => {
236
244
  <FieldDefinitionsSection allFieldDefinitions={allFieldDefinitionsWithDefaults} {gui} />
237
245
  {/if}
238
246
 
239
- {#if allDepositFields.length > 0 && showAdvancedOptions}
240
- <DepositsSection bind:allDepositFields {gui} />
247
+ {#if showAdvancedOptions}
248
+ {#each allDepositFields as deposit}
249
+ <DepositInput {deposit} {gui} />
250
+ {/each}
241
251
  {/if}
242
252
 
243
- {#if allTokenInputs.length > 0 && allTokenOutputs.length > 0 && showAdvancedOptions}
244
- <TokenIOSection bind:allTokenInputs bind:allTokenOutputs {gui} />
253
+ {#if showAdvancedOptions}
254
+ {#each allTokenInputs as input, i}
255
+ <TokenIOInput {i} label="Input" vault={input} {gui} />
256
+ {/each}
257
+
258
+ {#each allTokenOutputs as output, i}
259
+ <TokenIOInput {i} label="Output" vault={output} {gui} />
260
+ {/each}
245
261
  {/if}
246
262
 
247
263
  {#if $deploymentStepsError}
@@ -11,7 +11,11 @@ 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;
@@ -23,7 +27,11 @@ async function handlePresetClick(preset) {
23
27
  isPreset: true,
24
28
  value: preset.id
25
29
  });
26
- currentValue = gui.getFieldValue(fieldDefinition.binding);
30
+ const result = gui.getFieldValue(fieldDefinition.binding);
31
+ if (result.error) {
32
+ throw new Error(result.error.msg);
33
+ }
34
+ currentValue = result.value;
27
35
  }
28
36
  async function handleCustomInputChange(value) {
29
37
  inputValue = value;
@@ -31,7 +39,11 @@ async function handleCustomInputChange(value) {
31
39
  isPreset: false,
32
40
  value
33
41
  });
34
- currentValue = gui.getFieldValue(fieldDefinition.binding);
42
+ const result = gui.getFieldValue(fieldDefinition.binding);
43
+ if (result.error) {
44
+ throw new Error(result.error.msg);
45
+ }
46
+ currentValue = result.value;
35
47
  }
36
48
  </script>
37
49
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rainlanguage/ui-components",
3
- "version": "0.0.1-alpha.17",
3
+ "version": "0.0.1-alpha.19",
4
4
  "description": "A component library for building Svelte applications to be used with Raindex.",
5
5
  "license": "LicenseRef-DCL-1.0",
6
6
  "author": "Rain Open Source Software Ltd",
@@ -53,7 +53,7 @@
53
53
  "@fontsource/dm-sans": "^5.0.18",
54
54
  "@imask/svelte": "^7.3.0",
55
55
  "@observablehq/plot": "^0.6.13",
56
- "@rainlanguage/orderbook": "0.0.1-alpha.17",
56
+ "@rainlanguage/orderbook": "0.0.1-alpha.19",
57
57
  "@reown/appkit": "^1.6.4",
58
58
  "@reown/appkit-adapter-wagmi": "^1.6.4",
59
59
  "@sentry/sveltekit": "^7.107.0",
@@ -1,8 +0,0 @@
1
- <script>import DepositInput from "./DepositInput.svelte";
2
- export let allDepositFields;
3
- export let gui;
4
- </script>
5
-
6
- {#each allDepositFields as deposit}
7
- <DepositInput bind:deposit {gui} />
8
- {/each}
@@ -1,20 +0,0 @@
1
- import { SvelteComponent } from "svelte";
2
- import type { DotrainOrderGui, GuiDepositCfg } from '@rainlanguage/orderbook/js_api';
3
- declare const __propDef: {
4
- props: {
5
- allDepositFields: GuiDepositCfg[];
6
- gui: DotrainOrderGui;
7
- };
8
- events: {
9
- [evt: string]: CustomEvent<any>;
10
- };
11
- slots: {};
12
- exports?: {} | undefined;
13
- bindings?: string | undefined;
14
- };
15
- export type DepositsSectionProps = typeof __propDef.props;
16
- export type DepositsSectionEvents = typeof __propDef.events;
17
- export type DepositsSectionSlots = typeof __propDef.slots;
18
- export default class DepositsSection extends SvelteComponent<DepositsSectionProps, DepositsSectionEvents, DepositsSectionSlots> {
19
- }
20
- export {};
@@ -1,17 +0,0 @@
1
- <script>import TokenIOInput from "./TokenIOInput.svelte";
2
- export let allTokenInputs = [];
3
- export let allTokenOutputs = [];
4
- export let gui;
5
- </script>
6
-
7
- {#if allTokenInputs.length > 0}
8
- {#each allTokenInputs as input, i}
9
- <TokenIOInput {i} label="Input" vault={input} {gui} />
10
- {/each}
11
- {/if}
12
-
13
- {#if allTokenOutputs.length > 0}
14
- {#each allTokenOutputs as output, i}
15
- <TokenIOInput {i} label="Output" vault={output} {gui} />
16
- {/each}
17
- {/if}
@@ -1,21 +0,0 @@
1
- import { SvelteComponent } from "svelte";
2
- import type { DotrainOrderGui, OrderIOCfg } from '@rainlanguage/orderbook/js_api';
3
- declare const __propDef: {
4
- props: {
5
- allTokenInputs?: OrderIOCfg[];
6
- allTokenOutputs?: OrderIOCfg[];
7
- gui: DotrainOrderGui;
8
- };
9
- events: {
10
- [evt: string]: CustomEvent<any>;
11
- };
12
- slots: {};
13
- exports?: {} | undefined;
14
- bindings?: string | undefined;
15
- };
16
- export type TokenIoSectionProps = typeof __propDef.props;
17
- export type TokenIoSectionEvents = typeof __propDef.events;
18
- export type TokenIoSectionSlots = typeof __propDef.slots;
19
- export default class TokenIoSection extends SvelteComponent<TokenIoSectionProps, TokenIoSectionEvents, TokenIoSectionSlots> {
20
- }
21
- export {};