Skip to content

Commit

Permalink
Merge pull request #64 from TalismanSociety/feat/address-class-ethere…
Browse files Browse the repository at this point in the history
…um-mythos

feat: Support EVM addresses & add Mythos
  • Loading branch information
UrbanWill authored Aug 21, 2024
2 parents 8cd6e8f + b917cff commit 7e02a0a
Show file tree
Hide file tree
Showing 20 changed files with 245 additions and 82 deletions.
6 changes: 5 additions & 1 deletion apps/multisig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ export type Rpc = {
url: string
}

type Account = '*25519' | 'secp256k1'

export type SupportedChain = {
id: string
polkaAssemblyUrl?: string
Expand Down Expand Up @@ -49,6 +51,7 @@ export const SUPPORTED_CHAINS: Record<string, SupportedChain> = {
'phala': { id: 'phala' },
'rococo-testnet': { id: 'rococo-testnet' },
'shibuya-testnet': { id: 'shibuya-testnet' },
'mythos': { id: 'mythos', subscanUrl: 'https://mythos.subscan.io/' },
}

export type Chain = {
Expand All @@ -64,6 +67,7 @@ export type Chain = {
ss58Prefix: number
subscanUrl: string
polkaAssemblyUrl?: string
account: Account
}

export const CUSTOM_CHAINS: Omit<Chain, 'id'>[] = [
Expand All @@ -82,4 +86,4 @@ export const CUSTOM_CHAINS: Omit<Chain, 'id'>[] = [
// },
]

export const CHAINDATA_URL = 'https://raw.githubusercontent.com/TalismanSociety/chaindata/main/dist/chains/all.json'
export const CHAINDATA_URL = 'https://raw.githubusercontent.com/TalismanSociety/chaindata/main/pub/v1/chains/all.json'
2 changes: 1 addition & 1 deletion apps/multisig/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"@talismn/connect-wallets": "^1.1.3",
"@talismn/dot-pool-selector": "snapshot",
"@talismn/icons": "workspace:^",
"@talismn/siws": "0.0.8",
"@talismn/siws": "0.0.18",
"@talismn/ui": "workspace:^",
"@talismn/util": "^0.2.0",
"@tanstack/react-query": "^5.37.1",
Expand Down
3 changes: 2 additions & 1 deletion apps/multisig/scripts/chaingen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ const generateSupportedChains = async () => {
ss58Prefix: chain.prefix,
subscanUrl: chainDetails.subscanUrl ?? chain.subscanUrl,
polkaAssemblyUrl: chainDetails.polkaAssemblyUrl ?? chain.polkaAssemblyUrl,
account: chain.account,
})
}
}
CUSTOM_CHAINS.forEach(chain => {
supportedChains.push({ ...chain, id: `custom-${chain.genesisHash}` })
supportedChains.push({ ...chain, id: `custom-${chain.genesisHash}`, account: chain.account })
})

fs.writeFileSync(
Expand Down
6 changes: 4 additions & 2 deletions apps/multisig/src/components/AddressTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useEffect, useMemo, useState } from 'react'
import { cn } from '../util/tailwindcss'
import { useAzeroID } from '@domains/azeroid/AzeroIDResolver'
import { AzeroIDLogo } from './OtherLogos/AzeroID'
import { useSelectedMultisig } from '@domains/multisig'
import { useSelectedMultisig, DUMMY_MULTISIG_ID } from '@domains/multisig'
import { useApi } from '@domains/chains/pjs-api'
import { formatUnits } from '@util/numbers'
import { Skeleton } from '@talismn/ui'
Expand All @@ -27,6 +27,8 @@ export const AddressTooltip: React.FC<
const [a0Id, setA0Id] = useState<string>()
const onchainIdentity = useOnchainIdentity(address, chain)

const isLoggedIn = selectedMultisig.id !== DUMMY_MULTISIG_ID

const handleCopy = (e: React.MouseEvent) => {
e.stopPropagation()
copy(ss58Address, 'Address Copied!', <p className="text-[12px]">{address.toShortSs58(chain)}</p>)
Expand Down Expand Up @@ -107,7 +109,7 @@ export const AddressTooltip: React.FC<
{copied ? <Check size={16} /> : <Copy size={16} />}
</div>
</div>
{!!token && !!token.tokenSymbol && !!token.tokenDecimals && (
{isLoggedIn && !!token && !!token.tokenSymbol && !!token.tokenDecimals && (
<p className="mt-[8px] text-[12px] text-left">
Available Balance:{' '}
{balanceBN !== undefined ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@ import { Tooltip } from '@components/ui/tooltip'
import { Transaction } from '@domains/multisig'
import { useKnownAddresses } from '@hooks/useKnownAddresses'
import { Address } from '@util/addresses'
import { useSelectedMultisig } from '@domains/multisig'

export const TransactionSidesheetApprovals: React.FC<{ t: Transaction }> = ({ t }) => {
const { contactByAddress } = useKnownAddresses(t.multisig.orgId)
const [{ isEthereumAccount }] = useSelectedMultisig()
return (
<div css={{ display: 'grid', gap: '14px' }}>
{Object.entries(t.approvals).map(([encodedAddress, approval]) => {
const decodedAddress = Address.fromPubKey(encodedAddress)
{Object.entries(t.approvals).map(([address, approval]) => {
const decodedAddress = isEthereumAccount ? Address.fromSs58(address) : Address.fromPubKey(address)
if (!decodedAddress) {
console.error(`Could not decode address in t.approvals!`)
return null
}
const contact = contactByAddress[decodedAddress.toSs58()]
return (
<div key={encodedAddress} css={{ display: 'flex', width: '100%', justifyContent: 'space-between' }}>
<div key={address} css={{ display: 'flex', width: '100%', justifyContent: 'space-between' }}>
<div css={{ width: '100%' }}>
<MemberRow
member={{ address: decodedAddress, nickname: contact?.name, you: contact?.extensionName !== undefined }}
Expand Down
13 changes: 13 additions & 0 deletions apps/multisig/src/domains/chains/all-tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6757,6 +6757,19 @@ export const ALL_TOKENS = [
id: 'rococo-neuro-web-testnet',
},
},
{
id: 'mythos-substrate-native',
type: 'substrate-native',
isTestnet: false,
isDefault: true,
symbol: 'MYTH',
decimals: 18,
logo: 'https://raw.githubusercontent.com/TalismanSociety/chaindata/main/assets/chains/mythos.svg',
existentialDeposit: '10000000000000000',
chain: {
id: 'mythos',
},
},
]

export const ALL_TOKENS_BY_ID = ALL_TOKENS.reduce((a, b) => {
Expand Down
Loading

0 comments on commit 7e02a0a

Please sign in to comment.