@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.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import { Secp256r1Keypair } from '@mysten/sui/keypairs/secp256r1';
|
|
|
10
10
|
import { SUI_CLOCK_OBJECT_ID, fromHex, fromBase64, toBase64, normalizeStructTag, deriveObjectID, toHex } from '@mysten/sui/utils';
|
|
11
11
|
import { Transaction, coinWithBalance } from '@mysten/sui/transactions';
|
|
12
12
|
import { bcs } from '@mysten/sui/bcs';
|
|
13
|
-
import {
|
|
13
|
+
import { spawn } from 'child_process';
|
|
14
14
|
import { requestSuiFromFaucetV2, getFaucetHost } from '@mysten/sui/faucet';
|
|
15
15
|
|
|
16
16
|
var __create = Object.create;
|
|
@@ -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,
|
|
@@ -16341,6 +16342,31 @@ var USDC = class extends Coin {
|
|
|
16341
16342
|
});
|
|
16342
16343
|
}
|
|
16343
16344
|
};
|
|
16345
|
+
function execCmd(cmd) {
|
|
16346
|
+
return new Promise((resolve3, reject) => {
|
|
16347
|
+
const child = spawn(cmd, { shell: true });
|
|
16348
|
+
let stdout = "";
|
|
16349
|
+
let stderr = "";
|
|
16350
|
+
child.stdout.on("data", (data) => {
|
|
16351
|
+
stdout += data.toString();
|
|
16352
|
+
});
|
|
16353
|
+
child.stderr.on("data", (data) => {
|
|
16354
|
+
stderr += data.toString();
|
|
16355
|
+
});
|
|
16356
|
+
child.on("error", (err) => reject(err));
|
|
16357
|
+
child.on("close", (code) => {
|
|
16358
|
+
if (code === 0) {
|
|
16359
|
+
resolve3(stdout.trim());
|
|
16360
|
+
} else {
|
|
16361
|
+
const output = [stderr.trim(), stdout.trim()].filter(Boolean).join("\n") || `Process exited with code ${code}`;
|
|
16362
|
+
reject(new Error(`Publish bytes command failed:
|
|
16363
|
+
${output}`));
|
|
16364
|
+
}
|
|
16365
|
+
});
|
|
16366
|
+
});
|
|
16367
|
+
}
|
|
16368
|
+
|
|
16369
|
+
// src/utils/publish.ts
|
|
16344
16370
|
var PublishSingleton = class _PublishSingleton {
|
|
16345
16371
|
constructor(publishResp) {
|
|
16346
16372
|
this.publishResp = publishResp;
|
|
@@ -16355,11 +16381,21 @@ var PublishSingleton = class _PublishSingleton {
|
|
|
16355
16381
|
}
|
|
16356
16382
|
return packagePath;
|
|
16357
16383
|
}
|
|
16358
|
-
static
|
|
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) {
|
|
16359
16394
|
signer ??= ADMIN_KEYPAIR;
|
|
16360
16395
|
const _packagePath = this.getPackagePath(packagePath);
|
|
16396
|
+
const _pubFilePath = this.getPubFilePath(pubFilePath);
|
|
16361
16397
|
if (!_PublishSingleton.instance) {
|
|
16362
|
-
const publishResp = await _PublishSingleton.publishPackage(signer, _packagePath);
|
|
16398
|
+
const publishResp = await _PublishSingleton.publishPackage(signer, _packagePath, _pubFilePath);
|
|
16363
16399
|
_PublishSingleton.instance = new _PublishSingleton(publishResp);
|
|
16364
16400
|
}
|
|
16365
16401
|
}
|
|
@@ -16395,7 +16431,7 @@ var PublishSingleton = class _PublishSingleton {
|
|
|
16395
16431
|
false
|
|
16396
16432
|
);
|
|
16397
16433
|
}
|
|
16398
|
-
static getPublishCmd(packagePath, sender, inBytes = false) {
|
|
16434
|
+
static getPublishCmd(packagePath, sender, pubFilePath, inBytes = false) {
|
|
16399
16435
|
const network = Config.vars.NETWORK;
|
|
16400
16436
|
if (!fs3__default.existsSync(packagePath)) {
|
|
16401
16437
|
throw new Error(`Package doesn't exist under: ${packagePath}`);
|
|
@@ -16410,18 +16446,22 @@ var PublishSingleton = class _PublishSingleton {
|
|
|
16410
16446
|
if (isEphemeralChain) {
|
|
16411
16447
|
buildCommand += " --publish-unpublished-deps";
|
|
16412
16448
|
}
|
|
16449
|
+
if (pubFilePath) {
|
|
16450
|
+
buildCommand += ` --pubfile-path ${pubFilePath}`;
|
|
16451
|
+
}
|
|
16413
16452
|
buildCommand += inBytes ? ` --serialize-unsigned-transaction --sender ${sender}` : " --json";
|
|
16414
16453
|
return buildCommand;
|
|
16415
16454
|
}
|
|
16416
|
-
static async getPublishBytes(signer, packagePath) {
|
|
16455
|
+
static async getPublishBytes(signer, packagePath, pubFilePath) {
|
|
16417
16456
|
signer ??= ADMIN_KEYPAIR.toSuiAddress();
|
|
16418
16457
|
const _packagePath = this.getPackagePath(packagePath);
|
|
16419
|
-
const
|
|
16420
|
-
|
|
16458
|
+
const _pubFilePath = this.getPubFilePath(pubFilePath);
|
|
16459
|
+
const cmd = this.getPublishCmd(_packagePath, signer, _pubFilePath, true);
|
|
16460
|
+
return execCmd(cmd);
|
|
16421
16461
|
}
|
|
16422
|
-
static async publishPackage(signer, packagePath) {
|
|
16423
|
-
const cmd = this.getPublishCmd(packagePath, signer.toSuiAddress());
|
|
16424
|
-
const res =
|
|
16462
|
+
static async publishPackage(signer, packagePath, pubFilePath) {
|
|
16463
|
+
const cmd = this.getPublishCmd(packagePath, signer.toSuiAddress(), pubFilePath);
|
|
16464
|
+
const res = await execCmd(cmd);
|
|
16425
16465
|
const match = res.match(/\{[\s\S]*\}/);
|
|
16426
16466
|
if (!match) {
|
|
16427
16467
|
throw new Error(`No JSON found in the publish command output: ${res}`);
|
|
@@ -16448,9 +16488,9 @@ var PublishSingleton = class _PublishSingleton {
|
|
|
16448
16488
|
};
|
|
16449
16489
|
|
|
16450
16490
|
// src/utils/deploy.ts
|
|
16451
|
-
async function deploy(ConfigClass = Config, packagePath) {
|
|
16491
|
+
async function deploy(ConfigClass = Config, packagePath, pubFilePath) {
|
|
16452
16492
|
const vars = ConfigClass.vars;
|
|
16453
|
-
await PublishSingleton.publish(ADMIN_KEYPAIR, packagePath);
|
|
16493
|
+
await PublishSingleton.publish(ADMIN_KEYPAIR, packagePath, pubFilePath);
|
|
16454
16494
|
const newConfig = {
|
|
16455
16495
|
...vars,
|
|
16456
16496
|
PACKAGE_ID: PublishSingleton.packageId,
|