@omnisat/lasereyes 0.0.56 → 0.0.57
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.js +75 -70
- package/dist/index.mjs +75 -70
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -806,6 +806,7 @@ var LaserEyesProvider = ({
|
|
|
806
806
|
try {
|
|
807
807
|
localStorage == null ? void 0 : localStorage.setItem(LOCAL_STORAGE_DEFAULT_WALLET, UNISAT);
|
|
808
808
|
const lib = window.unisat;
|
|
809
|
+
setLibrary(lib);
|
|
809
810
|
const unisatAccounts = yield lib.requestAccounts();
|
|
810
811
|
if (!unisatAccounts)
|
|
811
812
|
throw new Error("No accounts found");
|
|
@@ -817,7 +818,6 @@ var LaserEyesProvider = ({
|
|
|
817
818
|
setPaymentAddress(unisatAccounts[0]);
|
|
818
819
|
setPublicKey(unisatPubKey);
|
|
819
820
|
setPaymentPublicKey(unisatPubKey);
|
|
820
|
-
setLibrary(lib);
|
|
821
821
|
yield getNetwork().then((network2) => {
|
|
822
822
|
if (config.network !== network2) {
|
|
823
823
|
switchNetwork(network2);
|
|
@@ -1543,81 +1543,86 @@ var LaserEyesProvider = ({
|
|
|
1543
1543
|
throw error;
|
|
1544
1544
|
}
|
|
1545
1545
|
});
|
|
1546
|
-
const signMessage = (
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
if (response.error.code === import_sats_connect.RpcErrorCode.USER_REJECTION) {
|
|
1563
|
-
throw new Error("User rejected the request");
|
|
1546
|
+
const signMessage = (0, import_react.useCallback)(
|
|
1547
|
+
(message, toSignAddress) => __async(void 0, null, function* () {
|
|
1548
|
+
var _a;
|
|
1549
|
+
try {
|
|
1550
|
+
if (!library)
|
|
1551
|
+
return;
|
|
1552
|
+
if (provider === UNISAT) {
|
|
1553
|
+
return yield library == null ? void 0 : library.signMessage(message);
|
|
1554
|
+
} else if (provider === XVERSE) {
|
|
1555
|
+
const tempAddy = toSignAddress || paymentAddress;
|
|
1556
|
+
const response = yield (0, import_sats_connect.request)("signMessage", {
|
|
1557
|
+
address: tempAddy,
|
|
1558
|
+
message
|
|
1559
|
+
});
|
|
1560
|
+
if (response.status === "success") {
|
|
1561
|
+
return response.result.signature;
|
|
1564
1562
|
} else {
|
|
1565
|
-
|
|
1563
|
+
if (response.error.code === import_sats_connect.RpcErrorCode.USER_REJECTION) {
|
|
1564
|
+
throw new Error("User rejected the request");
|
|
1565
|
+
} else {
|
|
1566
|
+
throw new Error(
|
|
1567
|
+
"Error signing message: " + response.error.message
|
|
1568
|
+
);
|
|
1569
|
+
}
|
|
1566
1570
|
}
|
|
1567
|
-
}
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1571
|
+
} else if (provider === OYL) {
|
|
1572
|
+
const tempAddy = toSignAddress || paymentAddress;
|
|
1573
|
+
return yield library == null ? void 0 : library.signMessage(message, "bip322", tempAddy);
|
|
1574
|
+
} else if (provider === MAGIC_EDEN) {
|
|
1575
|
+
const tempAddy = toSignAddress || paymentAddress;
|
|
1576
|
+
let signedMessage;
|
|
1577
|
+
yield (0, import_sats_connect.signMessage)({
|
|
1578
|
+
getProvider: () => __async(void 0, null, function* () {
|
|
1579
|
+
return window.magicEden.bitcoin;
|
|
1580
|
+
}),
|
|
1581
|
+
payload: {
|
|
1582
|
+
network: {
|
|
1583
|
+
type: import_sats_connect.BitcoinNetworkType.Mainnet
|
|
1584
|
+
},
|
|
1585
|
+
address: tempAddy,
|
|
1586
|
+
message,
|
|
1587
|
+
protocol: import_sats_connect.MessageSigningProtocols.BIP322
|
|
1581
1588
|
},
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
}
|
|
1589
|
-
|
|
1590
|
-
|
|
1589
|
+
onFinish: (response) => {
|
|
1590
|
+
signedMessage = response;
|
|
1591
|
+
},
|
|
1592
|
+
onCancel: () => {
|
|
1593
|
+
alert("Request canceled");
|
|
1594
|
+
}
|
|
1595
|
+
});
|
|
1596
|
+
return signedMessage;
|
|
1597
|
+
} else if (provider === OKX) {
|
|
1598
|
+
return yield library == null ? void 0 : library.signMessage(message);
|
|
1599
|
+
} else if (provider === LEATHER) {
|
|
1600
|
+
const paymentType = toSignAddress === address2 ? P2TR : P2WPKH;
|
|
1601
|
+
if (toSignAddress !== address2 && toSignAddress !== paymentAddress) {
|
|
1602
|
+
throw new Error("Invalid address to sign message");
|
|
1591
1603
|
}
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1604
|
+
const signed = yield library == null ? void 0 : library.request("signMessage", {
|
|
1605
|
+
message,
|
|
1606
|
+
paymentType
|
|
1607
|
+
});
|
|
1608
|
+
return (_a = signed == null ? void 0 : signed.result) == null ? void 0 : _a.signature;
|
|
1609
|
+
} else if (provider === PHANTOM) {
|
|
1610
|
+
const utf8Bytes = new TextEncoder().encode(message);
|
|
1611
|
+
const uintArray = new Uint8Array(utf8Bytes);
|
|
1612
|
+
const response = yield library == null ? void 0 : library.signMessage(address2, uintArray);
|
|
1613
|
+
const binaryString = String.fromCharCode(...response.signature);
|
|
1614
|
+
return btoa(binaryString);
|
|
1615
|
+
} else if (provider === WIZZ) {
|
|
1616
|
+
return yield library == null ? void 0 : library.signMessage(message);
|
|
1617
|
+
} else {
|
|
1618
|
+
throw new Error("The connected wallet doesn't support this method..");
|
|
1600
1619
|
}
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
paymentType
|
|
1604
|
-
});
|
|
1605
|
-
return (_a = signed == null ? void 0 : signed.result) == null ? void 0 : _a.signature;
|
|
1606
|
-
} else if (provider === PHANTOM) {
|
|
1607
|
-
const utf8Bytes = new TextEncoder().encode(message);
|
|
1608
|
-
const uintArray = new Uint8Array(utf8Bytes);
|
|
1609
|
-
const response = yield library == null ? void 0 : library.signMessage(address2, uintArray);
|
|
1610
|
-
const binaryString = String.fromCharCode(...response.signature);
|
|
1611
|
-
return btoa(binaryString);
|
|
1612
|
-
} else if (provider === WIZZ) {
|
|
1613
|
-
return yield library == null ? void 0 : library.signMessage(message);
|
|
1614
|
-
} else {
|
|
1615
|
-
throw new Error("The connected wallet doesn't support this method..");
|
|
1620
|
+
} catch (error) {
|
|
1621
|
+
throw error;
|
|
1616
1622
|
}
|
|
1617
|
-
}
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
});
|
|
1623
|
+
}),
|
|
1624
|
+
[library, address2, paymentAddress]
|
|
1625
|
+
);
|
|
1621
1626
|
const signPsbt = (psbt, finalize = false, broadcast = false) => __async(void 0, null, function* () {
|
|
1622
1627
|
try {
|
|
1623
1628
|
let psbtHex, psbtBase64;
|
package/dist/index.mjs
CHANGED
|
@@ -711,6 +711,7 @@ var LaserEyesProvider = ({
|
|
|
711
711
|
try {
|
|
712
712
|
localStorage == null ? void 0 : localStorage.setItem(LOCAL_STORAGE_DEFAULT_WALLET, UNISAT);
|
|
713
713
|
const lib = window.unisat;
|
|
714
|
+
setLibrary(lib);
|
|
714
715
|
const unisatAccounts = yield lib.requestAccounts();
|
|
715
716
|
if (!unisatAccounts)
|
|
716
717
|
throw new Error("No accounts found");
|
|
@@ -722,7 +723,6 @@ var LaserEyesProvider = ({
|
|
|
722
723
|
setPaymentAddress(unisatAccounts[0]);
|
|
723
724
|
setPublicKey(unisatPubKey);
|
|
724
725
|
setPaymentPublicKey(unisatPubKey);
|
|
725
|
-
setLibrary(lib);
|
|
726
726
|
yield getNetwork().then((network2) => {
|
|
727
727
|
if (config.network !== network2) {
|
|
728
728
|
switchNetwork(network2);
|
|
@@ -1448,81 +1448,86 @@ var LaserEyesProvider = ({
|
|
|
1448
1448
|
throw error;
|
|
1449
1449
|
}
|
|
1450
1450
|
});
|
|
1451
|
-
const signMessage = (
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
if (response.error.code === RpcErrorCode.USER_REJECTION) {
|
|
1468
|
-
throw new Error("User rejected the request");
|
|
1451
|
+
const signMessage = useCallback(
|
|
1452
|
+
(message, toSignAddress) => __async(void 0, null, function* () {
|
|
1453
|
+
var _a;
|
|
1454
|
+
try {
|
|
1455
|
+
if (!library)
|
|
1456
|
+
return;
|
|
1457
|
+
if (provider === UNISAT) {
|
|
1458
|
+
return yield library == null ? void 0 : library.signMessage(message);
|
|
1459
|
+
} else if (provider === XVERSE) {
|
|
1460
|
+
const tempAddy = toSignAddress || paymentAddress;
|
|
1461
|
+
const response = yield request("signMessage", {
|
|
1462
|
+
address: tempAddy,
|
|
1463
|
+
message
|
|
1464
|
+
});
|
|
1465
|
+
if (response.status === "success") {
|
|
1466
|
+
return response.result.signature;
|
|
1469
1467
|
} else {
|
|
1470
|
-
|
|
1468
|
+
if (response.error.code === RpcErrorCode.USER_REJECTION) {
|
|
1469
|
+
throw new Error("User rejected the request");
|
|
1470
|
+
} else {
|
|
1471
|
+
throw new Error(
|
|
1472
|
+
"Error signing message: " + response.error.message
|
|
1473
|
+
);
|
|
1474
|
+
}
|
|
1471
1475
|
}
|
|
1472
|
-
}
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1476
|
+
} else if (provider === OYL) {
|
|
1477
|
+
const tempAddy = toSignAddress || paymentAddress;
|
|
1478
|
+
return yield library == null ? void 0 : library.signMessage(message, "bip322", tempAddy);
|
|
1479
|
+
} else if (provider === MAGIC_EDEN) {
|
|
1480
|
+
const tempAddy = toSignAddress || paymentAddress;
|
|
1481
|
+
let signedMessage;
|
|
1482
|
+
yield signMessageSatsConnect({
|
|
1483
|
+
getProvider: () => __async(void 0, null, function* () {
|
|
1484
|
+
return window.magicEden.bitcoin;
|
|
1485
|
+
}),
|
|
1486
|
+
payload: {
|
|
1487
|
+
network: {
|
|
1488
|
+
type: BitcoinNetworkType.Mainnet
|
|
1489
|
+
},
|
|
1490
|
+
address: tempAddy,
|
|
1491
|
+
message,
|
|
1492
|
+
protocol: MessageSigningProtocols.BIP322
|
|
1486
1493
|
},
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
}
|
|
1494
|
-
|
|
1495
|
-
|
|
1494
|
+
onFinish: (response) => {
|
|
1495
|
+
signedMessage = response;
|
|
1496
|
+
},
|
|
1497
|
+
onCancel: () => {
|
|
1498
|
+
alert("Request canceled");
|
|
1499
|
+
}
|
|
1500
|
+
});
|
|
1501
|
+
return signedMessage;
|
|
1502
|
+
} else if (provider === OKX) {
|
|
1503
|
+
return yield library == null ? void 0 : library.signMessage(message);
|
|
1504
|
+
} else if (provider === LEATHER) {
|
|
1505
|
+
const paymentType = toSignAddress === address2 ? P2TR : P2WPKH;
|
|
1506
|
+
if (toSignAddress !== address2 && toSignAddress !== paymentAddress) {
|
|
1507
|
+
throw new Error("Invalid address to sign message");
|
|
1496
1508
|
}
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1509
|
+
const signed = yield library == null ? void 0 : library.request("signMessage", {
|
|
1510
|
+
message,
|
|
1511
|
+
paymentType
|
|
1512
|
+
});
|
|
1513
|
+
return (_a = signed == null ? void 0 : signed.result) == null ? void 0 : _a.signature;
|
|
1514
|
+
} else if (provider === PHANTOM) {
|
|
1515
|
+
const utf8Bytes = new TextEncoder().encode(message);
|
|
1516
|
+
const uintArray = new Uint8Array(utf8Bytes);
|
|
1517
|
+
const response = yield library == null ? void 0 : library.signMessage(address2, uintArray);
|
|
1518
|
+
const binaryString = String.fromCharCode(...response.signature);
|
|
1519
|
+
return btoa(binaryString);
|
|
1520
|
+
} else if (provider === WIZZ) {
|
|
1521
|
+
return yield library == null ? void 0 : library.signMessage(message);
|
|
1522
|
+
} else {
|
|
1523
|
+
throw new Error("The connected wallet doesn't support this method..");
|
|
1505
1524
|
}
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
paymentType
|
|
1509
|
-
});
|
|
1510
|
-
return (_a = signed == null ? void 0 : signed.result) == null ? void 0 : _a.signature;
|
|
1511
|
-
} else if (provider === PHANTOM) {
|
|
1512
|
-
const utf8Bytes = new TextEncoder().encode(message);
|
|
1513
|
-
const uintArray = new Uint8Array(utf8Bytes);
|
|
1514
|
-
const response = yield library == null ? void 0 : library.signMessage(address2, uintArray);
|
|
1515
|
-
const binaryString = String.fromCharCode(...response.signature);
|
|
1516
|
-
return btoa(binaryString);
|
|
1517
|
-
} else if (provider === WIZZ) {
|
|
1518
|
-
return yield library == null ? void 0 : library.signMessage(message);
|
|
1519
|
-
} else {
|
|
1520
|
-
throw new Error("The connected wallet doesn't support this method..");
|
|
1525
|
+
} catch (error) {
|
|
1526
|
+
throw error;
|
|
1521
1527
|
}
|
|
1522
|
-
}
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
});
|
|
1528
|
+
}),
|
|
1529
|
+
[library, address2, paymentAddress]
|
|
1530
|
+
);
|
|
1526
1531
|
const signPsbt = (psbt, finalize = false, broadcast = false) => __async(void 0, null, function* () {
|
|
1527
1532
|
try {
|
|
1528
1533
|
let psbtHex, psbtBase64;
|