@omnisat/lasereyes 0.0.15 → 0.0.17

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
@@ -110,9 +110,6 @@ type LaserEyesContextType = {
110
110
  txId?: string;
111
111
  } | undefined>;
112
112
  pushPsbt: (tx: string) => Promise<string | undefined>;
113
- inscribe: (content: any) => Promise<string | undefined>;
114
- isCreatingCommit: boolean;
115
- isInscribing: boolean;
116
113
  };
117
114
  type Config = {
118
115
  network: typeof MAINNET | typeof TESTNET | typeof REGTEST;
@@ -127,6 +124,13 @@ interface BlockchainInfoUTXO {
127
124
  confirmations: number;
128
125
  tx_index: number;
129
126
  }
127
+ interface CommitPsbtResponse {
128
+ inscriberAddress: string;
129
+ psbtHex: string;
130
+ psbtBase64: string;
131
+ feeRate: number;
132
+ totalFees: number;
133
+ }
130
134
 
131
135
  declare const createConfig: (config: Config) => Config;
132
136
 
@@ -168,11 +172,11 @@ declare const useInscriber: ({ inscribeApiUrl, }: {
168
172
  setMimeType: react.Dispatch<react.SetStateAction<"text/plain;charset=utf-8">>;
169
173
  previewUrl: string;
170
174
  setPreviewUrl: react.Dispatch<react.SetStateAction<string>>;
171
- getCommitPsbt: () => Promise<void>;
175
+ getCommitPsbt: () => Promise<CommitPsbtResponse>;
172
176
  isFetchingCommitPsbt: boolean;
173
177
  commitPsbtHex: string;
174
178
  commitPsbtBase64: string;
175
- handleSignCommit: () => Promise<string | undefined>;
179
+ handleSignCommit: (tx: string) => Promise<string | undefined>;
176
180
  commitTxId: string;
177
181
  setCommitTxId: react.Dispatch<react.SetStateAction<string>>;
178
182
  feeRate: number;
package/dist/index.js CHANGED
@@ -531,7 +531,6 @@ var LaserEyesContext = (0, import_react.createContext)(initialWalletContext);
531
531
  var useLaserEyes = () => {
532
532
  return (0, import_react.useContext)(LaserEyesContext);
533
533
  };
534
- var DeSCRIBE_API_URL = "http://localhost:3000/api";
535
534
  var LaserEyesProvider = ({
536
535
  children,
537
536
  config
@@ -1685,53 +1684,6 @@ var LaserEyesProvider = ({
1685
1684
  throw error;
1686
1685
  }
1687
1686
  });
1688
- const [isCreatingCommit, setIsCreatingCommit] = (0, import_react.useState)(false);
1689
- const [isInscribing, setIsInscribing] = (0, import_react.useState)(false);
1690
- const inscribe = (content) => __async(void 0, null, function* () {
1691
- var _a;
1692
- try {
1693
- console.log("inscribing!");
1694
- if (!library)
1695
- throw new Error("Library not found");
1696
- if (!paymentAddress)
1697
- throw new Error("Payment address not found");
1698
- if (!paymentPublicKey)
1699
- throw new Error("Payment public key not found");
1700
- setIsCreatingCommit(true);
1701
- const commitResponse = yield import_axios2.default.post(`${DeSCRIBE_API_URL}/create-inscription`, {
1702
- content,
1703
- paymentAddress,
1704
- paymentPublicKey,
1705
- feeRate: 10,
1706
- mimeType: "text/plain;charset=utf-8"
1707
- }).then((res) => res.data).finally(() => setIsCreatingCommit(false));
1708
- const signedResponse = yield signPsbt(commitResponse.psbtHex, true, true);
1709
- if (!signedResponse)
1710
- throw new Error("Error signing PSBT");
1711
- if (!signedResponse.txId)
1712
- throw new Error("Error pushing PSBT");
1713
- const { txId: commitTxId } = signedResponse;
1714
- setIsInscribing(true);
1715
- let txId;
1716
- try {
1717
- txId = yield import_axios2.default.post(`${DeSCRIBE_API_URL}/inscribe`, {
1718
- content,
1719
- mimeType: "text/plain;charset=utf-8",
1720
- ordinalAddress: address2,
1721
- commitTxId
1722
- }).then((res) => res.data).finally(() => setIsInscribing(false));
1723
- } catch (e) {
1724
- throw e;
1725
- }
1726
- if (!txId)
1727
- throw new Error("Error inscribing");
1728
- return txId;
1729
- } catch (error) {
1730
- if (error instanceof import_axios2.AxiosError && ((_a = error == null ? void 0 : error.response) == null ? void 0 : _a.data)) {
1731
- throw new Error(error.response.data);
1732
- }
1733
- }
1734
- });
1735
1687
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1736
1688
  LaserEyesContext.Provider,
1737
1689
  {
@@ -1767,10 +1719,7 @@ var LaserEyesProvider = ({
1767
1719
  sendBTC,
1768
1720
  signPsbt,
1769
1721
  pushPsbt,
1770
- signMessage,
1771
- inscribe,
1772
- isCreatingCommit,
1773
- isInscribing
1722
+ signMessage
1774
1723
  },
1775
1724
  children
1776
1725
  }
@@ -1827,6 +1776,7 @@ var useInscriber = ({
1827
1776
  setFeeRate(feeRate);
1828
1777
  setTotalFees(data.totalFees);
1829
1778
  setInscriberAddress(data.inscriberAddress);
1779
+ return data;
1830
1780
  });
1831
1781
  } catch (e) {
1832
1782
  console.error(e);
@@ -1835,9 +1785,9 @@ var useInscriber = ({
1835
1785
  setIsFetchingCommitPsbt(false);
1836
1786
  }
1837
1787
  }), [paymentAddress, paymentPublicKey, content, feeRate, mimeType, publicKey]);
1838
- const handleSignCommit = () => __async(void 0, null, function* () {
1788
+ const handleSignCommit = (tx) => __async(void 0, null, function* () {
1839
1789
  try {
1840
- const signedResponse = yield signPsbt(commitPsbtHex, true, true);
1790
+ const signedResponse = yield signPsbt(tx, true, true);
1841
1791
  setCommitTxId(signedResponse == null ? void 0 : signedResponse.txId);
1842
1792
  return signedResponse == null ? void 0 : signedResponse.txId;
1843
1793
  } catch (e) {
@@ -1847,6 +1797,7 @@ var useInscriber = ({
1847
1797
  });
1848
1798
  const inscribe = (0, import_react2.useCallback)(() => __async(void 0, null, function* () {
1849
1799
  try {
1800
+ setIsInscribing(true);
1850
1801
  if (!content)
1851
1802
  throw new Error("missing content");
1852
1803
  if (!address2)
@@ -1854,10 +1805,11 @@ var useInscriber = ({
1854
1805
  if (!mimeType)
1855
1806
  throw new Error("missing mimeType");
1856
1807
  if (!commitTxId) {
1857
- yield getCommitPsbt();
1858
- yield handleSignCommit();
1808
+ console.log("commitTxId not found, getting commit psbt");
1809
+ const signed = yield getCommitPsbt();
1810
+ console.log({ signed });
1811
+ yield handleSignCommit(signed.psbtBase64);
1859
1812
  }
1860
- setIsInscribing(true);
1861
1813
  yield delay(1e4);
1862
1814
  return yield import_axios3.default.post(`${inscribeApiUrl}/inscribe`, {
1863
1815
  content,
package/dist/index.mjs CHANGED
@@ -447,13 +447,12 @@ import {
447
447
  signTransaction
448
448
  } from "sats-connect";
449
449
  import { fromOutputScript } from "bitcoinjs-lib/src/address";
450
- import axios2, { AxiosError } from "axios";
450
+ import axios2 from "axios";
451
451
  import { jsx } from "react/jsx-runtime";
452
452
  var LaserEyesContext = createContext(initialWalletContext);
453
453
  var useLaserEyes = () => {
454
454
  return useContext(LaserEyesContext);
455
455
  };
456
- var DeSCRIBE_API_URL = "http://localhost:3000/api";
457
456
  var LaserEyesProvider = ({
458
457
  children,
459
458
  config
@@ -1607,53 +1606,6 @@ var LaserEyesProvider = ({
1607
1606
  throw error;
1608
1607
  }
1609
1608
  });
1610
- const [isCreatingCommit, setIsCreatingCommit] = useState(false);
1611
- const [isInscribing, setIsInscribing] = useState(false);
1612
- const inscribe = (content) => __async(void 0, null, function* () {
1613
- var _a;
1614
- try {
1615
- console.log("inscribing!");
1616
- if (!library)
1617
- throw new Error("Library not found");
1618
- if (!paymentAddress)
1619
- throw new Error("Payment address not found");
1620
- if (!paymentPublicKey)
1621
- throw new Error("Payment public key not found");
1622
- setIsCreatingCommit(true);
1623
- const commitResponse = yield axios2.post(`${DeSCRIBE_API_URL}/create-inscription`, {
1624
- content,
1625
- paymentAddress,
1626
- paymentPublicKey,
1627
- feeRate: 10,
1628
- mimeType: "text/plain;charset=utf-8"
1629
- }).then((res) => res.data).finally(() => setIsCreatingCommit(false));
1630
- const signedResponse = yield signPsbt(commitResponse.psbtHex, true, true);
1631
- if (!signedResponse)
1632
- throw new Error("Error signing PSBT");
1633
- if (!signedResponse.txId)
1634
- throw new Error("Error pushing PSBT");
1635
- const { txId: commitTxId } = signedResponse;
1636
- setIsInscribing(true);
1637
- let txId;
1638
- try {
1639
- txId = yield axios2.post(`${DeSCRIBE_API_URL}/inscribe`, {
1640
- content,
1641
- mimeType: "text/plain;charset=utf-8",
1642
- ordinalAddress: address2,
1643
- commitTxId
1644
- }).then((res) => res.data).finally(() => setIsInscribing(false));
1645
- } catch (e) {
1646
- throw e;
1647
- }
1648
- if (!txId)
1649
- throw new Error("Error inscribing");
1650
- return txId;
1651
- } catch (error) {
1652
- if (error instanceof AxiosError && ((_a = error == null ? void 0 : error.response) == null ? void 0 : _a.data)) {
1653
- throw new Error(error.response.data);
1654
- }
1655
- }
1656
- });
1657
1609
  return /* @__PURE__ */ jsx(
1658
1610
  LaserEyesContext.Provider,
1659
1611
  {
@@ -1689,10 +1641,7 @@ var LaserEyesProvider = ({
1689
1641
  sendBTC,
1690
1642
  signPsbt,
1691
1643
  pushPsbt,
1692
- signMessage,
1693
- inscribe,
1694
- isCreatingCommit,
1695
- isInscribing
1644
+ signMessage
1696
1645
  },
1697
1646
  children
1698
1647
  }
@@ -1749,6 +1698,7 @@ var useInscriber = ({
1749
1698
  setFeeRate(feeRate);
1750
1699
  setTotalFees(data.totalFees);
1751
1700
  setInscriberAddress(data.inscriberAddress);
1701
+ return data;
1752
1702
  });
1753
1703
  } catch (e) {
1754
1704
  console.error(e);
@@ -1757,9 +1707,9 @@ var useInscriber = ({
1757
1707
  setIsFetchingCommitPsbt(false);
1758
1708
  }
1759
1709
  }), [paymentAddress, paymentPublicKey, content, feeRate, mimeType, publicKey]);
1760
- const handleSignCommit = () => __async(void 0, null, function* () {
1710
+ const handleSignCommit = (tx) => __async(void 0, null, function* () {
1761
1711
  try {
1762
- const signedResponse = yield signPsbt(commitPsbtHex, true, true);
1712
+ const signedResponse = yield signPsbt(tx, true, true);
1763
1713
  setCommitTxId(signedResponse == null ? void 0 : signedResponse.txId);
1764
1714
  return signedResponse == null ? void 0 : signedResponse.txId;
1765
1715
  } catch (e) {
@@ -1769,6 +1719,7 @@ var useInscriber = ({
1769
1719
  });
1770
1720
  const inscribe = useCallback(() => __async(void 0, null, function* () {
1771
1721
  try {
1722
+ setIsInscribing(true);
1772
1723
  if (!content)
1773
1724
  throw new Error("missing content");
1774
1725
  if (!address2)
@@ -1776,10 +1727,11 @@ var useInscriber = ({
1776
1727
  if (!mimeType)
1777
1728
  throw new Error("missing mimeType");
1778
1729
  if (!commitTxId) {
1779
- yield getCommitPsbt();
1780
- yield handleSignCommit();
1730
+ console.log("commitTxId not found, getting commit psbt");
1731
+ const signed = yield getCommitPsbt();
1732
+ console.log({ signed });
1733
+ yield handleSignCommit(signed.psbtBase64);
1781
1734
  }
1782
- setIsInscribing(true);
1783
1735
  yield delay(1e4);
1784
1736
  return yield axios3.post(`${inscribeApiUrl}/inscribe`, {
1785
1737
  content,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnisat/lasereyes",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "sideEffects": false,
5
5
  "private": false,
6
6
  "license": "MIT",