Skip to content

Commit 76d65ed

Browse files
committed
fix(@pythnetwork/aptos-cli): fixed build
1 parent 8c57372 commit 76d65ed

File tree

5 files changed

+51
-20
lines changed

5 files changed

+51
-20
lines changed

target_chains/aptos/cli/package.json

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.0.0",
44
"description": "Utilities for managing the Pyth Target Chain contract on Aptos",
55
"private": true,
6-
"main": "index.js",
6+
"main": "./dist/cjs/index.js",
77
"scripts": {
88
"cli": "ts-node src/cli.ts",
99
"build": "ts-duality",
@@ -34,5 +34,40 @@
3434
"pnpm": ">=10.19.0"
3535
},
3636
"packageManager": "[email protected]",
37-
"type": "module"
37+
"type": "module",
38+
"exports": {
39+
"./cli": {
40+
"require": {
41+
"default": "./dist/cjs/cli.js",
42+
"types": "./dist/cjs/cli.d.ts"
43+
},
44+
"import": {
45+
"default": "./dist/esm/cli.js",
46+
"types": "./dist/esm/cli.d.ts"
47+
}
48+
},
49+
"./commands/aptos": {
50+
"require": {
51+
"default": "./dist/cjs/commands/aptos.js",
52+
"types": "./dist/cjs/commands/aptos.d.ts"
53+
},
54+
"import": {
55+
"default": "./dist/esm/commands/aptos.js",
56+
"types": "./dist/esm/commands/aptos.d.ts"
57+
}
58+
},
59+
".": {
60+
"require": {
61+
"default": "./dist/cjs/index.js",
62+
"types": "./dist/cjs/index.d.ts"
63+
},
64+
"import": {
65+
"default": "./dist/esm/index.js",
66+
"types": "./dist/esm/index.d.ts"
67+
}
68+
},
69+
"./package.json": "./package.json"
70+
},
71+
"module": "./dist/esm/index.js",
72+
"types": "./dist/cjs/index.d.ts"
3873
}

target_chains/aptos/cli/src/cli.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/usr/bin/env node
22

3-
import yargs from "yargs";
3+
import createCLI from "yargs";
44
import { hideBin } from "yargs/helpers";
5-
import { builder } from "./commands/aptos";
5+
import { builder } from "./commands/aptos.js";
66

7-
builder(yargs(hideBin(process.argv))).argv;
7+
const yargs = createCLI(hideBin(process.argv));
8+
9+
builder(yargs).argv;

target_chains/aptos/cli/src/commands/aptos.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import { Argv } from "yargs";
1+
import type { Argv } from "yargs";
22
import { spawnSync } from "child_process";
33
import { AptosAccount, AptosClient, BCS, TxnBuilderTypes } from "aptos";
44
import fs from "fs";
55
import sha3 from "js-sha3";
6-
import { ethers } from "ethers";
7-
import { DefaultStore } from "@pythnetwork/contract-manager/node/store";
86
import { AptosChain } from "@pythnetwork/contract-manager/core/chains";
97
import { getDefaultDeploymentConfig } from "@pythnetwork/contract-manager/core/base";
8+
import { DefaultStore } from "@pythnetwork/contract-manager/node/utils/store";
109

1110
const NETWORK_CHOICES = Object.entries(DefaultStore.chains)
12-
.filter(([chain, config]) => {
11+
.filter(([_, config]) => {
1312
return config instanceof AptosChain;
1413
})
1514
.map(([chain, _]) => {
@@ -181,7 +180,7 @@ export const builder: (args: Argv<any>) => Argv<any> = (yargs) =>
181180
const guardian_addresses_serializer = new BCS.Serializer();
182181
guardian_addresses_serializer.serializeU32AsUleb128(1);
183182
guardian_addresses_serializer.serializeBytes(
184-
Buffer.from(guardian_address, "hex"),
183+
Buffer.from(guardian_address!, "hex"),
185184
);
186185

187186
const args = [
@@ -351,7 +350,8 @@ export const builder: (args: Argv<any>) => Argv<any> = (yargs) =>
351350
const addr2 = argv["addr-2"];
352351
const url = `${endpoint}/accounts/${addr1}/resource/0x1::code::PackageRegistry`;
353352
const response = await (await fetch(url)).json();
354-
for (const module of response.data.packages[0].modules) {
353+
// @ts-expect-error - TODO: Please improve typings on the .json() response here
354+
for (const module of response?.data?.packages[0]?.modules ?? []) {
355355
const moduleName = module.name;
356356
const addr1Module = `${endpoint}/accounts/${addr1}/module/${moduleName}`;
357357
const addr2Module = `${endpoint}/accounts/${addr2}/module/${moduleName}`;
@@ -513,11 +513,3 @@ function createDeployDerivedTransaction(
513513
),
514514
);
515515
}
516-
517-
function hex(x: string): string {
518-
return ethers.utils.hexlify(x, { allowMissingPrefix: true });
519-
}
520-
521-
function evm_address(x: string): string {
522-
return hex(x).substring(2).padStart(64, "0");
523-
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./cli.js";

target_chains/aptos/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)