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