@msafe/sui3-sdk 1.0.14 → 1.0.17

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.cts CHANGED
@@ -334,6 +334,70 @@ declare class InvitationSDK {
334
334
  updateMSafeStatus(msafeAddress: string, status: UserMSafeStatus): Promise<void>;
335
335
  }
336
336
 
337
+ type GasFundingMode = 'classic' | 'addressBalance' | 'mixedTopUp';
338
+ interface GasFundingResult {
339
+ mode: GasFundingMode;
340
+ gasBudget: bigint;
341
+ coinBalance: bigint;
342
+ addressBalance: bigint;
343
+ }
344
+ declare class InsufficientGasFundsError extends Error {
345
+ readonly gasBudget: bigint;
346
+ readonly coinBalance: bigint;
347
+ readonly addressBalance: bigint;
348
+ constructor(gasBudget: bigint, coinBalance: bigint, addressBalance: bigint);
349
+ }
350
+ /**
351
+ * Gas budget must cover pre-rebate costs (computation + storage + overhead).
352
+ * storageRebate is refunded after execution and must not reduce the budget.
353
+ */
354
+ declare function computeGasBudget(gasUsed: Pick<SuiClientTypes.GasCostSummary, 'computationCost' | 'storageCost'>, gasPrice: bigint): bigint;
355
+ /**
356
+ * Select gas funding before tx.build() according to mixed coin/addressBalance policy:
357
+ * 1) budget without storageRebate (caller supplies computeGasBudget result)
358
+ * 2-3) fail if total < budget
359
+ * 4) coins exist and coinBal >= budget → classic setGasPayment(coins)
360
+ * 5) coins exist and total >= budget → mixed top-up via coin reservation
361
+ * 6) no usable coins and addrBal >= budget → Address Balance gas (payment: [])
362
+ */
363
+ declare function selectGasFunding(input: {
364
+ tx: Transaction;
365
+ suiClient: SuiGrpcClient;
366
+ owner: string;
367
+ gasBudget: bigint;
368
+ }): Promise<GasFundingResult>;
369
+ /**
370
+ * Estimate gas budget (no storageRebate) using a probe build/simulate.
371
+ * Prefers classic coin gas when coin objects exist so the estimate matches the
372
+ * cheaper payment path. Budget is left unset so Mysten can dry-run with MAX_GAS
373
+ * overrides (avoids locking the full balance away from GasCoin splits).
374
+ */
375
+ declare function estimateGasBudget(input: {
376
+ tx: Transaction;
377
+ suiClient: SuiGrpcClient;
378
+ owner: string;
379
+ gasPrice: bigint;
380
+ }): Promise<bigint>;
381
+ /**
382
+ * Resolve gasBudget (no rebate) and apply gas funding selection before build.
383
+ */
384
+ declare function prepareGasFunding(input: {
385
+ tx: Transaction;
386
+ suiClient: SuiGrpcClient;
387
+ owner: string;
388
+ gasPrice: bigint;
389
+ gasBudget?: bigint;
390
+ }): Promise<GasFundingResult>;
391
+ /**
392
+ * @deprecated Use {@link prepareGasFunding} / {@link selectGasFunding}.
393
+ * Kept as a thin classic-only helper for callers that only want coin gas when available.
394
+ */
395
+ declare function preferClassicGasPayment(input: {
396
+ tx: Transaction;
397
+ suiClient: SuiGrpcClient;
398
+ owner: string;
399
+ }): Promise<boolean>;
400
+
337
401
  declare class Simulator {
338
402
  private globals;
339
403
  constructor(globals: MSafeGlobals);
@@ -523,9 +587,19 @@ declare class Coin {
523
587
  }): bigint | undefined;
524
588
  }
525
589
 
590
+ declare const COIN_RESERVATION_MAGIC: Uint8Array;
591
+ declare function isCoinReservationDigest(digestBase58: string): boolean;
592
+ declare function createCoinReservationRef(reservedBalance: bigint, owner: string, chainIdentifier: string, epoch: string): {
593
+ objectId: string;
594
+ version: string;
595
+ digest: string;
596
+ };
597
+
526
598
  /**
527
- * Normalize a transaction value to {@link Transaction} (handles plain Transaction or serialized legacy shapes).
599
+ * Normalize a transaction value to {@link Transaction}.
600
+ * Prefer V2 restore paths — avoid deprecated V1 serialize() when possible
601
+ * (V1 drops CallArg::FundsWithdrawal).
528
602
  */
529
603
  declare function toSuiTransaction(txb: Transaction | unknown): Transaction;
530
604
 
