@omnisat/lasereyes 0.0.44 → 0.0.46
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 +4 -41
- package/dist/index.js +34 -179
- package/dist/index.mjs +34 -178
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -27,14 +27,14 @@ declare const MAINNET = "mainnet";
|
|
|
27
27
|
declare const SIGNET = "signet";
|
|
28
28
|
declare const TESTNET = "testnet";
|
|
29
29
|
declare const TESTNET4 = "testnet4";
|
|
30
|
-
declare const FRACTAL_MAINNET = "
|
|
31
|
-
declare const FRACTAL_TESTNET = "
|
|
30
|
+
declare const FRACTAL_MAINNET = "fractal mainnet";
|
|
31
|
+
declare const FRACTAL_TESTNET = "fractal testnet";
|
|
32
32
|
declare const REGTEST = "regtest";
|
|
33
33
|
declare const getXverseNetwork: (network: string) => "Mainnet" | "Testnet" | "Signet";
|
|
34
34
|
declare const getLeatherNetwork: (network: string) => "testnet" | "mainnet";
|
|
35
35
|
declare const getUnisatNetwork: (network: string) => "BITCOIN_MAINNET" | "BITCOIN_TESTNET" | "BITCOIN_TESTNET4" | "BITCOIN_SIGNET" | "FRACTAL_BITCOIN_MAINNET" | "FRACTAL_BITCOIN_TESTNET";
|
|
36
36
|
declare const getWizzNetwork: (network: string) => "livenet" | "testnet" | "testnet4" | "signet";
|
|
37
|
-
declare const getNetworkForUnisat: (network: string) => "testnet" | "testnet4" | "signet" | "mainnet" | "
|
|
37
|
+
declare const getNetworkForUnisat: (network: string) => "testnet" | "testnet4" | "signet" | "mainnet" | "fractal mainnet" | "fractal testnet";
|
|
38
38
|
declare const getNetworkForXverse: (network: string) => "testnet" | "mainnet";
|
|
39
39
|
declare const getNetworkForLeather: (network: string) => "testnet" | "mainnet";
|
|
40
40
|
declare const getNetworkForOkx: (network: string) => "testnet" | "mainnet";
|
|
@@ -139,13 +139,6 @@ interface MempoolUtxo {
|
|
|
139
139
|
};
|
|
140
140
|
value: number;
|
|
141
141
|
}
|
|
142
|
-
interface CommitPsbtResponse {
|
|
143
|
-
inscriberAddress: string;
|
|
144
|
-
psbtHex: string;
|
|
145
|
-
psbtBase64: string;
|
|
146
|
-
feeRate: number;
|
|
147
|
-
totalFees: number;
|
|
148
|
-
}
|
|
149
142
|
|
|
150
143
|
declare const createConfig: (config: Config) => Config;
|
|
151
144
|
|
|
@@ -171,36 +164,6 @@ declare function createSendBtcPsbt(address: string, paymentAddress: string, reci
|
|
|
171
164
|
declare function getRedeemScript(paymentPublicKey: string, network: typeof MAINNET | typeof TESTNET | typeof TESTNET4 | typeof SIGNET | typeof FRACTAL_MAINNET | typeof FRACTAL_TESTNET): Buffer | undefined;
|
|
172
165
|
declare function delay(ms: number): Promise<unknown>;
|
|
173
166
|
|
|
174
|
-
declare const useInscriber: ({ inscribeApiUrl, }: {
|
|
175
|
-
inscribeApiUrl: string;
|
|
176
|
-
}) => {
|
|
177
|
-
content: any;
|
|
178
|
-
setContent: React.Dispatch<any>;
|
|
179
|
-
setMimeType: React.Dispatch<React.SetStateAction<"text/plain;charset=utf-8">>;
|
|
180
|
-
previewUrl: string;
|
|
181
|
-
setPreviewUrl: React.Dispatch<React.SetStateAction<string>>;
|
|
182
|
-
getCommitPsbt: () => Promise<CommitPsbtResponse>;
|
|
183
|
-
isFetchingCommitPsbt: boolean;
|
|
184
|
-
commitPsbtHex: string;
|
|
185
|
-
commitPsbtBase64: string;
|
|
186
|
-
handleSignCommit: (tx?: string) => Promise<string | undefined>;
|
|
187
|
-
commitTxId: string;
|
|
188
|
-
setCommitTxId: React.Dispatch<React.SetStateAction<string>>;
|
|
189
|
-
feeRate: number;
|
|
190
|
-
setFeeRate: React.Dispatch<React.SetStateAction<number>>;
|
|
191
|
-
totalFees: number;
|
|
192
|
-
inscriberAddress: string;
|
|
193
|
-
inscribe: ({ content: providedContent, mimeType: providedMimeType, ordinalAddress: providedAddress, commitTxId: providedCommitTxId, }: {
|
|
194
|
-
content?: any;
|
|
195
|
-
mimeType?: string | undefined;
|
|
196
|
-
ordinalAddress?: string | undefined;
|
|
197
|
-
commitTxId?: string | undefined;
|
|
198
|
-
}) => Promise<string>;
|
|
199
|
-
isInscribing: boolean;
|
|
200
|
-
inscriptionTxId: string;
|
|
201
|
-
reset: () => void;
|
|
202
|
-
};
|
|
203
|
-
|
|
204
167
|
interface OylLogoProps extends React.SVGProps<SVGSVGElement> {
|
|
205
168
|
size?: number;
|
|
206
169
|
variant?: "first" | "second";
|
|
@@ -256,4 +219,4 @@ declare const WalletIcon: ({ size, className, variant, walletName, }: {
|
|
|
256
219
|
walletName: typeof XVERSE | typeof WIZZ | typeof LEATHER | typeof MAGIC_EDEN | typeof OKX | typeof PHANTOM | typeof UNISAT | typeof OYL;
|
|
257
220
|
}) => react_jsx_runtime.JSX.Element;
|
|
258
221
|
|
|
259
|
-
export { FRACTAL_MAINNET, FRACTAL_TESTNET, LEATHER, LEATHER_MAINNET, LEATHER_TESTNET, LaserEyesProvider, LeatherLogo, MAGIC_EDEN, MAINNET, MEMPOOL_SPACE_SIGNET_URL, MEMPOOL_SPACE_TESTNET_URL, MEMPOOL_SPACE_URL, MagicEdenLogo, OKX, OKX_MAINNET, OKX_TESTNET, OP_WALLET_MAINNET, OP_WALLET_TESTNET, OYL, OkxLogo, OylLogo, P2PKH, P2PSH, P2SH, P2TR, P2WPKH, P2WSH, PHANTOM, PhantomLogo, REGTEST, SIGNET, TESTNET, TESTNET4, UNISAT, UNISAT_FRACTAL_MAINNET, UNISAT_FRACTAL_TESTNET, UNISAT_MAINNET, UNISAT_SIGNET, UNISAT_TESTNET, UNISAT_TESTNET4, UnisatLogo, WALLETS, WIZZ, WIZZ_MAINNET, WIZZ_SIGNET, WIZZ_TESTNET, WIZZ_TESTNET4, WalletIcon, WizzLogo, XVERSE, XVERSE_MAINNET, XVERSE_NETWORK, XVERSE_SIGNET, XVERSE_TESTNET, XverseLogo, createConfig, createSendBtcPsbt, delay, estimateTxSize, findOrdinalsAddress, findPaymentAddress, getAddressUtxos, getBTCBalance, getBitcoinNetwork, getLeatherNetwork, getMempoolSpaceUrl, getNetworkForLeather, getNetworkForOkx, getNetworkForUnisat, getNetworkForWizz, getNetworkForXverse, getRedeemScript, getUnisatNetwork, getWizzNetwork, getXverseNetwork, isBase64, isHex, satoshisToBTC,
|
|
222
|
+
export { FRACTAL_MAINNET, FRACTAL_TESTNET, LEATHER, LEATHER_MAINNET, LEATHER_TESTNET, LaserEyesProvider, LeatherLogo, MAGIC_EDEN, MAINNET, MEMPOOL_SPACE_SIGNET_URL, MEMPOOL_SPACE_TESTNET_URL, MEMPOOL_SPACE_URL, MagicEdenLogo, OKX, OKX_MAINNET, OKX_TESTNET, OP_WALLET_MAINNET, OP_WALLET_TESTNET, OYL, OkxLogo, OylLogo, P2PKH, P2PSH, P2SH, P2TR, P2WPKH, P2WSH, PHANTOM, PhantomLogo, REGTEST, SIGNET, TESTNET, TESTNET4, UNISAT, UNISAT_FRACTAL_MAINNET, UNISAT_FRACTAL_TESTNET, UNISAT_MAINNET, UNISAT_SIGNET, UNISAT_TESTNET, UNISAT_TESTNET4, UnisatLogo, WALLETS, WIZZ, WIZZ_MAINNET, WIZZ_SIGNET, WIZZ_TESTNET, WIZZ_TESTNET4, WalletIcon, WizzLogo, XVERSE, XVERSE_MAINNET, XVERSE_NETWORK, XVERSE_SIGNET, XVERSE_TESTNET, XverseLogo, createConfig, createSendBtcPsbt, delay, estimateTxSize, findOrdinalsAddress, findPaymentAddress, getAddressUtxos, getBTCBalance, getBitcoinNetwork, getLeatherNetwork, getMempoolSpaceUrl, getNetworkForLeather, getNetworkForOkx, getNetworkForUnisat, getNetworkForWizz, getNetworkForXverse, getRedeemScript, getUnisatNetwork, getWizzNetwork, getXverseNetwork, isBase64, isHex, satoshisToBTC, useLaserEyes };
|
package/dist/index.js
CHANGED
|
@@ -166,7 +166,6 @@ __export(src_exports, {
|
|
|
166
166
|
isBase64: () => isBase64,
|
|
167
167
|
isHex: () => isHex,
|
|
168
168
|
satoshisToBTC: () => satoshisToBTC,
|
|
169
|
-
useInscriber: () => useInscriber,
|
|
170
169
|
useLaserEyes: () => useLaserEyes
|
|
171
170
|
});
|
|
172
171
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -196,8 +195,8 @@ var MAINNET = "mainnet";
|
|
|
196
195
|
var SIGNET = "signet";
|
|
197
196
|
var TESTNET = "testnet";
|
|
198
197
|
var TESTNET4 = "testnet4";
|
|
199
|
-
var FRACTAL_MAINNET = "
|
|
200
|
-
var FRACTAL_TESTNET = "
|
|
198
|
+
var FRACTAL_MAINNET = "fractal mainnet";
|
|
199
|
+
var FRACTAL_TESTNET = "fractal testnet";
|
|
201
200
|
var REGTEST = "regtest";
|
|
202
201
|
var getXverseNetwork = (network) => {
|
|
203
202
|
if (network === MAINNET)
|
|
@@ -499,7 +498,6 @@ function estimateTxSize(taprootInputCount, nonTaprootInputCount, outputCount) {
|
|
|
499
498
|
function getAddressUtxos(address2, network) {
|
|
500
499
|
return __async(this, null, function* () {
|
|
501
500
|
if (address2.startsWith("t")) {
|
|
502
|
-
console.log("starts with t");
|
|
503
501
|
if (network === MAINNET) {
|
|
504
502
|
return [];
|
|
505
503
|
}
|
|
@@ -1338,10 +1336,12 @@ var LaserEyesProvider = ({
|
|
|
1338
1336
|
}), [address2, provider, library]);
|
|
1339
1337
|
const switchNetwork = (network2) => __async(void 0, null, function* () {
|
|
1340
1338
|
try {
|
|
1339
|
+
console.log({ network: network2 });
|
|
1341
1340
|
if (!library)
|
|
1342
1341
|
return;
|
|
1343
1342
|
if (provider === UNISAT) {
|
|
1344
1343
|
const wantedNetwork = getUnisatNetwork(network2);
|
|
1344
|
+
console.log("wantedNetwork", wantedNetwork);
|
|
1345
1345
|
yield library == null ? void 0 : library.switchChain(wantedNetwork);
|
|
1346
1346
|
setNetwork(network2);
|
|
1347
1347
|
} else if (provider === WIZZ) {
|
|
@@ -1380,33 +1380,49 @@ var LaserEyesProvider = ({
|
|
|
1380
1380
|
throw error;
|
|
1381
1381
|
}
|
|
1382
1382
|
});
|
|
1383
|
-
const getBalance = () => __async(void 0, null, function* () {
|
|
1383
|
+
const getBalance = (0, import_react.useCallback)(() => __async(void 0, null, function* () {
|
|
1384
1384
|
try {
|
|
1385
1385
|
if (!library)
|
|
1386
1386
|
return;
|
|
1387
1387
|
if (provider === UNISAT) {
|
|
1388
|
-
|
|
1388
|
+
const bal = yield library.getBalance();
|
|
1389
|
+
setBalance(bal.total);
|
|
1390
|
+
return bal.total;
|
|
1389
1391
|
} else if (provider === XVERSE) {
|
|
1390
|
-
|
|
1392
|
+
const bal = yield getBTCBalance(paymentAddress, network);
|
|
1393
|
+
setBalance(bal);
|
|
1394
|
+
return bal;
|
|
1391
1395
|
} else if (provider === OYL) {
|
|
1392
1396
|
const balanceResponse = yield library.getBalance();
|
|
1393
|
-
|
|
1397
|
+
const bal = balanceResponse.btc.total * 1e8;
|
|
1398
|
+
setBalance(bal);
|
|
1399
|
+
return bal;
|
|
1394
1400
|
} else if (provider === MAGIC_EDEN) {
|
|
1395
|
-
|
|
1401
|
+
const bal = yield getBTCBalance(paymentAddress, network);
|
|
1402
|
+
setBalance(bal);
|
|
1403
|
+
return bal;
|
|
1396
1404
|
} else if (provider === OKX) {
|
|
1397
|
-
|
|
1405
|
+
const bal = yield getBTCBalance(paymentAddress, network);
|
|
1406
|
+
setBalance(bal);
|
|
1407
|
+
return bal;
|
|
1398
1408
|
} else if (provider === LEATHER) {
|
|
1399
|
-
|
|
1409
|
+
const bal = yield getBTCBalance(paymentAddress, network);
|
|
1410
|
+
setBalance(bal);
|
|
1411
|
+
return bal;
|
|
1400
1412
|
} else if (provider === PHANTOM) {
|
|
1401
|
-
|
|
1413
|
+
const bal = yield getBTCBalance(paymentAddress, network);
|
|
1414
|
+
setBalance(bal);
|
|
1415
|
+
return bal;
|
|
1402
1416
|
} else if (provider === WIZZ) {
|
|
1403
1417
|
const balanceResponse = yield library.getBalance();
|
|
1404
|
-
|
|
1418
|
+
const bal = balanceResponse.total;
|
|
1419
|
+
setBalance(bal);
|
|
1420
|
+
return bal;
|
|
1405
1421
|
}
|
|
1406
1422
|
} catch (error) {
|
|
1407
1423
|
throw error;
|
|
1408
1424
|
}
|
|
1409
|
-
});
|
|
1425
|
+
}), [provider, library, paymentAddress, network]);
|
|
1410
1426
|
const getInscriptions = () => __async(void 0, null, function* () {
|
|
1411
1427
|
try {
|
|
1412
1428
|
if (!library)
|
|
@@ -1924,11 +1940,11 @@ var LaserEyesProvider = ({
|
|
|
1924
1940
|
if (!library)
|
|
1925
1941
|
return;
|
|
1926
1942
|
if (provider === UNISAT) {
|
|
1927
|
-
return yield
|
|
1943
|
+
return yield import_axios2.default.post(`${getMempoolSpaceUrl2(network)}/api/tx`, psbt).then((res) => res.data);
|
|
1928
1944
|
} else if (provider === OYL) {
|
|
1929
|
-
return yield
|
|
1945
|
+
return yield import_axios2.default.post(`${getMempoolSpaceUrl2(network)}/api/tx`, psbt).then((res) => res.data);
|
|
1930
1946
|
} else if (provider === OKX) {
|
|
1931
|
-
return yield
|
|
1947
|
+
return yield import_axios2.default.post(`${getMempoolSpaceUrl2(network)}/api/tx`, psbt).then((res) => res.data);
|
|
1932
1948
|
} else if (provider === MAGIC_EDEN) {
|
|
1933
1949
|
return yield import_axios2.default.post(`${getMempoolSpaceUrl2(network)}/api/tx`, psbt).then((res) => res.data);
|
|
1934
1950
|
} else if (provider === LEATHER) {
|
|
@@ -1936,7 +1952,7 @@ var LaserEyesProvider = ({
|
|
|
1936
1952
|
const extracted = decoded.extractTransaction();
|
|
1937
1953
|
return yield import_axios2.default.post(`${getMempoolSpaceUrl2(network)}/api/tx`, extracted.toHex()).then((res) => res.data);
|
|
1938
1954
|
} else if (provider === WIZZ) {
|
|
1939
|
-
return yield
|
|
1955
|
+
return yield import_axios2.default.post(`${getMempoolSpaceUrl2(network)}/api/tx`, psbt).then((res) => res.data);
|
|
1940
1956
|
} else {
|
|
1941
1957
|
throw new Error("The connected wallet doesn't support this method..");
|
|
1942
1958
|
}
|
|
@@ -1987,166 +2003,6 @@ var LaserEyesProvider = ({
|
|
|
1987
2003
|
);
|
|
1988
2004
|
};
|
|
1989
2005
|
|
|
1990
|
-
// src/hooks/useInscriber.ts
|
|
1991
|
-
var import_react2 = require("react");
|
|
1992
|
-
|
|
1993
|
-
// src/consts/inscribe.ts
|
|
1994
|
-
var MIME_TYPE_TEXT = "text/plain;charset=utf-8";
|
|
1995
|
-
|
|
1996
|
-
// src/hooks/useInscriber.ts
|
|
1997
|
-
var import_axios3 = __toESM(require("axios"));
|
|
1998
|
-
var DESCRIBE_API_URL = "http://localhost:3000/api";
|
|
1999
|
-
var useInscriber = ({
|
|
2000
|
-
inscribeApiUrl = DESCRIBE_API_URL
|
|
2001
|
-
}) => {
|
|
2002
|
-
const { address: address2, paymentAddress, paymentPublicKey, publicKey, signPsbt } = useLaserEyes();
|
|
2003
|
-
const [content, setContent] = (0, import_react2.useState)("");
|
|
2004
|
-
const [mimeType, setMimeType] = (0, import_react2.useState)(MIME_TYPE_TEXT);
|
|
2005
|
-
const [commitPsbtHex, setCommitPsbtHex] = (0, import_react2.useState)("");
|
|
2006
|
-
const [commitPsbtBase64, setCommitPsbtBase64] = (0, import_react2.useState)("");
|
|
2007
|
-
const [commitTxId, setCommitTxId] = (0, import_react2.useState)("");
|
|
2008
|
-
const [feeRate, setFeeRate] = (0, import_react2.useState)(10);
|
|
2009
|
-
const [totalFees, setTotalFees] = (0, import_react2.useState)(0);
|
|
2010
|
-
const [inscriberAddress, setInscriberAddress] = (0, import_react2.useState)("");
|
|
2011
|
-
const [inscriptionTxId, setInscriptionTxId] = (0, import_react2.useState)("");
|
|
2012
|
-
const [previewUrl, setPreviewUrl] = (0, import_react2.useState)("");
|
|
2013
|
-
const [isFetchingCommitPsbt, setIsFetchingCommitPsbt] = (0, import_react2.useState)(false);
|
|
2014
|
-
const [isInscribing, setIsInscribing] = (0, import_react2.useState)(false);
|
|
2015
|
-
(0, import_react2.useEffect)(() => {
|
|
2016
|
-
setCommitPsbtHex("");
|
|
2017
|
-
setCommitPsbtBase64("");
|
|
2018
|
-
setCommitTxId("");
|
|
2019
|
-
}, [content, address2, mimeType, feeRate]);
|
|
2020
|
-
const getCommitPsbt = (0, import_react2.useCallback)(() => __async(void 0, null, function* () {
|
|
2021
|
-
try {
|
|
2022
|
-
if (!content)
|
|
2023
|
-
throw new Error("missing content");
|
|
2024
|
-
if (!paymentAddress)
|
|
2025
|
-
throw new Error("missing paymentAddress");
|
|
2026
|
-
if (!paymentPublicKey)
|
|
2027
|
-
throw new Error("missing paymentPublicKey");
|
|
2028
|
-
if (!feeRate)
|
|
2029
|
-
throw new Error("missing feeRate");
|
|
2030
|
-
if (!mimeType)
|
|
2031
|
-
throw new Error("missing mimeType");
|
|
2032
|
-
setIsFetchingCommitPsbt(true);
|
|
2033
|
-
return yield import_axios3.default.post(`${inscribeApiUrl}/create-inscription`, {
|
|
2034
|
-
content,
|
|
2035
|
-
paymentAddress,
|
|
2036
|
-
paymentPublicKey,
|
|
2037
|
-
feeRate,
|
|
2038
|
-
mimeType
|
|
2039
|
-
}).then((res) => res.data).then((data) => {
|
|
2040
|
-
setCommitPsbtHex(data.psbtHex);
|
|
2041
|
-
setCommitPsbtBase64(data.psbtBase64);
|
|
2042
|
-
setFeeRate(feeRate);
|
|
2043
|
-
setTotalFees(data.totalFees);
|
|
2044
|
-
setInscriberAddress(data.inscriberAddress);
|
|
2045
|
-
return data;
|
|
2046
|
-
});
|
|
2047
|
-
} catch (e) {
|
|
2048
|
-
console.error(e);
|
|
2049
|
-
throw new Error(e.response.data);
|
|
2050
|
-
} finally {
|
|
2051
|
-
setIsFetchingCommitPsbt(false);
|
|
2052
|
-
}
|
|
2053
|
-
}), [paymentAddress, paymentPublicKey, content, feeRate, mimeType, publicKey]);
|
|
2054
|
-
const handleSignCommit = (tx) => __async(void 0, null, function* () {
|
|
2055
|
-
try {
|
|
2056
|
-
const toBeSigned = tx != null ? tx : commitPsbtHex;
|
|
2057
|
-
if (!toBeSigned)
|
|
2058
|
-
throw new Error("missing tx");
|
|
2059
|
-
const signedResponse = yield signPsbt(toBeSigned, true, true);
|
|
2060
|
-
setCommitTxId(signedResponse == null ? void 0 : signedResponse.txId);
|
|
2061
|
-
return signedResponse == null ? void 0 : signedResponse.txId;
|
|
2062
|
-
} catch (e) {
|
|
2063
|
-
console.error(e);
|
|
2064
|
-
throw e;
|
|
2065
|
-
}
|
|
2066
|
-
});
|
|
2067
|
-
const inscribe = (0, import_react2.useCallback)(
|
|
2068
|
-
(_0) => __async(void 0, [_0], function* ({
|
|
2069
|
-
content: providedContent,
|
|
2070
|
-
mimeType: providedMimeType,
|
|
2071
|
-
ordinalAddress: providedAddress,
|
|
2072
|
-
commitTxId: providedCommitTxId
|
|
2073
|
-
}) {
|
|
2074
|
-
try {
|
|
2075
|
-
const inscribeContent = providedContent != null ? providedContent : content;
|
|
2076
|
-
const inscribeMimeType = providedMimeType != null ? providedMimeType : mimeType;
|
|
2077
|
-
const inscribeOutputAddress = providedAddress != null ? providedAddress : address2;
|
|
2078
|
-
let inscribeCommitTxId = providedCommitTxId != null ? providedCommitTxId : commitTxId;
|
|
2079
|
-
if (!inscribeContent)
|
|
2080
|
-
throw new Error("missing content");
|
|
2081
|
-
if (!inscribeMimeType)
|
|
2082
|
-
throw new Error("missing mimeType");
|
|
2083
|
-
if (!inscribeOutputAddress)
|
|
2084
|
-
throw new Error("missing address");
|
|
2085
|
-
setIsInscribing(true);
|
|
2086
|
-
if (!inscribeCommitTxId) {
|
|
2087
|
-
const signed = yield getCommitPsbt();
|
|
2088
|
-
inscribeCommitTxId = yield handleSignCommit(signed.psbtBase64);
|
|
2089
|
-
if (!inscribeCommitTxId)
|
|
2090
|
-
throw new Error("failed to broadcast commit");
|
|
2091
|
-
console.log("tempCommitTxId", inscribeCommitTxId);
|
|
2092
|
-
}
|
|
2093
|
-
yield delay(1e4);
|
|
2094
|
-
if (!inscribeCommitTxId)
|
|
2095
|
-
throw new Error("missing commitTxId");
|
|
2096
|
-
return yield import_axios3.default.post(`${inscribeApiUrl}/inscribe`, {
|
|
2097
|
-
content,
|
|
2098
|
-
mimeType,
|
|
2099
|
-
ordinalAddress: address2,
|
|
2100
|
-
commitTxId: inscribeCommitTxId
|
|
2101
|
-
}).then((res) => res.data).then((data) => {
|
|
2102
|
-
setInscriptionTxId(data);
|
|
2103
|
-
return data;
|
|
2104
|
-
});
|
|
2105
|
-
} catch (e) {
|
|
2106
|
-
console.error(e);
|
|
2107
|
-
throw e;
|
|
2108
|
-
} finally {
|
|
2109
|
-
setIsInscribing(false);
|
|
2110
|
-
}
|
|
2111
|
-
}),
|
|
2112
|
-
[address2, commitTxId, content, mimeType]
|
|
2113
|
-
);
|
|
2114
|
-
const reset = () => {
|
|
2115
|
-
setContent("");
|
|
2116
|
-
setMimeType(MIME_TYPE_TEXT);
|
|
2117
|
-
setCommitPsbtHex("");
|
|
2118
|
-
setCommitPsbtBase64("");
|
|
2119
|
-
setCommitTxId("");
|
|
2120
|
-
setFeeRate(10);
|
|
2121
|
-
setTotalFees(0);
|
|
2122
|
-
setInscriberAddress("");
|
|
2123
|
-
setInscriptionTxId("");
|
|
2124
|
-
setPreviewUrl("");
|
|
2125
|
-
};
|
|
2126
|
-
return {
|
|
2127
|
-
content,
|
|
2128
|
-
setContent,
|
|
2129
|
-
setMimeType,
|
|
2130
|
-
previewUrl,
|
|
2131
|
-
setPreviewUrl,
|
|
2132
|
-
getCommitPsbt,
|
|
2133
|
-
isFetchingCommitPsbt,
|
|
2134
|
-
commitPsbtHex,
|
|
2135
|
-
commitPsbtBase64,
|
|
2136
|
-
handleSignCommit,
|
|
2137
|
-
commitTxId,
|
|
2138
|
-
setCommitTxId,
|
|
2139
|
-
feeRate,
|
|
2140
|
-
setFeeRate,
|
|
2141
|
-
totalFees,
|
|
2142
|
-
inscriberAddress,
|
|
2143
|
-
inscribe,
|
|
2144
|
-
isInscribing,
|
|
2145
|
-
inscriptionTxId,
|
|
2146
|
-
reset
|
|
2147
|
-
};
|
|
2148
|
-
};
|
|
2149
|
-
|
|
2150
2006
|
// src/icons/oyl.tsx
|
|
2151
2007
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
2152
2008
|
var OylLogo = (_a) => {
|
|
@@ -2827,6 +2683,5 @@ var WalletIcon = ({
|
|
|
2827
2683
|
isBase64,
|
|
2828
2684
|
isHex,
|
|
2829
2685
|
satoshisToBTC,
|
|
2830
|
-
useInscriber,
|
|
2831
2686
|
useLaserEyes
|
|
2832
2687
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -84,8 +84,8 @@ var MAINNET = "mainnet";
|
|
|
84
84
|
var SIGNET = "signet";
|
|
85
85
|
var TESTNET = "testnet";
|
|
86
86
|
var TESTNET4 = "testnet4";
|
|
87
|
-
var FRACTAL_MAINNET = "
|
|
88
|
-
var FRACTAL_TESTNET = "
|
|
87
|
+
var FRACTAL_MAINNET = "fractal mainnet";
|
|
88
|
+
var FRACTAL_TESTNET = "fractal testnet";
|
|
89
89
|
var REGTEST = "regtest";
|
|
90
90
|
var getXverseNetwork = (network) => {
|
|
91
91
|
if (network === MAINNET)
|
|
@@ -394,7 +394,6 @@ function estimateTxSize(taprootInputCount, nonTaprootInputCount, outputCount) {
|
|
|
394
394
|
function getAddressUtxos(address2, network) {
|
|
395
395
|
return __async(this, null, function* () {
|
|
396
396
|
if (address2.startsWith("t")) {
|
|
397
|
-
console.log("starts with t");
|
|
398
397
|
if (network === MAINNET) {
|
|
399
398
|
return [];
|
|
400
399
|
}
|
|
@@ -1242,10 +1241,12 @@ var LaserEyesProvider = ({
|
|
|
1242
1241
|
}), [address2, provider, library]);
|
|
1243
1242
|
const switchNetwork = (network2) => __async(void 0, null, function* () {
|
|
1244
1243
|
try {
|
|
1244
|
+
console.log({ network: network2 });
|
|
1245
1245
|
if (!library)
|
|
1246
1246
|
return;
|
|
1247
1247
|
if (provider === UNISAT) {
|
|
1248
1248
|
const wantedNetwork = getUnisatNetwork(network2);
|
|
1249
|
+
console.log("wantedNetwork", wantedNetwork);
|
|
1249
1250
|
yield library == null ? void 0 : library.switchChain(wantedNetwork);
|
|
1250
1251
|
setNetwork(network2);
|
|
1251
1252
|
} else if (provider === WIZZ) {
|
|
@@ -1284,33 +1285,49 @@ var LaserEyesProvider = ({
|
|
|
1284
1285
|
throw error;
|
|
1285
1286
|
}
|
|
1286
1287
|
});
|
|
1287
|
-
const getBalance = () => __async(void 0, null, function* () {
|
|
1288
|
+
const getBalance = useCallback(() => __async(void 0, null, function* () {
|
|
1288
1289
|
try {
|
|
1289
1290
|
if (!library)
|
|
1290
1291
|
return;
|
|
1291
1292
|
if (provider === UNISAT) {
|
|
1292
|
-
|
|
1293
|
+
const bal = yield library.getBalance();
|
|
1294
|
+
setBalance(bal.total);
|
|
1295
|
+
return bal.total;
|
|
1293
1296
|
} else if (provider === XVERSE) {
|
|
1294
|
-
|
|
1297
|
+
const bal = yield getBTCBalance(paymentAddress, network);
|
|
1298
|
+
setBalance(bal);
|
|
1299
|
+
return bal;
|
|
1295
1300
|
} else if (provider === OYL) {
|
|
1296
1301
|
const balanceResponse = yield library.getBalance();
|
|
1297
|
-
|
|
1302
|
+
const bal = balanceResponse.btc.total * 1e8;
|
|
1303
|
+
setBalance(bal);
|
|
1304
|
+
return bal;
|
|
1298
1305
|
} else if (provider === MAGIC_EDEN) {
|
|
1299
|
-
|
|
1306
|
+
const bal = yield getBTCBalance(paymentAddress, network);
|
|
1307
|
+
setBalance(bal);
|
|
1308
|
+
return bal;
|
|
1300
1309
|
} else if (provider === OKX) {
|
|
1301
|
-
|
|
1310
|
+
const bal = yield getBTCBalance(paymentAddress, network);
|
|
1311
|
+
setBalance(bal);
|
|
1312
|
+
return bal;
|
|
1302
1313
|
} else if (provider === LEATHER) {
|
|
1303
|
-
|
|
1314
|
+
const bal = yield getBTCBalance(paymentAddress, network);
|
|
1315
|
+
setBalance(bal);
|
|
1316
|
+
return bal;
|
|
1304
1317
|
} else if (provider === PHANTOM) {
|
|
1305
|
-
|
|
1318
|
+
const bal = yield getBTCBalance(paymentAddress, network);
|
|
1319
|
+
setBalance(bal);
|
|
1320
|
+
return bal;
|
|
1306
1321
|
} else if (provider === WIZZ) {
|
|
1307
1322
|
const balanceResponse = yield library.getBalance();
|
|
1308
|
-
|
|
1323
|
+
const bal = balanceResponse.total;
|
|
1324
|
+
setBalance(bal);
|
|
1325
|
+
return bal;
|
|
1309
1326
|
}
|
|
1310
1327
|
} catch (error) {
|
|
1311
1328
|
throw error;
|
|
1312
1329
|
}
|
|
1313
|
-
});
|
|
1330
|
+
}), [provider, library, paymentAddress, network]);
|
|
1314
1331
|
const getInscriptions = () => __async(void 0, null, function* () {
|
|
1315
1332
|
try {
|
|
1316
1333
|
if (!library)
|
|
@@ -1828,11 +1845,11 @@ var LaserEyesProvider = ({
|
|
|
1828
1845
|
if (!library)
|
|
1829
1846
|
return;
|
|
1830
1847
|
if (provider === UNISAT) {
|
|
1831
|
-
return yield
|
|
1848
|
+
return yield axios2.post(`${getMempoolSpaceUrl2(network)}/api/tx`, psbt).then((res) => res.data);
|
|
1832
1849
|
} else if (provider === OYL) {
|
|
1833
|
-
return yield
|
|
1850
|
+
return yield axios2.post(`${getMempoolSpaceUrl2(network)}/api/tx`, psbt).then((res) => res.data);
|
|
1834
1851
|
} else if (provider === OKX) {
|
|
1835
|
-
return yield
|
|
1852
|
+
return yield axios2.post(`${getMempoolSpaceUrl2(network)}/api/tx`, psbt).then((res) => res.data);
|
|
1836
1853
|
} else if (provider === MAGIC_EDEN) {
|
|
1837
1854
|
return yield axios2.post(`${getMempoolSpaceUrl2(network)}/api/tx`, psbt).then((res) => res.data);
|
|
1838
1855
|
} else if (provider === LEATHER) {
|
|
@@ -1840,7 +1857,7 @@ var LaserEyesProvider = ({
|
|
|
1840
1857
|
const extracted = decoded.extractTransaction();
|
|
1841
1858
|
return yield axios2.post(`${getMempoolSpaceUrl2(network)}/api/tx`, extracted.toHex()).then((res) => res.data);
|
|
1842
1859
|
} else if (provider === WIZZ) {
|
|
1843
|
-
return yield
|
|
1860
|
+
return yield axios2.post(`${getMempoolSpaceUrl2(network)}/api/tx`, psbt).then((res) => res.data);
|
|
1844
1861
|
} else {
|
|
1845
1862
|
throw new Error("The connected wallet doesn't support this method..");
|
|
1846
1863
|
}
|
|
@@ -1891,166 +1908,6 @@ var LaserEyesProvider = ({
|
|
|
1891
1908
|
);
|
|
1892
1909
|
};
|
|
1893
1910
|
|
|
1894
|
-
// src/hooks/useInscriber.ts
|
|
1895
|
-
import { useCallback as useCallback2, useEffect as useEffect2, useState as useState2 } from "react";
|
|
1896
|
-
|
|
1897
|
-
// src/consts/inscribe.ts
|
|
1898
|
-
var MIME_TYPE_TEXT = "text/plain;charset=utf-8";
|
|
1899
|
-
|
|
1900
|
-
// src/hooks/useInscriber.ts
|
|
1901
|
-
import axios3 from "axios";
|
|
1902
|
-
var DESCRIBE_API_URL = "http://localhost:3000/api";
|
|
1903
|
-
var useInscriber = ({
|
|
1904
|
-
inscribeApiUrl = DESCRIBE_API_URL
|
|
1905
|
-
}) => {
|
|
1906
|
-
const { address: address2, paymentAddress, paymentPublicKey, publicKey, signPsbt } = useLaserEyes();
|
|
1907
|
-
const [content, setContent] = useState2("");
|
|
1908
|
-
const [mimeType, setMimeType] = useState2(MIME_TYPE_TEXT);
|
|
1909
|
-
const [commitPsbtHex, setCommitPsbtHex] = useState2("");
|
|
1910
|
-
const [commitPsbtBase64, setCommitPsbtBase64] = useState2("");
|
|
1911
|
-
const [commitTxId, setCommitTxId] = useState2("");
|
|
1912
|
-
const [feeRate, setFeeRate] = useState2(10);
|
|
1913
|
-
const [totalFees, setTotalFees] = useState2(0);
|
|
1914
|
-
const [inscriberAddress, setInscriberAddress] = useState2("");
|
|
1915
|
-
const [inscriptionTxId, setInscriptionTxId] = useState2("");
|
|
1916
|
-
const [previewUrl, setPreviewUrl] = useState2("");
|
|
1917
|
-
const [isFetchingCommitPsbt, setIsFetchingCommitPsbt] = useState2(false);
|
|
1918
|
-
const [isInscribing, setIsInscribing] = useState2(false);
|
|
1919
|
-
useEffect2(() => {
|
|
1920
|
-
setCommitPsbtHex("");
|
|
1921
|
-
setCommitPsbtBase64("");
|
|
1922
|
-
setCommitTxId("");
|
|
1923
|
-
}, [content, address2, mimeType, feeRate]);
|
|
1924
|
-
const getCommitPsbt = useCallback2(() => __async(void 0, null, function* () {
|
|
1925
|
-
try {
|
|
1926
|
-
if (!content)
|
|
1927
|
-
throw new Error("missing content");
|
|
1928
|
-
if (!paymentAddress)
|
|
1929
|
-
throw new Error("missing paymentAddress");
|
|
1930
|
-
if (!paymentPublicKey)
|
|
1931
|
-
throw new Error("missing paymentPublicKey");
|
|
1932
|
-
if (!feeRate)
|
|
1933
|
-
throw new Error("missing feeRate");
|
|
1934
|
-
if (!mimeType)
|
|
1935
|
-
throw new Error("missing mimeType");
|
|
1936
|
-
setIsFetchingCommitPsbt(true);
|
|
1937
|
-
return yield axios3.post(`${inscribeApiUrl}/create-inscription`, {
|
|
1938
|
-
content,
|
|
1939
|
-
paymentAddress,
|
|
1940
|
-
paymentPublicKey,
|
|
1941
|
-
feeRate,
|
|
1942
|
-
mimeType
|
|
1943
|
-
}).then((res) => res.data).then((data) => {
|
|
1944
|
-
setCommitPsbtHex(data.psbtHex);
|
|
1945
|
-
setCommitPsbtBase64(data.psbtBase64);
|
|
1946
|
-
setFeeRate(feeRate);
|
|
1947
|
-
setTotalFees(data.totalFees);
|
|
1948
|
-
setInscriberAddress(data.inscriberAddress);
|
|
1949
|
-
return data;
|
|
1950
|
-
});
|
|
1951
|
-
} catch (e) {
|
|
1952
|
-
console.error(e);
|
|
1953
|
-
throw new Error(e.response.data);
|
|
1954
|
-
} finally {
|
|
1955
|
-
setIsFetchingCommitPsbt(false);
|
|
1956
|
-
}
|
|
1957
|
-
}), [paymentAddress, paymentPublicKey, content, feeRate, mimeType, publicKey]);
|
|
1958
|
-
const handleSignCommit = (tx) => __async(void 0, null, function* () {
|
|
1959
|
-
try {
|
|
1960
|
-
const toBeSigned = tx != null ? tx : commitPsbtHex;
|
|
1961
|
-
if (!toBeSigned)
|
|
1962
|
-
throw new Error("missing tx");
|
|
1963
|
-
const signedResponse = yield signPsbt(toBeSigned, true, true);
|
|
1964
|
-
setCommitTxId(signedResponse == null ? void 0 : signedResponse.txId);
|
|
1965
|
-
return signedResponse == null ? void 0 : signedResponse.txId;
|
|
1966
|
-
} catch (e) {
|
|
1967
|
-
console.error(e);
|
|
1968
|
-
throw e;
|
|
1969
|
-
}
|
|
1970
|
-
});
|
|
1971
|
-
const inscribe = useCallback2(
|
|
1972
|
-
(_0) => __async(void 0, [_0], function* ({
|
|
1973
|
-
content: providedContent,
|
|
1974
|
-
mimeType: providedMimeType,
|
|
1975
|
-
ordinalAddress: providedAddress,
|
|
1976
|
-
commitTxId: providedCommitTxId
|
|
1977
|
-
}) {
|
|
1978
|
-
try {
|
|
1979
|
-
const inscribeContent = providedContent != null ? providedContent : content;
|
|
1980
|
-
const inscribeMimeType = providedMimeType != null ? providedMimeType : mimeType;
|
|
1981
|
-
const inscribeOutputAddress = providedAddress != null ? providedAddress : address2;
|
|
1982
|
-
let inscribeCommitTxId = providedCommitTxId != null ? providedCommitTxId : commitTxId;
|
|
1983
|
-
if (!inscribeContent)
|
|
1984
|
-
throw new Error("missing content");
|
|
1985
|
-
if (!inscribeMimeType)
|
|
1986
|
-
throw new Error("missing mimeType");
|
|
1987
|
-
if (!inscribeOutputAddress)
|
|
1988
|
-
throw new Error("missing address");
|
|
1989
|
-
setIsInscribing(true);
|
|
1990
|
-
if (!inscribeCommitTxId) {
|
|
1991
|
-
const signed = yield getCommitPsbt();
|
|
1992
|
-
inscribeCommitTxId = yield handleSignCommit(signed.psbtBase64);
|
|
1993
|
-
if (!inscribeCommitTxId)
|
|
1994
|
-
throw new Error("failed to broadcast commit");
|
|
1995
|
-
console.log("tempCommitTxId", inscribeCommitTxId);
|
|
1996
|
-
}
|
|
1997
|
-
yield delay(1e4);
|
|
1998
|
-
if (!inscribeCommitTxId)
|
|
1999
|
-
throw new Error("missing commitTxId");
|
|
2000
|
-
return yield axios3.post(`${inscribeApiUrl}/inscribe`, {
|
|
2001
|
-
content,
|
|
2002
|
-
mimeType,
|
|
2003
|
-
ordinalAddress: address2,
|
|
2004
|
-
commitTxId: inscribeCommitTxId
|
|
2005
|
-
}).then((res) => res.data).then((data) => {
|
|
2006
|
-
setInscriptionTxId(data);
|
|
2007
|
-
return data;
|
|
2008
|
-
});
|
|
2009
|
-
} catch (e) {
|
|
2010
|
-
console.error(e);
|
|
2011
|
-
throw e;
|
|
2012
|
-
} finally {
|
|
2013
|
-
setIsInscribing(false);
|
|
2014
|
-
}
|
|
2015
|
-
}),
|
|
2016
|
-
[address2, commitTxId, content, mimeType]
|
|
2017
|
-
);
|
|
2018
|
-
const reset = () => {
|
|
2019
|
-
setContent("");
|
|
2020
|
-
setMimeType(MIME_TYPE_TEXT);
|
|
2021
|
-
setCommitPsbtHex("");
|
|
2022
|
-
setCommitPsbtBase64("");
|
|
2023
|
-
setCommitTxId("");
|
|
2024
|
-
setFeeRate(10);
|
|
2025
|
-
setTotalFees(0);
|
|
2026
|
-
setInscriberAddress("");
|
|
2027
|
-
setInscriptionTxId("");
|
|
2028
|
-
setPreviewUrl("");
|
|
2029
|
-
};
|
|
2030
|
-
return {
|
|
2031
|
-
content,
|
|
2032
|
-
setContent,
|
|
2033
|
-
setMimeType,
|
|
2034
|
-
previewUrl,
|
|
2035
|
-
setPreviewUrl,
|
|
2036
|
-
getCommitPsbt,
|
|
2037
|
-
isFetchingCommitPsbt,
|
|
2038
|
-
commitPsbtHex,
|
|
2039
|
-
commitPsbtBase64,
|
|
2040
|
-
handleSignCommit,
|
|
2041
|
-
commitTxId,
|
|
2042
|
-
setCommitTxId,
|
|
2043
|
-
feeRate,
|
|
2044
|
-
setFeeRate,
|
|
2045
|
-
totalFees,
|
|
2046
|
-
inscriberAddress,
|
|
2047
|
-
inscribe,
|
|
2048
|
-
isInscribing,
|
|
2049
|
-
inscriptionTxId,
|
|
2050
|
-
reset
|
|
2051
|
-
};
|
|
2052
|
-
};
|
|
2053
|
-
|
|
2054
1911
|
// src/icons/oyl.tsx
|
|
2055
1912
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
2056
1913
|
var OylLogo = (_a) => {
|
|
@@ -2730,6 +2587,5 @@ export {
|
|
|
2730
2587
|
isBase64,
|
|
2731
2588
|
isHex,
|
|
2732
2589
|
satoshisToBTC,
|
|
2733
|
-
useInscriber,
|
|
2734
2590
|
useLaserEyes
|
|
2735
2591
|
};
|