diff --git a/example/src/App.tsx b/example/src/App.tsx index 29b0341..f89cb68 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -28,6 +28,7 @@ import { SendInscription } from './components/sendInscriptions'; import AddressDisplay from './components/AddressDisplay'; import { GetAddresses } from './components/bitcoin/GetAddresses.tsx'; import { SendBtc } from './components/bitcoin/SendBtc'; +import { CreateInscription } from './components/createInscription/index.tsx'; import EtchRunes from './components/EtchRunes'; import MintRunes from './components/MintRunes'; import { MobileUniversalLink } from './components/mobile/universalLink.tsx'; @@ -303,6 +304,7 @@ const BitcoinMethods = () => { + diff --git a/example/src/components/EtchRunes/index.tsx b/example/src/components/EtchRunes/index.tsx index 8a2fa84..655adf2 100644 --- a/example/src/components/EtchRunes/index.tsx +++ b/example/src/components/EtchRunes/index.tsx @@ -139,6 +139,12 @@ export const EtchRunes = ({ addresses, network }: Props) => { [BitcoinNetworkType.Testnet]: '/testnet', [BitcoinNetworkType.Signet]: '/signet', }; + + if (network === BitcoinNetworkType.Testnet4 || network === BitcoinNetworkType.Regtest) { + console.error('Network not supported for etching runes'); + return; + } + const fundTxLink = `https://mempool.space${networkPath[network]}/tx/${fundTxId}`; return ( diff --git a/example/src/components/MintRunes/index.tsx b/example/src/components/MintRunes/index.tsx index af8e44c..abdce4c 100644 --- a/example/src/components/MintRunes/index.tsx +++ b/example/src/components/MintRunes/index.tsx @@ -72,6 +72,10 @@ export const MintRunes = ({ addresses, network }: Props) => { [BitcoinNetworkType.Testnet]: '/testnet', [BitcoinNetworkType.Signet]: '/signet', }; + if (network === BitcoinNetworkType.Testnet4 || network === BitcoinNetworkType.Regtest) { + console.error('Network not supported for etching runes'); + return; + } const fundTxLink = `https://mempool.space${networkPath[network]}/tx/${fundTxId}`; return ( diff --git a/example/src/components/NetworkSelector/index.tsx b/example/src/components/NetworkSelector/index.tsx index 71bbcac..0c2844c 100644 --- a/example/src/components/NetworkSelector/index.tsx +++ b/example/src/components/NetworkSelector/index.tsx @@ -10,9 +10,11 @@ export const NetworkSelector = ({ network, setNetwork }: Props) => { const onNetworkChange = () => { const newNetwork = network === BitcoinNetworkType.Mainnet - ? BitcoinNetworkType.Testnet - : network === BitcoinNetworkType.Testnet + ? BitcoinNetworkType.Testnet4 + : network === BitcoinNetworkType.Testnet4 ? BitcoinNetworkType.Signet + : network === BitcoinNetworkType.Signet + ? BitcoinNetworkType.Testnet : BitcoinNetworkType.Mainnet; setNetwork(newNetwork); }; diff --git a/example/src/components/bitcoin/SendBtc/index.tsx b/example/src/components/bitcoin/SendBtc/index.tsx index 8bb2454..4d2ec30 100644 --- a/example/src/components/bitcoin/SendBtc/index.tsx +++ b/example/src/components/bitcoin/SendBtc/index.tsx @@ -1,6 +1,7 @@ import { useCallback, useState } from 'react'; import Wallet, { BitcoinNetworkType } from 'sats-connect'; import { Button, Card, Input, Success } from '../../../App.styles'; +import { getMempoolEndpoint } from '../../../util'; interface Props { network: BitcoinNetworkType; @@ -52,10 +53,7 @@ export const SendBtc = ({ network }: Props) => { })().catch(console.error); }, [recipients]); - const explorerUrl = - network === BitcoinNetworkType.Mainnet - ? `https://mempool.space/tx/${txnId}` - : `https://mempool.space/testnet/tx/${txnId}`; + const explorerUrl = `${getMempoolEndpoint(network)}tx/${txnId}`; return ( diff --git a/example/src/components/createInscription/index.tsx b/example/src/components/createInscription/index.tsx new file mode 100644 index 0000000..13f2cc9 --- /dev/null +++ b/example/src/components/createInscription/index.tsx @@ -0,0 +1,52 @@ +import { useCallback, useState } from 'react'; +import { BitcoinNetworkType, createInscription } from 'sats-connect'; +import { Button, Card, Input } from '../../App.styles'; + +interface Props { + network: BitcoinNetworkType; +} + +export const CreateInscription = ({ network }: Props) => { + const [content, setContent] = useState(''); + + const onClick = useCallback(() => { + (async () => { + alert(content); + await createInscription({ + payload: { + network: { + type: network, + }, + contentType: 'text/plain', + content: content, + payloadType: 'PLAIN_TEXT', + }, + onFinish: (response) => { + alert(response.txId); + }, + onCancel: () => alert('Canceled'), + }); + })().catch(console.error); + }, [content]); + + return ( + +

Create Inscription

+

Sample BRC20 deploy payload

+
{'{ "p": "brc-20","op": "deploy","tick": "rrfq","max": "21000000","lim": "1000"}'}
+ +

Sample BRC20 mint payload

+
{'{ "p": "brc-20","op": "mint","tick": "rrfq","amt": "1000" }'}
+ +

Inscription text/plain payload

+ setContent(e.target.value)} + /> + + +
+ ); +}; diff --git a/example/src/components/transferRunes/index.tsx b/example/src/components/transferRunes/index.tsx index a1931e2..71b3bef 100644 --- a/example/src/components/transferRunes/index.tsx +++ b/example/src/components/transferRunes/index.tsx @@ -1,6 +1,7 @@ import { useCallback, useMemo, useState } from 'react'; import Wallet, { BitcoinNetworkType } from 'sats-connect'; import { Button, Card, Input, Success } from '../../App.styles'; +import { getMempoolEndpoint } from '../../util'; interface Props { network: BitcoinNetworkType; @@ -52,13 +53,7 @@ const TransferRunes = ({ network }: Props) => { })().catch(console.error); }, [recipients]); - const explorerUrl = useMemo( - () => - network === BitcoinNetworkType.Mainnet - ? `https://mempool.space/tx/${txnId}` - : `https://mempool.space/testnet/tx/${txnId}`, - [network, txnId] - ); + const explorerUrl = useMemo(() => `${getMempoolEndpoint(network)}tx/${txnId}`, [network, txnId]); return ( diff --git a/example/src/util.ts b/example/src/util.ts new file mode 100644 index 0000000..af11e3c --- /dev/null +++ b/example/src/util.ts @@ -0,0 +1,17 @@ +import { BitcoinNetworkType } from '@sats-connect/core'; + +export function getMempoolEndpoint(network: BitcoinNetworkType): string { + let url = 'https://mempool.space/'; + switch (network) { + case BitcoinNetworkType.Testnet: + url += 'testnet/'; + break; + case BitcoinNetworkType.Signet: + url += 'signet/'; + break; + case BitcoinNetworkType.Testnet4: + url += 'testnet4/'; + break; + } + return url; +} diff --git a/package-lock.json b/package-lock.json index 1c9ec11..7239ee8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "sats-connect", - "version": "3.0.1", + "version": "3.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "sats-connect", - "version": "3.0.1", + "version": "3.0.2", "license": "ISC", "dependencies": { - "@sats-connect/core": "0.4.1", + "@sats-connect/core": "0.5.2", "@sats-connect/make-default-provider-config": "0.0.10", "@sats-connect/ui": "0.0.7" }, @@ -1716,9 +1716,9 @@ ] }, "node_modules/@sats-connect/core": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/@sats-connect/core/-/core-0.4.1.tgz", - "integrity": "sha512-//0ge/FbKQZdhfFBR7LKdJxpzVB+bGfqHwkjHl0EX3QwvAu8n0dSoUZlym43+KB7gy0rgv1+ECFrOCeYGpGFgA==", + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/@sats-connect/core/-/core-0.5.2.tgz", + "integrity": "sha512-i9bcmGX+ljJ/5MbCiu8CcpwOLNTgwV4MzOcItl0wzMswO7TMJ2wjTxjhjf3A6029Wbb+AKun5OLkmDf0jhuvCA==", "dependencies": { "axios": "1.7.7", "bitcoin-address-validation": "2.2.3", diff --git a/package.json b/package.json index ea3303c..1d8b8cd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sats-connect", - "version": "3.0.1", + "version": "3.0.2", "main": "dist/index.mjs", "files": [ "dist" @@ -24,7 +24,7 @@ ] }, "dependencies": { - "@sats-connect/core": "0.4.1", + "@sats-connect/core": "0.5.2", "@sats-connect/make-default-provider-config": "0.0.10", "@sats-connect/ui": "0.0.7" },