[xc-admin] Add pythtest-crosschain (#749)

* Add pythtest-crosschain

* Restore urls
This commit is contained in:
guibescos 2023-04-06 17:48:54 -05:00 committed by GitHub
parent 3842c9460b
commit e476199c2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 85 additions and 51 deletions

View File

@ -28,6 +28,6 @@ To activate a transaction:
```
npm install
npx lerna run build --scope "xc_admin_common"
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>
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>
```

View File

@ -21,7 +21,7 @@
},
"dependencies": {
"@certusone/wormhole-sdk": "^0.9.8",
"@pythnetwork/client": "^2.10.0",
"@pythnetwork/client": "^2.16.0",
"@solana/buffer-layout": "^4.0.1",
"@solana/web3.js": "^1.73.0",
"@sqds/mesh": "^1.0.6",

View File

@ -5,7 +5,11 @@ import { Cluster } from "@solana/web3.js";
* Return whether the cluster is governed remotely or not. For example Pythnet is governed remotely by a mainnet multisig.
*/
export function isRemoteCluster(cluster: PythCluster) {
return cluster == "pythnet" || cluster == "pythtest";
return (
cluster == "pythnet" ||
cluster == "pythtest-conformance" ||
cluster == "pythtest-crosschain"
);
}
/**
@ -15,25 +19,11 @@ export function getMultisigCluster(cluster: PythCluster): Cluster | "localnet" {
switch (cluster) {
case "pythnet":
return "mainnet-beta";
case "pythtest":
case "pythtest-conformance":
return "devnet";
case "pythtest-crosschain":
return "devnet";
default:
return cluster;
}
}
/**
* For cluster that are governed remotely (ex : Pythnet from Mainnet) return the network of the remote cluster
*/
export function getRemoteCluster(
cluster: PythCluster
): PythCluster | "localnet" {
switch (cluster) {
case "devnet":
return "pythtest";
case "mainnet-beta":
return "pythnet";
default:
return cluster;
}
}

View File

@ -3,7 +3,12 @@ import { PublicKey } from "@solana/web3.js";
export const WORMHOLE_ADDRESS: Record<PythCluster, PublicKey | undefined> = {
"mainnet-beta": new PublicKey("worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth"),
pythtest: new PublicKey("EUrRARh92Cdc54xrDn6qzaqjA77NRrCcfbr8kPwoTL4z"),
"pythtest-conformance": new PublicKey(
"EUrRARh92Cdc54xrDn6qzaqjA77NRrCcfbr8kPwoTL4z"
),
"pythtest-crosschain": new PublicKey(
"EUrRARh92Cdc54xrDn6qzaqjA77NRrCcfbr8kPwoTL4z"
),
devnet: new PublicKey("3u8hJUVTA4jH1wYAyUur7FFZVQ8H635K3tSHHF4ssjQ5"),
pythnet: new PublicKey("H3fxXJ86ADW2PNuDDmZJg6mzTtPxkYCpNuQUTgmJ7AjU"),
localnet: new PublicKey("Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o"),
@ -13,7 +18,8 @@ export const WORMHOLE_ADDRESS: Record<PythCluster, PublicKey | undefined> = {
// Source : https://book.wormhole.com/reference/rpcnodes.html
export const WORMHOLE_API_ENDPOINT: Record<PythCluster, string | undefined> = {
"mainnet-beta": "https://wormhole-v2-mainnet-api.certus.one",
pythtest: "https://wormhole-v2-testnet-api.certus.one",
"pythtest-conformance": "https://wormhole-v2-testnet-api.certus.one",
"pythtest-crosschain": "https://wormhole-v2-testnet-api.certus.one",
devnet: "https://wormhole-v2-testnet-api.certus.one",
pythnet: "https://wormhole-v2-mainnet-api.certus.one",
localnet: undefined,

View File

@ -49,10 +49,13 @@ const ClusterSwitch = ({ light }: { light?: boolean | null }) => {
value: 'devnet',
name: 'devnet',
},
// hide pythtest as its broken
{
value: 'pythtest',
name: 'pythtest',
value: 'pythtest-conformance',
name: 'pythtest-conformance',
},
{
value: 'pythtest-crosschain',
name: 'pythtest-crosschain',
},
]

View File

@ -16,7 +16,6 @@ import {
ExecutePostedVaa,
getMultisigCluster,
getProposals,
getRemoteCluster,
MultisigInstruction,
MultisigParser,
PRICE_FEED_MULTISIG,
@ -581,12 +580,7 @@ const Proposal = ({
className="flex justify-between"
>
<div>Target Chain</div>
<div>
{instruction.governanceAction.targetChainId === 'pythnet' &&
getRemoteCluster(cluster) === 'pythtest'
? 'pythtest'
: 'pythnet'}
</div>
<div>{cluster}</div>
</div>
</>
) : null}
@ -775,9 +769,8 @@ const Proposal = ({
{instruction.governanceAction instanceof ExecutePostedVaa
? instruction.governanceAction.instructions.map(
(innerInstruction, index) => {
const multisigParser = MultisigParser.fromCluster(
getRemoteCluster(cluster)
)
const multisigParser =
MultisigParser.fromCluster(cluster)
const parsedInstruction =
multisigParser.parseInstruction({
programId: innerInstruction.programId,
@ -1123,9 +1116,8 @@ const Proposals = ({
ix.name === 'postMessage' &&
ix.governanceAction instanceof ExecutePostedVaa &&
ix.governanceAction.instructions.every((remoteIx) => {
const innerMultisigParser = MultisigParser.fromCluster(
getRemoteCluster(cluster)
)
const innerMultisigParser =
MultisigParser.fromCluster(cluster)
const parsedRemoteInstruction =
innerMultisigParser.parseInstruction({
programId: remoteIx.programId,

View File

@ -1,5 +1,6 @@
import { Wallet } from '@coral-xyz/anchor'
import NodeWallet from '@coral-xyz/anchor/dist/cjs/nodewallet'
import { getPythProgramKeyForCluster } from '@pythnetwork/client'
import { useAnchorWallet } from '@solana/wallet-adapter-react'
import {
AccountMeta,
@ -12,6 +13,7 @@ import SquadsMesh from '@sqds/mesh'
import { MultisigAccount, TransactionAccount } from '@sqds/mesh/lib/types'
import { useContext, useEffect, useState } from 'react'
import {
ExecutePostedVaa,
getManyProposalsInstructions,
getMultisigCluster,
getProposals,
@ -129,7 +131,6 @@ export const useMultisig = (wallet: Wallet): MultisigHookData => {
)
try {
if (cancelled) return
// DELETE THIS TRY CATCH ONCE THIS MULTISIG EXISTS EVERYWHERE
setpriceFeedMultisigAccount(
await readOnlySquads.getMultisig(
PRICE_FEED_MULTISIG[getMultisigCluster(cluster)]
@ -149,7 +150,6 @@ export const useMultisig = (wallet: Wallet): MultisigHookData => {
)
try {
if (cancelled) return
// DELETE THIS TRY CATCH ONCE THIS MULTISIG EXISTS EVERYWHERE
const sortedPriceFeedMultisigProposals = await getSortedProposals(
readOnlySquads,
PRICE_FEED_MULTISIG[getMultisigCluster(cluster)]
@ -178,7 +178,14 @@ export const useMultisig = (wallet: Wallet): MultisigHookData => {
if (
isRemoteCluster(cluster) &&
ixs.length > 0 &&
ixs.some((ix) => ix instanceof WormholeMultisigInstruction)
ixs.some(
(ix) =>
ix instanceof WormholeMultisigInstruction &&
ix.governanceAction instanceof ExecutePostedVaa &&
ix.governanceAction.instructions.some((ix) =>
ix.programId.equals(getPythProgramKeyForCluster(cluster))
)
)
) {
proposalsRes.push(sortedPriceFeedMultisigProposals[idx])
instructionsRes.push(ixs)

View File

@ -47,7 +47,17 @@ const CLUSTER_URLS: Record<PythCluster, any> = {
wsUrl: 'wss://api.testnet.solana.com/',
},
],
pythtest: [
'pythtest-conformance': [
{
rpcUrl: 'http://pythtest.xyz.pyth.network',
wsUrl: 'ws://pythtest.xyz.pyth.network',
},
{
rpcUrl: 'https://api.pythtest.pyth.network/',
wsUrl: 'wss://api.pythtest.pyth.network/',
},
],
'pythtest-crosschain': [
{
rpcUrl: 'http://pythtest.xyz.pyth.network',
wsUrl: 'ws://pythtest.xyz.pyth.network',

44
package-lock.json generated
View File

@ -1384,7 +1384,7 @@
"license": "ISC",
"dependencies": {
"@certusone/wormhole-sdk": "^0.9.8",
"@pythnetwork/client": "^2.10.0",
"@pythnetwork/client": "^2.16.0",
"@solana/buffer-layout": "^4.0.1",
"@solana/web3.js": "^1.73.0",
"@sqds/mesh": "^1.0.6",
@ -11193,17 +11193,33 @@
"integrity": "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw=="
},
"node_modules/@pythnetwork/client": {
"version": "2.15.0",
"resolved": "https://registry.npmjs.org/@pythnetwork/client/-/client-2.15.0.tgz",
"integrity": "sha512-PTFI0ZWqbDiuiiB2Xx76ZU9PItHPIIQzsEqpbs0N9aumIeVXh6A1m/oZTZ7pRcG4jA9wROmA+GaYQU8UHzpjWA==",
"version": "2.16.0",
"resolved": "https://registry.npmjs.org/@pythnetwork/client/-/client-2.16.0.tgz",
"integrity": "sha512-56mNi40k8NPWO5w9v8AcMH7R5tOq/pusGDwUbde9WVEV9Jr3Yuob06mywpjOPzVps8kyL18o45pipzoJbZhsZw==",
"dependencies": {
"@coral-xyz/anchor": "^0.26.0",
"@coral-xyz/borsh": "^0.26.0",
"buffer": "^6.0.1"
},
"peerDependencies": {
"@solana/web3.js": "^1.30.2"
}
},
"node_modules/@pythnetwork/client/node_modules/@coral-xyz/borsh": {
"version": "0.26.0",
"resolved": "https://registry.npmjs.org/@coral-xyz/borsh/-/borsh-0.26.0.tgz",
"integrity": "sha512-uCZ0xus0CszQPHYfWAqKS5swS1UxvePu83oOF+TWpUkedsNlg6p2p4azxZNSSqwXb9uXMFgxhuMBX9r3Xoi0vQ==",
"dependencies": {
"bn.js": "^5.1.2",
"buffer-layout": "^1.2.0"
},
"engines": {
"node": ">=10"
},
"peerDependencies": {
"@solana/web3.js": "^1.68.0"
}
},
"node_modules/@pythnetwork/client/node_modules/buffer": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
@ -49988,7 +50004,7 @@
},
"target_chains/ethereum/sdk/js": {
"name": "@pythnetwork/pyth-evm-js",
"version": "1.13.0",
"version": "1.14.0",
"license": "Apache-2.0",
"dependencies": {
"@pythnetwork/price-service-client": "*",
@ -57892,14 +57908,24 @@
"integrity": "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw=="
},
"@pythnetwork/client": {
"version": "2.15.0",
"resolved": "https://registry.npmjs.org/@pythnetwork/client/-/client-2.15.0.tgz",
"integrity": "sha512-PTFI0ZWqbDiuiiB2Xx76ZU9PItHPIIQzsEqpbs0N9aumIeVXh6A1m/oZTZ7pRcG4jA9wROmA+GaYQU8UHzpjWA==",
"version": "2.16.0",
"resolved": "https://registry.npmjs.org/@pythnetwork/client/-/client-2.16.0.tgz",
"integrity": "sha512-56mNi40k8NPWO5w9v8AcMH7R5tOq/pusGDwUbde9WVEV9Jr3Yuob06mywpjOPzVps8kyL18o45pipzoJbZhsZw==",
"requires": {
"@coral-xyz/anchor": "^0.26.0",
"@coral-xyz/borsh": "^0.26.0",
"buffer": "^6.0.1"
},
"dependencies": {
"@coral-xyz/borsh": {
"version": "0.26.0",
"resolved": "https://registry.npmjs.org/@coral-xyz/borsh/-/borsh-0.26.0.tgz",
"integrity": "sha512-uCZ0xus0CszQPHYfWAqKS5swS1UxvePu83oOF+TWpUkedsNlg6p2p4azxZNSSqwXb9uXMFgxhuMBX9r3Xoi0vQ==",
"requires": {
"bn.js": "^5.1.2",
"buffer-layout": "^1.2.0"
}
},
"buffer": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
@ -91368,7 +91394,7 @@
"version": "file:governance/xc_admin/packages/xc_admin_common",
"requires": {
"@certusone/wormhole-sdk": "^0.9.8",
"@pythnetwork/client": "^2.10.0",
"@pythnetwork/client": "^2.16.0",
"@solana/buffer-layout": "^4.0.1",
"@solana/web3.js": "^1.73.0",
"@sqds/mesh": "^1.0.6",