Skip to content

Commit

Permalink
Nodes and Swaps
Browse files Browse the repository at this point in the history
New node page: Configure your own blockchain node URLs
New swap page: Simplified liquidity pool UX
Misc fixes
package version updates
  • Loading branch information
grctest committed Aug 26, 2024
1 parent 9b9e662 commit cf72808
Show file tree
Hide file tree
Showing 72 changed files with 2,585 additions and 116 deletions.
80 changes: 40 additions & 40 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@
"@radix-ui/react-toggle-group": "^1.1.0",
"@radix-ui/react-tooltip": "^1.1.2",
"@react-hook/throttle": "^2.2.0",
"@types/react": "^18.3.3",
"@types/react": "^18.3.4",
"@types/react-dom": "^18.3.0",
"assert": "^2.1.0",
"astro": "^4.14.2",
"astro": "^4.14.5",
"bigi": "^1.4.2",
"bignumber.js": "^9.1.2",
"bitsharesjs": "https://github.com/bitshares/bitsharesjs#develop",
Expand All @@ -102,7 +102,7 @@
"deep-equal": "^2.2.3",
"ecurve": "^1.0.6",
"electron-devtools-installer": "^3.2.0",
"embla-carousel-react": "^8.1.8",
"embla-carousel-react": "^8.2.0",
"express": "^4.19.2",
"fuse.js": "^7.0.0",
"input-otp": "^1.2.4",
Expand All @@ -114,10 +114,10 @@
"react": "^18.3.1",
"react-day-picker": "^8.10.1",
"react-dom": "^18.3.1",
"react-hook-form": "^7.52.2",
"react-hook-form": "^7.53.0",
"react-i18next": "^15.0.1",
"react-intersection-observer": "^9.13.0",
"react-resizable-panels": "^2.1.0",
"react-resizable-panels": "^2.1.1",
"react-window": "^1.8.10",
"recharts": "^2.12.7",
"safe-buffer": "^5.2.1",
Expand All @@ -136,7 +136,7 @@
"@babel/preset-env": "^7.25.3",
"@soda/friendly-errors-webpack-plugin": "^1.8.1",
"babel-loader": "^9.1.3",
"electron": "^31.4.0",
"electron": "^32.0.1",
"electron-builder": "^24.13.3",
"webpack": "^5.93.0",
"webpack-cli": "^5.1.4",
Expand Down
5 changes: 4 additions & 1 deletion src/components/AccountSearch.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useState, useEffect } from "react";
import { useStore } from '@nanostores/react';
import { useTranslation } from "react-i18next";
import { i18n as i18nInstance, locale } from "@/lib/i18n.js";

Expand All @@ -16,10 +17,12 @@ import { Button } from "@/components/ui/button";
import { Avatar } from "@/components/Avatar.tsx";

import { accountSearch } from "@/nanoeffects/UserSearch.ts";
import { $currentNode } from "@/stores/node.ts";