531
- export { AddressBookSDK, COIN_TYPE_ARG_REGEX, Coin, CoinHelper, CreateHelper, type CreateMSafeInfo, DEV_API_URL, DEV_SYNCING_URL, ENV_CONFIGS, Formatter, type FutureIntention, type GasObjectReference, HexToUint8Array, type HistorySendTx, type HistoryVote, type IWallet, InfoTypeEnabledDto, InfoTypeKey, LOCAL_API_URL, LOCAL_SYNCING_URL, MAINNET_RPC_URL, MSafeAccount, MSafeClient, type MSafeConfig, type MSafeConfigOptions, MSafeEnabledDto, MSafeEnv, MSafeGlobals, type NotificationData, type NotificationInfo, NotificationSubscribeDto, NotificationUpdateDto, PREV_API_URL, PROD_API_URL, type Pagination, type PendingTx, type PendingVote, type ProposeIntention, type ReceiveTransaction, SUI_COIN, SignatureVerifier, type SimulateDryRunResponse, type SimulationFailedResult, type SimulationOption, type SimulationResult, type SimulationSuccessResult, TESTNET_RPC_URL, Uint8ArrayToHex, addPrefix, getAllCoins, getMSafeConfig, getPublicKeyFromChain, httpUrlToGrpcBaseUrl, msafeChainToSuiNetwork, stringToBuffer, toSuiTransaction };
605
+ export { AddressBookSDK, COIN_RESERVATION_MAGIC, COIN_TYPE_ARG_REGEX, Coin, CoinHelper, CreateHelper, type CreateMSafeInfo, DEV_API_URL, DEV_SYNCING_URL, ENV_CONFIGS, Formatter, type FutureIntention, type GasFundingMode, type GasFundingResult, type GasObjectReference, HexToUint8Array, type HistorySendTx, type HistoryVote, type IWallet, InfoTypeEnabledDto, InfoTypeKey, InsufficientGasFundsError, LOCAL_API_URL, LOCAL_SYNCING_URL, MAINNET_RPC_URL, MSafeAccount, MSafeClient, type MSafeConfig, type MSafeConfigOptions, MSafeEnabledDto, MSafeEnv, MSafeGlobals, type NotificationData, type NotificationInfo, NotificationSubscribeDto, NotificationUpdateDto, PREV_API_URL, PROD_API_URL, type Pagination, type PendingTx, type PendingVote, type ProposeIntention, type ReceiveTransaction, SUI_COIN, SignatureVerifier, type SimulateDryRunResponse, type SimulationFailedResult, type SimulationOption, type SimulationResult, type SimulationSuccessResult, TESTNET_RPC_URL, Uint8ArrayToHex, addPrefix, computeGasBudget, createCoinReservationRef, estimateGasBudget, getAllCoins, getMSafeConfig, getPublicKeyFromChain, httpUrlToGrpcBaseUrl, isCoinReservationDigest, msafeChainToSuiNetwork, preferClassicGasPayment, prepareGasFunding, selectGasFunding, stringToBuffer, toSuiTransaction };
package/dist/index.d.ts CHANGED
@@ -334,6 +334,70 @@ declare class InvitationSDK {
334
334
  updateMSafeStatus(msafeAddress: string, status: UserMSafeStatus): Promise<void>;
335
335
  }
336
336
 
337
+ type GasFundingMode = 'classic' | 'addressBalance' | 'mixedTopUp';
338
+ interface GasFundingResult {
339
+ mode: GasFundingMode;
340
+ gasBudget: bigint;
341
+ coinBalance: bigint;
342
+ addressBalance: bigint;
343
+ }
344
+ declare class InsufficientGasFundsError extends Error {
345
+ readonly gasBudget: bigint;
346
+ readonly coinBalance: bigint;
347
+ readonly addressBalance: bigint;
348
+ constructor(gasBudget: bigint, coinBalance: bigint, addressBalance: bigint);
349
+ }
350
+ /**
351
+ * Gas budget must cover pre-rebate costs (computation + storage + overhead).
352
+ * storageRebate is refunded after execution and must not reduce the budget.
353
+ */
354
+ declare function computeGasBudget(gasUsed: Pick<SuiClientTypes.GasCostSummary, 'computationCost' | 'storageCost'>, gasPrice: bigint): bigint;
355
+ /**
356
+ * Select gas funding before tx.build() according to mixed coin/addressBalance policy:
357
+ * 1) budget without storageRebate (caller supplies computeGasBudget result)
358
+ * 2-3) fail if total < budget
359
+ * 4) coins exist and coinBal >= budget → classic setGasPayment(coins)
360
+ * 5) coins exist and total >= budget → mixed top-up via coin reservation
361
+ * 6) no usable coins and addrBal >= budget → Address Balance gas (payment: [])
362
+ */
363
+ declare function selectGasFunding(input: {
364
+ tx: Transaction;
365
+ suiClient: SuiGrpcClient;
366
+ owner: string;
367
+ gasBudget: bigint;
368
+ }): Promise<GasFundingResult>;
369
+ /**
370
+ * Estimate gas budget (no storageRebate) using a probe build/simulate.
371
+ * Prefers classic coin gas when coin objects exist so the estimate matches the
372
+ * cheaper payment path. Budget is left unset so Mysten can dry-run with MAX_GAS
373
+ * overrides (avoids locking the full balance away from GasCoin splits).
374
+ */
375
+ declare function estimateGasBudget(input: {
376
+ tx: Transaction;
377
+ suiClient: SuiGrpcClient;
378
+ owner: string;
379
+ gasPrice: bigint;
380
+ }): Promise<bigint>;
381
+ /**
382
+ * Resolve gasBudget (no rebate) and apply gas funding selection before build.
383
+ */
384
+ declare function prepareGasFunding(input: {
385
+ tx: Transaction;
386
+ suiClient: SuiGrpcClient;
387
+ owner: string;
388
+ gasPrice: bigint;
389
+ gasBudget?: bigint;
390
+ }): Promise<GasFundingResult>;
391
+ /**
392
+ * @deprecated Use {@link prepareGasFunding} / {@link selectGasFunding}.
393
+ * Kept as a thin classic-only helper for callers that only want coin gas when available.
394
+ */
395
+ declare function preferClassicGasPayment(input: {
396
+ tx: Transaction;
397
+ suiClient: SuiGrpcClient;
398
+ owner: string;
399
+ }): Promise<boolean>;
400
+
337
401
  declare class Simulator {
338
402
  private globals;
339
403
  constructor(globals: MSafeGlobals);
@@ -523,9 +587,19 @@ declare class Coin {
523
587
  }): bigint | undefined;
