@omnisat/lasereyes 0.0.12 → 0.0.14
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 +18 -2
- package/dist/index.js +640 -8
- package/dist/index.mjs +632 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -77,9 +77,13 @@ __export(src_exports, {
|
|
|
77
77
|
LEATHER_MAINNET: () => LEATHER_MAINNET,
|
|
78
78
|
LEATHER_TESTNET: () => LEATHER_TESTNET,
|
|
79
79
|
LaserEyesProvider: () => LaserEyesProvider,
|
|
80
|
+
MAGIC_EDEN: () => MAGIC_EDEN,
|
|
80
81
|
MAINNET: () => MAINNET,
|
|
81
82
|
MEMPOOL_SPACE_TESTNET_URL: () => MEMPOOL_SPACE_TESTNET_URL,
|
|
82
83
|
MEMPOOL_SPACE_URL: () => MEMPOOL_SPACE_URL,
|
|
84
|
+
OKX: () => OKX,
|
|
85
|
+
OKX_MAINNET: () => OKX_MAINNET,
|
|
86
|
+
OKX_TESTNET: () => OKX_TESTNET,
|
|
83
87
|
OYL: () => OYL,
|
|
84
88
|
P2PKH: () => P2PKH,
|
|
85
89
|
P2PSH: () => P2PSH,
|
|
@@ -89,11 +93,15 @@ __export(src_exports, {
|
|
|
89
93
|
P2WSH: () => P2WSH,
|
|
90
94
|
PHANTOM: () => PHANTOM,
|
|
91
95
|
REGTEST: () => REGTEST,
|
|
96
|
+
SIGNET: () => SIGNET,
|
|
92
97
|
TESTNET: () => TESTNET,
|
|
93
98
|
UNISAT: () => UNISAT,
|
|
94
99
|
UNISAT_MAINNET: () => UNISAT_MAINNET,
|
|
95
100
|
UNISAT_TESTNET: () => UNISAT_TESTNET,
|
|
96
101
|
WALLETS: () => WALLETS,
|
|
102
|
+
WIZZ: () => WIZZ,
|
|
103
|
+
WIZZ_MAINNET: () => WIZZ_MAINNET,
|
|
104
|
+
WIZZ_TESTNET: () => WIZZ_TESTNET,
|
|
97
105
|
XVERSE: () => XVERSE,
|
|
98
106
|
XVERSE_MAINNET: () => XVERSE_MAINNET,
|
|
99
107
|
XVERSE_NETWORK: () => XVERSE_NETWORK,
|
|
@@ -110,10 +118,13 @@ __export(src_exports, {
|
|
|
110
118
|
getLeatherNetwork: () => getLeatherNetwork,
|
|
111
119
|
getMempoolSpaceUrl: () => getMempoolSpaceUrl,
|
|
112
120
|
getNetworkForLeather: () => getNetworkForLeather,
|
|
121
|
+
getNetworkForOkx: () => getNetworkForOkx,
|
|
113
122
|
getNetworkForUnisat: () => getNetworkForUnisat,
|
|
123
|
+
getNetworkForWizz: () => getNetworkForWizz,
|
|
114
124
|
getNetworkForXverse: () => getNetworkForXverse,
|
|
115
125
|
getRedeemScript: () => getRedeemScript,
|
|
116
126
|
getUnisatNetwork: () => getUnisatNetwork,
|
|
127
|
+
getWizzNetwork: () => getWizzNetwork,
|
|
117
128
|
getXverseNetwork: () => getXverseNetwork,
|
|
118
129
|
isBase64: () => isBase64,
|
|
119
130
|
isHex: () => isHex,
|
|
@@ -128,9 +139,14 @@ var UNISAT_MAINNET = "livenet";
|
|
|
128
139
|
var UNISAT_TESTNET = "testnet";
|
|
129
140
|
var XVERSE_MAINNET = "Mainnet";
|
|
130
141
|
var XVERSE_TESTNET = "Testnet";
|
|
142
|
+
var OKX_MAINNET = "livenet";
|
|
143
|
+
var OKX_TESTNET = "testnet";
|
|
144
|
+
var WIZZ_MAINNET = "livenet";
|
|
145
|
+
var WIZZ_TESTNET = "testnet";
|
|
131
146
|
var LEATHER_MAINNET = "mainnet";
|
|
132
147
|
var LEATHER_TESTNET = "testnet";
|
|
133
148
|
var MAINNET = "mainnet";
|
|
149
|
+
var SIGNET = "signet";
|
|
134
150
|
var TESTNET = "testnet";
|
|
135
151
|
var REGTEST = "regtest";
|
|
136
152
|
var getXverseNetwork = (network) => {
|
|
@@ -154,6 +170,13 @@ var getUnisatNetwork = (network) => {
|
|
|
154
170
|
return UNISAT_TESTNET;
|
|
155
171
|
return UNISAT_MAINNET;
|
|
156
172
|
};
|
|
173
|
+
var getWizzNetwork = (network) => {
|
|
174
|
+
if (network === MAINNET)
|
|
175
|
+
return WIZZ_MAINNET;
|
|
176
|
+
if (network === TESTNET)
|
|
177
|
+
return WIZZ_TESTNET;
|
|
178
|
+
return WIZZ_MAINNET;
|
|
179
|
+
};
|
|
157
180
|
var getNetworkForUnisat = (network) => {
|
|
158
181
|
if (network === UNISAT_MAINNET)
|
|
159
182
|
return MAINNET;
|
|
@@ -175,6 +198,20 @@ var getNetworkForLeather = (network) => {
|
|
|
175
198
|
return TESTNET;
|
|
176
199
|
return MAINNET;
|
|
177
200
|
};
|
|
201
|
+
var getNetworkForOkx = (network) => {
|
|
202
|
+
if (network === OKX_MAINNET)
|
|
203
|
+
return MAINNET;
|
|
204
|
+
if (network === OKX_TESTNET)
|
|
205
|
+
return TESTNET;
|
|
206
|
+
return MAINNET;
|
|
207
|
+
};
|
|
208
|
+
var getNetworkForWizz = (network) => {
|
|
209
|
+
if (network === WIZZ_MAINNET)
|
|
210
|
+
return MAINNET;
|
|
211
|
+
if (network === WIZZ_TESTNET)
|
|
212
|
+
return TESTNET;
|
|
213
|
+
return MAINNET;
|
|
214
|
+
};
|
|
178
215
|
var MEMPOOL_SPACE_URL = "https://mempool.space";
|
|
179
216
|
var MEMPOOL_SPACE_TESTNET_URL = "https://mempool.space/testnet";
|
|
180
217
|
var getMempoolSpaceUrl = (network) => network === TESTNET ? MEMPOOL_SPACE_TESTNET_URL : MEMPOOL_SPACE_URL;
|
|
@@ -185,6 +222,9 @@ var UNISAT = "unisat";
|
|
|
185
222
|
var XVERSE = "xverse";
|
|
186
223
|
var PHANTOM = "phantom";
|
|
187
224
|
var LEATHER = "leather";
|
|
225
|
+
var MAGIC_EDEN = "magic-eden";
|
|
226
|
+
var OKX = "okx";
|
|
227
|
+
var WIZZ = "wizz";
|
|
188
228
|
var P2TR = "p2tr";
|
|
189
229
|
var P2PKH = "p2pkh";
|
|
190
230
|
var P2WPKH = "p2wpkh";
|
|
@@ -237,6 +277,11 @@ var initialWalletContext = {
|
|
|
237
277
|
hasUnisat: false,
|
|
238
278
|
hasXverse: false,
|
|
239
279
|
hasOyl: false,
|
|
280
|
+
hasMagicEden: false,
|
|
281
|
+
hasOkx: false,
|
|
282
|
+
hasLeather: false,
|
|
283
|
+
hasPhantom: false,
|
|
284
|
+
hasWizz: false,
|
|
240
285
|
connected: false,
|
|
241
286
|
isConnecting: false,
|
|
242
287
|
publicKey: "",
|
|
@@ -416,7 +461,7 @@ function createSendBtcPsbt(address2, paymentAddress, recipientAddress, amount, p
|
|
|
416
461
|
value
|
|
417
462
|
}
|
|
418
463
|
});
|
|
419
|
-
if (isTaprootOnly) {
|
|
464
|
+
if (!isTaprootOnly) {
|
|
420
465
|
const redeemScript = getRedeemScript(paymentPublicKey, network);
|
|
421
466
|
psbt.updateInput(counter, { redeemScript });
|
|
422
467
|
}
|
|
@@ -470,6 +515,7 @@ function getRedeemScript(paymentPublicKey, network) {
|
|
|
470
515
|
// src/providers/LaserEyesProvider.tsx
|
|
471
516
|
var import_sats_connect = require("sats-connect");
|
|
472
517
|
var import_address = require("bitcoinjs-lib/src/address");
|
|
518
|
+
var import_axios2 = __toESM(require("axios"));
|
|
473
519
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
474
520
|
var LaserEyesContext = (0, import_react.createContext)(initialWalletContext);
|
|
475
521
|
var useLaserEyes = () => {
|
|
@@ -496,6 +542,11 @@ var LaserEyesProvider = ({
|
|
|
496
542
|
const [hasUnisat, setHasUnisat] = (0, import_react.useState)(false);
|
|
497
543
|
const [hasXverse, setHasXverse] = (0, import_react.useState)(false);
|
|
498
544
|
const [hasOyl, setHasOyl] = (0, import_react.useState)(false);
|
|
545
|
+
const [hasMagicEden, setHasMagicEden] = (0, import_react.useState)(false);
|
|
546
|
+
const [hasOkx, setHasOkx] = (0, import_react.useState)(false);
|
|
547
|
+
const [hasLeather, setHasLeather] = (0, import_react.useState)(false);
|
|
548
|
+
const [hasPhantom, setHasPhantom] = (0, import_react.useState)(false);
|
|
549
|
+
const [hasWizz, setHasWizz] = (0, import_react.useState)(false);
|
|
499
550
|
const [network, setNetwork] = (0, import_usehooks_ts.useLocalStorage)("network", MAINNET, {
|
|
500
551
|
initializeWithValue: false
|
|
501
552
|
});
|
|
@@ -524,11 +575,44 @@ var LaserEyesProvider = ({
|
|
|
524
575
|
const oylLib = window == null ? void 0 : window.oyl;
|
|
525
576
|
setHasOyl(!!oylLib);
|
|
526
577
|
}, []);
|
|
578
|
+
(0, import_react.useEffect)(() => {
|
|
579
|
+
const magicEdenLib = window == null ? void 0 : window.magicEden;
|
|
580
|
+
setHasMagicEden(!!magicEdenLib);
|
|
581
|
+
}, []);
|
|
582
|
+
(0, import_react.useEffect)(() => {
|
|
583
|
+
}, []);
|
|
584
|
+
(0, import_react.useEffect)(() => {
|
|
585
|
+
var _a, _b;
|
|
586
|
+
let foundOkx;
|
|
587
|
+
if (network === TESTNET) {
|
|
588
|
+
foundOkx = (_a = window.okxwallet) == null ? void 0 : _a.bitcoinTestnet;
|
|
589
|
+
} else if (network === MAINNET) {
|
|
590
|
+
foundOkx = (_b = window.okxwallet) == null ? void 0 : _b.bitcoin;
|
|
591
|
+
}
|
|
592
|
+
setHasOkx(!!foundOkx);
|
|
593
|
+
}, []);
|
|
594
|
+
(0, import_react.useEffect)(() => {
|
|
595
|
+
const leatherLib = window == null ? void 0 : window.LeatherProvider;
|
|
596
|
+
setHasLeather(!!leatherLib);
|
|
597
|
+
}, []);
|
|
598
|
+
(0, import_react.useEffect)(() => {
|
|
599
|
+
var _a;
|
|
600
|
+
const phantomLib = (_a = window == null ? void 0 : window.phantom) == null ? void 0 : _a.bitcoin;
|
|
601
|
+
if (phantomLib && phantomLib.isPhantom) {
|
|
602
|
+
setHasPhantom(!!phantomLib);
|
|
603
|
+
} else {
|
|
604
|
+
setHasPhantom(false);
|
|
605
|
+
}
|
|
606
|
+
}, []);
|
|
607
|
+
(0, import_react.useEffect)(() => {
|
|
608
|
+
const wissLib = window == null ? void 0 : window.wizz;
|
|
609
|
+
setHasWizz(!!wissLib);
|
|
610
|
+
}, []);
|
|
527
611
|
(0, import_react.useEffect)(() => {
|
|
528
612
|
setBalance(void 0);
|
|
529
613
|
}, [network]);
|
|
530
614
|
(0, import_react.useEffect)(() => {
|
|
531
|
-
if (provider !== UNISAT) {
|
|
615
|
+
if (provider !== UNISAT && provider !== WIZZ) {
|
|
532
616
|
return;
|
|
533
617
|
}
|
|
534
618
|
library.getAccounts().then((accounts2) => {
|
|
@@ -628,23 +712,196 @@ var LaserEyesProvider = ({
|
|
|
628
712
|
setProvider(OYL);
|
|
629
713
|
handleAccountsChanged(result);
|
|
630
714
|
setConnected(true);
|
|
715
|
+
getBTCBalance(result[1]).then((totalBalance) => {
|
|
716
|
+
setBalance(totalBalance);
|
|
717
|
+
});
|
|
631
718
|
} catch (error) {
|
|
632
719
|
throw new Error(`Can't lasereyes to ${OYL} wallet`);
|
|
633
720
|
}
|
|
634
721
|
});
|
|
722
|
+
const connectMagicEden = () => __async(void 0, null, function* () {
|
|
723
|
+
try {
|
|
724
|
+
localStorage == null ? void 0 : localStorage.setItem(LOCAL_STORAGE_DEFAULT_WALLET, MAGIC_EDEN);
|
|
725
|
+
let xverseNetwork = getXverseNetwork((config == null ? void 0 : config.network) || MAINNET);
|
|
726
|
+
const getAddressOptions = {
|
|
727
|
+
getProvider: () => __async(void 0, null, function* () {
|
|
728
|
+
return window.magicEden.bitcoin;
|
|
729
|
+
}),
|
|
730
|
+
payload: {
|
|
731
|
+
purposes: ["ordinals", "payment"],
|
|
732
|
+
message: "Address for receiving Ordinals and payments",
|
|
733
|
+
network: {
|
|
734
|
+
type: xverseNetwork
|
|
735
|
+
}
|
|
736
|
+
},
|
|
737
|
+
onFinish: (response) => {
|
|
738
|
+
setPublicKey(String(response.addresses[0].publicKey));
|
|
739
|
+
setPaymentPublicKey(String(response.addresses[1].publicKey));
|
|
740
|
+
const foundAddress = findOrdinalsAddress(response.addresses);
|
|
741
|
+
const foundPaymentAddress = findPaymentAddress(response.addresses);
|
|
742
|
+
if (foundAddress && foundPaymentAddress) {
|
|
743
|
+
setAddress(foundAddress.address);
|
|
744
|
+
setPaymentAddress(foundPaymentAddress.address);
|
|
745
|
+
setProvider(MAGIC_EDEN);
|
|
746
|
+
setLibrary(window.magicEden.bitcoin);
|
|
747
|
+
}
|
|
748
|
+
getBTCBalance(foundPaymentAddress.address).then((totalBalance) => {
|
|
749
|
+
setBalance(totalBalance);
|
|
750
|
+
});
|
|
751
|
+
},
|
|
752
|
+
onCancel: () => {
|
|
753
|
+
throw new Error(`User canceled lasereyes to ${MAGIC_EDEN} wallet`);
|
|
754
|
+
},
|
|
755
|
+
onError: (error) => {
|
|
756
|
+
throw new Error(`Can't lasereyes to ${MAGIC_EDEN} wallet`);
|
|
757
|
+
}
|
|
758
|
+
};
|
|
759
|
+
console.log(JSON.stringify(getAddressOptions));
|
|
760
|
+
yield (0, import_sats_connect.getAddress)(getAddressOptions);
|
|
761
|
+
setConnected(true);
|
|
762
|
+
} catch (error) {
|
|
763
|
+
console.log("error", error);
|
|
764
|
+
throw error;
|
|
765
|
+
}
|
|
766
|
+
});
|
|
767
|
+
const connectOkx = () => __async(void 0, null, function* () {
|
|
768
|
+
try {
|
|
769
|
+
localStorage == null ? void 0 : localStorage.setItem(LOCAL_STORAGE_DEFAULT_WALLET, OKX);
|
|
770
|
+
const lib = network === TESTNET ? window.okxwallet.bitcoinTestnet : window.okxwallet.bitcoin;
|
|
771
|
+
const okxAccounts = yield lib.requestAccounts();
|
|
772
|
+
if (!okxAccounts)
|
|
773
|
+
throw new Error("No accounts found");
|
|
774
|
+
const okxPubKey = yield lib.getPublicKey();
|
|
775
|
+
if (!okxPubKey)
|
|
776
|
+
throw new Error("No public key found");
|
|
777
|
+
setAccounts(okxAccounts);
|
|
778
|
+
setAddress(okxAccounts[0]);
|
|
779
|
+
setPaymentAddress(okxAccounts[0]);
|
|
780
|
+
setPublicKey(okxPubKey);
|
|
781
|
+
setPaymentPublicKey(okxPubKey);
|
|
782
|
+
setLibrary(lib);
|
|
783
|
+
setProvider(OKX);
|
|
784
|
+
setConnected(true);
|
|
785
|
+
const balance2 = yield lib == null ? void 0 : lib.getBalance();
|
|
786
|
+
setBalance(balance2 == null ? void 0 : balance2.total);
|
|
787
|
+
} catch (error) {
|
|
788
|
+
throw error;
|
|
789
|
+
}
|
|
790
|
+
});
|
|
791
|
+
const connectLeather = () => __async(void 0, null, function* () {
|
|
792
|
+
try {
|
|
793
|
+
localStorage == null ? void 0 : localStorage.setItem(LOCAL_STORAGE_DEFAULT_WALLET, LEATHER);
|
|
794
|
+
const lib = window.LeatherProvider;
|
|
795
|
+
const getAddressesResponse = yield lib.request(
|
|
796
|
+
"getAddresses"
|
|
797
|
+
);
|
|
798
|
+
const addressesResponse = getAddressesResponse.result;
|
|
799
|
+
const addresses = addressesResponse.addresses;
|
|
800
|
+
const leatherAccountsParsed = addresses.map(
|
|
801
|
+
(address3) => address3.address
|
|
802
|
+
);
|
|
803
|
+
const taprootAddress = addresses.find(
|
|
804
|
+
(address3) => address3.type === P2TR
|
|
805
|
+
);
|
|
806
|
+
const segwitAddress = addresses.find(
|
|
807
|
+
(address3) => address3.type === P2WPKH
|
|
808
|
+
);
|
|
809
|
+
setAccounts(leatherAccountsParsed);
|
|
810
|
+
setAddress(String(taprootAddress == null ? void 0 : taprootAddress.address));
|
|
811
|
+
setPublicKey(String(taprootAddress == null ? void 0 : taprootAddress.publicKey));
|
|
812
|
+
setPaymentAddress(String(segwitAddress == null ? void 0 : segwitAddress.address));
|
|
813
|
+
setPaymentPublicKey(String(segwitAddress == null ? void 0 : segwitAddress.publicKey));
|
|
814
|
+
setLibrary(lib);
|
|
815
|
+
setProvider(LEATHER);
|
|
816
|
+
const balance2 = yield getBTCBalance(String(segwitAddress == null ? void 0 : segwitAddress.address));
|
|
817
|
+
setBalance(balance2);
|
|
818
|
+
handleAccountsChanged(leatherAccountsParsed);
|
|
819
|
+
setConnected(true);
|
|
820
|
+
yield getNetwork().then((network2) => {
|
|
821
|
+
if (!network2) {
|
|
822
|
+
setNetwork(MAINNET);
|
|
823
|
+
} else {
|
|
824
|
+
setNetwork(network2);
|
|
825
|
+
}
|
|
826
|
+
});
|
|
827
|
+
setConnected(true);
|
|
828
|
+
} catch (error) {
|
|
829
|
+
new Error(`Can't lasereyes to ${LEATHER} wallet`);
|
|
830
|
+
}
|
|
831
|
+
});
|
|
832
|
+
const connectPhantom = () => __async(void 0, null, function* () {
|
|
833
|
+
try {
|
|
834
|
+
localStorage == null ? void 0 : localStorage.setItem(LOCAL_STORAGE_DEFAULT_WALLET, PHANTOM);
|
|
835
|
+
const lib = window.phantom.bitcoin;
|
|
836
|
+
const phantomAccounts = yield lib.requestAccounts();
|
|
837
|
+
const phantomAccountsParsed = phantomAccounts.map(
|
|
838
|
+
(account) => account.address
|
|
839
|
+
);
|
|
840
|
+
setAccounts(phantomAccountsParsed);
|
|
841
|
+
const ordinalsAccount = phantomAccounts.find(
|
|
842
|
+
(account) => account.purpose === "ordinals"
|
|
843
|
+
);
|
|
844
|
+
const paymentAccount = phantomAccounts.find(
|
|
845
|
+
(account) => account.purpose === "payment"
|
|
846
|
+
);
|
|
847
|
+
setAddress(ordinalsAccount == null ? void 0 : ordinalsAccount.address);
|
|
848
|
+
setPublicKey(ordinalsAccount == null ? void 0 : ordinalsAccount.publicKey);
|
|
849
|
+
setPaymentAddress(paymentAccount == null ? void 0 : paymentAccount.address);
|
|
850
|
+
setPaymentPublicKey(paymentAccount == null ? void 0 : paymentAccount.publicKey);
|
|
851
|
+
setLibrary(lib);
|
|
852
|
+
setProvider(PHANTOM);
|
|
853
|
+
const balance2 = yield getBTCBalance(String(paymentAccount == null ? void 0 : paymentAccount.address));
|
|
854
|
+
setBalance(balance2);
|
|
855
|
+
setConnected(true);
|
|
856
|
+
} catch (error) {
|
|
857
|
+
throw new Error(`Can't lasereyes to ${PHANTOM} wallet`);
|
|
858
|
+
}
|
|
859
|
+
});
|
|
860
|
+
const connectWizz = () => __async(void 0, null, function* () {
|
|
861
|
+
try {
|
|
862
|
+
localStorage == null ? void 0 : localStorage.setItem(LOCAL_STORAGE_DEFAULT_WALLET, WIZZ);
|
|
863
|
+
const lib = window.wizz;
|
|
864
|
+
const wizzAccounts = yield lib.requestAccounts();
|
|
865
|
+
if (!wizzAccounts)
|
|
866
|
+
throw new Error("No accounts found");
|
|
867
|
+
const wizzPubKey = yield lib.getPublicKey();
|
|
868
|
+
if (!wizzPubKey)
|
|
869
|
+
throw new Error("No public key found");
|
|
870
|
+
setAccounts(wizzAccounts);
|
|
871
|
+
setAddress(wizzAccounts[0]);
|
|
872
|
+
setPaymentAddress(wizzAccounts[0]);
|
|
873
|
+
setPublicKey(wizzPubKey);
|
|
874
|
+
setPaymentPublicKey(wizzPubKey);
|
|
875
|
+
setLibrary(lib);
|
|
876
|
+
setProvider(WIZZ);
|
|
877
|
+
setConnected(true);
|
|
878
|
+
const balance2 = yield lib == null ? void 0 : lib.getBalance();
|
|
879
|
+
setBalance(balance2 == null ? void 0 : balance2.total);
|
|
880
|
+
} catch (error) {
|
|
881
|
+
throw error;
|
|
882
|
+
}
|
|
883
|
+
});
|
|
635
884
|
const connect = (walletName) => __async(void 0, null, function* () {
|
|
636
885
|
setIsConnecting(true);
|
|
637
886
|
try {
|
|
638
887
|
if (!walletName)
|
|
639
888
|
throw new Error("No wallet provided");
|
|
640
889
|
if (walletName === UNISAT) {
|
|
641
|
-
console.log("connectin unisat");
|
|
642
890
|
yield connectUnisat();
|
|
643
891
|
} else if (walletName === XVERSE) {
|
|
644
892
|
yield connectXverse();
|
|
645
893
|
} else if (walletName === OYL) {
|
|
646
|
-
console.log("connectin oyl");
|
|
647
894
|
yield connectOyl();
|
|
895
|
+
} else if (walletName === MAGIC_EDEN) {
|
|
896
|
+
yield connectMagicEden();
|
|
897
|
+
} else if (walletName === OKX) {
|
|
898
|
+
yield connectOkx();
|
|
899
|
+
} else if (walletName === LEATHER) {
|
|
900
|
+
yield connectLeather();
|
|
901
|
+
} else if (walletName === PHANTOM) {
|
|
902
|
+
yield connectPhantom();
|
|
903
|
+
} else if (walletName === WIZZ) {
|
|
904
|
+
yield connectWizz();
|
|
648
905
|
} else {
|
|
649
906
|
throw new Error("Unsupported wallet..");
|
|
650
907
|
}
|
|
@@ -679,7 +936,6 @@ var LaserEyesProvider = ({
|
|
|
679
936
|
if (self.accounts[0] === _accounts[0]) {
|
|
680
937
|
return;
|
|
681
938
|
}
|
|
682
|
-
console.log("acct changed", _accounts[0]);
|
|
683
939
|
self.accounts = _accounts;
|
|
684
940
|
if (_accounts.length > 0) {
|
|
685
941
|
connect(UNISAT);
|
|
@@ -696,6 +952,10 @@ var LaserEyesProvider = ({
|
|
|
696
952
|
connect(provider);
|
|
697
953
|
} else if (provider === XVERSE) {
|
|
698
954
|
throw new Error("Not implemented");
|
|
955
|
+
} else if (provider === WIZZ) {
|
|
956
|
+
foundNetwork = getNetworkForWizz(network2);
|
|
957
|
+
setNetwork(foundNetwork);
|
|
958
|
+
connect(provider);
|
|
699
959
|
} else {
|
|
700
960
|
throw new Error("The connected wallet doesn't support this method..");
|
|
701
961
|
}
|
|
@@ -734,6 +994,48 @@ var LaserEyesProvider = ({
|
|
|
734
994
|
return [address2];
|
|
735
995
|
} else if (provider === OYL) {
|
|
736
996
|
return yield library.requestAccounts();
|
|
997
|
+
} else if (provider === OKX) {
|
|
998
|
+
return yield library.requestAccounts();
|
|
999
|
+
} else if (provider === LEATHER) {
|
|
1000
|
+
localStorage == null ? void 0 : localStorage.setItem(LOCAL_STORAGE_DEFAULT_WALLET, LEATHER);
|
|
1001
|
+
const lib = window.LeatherProvider;
|
|
1002
|
+
const getAddressesResponse = yield lib.request(
|
|
1003
|
+
"getAddresses"
|
|
1004
|
+
);
|
|
1005
|
+
const addressesResponse = getAddressesResponse.result;
|
|
1006
|
+
const addresses = addressesResponse.addresses;
|
|
1007
|
+
const leatherAccountsParsed = addresses.map(
|
|
1008
|
+
(address3) => address3.address
|
|
1009
|
+
);
|
|
1010
|
+
const taprootAddress = addresses.find(
|
|
1011
|
+
(address3) => address3.type === P2TR
|
|
1012
|
+
);
|
|
1013
|
+
const segwitAddress = addresses.find(
|
|
1014
|
+
(address3) => address3.type === P2WPKH
|
|
1015
|
+
);
|
|
1016
|
+
setAccounts(leatherAccountsParsed);
|
|
1017
|
+
setAddress(String(taprootAddress == null ? void 0 : taprootAddress.address));
|
|
1018
|
+
setPaymentAddress(String(segwitAddress == null ? void 0 : segwitAddress.address));
|
|
1019
|
+
setLibrary(lib);
|
|
1020
|
+
setProvider(LEATHER);
|
|
1021
|
+
handleAccountsChanged(leatherAccountsParsed);
|
|
1022
|
+
setConnected(true);
|
|
1023
|
+
yield getNetwork().then((network2) => {
|
|
1024
|
+
if (!network2) {
|
|
1025
|
+
setNetwork(MAINNET);
|
|
1026
|
+
} else {
|
|
1027
|
+
setNetwork(network2);
|
|
1028
|
+
}
|
|
1029
|
+
});
|
|
1030
|
+
setConnected(true);
|
|
1031
|
+
} else if (provider === PHANTOM) {
|
|
1032
|
+
const phantomAccounts = yield library.requestAccounts();
|
|
1033
|
+
const phantomAccountsParsed = phantomAccounts.map(
|
|
1034
|
+
(account) => account.address
|
|
1035
|
+
);
|
|
1036
|
+
return phantomAccountsParsed;
|
|
1037
|
+
} else if (provider === WIZZ) {
|
|
1038
|
+
return yield library.requestAccounts();
|
|
737
1039
|
} else {
|
|
738
1040
|
throw new Error("The connected wallet doesn't support this method..");
|
|
739
1041
|
}
|
|
@@ -761,6 +1063,29 @@ var LaserEyesProvider = ({
|
|
|
761
1063
|
return TESTNET;
|
|
762
1064
|
}
|
|
763
1065
|
return MAINNET;
|
|
1066
|
+
} else if (provider === MAGIC_EDEN) {
|
|
1067
|
+
if (address2.slice(0, 1) === "t") {
|
|
1068
|
+
return TESTNET;
|
|
1069
|
+
}
|
|
1070
|
+
return MAINNET;
|
|
1071
|
+
} else if (provider === OKX) {
|
|
1072
|
+
const okxNetwork = yield library == null ? void 0 : library.getNetwork();
|
|
1073
|
+
const foundNetwork = getNetworkForOkx(okxNetwork);
|
|
1074
|
+
setNetwork(foundNetwork);
|
|
1075
|
+
} else if (provider === LEATHER) {
|
|
1076
|
+
if (address2.slice(0, 1) === "t") {
|
|
1077
|
+
return TESTNET;
|
|
1078
|
+
}
|
|
1079
|
+
return MAINNET;
|
|
1080
|
+
} else if (provider === PHANTOM) {
|
|
1081
|
+
if (address2.slice(0, 1) === "t") {
|
|
1082
|
+
return TESTNET;
|
|
1083
|
+
}
|
|
1084
|
+
return MAINNET;
|
|
1085
|
+
} else if (provider === WIZZ) {
|
|
1086
|
+
const wizzNetwork = yield library == null ? void 0 : library.getNetwork();
|
|
1087
|
+
const foundNetwork = getNetworkForWizz(wizzNetwork);
|
|
1088
|
+
setNetwork(foundNetwork);
|
|
764
1089
|
}
|
|
765
1090
|
return (_a = config == null ? void 0 : config.network) != null ? _a : MAINNET;
|
|
766
1091
|
} catch (error) {
|
|
@@ -772,7 +1097,11 @@ var LaserEyesProvider = ({
|
|
|
772
1097
|
if (!library)
|
|
773
1098
|
return;
|
|
774
1099
|
if (provider === UNISAT) {
|
|
775
|
-
const wantedNetwork =
|
|
1100
|
+
const wantedNetwork = getWizzNetwork(network2);
|
|
1101
|
+
yield library == null ? void 0 : library.switchNetwork(wantedNetwork);
|
|
1102
|
+
setNetwork(network2);
|
|
1103
|
+
} else if (provider === WIZZ) {
|
|
1104
|
+
const wantedNetwork = getNetworkForWizz(network2);
|
|
776
1105
|
yield library == null ? void 0 : library.switchNetwork(wantedNetwork);
|
|
777
1106
|
setNetwork(network2);
|
|
778
1107
|
} else {
|
|
@@ -790,6 +1119,10 @@ var LaserEyesProvider = ({
|
|
|
790
1119
|
return yield library == null ? void 0 : library.getPublicKey();
|
|
791
1120
|
} else if (provider === OYL) {
|
|
792
1121
|
return yield library == null ? void 0 : library.getPublicKey();
|
|
1122
|
+
} else if (provider === OKX) {
|
|
1123
|
+
return yield library == null ? void 0 : library.getPublicKey();
|
|
1124
|
+
} else if (provider === WIZZ) {
|
|
1125
|
+
return yield library == null ? void 0 : library.getPublicKey();
|
|
793
1126
|
} else {
|
|
794
1127
|
throw new Error("The connected wallet doesn't support this method..");
|
|
795
1128
|
}
|
|
@@ -808,6 +1141,17 @@ var LaserEyesProvider = ({
|
|
|
808
1141
|
} else if (provider === OYL) {
|
|
809
1142
|
const balanceResponse = yield library.getBalance();
|
|
810
1143
|
return balanceResponse.btc.total * 1e8;
|
|
1144
|
+
} else if (provider === MAGIC_EDEN) {
|
|
1145
|
+
return yield getBTCBalance(paymentAddress);
|
|
1146
|
+
} else if (provider === OKX) {
|
|
1147
|
+
return yield getBTCBalance(paymentAddress);
|
|
1148
|
+
} else if (provider === LEATHER) {
|
|
1149
|
+
return yield getBTCBalance(paymentAddress);
|
|
1150
|
+
} else if (provider === PHANTOM) {
|
|
1151
|
+
return yield getBTCBalance(paymentAddress);
|
|
1152
|
+
} else if (provider === WIZZ) {
|
|
1153
|
+
const balanceResponse = yield library.getBalance();
|
|
1154
|
+
return balanceResponse.total * 1e8;
|
|
811
1155
|
}
|
|
812
1156
|
} catch (error) {
|
|
813
1157
|
throw error;
|
|
@@ -821,6 +1165,10 @@ var LaserEyesProvider = ({
|
|
|
821
1165
|
return yield library.getInscriptions(0, 10);
|
|
822
1166
|
} else if (provider === OYL) {
|
|
823
1167
|
return yield library.getInscriptions(0, 10);
|
|
1168
|
+
} else if (provider === OKX) {
|
|
1169
|
+
return yield library.getInscriptions(0, 10);
|
|
1170
|
+
} else if (provider === WIZZ) {
|
|
1171
|
+
return yield library.getInscriptions(0, 10);
|
|
824
1172
|
} else {
|
|
825
1173
|
throw new Error("The connected wallet doesn't support this method..");
|
|
826
1174
|
}
|
|
@@ -829,6 +1177,7 @@ var LaserEyesProvider = ({
|
|
|
829
1177
|
}
|
|
830
1178
|
});
|
|
831
1179
|
const sendBTC = (to, amount) => __async(void 0, null, function* () {
|
|
1180
|
+
var _a;
|
|
832
1181
|
try {
|
|
833
1182
|
if (amount <= 0)
|
|
834
1183
|
throw new Error("Amount must be greater than 0");
|
|
@@ -860,6 +1209,21 @@ var LaserEyesProvider = ({
|
|
|
860
1209
|
}
|
|
861
1210
|
}
|
|
862
1211
|
} else if (provider === OYL) {
|
|
1212
|
+
const { psbtHex, psbtBase64 } = yield createSendBtcPsbt(
|
|
1213
|
+
address2,
|
|
1214
|
+
paymentAddress,
|
|
1215
|
+
to,
|
|
1216
|
+
amount,
|
|
1217
|
+
paymentPublicKey,
|
|
1218
|
+
//@ts-ignore
|
|
1219
|
+
network,
|
|
1220
|
+
7
|
|
1221
|
+
);
|
|
1222
|
+
const psbt = yield signPsbt(psbtHex, true, true);
|
|
1223
|
+
if (!psbt)
|
|
1224
|
+
throw new Error("Error sending BTC");
|
|
1225
|
+
return psbt.txId;
|
|
1226
|
+
} else if (provider === MAGIC_EDEN) {
|
|
863
1227
|
const { psbtHex, psbtBase64 } = yield createSendBtcPsbt(
|
|
864
1228
|
address2,
|
|
865
1229
|
paymentAddress,
|
|
@@ -874,12 +1238,43 @@ var LaserEyesProvider = ({
|
|
|
874
1238
|
if (!psbt)
|
|
875
1239
|
throw new Error("Error sending BTC");
|
|
876
1240
|
return psbt.txId;
|
|
1241
|
+
} else if (provider === OKX) {
|
|
1242
|
+
const txId = yield library == null ? void 0 : library.sendBitcoin(to, amount);
|
|
1243
|
+
if (!txId)
|
|
1244
|
+
throw new Error("Transaction failed");
|
|
1245
|
+
return txId;
|
|
1246
|
+
} else if (provider === LEATHER) {
|
|
1247
|
+
const response = yield library == null ? void 0 : library.request("sendTransfer", {
|
|
1248
|
+
recipients: [
|
|
1249
|
+
{
|
|
1250
|
+
address: to,
|
|
1251
|
+
amount
|
|
1252
|
+
}
|
|
1253
|
+
]
|
|
1254
|
+
});
|
|
1255
|
+
if ((_a = response == null ? void 0 : response.result) == null ? void 0 : _a.txid) {
|
|
1256
|
+
return response.result.txid;
|
|
1257
|
+
} else {
|
|
1258
|
+
if (response.error.code === import_sats_connect.RpcErrorCode.USER_REJECTION) {
|
|
1259
|
+
throw new Error("User rejected the request");
|
|
1260
|
+
} else {
|
|
1261
|
+
throw new Error("Error sending BTC: " + response.error.message);
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
} else if (provider === WIZZ) {
|
|
1265
|
+
const txId = yield library == null ? void 0 : library.sendBitcoin(to, amount);
|
|
1266
|
+
if (txId) {
|
|
1267
|
+
return txId;
|
|
1268
|
+
} else {
|
|
1269
|
+
throw new Error("Error sending BTC");
|
|
1270
|
+
}
|
|
877
1271
|
}
|
|
878
1272
|
} catch (error) {
|
|
879
1273
|
throw error;
|
|
880
1274
|
}
|
|
881
1275
|
});
|
|
882
1276
|
const signMessage = (message) => __async(void 0, null, function* () {
|
|
1277
|
+
var _a;
|
|
883
1278
|
try {
|
|
884
1279
|
if (!library)
|
|
885
1280
|
return;
|
|
@@ -899,6 +1294,47 @@ var LaserEyesProvider = ({
|
|
|
899
1294
|
throw new Error("Error signing message: " + response.error.message);
|
|
900
1295
|
}
|
|
901
1296
|
}
|
|
1297
|
+
} else if (provider === MAGIC_EDEN) {
|
|
1298
|
+
let signedMessage;
|
|
1299
|
+
yield (0, import_sats_connect.signMessage)({
|
|
1300
|
+
getProvider: () => __async(void 0, null, function* () {
|
|
1301
|
+
return window.magicEden.bitcoin;
|
|
1302
|
+
}),
|
|
1303
|
+
payload: {
|
|
1304
|
+
network: {
|
|
1305
|
+
type: import_sats_connect.BitcoinNetworkType.Mainnet
|
|
1306
|
+
},
|
|
1307
|
+
address: address2,
|
|
1308
|
+
message
|
|
1309
|
+
},
|
|
1310
|
+
onFinish: (response) => {
|
|
1311
|
+
signedMessage = response;
|
|
1312
|
+
},
|
|
1313
|
+
onCancel: () => {
|
|
1314
|
+
alert("Request canceled");
|
|
1315
|
+
}
|
|
1316
|
+
});
|
|
1317
|
+
return signedMessage;
|
|
1318
|
+
} else if (provider === OKX) {
|
|
1319
|
+
return yield library == null ? void 0 : library.signMessage(message);
|
|
1320
|
+
} else if (provider === LEATHER) {
|
|
1321
|
+
const signed = yield library == null ? void 0 : library.request("signMessage", {
|
|
1322
|
+
message,
|
|
1323
|
+
paymentType: P2TR
|
|
1324
|
+
});
|
|
1325
|
+
console.log(signed);
|
|
1326
|
+
return (_a = signed == null ? void 0 : signed.result) == null ? void 0 : _a.signature;
|
|
1327
|
+
} else if (provider === PHANTOM) {
|
|
1328
|
+
const utf8Bytes = new TextEncoder().encode(message);
|
|
1329
|
+
const uintArray = new Uint8Array(utf8Bytes);
|
|
1330
|
+
const response = yield library == null ? void 0 : library.signMessage(address2, uintArray);
|
|
1331
|
+
console.log(response);
|
|
1332
|
+
const binaryString = String.fromCharCode(...response.signature);
|
|
1333
|
+
return btoa(binaryString);
|
|
1334
|
+
} else if (provider === WIZZ) {
|
|
1335
|
+
return yield library == null ? void 0 : library.signMessage(message);
|
|
1336
|
+
} else {
|
|
1337
|
+
throw new Error("The connected wallet doesn't support this method..");
|
|
902
1338
|
}
|
|
903
1339
|
} catch (error) {
|
|
904
1340
|
throw error;
|
|
@@ -1036,11 +1472,183 @@ var LaserEyesProvider = ({
|
|
|
1036
1472
|
txId: void 0
|
|
1037
1473
|
};
|
|
1038
1474
|
}
|
|
1475
|
+
} else if (provider === MAGIC_EDEN) {
|
|
1476
|
+
const toSignPsbt = bitcoin2.Psbt.fromBase64(String(psbtBase64), {
|
|
1477
|
+
network: getBitcoinNetwork(network)
|
|
1478
|
+
});
|
|
1479
|
+
const inputs = toSignPsbt.data.inputs;
|
|
1480
|
+
const inputsToSign = [];
|
|
1481
|
+
const ordinalAddressData = {
|
|
1482
|
+
address: address2,
|
|
1483
|
+
signingIndexes: []
|
|
1484
|
+
};
|
|
1485
|
+
const paymentsAddressData = {
|
|
1486
|
+
address: paymentAddress,
|
|
1487
|
+
signingIndexes: []
|
|
1488
|
+
};
|
|
1489
|
+
let counter = 0;
|
|
1490
|
+
try {
|
|
1491
|
+
for (var iter2 = __forAwait(inputs), more2, temp2, error2; more2 = !(temp2 = yield iter2.next()).done; more2 = false) {
|
|
1492
|
+
let input = temp2.value;
|
|
1493
|
+
const { script } = input.witnessUtxo;
|
|
1494
|
+
const addressFromScript = (0, import_address.fromOutputScript)(
|
|
1495
|
+
script,
|
|
1496
|
+
getBitcoinNetwork(network)
|
|
1497
|
+
);
|
|
1498
|
+
if (addressFromScript === paymentAddress) {
|
|
1499
|
+
paymentsAddressData.signingIndexes.push(Number(counter));
|
|
1500
|
+
} else if (addressFromScript === address2) {
|
|
1501
|
+
ordinalAddressData.signingIndexes.push(Number(counter));
|
|
1502
|
+
}
|
|
1503
|
+
counter++;
|
|
1504
|
+
}
|
|
1505
|
+
} catch (temp2) {
|
|
1506
|
+
error2 = [temp2];
|
|
1507
|
+
} finally {
|
|
1508
|
+
try {
|
|
1509
|
+
more2 && (temp2 = iter2.return) && (yield temp2.call(iter2));
|
|
1510
|
+
} finally {
|
|
1511
|
+
if (error2)
|
|
1512
|
+
throw error2[0];
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
if (ordinalAddressData.signingIndexes.length > 0) {
|
|
1516
|
+
inputsToSign.push(ordinalAddressData);
|
|
1517
|
+
}
|
|
1518
|
+
if (paymentsAddressData.signingIndexes.length > 0) {
|
|
1519
|
+
inputsToSign.push(paymentsAddressData);
|
|
1520
|
+
}
|
|
1521
|
+
let txId, signedPsbtHex, signedPsbtBase64;
|
|
1522
|
+
const xverseNetwork = getXverseNetwork(network);
|
|
1523
|
+
const signPsbtOptions = {
|
|
1524
|
+
getProvider: () => __async(void 0, null, function* () {
|
|
1525
|
+
return window.magicEden.bitcoin;
|
|
1526
|
+
}),
|
|
1527
|
+
payload: {
|
|
1528
|
+
network: {
|
|
1529
|
+
type: xverseNetwork
|
|
1530
|
+
},
|
|
1531
|
+
message: "Sign Transaction",
|
|
1532
|
+
psbtBase64: toSignPsbt.toBase64(),
|
|
1533
|
+
broadcast,
|
|
1534
|
+
inputsToSign
|
|
1535
|
+
},
|
|
1536
|
+
onFinish: (response) => {
|
|
1537
|
+
if (response.psbtBase64) {
|
|
1538
|
+
const signedPsbt = bitcoin2.Psbt.fromBase64(
|
|
1539
|
+
String(response.psbtBase64),
|
|
1540
|
+
{
|
|
1541
|
+
network: getBitcoinNetwork(network)
|
|
1542
|
+
}
|
|
1543
|
+
);
|
|
1544
|
+
signedPsbtHex = signedPsbt.toHex();
|
|
1545
|
+
signedPsbtBase64 = signedPsbt.toBase64();
|
|
1546
|
+
}
|
|
1547
|
+
},
|
|
1548
|
+
onCancel: () => {
|
|
1549
|
+
console.log("Canceled");
|
|
1550
|
+
throw new Error("User canceled the request");
|
|
1551
|
+
},
|
|
1552
|
+
onError: (error3) => {
|
|
1553
|
+
console.log("error", error3);
|
|
1554
|
+
throw error3;
|
|
1555
|
+
}
|
|
1556
|
+
};
|
|
1557
|
+
yield (0, import_sats_connect.signTransaction)(signPsbtOptions);
|
|
1558
|
+
if (broadcast) {
|
|
1559
|
+
const signed = bitcoin2.Psbt.fromBase64(String(signedPsbtBase64));
|
|
1560
|
+
const finalized = signed.finalizeAllInputs();
|
|
1561
|
+
const extracted = finalized.extractTransaction();
|
|
1562
|
+
const txId2 = yield pushPsbt(extracted.toHex());
|
|
1563
|
+
return {
|
|
1564
|
+
signedPsbtHex: extracted.toHex(),
|
|
1565
|
+
signedPsbtBase64: "test",
|
|
1566
|
+
txId: txId2
|
|
1567
|
+
};
|
|
1568
|
+
} else {
|
|
1569
|
+
return {
|
|
1570
|
+
signedPsbtHex,
|
|
1571
|
+
signedPsbtBase64,
|
|
1572
|
+
txId
|
|
1573
|
+
};
|
|
1574
|
+
}
|
|
1575
|
+
} else if (provider === OKX) {
|
|
1576
|
+
const signedPsbt = yield library == null ? void 0 : library.signPsbt(psbtHex, {
|
|
1577
|
+
autoFinalized: finalize
|
|
1578
|
+
});
|
|
1579
|
+
const psbtSignedPsbt = bitcoin2.Psbt.fromHex(signedPsbt);
|
|
1580
|
+
if (finalize && broadcast) {
|
|
1581
|
+
const txId = yield pushPsbt(signedPsbt);
|
|
1582
|
+
return {
|
|
1583
|
+
signedPsbtHex: psbtSignedPsbt.toHex(),
|
|
1584
|
+
signedPsbtBase64: psbtSignedPsbt.toBase64(),
|
|
1585
|
+
txId
|
|
1586
|
+
};
|
|
1587
|
+
}
|
|
1588
|
+
return {
|
|
1589
|
+
signedPsbtHex: psbtSignedPsbt.toHex(),
|
|
1590
|
+
signedPsbtBase64: psbtSignedPsbt.toBase64(),
|
|
1591
|
+
txId: void 0
|
|
1592
|
+
};
|
|
1593
|
+
} else if (provider === LEATHER) {
|
|
1594
|
+
const requestParams = {
|
|
1595
|
+
hex: psbtHex,
|
|
1596
|
+
broadcast
|
|
1597
|
+
};
|
|
1598
|
+
const response = yield library == null ? void 0 : library.request(
|
|
1599
|
+
"signPsbt",
|
|
1600
|
+
requestParams
|
|
1601
|
+
);
|
|
1602
|
+
const leatherHexResult = response.result;
|
|
1603
|
+
const signedTx = leatherHexResult.hex;
|
|
1604
|
+
const signed = bitcoin2.Psbt.fromBase64(String(signedTx));
|
|
1605
|
+
if (finalize && broadcast) {
|
|
1606
|
+
const finalized = signed.finalizeAllInputs();
|
|
1607
|
+
const extracted = finalized.extractTransaction();
|
|
1608
|
+
const txId = yield pushPsbt(extracted.toHex());
|
|
1609
|
+
return {
|
|
1610
|
+
signedPsbtHex: signed.toHex(),
|
|
1611
|
+
signedPsbtBase64: signed.toBase64(),
|
|
1612
|
+
txId
|
|
1613
|
+
};
|
|
1614
|
+
} else if (finalize) {
|
|
1615
|
+
const finalized = signed.finalizeAllInputs();
|
|
1616
|
+
return {
|
|
1617
|
+
signedPsbtHex: finalized.toHex(),
|
|
1618
|
+
signedPsbtBase64: finalized.toBase64(),
|
|
1619
|
+
txId: void 0
|
|
1620
|
+
};
|
|
1621
|
+
} else {
|
|
1622
|
+
return {
|
|
1623
|
+
signedPsbtHex: signed.toHex(),
|
|
1624
|
+
signedPsbtBase64: signed.toBase64(),
|
|
1625
|
+
txId: void 0
|
|
1626
|
+
};
|
|
1627
|
+
}
|
|
1628
|
+
} else if (provider === WIZZ) {
|
|
1629
|
+
const signedPsbt = yield library == null ? void 0 : library.signPsbt(psbtHex, {
|
|
1630
|
+
autoFinalized: finalize,
|
|
1631
|
+
broadcast: false
|
|
1632
|
+
});
|
|
1633
|
+
const psbtSignedPsbt = bitcoin2.Psbt.fromHex(signedPsbt);
|
|
1634
|
+
if (finalize && broadcast) {
|
|
1635
|
+
const txId = yield pushPsbt(signedPsbt);
|
|
1636
|
+
return {
|
|
1637
|
+
signedPsbtHex: psbtSignedPsbt.toHex(),
|
|
1638
|
+
signedPsbtBase64: psbtSignedPsbt.toBase64(),
|
|
1639
|
+
txId
|
|
1640
|
+
};
|
|
1641
|
+
}
|
|
1642
|
+
return {
|
|
1643
|
+
signedPsbtHex: psbtSignedPsbt.toHex(),
|
|
1644
|
+
signedPsbtBase64: psbtSignedPsbt.toBase64(),
|
|
1645
|
+
txId: void 0
|
|
1646
|
+
};
|
|
1039
1647
|
} else {
|
|
1040
1648
|
throw new Error("The connected wallet doesn't support this method..");
|
|
1041
1649
|
}
|
|
1042
|
-
} catch (
|
|
1043
|
-
throw
|
|
1650
|
+
} catch (error3) {
|
|
1651
|
+
throw error3;
|
|
1044
1652
|
}
|
|
1045
1653
|
});
|
|
1046
1654
|
const pushPsbt = (psbt) => __async(void 0, null, function* () {
|
|
@@ -1051,6 +1659,14 @@ var LaserEyesProvider = ({
|
|
|
1051
1659
|
return yield library == null ? void 0 : library.pushPsbt(psbt);
|
|
1052
1660
|
} else if (provider === OYL) {
|
|
1053
1661
|
return yield library == null ? void 0 : library.pushPsbt(psbt);
|
|
1662
|
+
} else if (provider === OKX) {
|
|
1663
|
+
return yield library == null ? void 0 : library.pushPsbt(psbt);
|
|
1664
|
+
} else if (provider === MAGIC_EDEN) {
|
|
1665
|
+
return yield import_axios2.default.post("https://mempool.space/api/tx", psbt).then((res) => res.data);
|
|
1666
|
+
} else if (provider === LEATHER) {
|
|
1667
|
+
return yield import_axios2.default.post("https://mempool.space/api/tx", psbt).then((res) => res.data);
|
|
1668
|
+
} else if (provider === WIZZ) {
|
|
1669
|
+
return yield library == null ? void 0 : library.pushPsbt(psbt);
|
|
1054
1670
|
} else {
|
|
1055
1671
|
throw new Error("The connected wallet doesn't support this method..");
|
|
1056
1672
|
}
|
|
@@ -1076,6 +1692,11 @@ var LaserEyesProvider = ({
|
|
|
1076
1692
|
hasUnisat,
|
|
1077
1693
|
hasXverse,
|
|
1078
1694
|
hasOyl,
|
|
1695
|
+
hasMagicEden,
|
|
1696
|
+
hasOkx,
|
|
1697
|
+
hasLeather,
|
|
1698
|
+
hasPhantom,
|
|
1699
|
+
hasWizz,
|
|
1079
1700
|
// functions
|
|
1080
1701
|
connect,
|
|
1081
1702
|
disconnect,
|
|
@@ -1100,9 +1721,13 @@ var LaserEyesProvider = ({
|
|
|
1100
1721
|
LEATHER_MAINNET,
|
|
1101
1722
|
LEATHER_TESTNET,
|
|
1102
1723
|
LaserEyesProvider,
|
|
1724
|
+
MAGIC_EDEN,
|
|
1103
1725
|
MAINNET,
|
|
1104
1726
|
MEMPOOL_SPACE_TESTNET_URL,
|
|
1105
1727
|
MEMPOOL_SPACE_URL,
|
|
1728
|
+
OKX,
|
|
1729
|
+
OKX_MAINNET,
|
|
1730
|
+
OKX_TESTNET,
|
|
1106
1731
|
OYL,
|
|
1107
1732
|
P2PKH,
|
|
1108
1733
|
P2PSH,
|
|
@@ -1112,11 +1737,15 @@ var LaserEyesProvider = ({
|
|
|
1112
1737
|
P2WSH,
|
|
1113
1738
|
PHANTOM,
|
|
1114
1739
|
REGTEST,
|
|
1740
|
+
SIGNET,
|
|
1115
1741
|
TESTNET,
|
|
1116
1742
|
UNISAT,
|
|
1117
1743
|
UNISAT_MAINNET,
|
|
1118
1744
|
UNISAT_TESTNET,
|
|
1119
1745
|
WALLETS,
|
|
1746
|
+
WIZZ,
|
|
1747
|
+
WIZZ_MAINNET,
|
|
1748
|
+
WIZZ_TESTNET,
|
|
1120
1749
|
XVERSE,
|
|
1121
1750
|
XVERSE_MAINNET,
|
|
1122
1751
|
XVERSE_NETWORK,
|
|
@@ -1133,10 +1762,13 @@ var LaserEyesProvider = ({
|
|
|
1133
1762
|
getLeatherNetwork,
|
|
1134
1763
|
getMempoolSpaceUrl,
|
|
1135
1764
|
getNetworkForLeather,
|
|
1765
|
+
getNetworkForOkx,
|
|
1136
1766
|
getNetworkForUnisat,
|
|
1767
|
+
getNetworkForWizz,
|
|
1137
1768
|
getNetworkForXverse,
|
|
1138
1769
|
getRedeemScript,
|
|
1139
1770
|
getUnisatNetwork,
|
|
1771
|
+
getWizzNetwork,
|
|
1140
1772
|
getXverseNetwork,
|
|
1141
1773
|
isBase64,
|
|
1142
1774
|
isHex,
|