fix: check for the whole chain identifier ( namespace + ":" + reference ) (#300)
This commit is contained in:
parent
7882b3e101
commit
653b362e5c
@ -125,6 +125,7 @@ export enum DEFAULT_MULTIVERSX_METHODS {
|
|||||||
MULTIVERSX_SIGN_MESSAGE = "mvx_signMessage",
|
MULTIVERSX_SIGN_MESSAGE = "mvx_signMessage",
|
||||||
MULTIVERSX_SIGN_LOGIN_TOKEN = "mvx_signLoginToken",
|
MULTIVERSX_SIGN_LOGIN_TOKEN = "mvx_signLoginToken",
|
||||||
MULTIVERSX_SIGN_NATIVE_AUTH_TOKEN = "mvx_signNativeAuthToken",
|
MULTIVERSX_SIGN_NATIVE_AUTH_TOKEN = "mvx_signNativeAuthToken",
|
||||||
|
MULTIVERSX_CANCEL_ACTION = "mvx_cancelAction"
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum DEFAULT_MULTIVERSX_EVENTS {}
|
export enum DEFAULT_MULTIVERSX_EVENTS {}
|
||||||
|
@ -12,13 +12,13 @@ import { Card, Row, styled, Image, Avatar } from '@nextui-org/react'
|
|||||||
import { ReactNode, useMemo } from 'react'
|
import { ReactNode, useMemo } from 'react'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
chainId?: string | number
|
chainId?: string // namespace + ":" + reference
|
||||||
}
|
}
|
||||||
|
|
||||||
// const StyledLogo = styled(Image, {})
|
// const StyledLogo = styled(Image, {})
|
||||||
|
|
||||||
export default function ChainDataMini({ chainId }: Props) {
|
export default function ChainDataMini({ chainId }: Props) {
|
||||||
const chainData = useMemo(() => getChainData(chainId!), [chainId])
|
const chainData = useMemo(() => getChainData(chainId), [chainId])
|
||||||
console.log(chainData)
|
console.log(chainData)
|
||||||
|
|
||||||
if (!chainData) return <></>
|
if (!chainData) return <></>
|
||||||
|
@ -13,7 +13,7 @@ export const MULTIVERSX_MAINNET_CHAINS = {
|
|||||||
logo: '/chain-logos/multiversx-1.svg',
|
logo: '/chain-logos/multiversx-1.svg',
|
||||||
rgb: '43, 45, 46',
|
rgb: '43, 45, 46',
|
||||||
rpc: '',
|
rpc: '',
|
||||||
namespace: 'mutiversx'
|
namespace: 'mvx'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ export const MULTIVERSX_TEST_CHAINS = {
|
|||||||
logo: '/chain-logos/multiversx-1.svg',
|
logo: '/chain-logos/multiversx-1.svg',
|
||||||
rgb: '43, 45, 46',
|
rgb: '43, 45, 46',
|
||||||
rpc: '',
|
rpc: '',
|
||||||
namespace: 'mutiversx'
|
namespace: 'mvx'
|
||||||
}
|
}
|
||||||
// Keep only one Test Chain visible
|
// Keep only one Test Chain visible
|
||||||
// 'mvx:T': {
|
// 'mvx:T': {
|
||||||
@ -32,7 +32,8 @@ export const MULTIVERSX_TEST_CHAINS = {
|
|||||||
// name: 'MultiversX Testnet',
|
// name: 'MultiversX Testnet',
|
||||||
// logo: '/chain-logos/multiversx-1.svg',
|
// logo: '/chain-logos/multiversx-1.svg',
|
||||||
// rgb: '43, 45, 46',
|
// rgb: '43, 45, 46',
|
||||||
// rpc: ''
|
// rpc: '',
|
||||||
|
// namespace: 'mvx'
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,5 +47,6 @@ export const MULTIVERSX_SIGNING_METHODS = {
|
|||||||
MULTIVERSX_SIGN_TRANSACTIONS: 'mvx_signTransactions',
|
MULTIVERSX_SIGN_TRANSACTIONS: 'mvx_signTransactions',
|
||||||
MULTIVERSX_SIGN_MESSAGE: 'mvx_signMessage',
|
MULTIVERSX_SIGN_MESSAGE: 'mvx_signMessage',
|
||||||
MULTIVERSX_SIGN_LOGIN_TOKEN: 'mvx_signLoginToken',
|
MULTIVERSX_SIGN_LOGIN_TOKEN: 'mvx_signLoginToken',
|
||||||
MULTIVERSX_SIGN_NATIVE_AUTH_TOKEN: 'mvx_signNativeAuthToken'
|
MULTIVERSX_SIGN_NATIVE_AUTH_TOKEN: 'mvx_signNativeAuthToken',
|
||||||
|
MULTIVERSX_CANCEL_ACTION: 'mvx_cancelAction'
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,10 @@ export const ALL_CHAINS = {
|
|||||||
...TRON_CHAINS
|
...TRON_CHAINS
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getChainData(chainId: string | number) {
|
export function getChainData(chainId?: string) {
|
||||||
if (!chainId) return
|
if (!chainId) return
|
||||||
chainId = chainId.toString().includes(':') ? chainId.toString().split(':')[1] : chainId
|
const [namespace, reference] = chainId.toString().split(':')
|
||||||
return Object.values(ALL_CHAINS).find(chain => chain.chainId == chainId)
|
return Object.values(ALL_CHAINS).find(
|
||||||
|
chain => chain.chainId == reference && chain.namespace === namespace
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ export default function SessionProposalModal() {
|
|||||||
events: [],
|
events: [],
|
||||||
accounts: kadenaChains.map(chain => `${chain}:${kadenaAddresses[0]}`).flat()
|
accounts: kadenaChains.map(chain => `${chain}:${kadenaAddresses[0]}`).flat()
|
||||||
},
|
},
|
||||||
multiversx: {
|
mvx: {
|
||||||
chains: multiversxChains,
|
chains: multiversxChains,
|
||||||
methods: multiversxMethods,
|
methods: multiversxMethods,
|
||||||
events: [],
|
events: [],
|
||||||
@ -198,7 +198,7 @@ export default function SessionProposalModal() {
|
|||||||
return cosmosAddresses[0]
|
return cosmosAddresses[0]
|
||||||
case 'kadena':
|
case 'kadena':
|
||||||
return kadenaAddresses[0]
|
return kadenaAddresses[0]
|
||||||
case 'multiversx':
|
case 'mvx':
|
||||||
return multiversxAddresses[0]
|
return multiversxAddresses[0]
|
||||||
case 'near':
|
case 'near':
|
||||||
return nearAddresses[0]
|
return nearAddresses[0]
|
||||||
@ -324,9 +324,13 @@ export default function SessionProposalModal() {
|
|||||||
</Row>
|
</Row>
|
||||||
{supportedChains.length &&
|
{supportedChains.length &&
|
||||||
supportedChains.map((chain, i) => {
|
supportedChains.map((chain, i) => {
|
||||||
|
if (!chain) {
|
||||||
|
return <></>
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Row key={i}>
|
<Row key={i}>
|
||||||
<ChainDataMini key={i} chainId={chain?.chainId!} />
|
<ChainDataMini key={i} chainId={`${chain?.namespace}:${chain?.chainId}`} />
|
||||||
</Row>
|
</Row>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
|
@ -67,7 +67,7 @@ export default function SessionSignMultiversxModal() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<RequestModal
|
<RequestModal
|
||||||
intention="sign a Mtvx message"
|
intention="sign a MultiversX message"
|
||||||
metadata={requestSession.peer.metadata}
|
metadata={requestSession.peer.metadata}
|
||||||
onApprove={onApprove}
|
onApprove={onApprove}
|
||||||
onReject={onReject}
|
onReject={onReject}
|
||||||
|
Loading…
Reference in New Issue
Block a user