@omnisat/lasereyes 0.0.9 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,12 +1,8 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
+ import * as bitcoin from 'bitcoinjs-lib';
3
4
 
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';
5
+ declare const XVERSE_NETWORK: "Mainnet" | "Testnet";
10
6
  declare const UNISAT_MAINNET = "livenet";
11
7
  declare const UNISAT_TESTNET = "testnet";
12
8
  declare const XVERSE_MAINNET = "Mainnet";
@@ -15,15 +11,26 @@ declare const LEATHER_MAINNET = "mainnet";
15
11
  declare const LEATHER_TESTNET = "testnet";
16
12
  declare const MAINNET = "mainnet";
17
13
  declare const TESTNET = "testnet";
14
+ declare const REGTEST = "regtest";
18
15
  declare const getXverseNetwork: (network: string) => "Mainnet" | "Testnet";
19
16
  declare const getLeatherNetwork: (network: string) => "testnet" | "mainnet";
20
17
  declare const getUnisatNetwork: (network: string) => "livenet" | "testnet";
21
18
  declare const getNetworkForUnisat: (network: string) => "testnet" | "mainnet";
22
19
  declare const getNetworkForXverse: (network: string) => "testnet" | "mainnet";
23
20
  declare const getNetworkForLeather: (network: string) => "testnet" | "mainnet";
21
+ declare const MEMPOOL_SPACE_URL = "https://mempool.space";
22
+ declare const MEMPOOL_SPACE_TESTNET_URL = "https://mempool.space/testnet";
23
+ declare const getMempoolSpaceUrl: (network: string) => "https://mempool.space" | "https://mempool.space/testnet";
24
+
25
+ declare const OYL = "oyl";
26
+ declare const UNISAT = "unisat";
27
+ declare const XVERSE = "xverse";
28
+ declare const PHANTOM = "phantom";
29
+ declare const LEATHER = "leather";
24
30
  declare const P2TR = "p2tr";
25
31
  declare const P2PKH = "p2pkh";
26
32
  declare const P2WPKH = "p2wpkh";
33
+ declare const P2PSH = "p2psh";
27
34
  declare const P2WSH = "p2wsh";
28
35
  declare const P2SH = "p2sh";
