From 0fc9148f1841a5c0580458df2a4fb8adf56604c4 Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Tue, 6 Aug 2024 11:41:07 +0900 Subject: [PATCH 1/5] update xc-admin-frontend to show eclipse_mainnet proposals --- .../programs/remote-executor/Cargo.toml | 1 + .../src/state/governance_payload.rs | 4 ++ .../remote-executor/src/state/posted_vaa.rs | 2 +- .../packages/xc_admin_cli/src/index.ts | 5 ++- .../packages/xc_admin_common/src/chains.ts | 5 +++ .../packages/xc_admin_common/src/cluster.ts | 6 ++- .../packages/xc_admin_common/src/propose.ts | 19 +++++--- .../components/tabs/Proposals/Proposal.tsx | 43 +++++++++++++------ .../components/tabs/Proposals/utils.ts | 22 ++++++++++ 9 files changed, 84 insertions(+), 23 deletions(-) diff --git a/governance/remote_executor/programs/remote-executor/Cargo.toml b/governance/remote_executor/programs/remote-executor/Cargo.toml index 69a072b0c9..db20da538f 100644 --- a/governance/remote_executor/programs/remote-executor/Cargo.toml +++ b/governance/remote_executor/programs/remote-executor/Cargo.toml @@ -23,6 +23,7 @@ pythnet = [] pythtest = [] eclipse_devnet = [] eclipse_testnet = [] +eclipse_mainnet = [] [dependencies] anchor-lang = {version = "0.25.0", features = ["init-if-needed"]} diff --git a/governance/remote_executor/programs/remote-executor/src/state/governance_payload.rs b/governance/remote_executor/programs/remote-executor/src/state/governance_payload.rs index 84bda01748..494ab347d0 100644 --- a/governance/remote_executor/programs/remote-executor/src/state/governance_payload.rs +++ b/governance/remote_executor/programs/remote-executor/src/state/governance_payload.rs @@ -19,6 +19,7 @@ pub const CHAIN_ID_ARRAY: &[(&str, u16)] = &[ ("pythtest", 26), ("eclipse_devnet", 40001), ("eclipse_testnet", 40002), + ("eclipse_mainnet", 40003), ]; #[cfg(any(feature = "pythnet", feature = "pythtest"))] @@ -30,6 +31,9 @@ pub const CHAIN_ID: u16 = 40001; #[cfg(feature = "eclipse_testnet")] pub const CHAIN_ID: u16 = 40002; +#[cfg(feature = "eclipse_mainnet")] +pub const CHAIN_ID: u16 = 40003; + #[derive(AnchorDeserialize, AnchorSerialize, Debug, PartialEq, Eq)] pub struct ExecutorPayload { pub header: GovernanceHeader, diff --git a/governance/remote_executor/programs/remote-executor/src/state/posted_vaa.rs b/governance/remote_executor/programs/remote-executor/src/state/posted_vaa.rs index c94755b1b5..6732a98268 100644 --- a/governance/remote_executor/programs/remote-executor/src/state/posted_vaa.rs +++ b/governance/remote_executor/programs/remote-executor/src/state/posted_vaa.rs @@ -20,7 +20,7 @@ impl Owner for AnchorVaa { Pubkey::from_str("EUrRARh92Cdc54xrDn6qzaqjA77NRrCcfbr8kPwoTL4z").unwrap() } - #[cfg(any(feature = "eclipse_devnet", feature = "eclipse_testnet"))] + #[cfg(any(feature = "eclipse_devnet", feature = "eclipse_testnet", feature = "eclipse_mainnet"))] fn owner() -> Pubkey { Pubkey::from_str("HDwcJBJXjL9FpJ7UBsYBtaDjsBUhuLCUYoz3zr8SWWaQ").unwrap() } diff --git a/governance/xc_admin/packages/xc_admin_cli/src/index.ts b/governance/xc_admin/packages/xc_admin_cli/src/index.ts index 004c363bbb..ba457ccedb 100644 --- a/governance/xc_admin/packages/xc_admin_cli/src/index.ts +++ b/governance/xc_admin/packages/xc_admin_cli/src/index.ts @@ -33,6 +33,7 @@ import { MultisigParser, MultisigVault, PROGRAM_AUTHORITY_ESCROW, + SvmCluster, getMultisigCluster, getProposalInstructions, } from "@pythnetwork/xc-admin-common"; @@ -69,7 +70,7 @@ async function loadVaultFromOptions(options: any): Promise { options.ledgerDerivationChange ); // This is the cluster where we want to perform the action - const cluster: PythCluster = options.cluster; + const cluster: SvmCluster = options.cluster; // This is the cluster where the multisig lives that can perform actions on ^ const multisigCluster = getMultisigCluster(cluster); const vault: PublicKey = new PublicKey(options.vault); @@ -171,7 +172,7 @@ multisigCommand( "Accept governance authority transfer for the solana receiver program" ).action(async (options: any) => { const vault = await loadVaultFromOptions(options); - const targetCluster: PythCluster = options.cluster; + const targetCluster: SvmCluster = options.cluster; const programSolanaReceiver = new Program( pythSolanaReceiverIdl, diff --git a/governance/xc_admin/packages/xc_admin_common/src/chains.ts b/governance/xc_admin/packages/xc_admin_common/src/chains.ts index e48ba2a13a..aaf37b1174 100644 --- a/governance/xc_admin/packages/xc_admin_common/src/chains.ts +++ b/governance/xc_admin/packages/xc_admin_common/src/chains.ts @@ -23,6 +23,11 @@ export const RECEIVER_CHAINS = { arbitrum: 23, optimism: 24, + // SVM chains + eclipse_devnet: 40001, + eclipse_testnet: 40002, + eclipse_mainnet: 40003, + cronos: 60001, kcc: 60002, zksync: 60003, diff --git a/governance/xc_admin/packages/xc_admin_common/src/cluster.ts b/governance/xc_admin/packages/xc_admin_common/src/cluster.ts index 642800c3c3..60d1bb836d 100644 --- a/governance/xc_admin/packages/xc_admin_common/src/cluster.ts +++ b/governance/xc_admin/packages/xc_admin_common/src/cluster.ts @@ -1,6 +1,9 @@ import { PythCluster } from "@pythnetwork/client/lib/cluster"; import { Cluster } from "@solana/web3.js"; +export type NonPythnetSvmCluster = "eclipse_mainnet"; +export type SvmCluster = PythCluster | NonPythnetSvmCluster; + /** * Return whether the cluster is governed remotely or not. For example Pythnet is governed remotely by a mainnet multisig. */ @@ -15,9 +18,10 @@ export function isRemoteCluster(cluster: PythCluster) { /** * For cluster that are governed remotely (ex : Pythnet from Mainnet) return the network where the multisig lives */ -export function getMultisigCluster(cluster: PythCluster): Cluster | "localnet" { +export function getMultisigCluster(cluster: SvmCluster): Cluster | "localnet" { switch (cluster) { case "pythnet": + case "eclipse_mainnet": return "mainnet-beta"; case "pythtest-conformance": return "devnet"; diff --git a/governance/xc_admin/packages/xc_admin_common/src/propose.ts b/governance/xc_admin/packages/xc_admin_common/src/propose.ts index 827c9a9760..94c4b6e4b4 100644 --- a/governance/xc_admin/packages/xc_admin_common/src/propose.ts +++ b/governance/xc_admin/packages/xc_admin_common/src/propose.ts @@ -33,6 +33,8 @@ import { PriorityFeeConfig, } from "@pythnetwork/solana-utils"; import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet"; +import { SvmCluster } from "./cluster"; +import { ChainName } from "./chains"; export const MAX_EXECUTOR_PAYLOAD_SIZE = PACKET_DATA_SIZE_WITH_ROOM_FOR_COMPUTE_BUDGET - 687; // Bigger payloads won't fit in one addInstruction call when adding to the proposal @@ -84,9 +86,9 @@ export class MultisigVault { * is the PDA of the remote executor program representing the vault's Wormhole emitter address. * @param cluster */ - public async getVaultAuthorityPDA(cluster?: PythCluster): Promise { + public async getVaultAuthorityPDA(cluster?: SvmCluster): Promise { const msAccount = await this.getMultisigAccount(); - const localAuthorityPDA = await this.squad.getAuthorityPDA( + const localAuthorityPDA = this.squad.getAuthorityPDA( msAccount.publicKey, msAccount.authorityIndex ); @@ -288,7 +290,7 @@ export class MultisigVault { */ public async proposeInstructions( instructions: TransactionInstruction[], - targetCluster: PythCluster, + targetCluster: SvmCluster, priorityFeeConfig: PriorityFeeConfig = {} ): Promise { const msAccount = await this.getMultisigAccount(); @@ -321,7 +323,8 @@ export class MultisigVault { newProposalAddress, batch, i + 1, - this.wormholeAddress()! + this.wormholeAddress()!, + targetCluster ); ixToSend.push( await this.squad.buildAddInstruction( @@ -473,9 +476,13 @@ export async function wrapAsRemoteInstruction( proposalAddress: PublicKey, instructions: TransactionInstruction[], instructionIndex: number, - wormholeAddress: PublicKey + wormholeAddress: PublicKey, + targetCluster: SvmCluster ): Promise { - const buffer: Buffer = new ExecutePostedVaa("pythnet", instructions).encode(); + const buffer: Buffer = new ExecutePostedVaa( + targetCluster as ChainName, + instructions + ).encode(); return await getPostMessageInstruction( squad, vault, diff --git a/governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/Proposal.tsx b/governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/Proposal.tsx index 1190629c1e..109122f127 100644 --- a/governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/Proposal.tsx +++ b/governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/Proposal.tsx @@ -17,6 +17,7 @@ import { MultisigInstruction, MultisigParser, PythMultisigInstruction, + SvmCluster, WormholeMultisigInstruction, getManyProposalsInstructions, getMultisigCluster, @@ -37,11 +38,16 @@ import Spinner from '../../common/Spinner' import Loadbar from '../../loaders/Loadbar' import { Wallet } from '@coral-xyz/anchor' -import { PythCluster, getPythProgramKeyForCluster } from '@pythnetwork/client' +import { getPythProgramKeyForCluster } from '@pythnetwork/client' import { TransactionBuilder, sendTransactions } from '@pythnetwork/solana-utils' import { getMappingCluster, isPubkey } from '../../InstructionViews/utils' import { StatusTag } from './StatusTag' -import { getProposalStatus } from './utils' +import { + getProposalStatus, + getPythnetCluster, + isSolanaPullProgram, + isSvmChainId, +} from './utils' import VerifiedIcon from '@images/icons/verified.inline.svg' import VotedIcon from '@images/icons/voted.inline.svg' @@ -140,7 +146,7 @@ export const Proposal = ({ const [isTransactionLoading, setIsTransactionLoading] = useState(false) const { cluster: contextCluster } = useContext(ClusterContext) const multisigCluster = getMultisigCluster(contextCluster) - const targetClusters: (PythCluster | 'unknown')[] = [] + const targetClusters: (SvmCluster | 'unknown')[] = [] instructions.map((ix) => { if (!(ix instanceof WormholeMultisigInstruction)) { targetClusters.push(multisigCluster) @@ -148,17 +154,22 @@ export const Proposal = ({ ix instanceof WormholeMultisigInstruction && ix.governanceAction instanceof ExecutePostedVaa ) { - ix.governanceAction.instructions.map((ix) => { - const remoteClusters: PythCluster[] = [ + ix.governanceAction.instructions.map((innerIx) => { + const remoteClusters: SvmCluster[] = [ 'pythnet', 'pythtest-conformance', 'pythtest-crosschain', + 'eclipse_mainnet', ] for (const remoteCluster of remoteClusters) { if ( multisigCluster === getMultisigCluster(remoteCluster) && - (ix.programId.equals(getPythProgramKeyForCluster(remoteCluster)) || - ix.programId.equals(SystemProgram.programId)) + ix.governanceAction?.targetChainId === remoteCluster && + (innerIx.programId.equals( + getPythProgramKeyForCluster(getPythnetCluster(remoteCluster)) + ) || + innerIx.programId.equals(SystemProgram.programId) || + isSolanaPullProgram(innerIx.programId)) ) { targetClusters.push(remoteCluster) } @@ -203,7 +214,10 @@ export const Proposal = ({ ix.name === 'postMessage' && ix.governanceAction instanceof ExecutePostedVaa && ix.governanceAction.instructions.every((remoteIx) => { - const innerMultisigParser = MultisigParser.fromCluster(cluster) + console.log(getPythnetCluster(cluster)) + const innerMultisigParser = MultisigParser.fromCluster( + getPythnetCluster(cluster) + ) const parsedRemoteInstruction = innerMultisigParser.parseInstruction({ programId: remoteIx.programId, @@ -215,7 +229,7 @@ export const Proposal = ({ parsedRemoteInstruction instanceof AnchorMultisigInstruction ) }) && - ix.governanceAction.targetChainId === 'pythnet') + isSvmChainId(ix.governanceAction.targetChainId)) ) const voted = @@ -300,7 +314,7 @@ export const Proposal = ({ if (refreshData) await refreshData().fetchData() toast.success(msg) - } catch (e: any) { + } catch (e) { toast.error(capitalizeFirstLetter(e.message)) } finally { setIsTransactionLoading(false) @@ -488,7 +502,10 @@ export const Proposal = ({