524
588
  }
525
589
 
590
+ declare const COIN_RESERVATION_MAGIC: Uint8Array;
591
+ declare function isCoinReservationDigest(digestBase58: string): boolean;
592
+ declare function createCoinReservationRef(reservedBalance: bigint, owner: string, chainIdentifier: string, epoch: string): {
593
+ objectId: string;
594
+ version: string;
595
+ digest: string;
596
+ };
597
+
526
598
  /**
527
- * Normalize a transaction value to {@link Transaction} (handles plain Transaction or serialized legacy shapes).
599
+ * Normalize a transaction value to {@link Transaction}.
600
+ * Prefer V2 restore paths — avoid deprecated V1 serialize() when possible
601
+ * (V1 drops CallArg::FundsWithdrawal).
528
602
  */
529
603
  declare function toSuiTransaction(txb: Transaction | unknown): Transaction;
530
604
 
531
- export { AddressBookSDK, COIN_TYPE_ARG_REGEX, Coin, CoinHelper, CreateHelper, type CreateMSafeInfo, DEV_API_URL, DEV_SYNCING_URL, ENV_CONFIGS, Formatter, type FutureIntention, type GasObjectReference, HexToUint8Array, type HistorySendTx, type HistoryVote, type IWallet, InfoTypeEnabledDto, InfoTypeKey, LOCAL_API_URL, LOCAL_SYNCING_URL, MAINNET_RPC_URL, MSafeAccount, MSafeClient, type MSafeConfig, type MSafeConfigOptions, MSafeEnabledDto, MSafeEnv, MSafeGlobals, type NotificationData, type NotificationInfo, NotificationSubscribeDto, NotificationUpdateDto, PREV_API_URL, PROD_API_URL, type Pagination, type PendingTx, type PendingVote, type ProposeIntention, type ReceiveTransaction, SUI_COIN, SignatureVerifier, type SimulateDryRunResponse, type SimulationFailedResult, type SimulationOption, type SimulationResult, type SimulationSuccessResult, TESTNET_RPC_URL, Uint8ArrayToHex, addPrefix, getAllCoins, getMSafeConfig, getPublicKeyFromChain, httpUrlToGrpcBaseUrl, msafeChainToSuiNetwork, stringToBuffer, toSuiTransaction };
605
+ export { AddressBookSDK, COIN_RESERVATION_MAGIC, COIN_TYPE_ARG_REGEX, Coin, CoinHelper, CreateHelper, type CreateMSafeInfo, DEV_API_URL, DEV_SYNCING_URL, ENV_CONFIGS, Formatter, type FutureIntention, type GasFundingMode, type GasFundingResult, type GasObjectReference, HexToUint8Array, type HistorySendTx, type HistoryVote, type IWallet, InfoTypeEnabledDto, InfoTypeKey, InsufficientGasFundsError, LOCAL_API_URL, LOCAL_SYNCING_URL, MAINNET_RPC_URL, MSafeAccount, MSafeClient, type MSafeConfig, type MSafeConfigOptions, MSafeEnabledDto, MSafeEnv, MSafeGlobals, type NotificationData, type NotificationInfo, NotificationSubscribeDto, NotificationUpdateDto, PREV_API_URL, PROD_API_URL, type Pagination, type PendingTx, type PendingVote, type ProposeIntention, type ReceiveTransaction, SUI_COIN, SignatureVerifier, type SimulateDryRunResponse, type SimulationFailedResult, type SimulationOption, type SimulationResult, type SimulationSuccessResult, TESTNET_RPC_URL, Uint8ArrayToHex, addPrefix, computeGasBudget, createCoinReservationRef, estimateGasBudget, getAllCoins, getMSafeConfig, getPublicKeyFromChain, httpUrlToGrpcBaseUrl, isCoinReservationDigest, msafeChainToSuiNetwork, preferClassicGasPayment, prepareGasFunding, selectGasFunding, stringToBuffer, toSuiTransaction };