Skip to content

Commit

Permalink
Merge pull request #45 from BTS-CM/content-layer
Browse files Browse the repository at this point in the history
Switch to the Astro Content Layer
  • Loading branch information
grctest authored Feb 14, 2025
2 parents 97873df + fba137c commit 39cb398
Show file tree
Hide file tree
Showing 77 changed files with 1,647 additions and 1,369 deletions.
26 changes: 8 additions & 18 deletions src/components/AccountLists.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ import { useInitCache } from "@/nanoeffects/Init.ts";
import { $currentUser } from "@/stores/users.ts";
import { $currentNode } from "@/stores/node.ts";

import { $globalParamsCacheBTS, $globalParamsCacheTEST } from "@/stores/cache.ts";

import { humanReadableFloat } from "@/lib/common";

import { createObjectStore } from "@/nanoeffects/Objects.ts";
Expand All @@ -49,32 +47,24 @@ export default function AccountLists(properties) {
const { t, i18n } = useTranslation(locale.get(), { i18n: i18nInstance });
const currentNode = useStore($currentNode);

const [showDialog, setShowDialog] = useState(false);
const {
_globalParamsBTS,
_globalParamsTEST
} = properties;

const [showDialog, setShowDialog] = useState(false);
const [targetUser, setTargetUser] = useState();

const usr = useSyncExternalStore($currentUser.subscribe, $currentUser.get, () => true);

const _globalParamsBTS = useSyncExternalStore(
$globalParamsCacheBTS.subscribe,
$globalParamsCacheBTS.get,
() => true
);

const _globalParamsTEST = useSyncExternalStore(
$globalParamsCacheTEST.subscribe,
$globalParamsCacheTEST.get,
() => true
);

const _chain = useMemo(() => {
if (usr && usr.chain) {
return usr.chain;
}
return "bitshares";
}, [usr]);

useInitCache(_chain ?? "bitshares", ["globalParams"]);
useInitCache(_chain ?? "bitshares", []);

const globalParams = useMemo(() => {
if (_chain && (_globalParamsBTS || _globalParamsTEST)) {
Expand All @@ -86,8 +76,8 @@ export default function AccountLists(properties) {
const [fee, setFee] = useState(0);
useEffect(() => {
if (globalParams && globalParams.length) {
const foundFee = globalParams.find((x) => x[0] === 7); // operation: account_whitelist
const finalFee = humanReadableFloat(foundFee[1].fee, 5);
const foundFee = globalParams.find((x) => x.id === 7); // operation: account_whitelist
const finalFee = humanReadableFloat(foundFee.data.fee, 5);
setFee(finalFee);
}
}, [globalParams]);
Expand Down
2 changes: 1 addition & 1 deletion src/components/AccountSearch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function AccountSearch(properties) {
setInProgress(false);

if (response && response.id) {
console.log({ skipCheck, id: response.id, blocklist: blocklist });
//console.log({ skipCheck, id: response.id, blocklist: blocklist });
if (usr.chain === "bitshares" && !skipCheck) {
let hashedID;
try {
Expand Down
26 changes: 4 additions & 22 deletions src/components/CreatePrediction.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,49 +38,31 @@ import { Avatar } from "./Avatar.tsx";

import { useInitCache } from "@/nanoeffects/Init.ts";
import { $currentUser } from "@/stores/users.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 { blockchainFloat } from "@/bts/common";

export default function Prediction(properties) {
const { t, i18n } = useTranslation(locale.get(), { i18n: i18nInstance });
const usr = useSyncExternalStore($currentUser.subscribe, $currentUser.get, () => true);

const _assetsBTS = useSyncExternalStore($assetCacheBTS.subscribe, $assetCacheBTS.get, () => true);
const _assetsTEST = useSyncExternalStore(
$assetCacheTEST.subscribe,
$assetCacheTEST.get,
() => true
);

const { _assetsBTS, _assetsTEST, _marketSearchBTS, _marketSearchTEST } = properties;

const _chain = useMemo(() => {
if (usr && usr.chain) {
return usr.chain;
}
return "bitshares";
}, [usr]);

const _marketSearchBTS = useSyncExternalStore(
$marketSearchCacheBTS.subscribe,
$marketSearchCacheBTS.get,
() => true
);

const _marketSearchTEST = useSyncExternalStore(
$marketSearchCacheTEST.subscribe,
$marketSearchCacheTEST.get,
() => true
);

const marketSearch = useMemo(() => {
if (usr && usr.chain && (_marketSearchBTS || _marketSearchTEST)) {
return usr.chain === "bitshares" ? _marketSearchBTS : _marketSearchTEST;
}
return [];
}, [_marketSearchBTS, _marketSearchTEST, usr]);

useInitCache(_chain ?? "bitshares", ["assets", "marketSearch"]);
useInitCache(_chain ?? "bitshares", []);

const assets = useMemo(() => {
if (_chain && (_assetsBTS || _assetsTEST)) {
Expand Down
25 changes: 3 additions & 22 deletions src/components/CreateSmartcoin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ 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 { $marketSearchCacheBTS, $marketSearchCacheTEST } from "@/stores/cache.ts";
import { createObjectStore } from "@/nanoeffects/Objects.ts";

import {
Expand Down Expand Up @@ -97,24 +95,7 @@ export default function CreateSmartcoin(properties) {
const usr = useSyncExternalStore($currentUser.subscribe, $currentUser.get, () => true);
const currentNode = useStore($currentNode);

const _assetsBTS = useSyncExternalStore($assetCacheBTS.subscribe, $assetCacheBTS.get, () => true);
const _assetsTEST = useSyncExternalStore(
$assetCacheTEST.subscribe,
$assetCacheTEST.get,
() => true
);

const _marketSearchBTS = useSyncExternalStore(
$marketSearchCacheBTS.subscribe,
$marketSearchCacheBTS.get,
() => true
);

const _marketSearchTEST = useSyncExternalStore(
$marketSearchCacheTEST.subscribe,
$marketSearchCacheTEST.get,
() => true
);
const { _assetsBTS, _assetsTEST, _marketSearchBTS, _marketSearchTEST } = properties;

const marketSearch = useMemo(() => {
if (usr && usr.chain && (_marketSearchBTS || _marketSearchTEST)) {
Expand All @@ -130,7 +111,7 @@ export default function CreateSmartcoin(properties) {
return "bitshares";
}, [usr]);

useInitCache(_chain ?? "bitshares", ["assets", "marketSearch"]);
useInitCache(_chain ?? "bitshares", []);

const assets = useMemo(() => {
if (_chain && (_assetsBTS || _assetsTEST)) {
Expand Down Expand Up @@ -495,7 +476,7 @@ export default function CreateSmartcoin(properties) {
if (!_bitassetData || !_dynamicData) {
return;
}
console.log({ _bitassetData, _dynamicData, existingAssetData });
//console.log({ _bitassetData, _dynamicData, existingAssetData });
setDynamicData(_dynamicData);

if (_bitassetData.options.extensions.hasOwnProperty("force_settle_fee_percent")) {
Expand Down
23 changes: 2 additions & 21 deletions src/components/CreateUIA.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ 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 { $marketSearchCacheBTS, $marketSearchCacheTEST } from "@/stores/cache.ts";
import { createObjectStore } from "@/nanoeffects/Objects.ts";

import {
Expand Down Expand Up @@ -97,24 +95,7 @@ export default function UIA(properties) {
const usr = useSyncExternalStore($currentUser.subscribe, $currentUser.get, () => true);
const currentNode = useStore($currentNode);

const _assetsBTS = useSyncExternalStore($assetCacheBTS.subscribe, $assetCacheBTS.get, () => true);
const _assetsTEST = useSyncExternalStore(
$assetCacheTEST.subscribe,
$assetCacheTEST.get,
() => true
);

const _marketSearchBTS = useSyncExternalStore(
$marketSearchCacheBTS.subscribe,
$marketSearchCacheBTS.get,
() => true
);

const _marketSearchTEST = useSyncExternalStore(
$marketSearchCacheTEST.subscribe,
$marketSearchCacheTEST.get,
() => true
);
const { _assetsBTS, _assetsTEST, _marketSearchBTS, _marketSearchTEST } = properties;

const marketSearch = useMemo(() => {
if (usr && usr.chain && (_marketSearchBTS || _marketSearchTEST)) {
Expand All @@ -130,7 +111,7 @@ export default function UIA(properties) {
return "bitshares";
}, [usr]);

useInitCache(_chain ?? "bitshares", ["assets", "marketSearch"]);
useInitCache(_chain ?? "bitshares", []);

const assets = useMemo(() => {
if (_chain && (_assetsBTS || _assetsTEST)) {
Expand Down
25 changes: 3 additions & 22 deletions src/components/CreateVestingBalance.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ import { useInitCache } from "@/nanoeffects/Init.ts";
import { createUserBalancesStore } from "@/nanoeffects/UserBalances.ts";

import { $currentUser } from "@/stores/users.ts";
import { $assetCacheBTS, $assetCacheTEST } from "@/stores/cache.ts";
import { $marketSearchCacheBTS, $marketSearchCacheTEST } from "@/stores/cache.ts";
import { $currentNode } from "@/stores/node.ts";

import DeepLinkDialog from "./common/DeepLinkDialog.jsx";
Expand All @@ -48,12 +46,7 @@ export default function CreateVestingBalance(properties) {

const [showDialog, setShowDialog] = useState(false);

const _assetsBTS = useSyncExternalStore($assetCacheBTS.subscribe, $assetCacheBTS.get, () => true);
const _assetsTEST = useSyncExternalStore(
$assetCacheTEST.subscribe,
$assetCacheTEST.get,
() => true
);
const { _assetsBTS, _assetsTEST, _marketSearchBTS, _marketSearchTEST } = properties;

const _chain = useMemo(() => {
if (usr && usr.chain) {
Expand All @@ -62,26 +55,14 @@ export default function CreateVestingBalance(properties) {
return "bitshares";
}, [usr]);

useInitCache(_chain ?? "bitshares", ["assets", "marketSearch"]);
useInitCache(_chain ?? "bitshares", []);

const assets = useMemo(() => {
if (_chain && (_assetsBTS || _assetsTEST)) {
return _chain === "bitshares" ? _assetsBTS : _assetsTEST;
}
return [];
}, [_assetsBTS, _assetsTEST, _chain]);

const _marketSearchBTS = useSyncExternalStore(
$marketSearchCacheBTS.subscribe,
$marketSearchCacheBTS.get,
() => true
);

const _marketSearchTEST = useSyncExternalStore(
$marketSearchCacheTEST.subscribe,
$marketSearchCacheTEST.get,
() => true
);

const marketSearch = useMemo(() => {
if (usr && usr.chain && (_marketSearchBTS || _marketSearchTEST)) {
Expand Down Expand Up @@ -220,7 +201,7 @@ export default function CreateVestingBalance(properties) {
excludedUsers={[]}
setChosenAccount={(_account) => {
if (_account) {
console.log({ _account, usr });
//console.log({ _account, usr });
setTargetUser(_account);
}
setTargetUserDialogOpen(false);
Expand Down
26 changes: 2 additions & 24 deletions src/components/CreditBorrow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ import { useInitCache } from "@/nanoeffects/Init.ts";
import { $currentUser } from "@/stores/users.ts";
import { $blockList } from "@/stores/blocklist.ts";
import { $currentNode } from "@/stores/node.ts";
import {
$assetCacheBTS,
$assetCacheTEST,
$offersCacheBTS,
$offersCacheTEST,
} from "@/stores/cache.ts";

import { humanReadableFloat, debounce } from "@/lib/common.js";
import ExternalLink from "./common/ExternalLink.jsx";
Expand All @@ -59,23 +53,7 @@ export default function CreditBorrow(properties) {

const currentNode = useStore($currentNode);

const _assetsBTS = useSyncExternalStore($assetCacheBTS.subscribe, $assetCacheBTS.get, () => true);
const _assetsTEST = useSyncExternalStore(
$assetCacheTEST.subscribe,
$assetCacheTEST.get,
() => true
);

const _offersBTS = useSyncExternalStore(
$offersCacheBTS.subscribe,
$offersCacheBTS.get,
() => true
);
const _offersTEST = useSyncExternalStore(
$offersCacheTEST.subscribe,
$offersCacheTEST.get,
() => true
);
const { _assetsBTS, _assetsTEST, _offersBTS, _offersTEST } = properties;

const _chain = useMemo(() => {
if (usr && usr.chain) {
Expand All @@ -84,7 +62,7 @@ export default function CreditBorrow(properties) {
return "bitshares";
}, [usr]);

useInitCache(_chain ?? "bitshares", ["assets", "offers"]);
useInitCache(_chain ?? "bitshares", []);

const assets = useMemo(() => {
if (_chain && (_assetsBTS || _assetsTEST)) {
Expand Down
30 changes: 4 additions & 26 deletions src/components/CreditDeals.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ import { Input } from "@/components/ui/input";

import { $currentUser } from "@/stores/users.ts";
import { $currentNode } from "@/stores/node.ts";
import {
$assetCacheBTS,
$assetCacheTEST,
$globalParamsCacheBTS,
$globalParamsCacheTEST,
} from "@/stores/cache.ts";

import { useInitCache } from "@/nanoeffects/Init.ts";
import { createUserBalancesStore } from "@/nanoeffects/UserBalances.ts";
Expand All @@ -68,23 +62,7 @@ export default function CreditDeals(properties) {

const usr = useSyncExternalStore($currentUser.subscribe, $currentUser.get, () => true);

const _assetsBTS = useSyncExternalStore($assetCacheBTS.subscribe, $assetCacheBTS.get, () => true);
const _assetsTEST = useSyncExternalStore(
$assetCacheTEST.subscribe,
$assetCacheTEST.get,
() => true
);

const _globalParamsBTS = useSyncExternalStore(
$globalParamsCacheBTS.subscribe,
$globalParamsCacheBTS.get,
() => true
);
const _globalParamsTEST = useSyncExternalStore(
$globalParamsCacheTEST.subscribe,
$globalParamsCacheTEST.get,
() => true
);
const { _assetsBTS, _assetsTEST, _globalParamsBTS, _globalParamsTEST } = properties;

const _chain = useMemo(() => {
if (usr && usr.chain) {
Expand All @@ -93,7 +71,7 @@ export default function CreditDeals(properties) {
return "bitshares";
}, [usr]);

useInitCache(_chain ?? "bitshares", ["assets", "globalParams"]);
useInitCache(_chain ?? "bitshares", []);

const assets = useMemo(() => {
if (_chain && (_assetsBTS || _assetsTEST)) {
Expand All @@ -112,8 +90,8 @@ export default function CreditDeals(properties) {
const [fee, setFee] = useState(0);
useEffect(() => {
if (globalParams && globalParams.length) {
const foundFee = globalParams.find((x) => x[0] === 73);
const finalFee = humanReadableFloat(foundFee[1].fee, 5);
const foundFee = globalParams.find((x) => x.id === 73);
const finalFee = humanReadableFloat(foundFee.data.fee, 5);
setFee(finalFee);
}
}, [globalParams]);
Expand Down
Loading

0 comments on commit 39cb398

Please sign in to comment.