Skip to content

Commit e476199

Browse files
authored
[xc-admin] Add pythtest-crosschain (#749)
* Add pythtest-crosschain * Restore urls
1 parent 3842c94 commit e476199

File tree

9 files changed

+85
-51
lines changed

9 files changed

+85
-51
lines changed

governance/xc_admin/packages/xc_admin_cli/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ To activate a transaction:
2828
```
2929
npm install
3030
npx lerna run build --scope "xc_admin_common"
31-
npx ts-node src/index.ts activate -t <TRANSACTION_HASH> -c <CLUSTER: [mainnet|devnet|testnet|pythnet|pythtest]> -v <VAULT_ADDRESS> -w <WALLET_SECRET_KEY_FILEPATH: [filepath|"ledger"]> -lda <LEDGER_DERIVATION_ACCOUNT> -ldc <LEDGER_DERIVATION_CHANGE>
31+
npx ts-node src/index.ts activate -t <TRANSACTION_HASH> -c <CLUSTER: [mainnet|devnet|testnet] -v <VAULT_ADDRESS> -w <WALLET_SECRET_KEY_FILEPATH: [filepath|"ledger"]> -lda <LEDGER_DERIVATION_ACCOUNT> -ldc <LEDGER_DERIVATION_CHANGE>
3232
3333
```

governance/xc_admin/packages/xc_admin_common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"dependencies": {
2323
"@certusone/wormhole-sdk": "^0.9.8",
24-
"@pythnetwork/client": "^2.10.0",
24+
"@pythnetwork/client": "^2.16.0",
2525
"@solana/buffer-layout": "^4.0.1",
2626
"@solana/web3.js": "^1.73.0",
2727
"@sqds/mesh": "^1.0.6",

governance/xc_admin/packages/xc_admin_common/src/cluster.ts

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ import { Cluster } from "@solana/web3.js";
55
* Return whether the cluster is governed remotely or not. For example Pythnet is governed remotely by a mainnet multisig.
66
*/
77
export function isRemoteCluster(cluster: PythCluster) {
8-
return cluster == "pythnet" || cluster == "pythtest";
8+
return (
9+
cluster == "pythnet" ||
10+
cluster == "pythtest-conformance" ||
11+
cluster == "pythtest-crosschain"
12+
);
913
}
1014

1115
/**
@@ -15,24 +19,10 @@ export function getMultisigCluster(cluster: PythCluster): Cluster | "localnet" {
1519
switch (cluster) {
1620
case "pythnet":
1721
return "mainnet-beta";
18-
case "pythtest":
22+
case "pythtest-conformance":
23+
return "devnet";
24+
case "pythtest-crosschain":
1925
return "devnet";
20-
default:
21-
return cluster;
22-
}
23-
}
24-
25-
/**
26-
* For cluster that are governed remotely (ex : Pythnet from Mainnet) return the network of the remote cluster
27-
*/
28-
export function getRemoteCluster(
29-
cluster: PythCluster
30-
): PythCluster | "localnet" {
31-
switch (cluster) {
32-
case "devnet":
33-
return "pythtest";
34-
case "mainnet-beta":
35-
return "pythnet";
3626
default:
3727
return cluster;
3828
}

governance/xc_admin/packages/xc_admin_common/src/wormhole.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ import { PublicKey } from "@solana/web3.js";
33

44
export const WORMHOLE_ADDRESS: Record<PythCluster, PublicKey | undefined> = {
55
"mainnet-beta": new PublicKey("worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth"),
6-
pythtest: new PublicKey("EUrRARh92Cdc54xrDn6qzaqjA77NRrCcfbr8kPwoTL4z"),
6+
"pythtest-conformance": new PublicKey(
7+
"EUrRARh92Cdc54xrDn6qzaqjA77NRrCcfbr8kPwoTL4z"
8+
),
9+
"pythtest-crosschain": new PublicKey(
10+
"EUrRARh92Cdc54xrDn6qzaqjA77NRrCcfbr8kPwoTL4z"
11+
),
712
devnet: new PublicKey("3u8hJUVTA4jH1wYAyUur7FFZVQ8H635K3tSHHF4ssjQ5"),
813
pythnet: new PublicKey("H3fxXJ86ADW2PNuDDmZJg6mzTtPxkYCpNuQUTgmJ7AjU"),
914
localnet: new PublicKey("Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o"),
@@ -13,7 +18,8 @@ export const WORMHOLE_ADDRESS: Record<PythCluster, PublicKey | undefined> = {
1318
// Source : https://book.wormhole.com/reference/rpcnodes.html
1419
export const WORMHOLE_API_ENDPOINT: Record<PythCluster, string | undefined> = {
1520
"mainnet-beta": "https://wormhole-v2-mainnet-api.certus.one",
16-
pythtest: "https://wormhole-v2-testnet-api.certus.one",
21+
"pythtest-conformance": "https://wormhole-v2-testnet-api.certus.one",
22+
"pythtest-crosschain": "https://wormhole-v2-testnet-api.certus.one",
1723
devnet: "https://wormhole-v2-testnet-api.certus.one",
1824
pythnet: "https://wormhole-v2-mainnet-api.certus.one",
1925
localnet: undefined,

governance/xc_admin/packages/xc_admin_frontend/components/ClusterSwitch.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,13 @@ const ClusterSwitch = ({ light }: { light?: boolean | null }) => {
4949
value: 'devnet',
5050
name: 'devnet',
5151
},
52-
// hide pythtest as its broken
5352
{
54-
value: 'pythtest',
55-
name: 'pythtest',
53+
value: 'pythtest-conformance',
54+
name: 'pythtest-conformance',
55+
},
56+
{
57+
value: 'pythtest-crosschain',
58+
name: 'pythtest-crosschain',
5659
},
5760
]
5861

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

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
ExecutePostedVaa,
1717
getMultisigCluster,
1818
getProposals,
19-
getRemoteCluster,
2019
MultisigInstruction,
2120
MultisigParser,
2221
PRICE_FEED_MULTISIG,
@@ -581,12 +580,7 @@ const Proposal = ({
581580
className="flex justify-between"
582581
>
583582
<div>Target Chain</div>
584-
<div>
585-
{instruction.governanceAction.targetChainId === 'pythnet' &&
586-
getRemoteCluster(cluster) === 'pythtest'
587-
? 'pythtest'
588-
: 'pythnet'}
589-
</div>
583+
<div>{cluster}</div>
590584
</div>
591585
</>
592586
) : null}
@@ -775,9 +769,8 @@ const Proposal = ({
775769
{instruction.governanceAction instanceof ExecutePostedVaa
776770
? instruction.governanceAction.instructions.map(
777771
(innerInstruction, index) => {
778-
const multisigParser = MultisigParser.fromCluster(
779-
getRemoteCluster(cluster)
780-
)
772+
const multisigParser =
773+
MultisigParser.fromCluster(cluster)
781774
const parsedInstruction =
782775
multisigParser.parseInstruction({
783776
programId: innerInstruction.programId,
@@ -1123,9 +1116,8 @@ const Proposals = ({
11231116
ix.name === 'postMessage' &&
11241117
ix.governanceAction instanceof ExecutePostedVaa &&
11251118
ix.governanceAction.instructions.every((remoteIx) => {
1126-
const innerMultisigParser = MultisigParser.fromCluster(
1127-
getRemoteCluster(cluster)
1128-
)
1119+
const innerMultisigParser =
1120+
MultisigParser.fromCluster(cluster)
11291121
const parsedRemoteInstruction =
11301122
innerMultisigParser.parseInstruction({
11311123
programId: remoteIx.programId,

governance/xc_admin/packages/xc_admin_frontend/hooks/useMultisig.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Wallet } from '@coral-xyz/anchor'
22
import NodeWallet from '@coral-xyz/anchor/dist/cjs/nodewallet'
3+
import { getPythProgramKeyForCluster } from '@pythnetwork/client'
34
import { useAnchorWallet } from '@solana/wallet-adapter-react'
45
import {
56
AccountMeta,
@@ -12,6 +13,7 @@ import SquadsMesh from '@sqds/mesh'
1213
import { MultisigAccount, TransactionAccount } from '@sqds/mesh/lib/types'
1314
import { useContext, useEffect, useState } from 'react'
1415
import {
16+
ExecutePostedVaa,
1517
getManyProposalsInstructions,
1618
getMultisigCluster,
1719
getProposals,
@@ -129,7 +131,6 @@ export const useMultisig = (wallet: Wallet): MultisigHookData => {
129131
)
130132
try {
131133
if (cancelled) return
132-
// DELETE THIS TRY CATCH ONCE THIS MULTISIG EXISTS EVERYWHERE
133134
setpriceFeedMultisigAccount(
134135
await readOnlySquads.getMultisig(
135136
PRICE_FEED_MULTISIG[getMultisigCluster(cluster)]
@@ -149,7 +150,6 @@ export const useMultisig = (wallet: Wallet): MultisigHookData => {
149150
)
150151
try {
151152
if (cancelled) return
152-
// DELETE THIS TRY CATCH ONCE THIS MULTISIG EXISTS EVERYWHERE
153153
const sortedPriceFeedMultisigProposals = await getSortedProposals(
154154
readOnlySquads,
155155
PRICE_FEED_MULTISIG[getMultisigCluster(cluster)]
@@ -178,7 +178,14 @@ export const useMultisig = (wallet: Wallet): MultisigHookData => {
178178
if (
179179
isRemoteCluster(cluster) &&
180180
ixs.length > 0 &&
181-
ixs.some((ix) => ix instanceof WormholeMultisigInstruction)
181+
ixs.some(
182+
(ix) =>
183+
ix instanceof WormholeMultisigInstruction &&
184+
ix.governanceAction instanceof ExecutePostedVaa &&
185+
ix.governanceAction.instructions.some((ix) =>
186+
ix.programId.equals(getPythProgramKeyForCluster(cluster))
187+
)
188+
)
182189
) {
183190
proposalsRes.push(sortedPriceFeedMultisigProposals[idx])
184191
instructionsRes.push(ixs)

governance/xc_admin/packages/xc_admin_frontend/utils/pythClusterApiUrl.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,17 @@ const CLUSTER_URLS: Record<PythCluster, any> = {
4747
wsUrl: 'wss://api.testnet.solana.com/',
4848
},
4949
],
50-
pythtest: [
50+
'pythtest-conformance': [
51+
{
52+
rpcUrl: 'http://pythtest.xyz.pyth.network',
53+
wsUrl: 'ws://pythtest.xyz.pyth.network',
54+
},
55+
{
56+
rpcUrl: 'https://api.pythtest.pyth.network/',
57+
wsUrl: 'wss://api.pythtest.pyth.network/',
58+
},
59+
],
60+
'pythtest-crosschain': [
5161
{
5262
rpcUrl: 'http://pythtest.xyz.pyth.network',
5363
wsUrl: 'ws://pythtest.xyz.pyth.network',

package-lock.json

Lines changed: 35 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)