* feat: v2 wallet * feat: Web3Wallet sign integration * chore: adds `core` to package.json * feat: Web3Wallet Auth integration * chore: core & web3wallet canary * chore: rm config * chore: force redeploy * chore: rm core & sign-client deps * fix: rm `sign-client` usage * refactor: updates README * feat: adds metadata mock obj & removes relay url param * refactor: more url mentions * refactor: rm v2 wallet readme references & uses web3wallet.core... * refactor: wallet -> web3wallet * refactor: rm wallet to web3wallet * fix: adds async to example listeners
92 lines
2.7 KiB
TypeScript
92 lines
2.7 KiB
TypeScript
import ChainCard from '@/components/ChainCard'
|
|
import { COSMOS_MAINNET_CHAINS } from '@/data/COSMOSData'
|
|
import { EIP155_MAINNET_CHAINS, EIP155_TEST_CHAINS } from '@/data/EIP155Data'
|
|
import { NEAR_TEST_CHAINS } from '@/data/NEARData'
|
|
import { SOLANA_MAINNET_CHAINS, SOLANA_TEST_CHAINS } from '@/data/SolanaData'
|
|
import { ELROND_MAINNET_CHAINS, ELROND_TEST_CHAINS } from '@/data/ElrondData'
|
|
import { formatChainName } from '@/utils/HelperUtil'
|
|
import { Col, Row, Text } from '@nextui-org/react'
|
|
import { SessionTypes } from '@walletconnect/types'
|
|
import { Fragment } from 'react'
|
|
|
|
/**
|
|
* Utilities
|
|
*/
|
|
const CHAIN_METADATA = {
|
|
...COSMOS_MAINNET_CHAINS,
|
|
...SOLANA_MAINNET_CHAINS,
|
|
...ELROND_MAINNET_CHAINS,
|
|
...EIP155_MAINNET_CHAINS,
|
|
...EIP155_TEST_CHAINS,
|
|
...SOLANA_TEST_CHAINS,
|
|
...NEAR_TEST_CHAINS,
|
|
...ELROND_TEST_CHAINS
|
|
}
|
|
|
|
/**
|
|
* Types
|
|
*/
|
|
interface IProps {
|
|
namespace: SessionTypes.Namespace
|
|
}
|
|
|
|
/**
|
|
* Component
|
|
*/
|
|
export default function SessionChainCard({ namespace }: IProps) {
|
|
const chains: string[] = []
|
|
|
|
// WIP
|
|
|
|
namespace.accounts.forEach(account => {
|
|
const [type, chain] = account.split(':')
|
|
const chainId = `${type}:${chain}`
|
|
chains.push(chainId)
|
|
})
|
|
|
|
return (
|
|
<Fragment>
|
|
{chains.map(chainId => {
|
|
const extensionMethods: SessionTypes.Namespace['methods'] = []
|
|
const extensionEvents: SessionTypes.Namespace['events'] = []
|
|
|
|
namespace.extension?.map(({ accounts, methods, events }) => {
|
|
accounts.forEach(account => {
|
|
const [type, chain] = account.split(':')
|
|
const chainId = `${type}:${chain}`
|
|
if (chains.includes(chainId)) {
|
|
extensionMethods.push(...methods)
|
|
extensionEvents.push(...events)
|
|
}
|
|
})
|
|
})
|
|
|
|
const allMethods = [...namespace.methods, ...extensionMethods]
|
|
const allEvents = [...namespace.events, ...extensionEvents]
|
|
// @ts-expect-error
|
|
const rgb = CHAIN_METADATA[chainId]?.rgb
|
|
|
|
return (
|
|
<ChainCard key={chainId} rgb={rgb ?? ''} flexDirection="col" alignItems="flex-start">
|
|
<Text h5 css={{ marginBottom: '$5' }}>
|
|
{formatChainName(chainId)}
|
|
</Text>
|
|
<Row>
|
|
<Col>
|
|
<Text h6>Methods</Text>
|
|
<Text color="$gray300">{allMethods.length ? allMethods.join(', ') : '-'}</Text>
|
|
</Col>
|
|
</Row>
|
|
<Row css={{ marginTop: '$5' }}>
|
|
<Col>
|
|
<Text h6>Events</Text>
|
|
<Text color="$gray300">{allEvents.length ? allEvents.join(', ') : '-'}</Text>
|
|
</Col>
|
|
</Row>
|
|
</ChainCard>
|
|
)
|
|
})}
|
|
</Fragment>
|
|
)
|
|
}
|