@easysui/sdk 0.1.1 → 0.2.1
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/README.md +2 -3
- package/dist/index.d.mts +48 -17
- package/dist/index.d.ts +48 -17
- package/dist/index.js +170 -80
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +170 -81
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ var cryptography = require('@mysten/sui/cryptography');
|
|
|
8
8
|
var ed25519 = require('@mysten/sui/keypairs/ed25519');
|
|
9
9
|
var secp256k1 = require('@mysten/sui/keypairs/secp256k1');
|
|
10
10
|
var secp256r1 = require('@mysten/sui/keypairs/secp256r1');
|
|
11
|
+
var utils = require('@mysten/sui/utils');
|
|
11
12
|
var transactions = require('@mysten/sui/transactions');
|
|
12
13
|
var bcs = require('@mysten/sui/bcs');
|
|
13
14
|
var child_process = require('child_process');
|
|
@@ -57,20 +58,26 @@ function getKeypair(privkey) {
|
|
|
57
58
|
|
|
58
59
|
// src/config/static.ts
|
|
59
60
|
var STATIC_CONFIGS = {
|
|
61
|
+
localnet: {
|
|
62
|
+
CHAIN_ID: "d07607dc"
|
|
63
|
+
},
|
|
64
|
+
devnet: {
|
|
65
|
+
CHAIN_ID: "4c78adac"
|
|
66
|
+
},
|
|
60
67
|
testnet: {
|
|
68
|
+
CHAIN_ID: "4c78adac",
|
|
61
69
|
USDC_PACKAGE_ID: "0xa1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29"
|
|
62
70
|
},
|
|
63
71
|
mainnet: {
|
|
72
|
+
CHAIN_ID: "35834a8a",
|
|
64
73
|
USDC_PACKAGE_ID: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7"
|
|
65
74
|
}
|
|
66
75
|
};
|
|
67
|
-
|
|
68
|
-
// src/config/config.ts
|
|
69
|
-
dotenv__default.default.config({ path: path__default.default.resolve(process.cwd(), ".env") });
|
|
76
|
+
dotenv__default.default.config({ path: path__default.default.resolve(process.cwd(), ".env"), quiet: true });
|
|
70
77
|
var DENY_LIST_ID = "0x403";
|
|
71
|
-
var CLOCK_ID =
|
|
78
|
+
var CLOCK_ID = utils.SUI_CLOCK_OBJECT_ID;
|
|
72
79
|
var COIN_REGISTRY = "0x000000000000000000000000000000000000000000000000000000000000000c";
|
|
73
|
-
var ADMIN_KEYPAIR = getKeypair(process.env.ADMIN_PRIVATE_KEY);
|
|
80
|
+
var ADMIN_KEYPAIR = process.env.ADMIN_PRIVATE_KEY ? getKeypair(process.env.ADMIN_PRIVATE_KEY) : void 0;
|
|
74
81
|
var Config = class _Config {
|
|
75
82
|
static instance = null;
|
|
76
83
|
static getInstance() {
|
|
@@ -80,7 +87,7 @@ var Config = class _Config {
|
|
|
80
87
|
return this.instance;
|
|
81
88
|
}
|
|
82
89
|
get env() {
|
|
83
|
-
let env = process.env.
|
|
90
|
+
let env = process.env.NETWORK;
|
|
84
91
|
if (!["mainnet", "testnet", "devnet", "localnet"].includes(env || "")) {
|
|
85
92
|
env = "localnet";
|
|
86
93
|
}
|
|
@@ -96,7 +103,7 @@ var Config = class _Config {
|
|
|
96
103
|
static get vars() {
|
|
97
104
|
const instance = this.getInstance();
|
|
98
105
|
const NETWORK = instance.env;
|
|
99
|
-
dotenv__default.default.config({ path: path__default.default.resolve(process.cwd(), `.env.${NETWORK}`), override: true });
|
|
106
|
+
dotenv__default.default.config({ path: path__default.default.resolve(process.cwd(), `.env.${NETWORK}`), override: true, quiet: true });
|
|
100
107
|
const envVars = {
|
|
101
108
|
NETWORK,
|
|
102
109
|
RPC: client.getFullnodeUrl(NETWORK),
|
|
@@ -160,6 +167,22 @@ function analyze_cost(ptb, resp) {
|
|
|
160
167
|
columns.push(gasSpent);
|
|
161
168
|
fs3__namespace.appendFileSync(COST_ANALYSIS_FILE, columns.join(",") + "\n");
|
|
162
169
|
}
|
|
170
|
+
function toFormatType(type, bytes) {
|
|
171
|
+
switch (type) {
|
|
172
|
+
case 2 /* base64 */:
|
|
173
|
+
return utils.toBase64(bytes);
|
|
174
|
+
case 1 /* hex */:
|
|
175
|
+
return utils.toHex(bytes);
|
|
176
|
+
default:
|
|
177
|
+
throw "The FORMAT_TYPES must be one of hex or base64";
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
function isHex(str) {
|
|
181
|
+
return /^[0-9a-fA-F]+$/.test(str) && str.length % 2 === 0;
|
|
182
|
+
}
|
|
183
|
+
function hexToBase64(hex) {
|
|
184
|
+
return utils.toBase64(utils.fromHex(hex));
|
|
185
|
+
}
|
|
163
186
|
|
|
164
187
|
// src/utils/sui_client.ts
|
|
165
188
|
var MoveType = /* @__PURE__ */ ((MoveType2) => {
|
|
@@ -171,12 +194,19 @@ var MoveType = /* @__PURE__ */ ((MoveType2) => {
|
|
|
171
194
|
MoveType2[MoveType2["u256"] = 6] = "u256";
|
|
172
195
|
MoveType2[MoveType2["bool"] = 7] = "bool";
|
|
173
196
|
MoveType2[MoveType2["string"] = 8] = "string";
|
|
174
|
-
MoveType2[MoveType2["
|
|
175
|
-
MoveType2[MoveType2["
|
|
176
|
-
MoveType2[MoveType2["
|
|
177
|
-
MoveType2[MoveType2["
|
|
197
|
+
MoveType2[MoveType2["string_opt"] = 9] = "string_opt";
|
|
198
|
+
MoveType2[MoveType2["object"] = 10] = "object";
|
|
199
|
+
MoveType2[MoveType2["address"] = 11] = "address";
|
|
200
|
+
MoveType2[MoveType2["address_opt"] = 12] = "address_opt";
|
|
201
|
+
MoveType2[MoveType2["vec_address"] = 13] = "vec_address";
|
|
202
|
+
MoveType2[MoveType2["vec_u64"] = 14] = "vec_u64";
|
|
178
203
|
return MoveType2;
|
|
179
204
|
})(MoveType || {});
|
|
205
|
+
var txOptions = {
|
|
206
|
+
showEffects: true,
|
|
207
|
+
showObjectChanges: true,
|
|
208
|
+
showBalanceChanges: true
|
|
209
|
+
};
|
|
180
210
|
var SuiClient = class _SuiClient {
|
|
181
211
|
static instance = null;
|
|
182
212
|
client;
|
|
@@ -192,26 +222,21 @@ var SuiClient = class _SuiClient {
|
|
|
192
222
|
static get client() {
|
|
193
223
|
return this.getInstance().client;
|
|
194
224
|
}
|
|
195
|
-
static async
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
signer,
|
|
200
|
-
options: {
|
|
201
|
-
showEffects: true,
|
|
202
|
-
showObjectChanges: true,
|
|
203
|
-
showBalanceChanges: true
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
await _SuiClient.client.waitForTransaction({ digest: resp.digest });
|
|
207
|
-
if (resp.effects?.status.status !== "success") {
|
|
208
|
-
throw new Error(JSON.stringify(resp));
|
|
209
|
-
}
|
|
210
|
-
analyze_cost(ptb, resp);
|
|
211
|
-
return resp;
|
|
212
|
-
} catch (e) {
|
|
213
|
-
throw new Error(errorHandler(e));
|
|
225
|
+
static async waitForTransaction(ptb, resp) {
|
|
226
|
+
await _SuiClient.client.waitForTransaction({ digest: resp.digest });
|
|
227
|
+
if (resp.effects?.status.status !== "success") {
|
|
228
|
+
throw new Error(JSON.stringify(resp));
|
|
214
229
|
}
|
|
230
|
+
analyze_cost(ptb, resp);
|
|
231
|
+
return resp;
|
|
232
|
+
}
|
|
233
|
+
static async signAndExecute(ptb, signer) {
|
|
234
|
+
const resp = await _SuiClient.client.signAndExecuteTransaction({
|
|
235
|
+
transaction: ptb,
|
|
236
|
+
signer,
|
|
237
|
+
options: txOptions
|
|
238
|
+
});
|
|
239
|
+
return _SuiClient.waitForTransaction(ptb, resp);
|
|
215
240
|
}
|
|
216
241
|
static toMoveArg(ptb, value, type) {
|
|
217
242
|
if (typeof value === "object" && !Array.isArray(value)) {
|
|
@@ -220,7 +245,7 @@ var SuiClient = class _SuiClient {
|
|
|
220
245
|
if (!type) {
|
|
221
246
|
if (typeof value === "string") {
|
|
222
247
|
if (value.startsWith("0x")) {
|
|
223
|
-
type =
|
|
248
|
+
type = 10 /* object */;
|
|
224
249
|
} else {
|
|
225
250
|
type = 8 /* string */;
|
|
226
251
|
}
|
|
@@ -239,10 +264,12 @@ var SuiClient = class _SuiClient {
|
|
|
239
264
|
[6 /* u256 */]: (v) => ptb.pure.u256(v),
|
|
240
265
|
[7 /* bool */]: (v) => ptb.pure.bool(v),
|
|
241
266
|
[8 /* string */]: (v) => ptb.pure.string(v),
|
|
242
|
-
[9 /*
|
|
243
|
-
[10 /*
|
|
244
|
-
[11 /*
|
|
245
|
-
[12 /*
|
|
267
|
+
[9 /* string_opt */]: (v) => ptb.pure.option("string", v),
|
|
268
|
+
[10 /* object */]: (v) => ptb.object(v),
|
|
269
|
+
[11 /* address */]: (v) => ptb.pure.address(v),
|
|
270
|
+
[12 /* address_opt */]: (v) => ptb.pure.option("address", v),
|
|
271
|
+
[13 /* vec_address */]: (v) => ptb.pure.vector("address", v),
|
|
272
|
+
[14 /* vec_u64 */]: (v) => ptb.pure.vector("u64", v)
|
|
246
273
|
};
|
|
247
274
|
return factory[type](value);
|
|
248
275
|
}
|
|
@@ -252,20 +279,73 @@ var SuiClient = class _SuiClient {
|
|
|
252
279
|
typeArgs = [],
|
|
253
280
|
args = [],
|
|
254
281
|
argTypes = [],
|
|
255
|
-
errorHandler = (e) => e,
|
|
256
282
|
ptb,
|
|
257
283
|
withTransfer = false
|
|
258
284
|
}) {
|
|
285
|
+
ptb = this.getPTB(target, typeArgs, args, argTypes, signer.toSuiAddress(), withTransfer, ptb);
|
|
286
|
+
return _SuiClient.signAndExecute(ptb, signer);
|
|
287
|
+
}
|
|
288
|
+
static async getMoveCallBytes({
|
|
289
|
+
signer,
|
|
290
|
+
target,
|
|
291
|
+
typeArgs = [],
|
|
292
|
+
args = [],
|
|
293
|
+
argTypes = [],
|
|
294
|
+
ptb,
|
|
295
|
+
withTransfer = false,
|
|
296
|
+
gasOwner,
|
|
297
|
+
format = 1 /* hex */
|
|
298
|
+
}) {
|
|
299
|
+
ptb = this.getPTB(target, typeArgs, args, argTypes, signer, withTransfer, ptb);
|
|
300
|
+
return await this.getMoveCallBytesFromPTB(ptb, signer, gasOwner, format);
|
|
301
|
+
}
|
|
302
|
+
static async getMoveCallBytesFromPTB(ptb, signer, gasOwner, format = 1 /* hex */) {
|
|
303
|
+
ptb.setSender(signer);
|
|
304
|
+
gasOwner ??= signer;
|
|
305
|
+
ptb.setGasOwner(gasOwner || signer);
|
|
306
|
+
const bytes = await ptb.build({ client: _SuiClient.client, onlyTransactionKind: false });
|
|
307
|
+
return toFormatType(format, bytes);
|
|
308
|
+
}
|
|
309
|
+
static toBytes(bytes) {
|
|
310
|
+
if (typeof bytes === "string") {
|
|
311
|
+
return isHex(bytes) ? utils.fromHex(bytes) : utils.fromBase64(bytes);
|
|
312
|
+
}
|
|
313
|
+
return bytes;
|
|
314
|
+
}
|
|
315
|
+
static async getSignature(signatureOrKeypair, bytes) {
|
|
316
|
+
if (typeof signatureOrKeypair !== "string") {
|
|
317
|
+
const signature = await signatureOrKeypair.signTransaction(bytes);
|
|
318
|
+
return signature.signature;
|
|
319
|
+
}
|
|
320
|
+
return isHex(signatureOrKeypair) ? hexToBase64(signatureOrKeypair) : signatureOrKeypair;
|
|
321
|
+
}
|
|
322
|
+
static async executeMoveCallBytes(bytes, senderSignature, gasOwnerSignature) {
|
|
323
|
+
const transactionBlock = this.toBytes(bytes);
|
|
324
|
+
senderSignature = await this.getSignature(senderSignature, transactionBlock);
|
|
325
|
+
const signature = [senderSignature];
|
|
326
|
+
if (gasOwnerSignature) {
|
|
327
|
+
gasOwnerSignature = await this.getSignature(gasOwnerSignature, transactionBlock);
|
|
328
|
+
signature.push(gasOwnerSignature);
|
|
329
|
+
}
|
|
330
|
+
const resp = await _SuiClient.client.executeTransactionBlock({
|
|
331
|
+
transactionBlock: utils.toBase64(transactionBlock),
|
|
332
|
+
signature,
|
|
333
|
+
options: txOptions
|
|
334
|
+
});
|
|
335
|
+
const ptb = transactions.Transaction.from(utils.toBase64(transactionBlock));
|
|
336
|
+
return _SuiClient.waitForTransaction(ptb, resp);
|
|
337
|
+
}
|
|
338
|
+
static getPTB(target, typeArgs = [], args = [], argTypes = [], signer, withTransfer = false, ptb) {
|
|
259
339
|
ptb = ptb || new transactions.Transaction();
|
|
260
340
|
const obj = ptb.moveCall({
|
|
261
341
|
target,
|
|
262
342
|
typeArguments: typeArgs,
|
|
263
343
|
arguments: args.map((arg, i) => _SuiClient.toMoveArg(ptb, arg, argTypes[i]))
|
|
264
344
|
});
|
|
265
|
-
if (withTransfer) {
|
|
266
|
-
ptb.transferObjects([obj], signer
|
|
345
|
+
if (withTransfer && signer) {
|
|
346
|
+
ptb.transferObjects([obj], signer);
|
|
267
347
|
}
|
|
268
|
-
return
|
|
348
|
+
return ptb;
|
|
269
349
|
}
|
|
270
350
|
static async public_transfer(objects, from, to) {
|
|
271
351
|
const tx = new transactions.Transaction();
|
|
@@ -298,10 +378,22 @@ var SuiClient = class _SuiClient {
|
|
|
298
378
|
const bytes = Uint8Array.from(value);
|
|
299
379
|
return "0x" + Buffer.from(bytes).toString("hex");
|
|
300
380
|
}
|
|
381
|
+
static async devInspectString(ptb, sender) {
|
|
382
|
+
const value = await this.devInspectRaw(ptb, sender);
|
|
383
|
+
if (!value) {
|
|
384
|
+
return "";
|
|
385
|
+
}
|
|
386
|
+
return bcs.bcs.string().parse(new Uint8Array(value));
|
|
387
|
+
}
|
|
301
388
|
static async getObject(id) {
|
|
302
389
|
return _SuiClient.client.getObject({
|
|
303
390
|
id,
|
|
304
|
-
options: {
|
|
391
|
+
options: {
|
|
392
|
+
showContent: true,
|
|
393
|
+
showType: true,
|
|
394
|
+
showDisplay: true,
|
|
395
|
+
showBcs: true
|
|
396
|
+
}
|
|
305
397
|
});
|
|
306
398
|
}
|
|
307
399
|
static async getObjectsByType(owner, type) {
|
|
@@ -346,7 +438,7 @@ var Coin = class {
|
|
|
346
438
|
target: `0x2::coin::mint`,
|
|
347
439
|
typeArgs: [this.coinType],
|
|
348
440
|
args: [treasuryId, amount],
|
|
349
|
-
argTypes: [
|
|
441
|
+
argTypes: [10 /* object */, 4 /* u64 */],
|
|
350
442
|
withTransfer: true
|
|
351
443
|
});
|
|
352
444
|
}
|
|
@@ -361,7 +453,7 @@ var Coin = class {
|
|
|
361
453
|
target: `0x2::coin_registry::finalize_registration`,
|
|
362
454
|
typeArgs: [this.coinType],
|
|
363
455
|
args: [COIN_REGISTRY, currencyId],
|
|
364
|
-
argTypes: [
|
|
456
|
+
argTypes: [10 /* object */, 10 /* object */]
|
|
365
457
|
});
|
|
366
458
|
}
|
|
367
459
|
static async send(amount, from, to) {
|
|
@@ -395,7 +487,7 @@ var USDC = class extends Coin {
|
|
|
395
487
|
target: `${Config.vars.USDC_PACKAGE_ID}::treasury::configure_new_controller`,
|
|
396
488
|
typeArgs: [this.coinType],
|
|
397
489
|
args: [Config.vars.USDC_TREASURY_CAP, admin.toSuiAddress(), admin.toSuiAddress()],
|
|
398
|
-
argTypes: [
|
|
490
|
+
argTypes: [10 /* object */, 11 /* address */, 11 /* address */]
|
|
399
491
|
});
|
|
400
492
|
mintCapId = await getMintCapFromChain();
|
|
401
493
|
}
|
|
@@ -408,7 +500,7 @@ var USDC = class extends Coin {
|
|
|
408
500
|
target: `${Config.vars.USDC_PACKAGE_ID}::treasury::configure_minter`,
|
|
409
501
|
typeArgs: [this.coinType],
|
|
410
502
|
args: [Config.vars.USDC_TREASURY_CAP, DENY_LIST_ID, amount],
|
|
411
|
-
argTypes: [
|
|
503
|
+
argTypes: [10 /* object */, 10 /* object */, 4 /* u64 */]
|
|
412
504
|
});
|
|
413
505
|
await SuiClient.moveCall({
|
|
414
506
|
signer: admin,
|
|
@@ -416,11 +508,11 @@ var USDC = class extends Coin {
|
|
|
416
508
|
typeArgs: [this.coinType],
|
|
417
509
|
args: [Config.vars.USDC_TREASURY_CAP, mintCapId, DENY_LIST_ID, amount, receiver],
|
|
418
510
|
argTypes: [
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
511
|
+
10 /* object */,
|
|
512
|
+
10 /* object */,
|
|
513
|
+
10 /* object */,
|
|
422
514
|
4 /* u64 */,
|
|
423
|
-
|
|
515
|
+
11 /* address */
|
|
424
516
|
]
|
|
425
517
|
});
|
|
426
518
|
}
|
|
@@ -483,53 +575,41 @@ var PublishSingleton = class _PublishSingleton {
|
|
|
483
575
|
false
|
|
484
576
|
);
|
|
485
577
|
}
|
|
486
|
-
static
|
|
487
|
-
const
|
|
578
|
+
static getPublishCmd(packagePath, sender, inBytes = false) {
|
|
579
|
+
const network = Config.vars.NETWORK;
|
|
488
580
|
if (!fs3__namespace.default.existsSync(packagePath)) {
|
|
489
581
|
throw new Error(`Package doesn't exist under: ${packagePath}`);
|
|
490
582
|
}
|
|
491
583
|
if (fs3__namespace.default.existsSync(`${packagePath}/Move.lock`)) {
|
|
492
584
|
fs3__namespace.default.unlinkSync(`${packagePath}/Move.lock`);
|
|
493
585
|
}
|
|
586
|
+
if (fs3__namespace.default.existsSync(`Pub.${network}.toml`)) {
|
|
587
|
+
fs3__namespace.default.unlinkSync(`Pub.${network}.toml`);
|
|
588
|
+
}
|
|
494
589
|
fs3__namespace.default.rmSync(`${packagePath}/build`, { recursive: true, force: true });
|
|
495
|
-
|
|
496
|
-
const
|
|
590
|
+
const isEphemeralChain = network !== "mainnet" && network !== "testnet";
|
|
591
|
+
const publishCmd = isEphemeralChain ? `test-publish --build-env testnet` : "publish";
|
|
592
|
+
let buildCommand = `sui client ${publishCmd} ${packagePath}`;
|
|
497
593
|
if (network === "localnet" || network === "devnet") {
|
|
498
594
|
buildCommand += " --with-unpublished-dependencies";
|
|
499
595
|
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
modules,
|
|
503
|
-
dependencies
|
|
504
|
-
});
|
|
505
|
-
transaction.transferObjects([upgradeCap], sender);
|
|
506
|
-
return transaction;
|
|
596
|
+
buildCommand += inBytes ? " --serialize-unsigned-transaction" : " --json";
|
|
597
|
+
return buildCommand;
|
|
507
598
|
}
|
|
508
599
|
static async getPublishBytes(signer, packagePath) {
|
|
509
600
|
signer ??= ADMIN_KEYPAIR.toSuiAddress();
|
|
510
601
|
const _packagePath = this.getPackagePath(packagePath);
|
|
511
|
-
const
|
|
512
|
-
|
|
513
|
-
const txBytes = await transaction.build({ client: client$1, onlyTransactionKind: true });
|
|
514
|
-
return Buffer.from(txBytes).toString("base64");
|
|
602
|
+
const cmd = this.getPublishCmd(_packagePath, signer, true);
|
|
603
|
+
return child_process.execSync(cmd, { encoding: "utf-8" }).trim();
|
|
515
604
|
}
|
|
516
605
|
static async publishPackage(signer, packagePath) {
|
|
517
|
-
const
|
|
518
|
-
const
|
|
519
|
-
const
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
options: {
|
|
523
|
-
showObjectChanges: true,
|
|
524
|
-
showEffects: true
|
|
525
|
-
}
|
|
526
|
-
});
|
|
527
|
-
if (resp.effects?.status.status !== "success") {
|
|
528
|
-
throw new Error(`Failure during publish transaction:
|
|
529
|
-
${JSON.stringify(resp, null, 2)}`);
|
|
606
|
+
const cmd = this.getPublishCmd(packagePath, signer.toSuiAddress());
|
|
607
|
+
const res = child_process.execSync(cmd, { encoding: "utf-8" });
|
|
608
|
+
const match = res.match(/\{[\s\S]*\}/);
|
|
609
|
+
if (!match) {
|
|
610
|
+
throw new Error(`No JSON found in the publish command output: ${res}`);
|
|
530
611
|
}
|
|
531
|
-
|
|
532
|
-
return resp;
|
|
612
|
+
return JSON.parse(match[0]);
|
|
533
613
|
}
|
|
534
614
|
static findPublishedPackage(resp) {
|
|
535
615
|
return resp.objectChanges?.find(
|
|
@@ -544,9 +624,9 @@ ${JSON.stringify(resp, null, 2)}`);
|
|
|
544
624
|
};
|
|
545
625
|
|
|
546
626
|
// src/utils/deploy.ts
|
|
547
|
-
async function deploy(ConfigClass = Config) {
|
|
627
|
+
async function deploy(ConfigClass = Config, packagePath) {
|
|
548
628
|
const vars = ConfigClass.vars;
|
|
549
|
-
await PublishSingleton.publish();
|
|
629
|
+
await PublishSingleton.publish(ADMIN_KEYPAIR, packagePath);
|
|
550
630
|
const newConfig = {
|
|
551
631
|
...vars,
|
|
552
632
|
PACKAGE_ID: PublishSingleton.packageId,
|
|
@@ -604,6 +684,15 @@ async function waitForNextEpoch(timeoutMs = 5 * 60 * 1e3, pollIntervalMs = 2e3)
|
|
|
604
684
|
await sleep(pollIntervalMs);
|
|
605
685
|
}
|
|
606
686
|
}
|
|
687
|
+
function deriveObjectId(parentId, module, key, packageId, type, serializedBcs) {
|
|
688
|
+
serializedBcs ??= bcs.bcs.struct(key, { dummy_value: bcs.bcs.bool() }).serialize({ dummy_value: false });
|
|
689
|
+
const keyU8 = serializedBcs.toBytes();
|
|
690
|
+
let typeTag = `${packageId}::${module}::${key}`;
|
|
691
|
+
if (type) {
|
|
692
|
+
typeTag += `<${type}>`;
|
|
693
|
+
}
|
|
694
|
+
return utils.deriveObjectID(parentId, typeTag, keyU8);
|
|
695
|
+
}
|
|
607
696
|
|
|
608
697
|
exports.ADMIN_KEYPAIR = ADMIN_KEYPAIR;
|
|
609
698
|
exports.CLOCK_ID = CLOCK_ID;
|
|
@@ -619,6 +708,7 @@ exports.analyze_cost = analyze_cost;
|
|
|
619
708
|
exports.createFundedWallet = createFundedWallet;
|
|
620
709
|
exports.createWallet = createWallet;
|
|
621
710
|
exports.deploy = deploy;
|
|
711
|
+
exports.deriveObjectId = deriveObjectId;
|
|
622
712
|
exports.getDeployBytes = getDeployBytes;
|
|
623
713
|
exports.getKeypair = getKeypair;
|
|
624
714
|
exports.sleep = sleep;
|