Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contract_manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"url": "git+https://github.com/pyth-network/pyth-crosschain.git"
},
"dependencies": {
"@coral-xyz/anchor": "^0.29.0",
"@certusone/wormhole-sdk": "^0.9.8",
"@injectivelabs/networks": "1.0.68",
"@mysten/sui.js": "^0.37.1",
Expand Down
5 changes: 3 additions & 2 deletions contract_manager/src/governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import {
PythCluster,
} from "@pythnetwork/client/lib/cluster";
import SquadsMesh from "@sqds/mesh";
import { AnchorProvider, Wallet } from "@coral-xyz/anchor/dist/cjs/provider";
import { AnchorProvider } from "@coral-xyz/anchor";
import { Wallet } from "@coral-xyz/anchor/dist/cjs/provider";
import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet";
import {
executeProposal,
Expand Down Expand Up @@ -344,7 +345,7 @@ export class Vault extends Storable {
): Promise<WormholeMultisigProposal> {
const squad = this.getSquadOrThrow();
const multisigVault = new MultisigVault(
squad.wallet,
squad.wallet as Wallet,
this.cluster,
squad,
this.key
Expand Down
2 changes: 1 addition & 1 deletion governance/xc_admin/packages/crank_executor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"dependencies": {
"@certusone/wormhole-sdk": "^0.9.9",
"@coral-xyz/anchor": "^0.26.0",
"@coral-xyz/anchor": "^0.29.0",
"@pythnetwork/client": "^2.9.0",
"@solana/web3.js": "^1.73.0",
"@sqds/mesh": "^1.0.6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"dependencies": {
"@certusone/wormhole-sdk": "^0.9.9",
"@coral-xyz/anchor": "^0.26.0",
"@coral-xyz/anchor": "^0.29.0",
"@pythnetwork/client": "^2.9.0",
"@solana/web3.js": "^1.73.0",
"@sqds/mesh": "^1.0.6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"format": "prettier --write \"src/**/*.ts\""
},
"dependencies": {
"@coral-xyz/anchor": "^0.27.0",
"@coral-xyz/anchor": "^0.29.0",
"@pythnetwork/client": "^2.17.0",
"@solana/web3.js": "^1.76.0",
"@sqds/mesh": "^1.0.6",
Expand Down
2 changes: 1 addition & 1 deletion governance/xc_admin/packages/xc_admin_cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"cli": "npm run build && node lib/cli.js"
},
"dependencies": {
"@coral-xyz/anchor": "^0.26.0",
"@coral-xyz/anchor": "^0.29.0",
"@ledgerhq/hw-transport": "^6.27.10",
"@ledgerhq/hw-transport-node-hid": "^6.27.10",
"@pythnetwork/client": "^2.9.0",
Expand Down
48 changes: 24 additions & 24 deletions governance/xc_admin/packages/xc_admin_cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
import { Program } from "@coral-xyz/anchor";
import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet";
import { Wallet } from "@coral-xyz/anchor/dist/cjs/provider";
import { TOKEN_PROGRAM_ID } from "@coral-xyz/anchor/dist/cjs/utils/token";
import { pythOracleProgram } from "@pythnetwork/client";
import {
PythCluster,
getPythClusterApiUrl,
getPythProgramKeyForCluster,
} from "@pythnetwork/client/lib/cluster";
import {
createTransferInstruction,
getAssociatedTokenAddress,
getMint,
} from "@solana/spl-token";
import {
AccountMeta,
Connection,
Keypair,
LAMPORTS_PER_SOL,
PublicKey,
TransactionInstruction,
SYSVAR_RENT_PUBKEY,
SYSVAR_CLOCK_PUBKEY,
AccountMeta,
SYSVAR_RENT_PUBKEY,
StakeProgram,
SystemProgram,
LAMPORTS_PER_SOL,
Connection,
TransactionInstruction,
} from "@solana/web3.js";
import SquadsMesh from "@sqds/mesh";
import { program } from "commander";
import {
getPythProgramKeyForCluster,
PythCluster,
} from "@pythnetwork/client/lib/cluster";
import { getPythClusterApiUrl } from "@pythnetwork/client/lib/cluster";
import { AnchorProvider, Program } from "@coral-xyz/anchor";
import fs from "fs";
import SquadsMesh from "@sqds/mesh";
import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet";
import {
BPF_UPGRADABLE_LOADER,
getMultisigCluster,
getProposalInstructions,
MultisigParser,
PROGRAM_AUTHORITY_ESCROW,
MultisigVault,
PROGRAM_AUTHORITY_ESCROW,
getMultisigCluster,
getProposalInstructions,
} from "xc_admin_common";
import { pythOracleProgram } from "@pythnetwork/client";
import { Wallet } from "@coral-xyz/anchor/dist/cjs/provider";
import { LedgerNodeWallet } from "./ledger";
import {
createTransferInstruction,
getAssociatedTokenAddress,
getMint,
} from "@solana/spl-token";
import { TOKEN_PROGRAM_ID } from "@coral-xyz/anchor/dist/cjs/utils/token";

export async function loadHotWalletOrLedger(
wallet: string,
Expand Down
29 changes: 19 additions & 10 deletions governance/xc_admin/packages/xc_admin_cli/src/ledger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Transport, {
TransportStatusError,
} from "@ledgerhq/hw-transport";
import TransportNodeHid from "@ledgerhq/hw-transport-node-hid";
import { PublicKey, Transaction } from "@solana/web3.js";
import { PublicKey, Transaction, VersionedTransaction } from "@solana/web3.js";

export class LedgerNodeWallet implements Wallet {
private _derivationPath: Buffer;
Expand Down Expand Up @@ -35,21 +35,30 @@ export class LedgerNodeWallet implements Wallet {
return new LedgerNodeWallet(derivationPath, transport, publicKey);
}

async signTransaction(transaction: Transaction): Promise<Transaction> {
async signTransaction<T extends Transaction | VersionedTransaction>(
tx: T
): Promise<T> {
console.log("Please approve the transaction on your ledger device...");
const transport = this._transport;
const publicKey = this.publicKey;

const signature = await signTransaction(
transport,
transaction,
this._derivationPath
);
transaction.addSignature(publicKey, signature);
return transaction;
if (tx instanceof Transaction) {
const signature = await signTransaction(
transport,
tx,
this._derivationPath
);
tx.addSignature(publicKey, signature);
} else {
// Handle VersionedTransaction if necessary
throw new Error("VersionedTransaction is not supported yet.");
}
return tx;
}

async signAllTransactions(txs: Transaction[]): Promise<Transaction[]> {
async signAllTransactions<T extends Transaction | VersionedTransaction>(
txs: T[]
): Promise<T[]> {
return await Promise.all(txs.map((tx) => this.signTransaction(tx)));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"dependencies": {
"@certusone/wormhole-sdk": "^0.9.22",
"@coral-xyz/anchor": "^0.26.0",
"@coral-xyz/anchor": "^0.29.0",
"@pythnetwork/client": "^2.17.0",
"@solana/buffer-layout": "^4.0.1",
"@solana/web3.js": "^1.73.0",
Expand Down
8 changes: 6 additions & 2 deletions governance/xc_admin/packages/xc_admin_common/src/propose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ export class MultisigVault {
opts = AnchorProvider.defaultOptions();
}

return new AnchorProvider(this.squad.connection, this.squad.wallet, opts);
return new AnchorProvider(
this.squad.connection,
this.squad.wallet as Wallet,
opts
);
}

// Convenience wrappers around squads methods
Expand Down Expand Up @@ -515,7 +519,7 @@ async function getPostMessageInstruction(
const emitter = squad.getAuthorityPDA(vault, 1);
const provider = new AnchorProvider(
squad.connection,
squad.wallet,
squad.wallet as Wallet,
AnchorProvider.defaultOptions()
);
const wormholeProgram = createWormholeProgramInterface(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Link from 'next/link'
import Discord from '../../images/icons/discord.inline.svg'
import Github from '../../images/icons/github.inline.svg'
import LinkedIn from '../../images/icons/linkedin.inline.svg'
import Substack from '../../images/icons/substack.inline.svg'
import Telegram from '../../images/icons/telegram.inline.svg'
import Twitter from '../../images/icons/twitter.inline.svg'
import Youtube from '../../images/icons/youtube.inline.svg'
Expand Down Expand Up @@ -35,12 +34,7 @@ const SocialLinks = () => {
<Github />
</a>
</Link>
<Link href="https://pyth.substack.com">
<a target="_blank" className="mr-6">
<Substack />
</a>
</Link>
<Link href="https://www.youtube.com/channel/UCjCkvPN9ohl0UDvldfn1neg">
<Link href="https://www.youtube.com/@pythnetwork">
<a target="_blank" className="">
<Youtube />
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const Footer = () => {
<footer>
<div className="flex flex-col-reverse items-center justify-between px-4 pt-12 pb-4 sm:px-10 lg:flex-row lg:py-6">
<span className="text-[10px] lg:basis-[280px]">
© 2022 Pyth Data Association
© 2024 Pyth Data Association
</span>
<div className="py-10 lg:py-0">
<Link href="https://pyth.network/">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import Modal from '../common/Modal'
import Spinner from '../common/Spinner'
import Loadbar from '../loaders/Loadbar'
import PermissionDepermissionKey from '../PermissionDepermissionKey'
import { PriceRawConfig } from '../../hooks/usePyth'
import { Wallet } from '@coral-xyz/anchor/dist/cjs/provider'

const General = ({ proposerServerUrl }: { proposerServerUrl: string }) => {
const [data, setData] = useState<any>({})
Expand Down Expand Up @@ -126,14 +128,15 @@ const General = ({ proposerServerUrl }: { proposerServerUrl: string }) => {
metadata: {
...product.metadata,
},
priceAccounts: product.priceAccounts.map((p) => {
priceAccounts: product.priceAccounts.map((p: PriceRawConfig) => {
return {
address: p.address.toBase58(),
publishers: p.publishers
.map((p) => p.toBase58())
.slice(0, getMaximumNumberOfPublishers(cluster)),
expo: p.expo,
minPub: p.minPub,
maxLatency: p.maxLatency,
}
}),
}
Expand All @@ -144,7 +147,7 @@ const General = ({ proposerServerUrl }: { proposerServerUrl: string }) => {
setExistingSymbols(new Set(Object.keys(symbolToData)))
setData(sortDataMemo(symbolToData))
}
}, [rawConfig, dataIsLoading, sortDataMemo])
}, [rawConfig, dataIsLoading, sortDataMemo, cluster])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing dependency cluster since it is being used in the useEffect hook

Copy link
Contributor

@guibescos guibescos Feb 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmmm I'm not sure about this, maybe it's fine because changing cluster updates some of the other deps


const sortObjectByKeys = (obj: any) => {
const sortedObj: any = {}
Expand Down Expand Up @@ -367,7 +370,6 @@ const General = ({ proposerServerUrl }: { proposerServerUrl: string }) => {
}

// create add publisher instruction if there are any publishers

for (let publisherKey of newChanges.priceAccounts[0].publishers) {
instructions.push(
await pythProgramClient.methods
Expand Down Expand Up @@ -489,6 +491,26 @@ const General = ({ proposerServerUrl }: { proposerServerUrl: string }) => {
)
}

// check if maxLatency has changed
if (
prev.priceAccounts[0].maxLatency !==
newChanges.priceAccounts[0].maxLatency
) {
// create update product account instruction
instructions.push(
await pythProgramClient.methods
.setMaxLatency(
newChanges.priceAccounts[0].maxLatency,
[0, 0, 0]
)
.accounts({
priceAccount: new PublicKey(prev.priceAccounts[0].address),
fundingAccount,
})
.instruction()
)
}

// check if publishers have changed
const publisherKeysToAdd =
newChanges.priceAccounts[0].publishers.filter(
Expand Down Expand Up @@ -804,7 +826,7 @@ const General = ({ proposerServerUrl }: { proposerServerUrl: string }) => {
if (connected && squads) {
const provider = new AnchorProvider(
connection,
squads.wallet,
squads.wallet as Wallet,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

upgraded @coral-xyz/anchor version and now AnchorProvider requires a slightly different Wallet interface but squads.wallet is still using an old version of @projectserum/anchor package

AnchorProvider.defaultOptions()
)
setPythProgramClient(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
pythOracleProgram,
} from '@pythnetwork/client'
import { PythOracle } from '@pythnetwork/client/lib/anchor'
import { useAnchorWallet, useWallet } from '@solana/wallet-adapter-react'
import { useWallet } from '@solana/wallet-adapter-react'
import { WalletModalButton } from '@solana/wallet-adapter-react-ui'
import { PublicKey } from '@solana/web3.js'
import {
Expand Down Expand Up @@ -35,6 +35,7 @@ import Modal from '../common/Modal'
import Spinner from '../common/Spinner'
import EditButton from '../EditButton'
import Loadbar from '../loaders/Loadbar'
import { Wallet } from '@coral-xyz/anchor/dist/cjs/provider'

interface UpdatePermissionsProps {
account: PermissionAccount
Expand Down Expand Up @@ -267,7 +268,7 @@ const UpdatePermissions = () => {
setIsSendProposalButtonLoading(true)
try {
const vault = new MultisigVault(
squads.wallet,
squads.wallet as Wallet,
getMultisigCluster(cluster),
squads,
UPGRADE_MULTISIG[getMultisigCluster(cluster)]
Expand Down Expand Up @@ -338,7 +339,7 @@ const UpdatePermissions = () => {
if (connected && squads) {
const provider = new AnchorProvider(
connection,
squads.wallet,
squads.wallet as Wallet,
AnchorProvider.defaultOptions()
)
setPythProgramClient(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export type PriceRawConfig = {
address: PublicKey
expo: number
minPub: number
maxLatency: number
publishers: PublicKey[]
}

Expand Down Expand Up @@ -97,6 +98,7 @@ const usePyth = (): PythHookData => {
}),
expo: parsed.exponent,
minPub: parsed.minPublishers,
maxLatency: parsed.maxLatency,
}
allPythAccounts[i] = allPythAccounts[allPythAccounts.length - 1]
allPythAccounts.pop()
Expand Down
4 changes: 2 additions & 2 deletions governance/xc_admin/packages/xc_admin_frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"lint": "next lint"
},
"dependencies": {
"@coral-xyz/anchor": "^0.26.0",
"@coral-xyz/anchor": "^0.29.0",
"@headlessui/react": "^1.7.7",
"@pythnetwork/client": "^2.15.0",
"@pythnetwork/client": "^2.21.0",
"@radix-ui/react-label": "^2.0.0",
"@radix-ui/react-tooltip": "^1.0.3",
"@solana/spl-token": "^0.3.7",
Expand Down
Loading