@omnisat/lasereyes 0.0.18 → 0.0.19

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 CHANGED
@@ -183,7 +183,12 @@ declare const useInscriber: ({ inscribeApiUrl, }: {
183
183
  setFeeRate: react.Dispatch<react.SetStateAction<number>>;
184
184
  totalFees: number;
185
185
  inscriberAddress: string;
186
- inscribe: () => Promise<string>;
186
+ inscribe: ({ content: providedContent, mimeType: providedMimeType, ordinalAddress: providedAddress, commitTxId: providedCommitTxId, }: {
187
+ content?: any;
188
+ mimeType?: string | undefined;
189
+ ordinalAddress?: string | undefined;
190
+ commitTxId?: string | undefined;
191
+ }) => Promise<string>;
187
192
  isInscribing: boolean;
188
193
  inscriptionTxId: string;
189
194
  reset: () => void;
package/dist/index.js CHANGED
@@ -1468,9 +1468,7 @@ var LaserEyesProvider = ({
1468
1468
  const signedPsbt = yield library == null ? void 0 : library.signPsbt(psbtHex, true, true);
1469
1469
  console.log({ signedPsbt });
1470
1470
  const psbtSignedPsbt = bitcoin2.Psbt.fromHex(signedPsbt);
1471
- console.log("psbtSignedPsbt", psbtSignedPsbt.toBase64());
1472
1471
  if (broadcast) {
1473
- console.log("broadcastin");
1474
1472
  const txId = yield pushPsbt(psbtSignedPsbt.toHex());
1475
1473
  return {
1476
1474
  signedPsbtHex: psbtSignedPsbt.toHex(),
@@ -1753,6 +1751,11 @@ var useInscriber = ({
1753
1751
  const [previewUrl, setPreviewUrl] = (0, import_react2.useState)("");
1754
1752
  const [isFetchingCommitPsbt, setIsFetchingCommitPsbt] = (0, import_react2.useState)(false);
1755
1753
  const [isInscribing, setIsInscribing] = (0, import_react2.useState)(false);
1754
+ (0, import_react2.useEffect)(() => {
1755
+ setCommitPsbtHex("");
1756
+ setCommitPsbtBase64("");
1757
+ setCommitTxId("");
1758
+ }, [content, address2, mimeType, feeRate]);
1756
1759
  const getCommitPsbt = (0, import_react2.useCallback)(() => __async(void 0, null, function* () {
1757
1760
  try {
1758
1761
  if (!content)
@@ -1782,7 +1785,7 @@ var useInscriber = ({
1782
1785
  });
1783
1786
  } catch (e) {
1784
1787
  console.error(e);
1785
- throw e;
1788
+ throw new Error(e.response.data);
1786
1789
  } finally {
1787
1790
  setIsFetchingCommitPsbt(false);
1788
1791
  }
@@ -1800,38 +1803,53 @@ var useInscriber = ({
1800
1803
  throw e;
1801
1804
  }
1802
1805
  });
1803
- const inscribe = (0, import_react2.useCallback)(() => __async(void 0, null, function* () {
1804
- try {
1805
- setIsInscribing(true);
1806
- if (!content)
1807
- throw new Error("missing content");
1808
- if (!address2)
1809
- throw new Error("missing address");
1810
- if (!mimeType)
1811
- throw new Error("missing mimeType");
1812
- if (!commitTxId) {
1813
- console.log("commitTxId not found, getting commit psbt");
1814
- const signed = yield getCommitPsbt();
1815
- console.log({ signed });
1816
- yield handleSignCommit(signed.psbtBase64);
1806
+ const inscribe = (0, import_react2.useCallback)(
1807
+ (_0) => __async(void 0, [_0], function* ({
1808
+ content: providedContent,
1809
+ mimeType: providedMimeType,
1810
+ ordinalAddress: providedAddress,
1811
+ commitTxId: providedCommitTxId
1812
+ }) {
1813
+ try {
1814
+ const inscribeContent = providedContent != null ? providedContent : content;
1815
+ const inscribeMimeType = providedMimeType != null ? providedMimeType : mimeType;
1816
+ const inscribeOutputAddress = providedAddress != null ? providedAddress : address2;
1817
+ let inscribeCommitTxId = providedCommitTxId != null ? providedCommitTxId : commitTxId;
1818
+ if (!inscribeContent)
1819
+ throw new Error("missing content");
1820
+ if (!inscribeMimeType)
1821
+ throw new Error("missing mimeType");
1822
+ if (!inscribeOutputAddress)
1823
+ throw new Error("missing address");
1824
+ setIsInscribing(true);
1825
+ if (!inscribeCommitTxId) {
1826
+ const signed = yield getCommitPsbt();
1827
+ inscribeCommitTxId = yield handleSignCommit(signed.psbtBase64);
1828
+ if (!inscribeCommitTxId)
1829
+ throw new Error("failed to broadcast commit");
1830
+ console.log("tempCommitTxId", inscribeCommitTxId);
1831
+ }
1832
+ yield delay(1e4);
1833
+ if (!inscribeCommitTxId)
1834
+ throw new Error("missing commitTxId");
1835
+ return yield import_axios3.default.post(`${inscribeApiUrl}/inscribe`, {
1836
+ content,
1837
+ mimeType,
1838
+ ordinalAddress: address2,
1839
+ commitTxId: inscribeCommitTxId
1840
+ }).then((res) => res.data).then((data) => {
1841
+ setInscriptionTxId(data);
1842
+ return data;
1843
+ });
1844
+ } catch (e) {
1845
+ console.error(e);
1846
+ throw e;
1847
+ } finally {
1848
+ setIsInscribing(false);
1817
1849
  }
1818
- yield delay(1e4);
1819
- return yield import_axios3.default.post(`${inscribeApiUrl}/inscribe`, {
1820
- content,
1821
- mimeType,
1822
- ordinalAddress: address2,
1823
- commitTxId
1824
- }).then((res) => res.data).then((data) => {
1825
- setInscriptionTxId(data);
1826
- return data;
1827
- });
1828
- } catch (e) {
1829
- console.error(e);
1830
- throw e;
1831
- } finally {
1832
- setIsInscribing(false);
1833
- }
1834
- }), [address2, commitTxId, content, mimeType]);
1850
+ }),
1851
+ [address2, commitTxId, content, mimeType]
1852
+ );
1835
1853
  const reset = () => {
1836
1854
  setContent("");
1837
1855
  setMimeType(MIME_TYPE_TEXT);
@@ -1844,11 +1862,6 @@ var useInscriber = ({
1844
1862
  setInscriptionTxId("");
1845
1863
  setPreviewUrl("");
1846
1864
  };
1847
- (0, import_react2.useEffect)(() => {
1848
- if (commitTxId && !inscriptionTxId) {
1849
- inscribe();
1850
- }
1851
- }, [commitTxId, inscribe, inscriptionTxId]);
1852
1865
  return {
1853
1866
  content,
1854
1867
  setContent,
package/dist/index.mjs CHANGED
@@ -1390,9 +1390,7 @@ var LaserEyesProvider = ({
1390
1390
  const signedPsbt = yield library == null ? void 0 : library.signPsbt(psbtHex, true, true);
1391
1391
  console.log({ signedPsbt });
1392
1392
  const psbtSignedPsbt = bitcoin2.Psbt.fromHex(signedPsbt);
1393
- console.log("psbtSignedPsbt", psbtSignedPsbt.toBase64());
1394
1393
  if (broadcast) {
1395
- console.log("broadcastin");
1396
1394
  const txId = yield pushPsbt(psbtSignedPsbt.toHex());
1397
1395
  return {
1398
1396
  signedPsbtHex: psbtSignedPsbt.toHex(),
@@ -1675,6 +1673,11 @@ var useInscriber = ({
1675
1673
  const [previewUrl, setPreviewUrl] = useState2("");
1676
1674
  const [isFetchingCommitPsbt, setIsFetchingCommitPsbt] = useState2(false);
1677
1675
  const [isInscribing, setIsInscribing] = useState2(false);
1676
+ useEffect2(() => {
1677
+ setCommitPsbtHex("");
1678
+ setCommitPsbtBase64("");
1679
+ setCommitTxId("");
1680
+ }, [content, address2, mimeType, feeRate]);
1678
1681
  const getCommitPsbt = useCallback(() => __async(void 0, null, function* () {
1679
1682
  try {
1680
1683
  if (!content)
@@ -1704,7 +1707,7 @@ var useInscriber = ({
1704
1707
  });
1705
1708
  } catch (e) {
1706
1709
  console.error(e);
1707
- throw e;
1710
+ throw new Error(e.response.data);
1708
1711
  } finally {
1709
1712
  setIsFetchingCommitPsbt(false);
1710
1713
  }
@@ -1722,38 +1725,53 @@ var useInscriber = ({
1722
1725
  throw e;
1723
1726
  }
1724
1727
  });
1725
- const inscribe = useCallback(() => __async(void 0, null, function* () {
1726
- try {
1727
- setIsInscribing(true);
1728
- if (!content)
1729
- throw new Error("missing content");
1730
- if (!address2)
1731
- throw new Error("missing address");
1732
- if (!mimeType)
1733
- throw new Error("missing mimeType");
1734
- if (!commitTxId) {
1735
- console.log("commitTxId not found, getting commit psbt");
1736
- const signed = yield getCommitPsbt();
1737
- console.log({ signed });
1738
- yield handleSignCommit(signed.psbtBase64);
1728
+ const inscribe = useCallback(
1729
+ (_0) => __async(void 0, [_0], function* ({
1730
+ content: providedContent,
1731
+ mimeType: providedMimeType,
1732
+ ordinalAddress: providedAddress,
1733
+ commitTxId: providedCommitTxId
1734
+ }) {
1735
+ try {
1736
+ const inscribeContent = providedContent != null ? providedContent : content;
1737
+ const inscribeMimeType = providedMimeType != null ? providedMimeType : mimeType;
1738
+ const inscribeOutputAddress = providedAddress != null ? providedAddress : address2;
1739
+ let inscribeCommitTxId = providedCommitTxId != null ? providedCommitTxId : commitTxId;
1740
+ if (!inscribeContent)
1741
+ throw new Error("missing content");
1742
+ if (!inscribeMimeType)
1743
+ throw new Error("missing mimeType");
1744
+ if (!inscribeOutputAddress)
1745
+ throw new Error("missing address");
1746
+ setIsInscribing(true);
1747
+ if (!inscribeCommitTxId) {
1748
+ const signed = yield getCommitPsbt();
1749
+ inscribeCommitTxId = yield handleSignCommit(signed.psbtBase64);
1750
+ if (!inscribeCommitTxId)
1751
+ throw new Error("failed to broadcast commit");
1752
+ console.log("tempCommitTxId", inscribeCommitTxId);
1753
+ }
1754
+ yield delay(1e4);
1755
+ if (!inscribeCommitTxId)
1756
+ throw new Error("missing commitTxId");
1757
+ return yield axios3.post(`${inscribeApiUrl}/inscribe`, {
1758
+ content,
1759
+ mimeType,
1760
+ ordinalAddress: address2,
1761
+ commitTxId: inscribeCommitTxId
1762
+ }).then((res) => res.data).then((data) => {
1763
+ setInscriptionTxId(data);
1764
+ return data;
1765
+ });
1766
+ } catch (e) {
1767
+ console.error(e);
1768
+ throw e;
1769
+ } finally {
1770
+ setIsInscribing(false);
1739
1771
  }
1740
- yield delay(1e4);
1741
- return yield axios3.post(`${inscribeApiUrl}/inscribe`, {
1742
- content,
1743
- mimeType,
1744
- ordinalAddress: address2,
1745
- commitTxId
1746
- }).then((res) => res.data).then((data) => {
1747
- setInscriptionTxId(data);
1748
- return data;
1749
- });
1750
- } catch (e) {
1751
- console.error(e);
1752
- throw e;
1753
- } finally {
1754
- setIsInscribing(false);
1755
- }
1756
- }), [address2, commitTxId, content, mimeType]);
1772
+ }),
1773
+ [address2, commitTxId, content, mimeType]
1774
+ );
1757
1775
  const reset = () => {
1758
1776
  setContent("");
1759
1777
  setMimeType(MIME_TYPE_TEXT);
@@ -1766,11 +1784,6 @@ var useInscriber = ({
1766
1784
  setInscriptionTxId("");
1767
1785
  setPreviewUrl("");
1768
1786
  };
1769
- useEffect2(() => {
1770
- if (commitTxId && !inscriptionTxId) {
1771
- inscribe();
1772
- }
1773
- }, [commitTxId, inscribe, inscriptionTxId]);
1774
1787
  return {
1775
1788
  content,
1776
1789
  setContent,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnisat/lasereyes",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "sideEffects": false,
5
5
  "private": false,
6
6
  "license": "MIT",