Skip to content

Commit 8c57372

Browse files
committed
fix(pyth-iota-cli): fixed build
1 parent 3e4c337 commit 8c57372

File tree

6 files changed

+64
-13
lines changed

6 files changed

+64
-13
lines changed

target_chains/sui/cli-iota/package.json

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

target_chains/sui/cli-iota/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 { IotaChain } from "@pythnetwork/contract-manager/core/chains";
44
import { IotaPriceFeedContract } from "@pythnetwork/contract-manager/core/contracts/iota";
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 "@iota/iota-sdk/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): IotaPriceFeedContract {
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",
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-iota/src/pyth_deploy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88

99
import { Ed25519Keypair } from "@iota/iota-sdk/keypairs/ed25519";
1010
import { execSync } from "child_process";
11-
import { DataSource } from "@pythnetwork/xc-admin-common";
11+
import type { DataSource } from "@pythnetwork/xc-admin-common";
1212
import { IotaClient } from "@iota/iota-sdk/client";
1313
import { bcs } from "@iota/iota-sdk/bcs";
1414

@@ -45,7 +45,7 @@ export async function publishPackage(
4545
});
4646

4747
// Transfer upgrade capability to deployer
48-
txb.transferObjects([upgradeCap], txb.pure.address(keypair.toIotaAddress()));
48+
txb.transferObjects([upgradeCap!], txb.pure.address(keypair.toIotaAddress()));
4949

5050
// Execute transactions
5151
const result = await provider.signAndExecuteTransaction({
@@ -63,7 +63,7 @@ export async function publishPackage(
6363

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

target_chains/sui/cli-iota/src/upgrade_pyth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ export async function upgradePyth(
5959
modules,
6060
dependencies,
6161
package: pythPackage,
62-
ticket: upgradeTicket,
62+
ticket: upgradeTicket!,
6363
});
6464

6565
// Commit upgrade.
6666
tx.moveCall({
6767
target: `${pythPackage}::contract_upgrade::commit_upgrade`,
68-
arguments: [tx.object(contract.stateId), upgradeReceipt],
68+
arguments: [tx.object(contract.stateId), upgradeReceipt!],
6969
});
7070

7171
tx.setGasBudget(NANOS_PER_IOTA / 4n); // 0.25 IOTA

target_chains/sui/cli-iota/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)