btc-wallet 0.5.50-beta → 0.5.52-beta
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 +29 -13
- package/dist/index.js.map +3 -3
- package/esm/index.js +29 -13
- package/esm/index.js.map +3 -3
- package/package.json +1 -1
package/esm/index.js
CHANGED
@@ -2320,6 +2320,14 @@ var ConnectProvider = ({
|
|
2320
2320
|
name: ((_a = Object.keys(options.aaOptions.accountContracts)) == null ? void 0 : _a[0]) || "BTC",
|
2321
2321
|
version: ((_c = options.aaOptions.accountContracts[((_b = Object.keys(options.aaOptions.accountContracts)) == null ? void 0 : _b[0]) || "BTC"]) == null ? void 0 : _c[0].version) || "1.0.0"
|
2322
2322
|
});
|
2323
|
+
const initConnectorId = useCallback7(() => {
|
2324
|
+
const id = localStorage.getItem("current-connector-id");
|
2325
|
+
setConnectorId(id || "");
|
2326
|
+
}, []);
|
2327
|
+
const getConnector = useCallback7(() => {
|
2328
|
+
const connectorId2 = localStorage.getItem("current-connector-id");
|
2329
|
+
return connectors.find((item) => item.metadata.id === connectorId2);
|
2330
|
+
}, [connectorId, connectors]);
|
2323
2331
|
const setAccountContract = useCallback7(
|
2324
2332
|
(config) => {
|
2325
2333
|
if (!checkBTCVersion(options.aaOptions.accountContracts, config.name, config.version)) {
|
@@ -2331,11 +2339,8 @@ var ConnectProvider = ({
|
|
2331
2339
|
[options.aaOptions.accountContracts, _setAccountContract]
|
2332
2340
|
);
|
2333
2341
|
useEffect5(() => {
|
2334
|
-
|
2335
|
-
|
2336
|
-
setConnectorId(id);
|
2337
|
-
}
|
2338
|
-
}, [autoConnect]);
|
2342
|
+
initConnectorId();
|
2343
|
+
}, [autoConnect, initConnectorId]);
|
2339
2344
|
const evmSupportChainIds = useMemo5(() => {
|
2340
2345
|
var _a2;
|
2341
2346
|
let chainIds = (_a2 = options.aaOptions.accountContracts[accountContract.name]) == null ? void 0 : _a2.filter((item) => item.version === accountContract.version).map((item) => item.chainIds).reduce((a, b) => {
|
@@ -2345,16 +2350,15 @@ var ConnectProvider = ({
|
|
2345
2350
|
chainIds = Array.from(new Set(chainIds || []));
|
2346
2351
|
return chainIds;
|
2347
2352
|
}, [options.aaOptions.accountContracts, accountContract]);
|
2348
|
-
const connector = useMemo5(() =>
|
2349
|
-
return connectors.find((item) => item.metadata.id === connectorId);
|
2350
|
-
}, [connectorId, connectors]);
|
2353
|
+
const connector = useMemo5(() => getConnector(), [connectorId, connectors]);
|
2351
2354
|
const getPublicKey = useCallback7(() => __async(void 0, null, function* () {
|
2352
|
-
|
2355
|
+
const connector2 = getConnector();
|
2356
|
+
if (!connector2) {
|
2353
2357
|
throw new Error("Wallet not connected!");
|
2354
2358
|
}
|
2355
|
-
const pubKey = yield
|
2359
|
+
const pubKey = yield connector2.getPublicKey();
|
2356
2360
|
return pubKey;
|
2357
|
-
}), [
|
2361
|
+
}), [getConnector]);
|
2358
2362
|
const signMessage = useCallback7(
|
2359
2363
|
(message) => __async(void 0, null, function* () {
|
2360
2364
|
if (!connector) {
|
@@ -3655,7 +3659,7 @@ function getNetwork() {
|
|
3655
3659
|
});
|
3656
3660
|
}
|
3657
3661
|
function formatBtcAmount(amount) {
|
3658
|
-
return new Big2(amount).div(__pow(10, 8)).
|
3662
|
+
return new Big2(amount).div(__pow(10, 8)).toFixed();
|
3659
3663
|
}
|
3660
3664
|
function getBtcRpcUrl() {
|
3661
3665
|
return __async(this, null, function* () {
|
@@ -4264,6 +4268,18 @@ function calculateWithdraw(_0) {
|
|
4264
4268
|
errorMsg: "Not enough gas"
|
4265
4269
|
};
|
4266
4270
|
}
|
4271
|
+
const belowMinChangeAmount = newOutputs.some(
|
4272
|
+
(item) => item.value > 0 && item.value < Number(brgConfig.min_change_amount)
|
4273
|
+
);
|
4274
|
+
if (belowMinChangeAmount) {
|
4275
|
+
const minWithdrawAmount = new Big2(brgConfig.min_withdraw_amount).plus(brgConfig.min_change_amount).plus(gasLimit).plus(withdrawFee).toNumber();
|
4276
|
+
return {
|
4277
|
+
gasFee: newFee,
|
4278
|
+
withdrawFee,
|
4279
|
+
isError: true,
|
4280
|
+
errorMsg: `Transaction amount too small. Minimum required: ${formatBtcAmount(minWithdrawAmount)} BTC`
|
4281
|
+
};
|
4282
|
+
}
|
4267
4283
|
const inputSum = newInputs.reduce((sum, cur) => sum + Number(cur.value), 0);
|
4268
4284
|
const outputSum = newOutputs.reduce((sum, cur) => sum + Number(cur.value), 0);
|
4269
4285
|
if (newFee + outputSum !== inputSum) {
|
@@ -4965,7 +4981,7 @@ function getGroup(state) {
|
|
4965
4981
|
|
4966
4982
|
// src/index.ts
|
4967
4983
|
var getVersion = () => {
|
4968
|
-
return "0.5.
|
4984
|
+
return "0.5.52-beta";
|
4969
4985
|
};
|
4970
4986
|
if (typeof window !== "undefined") {
|
4971
4987
|
window.__BTC_WALLET_VERSION = getVersion();
|