Skip to content

Commit ec0dc70

Browse files
authored
add copy button for mint address (#133)
1 parent a46409c commit ec0dc70

File tree

1 file changed

+22
-1
lines changed
  • components/treasuryV2/Details/TokenDetails

1 file changed

+22
-1
lines changed

components/treasuryV2/Details/TokenDetails/Header.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useEffect, useState } from 'react'
22
import cx from 'classnames'
3-
import { PlusCircleIcon, ReplyIcon } from '@heroicons/react/outline'
3+
import { DocumentDuplicateIcon, PlusCircleIcon, ReplyIcon } from '@heroicons/react/outline'
44
import {
55
ASSOCIATED_TOKEN_PROGRAM_ID,
66
Token as SplToken,
@@ -20,6 +20,8 @@ import Address from '@components/Address'
2020

2121
import AddAssetModal from '../WalletDetails/AddAssetModal'
2222
import useLegacyConnectionContext from '@hooks/useLegacyConnectionContext'
23+
import Tooltip from '@components/Tooltip'
24+
import { notify } from '@utils/notifications'
2325

2426
interface Props {
2527
className?: string
@@ -55,6 +57,20 @@ export default function Header(props: Props) {
5557
}
5658
}, [props.asset, props.wallet])
5759

60+
async function copyMintAddress() {
61+
const mint = props.asset.raw.extensions.mint?.publicKey
62+
const base58 = mint?.toBase58() || ''
63+
64+
try {
65+
await navigator?.clipboard?.writeText(base58)
66+
} catch {
67+
notify({
68+
type: 'error',
69+
message: 'Could not copy address to clipboard',
70+
})
71+
}
72+
}
73+
5874
return (
5975
<div
6076
className={cx(
@@ -122,6 +138,11 @@ export default function Header(props: Props) {
122138
? 'SOL'
123139
: props.asset.symbol}
124140
</span>
141+
<span className="text-sm ml-2 inline-block relative top-1" onClick={copyMintAddress}>
142+
<Tooltip content="Copy Mint Address">
143+
<DocumentDuplicateIcon className="cursor-pointer h-[1.25em] w-[1.25em]" />
144+
</Tooltip>
145+
</span>
125146
</div>
126147
</div>
127148
</div>

0 commit comments

Comments
 (0)