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