@easysui/sdk 1.0.1 → 1.2.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 CHANGED
@@ -1,7 +1,8 @@
1
1
  import { Keypair } from '@mysten/sui/cryptography';
2
+ import * as _mysten_sui_transactions from '@mysten/sui/transactions';
2
3
  import { Transaction } from '@mysten/sui/transactions';
3
- import * as _mysten_sui_jsonRpc from '@mysten/sui/jsonRpc';
4
- import { SuiTransactionBlockResponse, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
4
+ import { SuiClientTypes } from '@mysten/sui/client';
5
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
5
6
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
6
7
 
7
8
  type Network = 'mainnet' | 'testnet' | 'devnet' | 'localnet';
@@ -19,6 +20,7 @@ interface BaseConfigVars {
19
20
  PACKAGE_PATH: string;
20
21
  PACKAGE_ID: string;
21
22
  UPGRADE_CAP_ID: string;
23
+ PUBFILE_PATH?: string;
22
24
  USDC_PACKAGE_ID?: string;
23
25
  USDC_TREASURY_CAP?: string;
24
26
  }
@@ -37,6 +39,7 @@ declare class Config<TConfigVars extends BaseConfigVars = ConfigVars> {
37
39
  declare class Coin {
38
40
  static get coinType(): string;
39
41
  static getBalance(owner: string): Promise<bigint>;
42
+ static coinWithBalance(balance: bigint): (tx: Transaction) => _mysten_sui_transactions.TransactionResult;
40
43
  static getCoin(owner: Keypair, amount?: bigint): Promise<string>;
41
44
  static _mint(treasuryId: string, amount: bigint, minter: Keypair): Promise<void>;
42
45
  static finalizeRegistration(registrar: Keypair): Promise<void>;
@@ -50,9 +53,9 @@ declare class USDC extends Coin {
50
53
  static faucet(amount: bigint, receiver: string, admin: Keypair): Promise<void>;
51
54
  }
52
55
 
53
- declare function analyze_cost(ptb: Transaction, resp: SuiTransactionBlockResponse): void;
56
+ declare function analyze_cost(ptb: Transaction, resp: SuiClientTypes.Transaction): void;
54
57
 
55
- declare function deploy<TConfig extends typeof Config = typeof Config, TConfigVars extends BaseConfigVars = BaseConfigVars>(ConfigClass?: TConfig, packagePath?: string): Promise<string>;
58
+ declare function deploy<TConfig extends typeof Config = typeof Config, TConfigVars extends BaseConfigVars = BaseConfigVars>(ConfigClass?: TConfig, packagePath?: string, pubFilePath?: string): Promise<string>;
56
59
  declare function getDeployBytes(): Promise<string>;
57
60
 
58
61
  declare function getKeypair(privkey: string): Keypair;
@@ -224,7 +227,8 @@ declare class PublishSingleton {
224
227
  private static instance;
225
228
  private constructor();
226
229
  private static getPackagePath;
227
- static publish(signer?: Keypair, packagePath?: string): Promise<void>;
230
+ private static getPubFilePath;
231
+ static publish(signer?: Keypair, packagePath?: string, pubFilePath?: string): Promise<void>;
228
232
  private static getInstance;
229
233
  static publishResponse(): SuiPublishResponse;
230
234
  static get packageId(): string;
@@ -232,8 +236,8 @@ declare class PublishSingleton {
232
236
  static get upgradeCapId(): string;
233
237
  static get usdcTreasuryCap(): string;
234
238
  private static getPublishCmd;
235
- static getPublishBytes(signer?: string, packagePath?: string): Promise<string>;
236
- static publishPackage(signer: Keypair, packagePath: string): Promise<SuiPublishResponse>;
239
+ static getPublishBytes(signer?: string, packagePath?: string, pubFilePath?: string): Promise<string>;
240
+ static publishPackage(signer: Keypair, packagePath: string, pubFilePath: string): Promise<SuiPublishResponse>;
237
241
  static findPublishedPackage(resp: SuiPublishResponse): ChangedObjectFlat | undefined;
238
242
  static findObjectChangeCreatedByType(resp: SuiPublishResponse, type: string): ChangedObjectFlat | undefined;
239
243
  static get pubFile(): string;
@@ -266,9 +270,9 @@ declare class SuiClient {
266
270
  private client;
267
271
  private constructor();
268
272
  private static getInstance;
269
- static get client(): SuiJsonRpcClient;
273
+ static get client(): SuiGrpcClient;
270
274
  private static waitForTransaction;
271
- static signAndExecute(ptb: Transaction, signer: Keypair): Promise<SuiTransactionBlockResponse>;
275
+ static signAndExecute(ptb: Transaction, signer: Keypair): Promise<SuiClientTypes.Transaction<{}>>;
272
276
  static toMoveArg(ptb: Transaction, value: any, type?: MoveType): any;
273
277
  static moveCall({ signer, target, typeArgs, args, argTypes, ptb, withTransfer, }: {
274
278
  signer: Keypair;
@@ -278,7 +282,7 @@ declare class SuiClient {
278
282
  argTypes?: MoveType[];
279
283
  ptb?: Transaction;
280
284
  withTransfer?: boolean;
281
- }): Promise<SuiTransactionBlockResponse>;
285
+ }): Promise<SuiClientTypes.Transaction<{}>>;
282
286
  static getMoveCallBytes({ signer, target, typeArgs, args, argTypes, ptb, withTransfer, gasOwner, format }: {
283
287
  signer: string;
284
288
  target: string;
@@ -293,17 +297,24 @@ declare class SuiClient {
293
297
  static getMoveCallBytesFromPTB(ptb: Transaction, signer: string, gasOwner?: string, format?: FORMAT_TYPES): Promise<string>;
294
298
  static toBytes(bytes: Uint8Array | string): Uint8Array<ArrayBufferLike>;
295
299
  static getSignature(signatureOrKeypair: string | Keypair, bytes: Uint8Array): Promise<string>;
296
- static executeMoveCallBytes(bytes: Uint8Array | string, senderSignature: string | Keypair, gasOwnerSignature?: string | Keypair): Promise<SuiTransactionBlockResponse>;
300
+ static executeMoveCallBytes(bytes: Uint8Array | string, senderSignature: string | Keypair, gasOwnerSignature?: string | Keypair): Promise<SuiClientTypes.Transaction<{}>>;
297
301
  static getPTB(target: string, typeArgs?: string[], args?: any[], argTypes?: MoveType[], signer?: string, withTransfer?: boolean, ptb?: Transaction): Transaction;
298
- static public_transfer(objects: string[], from: Keypair, to: string): Promise<SuiTransactionBlockResponse>;
299
- static devInspect(ptb: Transaction, sender: string): Promise<_mysten_sui_jsonRpc.DevInspectResults>;
300
- static devInspectRaw(ptb: Transaction, sender: string): Promise<number[] | undefined>;
302
+ static public_transfer(objects: string[], from: Keypair, to: string): Promise<SuiClientTypes.Transaction<{}>>;
303
+ static devInspect(ptb: Transaction, sender: string): Promise<SuiClientTypes.SimulateTransactionResult<{
304
+ commandResults: true;
305
+ }>>;
306
+ static devInspectRaw(ptb: Transaction, sender: string): Promise<Uint8Array<ArrayBufferLike> | undefined>;
301
307
  static devInspectBool(ptb: Transaction, sender: string): Promise<boolean | undefined>;
302
308
  static devInspectU64(ptb: Transaction, sender: string): Promise<bigint>;
303
309
  static devInspectAddress(ptb: Transaction, sender: string): Promise<string | undefined>;
304
310
  static devInspectString(ptb: Transaction, sender: string): Promise<string>;
305
- static getObject(id: string): Promise<_mysten_sui_jsonRpc.SuiObjectResponse>;
306
- static getObjectsByType(owner: string, type: string): Promise<(string | undefined)[]>;
311
+ static getObject(id: string): Promise<SuiClientTypes.GetObjectResponse<{
312
+ content: true;
313
+ type: boolean;
314
+ display: true;
315
+ bcs: boolean;
316
+ }>>;
317
+ static getObjectsByType(owner: string, type: string): Promise<string[]>;
307
318
  }
308
319
 
309
320
  declare function createWallet(): Ed25519Keypair;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { Keypair } from '@mysten/sui/cryptography';
2
+ import * as _mysten_sui_transactions from '@mysten/sui/transactions';
2
3
  import { Transaction } from '@mysten/sui/transactions';
3
- import * as _mysten_sui_jsonRpc from '@mysten/sui/jsonRpc';
4
- import { SuiTransactionBlockResponse, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
4
+ import { SuiClientTypes } from '@mysten/sui/client';
5
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
5
6
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
6
7
 
7
8
  type Network = 'mainnet' | 'testnet' | 'devnet' | 'localnet';
@@ -19,6 +20,7 @@ interface BaseConfigVars {
19
20
  PACKAGE_PATH: string;
20
21
  PACKAGE_ID: string;
21
22
  UPGRADE_CAP_ID: string;
23
+ PUBFILE_PATH?: string;
22
24
  USDC_PACKAGE_ID?: string;
23
25
  USDC_TREASURY_CAP?: string;
24
26
  }
@@ -37,6 +39,7 @@ declare class Config<TConfigVars extends BaseConfigVars = ConfigVars> {
37
39
  declare class Coin {
38
40
  static get coinType(): string;
39
41
  static getBalance(owner: string): Promise<bigint>;
42
+ static coinWithBalance(balance: bigint): (tx: Transaction) => _mysten_sui_transactions.TransactionResult;
40
43
  static getCoin(owner: Keypair, amount?: bigint): Promise<string>;
41
44
  static _mint(treasuryId: string, amount: bigint, minter: Keypair): Promise<void>;
42
45
  static finalizeRegistration(registrar: Keypair): Promise<void>;
@@ -50,9 +53,9 @@ declare class USDC extends Coin {
50
53
  static faucet(amount: bigint, receiver: string, admin: Keypair): Promise<void>;
51
54
  }
52
55
 
53
- declare function analyze_cost(ptb: Transaction, resp: SuiTransactionBlockResponse): void;
56
+ declare function analyze_cost(ptb: Transaction, resp: SuiClientTypes.Transaction): void;
54
57
 
55
- declare function deploy<TConfig extends typeof Config = typeof Config, TConfigVars extends BaseConfigVars = BaseConfigVars>(ConfigClass?: TConfig, packagePath?: string): Promise<string>;
58
+ declare function deploy<TConfig extends typeof Config = typeof Config, TConfigVars extends BaseConfigVars = BaseConfigVars>(ConfigClass?: TConfig, packagePath?: string, pubFilePath?: string): Promise<string>;
56
59
  declare function getDeployBytes(): Promise<string>;
57
60
 
58
61
  declare function getKeypair(privkey: string): Keypair;
@@ -224,7 +227,8 @@ declare class PublishSingleton {
224
227
  private static instance;
225
228
  private constructor();
226
229
  private static getPackagePath;
227
- static publish(signer?: Keypair, packagePath?: string): Promise<void>;
230
+ private static getPubFilePath;
231
+ static publish(signer?: Keypair, packagePath?: string, pubFilePath?: string): Promise<void>;
228
232
  private static getInstance;
229
233
  static publishResponse(): SuiPublishResponse;
230
234
  static get packageId(): string;
@@ -232,8 +236,8 @@ declare class PublishSingleton {
232
236
  static get upgradeCapId(): string;
233
237
  static get usdcTreasuryCap(): string;
234
238
  private static getPublishCmd;
235
- static getPublishBytes(signer?: string, packagePath?: string): Promise<string>;
236
- static publishPackage(signer: Keypair, packagePath: string): Promise<SuiPublishResponse>;
239
+ static getPublishBytes(signer?: string, packagePath?: string, pubFilePath?: string): Promise<string>;
240
+ static publishPackage(signer: Keypair, packagePath: string, pubFilePath: string): Promise<SuiPublishResponse>;
237
241
  static findPublishedPackage(resp: SuiPublishResponse): ChangedObjectFlat | undefined;
238
242
  static findObjectChangeCreatedByType(resp: SuiPublishResponse, type: string): ChangedObjectFlat | undefined;
239
243
  static get pubFile(): string;
@@ -266,9 +270,9 @@ declare class SuiClient {
266
270
  private client;
267
271
  private constructor();
268
272
  private static getInstance;
269
- static get client(): SuiJsonRpcClient;
273
+ static get client(): SuiGrpcClient;
270
274
  private static waitForTransaction;
271
- static signAndExecute(ptb: Transaction, signer: Keypair): Promise<SuiTransactionBlockResponse>;
275
+ static signAndExecute(ptb: Transaction, signer: Keypair): Promise<SuiClientTypes.Transaction<{}>>;
272
276
  static toMoveArg(ptb: Transaction, value: any, type?: MoveType): any;
273
277
  static moveCall({ signer, target, typeArgs, args, argTypes, ptb, withTransfer, }: {
274
278
  signer: Keypair;
@@ -278,7 +282,7 @@ declare class SuiClient {
278
282
  argTypes?: MoveType[];
279
283
  ptb?: Transaction;
280
284
  withTransfer?: boolean;
281
- }): Promise<SuiTransactionBlockResponse>;
285
+ }): Promise<SuiClientTypes.Transaction<{}>>;
282
286
  static getMoveCallBytes({ signer, target, typeArgs, args, argTypes, ptb, withTransfer, gasOwner, format }: {
283
287
  signer: string;
284
288
  target: string;
@@ -293,17 +297,24 @@ declare class SuiClient {
293
297
  static getMoveCallBytesFromPTB(ptb: Transaction, signer: string, gasOwner?: string, format?: FORMAT_TYPES): Promise<string>;
294
298
  static toBytes(bytes: Uint8Array | string): Uint8Array<ArrayBufferLike>;
295
299
  static getSignature(signatureOrKeypair: string | Keypair, bytes: Uint8Array): Promise<string>;
296
- static executeMoveCallBytes(bytes: Uint8Array | string, senderSignature: string | Keypair, gasOwnerSignature?: string | Keypair): Promise<SuiTransactionBlockResponse>;
300
+ static executeMoveCallBytes(bytes: Uint8Array | string, senderSignature: string | Keypair, gasOwnerSignature?: string | Keypair): Promise<SuiClientTypes.Transaction<{}>>;
297
301
  static getPTB(target: string, typeArgs?: string[], args?: any[], argTypes?: MoveType[], signer?: string, withTransfer?: boolean, ptb?: Transaction): Transaction;
298
- static public_transfer(objects: string[], from: Keypair, to: string): Promise<SuiTransactionBlockResponse>;
299
- static devInspect(ptb: Transaction, sender: string): Promise<_mysten_sui_jsonRpc.DevInspectResults>;
300
- static devInspectRaw(ptb: Transaction, sender: string): Promise<number[] | undefined>;
302
+ static public_transfer(objects: string[], from: Keypair, to: string): Promise<SuiClientTypes.Transaction<{}>>;
303
+ static devInspect(ptb: Transaction, sender: string): Promise<SuiClientTypes.SimulateTransactionResult<{
304
+ commandResults: true;
305
+ }>>;
306
+ static devInspectRaw(ptb: Transaction, sender: string): Promise<Uint8Array<ArrayBufferLike> | undefined>;
301
307
  static devInspectBool(ptb: Transaction, sender: string): Promise<boolean | undefined>;
302
308
  static devInspectU64(ptb: Transaction, sender: string): Promise<bigint>;
303
309
  static devInspectAddress(ptb: Transaction, sender: string): Promise<string | undefined>;
304
310
  static devInspectString(ptb: Transaction, sender: string): Promise<string>;
305
- static getObject(id: string): Promise<_mysten_sui_jsonRpc.SuiObjectResponse>;
306
- static getObjectsByType(owner: string, type: string): Promise<(string | undefined)[]>;
311
+ static getObject(id: string): Promise<SuiClientTypes.GetObjectResponse<{
312
+ content: true;
313
+ type: boolean;
314
+ display: true;
315
+ bcs: boolean;
316
+ }>>;
317
+ static getObjectsByType(owner: string, type: string): Promise<string[]>;
307
318
  }
308
319
 
309
320
  declare function createWallet(): Ed25519Keypair;
package/dist/index.js CHANGED
@@ -9,6 +9,7 @@ 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
11
  var utils = require('@mysten/sui/utils');
12
+ var grpc = require('@mysten/sui/grpc');
12
13
  var transactions = require('@mysten/sui/transactions');
13
14
  var bcs = require('@mysten/sui/bcs');
14
15
  var child_process = require('child_process');
@@ -1565,6 +1566,7 @@ var Config = class _Config {
1565
1566
  NETWORK,
1566
1567
  RPC: jsonRpc.getJsonRpcFullnodeUrl(NETWORK),
1567
1568
  PACKAGE_PATH: process.env.PACKAGE_PATH || "",
1569
+ PUBFILE_PATH: process.env.PUBFILE_PATH || "",
1568
1570
  PACKAGE_ID: process.env.PACKAGE_ID || "",
1569
1571
  UPGRADE_CAP_ID: process.env.UPGRADE_CAP_ID || "",
1570
1572
  USDC_TREASURY_CAP: process.env.USDC_TREASURY_CAP,
@@ -1659,16 +1661,11 @@ var MoveType = /* @__PURE__ */ ((MoveType2) => {
1659
1661
  MoveType2[MoveType2["vec_u64"] = 14] = "vec_u64";
1660
1662
  return MoveType2;
1661
1663
  })(MoveType || {});
1662
- var txOptions = {
1663
- showEffects: true,
1664
- showObjectChanges: true,
1665
- showBalanceChanges: true
1666
- };
1667
1664
  var SuiClient = class _SuiClient {
1668
1665
  static instance = null;
1669
1666
  client;
1670
1667
  constructor() {
1671
- this.client = new jsonRpc.SuiJsonRpcClient({ url: Config.vars.RPC, network: Config.vars.NETWORK });
1668
+ this.client = new grpc.SuiGrpcClient({ baseUrl: Config.vars.RPC, network: Config.vars.NETWORK });
1672
1669
  }
1673
1670
  static getInstance() {
1674
1671
  if (!_SuiClient.instance) {
@@ -1680,20 +1677,31 @@ var SuiClient = class _SuiClient {
1680
1677
  return this.getInstance().client;
1681
1678
  }
1682
1679
  static async waitForTransaction(ptb, resp) {
1683
- await _SuiClient.client.waitForTransaction({ digest: resp.digest });
1684
- if (resp.effects?.status.status !== "success") {
1680
+ await _SuiClient.client.core.waitForTransaction({ digest: resp.digest });
1681
+ if (!resp.status.success) {
1685
1682
  throw new Error(JSON.stringify(resp));
1686
1683
  }
1687
1684
  analyze_cost(ptb, resp);
1688
1685
  return resp;
1689
1686
  }
1690
1687
  static async signAndExecute(ptb, signer) {
1691
- const resp = await _SuiClient.client.signAndExecuteTransaction({
1688
+ const result = await _SuiClient.client.core.signAndExecuteTransaction({
1692
1689
  transaction: ptb,
1693
1690
  signer,
1694
- options: txOptions
1691
+ include: {
1692
+ effects: true,
1693
+ events: true,
1694
+ balanceChanges: true,
1695
+ objectTypes: true,
1696
+ transaction: true,
1697
+ bcs: true
1698
+ }
1695
1699
  });
1696
- return _SuiClient.waitForTransaction(ptb, resp);
1700
+ const tx = result.Transaction ?? result.FailedTransaction;
1701
+ if (!tx) {
1702
+ throw new Error("Transaction failed with no response");
1703
+ }
1704
+ return _SuiClient.waitForTransaction(ptb, tx);
1697
1705
  }
1698
1706
  static toMoveArg(ptb, value, type3) {
1699
1707
  if (typeof value === "object" && !Array.isArray(value)) {
@@ -1784,11 +1792,14 @@ var SuiClient = class _SuiClient {
1784
1792
  gasOwnerSignature = await this.getSignature(gasOwnerSignature, transactionBlock);
1785
1793
  signature.push(gasOwnerSignature);
1786
1794
  }
1787
- const resp = await _SuiClient.client.executeTransactionBlock({
1788
- transactionBlock: utils.toBase64(transactionBlock),
1789
- signature,
1790
- options: txOptions
1795
+ const result = await _SuiClient.client.core.executeTransaction({
1796
+ transaction: transactionBlock,
1797
+ signatures: signature
1791
1798
  });
1799
+ const resp = result.Transaction ?? result.FailedTransaction;
1800
+ if (!resp) {
1801
+ throw new Error("Transaction execution failed with no response");
1802
+ }
1792
1803
  const ptb = transactions.Transaction.from(utils.toBase64(transactionBlock));
1793
1804
  return _SuiClient.waitForTransaction(ptb, resp);
1794
1805
  }
@@ -1810,14 +1821,20 @@ var SuiClient = class _SuiClient {
1810
1821
  return await _SuiClient.signAndExecute(tx, from);
1811
1822
  }
1812
1823
  static async devInspect(ptb, sender) {
1813
- return await _SuiClient.client.devInspectTransactionBlock({
1814
- transactionBlock: ptb,
1815
- sender
1824
+ ptb.setSender(sender);
1825
+ return await _SuiClient.client.core.simulateTransaction({
1826
+ transaction: ptb,
1827
+ checksEnabled: false,
1828
+ include: { commandResults: true }
1816
1829
  });
1817
1830
  }
1818
1831
  static async devInspectRaw(ptb, sender) {
1819
1832
  const result = await this.devInspect(ptb, sender);
1820
- return result.results?.[0].returnValues?.[0]?.[0];
1833
+ const commandResult = result.commandResults?.[0];
1834
+ if (!commandResult || !commandResult.returnValues?.[0]) {
1835
+ return void 0;
1836
+ }
1837
+ return commandResult.returnValues[0];
1821
1838
  }
1822
1839
  static async devInspectBool(ptb, sender) {
1823
1840
  const result = await this.devInspectRaw(ptb, sender);
@@ -1843,24 +1860,25 @@ var SuiClient = class _SuiClient {
1843
1860
  return bcs.bcs.string().parse(new Uint8Array(value));
1844
1861
  }
1845
1862
  static async getObject(id) {
1846
- return _SuiClient.client.getObject({
1847
- id,
1848
- options: {
1849
- showContent: true,
1850
- showType: true,
1851
- showDisplay: true,
1852
- showBcs: true
1863
+ return _SuiClient.client.core.getObject({
1864
+ objectId: id,
1865
+ include: {
1866
+ content: true,
1867
+ type: true,
1868
+ display: true,
1869
+ bcs: true
1853
1870
  }
1854
1871
  });
1855
1872
  }
1856
1873
  static async getObjectsByType(owner, type3) {
1857
- const res = await _SuiClient.client.getOwnedObjects({
1874
+ const res = await _SuiClient.client.core.listOwnedObjects({
1858
1875
  owner,
1859
- filter: {
1860
- StructType: type3
1876
+ type: type3,
1877
+ include: {
1878
+ content: true
1861
1879
  }
1862
1880
  });
1863
- return res.data.map((o) => o.data?.objectId).filter((o) => o);
1881
+ return res.objects.map((o) => o.objectId).filter((o) => o);
1864
1882
  }
1865
1883
  };
1866
1884
 
@@ -16260,24 +16278,27 @@ var Coin = class {
16260
16278
  throw new Error("`coinType` getter must be implemented !");
16261
16279
  }
16262
16280
  static async getBalance(owner) {
16263
- const result = await SuiClient.client.getBalance({
16264
- owner,
16265
- coinType: this.coinType
16281
+ const result = await SuiClient.client.core.listBalances({
16282
+ owner
16266
16283
  });
16267
- return BigInt(result.totalBalance);
16284
+ const balance = result.balances.find((b) => b.coinType === this.coinType);
16285
+ return BigInt(balance?.balance || 0);
16268
16286
  }
16269
- static async getCoin(owner, amount) {
16270
- const balance = amount || await this.getBalance(owner.toSuiAddress());
16271
- const tx = new transactions.Transaction();
16272
- const coinSplit = transactions.coinWithBalance({
16287
+ static coinWithBalance(balance) {
16288
+ return transactions.coinWithBalance({
16273
16289
  balance,
16274
16290
  useGasCoin: false,
16275
16291
  type: this.coinType
16276
16292
  });
16293
+ }
16294
+ static async getCoin(owner, amount) {
16295
+ const balance = amount || await this.getBalance(owner.toSuiAddress());
16296
+ const tx = new transactions.Transaction();
16297
+ const coinSplit = this.coinWithBalance(balance);
16277
16298
  tx.transferObjects([coinSplit], owner.toSuiAddress());
16278
16299
  const result = await SuiClient.signAndExecute(tx, owner);
16279
- const coin = result.objectChanges?.find(
16280
- (o) => o.type === "created" && o.objectType === `0x2::coin::Coin<${this.coinType}>`
16300
+ const coin = result.effects?.changedObjects?.find(
16301
+ (o) => o.idOperation === "Created"
16281
16302
  );
16282
16303
  return coin?.objectId;
16283
16304
  }
@@ -16306,9 +16327,8 @@ var Coin = class {
16306
16327
  });
16307
16328
  }
16308
16329
  static async send(amount, from, to) {
16309
- const coin = await this.getCoin(from, amount);
16310
16330
  const ptb = new transactions.Transaction();
16311
- ptb.transferObjects([ptb.object(coin)], to);
16331
+ ptb.transferObjects([this.coinWithBalance(amount)], to);
16312
16332
  await SuiClient.signAndExecute(ptb, from);
16313
16333
  }
16314
16334
  static async assertBalance(wallet, amount) {
@@ -16405,11 +16425,21 @@ var PublishSingleton = class _PublishSingleton {
16405
16425
  }
16406
16426
  return packagePath;
16407
16427
  }
16408
- static async publish(signer, packagePath) {
16428
+ static getPubFilePath(pubFilePath) {
16429
+ pubFilePath ??= Config.vars.PUBFILE_PATH;
16430
+ if (!pubFilePath) {
16431
+ throw new Error(
16432
+ `You must set the \`PUBFILE_PATH\` environment variable to your Pub.${Config.vars.NETWORK}.toml path.`
16433
+ );
16434
+ }
16435
+ return pubFilePath;
16436
+ }
16437
+ static async publish(signer, packagePath, pubFilePath) {
16409
16438
  signer ??= ADMIN_KEYPAIR;
16410
16439
  const _packagePath = this.getPackagePath(packagePath);
16440
+ const _pubFilePath = this.getPubFilePath(pubFilePath);
16411
16441
  if (!_PublishSingleton.instance) {
16412
- const publishResp = await _PublishSingleton.publishPackage(signer, _packagePath);
16442
+ const publishResp = await _PublishSingleton.publishPackage(signer, _packagePath, _pubFilePath);
16413
16443
  _PublishSingleton.instance = new _PublishSingleton(publishResp);
16414
16444
  }
16415
16445
  }
@@ -16445,7 +16475,7 @@ var PublishSingleton = class _PublishSingleton {
16445
16475
  false
16446
16476
  );
16447
16477
  }
16448
- static getPublishCmd(packagePath, sender, inBytes = false) {
16478
+ static getPublishCmd(packagePath, sender, pubFilePath, inBytes = false) {
16449
16479
  const network = Config.vars.NETWORK;
16450
16480
  if (!fs3__namespace.default.existsSync(packagePath)) {
16451
16481
  throw new Error(`Package doesn't exist under: ${packagePath}`);
@@ -16460,17 +16490,21 @@ var PublishSingleton = class _PublishSingleton {
16460
16490
  if (isEphemeralChain) {
16461
16491
  buildCommand += " --publish-unpublished-deps";
16462
16492
  }
16493
+ if (pubFilePath) {
16494
+ buildCommand += ` --pubfile-path ${pubFilePath}`;
16495
+ }
16463
16496
  buildCommand += inBytes ? ` --serialize-unsigned-transaction --sender ${sender}` : " --json";
16464
16497
  return buildCommand;
16465
16498
  }
16466
- static async getPublishBytes(signer, packagePath) {
16499
+ static async getPublishBytes(signer, packagePath, pubFilePath) {
16467
16500
  signer ??= ADMIN_KEYPAIR.toSuiAddress();
16468
16501
  const _packagePath = this.getPackagePath(packagePath);
16469
- const cmd = this.getPublishCmd(_packagePath, signer, true);
16502
+ const _pubFilePath = this.getPubFilePath(pubFilePath);
16503
+ const cmd = this.getPublishCmd(_packagePath, signer, _pubFilePath, true);
16470
16504
  return execCmd(cmd);
16471
16505
  }
16472
- static async publishPackage(signer, packagePath) {
16473
- const cmd = this.getPublishCmd(packagePath, signer.toSuiAddress());
16506
+ static async publishPackage(signer, packagePath, pubFilePath) {
16507
+ const cmd = this.getPublishCmd(packagePath, signer.toSuiAddress(), pubFilePath);
16474
16508
  const res = await execCmd(cmd);
16475
16509
  const match = res.match(/\{[\s\S]*\}/);
16476
16510
  if (!match) {
@@ -16498,9 +16532,9 @@ var PublishSingleton = class _PublishSingleton {
16498
16532
  };
16499
16533
 
16500
16534
  // src/utils/deploy.ts
16501
- async function deploy(ConfigClass = Config, packagePath) {
16535
+ async function deploy(ConfigClass = Config, packagePath, pubFilePath) {
16502
16536
  const vars = ConfigClass.vars;
16503
- await PublishSingleton.publish(ADMIN_KEYPAIR, packagePath);
16537
+ await PublishSingleton.publish(ADMIN_KEYPAIR, packagePath, pubFilePath);
16504
16538
  const newConfig = {
16505
16539
  ...vars,
16506
16540
  PACKAGE_ID: PublishSingleton.packageId,
@@ -16545,12 +16579,14 @@ function sleep(ms) {
16545
16579
  return new Promise((resolve3) => setTimeout(resolve3, ms));
16546
16580
  }
16547
16581
  async function waitForNextEpoch(timeoutMs = 5 * 60 * 1e3, pollIntervalMs = 2e3) {
16548
- const startEpoch = (await SuiClient.client.getLatestSuiSystemState()).epoch;
16582
+ const startEpochData = await SuiClient.client.core.getCurrentSystemState();
16583
+ const startEpoch = BigInt(startEpochData.systemState.epoch);
16549
16584
  const startTime = Date.now();
16550
16585
  while (true) {
16551
- const { epoch } = await SuiClient.client.getLatestSuiSystemState();
16552
- if (Number(epoch) > Number(startEpoch)) {
16553
- return epoch;
16586
+ const currentEpochData = await SuiClient.client.core.getCurrentSystemState();
16587
+ const currentEpoch = BigInt(currentEpochData.systemState.epoch);
16588
+ if (currentEpoch > startEpoch) {
16589
+ return currentEpoch.toString();
16554
16590
  }
16555
16591
  if (Date.now() - startTime > timeoutMs) {
16556
16592
  throw new Error("Timeout waiting for next epoch.");