@omnisat/lasereyes 0.0.44 → 0.0.45
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 +1 -38
- package/dist/index.js +24 -171
- package/dist/index.mjs +24 -170
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -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);
|
|
@@ -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
|
}
|
|
@@ -1385,23 +1383,39 @@ var LaserEyesProvider = ({
|
|
|
1385
1383
|
if (!library)
|
|
1386
1384
|
return;
|
|
1387
1385
|
if (provider === UNISAT) {
|
|
1388
|
-
|
|
1386
|
+
const bal = yield library.getBalance();
|
|
1387
|
+
setBalance(bal.total);
|
|
1388
|
+
return bal.total;
|
|
1389
1389
|
} else if (provider === XVERSE) {
|
|
1390
|
-
|
|
1390
|
+
const bal = yield getBTCBalance(paymentAddress, network);
|
|
1391
|
+
setBalance(bal);
|
|
1392
|
+
return bal;
|
|
1391
1393
|
} else if (provider === OYL) {
|
|
1392
1394
|
const balanceResponse = yield library.getBalance();
|
|
1393
|
-
|
|
1395
|
+
const bal = balanceResponse.btc.total * 1e8;
|
|
1396
|
+
setBalance(bal);
|
|
1397
|
+
return bal;
|
|
1394
1398
|
} else if (provider === MAGIC_EDEN) {
|
|
1395
|
-
|
|
1399
|
+
const bal = yield getBTCBalance(paymentAddress, network);
|
|
1400
|
+
setBalance(bal);
|
|
1401
|
+
return bal;
|
|
1396
1402
|
} else if (provider === OKX) {
|
|
1397
|
-
|
|
1403
|
+
const bal = yield getBTCBalance(paymentAddress, network);
|
|
1404
|
+
setBalance(bal);
|
|
1405
|
+
return bal;
|
|
1398
1406
|
} else if (provider === LEATHER) {
|
|
1399
|
-
|
|
1407
|
+
const bal = yield getBTCBalance(paymentAddress, network);
|
|
1408
|
+
setBalance(bal);
|
|
1409
|
+
return bal;
|
|
1400
1410
|
} else if (provider === PHANTOM) {
|
|
1401
|
-
|
|
1411
|
+
const bal = yield getBTCBalance(paymentAddress, network);
|
|
1412
|
+
setBalance(bal);
|
|
1413
|
+
return bal;
|
|
1402
1414
|
} else if (provider === WIZZ) {
|
|
1403
1415
|
const balanceResponse = yield library.getBalance();
|
|
1404
|
-
|
|
1416
|
+
const bal = balanceResponse.total * 1e8;
|
|
1417
|
+
setBalance(bal);
|
|
1418
|
+
return bal;
|
|
1405
1419
|
}
|
|
1406
1420
|
} catch (error) {
|
|
1407
1421
|
throw error;
|
|
@@ -1987,166 +2001,6 @@ var LaserEyesProvider = ({
|
|
|
1987
2001
|
);
|
|
1988
2002
|
};
|
|
1989
2003
|
|
|
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
2004
|
// src/icons/oyl.tsx
|
|
2151
2005
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
2152
2006
|
var OylLogo = (_a) => {
|
|
@@ -2827,6 +2681,5 @@ var WalletIcon = ({
|
|
|
2827
2681
|
isBase64,
|
|
2828
2682
|
isHex,
|
|
2829
2683
|
satoshisToBTC,
|
|
2830
|
-
useInscriber,
|
|
2831
2684
|
useLaserEyes
|
|
2832
2685
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -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
|
}
|
|
@@ -1289,23 +1288,39 @@ var LaserEyesProvider = ({
|
|
|
1289
1288
|
if (!library)
|
|
1290
1289
|
return;
|
|
1291
1290
|
if (provider === UNISAT) {
|
|
1292
|
-
|
|
1291
|
+
const bal = yield library.getBalance();
|
|
1292
|
+
setBalance(bal.total);
|
|
1293
|
+
return bal.total;
|
|
1293
1294
|
} else if (provider === XVERSE) {
|
|
1294
|
-
|
|
1295
|
+
const bal = yield getBTCBalance(paymentAddress, network);
|
|
1296
|
+
setBalance(bal);
|
|
1297
|
+
return bal;
|
|
1295
1298
|
} else if (provider === OYL) {
|
|
1296
1299
|
const balanceResponse = yield library.getBalance();
|
|
1297
|
-
|
|
1300
|
+
const bal = balanceResponse.btc.total * 1e8;
|
|
1301
|
+
setBalance(bal);
|
|
1302
|
+
return bal;
|
|
1298
1303
|
} else if (provider === MAGIC_EDEN) {
|
|
1299
|
-
|
|
1304
|
+
const bal = yield getBTCBalance(paymentAddress, network);
|
|
1305
|
+
setBalance(bal);
|
|
1306
|
+
return bal;
|
|
1300
1307
|
} else if (provider === OKX) {
|
|
1301
|
-
|
|
1308
|
+
const bal = yield getBTCBalance(paymentAddress, network);
|
|
1309
|
+
setBalance(bal);
|
|
1310
|
+
return bal;
|
|
1302
1311
|
} else if (provider === LEATHER) {
|
|
1303
|
-
|
|
1312
|
+
const bal = yield getBTCBalance(paymentAddress, network);
|
|
1313
|
+
setBalance(bal);
|
|
1314
|
+
return bal;
|
|
1304
1315
|
} else if (provider === PHANTOM) {
|
|
1305
|
-
|
|
1316
|
+
const bal = yield getBTCBalance(paymentAddress, network);
|
|
1317
|
+
setBalance(bal);
|
|
1318
|
+
return bal;
|
|
1306
1319
|
} else if (provider === WIZZ) {
|
|
1307
1320
|
const balanceResponse = yield library.getBalance();
|
|
1308
|
-
|
|
1321
|
+
const bal = balanceResponse.total * 1e8;
|
|
1322
|
+
setBalance(bal);
|
|
1323
|
+
return bal;
|
|
1309
1324
|
}
|
|
1310
1325
|
} catch (error) {
|
|
1311
1326
|
throw error;
|
|
@@ -1891,166 +1906,6 @@ var LaserEyesProvider = ({
|
|
|
1891
1906
|
);
|
|
1892
1907
|
};
|
|
1893
1908
|
|
|
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
1909
|
// src/icons/oyl.tsx
|
|
2055
1910
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
2056
1911
|
var OylLogo = (_a) => {
|
|
@@ -2730,6 +2585,5 @@ export {
|
|
|
2730
2585
|
isBase64,
|
|
2731
2586
|
isHex,
|
|
2732
2587
|
satoshisToBTC,
|
|
2733
|
-
useInscriber,
|
|
2734
2588
|
useLaserEyes
|
|
2735
2589
|
};
|