Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metaport 2.1 Beta release #265

Merged
merged 35 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d366968
Add coinbaseWallet and enkryptWallet
dmytrotkk Nov 29, 2023
8db1949
Return staging config
dmytrotkk Nov 29, 2023
0a72b6b
Enable debug in config
dmytrotkk Nov 29, 2023
b43a5fa
Merge branch 'develop' of github.com:skalenetwork/metaport into add-w…
dmytrotkk Jan 4, 2024
149914d
Bump versions - viem, rainbowkit
dmytrotkk Jan 4, 2024
5d20642
Update dependencies, add rainbow wallet
dmytrotkk Jan 29, 2024
f980f0a
Merge pull request #245 from skalenetwork/add-new-testnet
dmytrotkk Feb 6, 2024
1387566
Merge pull request #247 from skalenetwork/add-new-testnet
dmytrotkk Feb 6, 2024
eae5ec2
Merge pull request #249 from skalenetwork/beta
dmytrotkk Feb 26, 2024
d9c5655
Merge pull request #251 from skalenetwork/beta
dmytrotkk Feb 26, 2024
edd26f8
Merge branch 'beta' of github.com:skalenetwork/metaport into add-wall…
dmytrotkk Mar 6, 2024
ed79838
Add trust wallet, add rabby wallet
dmytrotkk Mar 6, 2024
0a17440
Add wallets branch to CI
dmytrotkk Mar 6, 2024
0ae3457
Update CODEOWNERS
kladkogex Mar 11, 2024
c5f6893
Merge pull request #254 from skalenetwork/kladkogex-patch-1
kladkogex Mar 11, 2024
d26577a
Update error handling in sendTransaction
dmytrotkk Mar 24, 2024
5bb411a
Update bun.lock file after bun i
dmytrotkk Mar 24, 2024
3ed988d
Merge changes from update-error-handling-in-tx
dmytrotkk Mar 25, 2024
e0393a4
Merge pull request #234 from skalenetwork/add-wallets-rk
dmytrotkk Mar 25, 2024
fa88961
Add new legacy holesky network
dmytrotkk Mar 26, 2024
9e9c148
Add legacy network faucets, update skale-network submodule
dmytrotkk Mar 27, 2024
e720994
Update testnet storybook config
dmytrotkk Mar 27, 2024
b90dacb
Merge pull request #256 from skalenetwork/add-new-qa-network
dmytrotkk Mar 27, 2024
d2a718e
Update mainnet hubs metadata
dmytrotkk Mar 27, 2024
9bfd36c
Merge pull request #257 from skalenetwork/update-mainnet-hubs-meta
dmytrotkk Mar 27, 2024
5ad4668
Update skale-network submodule
dmytrotkk Apr 8, 2024
e9b7e6a
Merge pull request #258 from skalenetwork/update-mainnet-hubs-meta
dmytrotkk Apr 8, 2024
63e2276
Update legacy network faucet
dmytrotkk Apr 12, 2024
709f849
Merge pull request #259 from skalenetwork/update-mainnet-hubs-meta
dmytrotkk Apr 12, 2024
bc6687f
Update skale-network metadata
dmytrotkk Apr 15, 2024
ec11999
Merge pull request #260 from skalenetwork/update-mainnet-hubs-meta
dmytrotkk Apr 15, 2024
4606be5
Update sFUEL mining logic - fix error with hubs
dmytrotkk Apr 22, 2024
75bf319
Merge pull request #261 from skalenetwork/hotfix/sfuel-logic-upd
dmytrotkk Apr 22, 2024
6d67c98
Bump ima-js dependency
dmytrotkk Apr 24, 2024
4fae88a
Merge pull request #262 from skalenetwork/hotfix-bump-ima-js
dmytrotkk Apr 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- develop
- beta
- stable
- wallets

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
* @dmytrotkk @payvint @cstrangedk
* @dmytrotkk @payvint @kladkogex
*.md @skalenetwork/docowners
Binary file modified bun.lockb
Binary file not shown.
34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@skalenetwork/metaport",
"version": "2.0.3",
"version": "2.1.1",
"description": "SKALE Metaport Widget",
"keywords": [
"skale",
Expand Down Expand Up @@ -34,13 +34,13 @@
"version": "node -e \"console.log(require('./package.json').version);\""
},
"devDependencies": {
"@storybook/addon-essentials": "7.4.0",
"@storybook/addon-interactions": "7.4.0",
"@storybook/addon-links": "7.4.0",
"@storybook/addon-essentials": "^7.6.10",
"@storybook/addon-interactions": "^7.6.10",
"@storybook/addon-links": "^7.6.10",
"@storybook/addon-styling": "1.3.7",
"@storybook/blocks": "7.4.0",
"@storybook/react": "7.4.0",
"@storybook/react-vite": "7.4.0",
"@storybook/blocks": "^7.6.10",
"@storybook/react": "^7.6.10",
"@storybook/react-vite": "^7.6.10",
"@storybook/testing-library": "0.2.0",
"@testing-library/react": "14.0.0",
"@types/node": "20.4.9",
Expand All @@ -67,26 +67,26 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"sass": "^1.65.1",
"storybook": "7.4.0",
"storybook": "^7.6.10",
"typescript": "5.1.6",
"vite": "4.4.9",
"vite-plugin-dts": "3.5.1",
"vite-plugin-sass-dts": "^1.3.9",
"vitest": "0.34.1"
},
"dependencies": {
"@mui/material": "^5.14.8",
"@mui/lab": "^5.0.0-alpha.143",
"@mui/icons-material": "^5.14.8",
"@mui/material": "^5.15.6",
"@mui/lab": "^5.0.0-alpha.162",
"@mui/icons-material": "^5.15.6",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@rainbow-me/rainbowkit": "^1.1.1",
"@skalenetwork/ima-js": "2.0.0-beta.0",
"@rainbow-me/rainbowkit": "^1.3.6",
"@skalenetwork/ima-js": "2.0.2-develop.0",
"coingecko-api-v3": "^0.0.29",
"react-jazzicon": "^1.0.4",
"viem": "^1.10.8",
"wagmi": "^1.4.1",
"zustand": "^4.4.1"
"viem": "^1.21.4",
"wagmi": "^1.4.13",
"zustand": "^4.5.0"
},
"peerDependencies": {
"react": "18.2.0",
Expand All @@ -100,4 +100,4 @@
"prettier -w"
]
}
}
}
2 changes: 1 addition & 1 deletion skale-network
Submodule skale-network updated 30 files
+34 −2 metadata/legacy/chains.json
+4 −0 metadata/legacy/icons/adorable-quaint-bellatrix-cryptocrusades.svg
+4 −0 metadata/legacy/icons/adorable-quaint-bellatrix-motodex.svg
+9 −0 metadata/legacy/icons/adorable-quaint-bellatrix-nftb.svg
+26 −0 metadata/legacy/icons/adorable-quaint-bellatrix.svg
+0 −0 metadata/legacy/icons/spanish-smug-auva-clet-domains.svg
+0 −0 metadata/legacy/icons/spanish-smug-auva-nftrade.svg
+0 −0 metadata/legacy/icons/spanish-smug-auva-untitled-platformer.svg
+0 −0 metadata/legacy/icons/spanish-smug-auva-xp-network.svg
+0 −0 metadata/legacy/icons/spanish-smug-auva.svg
+0 −0 metadata/legacy/icons/these-long-sadalsuud-ruby.svg
+0 −0 metadata/legacy/icons/these-long-sadalsuud.svg
+ metadata/legacy/logos/adorable-quaint-bellatrix.png
+ metadata/legacy/logos/spanish-smug-auva.png
+ metadata/legacy/logos/these-long-sadalsuud.png
+70 −19 metadata/mainnet/chains.json
+174 −0 metadata/mainnet/icons/green-giddy-denebola-bit-hotel.svg
+290 −0 metadata/mainnet/icons/green-giddy-denebola-dex-go.svg
+197 −0 metadata/mainnet/icons/green-giddy-denebola-fivetars.svg
+16 −0 metadata/mainnet/icons/green-giddy-denebola-heavens-compass.svg
+34 −0 metadata/mainnet/icons/green-giddy-denebola-jump-trade.svg
+17 −0 metadata/mainnet/icons/honorable-steel-rasalhague-dmail.svg
+34 −0 metadata/mainnet/icons/honorable-steel-rasalhague-dripverse.svg
+90 −0 metadata/mainnet/icons/honorable-steel-rasalhague-pixudi.svg
+17,359 −0 releases/mainnet/skale-manager/1.10.0/skale-manager-1.10.0-mainnet-abi.json
+27 −0 releases/mainnet/skale-manager/1.10.0/skale-manager-1.10.0-mainnet-contracts.json
+1,859 −0 releases/staging/ima-contracts/1.5.0/mainnet/manifest.json
+11,096 −0 releases/staging/skale-manager/1.10.0/manifest.json
+15,455 −0 releases/staging/skale-manager/1.10.0/skale-manager-1.10.0-beta.0-custom-abi.json
+5,799 −0 releases/staging/skale-manager/1.9.4/manifest.json
2 changes: 1 addition & 1 deletion src/components/Metaport/Metaport.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Meta, StoryObj } from '@storybook/react'
import Metaport from './Metaport'

