@omnisat/lasereyes 0.0.18 → 0.0.20

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
@@ -900,18 +900,6 @@ var LaserEyesProvider = ({
900
900
  yield connectUnisat();
901
901
  } else if (walletName === XVERSE) {
902
902
  yield connectXverse();
903
- } else if (walletName === OYL) {
904
- yield connectOyl();
905
- } else if (walletName === MAGIC_EDEN) {
906
- yield connectMagicEden();
907
- } else if (walletName === OKX) {
908
- yield connectOkx();
909
- } else if (walletName === LEATHER) {
910
- yield connectLeather();
911
- } else if (walletName === PHANTOM) {
912
- yield connectPhantom();
913
- } else if (walletName === WIZZ) {
914
- yield connectWizz();
915
903
  } else {
916
904
  throw new Error("Unsupported wallet..");
917
905
  }
@@ -1468,9 +1456,7 @@ var LaserEyesProvider = ({
1468
1456
  const signedPsbt = yield library == null ? void 0 : library.signPsbt(psbtHex, true, true);
1469
1457
  console.log({ signedPsbt });
1470
1458
  const psbtSignedPsbt = bitcoin2.Psbt.fromHex(signedPsbt);
1471
- console.log("psbtSignedPsbt", psbtSignedPsbt.toBase64());
1472
1459
  if (broadcast) {
1473
- console.log("broadcastin");
1474
1460
  const txId = yield pushPsbt(psbtSignedPsbt.toHex());
1475
1461
  return {
1476
1462
  signedPsbtHex: psbtSignedPsbt.toHex(),
@@ -1753,6 +1739,11 @@ var useInscriber = ({
1753
1739
  const [previewUrl, setPreviewUrl] = (0, import_react2.useState)("");
1754
1740
  const [isFetchingCommitPsbt, setIsFetchingCommitPsbt] = (0, import_react2.useState)(false);
1755
1741
  const [isInscribing, setIsInscribing] = (0, import_react2.useState)(false);
1742
+ (0, import_react2.useEffect)(() => {
1743
+ setCommitPsbtHex("");
1744
+ setCommitPsbtBase64("");
1745
+ setCommitTxId("");
1746
+ }, [content, address2, mimeType, feeRate]);
1756
1747
  const getCommitPsbt = (0, import_react2.useCallback)(() => __async(void 0, null, function* () {
1757
1748
  try {
1758
1749
  if (!content)
@@ -1782,7 +1773,7 @@ var useInscriber = ({
1782
1773
  });
1783
1774
  } catch (e) {
1784
1775
  console.error(e);
1785
- throw e;
1776
+ throw new Error(e.response.data);
1786
1777
  } finally {
1787
1778
  setIsFetchingCommitPsbt(false);
1788
1779
  }
@@ -1800,38 +1791,53 @@ var useInscriber = ({
1800
1791
  throw e;
1801
1792
  }
1802
1793
  });
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);
1794
+ const inscribe = (0, import_react2.useCallback)(
1795
+ (_0) => __async(void 0, [_0], function* ({
1796
+ content: providedContent,
1797
+ mimeType: providedMimeType,
1798
+ ordinalAddress: providedAddress,
1799
+ commitTxId: providedCommitTxId
1800
+ }) {
1801
+ try {
1802
+ const inscribeContent = providedContent != null ? providedContent : content;
1803
+ const inscribeMimeType = providedMimeType != null ? providedMimeType : mimeType;
1804
+ const inscribeOutputAddress = providedAddress != null ? providedAddress : address2;
1805
+ let inscribeCommitTxId = providedCommitTxId != null ? providedCommitTxId : commitTxId;
1806
+ if (!inscribeContent)
1807
+ throw new Error("missing content");
1808
+ if (!inscribeMimeType)
1809
+ throw new Error("missing mimeType");
1810
+ if (!inscribeOutputAddress)
1811
+ throw new Error("missing address");
1812
+ setIsInscribing(true);
1813
+ if (!inscribeCommitTxId) {
1814
+ const signed = yield getCommitPsbt();
1815
+ inscribeCommitTxId = yield handleSignCommit(signed.psbtBase64);
1816
+ if (!inscribeCommitTxId)
1817
+ throw new Error("failed to broadcast commit");
1818
+ console.log("tempCommitTxId", inscribeCommitTxId);
1819
+ }
1820
+ yield delay(1e4);
1821
+ if (!inscribeCommitTxId)
1822
+ throw new Error("missing commitTxId");
1823
+ return yield import_axios3.default.post(`${inscribeApiUrl}/inscribe`, {
1824
+ content,
1825
+ mimeType,
1826
+ ordinalAddress: address2,
1827
+ commitTxId: inscribeCommitTxId
1828
+ }).then((res) => res.data).then((data) => {
1829
+ setInscriptionTxId(data);
1830
+ return data;
1831
+ });
1832
+ } catch (e) {
1833
+ console.error(e);
1834
+ throw e;
1835
+ } finally {
1836
+ setIsInscribing(false);
1817
1837
  }
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]);
1838
+ }),
1839
+ [address2, commitTxId, content, mimeType]
1840
+ );
1835
1841
  const reset = () => {
1836
1842
  setContent("");
1837
1843
  setMimeType(MIME_TYPE_TEXT);
@@ -1844,11 +1850,6 @@ var useInscriber = ({
1844
1850
  setInscriptionTxId("");
1845
1851
  setPreviewUrl("");
1846
1852
  };
1847
- (0, import_react2.useEffect)(() => {
1848
- if (commitTxId && !inscriptionTxId) {
1849
- inscribe();
1850
- }
1851
- }, [commitTxId, inscribe, inscriptionTxId]);
1852
1853
  return {
1853
1854
  content,
1854
1855
  setContent,
package/dist/index.mjs CHANGED
@@ -822,18 +822,6 @@ var LaserEyesProvider = ({
822
822
  yield connectUnisat();
823
823
  } else if (walletName === XVERSE) {
824
824
  yield connectXverse();
825
- } else if (walletName === OYL) {
826
- yield connectOyl();
827
- } else if (walletName === MAGIC_EDEN) {
828
- yield connectMagicEden();
829
- } else if (walletName === OKX) {
830
- yield connectOkx();
831
- } else if (walletName === LEATHER) {
832
- yield connectLeather();
833
- } else if (walletName === PHANTOM) {
834
- yield connectPhantom();
835
- } else if (walletName === WIZZ) {
836
- yield connectWizz();
837
825
  } else {
838
826
  throw new Error("Unsupported wallet..");
839
827
  }
@@ -1390,9 +1378,7 @@ var LaserEyesProvider = ({
1390
1378
  const signedPsbt = yield library == null ? void 0 : library.signPsbt(psbtHex, true, true);
1391
1379
  console.log({ signedPsbt });
1392
1380
  const psbtSignedPsbt = bitcoin2.Psbt.fromHex(signedPsbt);
1393
- console.log("psbtSignedPsbt", psbtSignedPsbt.toBase64());
1394
1381
  if (broadcast) {
1395
- console.log("broadcastin");
1396
1382
  const txId = yield pushPsbt(psbtSignedPsbt.toHex());
1397
1383
  return {
1398
1384
  signedPsbtHex: psbtSignedPsbt.toHex(),
@@ -1675,6 +1661,11 @@ var useInscriber = ({
1675
1661
  const [previewUrl, setPreviewUrl] = useState2("");
1676
1662
  const [isFetchingCommitPsbt, setIsFetchingCommitPsbt] = useState2(false);
1677
1663
  const [isInscribing, setIsInscribing] = useState2(false);
1664
+ useEffect2(() => {
1665
+ setCommitPsbtHex("");
1666
+ setCommitPsbtBase64("");
1667
+ setCommitTxId("");
1668
+ }, [content, address2, mimeType, feeRate]);
1678
1669
  const getCommitPsbt = useCallback(() => __async(void 0, null, function* () {
1679
1670
  try {
1680
1671
  if (!content)
@@ -1704,7 +1695,7 @@ var useInscriber = ({
1704
1695
  });
1705
1696
  } catch (e) {
1706
1697
  console.error(e);
1707
- throw e;
1698
+ throw new Error(e.response.data);
1708
1699
  } finally {
1709
1700
  setIsFetchingCommitPsbt(false);
1710
1701
  }
@@ -1722,38 +1713,53 @@ var useInscriber = ({
1722
1713
  throw e;
1723
1714
  }
1724
1715
  });
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);
1716
+ const inscribe = useCallback(
1717
+ (_0) => __async(void 0, [_0], function* ({
1718
+ content: providedContent,
1719
+ mimeType: providedMimeType,
1720
+ ordinalAddress: providedAddress,
1721
+ commitTxId: providedCommitTxId
1722
+ }) {
1723
+ try {
1724
+ const inscribeContent = providedContent != null ? providedContent : content;
1725
+ const inscribeMimeType = providedMimeType != null ? providedMimeType : mimeType;
1726
+ const inscribeOutputAddress = providedAddress != null ? providedAddress : address2;
1727
+ let inscribeCommitTxId = providedCommitTxId != null ? providedCommitTxId : commitTxId;
1728
+ if (!inscribeContent)
1729
+ throw new Error("missing content");
1730
+ if (!inscribeMimeType)
1731
+ throw new Error("missing mimeType");
1732
+ if (!inscribeOutputAddress)
1733
+ throw new Error("missing address");
1734
+ setIsInscribing(true);
1735
+ if (!inscribeCommitTxId) {
1736
+ const signed = yield getCommitPsbt();
1737
+ inscribeCommitTxId = yield handleSignCommit(signed.psbtBase64);
1738
+ if (!inscribeCommitTxId)
1739
+ throw new Error("failed to broadcast commit");
1740
+ console.log("tempCommitTxId", inscribeCommitTxId);
1741
+ }
1742
+ yield delay(1e4);
1743
+ if (!inscribeCommitTxId)
1744
+ throw new Error("missing commitTxId");
1745
+ return yield axios3.post(`${inscribeApiUrl}/inscribe`, {
1746
+ content,
1747
+ mimeType,
1748
+ ordinalAddress: address2,
1749
+ commitTxId: inscribeCommitTxId
1750
+ }).then((res) => res.data).then((data) => {
1751
+ setInscriptionTxId(data);
1752
+ return data;
1753
+ });
1754
+ } catch (e) {
1755
+ console.error(e);
1756
+ throw e;
1757
+ } finally {
1758
+ setIsInscribing(false);
1739
1759
  }
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]);
1760
+ }),
1761
+ [address2, commitTxId, content, mimeType]
1762
+ );
1757
1763
  const reset = () => {
1758
1764
  setContent("");
1759
1765
  setMimeType(MIME_TYPE_TEXT);
@@ -1766,11 +1772,6 @@ var useInscriber = ({
1766
1772
  setInscriptionTxId("");
1767
1773
  setPreviewUrl("");
1768
1774
  };
1769
- useEffect2(() => {
1770
- if (commitTxId && !inscriptionTxId) {
1771
- inscribe();
1772
- }
1773
- }, [commitTxId, inscribe, inscriptionTxId]);
1774
1775
  return {
1775
1776
  content,
1776
1777
  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.20",
4
4
  "sideEffects": false,
5
5
  "private": false,
6
6
  "license": "MIT",