From 86d5d9eeabf14ad47b2d5ab700459a5adcc26eba Mon Sep 17 00:00:00 2001 From: Dmytro Date: Thu, 21 Dec 2023 13:27:27 +0000 Subject: [PATCH 1/4] Add pricing launch timestamp --- src/Router.tsx | 9 ++++++--- src/components/ChainAccordion.tsx | 20 +++++++++++++------- src/core/paymaster.ts | 9 +++++++++ src/data/paymaster.ts | 12 ++++++++---- 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/Router.tsx b/src/Router.tsx index 2e1f5e6..bc0f985 100644 --- a/src/Router.tsx +++ b/src/Router.tsx @@ -21,6 +21,7 @@ import TermsModal from './components/TermsModal' import { getHistoryFromStorage, setHistoryToStorage } from './core/transferHistory' import { BRIDGE_PAGES } from './core/constants' +import { pricingLaunchTsReached } from './core/paymaster' // import chainsJson from './chainsJson.json'; @@ -100,9 +101,11 @@ export default function Router() { } /> } /> - - } /> - + {pricingLaunchTsReached(mpc.config.skaleNetwork) ? ( + + } /> + + ) : null} ) diff --git a/src/components/ChainAccordion.tsx b/src/components/ChainAccordion.tsx index 09446f7..3ce0804 100644 --- a/src/components/ChainAccordion.tsx +++ b/src/components/ChainAccordion.tsx @@ -54,14 +54,16 @@ import { HTTPS_PREFIX, WSS_PREFIX } from '../core/chain' +import { pricingLaunchTsReached } from '../core/paymaster' export default function ChainAccordion(props: { schainName: string mpc: MetaportCore className?: string }) { - const proxyBase = PROXY_ENDPOINTS[props.mpc.config.skaleNetwork] - const explorerBase = BASE_EXPLORER_URLS[props.mpc.config.skaleNetwork] + const network = props.mpc.config.skaleNetwork + const proxyBase = PROXY_ENDPOINTS[network] + const explorerBase = BASE_EXPLORER_URLS[network] const rpcUrl = getRpcUrl(proxyBase, props.schainName, HTTPS_PREFIX) const rpcWssUrl = getRpcWsUrl(proxyBase, props.schainName, WSS_PREFIX) @@ -190,11 +192,15 @@ export default function ChainAccordion(props: { explorerUrl={explorerUrl} /> - } - url={`/admin/${props.schainName}`} - /> + {pricingLaunchTsReached(network) ? ( + } + url={`/admin/${props.schainName}`} + /> + ) : ( +
+ )} ) } diff --git a/src/core/paymaster.ts b/src/core/paymaster.ts index e916a1b..c2b22f8 100644 --- a/src/core/paymaster.ts +++ b/src/core/paymaster.ts @@ -23,6 +23,7 @@ import { Contract, id, InterfaceAbi } from 'ethers' import { MetaportCore, interfaces } from '@skalenetwork/metaport' import PAYMASTER_INFO from '../data/paymaster' +import { getCurrentTsBigInt } from './timeHelper' export interface PaymasterInfo { maxReplenishmentPeriod: bigint @@ -61,6 +62,10 @@ export function getPaymasterAddress(skaleNetwork: interfaces.SkaleNetwork): stri return PAYMASTER_INFO.networks[skaleNetwork].address } +export function getPaymasterLaunchTs(skaleNetwork: interfaces.SkaleNetwork): bigint { + return BigInt(PAYMASTER_INFO.networks[skaleNetwork].launchTs) +} + export function getPaymasterAbi(): InterfaceAbi { return PAYMASTER_INFO.abi } @@ -73,6 +78,10 @@ export function initPaymaster(mpc: MetaportCore): Contract { return new Contract(paymasterAddress, getPaymasterAbi(), provider) } +export function pricingLaunchTsReached(skaleNetwork: interfaces.SkaleNetwork): boolean { + return getPaymasterLaunchTs(skaleNetwork) < getCurrentTsBigInt() +} + export async function getPaymasterInfo( paymaster: Contract, targetChainName: string, diff --git a/src/data/paymaster.ts b/src/data/paymaster.ts index 2a55115..0c675af 100644 --- a/src/data/paymaster.ts +++ b/src/data/paymaster.ts @@ -2,19 +2,23 @@ export default { networks: { mainnet: { chain: 'elated-tan-skat', - address: '0x' + address: '0x', + launchTs: '0' }, staging: { chain: 'staging-perfect-parallel-gacrux', - address: '0xeF18D694e7659C1Ed5dE7e83E72e871b32f3fE69' + address: '0xeF18D694e7659C1Ed5dE7e83E72e871b32f3fE69', + launchTs: '0' }, legacy: { chain: 'skale-innocent-nasty', - address: '0xCa1B0A6236BBA2b30F7260863b56209a97351853' + address: '0xCa1B0A6236BBA2b30F7260863b56209a97351853', + launchTs: '1708521648' }, regression: { chain: '', - address: '0x' + address: '0x', + launchTs: '0' } }, abi: [ From 0180714991ad1a5f743123b7336288144a2318be Mon Sep 17 00:00:00 2001 From: Dmytro Date: Thu, 28 Dec 2023 18:26:58 +0000 Subject: [PATCH 2/4] Update schain overview page css, fix elapsed time func --- src/components/CopySurface.tsx | 2 +- src/components/PricingInfo.tsx | 8 +++++- src/components/SchainDetails.tsx | 46 +++++++++++++++----------------- src/components/SkStack.tsx | 1 + src/components/Tile.tsx | 36 +++++++++++++------------ src/core/timeHelper.ts | 11 ++++---- src/data/paymaster.ts | 6 ++--- src/pages/Schain.tsx | 10 +------ 8 files changed, 59 insertions(+), 61 deletions(-) diff --git a/src/components/CopySurface.tsx b/src/components/CopySurface.tsx index 8a1a406..6d80ae1 100644 --- a/src/components/CopySurface.tsx +++ b/src/components/CopySurface.tsx @@ -59,7 +59,7 @@ export default function CopySurface(props: {
- +
{props.tokenMetadata ? ( diff --git a/src/components/PricingInfo.tsx b/src/components/PricingInfo.tsx index 83ee25e..8c430cb 100644 --- a/src/components/PricingInfo.tsx +++ b/src/components/PricingInfo.tsx @@ -57,7 +57,8 @@ export default function PricingInfo(props: { info: PaymasterInfo }) { const elapsedPercentage = calculateElapsedPercentage( props.info.schain.paidUntil, - props.info.maxReplenishmentPeriod + props.info.maxReplenishmentPeriod, + props.info.effectiveTimestamp ) function getDueDateStatus(days: number): DueDateStatus { @@ -110,6 +111,11 @@ export default function PricingInfo(props: { info: PaymasterInfo }) { value={`${formatTimePeriod(Math.abs(untilDueDateMonths), 'month')} `} text={dueDateText} color={dueDateStatus} + textRi={ + props.info.effectiveTimestamp + ? '// Current ts: ' + formatBigIntTimestampSeconds(props.info.effectiveTimestamp) + : '' + } />
diff --git a/src/components/SchainDetails.tsx b/src/components/SchainDetails.tsx index 30ac9b8..398ca9c 100644 --- a/src/components/SchainDetails.tsx +++ b/src/components/SchainDetails.tsx @@ -24,7 +24,6 @@ import { Helmet } from 'react-helmet' import Button from '@mui/material/Button' -import Stack from '@mui/material/Stack' import AddCircleRoundedIcon from '@mui/icons-material/AddCircleRounded' import ArrowOutwardRoundedIcon from '@mui/icons-material/ArrowOutwardRounded' @@ -43,10 +42,12 @@ import { interfaces } from '@skalenetwork/metaport' +import SkStack from './SkStack' import ChainLogo from './ChainLogo' import CopySurface from './CopySurface' import ChainAccordion from './ChainAccordion' import ChainCategories from './ChainCategories' +import Tile from './Tile' import { MAINNET_CHAIN_LOGOS } from '../core/constants' import { getRpcUrl, getExplorerUrl, getChainId, HTTPS_PREFIX } from '../core/chain' @@ -113,19 +114,20 @@ export default function SchainDetails(props: {
- - +

{chainAlias}

{chainDescription}

- -
- -
+ + + + -
+
- {props.chainMeta?.url ? ( -
+
+ {props.chainMeta?.url ? ( -
- ) : null} - -
- - - + ) : null} +
+
+ } + /> + +
diff --git a/src/components/SkStack.tsx b/src/components/SkStack.tsx index e862cf8..5ff9d0c 100644 --- a/src/components/SkStack.tsx +++ b/src/components/SkStack.tsx @@ -30,6 +30,7 @@ export default function SkStack(props: { }) { return ( -
- {props.icon ? ( -
{props.icon}
- ) : null} -

{props.text}

-

{props.textRi}

-
+ {props.text ? ( +
+ {props.icon ? ( +
{props.icon}
+ ) : null} +

{props.text}

+

{props.textRi}

+
+ ) : null}
{props.value ? (

- - - + ) } From 71c1b44def2224d70374f33f4265bd4ab2a55cab Mon Sep 17 00:00:00 2001 From: Dmytro Date: Tue, 2 Jan 2024 17:33:16 +0000 Subject: [PATCH 3/4] Minor CSS changes --- src/App.scss | 2 ++ src/components/SchainDetails.tsx | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/App.scss b/src/App.scss index d92d4c5..f6b2e0a 100644 --- a/src/App.scss +++ b/src/App.scss @@ -468,6 +468,8 @@ code { } .chainDetails { + max-width: calc(100vw - 32px); + .logo { height: 60pt; margin: 30px 0; diff --git a/src/components/SchainDetails.tsx b/src/components/SchainDetails.tsx index 398ca9c..0000722 100644 --- a/src/components/SchainDetails.tsx +++ b/src/components/SchainDetails.tsx @@ -115,10 +115,13 @@ export default function SchainDetails(props: {

-
-

{chainAlias}

-

{chainDescription}

-
+ +

{chainAlias}

+

{chainDescription}

+
} + />
Date: Tue, 2 Jan 2024 19:39:10 +0000 Subject: [PATCH 4/4] Update month selector in sChain pricing --- src/App.scss | 31 +++++++++++ src/components/MonthSelector.tsx | 90 ++++++++++++++++++-------------- src/components/SchainDetails.tsx | 10 ++-- src/pages/Admin.tsx | 4 +- 4 files changed, 91 insertions(+), 44 deletions(-) diff --git a/src/App.scss b/src/App.scss index f6b2e0a..dc9ca4a 100644 --- a/src/App.scss +++ b/src/App.scss @@ -493,6 +493,37 @@ code { height: 12px; } } + + .monthInputWrap { + border-radius: 25px; + background: rgba(41, 255, 148, 0.08); + padding-left: 20px; + } + + .monthInput { + width: 35pt; + + input { + font-weight: 500; + line-height: 0.9; + } + + .MuiInputBase-input { + padding: 0 !important; + } + + .MuiInput-root::after { + display: none !important; + border-bottom: none !important; + } + + .MuiInput-root::before { + display: none !important; + border-bottom: none !important; + } + } + + } .titleSection { diff --git a/src/components/MonthSelector.tsx b/src/components/MonthSelector.tsx index d05f35c..b2990d2 100644 --- a/src/components/MonthSelector.tsx +++ b/src/components/MonthSelector.tsx @@ -24,7 +24,8 @@ import { useState } from 'react' import Button from '@mui/material/Button' import TextField from '@mui/material/TextField' - +import CancelOutlinedIcon from '@mui/icons-material/CancelOutlined' +import CheckCircleRoundedIcon from '@mui/icons-material/CheckCircleRounded' import { cmn, cls } from '@skalenetwork/metaport' import { formatTimePeriod } from '../core/timeHelper' @@ -52,7 +53,7 @@ export default function MonthSelector(props: { } return ( -
+
{monthRecommendations .filter((x) => x <= props.max) .map((month: any, i: number) => ( @@ -69,48 +70,61 @@ export default function MonthSelector(props: { ))} {openCustom ? (
- ) => { - if ( - parseFloat(event.target.value) < 0 || - !Number.isInteger(Number(event.target.value)) - ) { - setTextPeriod('') - return - } - setTextPeriod(event.target.value) - }} - className={cls(cmn.mri10)} - /> +
+ ) => { + if ( + parseFloat(event.target.value) < 0 || + !Number.isInteger(Number(event.target.value)) + ) { + setTextPeriod('') + return + } + setTextPeriod(event.target.value) + }} + className={cls(cmn.mri10, 'monthInput')} + placeholder="0" + /> + +
) : ( diff --git a/src/components/SchainDetails.tsx b/src/components/SchainDetails.tsx index 0000722..3fd7e58 100644 --- a/src/components/SchainDetails.tsx +++ b/src/components/SchainDetails.tsx @@ -117,10 +117,12 @@ export default function SchainDetails(props: { -

{chainAlias}

-

{chainDescription}

-
} + children={ +
+

{chainAlias}

+

{chainDescription}

+
+ } /> diff --git a/src/pages/Admin.tsx b/src/pages/Admin.tsx index 4cd322f..d263264 100644 --- a/src/pages/Admin.tsx +++ b/src/pages/Admin.tsx @@ -41,8 +41,8 @@ export default function Admin(props: { mpc: MetaportCore }) { const alias = getChainAlias(network, name) return ( - - + +