Skip to content

Commit 7973320

Browse files
committed
fix(lazer) Lazer upgrade contracts script fix
1 parent b8a45a8 commit 7973320

File tree

4 files changed

+27
-12
lines changed

4 files changed

+27
-12
lines changed

contract_manager/scripts/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export const COMMON_UPGRADE_OPTIONS = {
175175
},
176176
"std-output": {
177177
type: "string",
178-
demandOption: true,
178+
demandOption: false,
179179
desc: "Path to the standard JSON output of the pyth contract (build artifact)",
180180
},
181181
} as const;

contract_manager/scripts/upgrade_evm_entropy_contracts.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ function registry(cluster: PythCluster): string {
5050

5151
async function main() {
5252
const argv = await parser.argv;
53+
if (!argv["std-output"]) {
54+
throw new Error("std-output is required");
55+
}
5356
const cacheFile =
5457
argv["contract-type"] === "executor"
5558
? EXECUTOR_CACHE_FILE

contract_manager/scripts/upgrade_evm_lazer_contracts.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ async function main() {
141141
const payloads: Buffer[] = [];
142142
const failures: string[] = [];
143143
for (const contract of Object.values(DefaultStore.lazer_contracts)) {
144-
if (selectedChains.includes(contract.chain)) {
144+
if (
145+
selectedChains.some((chain) => chain.getId() === contract.chain.getId())
146+
) {
145147
console.log("Deploying implementation to", contract.chain.getId());
146148
try {
147149
const address = await runIfNotCached(

contract_manager/src/node/utils/governance.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
deriveWormholeBridgeDataKey,
1313
} from "@certusone/wormhole-sdk/lib/cjs/solana/wormhole/index.js";
1414
import { AnchorProvider, Wallet } from "@coral-xyz/anchor";
15-
import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet.js";
1615
import type { PythCluster } from "@pythnetwork/client";
1716
import { getPythClusterApiUrl } from "@pythnetwork/client";
1817
import type { PriorityFeeConfig } from "@pythnetwork/solana-utils";
@@ -35,7 +34,7 @@ import {
3534
SYSVAR_RENT_PUBKEY,
3635
Transaction,
3736
} from "@solana/web3.js";
38-
import SquadsMesh from "@sqds/mesh";
37+
import SquadsMeshModule from "@sqds/mesh";
3938
import * as bs58 from "bs58";
4039

4140
import type { KeyValueConfig } from "../../core/base.js";
@@ -231,7 +230,7 @@ export class WormholeEmitter {
231230
export class WormholeMultisigProposal {
232231
constructor(
233232
public address: PublicKey,
234-
public squad: SquadsMesh,
233+
public squad: SquadsMeshInstance,
235234
public cluster: PythCluster,
236235
) {}
237236

@@ -267,7 +266,7 @@ export class WormholeMultisigProposal {
267266
this.cluster,
268267
),
269268
);
270-
} catch (error) {
269+
} catch (error: unknown) {
271270
if (!(error instanceof InvalidTransactionError)) throw error;
272271
}
273272
}
@@ -280,10 +279,19 @@ export class WormholeMultisigProposal {
280279
* A vault represents a pyth multisig governance realm which exists in solana mainnet or testnet.
281280
* It can be used for proposals to send wormhole messages to the wormhole bridge.
282281
*/
282+
type SquadsMeshClass = typeof SquadsMeshModule;
283+
type SquadsMeshInstance = InstanceType<SquadsMeshClass>;
284+
285+
function getSquadsMesh(): SquadsMeshClass {
286+
const mod = SquadsMeshModule as { default?: SquadsMeshClass };
287+
if (mod.default) return mod.default;
288+
return SquadsMeshModule;
289+
}
290+
283291
export class Vault extends Storable {
284292
static type = "vault";
285293
key: PublicKey;
286-
squad?: SquadsMesh;
294+
squad?: SquadsMeshInstance;
287295
cluster: PythCluster;
288296

289297
constructor(key: string, cluster: string) {
@@ -327,10 +335,11 @@ export class Vault extends Storable {
327335
wallet: Wallet,
328336
registry: SolanaRpcRegistry = getPythClusterApiUrl,
329337
): void {
330-
this.squad = SquadsMesh.endpoint(registry(this.cluster), wallet);
338+
const mesh = getSquadsMesh();
339+
this.squad = mesh.endpoint(registry(this.cluster), wallet);
331340
}
332341

333-
getSquadOrThrow(): SquadsMesh {
342+
getSquadOrThrow(): SquadsMeshInstance {
334343
if (!this.squad) throw new Error("Please connect a wallet to the vault");
335344
return this.squad;
336345
}
@@ -341,9 +350,10 @@ export class Vault extends Storable {
341350
*/
342351
// eslint-disable-next-line @typescript-eslint/require-await
343352
public async getEmitter(registry: SolanaRpcRegistry = getPythClusterApiUrl) {
344-
const squad = SquadsMesh.endpoint(
353+
const mesh = getSquadsMesh();
354+
const squad = mesh.endpoint(
345355
registry(this.cluster),
346-
new NodeWallet(Keypair.generate()), // dummy wallet
356+
new Wallet(Keypair.generate()), // dummy wallet
347357
);
348358
return squad.getAuthorityPDA(this.key, 1);
349359
}
@@ -401,7 +411,7 @@ export class Vault extends Storable {
401411
*/
402412
// eslint-disable-next-line @typescript-eslint/require-await
403413
export async function loadHotWallet(walletPath: string): Promise<Wallet> {
404-
return new NodeWallet(
414+
return new Wallet(
405415
Keypair.fromSecretKey(
406416
Uint8Array.from(JSON.parse(readFileSync(walletPath, "ascii"))),
407417
),

0 commit comments

Comments
 (0)