@easysui/sdk 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.js +51 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +52 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -19,6 +19,7 @@ interface BaseConfigVars {
|
|
|
19
19
|
PACKAGE_PATH: string;
|
|
20
20
|
PACKAGE_ID: string;
|
|
21
21
|
UPGRADE_CAP_ID: string;
|
|
22
|
+
PUBFILE_PATH?: string;
|
|
22
23
|
USDC_PACKAGE_ID?: string;
|
|
23
24
|
USDC_TREASURY_CAP?: string;
|
|
24
25
|
}
|
|
@@ -52,7 +53,7 @@ declare class USDC extends Coin {
|
|
|
52
53
|
|
|
53
54
|
declare function analyze_cost(ptb: Transaction, resp: SuiTransactionBlockResponse): void;
|
|
54
55
|
|
|
55
|
-
declare function deploy<TConfig extends typeof Config = typeof Config, TConfigVars extends BaseConfigVars = BaseConfigVars>(ConfigClass?: TConfig, packagePath?: string): Promise<string>;
|
|
56
|
+
declare function deploy<TConfig extends typeof Config = typeof Config, TConfigVars extends BaseConfigVars = BaseConfigVars>(ConfigClass?: TConfig, packagePath?: string, pubFilePath?: string): Promise<string>;
|
|
56
57
|
declare function getDeployBytes(): Promise<string>;
|
|
57
58
|
|
|
58
59
|
declare function getKeypair(privkey: string): Keypair;
|
|
@@ -224,7 +225,8 @@ declare class PublishSingleton {
|
|
|
224
225
|
private static instance;
|
|
225
226
|
private constructor();
|
|
226
227
|
private static getPackagePath;
|
|
227
|
-
static
|
|
228
|
+
private static getPubFilePath;
|
|
229
|
+
static publish(signer?: Keypair, packagePath?: string, pubFilePath?: string): Promise<void>;
|
|
228
230
|
private static getInstance;
|
|
229
231
|
static publishResponse(): SuiPublishResponse;
|
|
230
232
|
static get packageId(): string;
|
|
@@ -232,8 +234,8 @@ declare class PublishSingleton {
|
|
|
232
234
|
static get upgradeCapId(): string;
|
|
233
235
|
static get usdcTreasuryCap(): string;
|
|
234
236
|
private static getPublishCmd;
|
|
235
|
-
static getPublishBytes(signer?: string, packagePath?: string): Promise<string>;
|
|
236
|
-
static publishPackage(signer: Keypair, packagePath: string): Promise<SuiPublishResponse>;
|
|
237
|
+
static getPublishBytes(signer?: string, packagePath?: string, pubFilePath?: string): Promise<string>;
|
|
238
|
+
static publishPackage(signer: Keypair, packagePath: string, pubFilePath: string): Promise<SuiPublishResponse>;
|
|
237
239
|
static findPublishedPackage(resp: SuiPublishResponse): ChangedObjectFlat | undefined;
|
|
238
240
|
static findObjectChangeCreatedByType(resp: SuiPublishResponse, type: string): ChangedObjectFlat | undefined;
|
|
239
241
|
static get pubFile(): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ interface BaseConfigVars {
|
|
|
19
19
|
PACKAGE_PATH: string;
|
|
20
20
|
PACKAGE_ID: string;
|
|
21
21
|
UPGRADE_CAP_ID: string;
|
|
22
|
+
PUBFILE_PATH?: string;
|
|
22
23
|
USDC_PACKAGE_ID?: string;
|
|
23
24
|
USDC_TREASURY_CAP?: string;
|
|
24
25
|
}
|
|
@@ -52,7 +53,7 @@ declare class USDC extends Coin {
|
|
|
52
53
|
|
|
53
54
|
declare function analyze_cost(ptb: Transaction, resp: SuiTransactionBlockResponse): void;
|
|
54
55
|
|
|
55
|
-
declare function deploy<TConfig extends typeof Config = typeof Config, TConfigVars extends BaseConfigVars = BaseConfigVars>(ConfigClass?: TConfig, packagePath?: string): Promise<string>;
|
|
56
|
+
declare function deploy<TConfig extends typeof Config = typeof Config, TConfigVars extends BaseConfigVars = BaseConfigVars>(ConfigClass?: TConfig, packagePath?: string, pubFilePath?: string): Promise<string>;
|
|
56
57
|
declare function getDeployBytes(): Promise<string>;
|
|
57
58
|
|
|
58
59
|
declare function getKeypair(privkey: string): Keypair;
|
|
@@ -224,7 +225,8 @@ declare class PublishSingleton {
|
|
|
224
225
|
private static instance;
|
|
225
226
|
private constructor();
|
|
226
227
|
private static getPackagePath;
|
|
227
|
-
static
|
|
228
|
+
private static getPubFilePath;
|
|
229
|
+
static publish(signer?: Keypair, packagePath?: string, pubFilePath?: string): Promise<void>;
|
|
228
230
|
private static getInstance;
|
|
229
231
|
static publishResponse(): SuiPublishResponse;
|
|
230
232
|
static get packageId(): string;
|
|
@@ -232,8 +234,8 @@ declare class PublishSingleton {
|
|
|
232
234
|
static get upgradeCapId(): string;
|
|
233
235
|
static get usdcTreasuryCap(): string;
|
|
234
236
|
private static getPublishCmd;
|
|
235
|
-
static getPublishBytes(signer?: string, packagePath?: string): Promise<string>;
|
|
236
|
-
static publishPackage(signer: Keypair, packagePath: string): Promise<SuiPublishResponse>;
|
|
237
|
+
static getPublishBytes(signer?: string, packagePath?: string, pubFilePath?: string): Promise<string>;
|
|
238
|
+
static publishPackage(signer: Keypair, packagePath: string, pubFilePath: string): Promise<SuiPublishResponse>;
|
|
237
239
|
static findPublishedPackage(resp: SuiPublishResponse): ChangedObjectFlat | undefined;
|
|
238
240
|
static findObjectChangeCreatedByType(resp: SuiPublishResponse, type: string): ChangedObjectFlat | undefined;
|
|
239
241
|
static get pubFile(): string;
|
package/dist/index.js
CHANGED
|
@@ -1565,6 +1565,7 @@ var Config = class _Config {
|
|
|
1565
1565
|
NETWORK,
|
|
1566
1566
|
RPC: jsonRpc.getJsonRpcFullnodeUrl(NETWORK),
|
|
1567
1567
|
PACKAGE_PATH: process.env.PACKAGE_PATH || "",
|
|
1568
|
+
PUBFILE_PATH: process.env.PUBFILE_PATH || "",
|
|
1568
1569
|
PACKAGE_ID: process.env.PACKAGE_ID || "",
|
|
1569
1570
|
UPGRADE_CAP_ID: process.env.UPGRADE_CAP_ID || "",
|
|
1570
1571
|
USDC_TREASURY_CAP: process.env.USDC_TREASURY_CAP,
|
|
@@ -16366,6 +16367,31 @@ var USDC = class extends Coin {
|
|
|
16366
16367
|
});
|
|
16367
16368
|
}
|
|
16368
16369
|
};
|
|
16370
|
+
function execCmd(cmd) {
|
|
16371
|
+
return new Promise((resolve3, reject) => {
|
|
16372
|
+
const child = child_process.spawn(cmd, { shell: true });
|
|
16373
|
+
let stdout = "";
|
|
16374
|
+
let stderr = "";
|
|
16375
|
+
child.stdout.on("data", (data) => {
|
|
16376
|
+
stdout += data.toString();
|
|
16377
|
+
});
|
|
16378
|
+
child.stderr.on("data", (data) => {
|
|
16379
|
+
stderr += data.toString();
|
|
16380
|
+
});
|
|
16381
|
+
child.on("error", (err) => reject(err));
|
|
16382
|
+
child.on("close", (code) => {
|
|
16383
|
+
if (code === 0) {
|
|
16384
|
+
resolve3(stdout.trim());
|
|
16385
|
+
} else {
|
|
16386
|
+
const output = [stderr.trim(), stdout.trim()].filter(Boolean).join("\n") || `Process exited with code ${code}`;
|
|
16387
|
+
reject(new Error(`Publish bytes command failed:
|
|
16388
|
+
${output}`));
|
|
16389
|
+
}
|
|
16390
|
+
});
|
|
16391
|
+
});
|
|
16392
|
+
}
|
|
16393
|
+
|
|
16394
|
+
// src/utils/publish.ts
|
|
16369
16395
|
var PublishSingleton = class _PublishSingleton {
|
|
16370
16396
|
constructor(publishResp) {
|
|
16371
16397
|
this.publishResp = publishResp;
|
|
@@ -16380,11 +16406,21 @@ var PublishSingleton = class _PublishSingleton {
|
|
|
16380
16406
|
}
|
|
16381
16407
|
return packagePath;
|
|
16382
16408
|
}
|
|
16383
|
-
static
|
|
16409
|
+
static getPubFilePath(pubFilePath) {
|
|
16410
|
+
pubFilePath ??= Config.vars.PUBFILE_PATH;
|
|
16411
|
+
if (!pubFilePath) {
|
|
16412
|
+
throw new Error(
|
|
16413
|
+
`You must set the \`PUBFILE_PATH\` environment variable to your Pub.${Config.vars.NETWORK}.toml path.`
|
|
16414
|
+
);
|
|
16415
|
+
}
|
|
16416
|
+
return pubFilePath;
|
|
16417
|
+
}
|
|
16418
|
+
static async publish(signer, packagePath, pubFilePath) {
|
|
16384
16419
|
signer ??= ADMIN_KEYPAIR;
|
|
16385
16420
|
const _packagePath = this.getPackagePath(packagePath);
|
|
16421
|
+
const _pubFilePath = this.getPubFilePath(pubFilePath);
|
|
16386
16422
|
if (!_PublishSingleton.instance) {
|
|
16387
|
-
const publishResp = await _PublishSingleton.publishPackage(signer, _packagePath);
|
|
16423
|
+
const publishResp = await _PublishSingleton.publishPackage(signer, _packagePath, _pubFilePath);
|
|
16388
16424
|
_PublishSingleton.instance = new _PublishSingleton(publishResp);
|
|
16389
16425
|
}
|
|
16390
16426
|
}
|
|
@@ -16420,7 +16456,7 @@ var PublishSingleton = class _PublishSingleton {
|
|
|
16420
16456
|
false
|
|
16421
16457
|
);
|
|
16422
16458
|
}
|
|
16423
|
-
static getPublishCmd(packagePath, sender, inBytes = false) {
|
|
16459
|
+
static getPublishCmd(packagePath, sender, pubFilePath, inBytes = false) {
|
|
16424
16460
|
const network = Config.vars.NETWORK;
|
|
16425
16461
|
if (!fs3__namespace.default.existsSync(packagePath)) {
|
|
16426
16462
|
throw new Error(`Package doesn't exist under: ${packagePath}`);
|
|
@@ -16435,18 +16471,22 @@ var PublishSingleton = class _PublishSingleton {
|
|
|
16435
16471
|
if (isEphemeralChain) {
|
|
16436
16472
|
buildCommand += " --publish-unpublished-deps";
|
|
16437
16473
|
}
|
|
16474
|
+
if (pubFilePath) {
|
|
16475
|
+
buildCommand += ` --pubfile-path ${pubFilePath}`;
|
|
16476
|
+
}
|
|
16438
16477
|
buildCommand += inBytes ? ` --serialize-unsigned-transaction --sender ${sender}` : " --json";
|
|
16439
16478
|
return buildCommand;
|
|
16440
16479
|
}
|
|
16441
|
-
static async getPublishBytes(signer, packagePath) {
|
|
16480
|
+
static async getPublishBytes(signer, packagePath, pubFilePath) {
|
|
16442
16481
|
signer ??= ADMIN_KEYPAIR.toSuiAddress();
|
|
16443
16482
|
const _packagePath = this.getPackagePath(packagePath);
|
|
16444
|
-
const
|
|
16445
|
-
|
|
16483
|
+
const _pubFilePath = this.getPubFilePath(pubFilePath);
|
|
16484
|
+
const cmd = this.getPublishCmd(_packagePath, signer, _pubFilePath, true);
|
|
16485
|
+
return execCmd(cmd);
|
|
16446
16486
|
}
|
|
16447
|
-
static async publishPackage(signer, packagePath) {
|
|
16448
|
-
const cmd = this.getPublishCmd(packagePath, signer.toSuiAddress());
|
|
16449
|
-
const res =
|
|
16487
|
+
static async publishPackage(signer, packagePath, pubFilePath) {
|
|
16488
|
+
const cmd = this.getPublishCmd(packagePath, signer.toSuiAddress(), pubFilePath);
|
|
16489
|
+
const res = await execCmd(cmd);
|
|
16450
16490
|
const match = res.match(/\{[\s\S]*\}/);
|
|
16451
16491
|
if (!match) {
|
|
16452
16492
|
throw new Error(`No JSON found in the publish command output: ${res}`);
|
|
@@ -16473,9 +16513,9 @@ var PublishSingleton = class _PublishSingleton {
|
|
|
16473
16513
|
};
|
|
16474
16514
|
|
|
16475
16515
|
// src/utils/deploy.ts
|
|
16476
|
-
async function deploy(ConfigClass = Config, packagePath) {
|
|
16516
|
+
async function deploy(ConfigClass = Config, packagePath, pubFilePath) {
|
|
16477
16517
|
const vars = ConfigClass.vars;
|
|
16478
|
-
await PublishSingleton.publish(ADMIN_KEYPAIR, packagePath);
|
|
16518
|
+
await PublishSingleton.publish(ADMIN_KEYPAIR, packagePath, pubFilePath);
|
|
16479
16519
|
const newConfig = {
|
|
16480
16520
|
...vars,
|
|
16481
16521
|
PACKAGE_ID: PublishSingleton.packageId,
|