Skip to content

Commit 3e4c337

Browse files
committed
fix(pyth-sui-cli): fixed build
1 parent e191517 commit 3e4c337

File tree

7 files changed

+65
-14
lines changed

7 files changed

+65
-14
lines changed

apps/price_pusher/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,4 +232,4 @@
232232
"./package.json": "./package.json"
233233
},
234234
"module": "./dist/esm/index.js"
235-
}
235+
}

target_chains/sui/cli/package.json

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"name": "pyth-sui-cli",
33
"version": "0.1.0",
44
"description": "Pyth Sui Integration Cli tools",
5-
"main": "index.js",
65
"license": "Apache-2.0",
76
"scripts": {
87
"cli": "ts-node src/cli.ts",
@@ -31,5 +30,51 @@
3130
"pnpm": ">=10.19.0"
3231
},
3332
"packageManager": "[email protected]",
34-
"type": "module"
33+
"type": "module",
34+
"exports": {
35+
"./cli": {
36+
"require": {
37+
"default": "./dist/cjs/cli.js",
38+
"types": "./dist/cjs/cli.d.ts"
39+
},
40+
"import": {
41+
"default": "./dist/esm/cli.js",
42+
"types": "./dist/esm/cli.d.ts"
43+
}
44+
},
45+
".": {
46+
"require": {
47+
"default": "./dist/cjs/index.js",
48+
"types": "./dist/cjs/index.d.ts"
49+
},
50+
"import": {
51+
"default": "./dist/esm/index.js",
52+
"types": "./dist/esm/index.d.ts"
53+
}
54+
},
55+
"./pyth_deploy": {
56+
"require": {
57+
"default": "./dist/cjs/pyth_deploy.js",
58+
"types": "./dist/cjs/pyth_deploy.d.ts"
59+
},
60+
"import": {
61+
"default": "./dist/esm/pyth_deploy.js",
62+
"types": "./dist/esm/pyth_deploy.d.ts"
63+
}
64+
},
65+
"./upgrade_pyth": {
66+
"require": {
67+
"default": "./dist/cjs/upgrade_pyth.js",
68+
"types": "./dist/cjs/upgrade_pyth.d.ts"
69+
},
70+
"import": {
71+
"default": "./dist/esm/upgrade_pyth.js",
72+
"types": "./dist/esm/upgrade_pyth.d.ts"
73+
}
74+
},
75+
"./package.json": "./package.json"
76+
},
77+
"module": "./dist/esm/index.js",
78+
"types": "./dist/cjs/index.d.ts",
79+
"main": "./dist/cjs/index.js"
3580
}

target_chains/sui/cli/src/cli.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import yargs from "yargs";
1+
import createCLI from "yargs";
22
import { hideBin } from "yargs/helpers";
33
import { SuiChain } from "@pythnetwork/contract-manager/core/chains";
44
import { SuiPriceFeedContract } from "@pythnetwork/contract-manager/core/contracts/sui";
5-
import { DefaultStore } from "@pythnetwork/contract-manager/node/store";
65
import { getDefaultDeploymentConfig } from "@pythnetwork/contract-manager/core/base";
76
import { PriceServiceConnection } from "@pythnetwork/price-service-client";
87
import { execSync } from "child_process";
9-
import { initPyth, publishPackage } from "./pyth_deploy";
8+
import { initPyth, publishPackage } from "./pyth_deploy.js";
109
import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
1110
import { resolve } from "path";
1211
import {
1312
buildForBytecodeAndDigest,
1413
migratePyth,
1514
upgradePyth,
16-
} from "./upgrade_pyth";
15+
} from "./upgrade_pyth.js";
16+
import { DefaultStore } from "@pythnetwork/contract-manager/node/utils/store";
1717

1818
const OPTIONS = {
1919
"private-key": {
@@ -51,7 +51,9 @@ function getContract(contractId: string): SuiPriceFeedContract {
5151
return contract;
5252
}
5353

54-
yargs(hideBin(process.argv))
54+
const yargs = createCLI(hideBin(process.argv));
55+
56+
yargs
5557
.command(
5658
"create",
5759
"Create a new price feed",

target_chains/sui/cli/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from "./cli.js";
2+
export * from "./pyth_deploy.js";
3+
export * from "./upgrade_pyth.js";

target_chains/sui/cli/src/pyth_deploy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { MIST_PER_SUI, normalizeSuiObjectId, fromB64 } from "@mysten/sui/utils";
44

55
import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
66
import { execSync } from "child_process";
7-
import { DataSource } from "@pythnetwork/xc-admin-common";
7+
import type { DataSource } from "@pythnetwork/xc-admin-common";
88
import { SuiClient } from "@mysten/sui/client";
99
import { bcs } from "@mysten/sui/bcs";
1010

@@ -41,7 +41,7 @@ export async function publishPackage(
4141
});
4242

4343
// Transfer upgrade capability to deployer
44-
txb.transferObjects([upgradeCap], txb.pure.address(keypair.toSuiAddress()));
44+
txb.transferObjects([upgradeCap!], txb.pure.address(keypair.toSuiAddress()));
4545

4646
// Execute transactions
4747
const result = await provider.signAndExecuteTransaction({
@@ -59,7 +59,7 @@ export async function publishPackage(
5959

6060
if (
6161
publishedChanges?.length !== 1 ||
62-
publishedChanges[0].type !== "published"
62+
publishedChanges[0]?.type !== "published"
6363
) {
6464
throw new Error(
6565
"No publish event found in transaction:" +

target_chains/sui/cli/src/upgrade_pyth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ export async function upgradePyth(
5555
modules,
5656
dependencies,
5757
package: pythPackage,
58-
ticket: upgradeTicket,
58+
ticket: upgradeTicket!,
5959
});
6060

6161
// Commit upgrade.
6262
tx.moveCall({
6363
target: `${pythPackage}::contract_upgrade::commit_upgrade`,
64-
arguments: [tx.object(contract.stateId), upgradeReceipt],
64+
arguments: [tx.object(contract.stateId), upgradeReceipt!],
6565
});
6666

6767
tx.setGasBudget(MIST_PER_SUI / 4n); // 0.25 SUI

target_chains/sui/cli/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",

0 commit comments

Comments
 (0)