@t2000/sdk 0.1.8 → 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.js CHANGED
@@ -721,11 +721,11 @@ function solveHashcash(challenge) {
721
721
  }
722
722
 
723
723
  // src/gas/gasStation.ts
724
- async function requestGasSponsorship(txBytesBase64, sender, type) {
724
+ async function requestGasSponsorship(txJson, sender, type) {
725
725
  const res = await fetch(`${API_BASE_URL}/api/gas`, {
726
726
  method: "POST",
727
727
  headers: { "Content-Type": "application/json" },
728
- body: JSON.stringify({ txBytes: txBytesBase64, sender, type })
728
+ body: JSON.stringify({ txJson, sender, type })
729
729
  });
730
730
  const data = await res.json();
731
731
  if (!res.ok) {
@@ -795,9 +795,8 @@ async function executeAutoTopUp(client, keypair) {
795
795
  toAsset: "SUI",
796
796
  amount: topupAmountHuman
797
797
  });
798
- const txBytes = await tx.build({ client, onlyTransactionKind: true });
799
- const txBytesBase64 = Buffer.from(txBytes).toString("base64");
800
- const sponsoredResult = await requestGasSponsorship(txBytesBase64, address, "auto-topup");
798
+ const txJson = tx.serialize();
799
+ const sponsoredResult = await requestGasSponsorship(txJson, address, "auto-topup");
801
800
  const sponsoredTxBytes = Buffer.from(sponsoredResult.txBytes, "base64");
802
801
  const { signature: agentSig } = await keypair.signTransaction(sponsoredTxBytes);
803
802
  const result = await client.executeTransactionBlock({
@@ -872,9 +871,8 @@ async function tryAutoTopUpThenSelfFund(client, keypair, tx) {
872
871
  async function trySponsored(client, keypair, tx) {
873
872
  const address = keypair.getPublicKey().toSuiAddress();
874
873
  tx.setSender(address);
875
- const txBytes = await tx.build({ client, onlyTransactionKind: true });
876
- const txBytesBase64 = Buffer.from(txBytes).toString("base64");
877
- const sponsoredResult = await requestGasSponsorship(txBytesBase64, address);
874
+ const txJson = tx.serialize();
875
+ const sponsoredResult = await requestGasSponsorship(txJson, address);
878
876
  const sponsoredTxBytes = Buffer.from(sponsoredResult.txBytes, "base64");
879
877
  const { signature: agentSig } = await keypair.signTransaction(sponsoredTxBytes);
880
878
  const result = await client.executeTransactionBlock({