@t2000/sdk 0.1.9 → 0.2.1

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
@@ -723,11 +723,12 @@ function solveHashcash(challenge) {
723
723
  }
724
724
 
725
725
  // src/gas/gasStation.ts
726
- async function requestGasSponsorship(txBytesBase64, sender, type) {
726
+ async function requestGasSponsorship(txJson, sender, type) {
727
+ const txBytes = Buffer.from(txJson).toString("base64");
727
728
  const res = await fetch(`${API_BASE_URL}/api/gas`, {
728
729
  method: "POST",
729
730
  headers: { "Content-Type": "application/json" },
730
- body: JSON.stringify({ txBytes: txBytesBase64, sender, type })
731
+ body: JSON.stringify({ txJson, txBytes, sender, type })
731
732
  });
732
733
  const data = await res.json();
733
734
  if (!res.ok) {
@@ -798,8 +799,7 @@ async function executeAutoTopUp(client, keypair) {
798
799
  amount: topupAmountHuman
799
800
  });
800
801
  const txJson = tx.serialize();
801
- const txBytesBase64 = Buffer.from(txJson).toString("base64");
802
- const sponsoredResult = await requestGasSponsorship(txBytesBase64, address, "auto-topup");
802
+ const sponsoredResult = await requestGasSponsorship(txJson, address, "auto-topup");
803
803
  const sponsoredTxBytes = Buffer.from(sponsoredResult.txBytes, "base64");
804
804
  const { signature: agentSig } = await keypair.signTransaction(sponsoredTxBytes);
805
805
  const result = await client.executeTransactionBlock({
@@ -875,8 +875,7 @@ async function trySponsored(client, keypair, tx) {
875
875
  const address = keypair.getPublicKey().toSuiAddress();
876
876
  tx.setSender(address);
877
877
  const txJson = tx.serialize();
878
- const txBytesBase64 = Buffer.from(txJson).toString("base64");
879
- const sponsoredResult = await requestGasSponsorship(txBytesBase64, address);
878
+ const sponsoredResult = await requestGasSponsorship(txJson, address);
880
879
  const sponsoredTxBytes = Buffer.from(sponsoredResult.txBytes, "base64");
881
880
  const { signature: agentSig } = await keypair.signTransaction(sponsoredTxBytes);
882
881
  const result = await client.executeTransactionBlock({