btc-wallet 0.5.27-beta → 0.5.29-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/core/btcUtils.d.ts +6 -1
- package/dist/index.js +18 -21
- package/dist/index.js.map +2 -2
- package/esm/index.js +18 -21
- package/esm/index.js.map +2 -2
- package/package.json +1 -1
package/esm/index.js
CHANGED
@@ -19,18 +19,6 @@ var __spreadValues = (a, b) => {
|
|
19
19
|
return a;
|
20
20
|
};
|
21
21
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
22
|
-
var __objRest = (source, exclude) => {
|
23
|
-
var target = {};
|
24
|
-
for (var prop in source)
|
25
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
26
|
-
target[prop] = source[prop];
|
27
|
-
if (source != null && __getOwnPropSymbols)
|
28
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
29
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
30
|
-
target[prop] = source[prop];
|
31
|
-
}
|
32
|
-
return target;
|
33
|
-
};
|
34
22
|
var __accessCheck = (obj, member, msg) => {
|
35
23
|
if (!member.has(obj))
|
36
24
|
throw TypeError("Cannot " + msg);
|
@@ -3869,8 +3857,10 @@ function getBtcGasPrice() {
|
|
3869
3857
|
function getBtcUtxos(account) {
|
3870
3858
|
return __async(this, null, function* () {
|
3871
3859
|
const btcRpcUrl = yield getBtcRpcUrl();
|
3872
|
-
const utxos = yield fetch(
|
3873
|
-
|
3860
|
+
const utxos = yield fetch(
|
3861
|
+
`${btcRpcUrl}/address/${account}/utxo`
|
3862
|
+
).then((res) => res.json());
|
3863
|
+
return utxos.filter((item) => item.status.confirmed);
|
3874
3864
|
});
|
3875
3865
|
}
|
3876
3866
|
function calculateGasFee(account, amount, feeRate) {
|
@@ -4127,13 +4117,13 @@ function getWithdrawTransaction(_0) {
|
|
4127
4117
|
const config = getWalletConfig(env);
|
4128
4118
|
const _btcAddress = btcAddress || getBtcProvider().account;
|
4129
4119
|
const _csna = csna || (yield getCsnaAccountId(env));
|
4130
|
-
const
|
4120
|
+
const { inputs, outputs, isError, errorMsg, fromAmount, gasFee } = yield calculateWithdraw({
|
4131
4121
|
amount,
|
4132
4122
|
feeRate,
|
4133
4123
|
csna: _csna,
|
4134
4124
|
btcAddress: _btcAddress,
|
4135
4125
|
env
|
4136
|
-
})
|
4126
|
+
});
|
4137
4127
|
if (isError || !inputs || !outputs) {
|
4138
4128
|
throw new Error(errorMsg);
|
4139
4129
|
}
|
@@ -4141,7 +4131,7 @@ function getWithdrawTransaction(_0) {
|
|
4141
4131
|
console.log("outputs:", JSON.stringify(outputs));
|
4142
4132
|
console.log("inputs - outputs = gas");
|
4143
4133
|
console.log(
|
4144
|
-
`(${inputs.map((item) => item.value).join(" + ")}) - (${outputs.map((item) => item.value).join(" + ")}) = ${
|
4134
|
+
`(${inputs.map((item) => item.value).join(" + ")}) - (${outputs.map((item) => item.value).join(" + ")}) = ${gasFee}`
|
4145
4135
|
);
|
4146
4136
|
const network = yield getNetwork();
|
4147
4137
|
const btcNetwork = network === "mainnet" ? bitcoin.networks.bitcoin : bitcoin.networks.testnet;
|
@@ -4194,7 +4184,7 @@ function getWithdrawTransaction(_0) {
|
|
4194
4184
|
methodName: "ft_transfer_call",
|
4195
4185
|
args: {
|
4196
4186
|
receiver_id: config.bridgeContractId,
|
4197
|
-
amount:
|
4187
|
+
amount: fromAmount == null ? void 0 : fromAmount.toString(),
|
4198
4188
|
msg: JSON.stringify(msg)
|
4199
4189
|
},
|
4200
4190
|
gas: "300000000000000",
|
@@ -4369,6 +4359,7 @@ function createIframe({
|
|
4369
4359
|
document.body.appendChild(iframe);
|
4370
4360
|
return iframe;
|
4371
4361
|
}
|
4362
|
+
var currentMessageHandler = null;
|
4372
4363
|
function setupButtonClickHandler(button, iframe, wallet, originalWallet) {
|
4373
4364
|
return __async(this, null, function* () {
|
4374
4365
|
var _a;
|
@@ -4388,7 +4379,11 @@ function setupButtonClickHandler(button, iframe, wallet, originalWallet) {
|
|
4388
4379
|
executeBTCDepositAndAction,
|
4389
4380
|
getWithdrawTransaction
|
4390
4381
|
};
|
4391
|
-
|
4382
|
+
if (currentMessageHandler) {
|
4383
|
+
window.removeEventListener("message", currentMessageHandler);
|
4384
|
+
currentMessageHandler = null;
|
4385
|
+
}
|
4386
|
+
const handleWalletMessage = (event) => __async(this, null, function* () {
|
4392
4387
|
var _a2, _b;
|
4393
4388
|
if (event.origin !== iframeSrc.origin)
|
4394
4389
|
return;
|
@@ -4419,7 +4414,9 @@ function setupButtonClickHandler(button, iframe, wallet, originalWallet) {
|
|
4419
4414
|
{ targetOrigin: event.origin }
|
4420
4415
|
);
|
4421
4416
|
}
|
4422
|
-
})
|
4417
|
+
});
|
4418
|
+
currentMessageHandler = handleWalletMessage;
|
4419
|
+
window.addEventListener("message", handleWalletMessage);
|
4423
4420
|
});
|
4424
4421
|
}
|
4425
4422
|
function removeWalletButton() {
|
@@ -4842,7 +4839,7 @@ function getGroup(state) {
|
|
4842
4839
|
|
4843
4840
|
// src/index.ts
|
4844
4841
|
var getVersion = () => {
|
4845
|
-
return "0.5.
|
4842
|
+
return "0.5.29-beta";
|
4846
4843
|
};
|
4847
4844
|
if (typeof window !== "undefined") {
|
4848
4845
|
window.__BTC_WALLET_VERSION = getVersion();
|