[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 npm install
npx lerna run build --scope "xc_admin_common" 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": { "dependencies": {
"@certusone/wormhole-sdk": "^0.9.8", "@certusone/wormhole-sdk": "^0.9.8",
"@pythnetwork/client": "^2.10.0", "@pythnetwork/client": "^2.16.0",
"@solana/buffer-layout": "^4.0.1", "@solana/buffer-layout": "^4.0.1",
"@solana/web3.js": "^1.73.0", "@solana/web3.js": "^1.73.0",
"@sqds/mesh": "^1.0.6", "@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. * Return whether the cluster is governed remotely or not. For example Pythnet is governed remotely by a mainnet multisig.
*/ */
export function isRemoteCluster(cluster: PythCluster) { 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) { switch (cluster) {
case "pythnet": case "pythnet":
return "mainnet-beta"; return "mainnet-beta";
case "pythtest": case "pythtest-conformance":
return "devnet";
case "pythtest-crosschain":
return "devnet"; return "devnet";
default: default:
return cluster; 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> = { export const WORMHOLE_ADDRESS: Record<PythCluster, PublicKey | undefined> = {
"mainnet-beta": new PublicKey("worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth"), "mainnet-beta": new PublicKey("worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth"),
pythtest: new PublicKey("EUrRARh92Cdc54xrDn6qzaqjA77NRrCcfbr8kPwoTL4z"), "pythtest-conformance": new PublicKey(
"EUrRARh92Cdc54xrDn6qzaqjA77NRrCcfbr8kPwoTL4z"
),
"pythtest-crosschain": new PublicKey(
"EUrRARh92Cdc54xrDn6qzaqjA77NRrCcfbr8kPwoTL4z"
),
devnet: new PublicKey("3u8hJUVTA4jH1wYAyUur7FFZVQ8H635K3tSHHF4ssjQ5"), devnet: new PublicKey("3u8hJUVTA4jH1wYAyUur7FFZVQ8H635K3tSHHF4ssjQ5"),
pythnet: new PublicKey("H3fxXJ86ADW2PNuDDmZJg6mzTtPxkYCpNuQUTgmJ7AjU"), pythnet: new PublicKey("H3fxXJ86ADW2PNuDDmZJg6mzTtPxkYCpNuQUTgmJ7AjU"),
localnet: new PublicKey("Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o"), localnet: new PublicKey("Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o"),
@ -13,7 +18,8 @@ export const WORMHOLE_ADDRESS: Record<PythCluster, PublicKey | undefined> = {
// Source : https://book.wormhole.com/reference/rpcnodes.html // Source : https://book.wormhole.com/reference/rpcnodes.html
export const WORMHOLE_API_ENDPOINT: Record<PythCluster, string | undefined> = { export const WORMHOLE_API_ENDPOINT: Record<PythCluster, string | undefined> = {
"mainnet-beta": "https://wormhole-v2-mainnet-api.certus.one", "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", devnet: "https://wormhole-v2-testnet-api.certus.one",
pythnet: "https://wormhole-v2-mainnet-api.certus.one", pythnet: "https://wormhole-v2-mainnet-api.certus.one",
localnet: undefined, localnet: undefined,

View File

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

View File

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

View File

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

View File

@ -47,7 +47,17 @@ const CLUSTER_URLS: Record<PythCluster, any> = {
wsUrl: 'wss://api.testnet.solana.com/', 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', rpcUrl: 'http://pythtest.xyz.pyth.network',
wsUrl: 'ws://pythtest.xyz.pyth.network', wsUrl: 'ws://pythtest.xyz.pyth.network',

44
package-lock.json generated
View File

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