diff --git a/skale-network b/skale-network index 7faac7e..a090110 160000 --- a/skale-network +++ b/skale-network @@ -1 +1 @@ -Subproject commit 7faac7e66faace1ac87a7f29d73854fe5168c7c0 +Subproject commit a090110d2b480c4d38647ba38601f9907cddb63b diff --git a/src/components/ChainAppBtn.tsx b/src/components/ChainAppBtn.tsx new file mode 100644 index 0000000..fdb50b4 --- /dev/null +++ b/src/components/ChainAppBtn.tsx @@ -0,0 +1,98 @@ +/** + * @license + * SKALE Metaport + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/** + * @file ChainAppBtn.ts + * @copyright SKALE Labs 2024-Present + */ + +import { Button } from '@mui/material' +import KeyboardArrowRightRoundedIcon from '@mui/icons-material/KeyboardArrowRightRounded' + +import { cls, cmn, styles } from '../core/css' +import { SkaleNetwork } from '../core/interfaces' +import { getChainAlias } from '../core/metadata' + +import ChainIcon from './ChainIcon' + +export default function ChainAppBtn(props: { + skaleNetwork: SkaleNetwork + appName: string + chainName: string + handle?: (schainName: string, app?: string) => void + size?: 'sm' | 'md' + prim?: boolean +}) { + const size = props.size ?? 'sm' + const iconSize = props.size === 'sm' ? 'xs' : 'sm' + const prim = props.prim ?? size === 'md' + + return ( + + ) +} diff --git a/src/components/ChainApps.tsx b/src/components/ChainApps.tsx index 56e0b16..b6cff51 100644 --- a/src/components/ChainApps.tsx +++ b/src/components/ChainApps.tsx @@ -1,11 +1,38 @@ +/** + * @license + * SKALE Metaport + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/** + * @file ChainApps.ts + * @copyright SKALE Labs 2024-Present + */ + +import { ReactElement, useState } from 'react' import { Button } from '@mui/material' -import KeyboardArrowRightRoundedIcon from '@mui/icons-material/KeyboardArrowRightRounded' +import AddCircleRoundedIcon from '@mui/icons-material/AddCircleRounded' +import RemoveCircleRoundedIcon from '@mui/icons-material/RemoveCircleRounded' import { cls, cmn, styles } from '../core/css' import { SkaleNetwork } from '../core/interfaces' -import { getChainAppsMeta, getChainAlias } from '../core/metadata' +import { getChainAppsMeta } from '../core/metadata' -import ChainIcon from './ChainIcon' +import ChainAppBtn from './ChainAppBtn' + +import { sortObjectByKeys } from '../core/helper' export default function ChainApps(props: { skaleNetwork: SkaleNetwork @@ -14,70 +41,80 @@ export default function ChainApps(props: { size?: 'sm' | 'md' prim?: boolean }) { + const [show, setShow] = useState(false) + const apps = getChainAppsMeta(props.chainName, props.skaleNetwork) if (!apps || !Object.keys(apps) || Object.keys(apps).length === 0) return
const size = props.size ?? 'sm' - const iconSize = props.size === 'sm' ? 'xs' : 'sm' - const prim = props.prim ?? size === 'md' + const appButtons: ReactElement[] = [] + + for (const appName in sortObjectByKeys(apps)) { + appButtons.push( + + ) + } return (
- {Object.keys(apps).map((key, _) => ( - - ))} + Show {show ? 'less' : 'more'} apps +

+
+ } + +
) diff --git a/src/core/actions/erc20.ts b/src/core/actions/erc20.ts index 9cb3dc5..174de0c 100644 --- a/src/core/actions/erc20.ts +++ b/src/core/actions/erc20.ts @@ -287,7 +287,7 @@ export class TransferERC20M2S extends Action { log('TransferERC20M2S:execute - tx completed %O', tx) await this.sChain2.waitERC20BalanceChange(this.destToken, this.address, balanceOnDestination) this.updateState('received') - log('TransferERC20M2S:execute - tokens received to destination chain') + log('TransferERC20M2S:execute - tokens received on destination chain') } async preAction() { @@ -339,9 +339,9 @@ export class TransferERC20S2M extends Action { const block = await sChain.provider.getBlock(tx.blockNumber) this.updateState('transferDone', tx.hash, block.timestamp) log('TransferERC20S2M:execute - tx completed %O', tx) - this.mainnet.waitERC20BalanceChange(this.destToken, this.address, balanceOnDestination) + await this.mainnet.waitERC20BalanceChange(this.destToken, this.address, balanceOnDestination) this.updateState('received') - log('TransferERC20S2M:execute - tokens received to destination chain') + log('TransferERC20S2M:execute - tokens received on destination chain') } async preAction() { diff --git a/src/core/helper.ts b/src/core/helper.ts index 6ace6f4..b249410 100644 --- a/src/core/helper.ts +++ b/src/core/helper.ts @@ -56,3 +56,14 @@ export function getRandom(list: Array) { export async function sleep(ms: number): Promise { return await new Promise((resolve) => setTimeout(resolve, ms)) } + +export function sortObjectByKeys(obj: { [key: string]: any }): { [key: string]: any } { + const sortedKeys = Object.keys(obj).sort() + const sortedObject: { [key: string]: any } = {} + + for (const key of sortedKeys) { + sortedObject[key] = obj[key] + } + + return sortedObject +} diff --git a/src/styles/styles.module.scss b/src/styles/styles.module.scss index ed2d24e..14a14ca 100644 --- a/src/styles/styles.module.scss +++ b/src/styles/styles.module.scss @@ -366,6 +366,10 @@ button { .inputAmount { + img { + border-radius: 50%; + } + :global .MuiInput-root::after { border-bottom: none !important; } @@ -396,7 +400,7 @@ button { } } -.smallTable{ +.smallTable { code { font-size: 0.7rem; display: block;