diff --git a/src/components/UIA.jsx b/src/components/UIA.jsx index 0468058..ea95c5a 100644 --- a/src/components/UIA.jsx +++ b/src/components/UIA.jsx @@ -4,12 +4,10 @@ import { FixedSizeList as List } from "react-window"; import { useTranslation } from "react-i18next"; import { i18n as i18nInstance, locale } from "@/lib/i18n.js"; -import { DateTimePicker, TimePicker } from '@/components/ui/datetime-picker'; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea" import { Separator } from "@/components/ui/separator" -import { Label } from "@/components/ui/label"; import { Dialog, DialogContent, @@ -39,15 +37,24 @@ import { Avatar } from "./Avatar.tsx"; import { useInitCache } from "@/nanoeffects/Init.ts"; import { $currentUser } from "@/stores/users.ts"; +import { $currentNode } from "@/stores/node.ts"; import { $assetCacheBTS, $assetCacheTEST } from "@/stores/cache.ts"; -import { getPermissions, getFlags, debounce, humanReadableFloat } from "@/lib/common.js"; import { $marketSearchCacheBTS, $marketSearchCacheTEST } from "@/stores/cache.ts"; +import { createObjectStore } from "@/nanoeffects/Objects.ts"; -import { blockchainFloat } from "@/bts/common"; +import { + getPermissions, + getFlags, + debounce, + humanReadableFloat, + blockchainFloat, + getFlagBooleans +} from "@/lib/common.js"; export default function UIA(properties) { const { t, i18n } = useTranslation(locale.get(), { i18n: i18nInstance }); const usr = useSyncExternalStore($currentUser.subscribe, $currentUser.get, () => true); + const currentNode = useStore($currentNode); const _assetsBTS = useSyncExternalStore($assetCacheBTS.subscribe, $assetCacheBTS.get, () => true); const _assetsTEST = useSyncExternalStore( @@ -208,6 +215,9 @@ export default function UIA(properties) { return JSON.stringify({ main: desc, short_name: shortName, market }); }, [desc, market, shortName]); + const [editing, setEditing] = useState(false); // editing mode + const [existingAssetID, setExistingAssetID] = useState(); // existing asset ID + const trx = useMemo(() => { let _extensions = {}; if (enabledReferrerReward) { @@ -240,7 +250,7 @@ export default function UIA(properties) { }, quote: { amount: blockchainFloat(cerQuoteAmount, precision), - asset_id: "1.3.1" + asset_id: existingAssetID ?? "1.3.1" } }, whitelist_authorities: flagWhiteList && whitelistAuthorities && whitelistAuthorities.length @@ -250,11 +260,11 @@ export default function UIA(properties) { ? blacklistAuthorities.map((x) => x.id) : [], whitelist_markets: allowedMarkets.map((x) => { - const asset = assets.find((y) => y.symbol === x); + const asset = assets.find((y) => y.id === x); return asset ? asset.id : null; }).filter((x) => x), blacklist_markets: bannedMarkets.map((x) => { - const asset = assets.find((y) => y.symbol === x); + const asset = assets.find((y) => y.id === x); return asset ? asset.id : null; }).filter((x) => x), extensions: _extensions @@ -265,17 +275,29 @@ export default function UIA(properties) { }; }, [ usr, + assets, symbol, precision, description, maxSupply, commission, + maxCommission, issuer_permissions, flags, + flagWhiteList, + whitelistAuthorities, + blacklistAuthorities, + allowedMarkets, + bannedMarkets, cerBaseAmount, + cerQuoteAmount, enabledReferrerReward, enabledFeeSharingWhitelist, - enabledTakerFee + enabledTakerFee, + referrerReward, + feeSharingWhitelist, + takerFee, + existingAssetID ]); const debouncedMax = useCallback( @@ -325,14 +347,15 @@ export default function UIA(properties) { const [whitelistAuthorityDialogOpen, setWhitelistAuthorityDialogOpen] = useState(false); const [blacklistAuthorityDialogOpen, setBlacklistAuthorityDialogOpen] = useState(false); - const bannedMarketsRow = ({ index, style }) => { - let res = bannedMarkets[index]; + + const allowedMarketsRow = ({ index, style }) => { + let res = allowedMarkets[index]; if (!res) { return null; } - const currentAsset = assets.find((x) => x.symbol === res); - const issuer = marketSearch.find((x) => x.s === res); + const currentAsset = assets.find((x) => x.id === res); + const issuer = marketSearch.find((x) => x.id === res); return (
@@ -357,8 +380,8 @@ export default function UIA(properties) { className="mr-2 mt-2" onClick={(e) => { e.preventDefault(); - const _update = bannedMarkets.filter((x) => x !== res); - setBannedMarkets(_update); + const _update = allowedMarkets.filter((x) => x !== res); + setAllowedMarkets(_update); }} > ❌ @@ -369,17 +392,16 @@ export default function UIA(properties) {
); - }; - const allowedMarketsRow = ({ index, style }) => { - let res = allowedMarkets[index]; + const bannedMarketsRow = ({ index, style }) => { + let res = bannedMarkets[index]; if (!res) { return null; } - const currentAsset = assets.find((x) => x.symbol === res); - const issuer = marketSearch.find((x) => x.s === res); + const currentAsset = assets.find((x) => x.id === res); + const issuer = marketSearch.find((x) => x.id === res); return (
@@ -404,8 +426,8 @@ export default function UIA(properties) { className="mr-2 mt-2" onClick={(e) => { e.preventDefault(); - const _update = allowedMarkets.filter((x) => x !== res); - setAllowedMarkets(_update); + const _update = bannedMarkets.filter((x) => x !== res); + setBannedMarkets(_update); }} > ❌ @@ -416,6 +438,7 @@ export default function UIA(properties) {
); + }; const feeSharingWhitelistRow = ({ index, style }) => { @@ -513,13 +536,17 @@ export default function UIA(properties) { - #{index + 1}: {res.name} ({res.id}) + { + res.name + ? `#${index + 1}: ${res.name} (${res.id})` + : `#${index + 1}: ${res.id}` + }