@omnisat/lasereyes 0.0.6 → 0.0.7

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/LICENSE ADDED
@@ -0,0 +1,17 @@
1
+ MIT License
2
+ Copyright (c) 2024 Laser Eyes
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+ The above copyright notice and this permission notice shall be included in all
10
+ copies or substantial portions of the Software.
11
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17
+ SOFTWARE.
package/README.md CHANGED
@@ -18,9 +18,12 @@
18
18
 
19
19
  ---
20
20
 
21
+ ## Don't Trust, Verify
22
+ [Try It Out](https://demo.lasereyes.build)
23
+
21
24
  ## Documentation
22
25
 
23
- For documentation and guides, visit [Laser Eyes Docs](https://lasereyes.vercel.app/).
26
+ For documentation and guides, visit [Laser Eyes Docs](https://lasereyes.build/).
24
27
 
25
28
  ## Community
26
29
 
package/dist/index.js CHANGED
@@ -348,6 +348,7 @@ var LaserEyesProvider = ({
348
348
  const [network, setNetwork] = (0, import_usehooks_ts.useLocalStorage)("network", MAINNET, {
349
349
  initializeWithValue: false
350
350
  });
351
+ const defaultWallet = localStorage == null ? void 0 : localStorage.getItem(LOCAL_STORAGE_DEFAULT_WALLET);
351
352
  (0, import_react.useEffect)(() => {
352
353
  if (config) {
353
354
  setNetwork(config.network);
@@ -382,9 +383,6 @@ var LaserEyesProvider = ({
382
383
  };
383
384
  }, [library]);
384
385
  (0, import_react.useEffect)(() => {
385
- const defaultWallet = localStorage == null ? void 0 : localStorage.getItem(
386
- LOCAL_STORAGE_DEFAULT_WALLET
387
- );
388
386
  if (defaultWallet && !isConnecting) {
389
387
  setProvider(defaultWallet);
390
388
  connect(defaultWallet);
@@ -411,7 +409,7 @@ var LaserEyesProvider = ({
411
409
  const balance2 = yield lib == null ? void 0 : lib.getBalance();
412
410
  setBalance(balance2 == null ? void 0 : balance2.total);
413
411
  } catch (error) {
414
- throw new Error(`Can't lasereyes to ${UNISAT} wallet`);
412
+ throw error;
415
413
  }
416
414
  });
417
415
  const handleAccountsChanged = (_accounts) => {
@@ -429,19 +427,6 @@ var LaserEyesProvider = ({
429
427
  setConnected(false);
430
428
  }
431
429
  };
432
- const getBasicInfo = () => __async(void 0, null, function* () {
433
- if (provider !== UNISAT)
434
- return;
435
- const publicKey2 = yield library == null ? void 0 : library.getPublicKey();
436
- setPublicKey(String(publicKey2));
437
- const balance2 = yield library == null ? void 0 : library.getBalance();
438
- setBalance(balance2);
439
- const network2 = yield library == null ? void 0 : library.getNetwork();
440
- if (network2) {
441
- const foundNetwork = getNetworkForUnisat(String(network2));
442
- setNetwork(foundNetwork);
443
- }
444
- });
445
430
  const handleNetworkChanged = (network2) => {
446
431
  try {
447
432
  let foundNetwork = MAINNET;
@@ -479,6 +464,7 @@ var LaserEyesProvider = ({
479
464
  setAddress("");
480
465
  setPaymentAddress("");
481
466
  setPublicKey("");
467
+ setPaymentPublicKey("");
482
468
  setAccounts([]);
483
469
  setProvider(void 0);
484
470
  setLibrary(null);
@@ -603,7 +589,7 @@ var LaserEyesProvider = ({
603
589
  throw error;
604
590
  }
605
591
  });
606
- const signPsbt = (psbt, finalize = false, broadcast = true) => __async(void 0, null, function* () {
592
+ const signPsbt = (psbt, finalize = false, broadcast = false) => __async(void 0, null, function* () {
607
593
  try {
608
594
  let psbtHex, psbtBase64;
609
595
  if (!library)
@@ -621,17 +607,19 @@ var LaserEyesProvider = ({
621
607
  const signedPsbt = yield library == null ? void 0 : library.signPsbt(psbtHex, {
622
608
  autoFinalized: finalize
623
609
  });
624
- if (broadcast) {
610
+ const psbtSignedPsbt = bitcoin2.Psbt.fromHex(signedPsbt);
611
+ if (finalize && broadcast) {
625
612
  const txId = yield pushPsbt(signedPsbt);
626
613
  return {
627
- signedPsbtHex: signedPsbt.toHex(),
628
- signedPsbtBase64: signedPsbt.toBase64(),
614
+ signedPsbtHex: psbtSignedPsbt.toHex(),
615
+ signedPsbtBase64: psbtSignedPsbt.toBase64(),
629
616
  txId
630
617
  };
631
618
  }
632
619
  return {
633
- signedPsbtHex: signedPsbt.toHex(),
634
- signedPsbtBase64: signedPsbt.toBase64()
620
+ signedPsbtHex: psbtSignedPsbt.toHex(),
621
+ signedPsbtBase64: psbtSignedPsbt.toBase64(),
622
+ txId: void 0
635
623
  };
636
624
  } else {
637
625
  throw new Error("Unsupported wallet");
package/dist/index.mjs CHANGED
@@ -282,6 +282,7 @@ var LaserEyesProvider = ({
282
282
  const [network, setNetwork] = useLocalStorage("network", MAINNET, {
283
283
  initializeWithValue: false
284
284
  });
285
+ const defaultWallet = localStorage == null ? void 0 : localStorage.getItem(LOCAL_STORAGE_DEFAULT_WALLET);
285
286
  useEffect(() => {
286
287
  if (config) {
287
288
  setNetwork(config.network);
@@ -316,9 +317,6 @@ var LaserEyesProvider = ({
316
317
  };
317
318
  }, [library]);
318
319
  useEffect(() => {
319
- const defaultWallet = localStorage == null ? void 0 : localStorage.getItem(
320
- LOCAL_STORAGE_DEFAULT_WALLET
321
- );
322
320
  if (defaultWallet && !isConnecting) {
323
321
  setProvider(defaultWallet);
324
322
  connect(defaultWallet);
@@ -345,7 +343,7 @@ var LaserEyesProvider = ({
345
343
  const balance2 = yield lib == null ? void 0 : lib.getBalance();
346
344
  setBalance(balance2 == null ? void 0 : balance2.total);
347
345
  } catch (error) {
348
- throw new Error(`Can't lasereyes to ${UNISAT} wallet`);
346
+ throw error;
349
347
  }
350
348
  });
351
349
  const handleAccountsChanged = (_accounts) => {
@@ -363,19 +361,6 @@ var LaserEyesProvider = ({
363
361
  setConnected(false);
364
362
  }
365
363
  };
366
- const getBasicInfo = () => __async(void 0, null, function* () {
367
- if (provider !== UNISAT)
368
- return;
369
- const publicKey2 = yield library == null ? void 0 : library.getPublicKey();
370
- setPublicKey(String(publicKey2));
371
- const balance2 = yield library == null ? void 0 : library.getBalance();
372
- setBalance(balance2);
373
- const network2 = yield library == null ? void 0 : library.getNetwork();
374
- if (network2) {
375
- const foundNetwork = getNetworkForUnisat(String(network2));
376
- setNetwork(foundNetwork);
377
- }
378
- });
379
364
  const handleNetworkChanged = (network2) => {
380
365
  try {
381
366
  let foundNetwork = MAINNET;
@@ -413,6 +398,7 @@ var LaserEyesProvider = ({
413
398
  setAddress("");
414
399
  setPaymentAddress("");
415
400
  setPublicKey("");
401
+ setPaymentPublicKey("");
416
402
  setAccounts([]);
417
403
  setProvider(void 0);
418
404
  setLibrary(null);
@@ -537,7 +523,7 @@ var LaserEyesProvider = ({
537
523
  throw error;
538
524
  }
539
525
  });
540
- const signPsbt = (psbt, finalize = false, broadcast = true) => __async(void 0, null, function* () {
526
+ const signPsbt = (psbt, finalize = false, broadcast = false) => __async(void 0, null, function* () {
541
527
  try {
542
528
  let psbtHex, psbtBase64;
543
529
  if (!library)
@@ -555,17 +541,19 @@ var LaserEyesProvider = ({
555
541
  const signedPsbt = yield library == null ? void 0 : library.signPsbt(psbtHex, {
556
542
  autoFinalized: finalize
557
543
  });
558
- if (broadcast) {
544
+ const psbtSignedPsbt = bitcoin2.Psbt.fromHex(signedPsbt);
545
+ if (finalize && broadcast) {
559
546
  const txId = yield pushPsbt(signedPsbt);
560
547
  return {
561
- signedPsbtHex: signedPsbt.toHex(),
562
- signedPsbtBase64: signedPsbt.toBase64(),
548
+ signedPsbtHex: psbtSignedPsbt.toHex(),
549
+ signedPsbtBase64: psbtSignedPsbt.toBase64(),
563
550
  txId
564
551
  };
565
552
  }
566
553
  return {
567
- signedPsbtHex: signedPsbt.toHex(),
568
- signedPsbtBase64: signedPsbt.toBase64()
554
+ signedPsbtHex: psbtSignedPsbt.toHex(),
555
+ signedPsbtBase64: psbtSignedPsbt.toBase64(),
556
+ txId: void 0
569
557
  };
570
558
  } else {
571
559
  throw new Error("Unsupported wallet");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnisat/lasereyes",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "sideEffects": false,
5
5
  "private": false,
6
6
  "license": "MIT",