export default function AccountSearch(properties) {
const { chain, excludedUsers, setChosenAccount } = properties;
const { t, i18n } = useTranslation(locale.get(), { i18n: i18nInstance });
const currentNode = useStore($currentNode);

const [accountInput, setAccountInput] = useState();
const [errorMessage, setErrorMessage] = useState();
Expand All @@ -39,7 +42,7 @@ export default function AccountSearch(properties) {

let response;
try {
response = await accountSearch(chain, accountInput);
response = await accountSearch(chain, accountInput, currentNode ? currentNode.url : null);
} catch (error) {
console.log({ error, msg: t("AccountSearch:noSearch.error") });
setErrorMessage(t("AccountSearch:noSearch.error"));
Expand Down
5 changes: 4 additions & 1 deletion src/components/AccountSelect.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useState, useEffect, useSyncExternalStore } from "react";
import { useTranslation } from "react-i18next";
import { useStore } from '@nanostores/react';
import { i18n as i18nInstance, locale } from "@/lib/i18n.js";

import {
Expand All @@ -18,12 +19,14 @@ import { Button } from "@/components/ui/button";
import { Avatar } from "@/components/Avatar.tsx";

import { $currentUser, setCurrentUser, $userStorage, removeUser } from "@/stores/users.ts";
import { $currentNode } from "@/stores/node.ts";

import { accountSearch } from "@/nanoeffects/UserSearch.ts";

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

const [chain, setChain] = useState();
const [mode, setMode] = useState();
Expand All @@ -43,7 +46,7 @@ export default function AccountSelect(properties) {
async function lookupAccount() {
let response;
try {
response = await accountSearch(chain, accountInput);
response = await accountSearch(chain, accountInput, currentNode ? currentNode.url : null);
} catch (error) {
console.log({ error, msg: t("AccountSelect:noAccount") });
setErrorMessage(t("AccountSelect:noAccount"));
Expand Down
31 changes: 25 additions & 6 deletions src/components/CreditBorrow.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useState, useEffect, useSyncExternalStore, useMemo } from "react";
import React, { useState, useEffect, useSyncExternalStore, useMemo, useCallback } from "react";
import { FixedSizeList as List } from "react-window";
import Fuse from "fuse.js";
import { useStore } from '@nanostores/react';
import { useTranslation } from "react-i18next";
import { GearIcon } from "@radix-ui/react-icons";

import { i18n as i18nInstance, locale } from "@/lib/i18n.js";

Expand All @@ -23,14 +23,15 @@ import { createUserBalancesStore } from "@/nanoeffects/UserBalances.ts";
import { useInitCache } from "@/nanoeffects/Init.ts";

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

import { humanReadableFloat } from "@/lib/common.js";
import { humanReadableFloat, debounce } from "@/lib/common.js";

function hoursTillExpiration(expirationTime) {
var expirationDate = new Date(expirationTime);
Expand All @@ -50,6 +51,7 @@ const isValid = (str) => /^[a-zA-Z0-9.-]+$/.test(str);
export default function CreditBorrow(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(
Expand Down Expand Up @@ -105,7 +107,7 @@ export default function CreditBorrow(properties) {
let unsubscribeUserBalances;

if (usr && usr.id) {
const userBalancesStore = createUserBalancesStore([usr.chain, usr.id]);
const userBalancesStore = createUserBalancesStore([usr.chain, usr.id, currentNode ? currentNode.url : null]);

unsubscribeUserBalances = userBalancesStore.subscribe(({ data, error, loading }) => {
if (data && !error && !loading) {
Expand Down Expand Up @@ -350,6 +352,21 @@ export default function CreditBorrow(properties) {
return <CommonRow index={index} style={style} res={res} foundAsset={foundAsset} />;
};

const [thisSearchInput, setThisSearchInput] = useState();

const debouncedSetSearchInput = useCallback(
// Throttle slider
debounce((event) => {
setThisInput(event.target.value);
window.history.replaceState(
{},
"",
`?tab=search&searchTab=${activeSearch}&searchText=${event.target.value}`
);
}, 500),
[]
);

return (
<>
<div className="container mx-auto mt-5 mb-5">
Expand Down Expand Up @@ -512,10 +529,12 @@ export default function CreditBorrow(properties) {
</TabsList>
<Input
name="searchInput"
placeholder={thisInput ?? "Enter search text"}
placeholder={thisSearchInput ?? t("Smartcoins:enterSearchText")}
className="mb-3 mt-3 w-full"
value={thisSearchInput || ""}
onChange={(event) => {
setThisInput(event.target.value);
setThisSearchInput(event.target.value);
debouncedSetSearchInput(event)
}}
/>
<TabsContent value="borrow">
Expand Down
6 changes: 4 additions & 2 deletions src/components/CreditDeals.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState, useEffect, useSyncExternalStore, useMemo } from "react";
import { FixedSizeList as List } from "react-window";
import { useForm } from "react-hook-form";
import { useStore } from '@nanostores/react';
import { useTranslation } from "react-i18next";
import { i18n as i18nInstance, locale } from "@/lib/i18n.js";

Expand Down Expand Up @@ -38,6 +39,7 @@ import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";

import { $currentUser } from "@/stores/users.ts";
import { $currentNode } from "@/stores/node.ts";
import {
$assetCacheBTS,
$assetCacheTEST,
Expand All @@ -46,7 +48,6 @@ import {
} from "@/stores/cache.ts";

import { useInitCache } from "@/nanoeffects/Init.ts";

import { createUserBalancesStore } from "@/nanoeffects/UserBalances.ts";
import { createBorrowerDealsStore } from "@/nanoeffects/BorrowerDeals.ts";
import { createLenderDealsStore } from "@/nanoeffects/LenderDeals.ts";
Expand All @@ -63,6 +64,7 @@ export default function CreditDeals(properties) {
account: "",
},
});
const currentNode = useStore($currentNode);

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

Expand Down Expand Up @@ -159,7 +161,7 @@ export default function CreditDeals(properties) {
let unsubscribeUserBalances;

if (usr && usr.id) {
const userBalancesStore = createUserBalancesStore([usr.chain, usr.id]);
const userBalancesStore = createUserBalancesStore([usr.chain, usr.id, currentNode ? currentNode.url : null]);

unsubscribeUserBalances = userBalancesStore.subscribe(({ data, error, loading }) => {
if (data && !error && !loading) {
Expand Down
Loading

0 comments on commit cf72808

Please sign in to comment.