@msafe/sui3-sdk 1.0.15 → 1.0.18

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,64 @@ 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
+ declare function estimateGasBudget(input: {
370
+ tx: Transaction;
371
+ suiClient: SuiGrpcClient;
372
+ owner: string;
373
+ gasPrice: bigint;
374
+ }): Promise<bigint>;
375
+ /**
376
+ * Resolve gasBudget (no rebate) and apply gas funding selection before build.
377
+ */
378
+ declare function prepareGasFunding(input: {
379
+ tx: Transaction;
380
+ suiClient: SuiGrpcClient;
381
+ owner: string;
382
+ gasPrice: bigint;
383
+ gasBudget?: bigint;
384
+ }): Promise<GasFundingResult>;
385
+ /**
386
+ * @deprecated Use {@link prepareGasFunding} / {@link selectGasFunding}.
387
+ * Kept as a thin classic-only helper for callers that only want coin gas when available.
388
+ */
389
+ declare function preferClassicGasPayment(input: {
390
+ tx: Transaction;
391
+ suiClient: SuiGrpcClient;
392
+ owner: string;
393
+ }): Promise<boolean>;
394
+
337
395
  declare class Simulator {
338
396
  private globals;
339
397
  constructor(globals: MSafeGlobals);
@@ -523,9 +581,19 @@ declare class Coin {
523
581
  }): bigint | undefined;
524
582
  }
525
583
 
584
+ declare const COIN_RESERVATION_MAGIC: Uint8Array;
585
+ declare function isCoinReservationDigest(digestBase58: string): boolean;
586
+ declare function createCoinReservationRef(reservedBalance: bigint, owner: string, chainIdentifier: string, epoch: string): {
587
+ objectId: string;
588
+ version: string;
589
+ digest: string;
590
+ };
591
+
526
592
  /**
527
- * Normalize a transaction value to {@link Transaction} (handles plain Transaction or serialized legacy shapes).
593
+ * Normalize a transaction value to {@link Transaction}.
594
+ * Prefer V2 restore paths — avoid deprecated V1 serialize() when possible
595
+ * (V1 drops CallArg::FundsWithdrawal).
528
596
  */
529
597
  declare function toSuiTransaction(txb: Transaction | unknown): Transaction;
530
598
 
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 };
599
+ 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,64 @@ 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
+ declare function estimateGasBudget(input: {
370
+ tx: Transaction;
371
+ suiClient: SuiGrpcClient;
372
+ owner: string;
373
+ gasPrice: bigint;
374
+ }): Promise<bigint>;
375
+ /**
376
+ * Resolve gasBudget (no rebate) and apply gas funding selection before build.
377
+ */
378
+ declare function prepareGasFunding(input: {
379
+ tx: Transaction;
380
+ suiClient: SuiGrpcClient;
381
+ owner: string;
382
+ gasPrice: bigint;
383
+ gasBudget?: bigint;
384
+ }): Promise<GasFundingResult>;
385
+ /**
386
+ * @deprecated Use {@link prepareGasFunding} / {@link selectGasFunding}.
387
+ * Kept as a thin classic-only helper for callers that only want coin gas when available.
388
+ */
389
+ declare function preferClassicGasPayment(input: {
390
+ tx: Transaction;
391
+ suiClient: SuiGrpcClient;
392
+ owner: string;
393
+ }): Promise<boolean>;
394
+
337
395
  declare class Simulator {
338
396
  private globals;
339
397
  constructor(globals: MSafeGlobals);
@@ -523,9 +581,19 @@ declare class Coin {
523
581
  }): bigint | undefined;
524
582
  }
525
583
 
584
+ declare const COIN_RESERVATION_MAGIC: Uint8Array;
585
+ declare function isCoinReservationDigest(digestBase58: string): boolean;
586
+ declare function createCoinReservationRef(reservedBalance: bigint, owner: string, chainIdentifier: string, epoch: string): {
587
+ objectId: string;
588
+ version: string;
589
+ digest: string;
590
+ };
591
+
526
592
  /**
527
- * Normalize a transaction value to {@link Transaction} (handles plain Transaction or serialized legacy shapes).
593
+ * Normalize a transaction value to {@link Transaction}.
594
+ * Prefer V2 restore paths — avoid deprecated V1 serialize() when possible
595
+ * (V1 drops CallArg::FundsWithdrawal).
528
596
  */
529
597
  declare function toSuiTransaction(txb: Transaction | unknown): Transaction;
530
598
 
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 };
599
+ 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 };