Parcourir la source

fix(pyth-iota-cli): fixed build

benduran il y a 3 semaines
Parent
commit
8c57372132

+ 47 - 2
target_chains/sui/cli-iota/package.json

@@ -2,7 +2,7 @@
   "name": "pyth-iota-cli",
   "version": "0.1.0",
   "description": "Pyth IOTA Integration Cli tools",
-  "main": "index.js",
+  "main": "./dist/cjs/index.js",
   "license": "Apache-2.0",
   "scripts": {
     "cli": "ts-node src/cli.ts",
@@ -31,5 +31,50 @@
     "pnpm": ">=10.19.0"
   },
   "packageManager": "pnpm@10.19.0",
-  "type": "module"
+  "type": "module",
+  "exports": {
+    "./cli": {
+      "require": {
+        "default": "./dist/cjs/cli.js",
+        "types": "./dist/cjs/cli.d.ts"
+      },
+      "import": {
+        "default": "./dist/esm/cli.js",
+        "types": "./dist/esm/cli.d.ts"
+      }
+    },
+    ".": {
+      "require": {
+        "default": "./dist/cjs/index.js",
+        "types": "./dist/cjs/index.d.ts"
+      },
+      "import": {
+        "default": "./dist/esm/index.js",
+        "types": "./dist/esm/index.d.ts"
+      }
+    },
+    "./pyth_deploy": {
+      "require": {
+        "default": "./dist/cjs/pyth_deploy.js",
+        "types": "./dist/cjs/pyth_deploy.d.ts"
+      },
+      "import": {
+        "default": "./dist/esm/pyth_deploy.js",
+        "types": "./dist/esm/pyth_deploy.d.ts"
+      }
+    },
+    "./upgrade_pyth": {
+      "require": {
+        "default": "./dist/cjs/upgrade_pyth.js",
+        "types": "./dist/cjs/upgrade_pyth.d.ts"
+      },
+      "import": {
+        "default": "./dist/esm/upgrade_pyth.js",
+        "types": "./dist/esm/upgrade_pyth.d.ts"
+      }
+    },
+    "./package.json": "./package.json"
+  },
+  "module": "./dist/esm/index.js",
+  "types": "./dist/cjs/index.d.ts"
 }

+ 7 - 5
target_chains/sui/cli-iota/src/cli.ts

@@ -1,19 +1,19 @@
-import yargs from "yargs";
+import createCLI from "yargs";
 import { hideBin } from "yargs/helpers";
 import { IotaChain } from "@pythnetwork/contract-manager/core/chains";
 import { IotaPriceFeedContract } from "@pythnetwork/contract-manager/core/contracts/iota";
-import { DefaultStore } from "@pythnetwork/contract-manager/node/store";
 import { getDefaultDeploymentConfig } from "@pythnetwork/contract-manager/core/base";
 import { PriceServiceConnection } from "@pythnetwork/price-service-client";
 import { execSync } from "child_process";
-import { initPyth, publishPackage } from "./pyth_deploy";
+import { initPyth, publishPackage } from "./pyth_deploy.js";
 import { Ed25519Keypair } from "@iota/iota-sdk/keypairs/ed25519";
 import { resolve } from "path";
 import {
   buildForBytecodeAndDigest,
   migratePyth,
   upgradePyth,
-} from "./upgrade_pyth";
+} from "./upgrade_pyth.js";
+import { DefaultStore } from "@pythnetwork/contract-manager/node/utils/store";
 
 const OPTIONS = {
   "private-key": {
@@ -51,7 +51,9 @@ function getContract(contractId: string): IotaPriceFeedContract {
   return contract;
 }
 
-yargs(hideBin(process.argv))
+const yargs = createCLI(hideBin(process.argv));
+
+yargs
   .command(
     "create",
     "Create a new price feed",

+ 3 - 0
target_chains/sui/cli-iota/src/index.ts

@@ -0,0 +1,3 @@
+export * from "./cli.js";
+export * from "./pyth_deploy.js";
+export * from "./upgrade_pyth.js";

+ 3 - 3
target_chains/sui/cli-iota/src/pyth_deploy.ts

@@ -8,7 +8,7 @@ import {
 
 import { Ed25519Keypair } from "@iota/iota-sdk/keypairs/ed25519";
 import { execSync } from "child_process";
-import { DataSource } from "@pythnetwork/xc-admin-common";
+import type { DataSource } from "@pythnetwork/xc-admin-common";
 import { IotaClient } from "@iota/iota-sdk/client";
 import { bcs } from "@iota/iota-sdk/bcs";
 
@@ -45,7 +45,7 @@ export async function publishPackage(
   });
 
   // Transfer upgrade capability to deployer
-  txb.transferObjects([upgradeCap], txb.pure.address(keypair.toIotaAddress()));
+  txb.transferObjects([upgradeCap!], txb.pure.address(keypair.toIotaAddress()));
 
   // Execute transactions
   const result = await provider.signAndExecuteTransaction({
@@ -63,7 +63,7 @@ export async function publishPackage(
 
   if (
     publishedChanges?.length !== 1 ||
-    publishedChanges[0].type !== "published"
+    publishedChanges[0]?.type !== "published"
   ) {
     throw new Error(
       "No publish event found in transaction:" +

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

@@ -59,13 +59,13 @@ export async function upgradePyth(
     modules,
     dependencies,
     package: pythPackage,
-    ticket: upgradeTicket,
+    ticket: upgradeTicket!,
   });
 
   // Commit upgrade.
   tx.moveCall({
     target: `${pythPackage}::contract_upgrade::commit_upgrade`,
-    arguments: [tx.object(contract.stateId), upgradeReceipt],
+    arguments: [tx.object(contract.stateId), upgradeReceipt!],
   });
 
   tx.setGasBudget(NANOS_PER_IOTA / 4n); // 0.25 IOTA

+ 2 - 1
target_chains/sui/cli-iota/tsconfig.build.json

@@ -3,7 +3,8 @@
   "compilerOptions": {
     "noEmit": false,
     "incremental": false,
-    "declaration": true
+    "declaration": true,
+    "isolatedModules": false
   },
   "exclude": [
     "node_modules",