@omnisat/lasereyes 0.0.21 → 0.0.23
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 +9 -19
- package/dist/index.js +121 -74
- package/dist/index.mjs +119 -72
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ declare const UNISAT_MAINNET = "livenet";
|
|
|
8
8
|
declare const UNISAT_TESTNET = "testnet";
|
|
9
9
|
declare const XVERSE_MAINNET = "Mainnet";
|
|
10
10
|
declare const XVERSE_TESTNET = "Testnet";
|
|
11
|
+
declare const XVERSE_SIGNET = "Signet";
|
|
11
12
|
declare const OKX_MAINNET = "livenet";
|
|
12
13
|
declare const OKX_TESTNET = "testnet";
|
|
13
14
|
declare const WIZZ_MAINNET = "livenet";
|
|
@@ -18,7 +19,7 @@ declare const MAINNET = "mainnet";
|
|
|
18
19
|
declare const SIGNET = "signet";
|
|
19
20
|
declare const TESTNET = "testnet";
|
|
20
21
|
declare const REGTEST = "regtest";
|
|
21
|
-
declare const getXverseNetwork: (network: string) => "Mainnet" | "Testnet";
|
|
22
|
+
declare const getXverseNetwork: (network: string) => "Mainnet" | "Testnet" | "Signet";
|
|
22
23
|
declare const getLeatherNetwork: (network: string) => "testnet" | "mainnet";
|
|
23
24
|
declare const getUnisatNetwork: (network: string) => "livenet" | "testnet";
|
|
24
25
|
declare const getWizzNetwork: (network: string) => "livenet" | "testnet";
|
|
@@ -29,7 +30,8 @@ declare const getNetworkForOkx: (network: string) => "testnet" | "mainnet";
|
|
|
29
30
|
declare const getNetworkForWizz: (network: string) => "testnet" | "mainnet";
|
|
30
31
|
declare const MEMPOOL_SPACE_URL = "https://mempool.space";
|
|
31
32
|
declare const MEMPOOL_SPACE_TESTNET_URL = "https://mempool.space/testnet";
|
|
32
|
-
declare const
|
|
33
|
+
declare const MEMPOOL_SPACE_SIGNET_URL = "https://mempool.space/signet";
|
|
34
|
+
declare const getMempoolSpaceUrl: (network: typeof MAINNET | typeof TESTNET | typeof SIGNET | typeof REGTEST) => "https://mempool.space" | "https://mempool.space/testnet" | "https://mempool.space/signet";
|
|
33
35
|
|
|
34
36
|
declare const OYL = "oyl";
|
|
35
37
|
declare const UNISAT = "unisat";
|
|
@@ -82,7 +84,7 @@ type LaserEyesContextType = {
|
|
|
82
84
|
paymentAddress: string;
|
|
83
85
|
paymentPublicKey: string;
|
|
84
86
|
balance: number | undefined;
|
|
85
|
-
network: typeof MAINNET | typeof TESTNET | typeof REGTEST;
|
|
87
|
+
network: typeof MAINNET | typeof TESTNET | typeof SIGNET | typeof REGTEST;
|
|
86
88
|
library: any;
|
|
87
89
|
provider: any;
|
|
88
90
|
accounts: string[];
|
|
@@ -98,7 +100,7 @@ type LaserEyesContextType = {
|
|
|
98
100
|
disconnect: () => void;
|
|
99
101
|
requestAccounts: () => Promise<string[]>;
|
|
100
102
|
getNetwork: () => Promise<string | undefined>;
|
|
101
|
-
switchNetwork: (network: typeof MAINNET | typeof TESTNET | typeof REGTEST) => Promise<void>;
|
|
103
|
+
switchNetwork: (network: typeof MAINNET | typeof TESTNET | typeof SIGNET | typeof REGTEST) => Promise<void>;
|
|
102
104
|
getPublicKey: () => Promise<string>;
|
|
103
105
|
getBalance: () => Promise<string>;
|
|
104
106
|
getInscriptions: () => Promise<any[]>;
|
|
@@ -112,18 +114,8 @@ type LaserEyesContextType = {
|
|
|
112
114
|
pushPsbt: (tx: string) => Promise<string | undefined>;
|
|
113
115
|
};
|
|
114
116
|
type Config = {
|
|
115
|
-
network: typeof MAINNET | typeof TESTNET | typeof REGTEST;
|
|
117
|
+
network: typeof MAINNET | typeof TESTNET | typeof SIGNET | typeof REGTEST;
|
|
116
118
|
};
|
|
117
|
-
interface BlockchainInfoUTXO {
|
|
118
|
-
tx_hash_big_endian: string;
|
|
119
|
-
tx_hash: string;
|
|
120
|
-
tx_output_n: number;
|
|
121
|
-
script: string;
|
|
122
|
-
value: number;
|
|
123
|
-
value_hex: string;
|
|
124
|
-
confirmations: number;
|
|
125
|
-
tx_index: number;
|
|
126
|
-
}
|
|
127
119
|
interface CommitPsbtResponse {
|
|
128
120
|
inscriberAddress: string;
|
|
129
121
|
psbtHex: string;
|
|
@@ -147,15 +139,13 @@ interface DeScribeCreateResponse {
|
|
|
147
139
|
totalFees: number;
|
|
148
140
|
}
|
|
149
141
|
|
|
150
|
-
declare const getBitcoinNetwork: (network: typeof MAINNET | typeof TESTNET | typeof REGTEST) => bitcoin.networks.Network;
|
|
142
|
+
declare const getBitcoinNetwork: (network: typeof MAINNET | typeof TESTNET | typeof SIGNET | typeof REGTEST) => bitcoin.networks.Network;
|
|
151
143
|
declare const findOrdinalsAddress: (addresses: any) => any;
|
|
152
144
|
declare const findPaymentAddress: (addresses: any) => any;
|
|
153
145
|
declare const getBTCBalance: (address: string) => Promise<number>;
|
|
154
|
-
declare const getAddressUtxos: (address: string) => Promise<BlockchainInfoUTXO[]>;
|
|
155
146
|
declare const satoshisToBTC: (satoshis: number) => string;
|
|
156
147
|
declare const isBase64: (str: string) => boolean;
|
|
157
148
|
declare const isHex: (str: string) => boolean;
|
|
158
|
-
declare function getAddressType(address: string): "p2tr" | "p2pkh" | "p2wpkh" | "p2psh" | "p2wsh";
|
|
159
149
|
declare function estimateTxSize(taprootInputCount: number, nonTaprootInputCount: number, outputCount: number): number;
|
|
160
150
|
declare function createSendBtcPsbt(address: string, paymentAddress: string, recipientAddress: string, amount: number, paymentPublicKey: string, network: typeof MAINNET | typeof TESTNET, feeRate?: number): Promise<{
|
|
161
151
|
psbtBase64: string;
|
|
@@ -194,4 +184,4 @@ declare const useInscriber: ({ inscribeApiUrl, }: {
|
|
|
194
184
|
reset: () => void;
|
|
195
185
|
};
|
|
196
186
|
|
|
197
|
-
export { DeScribeCreateResponse, LEATHER, LEATHER_MAINNET, LEATHER_TESTNET, LaserEyesProvider, MAGIC_EDEN, MAINNET, MEMPOOL_SPACE_TESTNET_URL, MEMPOOL_SPACE_URL, OKX, OKX_MAINNET, OKX_TESTNET, OYL, P2PKH, P2PSH, P2SH, P2TR, P2WPKH, P2WSH, PHANTOM, REGTEST, SIGNET, TESTNET, UNISAT, UNISAT_MAINNET, UNISAT_TESTNET, WALLETS, WIZZ, WIZZ_MAINNET, WIZZ_TESTNET, XVERSE, XVERSE_MAINNET, XVERSE_NETWORK, XVERSE_TESTNET, createConfig, createSendBtcPsbt, delay, estimateTxSize, findOrdinalsAddress, findPaymentAddress,
|
|
187
|
+
export { DeScribeCreateResponse, LEATHER, LEATHER_MAINNET, LEATHER_TESTNET, LaserEyesProvider, MAGIC_EDEN, MAINNET, MEMPOOL_SPACE_SIGNET_URL, MEMPOOL_SPACE_TESTNET_URL, MEMPOOL_SPACE_URL, OKX, OKX_MAINNET, OKX_TESTNET, OYL, P2PKH, P2PSH, P2SH, P2TR, P2WPKH, P2WSH, PHANTOM, REGTEST, SIGNET, TESTNET, UNISAT, UNISAT_MAINNET, UNISAT_TESTNET, WALLETS, WIZZ, WIZZ_MAINNET, WIZZ_TESTNET, XVERSE, XVERSE_MAINNET, XVERSE_NETWORK, XVERSE_SIGNET, XVERSE_TESTNET, createConfig, createSendBtcPsbt, delay, estimateTxSize, findOrdinalsAddress, findPaymentAddress, getBTCBalance, getBitcoinNetwork, getLeatherNetwork, getMempoolSpaceUrl, getNetworkForLeather, getNetworkForOkx, getNetworkForUnisat, getNetworkForWizz, getNetworkForXverse, getRedeemScript, getUnisatNetwork, getWizzNetwork, getXverseNetwork, isBase64, isHex, satoshisToBTC, useInscriber, useLaserEyes };
|
package/dist/index.js
CHANGED
|
@@ -79,6 +79,7 @@ __export(src_exports, {
|
|
|
79
79
|
LaserEyesProvider: () => LaserEyesProvider,
|
|
80
80
|
MAGIC_EDEN: () => MAGIC_EDEN,
|
|
81
81
|
MAINNET: () => MAINNET,
|
|
82
|
+
MEMPOOL_SPACE_SIGNET_URL: () => MEMPOOL_SPACE_SIGNET_URL,
|
|
82
83
|
MEMPOOL_SPACE_TESTNET_URL: () => MEMPOOL_SPACE_TESTNET_URL,
|
|
83
84
|
MEMPOOL_SPACE_URL: () => MEMPOOL_SPACE_URL,
|
|
84
85
|
OKX: () => OKX,
|
|
@@ -105,6 +106,7 @@ __export(src_exports, {
|
|
|
105
106
|
XVERSE: () => XVERSE,
|
|
106
107
|
XVERSE_MAINNET: () => XVERSE_MAINNET,
|
|
107
108
|
XVERSE_NETWORK: () => XVERSE_NETWORK,
|
|
109
|
+
XVERSE_SIGNET: () => XVERSE_SIGNET,
|
|
108
110
|
XVERSE_TESTNET: () => XVERSE_TESTNET,
|
|
109
111
|
createConfig: () => createConfig,
|
|
110
112
|
createSendBtcPsbt: () => createSendBtcPsbt,
|
|
@@ -112,8 +114,6 @@ __export(src_exports, {
|
|
|
112
114
|
estimateTxSize: () => estimateTxSize,
|
|
113
115
|
findOrdinalsAddress: () => findOrdinalsAddress,
|
|
114
116
|
findPaymentAddress: () => findPaymentAddress,
|
|
115
|
-
getAddressType: () => getAddressType,
|
|
116
|
-
getAddressUtxos: () => getAddressUtxos,
|
|
117
117
|
getBTCBalance: () => getBTCBalance,
|
|
118
118
|
getBitcoinNetwork: () => getBitcoinNetwork,
|
|
119
119
|
getLeatherNetwork: () => getLeatherNetwork,
|
|
@@ -141,6 +141,7 @@ var UNISAT_MAINNET = "livenet";
|
|
|
141
141
|
var UNISAT_TESTNET = "testnet";
|
|
142
142
|
var XVERSE_MAINNET = "Mainnet";
|
|
143
143
|
var XVERSE_TESTNET = "Testnet";
|
|
144
|
+
var XVERSE_SIGNET = "Signet";
|
|
144
145
|
var OKX_MAINNET = "livenet";
|
|
145
146
|
var OKX_TESTNET = "testnet";
|
|
146
147
|
var WIZZ_MAINNET = "livenet";
|
|
@@ -156,6 +157,8 @@ var getXverseNetwork = (network) => {
|
|
|
156
157
|
return XVERSE_MAINNET;
|
|
157
158
|
if (network === TESTNET)
|
|
158
159
|
return XVERSE_TESTNET;
|
|
160
|
+
if (network === SIGNET)
|
|
161
|
+
return XVERSE_SIGNET;
|
|
159
162
|
return XVERSE_MAINNET;
|
|
160
163
|
};
|
|
161
164
|
var getLeatherNetwork = (network) => {
|
|
@@ -216,7 +219,8 @@ var getNetworkForWizz = (network) => {
|
|
|
216
219
|
};
|
|
217
220
|
var MEMPOOL_SPACE_URL = "https://mempool.space";
|
|
218
221
|
var MEMPOOL_SPACE_TESTNET_URL = "https://mempool.space/testnet";
|
|
219
|
-
var
|
|
222
|
+
var MEMPOOL_SPACE_SIGNET_URL = "https://mempool.space/signet";
|
|
223
|
+
var getMempoolSpaceUrl = (network) => network === TESTNET ? MEMPOOL_SPACE_TESTNET_URL : network === SIGNET ? MEMPOOL_SPACE_SIGNET_URL : MEMPOOL_SPACE_URL;
|
|
220
224
|
|
|
221
225
|
// src/consts/wallets.ts
|
|
222
226
|
var OYL = "oyl";
|
|
@@ -357,6 +361,8 @@ bitcoin.initEccLib(ecc);
|
|
|
357
361
|
var getBitcoinNetwork = (network) => {
|
|
358
362
|
if (network === TESTNET) {
|
|
359
363
|
return bitcoin.networks.testnet;
|
|
364
|
+
} else if (network === SIGNET) {
|
|
365
|
+
return bitcoin.networks.testnet;
|
|
360
366
|
} else if (network === REGTEST) {
|
|
361
367
|
return bitcoin.networks.regtest;
|
|
362
368
|
} else {
|
|
@@ -381,13 +387,6 @@ var getBTCBalance = (address2) => __async(void 0, null, function* () {
|
|
|
381
387
|
throw new Error("Failed to fetch BTC balance");
|
|
382
388
|
}
|
|
383
389
|
});
|
|
384
|
-
var getAddressUtxos = (address2) => __async(void 0, null, function* () {
|
|
385
|
-
try {
|
|
386
|
-
return yield import_axios.default.get(`https://blockchain.info/unspent?active=${address2}`).then((response) => response.data.unspent_outputs);
|
|
387
|
-
} catch (error) {
|
|
388
|
-
throw new Error("Failed to fetch UTXOs");
|
|
389
|
-
}
|
|
390
|
-
});
|
|
391
390
|
var satoshisToBTC = (satoshis) => {
|
|
392
391
|
if (Number.isNaN(satoshis) || satoshis === void 0)
|
|
393
392
|
return "--";
|
|
@@ -402,32 +401,6 @@ var isHex = (str) => {
|
|
|
402
401
|
const hexRegex = /^[a-fA-F0-9]+$/;
|
|
403
402
|
return hexRegex.test(str);
|
|
404
403
|
};
|
|
405
|
-
function getAddressType(address2) {
|
|
406
|
-
try {
|
|
407
|
-
bitcoin.address.fromBase58Check(address2);
|
|
408
|
-
return P2PKH;
|
|
409
|
-
} catch (e) {
|
|
410
|
-
}
|
|
411
|
-
try {
|
|
412
|
-
bitcoin.address.fromBase58Check(address2);
|
|
413
|
-
return P2PSH;
|
|
414
|
-
} catch (e) {
|
|
415
|
-
}
|
|
416
|
-
try {
|
|
417
|
-
const { version, data } = bitcoin.address.fromBech32(address2);
|
|
418
|
-
if (version === 0) {
|
|
419
|
-
if (data.length === 20) {
|
|
420
|
-
return P2WPKH;
|
|
421
|
-
} else if (data.length === 32) {
|
|
422
|
-
return P2WSH;
|
|
423
|
-
}
|
|
424
|
-
} else if (version === 1 && data.length === 32) {
|
|
425
|
-
return P2TR;
|
|
426
|
-
}
|
|
427
|
-
} catch (e) {
|
|
428
|
-
}
|
|
429
|
-
throw new Error("Invalid address");
|
|
430
|
-
}
|
|
431
404
|
function estimateTxSize(taprootInputCount, nonTaprootInputCount, outputCount) {
|
|
432
405
|
const baseTxSize = 10;
|
|
433
406
|
const taprootInputSize = 57;
|
|
@@ -573,50 +546,119 @@ var LaserEyesProvider = ({
|
|
|
573
546
|
}
|
|
574
547
|
}, [config, library]);
|
|
575
548
|
(0, import_react.useEffect)(() => {
|
|
576
|
-
const
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
549
|
+
const observer = new MutationObserver(() => {
|
|
550
|
+
const unisatLib = window == null ? void 0 : window.unisat;
|
|
551
|
+
if (unisatLib) {
|
|
552
|
+
setHasUnisat(true);
|
|
553
|
+
observer.disconnect();
|
|
554
|
+
}
|
|
555
|
+
});
|
|
556
|
+
observer.observe(document, { childList: true, subtree: true });
|
|
557
|
+
return () => {
|
|
558
|
+
observer.disconnect();
|
|
559
|
+
};
|
|
583
560
|
}, []);
|
|
584
561
|
(0, import_react.useEffect)(() => {
|
|
585
|
-
const
|
|
586
|
-
|
|
562
|
+
const observer = new MutationObserver(() => {
|
|
563
|
+
var _a;
|
|
564
|
+
const xverseLib = (_a = window == null ? void 0 : window.XverseProviders) == null ? void 0 : _a.BitcoinProvider;
|
|
565
|
+
if (xverseLib) {
|
|
566
|
+
setHasXverse(true);
|
|
567
|
+
observer.disconnect();
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
observer.observe(document, { childList: true, subtree: true });
|
|
571
|
+
return () => {
|
|
572
|
+
observer.disconnect();
|
|
573
|
+
};
|
|
587
574
|
}, []);
|
|
588
575
|
(0, import_react.useEffect)(() => {
|
|
589
|
-
const
|
|
590
|
-
|
|
576
|
+
const observer = new MutationObserver(() => {
|
|
577
|
+
const oylLib = window == null ? void 0 : window.oyl;
|
|
578
|
+
if (oylLib) {
|
|
579
|
+
setHasOyl(true);
|
|
580
|
+
observer.disconnect();
|
|
581
|
+
}
|
|
582
|
+
});
|
|
583
|
+
observer.observe(document, { childList: true, subtree: true });
|
|
584
|
+
return () => {
|
|
585
|
+
observer.disconnect();
|
|
586
|
+
};
|
|
591
587
|
}, []);
|
|
592
588
|
(0, import_react.useEffect)(() => {
|
|
589
|
+
const observer = new MutationObserver(() => {
|
|
590
|
+
const magicEdenLib = window == null ? void 0 : window.magicEden;
|
|
591
|
+
if (magicEdenLib) {
|
|
592
|
+
setHasMagicEden(true);
|
|
593
|
+
observer.disconnect();
|
|
594
|
+
}
|
|
595
|
+
});
|
|
596
|
+
observer.observe(document, { childList: true, subtree: true });
|
|
597
|
+
return () => {
|
|
598
|
+
observer.disconnect();
|
|
599
|
+
};
|
|
593
600
|
}, []);
|
|
594
601
|
(0, import_react.useEffect)(() => {
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
602
|
+
const observer = new MutationObserver(() => {
|
|
603
|
+
var _a, _b;
|
|
604
|
+
let foundOkx;
|
|
605
|
+
if (network === TESTNET) {
|
|
606
|
+
foundOkx = (_a = window == null ? void 0 : window.okxwallet) == null ? void 0 : _a.bitcoinTestnet;
|
|
607
|
+
} else if (network === MAINNET) {
|
|
608
|
+
foundOkx = (_b = window == null ? void 0 : window.okxwallet) == null ? void 0 : _b.bitcoin;
|
|
609
|
+
}
|
|
610
|
+
if (foundOkx) {
|
|
611
|
+
setHasOkx(true);
|
|
612
|
+
observer.disconnect();
|
|
613
|
+
}
|
|
614
|
+
});
|
|
615
|
+
observer.observe(document, { childList: true, subtree: true });
|
|
616
|
+
return () => {
|
|
617
|
+
observer.disconnect();
|
|
618
|
+
};
|
|
619
|
+
}, [network]);
|
|
604
620
|
(0, import_react.useEffect)(() => {
|
|
605
|
-
const
|
|
606
|
-
|
|
621
|
+
const observer = new MutationObserver(() => {
|
|
622
|
+
const leatherLib = window == null ? void 0 : window.LeatherProvider;
|
|
623
|
+
if (leatherLib) {
|
|
624
|
+
setHasLeather(true);
|
|
625
|
+
observer.disconnect();
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
observer.observe(document, { childList: true, subtree: true });
|
|
629
|
+
return () => {
|
|
630
|
+
observer.disconnect();
|
|
631
|
+
};
|
|
607
632
|
}, []);
|
|
608
633
|
(0, import_react.useEffect)(() => {
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
634
|
+
const observer = new MutationObserver(() => {
|
|
635
|
+
var _a;
|
|
636
|
+
const phantomLib = (_a = window == null ? void 0 : window.phantom) == null ? void 0 : _a.bitcoin;
|
|
637
|
+
if (phantomLib && phantomLib.isPhantom) {
|
|
638
|
+
setHasPhantom(true);
|
|
639
|
+
observer.disconnect();
|
|
640
|
+
} else {
|
|
641
|
+
setHasPhantom(false);
|
|
642
|
+
observer.disconnect();
|
|
643
|
+
}
|
|
644
|
+
});
|
|
645
|
+
observer.observe(document, { childList: true, subtree: true });
|
|
646
|
+
return () => {
|
|
647
|
+
observer.disconnect();
|
|
648
|
+
};
|
|
616
649
|
}, []);
|
|
617
650
|
(0, import_react.useEffect)(() => {
|
|
618
|
-
const
|
|
619
|
-
|
|
651
|
+
const observer = new MutationObserver(() => {
|
|
652
|
+
const wizzLib = window == null ? void 0 : window.wizz;
|
|
653
|
+
if (wizzLib) {
|
|
654
|
+
setHasWizz(true);
|
|
655
|
+
observer.disconnect();
|
|
656
|
+
}
|
|
657
|
+
});
|
|
658
|
+
observer.observe(document, { childList: true, subtree: true });
|
|
659
|
+
return () => {
|
|
660
|
+
observer.disconnect();
|
|
661
|
+
};
|
|
620
662
|
}, []);
|
|
621
663
|
(0, import_react.useEffect)(() => {
|
|
622
664
|
setBalance(void 0);
|
|
@@ -900,6 +942,8 @@ var LaserEyesProvider = ({
|
|
|
900
942
|
yield connectUnisat();
|
|
901
943
|
} else if (walletName === XVERSE) {
|
|
902
944
|
yield connectXverse();
|
|
945
|
+
} else if (walletName === LEATHER) {
|
|
946
|
+
yield connectLeather();
|
|
903
947
|
} else {
|
|
904
948
|
throw new Error("Unsupported wallet..");
|
|
905
949
|
}
|
|
@@ -1318,7 +1362,7 @@ var LaserEyesProvider = ({
|
|
|
1318
1362
|
} else if (provider === LEATHER) {
|
|
1319
1363
|
const signed = yield library == null ? void 0 : library.request("signMessage", {
|
|
1320
1364
|
message,
|
|
1321
|
-
paymentType:
|
|
1365
|
+
paymentType: P2WPKH
|
|
1322
1366
|
});
|
|
1323
1367
|
return (_a = signed == null ? void 0 : signed.result) == null ? void 0 : _a.signature;
|
|
1324
1368
|
} else if (provider === PHANTOM) {
|
|
@@ -1347,8 +1391,8 @@ var LaserEyesProvider = ({
|
|
|
1347
1391
|
psbtBase64 = bitcoin2.Psbt.fromHex(psbt).toBase64();
|
|
1348
1392
|
psbtHex = psbt;
|
|
1349
1393
|
} else if (isBase64(psbt)) {
|
|
1350
|
-
psbtHex = bitcoin2.Psbt.fromBase64(psbt).toHex();
|
|
1351
1394
|
psbtBase64 = psbt;
|
|
1395
|
+
psbtHex = bitcoin2.Psbt.fromBase64(psbt).toHex();
|
|
1352
1396
|
} else {
|
|
1353
1397
|
throw new Error("Invalid PSBT format");
|
|
1354
1398
|
}
|
|
@@ -1589,7 +1633,8 @@ var LaserEyesProvider = ({
|
|
|
1589
1633
|
} else if (provider === LEATHER) {
|
|
1590
1634
|
const requestParams = {
|
|
1591
1635
|
hex: psbtHex,
|
|
1592
|
-
broadcast
|
|
1636
|
+
broadcast,
|
|
1637
|
+
network
|
|
1593
1638
|
};
|
|
1594
1639
|
const response = yield library == null ? void 0 : library.request(
|
|
1595
1640
|
"signPsbt",
|
|
@@ -1597,7 +1642,7 @@ var LaserEyesProvider = ({
|
|
|
1597
1642
|
);
|
|
1598
1643
|
const leatherHexResult = response.result;
|
|
1599
1644
|
const signedTx = leatherHexResult.hex;
|
|
1600
|
-
const signed = bitcoin2.Psbt.
|
|
1645
|
+
const signed = bitcoin2.Psbt.fromHex(String(signedTx));
|
|
1601
1646
|
if (finalize && broadcast) {
|
|
1602
1647
|
const finalized = signed.finalizeAllInputs();
|
|
1603
1648
|
const extracted = finalized.extractTransaction();
|
|
@@ -1660,7 +1705,9 @@ var LaserEyesProvider = ({
|
|
|
1660
1705
|
} else if (provider === MAGIC_EDEN) {
|
|
1661
1706
|
return yield import_axios2.default.post("https://mempool.space/api/tx", psbt).then((res) => res.data);
|
|
1662
1707
|
} else if (provider === LEATHER) {
|
|
1663
|
-
|
|
1708
|
+
const decoded = bitcoin2.Psbt.fromHex(psbt);
|
|
1709
|
+
const extracted = decoded.extractTransaction();
|
|
1710
|
+
return yield import_axios2.default.post("https://mempool.space/api/tx", extracted.toHex()).then((res) => res.data);
|
|
1664
1711
|
} else if (provider === WIZZ) {
|
|
1665
1712
|
return yield library == null ? void 0 : library.pushPsbt(psbt);
|
|
1666
1713
|
} else {
|
|
@@ -1879,6 +1926,7 @@ var useInscriber = ({
|
|
|
1879
1926
|
LaserEyesProvider,
|
|
1880
1927
|
MAGIC_EDEN,
|
|
1881
1928
|
MAINNET,
|
|
1929
|
+
MEMPOOL_SPACE_SIGNET_URL,
|
|
1882
1930
|
MEMPOOL_SPACE_TESTNET_URL,
|
|
1883
1931
|
MEMPOOL_SPACE_URL,
|
|
1884
1932
|
OKX,
|
|
@@ -1905,6 +1953,7 @@ var useInscriber = ({
|
|
|
1905
1953
|
XVERSE,
|
|
1906
1954
|
XVERSE_MAINNET,
|
|
1907
1955
|
XVERSE_NETWORK,
|
|
1956
|
+
XVERSE_SIGNET,
|
|
1908
1957
|
XVERSE_TESTNET,
|
|
1909
1958
|
createConfig,
|
|
1910
1959
|
createSendBtcPsbt,
|
|
@@ -1912,8 +1961,6 @@ var useInscriber = ({
|
|
|
1912
1961
|
estimateTxSize,
|
|
1913
1962
|
findOrdinalsAddress,
|
|
1914
1963
|
findPaymentAddress,
|
|
1915
|
-
getAddressType,
|
|
1916
|
-
getAddressUtxos,
|
|
1917
1964
|
getBTCBalance,
|
|
1918
1965
|
getBitcoinNetwork,
|
|
1919
1966
|
getLeatherNetwork,
|
package/dist/index.mjs
CHANGED
|
@@ -50,6 +50,7 @@ var UNISAT_MAINNET = "livenet";
|
|
|
50
50
|
var UNISAT_TESTNET = "testnet";
|
|
51
51
|
var XVERSE_MAINNET = "Mainnet";
|
|
52
52
|
var XVERSE_TESTNET = "Testnet";
|
|
53
|
+
var XVERSE_SIGNET = "Signet";
|
|
53
54
|
var OKX_MAINNET = "livenet";
|
|
54
55
|
var OKX_TESTNET = "testnet";
|
|
55
56
|
var WIZZ_MAINNET = "livenet";
|
|
@@ -65,6 +66,8 @@ var getXverseNetwork = (network) => {
|
|
|
65
66
|
return XVERSE_MAINNET;
|
|
66
67
|
if (network === TESTNET)
|
|
67
68
|
return XVERSE_TESTNET;
|
|
69
|
+
if (network === SIGNET)
|
|
70
|
+
return XVERSE_SIGNET;
|
|
68
71
|
return XVERSE_MAINNET;
|
|
69
72
|
};
|
|
70
73
|
var getLeatherNetwork = (network) => {
|
|
@@ -125,7 +128,8 @@ var getNetworkForWizz = (network) => {
|
|
|
125
128
|
};
|
|
126
129
|
var MEMPOOL_SPACE_URL = "https://mempool.space";
|
|
127
130
|
var MEMPOOL_SPACE_TESTNET_URL = "https://mempool.space/testnet";
|
|
128
|
-
var
|
|
131
|
+
var MEMPOOL_SPACE_SIGNET_URL = "https://mempool.space/signet";
|
|
132
|
+
var getMempoolSpaceUrl = (network) => network === TESTNET ? MEMPOOL_SPACE_TESTNET_URL : network === SIGNET ? MEMPOOL_SPACE_SIGNET_URL : MEMPOOL_SPACE_URL;
|
|
129
133
|
|
|
130
134
|
// src/consts/wallets.ts
|
|
131
135
|
var OYL = "oyl";
|
|
@@ -272,6 +276,8 @@ bitcoin.initEccLib(ecc);
|
|
|
272
276
|
var getBitcoinNetwork = (network) => {
|
|
273
277
|
if (network === TESTNET) {
|
|
274
278
|
return bitcoin.networks.testnet;
|
|
279
|
+
} else if (network === SIGNET) {
|
|
280
|
+
return bitcoin.networks.testnet;
|
|
275
281
|
} else if (network === REGTEST) {
|
|
276
282
|
return bitcoin.networks.regtest;
|
|
277
283
|
} else {
|
|
@@ -296,13 +302,6 @@ var getBTCBalance = (address2) => __async(void 0, null, function* () {
|
|
|
296
302
|
throw new Error("Failed to fetch BTC balance");
|
|
297
303
|
}
|
|
298
304
|
});
|
|
299
|
-
var getAddressUtxos = (address2) => __async(void 0, null, function* () {
|
|
300
|
-
try {
|
|
301
|
-
return yield axios.get(`https://blockchain.info/unspent?active=${address2}`).then((response) => response.data.unspent_outputs);
|
|
302
|
-
} catch (error) {
|
|
303
|
-
throw new Error("Failed to fetch UTXOs");
|
|
304
|
-
}
|
|
305
|
-
});
|
|
306
305
|
var satoshisToBTC = (satoshis) => {
|
|
307
306
|
if (Number.isNaN(satoshis) || satoshis === void 0)
|
|
308
307
|
return "--";
|
|
@@ -317,32 +316,6 @@ var isHex = (str) => {
|
|
|
317
316
|
const hexRegex = /^[a-fA-F0-9]+$/;
|
|
318
317
|
return hexRegex.test(str);
|
|
319
318
|
};
|
|
320
|
-
function getAddressType(address2) {
|
|
321
|
-
try {
|
|
322
|
-
bitcoin.address.fromBase58Check(address2);
|
|
323
|
-
return P2PKH;
|
|
324
|
-
} catch (e) {
|
|
325
|
-
}
|
|
326
|
-
try {
|
|
327
|
-
bitcoin.address.fromBase58Check(address2);
|
|
328
|
-
return P2PSH;
|
|
329
|
-
} catch (e) {
|
|
330
|
-
}
|
|
331
|
-
try {
|
|
332
|
-
const { version, data } = bitcoin.address.fromBech32(address2);
|
|
333
|
-
if (version === 0) {
|
|
334
|
-
if (data.length === 20) {
|
|
335
|
-
return P2WPKH;
|
|
336
|
-
} else if (data.length === 32) {
|
|
337
|
-
return P2WSH;
|
|
338
|
-
}
|
|
339
|
-
} else if (version === 1 && data.length === 32) {
|
|
340
|
-
return P2TR;
|
|
341
|
-
}
|
|
342
|
-
} catch (e) {
|
|
343
|
-
}
|
|
344
|
-
throw new Error("Invalid address");
|
|
345
|
-
}
|
|
346
319
|
function estimateTxSize(taprootInputCount, nonTaprootInputCount, outputCount) {
|
|
347
320
|
const baseTxSize = 10;
|
|
348
321
|
const taprootInputSize = 57;
|
|
@@ -495,50 +468,119 @@ var LaserEyesProvider = ({
|
|
|
495
468
|
}
|
|
496
469
|
}, [config, library]);
|
|
497
470
|
useEffect(() => {
|
|
498
|
-
const
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
471
|
+
const observer = new MutationObserver(() => {
|
|
472
|
+
const unisatLib = window == null ? void 0 : window.unisat;
|
|
473
|
+
if (unisatLib) {
|
|
474
|
+
setHasUnisat(true);
|
|
475
|
+
observer.disconnect();
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
observer.observe(document, { childList: true, subtree: true });
|
|
479
|
+
return () => {
|
|
480
|
+
observer.disconnect();
|
|
481
|
+
};
|
|
505
482
|
}, []);
|
|
506
483
|
useEffect(() => {
|
|
507
|
-
const
|
|
508
|
-
|
|
484
|
+
const observer = new MutationObserver(() => {
|
|
485
|
+
var _a;
|
|
486
|
+
const xverseLib = (_a = window == null ? void 0 : window.XverseProviders) == null ? void 0 : _a.BitcoinProvider;
|
|
487
|
+
if (xverseLib) {
|
|
488
|
+
setHasXverse(true);
|
|
489
|
+
observer.disconnect();
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
observer.observe(document, { childList: true, subtree: true });
|
|
493
|
+
return () => {
|
|
494
|
+
observer.disconnect();
|
|
495
|
+
};
|
|
509
496
|
}, []);
|
|
510
497
|
useEffect(() => {
|
|
511
|
-
const
|
|
512
|
-
|
|
498
|
+
const observer = new MutationObserver(() => {
|
|
499
|
+
const oylLib = window == null ? void 0 : window.oyl;
|
|
500
|
+
if (oylLib) {
|
|
501
|
+
setHasOyl(true);
|
|
502
|
+
observer.disconnect();
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
observer.observe(document, { childList: true, subtree: true });
|
|
506
|
+
return () => {
|
|
507
|
+
observer.disconnect();
|
|
508
|
+
};
|
|
513
509
|
}, []);
|
|
514
510
|
useEffect(() => {
|
|
511
|
+
const observer = new MutationObserver(() => {
|
|
512
|
+
const magicEdenLib = window == null ? void 0 : window.magicEden;
|
|
513
|
+
if (magicEdenLib) {
|
|
514
|
+
setHasMagicEden(true);
|
|
515
|
+
observer.disconnect();
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
observer.observe(document, { childList: true, subtree: true });
|
|
519
|
+
return () => {
|
|
520
|
+
observer.disconnect();
|
|
521
|
+
};
|
|
515
522
|
}, []);
|
|
516
523
|
useEffect(() => {
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
524
|
+
const observer = new MutationObserver(() => {
|
|
525
|
+
var _a, _b;
|
|
526
|
+
let foundOkx;
|
|
527
|
+
if (network === TESTNET) {
|
|
528
|
+
foundOkx = (_a = window == null ? void 0 : window.okxwallet) == null ? void 0 : _a.bitcoinTestnet;
|
|
529
|
+
} else if (network === MAINNET) {
|
|
530
|
+
foundOkx = (_b = window == null ? void 0 : window.okxwallet) == null ? void 0 : _b.bitcoin;
|
|
531
|
+
}
|
|
532
|
+
if (foundOkx) {
|
|
533
|
+
setHasOkx(true);
|
|
534
|
+
observer.disconnect();
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
observer.observe(document, { childList: true, subtree: true });
|
|
538
|
+
return () => {
|
|
539
|
+
observer.disconnect();
|
|
540
|
+
};
|
|
541
|
+
}, [network]);
|
|
526
542
|
useEffect(() => {
|
|
527
|
-
const
|
|
528
|
-
|
|
543
|
+
const observer = new MutationObserver(() => {
|
|
544
|
+
const leatherLib = window == null ? void 0 : window.LeatherProvider;
|
|
545
|
+
if (leatherLib) {
|
|
546
|
+
setHasLeather(true);
|
|
547
|
+
observer.disconnect();
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
observer.observe(document, { childList: true, subtree: true });
|
|
551
|
+
return () => {
|
|
552
|
+
observer.disconnect();
|
|
553
|
+
};
|
|
529
554
|
}, []);
|
|
530
555
|
useEffect(() => {
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
556
|
+
const observer = new MutationObserver(() => {
|
|
557
|
+
var _a;
|
|
558
|
+
const phantomLib = (_a = window == null ? void 0 : window.phantom) == null ? void 0 : _a.bitcoin;
|
|
559
|
+
if (phantomLib && phantomLib.isPhantom) {
|
|
560
|
+
setHasPhantom(true);
|
|
561
|
+
observer.disconnect();
|
|
562
|
+
} else {
|
|
563
|
+
setHasPhantom(false);
|
|
564
|
+
observer.disconnect();
|
|
565
|
+
}
|
|
566
|
+
});
|
|
567
|
+
observer.observe(document, { childList: true, subtree: true });
|
|
568
|
+
return () => {
|
|
569
|
+
observer.disconnect();
|
|
570
|
+
};
|
|
538
571
|
}, []);
|
|
539
572
|
useEffect(() => {
|
|
540
|
-
const
|
|
541
|
-
|
|
573
|
+
const observer = new MutationObserver(() => {
|
|
574
|
+
const wizzLib = window == null ? void 0 : window.wizz;
|
|
575
|
+
if (wizzLib) {
|
|
576
|
+
setHasWizz(true);
|
|
577
|
+
observer.disconnect();
|
|
578
|
+
}
|
|
579
|
+
});
|
|
580
|
+
observer.observe(document, { childList: true, subtree: true });
|
|
581
|
+
return () => {
|
|
582
|
+
observer.disconnect();
|
|
583
|
+
};
|
|
542
584
|
}, []);
|
|
543
585
|
useEffect(() => {
|
|
544
586
|
setBalance(void 0);
|
|
@@ -822,6 +864,8 @@ var LaserEyesProvider = ({
|
|
|
822
864
|
yield connectUnisat();
|
|
823
865
|
} else if (walletName === XVERSE) {
|
|
824
866
|
yield connectXverse();
|
|
867
|
+
} else if (walletName === LEATHER) {
|
|
868
|
+
yield connectLeather();
|
|
825
869
|
} else {
|
|
826
870
|
throw new Error("Unsupported wallet..");
|
|
827
871
|
}
|
|
@@ -1240,7 +1284,7 @@ var LaserEyesProvider = ({
|
|
|
1240
1284
|
} else if (provider === LEATHER) {
|
|
1241
1285
|
const signed = yield library == null ? void 0 : library.request("signMessage", {
|
|
1242
1286
|
message,
|
|
1243
|
-
paymentType:
|
|
1287
|
+
paymentType: P2WPKH
|
|
1244
1288
|
});
|
|
1245
1289
|
return (_a = signed == null ? void 0 : signed.result) == null ? void 0 : _a.signature;
|
|
1246
1290
|
} else if (provider === PHANTOM) {
|
|
@@ -1269,8 +1313,8 @@ var LaserEyesProvider = ({
|
|
|
1269
1313
|
psbtBase64 = bitcoin2.Psbt.fromHex(psbt).toBase64();
|
|
1270
1314
|
psbtHex = psbt;
|
|
1271
1315
|
} else if (isBase64(psbt)) {
|
|
1272
|
-
psbtHex = bitcoin2.Psbt.fromBase64(psbt).toHex();
|
|
1273
1316
|
psbtBase64 = psbt;
|
|
1317
|
+
psbtHex = bitcoin2.Psbt.fromBase64(psbt).toHex();
|
|
1274
1318
|
} else {
|
|
1275
1319
|
throw new Error("Invalid PSBT format");
|
|
1276
1320
|
}
|
|
@@ -1511,7 +1555,8 @@ var LaserEyesProvider = ({
|
|
|
1511
1555
|
} else if (provider === LEATHER) {
|
|
1512
1556
|
const requestParams = {
|
|
1513
1557
|
hex: psbtHex,
|
|
1514
|
-
broadcast
|
|
1558
|
+
broadcast,
|
|
1559
|
+
network
|
|
1515
1560
|
};
|
|
1516
1561
|
const response = yield library == null ? void 0 : library.request(
|
|
1517
1562
|
"signPsbt",
|
|
@@ -1519,7 +1564,7 @@ var LaserEyesProvider = ({
|
|
|
1519
1564
|
);
|
|
1520
1565
|
const leatherHexResult = response.result;
|
|
1521
1566
|
const signedTx = leatherHexResult.hex;
|
|
1522
|
-
const signed = bitcoin2.Psbt.
|
|
1567
|
+
const signed = bitcoin2.Psbt.fromHex(String(signedTx));
|
|
1523
1568
|
if (finalize && broadcast) {
|
|
1524
1569
|
const finalized = signed.finalizeAllInputs();
|
|
1525
1570
|
const extracted = finalized.extractTransaction();
|
|
@@ -1582,7 +1627,9 @@ var LaserEyesProvider = ({
|
|
|
1582
1627
|
} else if (provider === MAGIC_EDEN) {
|
|
1583
1628
|
return yield axios2.post("https://mempool.space/api/tx", psbt).then((res) => res.data);
|
|
1584
1629
|
} else if (provider === LEATHER) {
|
|
1585
|
-
|
|
1630
|
+
const decoded = bitcoin2.Psbt.fromHex(psbt);
|
|
1631
|
+
const extracted = decoded.extractTransaction();
|
|
1632
|
+
return yield axios2.post("https://mempool.space/api/tx", extracted.toHex()).then((res) => res.data);
|
|
1586
1633
|
} else if (provider === WIZZ) {
|
|
1587
1634
|
return yield library == null ? void 0 : library.pushPsbt(psbt);
|
|
1588
1635
|
} else {
|
|
@@ -1800,6 +1847,7 @@ export {
|
|
|
1800
1847
|
LaserEyesProvider,
|
|
1801
1848
|
MAGIC_EDEN,
|
|
1802
1849
|
MAINNET,
|
|
1850
|
+
MEMPOOL_SPACE_SIGNET_URL,
|
|
1803
1851
|
MEMPOOL_SPACE_TESTNET_URL,
|
|
1804
1852
|
MEMPOOL_SPACE_URL,
|
|
1805
1853
|
OKX,
|
|
@@ -1826,6 +1874,7 @@ export {
|
|
|
1826
1874
|
XVERSE,
|
|
1827
1875
|
XVERSE_MAINNET,
|
|
1828
1876
|
XVERSE_NETWORK,
|
|
1877
|
+
XVERSE_SIGNET,
|
|
1829
1878
|
XVERSE_TESTNET,
|
|
1830
1879
|
createConfig,
|
|
1831
1880
|
createSendBtcPsbt,
|
|
@@ -1833,8 +1882,6 @@ export {
|
|
|
1833
1882
|
estimateTxSize,
|
|
1834
1883
|
findOrdinalsAddress,
|
|
1835
1884
|
findPaymentAddress,
|
|
1836
|
-
getAddressType,
|
|
1837
|
-
getAddressUtxos,
|
|
1838
1885
|
getBTCBalance,
|
|
1839
1886
|
getBitcoinNetwork,
|
|
1840
1887
|
getLeatherNetwork,
|