@dynamic-labs-sdk/bitcoin 1.50.0 → 1.51.0
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/{InvalidPsbtError-BQ0X8LYh.esm.js → InvalidPsbtError-BJJfPn8u.esm.js} +2 -2
- package/dist/{InvalidPsbtError-BQ0X8LYh.esm.js.map → InvalidPsbtError-BJJfPn8u.esm.js.map} +1 -1
- package/dist/{InvalidPsbtError-BtG6j71H.cjs → InvalidPsbtError-CEUC70ze.cjs} +3 -3
- package/dist/{InvalidPsbtError-BtG6j71H.cjs.map → InvalidPsbtError-CEUC70ze.cjs.map} +1 -1
- package/dist/addBitcoinExtension/addBitcoinExtension.d.ts +1 -1
- package/dist/{addBitcoinInjectedWalletsExtension-4GYI8iHQ.esm.js → addBitcoinInjectedWalletsExtension-ANJKUrmH.esm.js} +74 -284
- package/dist/addBitcoinInjectedWalletsExtension-ANJKUrmH.esm.js.map +1 -0
- package/dist/{addBitcoinInjectedWalletsExtension-DFdi5NiU.cjs → addBitcoinInjectedWalletsExtension-CRclUht6.cjs} +58 -268
- package/dist/addBitcoinInjectedWalletsExtension-CRclUht6.cjs.map +1 -0
- package/dist/{addWaasBitcoinExtension-C9WFNyTk.cjs → addWaasBitcoinExtension-CTCGJEJ6.cjs} +2 -2
- package/dist/{addWaasBitcoinExtension-C9WFNyTk.cjs.map → addWaasBitcoinExtension-CTCGJEJ6.cjs.map} +1 -1
- package/dist/{addWaasBitcoinExtension--NcrqR2o.esm.js → addWaasBitcoinExtension-Dxru051x.esm.js} +2 -2
- package/dist/{addWaasBitcoinExtension--NcrqR2o.esm.js.map → addWaasBitcoinExtension-Dxru051x.esm.js.map} +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +4 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/injected/addBitcoinInjectedWalletsExtension/addBitcoinInjectedWalletsExtension.d.ts +1 -1
- package/dist/injected/addBitcoinInjectedWalletsExtension/addBitcoinInjectedWalletsExtension.d.ts.map +1 -1
- package/dist/injected.cjs +3 -3
- package/dist/injected.esm.js +2 -2
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/waas.cjs +2 -2
- package/dist/waas.esm.js +2 -2
- package/package.json +4 -4
- package/dist/addBitcoinInjectedWalletsExtension-4GYI8iHQ.esm.js.map +0 -1
- package/dist/addBitcoinInjectedWalletsExtension-DFdi5NiU.cjs.map +0 -1
- package/dist/injected/utils/magicEden/createMagicEdenBitcoinWalletProvider/createMagicEdenBitcoinWalletProvider.d.ts +0 -12
- package/dist/injected/utils/magicEden/createMagicEdenBitcoinWalletProvider/createMagicEdenBitcoinWalletProvider.d.ts.map +0 -1
- package/dist/injected/utils/magicEden/createMagicEdenBitcoinWalletProvider/index.d.ts +0 -2
- package/dist/injected/utils/magicEden/createMagicEdenBitcoinWalletProvider/index.d.ts.map +0 -1
- package/dist/injected/utils/magicEden/getMagicEdenInjectedProvider/getMagicEdenInjectedProvider.d.ts +0 -4
- package/dist/injected/utils/magicEden/getMagicEdenInjectedProvider/getMagicEdenInjectedProvider.d.ts.map +0 -1
- package/dist/injected/utils/magicEden/getMagicEdenInjectedProvider/index.d.ts +0 -2
- package/dist/injected/utils/magicEden/getMagicEdenInjectedProvider/index.d.ts.map +0 -1
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { a as bitcoinExecuteSwapTransaction, c as isBitcoinWalletAccount, l as registerBitcoinNetworkProviderBuilder, n as bitcoinTransferAmount, t as InvalidPsbtError, u as getMempoolApiUrl } from "./InvalidPsbtError-
|
|
1
|
+
import { a as bitcoinExecuteSwapTransaction, c as isBitcoinWalletAccount, l as registerBitcoinNetworkProviderBuilder, n as bitcoinTransferAmount, t as InvalidPsbtError, u as getMempoolApiUrl } from "./InvalidPsbtError-BJJfPn8u.esm.js";
|
|
2
2
|
import { DYNAMIC_ICONIC_SPRITE_URL, WalletProviderPriority, assertDefined, createWalletProviderEventEmitter, formatWalletProviderGroupKey, formatWalletProviderKey, getActiveNetworkIdFromLastKnownRegistry, getBuffer, getCore, getDefaultClient, getInjectedProviderFromWindow, getWalletProviderRegistry, hasExtension, registerExtension } from "@dynamic-labs-sdk/client/core";
|
|
3
3
|
import { InvalidParamError, UserRejectedError, assertWalletAccountSigningAvailability, getNetworksData, getWalletAccountAddressByType } from "@dynamic-labs-sdk/client";
|
|
4
4
|
import { WalletProviderEnum } from "@dynamic-labs/sdk-api-core";
|
|
5
5
|
import { Psbt, Transaction, address, networks, payments } from "bitcoinjs-lib";
|
|
6
|
-
import {
|
|
7
|
-
import { AddressPurpose, BitcoinNetworkType, MessageSigningProtocols, RpcErrorCode, addListener, getAddress, request, sendBtcTransaction, signMessage, signMultipleTransactions, signTransaction } from "sats-connect";
|
|
6
|
+
import { BitcoinNetworkType, MessageSigningProtocols, RpcErrorCode, addListener, request, signMultipleTransactions } from "sats-connect";
|
|
8
7
|
|
|
9
8
|
//#region src/utils/bitcoinConfirmTransaction/bitcoinConfirmTransaction.ts
|
|
10
9
|
const POLLING_INTERVAL_MS = 3e3;
|
|
@@ -191,7 +190,7 @@ const createBinanceBitcoinWalletProvider = ({ dynamicClient, injectedProvider })
|
|
|
191
190
|
const getConnectedAddresses = async () => {
|
|
192
191
|
return { addresses: await injectedProvider.getAccounts() };
|
|
193
192
|
};
|
|
194
|
-
const signMessage
|
|
193
|
+
const signMessage = async ({ message, walletAccount, protocol }) => {
|
|
195
194
|
assertDefined(walletAccount, "Wallet account not found");
|
|
196
195
|
await assertWalletAccountSigningAvailability({ walletAccount }, dynamicClient);
|
|
197
196
|
return { signature: await injectedProvider.signMessage(message, protocol) };
|
|
@@ -252,7 +251,7 @@ const createBinanceBitcoinWalletProvider = ({ dynamicClient, injectedProvider })
|
|
|
252
251
|
groupKey: formatWalletProviderGroupKey(BINANCE_METADATA.displayName),
|
|
253
252
|
key,
|
|
254
253
|
metadata: BINANCE_METADATA,
|
|
255
|
-
signMessage
|
|
254
|
+
signMessage,
|
|
256
255
|
signPsbt,
|
|
257
256
|
signPsbts,
|
|
258
257
|
transferAmount: (args) => bitcoinTransferAmount(args, dynamicClient),
|
|
@@ -300,7 +299,7 @@ const createUnisatWalletProvider = ({ dynamicClient, injectedProvider }) => {
|
|
|
300
299
|
await assertWalletAccountSigningAvailability({ walletAccount }, dynamicClient);
|
|
301
300
|
return { transactionId: await injectedProvider.sendBitcoin(transaction.recipientAddress, Number(transaction.amount)) };
|
|
302
301
|
};
|
|
303
|
-
const signMessage
|
|
302
|
+
const signMessage = async ({ message, walletAccount, protocol }) => {
|
|
304
303
|
assertDefined(walletAccount, "Wallet account not found");
|
|
305
304
|
await assertWalletAccountSigningAvailability({ walletAccount }, dynamicClient);
|
|
306
305
|
return { signature: await injectedProvider.signMessage(message, protocol) };
|
|
@@ -365,7 +364,7 @@ const createUnisatWalletProvider = ({ dynamicClient, injectedProvider }) => {
|
|
|
365
364
|
key,
|
|
366
365
|
metadata: UNISAT_METADATA,
|
|
367
366
|
sendBitcoin,
|
|
368
|
-
signMessage
|
|
367
|
+
signMessage,
|
|
369
368
|
signPsbt,
|
|
370
369
|
signPsbts,
|
|
371
370
|
transferAmount: (args) => bitcoinTransferAmount(args, dynamicClient),
|
|
@@ -482,7 +481,7 @@ const createLeatherBitcoinWalletProvider = ({ dynamicClient, injectedProvider })
|
|
|
482
481
|
throw error;
|
|
483
482
|
})).result.txid };
|
|
484
483
|
};
|
|
485
|
-
const signMessage
|
|
484
|
+
const signMessage = async ({ message, walletAccount, addressType }) => {
|
|
486
485
|
assertDefined(walletAccount, "Wallet account not found");
|
|
487
486
|
let paymentType = "p2tr";
|
|
488
487
|
if (addressType === "payment") paymentType = "p2wpkh";
|
|
@@ -534,7 +533,7 @@ const createLeatherBitcoinWalletProvider = ({ dynamicClient, injectedProvider })
|
|
|
534
533
|
key,
|
|
535
534
|
metadata: LEATHER_METADATA,
|
|
536
535
|
sendBitcoin,
|
|
537
|
-
signMessage
|
|
536
|
+
signMessage,
|
|
538
537
|
signPsbt,
|
|
539
538
|
signPsbts,
|
|
540
539
|
transferAmount: (args) => bitcoinTransferAmount(args, dynamicClient),
|
|
@@ -550,261 +549,6 @@ const getLeatherBitcoinInjectedProvider = () => {
|
|
|
550
549
|
return getInjectedProviderFromWindow(LEATHER_BITCOIN_PROVIDER_LOCATOR);
|
|
551
550
|
};
|
|
552
551
|
|
|
553
|
-
//#endregion
|
|
554
|
-
//#region src/utils/convertNetworkIdToSatsConnectNetworkType/convertNetworkIdToSatsConnectNetworkType.ts
|
|
555
|
-
/** @notInstrumented */
|
|
556
|
-
const convertNetworkIdToSatsConnectNetworkType = (networkId) => {
|
|
557
|
-
if (networkId === "2") return BitcoinNetworkType.Testnet;
|
|
558
|
-
if (networkId === "3") return BitcoinNetworkType.Signet;
|
|
559
|
-
return BitcoinNetworkType.Mainnet;
|
|
560
|
-
};
|
|
561
|
-
|
|
562
|
-
//#endregion
|
|
563
|
-
//#region src/utils/getPsbtInputsToSignForSatsConnect/getPsbtInputsToSignForSatsConnect.ts
|
|
564
|
-
/**
|
|
565
|
-
* This method will create the psbt sign options for SatsConnect for the given request
|
|
566
|
-
* It will validate the psbt against the signature data provided in the request
|
|
567
|
-
* It will return the inputs to sign if the signature data is provided
|
|
568
|
-
* @notInstrumented
|
|
569
|
-
*/
|
|
570
|
-
const getPsbtInputsToSignForSatsConnect = ({ psbt, request: request$1, isLegacySatsConnect }) => {
|
|
571
|
-
if (!request$1.signature) return [];
|
|
572
|
-
validatePsbt({
|
|
573
|
-
allowedSigHashTypes: request$1.allowedSighash,
|
|
574
|
-
psbt,
|
|
575
|
-
signatureData: request$1.signature
|
|
576
|
-
});
|
|
577
|
-
const inputsToSign = [];
|
|
578
|
-
for (const signature of request$1.signature) if (signature.signingIndexes?.length) for (const index of signature.signingIndexes) inputsToSign.push({
|
|
579
|
-
address: signature.address,
|
|
580
|
-
sigHash: isLegacySatsConnect ? getSigHashType({ input: psbt.data.inputs[index] }) : request$1.allowedSighash[0],
|
|
581
|
-
signingIndexes: [index]
|
|
582
|
-
});
|
|
583
|
-
return inputsToSign;
|
|
584
|
-
};
|
|
585
|
-
|
|
586
|
-
//#endregion
|
|
587
|
-
//#region src/utils/getSatsConnectSigningProtocol/getSatsConnectSigningProtocol.ts
|
|
588
|
-
/** @notInstrumented */
|
|
589
|
-
const getSatsConnectSigningProtocol = (protocol) => {
|
|
590
|
-
if (!protocol) return;
|
|
591
|
-
return protocol === "ecdsa" ? MessageSigningProtocols.ECDSA : MessageSigningProtocols.BIP322;
|
|
592
|
-
};
|
|
593
|
-
|
|
594
|
-
//#endregion
|
|
595
|
-
//#region src/utils/parseBitcoinConnectionResult/parseBitcoinConnectionResult.ts
|
|
596
|
-
/** @notInstrumented */
|
|
597
|
-
const parseBitcoinConnectionResult = ({ connectedAddresses }) => {
|
|
598
|
-
const addresses = connectedAddresses.filter((address$1) => address$1.purpose === "ordinals" || address$1.purpose === "payment").map((account) => ({
|
|
599
|
-
address: account.address,
|
|
600
|
-
publicKey: account.publicKey,
|
|
601
|
-
type: account.purpose === "payment" ? "payment" : "ordinals"
|
|
602
|
-
}));
|
|
603
|
-
addresses.sort((a) => a.type === "ordinals" ? -1 : 1);
|
|
604
|
-
return { addresses };
|
|
605
|
-
};
|
|
606
|
-
|
|
607
|
-
//#endregion
|
|
608
|
-
//#region src/injected/utils/magicEden/createMagicEdenBitcoinWalletProvider/createMagicEdenBitcoinWalletProvider.ts
|
|
609
|
-
const MAGIC_EDEN_METADATA = {
|
|
610
|
-
displayName: "Magic Eden",
|
|
611
|
-
icon: `${DYNAMIC_ICONIC_SPRITE_URL}#magiceden`,
|
|
612
|
-
supportedHardwareWalletVendors: ["ledger"]
|
|
613
|
-
};
|
|
614
|
-
/** @notInstrumented */
|
|
615
|
-
const createMagicEdenBitcoinWalletProvider = ({ dynamicClient, satsConnectProvider }) => {
|
|
616
|
-
const chain = "BTC";
|
|
617
|
-
const walletProviderType = WalletProviderEnum.BrowserExtension;
|
|
618
|
-
const key = formatWalletProviderKey({
|
|
619
|
-
chain,
|
|
620
|
-
displayName: MAGIC_EDEN_METADATA.displayName,
|
|
621
|
-
walletProviderType
|
|
622
|
-
});
|
|
623
|
-
const getNetworkPayload = async () => {
|
|
624
|
-
return { network: { type: convertNetworkIdToSatsConnectNetworkType((await getActiveNetworkId()).networkId) } };
|
|
625
|
-
};
|
|
626
|
-
const connect = async () => {
|
|
627
|
-
const { network } = await getNetworkPayload();
|
|
628
|
-
return new Promise((resolve, reject) => {
|
|
629
|
-
getAddress({
|
|
630
|
-
getProvider: async () => satsConnectProvider,
|
|
631
|
-
onCancel: () => {
|
|
632
|
-
reject(new UserRejectedError({ action: "connect" }));
|
|
633
|
-
},
|
|
634
|
-
onFinish: async (response) => {
|
|
635
|
-
const { addresses: connectedAddresses } = response;
|
|
636
|
-
const { addresses } = parseBitcoinConnectionResult({ connectedAddresses });
|
|
637
|
-
resolve({ addresses });
|
|
638
|
-
},
|
|
639
|
-
payload: {
|
|
640
|
-
message: "Address for receiving Ordinals and payments",
|
|
641
|
-
network,
|
|
642
|
-
purposes: [AddressPurpose.Ordinals, AddressPurpose.Payment]
|
|
643
|
-
}
|
|
644
|
-
});
|
|
645
|
-
});
|
|
646
|
-
};
|
|
647
|
-
const getActiveNetworkId = async () => getActiveNetworkIdFromLastKnownRegistry({
|
|
648
|
-
client: dynamicClient,
|
|
649
|
-
walletProviderKey: key
|
|
650
|
-
});
|
|
651
|
-
const getConnectedAddresses = async () => {
|
|
652
|
-
const { addresses } = await connect();
|
|
653
|
-
return { addresses: addresses.map((address$1) => address$1.address) };
|
|
654
|
-
};
|
|
655
|
-
const sendBitcoin = async ({ transaction, walletAccount }) => {
|
|
656
|
-
await assertWalletAccountSigningAvailability({ walletAccount }, dynamicClient);
|
|
657
|
-
const senderAddress = getWalletAccountAddressByType({
|
|
658
|
-
type: "payment",
|
|
659
|
-
walletAccount
|
|
660
|
-
}) ?? walletAccount.address;
|
|
661
|
-
const { network } = await getNetworkPayload();
|
|
662
|
-
return new Promise((resolve, reject) => {
|
|
663
|
-
sendBtcTransaction({
|
|
664
|
-
getProvider: async () => satsConnectProvider,
|
|
665
|
-
onCancel: () => {
|
|
666
|
-
reject(new UserRejectedError({ action: "sendBitcoin" }));
|
|
667
|
-
},
|
|
668
|
-
onFinish: (response) => {
|
|
669
|
-
resolve({ transactionId: response });
|
|
670
|
-
},
|
|
671
|
-
payload: {
|
|
672
|
-
network,
|
|
673
|
-
recipients: [{
|
|
674
|
-
address: transaction.recipientAddress,
|
|
675
|
-
amountSats: BigInt(transaction.amount)
|
|
676
|
-
}],
|
|
677
|
-
senderAddress
|
|
678
|
-
}
|
|
679
|
-
});
|
|
680
|
-
});
|
|
681
|
-
};
|
|
682
|
-
const signMessage$1 = async ({ message, walletAccount, protocol, addressType }) => {
|
|
683
|
-
assertDefined(walletAccount, "Wallet account not found");
|
|
684
|
-
await assertWalletAccountSigningAvailability({ walletAccount }, dynamicClient);
|
|
685
|
-
const { network } = await getNetworkPayload();
|
|
686
|
-
let addressToSignWith = walletAccount.address;
|
|
687
|
-
if (addressType) addressToSignWith = getWalletAccountAddressByType({
|
|
688
|
-
type: addressType,
|
|
689
|
-
walletAccount
|
|
690
|
-
}) ?? addressToSignWith;
|
|
691
|
-
return new Promise((resolve, reject) => {
|
|
692
|
-
signMessage({
|
|
693
|
-
getProvider: async () => satsConnectProvider,
|
|
694
|
-
onCancel: () => {
|
|
695
|
-
reject(new UserRejectedError({ action: "signMessage" }));
|
|
696
|
-
},
|
|
697
|
-
onFinish: async (response) => {
|
|
698
|
-
resolve({ signature: response });
|
|
699
|
-
},
|
|
700
|
-
payload: {
|
|
701
|
-
address: addressToSignWith,
|
|
702
|
-
message,
|
|
703
|
-
network,
|
|
704
|
-
protocol: getSatsConnectSigningProtocol(protocol)
|
|
705
|
-
}
|
|
706
|
-
});
|
|
707
|
-
});
|
|
708
|
-
};
|
|
709
|
-
const signPsbt = async ({ request: request$1, walletAccount }) => {
|
|
710
|
-
if (!request$1.allowedSighash.length) throw new InvalidPsbtError("allowedSighash cannot be an empty array");
|
|
711
|
-
await assertWalletAccountSigningAvailability({ walletAccount }, dynamicClient);
|
|
712
|
-
const network = convertNetworkIdForPsbt((await getActiveNetworkId()).networkId);
|
|
713
|
-
const { network: networkPayload } = await getNetworkPayload();
|
|
714
|
-
const inputsToSign = getPsbtInputsToSignForSatsConnect({
|
|
715
|
-
isLegacySatsConnect: true,
|
|
716
|
-
psbt: Psbt.fromBase64(request$1.unsignedPsbtBase64, { network }),
|
|
717
|
-
request: request$1
|
|
718
|
-
});
|
|
719
|
-
return new Promise((resolve, reject) => {
|
|
720
|
-
signTransaction({
|
|
721
|
-
getProvider: async () => satsConnectProvider,
|
|
722
|
-
onCancel: () => {
|
|
723
|
-
reject(new UserRejectedError({ action: "signPsbt" }));
|
|
724
|
-
},
|
|
725
|
-
onFinish: (response) => {
|
|
726
|
-
resolve({ signedPsbt: response.psbtBase64 });
|
|
727
|
-
},
|
|
728
|
-
payload: {
|
|
729
|
-
broadcast: false,
|
|
730
|
-
inputsToSign,
|
|
731
|
-
message: "Sign Pbst",
|
|
732
|
-
network: networkPayload,
|
|
733
|
-
psbtBase64: request$1.unsignedPsbtBase64
|
|
734
|
-
}
|
|
735
|
-
});
|
|
736
|
-
});
|
|
737
|
-
};
|
|
738
|
-
const signPsbts = async ({ requests, walletAccount }) => {
|
|
739
|
-
await assertWalletAccountSigningAvailability({ walletAccount }, dynamicClient);
|
|
740
|
-
const network = convertNetworkIdForPsbt((await getActiveNetworkId()).networkId);
|
|
741
|
-
const { network: networkPayload } = await getNetworkPayload();
|
|
742
|
-
const psbtsToSign = [];
|
|
743
|
-
for (const request$2 of requests) {
|
|
744
|
-
const inputsToSign = getPsbtInputsToSignForSatsConnect({
|
|
745
|
-
isLegacySatsConnect: true,
|
|
746
|
-
psbt: Psbt.fromBase64(request$2.unsignedPsbtBase64, { network }),
|
|
747
|
-
request: request$2
|
|
748
|
-
});
|
|
749
|
-
psbtsToSign.push({
|
|
750
|
-
inputsToSign,
|
|
751
|
-
psbtBase64: request$2.unsignedPsbtBase64
|
|
752
|
-
});
|
|
753
|
-
}
|
|
754
|
-
const request$1 = createUnsecuredToken({
|
|
755
|
-
message: "Sign Pbsts",
|
|
756
|
-
network: networkPayload,
|
|
757
|
-
psbts: psbtsToSign
|
|
758
|
-
});
|
|
759
|
-
return { signedPsbts: (await satsConnectProvider.signMultipleTransactions(request$1)).map((response) => response.psbtBase64) };
|
|
760
|
-
};
|
|
761
|
-
const { getEventEmitter, cleanupEventEmitter } = createWalletProviderEventEmitter({
|
|
762
|
-
removeEventListeners: ({ setupReturnValue }) => {
|
|
763
|
-
assertDefined(setupReturnValue, "Setup return value not defined");
|
|
764
|
-
setupReturnValue.removeAccountChangeListener();
|
|
765
|
-
},
|
|
766
|
-
setupEventListeners: ({ handleAccountsChanged }) => {
|
|
767
|
-
return { removeAccountChangeListener: addListener("accountsChanged", (accounts) => {
|
|
768
|
-
if (!accounts) return;
|
|
769
|
-
handleAccountsChanged({ addresses: accounts.map((account) => account.address) });
|
|
770
|
-
}) };
|
|
771
|
-
},
|
|
772
|
-
supportedEvents: ["accountsChanged"]
|
|
773
|
-
});
|
|
774
|
-
const destroy = async () => {
|
|
775
|
-
cleanupEventEmitter();
|
|
776
|
-
};
|
|
777
|
-
return {
|
|
778
|
-
chain,
|
|
779
|
-
confirmTransaction: (args) => bitcoinConfirmTransaction(args, dynamicClient),
|
|
780
|
-
connect,
|
|
781
|
-
destroy,
|
|
782
|
-
get events() {
|
|
783
|
-
return getEventEmitter();
|
|
784
|
-
},
|
|
785
|
-
executeSwapTransaction: (args) => bitcoinExecuteSwapTransaction(args, dynamicClient),
|
|
786
|
-
getActiveNetworkId,
|
|
787
|
-
getConnectedAddresses,
|
|
788
|
-
groupKey: formatWalletProviderGroupKey(MAGIC_EDEN_METADATA.displayName),
|
|
789
|
-
key,
|
|
790
|
-
metadata: MAGIC_EDEN_METADATA,
|
|
791
|
-
sendBitcoin,
|
|
792
|
-
signMessage: signMessage$1,
|
|
793
|
-
signPsbt,
|
|
794
|
-
signPsbts,
|
|
795
|
-
transferAmount: (args) => bitcoinTransferAmount(args, dynamicClient),
|
|
796
|
-
walletProviderType
|
|
797
|
-
};
|
|
798
|
-
};
|
|
799
|
-
|
|
800
|
-
//#endregion
|
|
801
|
-
//#region src/injected/utils/magicEden/getMagicEdenInjectedProvider/getMagicEdenInjectedProvider.ts
|
|
802
|
-
const MAGIC_EDEN_BITCOIN_PROVIDER_LOCATOR = "magicEden.bitcoin";
|
|
803
|
-
/** @notInstrumented */
|
|
804
|
-
const getMagicEdenInjectedProvider = () => {
|
|
805
|
-
return getInjectedProviderFromWindow(MAGIC_EDEN_BITCOIN_PROVIDER_LOCATOR);
|
|
806
|
-
};
|
|
807
|
-
|
|
808
552
|
//#endregion
|
|
809
553
|
//#region src/injected/utils/okx/createOkxBitcoinWalletProvider/createOkxBitcoinWalletProvider.ts
|
|
810
554
|
const OKX_METADATA = {
|
|
@@ -837,7 +581,7 @@ const createOkxBitcoinWalletProvider = ({ dynamicClient, injectedProvider }) =>
|
|
|
837
581
|
await assertWalletAccountSigningAvailability({ walletAccount }, dynamicClient);
|
|
838
582
|
return { transactionId: await injectedProvider.sendBitcoin(transaction.recipientAddress, transaction.amount.toString()) };
|
|
839
583
|
};
|
|
840
|
-
const signMessage
|
|
584
|
+
const signMessage = async ({ message, walletAccount, protocol }) => {
|
|
841
585
|
assertDefined(walletAccount, "Wallet account not found");
|
|
842
586
|
await assertWalletAccountSigningAvailability({ walletAccount }, dynamicClient);
|
|
843
587
|
return { signature: await injectedProvider.signMessage(message, protocol) };
|
|
@@ -894,7 +638,7 @@ const createOkxBitcoinWalletProvider = ({ dynamicClient, injectedProvider }) =>
|
|
|
894
638
|
key,
|
|
895
639
|
metadata: OKX_METADATA,
|
|
896
640
|
sendBitcoin,
|
|
897
|
-
signMessage
|
|
641
|
+
signMessage,
|
|
898
642
|
signPsbt,
|
|
899
643
|
signPsbts,
|
|
900
644
|
transferAmount: (args) => bitcoinTransferAmount(args, dynamicClient),
|
|
@@ -941,7 +685,7 @@ const createOneKeyBitcoinWalletProvider = ({ dynamicClient, injectedProvider })
|
|
|
941
685
|
await assertWalletAccountSigningAvailability({ walletAccount }, dynamicClient);
|
|
942
686
|
return { transactionId: await injectedProvider.sendBitcoin(transaction.recipientAddress, transaction.amount.toString()) };
|
|
943
687
|
};
|
|
944
|
-
const signMessage
|
|
688
|
+
const signMessage = async ({ message, walletAccount, protocol }) => {
|
|
945
689
|
assertDefined(walletAccount, "Wallet account not found");
|
|
946
690
|
await assertWalletAccountSigningAvailability({ walletAccount }, dynamicClient);
|
|
947
691
|
return { signature: await injectedProvider.signMessage(message, protocol) };
|
|
@@ -993,7 +737,7 @@ const createOneKeyBitcoinWalletProvider = ({ dynamicClient, injectedProvider })
|
|
|
993
737
|
key,
|
|
994
738
|
metadata: ONEKEY_METADATA,
|
|
995
739
|
sendBitcoin,
|
|
996
|
-
signMessage
|
|
740
|
+
signMessage,
|
|
997
741
|
signPsbt,
|
|
998
742
|
signPsbts,
|
|
999
743
|
transferAmount: (args) => bitcoinTransferAmount(args, dynamicClient),
|
|
@@ -1049,7 +793,7 @@ const createOylBitcoinWalletProvider = ({ dynamicClient, injectedProvider }) =>
|
|
|
1049
793
|
const { addresses } = await connect();
|
|
1050
794
|
return { addresses: addresses.map((address$1) => address$1.address) };
|
|
1051
795
|
};
|
|
1052
|
-
const signMessage
|
|
796
|
+
const signMessage = async ({ message, walletAccount, addressType, protocol }) => {
|
|
1053
797
|
assertDefined(walletAccount, "Wallet account not found");
|
|
1054
798
|
await assertWalletAccountSigningAvailability({ walletAccount }, dynamicClient);
|
|
1055
799
|
let addressToSignWith = walletAccount.address;
|
|
@@ -1095,7 +839,7 @@ const createOylBitcoinWalletProvider = ({ dynamicClient, injectedProvider }) =>
|
|
|
1095
839
|
groupKey: formatWalletProviderGroupKey(OYL_METADATA.displayName),
|
|
1096
840
|
key,
|
|
1097
841
|
metadata: OYL_METADATA,
|
|
1098
|
-
signMessage
|
|
842
|
+
signMessage,
|
|
1099
843
|
signPsbt,
|
|
1100
844
|
signPsbts,
|
|
1101
845
|
transferAmount: (args) => bitcoinTransferAmount(args, dynamicClient),
|
|
@@ -1144,7 +888,7 @@ const createPhantomBitcoinWalletProvider = ({ dynamicClient, injectedProvider })
|
|
|
1144
888
|
const { addresses } = await connect();
|
|
1145
889
|
return { addresses: addresses.map((address$1) => address$1.address) };
|
|
1146
890
|
};
|
|
1147
|
-
const signMessage
|
|
891
|
+
const signMessage = async ({ message, walletAccount, addressType }) => {
|
|
1148
892
|
assertDefined(walletAccount, "Wallet account not found");
|
|
1149
893
|
await assertWalletAccountSigningAvailability({ walletAccount }, dynamicClient);
|
|
1150
894
|
let addressToSignWith = walletAccount.address;
|
|
@@ -1206,7 +950,7 @@ const createPhantomBitcoinWalletProvider = ({ dynamicClient, injectedProvider })
|
|
|
1206
950
|
groupKey: formatWalletProviderGroupKey(PHANTOM_METADATA.displayName),
|
|
1207
951
|
key,
|
|
1208
952
|
metadata: PHANTOM_METADATA,
|
|
1209
|
-
signMessage
|
|
953
|
+
signMessage,
|
|
1210
954
|
signPsbt,
|
|
1211
955
|
signPsbts,
|
|
1212
956
|
transferAmount: (args) => bitcoinTransferAmount(args, dynamicClient),
|
|
@@ -1230,6 +974,60 @@ const getUnisatInjectedProvider = () => {
|
|
|
1230
974
|
return getInjectedProviderFromWindow(UNISAT_PROVIDER_LOCATOR);
|
|
1231
975
|
};
|
|
1232
976
|
|
|
977
|
+
//#endregion
|
|
978
|
+
//#region src/utils/convertNetworkIdToSatsConnectNetworkType/convertNetworkIdToSatsConnectNetworkType.ts
|
|
979
|
+
/** @notInstrumented */
|
|
980
|
+
const convertNetworkIdToSatsConnectNetworkType = (networkId) => {
|
|
981
|
+
if (networkId === "2") return BitcoinNetworkType.Testnet;
|
|
982
|
+
if (networkId === "3") return BitcoinNetworkType.Signet;
|
|
983
|
+
return BitcoinNetworkType.Mainnet;
|
|
984
|
+
};
|
|
985
|
+
|
|
986
|
+
//#endregion
|
|
987
|
+
//#region src/utils/getPsbtInputsToSignForSatsConnect/getPsbtInputsToSignForSatsConnect.ts
|
|
988
|
+
/**
|
|
989
|
+
* This method will create the psbt sign options for SatsConnect for the given request
|
|
990
|
+
* It will validate the psbt against the signature data provided in the request
|
|
991
|
+
* It will return the inputs to sign if the signature data is provided
|
|
992
|
+
* @notInstrumented
|
|
993
|
+
*/
|
|
994
|
+
const getPsbtInputsToSignForSatsConnect = ({ psbt, request: request$1, isLegacySatsConnect }) => {
|
|
995
|
+
if (!request$1.signature) return [];
|
|
996
|
+
validatePsbt({
|
|
997
|
+
allowedSigHashTypes: request$1.allowedSighash,
|
|
998
|
+
psbt,
|
|
999
|
+
signatureData: request$1.signature
|
|
1000
|
+
});
|
|
1001
|
+
const inputsToSign = [];
|
|
1002
|
+
for (const signature of request$1.signature) if (signature.signingIndexes?.length) for (const index of signature.signingIndexes) inputsToSign.push({
|
|
1003
|
+
address: signature.address,
|
|
1004
|
+
sigHash: isLegacySatsConnect ? getSigHashType({ input: psbt.data.inputs[index] }) : request$1.allowedSighash[0],
|
|
1005
|
+
signingIndexes: [index]
|
|
1006
|
+
});
|
|
1007
|
+
return inputsToSign;
|
|
1008
|
+
};
|
|
1009
|
+
|
|
1010
|
+
//#endregion
|
|
1011
|
+
//#region src/utils/getSatsConnectSigningProtocol/getSatsConnectSigningProtocol.ts
|
|
1012
|
+
/** @notInstrumented */
|
|
1013
|
+
const getSatsConnectSigningProtocol = (protocol) => {
|
|
1014
|
+
if (!protocol) return;
|
|
1015
|
+
return protocol === "ecdsa" ? MessageSigningProtocols.ECDSA : MessageSigningProtocols.BIP322;
|
|
1016
|
+
};
|
|
1017
|
+
|
|
1018
|
+
//#endregion
|
|
1019
|
+
//#region src/utils/parseBitcoinConnectionResult/parseBitcoinConnectionResult.ts
|
|
1020
|
+
/** @notInstrumented */
|
|
1021
|
+
const parseBitcoinConnectionResult = ({ connectedAddresses }) => {
|
|
1022
|
+
const addresses = connectedAddresses.filter((address$1) => address$1.purpose === "ordinals" || address$1.purpose === "payment").map((account) => ({
|
|
1023
|
+
address: account.address,
|
|
1024
|
+
publicKey: account.publicKey,
|
|
1025
|
+
type: account.purpose === "payment" ? "payment" : "ordinals"
|
|
1026
|
+
}));
|
|
1027
|
+
addresses.sort((a) => a.type === "ordinals" ? -1 : 1);
|
|
1028
|
+
return { addresses };
|
|
1029
|
+
};
|
|
1030
|
+
|
|
1233
1031
|
//#endregion
|
|
1234
1032
|
//#region src/utils/signMultipleTransactionsWithSatsConnect/signMultipleTransactionsWithSatsConnect.ts
|
|
1235
1033
|
/** @notInstrumented */
|
|
@@ -1302,7 +1100,7 @@ const createXverseBitcoinWalletProvider = ({ dynamicClient, satsConnectProvider
|
|
|
1302
1100
|
if (response.status !== "success") throw response.error;
|
|
1303
1101
|
return { transactionId: response.result.txid };
|
|
1304
1102
|
};
|
|
1305
|
-
const signMessage
|
|
1103
|
+
const signMessage = async ({ message, walletAccount, protocol, addressType }) => {
|
|
1306
1104
|
assertDefined(walletAccount, "Wallet account not found");
|
|
1307
1105
|
await assertWalletAccountSigningAvailability({ walletAccount }, dynamicClient);
|
|
1308
1106
|
let addressToSignWith = walletAccount.address;
|
|
@@ -1403,7 +1201,7 @@ const createXverseBitcoinWalletProvider = ({ dynamicClient, satsConnectProvider
|
|
|
1403
1201
|
key,
|
|
1404
1202
|
metadata: XVERSE_METADATA,
|
|
1405
1203
|
sendBitcoin,
|
|
1406
|
-
signMessage
|
|
1204
|
+
signMessage,
|
|
1407
1205
|
signPsbt,
|
|
1408
1206
|
signPsbts,
|
|
1409
1207
|
transferAmount: (args) => bitcoinTransferAmount(args, dynamicClient),
|
|
@@ -1425,7 +1223,7 @@ const BITCOIN_INJECTED_WALLETS_EXTENSION_KEY = "bitcoinInjectedWallets";
|
|
|
1425
1223
|
/**
|
|
1426
1224
|
* Adds the Bitcoin Injected Wallets extension to the Dynamic client.
|
|
1427
1225
|
*
|
|
1428
|
-
* This extension enables integration with many Bitcoin wallets, like
|
|
1226
|
+
* This extension enables integration with many Bitcoin wallets, like Xverse, Unisat, Phantom, and more.
|
|
1429
1227
|
*
|
|
1430
1228
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1431
1229
|
* @notInstrumented
|
|
@@ -1460,14 +1258,6 @@ const addBitcoinInjectedWalletsExtension = (client = getDefaultClient()) => {
|
|
|
1460
1258
|
});
|
|
1461
1259
|
injectedWalletProviders.push(xverseWalletProvider);
|
|
1462
1260
|
}
|
|
1463
|
-
const magicEdenInjectedProvider = getMagicEdenInjectedProvider();
|
|
1464
|
-
if (magicEdenInjectedProvider) {
|
|
1465
|
-
const magicEdenWalletProvider = createMagicEdenBitcoinWalletProvider({
|
|
1466
|
-
dynamicClient: client,
|
|
1467
|
-
satsConnectProvider: magicEdenInjectedProvider
|
|
1468
|
-
});
|
|
1469
|
-
injectedWalletProviders.push(magicEdenWalletProvider);
|
|
1470
|
-
}
|
|
1471
1261
|
const okxInjectedProvider = getOkxBitcoinInjectedProvider();
|
|
1472
1262
|
if (okxInjectedProvider) {
|
|
1473
1263
|
const okxWalletProvider = createOkxBitcoinWalletProvider({
|
|
@@ -1526,4 +1316,4 @@ const addBitcoinInjectedWalletsExtension = (client = getDefaultClient()) => {
|
|
|
1526
1316
|
|
|
1527
1317
|
//#endregion
|
|
1528
1318
|
export { addBitcoinInjectedWalletsExtension as t };
|
|
1529
|
-
//# sourceMappingURL=addBitcoinInjectedWalletsExtension-
|
|
1319
|
+
//# sourceMappingURL=addBitcoinInjectedWalletsExtension-ANJKUrmH.esm.js.map
|