From 0736835c3a1952a81bc7f9d84f6a56b3fbeaad17 Mon Sep 17 00:00:00 2001 From: Marcel Ebert Date: Thu, 12 Sep 2024 12:20:15 +0200 Subject: [PATCH 01/15] Bump api-solang to latest version --- package.json | 2 +- yarn.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index d5049a15..2e166748 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "@hookform/resolvers": "^2.9.11", "@netlify/functions": "^2.8.1", "@pendulum-chain/api": "^0.3.8", - "@pendulum-chain/api-solang": "^0.4.0", + "@pendulum-chain/api-solang": "^0.6.1", "@polkadot/api": "^10.9.1", "@polkadot/api-base": "^10.9.1", "@polkadot/api-contract": "^10.9.1", diff --git a/yarn.lock b/yarn.lock index 3436d92b..bd5cbfe8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3342,9 +3342,9 @@ __metadata: languageName: node linkType: hard -"@pendulum-chain/api-solang@npm:^0.4.0": - version: 0.4.0 - resolution: "@pendulum-chain/api-solang@npm:0.4.0" +"@pendulum-chain/api-solang@npm:^0.6.1": + version: 0.6.1 + resolution: "@pendulum-chain/api-solang@npm:0.6.1" peerDependencies: "@polkadot/api": ^10.0 "@polkadot/api-contract": ^10.12.1 @@ -3353,7 +3353,7 @@ __metadata: "@polkadot/types-codec": ^10.0 "@polkadot/util": "*" "@polkadot/util-crypto": "*" - checksum: 10c0/37f0b225b1529dd46b38e050a4fac89acb706bc62b10855db83f4e8658423aeb921f8ad16fadcd21e9aef68aa5ac66274dbdd829247005a3e207a94411ab1cd0 + checksum: 10c0/9db47f45bad07c33820b73bd0ef0c4573102a6fa11a135f4e31f9381c8a9d76804c5b217433ac63c25ebd17f2126457c50e41cb4867641aeffa027b247811905 languageName: node linkType: hard @@ -13453,7 +13453,7 @@ __metadata: "@hookform/resolvers": "npm:^2.9.11" "@netlify/functions": "npm:^2.8.1" "@pendulum-chain/api": "npm:^0.3.8" - "@pendulum-chain/api-solang": "npm:^0.4.0" + "@pendulum-chain/api-solang": "npm:^0.6.1" "@pendulum-chain/types": "npm:^0.3.8" "@polkadot/api": "npm:^10.9.1" "@polkadot/api-base": "npm:^10.9.1" From b3d108bb55c970405c8356f3a374ba6a92e22244 Mon Sep 17 00:00:00 2001 From: Marcel Ebert Date: Thu, 12 Sep 2024 12:21:31 +0200 Subject: [PATCH 02/15] Show button to view nabla transaction on explorer --- .../nabla/common/TransactionProgress.tsx | 41 +++++++++++++++---- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/src/components/nabla/common/TransactionProgress.tsx b/src/components/nabla/common/TransactionProgress.tsx index 4a74e95f..90b6e7c0 100644 --- a/src/components/nabla/common/TransactionProgress.tsx +++ b/src/components/nabla/common/TransactionProgress.tsx @@ -5,6 +5,8 @@ import { ExecuteMessageResult } from '@pendulum-chain/api-solang'; import Spinner from '../../../assets/spinner'; import { UseContractWriteResponse } from '../../../hooks/nabla/useContractWrite'; +import { TenantName } from '../../../models/Tenant'; +import { useGlobalState } from '../../../GlobalStateProvider'; export interface TransactionProgressProps { mutation: UseContractWriteResponse; @@ -26,43 +28,64 @@ const getErrorMessage = (data?: ExecuteMessageResult['result']) => { } }; +function getExplorerUrl(tenant: TenantName, data?: ExecuteMessageResult['execution']) { + if (tenant === TenantName.Pendulum && data?.type === 'extrinsic') { + return `https://pendulum.subscan.io/extrinsic/${data.txHash.toHex()}`; + } + + return undefined; +} + export function TransactionProgress({ mutation, children, onClose }: TransactionProgressProps): JSX.Element | null { - if (mutation.isIdle) return null; + const { tenantName } = useGlobalState(); const errorMsg = getErrorMessage(mutation.data?.result); + + const explorerUrl = getExplorerUrl(tenantName, mutation.data?.execution); + + if (mutation.isIdle) return null; + if (mutation.isLoading) { const isPending = false; // TODO: currently there is not status for this (waiting confirmation in wallet) return ( <> -
+
-

+

{isPending ? 'Waiting for confirmation' : 'Executing transaction'}

{children} -

+

{isPending ? 'Confirm this transaction in your wallet' : 'Proceed in your wallet'}

); } + return ( <>
{mutation.isSuccess ? ( - + ) : ( - + )}
-
+

{mutation.isSuccess ? 'Transaction successful' : 'Transaction failed'}

- {!mutation.isSuccess && !!errorMsg &&

{errorMsg}

} + {!mutation.isSuccess && !!errorMsg &&

{errorMsg}

} + {!!explorerUrl && ( + + + + )} {!!onClose && ( - )} From 572e5a1edecf3a9a252f005c78c90acce6a04215 Mon Sep 17 00:00:00 2001 From: Marcel Ebert Date: Thu, 12 Sep 2024 12:31:23 +0200 Subject: [PATCH 03/15] Change margin of buttons --- src/components/nabla/common/TransactionProgress.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/nabla/common/TransactionProgress.tsx b/src/components/nabla/common/TransactionProgress.tsx index 90b6e7c0..e6bd86b8 100644 --- a/src/components/nabla/common/TransactionProgress.tsx +++ b/src/components/nabla/common/TransactionProgress.tsx @@ -77,6 +77,7 @@ export function TransactionProgress({ mutation, children, onClose }: Transaction
{!mutation.isSuccess && !!errorMsg &&

{errorMsg}

} +
{!!explorerUrl && ( )} From ee87ac02b42ce049f6cc02044c62456ae4155434 Mon Sep 17 00:00:00 2001 From: Marcel Ebert Date: Thu, 12 Sep 2024 12:31:38 +0200 Subject: [PATCH 04/15] Enable Nabla on Pendulum (only for testing, to be removed) --- src/config/apps/nabla.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/config/apps/nabla.ts b/src/config/apps/nabla.ts index d6d70af7..41011c58 100644 --- a/src/config/apps/nabla.ts +++ b/src/config/apps/nabla.ts @@ -1,5 +1,6 @@ import { TenantName } from '../../models/Tenant'; import { AppConfigBase } from './types'; + export type NablaConfig = AppConfigBase & Partial< Record< @@ -13,11 +14,16 @@ export type NablaConfig = AppConfigBase & >; export const nablaConfig: NablaConfig = { - tenants: [TenantName.Foucoco], - environment: ['staging', 'development'], + tenants: [TenantName.Foucoco, TenantName.Pendulum], + environment: ['staging', 'development', 'production'], foucoco: { indexerUrl: 'https://pendulum.squids.live/foucoco-squid/graphql', router: '6mYwT4yRrrMK978NszqBvxkvXjYnsmKfs2BkYGJGiR4XY9Sc', oracle: '6kqj1tnYUGY3L93YFArXKF2E4tpQ2tUJ4DARwkAjZEyDoof6', }, + pendulum: { + indexerUrl: 'https://pendulum.squids.live/pendulum-squid/graphql', + router: '6buMJsFCbXpHRyacKTjBn3Jss241b2aA7CZf9tKzKHMJWpcJ', + oracle: '6f9uHwN2r5w82Bjrywc4wmZYb6TN64bZH5Ev87qmJ675uFvq', + }, }; From 947235122027b715fb9594f3a71670b56d0169ab Mon Sep 17 00:00:00 2001 From: Kacper Szarkiewicz Date: Wed, 25 Sep 2024 13:26:42 +0100 Subject: [PATCH 05/15] remove unnecessary code --- src/components/nabla/common/TransactionProgress.tsx | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/components/nabla/common/TransactionProgress.tsx b/src/components/nabla/common/TransactionProgress.tsx index e6bd86b8..24441b34 100644 --- a/src/components/nabla/common/TransactionProgress.tsx +++ b/src/components/nabla/common/TransactionProgress.tsx @@ -32,11 +32,9 @@ function getExplorerUrl(tenant: TenantName, data?: ExecuteMessageResult['executi if (tenant === TenantName.Pendulum && data?.type === 'extrinsic') { return `https://pendulum.subscan.io/extrinsic/${data.txHash.toHex()}`; } - - return undefined; } -export function TransactionProgress({ mutation, children, onClose }: TransactionProgressProps): JSX.Element | null { +export function TransactionProgress({ mutation, children, onClose }: TransactionProgressProps) { const { tenantName } = useGlobalState(); const errorMsg = getErrorMessage(mutation.data?.result); @@ -79,10 +77,8 @@ export function TransactionProgress({ mutation, children, onClose }: Transaction {!mutation.isSuccess && !!errorMsg &&

{errorMsg}

}
{!!explorerUrl && ( - - + + View on Explorer )} {!!onClose && ( From 3241f1d84c5fcdbc63883fb9859f6875c6750d02 Mon Sep 17 00:00:00 2001 From: Kacper Szarkiewicz Date: Wed, 25 Sep 2024 15:41:02 +0100 Subject: [PATCH 06/15] improve nav responsiveness when multiple collapse groups appear --- src/components/Layout/Nav.tsx | 14 +++++++------- src/components/Layout/index.tsx | 16 ++++++++-------- src/index.css | 4 ++++ 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/components/Layout/Nav.tsx b/src/components/Layout/Nav.tsx index 5d13e166..cb1cd04b 100644 --- a/src/components/Layout/Nav.tsx +++ b/src/components/Layout/Nav.tsx @@ -1,8 +1,7 @@ -import { memo, useEffect, useMemo, useState } from 'preact/compat'; +import { memo, useEffect, useMemo, useState, useRef } from 'preact/compat'; import { NavLink, useLocation } from 'react-router-dom'; import { useGlobalState } from '../../GlobalStateProvider'; -import useBoolean from '../../hooks/useBoolean'; import { createLinks, LinkItem } from './links'; import { NavCollapseButtonContent } from './NavCollapseButtonContent'; @@ -25,17 +24,18 @@ const CollapseMenu = ({ const paths = path.split('/').filter(Boolean); return paths[1] && paths[1].startsWith(link.replace('/', '')) ? true : false; }, [link, pathname]); - const [isOpen, { toggle }] = useBoolean(isActive); + + const inputRef = useRef(null); return ( -
+
+ @@ -109,7 +109,7 @@ const Nav = memo(({ onClick }: NavProps) => { ariaControls="submenu" button={} > -
-
+
-
- -
    +
    • @@ -104,7 +104,7 @@ export default function Layout(): JSX.Element | null {
{ if (visible && isMobile) { setVisible(false); diff --git a/src/index.css b/src/index.css index 0bfa7bc6..2c75097b 100644 --- a/src/index.css +++ b/src/index.css @@ -353,6 +353,10 @@ w3m-modal { scrollbar-width: none; } +.scroll-thin { + scrollbar-width: thin; +} + :root:has(:is(.modal-open, .modal:target, .modal-toggle:checked + .modal, .modal[open])) { scrollbar-gutter: unset; } From fe379f0650105e75d3f8c9e7f20b26127458b461 Mon Sep 17 00:00:00 2001 From: Kacper Szarkiewicz Date: Wed, 25 Sep 2024 15:42:29 +0100 Subject: [PATCH 07/15] fix button class --- src/components/nabla/common/TransactionProgress.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/nabla/common/TransactionProgress.tsx b/src/components/nabla/common/TransactionProgress.tsx index 24441b34..20403b71 100644 --- a/src/components/nabla/common/TransactionProgress.tsx +++ b/src/components/nabla/common/TransactionProgress.tsx @@ -77,7 +77,7 @@ export function TransactionProgress({ mutation, children, onClose }: Transaction {!mutation.isSuccess && !!errorMsg &&

{errorMsg}

}
{!!explorerUrl && ( - + View on Explorer )} From 293f97b352bb109f300f6dcd77c7af143fc4eafd Mon Sep 17 00:00:00 2001 From: Kacper Szarkiewicz Date: Wed, 25 Sep 2024 15:50:50 +0100 Subject: [PATCH 08/15] change swap footer text --- src/components/Layout/Nav.tsx | 2 +- src/components/nabla/common/NablaFootnote.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Layout/Nav.tsx b/src/components/Layout/Nav.tsx index cb1cd04b..5b00d200 100644 --- a/src/components/Layout/Nav.tsx +++ b/src/components/Layout/Nav.tsx @@ -28,7 +28,7 @@ const CollapseMenu = ({ const inputRef = useRef(null); return ( -
+
+
{children}
+
+ ); +}; From acd3023fb29e50a0d53798a6d9e7be123bde962f Mon Sep 17 00:00:00 2001 From: Kacper Szarkiewicz Date: Mon, 30 Sep 2024 12:21:45 +0200 Subject: [PATCH 12/15] change Nav component structure --- src/components/Layout/Nav.tsx | 129 ---------------------------- src/components/Layout/Nav/index.tsx | 80 +++++++++++++++++ 2 files changed, 80 insertions(+), 129 deletions(-) delete mode 100644 src/components/Layout/Nav.tsx create mode 100644 src/components/Layout/Nav/index.tsx diff --git a/src/components/Layout/Nav.tsx b/src/components/Layout/Nav.tsx deleted file mode 100644 index a3d97aed..00000000 --- a/src/components/Layout/Nav.tsx +++ /dev/null @@ -1,129 +0,0 @@ -import { memo, useEffect, useMemo, useState, useRef } from 'preact/compat'; -import { NavLink, useLocation } from 'react-router-dom'; - -import { useGlobalState } from '../../GlobalStateProvider'; -import { createLinks, LinkItem } from './links'; -import { NavCollapseButtonContent } from './NavCollapseButtonContent'; - -const CollapseMenu = ({ - link, - disabled, - button, - children, - ariaControls, -}: { - link: string; - disabled?: boolean; - button: JSX.Element | null; - children: JSX.Element | null; - ariaControls?: string; -}) => { - const { pathname } = useLocation(); - const isActive = useMemo(() => { - const [path] = pathname.split('?'); - const paths = path.split('/').filter(Boolean); - return paths[1] && paths[1].startsWith(link.replace('/', '')) ? true : false; - }, [link, pathname]); - - const inputRef = useRef(null); - - return ( -
- - -
{children}
-
- ); -}; - -export const NavItem = ({ - item, - onClick, - isSubNavItem = false, -}: { - item: LinkItem; - onClick?: () => void; - isSubNavItem?: boolean; -}) => { - const { link, prefix, suffix, title, props, hidden } = item; - if (hidden) return null; - const isExternal = link.startsWith('http'); - const linkUi = ( - <> - {prefix} - {title} - {suffix} - - ); - const cls = `nav-item font-outfit ${props?.className?.() || ''} ${isSubNavItem ? 'text-sm' : ''}`; - return isExternal ? ( - - {linkUi} - - ) : ( - - {linkUi} - - ); -}; - -export type NavProps = { - onClick?: () => void; -}; - -const Nav = memo(({ onClick }: NavProps) => { - const state = useGlobalState(); - - const [isPlaying, setIsPlaying] = useState(false); - const [links, setLinks] = useState([]); - - const handleMouseEnter = () => { - setIsPlaying(true); - }; - - useEffect(() => { - const [defaultLinks, loadedLinksPromise] = createLinks(state.tenantName); - setLinks(defaultLinks); - - loadedLinksPromise.then((links) => setLinks(links)).catch((error) => console.error("Couldn't load links", error)); - }, [state.tenantName]); - - return ( - - ); -}); - -export default Nav; diff --git a/src/components/Layout/Nav/index.tsx b/src/components/Layout/Nav/index.tsx new file mode 100644 index 00000000..a22cdb65 --- /dev/null +++ b/src/components/Layout/Nav/index.tsx @@ -0,0 +1,80 @@ +import { memo, useEffect, useMemo, useState } from 'preact/compat'; +import { useLocation } from 'react-router-dom'; +import { useGlobalState } from '../../../GlobalStateProvider'; +import { NavCollapseButtonContent } from '../NavCollapseButtonContent'; +import { createLinks, LinkItem } from '../links'; +import { NavItem } from './NavItem'; +import { NavCollapseMenu } from './NavCollapseMenu'; + +const getActiveLink = (pathname: string): string | null => { + const [path] = pathname.split('?'); + const paths = path.split('/').filter(Boolean); + return paths.length > 1 ? `/${paths[1]}` : null; +}; + +export type NavProps = { + onClick?: () => void; +}; + +const Nav = memo(({ onClick }: NavProps) => { + const state = useGlobalState(); + + const [isPlaying, setIsPlaying] = useState(false); + const [links, setLinks] = useState([]); + + const { pathname } = useLocation(); + const activeLink = useMemo(() => getActiveLink(pathname), [pathname]); + const [activeSelection, setActiveSelection] = useState(activeLink); + + const handleMouseEnter = () => { + setIsPlaying(true); + }; + + useEffect(() => { + const [defaultLinks, loadedLinksPromise] = createLinks(state.tenantName); + setLinks(defaultLinks); + + loadedLinksPromise.then(setLinks).catch((error) => console.error("Couldn't load links", error)); + }, [state.tenantName]); + + return ( + + ); +}); + +export default Nav; From 0e6b8a8d945d4db778a32c3247761f48aebd6ef7 Mon Sep 17 00:00:00 2001 From: Kacper Szarkiewicz Date: Mon, 30 Sep 2024 12:22:24 +0200 Subject: [PATCH 13/15] remove unnecessary Promise constructor, no-async-promise-executor --- src/components/Layout/links.tsx | 43 ++++++++++++++++----------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/src/components/Layout/links.tsx b/src/components/Layout/links.tsx index 1d6501b8..36e5b9ff 100644 --- a/src/components/Layout/links.tsx +++ b/src/components/Layout/links.tsx @@ -169,26 +169,25 @@ export function createLinks(tenantName: TenantName): [LinkItem[], Promise { - const alchemyPayLink = await config.alchemyPay.encodeUrlWithRedirection( - config.alchemyPay.prodUrl, - window.location.href, - ); - - resolve([ - dashboardLinkItem, - zenlinkAmmLinkItem, - spacewalkLinkItem, - nablaLinkItem, - stakingLinkItem, - governanceLinkItem, - { - ...alchemyPayLinkItem, - link: alchemyPayLink, - }, - ]); - }), - ]; + const getLinks = async () => { + const alchemyPayLink = await config.alchemyPay.encodeUrlWithRedirection( + config.alchemyPay.prodUrl, + window.location.href, + ); + + return [ + dashboardLinkItem, + zenlinkAmmLinkItem, + spacewalkLinkItem, + nablaLinkItem, + stakingLinkItem, + governanceLinkItem, + { + ...alchemyPayLinkItem, + link: alchemyPayLink, + }, + ]; + }; + + return [links, getLinks()]; } From 580f0cdbc254abe423865ce8d604cad6542aec7b Mon Sep 17 00:00:00 2001 From: Kacper Szarkiewicz Date: Mon, 30 Sep 2024 12:49:54 +0200 Subject: [PATCH 14/15] remove unused Nav component --- src/components/Layout/Nav.tsx | 129 ---------------------------------- 1 file changed, 129 deletions(-) delete mode 100644 src/components/Layout/Nav.tsx diff --git a/src/components/Layout/Nav.tsx b/src/components/Layout/Nav.tsx deleted file mode 100644 index a3d97aed..00000000 --- a/src/components/Layout/Nav.tsx +++ /dev/null @@ -1,129 +0,0 @@ -import { memo, useEffect, useMemo, useState, useRef } from 'preact/compat'; -import { NavLink, useLocation } from 'react-router-dom'; - -import { useGlobalState } from '../../GlobalStateProvider'; -import { createLinks, LinkItem } from './links'; -import { NavCollapseButtonContent } from './NavCollapseButtonContent'; - -const CollapseMenu = ({ - link, - disabled, - button, - children, - ariaControls, -}: { - link: string; - disabled?: boolean; - button: JSX.Element | null; - children: JSX.Element | null; - ariaControls?: string; -}) => { - const { pathname } = useLocation(); - const isActive = useMemo(() => { - const [path] = pathname.split('?'); - const paths = path.split('/').filter(Boolean); - return paths[1] && paths[1].startsWith(link.replace('/', '')) ? true : false; - }, [link, pathname]); - - const inputRef = useRef(null); - - return ( -
- - -
{children}
-
- ); -}; - -export const NavItem = ({ - item, - onClick, - isSubNavItem = false, -}: { - item: LinkItem; - onClick?: () => void; - isSubNavItem?: boolean; -}) => { - const { link, prefix, suffix, title, props, hidden } = item; - if (hidden) return null; - const isExternal = link.startsWith('http'); - const linkUi = ( - <> - {prefix} - {title} - {suffix} - - ); - const cls = `nav-item font-outfit ${props?.className?.() || ''} ${isSubNavItem ? 'text-sm' : ''}`; - return isExternal ? ( - - {linkUi} - - ) : ( - - {linkUi} - - ); -}; - -export type NavProps = { - onClick?: () => void; -}; - -const Nav = memo(({ onClick }: NavProps) => { - const state = useGlobalState(); - - const [isPlaying, setIsPlaying] = useState(false); - const [links, setLinks] = useState([]); - - const handleMouseEnter = () => { - setIsPlaying(true); - }; - - useEffect(() => { - const [defaultLinks, loadedLinksPromise] = createLinks(state.tenantName); - setLinks(defaultLinks); - - loadedLinksPromise.then((links) => setLinks(links)).catch((error) => console.error("Couldn't load links", error)); - }, [state.tenantName]); - - return ( - - ); -}); - -export default Nav; From f191c250a8d0c305a1c1bf2d4b7039b2712f4dd9 Mon Sep 17 00:00:00 2001 From: Kacper Szarkiewicz Date: Mon, 30 Sep 2024 12:50:10 +0200 Subject: [PATCH 15/15] disable ForexAMM for Pendulum --- src/config/apps/nabla.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/config/apps/nabla.ts b/src/config/apps/nabla.ts index 41011c58..cf0da3de 100644 --- a/src/config/apps/nabla.ts +++ b/src/config/apps/nabla.ts @@ -14,16 +14,11 @@ export type NablaConfig = AppConfigBase & >; export const nablaConfig: NablaConfig = { - tenants: [TenantName.Foucoco, TenantName.Pendulum], - environment: ['staging', 'development', 'production'], + tenants: [TenantName.Foucoco], + environment: ['staging', 'development'], foucoco: { indexerUrl: 'https://pendulum.squids.live/foucoco-squid/graphql', router: '6mYwT4yRrrMK978NszqBvxkvXjYnsmKfs2BkYGJGiR4XY9Sc', oracle: '6kqj1tnYUGY3L93YFArXKF2E4tpQ2tUJ4DARwkAjZEyDoof6', }, - pendulum: { - indexerUrl: 'https://pendulum.squids.live/pendulum-squid/graphql', - router: '6buMJsFCbXpHRyacKTjBn3Jss241b2aA7CZf9tKzKHMJWpcJ', - oracle: '6f9uHwN2r5w82Bjrywc4wmZYb6TN64bZH5Ev87qmJ675uFvq', - }, };