@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.cjs +6 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -8
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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(
|
|
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({
|
|
730
|
+
body: JSON.stringify({ txJson, sender, type })
|
|
731
731
|
});
|
|
732
732
|
const data = await res.json();
|
|
733
733
|
if (!res.ok) {
|
|
@@ -797,9 +797,8 @@ async function executeAutoTopUp(client, keypair) {
|
|
|
797
797
|
toAsset: "SUI",
|
|
798
798
|
amount: topupAmountHuman
|
|
799
799
|
});
|
|
800
|
-
const
|
|
801
|
-
const
|
|
802
|
-
const sponsoredResult = await requestGasSponsorship(txBytesBase64, address, "auto-topup");
|
|
800
|
+
const txJson = tx.serialize();
|
|
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({
|
|
@@ -874,9 +873,8 @@ async function tryAutoTopUpThenSelfFund(client, keypair, tx) {
|
|
|
874
873
|
async function trySponsored(client, keypair, tx) {
|
|
875
874
|
const address = keypair.getPublicKey().toSuiAddress();
|
|
876
875
|
tx.setSender(address);
|
|
877
|
-
const
|
|
878
|
-
const
|
|
879
|
-
const sponsoredResult = await requestGasSponsorship(txBytesBase64, address);
|
|
876
|
+
const txJson = tx.serialize();
|
|
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({
|