Skip to content

Commit 3594fa0

Browse files
committed
fix(xc-admin-crank-pythnet-relayer): fixed build
1 parent afa3477 commit 3594fa0

File tree

4 files changed

+28
-15
lines changed

4 files changed

+28
-15
lines changed

governance/xc_admin/packages/crank_pythnet_relayer/package.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"author": "",
77
"homepage": "https://github.com/pyth-network/pyth-crosschain",
88
"license": "ISC",
9-
"main": "src/index.ts",
9+
"main": "./dist/index.js",
1010
"repository": {
1111
"type": "git",
1212
"url": "git+https://github.com/pyth-network/pyth-crosschain.git"
@@ -15,8 +15,8 @@
1515
"url": "https://github.com/pyth-network/pyth-crosschain/issues"
1616
},
1717
"scripts": {
18-
"build": "ts-duality",
19-
"start": "node lib/index.js",
18+
"build": "ts-duality --noEsm",
19+
"start": "node dist/index.js",
2020
"fix:format": "prettier --write \"src/**/*.ts\"",
2121
"test:format": "prettier --check \"src/**/*.ts\"",
2222
"clean": "rm -rf ./dist"
@@ -37,5 +37,13 @@
3737
"pnpm": ">=10.19.0"
3838
},
3939
"packageManager": "[email protected]",
40-
"type": "module"
40+
"type": "module",
41+
"exports": {
42+
".": {
43+
"default": "./dist/index.js",
44+
"types": "./dist/index.d.ts"
45+
},
46+
"./package.json": "./package.json"
47+
},
48+
"types": "./dist/index.d.ts"
4149
}

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet";
66
import { AccountType, parseProductData } from "@pythnetwork/client";
77
import {
88
getPythClusterApiUrl,
9-
PythCluster,
9+
type PythCluster,
1010
} from "@pythnetwork/client/lib/cluster";
1111
import {
12-
AccountMeta,
13-
Commitment,
12+
type AccountMeta,
13+
type Commitment,
1414
ComputeBudgetProgram,
1515
Connection,
1616
Keypair,
@@ -67,7 +67,7 @@ async function run() {
6767
)[0];
6868
const executorKey: PublicKey = mapKey(EMITTER);
6969
const claimRecord =
70-
await remoteExecutor.account.claimRecord.fetchNullable(claimRecordAddress);
70+
await remoteExecutor.account.claimRecord?.fetchNullable(claimRecordAddress);
7171
let lastSequenceNumber: number = claimRecord
7272
? (claimRecord.sequence as BN).toNumber()
7373
: -1;
@@ -78,13 +78,13 @@ async function run() {
7878
lastSequenceNumber += 1;
7979
console.log(`Trying sequence number : ${lastSequenceNumber}`);
8080

81-
const response = await (
81+
const response = (await (
8282
await fetch(
8383
`${wormholeApi}/v1/signed_vaa/1/${EMITTER.toBuffer().toString(
8484
"hex",
8585
)}/${lastSequenceNumber}`,
8686
)
87-
).json();
87+
).json()) as Partial<{ code: number; vaaBytes: string }>;
8888

8989
if (response.vaaBytes) {
9090
const vaa = parseVaa(Buffer.from(response.vaaBytes, "base64"));
@@ -144,19 +144,19 @@ async function run() {
144144
),
145145
);
146146
productAccountToSymbol[
147-
parsedInstruction.accounts.named.productAccount.pubkey.toBase58()
147+
parsedInstruction.accounts.named.productAccount!.pubkey.toBase58()
148148
] = parsedInstruction.args.symbol;
149149
} else if (
150150
parsedInstruction instanceof PythMultisigInstruction &&
151151
parsedInstruction.name == "addPrice"
152152
) {
153153
const productAccount = await provider.connection.getAccountInfo(
154-
parsedInstruction.accounts.named.productAccount.pubkey,
154+
parsedInstruction.accounts.named.productAccount!.pubkey,
155155
);
156156
const productSymbol = productAccount
157157
? parseProductData(productAccount.data).product.symbol
158158
: productAccountToSymbol[
159-
parsedInstruction.accounts.named.productAccount.pubkey.toBase58()
159+
parsedInstruction.accounts.named.productAccount!.pubkey.toBase58()
160160
];
161161
if (productSymbol) {
162162
preInstructions.push(
@@ -187,7 +187,7 @@ async function run() {
187187

188188
try {
189189
await remoteExecutor.methods
190-
.executePostedVaa()
190+
.executePostedVaa?.()
191191
.accounts({
192192
claimRecord: claimRecordAddress,
193193
postedVaa: derivePostedVaaKey(

governance/xc_admin/packages/crank_pythnet_relayer/tsconfig.build.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"compilerOptions": {
44
"noEmit": false,
55
"incremental": false,
6-
"declaration": true
6+
"declaration": true,
7+
"isolatedModules": false
78
},
89
"exclude": [
910
"node_modules",
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)