Skip to content

Commit afa3477

Browse files
committed
fix(xc-admin-cli): fixed build
1 parent 05959a0 commit afa3477

File tree

4 files changed

+53
-32
lines changed

4 files changed

+53
-32
lines changed

governance/xc_admin/packages/xc_admin_cli/package.json

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"author": "",
77
"homepage": "https://github.com/pyth-network/pyth-crosschain",
88
"license": "ISC",
9-
"main": "src/index.ts",
9+
"main": "./dist/index.js",
10+
"type": "module",
1011
"repository": {
1112
"type": "git",
1213
"url": "git+https://github.com/pyth-network/pyth-crosschain.git"
@@ -42,5 +43,17 @@
4243
"node": ">=22.16.0",
4344
"pnpm": ">=10.19.0"
4445
},
45-
"packageManager": "[email protected]"
46+
"packageManager": "[email protected]",
47+
"exports": {
48+
".": {
49+
"default": "./dist/index.js",
50+
"types": "./dist/index.d.ts"
51+
},
52+
"./ledger": {
53+
"default": "./dist/ledger.js",
54+
"types": "./dist/ledger.d.ts"
55+
},
56+
"./package.json": "./package.json"
57+
},
58+
"types": "./dist/index.d.ts"
4659
}

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

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
import { Program, BN, Idl } from "@coral-xyz/anchor";
1+
import { Program, BN, type Idl } from "@coral-xyz/anchor";
22
import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet";
3-
import { Wallet } from "@coral-xyz/anchor/dist/cjs/provider";
3+
import type { Wallet } from "@coral-xyz/anchor/dist/cjs/provider";
44
import { TOKEN_PROGRAM_ID } from "@coral-xyz/anchor/dist/cjs/utils/token";
55
import {
66
pythOracleProgram,
7-
PythHttpClient,
87
parseBaseData,
98
AccountType,
109
parsePriceData,
1110
} from "@pythnetwork/client";
1211
import {
13-
PythCluster,
12+
type PythCluster,
1413
getPythClusterApiUrl,
1514
getPythProgramKeyForCluster,
1615
} from "@pythnetwork/client/lib/cluster";
@@ -20,7 +19,7 @@ import {
2019
getMint,
2120
} from "@solana/spl-token";
2221
import {
23-
AccountMeta,
22+
type AccountMeta,
2423
Connection,
2524
Keypair,
2625
LAMPORTS_PER_SOL,
@@ -65,7 +64,6 @@ import {
6564
DEFAULT_PRIORITY_FEE_CONFIG,
6665
TransactionBuilder,
6766
} from "@pythnetwork/solana-utils";
68-
import { bs58 } from "@coral-xyz/anchor/dist/cjs/utils/bytes";
6967

7068
export async function loadHotWalletOrLedger(
7169
wallet: string,
@@ -170,7 +168,7 @@ multisigCommand(
170168
)[0];
171169

172170
const proposalInstruction = await programAuthorityEscrow.methods
173-
.accept()
171+
.accept?.()
174172
.accounts({
175173
currentAuthority: current,
176174
newAuthority: await vault.getVaultAuthorityPDA(targetCluster),
@@ -180,11 +178,13 @@ multisigCommand(
180178
})
181179
.instruction();
182180

183-
await vault.proposeInstructions(
184-
[proposalInstruction],
185-
targetCluster,
186-
DEFAULT_PRIORITY_FEE_CONFIG,
187-
);
181+
if (proposalInstruction) {
182+
await vault.proposeInstructions(
183+
[proposalInstruction],
184+
targetCluster,
185+
DEFAULT_PRIORITY_FEE_CONFIG,
186+
);
187+
}
188188
});
189189

190190
multisigCommand(
@@ -423,7 +423,7 @@ multisigCommand(
423423
.map((stakeAccounts, index) => {
424424
if (stakeAccounts.length === 0) {
425425
console.log(
426-
`Skipping vote account ${voteAccounts[index].toBase58()} - no stake accounts found`,
426+
`Skipping vote account ${voteAccounts[index]?.toBase58()} - no stake accounts found`,
427427
);
428428
}
429429
return stakeAccounts;
@@ -444,7 +444,7 @@ multisigCommand(
444444

445445
console.log(
446446
"Successfully proposed at: https://proposals.pyth.network/?tab=proposals&proposal=" +
447-
proposalAddresses[0].toBase58(),
447+
proposalAddresses[0]?.toBase58(),
448448
);
449449
});
450450

@@ -551,7 +551,7 @@ multisigCommand(
551551
stakePubkey,
552552
authorizedPubkey,
553553
votePubkey,
554-
}).instructions[0],
554+
}).instructions[0]!,
555555
);
556556
}
557557

