@t2000/sdk 0.1.5 → 0.1.7

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
@@ -892,11 +892,7 @@ async function tryAutoTopUpThenSelfFund(client, keypair, tx) {
892
892
  const address = keypair.getPublicKey().toSuiAddress();
893
893
  const canTopUp = await shouldAutoTopUp(client, address);
894
894
  if (!canTopUp) return null;
895
- try {
896
- await executeAutoTopUp(client, keypair);
897
- } catch {
898
- return null;
899
- }
895
+ await executeAutoTopUp(client, keypair);
900
896
  tx.setSender(address);
901
897
  const result = await client.signAndExecuteTransaction({
902
898
  signer: keypair,
@@ -914,19 +910,9 @@ async function tryAutoTopUpThenSelfFund(client, keypair, tx) {
914
910
  async function trySponsored(client, keypair, tx) {
915
911
  const address = keypair.getPublicKey().toSuiAddress();
916
912
  tx.setSender(address);
917
- let txBytes;
918
- try {
919
- txBytes = await tx.build({ client, onlyTransactionKind: true });
920
- } catch {
921
- return null;
922
- }
913
+ const txBytes = await tx.build({ client, onlyTransactionKind: true });
923
914
  const txBytesBase64 = Buffer.from(txBytes).toString("base64");
924
- let sponsoredResult;
925
- try {
926
- sponsoredResult = await requestGasSponsorship(txBytesBase64, address);
927
- } catch {
928
- return null;
929
- }
915
+ const sponsoredResult = await requestGasSponsorship(txBytesBase64, address);
930
916
  const sponsoredTxBytes = Buffer.from(sponsoredResult.txBytes, "base64");
931
917
  const { signature: agentSig } = await keypair.signTransaction(sponsoredTxBytes);
932
918
  const result = await client.executeTransactionBlock({
@@ -945,28 +931,35 @@ async function trySponsored(client, keypair, tx) {
945
931
  };
946
932
  }
947
933
  async function executeWithGas(client, keypair, buildTx) {
934
+ const errors = [];
948
935
  try {
949
936
  const tx = await buildTx();
950
937
  const result = await trySelfFunded(client, keypair, tx);
951
938
  if (result) return result;
952
- } catch {
939
+ errors.push("self-funded: SUI below threshold");
940
+ } catch (err) {
941
+ errors.push(`self-funded: ${err instanceof Error ? err.message : String(err)}`);
953
942
  }
954
943
  try {
955
944
  const tx = await buildTx();
956
945
  const result = await tryAutoTopUpThenSelfFund(client, keypair, tx);
957
946
  if (result) return result;
958
- } catch {
947
+ errors.push("auto-topup: not eligible (low USDC or sufficient SUI)");
948
+ } catch (err) {
949
+ errors.push(`auto-topup: ${err instanceof Error ? err.message : String(err)}`);
959
950
  }
960
951
  try {
961
952
  const tx = await buildTx();
962
953
  const result = await trySponsored(client, keypair, tx);
963
954
  if (result) return result;
964
- } catch {
955
+ errors.push("sponsored: returned null");
956
+ } catch (err) {
957
+ errors.push(`sponsored: ${err instanceof Error ? err.message : String(err)}`);
965
958
  }
966
959
  throw new T2000Error(
967
960
  "INSUFFICIENT_GAS",
968
- "No SUI for gas and Gas Station unavailable. Fund your wallet with SUI or USDC.",
969
- { reason: "all_gas_methods_exhausted" }
961
+ `No SUI for gas and Gas Station unavailable. Fund your wallet with SUI or USDC. [${errors.join(" | ")}]`,
962
+ { reason: "all_gas_methods_exhausted", errors }
970
963
  );
971
964
  }
972
965