@omnisat/lasereyes 0.0.14 → 0.0.16
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 +35 -1
- package/dist/index.js +152 -1
- package/dist/index.mjs +152 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as react from 'react';
|
|
2
3
|
import { ReactNode } from 'react';
|
|
3
4
|
import * as bitcoin from 'bitcoinjs-lib';
|
|
4
5
|
|
|
@@ -131,6 +132,13 @@ declare const LaserEyesProvider: ({ children, config, }: {
|
|
|
131
132
|
children: ReactNode;
|
|
132
133
|
config?: Config | undefined;
|
|
133
134
|
}) => react_jsx_runtime.JSX.Element;
|
|
135
|
+
interface DeScribeCreateResponse {
|
|
136
|
+
inscriberAddress: string;
|
|
137
|
+
psbtHex: string;
|
|
138
|
+
psbtBase64: string;
|
|
139
|
+
feeRate: number;
|
|
140
|
+
totalFees: number;
|
|
141
|
+
}
|
|
134
142
|
|
|
135
143
|
declare const getBitcoinNetwork: (network: typeof MAINNET | typeof TESTNET | typeof REGTEST) => bitcoin.networks.Network;
|
|
136
144
|
declare const findOrdinalsAddress: (addresses: any) => any;
|
|
@@ -147,5 +155,31 @@ declare function createSendBtcPsbt(address: string, paymentAddress: string, reci
|
|
|
147
155
|
psbtHex: string;
|
|
148
156
|
}>;
|
|
149
157
|
declare function getRedeemScript(paymentPublicKey: string, network: typeof MAINNET | typeof TESTNET): Buffer | undefined;
|
|
158
|
+
declare function delay(ms: number): Promise<unknown>;
|
|
159
|
+
|
|
160
|
+
declare const useInscriber: ({ inscribeApiUrl, }: {
|
|
161
|
+
inscribeApiUrl: string;
|
|
162
|
+
}) => {
|
|
163
|
+
content: any;
|
|
164
|
+
setContent: react.Dispatch<any>;
|
|
165
|
+
setMimeType: react.Dispatch<react.SetStateAction<"text/plain;charset=utf-8">>;
|
|
166
|
+
previewUrl: string;
|
|
167
|
+
setPreviewUrl: react.Dispatch<react.SetStateAction<string>>;
|
|
168
|
+
getCommitPsbt: () => Promise<void>;
|
|
169
|
+
isFetchingCommitPsbt: boolean;
|
|
170
|
+
commitPsbtHex: string;
|
|
171
|
+
commitPsbtBase64: string;
|
|
172
|
+
handleSignCommit: () => Promise<string | undefined>;
|
|
173
|
+
commitTxId: string;
|
|
174
|
+
setCommitTxId: react.Dispatch<react.SetStateAction<string>>;
|
|
175
|
+
feeRate: number;
|
|
176
|
+
setFeeRate: react.Dispatch<react.SetStateAction<number>>;
|
|
177
|
+
totalFees: number;
|
|
178
|
+
inscriberAddress: string;
|
|
179
|
+
inscribe: () => Promise<string>;
|
|
180
|
+
isInscribing: boolean;
|
|
181
|
+
inscriptionTxId: string;
|
|
182
|
+
reset: () => void;
|
|
183
|
+
};
|
|
150
184
|
|
|
151
|
-
export { 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, estimateTxSize, findOrdinalsAddress, findPaymentAddress, getAddressType, getAddressUtxos, getBTCBalance, getBitcoinNetwork, getLeatherNetwork, getMempoolSpaceUrl, getNetworkForLeather, getNetworkForOkx, getNetworkForUnisat, getNetworkForWizz, getNetworkForXverse, getRedeemScript, getUnisatNetwork, getWizzNetwork, getXverseNetwork, isBase64, isHex, satoshisToBTC, useLaserEyes };
|
|
185
|
+
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, getAddressType, getAddressUtxos, getBTCBalance, getBitcoinNetwork, getLeatherNetwork, getMempoolSpaceUrl, getNetworkForLeather, getNetworkForOkx, getNetworkForUnisat, getNetworkForWizz, getNetworkForXverse, getRedeemScript, getUnisatNetwork, getWizzNetwork, getXverseNetwork, isBase64, isHex, satoshisToBTC, useInscriber, useLaserEyes };
|
package/dist/index.js
CHANGED
|
@@ -108,6 +108,7 @@ __export(src_exports, {
|
|
|
108
108
|
XVERSE_TESTNET: () => XVERSE_TESTNET,
|
|
109
109
|
createConfig: () => createConfig,
|
|
110
110
|
createSendBtcPsbt: () => createSendBtcPsbt,
|
|
111
|
+
delay: () => delay,
|
|
111
112
|
estimateTxSize: () => estimateTxSize,
|
|
112
113
|
findOrdinalsAddress: () => findOrdinalsAddress,
|
|
113
114
|
findPaymentAddress: () => findPaymentAddress,
|
|
@@ -129,6 +130,7 @@ __export(src_exports, {
|
|
|
129
130
|
isBase64: () => isBase64,
|
|
130
131
|
isHex: () => isHex,
|
|
131
132
|
satoshisToBTC: () => satoshisToBTC,
|
|
133
|
+
useInscriber: () => useInscriber,
|
|
132
134
|
useLaserEyes: () => useLaserEyes
|
|
133
135
|
});
|
|
134
136
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -329,7 +331,12 @@ var initialWalletContext = {
|
|
|
329
331
|
}),
|
|
330
332
|
pushPsbt: (tx) => __async(void 0, null, function* () {
|
|
331
333
|
return "";
|
|
332
|
-
})
|
|
334
|
+
}),
|
|
335
|
+
inscribe: (content) => __async(void 0, null, function* () {
|
|
336
|
+
return "";
|
|
337
|
+
}),
|
|
338
|
+
isCreatingCommit: false,
|
|
339
|
+
isInscribing: false
|
|
333
340
|
};
|
|
334
341
|
|
|
335
342
|
// src/providers/LaserEyesProvider.tsx
|
|
@@ -511,6 +518,9 @@ function getRedeemScript(paymentPublicKey, network) {
|
|
|
511
518
|
});
|
|
512
519
|
return (_a = p2sh == null ? void 0 : p2sh.redeem) == null ? void 0 : _a.output;
|
|
513
520
|
}
|
|
521
|
+
function delay(ms) {
|
|
522
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
523
|
+
}
|
|
514
524
|
|
|
515
525
|
// src/providers/LaserEyesProvider.tsx
|
|
516
526
|
var import_sats_connect = require("sats-connect");
|
|
@@ -1715,6 +1725,145 @@ var LaserEyesProvider = ({
|
|
|
1715
1725
|
}
|
|
1716
1726
|
);
|
|
1717
1727
|
};
|
|
1728
|
+
|
|
1729
|
+
// src/hooks/useInscriber.ts
|
|
1730
|
+
var import_react2 = require("react");
|
|
1731
|
+
|
|
1732
|
+
// src/consts/inscribe.ts
|
|
1733
|
+
var MIME_TYPE_TEXT = "text/plain;charset=utf-8";
|
|
1734
|
+
|
|
1735
|
+
// src/hooks/useInscriber.ts
|
|
1736
|
+
var import_axios3 = __toESM(require("axios"));
|
|
1737
|
+
var DESCRIBE_API_URL = "http://localhost:3000/api";
|
|
1738
|
+
var useInscriber = ({
|
|
1739
|
+
inscribeApiUrl = DESCRIBE_API_URL
|
|
1740
|
+
}) => {
|
|
1741
|
+
const { address: address2, paymentAddress, paymentPublicKey, publicKey, signPsbt } = useLaserEyes();
|
|
1742
|
+
const [content, setContent] = (0, import_react2.useState)("");
|
|
1743
|
+
const [mimeType, setMimeType] = (0, import_react2.useState)(MIME_TYPE_TEXT);
|
|
1744
|
+
const [commitPsbtHex, setCommitPsbtHex] = (0, import_react2.useState)("");
|
|
1745
|
+
const [commitPsbtBase64, setCommitPsbtBase64] = (0, import_react2.useState)("");
|
|
1746
|
+
const [commitTxId, setCommitTxId] = (0, import_react2.useState)("");
|
|
1747
|
+
const [feeRate, setFeeRate] = (0, import_react2.useState)(10);
|
|
1748
|
+
const [totalFees, setTotalFees] = (0, import_react2.useState)(0);
|
|
1749
|
+
const [inscriberAddress, setInscriberAddress] = (0, import_react2.useState)("");
|
|
1750
|
+
const [inscriptionTxId, setInscriptionTxId] = (0, import_react2.useState)("");
|
|
1751
|
+
const [previewUrl, setPreviewUrl] = (0, import_react2.useState)("");
|
|
1752
|
+
const [isFetchingCommitPsbt, setIsFetchingCommitPsbt] = (0, import_react2.useState)(false);
|
|
1753
|
+
const [isInscribing, setIsInscribing] = (0, import_react2.useState)(false);
|
|
1754
|
+
const getCommitPsbt = (0, import_react2.useCallback)(() => __async(void 0, null, function* () {
|
|
1755
|
+
try {
|
|
1756
|
+
if (!content)
|
|
1757
|
+
throw new Error("missing content");
|
|
1758
|
+
if (!paymentAddress)
|
|
1759
|
+
throw new Error("missing paymentAddress");
|
|
1760
|
+
if (!paymentPublicKey)
|
|
1761
|
+
throw new Error("missing paymentPublicKey");
|
|
1762
|
+
if (!feeRate)
|
|
1763
|
+
throw new Error("missing feeRate");
|
|
1764
|
+
if (!mimeType)
|
|
1765
|
+
throw new Error("missing mimeType");
|
|
1766
|
+
setIsFetchingCommitPsbt(true);
|
|
1767
|
+
return yield import_axios3.default.post(`${inscribeApiUrl}/create-inscription`, {
|
|
1768
|
+
content,
|
|
1769
|
+
paymentAddress,
|
|
1770
|
+
paymentPublicKey,
|
|
1771
|
+
feeRate,
|
|
1772
|
+
mimeType
|
|
1773
|
+
}).then((res) => res.data).then((data) => {
|
|
1774
|
+
setCommitPsbtHex(data.psbtHex);
|
|
1775
|
+
setCommitPsbtBase64(data.psbtBase64);
|
|
1776
|
+
setFeeRate(feeRate);
|
|
1777
|
+
setTotalFees(data.totalFees);
|
|
1778
|
+
setInscriberAddress(data.inscriberAddress);
|
|
1779
|
+
});
|
|
1780
|
+
} catch (e) {
|
|
1781
|
+
console.error(e);
|
|
1782
|
+
throw e;
|
|
1783
|
+
} finally {
|
|
1784
|
+
setIsFetchingCommitPsbt(false);
|
|
1785
|
+
}
|
|
1786
|
+
}), [paymentAddress, paymentPublicKey, content, feeRate, mimeType, publicKey]);
|
|
1787
|
+
const handleSignCommit = () => __async(void 0, null, function* () {
|
|
1788
|
+
try {
|
|
1789
|
+
const signedResponse = yield signPsbt(commitPsbtHex, true, true);
|
|
1790
|
+
setCommitTxId(signedResponse == null ? void 0 : signedResponse.txId);
|
|
1791
|
+
return signedResponse == null ? void 0 : signedResponse.txId;
|
|
1792
|
+
} catch (e) {
|
|
1793
|
+
console.error(e);
|
|
1794
|
+
throw e;
|
|
1795
|
+
}
|
|
1796
|
+
});
|
|
1797
|
+
const inscribe = (0, import_react2.useCallback)(() => __async(void 0, null, function* () {
|
|
1798
|
+
try {
|
|
1799
|
+
if (!content)
|
|
1800
|
+
throw new Error("missing content");
|
|
1801
|
+
if (!address2)
|
|
1802
|
+
throw new Error("missing address");
|
|
1803
|
+
if (!mimeType)
|
|
1804
|
+
throw new Error("missing mimeType");
|
|
1805
|
+
if (!commitTxId) {
|
|
1806
|
+
yield getCommitPsbt();
|
|
1807
|
+
yield handleSignCommit();
|
|
1808
|
+
}
|
|
1809
|
+
setIsInscribing(true);
|
|
1810
|
+
yield delay(1e4);
|
|
1811
|
+
return yield import_axios3.default.post(`${inscribeApiUrl}/inscribe`, {
|
|
1812
|
+
content,
|
|
1813
|
+
mimeType,
|
|
1814
|
+
ordinalAddress: address2,
|
|
1815
|
+
commitTxId
|
|
1816
|
+
}).then((res) => res.data).then((data) => {
|
|
1817
|
+
setInscriptionTxId(data);
|
|
1818
|
+
return data;
|
|
1819
|
+
});
|
|
1820
|
+
} catch (e) {
|
|
1821
|
+
console.error(e);
|
|
1822
|
+
throw e;
|
|
1823
|
+
} finally {
|
|
1824
|
+
setIsInscribing(false);
|
|
1825
|
+
}
|
|
1826
|
+
}), [address2, commitTxId, content, mimeType]);
|
|
1827
|
+
const reset = () => {
|
|
1828
|
+
setContent("");
|
|
1829
|
+
setMimeType(MIME_TYPE_TEXT);
|
|
1830
|
+
setCommitPsbtHex("");
|
|
1831
|
+
setCommitPsbtBase64("");
|
|
1832
|
+
setCommitTxId("");
|
|
1833
|
+
setFeeRate(10);
|
|
1834
|
+
setTotalFees(0);
|
|
1835
|
+
setInscriberAddress("");
|
|
1836
|
+
setInscriptionTxId("");
|
|
1837
|
+
setPreviewUrl("");
|
|
1838
|
+
};
|
|
1839
|
+
(0, import_react2.useEffect)(() => {
|
|
1840
|
+
if (commitTxId && !inscriptionTxId) {
|
|
1841
|
+
inscribe();
|
|
1842
|
+
}
|
|
1843
|
+
}, [commitTxId, inscribe, inscriptionTxId]);
|
|
1844
|
+
return {
|
|
1845
|
+
content,
|
|
1846
|
+
setContent,
|
|
1847
|
+
setMimeType,
|
|
1848
|
+
previewUrl,
|
|
1849
|
+
setPreviewUrl,
|
|
1850
|
+
getCommitPsbt,
|
|
1851
|
+
isFetchingCommitPsbt,
|
|
1852
|
+
commitPsbtHex,
|
|
1853
|
+
commitPsbtBase64,
|
|
1854
|
+
handleSignCommit,
|
|
1855
|
+
commitTxId,
|
|
1856
|
+
setCommitTxId,
|
|
1857
|
+
feeRate,
|
|
1858
|
+
setFeeRate,
|
|
1859
|
+
totalFees,
|
|
1860
|
+
inscriberAddress,
|
|
1861
|
+
inscribe,
|
|
1862
|
+
isInscribing,
|
|
1863
|
+
inscriptionTxId,
|
|
1864
|
+
reset
|
|
1865
|
+
};
|
|
1866
|
+
};
|
|
1718
1867
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1719
1868
|
0 && (module.exports = {
|
|
1720
1869
|
LEATHER,
|
|
@@ -1752,6 +1901,7 @@ var LaserEyesProvider = ({
|
|
|
1752
1901
|
XVERSE_TESTNET,
|
|
1753
1902
|
createConfig,
|
|
1754
1903
|
createSendBtcPsbt,
|
|
1904
|
+
delay,
|
|
1755
1905
|
estimateTxSize,
|
|
1756
1906
|
findOrdinalsAddress,
|
|
1757
1907
|
findPaymentAddress,
|
|
@@ -1773,5 +1923,6 @@ var LaserEyesProvider = ({
|
|
|
1773
1923
|
isBase64,
|
|
1774
1924
|
isHex,
|
|
1775
1925
|
satoshisToBTC,
|
|
1926
|
+
useInscriber,
|
|
1776
1927
|
useLaserEyes
|
|
1777
1928
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -246,7 +246,12 @@ var initialWalletContext = {
|
|
|
246
246
|
}),
|
|
247
247
|
pushPsbt: (tx) => __async(void 0, null, function* () {
|
|
248
248
|
return "";
|
|
249
|
-
})
|
|
249
|
+
}),
|
|
250
|
+
inscribe: (content) => __async(void 0, null, function* () {
|
|
251
|
+
return "";
|
|
252
|
+
}),
|
|
253
|
+
isCreatingCommit: false,
|
|
254
|
+
isInscribing: false
|
|
250
255
|
};
|
|
251
256
|
|
|
252
257
|
// src/providers/LaserEyesProvider.tsx
|
|
@@ -428,6 +433,9 @@ function getRedeemScript(paymentPublicKey, network) {
|
|
|
428
433
|
});
|
|
429
434
|
return (_a = p2sh == null ? void 0 : p2sh.redeem) == null ? void 0 : _a.output;
|
|
430
435
|
}
|
|
436
|
+
function delay(ms) {
|
|
437
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
438
|
+
}
|
|
431
439
|
|
|
432
440
|
// src/providers/LaserEyesProvider.tsx
|
|
433
441
|
import {
|
|
@@ -435,8 +443,8 @@ import {
|
|
|
435
443
|
getAddress,
|
|
436
444
|
request,
|
|
437
445
|
RpcErrorCode,
|
|
438
|
-
|
|
439
|
-
|
|
446
|
+
signMessage as signMessageSatsConnect,
|
|
447
|
+
signTransaction
|
|
440
448
|
} from "sats-connect";
|
|
441
449
|
import { fromOutputScript } from "bitcoinjs-lib/src/address";
|
|
442
450
|
import axios2 from "axios";
|
|
@@ -1639,6 +1647,145 @@ var LaserEyesProvider = ({
|
|
|
1639
1647
|
}
|
|
1640
1648
|
);
|
|
1641
1649
|
};
|
|
1650
|
+
|
|
1651
|
+
// src/hooks/useInscriber.ts
|
|
1652
|
+
import { useCallback, useEffect as useEffect2, useState as useState2 } from "react";
|
|
1653
|
+
|
|
1654
|
+
// src/consts/inscribe.ts
|
|
1655
|
+
var MIME_TYPE_TEXT = "text/plain;charset=utf-8";
|
|
1656
|
+
|
|
1657
|
+
// src/hooks/useInscriber.ts
|
|
1658
|
+
import axios3 from "axios";
|
|
1659
|
+
var DESCRIBE_API_URL = "http://localhost:3000/api";
|
|
1660
|
+
var useInscriber = ({
|
|
1661
|
+
inscribeApiUrl = DESCRIBE_API_URL
|
|
1662
|
+
}) => {
|
|
1663
|
+
const { address: address2, paymentAddress, paymentPublicKey, publicKey, signPsbt } = useLaserEyes();
|
|
1664
|
+
const [content, setContent] = useState2("");
|
|
1665
|
+
const [mimeType, setMimeType] = useState2(MIME_TYPE_TEXT);
|
|
1666
|
+
const [commitPsbtHex, setCommitPsbtHex] = useState2("");
|
|
1667
|
+
const [commitPsbtBase64, setCommitPsbtBase64] = useState2("");
|
|
1668
|
+
const [commitTxId, setCommitTxId] = useState2("");
|
|
1669
|
+
const [feeRate, setFeeRate] = useState2(10);
|
|
1670
|
+
const [totalFees, setTotalFees] = useState2(0);
|
|
1671
|
+
const [inscriberAddress, setInscriberAddress] = useState2("");
|
|
1672
|
+
const [inscriptionTxId, setInscriptionTxId] = useState2("");
|
|
1673
|
+
const [previewUrl, setPreviewUrl] = useState2("");
|
|
1674
|
+
const [isFetchingCommitPsbt, setIsFetchingCommitPsbt] = useState2(false);
|
|
1675
|
+
const [isInscribing, setIsInscribing] = useState2(false);
|
|
1676
|
+
const getCommitPsbt = useCallback(() => __async(void 0, null, function* () {
|
|
1677
|
+
try {
|
|
1678
|
+
if (!content)
|
|
1679
|
+
throw new Error("missing content");
|
|
1680
|
+
if (!paymentAddress)
|
|
1681
|
+
throw new Error("missing paymentAddress");
|
|
1682
|
+
if (!paymentPublicKey)
|
|
1683
|
+
throw new Error("missing paymentPublicKey");
|
|
1684
|
+
if (!feeRate)
|
|
1685
|
+
throw new Error("missing feeRate");
|
|
1686
|
+
if (!mimeType)
|
|
1687
|
+
throw new Error("missing mimeType");
|
|
1688
|
+
setIsFetchingCommitPsbt(true);
|
|
1689
|
+
return yield axios3.post(`${inscribeApiUrl}/create-inscription`, {
|
|
1690
|
+
content,
|
|
1691
|
+
paymentAddress,
|
|
1692
|
+
paymentPublicKey,
|
|
1693
|
+
feeRate,
|
|
1694
|
+
mimeType
|
|
1695
|
+
}).then((res) => res.data).then((data) => {
|
|
1696
|
+
setCommitPsbtHex(data.psbtHex);
|
|
1697
|
+
setCommitPsbtBase64(data.psbtBase64);
|
|
1698
|
+
setFeeRate(feeRate);
|
|
1699
|
+
setTotalFees(data.totalFees);
|
|
1700
|
+
setInscriberAddress(data.inscriberAddress);
|
|
1701
|
+
});
|
|
1702
|
+
} catch (e) {
|
|
1703
|
+
console.error(e);
|
|
1704
|
+
throw e;
|
|
1705
|
+
} finally {
|
|
1706
|
+
setIsFetchingCommitPsbt(false);
|
|
1707
|
+
}
|
|
1708
|
+
}), [paymentAddress, paymentPublicKey, content, feeRate, mimeType, publicKey]);
|
|
1709
|
+
const handleSignCommit = () => __async(void 0, null, function* () {
|
|
1710
|
+
try {
|
|
1711
|
+
const signedResponse = yield signPsbt(commitPsbtHex, true, true);
|
|
1712
|
+
setCommitTxId(signedResponse == null ? void 0 : signedResponse.txId);
|
|
1713
|
+
return signedResponse == null ? void 0 : signedResponse.txId;
|
|
1714
|
+
} catch (e) {
|
|
1715
|
+
console.error(e);
|
|
1716
|
+
throw e;
|
|
1717
|
+
}
|
|
1718
|
+
});
|
|
1719
|
+
const inscribe = useCallback(() => __async(void 0, null, function* () {
|
|
1720
|
+
try {
|
|
1721
|
+
if (!content)
|
|
1722
|
+
throw new Error("missing content");
|
|
1723
|
+
if (!address2)
|
|
1724
|
+
throw new Error("missing address");
|
|
1725
|
+
if (!mimeType)
|
|
1726
|
+
throw new Error("missing mimeType");
|
|
1727
|
+
if (!commitTxId) {
|
|
1728
|
+
yield getCommitPsbt();
|
|
1729
|
+
yield handleSignCommit();
|
|
1730
|
+
}
|
|
1731
|
+
setIsInscribing(true);
|
|
1732
|
+
yield delay(1e4);
|
|
1733
|
+
return yield axios3.post(`${inscribeApiUrl}/inscribe`, {
|
|
1734
|
+
content,
|
|
1735
|
+
mimeType,
|
|
1736
|
+
ordinalAddress: address2,
|
|
1737
|
+
commitTxId
|
|
1738
|
+
}).then((res) => res.data).then((data) => {
|
|
1739
|
+
setInscriptionTxId(data);
|
|
1740
|
+
return data;
|
|
1741
|
+
});
|
|
1742
|
+
} catch (e) {
|
|
1743
|
+
console.error(e);
|
|
1744
|
+
throw e;
|
|
1745
|
+
} finally {
|
|
1746
|
+
setIsInscribing(false);
|
|
1747
|
+
}
|
|
1748
|
+
}), [address2, commitTxId, content, mimeType]);
|
|
1749
|
+
const reset = () => {
|
|
1750
|
+
setContent("");
|
|
1751
|
+
setMimeType(MIME_TYPE_TEXT);
|
|
1752
|
+
setCommitPsbtHex("");
|
|
1753
|
+
setCommitPsbtBase64("");
|
|
1754
|
+
setCommitTxId("");
|
|
1755
|
+
setFeeRate(10);
|
|
1756
|
+
setTotalFees(0);
|
|
1757
|
+
setInscriberAddress("");
|
|
1758
|
+
setInscriptionTxId("");
|
|
1759
|
+
setPreviewUrl("");
|
|
1760
|
+
};
|
|
1761
|
+
useEffect2(() => {
|
|
1762
|
+
if (commitTxId && !inscriptionTxId) {
|
|
1763
|
+
inscribe();
|
|
1764
|
+
}
|
|
1765
|
+
}, [commitTxId, inscribe, inscriptionTxId]);
|
|
1766
|
+
return {
|
|
1767
|
+
content,
|
|
1768
|
+
setContent,
|
|
1769
|
+
setMimeType,
|
|
1770
|
+
previewUrl,
|
|
1771
|
+
setPreviewUrl,
|
|
1772
|
+
getCommitPsbt,
|
|
1773
|
+
isFetchingCommitPsbt,
|
|
1774
|
+
commitPsbtHex,
|
|
1775
|
+
commitPsbtBase64,
|
|
1776
|
+
handleSignCommit,
|
|
1777
|
+
commitTxId,
|
|
1778
|
+
setCommitTxId,
|
|
1779
|
+
feeRate,
|
|
1780
|
+
setFeeRate,
|
|
1781
|
+
totalFees,
|
|
1782
|
+
inscriberAddress,
|
|
1783
|
+
inscribe,
|
|
1784
|
+
isInscribing,
|
|
1785
|
+
inscriptionTxId,
|
|
1786
|
+
reset
|
|
1787
|
+
};
|
|
1788
|
+
};
|
|
1642
1789
|
export {
|
|
1643
1790
|
LEATHER,
|
|
1644
1791
|
LEATHER_MAINNET,
|
|
@@ -1675,6 +1822,7 @@ export {
|
|
|
1675
1822
|
XVERSE_TESTNET,
|
|
1676
1823
|
createConfig,
|
|
1677
1824
|
createSendBtcPsbt,
|
|
1825
|
+
delay,
|
|
1678
1826
|
estimateTxSize,
|
|
1679
1827
|
findOrdinalsAddress,
|
|
1680
1828
|
findPaymentAddress,
|
|
@@ -1696,5 +1844,6 @@ export {
|
|
|
1696
1844
|
isBase64,
|
|
1697
1845
|
isHex,
|
|
1698
1846
|
satoshisToBTC,
|
|
1847
|
+
useInscriber,
|
|
1699
1848
|
useLaserEyes
|
|
1700
1849
|
};
|