@rainlanguage/ui-components 0.0.1-alpha.21 → 0.0.1-alpha.210
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 +47 -33
- package/dist/__mocks__/stores.js +61 -38
- 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/CheckboxMyItemsOnly.svelte +3 -2
- package/dist/components/CheckboxMyItemsOnly.svelte.d.ts +2 -3
- 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 +45 -23
- package/dist/components/ListViewOrderbookFilters.svelte.d.ts +27 -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 +209 -216
- 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 +184 -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/DropdownOrderListAccounts.svelte +5 -2
- package/dist/components/dropdown/DropdownOrderListAccounts.svelte.d.ts +2 -3
- 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/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 +200 -108
- package/dist/components/tables/OrdersListTable.svelte.d.ts +17 -21
- package/dist/components/tables/VaultBalanceChangesTable.svelte +83 -43
- package/dist/components/tables/VaultBalanceChangesTable.svelte.d.ts +13 -11
- package/dist/components/tables/VaultsListTable.svelte +268 -145
- package/dist/components/tables/VaultsListTable.svelte.d.ts +24 -32
- 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 +42 -19
- package/dist/index.js +41 -16
- 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 +7 -2
- 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 -14
- 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/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/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,120 +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
|
-
import {} from "@rainlanguage/orderbook/js_api";
|
|
5
|
-
import WalletConnect from "../wallet/WalletConnect.svelte";
|
|
6
4
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
DotrainOrderGui,
|
|
6
|
+
RaindexClient,
|
|
7
|
+
AccountBalance,
|
|
8
|
+
Float
|
|
9
|
+
} from "@rainlanguage/orderbook";
|
|
10
|
+
import WalletConnect from "../wallet/WalletConnect.svelte";
|
|
11
11
|
import {} from "svelte/store";
|
|
12
|
-
import ShareChoicesButton from "./ShareChoicesButton.svelte";
|
|
13
12
|
import { handleShareChoices } from "../../services/handleShareChoices";
|
|
14
|
-
import { getDeploymentTransactionArgs } from "./getDeploymentTransactionArgs";
|
|
15
13
|
import { DeploymentStepsError, DeploymentStepsErrorCode } from "../../errors";
|
|
16
|
-
import { onMount } from "svelte";
|
|
14
|
+
import { onDestroy, onMount } from "svelte";
|
|
17
15
|
import FieldDefinitionInput from "./FieldDefinitionInput.svelte";
|
|
18
16
|
import DepositInput from "./DepositInput.svelte";
|
|
19
17
|
import SelectToken from "./SelectToken.svelte";
|
|
20
18
|
import DeploymentSectionHeader from "./DeploymentSectionHeader.svelte";
|
|
21
19
|
import { useGui } from "../../hooks/useGui";
|
|
22
|
-
|
|
23
|
-
|
|
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";
|
|
24
24
|
export let deployment;
|
|
25
|
-
export let
|
|
26
|
-
export let
|
|
27
|
-
export let
|
|
25
|
+
export let orderDetail;
|
|
26
|
+
export let onDeploy;
|
|
27
|
+
export let wagmiConnected;
|
|
28
|
+
export let appKitModal;
|
|
29
|
+
export let account;
|
|
28
30
|
let allDepositFields = [];
|
|
29
31
|
let allTokenOutputs = [];
|
|
32
|
+
let allTokenInputs = [];
|
|
30
33
|
let allFieldDefinitionsWithoutDefaults = [];
|
|
31
34
|
let allFieldDefinitionsWithDefaults = [];
|
|
32
35
|
let allTokensSelected = false;
|
|
33
36
|
let showAdvancedOptions = false;
|
|
34
|
-
let checkingDeployment = false;
|
|
35
37
|
let allTokenInfos = [];
|
|
38
|
+
let selectTokens = void 0;
|
|
39
|
+
let checkingDeployment = false;
|
|
40
|
+
let tokenBalances = /* @__PURE__ */ new Map();
|
|
36
41
|
const gui = useGui();
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const subgraphUrl = $settings?.subgraphs?.[networkKey] ?? "";
|
|
42
|
+
const registry = useRegistry();
|
|
43
|
+
const raindexClient = useRaindexClient();
|
|
40
44
|
let deploymentStepsError = DeploymentStepsError.error;
|
|
41
|
-
export let wagmiConfig;
|
|
42
|
-
export let wagmiConnected;
|
|
43
|
-
export let appKitModal;
|
|
44
|
-
export let signerAddress;
|
|
45
45
|
onMount(async () => {
|
|
46
|
+
const selectTokensResult = gui.getSelectTokens();
|
|
47
|
+
if (selectTokensResult.error) {
|
|
48
|
+
throw new Error(selectTokensResult.error.msg);
|
|
49
|
+
}
|
|
50
|
+
selectTokens = selectTokensResult.value;
|
|
46
51
|
await areAllTokensSelected();
|
|
47
52
|
});
|
|
48
|
-
|
|
49
|
-
|
|
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;
|
|
60
|
-
} catch (e) {
|
|
61
|
-
DeploymentStepsError.catch(e, DeploymentStepsErrorCode.NO_FIELD_DEFINITIONS);
|
|
62
|
-
}
|
|
53
|
+
$: if (selectTokens?.length === 0 || allTokensSelected) {
|
|
54
|
+
updateFields();
|
|
63
55
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
let depositFields = result.value.deposits;
|
|
71
|
-
allDepositFields = depositFields;
|
|
72
|
-
} catch (e) {
|
|
73
|
-
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;
|
|
74
62
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
let result = gui.getCurrentDeployment();
|
|
80
|
-
if (result.error) {
|
|
81
|
-
throw new Error(result.error.msg);
|
|
82
|
-
}
|
|
83
|
-
allTokenInputs = result.value.deployment.order.inputs;
|
|
84
|
-
} catch (e) {
|
|
85
|
-
DeploymentStepsError.catch(e, DeploymentStepsErrorCode.NO_TOKEN_INPUTS);
|
|
63
|
+
if (selectTokens) {
|
|
64
|
+
selectTokens.forEach(async (selectToken) => {
|
|
65
|
+
await getTokenInfoAndFetchBalance(selectToken.key);
|
|
66
|
+
});
|
|
86
67
|
}
|
|
87
|
-
}
|
|
88
|
-
|
|
68
|
+
});
|
|
69
|
+
onDestroy(() => {
|
|
70
|
+
unsubscribeAccount();
|
|
71
|
+
});
|
|
72
|
+
function getAllGuiConfig() {
|
|
89
73
|
try {
|
|
90
|
-
let result = gui.
|
|
74
|
+
let result = gui.getAllGuiConfig();
|
|
91
75
|
if (result.error) {
|
|
92
76
|
throw new Error(result.error.msg);
|
|
93
77
|
}
|
|
94
|
-
|
|
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;
|
|
95
83
|
} catch (e) {
|
|
96
|
-
DeploymentStepsError.catch(e, DeploymentStepsErrorCode.
|
|
84
|
+
DeploymentStepsError.catch(e, DeploymentStepsErrorCode.NO_GUI_CONFIG);
|
|
97
85
|
}
|
|
98
86
|
}
|
|
99
|
-
|
|
100
|
-
updateFields();
|
|
101
|
-
}
|
|
102
|
-
async function updateFields() {
|
|
87
|
+
function updateFields() {
|
|
103
88
|
try {
|
|
104
89
|
DeploymentStepsError.clear();
|
|
105
|
-
|
|
106
|
-
getAllFieldDefinitions();
|
|
107
|
-
getAllTokenInputs();
|
|
108
|
-
getAllTokenOutputs();
|
|
90
|
+
getAllGuiConfig();
|
|
109
91
|
} catch (e) {
|
|
110
92
|
DeploymentStepsError.catch(e, DeploymentStepsErrorCode.NO_GUI);
|
|
111
93
|
}
|
|
112
94
|
}
|
|
113
95
|
async function _handleShareChoices() {
|
|
114
|
-
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;
|
|
115
125
|
}
|
|
116
|
-
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) {
|
|
117
138
|
await areAllTokensSelected();
|
|
139
|
+
await getTokenInfoAndFetchBalance(key);
|
|
118
140
|
if (allTokensSelected) {
|
|
119
141
|
let result = await gui.getAllTokenInfos();
|
|
120
142
|
if (result.error) {
|
|
@@ -123,175 +145,146 @@ async function onSelectTokenSelect() {
|
|
|
123
145
|
let newAllTokenInfos = result.value;
|
|
124
146
|
if (allTokenInfos !== newAllTokenInfos) {
|
|
125
147
|
allTokenInfos = newAllTokenInfos;
|
|
126
|
-
|
|
127
|
-
getAllFieldDefinitions();
|
|
148
|
+
getAllGuiConfig();
|
|
128
149
|
}
|
|
129
150
|
}
|
|
130
151
|
}
|
|
131
|
-
async function handleDeployButtonClick() {
|
|
132
|
-
DeploymentStepsError.clear();
|
|
133
|
-
if (!allTokenOutputs) {
|
|
134
|
-
DeploymentStepsError.catch(null, DeploymentStepsErrorCode.NO_TOKEN_OUTPUTS);
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
if (!wagmiConfig) {
|
|
138
|
-
DeploymentStepsError.catch(null, DeploymentStepsErrorCode.NO_CHAIN);
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
if (!networkKey) {
|
|
142
|
-
DeploymentStepsError.catch(null, DeploymentStepsErrorCode.NO_CHAIN);
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
let result = null;
|
|
146
|
-
checkingDeployment = true;
|
|
147
|
-
try {
|
|
148
|
-
result = await getDeploymentTransactionArgs(gui, $wagmiConfig);
|
|
149
|
-
} catch (e) {
|
|
150
|
-
checkingDeployment = false;
|
|
151
|
-
DeploymentStepsError.catch(e, DeploymentStepsErrorCode.ADD_ORDER_FAILED);
|
|
152
|
-
}
|
|
153
|
-
if (!result) {
|
|
154
|
-
checkingDeployment = false;
|
|
155
|
-
DeploymentStepsError.catch(null, DeploymentStepsErrorCode.ADD_ORDER_FAILED);
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
checkingDeployment = false;
|
|
159
|
-
const onAccept = () => {
|
|
160
|
-
if (!networkKey) {
|
|
161
|
-
DeploymentStepsError.catch(null, DeploymentStepsErrorCode.NO_CHAIN);
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
handleDeployModal({
|
|
165
|
-
open: true,
|
|
166
|
-
args: {
|
|
167
|
-
...result,
|
|
168
|
-
subgraphUrl,
|
|
169
|
-
network: networkKey
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
};
|
|
173
|
-
handleDisclaimerModal({
|
|
174
|
-
open: true,
|
|
175
|
-
onAccept
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
152
|
const areAllTokensSelected = async () => {
|
|
179
153
|
try {
|
|
180
|
-
|
|
154
|
+
const areAllTokensSelectedResult = gui.areAllTokensSelected();
|
|
155
|
+
if (areAllTokensSelectedResult.error) {
|
|
156
|
+
throw new Error(areAllTokensSelectedResult.error.msg);
|
|
157
|
+
}
|
|
158
|
+
allTokensSelected = areAllTokensSelectedResult.value;
|
|
181
159
|
if (!allTokensSelected) return;
|
|
182
|
-
|
|
183
|
-
if (
|
|
184
|
-
throw new Error(
|
|
160
|
+
const getAllTokenInfosResult = await gui.getAllTokenInfos();
|
|
161
|
+
if (getAllTokenInfosResult.error) {
|
|
162
|
+
throw new Error(getAllTokenInfosResult.error.msg);
|
|
163
|
+
}
|
|
164
|
+
allTokenInfos = getAllTokenInfosResult.value;
|
|
165
|
+
const hasDepositsResult = gui.hasAnyDeposit();
|
|
166
|
+
if (hasDepositsResult.error) {
|
|
167
|
+
throw new Error(hasDepositsResult.error.msg);
|
|
185
168
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
169
|
+
const hasVaultIdsResult = gui.hasAnyVaultId();
|
|
170
|
+
if (hasVaultIdsResult.error) {
|
|
171
|
+
throw new Error(hasVaultIdsResult.error.msg);
|
|
172
|
+
}
|
|
173
|
+
if (hasDepositsResult.value || hasVaultIdsResult.value) {
|
|
190
174
|
showAdvancedOptions = true;
|
|
191
175
|
}
|
|
192
176
|
} catch (e) {
|
|
193
177
|
DeploymentStepsError.catch(e, DeploymentStepsErrorCode.NO_SELECT_TOKENS);
|
|
194
178
|
}
|
|
195
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
|
+
}
|
|
196
201
|
</script>
|
|
197
202
|
|
|
198
203
|
<div>
|
|
199
|
-
{#if
|
|
200
|
-
<
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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>
|
|
204
215
|
{/if}
|
|
205
|
-
</Alert>
|
|
206
|
-
{/if}
|
|
207
|
-
{#if dotrain}
|
|
208
|
-
{#if gui}
|
|
209
|
-
<div class="flex max-w-3xl flex-col gap-12" in:fade>
|
|
210
|
-
{#if deployment}
|
|
211
|
-
<div class="flex max-w-2xl flex-col gap-4 text-start">
|
|
212
|
-
<h1 class=" text-4xl font-semibold text-gray-900 lg:text-6xl dark:text-white">
|
|
213
|
-
{strategyDetail.name}
|
|
214
|
-
</h1>
|
|
215
|
-
<p class="text-xl text-gray-600 lg:text-2xl dark:text-gray-400">
|
|
216
|
-
{deployment.description}
|
|
217
|
-
</p>
|
|
218
|
-
</div>
|
|
219
|
-
{/if}
|
|
220
216
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
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}
|
|
231
234
|
{/if}
|
|
232
235
|
|
|
233
|
-
{
|
|
234
|
-
{#if allFieldDefinitionsWithoutDefaults.length > 0}
|
|
235
|
-
{#each allFieldDefinitionsWithoutDefaults as fieldDefinition}
|
|
236
|
-
<FieldDefinitionInput {fieldDefinition} {gui} />
|
|
237
|
-
{/each}
|
|
238
|
-
{/if}
|
|
236
|
+
<Toggle bind:checked={showAdvancedOptions}>Show advanced options</Toggle>
|
|
239
237
|
|
|
240
|
-
|
|
238
|
+
{#if showAdvancedOptions}
|
|
239
|
+
{#each allFieldDefinitionsWithDefaults as fieldDefinition}
|
|
240
|
+
<FieldDefinitionInput {fieldDefinition} />
|
|
241
|
+
{/each}
|
|
241
242
|
|
|
242
|
-
{#
|
|
243
|
-
{
|
|
244
|
-
|
|
245
|
-
{/each}
|
|
246
|
-
{/if}
|
|
243
|
+
{#each allDepositFields as deposit}
|
|
244
|
+
<DepositInput {deposit} />
|
|
245
|
+
{/each}
|
|
247
246
|
|
|
248
|
-
{#
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
{/each}
|
|
252
|
-
{/if}
|
|
247
|
+
{#each allTokenOutputs as output}
|
|
248
|
+
<TokenIOInput label="Output" vault={output} {tokenBalances} />
|
|
249
|
+
{/each}
|
|
253
250
|
|
|
254
|
-
{#
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
251
|
+
{#each allTokenInputs as input}
|
|
252
|
+
<TokenIOInput label="Input" vault={input} {tokenBalances} />
|
|
253
|
+
{/each}
|
|
254
|
+
{/if}
|
|
258
255
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
{
|
|
262
|
-
|
|
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}
|
|
263
264
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
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
|
|
269
279
|
{/if}
|
|
270
|
-
</
|
|
280
|
+
</Button>
|
|
281
|
+
{:else}
|
|
282
|
+
<WalletConnect {appKitModal} connected={wagmiConnected} />
|
|
271
283
|
{/if}
|
|
272
|
-
|
|
273
|
-
<
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
on:click={handleDeployButtonClick}
|
|
278
|
-
class="bg-gradient-to-br from-blue-600 to-violet-600"
|
|
279
|
-
>
|
|
280
|
-
{#if checkingDeployment}
|
|
281
|
-
<Spinner size="4" color="white" />
|
|
282
|
-
<span class="ml-2">Checking deployment...</span>
|
|
283
|
-
{:else}
|
|
284
|
-
Deploy Strategy
|
|
285
|
-
{/if}
|
|
286
|
-
</Button>
|
|
287
|
-
{:else}
|
|
288
|
-
<WalletConnect {appKitModal} connected={wagmiConnected} {signerAddress} />
|
|
289
|
-
{/if}
|
|
290
|
-
<ComposedRainlangModal {gui} />
|
|
291
|
-
<ShareChoicesButton handleShareChoices={_handleShareChoices} />
|
|
292
|
-
</div>
|
|
293
|
-
{/if}
|
|
294
|
-
</div>
|
|
295
|
-
{/if}
|
|
284
|
+
<ComposedRainlangModal />
|
|
285
|
+
<ShareChoicesButton handleShareChoices={_handleShareChoices} />
|
|
286
|
+
</div>
|
|
287
|
+
{/if}
|
|
288
|
+
</div>
|
|
296
289
|
{/if}
|
|
297
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)}
|