29
36
  declare const WALLETS: {
@@ -56,42 +63,38 @@ declare const WALLETS: {
56
63
  };
57
64
 
58
65
  type LaserEyesContextType = {
59
- hasOyl: boolean;
60
- hasUnisat: boolean;
61
- hasLeather: boolean;
62
- hasXverse: boolean;
63
66
  connected: boolean;
64
67
  isConnecting: boolean;
65
68
  publicKey: string;
66
69
  address: string;
67
70
  paymentAddress: string;
68
71
  paymentPublicKey: string;
69
- balance: {
70
- confirmed: number;
71
- unconfirmed: number;
72
- total: number;
73
- };
74
- network: string;
72
+ balance: number | undefined;
73
+ network: typeof MAINNET | typeof TESTNET | typeof REGTEST;
75
74
  library: any;
76
75
  provider: any;
77
76
  accounts: string[];
78
- connect: (walletName: typeof OYL | typeof UNISAT | typeof XVERSE | typeof LEATHER) => Promise<void>;
77
+ hasUnisat: boolean;
78
+ hasXverse: boolean;
79
+ connect: (walletName: typeof UNISAT | typeof XVERSE) => Promise<void>;
79
80
  disconnect: () => void;
80
81
  requestAccounts: () => Promise<string[]>;
81
82
  getNetwork: () => Promise<string | undefined>;
82
- switchNetwork: (network: "mainnet" | "testnet") => Promise<string | undefined>;
83
+ switchNetwork: (network: typeof MAINNET | typeof TESTNET | typeof REGTEST) => Promise<void>;
83
84
  getPublicKey: () => Promise<string>;
84
85
  getBalance: () => Promise<string>;
86
+ getInscriptions: () => Promise<any[]>;
85
87
  sendBTC: (to: string, amount: number) => Promise<string>;
86
88
  signMessage: (message: string) => Promise<string>;
87
- signPsbt: (tx: string, finalize?: boolean, broadcast?: boolean) => Promise<string | {
88
- signedPsbtHex: string;
89
- signedPsbtBase64: string;
89
+ signPsbt: (tx: string, finalize?: boolean, broadcast?: boolean) => Promise<{
90
+ signedPsbtHex: string | undefined;
91
+ signedPsbtBase64: string | undefined;
92
+ txId?: string;
90
93
  } | undefined>;
91
94
  pushPsbt: (tx: string) => Promise<string | undefined>;
92
95
  };
93
96
  type Config = {
94
- network: string;
97
+ network: typeof MAINNET | typeof TESTNET | typeof REGTEST;
95
98
  };
96
99
 
97
100
  declare const createConfig: (config: Config) => Config;
@@ -99,8 +102,16 @@ declare const createConfig: (config: Config) => Config;
99
102
  declare const useLaserEyes: () => LaserEyesContextType;
100
103
  declare const LaserEyesProvider: ({ children, config, }: {
101
104
  children: ReactNode;
102
- config: Config;
105
+ config?: Config | undefined;
103
106
  }) => react_jsx_runtime.JSX.Element;
104
- //# sourceMappingURL=LaserEyesProvider.d.ts.map
105
107
 
106
- 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 };
108
+ declare const getBitcoinNetwork: (network: typeof MAINNET | typeof TESTNET | typeof REGTEST) => bitcoin.networks.Network;
109
+ declare const findOrdinalsAddress: (addresses: any) => any;
110
+ declare const findPaymentAddress: (addresses: any) => any;
111
+ declare const getBTCBalance: (address: string) => Promise<number>;
112
+ declare const satoshisToBTC: (satoshis: number) => string;
113
+ declare const isBase64: (str: string) => boolean;
114
+ declare const isHex: (str: string) => boolean;
115
+ declare function getAddressType(address: string): "p2tr" | "p2pkh" | "p2wpkh" | "p2psh" | "p2wsh";
116
+
117
+ export { LEATHER, LEATHER_MAINNET, LEATHER_TESTNET, LaserEyesProvider, MAINNET, MEMPOOL_SPACE_TESTNET_URL, MEMPOOL_SPACE_URL, OYL, P2PKH, P2PSH, P2SH, P2TR, P2WPKH, P2WSH, PHANTOM, REGTEST, TESTNET, UNISAT, UNISAT_MAINNET, UNISAT_TESTNET, WALLETS, XVERSE, XVERSE_MAINNET, XVERSE_NETWORK, XVERSE_TESTNET, createConfig, findOrdinalsAddress, findPaymentAddress, getAddressType, getBTCBalance, getBitcoinNetwork, getLeatherNetwork, getMempoolSpaceUrl, getNetworkForLeather, getNetworkForUnisat, getNetworkForXverse, getUnisatNetwork, getXverseNetwork, isBase64, isHex, satoshisToBTC, useLaserEyes };
package/dist/index.js CHANGED
@@ -690,8 +690,24 @@ var LaserEyesProvider = ({
690
690
  if (!txId)
691
691
  throw new Error("Transaction failed");
692
692
  return txId;
693
- } else {
694
- throw new Error("The connected wallet doesn't support this method..");
693
+ } else if (provider === XVERSE) {
694
+ const response = yield (0, import_sats_connect.request)("sendTransfer", {
695
+ recipients: [
696
+ {
697
+ address: to,
698
+ amount: Number(amount)
699
+ }
700
+ ]
701
+ });
702
+ if (response.status === "success") {
703
+ return response.result.txid;
704
+ } else {
705
+ if (response.error.code === import_sats_connect.RpcErrorCode.USER_REJECTION) {
706
+ throw new Error("User rejected the request");
707
+ } else {
708
+ throw new Error("Error sending BTC: " + response.error.message);
709
+ }
710
+ }
695
711
  }
696
712
  } catch (error) {
697
713
  throw error;
package/dist/index.mjs CHANGED
@@ -627,8 +627,24 @@ var LaserEyesProvider = ({
627
627
  if (!txId)
628
628
  throw new Error("Transaction failed");
629
629
  return txId;
630
- } else {
631
- throw new Error("The connected wallet doesn't support this method..");
630
+ } else if (provider === XVERSE) {
631
+ const response = yield request("sendTransfer", {
632
+ recipients: [
633
+ {
634
+ address: to,
635
+ amount: Number(amount)
636
+ }
637
+ ]
638
+ });
639
+ if (response.status === "success") {
640
+ return response.result.txid;
641
+ } else {
642
+ if (response.error.code === RpcErrorCode.USER_REJECTION) {
643
+ throw new Error("User rejected the request");
644
+ } else {
645
+ throw new Error("Error sending BTC: " + response.error.message);
646
+ }
647
+ }
632
648
  }
633
649
  } catch (error) {
634
650
  throw error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnisat/lasereyes",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "sideEffects": false,
5
5
  "private": false,
6
6
  "license": "MIT",
@@ -12,12 +12,11 @@
12
12
  ],
13
13
  "scripts": {
14
14
  "build": "tsup src/index.tsx --format esm,cjs --dts --external react",
15
- "clean": "rm -rf dist",
15
+ "clean": "rimraf dist && rimraf src/**/*.d.ts src/**/*.d.ts.map src/**/*.js",
16
16
  "dev": "tsup src/index.tsx --format esm,cjs --watch --dts --external react"
17
17
  },
18
18
  "dependencies": {
19
19
  "@changesets/cli": "^2.27.5",
20
- "@mempool/mempool.js": "^2.3.0",
21
20
  "axios": "^1.7.2",
22
21
  "bitcoinjs-lib": "^6.1.3",
23
22
  "react": "^18",
@@ -29,6 +28,7 @@
29
28
  "devDependencies": {
30
29
  "@types/react": "^18",
31
30
  "@types/react-dom": "^18",
31
+ "rimraf": "^6.0.1",
32
32
  "tsup": "^6.7.0",
33
33
  "typescript": "^4.9.5"
34
34
  }