btc-wallet 0.0.9 → 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 -28
- package/dist/index.js.map +3 -3
- package/esm/index.js +12 -28
- package/esm/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -2359,7 +2359,6 @@ var import_js_sha256 = require("js-sha256");
|
|
2359
2359
|
// src/utils/initWalletButton.ts
|
2360
2360
|
function setupWalletButton(network, wallet, originalWallet) {
|
2361
2361
|
if (document.getElementById("satoshi-wallet-button")) {
|
2362
|
-
sendInitializeData(wallet, originalWallet);
|
2363
2362
|
return;
|
2364
2363
|
}
|
2365
2364
|
const iframe = createIframe({
|
@@ -2428,42 +2427,27 @@ function createIframe({
|
|
2428
2427
|
document.body.appendChild(iframe);
|
2429
2428
|
return iframe;
|
2430
2429
|
}
|
2431
|
-
function
|
2430
|
+
function setupButtonClickHandler(button, iframe, wallet, originalWallet) {
|
2432
2431
|
return __async(this, null, function* () {
|
2433
|
-
var _a
|
2434
|
-
yield delay(1e3);
|
2432
|
+
var _a;
|
2435
2433
|
const accountId = (_a = yield wallet == null ? void 0 : wallet.getAccounts()) == null ? void 0 : _a[0].accountId;
|
2436
2434
|
const originalAccountId = originalWallet.account;
|
2437
2435
|
const originalPublicKey = yield originalWallet.getPublicKey();
|
2438
|
-
const iframe = document.getElementById("satoshi-wallet-iframe");
|
2439
|
-
if ((iframe == null ? void 0 : iframe.contentWindow) && ((_b = iframe.contentDocument) == null ? void 0 : _b.readyState) === "complete") {
|
2440
|
-
iframe.contentWindow.postMessage({
|
2441
|
-
action: "initializeData",
|
2442
|
-
success: true,
|
2443
|
-
data: {
|
2444
|
-
accountId,
|
2445
|
-
originalAccountId,
|
2446
|
-
originalPublicKey
|
2447
|
-
}
|
2448
|
-
});
|
2449
|
-
}
|
2450
|
-
});
|
2451
|
-
}
|
2452
|
-
function setupButtonClickHandler(button, iframe, wallet, originalWallet) {
|
2453
|
-
return __async(this, null, function* () {
|
2454
|
-
iframe.onload = () => sendInitializeData(wallet, originalWallet);
|
2455
2436
|
const iframeSrc = new URL(iframe.src);
|
2456
2437
|
iframeSrc.searchParams.set("origin", window.location.origin);
|
2438
|
+
accountId && iframeSrc.searchParams.set("accountId", accountId);
|
2439
|
+
originalAccountId && iframeSrc.searchParams.set("originalAccountId", originalAccountId);
|
2440
|
+
originalPublicKey && iframeSrc.searchParams.set("originalPublicKey", originalPublicKey);
|
2457
2441
|
iframe.src = iframeSrc.toString();
|
2458
2442
|
window.addEventListener("message", (event) => __async(this, null, function* () {
|
2459
|
-
var
|
2443
|
+
var _a2, _b;
|
2460
2444
|
if (event.origin !== iframeSrc.origin)
|
2461
2445
|
return;
|
2462
2446
|
const { action, requestId, data } = event.data;
|
2463
2447
|
if (action === "signAndSendTransaction") {
|
2464
2448
|
try {
|
2465
2449
|
const result = yield wallet.signAndSendTransaction(data);
|
2466
|
-
(
|
2450
|
+
(_a2 = event.source) == null ? void 0 : _a2.postMessage(
|
2467
2451
|
{
|
2468
2452
|
requestId,
|
2469
2453
|
data,
|
@@ -2826,16 +2810,16 @@ function toHex(originalString) {
|
|
2826
2810
|
}
|
2827
2811
|
function initWalletButton(network, accountId, wallet) {
|
2828
2812
|
return __async(this, null, function* () {
|
2829
|
-
yield delay(
|
2813
|
+
yield delay(1e3);
|
2830
2814
|
const checkAndSetupWalletButton = () => {
|
2831
2815
|
if (accountId && window.btcContext.account) {
|
2832
2816
|
setupWalletButton(network, wallet, window.btcContext);
|
2833
2817
|
} else {
|
2834
2818
|
removeWalletButton();
|
2819
|
+
!window.btcContext.account && setTimeout(() => {
|
2820
|
+
checkAndSetupWalletButton();
|
2821
|
+
}, 5e3);
|
2835
2822
|
}
|
2836
|
-
!window.btcContext.account && setTimeout(() => {
|
2837
|
-
checkAndSetupWalletButton();
|
2838
|
-
}, 1e4);
|
2839
2823
|
};
|
2840
2824
|
checkAndSetupWalletButton();
|
2841
2825
|
});
|
@@ -2885,7 +2869,7 @@ function pollTransactionStatuses(network, hashes) {
|
|
2885
2869
|
|
2886
2870
|
// src/index.ts
|
2887
2871
|
var getVersion = () => {
|
2888
|
-
return "0.
|
2872
|
+
return "0.1.1";
|
2889
2873
|
};
|
2890
2874
|
if (typeof window !== "undefined") {
|
2891
2875
|
window.__PARTICLE_BTC_CONNECT_VERSION = getVersion();
|