From 03c18d0893b3cb6c6d6befd1368ac4df53a84acc Mon Sep 17 00:00:00 2001 From: CM Date: Sun, 15 Sep 2024 20:23:00 +0100 Subject: [PATCH] New page & misc changes New page: Issued assets overview --- src/components/CreditBorrow.jsx | 2 +- src/components/CreditDeals.jsx | 2 +- src/components/CreditOffers.jsx | 2 +- src/components/Home.jsx | 20 ++ src/components/IssuedAssets.jsx | 406 ++++++++++++++++++++++++++ src/components/Predictions.jsx | 10 + src/components/Smartcoins.jsx | 2 +- src/components/UIA.jsx | 1 - src/data/locales/da/Home.json | 7 + src/data/locales/da/PageHeader.json | 3 +- src/data/locales/de/Home.json | 7 + src/data/locales/de/PageHeader.json | 3 +- src/data/locales/en/Home.json | 7 + src/data/locales/en/IssuedAssets.json | 22 ++ src/data/locales/en/PageHeader.json | 3 +- src/data/locales/es/Home.json | 7 + src/data/locales/es/PageHeader.json | 3 +- src/data/locales/et/Home.json | 7 + src/data/locales/et/PageHeader.json | 3 +- src/data/locales/fr/Home.json | 7 + src/data/locales/fr/PageHeader.json | 3 +- src/data/locales/it/Home.json | 7 + src/data/locales/it/PageHeader.json | 3 +- src/data/locales/ja/Home.json | 7 + src/data/locales/ja/PageHeader.json | 3 +- src/data/locales/ko/Home.json | 7 + src/data/locales/ko/PageHeader.json | 3 +- src/data/locales/pt/Home.json | 7 + src/data/locales/pt/PageHeader.json | 3 +- src/data/locales/th/Home.json | 7 + src/data/locales/th/PageHeader.json | 3 +- src/lib/i18n.js | 3 +- src/nanoeffects/IssuedAssets.ts | 102 +++++++ src/nanoeffects/LenderDeals.ts | 1 + src/pages/issued_assets.astro | 27 ++ 35 files changed, 693 insertions(+), 17 deletions(-) create mode 100644 src/components/IssuedAssets.jsx create mode 100644 src/data/locales/en/IssuedAssets.json create mode 100644 src/nanoeffects/IssuedAssets.ts create mode 100644 src/pages/issued_assets.astro diff --git a/src/components/CreditBorrow.jsx b/src/components/CreditBorrow.jsx index f1069e0..20758bd 100644 --- a/src/components/CreditBorrow.jsx +++ b/src/components/CreditBorrow.jsx @@ -244,7 +244,7 @@ export default function CreditBorrow(properties) { function CommonRow({ index, style, res, foundAsset }) { return (
- {}}> + {t("CreditBorrow:common.title", { diff --git a/src/components/CreditDeals.jsx b/src/components/CreditDeals.jsx index 4321f4e..a02e2f2 100644 --- a/src/components/CreditDeals.jsx +++ b/src/components/CreditDeals.jsx @@ -275,7 +275,7 @@ export default function CreditDeals(properties) { return (
- {}}> + {t("CreditDeals:dealNo")} diff --git a/src/components/CreditOffers.jsx b/src/components/CreditOffers.jsx index 8fa6f3f..35d90e8 100644 --- a/src/components/CreditOffers.jsx +++ b/src/components/CreditOffers.jsx @@ -85,7 +85,7 @@ export default function CreditOffers(properties) { function CommonRow({ index, style, res, foundAsset }) { return (
- {}}> + {t("CreditBorrow:common.title", { diff --git a/src/components/Home.jsx b/src/components/Home.jsx index 0c17c41..9f0b592 100644 --- a/src/components/Home.jsx +++ b/src/components/Home.jsx @@ -360,6 +360,26 @@ export default function Home(properties) { + + + + + + + {t("Home:issued_assets.title")} + {t("Home:issued_assets.subtitle")} + + + + + +
    +
  • {t("Home:issued_assets.hover1")}
  • +
  • {t("Home:issued_assets.hover2")}
  • +
  • {t("Home:issued_assets.hover3")}
  • +
+
+

diff --git a/src/components/IssuedAssets.jsx b/src/components/IssuedAssets.jsx new file mode 100644 index 0000000..7f69143 --- /dev/null +++ b/src/components/IssuedAssets.jsx @@ -0,0 +1,406 @@ +import React, { useState, useEffect, useSyncExternalStore, useMemo } from "react"; +import { FixedSizeList as List } from "react-window"; +import { useStore } from '@nanostores/react'; + +import { useTranslation } from "react-i18next"; +import { i18n as i18nInstance, locale } from "@/lib/i18n.js"; + +import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; +import { HoverCard, HoverCardContent, HoverCardTrigger } from "@/components/ui/hover-card"; + +import { + Card, + CardContent, + CardDescription, + CardFooter, + CardHeader, + CardTitle, +} from "@/components/ui/card"; + +import { Button } from "@/components/ui/button"; +import { Badge } from "@/components/ui/badge"; +import { Input } from "@/components/ui/input"; + +import { useInitCache } from "@/nanoeffects/Init.ts"; +import { createIssuedAssetsStore } from "@/nanoeffects/IssuedAssets.ts"; + +import { $currentUser } from "@/stores/users.ts"; +import { $currentNode } from "@/stores/node.ts"; + +import ExternalLink from "./common/ExternalLink.jsx"; + +const activeTabStyle = { backgroundColor: "#252526", color: "white" }; + +export default function IssuedAssets(properties) { + const { t, i18n } = useTranslation(locale.get(), { i18n: i18nInstance }); + const usr = useSyncExternalStore($currentUser.subscribe, $currentUser.get, () => true); + const currentNode = useStore($currentNode); + + const _chain = useMemo(() => { + if (usr && usr.chain) { + return usr.chain; + } + return "bitshares"; + }, [usr]); + + useInitCache(_chain ?? "bitshares", []); + + const [issuedAssets, setIssuedAssets] = useState([]); + const [loading, setLoading] = useState(false); + useEffect(() => { + async function fetching() { + const requiredStore = createIssuedAssetsStore([ + usr.chain, usr.id, currentNode ? currentNode.url : null + ]); + + requiredStore.subscribe(({ data, error, loading }) => { + if (data && !error && !loading) { + /* + { + "id": "1.3.6021", + "symbol": "NFTEA", + "precision": 0, + "issuer": "1.2.1803677", + "options": { + "max_supply": 1, + "market_fee_percent": 0, + "max_market_fee": 0, + "issuer_permissions": 79, + "flags": 0, + "core_exchange_rate": { + "base": { + "amount": 100000, + "asset_id": "1.3.0" + }, + "quote": { + "amount": 1, + "asset_id": "1.3.6021" + } + }, + "whitelist_authorities": [], + "blacklist_authorities": [], + "whitelist_markets": [], + "blacklist_markets": [], + "description": "{\"main\":\"NFTEA.gallery\\n\\nNFT gallery powered by the Bitshares blockchain!\",\"short_name\":\"NFTEA\",\"market\":\"BTS\"}", + "extensions": { + "reward_percent": 0, + "whitelist_market_fee_sharing": [] + } + }, + "dynamic_asset_data_id": "2.3.6021", + "creation_block_num": 58742662, + "creation_time": "2021-05-26T16:02:15", + "total_in_collateral": 0 + } + */ + setLoading(false); + setIssuedAssets(data); + } + }); + } + + if (usr && usr.id && currentNode && currentNode.url) { + setLoading(true); + fetching(); + } + }, [usr, currentNode]); + + const [activeTab, setActiveTab] = useState("uia"); + + const relevantAssets = useMemo(() => { + if (!issuedAssets || !issuedAssets.length) { + return []; + } + + switch (activeTab) { + case "uia": + return issuedAssets.filter((asset) => + !asset.bitasset_data_id && + !asset.options.description.includes("nft_object") + ); + case "smartcoins": + return issuedAssets.filter((asset) => + asset.bitasset_data_id && + !asset.options.description.includes("condition") && + !asset.options.description.includes("expiry") + ); + case "prediction": + return issuedAssets.filter((asset) => + asset.bitasset_data_id && + asset.options.description.includes("condition") && + asset.options.description.includes("expiry") + ); + case "nft": + return issuedAssets.filter((asset) => !asset.bitasset_data_id && asset.options.description.includes("nft_object")); + default: + return []; + } + }, [issuedAssets, activeTab]); + + const AssetRow = ({ index, style }) => { + const issuedAsset = relevantAssets[index]; + if (!issuedAsset) { + return null; + } + + const description = issuedAsset.options.description; + const parsedDescription = description.length && description.includes("main") + ? JSON.parse(description) + : null + + return ( +
+ + + + + + {" "} + {"("} + + {")"} + + + + + + + + + + + + { + activeTab === "smartcoins" + ? + + + : null + } + { + activeTab === "smartcoins" + ? null // TODO: Support editing smartcoins + : null + } + { + activeTab === "prediction" + ? null // TODO: Support hyperlinking directly to a PMA to bet on... + : null + } + { + activeTab === "uia" + ? + + + : null + } + { + activeTab === "prediction" + ? + + // TODO: Support hyperlinking directly to a PMA to bet on... + : null + } + + + + +
+ ); + }; + + return ( + <> +
+
+ + + {t("IssuedAssets:title")} + {t("IssuedAssets:description")} + + + + + {activeTab === "uia" ? ( + + {t("IssuedAssets:uiaButton")} + + ) : ( + { + setActiveTab("uia"); + window.history.replaceState({}, "", `?tab=uia`); + }} + > + {t("IssuedAssets:uiaButton")} + + )} + {activeTab === "smartcoins" ? ( + + {t("IssuedAssets:smartcoinsButton")} + + ) : ( + { + setActiveTab("smartcoins"); + window.history.replaceState({}, "", `?tab=smartcoins`); + }} + > + {t("IssuedAssets:smartcoinsButton")} + + )} + {activeTab === "prediction" ? ( + + {t("IssuedAssets:predictionButton")} + + ) : ( + { + setActiveTab("prediction"); + window.history.replaceState({}, "", `?tab=prediction`); + }} + > + {t("IssuedAssets:predictionButton")} + + )} + {activeTab === "nft" ? ( + + {t("IssuedAssets:nftButton")} + + ) : ( + { + setActiveTab("nft"); + window.history.replaceState({}, "", `?tab=nft`); + }} + > + {t("IssuedAssets:nftButton")} + + )} + + +
+ {t("IssuedAssets:listingUIA", { count: relevantAssets.length })} +
+ { + loading + ?
{t("CreditBorrow:common.loading")}
+ : null + } + { + !loading && !relevantAssets || !relevantAssets.length + ?
{t("IssuedAssets:noUIA")}
+ : + {AssetRow} + + } +
+ +
+ {t("IssuedAssets:listingSmartcoins", { count: relevantAssets.length })} +
+ { + loading + ?
{t("CreditBorrow:common.loading")}
+ : null + } + { + !loading && !relevantAssets || !relevantAssets.length + ?
{t("IssuedAssets:noSmartcoins")}
+ : + {AssetRow} + + } +
+ +
+ {t("IssuedAssets:listingPredictionMarkets", { count: relevantAssets.length })} +
+ { + loading + ?
{t("CreditBorrow:common.loading")}
+ : null + } + { + !loading && !relevantAssets || !relevantAssets.length + ?
{t("IssuedAssets:noPredictionMarkets")}
+ : + {AssetRow} + + } +
+ +
+ {t("IssuedAssets:listingNFTs", { count: relevantAssets.length })} +
+ { + loading + ?
{t("CreditBorrow:common.loading")}
+ : null + } + { + !loading && !relevantAssets || !relevantAssets.length + ?
{t("IssuedAssets:noNFTs")}
+ : + {AssetRow} + + } +
+
+
+
+
+
+ + ); +} diff --git a/src/components/Predictions.jsx b/src/components/Predictions.jsx index d62b26d..e58b801 100644 --- a/src/components/Predictions.jsx +++ b/src/components/Predictions.jsx @@ -1792,6 +1792,16 @@ export default function Predictions(properties) {

; }; + + useEffect(() => { + const urlSearchParams = new URLSearchParams(window.location.search); + const params = Object.fromEntries(urlSearchParams.entries()); + + if (params.hasOwnProperty("id")) { + setView("mine"); + } + }, []); + return (
diff --git a/src/components/Smartcoins.jsx b/src/components/Smartcoins.jsx index 44ee981..d707b16 100644 --- a/src/components/Smartcoins.jsx +++ b/src/components/Smartcoins.jsx @@ -244,7 +244,7 @@ export default function Smartcoins(properties) { return (
- {}}> + {mode === "bitasset" ? "Bitasset" : "Smartcoin"} " diff --git a/src/components/UIA.jsx b/src/components/UIA.jsx index ea95c5a..2e59a95 100644 --- a/src/components/UIA.jsx +++ b/src/components/UIA.jsx @@ -347,7 +347,6 @@ export default function UIA(properties) { const [whitelistAuthorityDialogOpen, setWhitelistAuthorityDialogOpen] = useState(false); const [blacklistAuthorityDialogOpen, setBlacklistAuthorityDialogOpen] = useState(false); - const allowedMarketsRow = ({ index, style }) => { let res = allowedMarkets[index]; if (!res) { diff --git a/src/data/locales/da/Home.json b/src/data/locales/da/Home.json index cd6a8ec..33e24ee 100644 --- a/src/data/locales/da/Home.json +++ b/src/data/locales/da/Home.json @@ -110,6 +110,13 @@ "hover2": "Forudsigelsesmarkeder kan handle om alt.", "hover3": "Hvert forudsigelsesmarkedsaktiv har et unikt gebyr." }, + "issued_assets": { + "title": "📃 Dine udstedte aktiver", + "subtitle": "Se alle de aktiver, du har oprettet", + "hover1": "Se brugerudstedte aktiver, forudsigelige markedsaktiver, smartcoins og ikke-fungible tokens!", + "hover2": "Rediger de aktiver, du har oprettet på blockchain.", + "hover3": "Udsted eventuelt en mængde af dine oprettede aktiver." + }, "create_prediction": { "title": "🔮 Forudsigelsesmarkedsaktiv", "subtitle": "Lav et væddemål om hvad som helst", diff --git a/src/data/locales/da/PageHeader.json b/src/data/locales/da/PageHeader.json index 6e477ee..94cd468 100644 --- a/src/data/locales/da/PageHeader.json +++ b/src/data/locales/da/PageHeader.json @@ -61,7 +61,8 @@ "predictions": "Find et forudsigelsesmarkedsaktiv nedenfor for at spille på.", "tfunds": "Find, opret, opdater eller slet Same-T-midler nedenfor!", "create_vesting": "Brug denne formular til at oprette en optjeningssaldo for enhver konto!", - "uia": "Opret dit eget brugerudstedte aktiv med formularen nedenfor!" + "uia": "Opret dit eget brugerudstedte aktiv med formularen nedenfor!", + "issuedAssets": "Administrer de blockchain-aktiver, du har oprettet, på fanerne nedenfor!" }, "back": "Gå tilbage", "usage": "Designet til brug med ", diff --git a/src/data/locales/de/Home.json b/src/data/locales/de/Home.json index 03b511c..84ed2c6 100644 --- a/src/data/locales/de/Home.json +++ b/src/data/locales/de/Home.json @@ -110,6 +110,13 @@ "hover2": "Auf Prognosemärkten kann es um alles Mögliche gehen.", "hover3": "Für jedes Prognosemarkt-Asset gibt es eine eigene Gebühr." }, + "issued_assets": { + "title": "📃 Ihre ausgegebenen Vermögenswerte", + "subtitle": "Sehen Sie sich alle von Ihnen erstellten Assets an", + "hover1": "Sehen Sie sich von Benutzern bereitgestellte Vermögenswerte, prognostizierte Marktwerte, Smartcoins und nicht fungible Token an!", + "hover2": "Bearbeiten Sie die Assets, die Sie in der Blockchain erstellt haben.", + "hover3": "Geben Sie optional eine Menge Ihrer erstellten Vermögenswerte aus." + }, "create_prediction": { "title": "🔮 Vorhersage des Marktwerts", "subtitle": "Erstellen Sie eine Wette über alles", diff --git a/src/data/locales/de/PageHeader.json b/src/data/locales/de/PageHeader.json index 207b20e..6d2c8c2 100644 --- a/src/data/locales/de/PageHeader.json +++ b/src/data/locales/de/PageHeader.json @@ -62,7 +62,8 @@ "predictions": "Suchen Sie unten nach einem Prognosemarkt-Asset, auf das Sie wetten können.", "tfunds": "Suchen, erstellen, aktualisieren oder löschen Sie unten Same-T-Fonds!", "create_vesting": "Verwenden Sie dieses Formular, um ein Sperrguthaben für jedes Konto zu erstellen!", - "uia": "Erstellen Sie mit dem untenstehenden Formular Ihr eigenes, vom Benutzer ausgegebenes Asset!" + "uia": "Erstellen Sie mit dem untenstehenden Formular Ihr eigenes, vom Benutzer ausgegebenes Asset!", + "issuedAssets": "Verwalten Sie die von Ihnen erstellten Blockchain-Assets in den folgenden Registerkarten!" }, "back": "Geh zurück", "usage": "Konzipiert für den Einsatz mit ", diff --git a/src/data/locales/en/Home.json b/src/data/locales/en/Home.json index 29b2441..aa3272f 100644 --- a/src/data/locales/en/Home.json +++ b/src/data/locales/en/Home.json @@ -110,6 +110,13 @@ "hover2": "Prediction markets can be about anything.", "hover3": "Each prediction market asset has an unique fee." }, + "issued_assets": { + "title": "📃 Your Issued Assets", + "subtitle": "View all the assets you've created", + "hover1": "View user issed assets, prediction market assets, smartcoins and non-fungible tokens!", + "hover2": "Edit the assets you've created on the blockchain.", + "hover3": "Optionally issue a quantity of your created assets." + }, "create_prediction": { "title": "🔮 Prediction Market Asset", "subtitle": "Create a bet about anything", diff --git a/src/data/locales/en/IssuedAssets.json b/src/data/locales/en/IssuedAssets.json new file mode 100644 index 0000000..bdb4a54 --- /dev/null +++ b/src/data/locales/en/IssuedAssets.json @@ -0,0 +1,22 @@ +{ + "proceedToTrade": "Trade", + "creditBorrow": "Borrow", + "creditLend": "Lend", + "proceedToBorrow": "Issue", + "manageUIA": "Edit", + "pmaBet": "Bet", + "uiaButton": "User Issued Assets", + "smartcoinsButton": "Smartcoin Assets", + "predictionButton": "Prediction Market Assets", + "nftButton": "Non-Fungible Token Assets", + "listingUIA": "Listing {{count}} User Issued Assets", + "noUIA": "No User Issued Assets found", + "listingSmartcoins": "Listing {{count}} Smartcoin Assets", + "noSmartcoins": "No Smartcoin Assets found", + "listingPredictionMarkets": "Listing {{count}} Prediction Market Assets", + "noPredictionMarkets": "No Prediction Market Assets found", + "listingNFTs": "Listing {{count}} Non-Fungible Token Assets", + "noNFTs": "No Non-Fungible Token Assets found", + "title": "Viewing the blockchain assets you've created", + "description": "From here you can manage the assets you've created, including updating their details, issuing more of them, and more." +} \ No newline at end of file diff --git a/src/data/locales/en/PageHeader.json b/src/data/locales/en/PageHeader.json index a7513bc..b999232 100644 --- a/src/data/locales/en/PageHeader.json +++ b/src/data/locales/en/PageHeader.json @@ -62,7 +62,8 @@ "predictions": "Locate a prediction market asset below to bet on.", "tfunds": "Find, create, update or delete Same-T funds below!", "create_vesting": "Use this form to create a vesting balance for any account!", - "uia": "Create your own user issued asset with the form below!" + "uia": "Create your own user issued asset with the form below!", + "issuedAssets": "Manage the blockchain assets you've created within the tabs below!" }, "back": "Go back", "usage": "Designed for use with ", diff --git a/src/data/locales/es/Home.json b/src/data/locales/es/Home.json index bfe36af..fd7fa01 100644 --- a/src/data/locales/es/Home.json +++ b/src/data/locales/es/Home.json @@ -110,6 +110,13 @@ "hover2": "Los mercados de predicción pueden tratar sobre cualquier cosa.", "hover3": "Cada activo del mercado de predicción tiene una tarifa única." }, + "issued_assets": { + "title": "📃 Sus activos emitidos", + "subtitle": "Ver todos los activos que has creado", + "hover1": "¡Vea los activos emitidos por los usuarios, los activos del mercado de predicción, las monedas inteligentes y los tokens no fungibles!", + "hover2": "Edite los activos que ha creado en blockchain.", + "hover3": "Opcionalmente, emita una cantidad de sus activos creados." + }, "create_prediction": { "title": "🔮 Activo del mercado de predicción", "subtitle": "Crea una apuesta sobre cualquier cosa.", diff --git a/src/data/locales/es/PageHeader.json b/src/data/locales/es/PageHeader.json index 950c13a..656528f 100644 --- a/src/data/locales/es/PageHeader.json +++ b/src/data/locales/es/PageHeader.json @@ -62,7 +62,8 @@ "predictions": "Localice un activo del mercado de predicción a continuación para apostar.", "tfunds": "¡Encuentre, cree, actualice o elimine fondos de Same-T a continuación!", "create_vesting": "¡Utilice este formulario para crear un saldo de adquisición de derechos para cualquier cuenta!", - "uia": "¡Cree su propio activo emitido por el usuario con el siguiente formulario!" + "uia": "¡Cree su propio activo emitido por el usuario con el siguiente formulario!", + "issuedAssets": "¡Administre los activos de blockchain que ha creado en las pestañas a continuación!" }, "back": "Regresa", "usage": "Diseñado para usar con ", diff --git a/src/data/locales/et/Home.json b/src/data/locales/et/Home.json index fd606f6..425d295 100644 --- a/src/data/locales/et/Home.json +++ b/src/data/locales/et/Home.json @@ -110,6 +110,13 @@ "hover2": "Ennustusturgudel võib olla ükskõik mida.", "hover3": "Igal ennustusturu varal on ainulaadne tasu." }, + "issued_assets": { + "title": "📃 Teie väljastatud varad", + "subtitle": "Vaadake kõiki loodud varasid", + "hover1": "Vaadake kasutaja väljastatud varasid, ennustusturu varasid, nutikoine ja mittevahetatavaid žetoone!", + "hover2": "Muutke plokiahelas loodud varasid.", + "hover3": "Soovi korral väljastage loodud varade kogus." + }, "create_prediction": { "title": "🔮 Ennustusturu vara", "subtitle": "Tehke panus ükskõik mille kohta", diff --git a/src/data/locales/et/PageHeader.json b/src/data/locales/et/PageHeader.json index 6f9a31d..0e2ccb7 100644 --- a/src/data/locales/et/PageHeader.json +++ b/src/data/locales/et/PageHeader.json @@ -62,7 +62,8 @@ "predictions": "Leidke altpoolt ennustatav turuvara, millele panustada.", "tfunds": "Otsige, looge, värskendage või kustutage Same-T fonde allpool!", "create_vesting": "Kasutage seda vormi mis tahes konto omandisaldo loomiseks!", - "uia": "Looge alloleva vormi abil oma kasutaja väljastatud vara!" + "uia": "Looge alloleva vormi abil oma kasutaja väljastatud vara!", + "issuedAssets": "Hallake oma loodud plokiahela varasid allolevatel vahekaartidel!" }, "back": "Mine tagasi", "usage": "Mõeldud kasutamiseks koos ", diff --git a/src/data/locales/fr/Home.json b/src/data/locales/fr/Home.json index 22a2ec5..e8d49a6 100644 --- a/src/data/locales/fr/Home.json +++ b/src/data/locales/fr/Home.json @@ -110,6 +110,13 @@ "hover2": "Les marchés de prédiction peuvent concerner n’importe quoi.", "hover3": "Chaque actif du marché de prédiction a des frais uniques." }, + "issued_assets": { + "title": "📃 Vos actifs émis", + "subtitle": "Afficher tous les éléments que vous avez créés", + "hover1": "Affichez les actifs émis par les utilisateurs, les actifs du marché de prédiction, les smartcoins et les jetons non fongibles !", + "hover2": "Modifiez les actifs que vous avez créés sur la blockchain.", + "hover3": "Émettez éventuellement une quantité de vos actifs créés." + }, "create_prediction": { "title": "🔮 Actif du marché de prédiction", "subtitle": "Créer un pari sur n'importe quoi", diff --git a/src/data/locales/fr/PageHeader.json b/src/data/locales/fr/PageHeader.json index a254505..0294b34 100644 --- a/src/data/locales/fr/PageHeader.json +++ b/src/data/locales/fr/PageHeader.json @@ -62,7 +62,8 @@ "predictions": "Localisez ci-dessous un actif du marché de prédiction sur lequel parier.", "tfunds": "Recherchez, créez, mettez à jour ou supprimez des fonds Same-T ci-dessous !", "create_vesting": "Utilisez ce formulaire pour créer un solde d'acquisition pour n'importe quel compte !", - "uia": "Créez votre propre actif émis par l'utilisateur avec le formulaire ci-dessous !" + "uia": "Créez votre propre actif émis par l'utilisateur avec le formulaire ci-dessous !", + "issuedAssets": "Gérez les actifs blockchain que vous avez créés dans les onglets ci-dessous !" }, "back": "Retourner", "usage": "Conçu pour être utilisé avec ", diff --git a/src/data/locales/it/Home.json b/src/data/locales/it/Home.json index 1a6685b..845c26b 100644 --- a/src/data/locales/it/Home.json +++ b/src/data/locales/it/Home.json @@ -110,6 +110,13 @@ "hover2": "I mercati di previsione possono riguardare qualsiasi cosa.", "hover3": "Ogni asset del mercato di previsione ha una tariffa unica." }, + "issued_assets": { + "title": "📃 I tuoi beni emessi", + "subtitle": "Visualizza tutte le risorse che hai creato", + "hover1": "Visualizza le risorse emesse dagli utenti, le risorse del mercato di previsione, gli smartcoin e i token non fungibili!", + "hover2": "Modifica le risorse che hai creato sulla blockchain.", + "hover3": "Facoltativamente, emetti una quantità delle risorse create." + }, "create_prediction": { "title": "🔮 Asset di mercato di previsione", "subtitle": "Crea una scommessa su qualsiasi cosa", diff --git a/src/data/locales/it/PageHeader.json b/src/data/locales/it/PageHeader.json index f42e1b8..96e8441 100644 --- a/src/data/locales/it/PageHeader.json +++ b/src/data/locales/it/PageHeader.json @@ -62,7 +62,8 @@ "predictions": "Individua di seguito un asset del mercato di previsione su cui scommettere.", "tfunds": "Trova, crea, aggiorna o elimina i fondi Same-T qui sotto!", "create_vesting": "Utilizza questo modulo per creare un saldo di maturazione per qualsiasi account!", - "uia": "Crea la tua risorsa emessa dall'utente con il modulo sottostante!" + "uia": "Crea la tua risorsa emessa dall'utente con il modulo sottostante!", + "issuedAssets": "Gestisci le risorse blockchain che hai creato nelle schede seguenti!" }, "back": "Torna indietro", "usage": "Progettato per l'uso con ", diff --git a/src/data/locales/ja/Home.json b/src/data/locales/ja/Home.json index 7fb8578..e7351d8 100644 --- a/src/data/locales/ja/Home.json +++ b/src/data/locales/ja/Home.json @@ -110,6 +110,13 @@ "hover2": "予測市場は何でも構いません。", "hover3": "各予測市場資産には固有の手数料がかかります。" }, + "issued_assets": { + "title": "📃 発行された資産", + "subtitle": "作成したすべてのアセットを表示する", + "hover1": "ユーザーが発行した資産、予測市場資産、スマートコイン、代替不可能なトークンを表示します。", + "hover2": "ブロックチェーン上に作成したアセットを編集します。", + "hover3": "必要に応じて、作成したアセットの数量を発行します。" + }, "create_prediction": { "title": "🔮 予測市場資産", "subtitle": "あらゆるものについて賭けを立てる", diff --git a/src/data/locales/ja/PageHeader.json b/src/data/locales/ja/PageHeader.json index 0fcce90..af17abe 100644 --- a/src/data/locales/ja/PageHeader.json +++ b/src/data/locales/ja/PageHeader.json @@ -62,7 +62,8 @@ "predictions": "賭ける予測市場資産を以下から見つけてください。", "tfunds": "以下の Same-T ファンドを検索、作成、更新、削除してください。", "create_vesting": "このフォームを使用して、任意のアカウントの権利確定残高を作成してください。", - "uia": "以下のフォームを使用して、独自のユーザー発行アセットを作成してください。" + "uia": "以下のフォームを使用して、独自のユーザー発行アセットを作成してください。", + "issuedAssets": "以下のタブ内で作成したブロックチェーン資産を管理します。" }, "back": "戻る", "usage": "で使用するように設計されています ", diff --git a/src/data/locales/ko/Home.json b/src/data/locales/ko/Home.json index 52c28a5..1fd6c8a 100644 --- a/src/data/locales/ko/Home.json +++ b/src/data/locales/ko/Home.json @@ -110,6 +110,13 @@ "hover2": "예측 시장은 무엇이든 될 수 있습니다.", "hover3": "각 예측 시장 자산에는 고유한 수수료가 있습니다." }, + "issued_assets": { + "title": "📃 귀하의 발행 자산", + "subtitle": "귀하가 생성한 모든 자산 보기", + "hover1": "사용자가 발행한 자산, 예측 시장 자산, 스마트코인 및 대체 불가능한 토큰을 확인하세요!", + "hover2": "블록체인에서 생성한 자산을 편집하세요.", + "hover3": "선택적으로 생성된 자산의 수량을 발행합니다." + }, "create_prediction": { "title": "🔮 예측 시장 자산", "subtitle": "무엇이든 내기를 걸어보세요", diff --git a/src/data/locales/ko/PageHeader.json b/src/data/locales/ko/PageHeader.json index 1946e94..e86b9e1 100644 --- a/src/data/locales/ko/PageHeader.json +++ b/src/data/locales/ko/PageHeader.json @@ -62,7 +62,8 @@ "predictions": "아래에서 베팅할 예측 시장 자산을 찾으세요.", "tfunds": "아래에서 Same-T 자금을 찾아 생성, 업데이트 또는 삭제하세요!", "create_vesting": "이 양식을 사용하여 모든 계정에 대한 베스팅 잔액을 만드세요!", - "uia": "아래 양식을 사용하여 나만의 사용자 발행 자산을 만들어보세요!" + "uia": "아래 양식을 사용하여 나만의 사용자 발행 자산을 만들어보세요!", + "issuedAssets": "귀하가 생성한 블록체인 자산을 아래 탭에서 관리해보세요!" }, "back": "돌아가기", "usage": "다음과 함께 사용하도록 설계됨 ", diff --git a/src/data/locales/pt/Home.json b/src/data/locales/pt/Home.json index c9a3445..adb1a26 100644 --- a/src/data/locales/pt/Home.json +++ b/src/data/locales/pt/Home.json @@ -110,6 +110,13 @@ "hover2": "Os mercados de previsão podem ser sobre qualquer coisa.", "hover3": "Cada ativo de mercado de previsão possui uma taxa exclusiva." }, + "issued_assets": { + "title": "📃 Seus ativos emitidos", + "subtitle": "Veja todos os ativos que você criou", + "hover1": "Veja ativos emitidos pelo usuário, ativos de mercado de previsão, smartcoins e tokens não fungíveis!", + "hover2": "Edite os ativos que você criou no blockchain.", + "hover3": "Opcionalmente, emita uma quantidade de seus ativos criados." + }, "create_prediction": { "title": "🔮 Previsão de ativos de mercado", "subtitle": "Crie uma aposta sobre qualquer coisa", diff --git a/src/data/locales/pt/PageHeader.json b/src/data/locales/pt/PageHeader.json index c912ecc..ad86a58 100644 --- a/src/data/locales/pt/PageHeader.json +++ b/src/data/locales/pt/PageHeader.json @@ -62,7 +62,8 @@ "predictions": "Localize abaixo um ativo de mercado de previsão para apostar.", "tfunds": "Encontre, crie, atualize ou exclua fundos Same-T abaixo!", "create_vesting": "Use este formulário para criar um saldo de aquisição para qualquer conta!", - "uia": "Crie seu próprio ativo emitido pelo usuário com o formulário abaixo!" + "uia": "Crie seu próprio ativo emitido pelo usuário com o formulário abaixo!", + "issuedAssets": "Gerencie os ativos blockchain que você criou nas guias abaixo!" }, "back": "Volte", "usage": "Projetado para uso com ", diff --git a/src/data/locales/th/Home.json b/src/data/locales/th/Home.json index 1909bde..a4268b0 100644 --- a/src/data/locales/th/Home.json +++ b/src/data/locales/th/Home.json @@ -110,6 +110,13 @@ "hover2": "ตลาดการคาดการณ์สามารถเป็นอะไรก็ได้", "hover3": "สินทรัพย์ในตลาดการคาดการณ์แต่ละรายการมีค่าธรรมเนียมเฉพาะ" }, + "issued_assets": { + "title": "📃 สินทรัพย์ที่ออกของคุณ", + "subtitle": "ดูทรัพย์สินทั้งหมดที่คุณสร้างขึ้น", + "hover1": "ดูสินทรัพย์ที่ผู้ใช้ออก สินทรัพย์ในตลาดการคาดการณ์ สมาร์ทคอยน์ และโทเค็นที่ไม่สามารถเข้ากันได้!", + "hover2": "แก้ไขเนื้อหาที่คุณสร้างบนบล็อคเชน", + "hover3": "คุณสามารถเลือกออกปริมาณของสินทรัพย์ที่คุณสร้างขึ้นได้" + }, "create_prediction": { "title": "🔮 สินทรัพย์ตลาดทำนาย", "subtitle": "สร้างเดิมพันเกี่ยวกับอะไรก็ได้", diff --git a/src/data/locales/th/PageHeader.json b/src/data/locales/th/PageHeader.json index c869e6d..a9f224b 100644 --- a/src/data/locales/th/PageHeader.json +++ b/src/data/locales/th/PageHeader.json @@ -62,7 +62,8 @@ "predictions": "ค้นหาสินทรัพย์ในตลาดการคาดการณ์ด้านล่างเพื่อเดิมพัน", "tfunds": "ค้นหา สร้าง อัปเดต หรือลบกองทุน Same-T ด้านล่าง!", "create_vesting": "ใช้แบบฟอร์มนี้เพื่อสร้างยอดคงเหลือสำหรับบัญชีใดๆ ก็ตาม!", - "uia": "สร้างสินทรัพย์ที่ผู้ใช้ออกของคุณเองด้วยแบบฟอร์มด้านล่าง!" + "uia": "สร้างสินทรัพย์ที่ผู้ใช้ออกของคุณเองด้วยแบบฟอร์มด้านล่าง!", + "issuedAssets": "จัดการสินทรัพย์บล็อคเชนที่คุณสร้างขึ้นภายในแท็บด้านล่าง!" }, "back": "กลับไป", "usage": "ออกแบบมาเพื่อใช้กับ ", diff --git a/src/lib/i18n.js b/src/lib/i18n.js index 97eb2bd..e24816e 100644 --- a/src/lib/i18n.js +++ b/src/lib/i18n.js @@ -47,7 +47,8 @@ const pages = [ "Predictions", "SameTFunds", "CreateVestingBalance", - "CreateUIA" + "CreateUIA", + "IssuedAssets" ]; const locale = persistentAtom("locale", "en"); diff --git a/src/nanoeffects/IssuedAssets.ts b/src/nanoeffects/IssuedAssets.ts new file mode 100644 index 0000000..ae72f49 --- /dev/null +++ b/src/nanoeffects/IssuedAssets.ts @@ -0,0 +1,102 @@ +import { nanoquery } from "@nanostores/query"; +import Apis from "@/bts/ws/ApiInstances"; +import { chains } from "@/config/chains"; + +const MAXIMUM_ISSUED_ASSETS = 1000; // Arbitrary number.. +const BTS_LIMIT = 50; +const TEST_LIMIT = 10; + +const MAX_BTS_ITERATIONS = MAXIMUM_ISSUED_ASSETS / BTS_LIMIT; +const MAX_TEST_ITERATIONS = MAXIMUM_ISSUED_ASSETS / TEST_LIMIT; + +async function fetchingIssuedAssets( + chain: string, + accountID: string, + specificNode?: string | null, + existingAPI?: any +) { + return new Promise(async (resolve, reject) => { + const node = specificNode ? specificNode : (chains as any)[chain].nodeList[0].url; + const maximumQuerySize = chain === "bitshares" ? BTS_LIMIT : TEST_LIMIT; + const maximumIterations = chain === "bitshares" ? MAX_BTS_ITERATIONS : MAX_TEST_ITERATIONS; + + let currentAPI; + try { + currentAPI = existingAPI + ? existingAPI + : await Apis.instance(node, true, 4000, { enableDatabase: true }, (error: Error) => + console.log({ error }) + ); + } catch (error) { + console.log({ error }); + return; + } + + let issuedAssets: any[] = []; + try { + issuedAssets = await currentAPI.db_api().exec("get_assets_by_issuer", [accountID, "1.3.0", maximumQuerySize]); + } catch (error) { + console.log({ error }); + currentAPI.close(); + return; + } + + if (!issuedAssets) { + console.log(`Failed to fetch issued assets`); + currentAPI.close(); + return []; + } + + if (issuedAssets.length === maximumQuerySize) { + for (let i = 1; i < maximumQuerySize; i++) { + let nextPage; + try { + nextPage = await currentAPI.db_api().exec( + "get_credit_deals_by_offer_owner", + [accountID, issuedAssets[issuedAssets.length - 1].id, maximumQuerySize] + ); + } catch (error) { + console.log({ error }); + if (!existingAPI) { + currentAPI.close(); + } + reject(error); + return; + } + + if (nextPage && nextPage.length) { + issuedAssets = [...issuedAssets, ...nextPage]; + } else { + break; + } + } + } + + if (!existingAPI) { + currentAPI.close(); + } + + return resolve(issuedAssets); + }); +} + +const [createIssuedAssetsStore] = nanoquery({ + fetcher: async (...args: unknown[]) => { + const chain = args[0] as string; + const userID = args[1] as string; + const specificNode = args[2] ? (args[2] as string) : null; + + let response; + try { + response = await fetchingIssuedAssets(chain, userID, specificNode); + } catch (error) { + console.log({ error }); + return []; + } + + return response; + }, + }); + + export { createIssuedAssetsStore }; + \ No newline at end of file diff --git a/src/nanoeffects/LenderDeals.ts b/src/nanoeffects/LenderDeals.ts index a5f4aaa..bedc071 100644 --- a/src/nanoeffects/LenderDeals.ts +++ b/src/nanoeffects/LenderDeals.ts @@ -81,6 +81,7 @@ function fetchLenderDeals ( if (!existingAPI) { currentAPI.close(); } + return resolve(lenderDeals); }); } diff --git a/src/pages/issued_assets.astro b/src/pages/issued_assets.astro new file mode 100644 index 0000000..b88c711 --- /dev/null +++ b/src/pages/issued_assets.astro @@ -0,0 +1,27 @@ +--- +import Layout from '../layouts/Layout.astro'; +import IssuedAssets from '../components/IssuedAssets.jsx'; +import PageHeader from '../components/PageHeader'; +import PageFooter from '../components/PageFooter'; +--- + + +
+ + + +
+
+ + \ No newline at end of file