@rainlanguage/ui-components 0.0.1-alpha.23 → 0.0.1-alpha.231
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/dist/__fixtures__/settings.yaml +125 -0
- package/dist/__mocks__/CodeMirrorRainlang.svelte +4 -0
- package/dist/__mocks__/CodeMirrorRainlang.svelte.d.ts +18 -0
- package/dist/__mocks__/MockComponent.svelte +4 -0
- package/dist/__mocks__/MockComponent.svelte.d.ts +3 -1
- package/dist/__mocks__/stores.d.ts +53 -43
- package/dist/__mocks__/stores.js +66 -49
- package/dist/components/ButtonLoading.svelte +1 -1
- package/dist/components/ButtonVaultLink.svelte +11 -11
- package/dist/components/ButtonVaultLink.svelte.d.ts +4 -3
- package/dist/components/CheckboxInactiveOrdersVault.svelte +20 -0
- package/dist/components/CheckboxInactiveOrdersVault.svelte.d.ts +19 -0
- package/dist/components/CheckboxZeroBalanceVault.svelte.d.ts +2 -2
- package/dist/components/CodeMirrorDotrain.svelte +4 -0
- package/dist/components/CodeMirrorDotrain.svelte.d.ts +1 -0
- package/dist/components/CodeMirrorRainlang.svelte +3 -12
- package/dist/components/CodeMirrorRainlang.svelte.d.ts +2 -2
- package/dist/components/EditableSpan.svelte +3 -14
- package/dist/components/EditableSpan.svelte.d.ts +0 -1
- package/dist/components/Hash.svelte +3 -3
- package/dist/components/License.svelte +5 -4
- package/dist/components/ListViewOrderbookFilters.svelte +39 -33
- package/dist/components/ListViewOrderbookFilters.svelte.d.ts +26 -22
- package/dist/components/LocalDbStatusBadge.svelte +27 -0
- package/dist/components/LocalDbStatusBadge.svelte.d.ts +19 -0
- package/dist/components/LocalDbStatusCard.svelte +40 -0
- package/dist/components/LocalDbStatusCard.svelte.d.ts +20 -0
- package/dist/components/LocalDbStatusModal.svelte +103 -0
- package/dist/components/LocalDbStatusModal.svelte.d.ts +21 -0
- package/dist/components/OrderOrVaultHash.svelte +12 -12
- package/dist/components/OrderOrVaultHash.svelte.d.ts +4 -4
- package/dist/components/PageHeader.svelte +1 -1
- package/dist/components/TanstackAppTable.svelte +179 -28
- package/dist/components/TanstackAppTable.svelte.d.ts +14 -8
- package/dist/components/ToastDetail.svelte +42 -0
- package/dist/components/ToastDetail.svelte.d.ts +20 -0
- package/dist/components/Tooltip.svelte +8 -0
- package/dist/components/Tooltip.svelte.d.ts +21 -0
- package/dist/components/VaultBalanceChangeTypeFilter.svelte +23 -0
- package/dist/components/VaultBalanceChangeTypeFilter.svelte.d.ts +19 -0
- package/dist/components/VaultCard.svelte +18 -0
- package/dist/components/VaultCard.svelte.d.ts +19 -0
- package/dist/components/charts/LightweightChart.svelte +1 -1
- package/dist/components/charts/LightweightChart.svelte.d.ts +5 -5
- package/dist/components/charts/OrderTradesChart.svelte +300 -28
- package/dist/components/charts/OrderTradesChart.svelte.d.ts +4 -4
- package/dist/components/charts/TanstackLightweightChartLine.svelte +5 -9
- package/dist/components/charts/VaultBalanceChart.svelte +8 -26
- package/dist/components/charts/VaultBalanceChart.svelte.d.ts +1 -7
- package/dist/components/charts/transformAndSortData.d.ts +24 -0
- package/dist/components/charts/transformAndSortData.js +111 -0
- package/dist/components/checkbox/CheckboxActiveOrders.svelte +11 -0
- package/dist/components/checkbox/CheckboxActiveOrders.svelte.d.ts +19 -0
- package/dist/components/deployment/ButtonSelectOption.svelte +2 -0
- package/dist/components/deployment/ButtonSelectOption.svelte.d.ts +1 -0
- package/dist/components/deployment/ComposedRainlangModal.svelte +2 -1
- package/dist/components/deployment/ComposedRainlangModal.svelte.d.ts +1 -4
- package/dist/components/deployment/DeploymentSectionHeader.svelte +7 -4
- package/dist/components/deployment/DeploymentSteps.svelte +185 -213
- package/dist/components/deployment/DeploymentSteps.svelte.d.ts +6 -12
- package/dist/components/deployment/DeploymentTile.svelte +2 -2
- package/dist/components/deployment/DeploymentTile.svelte.d.ts +1 -1
- package/dist/components/deployment/DeploymentsSection.svelte +15 -22
- package/dist/components/deployment/DeploymentsSection.svelte.d.ts +3 -2
- package/dist/components/deployment/DepositInput.svelte +8 -10
- package/dist/components/deployment/DepositInput.svelte.d.ts +1 -2
- package/dist/components/deployment/DisclaimerModal.svelte +6 -7
- package/dist/components/deployment/FieldDefinitionInput.svelte +7 -11
- package/dist/components/deployment/FieldDefinitionInput.svelte.d.ts +1 -2
- package/dist/components/deployment/InvalidOrdersSection.svelte +17 -0
- package/dist/components/deployment/InvalidOrdersSection.svelte.d.ts +19 -0
- package/dist/components/deployment/{StrategyPage.svelte → OrderPage.svelte} +15 -24
- package/dist/components/deployment/OrderPage.svelte.d.ts +21 -0
- package/dist/components/deployment/SelectToken.svelte +125 -48
- package/dist/components/deployment/SelectToken.svelte.d.ts +4 -3
- package/dist/components/deployment/TokenBalance.svelte +19 -0
- package/dist/components/deployment/TokenBalance.svelte.d.ts +19 -0
- package/dist/components/deployment/TokenIOInput.svelte +25 -15
- package/dist/components/deployment/TokenIOInput.svelte.d.ts +3 -3
- package/dist/components/deployment/TokenSelectionModal.svelte +148 -0
- package/dist/components/deployment/TokenSelectionModal.svelte.d.ts +20 -0
- package/dist/components/deployment/{ValidStrategiesSection.svelte → ValidOrdersSection.svelte} +7 -7
- package/dist/components/deployment/ValidOrdersSection.svelte.d.ts +19 -0
- package/dist/components/deployment/VaultIdInformation.svelte +17 -0
- package/dist/components/deployment/VaultIdInformation.svelte.d.ts +21 -0
- package/dist/components/detail/OrderDetail.svelte +212 -80
- package/dist/components/detail/OrderDetail.svelte.d.ts +21 -15
- package/dist/components/detail/TanstackOrderQuote.svelte +92 -46
- package/dist/components/detail/TanstackOrderQuote.svelte.d.ts +14 -16
- package/dist/components/detail/VaultDetail.svelte +78 -77
- package/dist/components/detail/VaultDetail.svelte.d.ts +12 -18
- package/dist/components/dropdown/DropdownActiveNetworks.svelte +44 -0
- package/dist/components/dropdown/DropdownActiveNetworks.svelte.d.ts +19 -0
- package/dist/components/dropdown/DropdownCheckbox.svelte +4 -4
- package/dist/components/dropdown/DropdownOrderbooksFilter.svelte +172 -0
- package/dist/components/dropdown/DropdownOrderbooksFilter.svelte.d.ts +25 -0
- package/dist/components/dropdown/DropdownTokensFilter.svelte +152 -0
- package/dist/components/dropdown/DropdownTokensFilter.svelte.d.ts +28 -0
- package/dist/components/icon/Refresh.svelte +2 -1
- package/dist/components/icon/Refresh.svelte.d.ts +1 -0
- package/dist/components/input/InputOrderHash.svelte +1 -1
- package/dist/components/input/InputOrderHash.svelte.d.ts +3 -3
- package/dist/components/input/InputOwnerFilter.svelte +48 -0
- package/dist/components/input/InputOwnerFilter.svelte.d.ts +19 -0
- package/dist/components/input/InputRegistryUrl.svelte +36 -14
- package/dist/components/input/InputToken.svelte +2 -2
- package/dist/components/input/InputTokenAmount.svelte +16 -21
- package/dist/components/input/InputTokenAmount.svelte.d.ts +3 -3
- package/dist/components/tables/OrderAPY.svelte +6 -33
- package/dist/components/tables/OrderAPY.svelte.d.ts +1 -4
- package/dist/components/tables/OrderTradesListTable.svelte +84 -81
- package/dist/components/tables/OrderTradesListTable.svelte.d.ts +4 -4
- package/dist/components/tables/OrderVaultsVolTable.svelte +17 -22
- package/dist/components/tables/OrderVaultsVolTable.svelte.d.ts +2 -2
- package/dist/components/tables/OrdersListTable.svelte +206 -114
- package/dist/components/tables/OrdersListTable.svelte.d.ts +18 -23
- package/dist/components/tables/VaultBalanceChangesTable.svelte +83 -43
- package/dist/components/tables/VaultBalanceChangesTable.svelte.d.ts +13 -11
- package/dist/components/tables/VaultsListTable.svelte +270 -148
- package/dist/components/tables/VaultsListTable.svelte.d.ts +24 -33
- package/dist/components/transactions/FixedBottomTransaction.svelte +63 -0
- package/dist/components/transactions/FixedBottomTransaction.svelte.d.ts +16 -0
- package/dist/components/transactions/TransactionDetail.svelte +31 -0
- package/dist/components/transactions/TransactionDetail.svelte.d.ts +20 -0
- package/dist/components/transactions/TransactionList.svelte +17 -0
- package/dist/components/transactions/TransactionList.svelte.d.ts +16 -0
- package/dist/components/transactions/getStatusEmoji.d.ts +2 -0
- package/dist/components/transactions/getStatusEmoji.js +20 -0
- package/dist/components/wallet/WalletConnect.svelte +5 -4
- package/dist/components/wallet/WalletConnect.svelte.d.ts +0 -1
- package/dist/consts.d.ts +1 -0
- package/dist/consts.js +1 -0
- package/dist/errors/DeploymentStepsError.d.ts +8 -2
- package/dist/errors/DeploymentStepsError.js +7 -1
- package/dist/hooks/useGui.d.ts +1 -1
- package/dist/hooks/useGui.js +1 -1
- package/dist/hooks/useLocalDb.d.ts +3 -0
- package/dist/hooks/useLocalDb.js +10 -0
- package/dist/hooks/useRaindexClient.d.ts +3 -0
- package/dist/hooks/useRaindexClient.js +11 -0
- package/dist/index.d.ts +43 -20
- package/dist/index.js +42 -17
- package/dist/models/Transaction.d.ts +75 -0
- package/dist/models/Transaction.js +100 -0
- package/dist/providers/GuiProvider.svelte +1 -1
- package/dist/providers/GuiProvider.svelte.d.ts +1 -1
- package/dist/providers/LocalDbProvider.svelte +8 -0
- package/dist/providers/LocalDbProvider.svelte.d.ts +21 -0
- package/dist/providers/RaindexClientProvider.svelte +8 -0
- package/dist/providers/RaindexClientProvider.svelte.d.ts +21 -0
- package/dist/providers/dotrainRegistry/DotrainRegistryProvider.svelte +8 -0
- package/dist/providers/dotrainRegistry/DotrainRegistryProvider.svelte.d.ts +24 -0
- package/dist/providers/dotrainRegistry/context.d.ts +9 -0
- package/dist/providers/dotrainRegistry/context.js +40 -0
- package/dist/providers/dotrainRegistry/useDotrainRegistry.d.ts +5 -0
- package/dist/providers/dotrainRegistry/useDotrainRegistry.js +35 -0
- package/dist/providers/registry/RegistryManager.d.ts +65 -0
- package/dist/providers/registry/RegistryManager.js +133 -0
- package/dist/providers/registry/RegistryProvider.svelte +6 -0
- package/dist/providers/registry/RegistryProvider.svelte.d.ts +21 -0
- package/dist/providers/registry/context.d.ts +10 -0
- package/dist/providers/registry/context.js +46 -0
- package/dist/providers/registry/useRegistry.d.ts +7 -0
- package/dist/providers/registry/useRegistry.js +29 -0
- package/dist/providers/toasts/ToastProvider.svelte +17 -0
- package/dist/providers/toasts/ToastProvider.svelte.d.ts +18 -0
- package/dist/providers/toasts/context.d.ts +14 -0
- package/dist/providers/toasts/context.js +22 -0
- package/dist/providers/toasts/useToasts.d.ts +16 -0
- package/dist/providers/toasts/useToasts.js +63 -0
- package/dist/providers/transactions/TransactionManager.d.ts +235 -0
- package/dist/providers/transactions/TransactionManager.js +509 -0
- package/dist/providers/transactions/TransactionProvider.svelte +11 -0
- package/dist/providers/transactions/TransactionProvider.svelte.d.ts +24 -0
- package/dist/providers/transactions/context.d.ts +19 -0
- package/dist/providers/transactions/context.js +28 -0
- package/dist/providers/transactions/useTransactions.d.ts +13 -0
- package/dist/providers/transactions/useTransactions.js +18 -0
- package/dist/providers/wallet/WalletProvider.svelte +7 -0
- package/dist/providers/wallet/WalletProvider.svelte.d.ts +21 -0
- package/dist/providers/wallet/context.d.ts +10 -0
- package/dist/providers/wallet/context.js +47 -0
- package/dist/providers/wallet/useAccount.d.ts +8 -0
- package/dist/providers/wallet/useAccount.js +148 -0
- package/dist/queries/keys.d.ts +1 -0
- package/dist/queries/keys.js +1 -0
- package/dist/queries/queryClient.d.ts +1 -1
- package/dist/queries/queryClient.js +11 -6
- package/dist/services/awaitTransactionIndexing.d.ts +107 -0
- package/dist/services/awaitTransactionIndexing.js +58 -0
- package/dist/services/getExplorerLink.d.ts +1 -1
- package/dist/services/getExplorerLink.js +2 -4
- package/dist/services/handleShareChoices.d.ts +2 -2
- package/dist/services/handleShareChoices.js +2 -1
- package/dist/services/historicalOrderCharts.d.ts +2 -2
- package/dist/services/historicalOrderCharts.js +267 -333
- package/dist/services/index.d.ts +2 -1
- package/dist/services/index.js +2 -1
- package/dist/services/loadRegistryUrl.d.ts +2 -0
- package/dist/services/loadRegistryUrl.js +22 -0
- package/dist/services/pairTradesChartData.d.ts +47 -0
- package/dist/services/pairTradesChartData.js +190 -0
- package/dist/services/registry.d.ts +5 -5
- package/dist/services/registry.js +8 -208
- package/dist/services/time.d.ts +12 -0
- package/dist/services/time.js +88 -6
- package/dist/storesGeneric/cachedWritableStore.d.ts +57 -0
- package/dist/storesGeneric/cachedWritableStore.js +93 -0
- package/dist/types/account.d.ts +3 -0
- package/dist/types/appStores.d.ts +9 -16
- package/dist/types/modal.d.ts +26 -14
- package/dist/types/{strategy.d.ts → order.d.ts} +3 -3
- package/dist/types/order.js +1 -0
- package/dist/types/toast.d.ts +11 -0
- package/dist/types/toast.js +1 -0
- package/dist/types/tokenBalance.d.ts +6 -0
- package/dist/types/tokenBalance.js +1 -0
- package/dist/types/transaction.d.ts +66 -21
- package/dist/types/transaction.js +31 -1
- package/dist/utils/configHelpers.d.ts +4 -0
- package/dist/utils/configHelpers.js +21 -0
- package/dist/utils/constructHashLink.d.ts +24 -0
- package/dist/utils/constructHashLink.js +115 -0
- package/dist/utils/getNetworkName.d.ts +1 -0
- package/dist/utils/getNetworkName.js +13 -0
- package/dist/utils/number.d.ts +0 -7
- package/dist/utils/number.js +0 -27
- package/dist/utils/tokens.d.ts +2 -0
- package/dist/utils/tokens.js +3 -0
- package/dist/utils/vaultBalanceChangeLabels.d.ts +4 -0
- package/dist/utils/vaultBalanceChangeLabels.js +18 -0
- package/package.json +39 -34
- package/dist/__fixtures__/orderDetail.d.ts +0 -99
- package/dist/__fixtures__/orderDetail.js +0 -204
- package/dist/__fixtures__/settings-12-11-24.json +0 -160
- package/dist/__mocks__/mockTransactionStore.d.ts +0 -22
- package/dist/__mocks__/mockTransactionStore.js +0 -56
- package/dist/__mocks__/settings.d.ts +0 -3
- package/dist/__mocks__/settings.js +0 -37
- package/dist/components/CheckboxMyItemsOnly.svelte +0 -23
- package/dist/components/CheckboxMyItemsOnly.svelte.d.ts +0 -21
- package/dist/components/deployment/InvalidStrategiesSection.svelte +0 -19
- package/dist/components/deployment/InvalidStrategiesSection.svelte.d.ts +0 -19
- package/dist/components/deployment/StrategyPage.svelte.d.ts +0 -19
- package/dist/components/deployment/ValidStrategiesSection.svelte.d.ts +0 -19
- package/dist/components/deployment/getDeploymentTransactionArgs.d.ts +0 -17
- package/dist/components/deployment/getDeploymentTransactionArgs.js +0 -28
- package/dist/components/detail/DepositOrWithdrawButtons.svelte +0 -44
- package/dist/components/detail/DepositOrWithdrawButtons.svelte.d.ts +0 -26
- package/dist/components/dropdown/DropdownActiveSubgraphs.svelte +0 -38
- package/dist/components/dropdown/DropdownActiveSubgraphs.svelte.d.ts +0 -21
- package/dist/components/dropdown/DropdownOrderListAccounts.svelte +0 -15
- package/dist/components/dropdown/DropdownOrderListAccounts.svelte.d.ts +0 -20
- package/dist/components/dropdown/DropdownOrderStatus.svelte +0 -31
- package/dist/components/dropdown/DropdownOrderStatus.svelte.d.ts +0 -19
- package/dist/stores/transactionStore.d.ts +0 -98
- package/dist/stores/transactionStore.js +0 -303
- package/dist/utils/time.d.ts +0 -12
- package/dist/utils/time.js +0 -27
- package/dist/utils/vault.d.ts +0 -2
- package/dist/utils/vault.js +0 -29
- /package/dist/types/{strategy.js → account.js} +0 -0
|
@@ -1,131 +1,142 @@
|
|
|
1
|
-
<script>import { Alert } from "flowbite-svelte";
|
|
1
|
+
<script>import { Alert, Button, Spinner, Toggle } from "flowbite-svelte";
|
|
2
2
|
import TokenIOInput from "./TokenIOInput.svelte";
|
|
3
3
|
import ComposedRainlangModal from "./ComposedRainlangModal.svelte";
|
|
4
4
|
import {
|
|
5
|
-
|
|
5
|
+
DotrainOrderGui,
|
|
6
|
+
RaindexClient,
|
|
7
|
+
AccountBalance,
|
|
8
|
+
Float
|
|
9
|
+
} from "@rainlanguage/orderbook";
|
|
6
10
|
import WalletConnect from "../wallet/WalletConnect.svelte";
|
|
7
|
-
import {
|
|
8
|
-
} from "@rainlanguage/orderbook/js_api";
|
|
9
|
-
import { fade } from "svelte/transition";
|
|
10
|
-
import { Button, Toggle, Spinner } from "flowbite-svelte";
|
|
11
|
-
import {} from "@wagmi/core";
|
|
12
11
|
import {} from "svelte/store";
|
|
13
|
-
import ShareChoicesButton from "./ShareChoicesButton.svelte";
|
|
14
12
|
import { handleShareChoices } from "../../services/handleShareChoices";
|
|
15
|
-
import { getDeploymentTransactionArgs } from "./getDeploymentTransactionArgs";
|
|
16
13
|
import { DeploymentStepsError, DeploymentStepsErrorCode } from "../../errors";
|
|
17
|
-
import { onMount } from "svelte";
|
|
14
|
+
import { onDestroy, onMount } from "svelte";
|
|
18
15
|
import FieldDefinitionInput from "./FieldDefinitionInput.svelte";
|
|
19
16
|
import DepositInput from "./DepositInput.svelte";
|
|
20
17
|
import SelectToken from "./SelectToken.svelte";
|
|
21
18
|
import DeploymentSectionHeader from "./DeploymentSectionHeader.svelte";
|
|
22
19
|
import { useGui } from "../../hooks/useGui";
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
import { fade } from "svelte/transition";
|
|
21
|
+
import ShareChoicesButton from "./ShareChoicesButton.svelte";
|
|
22
|
+
import { useRegistry } from "../../providers/registry/useRegistry";
|
|
23
|
+
import { useRaindexClient } from "../../hooks/useRaindexClient";
|
|
25
24
|
export let deployment;
|
|
26
|
-
export let
|
|
27
|
-
export let
|
|
28
|
-
export let
|
|
25
|
+
export let orderDetail;
|
|
26
|
+
export let onDeploy;
|
|
27
|
+
export let wagmiConnected;
|
|
28
|
+
export let appKitModal;
|
|
29
|
+
export let account;
|
|
29
30
|
let allDepositFields = [];
|
|
30
31
|
let allTokenOutputs = [];
|
|
32
|
+
let allTokenInputs = [];
|
|
31
33
|
let allFieldDefinitionsWithoutDefaults = [];
|
|
32
34
|
let allFieldDefinitionsWithDefaults = [];
|
|
33
35
|
let allTokensSelected = false;
|
|
34
36
|
let showAdvancedOptions = false;
|
|
35
|
-
let checkingDeployment = false;
|
|
36
37
|
let allTokenInfos = [];
|
|
37
|
-
const gui = useGui();
|
|
38
38
|
let selectTokens = void 0;
|
|
39
|
-
let
|
|
40
|
-
|
|
39
|
+
let checkingDeployment = false;
|
|
40
|
+
let tokenBalances = /* @__PURE__ */ new Map();
|
|
41
|
+
const gui = useGui();
|
|
42
|
+
const registry = useRegistry();
|
|
43
|
+
const raindexClient = useRaindexClient();
|
|
41
44
|
let deploymentStepsError = DeploymentStepsError.error;
|
|
42
|
-
export let wagmiConfig;
|
|
43
|
-
export let wagmiConnected;
|
|
44
|
-
export let appKitModal;
|
|
45
|
-
export let signerAddress;
|
|
46
45
|
onMount(async () => {
|
|
47
46
|
const selectTokensResult = gui.getSelectTokens();
|
|
48
47
|
if (selectTokensResult.error) {
|
|
49
48
|
throw new Error(selectTokensResult.error.msg);
|
|
50
49
|
}
|
|
51
50
|
selectTokens = selectTokensResult.value;
|
|
52
|
-
const networkKeyResult = gui.getNetworkKey();
|
|
53
|
-
if (networkKeyResult.error) {
|
|
54
|
-
throw new Error(networkKeyResult.error.msg);
|
|
55
|
-
}
|
|
56
|
-
networkKey = networkKeyResult.value;
|
|
57
51
|
await areAllTokensSelected();
|
|
58
52
|
});
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const allFieldDefinitionsResult = gui.getAllFieldDefinitions(false);
|
|
62
|
-
if (allFieldDefinitionsResult.error) {
|
|
63
|
-
throw new Error(allFieldDefinitionsResult.error.msg);
|
|
64
|
-
}
|
|
65
|
-
allFieldDefinitionsWithoutDefaults = allFieldDefinitionsResult.value;
|
|
66
|
-
const allFieldDefinitionsWithDefaultsResult = gui.getAllFieldDefinitions(true);
|
|
67
|
-
if (allFieldDefinitionsWithDefaultsResult.error) {
|
|
68
|
-
throw new Error(allFieldDefinitionsWithDefaultsResult.error.msg);
|
|
69
|
-
}
|
|
70
|
-
allFieldDefinitionsWithDefaults = allFieldDefinitionsWithDefaultsResult.value;
|
|
71
|
-
} catch (e) {
|
|
72
|
-
DeploymentStepsError.catch(e, DeploymentStepsErrorCode.NO_FIELD_DEFINITIONS);
|
|
73
|
-
}
|
|
53
|
+
$: if (selectTokens?.length === 0 || allTokensSelected) {
|
|
54
|
+
updateFields();
|
|
74
55
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
let depositFields = result.value.deposits;
|
|
82
|
-
allDepositFields = depositFields;
|
|
83
|
-
} catch (e) {
|
|
84
|
-
DeploymentStepsError.catch(e, DeploymentStepsErrorCode.NO_DEPOSITS);
|
|
56
|
+
let unsubscribeAccount = account.subscribe((account2) => {
|
|
57
|
+
if (!account2) {
|
|
58
|
+
const balances = tokenBalances;
|
|
59
|
+
balances.clear();
|
|
60
|
+
tokenBalances = balances;
|
|
61
|
+
return;
|
|
85
62
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
let result = gui.getCurrentDeployment();
|
|
91
|
-
if (result.error) {
|
|
92
|
-
throw new Error(result.error.msg);
|
|
93
|
-
}
|
|
94
|
-
allTokenInputs = result.value.deployment.order.inputs;
|
|
95
|
-
} catch (e) {
|
|
96
|
-
DeploymentStepsError.catch(e, DeploymentStepsErrorCode.NO_TOKEN_INPUTS);
|
|
63
|
+
if (selectTokens) {
|
|
64
|
+
selectTokens.forEach(async (selectToken) => {
|
|
65
|
+
await getTokenInfoAndFetchBalance(selectToken.key);
|
|
66
|
+
});
|
|
97
67
|
}
|
|
98
|
-
}
|
|
99
|
-
|
|
68
|
+
});
|
|
69
|
+
onDestroy(() => {
|
|
70
|
+
unsubscribeAccount();
|
|
71
|
+
});
|
|
72
|
+
function getAllGuiConfig() {
|
|
100
73
|
try {
|
|
101
|
-
let result = gui.
|
|
74
|
+
let result = gui.getAllGuiConfig();
|
|
102
75
|
if (result.error) {
|
|
103
76
|
throw new Error(result.error.msg);
|
|
104
77
|
}
|
|
105
|
-
|
|
78
|
+
allFieldDefinitionsWithoutDefaults = result.value.fieldDefinitionsWithoutDefaults;
|
|
79
|
+
allFieldDefinitionsWithDefaults = result.value.fieldDefinitionsWithDefaults;
|
|
80
|
+
allDepositFields = result.value.deposits;
|
|
81
|
+
allTokenOutputs = result.value.orderOutputs;
|
|
82
|
+
allTokenInputs = result.value.orderInputs;
|
|
106
83
|
} catch (e) {
|
|
107
|
-
DeploymentStepsError.catch(e, DeploymentStepsErrorCode.
|
|
84
|
+
DeploymentStepsError.catch(e, DeploymentStepsErrorCode.NO_GUI_CONFIG);
|
|
108
85
|
}
|
|
109
86
|
}
|
|
110
|
-
|
|
111
|
-
updateFields();
|
|
112
|
-
}
|
|
113
|
-
async function updateFields() {
|
|
87
|
+
function updateFields() {
|
|
114
88
|
try {
|
|
115
89
|
DeploymentStepsError.clear();
|
|
116
|
-
|
|
117
|
-
getAllFieldDefinitions();
|
|
118
|
-
getAllTokenInputs();
|
|
119
|
-
getAllTokenOutputs();
|
|
90
|
+
getAllGuiConfig();
|
|
120
91
|
} catch (e) {
|
|
121
92
|
DeploymentStepsError.catch(e, DeploymentStepsErrorCode.NO_GUI);
|
|
122
93
|
}
|
|
123
94
|
}
|
|
124
95
|
async function _handleShareChoices() {
|
|
125
|
-
await handleShareChoices(gui);
|
|
96
|
+
await handleShareChoices(gui, registry.getCurrentRegistry());
|
|
97
|
+
}
|
|
98
|
+
async function fetchTokenBalance(tokenInfo) {
|
|
99
|
+
if (!$account) return;
|
|
100
|
+
const balances = tokenBalances;
|
|
101
|
+
balances.set(tokenInfo.key, {
|
|
102
|
+
value: { balance: Float.parse("0").value, formattedBalance: "0" },
|
|
103
|
+
loading: true,
|
|
104
|
+
error: ""
|
|
105
|
+
});
|
|
106
|
+
const { value: accountBalance, error } = await gui.getAccountBalance(
|
|
107
|
+
tokenInfo.address,
|
|
108
|
+
$account
|
|
109
|
+
);
|
|
110
|
+
if (error) {
|
|
111
|
+
balances.set(tokenInfo.key, {
|
|
112
|
+
value: { balance: Float.parse("0").value, formattedBalance: "0" },
|
|
113
|
+
loading: false,
|
|
114
|
+
error: error.readableMsg
|
|
115
|
+
});
|
|
116
|
+
tokenBalances = balances;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
balances.set(tokenInfo.key, {
|
|
120
|
+
value: accountBalance,
|
|
121
|
+
loading: false,
|
|
122
|
+
error: ""
|
|
123
|
+
});
|
|
124
|
+
tokenBalances = balances;
|
|
126
125
|
}
|
|
127
|
-
async function
|
|
126
|
+
async function getTokenInfoAndFetchBalance(key) {
|
|
127
|
+
const tokenInfoResult = await gui.getTokenInfo(key);
|
|
128
|
+
if (tokenInfoResult.error) {
|
|
129
|
+
throw new Error(tokenInfoResult.error.msg);
|
|
130
|
+
}
|
|
131
|
+
const tokenInfo = tokenInfoResult.value;
|
|
132
|
+
if (!tokenInfo || !tokenInfo.address) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
await fetchTokenBalance(tokenInfo);
|
|
136
|
+
}
|
|
137
|
+
async function onSelectTokenSelect(key) {
|
|
128
138
|
await areAllTokensSelected();
|
|
139
|
+
await getTokenInfoAndFetchBalance(key);
|
|
129
140
|
if (allTokensSelected) {
|
|
130
141
|
let result = await gui.getAllTokenInfos();
|
|
131
142
|
if (result.error) {
|
|
@@ -134,58 +145,10 @@ async function onSelectTokenSelect() {
|
|
|
134
145
|
let newAllTokenInfos = result.value;
|
|
135
146
|
if (allTokenInfos !== newAllTokenInfos) {
|
|
136
147
|
allTokenInfos = newAllTokenInfos;
|
|
137
|
-
|
|
138
|
-
getAllFieldDefinitions();
|
|
148
|
+
getAllGuiConfig();
|
|
139
149
|
}
|
|
140
150
|
}
|
|
141
151
|
}
|
|
142
|
-
async function handleDeployButtonClick() {
|
|
143
|
-
DeploymentStepsError.clear();
|
|
144
|
-
if (!allTokenOutputs) {
|
|
145
|
-
DeploymentStepsError.catch(null, DeploymentStepsErrorCode.NO_TOKEN_OUTPUTS);
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
if (!wagmiConfig) {
|
|
149
|
-
DeploymentStepsError.catch(null, DeploymentStepsErrorCode.NO_CHAIN);
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
if (!networkKey) {
|
|
153
|
-
DeploymentStepsError.catch(null, DeploymentStepsErrorCode.NO_CHAIN);
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
let result = null;
|
|
157
|
-
checkingDeployment = true;
|
|
158
|
-
try {
|
|
159
|
-
result = await getDeploymentTransactionArgs(gui, $wagmiConfig);
|
|
160
|
-
} catch (e) {
|
|
161
|
-
checkingDeployment = false;
|
|
162
|
-
DeploymentStepsError.catch(e, DeploymentStepsErrorCode.ADD_ORDER_FAILED);
|
|
163
|
-
}
|
|
164
|
-
if (!result) {
|
|
165
|
-
checkingDeployment = false;
|
|
166
|
-
DeploymentStepsError.catch(null, DeploymentStepsErrorCode.ADD_ORDER_FAILED);
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
checkingDeployment = false;
|
|
170
|
-
const onAccept = () => {
|
|
171
|
-
if (!networkKey) {
|
|
172
|
-
DeploymentStepsError.catch(null, DeploymentStepsErrorCode.NO_CHAIN);
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
handleDeployModal({
|
|
176
|
-
open: true,
|
|
177
|
-
args: {
|
|
178
|
-
...result,
|
|
179
|
-
subgraphUrl,
|
|
180
|
-
network: networkKey
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
};
|
|
184
|
-
handleDisclaimerModal({
|
|
185
|
-
open: true,
|
|
186
|
-
onAccept
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
152
|
const areAllTokensSelected = async () => {
|
|
190
153
|
try {
|
|
191
154
|
const areAllTokensSelectedResult = gui.areAllTokensSelected();
|
|
@@ -214,105 +177,114 @@ const areAllTokensSelected = async () => {
|
|
|
214
177
|
DeploymentStepsError.catch(e, DeploymentStepsErrorCode.NO_SELECT_TOKENS);
|
|
215
178
|
}
|
|
216
179
|
};
|
|
180
|
+
async function handleDeployButtonClick() {
|
|
181
|
+
if (checkingDeployment) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
checkingDeployment = true;
|
|
185
|
+
try {
|
|
186
|
+
if (!$account) {
|
|
187
|
+
DeploymentStepsError.catch(
|
|
188
|
+
"No wallet connected",
|
|
189
|
+
DeploymentStepsErrorCode.ADD_ORDER_FAILED
|
|
190
|
+
);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
DeploymentStepsError.clear();
|
|
194
|
+
return onDeploy(raindexClient, gui);
|
|
195
|
+
} catch (e) {
|
|
196
|
+
DeploymentStepsError.catch(e, DeploymentStepsErrorCode.ADD_ORDER_FAILED);
|
|
197
|
+
} finally {
|
|
198
|
+
checkingDeployment = false;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
217
201
|
</script>
|
|
218
202
|
|
|
219
203
|
<div>
|
|
220
|
-
{#if
|
|
221
|
-
<
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
204
|
+
{#if gui}
|
|
205
|
+
<div class="flex max-w-3xl flex-col gap-12" in:fade>
|
|
206
|
+
{#if deployment}
|
|
207
|
+
<div class="flex max-w-2xl flex-col gap-4 text-start">
|
|
208
|
+
<h1 class="text-4xl font-semibold text-gray-900 lg:text-6xl dark:text-white">
|
|
209
|
+
{orderDetail.name}
|
|
210
|
+
</h1>
|
|
211
|
+
<p class="text-xl text-gray-600 lg:text-2xl dark:text-gray-400">
|
|
212
|
+
{deployment.description}
|
|
213
|
+
</p>
|
|
214
|
+
</div>
|
|
225
215
|
{/if}
|
|
226
|
-
</Alert>
|
|
227
|
-
{/if}
|
|
228
|
-
{#if dotrain}
|
|
229
|
-
{#if gui}
|
|
230
|
-
<div class="flex max-w-3xl flex-col gap-12" in:fade>
|
|
231
|
-
{#if deployment}
|
|
232
|
-
<div class="flex max-w-2xl flex-col gap-4 text-start">
|
|
233
|
-
<h1 class=" text-4xl font-semibold text-gray-900 lg:text-6xl dark:text-white">
|
|
234
|
-
{strategyDetail.name}
|
|
235
|
-
</h1>
|
|
236
|
-
<p class="text-xl text-gray-600 lg:text-2xl dark:text-gray-400">
|
|
237
|
-
{deployment.description}
|
|
238
|
-
</p>
|
|
239
|
-
</div>
|
|
240
|
-
{/if}
|
|
241
216
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
217
|
+
{#if selectTokens && selectTokens.length > 0}
|
|
218
|
+
<div class="flex w-full flex-col gap-4">
|
|
219
|
+
<DeploymentSectionHeader
|
|
220
|
+
title="Select Tokens"
|
|
221
|
+
description="Select the tokens that you want to use in your order."
|
|
222
|
+
/>
|
|
223
|
+
{#each selectTokens as token}
|
|
224
|
+
<SelectToken {token} {onSelectTokenSelect} {tokenBalances} />
|
|
225
|
+
{/each}
|
|
226
|
+
</div>
|
|
227
|
+
{/if}
|
|
228
|
+
|
|
229
|
+
{#if allTokensSelected || selectTokens?.length === 0}
|
|
230
|
+
{#if allFieldDefinitionsWithoutDefaults.length > 0}
|
|
231
|
+
{#each allFieldDefinitionsWithoutDefaults as fieldDefinition}
|
|
232
|
+
<FieldDefinitionInput {fieldDefinition} />
|
|
233
|
+
{/each}
|
|
252
234
|
{/if}
|
|
253
235
|
|
|
254
|
-
{
|
|
255
|
-
{#if allFieldDefinitionsWithoutDefaults.length > 0}
|
|
256
|
-
{#each allFieldDefinitionsWithoutDefaults as fieldDefinition}
|
|
257
|
-
<FieldDefinitionInput {fieldDefinition} {gui} />
|
|
258
|
-
{/each}
|
|
259
|
-
{/if}
|
|
236
|
+
<Toggle bind:checked={showAdvancedOptions}>Show advanced options</Toggle>
|
|
260
237
|
|
|
261
|
-
|
|
238
|
+
{#if showAdvancedOptions}
|
|
239
|
+
{#each allFieldDefinitionsWithDefaults as fieldDefinition}
|
|
240
|
+
<FieldDefinitionInput {fieldDefinition} />
|
|
241
|
+
{/each}
|
|
262
242
|
|
|
263
|
-
{#
|
|
264
|
-
{
|
|
265
|
-
|
|
266
|
-
{/each}
|
|
267
|
-
{/if}
|
|
243
|
+
{#each allDepositFields as deposit}
|
|
244
|
+
<DepositInput {deposit} />
|
|
245
|
+
{/each}
|
|
268
246
|
|
|
269
|
-
{#
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
{/each}
|
|
273
|
-
{/if}
|
|
247
|
+
{#each allTokenOutputs as output}
|
|
248
|
+
<TokenIOInput label="Output" vault={output} {tokenBalances} />
|
|
249
|
+
{/each}
|
|
274
250
|
|
|
275
|
-
{#
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
251
|
+
{#each allTokenInputs as input}
|
|
252
|
+
<TokenIOInput label="Input" vault={input} {tokenBalances} />
|
|
253
|
+
{/each}
|
|
254
|
+
{/if}
|
|
279
255
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
{
|
|
283
|
-
|
|
256
|
+
{#if $deploymentStepsError}
|
|
257
|
+
<Alert color="red">
|
|
258
|
+
<p class="text-red-500">{$deploymentStepsError.code}</p>
|
|
259
|
+
{#if $deploymentStepsError.details}
|
|
260
|
+
<p class="text-red-500">{$deploymentStepsError.details}</p>
|
|
261
|
+
{/if}
|
|
262
|
+
</Alert>
|
|
263
|
+
{/if}
|
|
284
264
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
265
|
+
<div class="flex flex-wrap items-start justify-start gap-2">
|
|
266
|
+
{#if $account}
|
|
267
|
+
<Button
|
|
268
|
+
data-testid="deploy-button"
|
|
269
|
+
size="lg"
|
|
270
|
+
disabled={checkingDeployment}
|
|
271
|
+
on:click={handleDeployButtonClick}
|
|
272
|
+
class="bg-gradient-to-br from-blue-600 to-violet-600"
|
|
273
|
+
>
|
|
274
|
+
{#if checkingDeployment}
|
|
275
|
+
<Spinner size="4" color="white" />
|
|
276
|
+
<span class="ml-2">Checking deployment...</span>
|
|
277
|
+
{:else}
|
|
278
|
+
Deploy Order
|
|
290
279
|
{/if}
|
|
291
|
-
</
|
|
280
|
+
</Button>
|
|
281
|
+
{:else}
|
|
282
|
+
<WalletConnect {appKitModal} connected={wagmiConnected} />
|
|
292
283
|
{/if}
|
|
293
|
-
|
|
294
|
-
<
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
on:click={handleDeployButtonClick}
|
|
299
|
-
class="bg-gradient-to-br from-blue-600 to-violet-600"
|
|
300
|
-
>
|
|
301
|
-
{#if checkingDeployment}
|
|
302
|
-
<Spinner size="4" color="white" />
|
|
303
|
-
<span class="ml-2">Checking deployment...</span>
|
|
304
|
-
{:else}
|
|
305
|
-
Deploy Strategy
|
|
306
|
-
{/if}
|
|
307
|
-
</Button>
|
|
308
|
-
{:else}
|
|
309
|
-
<WalletConnect {appKitModal} connected={wagmiConnected} {signerAddress} />
|
|
310
|
-
{/if}
|
|
311
|
-
<ComposedRainlangModal {gui} />
|
|
312
|
-
<ShareChoicesButton handleShareChoices={_handleShareChoices} />
|
|
313
|
-
</div>
|
|
314
|
-
{/if}
|
|
315
|
-
</div>
|
|
316
|
-
{/if}
|
|
284
|
+
<ComposedRainlangModal />
|
|
285
|
+
<ShareChoicesButton handleShareChoices={_handleShareChoices} />
|
|
286
|
+
</div>
|
|
287
|
+
{/if}
|
|
288
|
+
</div>
|
|
317
289
|
{/if}
|
|
318
290
|
</div>
|
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import { type
|
|
3
|
-
import { type NameAndDescriptionCfg } from '@rainlanguage/orderbook/js_api';
|
|
4
|
-
import { type Config } from '@wagmi/core';
|
|
2
|
+
import { type NameAndDescriptionCfg, DotrainOrderGui, RaindexClient } from '@rainlanguage/orderbook';
|
|
5
3
|
import { type Writable } from 'svelte/store';
|
|
6
4
|
import type { AppKit } from '@reown/appkit';
|
|
7
|
-
import type {
|
|
5
|
+
import type { Account } from '../../types/account';
|
|
8
6
|
declare const __propDef: {
|
|
9
7
|
props: {
|
|
10
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
handleDisclaimerModal: (args: DisclaimerModalProps) => void;
|
|
20
|
-
wagmiConfig: Writable<Config | undefined>;
|
|
13
|
+
/** Strategy details containing name and description configuration */ orderDetail: NameAndDescriptionCfg;
|
|
14
|
+
/** Handlers for deployment modals */ onDeploy: (raindexClient: RaindexClient, gui: DotrainOrderGui) => void;
|
|
21
15
|
wagmiConnected: Writable<boolean>;
|
|
22
16
|
appKitModal: Writable<AppKit>;
|
|
23
|
-
|
|
17
|
+
account: Account;
|
|
24
18
|
};
|
|
25
19
|
events: {
|
|
26
20
|
[evt: string]: CustomEvent<any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>import { page } from "$app/stores";
|
|
2
2
|
import { onMount } from "svelte";
|
|
3
|
-
export let
|
|
3
|
+
export let orderName;
|
|
4
4
|
export let key;
|
|
5
5
|
export let name;
|
|
6
6
|
export let description;
|
|
@@ -11,7 +11,7 @@ onMount(async () => {
|
|
|
11
11
|
</script>
|
|
12
12
|
|
|
13
13
|
<a
|
|
14
|
-
href={`/deploy/${
|
|
14
|
+
href={`/deploy/${orderName}/${key}${customRegistryParam}`}
|
|
15
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
16
|
>
|
|
17
17
|
<h1 class="text-2xl font-semibold text-gray-900 dark:text-white">{name}</h1>
|
|
@@ -1,24 +1,17 @@
|
|
|
1
|
-
<script>import
|
|
2
|
-
|
|
3
|
-
export let
|
|
4
|
-
|
|
1
|
+
<script>import DeploymentTile from "./DeploymentTile.svelte";
|
|
2
|
+
export let deployments = [];
|
|
3
|
+
export let orderName;
|
|
4
|
+
$: deploymentEntries = deployments instanceof Map ? Array.from(deployments.entries()) : deployments ?? [];
|
|
5
5
|
</script>
|
|
6
6
|
|
|
7
|
-
{#
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
>
|
|
19
|
-
{#each result.value as [key, { name, description }]}
|
|
20
|
-
<DeploymentTile {name} {description} {key} {strategyName} />
|
|
21
|
-
{/each}
|
|
22
|
-
</div>
|
|
23
|
-
{/if}
|
|
24
|
-
{/await}
|
|
7
|
+
{#if deploymentEntries.length === 0}
|
|
8
|
+
<p class="text-gray-500">No deployments found for this order.</p>
|
|
9
|
+
{:else}
|
|
10
|
+
<div
|
|
11
|
+
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"
|
|
12
|
+
>
|
|
13
|
+
{#each deploymentEntries as [key, { name, description }]}
|
|
14
|
+
<DeploymentTile {name} {description} {key} {orderName} />
|
|
15
|
+
{/each}
|
|
16
|
+
</div>
|
|
17
|
+
{/if}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { NameAndDescriptionCfg } from '@rainlanguage/orderbook';
|
|
2
3
|
declare const __propDef: {
|
|
3
4
|
props: {
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
deployments?: Map<string, NameAndDescriptionCfg> | [string, NameAndDescriptionCfg][];
|
|
6
|
+
orderName: string;
|
|
6
7
|
};
|
|
7
8
|
events: {
|
|
8
9
|
[evt: string]: CustomEvent<any>;
|
|
@@ -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
|
-
|
|
9
|
+
const gui = useGui();
|
|
11
10
|
let error = "";
|
|
12
11
|
let currentDeposit;
|
|
13
12
|
let inputValue = "";
|
|
@@ -44,11 +43,10 @@ const getTokenSymbol = async () => {
|
|
|
44
43
|
error = errorMessage;
|
|
45
44
|
}
|
|
46
45
|
};
|
|
47
|
-
function handlePresetClick(preset) {
|
|
46
|
+
async function handlePresetClick(preset) {
|
|
48
47
|
if (deposit.token?.key) {
|
|
49
48
|
inputValue = preset;
|
|
50
|
-
gui
|
|
51
|
-
gui = gui;
|
|
49
|
+
await gui.setDeposit(deposit.token?.key, preset);
|
|
52
50
|
try {
|
|
53
51
|
currentDeposit = getCurrentDeposit();
|
|
54
52
|
} catch (e) {
|
|
@@ -56,12 +54,11 @@ function handlePresetClick(preset) {
|
|
|
56
54
|
}
|
|
57
55
|
}
|
|
58
56
|
}
|
|
59
|
-
function handleInput(e) {
|
|
57
|
+
async function handleInput(e) {
|
|
60
58
|
if (deposit.token?.key) {
|
|
61
59
|
if (e.currentTarget instanceof HTMLInputElement) {
|
|
62
60
|
inputValue = e.currentTarget.value;
|
|
63
|
-
gui
|
|
64
|
-
gui = gui;
|
|
61
|
+
await gui.setDeposit(deposit.token.key, e.currentTarget.value);
|
|
65
62
|
try {
|
|
66
63
|
currentDeposit = getCurrentDeposit();
|
|
67
64
|
} catch (e2) {
|
|
@@ -88,6 +85,7 @@ $: if (deposit.token?.key) {
|
|
|
88
85
|
<div class="flex w-full flex-wrap gap-4">
|
|
89
86
|
{#each deposit.presets as preset}
|
|
90
87
|
<ButtonSelectOption
|
|
88
|
+
dataTestId={`deposit-preset-${preset}`}
|
|
91
89
|
active={currentDeposit?.amount === preset}
|
|
92
90
|
buttonText={preset}
|
|
93
91
|
clickHandler={() => handlePresetClick(preset)}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import {
|
|
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>;
|