@omnisat/lasereyes 0.0.2

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/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # @omnisat/lasereyes
2
+ ![Laser Eyes](http://localhost:3001/lasereyes.png)
3
+
4
+
5
+ # Laser Eyes
6
+ ## React Hooks for Bitcoin
7
+
8
+ Laser Eyes is a collection of React Hooks containing everything you need to start working with Bitcoin.
9
+ Laser Eyes makes it easy to "Connect" interface with Bitcoin, Inscriptions, balance information, interact with BRC-20s, and more.
10
+
11
+ ### Install
12
+
13
+ ```yarn add @omnisat/lasereyes```
14
+
15
+ ### Usage Overview
16
+ ```javascript
17
+
18
+ import { LaserEyesProvider, createConfig } from '@omnisat/lasereyes'
19
+
20
+ const config = createConfig({
21
+ ...
22
+ })
23
+
24
+ function App() {
25
+ return (
26
+ <LaserEyesProvider config={config}>
27
+ <Profile />
28
+ </LaserEyesProvider>
29
+ )
30
+ }
31
+ ```
32
+
33
+ # Usage
34
+ ## how to
35
+
36
+ The following hooks support typed inference:
37
+
38
+ ### Read Methods
39
+
40
+ connect
41
+ ```lasereyes.connect()```
42
+
43
+ Get addresses of current account
44
+ ```lasereyes.requestAccounts()```
45
+
46
+ Returns testnet or mainnet
47
+ ```lasereyes.getNetwork()```
48
+
49
+ Get public key of account
50
+ ```lasereyes.getPublicKey()```
51
+
52
+ Get Balance of current account
53
+ ```lasereyes.getBalance()```
54
+
55
+ Get All inscriptions
56
+ ```lasereyes.getInscriptions()```
57
+
58
+ Get All Tokens
59
+ ```lasereyes.getAllBRC20Tokens()```
60
+
61
+
62
+ ### Write Methods
63
+
64
+ Send Bitcoin
65
+ ```lasereyes.sendBTC(toPK, btc_in_sats, ...)```
66
+
67
+ Pay & Inscribe
68
+ ```lasereyes.pay_inscribe(...)````
69
+
70
+ Transferable: The amount has been inscribed into one or more TRANSFER inscriptions (can be transferred immediately).
71
+ Available: The amount that is available as a part of a balance (including both minted and received) but not transferable yet.
72
+ To spend an available amount, you must first inscribe a certain amount into a TRANSFER inscription.
73
+
74
+ The transfer Amount can be calculated by the sum of the chosen amounts of TRANSFER inscriptions.
75
+ If you don’t have enough transferable inscriptions, you will need to inscribe them first.
76
+
77
+ Once a number of TRANSFER inscriptions are chosen, proceed to send them by asserting an address
78
+
79
+ sign the tx to send.
80
+
81
+ Deploy a Inscription
82
+ ```lasereyes.deploy(...)```
83
+
84
+ Mint a deployed Inscription
85
+ ```lasereyes.mint(...)```
86
+
87
+ Sign a message
88
+ ```lasereyes.signMessage(...)```
89
+
90
+ Sign a single PSBT
91
+ ```lasereyes.signPsbt(...)```
92
+
93
+ Sign an array of PSBT
94
+ ```lasereyes.signPsbts(...)```
95
+
96
+ ### Events
97
+
98
+ `networkChanged`
99
+ Testnet, mainnet
100
+
101
+ `accountsChanged`
102
+ user changes account pub keys
@@ -0,0 +1,111 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+
4
+ declare const OYL = "oyl";
5
+ declare const UNISAT = "unisat";
6
+ declare const XVERSE = "xverse";
7
+ declare const PHANTOM = "phantom";
8
+ declare const LEATHER = "leather";
9
+ declare const XVERSE_NETWORK: 'Mainnet' | 'Testnet';
10
+ declare const UNISAT_MAINNET = "livenet";
11
+ declare const UNISAT_TESTNET = "testnet";
12
+ declare const XVERSE_MAINNET = "Mainnet";
13
+ declare const XVERSE_TESTNET = "Testnet";
14
+ declare const LEATHER_MAINNET = "mainnet";
15
+ declare const LEATHER_TESTNET = "testnet";
16
+ declare const MAINNET = "mainnet";
17
+ declare const TESTNET = "testnet";
18
+ declare const getXverseNetwork: (network: string) => "Mainnet" | "Testnet";
19
+ declare const getLeatherNetwork: (network: string) => "testnet" | "mainnet";
20
+ declare const getUnisatNetwork: (network: string) => "livenet" | "testnet";
21
+ declare const getNetworkForUnisat: (network: string) => "testnet" | "mainnet";
22
+ declare const getNetworkForXverse: (network: string) => "testnet" | "mainnet";
23
+ declare const getNetworkForLeather: (network: string) => "testnet" | "mainnet";
24
+ declare const P2TR = "p2tr";
25
+ declare const P2PKH = "p2pkh";
26
+ declare const P2WPKH = "p2wpkh";
27
+ declare const P2WSH = "p2wsh";
28
+ declare const P2SH = "p2sh";
29
+ declare const WALLETS: {
30
+ oyl: {
31
+ name: string;
32
+ icon: string;
33
+ site: string;
34
+ disabled: boolean;
35
+ };
36
+ unisat: {
37
+ name: string;
38
+ icon: string;
39
+ site: string;
40
+ disabled: boolean;
41
+ };
42
+ xverse: {
43
+ name: string;
44
+ icon: string;
45
+ site: string;
46
+ config: () => void;
47
+ disabled: boolean;
48
+ };
49
+ leather: {
50
+ name: string;
51
+ icon: string;
52
+ site: string;
53
+ config: () => void;
54
+ disabled: boolean;
55
+ };
56
+ };
57
+
58
+ type LaserEyesContextType = {
59
+ hasOyl: boolean;
60
+ hasUnisat: boolean;
61
+ hasLeather: boolean;
62
+ hasXverse: boolean;
63
+ connected: boolean;
64
+ isConnecting: boolean;
65
+ publicKey: string;
66
+ address: string;
67
+ paymentAddress: string;
68
+ paymentPublicKey: string;
69
+ balance: {
70
+ confirmed: number;
71
+ unconfirmed: number;
72
+ total: number;
73
+ };
74
+ network: string;
75
+ library: any;
76
+ provider: any;
77
+ accounts: string[];
78
+ connect: (walletName: typeof OYL | typeof UNISAT | typeof XVERSE | typeof LEATHER) => Promise<void>;
79
+ disconnect: () => void;
80
+ requestAccounts: () => Promise<string[]>;
81
+ getNetwork: () => Promise<string | undefined>;
82
+ switchNetwork: (network: 'mainnet' | 'testnet') => Promise<string | undefined>;
83
+ getPublicKey: () => Promise<string>;
84
+ getBalance: () => Promise<string>;
85
+ getInscriptions: () => Promise<any>;
86
+ getAllBRC20Tokens: () => Promise<any>;
87
+ sendBTC: (to: string, amount: number) => Promise<string>;
88
+ payInscribe: () => Promise<void>;
89
+ deploy: () => Promise<void>;
90
+ mint: () => Promise<void>;
91
+ signMessage: (message: string) => Promise<string>;
92
+ signPsbt: (tx: string, finalize?: boolean, broadcast?: boolean) => Promise<string | {
93
+ signedPsbtHex: string;
94
+ signedPsbtBase64: string;
95
+ } | undefined>;
96
+ pushPsbt: (tx: string) => Promise<string | undefined>;
97
+ };
98
+ type Config = {
99
+ network: string;
100
+ provider: string;
101
+ chainId: number;
102
+ };
103
+
104
+ declare const createConfig: (config: Config) => Config;
105
+
106
+ declare const useLaserEyes: () => LaserEyesContextType;
107
+ declare const LaserEyesProvider: ({ children }: {
108
+ children: ReactNode;
109
+ }) => react_jsx_runtime.JSX.Element;
110
+
111
+ export { LEATHER, LEATHER_MAINNET, LEATHER_TESTNET, LaserEyesProvider, MAINNET, OYL, P2PKH, P2SH, P2TR, P2WPKH, P2WSH, PHANTOM, TESTNET, UNISAT, UNISAT_MAINNET, UNISAT_TESTNET, WALLETS, XVERSE, XVERSE_MAINNET, XVERSE_NETWORK, XVERSE_TESTNET, createConfig, getLeatherNetwork, getNetworkForLeather, getNetworkForUnisat, getNetworkForXverse, getUnisatNetwork, getXverseNetwork, useLaserEyes };