import { METAPORT_CONFIG } from '../../metadata/metaportConfigStaging'
import { METAPORT_CONFIG } from '../../metadata/metaportConfigTestnet'
METAPORT_CONFIG.mainnetEndpoint = import.meta.env.VITE_MAINNET_ENDPOINT
METAPORT_CONFIG.projectId = import.meta.env.VITE_WC_PROJECT_ID

Expand Down
13 changes: 2 additions & 11 deletions src/components/MetaportProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ import { jsonRpcProvider } from 'wagmi/providers/jsonRpc'
import { connectorsForWallets } from '@rainbow-me/rainbowkit'
import { PaletteMode } from '@mui/material'

import {
injectedWallet,
// coinbaseWallet,
metaMaskWallet
// enkryptWallet
} from '@rainbow-me/rainbowkit/wallets'
import { injectedWallet, metaMaskWallet, enkryptWallet } from '@rainbow-me/rainbowkit/wallets'

import { MetaportConfig, ActionStateUpdate } from '../core/interfaces'

Expand Down Expand Up @@ -73,11 +68,7 @@ export default function MetaportProvider(props: {
]
)

const wallets = [
// enkryptWallet({ chains }),
injectedWallet({ chains })
// coinbaseWallet({ chains, appName: 'SKALE Metaport' })
]
const wallets = [enkryptWallet({ chains }), injectedWallet({ chains })]