Summary

- +
{instructions?.map((instruction, index) => ( @@ -549,7 +566,7 @@ export const Proposal = ({ {typeof instruction.args[key] === 'string' ? instruction.args[key] : instruction.args[key] instanceof Uint8Array - ? instruction.args[key].toString('hex') + ? instruction.args[key].toString() : typeof instruction.args[key] === 'bigint' ? instruction.args[key].toString() : JSON.stringify(instruction.args[key])} @@ -576,7 +593,7 @@ export const Proposal = ({ )} {instruction instanceof WormholeMultisigInstruction && ( )} diff --git a/governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/utils.ts b/governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/utils.ts index 793f8ec7ac..375b90b779 100644 --- a/governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/utils.ts +++ b/governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/utils.ts @@ -7,6 +7,7 @@ import { MultisigParser, PythGovernanceActionImpl, SetDataSources, + SvmCluster, WormholeMultisigInstruction, } from '@pythnetwork/xc-admin-common' @@ -117,3 +118,24 @@ const getTransactionSummary = (instruction: MultisigInstruction) => { } as const } } + +export const isSolanaPullProgram = (programId: PublicKey) => { + const solanaPullProgramIds = [ + new PublicKey('rec5EKMGg6MxZYaMdyBfgwp4d5rB9T1VQH5pJv5LtFJ'), + new PublicKey('HDwcJBJXjL9FpJ7UBsYBtaDjsBUhuLCUYoz3zr8SWWaQ'), + new PublicKey('pythWSnswVUd12oZpeFP8e9CVaEqJg25g1Vtc2biRsT'), + ] + return solanaPullProgramIds.some((id) => programId.equals(id)) +} + +export const isSvmChainId = (chainId: string) => { + const svmChainIds = ['pythnet', 'eclipse_mainnet'] + return svmChainIds.includes(chainId) +} + +export const getPythnetCluster = (cluster: SvmCluster): PythCluster => { + if (isSvmChainId(cluster)) { + return 'pythnet' + } + return cluster as PythCluster +} From 9cecceea074972ce18fe73d812fb8adf0d088644 Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Tue, 6 Aug 2024 11:43:44 +0900 Subject: [PATCH 2/5] fix test --- .../xc_admin_frontend/components/tabs/Proposals/Proposal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/Proposal.tsx b/governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/Proposal.tsx index 109122f127..1b65e95142 100644 --- a/governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/Proposal.tsx +++ b/governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/Proposal.tsx @@ -314,7 +314,7 @@ export const Proposal = ({ if (refreshData) await refreshData().fetchData() toast.success(msg) - } catch (e) { + } catch (e: any) { toast.error(capitalizeFirstLetter(e.message)) } finally { setIsTransactionLoading(false) From 0b981e6b50dd9a2bbd596a16063c7e7e15667329 Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Tue, 6 Aug 2024 11:52:00 +0900 Subject: [PATCH 3/5] precommit --- .../programs/remote-executor/src/state/posted_vaa.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/governance/remote_executor/programs/remote-executor/src/state/posted_vaa.rs b/governance/remote_executor/programs/remote-executor/src/state/posted_vaa.rs index 6732a98268..4e5e769957 100644 --- a/governance/remote_executor/programs/remote-executor/src/state/posted_vaa.rs +++ b/governance/remote_executor/programs/remote-executor/src/state/posted_vaa.rs @@ -20,7 +20,11 @@ impl Owner for AnchorVaa { Pubkey::from_str("EUrRARh92Cdc54xrDn6qzaqjA77NRrCcfbr8kPwoTL4z").unwrap() } - #[cfg(any(feature = "eclipse_devnet", feature = "eclipse_testnet", feature = "eclipse_mainnet"))] + #[cfg(any( + feature = "eclipse_devnet", + feature = "eclipse_testnet", + feature = "eclipse_mainnet" + ))] fn owner() -> Pubkey { Pubkey::from_str("HDwcJBJXjL9FpJ7UBsYBtaDjsBUhuLCUYoz3zr8SWWaQ").unwrap() } From b0c6fb3ed86c39f7f3b71a254f98653f316f90e3 Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Tue, 6 Aug 2024 22:43:40 +0900 Subject: [PATCH 4/5] revert specific files to match main --- .../packages/xc_admin_cli/src/index.ts | 5 +-- .../packages/xc_admin_common/src/cluster.ts | 6 +-- .../packages/xc_admin_common/src/propose.ts | 19 +++------ .../components/tabs/Proposals/Proposal.tsx | 41 ++++++------------- .../components/tabs/Proposals/utils.ts | 22 ---------- 5 files changed, 21 insertions(+), 72 deletions(-) diff --git a/governance/xc_admin/packages/xc_admin_cli/src/index.ts b/governance/xc_admin/packages/xc_admin_cli/src/index.ts index ba457ccedb..004c363bbb 100644 --- a/governance/xc_admin/packages/xc_admin_cli/src/index.ts +++ b/governance/xc_admin/packages/xc_admin_cli/src/index.ts @@ -33,7 +33,6 @@ import { MultisigParser, MultisigVault, PROGRAM_AUTHORITY_ESCROW, - SvmCluster, getMultisigCluster, getProposalInstructions, } from "@pythnetwork/xc-admin-common"; @@ -70,7 +69,7 @@ async function loadVaultFromOptions(options: any): Promise { options.ledgerDerivationChange ); // This is the cluster where we want to perform the action - const cluster: SvmCluster = options.cluster; + const cluster: PythCluster = options.cluster; // This is the cluster where the multisig lives that can perform actions on ^ const multisigCluster = getMultisigCluster(cluster); const vault: PublicKey = new PublicKey(options.vault); @@ -172,7 +171,7 @@ multisigCommand( "Accept governance authority transfer for the solana receiver program" ).action(async (options: any) => { const vault = await loadVaultFromOptions(options); - const targetCluster: SvmCluster = options.cluster; + const targetCluster: PythCluster = options.cluster; const programSolanaReceiver = new Program( pythSolanaReceiverIdl, diff --git a/governance/xc_admin/packages/xc_admin_common/src/cluster.ts b/governance/xc_admin/packages/xc_admin_common/src/cluster.ts index 60d1bb836d..642800c3c3 100644 --- a/governance/xc_admin/packages/xc_admin_common/src/cluster.ts +++ b/governance/xc_admin/packages/xc_admin_common/src/cluster.ts @@ -1,9 +1,6 @@ import { PythCluster } from "@pythnetwork/client/lib/cluster"; import { Cluster } from "@solana/web3.js"; -export type NonPythnetSvmCluster = "eclipse_mainnet"; -export type SvmCluster = PythCluster | NonPythnetSvmCluster; - /** * Return whether the cluster is governed remotely or not. For example Pythnet is governed remotely by a mainnet multisig. */ @@ -18,10 +15,9 @@ export function isRemoteCluster(cluster: PythCluster) { /** * For cluster that are governed remotely (ex : Pythnet from Mainnet) return the network where the multisig lives */ -export function getMultisigCluster(cluster: SvmCluster): Cluster | "localnet" { +export function getMultisigCluster(cluster: PythCluster): Cluster | "localnet" { switch (cluster) { case "pythnet": - case "eclipse_mainnet": return "mainnet-beta"; case "pythtest-conformance": return "devnet"; diff --git a/governance/xc_admin/packages/xc_admin_common/src/propose.ts b/governance/xc_admin/packages/xc_admin_common/src/propose.ts index 94c4b6e4b4..827c9a9760 100644 --- a/governance/xc_admin/packages/xc_admin_common/src/propose.ts +++ b/governance/xc_admin/packages/xc_admin_common/src/propose.ts @@ -33,8 +33,6 @@ import { PriorityFeeConfig, } from "@pythnetwork/solana-utils"; import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet"; -import { SvmCluster } from "./cluster"; -import { ChainName } from "./chains"; export const MAX_EXECUTOR_PAYLOAD_SIZE = PACKET_DATA_SIZE_WITH_ROOM_FOR_COMPUTE_BUDGET - 687; // Bigger payloads won't fit in one addInstruction call when adding to the proposal @@ -86,9 +84,9 @@ export class MultisigVault { * is the PDA of the remote executor program representing the vault's Wormhole emitter address. * @param cluster */ - public async getVaultAuthorityPDA(cluster?: SvmCluster): Promise { + public async getVaultAuthorityPDA(cluster?: PythCluster): Promise { const msAccount = await this.getMultisigAccount(); - const localAuthorityPDA = this.squad.getAuthorityPDA( + const localAuthorityPDA = await this.squad.getAuthorityPDA( msAccount.publicKey, msAccount.authorityIndex ); @@ -290,7 +288,7 @@ export class MultisigVault { */ public async proposeInstructions( instructions: TransactionInstruction[], - targetCluster: SvmCluster, + targetCluster: PythCluster, priorityFeeConfig: PriorityFeeConfig = {} ): Promise { const msAccount = await this.getMultisigAccount(); @@ -323,8 +321,7 @@ export class MultisigVault { newProposalAddress, batch, i + 1, - this.wormholeAddress()!, - targetCluster + this.wormholeAddress()! ); ixToSend.push( await this.squad.buildAddInstruction( @@ -476,13 +473,9 @@ export async function wrapAsRemoteInstruction( proposalAddress: PublicKey, instructions: TransactionInstruction[], instructionIndex: number, - wormholeAddress: PublicKey, - targetCluster: SvmCluster + wormholeAddress: PublicKey ): Promise { - const buffer: Buffer = new ExecutePostedVaa( - targetCluster as ChainName, - instructions - ).encode(); + const buffer: Buffer = new ExecutePostedVaa("pythnet", instructions).encode(); return await getPostMessageInstruction( squad, vault, diff --git a/governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/Proposal.tsx b/governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/Proposal.tsx index 1b65e95142..1190629c1e 100644 --- a/governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/Proposal.tsx +++ b/governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/Proposal.tsx @@ -17,7 +17,6 @@ import { MultisigInstruction, MultisigParser, PythMultisigInstruction, - SvmCluster, WormholeMultisigInstruction, getManyProposalsInstructions, getMultisigCluster, @@ -38,16 +37,11 @@ import Spinner from '../../common/Spinner' import Loadbar from '../../loaders/Loadbar' import { Wallet } from '@coral-xyz/anchor' -import { getPythProgramKeyForCluster } from '@pythnetwork/client' +import { PythCluster, getPythProgramKeyForCluster } from '@pythnetwork/client' import { TransactionBuilder, sendTransactions } from '@pythnetwork/solana-utils' import { getMappingCluster, isPubkey } from '../../InstructionViews/utils' import { StatusTag } from './StatusTag' -import { - getProposalStatus, - getPythnetCluster, - isSolanaPullProgram, - isSvmChainId, -} from './utils' +import { getProposalStatus } from './utils' import VerifiedIcon from '@images/icons/verified.inline.svg' import VotedIcon from '@images/icons/voted.inline.svg' @@ -146,7 +140,7 @@ export const Proposal = ({ const [isTransactionLoading, setIsTransactionLoading] = useState(false) const { cluster: contextCluster } = useContext(ClusterContext) const multisigCluster = getMultisigCluster(contextCluster) - const targetClusters: (SvmCluster | 'unknown')[] = [] + const targetClusters: (PythCluster | 'unknown')[] = [] instructions.map((ix) => { if (!(ix instanceof WormholeMultisigInstruction)) { targetClusters.push(multisigCluster) @@ -154,22 +148,17 @@ export const Proposal = ({ ix instanceof WormholeMultisigInstruction && ix.governanceAction instanceof ExecutePostedVaa ) { - ix.governanceAction.instructions.map((innerIx) => { - const remoteClusters: SvmCluster[] = [ + ix.governanceAction.instructions.map((ix) => { + const remoteClusters: PythCluster[] = [ 'pythnet', 'pythtest-conformance', 'pythtest-crosschain', - 'eclipse_mainnet', ] for (const remoteCluster of remoteClusters) { if ( multisigCluster === getMultisigCluster(remoteCluster) && - ix.governanceAction?.targetChainId === remoteCluster && - (innerIx.programId.equals( - getPythProgramKeyForCluster(getPythnetCluster(remoteCluster)) - ) || - innerIx.programId.equals(SystemProgram.programId) || - isSolanaPullProgram(innerIx.programId)) + (ix.programId.equals(getPythProgramKeyForCluster(remoteCluster)) || + ix.programId.equals(SystemProgram.programId)) ) { targetClusters.push(remoteCluster) } @@ -214,10 +203,7 @@ export const Proposal = ({ ix.name === 'postMessage' && ix.governanceAction instanceof ExecutePostedVaa && ix.governanceAction.instructions.every((remoteIx) => { - console.log(getPythnetCluster(cluster)) - const innerMultisigParser = MultisigParser.fromCluster( - getPythnetCluster(cluster) - ) + const innerMultisigParser = MultisigParser.fromCluster(cluster) const parsedRemoteInstruction = innerMultisigParser.parseInstruction({ programId: remoteIx.programId, @@ -229,7 +215,7 @@ export const Proposal = ({ parsedRemoteInstruction instanceof AnchorMultisigInstruction ) }) && - isSvmChainId(ix.governanceAction.targetChainId)) + ix.governanceAction.targetChainId === 'pythnet') ) const voted = @@ -502,10 +488,7 @@ export const Proposal = ({

Summary

- +
{instructions?.map((instruction, index) => ( @@ -566,7 +549,7 @@ export const Proposal = ({ {typeof instruction.args[key] === 'string' ? instruction.args[key] : instruction.args[key] instanceof Uint8Array - ? instruction.args[key].toString() + ? instruction.args[key].toString('hex') : typeof instruction.args[key] === 'bigint' ? instruction.args[key].toString() : JSON.stringify(instruction.args[key])} @@ -593,7 +576,7 @@ export const Proposal = ({ )} {instruction instanceof WormholeMultisigInstruction && ( )} diff --git a/governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/utils.ts b/governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/utils.ts index 375b90b779..793f8ec7ac 100644 --- a/governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/utils.ts +++ b/governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/utils.ts @@ -7,7 +7,6 @@ import { MultisigParser, PythGovernanceActionImpl, SetDataSources, - SvmCluster, WormholeMultisigInstruction, } from '@pythnetwork/xc-admin-common' @@ -118,24 +117,3 @@ const getTransactionSummary = (instruction: MultisigInstruction) => { } as const } } - -export const isSolanaPullProgram = (programId: PublicKey) => { - const solanaPullProgramIds = [ - new PublicKey('rec5EKMGg6MxZYaMdyBfgwp4d5rB9T1VQH5pJv5LtFJ'), - new PublicKey('HDwcJBJXjL9FpJ7UBsYBtaDjsBUhuLCUYoz3zr8SWWaQ'), - new PublicKey('pythWSnswVUd12oZpeFP8e9CVaEqJg25g1Vtc2biRsT'), - ] - return solanaPullProgramIds.some((id) => programId.equals(id)) -} - -export const isSvmChainId = (chainId: string) => { - const svmChainIds = ['pythnet', 'eclipse_mainnet'] - return svmChainIds.includes(chainId) -} - -export const getPythnetCluster = (cluster: SvmCluster): PythCluster => { - if (isSvmChainId(cluster)) { - return 'pythnet' - } - return cluster as PythCluster -} From 3cd905b5cfa3b2644e586b8cc19d9a7065cbe2f5 Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Tue, 6 Aug 2024 22:45:07 +0900 Subject: [PATCH 5/5] dont show text if targetNetwork is not resolved --- .../xc_admin_frontend/components/tabs/Proposals/Proposal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/Proposal.tsx b/governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/Proposal.tsx index 1190629c1e..6d8f3ebdd1 100644 --- a/governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/Proposal.tsx +++ b/governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/Proposal.tsx @@ -377,7 +377,7 @@ export const Proposal = ({ {uniqueTargetCluster ? `Target network: ${targetClusters[0]}` : targetClusters.length == 0 - ? 'No target network detected' + ? '' : `Multiple target networks detected ${targetClusters.join(' ')}`}