diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cf887821..4492939e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,60 +13,93 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 + + - name: Setup pnpm + uses: pnpm/action-setup@v2 + with: + version: 6.32.9 - name: Setup Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: 18 + node-version: '18' cache: 'pnpm' - name: Install dependencies - run: | - pnpm install - pnpm run build + run: pnpm install + + - name: Build + run: pnpm run build lint: runs-on: ubuntu-latest + needs: setup steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 + + - name: Setup pnpm + uses: pnpm/action-setup@v2 + with: + version: 6.32.9 + - name: Setup Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: 18 + node-version: '18' cache: 'pnpm' + - name: Install dependencies run: pnpm install + - name: Lint code run: pnpm lint test: runs-on: ubuntu-latest + needs: setup steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 + + - name: Setup pnpm + uses: pnpm/action-setup@v2 + with: + version: 6.32.9 + - name: Setup Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: 18 + node-version: '18' cache: 'pnpm' + - name: Install dependencies run: pnpm install + - name: Run tests run: pnpm test format: runs-on: ubuntu-latest + needs: setup steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 + + - name: Setup pnpm + uses: pnpm/action-setup@v2 + with: + version: 6.32.9 + - name: Setup Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: 18 + node-version: '18' cache: 'pnpm' + - name: Install dependencies run: pnpm install + - name: Format code run: pnpm format diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8b21376f..af7caf99 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,15 +8,14 @@ on: jobs: release: runs-on: ubuntu-latest + steps: - name: Checkout repository uses: actions/checkout@v3 - - name: Setup Node.js - uses: actions/setup-node@v3 + - uses: pnpm/action-setup@v4 with: - node-version: 18 - cache: 'pnpm' + version: 9 - name: Install dependencies run: pnpm install @@ -25,15 +24,22 @@ jobs: run: pnpx changeset version - name: Push Changeset version update - run: echo "Pushing Changeset version update" -# run: | -# git config --global user.name "github-actions[bot]" -# git config --global user.email "github-actions[bot]@users.noreply.github.com" -# git add . -# git commit -m "Version Packages" -# git push -# -# - name: Publish to npm -# run: pnpm publish --access public -# env: -# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git add . + git commit -m "Version Packages" + git push + + - name: Create GitHub Release + uses: changesets/action@v2 + with: + publish: false + version: false + changelog: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # Echo statement instead of publishing to npm (for now) + - name: Echo publish action + run: echo "This is where the package would be published to npm." diff --git a/README.md b/README.md index 6d922ef7..c22e166f 100644 --- a/README.md +++ b/README.md @@ -14,10 +14,10 @@ A common wallet interface for building React applications on Bitcoin. ![Version](https://img.shields.io/npm/v/@omnisat/lasereyes) ![license](https://img.shields.io/github/license/omnisat/lasereyes.svg?style=flat-square) - --- ## Don't Trust, Verify + [Try It Out](https://demo.lasereyes.build) ## Documentation diff --git a/apps/demo.lasereyes.build/app/api/authorize/route.ts b/apps/demo.lasereyes.build/app/api/authorize/route.ts index 9d8ab859..51bdf819 100644 --- a/apps/demo.lasereyes.build/app/api/authorize/route.ts +++ b/apps/demo.lasereyes.build/app/api/authorize/route.ts @@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from 'next/server' import { Verifier } from 'bip322-js' import * as jwt from 'jsonwebtoken' -const SECRET_KEY = process.env.JWT_SECRET_KEY +const SECRET_KEY = String(process.env.JWT_SECRET_KEY) export const POST = async (req: NextRequest) => { try { diff --git a/apps/demo.lasereyes.build/app/page.tsx b/apps/demo.lasereyes.build/app/page.tsx index e7eb5937..d4dbc1f2 100644 --- a/apps/demo.lasereyes.build/app/page.tsx +++ b/apps/demo.lasereyes.build/app/page.tsx @@ -11,9 +11,12 @@ import { import App from '@/components/App' import { useState } from 'react' -import dynamic from "next/dynamic"; +import dynamic from 'next/dynamic' -const DynamicLaserEyesProvider = dynamic(() => import('@omnisat/lasereyes-react').then((mod) => mod.LaserEyesProvider), { ssr: false }); +const DynamicLaserEyesProvider = dynamic( + () => import('@omnisat/lasereyes-react').then((mod) => mod.LaserEyesProvider), + { ssr: false } +) export default function Home() { const [network, setNetwork] = useState< diff --git a/apps/demo.lasereyes.build/components/ClickToCopyNpmInstallPill.tsx b/apps/demo.lasereyes.build/components/ClickToCopyNpmInstallPill.tsx index 3a893ed4..e78f9508 100644 --- a/apps/demo.lasereyes.build/components/ClickToCopyNpmInstallPill.tsx +++ b/apps/demo.lasereyes.build/components/ClickToCopyNpmInstallPill.tsx @@ -39,7 +39,7 @@ export const ClickToCopyNpmInstallPill = ({
diff --git a/apps/demo.lasereyes.build/components/ui/avatar.tsx b/apps/demo.lasereyes.build/components/ui/avatar.tsx index 51e507ba..4ea9b930 100644 --- a/apps/demo.lasereyes.build/components/ui/avatar.tsx +++ b/apps/demo.lasereyes.build/components/ui/avatar.tsx @@ -1,9 +1,9 @@ -"use client" +'use client' -import * as React from "react" -import * as AvatarPrimitive from "@radix-ui/react-avatar" +import * as React from 'react' +import * as AvatarPrimitive from '@radix-ui/react-avatar' -import { cn } from "@/lib/utils" +import { cn } from '@/lib/utils' const Avatar = React.forwardRef< React.ElementRef, @@ -12,7 +12,7 @@ const Avatar = React.forwardRef< (({ className, ...props }, ref) => ( )) @@ -39,7 +39,7 @@ const AvatarFallback = React.forwardRef< , @@ -13,13 +13,13 @@ const Checkbox = React.forwardRef< diff --git a/apps/demo.lasereyes.build/components/ui/input.tsx b/apps/demo.lasereyes.build/components/ui/input.tsx index 677d05fd..d52138b9 100644 --- a/apps/demo.lasereyes.build/components/ui/input.tsx +++ b/apps/demo.lasereyes.build/components/ui/input.tsx @@ -1,6 +1,6 @@ -import * as React from "react" +import * as React from 'react' -import { cn } from "@/lib/utils" +import { cn } from '@/lib/utils' export interface InputProps extends React.InputHTMLAttributes {} @@ -11,7 +11,7 @@ const Input = React.forwardRef( ( ) } ) -Input.displayName = "Input" +Input.displayName = 'Input' export { Input } diff --git a/apps/demo.lasereyes.build/components/ui/sonner.d.ts b/apps/demo.lasereyes.build/components/ui/sonner.d.ts index be6f195e..cd6157fe 100644 --- a/apps/demo.lasereyes.build/components/ui/sonner.d.ts +++ b/apps/demo.lasereyes.build/components/ui/sonner.d.ts @@ -1,5 +1,7 @@ -import { Toaster as Sonner } from "sonner"; -type ToasterProps = React.ComponentProps; -declare const Toaster: ({ ...props }: ToasterProps) => import("react/jsx-runtime").JSX.Element; -export { Toaster }; -//# sourceMappingURL=sonner.d.ts.map \ No newline at end of file +import { Toaster as Sonner } from 'sonner' +type ToasterProps = React.ComponentProps +declare const Toaster: ({ + ...props +}: ToasterProps) => import('react/jsx-runtime').JSX.Element +export { Toaster } +//# sourceMappingURL=sonner.d.ts.map diff --git a/apps/demo.lasereyes.build/components/ui/sonner.tsx b/apps/demo.lasereyes.build/components/ui/sonner.tsx index 452f4d9f..595cff5c 100644 --- a/apps/demo.lasereyes.build/components/ui/sonner.tsx +++ b/apps/demo.lasereyes.build/components/ui/sonner.tsx @@ -1,26 +1,26 @@ -"use client" +'use client' -import { useTheme } from "next-themes" -import { Toaster as Sonner } from "sonner" +import { useTheme } from 'next-themes' +import { Toaster as Sonner } from 'sonner' type ToasterProps = React.ComponentProps const Toaster = ({ ...props }: ToasterProps) => { - const { theme = "system" } = useTheme() + const { theme = 'system' } = useTheme() return ( { - console.log("state changed", state); -}); + console.log('state changed', state) +}) client.$network.listen((network) => { - console.log("Network changed", network); -}); + console.log('Network changed', network) +}) diff --git a/packages/lasereyes-core/src/client/providers/index.ts b/packages/lasereyes-core/src/client/providers/index.ts index 7bde2ef7..8f879f7e 100644 --- a/packages/lasereyes-core/src/client/providers/index.ts +++ b/packages/lasereyes-core/src/client/providers/index.ts @@ -1,56 +1,56 @@ -import { MapStore, WritableAtom } from "nanostores"; -import { LaserEyesStoreType } from "../types"; -import { Config, NetworkType, ProviderType } from "../../types"; -import { LaserEyesClient } from ".."; +import { MapStore, WritableAtom } from 'nanostores' +import { LaserEyesStoreType } from '../types' +import { Config, NetworkType, ProviderType } from '../../types' +import { LaserEyesClient } from '..' export const UNSUPPORTED_PROVIDER_METHOD_ERROR = new Error( "The connected wallet doesn't support this method..." -); -export const WALLET_NOT_INSTALLED_ERROR = new Error("Wallet is not installed"); +) +export const WALLET_NOT_INSTALLED_ERROR = new Error('Wallet is not installed') export abstract class WalletProvider { - readonly $store: MapStore; - readonly $network: WritableAtom; + readonly $store: MapStore + readonly $network: WritableAtom constructor( stores: { - readonly $store: MapStore; - readonly $network: WritableAtom; + readonly $store: MapStore + readonly $network: WritableAtom }, readonly parent: LaserEyesClient, readonly config?: Config ) { - this.$store = stores.$store; - this.$network = stores.$network; + this.$store = stores.$store + this.$network = stores.$network - this.initialize(); + this.initialize() } disconnect(): void {} - abstract initialize(): void; + abstract initialize(): void - abstract dispose(): void; + abstract dispose(): void - abstract connect(defaultWallet: ProviderType): Promise; + abstract connect(defaultWallet: ProviderType): Promise - abstract requestAccounts(): Promise; + abstract requestAccounts(): Promise switchNetwork(_network: NetworkType): void { - this.parent.disconnect(); - throw UNSUPPORTED_PROVIDER_METHOD_ERROR; + this.parent.disconnect() + throw UNSUPPORTED_PROVIDER_METHOD_ERROR } - abstract getNetwork(): Promise; + abstract getNetwork(): Promise - abstract getPublicKey(): Promise; + abstract getPublicKey(): Promise - abstract getBalance(): Promise; + abstract getBalance(): Promise - abstract getInscriptions(): Promise; + abstract getInscriptions(): Promise - abstract sendBTC(to: string, amount: number): Promise; + abstract sendBTC(to: string, amount: number): Promise - abstract signMessage(message: string, toSignAddress?: string): Promise; + abstract signMessage(message: string, toSignAddress?: string): Promise abstract signPsbt( tx: string, @@ -60,12 +60,12 @@ export abstract class WalletProvider { broadcast?: boolean ): Promise< | { - signedPsbtHex: string | undefined; - signedPsbtBase64: string | undefined; - txId?: string; + signedPsbtHex: string | undefined + signedPsbtBase64: string | undefined + txId?: string } | undefined - >; + > - abstract pushPsbt(tx: string): Promise; + abstract pushPsbt(tx: string): Promise } diff --git a/packages/lasereyes-core/src/client/providers/oyl.ts b/packages/lasereyes-core/src/client/providers/oyl.ts index d8f363bd..2406b7aa 100644 --- a/packages/lasereyes-core/src/client/providers/oyl.ts +++ b/packages/lasereyes-core/src/client/providers/oyl.ts @@ -1,205 +1,205 @@ -import * as bitcoin from "bitcoinjs-lib"; -import {UNSUPPORTED_PROVIDER_METHOD_ERROR, WalletProvider} from "."; -import { ProviderType, NetworkType } from "../../types"; -import {createSendBtcPsbt, getBTCBalance} from "../../lib/helpers"; -import {OYL} from "../../constants/wallets"; -import {listenKeys, MapStore} from "nanostores"; -import {persistentMap} from "@nanostores/persistent"; -import {LaserEyesStoreType} from "../types.ts"; +import * as bitcoin from 'bitcoinjs-lib' +import { UNSUPPORTED_PROVIDER_METHOD_ERROR, WalletProvider } from '.' +import { ProviderType, NetworkType } from '../../types' +import { createSendBtcPsbt, getBTCBalance } from '../../lib/helpers' +import { OYL } from '../../constants/wallets' +import { listenKeys, MapStore } from 'nanostores' +import { persistentMap } from '@nanostores/persistent' +import { LaserEyesStoreType } from '../types.ts' const keysToPersist = [ - "address", - "paymentAddress", - "publicKey", - "paymentPublicKey", - "balance", -] as const; + 'address', + 'paymentAddress', + 'publicKey', + 'paymentPublicKey', + 'balance', +] as const -type PersistedKey = (typeof keysToPersist)[number]; +type PersistedKey = (typeof keysToPersist)[number] -const OYL_WALLET_PERSISTENCE_KEY = "OYL_CONNECTED_WALLET_STATE"; +const OYL_WALLET_PERSISTENCE_KEY = 'OYL_CONNECTED_WALLET_STATE' export default class OylProvider extends WalletProvider { - public get library(): any | undefined { - return (window as any).oyl; - } - - public get network(): NetworkType { - return this.$network.get(); - } - - observer?: MutationObserver; - $valueStore: MapStore> = persistentMap( - OYL_WALLET_PERSISTENCE_KEY, - { - address: "", - paymentAddress: "", - paymentPublicKey: "", - publicKey: "", - balance: "", + public get library(): any | undefined { + return (window as any).oyl + } + + public get network(): NetworkType { + return this.$network.get() + } + + observer?: MutationObserver + $valueStore: MapStore> = persistentMap( + OYL_WALLET_PERSISTENCE_KEY, + { + address: '', + paymentAddress: '', + paymentPublicKey: '', + publicKey: '', + balance: '', + } + ) + + removeSubscriber?: Function + + restorePersistedValues() { + const vals = this.$valueStore.get() + for (const key of keysToPersist) { + this.$store.setKey(key, vals[key]) + } + } + + watchStateChange( + newState: LaserEyesStoreType, + _: LaserEyesStoreType | undefined, + changedKey: keyof LaserEyesStoreType | undefined + ) { + if (changedKey && newState.provider === OYL) { + if (changedKey === 'balance') { + this.$valueStore.setKey('balance', newState.balance?.toString() ?? '') + } else if ((keysToPersist as readonly string[]).includes(changedKey)) { + this.$valueStore.setKey( + changedKey as PersistedKey, + newState[changedKey]?.toString() ?? '' + ) + } + } + } + + initialize() { + console.log('initializing') + listenKeys(this.$store, ['provider'], (newStore) => { + if (newStore.provider !== OYL) { + if (this.removeSubscriber) { + this.$valueStore.set({ + address: '', + publicKey: '', + paymentAddress: '', + paymentPublicKey: '', + balance: '', + }) + this.removeSubscriber() + this.removeSubscriber = undefined } - ); - - removeSubscriber?: Function; - - restorePersistedValues() { - const vals = this.$valueStore.get(); - for (const key of keysToPersist) { - this.$store.setKey(key, vals[key]); - } - } - - watchStateChange( - newState: LaserEyesStoreType, - _: LaserEyesStoreType | undefined, - changedKey: keyof LaserEyesStoreType | undefined - ) { - if (changedKey && newState.provider === OYL) { - if (changedKey === "balance") { - this.$valueStore.setKey("balance", newState.balance?.toString() ?? ""); - } else if ((keysToPersist as readonly string[]).includes(changedKey)) { - this.$valueStore.setKey( - changedKey as PersistedKey, - newState[changedKey]?.toString() ?? "" - ); - } - } - } - - initialize() { - console.log("initializing") - listenKeys(this.$store, ["provider"], (newStore) => { - if (newStore.provider !== OYL) { - if (this.removeSubscriber) { - this.$valueStore.set({ - address: "", - publicKey: "", - paymentAddress: "", - paymentPublicKey: "", - balance: "", - }); - this.removeSubscriber(); - this.removeSubscriber = undefined; - } - } else { - this.removeSubscriber = this.$store.subscribe( - this.watchStateChange.bind(this) - ); - } - }); - - this.observer = new window.MutationObserver(() => { - const oylLib = (window as any)?.oyl; - if (oylLib) { - this.$store.setKey("hasProvider", { - ...this.$store.get().hasProvider, - [OYL]: true, - }); - this.observer?.disconnect(); - } - }); - this.observer.observe(document, { childList: true, subtree: true }); - } - - dispose() { - this.observer?.disconnect(); - } - - async connect(_: ProviderType): Promise { - if (!this.library) throw new Error("Oyl isn't installed"); - const { nativeSegwit, taproot } = await this.library.getAddresses(); - if (!nativeSegwit || !taproot) throw new Error("No accounts found"); - this.$store.setKey("address", taproot.address); - this.$store.setKey("paymentAddress", nativeSegwit.address); - this.$store.setKey("publicKey", taproot.publicKey); - this.$store.setKey("paymentPublicKey", nativeSegwit.publicKey); - this.$store.setKey("provider", OYL); - - // TODO: Confirm if this is necessary and why - getBTCBalance(nativeSegwit.address, this.network).then((totalBalance) => { - this.$store.setKey("balance", totalBalance); - }); - this.$store.setKey("connected", true); - const balance = await this.getBalance(); - if (balance) this.$store.setKey("balance", balance); - } - - async getNetwork() { - return this.network; - } - - async sendBTC(to: string, amount: number): Promise { - const { psbtHex } = await createSendBtcPsbt( - this.$store.get().address, - this.$store.get().paymentAddress, - to, - amount, - this.$store.get().paymentPublicKey, - this.network, - 7 - ); - const psbt = await this.signPsbt("", psbtHex, "", true, true); - if (!psbt) throw new Error("Error sending BTC"); - // @ts-ignore - return psbt.txId; - } - async signMessage(message: string, toSignAddress?: string): Promise { - const tempAddy = toSignAddress || this.$store.get().paymentAddress; - const response = await this.library.signMessage({ - address: tempAddy, - message, - }); - return response.signature; - } - async signPsbt( - _: string, - psbtHex: string, - __: string, - finalize?: boolean | undefined, - broadcast?: boolean | undefined - ): Promise< - | { - signedPsbtHex: string | undefined; - signedPsbtBase64: string | undefined; - txId?: string | undefined; - } - | undefined - > { - const { psbt, txid } = await this.library.signPsbt({ - psbt: psbtHex, - finalize, - broadcast, - }); - const psbtSignedPsbt = bitcoin.Psbt.fromHex(psbt); - return { - signedPsbtHex: psbtSignedPsbt.toHex(), - signedPsbtBase64: psbtSignedPsbt.toBase64(), - txId: txid, - }; - } - async pushPsbt(tx: string): Promise { - const response = await this.library.pushPsbt({ psbt: tx }); - return response.txid; - } - - async getPublicKey() { - return await this.library?.getPublicKey(); - } - async getBalance() { - const {total} = await this.library.getBalance(); - this.$store.setKey("balance", total); - return total; - } - - async getInscriptions(): Promise { - return await this.library.getInscriptions(0, 10); - } - - async requestAccounts(): Promise { - return await this.library.requestAccounts(); - } - - async switchNetwork(): Promise { - throw UNSUPPORTED_PROVIDER_METHOD_ERROR; - } + } else { + this.removeSubscriber = this.$store.subscribe( + this.watchStateChange.bind(this) + ) + } + }) + + this.observer = new window.MutationObserver(() => { + const oylLib = (window as any)?.oyl + if (oylLib) { + this.$store.setKey('hasProvider', { + ...this.$store.get().hasProvider, + [OYL]: true, + }) + this.observer?.disconnect() + } + }) + this.observer.observe(document, { childList: true, subtree: true }) + } + + dispose() { + this.observer?.disconnect() + } + + async connect(_: ProviderType): Promise { + if (!this.library) throw new Error("Oyl isn't installed") + const { nativeSegwit, taproot } = await this.library.getAddresses() + if (!nativeSegwit || !taproot) throw new Error('No accounts found') + this.$store.setKey('address', taproot.address) + this.$store.setKey('paymentAddress', nativeSegwit.address) + this.$store.setKey('publicKey', taproot.publicKey) + this.$store.setKey('paymentPublicKey', nativeSegwit.publicKey) + this.$store.setKey('provider', OYL) + + // TODO: Confirm if this is necessary and why + getBTCBalance(nativeSegwit.address, this.network).then((totalBalance) => { + this.$store.setKey('balance', totalBalance) + }) + this.$store.setKey('connected', true) + const balance = await this.getBalance() + if (balance) this.$store.setKey('balance', balance) + } + + async getNetwork() { + return this.network + } + + async sendBTC(to: string, amount: number): Promise { + const { psbtHex } = await createSendBtcPsbt( + this.$store.get().address, + this.$store.get().paymentAddress, + to, + amount, + this.$store.get().paymentPublicKey, + this.network, + 7 + ) + const psbt = await this.signPsbt('', psbtHex, '', true, true) + if (!psbt) throw new Error('Error sending BTC') + // @ts-ignore + return psbt.txId + } + async signMessage(message: string, toSignAddress?: string): Promise { + const tempAddy = toSignAddress || this.$store.get().paymentAddress + const response = await this.library.signMessage({ + address: tempAddy, + message, + }) + return response.signature + } + async signPsbt( + _: string, + psbtHex: string, + __: string, + finalize?: boolean | undefined, + broadcast?: boolean | undefined + ): Promise< + | { + signedPsbtHex: string | undefined + signedPsbtBase64: string | undefined + txId?: string | undefined + } + | undefined + > { + const { psbt, txid } = await this.library.signPsbt({ + psbt: psbtHex, + finalize, + broadcast, + }) + const psbtSignedPsbt = bitcoin.Psbt.fromHex(psbt) + return { + signedPsbtHex: psbtSignedPsbt.toHex(), + signedPsbtBase64: psbtSignedPsbt.toBase64(), + txId: txid, + } + } + async pushPsbt(tx: string): Promise { + const response = await this.library.pushPsbt({ psbt: tx }) + return response.txid + } + + async getPublicKey() { + return await this.library?.getPublicKey() + } + async getBalance() { + const { total } = await this.library.getBalance() + this.$store.setKey('balance', total) + return total + } + + async getInscriptions(): Promise { + return await this.library.getInscriptions(0, 10) + } + + async requestAccounts(): Promise { + return await this.library.requestAccounts() + } + + async switchNetwork(): Promise { + throw UNSUPPORTED_PROVIDER_METHOD_ERROR + } } diff --git a/packages/lasereyes-core/src/client/providers/wizz.ts b/packages/lasereyes-core/src/client/providers/wizz.ts index 904909e4..c9ac95cf 100644 --- a/packages/lasereyes-core/src/client/providers/wizz.ts +++ b/packages/lasereyes-core/src/client/providers/wizz.ts @@ -1,5 +1,5 @@ -import axios from "axios"; -import { WALLET_NOT_INSTALLED_ERROR, WalletProvider } from "."; +import axios from 'axios' +import { WALLET_NOT_INSTALLED_ERROR, WalletProvider } from '.' import { NetworkType, WizzBalanceResponse, @@ -8,147 +8,146 @@ import { WIZZ_MAINNET, getNetworkForWizz, WIZZ, -} from "../.."; -import { getMempoolSpaceUrl } from "../../lib/urls"; -import * as bitcoin from "bitcoinjs-lib"; -import { listenKeys } from "nanostores"; +} from '../..' +import { getMempoolSpaceUrl } from '../../lib/urls' +import * as bitcoin from 'bitcoinjs-lib' +import { listenKeys } from 'nanostores' export class WizzProvider extends WalletProvider { public get library(): any | undefined { - return (window as any).wizz; + return (window as any).wizz } public get network(): string { - return this.$network.get(); + return this.$network.get() } - observer?: MutationObserver; + observer?: MutationObserver private handleNetworkChanged(_network: NetworkType) { // const foundNetwork = getNetworkForWizz(_network); // this.$network.set(foundNetwork); - this.parent.connect(WIZZ); + this.parent.connect(WIZZ) } private handleAccountsChanged(accounts: string[]) { if (!accounts.length) { - this.parent.disconnect(); - return; + this.parent.disconnect() + return } if (this.$store.get().accounts[0] === accounts[0]) { - return; + return } - this.$store.setKey("accounts", accounts); + this.$store.setKey('accounts', accounts) } initialize(): void { - listenKeys(this.$store, ["provider"], (value) => { + listenKeys(this.$store, ['provider'], (value) => { if (value.provider === WIZZ) { - this.addLibraryListeners(); + this.addLibraryListeners() } else { - this.removeLibraryListeners(); + this.removeLibraryListeners() } - }); + }) this.observer = new window.MutationObserver(() => { if (this.library) { - this.$store.setKey("hasProvider", { + this.$store.setKey('hasProvider', { ...this.$store.get().hasProvider, [WIZZ]: true, - }); - this.observer?.disconnect(); + }) + this.observer?.disconnect() } - }); - this.observer.observe(document, { childList: true, subtree: true }); + }) + this.observer.observe(document, { childList: true, subtree: true }) } private removeLibraryListeners() { this.library?.removeListener( - "networkChanged", + 'networkChanged', this.handleNetworkChanged.bind(this) - ); + ) this.library?.removeListener( - "accountsChanged", + 'accountsChanged', this.handleAccountsChanged.bind(this) - ); + ) } private addLibraryListeners() { - this.library?.on("networkChanged", this.handleNetworkChanged.bind(this)); - this.library?.on("accountsChanged", this.handleAccountsChanged.bind(this)); + this.library?.on('networkChanged', this.handleNetworkChanged.bind(this)) + this.library?.on('accountsChanged', this.handleAccountsChanged.bind(this)) } dispose(): void { - this.observer?.disconnect(); - this.removeLibraryListeners(); + this.observer?.disconnect() + this.removeLibraryListeners() } async connect(): Promise { - if (!this.library) throw WALLET_NOT_INSTALLED_ERROR; - const wizzAccounts = await this.library.requestAccounts(); - if (!wizzAccounts) throw new Error("No accounts found"); - const wizzPubKey = await this.library.getPublicKey(); - if (!wizzPubKey) throw new Error("No public key found"); - this.$store.setKey("accounts", wizzAccounts); - this.$store.setKey("address", wizzAccounts[0]); - this.$store.setKey("paymentAddress", wizzAccounts[0]); - this.$store.setKey("publicKey", wizzPubKey); - this.$store.setKey("paymentPublicKey", wizzPubKey); - - this.$store.setKey("provider", WIZZ); + if (!this.library) throw WALLET_NOT_INSTALLED_ERROR + const wizzAccounts = await this.library.requestAccounts() + if (!wizzAccounts) throw new Error('No accounts found') + const wizzPubKey = await this.library.getPublicKey() + if (!wizzPubKey) throw new Error('No public key found') + this.$store.setKey('accounts', wizzAccounts) + this.$store.setKey('address', wizzAccounts[0]) + this.$store.setKey('paymentAddress', wizzAccounts[0]) + this.$store.setKey('publicKey', wizzPubKey) + this.$store.setKey('paymentPublicKey', wizzPubKey) + + this.$store.setKey('provider', WIZZ) await this.getNetwork().then((network) => { if (network && this.config?.network !== network) { - this.parent.switchNetwork(network); + this.parent.switchNetwork(network) } - }); - await this.parent.getBalance(); - this.$store.setKey("connected", true); + }) + await this.parent.getBalance() + this.$store.setKey('connected', true) } async requestAccounts(): Promise { - return await this.library.requestAccounts(); + return await this.library.requestAccounts() } async getNetwork(): Promise { - const wizzNetwork = await this.library?.getNetwork(); - return wizzNetwork ? getNetworkForWizz(wizzNetwork) : undefined; + const wizzNetwork = await this.library?.getNetwork() + return wizzNetwork ? getNetworkForWizz(wizzNetwork) : undefined } async switchNetwork(_network: NetworkType): Promise { if (_network === FRACTAL_TESTNET || _network === FRACTAL_MAINNET) { - return await this.library.switchNetwork(WIZZ_MAINNET); + return await this.library.switchNetwork(WIZZ_MAINNET) } - const wantedNetwork = getNetworkForWizz(_network); - await this.library?.switchNetwork(wantedNetwork); - this.$network.set(_network); - await this.parent.getBalance(); + const wantedNetwork = getNetworkForWizz(_network) + await this.library?.switchNetwork(wantedNetwork) + this.$network.set(_network) + await this.parent.getBalance() } async getPublicKey(): Promise { - return await this.library?.getPublicKey(); + return await this.library?.getPublicKey() } async getBalance(): Promise { - const balanceResponse: WizzBalanceResponse = - await this.library.getBalance(); - return balanceResponse.total; + const balanceResponse: WizzBalanceResponse = await this.library.getBalance() + return balanceResponse.total } async getInscriptions(): Promise { - return await this.library.getInscriptions(0, 10); + return await this.library.getInscriptions(0, 10) } async sendBTC(to: string, amount: number): Promise { - const txId = await this.library?.sendBitcoin(to, amount); + const txId = await this.library?.sendBitcoin(to, amount) if (txId) { - return txId; + return txId } else { - throw new Error("Error sending BTC"); + throw new Error('Error sending BTC') } } async signMessage(message: string): Promise { - return await this.library?.signMessage(message); + return await this.library?.signMessage(message) } async signPsbt( @@ -159,34 +158,34 @@ export class WizzProvider extends WalletProvider { broadcast?: boolean | undefined ): Promise< | { - signedPsbtHex: string | undefined; - signedPsbtBase64: string | undefined; - txId?: string | undefined; + signedPsbtHex: string | undefined + signedPsbtBase64: string | undefined + txId?: string | undefined } | undefined > { const signedPsbt = await this.library?.signPsbt(psbtHex, { autoFinalized: finalize, broadcast: false, - }); + }) - const psbtSignedPsbt = bitcoin.Psbt.fromHex(signedPsbt); + const psbtSignedPsbt = bitcoin.Psbt.fromHex(signedPsbt) - let txId; + let txId if (finalize && broadcast) { - txId = await this.pushPsbt(signedPsbt); + txId = await this.pushPsbt(signedPsbt) } return { signedPsbtHex: psbtSignedPsbt.toHex(), signedPsbtBase64: psbtSignedPsbt.toBase64(), txId: txId, - }; + } } async pushPsbt(tx: string): Promise { return await axios .post(`${getMempoolSpaceUrl(this.$network.get())}/api/tx`, tx) - .then((res) => res.data); + .then((res) => res.data) } } diff --git a/packages/lasereyes-core/src/client/types.ts b/packages/lasereyes-core/src/client/types.ts index 05ad24cf..d518469c 100644 --- a/packages/lasereyes-core/src/client/types.ts +++ b/packages/lasereyes-core/src/client/types.ts @@ -1,15 +1,15 @@ -import { ProviderType } from "../types"; +import { ProviderType } from '../types' export type LaserEyesStoreType = { - provider: ProviderType | undefined; - address: string; - paymentAddress: string; - publicKey: string; - paymentPublicKey: string; - connected: boolean; - isConnecting: boolean; - isInitializing: boolean; - accounts: string[]; - balance: bigint | undefined; - hasProvider: Record; -}; \ No newline at end of file + provider: ProviderType | undefined + address: string + paymentAddress: string + publicKey: string + paymentPublicKey: string + connected: boolean + isConnecting: boolean + isInitializing: boolean + accounts: string[] + balance: bigint | undefined + hasProvider: Record +} diff --git a/packages/lasereyes-core/src/constants/index.ts b/packages/lasereyes-core/src/constants/index.ts index 75fd92ca..3341c441 100644 --- a/packages/lasereyes-core/src/constants/index.ts +++ b/packages/lasereyes-core/src/constants/index.ts @@ -1,3 +1,3 @@ -export * from "./networks"; -export * from "./wallets"; -export * from "./settings"; +export * from './networks' +export * from './wallets' +export * from './settings' diff --git a/packages/lasereyes-core/src/constants/settings.ts b/packages/lasereyes-core/src/constants/settings.ts index a97ffe4c..c3777bbf 100644 --- a/packages/lasereyes-core/src/constants/settings.ts +++ b/packages/lasereyes-core/src/constants/settings.ts @@ -1 +1 @@ -export const LOCAL_STORAGE_DEFAULT_WALLET = "defaultWallet"; \ No newline at end of file +export const LOCAL_STORAGE_DEFAULT_WALLET = 'defaultWallet' diff --git a/packages/lasereyes-core/src/constants/wallets.ts b/packages/lasereyes-core/src/constants/wallets.ts index 5eced5bf..31ab76bd 100644 --- a/packages/lasereyes-core/src/constants/wallets.ts +++ b/packages/lasereyes-core/src/constants/wallets.ts @@ -1,45 +1,45 @@ -export const OYL = "oyl"; -export const UNISAT = "unisat"; -export const XVERSE = "xverse"; -export const PHANTOM = "phantom"; -export const LEATHER = "leather"; -export const MAGIC_EDEN = "magic-eden"; -export const OKX = "okx"; -export const WIZZ = "wizz"; -export const ORANGE = "orange"; +export const OYL = 'oyl' +export const UNISAT = 'unisat' +export const XVERSE = 'xverse' +export const PHANTOM = 'phantom' +export const LEATHER = 'leather' +export const MAGIC_EDEN = 'magic-eden' +export const OKX = 'okx' +export const WIZZ = 'wizz' +export const ORANGE = 'orange' -export const P2TR = "p2tr"; -export const P2PKH = "p2pkh"; -export const P2WPKH = "p2wpkh"; -export const P2PSH = "p2psh"; -export const P2WSH = "p2wsh"; -export const P2SH = "p2sh"; +export const P2TR = 'p2tr' +export const P2PKH = 'p2pkh' +export const P2WPKH = 'p2wpkh' +export const P2PSH = 'p2psh' +export const P2WSH = 'p2wsh' +export const P2SH = 'p2sh' export const WALLETS = { oyl: { name: OYL, - icon: "data:image/svg+xml,%3Csvg%20width%3D%2296%22%20height%3D%2216%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M17.27.318c2.947%200%205.72.26%208.32.78%202.6.507%204.714%201.307%206.34%202.4%201.64%201.094%202.46%202.467%202.46%204.12%200%201.654-.82%203.047-2.46%204.18-1.64%201.12-3.766%201.954-6.38%202.5-2.6.547-5.36.82-8.28.82-2.946%200-5.72-.253-8.32-.76-2.6-.52-4.72-1.326-6.36-2.42C.964%2010.845.15%209.472.15%207.818c0-1.653.82-3.04%202.46-4.16%201.64-1.133%203.76-1.973%206.36-2.52%202.614-.546%205.38-.82%208.3-.82Zm.04%2011.96c1.4%200%202.8-.146%204.2-.44%201.414-.293%202.6-.78%203.56-1.46.96-.68%201.44-1.566%201.44-2.66%200-1.093-.48-1.98-1.44-2.66-.96-.68-2.146-1.166-3.56-1.46-1.4-.293-2.8-.44-4.2-.44h-.08c-1.4%200-2.806.147-4.22.44-1.4.294-2.58.78-3.54%201.46-.96.68-1.44%201.567-1.44%202.66%200%201.094.48%201.98%201.44%202.66.96.68%202.14%201.167%203.54%201.46%201.414.294%202.82.44%204.22.44h.08ZM61.293.758c.08-.026.14-.04.18-.04h8.24c.12%200%20.214.04.28.12.08.08.12.174.12.28%200%20.147-.066.26-.2.34l-14%207.7c-.133.067-.2.18-.2.34v4.82c0%20.107-.04.2-.12.28a.384.384%200%200%201-.28.12h-6.94c-.106%200-.2-.04-.28-.12a.384.384%200%200%201-.12-.28v-4.82c0-.16-.066-.273-.2-.34l-13.98-7.7a.376.376%200%200%201-.2-.34c0-.106.034-.2.1-.28.067-.08.16-.12.28-.12h8.24c.054%200%20.12.014.2.04l9.24%205.1c.08.027.147.04.2.04.04%200%20.1-.013.18-.04l9.26-5.1Zm11.232.36c0-.106.033-.2.1-.28.08-.08.173-.12.28-.12h6.84c.106%200%20.193.04.26.12.08.08.12.174.12.28v10.32c0%20.107.04.2.12.28.08.08.173.12.28.12h14.46c.106%200%20.193.04.26.12.08.08.12.174.12.28v2.08c0%20.107-.04.2-.12.28a.322.322%200%200%201-.26.12h-22.08c-.107%200-.2-.04-.28-.12a.424.424%200%200%201-.1-.28v-13.2Z%22%20fill%3D%22%23fff%22%2F%3E%3C%2Fsvg%3E", - site: "https://oyl.io/", + icon: 'data:image/svg+xml,%3Csvg%20width%3D%2296%22%20height%3D%2216%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M17.27.318c2.947%200%205.72.26%208.32.78%202.6.507%204.714%201.307%206.34%202.4%201.64%201.094%202.46%202.467%202.46%204.12%200%201.654-.82%203.047-2.46%204.18-1.64%201.12-3.766%201.954-6.38%202.5-2.6.547-5.36.82-8.28.82-2.946%200-5.72-.253-8.32-.76-2.6-.52-4.72-1.326-6.36-2.42C.964%2010.845.15%209.472.15%207.818c0-1.653.82-3.04%202.46-4.16%201.64-1.133%203.76-1.973%206.36-2.52%202.614-.546%205.38-.82%208.3-.82Zm.04%2011.96c1.4%200%202.8-.146%204.2-.44%201.414-.293%202.6-.78%203.56-1.46.96-.68%201.44-1.566%201.44-2.66%200-1.093-.48-1.98-1.44-2.66-.96-.68-2.146-1.166-3.56-1.46-1.4-.293-2.8-.44-4.2-.44h-.08c-1.4%200-2.806.147-4.22.44-1.4.294-2.58.78-3.54%201.46-.96.68-1.44%201.567-1.44%202.66%200%201.094.48%201.98%201.44%202.66.96.68%202.14%201.167%203.54%201.46%201.414.294%202.82.44%204.22.44h.08ZM61.293.758c.08-.026.14-.04.18-.04h8.24c.12%200%20.214.04.28.12.08.08.12.174.12.28%200%20.147-.066.26-.2.34l-14%207.7c-.133.067-.2.18-.2.34v4.82c0%20.107-.04.2-.12.28a.384.384%200%200%201-.28.12h-6.94c-.106%200-.2-.04-.28-.12a.384.384%200%200%201-.12-.28v-4.82c0-.16-.066-.273-.2-.34l-13.98-7.7a.376.376%200%200%201-.2-.34c0-.106.034-.2.1-.28.067-.08.16-.12.28-.12h8.24c.054%200%20.12.014.2.04l9.24%205.1c.08.027.147.04.2.04.04%200%20.1-.013.18-.04l9.26-5.1Zm11.232.36c0-.106.033-.2.1-.28.08-.08.173-.12.28-.12h6.84c.106%200%20.193.04.26.12.08.08.12.174.12.28v10.32c0%20.107.04.2.12.28.08.08.173.12.28.12h14.46c.106%200%20.193.04.26.12.08.08.12.174.12.28v2.08c0%20.107-.04.2-.12.28a.322.322%200%200%201-.26.12h-22.08c-.107%200-.2-.04-.28-.12a.424.424%200%200%201-.1-.28v-13.2Z%22%20fill%3D%22%23fff%22%2F%3E%3C%2Fsvg%3E', + site: 'https://oyl.io/', disabled: false, }, unisat: { name: UNISAT, - icon: "/wallet-logos/unisat_logo.png", - site: "https://unisat.io/", + icon: '/wallet-logos/unisat_logo.png', + site: 'https://unisat.io/', disabled: false, }, xverse: { name: XVERSE, - icon: "/wallet-logos/xverse_logo.png", - site: "https://www.xverse.app/", + icon: '/wallet-logos/xverse_logo.png', + site: 'https://www.xverse.app/', config: () => {}, disabled: false, }, leather: { name: LEATHER, - icon: "/wallet-logos/leather_logo.png", - site: "https://leather.io/", + icon: '/wallet-logos/leather_logo.png', + site: 'https://leather.io/', config: () => {}, disabled: true, }, -}; +} diff --git a/packages/lasereyes-core/src/index.ts b/packages/lasereyes-core/src/index.ts index fd9a8359..3f983bca 100644 --- a/packages/lasereyes-core/src/index.ts +++ b/packages/lasereyes-core/src/index.ts @@ -1,9 +1,9 @@ -import { LaserEyesClient } from "./client"; -import { createStores } from "./client/utils"; -import { createConfig } from "./client/utils"; +import { LaserEyesClient } from './client' +import { createStores } from './client/utils' +import { createConfig } from './client/utils' -export { LaserEyesClient, createStores, createConfig }; -export * from "./types"; -export * from "./constants"; -export * from "./client/types"; -export * from "./client/providers"; +export { LaserEyesClient, createStores, createConfig } +export * from './types' +export * from './constants' +export * from './client/types' +export * from './client/providers' diff --git a/packages/lasereyes-core/src/lib/urls.ts b/packages/lasereyes-core/src/lib/urls.ts index 16c14953..6a3a87b5 100644 --- a/packages/lasereyes-core/src/lib/urls.ts +++ b/packages/lasereyes-core/src/lib/urls.ts @@ -5,16 +5,16 @@ import { SIGNET, TESTNET, TESTNET4, -} from "../constants/networks"; +} from '../constants/networks' -export const MEMPOOL_SPACE_URL = "https://mempool.space"; -export const MEMPOOL_SPACE_TESTNET_URL = "https://mempool.space/testnet"; -export const MEMPOOL_SPACE_TESTNET4_URL = "https://mempool.space/testnet4"; -export const MEMPOOL_SPACE_SIGNET_URL = "https://mempool.space/signet"; +export const MEMPOOL_SPACE_URL = 'https://mempool.space' +export const MEMPOOL_SPACE_TESTNET_URL = 'https://mempool.space/testnet' +export const MEMPOOL_SPACE_TESTNET4_URL = 'https://mempool.space/testnet4' +export const MEMPOOL_SPACE_SIGNET_URL = 'https://mempool.space/signet' export const MEMPOOL_SPACE_FRACTAL_MAINNET_URL = - "https://mempool.fractalbitcoin.io"; + 'https://mempool.fractalbitcoin.io' export const MEMPOOL_SPACE_FRACTAL_TESTNET_URL = - "https://mempool-testnet.fractalbitcoin.io"; + 'https://mempool-testnet.fractalbitcoin.io' export const getMempoolSpaceUrl = ( network: @@ -28,11 +28,11 @@ export const getMempoolSpaceUrl = ( network === TESTNET ? MEMPOOL_SPACE_TESTNET_URL : network === TESTNET4 - ? MEMPOOL_SPACE_TESTNET4_URL - : network === SIGNET - ? MEMPOOL_SPACE_SIGNET_URL - : network === FRACTAL_MAINNET - ? MEMPOOL_SPACE_FRACTAL_MAINNET_URL - : network === FRACTAL_TESTNET - ? MEMPOOL_SPACE_FRACTAL_TESTNET_URL - : MEMPOOL_SPACE_URL; \ No newline at end of file + ? MEMPOOL_SPACE_TESTNET4_URL + : network === SIGNET + ? MEMPOOL_SPACE_SIGNET_URL + : network === FRACTAL_MAINNET + ? MEMPOOL_SPACE_FRACTAL_MAINNET_URL + : network === FRACTAL_TESTNET + ? MEMPOOL_SPACE_FRACTAL_TESTNET_URL + : MEMPOOL_SPACE_URL diff --git a/packages/lasereyes-core/tsconfig.json b/packages/lasereyes-core/tsconfig.json index 77f1fe2e..4ac317c3 100644 --- a/packages/lasereyes-core/tsconfig.json +++ b/packages/lasereyes-core/tsconfig.json @@ -19,5 +19,5 @@ "noUnusedParameters": true, "noFallthroughCasesInSwitch": true }, - "include": ["src", "__tests__"], + "include": ["src"], } diff --git a/packages/lasereyes-react/lib/icons/index.tsx b/packages/lasereyes-react/lib/icons/index.tsx index 9c3c1b04..320acd74 100644 --- a/packages/lasereyes-react/lib/icons/index.tsx +++ b/packages/lasereyes-react/lib/icons/index.tsx @@ -1,11 +1,11 @@ -export * from "./oyl"; -export * from "./leather"; -export * from "./phantom"; -export * from "./xverse"; -export * from "./unisat"; -export * from "./wizz"; -export * from "./okx"; -export * from "./magiceden"; -export * from "./orange.tsx"; +export * from './oyl' +export * from './leather' +export * from './phantom' +export * from './xverse' +export * from './unisat' +export * from './wizz' +export * from './okx' +export * from './magiceden' +export * from './orange.tsx' -export * from "./walletIcon"; +export * from './walletIcon' diff --git a/packages/lasereyes-react/lib/icons/leather.tsx b/packages/lasereyes-react/lib/icons/leather.tsx index 463245d0..8e484111 100644 --- a/packages/lasereyes-react/lib/icons/leather.tsx +++ b/packages/lasereyes-react/lib/icons/leather.tsx @@ -1,17 +1,17 @@ -import * as React from "react"; +import * as React from 'react' interface LeatherLogoProps extends React.SVGProps { - size?: number; - variant?: "first" | "second"; + size?: number + variant?: 'first' | 'second' } const LeatherLogo: React.FC = ({ size = 42, - variant = "first", + variant = 'first', className, ...props }) => { - if (variant === "first") { + if (variant === 'first') { return ( = ({ fill="#F5F1ED" /> - ); + ) } return ( @@ -47,7 +47,7 @@ const LeatherLogo: React.FC = ({ fill="#12100F" /> - ); -}; + ) +} -export { LeatherLogo }; +export { LeatherLogo } diff --git a/packages/lasereyes-react/lib/icons/magiceden.tsx b/packages/lasereyes-react/lib/icons/magiceden.tsx index a9d90e0f..d84a3504 100644 --- a/packages/lasereyes-react/lib/icons/magiceden.tsx +++ b/packages/lasereyes-react/lib/icons/magiceden.tsx @@ -1,13 +1,13 @@ -import * as React from "react"; +import * as React from 'react' interface MagicedenLogoProps extends React.SVGProps { - size?: number; - variant?: "first" | "second"; + size?: number + variant?: 'first' | 'second' } const MagicEdenLogo: React.FC = ({ size = 42, - variant = "first", + variant = 'first', className, ...props }) => { @@ -59,7 +59,7 @@ const MagicEdenLogo: React.FC = ({ - ); -}; + ) +} -export { MagicEdenLogo }; +export { MagicEdenLogo } diff --git a/packages/lasereyes-react/lib/icons/okx.tsx b/packages/lasereyes-react/lib/icons/okx.tsx index bc2c5503..75394b56 100644 --- a/packages/lasereyes-react/lib/icons/okx.tsx +++ b/packages/lasereyes-react/lib/icons/okx.tsx @@ -1,13 +1,13 @@ -import * as React from "react"; +import * as React from 'react' interface OkxLogoProps extends React.SVGProps { - size?: number; - variant?: "first" | "second"; + size?: number + variant?: 'first' | 'second' } const OkxLogo: React.FC = ({ size = 42, - variant = "first", + variant = 'first', className, ...props }) => { @@ -39,7 +39,7 @@ const OkxLogo: React.FC = ({ - ); -}; + ) +} -export { OkxLogo }; +export { OkxLogo } diff --git a/packages/lasereyes-react/lib/icons/orange.tsx b/packages/lasereyes-react/lib/icons/orange.tsx index fc8d446f..0982b91a 100644 --- a/packages/lasereyes-react/lib/icons/orange.tsx +++ b/packages/lasereyes-react/lib/icons/orange.tsx @@ -1,13 +1,13 @@ -import * as React from "react"; +import * as React from 'react' interface OrangeLogoProps extends React.SVGProps { - size?: number; - variant?: "first" | "second"; + size?: number + variant?: 'first' | 'second' } const OrangeLogo: React.FC = ({ size = 42, - variant = "first", + variant = 'first', className, ...props }) => ( @@ -36,14 +36,14 @@ const OrangeLogo: React.FC = ({ @@ -100,9 +100,9 @@ const OrangeLogo: React.FC = ({ width={42} height={42} style={{ - fill: "rgb(0%,0%,0%)", + fill: 'rgb(0%,0%,0%)', fillOpacity: 0.6, - stroke: "none", + stroke: 'none', }} /> @@ -121,9 +121,9 @@ const OrangeLogo: React.FC = ({ width={42} height={42} style={{ - fill: "rgb(0%,0%,0%)", + fill: 'rgb(0%,0%,0%)', fillOpacity: 0.701961, - stroke: "none", + stroke: 'none', }} /> @@ -148,9 +148,9 @@ const OrangeLogo: React.FC = ({ width={42} height={42} style={{ - fill: "rgb(0%,0%,0%)", + fill: 'rgb(0%,0%,0%)', fillOpacity: 0.2, - stroke: "none", + stroke: 'none', }} /> @@ -177,9 +177,9 @@ const OrangeLogo: React.FC = ({ @@ -189,5 +189,5 @@ const OrangeLogo: React.FC = ({ -); -export default OrangeLogo; +) +export default OrangeLogo diff --git a/packages/lasereyes-react/lib/icons/oyl.tsx b/packages/lasereyes-react/lib/icons/oyl.tsx index d320ddb2..2a793c52 100644 --- a/packages/lasereyes-react/lib/icons/oyl.tsx +++ b/packages/lasereyes-react/lib/icons/oyl.tsx @@ -1,17 +1,17 @@ -import * as React from "react"; +import * as React from 'react' interface OylLogoProps extends React.SVGProps { - size?: number; - variant?: "first" | "second"; + size?: number + variant?: 'first' | 'second' } const OylLogo: React.FC = ({ size = 42, - variant = "first", + variant = 'first', className, ...props }) => { - if (variant === "first") { + if (variant === 'first') { return ( = ({ height="42" rx="10" fill="#090A0C" - style={{ fill: "#090A0C", fillOpacity: 1 }} + style={{ fill: '#090A0C', fillOpacity: 1 }} /> - ); + ) } return ( @@ -53,15 +53,15 @@ const OylLogo: React.FC = ({ height="42" rx="10" fill="white" - style={{ fill: "white", fillOpacity: 1 }} + style={{ fill: 'white', fillOpacity: 1 }} /> - ); -}; + ) +} -export { OylLogo }; +export { OylLogo } diff --git a/packages/lasereyes-react/lib/icons/phantom.tsx b/packages/lasereyes-react/lib/icons/phantom.tsx index e8d7619c..1308e8b7 100644 --- a/packages/lasereyes-react/lib/icons/phantom.tsx +++ b/packages/lasereyes-react/lib/icons/phantom.tsx @@ -1,17 +1,17 @@ -import * as React from "react"; +import * as React from 'react' interface PhantomLogoProps extends React.SVGProps { - size?: number; - variant?: "first" | "second"; + size?: number + variant?: 'first' | 'second' } const PhantomLogo: React.FC = ({ size = 42, - variant = "first", + variant = 'first', className, ...props }) => { - if (variant === "first") { + if (variant === 'first') { return ( = ({ - ); + ) } return ( @@ -71,7 +71,7 @@ const PhantomLogo: React.FC = ({ - ); -}; + ) +} -export { PhantomLogo }; +export { PhantomLogo } diff --git a/packages/lasereyes-react/lib/icons/unisat.tsx b/packages/lasereyes-react/lib/icons/unisat.tsx index 4db31c42..c8815cf7 100644 --- a/packages/lasereyes-react/lib/icons/unisat.tsx +++ b/packages/lasereyes-react/lib/icons/unisat.tsx @@ -1,13 +1,13 @@ -import * as React from "react"; +import * as React from 'react' interface UnisatLogoProps extends React.SVGProps { - size?: number; - variant?: "first" | "second"; + size?: number + variant?: 'first' | 'second' } const UnisatLogo: React.FC = ({ size = 42, - variant = "first", + variant = 'first', className, ...props }) => { @@ -84,7 +84,7 @@ const UnisatLogo: React.FC = ({ - ); -}; + ) +} -export { UnisatLogo }; +export { UnisatLogo } diff --git a/packages/lasereyes-react/lib/icons/walletIcon.tsx b/packages/lasereyes-react/lib/icons/walletIcon.tsx index caf7eceb..867e0488 100644 --- a/packages/lasereyes-react/lib/icons/walletIcon.tsx +++ b/packages/lasereyes-react/lib/icons/walletIcon.tsx @@ -1,13 +1,24 @@ -import { WizzLogo } from "./wizz"; -import { XverseLogo } from "./xverse"; -import { LeatherLogo } from "./leather"; -import { MagicEdenLogo } from "./magiceden"; -import { OkxLogo } from "./okx"; -import { PhantomLogo } from "./phantom"; -import { UnisatLogo } from "./unisat"; -import { OylLogo } from "./oyl"; -import OrangeLogo from "./orange"; -import {ProviderType, XVERSE, LEATHER, MAGIC_EDEN, OKX, PHANTOM, UNISAT, WIZZ, ORANGE, OYL} from "@omnisat/lasereyes-core"; +import { WizzLogo } from './wizz' +import { XverseLogo } from './xverse' +import { LeatherLogo } from './leather' +import { MagicEdenLogo } from './magiceden' +import { OkxLogo } from './okx' +import { PhantomLogo } from './phantom' +import { UnisatLogo } from './unisat' +import { OylLogo } from './oyl' +import OrangeLogo from './orange' +import { + ProviderType, + XVERSE, + LEATHER, + MAGIC_EDEN, + OKX, + PHANTOM, + UNISAT, + WIZZ, + ORANGE, + OYL, +} from '@omnisat/lasereyes-core' const WalletIcon = ({ size, @@ -15,34 +26,32 @@ const WalletIcon = ({ variant, walletName, }: { - size: number; - className?: string; - variant?: "first" | "second"; + size: number + className?: string + variant?: 'first' | 'second' walletName: ProviderType }) => { if (walletName === XVERSE) { - return ; + return } else if (walletName === WIZZ) { - return ; + return } else if (walletName === LEATHER) { - return ; + return } else if (walletName === MAGIC_EDEN) { - return ( - - ); + return } else if (walletName === OKX) { - return ; + return } else if (walletName === PHANTOM) { - return ; + return } else if (walletName === UNISAT) { - return ; + return } else if (walletName === OYL) { - return ; + return } else if (walletName === ORANGE) { - return ; + return } else { - return ; + return } -}; +} -export { WalletIcon }; +export { WalletIcon } diff --git a/packages/lasereyes-react/lib/icons/wizz.tsx b/packages/lasereyes-react/lib/icons/wizz.tsx index 02b27aef..be6bf390 100644 --- a/packages/lasereyes-react/lib/icons/wizz.tsx +++ b/packages/lasereyes-react/lib/icons/wizz.tsx @@ -1,13 +1,13 @@ -import * as React from "react"; +import * as React from 'react' interface WizzLogoProps extends React.SVGProps { - size?: number; - variant?: "first" | "second"; + size?: number + variant?: 'first' | 'second' } const WizzLogo: React.FC = ({ size = 42, - variant = "first", + variant = 'first', className, ...props }) => { @@ -54,7 +54,7 @@ const WizzLogo: React.FC = ({ - ); -}; + ) +} -export { WizzLogo }; +export { WizzLogo } diff --git a/packages/lasereyes-react/lib/icons/xverse.tsx b/packages/lasereyes-react/lib/icons/xverse.tsx index 9279085f..99c9f035 100644 --- a/packages/lasereyes-react/lib/icons/xverse.tsx +++ b/packages/lasereyes-react/lib/icons/xverse.tsx @@ -1,13 +1,13 @@ -import * as React from "react"; +import * as React from 'react' interface XverseLogoProps extends React.SVGProps { - size?: number; - variant?: "first" | "second"; + size?: number + variant?: 'first' | 'second' } const XverseLogo: React.FC = ({ size = 42, - variant = "first", + variant = 'first', className, ...props }) => { @@ -41,7 +41,7 @@ const XverseLogo: React.FC = ({ - ); -}; + ) +} -export { XverseLogo }; +export { XverseLogo } diff --git a/packages/lasereyes-react/lib/index.ts b/packages/lasereyes-react/lib/index.ts index 40b2a6b2..88614258 100644 --- a/packages/lasereyes-react/lib/index.ts +++ b/packages/lasereyes-react/lib/index.ts @@ -1,7 +1,7 @@ -import { useLaserEyes } from "./providers/hooks"; -import LaserEyesProvider from "./providers/lasereyes-provider"; +import { useLaserEyes } from './providers/hooks' +import LaserEyesProvider from './providers/lasereyes-provider' -export * from "@omnisat/lasereyes-core"; -export { LaserEyesProvider, useLaserEyes }; -export * from "./providers/types"; -export * from "./icons"; +export * from '@omnisat/lasereyes-core' +export { LaserEyesProvider, useLaserEyes } +export * from './providers/types' +export * from './icons' diff --git a/packages/lasereyes-react/lib/providers/hooks.ts b/packages/lasereyes-react/lib/providers/hooks.ts index 60173e61..6f862df2 100644 --- a/packages/lasereyes-react/lib/providers/hooks.ts +++ b/packages/lasereyes-react/lib/providers/hooks.ts @@ -1,7 +1,7 @@ -import { useContext } from "react"; -import { LaserEyesContext } from "./context"; -import { LaserEyesContextType } from "./types"; +import { useContext } from 'react' +import { LaserEyesContext } from './context' +import { LaserEyesContextType } from './types' export const useLaserEyes = (): LaserEyesContextType => { - return useContext(LaserEyesContext); -}; + return useContext(LaserEyesContext) +} diff --git a/packages/lasereyes-react/tsconfig.app.json b/packages/lasereyes-react/tsconfig.app.json index ceee7738..4dc53538 100644 --- a/packages/lasereyes-react/tsconfig.app.json +++ b/packages/lasereyes-react/tsconfig.app.json @@ -23,5 +23,5 @@ "@": ["./lib"] } }, - "include": ["src", "lib"] + "include": ["lib"] } diff --git a/packages/lasereyes-react/vite.config.ts b/packages/lasereyes-react/vite.config.ts index b935a4da..d617ac97 100644 --- a/packages/lasereyes-react/vite.config.ts +++ b/packages/lasereyes-react/vite.config.ts @@ -1,36 +1,36 @@ -import { resolve } from "path"; -import { defineConfig } from "vite"; -import react from "@vitejs/plugin-react-swc"; -import dts from "vite-plugin-dts"; +import { resolve } from 'path' +import { defineConfig } from 'vite' +import react from '@vitejs/plugin-react-swc' +import dts from 'vite-plugin-dts' // https://vitejs.dev/config/ export default defineConfig({ plugins: [ react(), dts({ - tsconfigPath: resolve(__dirname, "./tsconfig.build.json"), + tsconfigPath: resolve(__dirname, './tsconfig.build.json'), }), ], resolve: { alias: { - "@": resolve(__dirname, "./lib"), + '@': resolve(__dirname, './lib'), }, }, build: { lib: { - entry: resolve(__dirname, "./lib/index.ts"), - name: "lasereyes-react", - fileName: "index", + entry: resolve(__dirname, './lib/index.ts'), + name: 'lasereyes-react', + fileName: 'index', }, rollupOptions: { - external: ["react", "react-dom"], + external: ['react', 'react-dom'], output: { globals: { - react: "React", - "react-dom": "ReactDOM", + react: 'React', + 'react-dom': 'ReactDOM', }, - banner: "'use client';" + banner: "'use client';", }, }, }, -}); +}) diff --git a/packages/lasereyes/index.ts b/packages/lasereyes/index.ts index 1c6884c3..d281767a 100644 --- a/packages/lasereyes/index.ts +++ b/packages/lasereyes/index.ts @@ -1,3 +1,2 @@ -export * from '@omnisat/lasereyes-core'; -export { useLaserEyes, LaserEyesProvider } from '@omnisat/lasereyes-react'; - +export * from '@omnisat/lasereyes-core' +export { useLaserEyes, LaserEyesProvider } from '@omnisat/lasereyes-react'