@easysui/sdk 1.0.1 → 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.mjs CHANGED
@@ -1540,6 +1540,7 @@ var Config = class _Config {
1540
1540
  NETWORK,
1541
1541
  RPC: getJsonRpcFullnodeUrl(NETWORK),
1542
1542
  PACKAGE_PATH: process.env.PACKAGE_PATH || "",
1543
+ PUBFILE_PATH: process.env.PUBFILE_PATH || "",
1543
1544
  PACKAGE_ID: process.env.PACKAGE_ID || "",
1544
1545
  UPGRADE_CAP_ID: process.env.UPGRADE_CAP_ID || "",
1545
1546
  USDC_TREASURY_CAP: process.env.USDC_TREASURY_CAP,
@@ -16380,11 +16381,21 @@ var PublishSingleton = class _PublishSingleton {
16380
16381
  }
16381
16382
  return packagePath;
16382
16383
  }
16383
- static async publish(signer, packagePath) {
16384
+ static getPubFilePath(pubFilePath) {
16385
+ pubFilePath ??= Config.vars.PUBFILE_PATH;
16386
+ if (!pubFilePath) {
16387
+ throw new Error(
16388
+ `You must set the \`PUBFILE_PATH\` environment variable to your Pub.${Config.vars.NETWORK}.toml path.`
16389
+ );
16390
+ }
16391
+ return pubFilePath;
16392
+ }
16393
+ static async publish(signer, packagePath, pubFilePath) {
16384
16394
  signer ??= ADMIN_KEYPAIR;
16385
16395
  const _packagePath = this.getPackagePath(packagePath);
16396
+ const _pubFilePath = this.getPubFilePath(pubFilePath);
16386
16397
  if (!_PublishSingleton.instance) {
16387
- const publishResp = await _PublishSingleton.publishPackage(signer, _packagePath);
16398
+ const publishResp = await _PublishSingleton.publishPackage(signer, _packagePath, _pubFilePath);
16388
16399
  _PublishSingleton.instance = new _PublishSingleton(publishResp);
16389
16400
  }
16390
16401
  }
@@ -16420,7 +16431,7 @@ var PublishSingleton = class _PublishSingleton {
16420
16431
  false
16421
16432
  );
16422
16433
  }
16423
- static getPublishCmd(packagePath, sender, inBytes = false) {
16434
+ static getPublishCmd(packagePath, sender, pubFilePath, inBytes = false) {
16424
16435
  const network = Config.vars.NETWORK;
16425
16436
  if (!fs3__default.existsSync(packagePath)) {
16426
16437
  throw new Error(`Package doesn't exist under: ${packagePath}`);
@@ -16435,17 +16446,21 @@ var PublishSingleton = class _PublishSingleton {
16435
16446
  if (isEphemeralChain) {
16436
16447
  buildCommand += " --publish-unpublished-deps";
16437
16448
  }
16449
+ if (pubFilePath) {
16450
+ buildCommand += ` --pubfile-path ${pubFilePath}`;
16451
+ }
16438
16452
  buildCommand += inBytes ? ` --serialize-unsigned-transaction --sender ${sender}` : " --json";
16439
16453
  return buildCommand;
16440
16454
  }
16441
- static async getPublishBytes(signer, packagePath) {
16455
+ static async getPublishBytes(signer, packagePath, pubFilePath) {
16442
16456
  signer ??= ADMIN_KEYPAIR.toSuiAddress();
16443
16457
  const _packagePath = this.getPackagePath(packagePath);
16444
- const cmd = this.getPublishCmd(_packagePath, signer, true);
16458
+ const _pubFilePath = this.getPubFilePath(pubFilePath);
16459
+ const cmd = this.getPublishCmd(_packagePath, signer, _pubFilePath, true);
16445
16460
  return execCmd(cmd);
16446
16461
  }
16447
- static async publishPackage(signer, packagePath) {
16448
- const cmd = this.getPublishCmd(packagePath, signer.toSuiAddress());
16462
+ static async publishPackage(signer, packagePath, pubFilePath) {
16463
+ const cmd = this.getPublishCmd(packagePath, signer.toSuiAddress(), pubFilePath);
16449
16464
  const res = await execCmd(cmd);
16450
16465
  const match = res.match(/\{[\s\S]*\}/);
16451
16466
  if (!match) {
@@ -16473,9 +16488,9 @@ var PublishSingleton = class _PublishSingleton {
16473
16488
  };
16474
16489
 
16475
16490
  // src/utils/deploy.ts
16476
- async function deploy(ConfigClass = Config, packagePath) {
16491
+ async function deploy(ConfigClass = Config, packagePath, pubFilePath) {
16477
16492
  const vars = ConfigClass.vars;
16478
- await PublishSingleton.publish(ADMIN_KEYPAIR, packagePath);
16493
+ await PublishSingleton.publish(ADMIN_KEYPAIR, packagePath, pubFilePath);
16479
16494
  const newConfig = {
16480
16495
  ...vars,
16481
16496
  PACKAGE_ID: PublishSingleton.packageId,