Skip to content

Commit 2bfbfed

Browse files
authored
feat(xc-admin): add support for setMaxLatency instruction (#1328)
* Remove Substack link from SocialLinks component * Update copyright year in Footer component * fix useEffect dep * add support for maxLatency * update wallet interface * fix * fix * revert import format * fix * fix * fix * fix * update anchor to 0.29.0 * remove unneeded casts
1 parent 98f83ef commit 2bfbfed

File tree

17 files changed

+158
-300
lines changed

17 files changed

+158
-300
lines changed

contract_manager/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"url": "git+https://github.com/pyth-network/pyth-crosschain.git"
2222
},
2323
"dependencies": {
24+
"@coral-xyz/anchor": "^0.29.0",
2425
"@certusone/wormhole-sdk": "^0.9.8",
2526
"@injectivelabs/networks": "1.0.68",
2627
"@mysten/sui.js": "^0.49.1",

contract_manager/src/governance.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import {
1717
PythCluster,
1818
} from "@pythnetwork/client/lib/cluster";
1919
import SquadsMesh from "@sqds/mesh";
20-
import { AnchorProvider, Wallet } from "@coral-xyz/anchor/dist/cjs/provider";
20+
import { AnchorProvider } from "@coral-xyz/anchor";
21+
import { Wallet } from "@coral-xyz/anchor/dist/cjs/provider";
2122
import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet";
2223
import {
2324
executeProposal,
@@ -344,7 +345,7 @@ export class Vault extends Storable {
344345
): Promise<WormholeMultisigProposal> {
345346
const squad = this.getSquadOrThrow();
346347
const multisigVault = new MultisigVault(
347-
squad.wallet,
348+
squad.wallet as Wallet,
348349
this.cluster,
349350
squad,
350351
this.key

governance/xc_admin/packages/crank_executor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
},
2121
"dependencies": {
2222
"@certusone/wormhole-sdk": "^0.9.9",
23-
"@coral-xyz/anchor": "^0.26.0",
23+
"@coral-xyz/anchor": "^0.29.0",
2424
"@pythnetwork/client": "^2.9.0",
2525
"@solana/web3.js": "^1.73.0",
2626
"@sqds/mesh": "^1.0.6",

governance/xc_admin/packages/crank_pythnet_relayer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
},
2121
"dependencies": {
2222
"@certusone/wormhole-sdk": "^0.9.9",
23-
"@coral-xyz/anchor": "^0.26.0",
23+
"@coral-xyz/anchor": "^0.29.0",
2424
"@pythnetwork/client": "^2.9.0",
2525
"@solana/web3.js": "^1.73.0",
2626
"@sqds/mesh": "^1.0.6",

governance/xc_admin/packages/proposer_server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"format": "prettier --write \"src/**/*.ts\""
2020
},
2121
"dependencies": {
22-
"@coral-xyz/anchor": "^0.27.0",
22+
"@coral-xyz/anchor": "^0.29.0",
2323
"@pythnetwork/client": "^2.17.0",
2424
"@solana/web3.js": "^1.76.0",
2525
"@sqds/mesh": "^1.0.6",

governance/xc_admin/packages/xc_admin_cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"cli": "npm run build && node lib/cli.js"
2121
},
2222
"dependencies": {
23-
"@coral-xyz/anchor": "^0.26.0",
23+
"@coral-xyz/anchor": "^0.29.0",
2424
"@ledgerhq/hw-transport": "^6.27.10",
2525
"@ledgerhq/hw-transport-node-hid": "^6.27.10",
2626
"@pythnetwork/client": "^2.9.0",

governance/xc_admin/packages/xc_admin_cli/src/index.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1+
import { Program } from "@coral-xyz/anchor";
2+
import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet";
3+
import { Wallet } from "@coral-xyz/anchor/dist/cjs/provider";
4+
import { TOKEN_PROGRAM_ID } from "@coral-xyz/anchor/dist/cjs/utils/token";
5+
import { pythOracleProgram } from "@pythnetwork/client";
6+
import {
7+
PythCluster,
8+
getPythClusterApiUrl,
9+
getPythProgramKeyForCluster,
10+
} from "@pythnetwork/client/lib/cluster";
11+
import {
12+
createTransferInstruction,
13+
getAssociatedTokenAddress,
14+
getMint,
15+
} from "@solana/spl-token";
116
import {
17+
AccountMeta,
18+
Connection,
219
Keypair,
20+
LAMPORTS_PER_SOL,
321
PublicKey,
4-
TransactionInstruction,
5-
SYSVAR_RENT_PUBKEY,
622
SYSVAR_CLOCK_PUBKEY,
7-
AccountMeta,
23+
SYSVAR_RENT_PUBKEY,
824
StakeProgram,
925
SystemProgram,
10-
LAMPORTS_PER_SOL,
11-
Connection,
26+
TransactionInstruction,
1227
} from "@solana/web3.js";
28+
import SquadsMesh from "@sqds/mesh";
1329
import { program } from "commander";
14-
import {
15-
getPythProgramKeyForCluster,
16-
PythCluster,
17-
} from "@pythnetwork/client/lib/cluster";
18-
import { getPythClusterApiUrl } from "@pythnetwork/client/lib/cluster";
19-
import { AnchorProvider, Program } from "@coral-xyz/anchor";
2030
import fs from "fs";
21-
import SquadsMesh from "@sqds/mesh";
22-
import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet";
2331
import {
2432
BPF_UPGRADABLE_LOADER,
25-
getMultisigCluster,
26-
getProposalInstructions,
2733
MultisigParser,
28-
PROGRAM_AUTHORITY_ESCROW,
2934
MultisigVault,
35+
PROGRAM_AUTHORITY_ESCROW,
36+
getMultisigCluster,
37+
getProposalInstructions,
3038
} from "xc_admin_common";
31-
import { pythOracleProgram } from "@pythnetwork/client";
32-
import { Wallet } from "@coral-xyz/anchor/dist/cjs/provider";
3339
import { LedgerNodeWallet } from "./ledger";
34-
import {
35-
createTransferInstruction,
36-
getAssociatedTokenAddress,
37-
getMint,
38-
} from "@solana/spl-token";
39-
import { TOKEN_PROGRAM_ID } from "@coral-xyz/anchor/dist/cjs/utils/token";
4040

4141
export async function loadHotWalletOrLedger(
4242
wallet: string,

governance/xc_admin/packages/xc_admin_cli/src/ledger.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Transport, {
44
TransportStatusError,
55
} from "@ledgerhq/hw-transport";
66
import TransportNodeHid from "@ledgerhq/hw-transport-node-hid";
7-
import { PublicKey, Transaction } from "@solana/web3.js";
7+
import { PublicKey, Transaction, VersionedTransaction } from "@solana/web3.js";
88

99
export class LedgerNodeWallet implements Wallet {
1010
private _derivationPath: Buffer;
@@ -35,21 +35,30 @@ export class LedgerNodeWallet implements Wallet {
3535
return new LedgerNodeWallet(derivationPath, transport, publicKey);
3636
}
3737

38-
async signTransaction(transaction: Transaction): Promise<Transaction> {
38+
async signTransaction<T extends Transaction | VersionedTransaction>(
39+
tx: T
40+
): Promise<T> {
3941
console.log("Please approve the transaction on your ledger device...");
4042
const transport = this._transport;
4143
const publicKey = this.publicKey;
4244

43-
const signature = await signTransaction(
44-
transport,
45-
transaction,
46-
this._derivationPath
47-
);
48-
transaction.addSignature(publicKey, signature);
49-
return transaction;
45+
if (tx instanceof Transaction) {
46+
const signature = await signTransaction(
47+
transport,
48+
tx,
49+
this._derivationPath
50+
);
51+
tx.addSignature(publicKey, signature);
52+
} else {
53+
// Handle VersionedTransaction if necessary
54+
throw new Error("VersionedTransaction is not supported yet.");
55+
}
56+
return tx;
5057
}
5158

52-
async signAllTransactions(txs: Transaction[]): Promise<Transaction[]> {
59+
async signAllTransactions<T extends Transaction | VersionedTransaction>(
60+
txs: T[]
61+
): Promise<T[]> {
5362
return await Promise.all(txs.map((tx) => this.signTransaction(tx)));
5463
}
5564
}

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.22",
24-
"@coral-xyz/anchor": "^0.26.0",
24+
"@coral-xyz/anchor": "^0.29.0",
2525
"@pythnetwork/client": "^2.17.0",
2626
"@solana/buffer-layout": "^4.0.1",
2727
"@solana/web3.js": "^1.73.0",

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ export class MultisigVault {
106106
opts = AnchorProvider.defaultOptions();
107107
}
108108

109-
return new AnchorProvider(this.squad.connection, this.squad.wallet, opts);
109+
return new AnchorProvider(
110+
this.squad.connection,
111+
this.squad.wallet as Wallet,
112+
opts
113+
);
110114
}
111115

112116
// Convenience wrappers around squads methods
@@ -515,7 +519,7 @@ async function getPostMessageInstruction(
515519
const emitter = squad.getAuthorityPDA(vault, 1);
516520
const provider = new AnchorProvider(
517521
squad.connection,
518-
squad.wallet,
522+
squad.wallet as Wallet,
519523
AnchorProvider.defaultOptions()
520524
);
521525
const wormholeProgram = createWormholeProgramInterface(

0 commit comments

Comments
 (0)