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
4 changes: 2 additions & 2 deletions contract_manager/scripts/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { existsSync, readFileSync, writeFileSync } from "node:fs";
import path from "node:path";

import Web3 from "web3";
import { Contract } from "web3-eth-contract";
import type { Contract } from "web3-eth-contract";
import type { InferredOptionType } from "yargs";

import type { PrivateKey } from "../src/core/base";
Expand Down Expand Up @@ -175,7 +175,7 @@ export const COMMON_UPGRADE_OPTIONS = {
},
"std-output": {
type: "string",
demandOption: true,
demandOption: false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

why did you change this and added a check in another place?

Copy link
Contributor

Choose a reason for hiding this comment

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

plus 1 to this question. Yargs handles this for you. It also provides you a way to customize the error message if the argument is not provided

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't need "std-output" in the upgrade_evm_lazer script.

desc: "Path to the standard JSON output of the pyth contract (build artifact)",
},
} as const;
Expand Down
3 changes: 3 additions & 0 deletions contract_manager/scripts/upgrade_evm_entropy_contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ function registry(cluster: PythCluster): string {

async function main() {
const argv = await parser.argv;
if (!argv["std-output"]) {
throw new Error("std-output is required");
}
const cacheFile =
argv["contract-type"] === "executor"
? EXECUTOR_CACHE_FILE
Expand Down
4 changes: 3 additions & 1 deletion contract_manager/scripts/upgrade_evm_lazer_contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ async function main() {
const payloads: Buffer[] = [];
const failures: string[] = [];
for (const contract of Object.values(DefaultStore.lazer_contracts)) {
if (selectedChains.includes(contract.chain)) {
if (
selectedChains.some((chain) => chain.getId() === contract.chain.getId())
) {
console.log("Deploying implementation to", contract.chain.getId());
try {
const address = await runIfNotCached(
Expand Down
27 changes: 17 additions & 10 deletions contract_manager/src/node/utils/governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
deriveWormholeBridgeDataKey,
} from "@certusone/wormhole-sdk/lib/cjs/solana/wormhole/index.js";
import { AnchorProvider, Wallet } from "@coral-xyz/anchor";
import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet.js";
import type { PythCluster } from "@pythnetwork/client";
import { getPythClusterApiUrl } from "@pythnetwork/client";
import type { PriorityFeeConfig } from "@pythnetwork/solana-utils";
Expand All @@ -35,7 +34,7 @@ import {
SYSVAR_RENT_PUBKEY,
Transaction,
} from "@solana/web3.js";
import SquadsMesh from "@sqds/mesh";
import SquadsMeshClass from "@sqds/mesh";
import * as bs58 from "bs58";

import type { KeyValueConfig } from "../../core/base.js";
Expand Down Expand Up @@ -231,7 +230,7 @@ export class WormholeEmitter {
export class WormholeMultisigProposal {
constructor(
public address: PublicKey,
public squad: SquadsMesh,
public squad: SquadsMeshInstance,
public cluster: PythCluster,
) {}

Expand Down Expand Up @@ -267,7 +266,7 @@ export class WormholeMultisigProposal {
this.cluster,
),
);
} catch (error) {
} catch (error: unknown) {
if (!(error instanceof InvalidTransactionError)) throw error;
}
}
Expand All @@ -280,10 +279,16 @@ export class WormholeMultisigProposal {
* A vault represents a pyth multisig governance realm which exists in solana mainnet or testnet.
* It can be used for proposals to send wormhole messages to the wormhole bridge.
*/
type SquadsMeshInstance = InstanceType<typeof SquadsMeshClass>;

function getSquadsMesh() {
return SquadsMeshClass;
}

export class Vault extends Storable {
static type = "vault";
key: PublicKey;
squad?: SquadsMesh;
squad?: SquadsMeshInstance;
cluster: PythCluster;

constructor(key: string, cluster: string) {
Expand Down Expand Up @@ -327,10 +332,11 @@ export class Vault extends Storable {
wallet: Wallet,
registry: SolanaRpcRegistry = getPythClusterApiUrl,
): void {
this.squad = SquadsMesh.endpoint(registry(this.cluster), wallet);
const mesh = getSquadsMesh();
this.squad = mesh.endpoint(registry(this.cluster), wallet);
}

getSquadOrThrow(): SquadsMesh {
getSquadOrThrow(): SquadsMeshInstance {
if (!this.squad) throw new Error("Please connect a wallet to the vault");
return this.squad;
}
Expand All @@ -341,9 +347,10 @@ export class Vault extends Storable {
*/
// eslint-disable-next-line @typescript-eslint/require-await
public async getEmitter(registry: SolanaRpcRegistry = getPythClusterApiUrl) {
const squad = SquadsMesh.endpoint(
const mesh = getSquadsMesh();
const squad = mesh.endpoint(
registry(this.cluster),
new NodeWallet(Keypair.generate()), // dummy wallet
new Wallet(Keypair.generate()), // dummy wallet
);
return squad.getAuthorityPDA(this.key, 1);
}
Expand Down Expand Up @@ -401,7 +408,7 @@ export class Vault extends Storable {
*/
// eslint-disable-next-line @typescript-eslint/require-await
export async function loadHotWallet(walletPath: string): Promise<Wallet> {
return new NodeWallet(
return new Wallet(
Keypair.fromSecretKey(
Uint8Array.from(JSON.parse(readFileSync(walletPath, "ascii"))),
),
Expand Down
Loading