@t2000/sdk 0.1.9 → 0.2.0

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