@@ -564,7 +564,7 @@ multisigCommand(
564564
// This should be a single proposal normally
565565
console.log(
566566
"Successfully proposed at: https://proposals.pyth.network/?tab=proposals&proposal=" +
567-
proposalAddresses[0].toBase58(),
567+
proposalAddresses[0]?.toBase58(),
568568
);
569569
});
570570

@@ -750,7 +750,7 @@ program
750750
console.log(
751751
JSON.stringify(
752752
parsed,
753-
(key, value) => (typeof value === "bigint" ? value.toString() : value), // return everything else unchanged
753+
(_, value) => (typeof value === "bigint" ? value.toString() : value), // return everything else unchanged
754754
2,
755755
),
756756
);
@@ -975,18 +975,20 @@ multisigCommand(
975975

976976
// Use Anchor to create the instruction
977977
const updateInstruction = await lazerProgram.methods
978-
.update(trustedSigner, expiryTime)
978+
.update?.(trustedSigner, expiryTime)
979979
.accounts({
980980
topAuthority: await vault.getVaultAuthorityPDA(targetCluster),
981981
storage: new PublicKey(SOLANA_LAZER_STORAGE_ID),
982982
})
983983
.instruction();
984984

985-
await vault.proposeInstructions(
986-
[updateInstruction],
987-
targetCluster,
988-
DEFAULT_PRIORITY_FEE_CONFIG,
989-
);
985+
if (updateInstruction) {
986+
await vault.proposeInstructions(
987+
[updateInstruction],
988+
targetCluster,
989+
DEFAULT_PRIORITY_FEE_CONFIG,
990+
);
991+
}
990992
});
991993

992994
multisigCommand(
@@ -1045,18 +1047,20 @@ multisigCommand(
10451047

10461048
// Use Anchor to create the instruction
10471049
const updateSignerInstruction = await lazerProgram.methods
1048-
.updateEcdsaSigner(trustedSigner, expiryTime)
1050+
.updateEcdsaSigner?.(trustedSigner, expiryTime)
10491051
.accounts({
10501052
topAuthority: await vault.getVaultAuthorityPDA(targetCluster),
10511053
storage: new PublicKey(SOLANA_LAZER_STORAGE_ID),
10521054
})
10531055
.instruction();
10541056

1055-
await vault.proposeInstructions(
1056-
[upgradeInstruction, updateSignerInstruction],
1057-
targetCluster,
1058-
DEFAULT_PRIORITY_FEE_CONFIG,
1059-
);
1057+
if (updateSignerInstruction) {
1058+
await vault.proposeInstructions(
1059+
[upgradeInstruction, updateSignerInstruction],
1060+
targetCluster,
1061+
DEFAULT_PRIORITY_FEE_CONFIG,
1062+
);
1063+
}
10601064
});
10611065

10621066
program.parse();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Wallet } from "@coral-xyz/anchor/dist/cjs/provider";
1+
import type { Wallet } from "@coral-xyz/anchor/dist/cjs/provider";
22
import Transport, {
33
StatusCodes,
44
TransportStatusError,
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{
22
"extends": "@cprussin/tsconfig/base.json",
33
"include": ["src"],
4+
"compilerOptions": {
5+
"module": "preserve",
6+
"moduleResolution": "node"
7+
},
48
"exclude": ["dist", "node_modules", "**/__tests__/*"]
59
}

0 commit comments

Comments
 (0)