@weblock-wallet/sdk 0.1.62 → 0.1.64
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 +38 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +38 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -104695,8 +104695,22 @@ var WalletService = class {
|
|
|
104695
104695
|
"TRANSACTION_FAILED" /* TRANSACTION_FAILED */
|
|
104696
104696
|
);
|
|
104697
104697
|
}
|
|
104698
|
-
const
|
|
104699
|
-
|
|
104698
|
+
const pendingNonceHex = await this.rpcClient.sendRpc({
|
|
104699
|
+
chainId: params.chainId,
|
|
104700
|
+
method: "eth_getTransactionCount" /* ETH_GET_TRANSACTION_COUNT */,
|
|
104701
|
+
params: [from, "pending"]
|
|
104702
|
+
});
|
|
104703
|
+
const pendingNonce = parseInt(
|
|
104704
|
+
pendingNonceHex?.result ?? "0x0",
|
|
104705
|
+
16
|
|
104706
|
+
);
|
|
104707
|
+
const nonce = params.nonce ?? pendingNonce;
|
|
104708
|
+
let gasPrice = params.gasPrice ?? await this.getGasPrice(params.chainId);
|
|
104709
|
+
try {
|
|
104710
|
+
const bumped = BigInt(gasPrice) * 12n / 10n;
|
|
104711
|
+
gasPrice = "0x" + bumped.toString(16);
|
|
104712
|
+
} catch {
|
|
104713
|
+
}
|
|
104700
104714
|
let gasLimit = params.gasLimit;
|
|
104701
104715
|
if (!gasLimit) {
|
|
104702
104716
|
try {
|
|
@@ -104745,8 +104759,19 @@ var WalletService = class {
|
|
|
104745
104759
|
await LocalForage.delete(STORAGE_KEYS.share2(this.orgHost));
|
|
104746
104760
|
return txHash;
|
|
104747
104761
|
} catch (error) {
|
|
104762
|
+
if (error instanceof SDKError) {
|
|
104763
|
+
throw error;
|
|
104764
|
+
}
|
|
104765
|
+
const msg = (() => {
|
|
104766
|
+
try {
|
|
104767
|
+
const anyErr = error;
|
|
104768
|
+
return anyErr?.shortMessage || anyErr?.reason || anyErr?.message || String(error);
|
|
104769
|
+
} catch {
|
|
104770
|
+
return "Unknown error";
|
|
104771
|
+
}
|
|
104772
|
+
})();
|
|
104748
104773
|
throw new SDKError(
|
|
104749
|
-
|
|
104774
|
+
`Transaction failed: ${msg}`,
|
|
104750
104775
|
"TRANSACTION_FAILED" /* TRANSACTION_FAILED */,
|
|
104751
104776
|
error
|
|
104752
104777
|
);
|
|
@@ -105221,17 +105246,17 @@ var RpcClient = class {
|
|
|
105221
105246
|
method: request.method,
|
|
105222
105247
|
params: request.params
|
|
105223
105248
|
};
|
|
105224
|
-
const res = await this.client.post(
|
|
105225
|
-
|
|
105226
|
-
|
|
105227
|
-
|
|
105228
|
-
|
|
105249
|
+
const res = await this.client.post(this.baseUrl, rpcRequest, {
|
|
105250
|
+
needsAccessToken: true
|
|
105251
|
+
});
|
|
105252
|
+
if (res && typeof res.result === "string") {
|
|
105253
|
+
const t5 = res.result.trim();
|
|
105254
|
+
if (t5.startsWith("{") && t5.endsWith("}") || t5.startsWith("[") && t5.endsWith("]")) {
|
|
105255
|
+
try {
|
|
105256
|
+
res.result = JSON.parse(t5);
|
|
105257
|
+
} catch {
|
|
105258
|
+
}
|
|
105229
105259
|
}
|
|
105230
|
-
);
|
|
105231
|
-
if (res?.error) {
|
|
105232
|
-
const err = res.error;
|
|
105233
|
-
const msg = err?.message || "RPC error";
|
|
105234
|
-
throw new SDKError(msg, "REQUEST_FAILED" /* REQUEST_FAILED */, err);
|
|
105235
105260
|
}
|
|
105236
105261
|
return res;
|
|
105237
105262
|
}
|