btc-wallet 0.0.4 → 0.0.6
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/context/index.d.ts +1 -1
- package/dist/hooks/useConnectModal.d.ts +1 -1
- package/dist/index.js +30 -13
- package/dist/index.js.map +2 -2
- package/esm/index.js +30 -13
- package/esm/index.js.map +2 -2
- package/package.json +1 -1
package/esm/index.js
CHANGED
@@ -1939,6 +1939,7 @@ var ConnectProvider = ({
|
|
1939
1939
|
accounts2 = yield connector2.requestAccounts();
|
1940
1940
|
}
|
1941
1941
|
setAccounts(accounts2);
|
1942
|
+
return accounts2;
|
1942
1943
|
}),
|
1943
1944
|
[]
|
1944
1945
|
);
|
@@ -2194,7 +2195,7 @@ function BtcWalletSelectorContextProvider({ children, autoConnect = false }) {
|
|
2194
2195
|
visible: true
|
2195
2196
|
}
|
2196
2197
|
},
|
2197
|
-
autoConnect,
|
2198
|
+
autoConnect: false,
|
2198
2199
|
connectors: [new UnisatConnector()],
|
2199
2200
|
children: [
|
2200
2201
|
children,
|
@@ -2227,17 +2228,23 @@ function useBtcWalletSelector() {
|
|
2227
2228
|
signMessageFn.current = signMessage;
|
2228
2229
|
}, [signMessage]);
|
2229
2230
|
useEffect7(() => {
|
2231
|
+
const fn = (account) => {
|
2232
|
+
if (account) {
|
2233
|
+
getPublicKey().then((res) => {
|
2234
|
+
publicKey.current = res;
|
2235
|
+
context.emit("updatePublicKey", res);
|
2236
|
+
});
|
2237
|
+
}
|
2238
|
+
};
|
2230
2239
|
if (connector) {
|
2231
|
-
connector.on("accountsChanged",
|
2232
|
-
if (account) {
|
2233
|
-
getPublicKey().then((res) => {
|
2234
|
-
publicKey.current = res;
|
2235
|
-
context.emit("updatePublicKey", res);
|
2236
|
-
});
|
2237
|
-
}
|
2238
|
-
});
|
2240
|
+
connector.on("accountsChanged", fn);
|
2239
2241
|
}
|
2240
2242
|
connectorRef.current = connector;
|
2243
|
+
return () => {
|
2244
|
+
if (connector) {
|
2245
|
+
connector.removeListener("accountsChanged", fn);
|
2246
|
+
}
|
2247
|
+
};
|
2241
2248
|
}, [connector]);
|
2242
2249
|
return {
|
2243
2250
|
login: () => __async(this, null, function* () {
|
@@ -2255,7 +2262,9 @@ function useBtcWalletSelector() {
|
|
2255
2262
|
return null;
|
2256
2263
|
}
|
2257
2264
|
}
|
2258
|
-
|
2265
|
+
requestDirectAccount(connectorRef.current).catch((e) => {
|
2266
|
+
context.emit("btcLoginError");
|
2267
|
+
});
|
2259
2268
|
}),
|
2260
2269
|
logout: () => {
|
2261
2270
|
disconnect && disconnect();
|
@@ -2365,6 +2374,7 @@ function createIframe({
|
|
2365
2374
|
}) {
|
2366
2375
|
const iframe = document.createElement("iframe");
|
2367
2376
|
iframe.id = "satoshi-wallet-iframe";
|
2377
|
+
iframe.allow = "clipboard-read; clipboard-write";
|
2368
2378
|
iframe.src = iframeUrl;
|
2369
2379
|
Object.assign(iframe.style, __spreadValues({
|
2370
2380
|
position: "fixed",
|
@@ -2518,7 +2528,13 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
|
|
2518
2528
|
]
|
2519
2529
|
});
|
2520
2530
|
}));
|
2531
|
+
context.on("btcLoginError", (e) => __async(void 0, null, function* () {
|
2532
|
+
emitter.emit("accountsChanged", {
|
2533
|
+
accounts: []
|
2534
|
+
});
|
2535
|
+
}));
|
2521
2536
|
if ("autoConnect" in metadata && metadata.autoConnect && localStorage.getItem("near-wallet-selector:selectedWalletId") === '"btc-wallet"') {
|
2537
|
+
btcContext.autoConnect();
|
2522
2538
|
}
|
2523
2539
|
clearInterval(inter);
|
2524
2540
|
}
|
@@ -2661,7 +2677,8 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
|
|
2661
2677
|
baseDecode(header.hash)
|
2662
2678
|
);
|
2663
2679
|
const txBytes = encodeTransaction(_transaction);
|
2664
|
-
const txHex =
|
2680
|
+
const txHex = Array.from(txBytes, (byte) => ("0" + (byte & 255).toString(16)).slice(-2)).join("");
|
2681
|
+
;
|
2665
2682
|
const hash = bs58.encode(new Uint8Array(sha256.array(txBytes)));
|
2666
2683
|
return { txBytes, txHex, hash };
|
2667
2684
|
});
|
@@ -2674,7 +2691,7 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
|
|
2674
2691
|
const intention = {
|
2675
2692
|
chain_id: "397",
|
2676
2693
|
csna: accountId,
|
2677
|
-
near_transactions: newTransactions.map((t) =>
|
2694
|
+
near_transactions: newTransactions.map((t) => t.txHex),
|
2678
2695
|
gas_token: token,
|
2679
2696
|
gas_limit: "3000",
|
2680
2697
|
nonce: Number(nonce).toString()
|
@@ -2817,7 +2834,7 @@ function pollTransactionStatuses(network, hashes) {
|
|
2817
2834
|
|
2818
2835
|
// src/index.ts
|
2819
2836
|
var getVersion = () => {
|
2820
|
-
return "0.0.
|
2837
|
+
return "0.0.6";
|
2821
2838
|
};
|
2822
2839
|
if (typeof window !== "undefined") {
|
2823
2840
|
window.__PARTICLE_BTC_CONNECT_VERSION = getVersion();
|