11import { PublicKey } from '@solana/web3.js'
2+ import copy from 'copy-to-clipboard'
3+ import React from 'react'
24import { usePythContext } from '../../contexts/PythContext'
5+ import CopyIcon from '../../images/icons/copy.inline.svg'
36import ClusterSwitch from '../ClusterSwitch'
47import Loadbar from '../loaders/Loadbar'
58
6- function UpdatePermissions ( ) {
9+ interface UpdatePermissionsProps {
10+ account : string
11+ pubkey ?: PublicKey
12+ }
13+
14+ const UpdatePermissionsRow : React . FunctionComponent < UpdatePermissionsProps > = ( {
15+ account,
16+ pubkey = new PublicKey ( 0 ) ,
17+ } ) => {
18+ return (
19+ < tr key = { account } className = "border-t border-beige-300" >
20+ < td className = "py-3 pl-4 pr-2 lg:pl-14" > { account } </ td >
21+ < td className = "py-3 pl-1 lg:pl-14" >
22+ < div
23+ className = "-ml-1 inline-flex cursor-pointer items-center px-1 hover:bg-dark hover:text-white active:bg-darkGray3"
24+ onClick = { ( ) => {
25+ copy ( pubkey . toBase58 ( ) )
26+ } }
27+ >
28+ < span className = "mr-2 hidden lg:block" > { pubkey . toBase58 ( ) } </ span >
29+ < span className = "mr-2 lg:hidden" >
30+ { pubkey . toBase58 ( ) . slice ( 0 , 6 ) +
31+ '...' +
32+ pubkey . toBase58 ( ) . slice ( - 6 ) }
33+ </ span > { ' ' }
34+ < CopyIcon className = "shrink-0" />
35+ </ div >
36+ </ td >
37+ </ tr >
38+ )
39+ }
40+
41+ const UpdatePermissions = ( ) => {
742 const { rawConfig, dataIsLoading } = usePythContext ( )
843
944 return (
@@ -23,25 +58,33 @@ function UpdatePermissions() {
2358 < Loadbar theme = "light" />
2459 </ div >
2560 ) : (
26- < div className = "mt-3" >
27- < p className = "h5 mb-8" >
28- Master Authority:{ ' ' }
29- { rawConfig . permissionAccount
30- ? rawConfig . permissionAccount . masterAuthority . toBase58 ( )
31- : new PublicKey ( 0 ) . toBase58 ( ) }
32- </ p >
33- < p className = "h5 mb-8" >
34- Data Curation Authority:{ ' ' }
35- { rawConfig . permissionAccount
36- ? rawConfig . permissionAccount . dataCurationAuthority . toBase58 ( )
37- : new PublicKey ( 0 ) . toBase58 ( ) }
38- </ p >
39- < p className = "h5 mb-8" >
40- Security Authority:{ ' ' }
41- { rawConfig . permissionAccount
42- ? rawConfig . permissionAccount . securityAuthority . toBase58 ( )
43- : new PublicKey ( 0 ) . toBase58 ( ) }
44- </ p >
61+ < div className = "table-responsive mb-10" >
62+ < table className = "w-full bg-darkGray text-left" >
63+ < thead >
64+ < tr >
65+ < th className = "base16 pt-8 pb-6 pl-4 pr-2 font-semibold opacity-60 lg:pl-14" >
66+ Account
67+ </ th >
68+ < th className = "base16 pt-8 pb-6 pl-1 pr-2 font-semibold opacity-60 lg:pl-14" >
69+ Public Key
70+ </ th >
71+ </ tr >
72+ </ thead >
73+ < tbody >
74+ < UpdatePermissionsRow
75+ account = "Master Authority"
76+ pubkey = { rawConfig . permissionAccount ?. masterAuthority }
77+ />
78+ < UpdatePermissionsRow
79+ account = "Data Curation Authority"
80+ pubkey = { rawConfig . permissionAccount ?. dataCurationAuthority }
81+ />
82+ < UpdatePermissionsRow
83+ account = "Security Authority"
84+ pubkey = { rawConfig . permissionAccount ?. securityAuthority }
85+ />
86+ </ tbody >
87+ </ table >
4588 </ div >
4689 ) }
4790 </ div >
0 commit comments