Skip to content

Commit

Permalink
Merge pull request #234 from skalenetwork/add-wallets-rk
Browse files Browse the repository at this point in the history
Add coinbaseWallet and enkryptWallet
  • Loading branch information
dmytrotkk authored Mar 25, 2024
2 parents c5f6893 + 3ed988d commit e0393a4
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 79 deletions.
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
Binary file modified bun.lockb
Binary file not shown.
32 changes: 16 additions & 16 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.0",
"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",
"@rainbow-me/rainbowkit": "^1.3.6",
"@skalenetwork/ima-js": "2.0.0-beta.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"
]
}
}
}
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
1 change: 1 addition & 0 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 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
}
}
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)
}
65 changes: 20 additions & 45 deletions src/metadata/metaportConfigStaging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ export const METAPORT_CONFIG: interfaces.MetaportConfig = {
'staging-legal-crazy-castor', // Europa
'staging-utter-unripe-menkar', // Calypso
'staging-faint-slimy-achird', // Nebula
'staging-fast-active-bellatrix', // Chaos Testnet
'staging-perfect-parallel-gacrux', // Test Chain 1
'staging-severe-violet-wezen' // Test Chain 2
'staging-fast-active-bellatrix' // Chaos Testnet
],
tokens: {
eth: {
Expand Down Expand Up @@ -85,9 +83,6 @@ export const METAPORT_CONFIG: interfaces.MetaportConfig = {
'staging-utter-unripe-menkar': {
hub: 'staging-legal-crazy-castor'
}
// 'staging-faint-slimy-achird': {
// hub: 'staging-legal-crazy-castor'
// }
}
}
},
Expand Down Expand Up @@ -134,6 +129,9 @@ export const METAPORT_CONFIG: interfaces.MetaportConfig = {
'staging-legal-crazy-castor': {},
'staging-utter-unripe-menkar': {
hub: 'staging-legal-crazy-castor'
},
'staging-faint-slimy-achird': {
hub: 'staging-legal-crazy-castor'
}
}
},
Expand Down Expand Up @@ -235,21 +233,7 @@ export const METAPORT_CONFIG: interfaces.MetaportConfig = {
}
},
'staging-faint-slimy-achird': {
// Nebula connections
// eth: {
// eth: {
// address: '0x',
// chains: {
// 'staging-legal-crazy-castor': {
// clone: true
// },
// mainnet: {
// hub: 'staging-legal-crazy-castor',
// clone: true
// },
// }
// }
// },
// nebula connections
erc20: {
skl: {
address: '0x7F73B66d4e6e67bCdeaF277b9962addcDabBFC4d',
Expand All @@ -266,6 +250,18 @@ export const METAPORT_CONFIG: interfaces.MetaportConfig = {
clone: true
}
}
},
usdc: {
address: '0x717d43399ab3a8aada669CDC9560a6BAfdeA9796',
chains: {
'staging-legal-crazy-castor': {
clone: true
},
mainnet: {
hub: 'staging-legal-crazy-castor',
clone: true
}
}
}
}
},
Expand All @@ -281,9 +277,6 @@ export const METAPORT_CONFIG: interfaces.MetaportConfig = {
'staging-utter-unripe-menkar': {
wrapper: '0xa270484784f043e159f74C03B691F80B6F6e3c24'
}
// 'staging-faint-slimy-achird': {
// wrapper: '0xa270484784f043e159f74C03B691F80B6F6e3c24'
// }
}
}
},
Expand Down Expand Up @@ -342,6 +335,9 @@ export const METAPORT_CONFIG: interfaces.MetaportConfig = {
},
'staging-utter-unripe-menkar': {
wrapper: '0x4f250cCE5b8B39caA96D1144b9A32E1c6a9f97b0'
},
'staging-faint-slimy-achird': {
wrapper: '0x4f250cCE5b8B39caA96D1144b9A32E1c6a9f97b0'
}
}
},
Expand All @@ -365,27 +361,6 @@ export const METAPORT_CONFIG: interfaces.MetaportConfig = {
}
}
}
},
'staging-severe-violet-wezen': {
erc20: {}
},
'staging-perfect-parallel-gacrux': {
erc20: {},
erc721: {},
erc1155: {
// "skaliens": {
// "address": "0xBA9fF38A2b22edDfa8e05805bD22C8f20c40546e",
// "chains": {}
// },
// "medals": {
// "address": "0x5D8bD602dC5468B3998e8514A1851bd5888E9639",
// "chains": {}
// },
// "_ANIMALS_0xDf87EEF0977148129969b01b329379b17756cdDE": {
// "address": "0xDf87EEF0977148129969b01b329379b17756cdDE",
// "chains": {}
// }
}
}
},
theme: {
Expand Down

0 comments on commit e0393a4

Please sign in to comment.