@t2000/sdk 0.18.36 → 0.18.37

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.cjs CHANGED
@@ -56161,7 +56161,8 @@ async function trySelfFunded(client, keypair, tx) {
56161
56161
  digest: result.digest,
56162
56162
  effects: result.effects,
56163
56163
  gasMethod: "self-funded",
56164
- gasCostSui: extractGasCost(result.effects)
56164
+ gasCostSui: extractGasCost(result.effects),
56165
+ preTxSuiMist: suiBalance
56165
56166
  };
56166
56167
  }
56167
56168
  async function tryAutoTopUpThenSelfFund(client, keypair, buildTx) {
@@ -56171,6 +56172,7 @@ async function tryAutoTopUpThenSelfFund(client, keypair, buildTx) {
56171
56172
  await executeAutoTopUp(client, keypair);
56172
56173
  const tx = await buildTx();
56173
56174
  tx.setSender(address);
56175
+ const suiAfterTopUp = await getSuiBalance(client, address);
56174
56176
  const result = await client.signAndExecuteTransaction({
56175
56177
  signer: keypair,
56176
56178
  transaction: tx,
@@ -56182,11 +56184,13 @@ async function tryAutoTopUpThenSelfFund(client, keypair, buildTx) {
56182
56184
  digest: result.digest,
56183
56185
  effects: result.effects,
56184
56186
  gasMethod: "auto-topup",
56185
- gasCostSui: extractGasCost(result.effects)
56187
+ gasCostSui: extractGasCost(result.effects),
56188
+ preTxSuiMist: suiAfterTopUp
56186
56189
  };
56187
56190
  }
56188
56191
  async function trySponsored(client, keypair, tx) {
56189
56192
  const address = keypair.getPublicKey().toSuiAddress();
56193
+ const suiBalance = await getSuiBalance(client, address);
56190
56194
  tx.setSender(address);
56191
56195
  let txJson;
56192
56196
  let txBcsBase64;
@@ -56212,7 +56216,8 @@ async function trySponsored(client, keypair, tx) {
56212
56216
  digest: result.digest,
56213
56217
  effects: result.effects,
56214
56218
  gasMethod: "sponsored",
56215
- gasCostSui: gasCost
56219
+ gasCostSui: gasCost,
56220
+ preTxSuiMist: suiBalance
56216
56221
  };
56217
56222
  }
56218
56223
  async function waitForIndexer(client, digest) {
@@ -56231,9 +56236,19 @@ async function executeWithGas(client, keypair, buildTx, options) {
56231
56236
  }
56232
56237
  const result = await resolveGas(client, keypair, buildTx);
56233
56238
  try {
56234
- const address = keypair.getPublicKey().toSuiAddress();
56235
- if (await shouldAutoTopUp(client, address)) {
56236
- await executeAutoTopUp(client, keypair);
56239
+ if (result.preTxSuiMist !== void 0) {
56240
+ const gasCostMist = result.gasMethod === "sponsored" ? 0n : BigInt(Math.round(result.gasCostSui * 1e9));
56241
+ const estimatedRemaining = result.preTxSuiMist - gasCostMist;
56242
+ if (estimatedRemaining < AUTO_TOPUP_THRESHOLD) {
56243
+ const address = keypair.getPublicKey().toSuiAddress();
56244
+ const usdcBal = await client.getBalance({
56245
+ owner: address,
56246
+ coinType: SUPPORTED_ASSETS.USDC.type
56247
+ });
56248
+ if (BigInt(usdcBal.totalBalance) >= AUTO_TOPUP_MIN_USDC) {
56249
+ await executeAutoTopUp(client, keypair);
56250
+ }
56251
+ }
56237
56252
  }
56238
56253
  } catch {
56239
56254
  }