Skip to content

Commit f595d61

Browse files
m30mcctdaniel
andauthored
Xc admin frontend refactor (#964)
* Remove fetching proposal internals on page load Without the internals we can not show the verified/voted icons in the proposals page, therefore we have to remove them * Refactor squads creation based on wallet Previously there was a logic to use a separate wallet for proposeSquads but now it is removed and we can unify vote/propose squads * Disable propose button if no action and show hint * Expose refresh functionality on multisig proposals * Fetch instructions within proposal and calculate voted/verified properties inside * Extract WormholeInstructionView as a separate component Moved some name mappings to pythContext so we don't need prop drilling * Add support for parsing governance instructions + minor refactors * Add ability to show / approve upgrade proposals * fix buttons overflow * Use the actual targetChainId instead of relying on the cluster context for instruction visualization * Do not fetch the data again if the multisigCluster remains the same --------- Co-authored-by: Daniel Chew <[email protected]>
1 parent 0e5d7d0 commit f595d61

File tree

10 files changed

+939
-869
lines changed

10 files changed

+939
-869
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
export const SignerTag = () => {
2+
return (
3+
<div className="flex max-h-[22px] max-w-[74px] items-center justify-center rounded-full bg-[#605D72] py-1 px-2 text-xs">
4+
Signer
5+
</div>
6+
)
7+
}
8+
9+
export const WritableTag = () => {
10+
return (
11+
<div className="flex max-h-[22px] max-w-[74px] items-center justify-center rounded-full bg-offPurple py-1 px-2 text-xs">
12+
Writable
13+
</div>
14+
)
15+
}
16+
17+
export const ParsedAccountPubkeyRow = ({
18+
mapping,
19+
title,
20+
pubkey,
21+
}: {
22+
mapping: { [key: string]: string }
23+
title: string
24+
pubkey: string
25+
}) => {
26+
return (
27+
<div className="flex justify-between pb-3">
28+
<div className="max-w-[80px] break-words sm:max-w-none sm:break-normal">
29+
&#10551; {title}
30+
</div>
31+
<div className="space-y-2 sm:flex sm:space-x-2">{mapping[pubkey]}</div>
32+
</div>
33+
)
34+
}

governance/xc_admin/packages/xc_admin_frontend/components/InstructionViews/WormholeInstructionView.tsx

Lines changed: 451 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { PublicKey } from '@solana/web3.js'
2+
3+
export const getMappingCluster = (cluster: string) => {
4+
if (cluster === 'mainnet-beta' || cluster === 'pythnet') {
5+
return 'pythnet'
6+
} else {
7+
return 'pythtest'
8+
}
9+
}
10+
11+
// check if a string is a pubkey
12+
export const isPubkey = (str: string) => {
13+
try {
14+
new PublicKey(str)
15+
return true
16+
} catch (e) {
17+
return false
18+
}
19+
}

governance/xc_admin/packages/xc_admin_frontend/components/tabs/General.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -778,14 +778,18 @@ const General = ({ proposerServerUrl }: { proposerServerUrl: string }) => {
778778
) : (
779779
<p className="mb-8 leading-6">No proposed changes.</p>
780780
)}
781-
{Object.keys(changes).length > 0 ? (
782-
<button
783-
className="action-btn text-base"
784-
onClick={handleSendProposalButtonClick}
785-
>
786-
{isSendProposalButtonLoading ? <Spinner /> : 'Send Proposal'}
787-
</button>
788-
) : null}
781+
{Object.keys(changes).length > 0 && (
782+
<>
783+
<button
784+
className="action-btn text-base"
785+
onClick={handleSendProposalButtonClick}
786+
disabled={isSendProposalButtonLoading || !proposeSquads}
787+
>
788+
{isSendProposalButtonLoading ? <Spinner /> : 'Send Proposal'}
789+
</button>
790+
{!proposeSquads && <div>Please connect your wallet</div>}
791+
</>
792+
)}
789793
</>
790794
)
791795
}

0 commit comments

Comments
 (0)