if (props.config.projectId) {
wallets.push(metaMaskWallet({ chains, projectId: props.config.projectId }))
Expand Down
93 changes: 38 additions & 55 deletions src/components/SFuelWarning.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* @copyright SKALE Labs 2023-Present
*/

import { useEffect } from 'react'
import { useEffect, useState } from 'react'
import debug from 'debug'

import { useAccount } from 'wagmi'
Expand Down Expand Up @@ -64,11 +64,16 @@ export default function SFuelWarning(props: {}) {
const hubChainStation = useSFuelStore((state) => state.hubChainStation)
const setHubChainStation = useSFuelStore((state) => state.setHubChainStation)

const sFuelStatus = useSFuelStore((state) => state.sFuelStatus)
const setSFuelStatus = useSFuelStore((state) => state.setSFuelStatus)
const fromChainData = useSFuelStore((state) => state.fromChainData)
const setFromChainData = useSFuelStore((state) => state.setFromChainData)

const sFuelOk = useSFuelStore((state) => state.sFuelOk)
const setSFuelOk = useSFuelStore((state) => state.setSFuelOk)
const toChainData = useSFuelStore((state) => state.toChainData)
const setToChainData = useSFuelStore((state) => state.setToChainData)

const hubChainData = useSFuelStore((state) => state.hubChainData)
const setHubChainData = useSFuelStore((state) => state.setHubChainData)

const [refilledFlag, setRefilledFlag] = useState<boolean>(false)

const { address } = useAccount()

Expand All @@ -84,7 +89,6 @@ export default function SFuelWarning(props: {}) {
setFromChainStation(null)
setToChainStation(null)
setHubChainStation(null)
setSFuelOk(false)
log('Initializing SFuelWarning', chainName1, chainName2, hubChain, address)
createStations()
}, [chainName1, chainName2, hubChain, address])
Expand All @@ -106,34 +110,19 @@ export default function SFuelWarning(props: {}) {
}

async function updateStationsData() {
let fromData
let toData
let hubData
if (fromChainStation) {
fromData = await fromChainStation.getData(address)
setFromChainData(await fromChainStation.getData(address))
}
if (toChainStation) {
toData = await toChainStation.getData(address)
setToChainData(await toChainStation.getData(address))
setLoading(false)
}
if (hubChainStation) {
hubData = await hubChainStation.getData(address)
setHubChainData(await hubChainStation.getData(address))
}
if ((fromData && !fromData.ok) || (hubData && !hubData.ok)) {
setSFuelStatus('error')
setSFuelOk(false)
} else {
if (toData && !toData.ok) {
setSFuelStatus('warning')
setSFuelOk(false)
} else {
if (fromData && fromData.ok && toData && toData.ok) {
setSFuelStatus('action')
setSFuelOk(true)
}
}
}
if (fromData && toData) {
setLoading(false)
if (refilledFlag) {
setMining(false)
setRefilledFlag(false)
}
}

Expand Down Expand Up @@ -173,24 +162,12 @@ export default function SFuelWarning(props: {}) {
if (fromPowRes) log(chainName1, fromPowRes.message)
if (toPowRes) log(chainName2, toPowRes.message)
if (hubPowRes) log(hubChain, hubPowRes.message)
} else {
await updateStationsData()
setSFuelStatus('action')
setSFuelOk(true)
}
setMining(false)
setRefilledFlag(true)
}

const mainnetTransfer = chainName1 === MAINNET_CHAIN_NAME || chainName2 === MAINNET_CHAIN_NAME
const noSFuelDest = sFuelStatus === 'warning' && chainName1 === MAINNET_CHAIN_NAME
const noSFuelSource = sFuelStatus === 'error' && chainName2 === MAINNET_CHAIN_NAME
const sFuelBtn = noSFuelDest || noSFuelSource || !mainnetTransfer

function getSFuelText() {
if (sFuelBtn) {
return SFUEL_TEXT['sfuel'][sFuelStatus]
}
return SFUEL_TEXT['gas'][sFuelStatus]
return SFUEL_TEXT[noEth ? 'gas' : 'sfuel']['error']
}

if (loading && chainName2)
Expand All @@ -200,20 +177,28 @@ export default function SFuelWarning(props: {}) {
</div>
)

const sourceFaucetAvailable =
chainName1 === MAINNET_CHAIN_NAME || isFaucetAvailable(chainName1, mpc.config.skaleNetwork)
const destFaucetAvailable =
chainName2 === MAINNET_CHAIN_NAME || isFaucetAvailable(chainName2, mpc.config.skaleNetwork)
const hubFaucetAvailable = !hubChain || isFaucetAvailable(hubChain, mpc.config.skaleNetwork)
const faucetsAvailable = sourceFaucetAvailable && destFaucetAvailable && hubFaucetAvailable
const fromMainnet = chainName1 === MAINNET_CHAIN_NAME
const toMainnet = chainName2 === MAINNET_CHAIN_NAME

const fromFaucet = isFaucetAvailable(chainName1, mpc.config.skaleNetwork)
const destFaucet = isFaucetAvailable(chainName2, mpc.config.skaleNetwork)
const hubFaucet = isFaucetAvailable(hubChain, mpc.config.skaleNetwork) || !hubChain

const fromOk = fromChainData && fromChainData.ok
const toOk = toChainData && toChainData.ok
const hubOk = (hubChainData && hubChainData.ok) || !hubChainData

const isOk = fromOk && toOk && hubOk
const sFuelBtn = (fromFaucet || fromMainnet) && (destFaucet || toMainnet) && hubFaucet
const noEth = (fromMainnet && !fromOk) || (toMainnet && !toOk)

return (
<Collapse in={!loading && sFuelStatus !== 'action' && !sFuelOk}>
<Collapse in={!loading && !isOk}>
<div className={cls(cmn.mtop20, cmn.mbott5)}>
<p className={cls(cmn.flex, cmn.p3, cmn.p, cmn.pPrim, cmn.flexGrow, cmn.mleft10)}>
⛽ {getSFuelText()}
</p>
{!faucetsAvailable ? (
{!sFuelBtn || noEth ? (
<p
className={cls(
cmn.flex,
Expand All @@ -225,11 +210,9 @@ export default function SFuelWarning(props: {}) {
cmn.mtop10
)}
>
❗️ Faucet is not available for one of the selected chains, contact with chain owner to
get sFUEL
❗️ Faucet is not available for one of the selected chains
</p>
) : null}
{sFuelBtn && faucetsAvailable ? (
) : (
<div>
{mining ? (
<LoadingButton
Expand All @@ -254,7 +237,7 @@ export default function SFuelWarning(props: {}) {
</Button>
)}
</div>
) : null}
)}
</div>
</Collapse>
)
Expand Down
7 changes: 4 additions & 3 deletions src/core/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const DEFAULT_MIN_SFUEL_WEI = 21000000000000n
export const DEFAULT_ERC20_DECIMALS = '18'
export const DEFAULT_ERROR_MSG = 'Ooops... Something went wrong...'
export const TRANSFER_ERROR_MSG = 'Error during the transfer'
export const TRANSACTION_ERROR_MSG = 'Transaction sending failed'

export const DEFAULT_MP_MARGIN = '20pt'
export const DEFAULT_MP_Z_INDEX = 99000
Expand All @@ -54,23 +55,23 @@ export const HTTPS_PREFIX = 'https://'
export const MAINNET_EXPLORER_URLS: { [skaleNetwork: string]: string } = {
mainnet: 'https://etherscan.io',
staging: 'https://goerli.etherscan.io/',
legacy: 'https://goerli.etherscan.io/',
legacy: 'https://holesky.etherscan.io/',
regression: 'https://goerli.etherscan.io/',
testnet: 'https://holesky.etherscan.io/'
}

export const BASE_EXPLORER_URLS: { [skaleNetwork: string]: string } = {
mainnet: 'explorer.mainnet.skalenodes.com',
staging: 'explorer.staging-v3.skalenodes.com',
legacy: 'legacy-explorer.skalenodes.com',
legacy: 'legacy-explorer.skaleserver.com',
regression: 'regression-explorer.skalenodes.com',
testnet: 'explorer.testnet.skalenodes.com'
}

export const MAINNET_WS_ENDPOINTS: { [skaleNetwork: string]: string } = {
mainnet: 'wss://ethereum.publicnode.com',
staging: 'wss://ethereum-goerli.publicnode.com',
legacy: 'wss://ethereum-goerli.publicnode.com',
legacy: 'wss://ethereum-holesky.publicnode.com',
regression: 'wss://ethereum-goerli.publicnode.com',
testnet: 'wss://ethereum-holesky.publicnode.com'
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/interfaces/Transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* @copyright SKALE Labs 2023-Present
*/

import { type TransactionResponse } from 'ethers';
import { type TransactionResponse } from 'ethers'

export interface TxResponse {
status: boolean
Expand All @@ -32,4 +32,4 @@ export interface TxResponse {
export interface TxResponseError {
name: string
msg: string
}
}
2 changes: 1 addition & 1 deletion src/core/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const PROTOCOL: { [protocol in 'http' | 'ws']: string } = {

export const CHAIN_IDS: { [network in SkaleNetwork]: number } = {
staging: 5,
legacy: 5,
legacy: 17000,
regression: 5,
mainnet: 1,
testnet: 17000
Expand Down
22 changes: 17 additions & 5 deletions src/core/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
* @copyright SKALE Labs 2023-Present
*/

import { type TransactionResponse } from 'ethers';
import { TRANSFER_ERROR_MSG } from './constants'
import { type TransactionResponse } from 'ethers'
import { TRANSACTION_ERROR_MSG } from './constants'
import { TxResponse } from './interfaces'


export async function sendTransaction(func: any, args: any[]): Promise<TxResponse> {
try {
const response: TransactionResponse = await func(...args)
Expand All @@ -38,8 +37,10 @@ export async function sendTransaction(func: any, args: any[]): Promise<TxRespons
if (err.code && err.code === 'ACTION_REJECTED') {
name = 'Transaction signing was rejected'
} else {
name = TRANSFER_ERROR_MSG
name = TRANSACTION_ERROR_MSG
}
const revertMsg = parseErrorMessage(err.message)
if (revertMsg) name = revertMsg
if (err.info && err.info.error && err.info.error.data && err.info.error.data.message) {
name = err.info.error.data.message
}
Expand All @@ -48,4 +49,15 @@ export async function sendTransaction(func: any, args: any[]): Promise<TxRespons
}
return { status: false, err: { name, msg }, response: undefined }
}
}
}

function parseErrorMessage(input: string | undefined): string | null {
if (!input) return null
const startDelimiter = 'execution reverted: "'
const endDelimiter = '"'
const startIndex = input.indexOf(startDelimiter)
if (startIndex === -1) return null
const endIndex = input.indexOf(endDelimiter, startIndex + startDelimiter.length)
if (endIndex === -1) return null
return input.substring(startIndex + startDelimiter.length, endIndex)
}
Loading
Loading