@omnisat/lasereyes 0.0.23 → 0.0.25
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.d.ts +1 -0
- package/dist/index.js +26 -6
- package/dist/index.mjs +30 -9
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -288,6 +288,7 @@ var initialWalletContext = {
|
|
|
288
288
|
hasLeather: false,
|
|
289
289
|
hasPhantom: false,
|
|
290
290
|
hasWizz: false,
|
|
291
|
+
isInitializing: true,
|
|
291
292
|
connected: false,
|
|
292
293
|
isConnecting: false,
|
|
293
294
|
publicKey: "",
|
|
@@ -514,6 +515,7 @@ var LaserEyesProvider = ({
|
|
|
514
515
|
const self = selfRef.current;
|
|
515
516
|
const [library, setLibrary] = (0, import_react.useState)(null);
|
|
516
517
|
const [provider, setProvider] = (0, import_react.useState)();
|
|
518
|
+
const [isInitializing, setIsInitializing] = (0, import_react.useState)(true);
|
|
517
519
|
const [connected, setConnected] = (0, import_react.useState)(false);
|
|
518
520
|
const [isConnecting, setIsConnecting] = (0, import_react.useState)(false);
|
|
519
521
|
const [accounts, setAccounts] = (0, import_react.useState)([]);
|
|
@@ -545,6 +547,11 @@ var LaserEyesProvider = ({
|
|
|
545
547
|
});
|
|
546
548
|
}
|
|
547
549
|
}, [config, library]);
|
|
550
|
+
const checkInitializationComplete = () => {
|
|
551
|
+
if (hasUnisat !== void 0 && hasXverse !== void 0 && hasOyl !== void 0 && hasMagicEden !== void 0 && hasOkx !== void 0 && hasLeather !== void 0 && hasPhantom !== void 0 && hasWizz !== void 0) {
|
|
552
|
+
setIsInitializing(false);
|
|
553
|
+
}
|
|
554
|
+
};
|
|
548
555
|
(0, import_react.useEffect)(() => {
|
|
549
556
|
const observer = new MutationObserver(() => {
|
|
550
557
|
const unisatLib = window == null ? void 0 : window.unisat;
|
|
@@ -660,6 +667,18 @@ var LaserEyesProvider = ({
|
|
|
660
667
|
observer.disconnect();
|
|
661
668
|
};
|
|
662
669
|
}, []);
|
|
670
|
+
(0, import_react.useEffect)(() => {
|
|
671
|
+
checkInitializationComplete();
|
|
672
|
+
}, [
|
|
673
|
+
hasUnisat,
|
|
674
|
+
hasXverse,
|
|
675
|
+
hasOyl,
|
|
676
|
+
hasMagicEden,
|
|
677
|
+
hasOkx,
|
|
678
|
+
hasLeather,
|
|
679
|
+
hasPhantom,
|
|
680
|
+
hasWizz
|
|
681
|
+
]);
|
|
663
682
|
(0, import_react.useEffect)(() => {
|
|
664
683
|
setBalance(void 0);
|
|
665
684
|
}, [network]);
|
|
@@ -686,7 +705,7 @@ var LaserEyesProvider = ({
|
|
|
686
705
|
connect(defaultWallet);
|
|
687
706
|
}
|
|
688
707
|
}, []);
|
|
689
|
-
const connectUnisat = () => __async(void 0, null, function* () {
|
|
708
|
+
const connectUnisat = (0, import_react.useCallback)(() => __async(void 0, null, function* () {
|
|
690
709
|
try {
|
|
691
710
|
localStorage == null ? void 0 : localStorage.setItem(LOCAL_STORAGE_DEFAULT_WALLET, UNISAT);
|
|
692
711
|
const lib = window.unisat;
|
|
@@ -709,8 +728,8 @@ var LaserEyesProvider = ({
|
|
|
709
728
|
} catch (error) {
|
|
710
729
|
throw error;
|
|
711
730
|
}
|
|
712
|
-
});
|
|
713
|
-
const connectXverse = () => __async(void 0, null, function* () {
|
|
731
|
+
}), [hasUnisat]);
|
|
732
|
+
const connectXverse = (0, import_react.useCallback)(() => __async(void 0, null, function* () {
|
|
714
733
|
try {
|
|
715
734
|
localStorage == null ? void 0 : localStorage.setItem(LOCAL_STORAGE_DEFAULT_WALLET, XVERSE);
|
|
716
735
|
let xverseNetwork = getXverseNetwork((config == null ? void 0 : config.network) || MAINNET);
|
|
@@ -749,7 +768,7 @@ var LaserEyesProvider = ({
|
|
|
749
768
|
} catch (error) {
|
|
750
769
|
throw error;
|
|
751
770
|
}
|
|
752
|
-
});
|
|
771
|
+
}), [hasXverse]);
|
|
753
772
|
const connectOyl = () => __async(void 0, null, function* () {
|
|
754
773
|
try {
|
|
755
774
|
localStorage == null ? void 0 : localStorage.setItem(LOCAL_STORAGE_DEFAULT_WALLET, OYL);
|
|
@@ -840,7 +859,7 @@ var LaserEyesProvider = ({
|
|
|
840
859
|
throw error;
|
|
841
860
|
}
|
|
842
861
|
});
|
|
843
|
-
const connectLeather = () => __async(void 0, null, function* () {
|
|
862
|
+
const connectLeather = (0, import_react.useCallback)(() => __async(void 0, null, function* () {
|
|
844
863
|
try {
|
|
845
864
|
localStorage == null ? void 0 : localStorage.setItem(LOCAL_STORAGE_DEFAULT_WALLET, LEATHER);
|
|
846
865
|
const lib = window.LeatherProvider;
|
|
@@ -880,7 +899,7 @@ var LaserEyesProvider = ({
|
|
|
880
899
|
} catch (error) {
|
|
881
900
|
new Error(`Can't lasereyes to ${LEATHER} wallet`);
|
|
882
901
|
}
|
|
883
|
-
});
|
|
902
|
+
}), [hasLeather]);
|
|
884
903
|
const connectPhantom = () => __async(void 0, null, function* () {
|
|
885
904
|
try {
|
|
886
905
|
localStorage == null ? void 0 : localStorage.setItem(LOCAL_STORAGE_DEFAULT_WALLET, PHANTOM);
|
|
@@ -1730,6 +1749,7 @@ var LaserEyesProvider = ({
|
|
|
1730
1749
|
provider,
|
|
1731
1750
|
balance,
|
|
1732
1751
|
network,
|
|
1752
|
+
isInitializing,
|
|
1733
1753
|
connected,
|
|
1734
1754
|
isConnecting,
|
|
1735
1755
|
hasUnisat,
|
package/dist/index.mjs
CHANGED
|
@@ -185,6 +185,7 @@ var createConfig = (config) => {
|
|
|
185
185
|
// src/providers/LaserEyesProvider.tsx
|
|
186
186
|
import {
|
|
187
187
|
createContext,
|
|
188
|
+
useCallback,
|
|
188
189
|
useContext,
|
|
189
190
|
useEffect,
|
|
190
191
|
useRef,
|
|
@@ -203,6 +204,7 @@ var initialWalletContext = {
|
|
|
203
204
|
hasLeather: false,
|
|
204
205
|
hasPhantom: false,
|
|
205
206
|
hasWizz: false,
|
|
207
|
+
isInitializing: true,
|
|
206
208
|
connected: false,
|
|
207
209
|
isConnecting: false,
|
|
208
210
|
publicKey: "",
|
|
@@ -436,6 +438,7 @@ var LaserEyesProvider = ({
|
|
|
436
438
|
const self = selfRef.current;
|
|
437
439
|
const [library, setLibrary] = useState(null);
|
|
438
440
|
const [provider, setProvider] = useState();
|
|
441
|
+
const [isInitializing, setIsInitializing] = useState(true);
|
|
439
442
|
const [connected, setConnected] = useState(false);
|
|
440
443
|
const [isConnecting, setIsConnecting] = useState(false);
|
|
441
444
|
const [accounts, setAccounts] = useState([]);
|
|
@@ -467,6 +470,11 @@ var LaserEyesProvider = ({
|
|
|
467
470
|
});
|
|
468
471
|
}
|
|
469
472
|
}, [config, library]);
|
|
473
|
+
const checkInitializationComplete = () => {
|
|
474
|
+
if (hasUnisat !== void 0 && hasXverse !== void 0 && hasOyl !== void 0 && hasMagicEden !== void 0 && hasOkx !== void 0 && hasLeather !== void 0 && hasPhantom !== void 0 && hasWizz !== void 0) {
|
|
475
|
+
setIsInitializing(false);
|
|
476
|
+
}
|
|
477
|
+
};
|
|
470
478
|
useEffect(() => {
|
|
471
479
|
const observer = new MutationObserver(() => {
|
|
472
480
|
const unisatLib = window == null ? void 0 : window.unisat;
|
|
@@ -582,6 +590,18 @@ var LaserEyesProvider = ({
|
|
|
582
590
|
observer.disconnect();
|
|
583
591
|
};
|
|
584
592
|
}, []);
|
|
593
|
+
useEffect(() => {
|
|
594
|
+
checkInitializationComplete();
|
|
595
|
+
}, [
|
|
596
|
+
hasUnisat,
|
|
597
|
+
hasXverse,
|
|
598
|
+
hasOyl,
|
|
599
|
+
hasMagicEden,
|
|
600
|
+
hasOkx,
|
|
601
|
+
hasLeather,
|
|
602
|
+
hasPhantom,
|
|
603
|
+
hasWizz
|
|
604
|
+
]);
|
|
585
605
|
useEffect(() => {
|
|
586
606
|
setBalance(void 0);
|
|
587
607
|
}, [network]);
|
|
@@ -608,7 +628,7 @@ var LaserEyesProvider = ({
|
|
|
608
628
|
connect(defaultWallet);
|
|
609
629
|
}
|
|
610
630
|
}, []);
|
|
611
|
-
const connectUnisat = () => __async(void 0, null, function* () {
|
|
631
|
+
const connectUnisat = useCallback(() => __async(void 0, null, function* () {
|
|
612
632
|
try {
|
|
613
633
|
localStorage == null ? void 0 : localStorage.setItem(LOCAL_STORAGE_DEFAULT_WALLET, UNISAT);
|
|
614
634
|
const lib = window.unisat;
|
|
@@ -631,8 +651,8 @@ var LaserEyesProvider = ({
|
|
|
631
651
|
} catch (error) {
|
|
632
652
|
throw error;
|
|
633
653
|
}
|
|
634
|
-
});
|
|
635
|
-
const connectXverse = () => __async(void 0, null, function* () {
|
|
654
|
+
}), [hasUnisat]);
|
|
655
|
+
const connectXverse = useCallback(() => __async(void 0, null, function* () {
|
|
636
656
|
try {
|
|
637
657
|
localStorage == null ? void 0 : localStorage.setItem(LOCAL_STORAGE_DEFAULT_WALLET, XVERSE);
|
|
638
658
|
let xverseNetwork = getXverseNetwork((config == null ? void 0 : config.network) || MAINNET);
|
|
@@ -671,7 +691,7 @@ var LaserEyesProvider = ({
|
|
|
671
691
|
} catch (error) {
|
|
672
692
|
throw error;
|
|
673
693
|
}
|
|
674
|
-
});
|
|
694
|
+
}), [hasXverse]);
|
|
675
695
|
const connectOyl = () => __async(void 0, null, function* () {
|
|
676
696
|
try {
|
|
677
697
|
localStorage == null ? void 0 : localStorage.setItem(LOCAL_STORAGE_DEFAULT_WALLET, OYL);
|
|
@@ -762,7 +782,7 @@ var LaserEyesProvider = ({
|
|
|
762
782
|
throw error;
|
|
763
783
|
}
|
|
764
784
|
});
|
|
765
|
-
const connectLeather = () => __async(void 0, null, function* () {
|
|
785
|
+
const connectLeather = useCallback(() => __async(void 0, null, function* () {
|
|
766
786
|
try {
|
|
767
787
|
localStorage == null ? void 0 : localStorage.setItem(LOCAL_STORAGE_DEFAULT_WALLET, LEATHER);
|
|
768
788
|
const lib = window.LeatherProvider;
|
|
@@ -802,7 +822,7 @@ var LaserEyesProvider = ({
|
|
|
802
822
|
} catch (error) {
|
|
803
823
|
new Error(`Can't lasereyes to ${LEATHER} wallet`);
|
|
804
824
|
}
|
|
805
|
-
});
|
|
825
|
+
}), [hasLeather]);
|
|
806
826
|
const connectPhantom = () => __async(void 0, null, function* () {
|
|
807
827
|
try {
|
|
808
828
|
localStorage == null ? void 0 : localStorage.setItem(LOCAL_STORAGE_DEFAULT_WALLET, PHANTOM);
|
|
@@ -1652,6 +1672,7 @@ var LaserEyesProvider = ({
|
|
|
1652
1672
|
provider,
|
|
1653
1673
|
balance,
|
|
1654
1674
|
network,
|
|
1675
|
+
isInitializing,
|
|
1655
1676
|
connected,
|
|
1656
1677
|
isConnecting,
|
|
1657
1678
|
hasUnisat,
|
|
@@ -1682,7 +1703,7 @@ var LaserEyesProvider = ({
|
|
|
1682
1703
|
};
|
|
1683
1704
|
|
|
1684
1705
|
// src/hooks/useInscriber.ts
|
|
1685
|
-
import { useCallback, useEffect as useEffect2, useState as useState2 } from "react";
|
|
1706
|
+
import { useCallback as useCallback2, useEffect as useEffect2, useState as useState2 } from "react";
|
|
1686
1707
|
|
|
1687
1708
|
// src/consts/inscribe.ts
|
|
1688
1709
|
var MIME_TYPE_TEXT = "text/plain;charset=utf-8";
|
|
@@ -1711,7 +1732,7 @@ var useInscriber = ({
|
|
|
1711
1732
|
setCommitPsbtBase64("");
|
|
1712
1733
|
setCommitTxId("");
|
|
1713
1734
|
}, [content, address2, mimeType, feeRate]);
|
|
1714
|
-
const getCommitPsbt =
|
|
1735
|
+
const getCommitPsbt = useCallback2(() => __async(void 0, null, function* () {
|
|
1715
1736
|
try {
|
|
1716
1737
|
if (!content)
|
|
1717
1738
|
throw new Error("missing content");
|
|
@@ -1758,7 +1779,7 @@ var useInscriber = ({
|
|
|
1758
1779
|
throw e;
|
|
1759
1780
|
}
|
|
1760
1781
|
});
|
|
1761
|
-
const inscribe =
|
|
1782
|
+
const inscribe = useCallback2(
|
|
1762
1783
|
(_0) => __async(void 0, [_0], function* ({
|
|
1763
1784
|
content: providedContent,
|
|
1764
1785
|
mimeType: providedMimeType,
|