@t2000/sdk 0.18.20 → 0.18.23

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.js CHANGED
@@ -56158,6 +56158,16 @@ async function trySponsored(client, keypair, tx) {
56158
56158
  gasCostSui: gasCost
56159
56159
  };
56160
56160
  }
56161
+ async function waitForIndexer(client, digest) {
56162
+ for (let i = 0; i < 3; i++) {
56163
+ try {
56164
+ await client.getTransactionBlock({ digest, options: { showObjectChanges: true } });
56165
+ return;
56166
+ } catch {
56167
+ await new Promise((r) => setTimeout(r, 1e3));
56168
+ }
56169
+ }
56170
+ }
56161
56171
  async function executeWithGas(client, keypair, buildTx, options) {
56162
56172
  if (options?.enforcer && options?.metadata) {
56163
56173
  options.enforcer.check(options.metadata);
@@ -56166,7 +56176,10 @@ async function executeWithGas(client, keypair, buildTx, options) {
56166
56176
  try {
56167
56177
  const tx = await buildTx();
56168
56178
  const result = await trySelfFunded(client, keypair, tx);
56169
- if (result) return result;
56179
+ if (result) {
56180
+ await waitForIndexer(client, result.digest);
56181
+ return result;
56182
+ }
56170
56183
  errors.push("self-funded: SUI below threshold");
56171
56184
  } catch (err) {
56172
56185
  const msg = err instanceof Error ? err.message : String(err);
@@ -56177,15 +56190,35 @@ async function executeWithGas(client, keypair, buildTx, options) {
56177
56190
  }
56178
56191
  try {
56179
56192
  const result = await tryAutoTopUpThenSelfFund(client, keypair, buildTx);
56180
- if (result) return result;
56193
+ if (result) {
56194
+ await waitForIndexer(client, result.digest);
56195
+ return result;
56196
+ }
56181
56197
  errors.push("auto-topup: not eligible (low USDC or sufficient SUI)");
56182
56198
  } catch (err) {
56183
56199
  errors.push(`auto-topup: ${err instanceof Error ? err.message : String(err)}`);
56184
56200
  }
56201
+ try {
56202
+ const tx = await buildTx();
56203
+ const result = await trySelfFunded(client, keypair, tx);
56204
+ if (result) {
56205
+ await waitForIndexer(client, result.digest);
56206
+ return result;
56207
+ }
56208
+ } catch (err) {
56209
+ const msg = err instanceof Error ? err.message : String(err);
56210
+ if (isMoveAbort(msg)) {
56211
+ throw new T2000Error("TRANSACTION_FAILED", parseMoveAbortMessage(msg));
56212
+ }
56213
+ errors.push(`self-funded-retry: ${msg}`);
56214
+ }
56185
56215
  try {
56186
56216
  const tx = await buildTx();
56187
56217
  const result = await trySponsored(client, keypair, tx);
56188
- if (result) return result;
56218
+ if (result) {
56219
+ await waitForIndexer(client, result.digest);
56220
+ return result;
56221
+ }
56189
56222
  errors.push("sponsored: returned null");
56190
56223
  } catch (err) {
56191
56224
  errors.push(`sponsored: ${err instanceof Error ? err.message : String(err)}`);