btc-wallet 0.1.0 → 0.1.1
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 +12 -31
- package/dist/index.js.map +3 -3
- package/esm/index.js +12 -31
- package/esm/index.js.map +3 -3
- package/package.json +1 -1
package/esm/index.js
CHANGED
@@ -2318,7 +2318,6 @@ import { sha256 } from "js-sha256";
|
|
2318
2318
|
// src/utils/initWalletButton.ts
|
2319
2319
|
function setupWalletButton(network, wallet, originalWallet) {
|
2320
2320
|
if (document.getElementById("satoshi-wallet-button")) {
|
2321
|
-
sendInitializeData(wallet, originalWallet);
|
2322
2321
|
return;
|
2323
2322
|
}
|
2324
2323
|
const iframe = createIframe({
|
@@ -2387,45 +2386,27 @@ function createIframe({
|
|
2387
2386
|
document.body.appendChild(iframe);
|
2388
2387
|
return iframe;
|
2389
2388
|
}
|
2390
|
-
function
|
2389
|
+
function setupButtonClickHandler(button, iframe, wallet, originalWallet) {
|
2391
2390
|
return __async(this, null, function* () {
|
2392
|
-
var _a
|
2393
|
-
yield delay(1e3);
|
2391
|
+
var _a;
|
2394
2392
|
const accountId = (_a = yield wallet == null ? void 0 : wallet.getAccounts()) == null ? void 0 : _a[0].accountId;
|
2395
2393
|
const originalAccountId = originalWallet.account;
|
2396
2394
|
const originalPublicKey = yield originalWallet.getPublicKey();
|
2397
|
-
const iframe = document.getElementById("satoshi-wallet-iframe");
|
2398
|
-
if ((iframe == null ? void 0 : iframe.contentWindow) && ((_b = iframe.contentDocument) == null ? void 0 : _b.readyState) === "complete") {
|
2399
|
-
iframe.contentWindow.postMessage(
|
2400
|
-
{
|
2401
|
-
action: "initializeData",
|
2402
|
-
success: true,
|
2403
|
-
data: {
|
2404
|
-
accountId,
|
2405
|
-
originalAccountId,
|
2406
|
-
originalPublicKey
|
2407
|
-
}
|
2408
|
-
},
|
2409
|
-
{ targetOrigin: window.location.origin }
|
2410
|
-
);
|
2411
|
-
}
|
2412
|
-
});
|
2413
|
-
}
|
2414
|
-
function setupButtonClickHandler(button, iframe, wallet, originalWallet) {
|
2415
|
-
return __async(this, null, function* () {
|
2416
|
-
iframe.onload = () => sendInitializeData(wallet, originalWallet);
|
2417
2395
|
const iframeSrc = new URL(iframe.src);
|
2418
2396
|
iframeSrc.searchParams.set("origin", window.location.origin);
|
2397
|
+
accountId && iframeSrc.searchParams.set("accountId", accountId);
|
2398
|
+
originalAccountId && iframeSrc.searchParams.set("originalAccountId", originalAccountId);
|
2399
|
+
originalPublicKey && iframeSrc.searchParams.set("originalPublicKey", originalPublicKey);
|
2419
2400
|
iframe.src = iframeSrc.toString();
|
2420
2401
|
window.addEventListener("message", (event) => __async(this, null, function* () {
|
2421
|
-
var
|
2402
|
+
var _a2, _b;
|
2422
2403
|
if (event.origin !== iframeSrc.origin)
|
2423
2404
|
return;
|
2424
2405
|
const { action, requestId, data } = event.data;
|
2425
2406
|
if (action === "signAndSendTransaction") {
|
2426
2407
|
try {
|
2427
2408
|
const result = yield wallet.signAndSendTransaction(data);
|
2428
|
-
(
|
2409
|
+
(_a2 = event.source) == null ? void 0 : _a2.postMessage(
|
2429
2410
|
{
|
2430
2411
|
requestId,
|
2431
2412
|
data,
|
@@ -2788,16 +2769,16 @@ function toHex(originalString) {
|
|
2788
2769
|
}
|
2789
2770
|
function initWalletButton(network, accountId, wallet) {
|
2790
2771
|
return __async(this, null, function* () {
|
2791
|
-
yield delay(
|
2772
|
+
yield delay(1e3);
|
2792
2773
|
const checkAndSetupWalletButton = () => {
|
2793
2774
|
if (accountId && window.btcContext.account) {
|
2794
2775
|
setupWalletButton(network, wallet, window.btcContext);
|
2795
2776
|
} else {
|
2796
2777
|
removeWalletButton();
|
2778
|
+
!window.btcContext.account && setTimeout(() => {
|
2779
|
+
checkAndSetupWalletButton();
|
2780
|
+
}, 5e3);
|
2797
2781
|
}
|
2798
|
-
!window.btcContext.account && setTimeout(() => {
|
2799
|
-
checkAndSetupWalletButton();
|
2800
|
-
}, 1e4);
|
2801
2782
|
};
|
2802
2783
|
checkAndSetupWalletButton();
|
2803
2784
|
});
|
@@ -2847,7 +2828,7 @@ function pollTransactionStatuses(network, hashes) {
|
|
2847
2828
|
|
2848
2829
|
// src/index.ts
|
2849
2830
|
var getVersion = () => {
|
2850
|
-
return "0.1.
|
2831
|
+
return "0.1.1";
|
2851
2832
|
};
|
2852
2833
|
if (typeof window !== "undefined") {
|
2853
2834
|
window.__PARTICLE_BTC_CONNECT_VERSION = getVersion();
|