@rainlanguage/ui-components 0.0.1-alpha.10
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.
- package/README.md +58 -0
- package/dist/__fixtures__/orderDetail.d.ts +99 -0
- package/dist/__fixtures__/orderDetail.js +204 -0
- package/dist/__fixtures__/settings-12-11-24.json +160 -0
- package/dist/__mocks__/MockComponent.d.ts +1 -0
- package/dist/__mocks__/MockComponent.js +2 -0
- package/dist/__mocks__/MockComponent.svelte +3 -0
- package/dist/__mocks__/MockComponent.svelte.d.ts +18 -0
- package/dist/__mocks__/mockTransactionStore.d.ts +22 -0
- package/dist/__mocks__/mockTransactionStore.js +56 -0
- package/dist/__mocks__/mockWeb3Config.d.ts +2 -0
- package/dist/__mocks__/mockWeb3Config.js +15 -0
- package/dist/__mocks__/queries.d.ts +13 -0
- package/dist/__mocks__/queries.js +64 -0
- package/dist/__mocks__/settings.d.ts +3 -0
- package/dist/__mocks__/settings.js +37 -0
- package/dist/__mocks__/stores.d.ts +94 -0
- package/dist/__mocks__/stores.js +113 -0
- package/dist/app.css +3 -0
- package/dist/assets/ledger.svg +6 -0
- package/dist/assets/logo-dark.svg +15 -0
- package/dist/assets/logo-light.svg +15 -0
- package/dist/assets/walletconnect.svg +1 -0
- package/dist/components/BadgeActive.svelte +9 -0
- package/dist/components/BadgeActive.svelte.d.ts +19 -0
- package/dist/components/BlockQuote.svelte +1 -0
- package/dist/components/BlockQuote.svelte.d.ts +29 -0
- package/dist/components/ButtonDarkMode.svelte +14 -0
- package/dist/components/ButtonDarkMode.svelte.d.ts +18 -0
- package/dist/components/ButtonLoading.svelte +11 -0
- package/dist/components/ButtonLoading.svelte.d.ts +24 -0
- package/dist/components/ButtonTab.svelte +7 -0
- package/dist/components/ButtonTab.svelte.d.ts +23 -0
- package/dist/components/ButtonVaultLink.svelte +29 -0
- package/dist/components/ButtonVaultLink.svelte.d.ts +22 -0
- package/dist/components/CardProperty.svelte +11 -0
- package/dist/components/CardProperty.svelte.d.ts +31 -0
- package/dist/components/CheckboxMyItemsOnly.svelte +23 -0
- package/dist/components/CheckboxMyItemsOnly.svelte.d.ts +21 -0
- package/dist/components/CheckboxZeroBalanceVault.svelte +20 -0
- package/dist/components/CheckboxZeroBalanceVault.svelte.d.ts +19 -0
- package/dist/components/CodeMirrorDotrain.svelte +35 -0
- package/dist/components/CodeMirrorDotrain.svelte.d.ts +23 -0
- package/dist/components/CodeMirrorRainlang.svelte +34 -0
- package/dist/components/CodeMirrorRainlang.svelte.d.ts +23 -0
- package/dist/components/DropdownProperty.svelte +12 -0
- package/dist/components/DropdownProperty.svelte.d.ts +19 -0
- package/dist/components/EditableSpan.svelte +46 -0
- package/dist/components/EditableSpan.svelte.d.ts +21 -0
- package/dist/components/Hash.svelte +85 -0
- package/dist/components/Hash.svelte.d.ts +28 -0
- package/dist/components/Heading.svelte +19 -0
- package/dist/components/Heading.svelte.d.ts +29 -0
- package/dist/components/IconError.svelte +8 -0
- package/dist/components/IconError.svelte.d.ts +16 -0
- package/dist/components/IconExternalLink.svelte +18 -0
- package/dist/components/IconExternalLink.svelte.d.ts +18 -0
- package/dist/components/IconInfo.svelte +8 -0
- package/dist/components/IconInfo.svelte.d.ts +16 -0
- package/dist/components/IconLedger.svelte +13 -0
- package/dist/components/IconLedger.svelte.d.ts +16 -0
- package/dist/components/IconSuccess.svelte +8 -0
- package/dist/components/IconSuccess.svelte.d.ts +16 -0
- package/dist/components/IconTelegram.svelte +12 -0
- package/dist/components/IconTelegram.svelte.d.ts +25 -0
- package/dist/components/IconWalletConnect.svelte +13 -0
- package/dist/components/IconWalletConnect.svelte.d.ts +16 -0
- package/dist/components/IconWarning.svelte +8 -0
- package/dist/components/IconWarning.svelte.d.ts +16 -0
- package/dist/components/License.svelte +29 -0
- package/dist/components/License.svelte.d.ts +25 -0
- package/dist/components/ListViewOrderbookFilters.svelte +58 -0
- package/dist/components/ListViewOrderbookFilters.svelte.d.ts +28 -0
- package/dist/components/OrderOrVaultHash.svelte +24 -0
- package/dist/components/OrderOrVaultHash.svelte.d.ts +22 -0
- package/dist/components/PageHeader.svelte +33 -0
- package/dist/components/PageHeader.svelte.d.ts +21 -0
- package/dist/components/TanstackAppTable.svelte +73 -0
- package/dist/components/TanstackAppTable.svelte.d.ts +30 -0
- package/dist/components/Text.svelte +12 -0
- package/dist/components/Text.svelte.d.ts +31 -0
- package/dist/components/charts/APYTimeFilters.svelte +47 -0
- package/dist/components/charts/APYTimeFilters.svelte.d.ts +19 -0
- package/dist/components/charts/ChartTimeFilters.svelte +35 -0
- package/dist/components/charts/ChartTimeFilters.svelte.d.ts +18 -0
- package/dist/components/charts/LightweightChart.svelte +110 -0
- package/dist/components/charts/LightweightChart.svelte.d.ts +29 -0
- package/dist/components/charts/OrderTradesChart.svelte +36 -0
- package/dist/components/charts/OrderTradesChart.svelte.d.ts +21 -0
- package/dist/components/charts/TableTimeFilters.svelte +48 -0
- package/dist/components/charts/TableTimeFilters.svelte.d.ts +19 -0
- package/dist/components/charts/TanstackLightweightChartLine.svelte +24 -0
- package/dist/components/charts/TanstackLightweightChartLine.svelte.d.ts +23 -0
- package/dist/components/charts/VaultBalanceChart.svelte +37 -0
- package/dist/components/charts/VaultBalanceChart.svelte.d.ts +22 -0
- package/dist/components/checkbox/Checkbox.svelte +17 -0
- package/dist/components/checkbox/Checkbox.svelte.d.ts +21 -0
- package/dist/components/deployment/ButtonSelectOption.svelte +14 -0
- package/dist/components/deployment/ButtonSelectOption.svelte.d.ts +20 -0
- package/dist/components/deployment/ComposedRainlangModal.svelte +35 -0
- package/dist/components/deployment/ComposedRainlangModal.svelte.d.ts +19 -0
- package/dist/components/deployment/DeploymentSectionHeader.svelte +14 -0
- package/dist/components/deployment/DeploymentSectionHeader.svelte.d.ts +19 -0
- package/dist/components/deployment/DeploymentSteps.svelte +252 -0
- package/dist/components/deployment/DeploymentSteps.svelte.d.ts +38 -0
- package/dist/components/deployment/DeploymentTile.svelte +19 -0
- package/dist/components/deployment/DeploymentTile.svelte.d.ts +21 -0
- package/dist/components/deployment/DeploymentsSection.svelte +20 -0
- package/dist/components/deployment/DeploymentsSection.svelte.d.ts +19 -0
- package/dist/components/deployment/DepositInput.svelte +93 -0
- package/dist/components/deployment/DepositInput.svelte.d.ts +20 -0
- package/dist/components/deployment/DepositsSection.svelte +8 -0
- package/dist/components/deployment/DepositsSection.svelte.d.ts +20 -0
- package/dist/components/deployment/DisclaimerModal.svelte +54 -0
- package/dist/components/deployment/DisclaimerModal.svelte.d.ts +19 -0
- package/dist/components/deployment/FieldDefinitionInput.svelte +66 -0
- package/dist/components/deployment/FieldDefinitionInput.svelte.d.ts +20 -0
- package/dist/components/deployment/FieldDefinitionsSection.svelte +9 -0
- package/dist/components/deployment/FieldDefinitionsSection.svelte.d.ts +20 -0
- package/dist/components/deployment/InvalidStrategiesSection.svelte +19 -0
- package/dist/components/deployment/InvalidStrategiesSection.svelte.d.ts +19 -0
- package/dist/components/deployment/SelectToken.svelte +88 -0
- package/dist/components/deployment/SelectToken.svelte.d.ts +21 -0
- package/dist/components/deployment/SelectTokensSection.svelte +17 -0
- package/dist/components/deployment/SelectTokensSection.svelte.d.ts +21 -0
- package/dist/components/deployment/ShareChoicesButton.svelte +26 -0
- package/dist/components/deployment/ShareChoicesButton.svelte.d.ts +18 -0
- package/dist/components/deployment/StrategyPage.svelte +70 -0
- package/dist/components/deployment/StrategyPage.svelte.d.ts +19 -0
- package/dist/components/deployment/TokenIOInput.svelte +62 -0
- package/dist/components/deployment/TokenIOInput.svelte.d.ts +22 -0
- package/dist/components/deployment/TokenIOSection.svelte +17 -0
- package/dist/components/deployment/TokenIOSection.svelte.d.ts +21 -0
- package/dist/components/deployment/ValidStrategiesSection.svelte +25 -0
- package/dist/components/deployment/ValidStrategiesSection.svelte.d.ts +19 -0
- package/dist/components/deployment/getDeploymentTransactionArgs.d.ts +17 -0
- package/dist/components/deployment/getDeploymentTransactionArgs.js +24 -0
- package/dist/components/detail/DepositOrWithdrawButtons.svelte +44 -0
- package/dist/components/detail/DepositOrWithdrawButtons.svelte.d.ts +26 -0
- package/dist/components/detail/OrderDetail.svelte +195 -0
- package/dist/components/detail/OrderDetail.svelte.d.ts +36 -0
- package/dist/components/detail/TanstackOrderQuote.svelte +173 -0
- package/dist/components/detail/TanstackOrderQuote.svelte.d.ts +22 -0
- package/dist/components/detail/TanstackPageContentDetail.svelte +56 -0
- package/dist/components/detail/TanstackPageContentDetail.svelte.d.ts +31 -0
- package/dist/components/detail/VaultDetail.svelte +178 -0
- package/dist/components/detail/VaultDetail.svelte.d.ts +35 -0
- package/dist/components/dropdown/DropdownActiveSubgraphs.svelte +38 -0
- package/dist/components/dropdown/DropdownActiveSubgraphs.svelte.d.ts +21 -0
- package/dist/components/dropdown/DropdownCheckbox.svelte +77 -0
- package/dist/components/dropdown/DropdownCheckbox.svelte.d.ts +26 -0
- package/dist/components/dropdown/DropdownOrderListAccounts.svelte +15 -0
- package/dist/components/dropdown/DropdownOrderListAccounts.svelte.d.ts +20 -0
- package/dist/components/dropdown/DropdownOrderStatus.svelte +31 -0
- package/dist/components/dropdown/DropdownOrderStatus.svelte.d.ts +19 -0
- package/dist/components/dropdown/DropdownRadio.svelte +45 -0
- package/dist/components/dropdown/DropdownRadio.svelte.d.ts +30 -0
- package/dist/components/icon/RainLogo.svelte +54 -0
- package/dist/components/icon/RainLogo.svelte.d.ts +25 -0
- package/dist/components/icon/Refresh.svelte +57 -0
- package/dist/components/icon/Refresh.svelte.d.ts +40 -0
- package/dist/components/input/InputHex.svelte +42 -0
- package/dist/components/input/InputHex.svelte.d.ts +19 -0
- package/dist/components/input/InputOrderHash.svelte +22 -0
- package/dist/components/input/InputOrderHash.svelte.d.ts +20 -0
- package/dist/components/input/InputRegistryUrl.svelte +18 -0
- package/dist/components/input/InputRegistryUrl.svelte.d.ts +16 -0
- package/dist/components/input/InputToken.svelte +53 -0
- package/dist/components/input/InputToken.svelte.d.ts +19 -0
- package/dist/components/input/InputTokenAmount.svelte +63 -0
- package/dist/components/input/InputTokenAmount.svelte.d.ts +21 -0
- package/dist/components/tables/OrderAPY.svelte +57 -0
- package/dist/components/tables/OrderAPY.svelte.d.ts +19 -0
- package/dist/components/tables/OrderTradesListTable.svelte +145 -0
- package/dist/components/tables/OrderTradesListTable.svelte.d.ts +21 -0
- package/dist/components/tables/OrderVaultsVolTable.svelte +67 -0
- package/dist/components/tables/OrderVaultsVolTable.svelte.d.ts +19 -0
- package/dist/components/tables/OrdersListTable.svelte +181 -0
- package/dist/components/tables/OrdersListTable.svelte.d.ts +35 -0
- package/dist/components/tables/VaultBalanceChangesTable.svelte +74 -0
- package/dist/components/tables/VaultBalanceChangesTable.svelte.d.ts +17 -0
- package/dist/components/tables/VaultsListTable.svelte +229 -0
- package/dist/components/tables/VaultsListTable.svelte.d.ts +40 -0
- package/dist/components/wallet/WalletConnect.svelte +28 -0
- package/dist/components/wallet/WalletConnect.svelte.d.ts +23 -0
- package/dist/errors/DeploymentStepsError.d.ts +24 -0
- package/dist/errors/DeploymentStepsError.js +45 -0
- package/dist/errors/index.d.ts +1 -0
- package/dist/errors/index.js +1 -0
- package/dist/index.d.ts +89 -0
- package/dist/index.js +89 -0
- package/dist/queries/constants.d.ts +2 -0
- package/dist/queries/constants.js +2 -0
- package/dist/queries/keys.d.ts +9 -0
- package/dist/queries/keys.js +9 -0
- package/dist/queries/queryClient.d.ts +3 -0
- package/dist/queries/queryClient.js +16 -0
- package/dist/services/getExplorerLink.d.ts +1 -0
- package/dist/services/getExplorerLink.js +10 -0
- package/dist/services/handleShareChoices.d.ts +2 -0
- package/dist/services/handleShareChoices.js +10 -0
- package/dist/services/historicalOrderCharts.d.ts +12 -0
- package/dist/services/historicalOrderCharts.js +496 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.js +1 -0
- package/dist/services/registry.d.ts +25 -0
- package/dist/services/registry.js +133 -0
- package/dist/services/time.d.ts +6 -0
- package/dist/services/time.js +17 -0
- package/dist/stores/transactionStore.d.ts +98 -0
- package/dist/stores/transactionStore.js +303 -0
- package/dist/test/matchers.d.ts +6 -0
- package/dist/test/matchers.js +4 -0
- package/dist/types/appStores.d.ts +19 -0
- package/dist/types/appStores.js +1 -0
- package/dist/types/modal.d.ts +20 -0
- package/dist/types/modal.js +1 -0
- package/dist/types/strategy.d.ts +10 -0
- package/dist/types/strategy.js +1 -0
- package/dist/types/transaction.d.ts +27 -0
- package/dist/types/transaction.js +1 -0
- package/dist/utils/breadcrumbs.d.ts +5 -0
- package/dist/utils/breadcrumbs.js +9 -0
- package/dist/utils/codeMirrorThemes.d.ts +2 -0
- package/dist/utils/codeMirrorThemes.js +86 -0
- package/dist/utils/hex.d.ts +2 -0
- package/dist/utils/hex.js +3 -0
- package/dist/utils/lightweightChartsThemes.d.ts +52 -0
- package/dist/utils/lightweightChartsThemes.js +21 -0
- package/dist/utils/number.d.ts +14 -0
- package/dist/utils/number.js +43 -0
- package/dist/utils/time.d.ts +12 -0
- package/dist/utils/time.js +27 -0
- package/dist/utils/vault.d.ts +2 -0
- package/dist/utils/vault.js +29 -0
- package/package.json +86 -0
|
@@ -0,0 +1,252 @@
|
|
|
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";
|
|
5
|
+
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
|
+
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";
|
|
15
|
+
import {} from "svelte/store";
|
|
16
|
+
import ShareChoicesButton from "./ShareChoicesButton.svelte";
|
|
17
|
+
import { handleShareChoices } from "../../services/handleShareChoices";
|
|
18
|
+
import { getDeploymentTransactionArgs } from "./getDeploymentTransactionArgs";
|
|
19
|
+
import { DeploymentStepsError, DeploymentStepsErrorCode } from "../../errors";
|
|
20
|
+
import { onMount } from "svelte";
|
|
21
|
+
export let settings;
|
|
22
|
+
export let dotrain;
|
|
23
|
+
export let deployment;
|
|
24
|
+
export let strategyDetail;
|
|
25
|
+
export let gui;
|
|
26
|
+
export let handleDeployModal;
|
|
27
|
+
export let handleDisclaimerModal;
|
|
28
|
+
let allDepositFields = [];
|
|
29
|
+
let allTokenOutputs = [];
|
|
30
|
+
let allFieldDefinitionsWithoutDefaults = [];
|
|
31
|
+
let allFieldDefinitionsWithDefaults = [];
|
|
32
|
+
let allTokensSelected = false;
|
|
33
|
+
let showAdvancedOptions = false;
|
|
34
|
+
let checkingDeployment = false;
|
|
35
|
+
let allTokenInfos = [];
|
|
36
|
+
const selectTokens = gui.getSelectTokens();
|
|
37
|
+
const networkKey = gui.getNetworkKey();
|
|
38
|
+
const subgraphUrl = $settings?.subgraphs?.[networkKey] ?? "";
|
|
39
|
+
let deploymentStepsError = DeploymentStepsError.error;
|
|
40
|
+
export let wagmiConfig;
|
|
41
|
+
export let wagmiConnected;
|
|
42
|
+
export let appKitModal;
|
|
43
|
+
export let signerAddress;
|
|
44
|
+
onMount(async () => {
|
|
45
|
+
await areAllTokensSelected();
|
|
46
|
+
});
|
|
47
|
+
function getAllFieldDefinitions() {
|
|
48
|
+
try {
|
|
49
|
+
allFieldDefinitionsWithoutDefaults = gui.getAllFieldDefinitions(false);
|
|
50
|
+
allFieldDefinitionsWithDefaults = gui.getAllFieldDefinitions(true);
|
|
51
|
+
} catch (e) {
|
|
52
|
+
DeploymentStepsError.catch(e, DeploymentStepsErrorCode.NO_FIELD_DEFINITIONS);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async function getAllDepositFields() {
|
|
56
|
+
try {
|
|
57
|
+
let dep = gui.getCurrentDeployment();
|
|
58
|
+
let depositFields = dep.deposits;
|
|
59
|
+
allDepositFields = depositFields;
|
|
60
|
+
} catch (e) {
|
|
61
|
+
DeploymentStepsError.catch(e, DeploymentStepsErrorCode.NO_DEPOSITS);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
let allTokenInputs = [];
|
|
65
|
+
function getAllTokenInputs() {
|
|
66
|
+
try {
|
|
67
|
+
allTokenInputs = gui.getCurrentDeployment().deployment.order.inputs;
|
|
68
|
+
} catch (e) {
|
|
69
|
+
DeploymentStepsError.catch(e, DeploymentStepsErrorCode.NO_TOKEN_INPUTS);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function getAllTokenOutputs() {
|
|
73
|
+
try {
|
|
74
|
+
allTokenOutputs = gui.getCurrentDeployment().deployment.order.outputs;
|
|
75
|
+
} catch (e) {
|
|
76
|
+
DeploymentStepsError.catch(e, DeploymentStepsErrorCode.NO_TOKEN_OUTPUTS);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
$: if (selectTokens?.length === 0 || allTokensSelected) {
|
|
80
|
+
updateFields();
|
|
81
|
+
}
|
|
82
|
+
async function updateFields() {
|
|
83
|
+
try {
|
|
84
|
+
DeploymentStepsError.clear();
|
|
85
|
+
getAllDepositFields();
|
|
86
|
+
getAllFieldDefinitions();
|
|
87
|
+
getAllTokenInputs();
|
|
88
|
+
getAllTokenOutputs();
|
|
89
|
+
} catch (e) {
|
|
90
|
+
DeploymentStepsError.catch(e, DeploymentStepsErrorCode.NO_GUI);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async function _handleShareChoices() {
|
|
94
|
+
await handleShareChoices(gui);
|
|
95
|
+
}
|
|
96
|
+
async function onSelectTokenSelect() {
|
|
97
|
+
await areAllTokensSelected();
|
|
98
|
+
if (allTokensSelected) {
|
|
99
|
+
let newAllTokenInfos = await gui.getAllTokenInfos();
|
|
100
|
+
if (allTokenInfos !== newAllTokenInfos) {
|
|
101
|
+
allTokenInfos = newAllTokenInfos;
|
|
102
|
+
getAllDepositFields();
|
|
103
|
+
getAllFieldDefinitions();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
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;
|
|
116
|
+
}
|
|
117
|
+
if (!networkKey) {
|
|
118
|
+
DeploymentStepsError.catch(null, DeploymentStepsErrorCode.NO_CHAIN);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
let result = null;
|
|
122
|
+
checkingDeployment = true;
|
|
123
|
+
try {
|
|
124
|
+
result = await getDeploymentTransactionArgs(gui, $wagmiConfig);
|
|
125
|
+
} catch (e) {
|
|
126
|
+
checkingDeployment = false;
|
|
127
|
+
DeploymentStepsError.catch(e, DeploymentStepsErrorCode.ADD_ORDER_FAILED);
|
|
128
|
+
}
|
|
129
|
+
if (!result) {
|
|
130
|
+
checkingDeployment = false;
|
|
131
|
+
DeploymentStepsError.catch(null, DeploymentStepsErrorCode.ADD_ORDER_FAILED);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
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
|
+
}
|
|
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
|
+
</script>
|
|
169
|
+
|
|
170
|
+
<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>
|
|
176
|
+
{/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
|
+
|
|
193
|
+
{#if selectTokens && selectTokens.length > 0}
|
|
194
|
+
<SelectTokensSection {gui} {selectTokens} {onSelectTokenSelect} />
|
|
195
|
+
{/if}
|
|
196
|
+
|
|
197
|
+
{#if allTokensSelected || selectTokens?.length === 0}
|
|
198
|
+
{#if allFieldDefinitionsWithoutDefaults.length > 0}
|
|
199
|
+
<FieldDefinitionsSection
|
|
200
|
+
allFieldDefinitions={allFieldDefinitionsWithoutDefaults}
|
|
201
|
+
{gui}
|
|
202
|
+
/>
|
|
203
|
+
{/if}
|
|
204
|
+
|
|
205
|
+
<Toggle bind:checked={showAdvancedOptions}>Show advanced options</Toggle>
|
|
206
|
+
|
|
207
|
+
{#if allFieldDefinitionsWithDefaults.length > 0 && showAdvancedOptions}
|
|
208
|
+
<FieldDefinitionsSection allFieldDefinitions={allFieldDefinitionsWithDefaults} {gui} />
|
|
209
|
+
{/if}
|
|
210
|
+
|
|
211
|
+
{#if allDepositFields.length > 0 && showAdvancedOptions}
|
|
212
|
+
<DepositsSection bind:allDepositFields {gui} />
|
|
213
|
+
{/if}
|
|
214
|
+
|
|
215
|
+
{#if allTokenInputs.length > 0 && allTokenOutputs.length > 0 && showAdvancedOptions}
|
|
216
|
+
<TokenIOSection bind:allTokenInputs bind:allTokenOutputs {gui} />
|
|
217
|
+
{/if}
|
|
218
|
+
|
|
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}
|
|
227
|
+
|
|
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} />
|
|
244
|
+
{/if}
|
|
245
|
+
<ComposedRainlangModal {gui} />
|
|
246
|
+
<ShareChoicesButton handleShareChoices={_handleShareChoices} />
|
|
247
|
+
</div>
|
|
248
|
+
{/if}
|
|
249
|
+
</div>
|
|
250
|
+
{/if}
|
|
251
|
+
{/if}
|
|
252
|
+
</div>
|
|
@@ -0,0 +1,38 @@
|
|
|
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';
|
|
5
|
+
import { type Writable } from 'svelte/store';
|
|
6
|
+
import type { AppKit } from '@reown/appkit';
|
|
7
|
+
import type { DisclaimerModalProps, DeployModalProps } from '../../types/modal';
|
|
8
|
+
declare const __propDef: {
|
|
9
|
+
props: {
|
|
10
|
+
settings: Writable<ConfigSource>;
|
|
11
|
+
dotrain: string;
|
|
12
|
+
deployment: {
|
|
13
|
+
key: string;
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
strategyDetail: NameAndDescriptionCfg;
|
|
18
|
+
gui: DotrainOrderGui;
|
|
19
|
+
handleDeployModal: (args: DeployModalProps) => void;
|
|
20
|
+
handleDisclaimerModal: (args: DisclaimerModalProps) => void;
|
|
21
|
+
wagmiConfig: Writable<Config | undefined>;
|
|
22
|
+
wagmiConnected: Writable<boolean>;
|
|
23
|
+
appKitModal: Writable<AppKit>;
|
|
24
|
+
signerAddress: Writable<string | null>;
|
|
25
|
+
};
|
|
26
|
+
events: {
|
|
27
|
+
[evt: string]: CustomEvent<any>;
|
|
28
|
+
};
|
|
29
|
+
slots: {};
|
|
30
|
+
exports?: {} | undefined;
|
|
31
|
+
bindings?: string | undefined;
|
|
32
|
+
};
|
|
33
|
+
export type DeploymentStepsProps = typeof __propDef.props;
|
|
34
|
+
export type DeploymentStepsEvents = typeof __propDef.events;
|
|
35
|
+
export type DeploymentStepsSlots = typeof __propDef.slots;
|
|
36
|
+
export default class DeploymentSteps extends SvelteComponent<DeploymentStepsProps, DeploymentStepsEvents, DeploymentStepsSlots> {
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script>import { page } from "$app/stores";
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
export let strategyName;
|
|
4
|
+
export let key;
|
|
5
|
+
export let name;
|
|
6
|
+
export let description;
|
|
7
|
+
let customRegistryParam = "";
|
|
8
|
+
onMount(async () => {
|
|
9
|
+
customRegistryParam = $page.url.searchParams.get("registry") ? `?registry=${$page.url.searchParams.get("registry")}` : "";
|
|
10
|
+
});
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<a
|
|
14
|
+
href={`/deploy/${strategyName}/${key}${customRegistryParam}`}
|
|
15
|
+
class="flex h-full w-full max-w-sm cursor-pointer flex-col gap-y-4 rounded-3xl border border-gray-200 bg-white p-4 text-left hover:bg-gray-100 dark:border-gray-700 dark:bg-gray-800 dark:hover:bg-gray-700"
|
|
16
|
+
>
|
|
17
|
+
<h1 class="text-2xl font-semibold text-gray-900 dark:text-white">{name}</h1>
|
|
18
|
+
<p class="text-gray-600 dark:text-gray-400">{description}</p>
|
|
19
|
+
</a>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
strategyName: string;
|
|
5
|
+
key: string;
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
[evt: string]: CustomEvent<any>;
|
|
11
|
+
};
|
|
12
|
+
slots: {};
|
|
13
|
+
exports?: {} | undefined;
|
|
14
|
+
bindings?: string | undefined;
|
|
15
|
+
};
|
|
16
|
+
export type DeploymentTileProps = typeof __propDef.props;
|
|
17
|
+
export type DeploymentTileEvents = typeof __propDef.events;
|
|
18
|
+
export type DeploymentTileSlots = typeof __propDef.slots;
|
|
19
|
+
export default class DeploymentTile extends SvelteComponent<DeploymentTileProps, DeploymentTileEvents, DeploymentTileSlots> {
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script>import { DotrainOrderGui } from "@rainlanguage/orderbook/js_api";
|
|
2
|
+
import DeploymentTile from "./DeploymentTile.svelte";
|
|
3
|
+
export let dotrain;
|
|
4
|
+
export let strategyName;
|
|
5
|
+
</script>
|
|
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>
|
|
20
|
+
{/await}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
dotrain: string;
|
|
5
|
+
strategyName: string;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {};
|
|
11
|
+
exports?: {} | undefined;
|
|
12
|
+
bindings?: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
export type DeploymentsSectionProps = typeof __propDef.props;
|
|
15
|
+
export type DeploymentsSectionEvents = typeof __propDef.events;
|
|
16
|
+
export type DeploymentsSectionSlots = typeof __propDef.slots;
|
|
17
|
+
export default class DeploymentsSection extends SvelteComponent<DeploymentsSectionProps, DeploymentsSectionEvents, DeploymentsSectionSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<script>import {
|
|
2
|
+
DotrainOrderGui
|
|
3
|
+
} from "@rainlanguage/orderbook/js_api";
|
|
4
|
+
import { Input } from "flowbite-svelte";
|
|
5
|
+
import ButtonSelectOption from "./ButtonSelectOption.svelte";
|
|
6
|
+
import DeploymentSectionHeader from "./DeploymentSectionHeader.svelte";
|
|
7
|
+
import { CloseCircleSolid } from "flowbite-svelte-icons";
|
|
8
|
+
import { onMount } from "svelte";
|
|
9
|
+
export let deposit;
|
|
10
|
+
export let gui;
|
|
11
|
+
let error = "";
|
|
12
|
+
let currentDeposit;
|
|
13
|
+
let inputValue = "";
|
|
14
|
+
let tokenInfo = null;
|
|
15
|
+
onMount(() => {
|
|
16
|
+
setCurrentDeposit();
|
|
17
|
+
});
|
|
18
|
+
const setCurrentDeposit = async () => {
|
|
19
|
+
try {
|
|
20
|
+
currentDeposit = gui.getDeposits().find((d) => d.token === deposit.token?.key);
|
|
21
|
+
inputValue = currentDeposit?.amount || "";
|
|
22
|
+
} catch {
|
|
23
|
+
currentDeposit = void 0;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const getTokenSymbol = async () => {
|
|
27
|
+
if (!deposit.token?.key) return;
|
|
28
|
+
try {
|
|
29
|
+
tokenInfo = await gui?.getTokenInfo(deposit.token?.key);
|
|
30
|
+
} catch (e) {
|
|
31
|
+
const errorMessage = e.message ? e.message : "Error getting token info.";
|
|
32
|
+
error = errorMessage;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
function handlePresetClick(preset) {
|
|
36
|
+
if (deposit.token?.key) {
|
|
37
|
+
inputValue = preset;
|
|
38
|
+
gui?.saveDeposit(deposit.token?.key, preset);
|
|
39
|
+
gui = gui;
|
|
40
|
+
currentDeposit = gui?.getDeposits().find((d) => d.token === deposit.token?.key);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function handleInput(e) {
|
|
44
|
+
if (deposit.token?.key) {
|
|
45
|
+
if (e.currentTarget instanceof HTMLInputElement) {
|
|
46
|
+
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);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
$: if (deposit.token?.key) {
|
|
54
|
+
getTokenSymbol();
|
|
55
|
+
}
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<div class="flex w-full flex-col gap-6">
|
|
59
|
+
<DeploymentSectionHeader
|
|
60
|
+
title={tokenInfo?.symbol ? `Deposit amount (${tokenInfo?.symbol})` : 'Deposit amount'}
|
|
61
|
+
description={tokenInfo?.symbol
|
|
62
|
+
? `The amount of ${tokenInfo?.symbol} that you want to deposit.`
|
|
63
|
+
: 'The amount that you want to deposit.'}
|
|
64
|
+
/>
|
|
65
|
+
|
|
66
|
+
<div class="flex w-full flex-col gap-6">
|
|
67
|
+
{#if deposit.presets}
|
|
68
|
+
<div class="flex w-full flex-wrap gap-4">
|
|
69
|
+
{#each deposit.presets as preset}
|
|
70
|
+
<ButtonSelectOption
|
|
71
|
+
active={currentDeposit?.amount === preset}
|
|
72
|
+
buttonText={preset}
|
|
73
|
+
clickHandler={() => handlePresetClick(preset)}
|
|
74
|
+
/>
|
|
75
|
+
{/each}
|
|
76
|
+
</div>
|
|
77
|
+
{/if}
|
|
78
|
+
|
|
79
|
+
<Input
|
|
80
|
+
size="lg"
|
|
81
|
+
placeholder="Enter deposit amount"
|
|
82
|
+
bind:value={inputValue}
|
|
83
|
+
on:input={(e) => handleInput(e)}
|
|
84
|
+
/>
|
|
85
|
+
|
|
86
|
+
{#if error}
|
|
87
|
+
<div class="flex h-5 flex-row items-center gap-2">
|
|
88
|
+
<CloseCircleSolid class="h-5 w-5" color="red" />
|
|
89
|
+
<span>{error}</span>
|
|
90
|
+
</div>
|
|
91
|
+
{/if}
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import { DotrainOrderGui, type GuiDepositCfg } from '@rainlanguage/orderbook/js_api';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
deposit: 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 DepositInputProps = typeof __propDef.props;
|
|
16
|
+
export type DepositInputEvents = typeof __propDef.events;
|
|
17
|
+
export type DepositInputSlots = typeof __propDef.slots;
|
|
18
|
+
export default class DepositInput extends SvelteComponent<DepositInputProps, DepositInputEvents, DepositInputSlots> {
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<script>import { Alert, Modal, Button } from "flowbite-svelte";
|
|
2
|
+
import { ExclamationCircleSolid } from "flowbite-svelte-icons";
|
|
3
|
+
export let open = false;
|
|
4
|
+
export let onAccept = () => {
|
|
5
|
+
};
|
|
6
|
+
async function handleAcceptDisclaimer() {
|
|
7
|
+
open = false;
|
|
8
|
+
onAccept();
|
|
9
|
+
}
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<Modal
|
|
13
|
+
bind:open
|
|
14
|
+
class="max-h-full dark:border dark:border-gray-700 dark:bg-gray-900"
|
|
15
|
+
dialogClass="fixed top-0 start-0 end-1 h-modal md:inset-0 md:h-full z-50 w-full p-4 flex justify-center items-center h-full"
|
|
16
|
+
>
|
|
17
|
+
<div class="flex flex-col items-start gap-y-8 p-4">
|
|
18
|
+
<div class="space-y-4">
|
|
19
|
+
<Alert color="red" class="text-base">
|
|
20
|
+
<div class="flex items-center justify-center">
|
|
21
|
+
<ExclamationCircleSolid class="h-6 w-6 text-red-500" />
|
|
22
|
+
<span class="ml-2">
|
|
23
|
+
Before you deploy your strategy, make sure you understand the following...
|
|
24
|
+
</span>
|
|
25
|
+
</div>
|
|
26
|
+
</Alert>
|
|
27
|
+
<ul class="list-outside list-disc space-y-2">
|
|
28
|
+
<li class="ml-4">
|
|
29
|
+
This front end is provided as a tool to interact with the Raindex smart contracts.
|
|
30
|
+
</li>
|
|
31
|
+
<li class="ml-4">
|
|
32
|
+
You are deploying your own strategy and depositing funds to an immutable smart contract
|
|
33
|
+
using your own wallet and private keys.
|
|
34
|
+
</li>
|
|
35
|
+
<li class="ml-4">
|
|
36
|
+
Nobody is custodying your funds, there is no recourse for recovery of funds if lost.
|
|
37
|
+
</li>
|
|
38
|
+
<li class="ml-4">There is no endorsement or guarantee provided with these strategies.</li>
|
|
39
|
+
<li class="ml-4">
|
|
40
|
+
Do not proceed if you do not understand the strategy you are deploying.
|
|
41
|
+
</li>
|
|
42
|
+
<li class="ml-4">Do not invest unless you are prepared to lose all funds.</li>
|
|
43
|
+
</ul>
|
|
44
|
+
</div>
|
|
45
|
+
<div class="flex justify-center gap-2">
|
|
46
|
+
<Button
|
|
47
|
+
size="lg"
|
|
48
|
+
class="w-32 bg-gradient-to-br from-blue-600 to-violet-600"
|
|
49
|
+
on:click={handleAcceptDisclaimer}>Deploy</Button
|
|
50
|
+
>
|
|
51
|
+
<Button size="lg" class="w-32" color="light" on:click={() => (open = false)}>Cancel</Button>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
</Modal>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
open?: boolean;
|
|
5
|
+
onAccept?: () => void;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {};
|
|
11
|
+
exports?: {} | undefined;
|
|
12
|
+
bindings?: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
export type DisclaimerModalProps = typeof __propDef.props;
|
|
15
|
+
export type DisclaimerModalEvents = typeof __propDef.events;
|
|
16
|
+
export type DisclaimerModalSlots = typeof __propDef.slots;
|
|
17
|
+
export default class DisclaimerModal extends SvelteComponent<DisclaimerModalProps, DisclaimerModalEvents, DisclaimerModalSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<script>import { Input } from "flowbite-svelte";
|
|
2
|
+
import {
|
|
3
|
+
DotrainOrderGui
|
|
4
|
+
} from "@rainlanguage/orderbook/js_api";
|
|
5
|
+
import ButtonSelectOption from "./ButtonSelectOption.svelte";
|
|
6
|
+
import DeploymentSectionHeader from "./DeploymentSectionHeader.svelte";
|
|
7
|
+
import { onMount } from "svelte";
|
|
8
|
+
export let fieldDefinition;
|
|
9
|
+
export let gui;
|
|
10
|
+
let currentValue;
|
|
11
|
+
let inputValue = currentValue?.value ? currentValue?.value : fieldDefinition.default || null;
|
|
12
|
+
onMount(() => {
|
|
13
|
+
try {
|
|
14
|
+
currentValue = gui.getFieldValue(fieldDefinition.binding);
|
|
15
|
+
inputValue = currentValue?.value ? currentValue?.value : fieldDefinition.default || null;
|
|
16
|
+
} catch {
|
|
17
|
+
currentValue = void 0;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
async function handlePresetClick(preset) {
|
|
21
|
+
inputValue = preset.value;
|
|
22
|
+
gui?.saveFieldValue(fieldDefinition.binding, {
|
|
23
|
+
isPreset: true,
|
|
24
|
+
value: preset.id
|
|
25
|
+
});
|
|
26
|
+
currentValue = gui.getFieldValue(fieldDefinition.binding);
|
|
27
|
+
}
|
|
28
|
+
async function handleCustomInputChange(value) {
|
|
29
|
+
inputValue = value;
|
|
30
|
+
gui?.saveFieldValue(fieldDefinition.binding, {
|
|
31
|
+
isPreset: false,
|
|
32
|
+
value
|
|
33
|
+
});
|
|
34
|
+
currentValue = gui.getFieldValue(fieldDefinition.binding);
|
|
35
|
+
}
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<div class="flex w-full flex-col gap-6">
|
|
39
|
+
<DeploymentSectionHeader title={fieldDefinition.name} description={fieldDefinition.description} />
|
|
40
|
+
<div class="flex w-full flex-col gap-6">
|
|
41
|
+
{#if fieldDefinition.presets}
|
|
42
|
+
<div class="flex w-full flex-wrap gap-4">
|
|
43
|
+
{#each fieldDefinition.presets as preset}
|
|
44
|
+
<ButtonSelectOption
|
|
45
|
+
buttonText={preset.name || preset.value}
|
|
46
|
+
clickHandler={() => handlePresetClick(preset)}
|
|
47
|
+
active={currentValue?.value === preset.value}
|
|
48
|
+
/>
|
|
49
|
+
{/each}
|
|
50
|
+
</div>
|
|
51
|
+
{/if}
|
|
52
|
+
|
|
53
|
+
{#if !fieldDefinition.presets || fieldDefinition.showCustomField}
|
|
54
|
+
<Input
|
|
55
|
+
size="lg"
|
|
56
|
+
placeholder="Enter custom value"
|
|
57
|
+
bind:value={inputValue}
|
|
58
|
+
on:input={({ currentTarget }) => {
|
|
59
|
+
if (currentTarget instanceof HTMLInputElement) {
|
|
60
|
+
handleCustomInputChange(currentTarget.value);
|
|
61
|
+
}
|
|
62
|
+
}}
|
|
63
|
+
/>
|
|
64
|
+
{/if}
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import { DotrainOrderGui, type GuiFieldDefinitionCfg } from '@rainlanguage/orderbook/js_api';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
fieldDefinition: GuiFieldDefinitionCfg;
|
|
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 FieldDefinitionInputProps = typeof __propDef.props;
|
|
16
|
+
export type FieldDefinitionInputEvents = typeof __propDef.events;
|
|
17
|
+
export type FieldDefinitionInputSlots = typeof __propDef.slots;
|
|
18
|
+
export default class FieldDefinitionInput extends SvelteComponent<FieldDefinitionInputProps, FieldDefinitionInputEvents, FieldDefinitionInputSlots> {
|
|
19
|
+
}
|
|
20
|
+
export {};
|