@dynamic-labs-sdk/bitcoin 1.18.0 → 1.19.1
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/addBitcoinExtension/addBitcoinExtension.d.ts +10 -1
- package/dist/addBitcoinExtension/addBitcoinExtension.d.ts.map +1 -1
- package/dist/{addBitcoinInjectedWalletsExtension-P-36oK75.cjs → addBitcoinInjectedWalletsExtension-DBK8dr4V.cjs} +3 -3
- package/dist/{addBitcoinInjectedWalletsExtension-P-36oK75.cjs.map → addBitcoinInjectedWalletsExtension-DBK8dr4V.cjs.map} +1 -1
- package/dist/{addBitcoinInjectedWalletsExtension-CZbBF0L9.esm.js → addBitcoinInjectedWalletsExtension-DE2jrn09.esm.js} +2 -2
- package/dist/{addBitcoinInjectedWalletsExtension-CZbBF0L9.esm.js.map → addBitcoinInjectedWalletsExtension-DE2jrn09.esm.js.map} +1 -1
- package/dist/{addWaasBitcoinExtension-DTE42Z_R.esm.js → addWaasBitcoinExtension-BJ2N-I0D.esm.js} +2 -2
- package/dist/{addWaasBitcoinExtension-DTE42Z_R.esm.js.map → addWaasBitcoinExtension-BJ2N-I0D.esm.js.map} +1 -1
- package/dist/{addWaasBitcoinExtension-D9iaqGxY.cjs → addWaasBitcoinExtension-D-cviSbW.cjs} +2 -2
- package/dist/{addWaasBitcoinExtension-D9iaqGxY.cjs.map → addWaasBitcoinExtension-D-cviSbW.cjs.map} +1 -1
- package/dist/{bitcoinTransferAmount-CmhABTHH.cjs → bitcoinTransferAmount-D6FaWJqj.cjs} +45 -13
- package/dist/bitcoinTransferAmount-D6FaWJqj.cjs.map +1 -0
- package/dist/{bitcoinTransferAmount-KNyaHLlt.esm.js → bitcoinTransferAmount-k4mPyiFn.esm.js} +44 -12
- package/dist/bitcoinTransferAmount-k4mPyiFn.esm.js.map +1 -0
- package/dist/index.cjs +78 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +78 -20
- package/dist/index.esm.js.map +1 -1
- package/dist/injected.cjs +3 -3
- package/dist/injected.esm.js +2 -2
- package/dist/isBitcoinNetworkProvider/isBitcoinNetworkProvider.d.ts +10 -1
- package/dist/isBitcoinNetworkProvider/isBitcoinNetworkProvider.d.ts.map +1 -1
- package/dist/isBitcoinWalletAccount/isBitcoinWalletAccount.d.ts +9 -1
- package/dist/isBitcoinWalletAccount/isBitcoinWalletAccount.d.ts.map +1 -1
- package/dist/sendBitcoin/sendBitcoin.d.ts +18 -7
- package/dist/sendBitcoin/sendBitcoin.d.ts.map +1 -1
- package/dist/sendRawTransaction/sendRawTransaction.d.ts +18 -5
- package/dist/sendRawTransaction/sendRawTransaction.d.ts.map +1 -1
- package/dist/signMessageWithCustomOptions/signMessageWithCustomOptions.d.ts +23 -10
- package/dist/signMessageWithCustomOptions/signMessageWithCustomOptions.d.ts.map +1 -1
- package/dist/signPsbt/signPsbt.d.ts +17 -5
- package/dist/signPsbt/signPsbt.d.ts.map +1 -1
- package/dist/signPsbts/signPsbts.d.ts +20 -5
- package/dist/signPsbts/signPsbts.d.ts.map +1 -1
- 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/bitcoinTransferAmount-CmhABTHH.cjs.map +0 -1
- package/dist/bitcoinTransferAmount-KNyaHLlt.esm.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bitcoinTransferAmount-D6FaWJqj.cjs","names":["BaseError","InvalidParamError","Psbt","BaseError","MethodNotImplementedError","InvalidParamError"],"sources":["../package.json","../src/constants.ts","../src/utils/getMempoolApiUrl/getMempoolApiUrl.ts","../src/utils/satoshisToBtc/satoshisToBtc.ts","../src/utils/fetchBtcBalance/fetchBtcBalance.ts","../src/utils/createBitcoinNetworkProvider/createBitcoinNetworkProvider.ts","../src/registerBitcoinNetworkProviderBuilder/registerBitcoinNetworkProviderBuilder.ts","../src/isBitcoinWalletAccount/isBitcoinWalletAccount.ts","../src/isBitcoinWalletProvider/isBitcoinWalletProvider.ts","../src/errors/SendBitcoinRawTransactionError.ts","../src/sendRawTransaction/sendRawTransaction.ts","../src/utils/convertPsbtToBase64/convertPsbtToBase64.ts","../src/utils/bitcoinExecuteSwapTransaction/bitcoinExecuteSwapTransaction.ts","../src/errors/NotBitcoinProviderError.ts","../src/sendBitcoin/sendBitcoin.ts","../src/utils/bitcoinTransferAmount/bitcoinTransferAmount.ts"],"sourcesContent":["","export const MEMPOOL_API_URL = 'https://mempool.space/api';\nexport const MEMPOOL_API_URL_TESTNET = 'https://mempool.space/testnet/api';\nexport const MEMPOOL_API_URL_SIGNET = 'https://mempool.space/signet/api';\n","import { MEMPOOL_API_URL, MEMPOOL_API_URL_TESTNET } from '../../constants';\n\n/** @notInstrumented */\nexport const getMempoolApiUrl = (address: string) =>\n address.startsWith('t') ? MEMPOOL_API_URL_TESTNET : MEMPOOL_API_URL;\n","/** @notInstrumented */\nexport const satoshisToBtc = (satoshis: number) => satoshis / 100000000;\n","import { getMempoolApiUrl } from '../getMempoolApiUrl';\nimport { satoshisToBtc } from '../satoshisToBtc';\n\n/** @notInstrumented */\nexport const fetchBtcBalance = async ({\n address,\n}: {\n address: string;\n}): Promise<string | null> => {\n const API_URL = getMempoolApiUrl(address);\n\n const response = await fetch(`${API_URL}/address/${address}`);\n\n if (!response.ok) {\n return null;\n }\n\n const addressInfo = await response.json();\n\n if (!addressInfo?.chain_stats || !addressInfo?.mempool_stats) {\n return null;\n }\n\n const confirmedBalanceInSats =\n Number(addressInfo.chain_stats.funded_txo_sum) -\n Number(addressInfo.chain_stats.spent_txo_sum);\n\n const unconfirmedBalanceInSats =\n Number(addressInfo.mempool_stats.funded_txo_sum) -\n Number(addressInfo.mempool_stats.spent_txo_sum);\n\n const balance = satoshisToBtc(\n confirmedBalanceInSats + unconfirmedBalanceInSats\n );\n\n return balance.toString();\n};\n","import type { NetworkData } from '@dynamic-labs-sdk/client';\nimport { createBaseNetworkProvider } from '@dynamic-labs-sdk/client/core';\n\nimport type { BitcoinNetworkProvider } from '../../BitcoinNetworkProvider.types';\nimport { fetchBtcBalance } from '../fetchBtcBalance';\n\n/** @notInstrumented */\nexport const createBitcoinNetworkProvider = (\n networkData: NetworkData\n): BitcoinNetworkProvider => ({\n ...createBaseNetworkProvider('BTC', networkData),\n cluster: networkData.cluster,\n getBalance: async ({ address }) => ({\n balance: await fetchBtcBalance({\n address,\n }),\n }),\n});\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { getNetworkProviderBuilderRegistry } from '@dynamic-labs-sdk/client/core';\n\nimport { createBitcoinNetworkProvider } from '../utils/createBitcoinNetworkProvider';\n\n/** @notInstrumented */\nexport const registerBitcoinNetworkProviderBuilder = (\n client: DynamicClient\n): void => {\n const networkProviderBuilderRegistry =\n getNetworkProviderBuilderRegistry(client);\n\n /**\n * If the Bitcoin network provider builder is already registered, return.\n */\n if (networkProviderBuilderRegistry.get().get('BTC')) {\n return;\n }\n\n networkProviderBuilderRegistry.register({\n builder: createBitcoinNetworkProvider,\n chain: 'BTC',\n });\n};\n","import type { WalletAccount } from '@dynamic-labs-sdk/client';\n\nimport type { BitcoinWalletAccount } from '../BitcoinWalletAccount.types';\n\n/**\n * Type guard function to check if a wallet account is a Bitcoin wallet account.\n *\n * @example\n * ```ts\n * const accounts = getWalletAccounts();\n * const btcAccounts = accounts.filter(isBitcoinWalletAccount);\n * ```\n *\n * @param walletAccount - The wallet account to check.\n * @returns True if the wallet account is a Bitcoin wallet account, false otherwise.\n * @see isBitcoinNetworkProvider\n * @see addBitcoinExtension\n * @notInstrumented\n */\nexport const isBitcoinWalletAccount = (\n walletAccount: WalletAccount\n): walletAccount is BitcoinWalletAccount => walletAccount.chain === 'BTC';\n","import type { WalletProvider } from '@dynamic-labs-sdk/client/core';\n\nimport type { BitcoinWalletProvider } from '../BitcoinWalletProvider.types';\n\n/** @notInstrumented */\nexport const isBitcoinWalletProvider = (\n provider: WalletProvider\n): provider is BitcoinWalletProvider => {\n return provider.chain === 'BTC';\n};\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\ntype SendBitcoinRawTransactionErrorParams = {\n originalError: unknown;\n};\n\nexport class SendBitcoinRawTransactionError extends BaseError {\n constructor({ originalError }: SendBitcoinRawTransactionErrorParams) {\n const cause = originalError instanceof Error ? originalError : null;\n\n super({\n cause,\n code: 'send_bitcoin_raw_transaction_error',\n docsUrl: null,\n name: 'SendBitcoinRawTransactionError',\n shortMessage: 'Failed to send Bitcoin raw transaction',\n });\n }\n}\n","import { getDefaultClient } from '@dynamic-labs-sdk/client';\nimport { getCore } from '@dynamic-labs-sdk/client/core';\n\nimport type { BitcoinWalletAccount } from '../BitcoinWalletAccount.types';\nimport { SendBitcoinRawTransactionError } from '../errors/SendBitcoinRawTransactionError';\nimport { getMempoolApiUrl } from '../utils/getMempoolApiUrl';\n\ntype SendRawTransactionParams = {\n rawTransaction: string;\n walletAccount: BitcoinWalletAccount;\n};\n\n/**\n * Sends a raw transaction using the mempool.space API.\n *\n * @example\n * ```ts\n * const { transactionId } = await sendRawTransaction({\n * walletAccount: btcAccount,\n * rawTransaction: '0200000001...',\n * });\n * ```\n *\n * @param params.rawTransaction - The raw transaction hex to broadcast.\n * @param params.walletAccount - The wallet account whose network determines the API endpoint.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns An object containing the transaction id.\n * @throws {SendBitcoinRawTransactionError} If the mempool API returns an error.\n * @see sendBitcoin\n * @see signPsbt\n * @notInstrumented\n */\nexport const sendRawTransaction = async (\n { rawTransaction, walletAccount }: SendRawTransactionParams,\n client = getDefaultClient()\n): Promise<{\n transactionId: string;\n}> => {\n const fetchService = getCore(client).fetch;\n\n const API_URL = getMempoolApiUrl(walletAccount.address);\n\n const response = await fetchService(`${API_URL}/tx`, {\n body: rawTransaction,\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n method: 'POST',\n });\n\n if (!response.ok) {\n throw new SendBitcoinRawTransactionError({\n originalError: await response.text(),\n });\n }\n\n // this endpoint returns the transaction ID\n const transactionId = await response.text();\n\n return { transactionId };\n};\n","import { getBuffer } from '@dynamic-labs-sdk/client/core';\n\n/** @notInstrumented */\n// eslint-disable-next-line custom-rules/require-single-object-param\nexport const convertPsbtToBase64 = (psbt: string): string => {\n // Lowercase to handle uppercase hex encoding (e.g., 70736274FF)\n const psbtBase64 = psbt.toLowerCase().startsWith('70736274ff')\n ? getBuffer().from(psbt, 'hex').toString('base64')\n : psbt;\n\n return psbtBase64;\n};\n","import {\n type DynamicClient,\n InvalidParamError,\n} from '@dynamic-labs-sdk/client';\nimport type {\n ExecuteSwapTransactionParams,\n ExecuteSwapTransactionResult,\n} from '@dynamic-labs-sdk/client/core';\nimport { getWalletProviderFromWalletAccount } from '@dynamic-labs-sdk/client/core';\nimport { Psbt } from 'bitcoinjs-lib';\n\nimport { isBitcoinWalletAccount } from '../../isBitcoinWalletAccount';\nimport { isBitcoinWalletProvider } from '../../isBitcoinWalletProvider';\nimport { sendRawTransaction } from '../../sendRawTransaction';\nimport { convertPsbtToBase64 } from '../convertPsbtToBase64';\n\n/** @notInstrumented */\nexport const bitcoinExecuteSwapTransaction = async (\n { onStepChange, signingPayload, walletAccount }: ExecuteSwapTransactionParams,\n client: DynamicClient\n): Promise<ExecuteSwapTransactionResult> => {\n const provider = getWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n if (\n !isBitcoinWalletAccount(walletAccount) ||\n !isBitcoinWalletProvider(provider)\n ) {\n throw new InvalidParamError(\n 'Wallet account is not a Bitcoin wallet account'\n );\n }\n\n if (!signingPayload.psbt) {\n throw new InvalidParamError(\n 'Signing payload is missing PSBT transaction data'\n );\n }\n\n onStepChange?.('transaction');\n\n // make sure the psbt is base64 encoded, no matter if it comes as hex or base64\n const psbtBase64 = convertPsbtToBase64(signingPayload.psbt);\n\n // Parse the unsigned PSBT to determine which inputs need signing.\n // Explicitly passing signingIndexes ensures all wallet providers\n // (including Phantom, which requires it) know which inputs to sign.\n const unsignedPsbt = Psbt.fromBase64(psbtBase64);\n const signingIndexes = unsignedPsbt.txInputs.map((_, i) => i);\n\n const { signedPsbt } = await provider.signPsbt({\n request: {\n allowedSighash: [1],\n signature: [\n {\n address: walletAccount.address,\n signingIndexes,\n },\n ],\n unsignedPsbtBase64: psbtBase64,\n },\n walletAccount,\n });\n\n const psbt = Psbt.fromBase64(signedPsbt);\n\n // Some wallets return an already-finalized PSBT; only finalize\n // inputs that haven't been finalized yet.\n psbt.data.inputs.forEach((input, idx) => {\n if (!input.finalScriptSig && !input.finalScriptWitness) {\n psbt.finalizeInput(idx);\n }\n });\n\n const rawTxHex = psbt.extractTransaction().toHex();\n\n const { transactionId } = await sendRawTransaction(\n { rawTransaction: rawTxHex, walletAccount },\n client\n );\n\n return { transactionHash: transactionId };\n};\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\nexport class NotBitcoinProviderError extends BaseError {\n public readonly providerKey: string;\n\n constructor(params: { providerKey: string }) {\n super({\n cause: null,\n code: 'not_bitcoin_provider_error',\n docsUrl: null,\n name: 'NotBitcoinProviderError',\n shortMessage: 'Provider is not a Bitcoin wallet provider',\n });\n\n this.providerKey = params.providerKey;\n }\n}\n","import { getDefaultClient } from '@dynamic-labs-sdk/client';\nimport {\n MethodNotImplementedError,\n getWalletProviderFromWalletAccount,\n} from '@dynamic-labs-sdk/client/core';\n\nimport type { BitcoinWalletAccount } from '../BitcoinWalletAccount.types';\nimport type {\n BitcoinSendTransactionResponse,\n BitcoinTransaction,\n} from '../BitcoinWalletProvider.types';\nimport { NotBitcoinProviderError } from '../errors/NotBitcoinProviderError';\nimport { isBitcoinWalletProvider } from '../isBitcoinWalletProvider';\n\ntype SendBitcoinParams = {\n transaction: BitcoinTransaction;\n walletAccount: BitcoinWalletAccount;\n};\n\n/**\n * Sends a Bitcoin transaction.\n *\n * @example\n * ```ts\n * const { transactionId } = await sendBitcoin({\n * walletAccount: btcAccount,\n * transaction: { recipientAddress: 'bc1q...', amount: 50000n },\n * });\n * ```\n *\n * @param params.transaction - The transaction to send.\n * @param params.walletAccount - The wallet account to send the transaction from.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns An object containing the transaction id.\n * @throws {MethodNotImplementedError} If the wallet provider does not implement the sendBitcoin method.\n * @throws {NotBitcoinProviderError} If the wallet account is not a valid BitcoinWalletAccount.\n * @see sendRawTransaction\n * @see signPsbt\n * @notInstrumented\n */\nexport const sendBitcoin = async (\n { walletAccount, transaction }: SendBitcoinParams,\n client = getDefaultClient()\n): Promise<BitcoinSendTransactionResponse> => {\n const provider = getWalletProviderFromWalletAccount(\n {\n walletAccount,\n },\n client\n );\n\n if (!isBitcoinWalletProvider(provider)) {\n throw new NotBitcoinProviderError({ providerKey: provider.key });\n }\n\n if (!provider.sendBitcoin) {\n throw new MethodNotImplementedError('sendBitcoin');\n }\n\n return provider.sendBitcoin({ transaction, walletAccount });\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { InvalidParamError } from '@dynamic-labs-sdk/client';\nimport {\n type TransferAmountParams,\n parseAmountToSmallestUnit,\n} from '@dynamic-labs-sdk/client/core';\n\nimport { isBitcoinWalletAccount } from '../../isBitcoinWalletAccount';\nimport { sendBitcoin } from '../../sendBitcoin';\n\nconst BTC_DECIMALS = 8;\n\n/**\n * Transfers native BTC from one wallet to another.\n *\n * Converts the human-readable BTC amount string to satoshis (8 decimals)\n * and delegates to `sendBitcoin`.\n *\n * @param params.amount - The amount in BTC as a decimal string (e.g. \"0.001\").\n * @param params.recipient - The recipient Bitcoin address.\n * @param params.walletAccount - The wallet account to send from.\n * @param client - The Dynamic client instance.\n * @returns An object containing the transaction hash.\n * @notInstrumented\n */\nexport const bitcoinTransferAmount = async (\n { amount, recipient, walletAccount }: TransferAmountParams,\n client: DynamicClient\n): Promise<{ transactionHash: string }> => {\n if (!isBitcoinWalletAccount(walletAccount)) {\n throw new InvalidParamError(\n 'Wallet account is not a Bitcoin wallet account'\n );\n }\n\n const satoshis = parseAmountToSmallestUnit({ amount, decimals: BTC_DECIMALS });\n\n const result = await sendBitcoin(\n {\n transaction: {\n amount: satoshis,\n recipientAddress: recipient,\n },\n walletAccount,\n },\n client\n );\n\n return { transactionHash: result.transactionId };\n};\n"],"mappings":"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"}
|
package/dist/{bitcoinTransferAmount-KNyaHLlt.esm.js → bitcoinTransferAmount-k4mPyiFn.esm.js}
RENAMED
|
@@ -4,7 +4,7 @@ import { Psbt } from "bitcoinjs-lib";
|
|
|
4
4
|
|
|
5
5
|
//#region package.json
|
|
6
6
|
var name = "@dynamic-labs-sdk/bitcoin";
|
|
7
|
-
var version = "1.
|
|
7
|
+
var version = "1.19.1";
|
|
8
8
|
|
|
9
9
|
//#endregion
|
|
10
10
|
//#region src/constants.ts
|
|
@@ -62,8 +62,16 @@ const registerBitcoinNetworkProviderBuilder = (client) => {
|
|
|
62
62
|
/**
|
|
63
63
|
* Type guard function to check if a wallet account is a Bitcoin wallet account.
|
|
64
64
|
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* const accounts = getWalletAccounts();
|
|
68
|
+
* const btcAccounts = accounts.filter(isBitcoinWalletAccount);
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
65
71
|
* @param walletAccount - The wallet account to check.
|
|
66
72
|
* @returns True if the wallet account is a Bitcoin wallet account, false otherwise.
|
|
73
|
+
* @see isBitcoinNetworkProvider
|
|
74
|
+
* @see addBitcoinExtension
|
|
67
75
|
* @notInstrumented
|
|
68
76
|
*/
|
|
69
77
|
const isBitcoinWalletAccount = (walletAccount) => walletAccount.chain === "BTC";
|
|
@@ -93,10 +101,23 @@ var SendBitcoinRawTransactionError = class extends BaseError {
|
|
|
93
101
|
//#endregion
|
|
94
102
|
//#region src/sendRawTransaction/sendRawTransaction.ts
|
|
95
103
|
/**
|
|
96
|
-
* Sends a raw transaction using the mempool.space API
|
|
97
|
-
*
|
|
98
|
-
* @
|
|
99
|
-
*
|
|
104
|
+
* Sends a raw transaction using the mempool.space API.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* const { transactionId } = await sendRawTransaction({
|
|
109
|
+
* walletAccount: btcAccount,
|
|
110
|
+
* rawTransaction: '0200000001...',
|
|
111
|
+
* });
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
114
|
+
* @param params.rawTransaction - The raw transaction hex to broadcast.
|
|
115
|
+
* @param params.walletAccount - The wallet account whose network determines the API endpoint.
|
|
116
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
117
|
+
* @returns An object containing the transaction id.
|
|
118
|
+
* @throws {SendBitcoinRawTransactionError} If the mempool API returns an error.
|
|
119
|
+
* @see sendBitcoin
|
|
120
|
+
* @see signPsbt
|
|
100
121
|
* @notInstrumented
|
|
101
122
|
*/
|
|
102
123
|
const sendRawTransaction = async ({ rawTransaction, walletAccount }, client = getDefaultClient$1()) => {
|
|
@@ -168,13 +189,24 @@ var NotBitcoinProviderError = class extends BaseError {
|
|
|
168
189
|
//#endregion
|
|
169
190
|
//#region src/sendBitcoin/sendBitcoin.ts
|
|
170
191
|
/**
|
|
171
|
-
* Sends a Bitcoin transaction
|
|
172
|
-
*
|
|
173
|
-
* @
|
|
192
|
+
* Sends a Bitcoin transaction.
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```ts
|
|
196
|
+
* const { transactionId } = await sendBitcoin({
|
|
197
|
+
* walletAccount: btcAccount,
|
|
198
|
+
* transaction: { recipientAddress: 'bc1q...', amount: 50000n },
|
|
199
|
+
* });
|
|
200
|
+
* ```
|
|
201
|
+
*
|
|
202
|
+
* @param params.transaction - The transaction to send.
|
|
203
|
+
* @param params.walletAccount - The wallet account to send the transaction from.
|
|
174
204
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
175
|
-
* @returns An object containing the transaction id
|
|
176
|
-
* @throws {MethodNotImplementedError} If the wallet provider does not implement the sendBitcoin method
|
|
177
|
-
* @throws {NotBitcoinProviderError} If the wallet account is not a valid BitcoinWalletAccount
|
|
205
|
+
* @returns An object containing the transaction id.
|
|
206
|
+
* @throws {MethodNotImplementedError} If the wallet provider does not implement the sendBitcoin method.
|
|
207
|
+
* @throws {NotBitcoinProviderError} If the wallet account is not a valid BitcoinWalletAccount.
|
|
208
|
+
* @see sendRawTransaction
|
|
209
|
+
* @see signPsbt
|
|
178
210
|
* @notInstrumented
|
|
179
211
|
*/
|
|
180
212
|
const sendBitcoin = async ({ walletAccount, transaction }, client = getDefaultClient$1()) => {
|
|
@@ -219,4 +251,4 @@ const bitcoinTransferAmount = async ({ amount, recipient, walletAccount }, clien
|
|
|
219
251
|
|
|
220
252
|
//#endregion
|
|
221
253
|
export { sendRawTransaction as a, registerBitcoinNetworkProviderBuilder as c, version as d, bitcoinExecuteSwapTransaction as i, getMempoolApiUrl as l, sendBitcoin as n, isBitcoinWalletProvider as o, NotBitcoinProviderError as r, isBitcoinWalletAccount as s, bitcoinTransferAmount as t, name as u };
|
|
222
|
-
//# sourceMappingURL=bitcoinTransferAmount-
|
|
254
|
+
//# sourceMappingURL=bitcoinTransferAmount-k4mPyiFn.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bitcoinTransferAmount-k4mPyiFn.esm.js","names":["address","address","getDefaultClient","getDefaultClient"],"sources":["../package.json","../src/constants.ts","../src/utils/getMempoolApiUrl/getMempoolApiUrl.ts","../src/utils/satoshisToBtc/satoshisToBtc.ts","../src/utils/fetchBtcBalance/fetchBtcBalance.ts","../src/utils/createBitcoinNetworkProvider/createBitcoinNetworkProvider.ts","../src/registerBitcoinNetworkProviderBuilder/registerBitcoinNetworkProviderBuilder.ts","../src/isBitcoinWalletAccount/isBitcoinWalletAccount.ts","../src/isBitcoinWalletProvider/isBitcoinWalletProvider.ts","../src/errors/SendBitcoinRawTransactionError.ts","../src/sendRawTransaction/sendRawTransaction.ts","../src/utils/convertPsbtToBase64/convertPsbtToBase64.ts","../src/utils/bitcoinExecuteSwapTransaction/bitcoinExecuteSwapTransaction.ts","../src/errors/NotBitcoinProviderError.ts","../src/sendBitcoin/sendBitcoin.ts","../src/utils/bitcoinTransferAmount/bitcoinTransferAmount.ts"],"sourcesContent":["","export const MEMPOOL_API_URL = 'https://mempool.space/api';\nexport const MEMPOOL_API_URL_TESTNET = 'https://mempool.space/testnet/api';\nexport const MEMPOOL_API_URL_SIGNET = 'https://mempool.space/signet/api';\n","import { MEMPOOL_API_URL, MEMPOOL_API_URL_TESTNET } from '../../constants';\n\n/** @notInstrumented */\nexport const getMempoolApiUrl = (address: string) =>\n address.startsWith('t') ? MEMPOOL_API_URL_TESTNET : MEMPOOL_API_URL;\n","/** @notInstrumented */\nexport const satoshisToBtc = (satoshis: number) => satoshis / 100000000;\n","import { getMempoolApiUrl } from '../getMempoolApiUrl';\nimport { satoshisToBtc } from '../satoshisToBtc';\n\n/** @notInstrumented */\nexport const fetchBtcBalance = async ({\n address,\n}: {\n address: string;\n}): Promise<string | null> => {\n const API_URL = getMempoolApiUrl(address);\n\n const response = await fetch(`${API_URL}/address/${address}`);\n\n if (!response.ok) {\n return null;\n }\n\n const addressInfo = await response.json();\n\n if (!addressInfo?.chain_stats || !addressInfo?.mempool_stats) {\n return null;\n }\n\n const confirmedBalanceInSats =\n Number(addressInfo.chain_stats.funded_txo_sum) -\n Number(addressInfo.chain_stats.spent_txo_sum);\n\n const unconfirmedBalanceInSats =\n Number(addressInfo.mempool_stats.funded_txo_sum) -\n Number(addressInfo.mempool_stats.spent_txo_sum);\n\n const balance = satoshisToBtc(\n confirmedBalanceInSats + unconfirmedBalanceInSats\n );\n\n return balance.toString();\n};\n","import type { NetworkData } from '@dynamic-labs-sdk/client';\nimport { createBaseNetworkProvider } from '@dynamic-labs-sdk/client/core';\n\nimport type { BitcoinNetworkProvider } from '../../BitcoinNetworkProvider.types';\nimport { fetchBtcBalance } from '../fetchBtcBalance';\n\n/** @notInstrumented */\nexport const createBitcoinNetworkProvider = (\n networkData: NetworkData\n): BitcoinNetworkProvider => ({\n ...createBaseNetworkProvider('BTC', networkData),\n cluster: networkData.cluster,\n getBalance: async ({ address }) => ({\n balance: await fetchBtcBalance({\n address,\n }),\n }),\n});\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { getNetworkProviderBuilderRegistry } from '@dynamic-labs-sdk/client/core';\n\nimport { createBitcoinNetworkProvider } from '../utils/createBitcoinNetworkProvider';\n\n/** @notInstrumented */\nexport const registerBitcoinNetworkProviderBuilder = (\n client: DynamicClient\n): void => {\n const networkProviderBuilderRegistry =\n getNetworkProviderBuilderRegistry(client);\n\n /**\n * If the Bitcoin network provider builder is already registered, return.\n */\n if (networkProviderBuilderRegistry.get().get('BTC')) {\n return;\n }\n\n networkProviderBuilderRegistry.register({\n builder: createBitcoinNetworkProvider,\n chain: 'BTC',\n });\n};\n","import type { WalletAccount } from '@dynamic-labs-sdk/client';\n\nimport type { BitcoinWalletAccount } from '../BitcoinWalletAccount.types';\n\n/**\n * Type guard function to check if a wallet account is a Bitcoin wallet account.\n *\n * @example\n * ```ts\n * const accounts = getWalletAccounts();\n * const btcAccounts = accounts.filter(isBitcoinWalletAccount);\n * ```\n *\n * @param walletAccount - The wallet account to check.\n * @returns True if the wallet account is a Bitcoin wallet account, false otherwise.\n * @see isBitcoinNetworkProvider\n * @see addBitcoinExtension\n * @notInstrumented\n */\nexport const isBitcoinWalletAccount = (\n walletAccount: WalletAccount\n): walletAccount is BitcoinWalletAccount => walletAccount.chain === 'BTC';\n","import type { WalletProvider } from '@dynamic-labs-sdk/client/core';\n\nimport type { BitcoinWalletProvider } from '../BitcoinWalletProvider.types';\n\n/** @notInstrumented */\nexport const isBitcoinWalletProvider = (\n provider: WalletProvider\n): provider is BitcoinWalletProvider => {\n return provider.chain === 'BTC';\n};\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\ntype SendBitcoinRawTransactionErrorParams = {\n originalError: unknown;\n};\n\nexport class SendBitcoinRawTransactionError extends BaseError {\n constructor({ originalError }: SendBitcoinRawTransactionErrorParams) {\n const cause = originalError instanceof Error ? originalError : null;\n\n super({\n cause,\n code: 'send_bitcoin_raw_transaction_error',\n docsUrl: null,\n name: 'SendBitcoinRawTransactionError',\n shortMessage: 'Failed to send Bitcoin raw transaction',\n });\n }\n}\n","import { getDefaultClient } from '@dynamic-labs-sdk/client';\nimport { getCore } from '@dynamic-labs-sdk/client/core';\n\nimport type { BitcoinWalletAccount } from '../BitcoinWalletAccount.types';\nimport { SendBitcoinRawTransactionError } from '../errors/SendBitcoinRawTransactionError';\nimport { getMempoolApiUrl } from '../utils/getMempoolApiUrl';\n\ntype SendRawTransactionParams = {\n rawTransaction: string;\n walletAccount: BitcoinWalletAccount;\n};\n\n/**\n * Sends a raw transaction using the mempool.space API.\n *\n * @example\n * ```ts\n * const { transactionId } = await sendRawTransaction({\n * walletAccount: btcAccount,\n * rawTransaction: '0200000001...',\n * });\n * ```\n *\n * @param params.rawTransaction - The raw transaction hex to broadcast.\n * @param params.walletAccount - The wallet account whose network determines the API endpoint.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns An object containing the transaction id.\n * @throws {SendBitcoinRawTransactionError} If the mempool API returns an error.\n * @see sendBitcoin\n * @see signPsbt\n * @notInstrumented\n */\nexport const sendRawTransaction = async (\n { rawTransaction, walletAccount }: SendRawTransactionParams,\n client = getDefaultClient()\n): Promise<{\n transactionId: string;\n}> => {\n const fetchService = getCore(client).fetch;\n\n const API_URL = getMempoolApiUrl(walletAccount.address);\n\n const response = await fetchService(`${API_URL}/tx`, {\n body: rawTransaction,\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n method: 'POST',\n });\n\n if (!response.ok) {\n throw new SendBitcoinRawTransactionError({\n originalError: await response.text(),\n });\n }\n\n // this endpoint returns the transaction ID\n const transactionId = await response.text();\n\n return { transactionId };\n};\n","import { getBuffer } from '@dynamic-labs-sdk/client/core';\n\n/** @notInstrumented */\n// eslint-disable-next-line custom-rules/require-single-object-param\nexport const convertPsbtToBase64 = (psbt: string): string => {\n // Lowercase to handle uppercase hex encoding (e.g., 70736274FF)\n const psbtBase64 = psbt.toLowerCase().startsWith('70736274ff')\n ? getBuffer().from(psbt, 'hex').toString('base64')\n : psbt;\n\n return psbtBase64;\n};\n","import {\n type DynamicClient,\n InvalidParamError,\n} from '@dynamic-labs-sdk/client';\nimport type {\n ExecuteSwapTransactionParams,\n ExecuteSwapTransactionResult,\n} from '@dynamic-labs-sdk/client/core';\nimport { getWalletProviderFromWalletAccount } from '@dynamic-labs-sdk/client/core';\nimport { Psbt } from 'bitcoinjs-lib';\n\nimport { isBitcoinWalletAccount } from '../../isBitcoinWalletAccount';\nimport { isBitcoinWalletProvider } from '../../isBitcoinWalletProvider';\nimport { sendRawTransaction } from '../../sendRawTransaction';\nimport { convertPsbtToBase64 } from '../convertPsbtToBase64';\n\n/** @notInstrumented */\nexport const bitcoinExecuteSwapTransaction = async (\n { onStepChange, signingPayload, walletAccount }: ExecuteSwapTransactionParams,\n client: DynamicClient\n): Promise<ExecuteSwapTransactionResult> => {\n const provider = getWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n if (\n !isBitcoinWalletAccount(walletAccount) ||\n !isBitcoinWalletProvider(provider)\n ) {\n throw new InvalidParamError(\n 'Wallet account is not a Bitcoin wallet account'\n );\n }\n\n if (!signingPayload.psbt) {\n throw new InvalidParamError(\n 'Signing payload is missing PSBT transaction data'\n );\n }\n\n onStepChange?.('transaction');\n\n // make sure the psbt is base64 encoded, no matter if it comes as hex or base64\n const psbtBase64 = convertPsbtToBase64(signingPayload.psbt);\n\n // Parse the unsigned PSBT to determine which inputs need signing.\n // Explicitly passing signingIndexes ensures all wallet providers\n // (including Phantom, which requires it) know which inputs to sign.\n const unsignedPsbt = Psbt.fromBase64(psbtBase64);\n const signingIndexes = unsignedPsbt.txInputs.map((_, i) => i);\n\n const { signedPsbt } = await provider.signPsbt({\n request: {\n allowedSighash: [1],\n signature: [\n {\n address: walletAccount.address,\n signingIndexes,\n },\n ],\n unsignedPsbtBase64: psbtBase64,\n },\n walletAccount,\n });\n\n const psbt = Psbt.fromBase64(signedPsbt);\n\n // Some wallets return an already-finalized PSBT; only finalize\n // inputs that haven't been finalized yet.\n psbt.data.inputs.forEach((input, idx) => {\n if (!input.finalScriptSig && !input.finalScriptWitness) {\n psbt.finalizeInput(idx);\n }\n });\n\n const rawTxHex = psbt.extractTransaction().toHex();\n\n const { transactionId } = await sendRawTransaction(\n { rawTransaction: rawTxHex, walletAccount },\n client\n );\n\n return { transactionHash: transactionId };\n};\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\nexport class NotBitcoinProviderError extends BaseError {\n public readonly providerKey: string;\n\n constructor(params: { providerKey: string }) {\n super({\n cause: null,\n code: 'not_bitcoin_provider_error',\n docsUrl: null,\n name: 'NotBitcoinProviderError',\n shortMessage: 'Provider is not a Bitcoin wallet provider',\n });\n\n this.providerKey = params.providerKey;\n }\n}\n","import { getDefaultClient } from '@dynamic-labs-sdk/client';\nimport {\n MethodNotImplementedError,\n getWalletProviderFromWalletAccount,\n} from '@dynamic-labs-sdk/client/core';\n\nimport type { BitcoinWalletAccount } from '../BitcoinWalletAccount.types';\nimport type {\n BitcoinSendTransactionResponse,\n BitcoinTransaction,\n} from '../BitcoinWalletProvider.types';\nimport { NotBitcoinProviderError } from '../errors/NotBitcoinProviderError';\nimport { isBitcoinWalletProvider } from '../isBitcoinWalletProvider';\n\ntype SendBitcoinParams = {\n transaction: BitcoinTransaction;\n walletAccount: BitcoinWalletAccount;\n};\n\n/**\n * Sends a Bitcoin transaction.\n *\n * @example\n * ```ts\n * const { transactionId } = await sendBitcoin({\n * walletAccount: btcAccount,\n * transaction: { recipientAddress: 'bc1q...', amount: 50000n },\n * });\n * ```\n *\n * @param params.transaction - The transaction to send.\n * @param params.walletAccount - The wallet account to send the transaction from.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns An object containing the transaction id.\n * @throws {MethodNotImplementedError} If the wallet provider does not implement the sendBitcoin method.\n * @throws {NotBitcoinProviderError} If the wallet account is not a valid BitcoinWalletAccount.\n * @see sendRawTransaction\n * @see signPsbt\n * @notInstrumented\n */\nexport const sendBitcoin = async (\n { walletAccount, transaction }: SendBitcoinParams,\n client = getDefaultClient()\n): Promise<BitcoinSendTransactionResponse> => {\n const provider = getWalletProviderFromWalletAccount(\n {\n walletAccount,\n },\n client\n );\n\n if (!isBitcoinWalletProvider(provider)) {\n throw new NotBitcoinProviderError({ providerKey: provider.key });\n }\n\n if (!provider.sendBitcoin) {\n throw new MethodNotImplementedError('sendBitcoin');\n }\n\n return provider.sendBitcoin({ transaction, walletAccount });\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { InvalidParamError } from '@dynamic-labs-sdk/client';\nimport {\n type TransferAmountParams,\n parseAmountToSmallestUnit,\n} from '@dynamic-labs-sdk/client/core';\n\nimport { isBitcoinWalletAccount } from '../../isBitcoinWalletAccount';\nimport { sendBitcoin } from '../../sendBitcoin';\n\nconst BTC_DECIMALS = 8;\n\n/**\n * Transfers native BTC from one wallet to another.\n *\n * Converts the human-readable BTC amount string to satoshis (8 decimals)\n * and delegates to `sendBitcoin`.\n *\n * @param params.amount - The amount in BTC as a decimal string (e.g. \"0.001\").\n * @param params.recipient - The recipient Bitcoin address.\n * @param params.walletAccount - The wallet account to send from.\n * @param client - The Dynamic client instance.\n * @returns An object containing the transaction hash.\n * @notInstrumented\n */\nexport const bitcoinTransferAmount = async (\n { amount, recipient, walletAccount }: TransferAmountParams,\n client: DynamicClient\n): Promise<{ transactionHash: string }> => {\n if (!isBitcoinWalletAccount(walletAccount)) {\n throw new InvalidParamError(\n 'Wallet account is not a Bitcoin wallet account'\n );\n }\n\n const satoshis = parseAmountToSmallestUnit({ amount, decimals: BTC_DECIMALS });\n\n const result = await sendBitcoin(\n {\n transaction: {\n amount: satoshis,\n recipientAddress: recipient,\n },\n walletAccount,\n },\n client\n );\n\n return { transactionHash: result.transactionId };\n};\n"],"mappings":"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"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const require_addWaasBitcoinExtension = require('./addWaasBitcoinExtension-
|
|
2
|
-
const require_bitcoinTransferAmount = require('./bitcoinTransferAmount-
|
|
3
|
-
const require_addBitcoinInjectedWalletsExtension = require('./addBitcoinInjectedWalletsExtension-
|
|
1
|
+
const require_addWaasBitcoinExtension = require('./addWaasBitcoinExtension-D-cviSbW.cjs');
|
|
2
|
+
const require_bitcoinTransferAmount = require('./bitcoinTransferAmount-D6FaWJqj.cjs');
|
|
3
|
+
const require_addBitcoinInjectedWalletsExtension = require('./addBitcoinInjectedWalletsExtension-DBK8dr4V.cjs');
|
|
4
4
|
let _dynamic_labs_sdk_assert_package_version = require("@dynamic-labs-sdk/assert-package-version");
|
|
5
5
|
let _dynamic_labs_sdk_client_core = require("@dynamic-labs-sdk/client/core");
|
|
6
6
|
let _dynamic_labs_sdk_client = require("@dynamic-labs-sdk/client");
|
|
@@ -14,7 +14,16 @@ let _dynamic_labs_sdk_client = require("@dynamic-labs-sdk/client");
|
|
|
14
14
|
* including injected wallets (MagicEden, Xverse, Unisat, and more) and embedded wallets
|
|
15
15
|
* managed by Dynamic's infrastructure.
|
|
16
16
|
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* const client = createDynamicClient({ environmentId: 'env-123' });
|
|
20
|
+
* addBitcoinExtension(client);
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
17
23
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
24
|
+
* @returns Nothing. The Bitcoin extensions are registered on the client as a side effect.
|
|
25
|
+
* @see isBitcoinWalletAccount
|
|
26
|
+
* @see isBitcoinNetworkProvider
|
|
18
27
|
* @notInstrumented
|
|
19
28
|
*/
|
|
20
29
|
const addBitcoinExtension = (client = (0, _dynamic_labs_sdk_client_core.getDefaultClient)()) => {
|
|
@@ -27,8 +36,17 @@ const addBitcoinExtension = (client = (0, _dynamic_labs_sdk_client_core.getDefau
|
|
|
27
36
|
/**
|
|
28
37
|
* Type guard function to check if a network provider is a Bitcoin network provider.
|
|
29
38
|
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* if (isBitcoinNetworkProvider(networkProvider)) {
|
|
42
|
+
* const { balance } = await networkProvider.getBalance({ address });
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
30
46
|
* @param networkProvider - The network provider to check.
|
|
31
47
|
* @returns True if the network provider is a Bitcoin network provider, false otherwise.
|
|
48
|
+
* @see isBitcoinWalletAccount
|
|
49
|
+
* @see addBitcoinExtension
|
|
32
50
|
* @notInstrumented
|
|
33
51
|
*/
|
|
34
52
|
const isBitcoinNetworkProvider = (networkProvider) => networkProvider.chain === "BTC";
|
|
@@ -36,18 +54,31 @@ const isBitcoinNetworkProvider = (networkProvider) => networkProvider.chain ===
|
|
|
36
54
|
//#endregion
|
|
37
55
|
//#region src/signMessageWithCustomOptions/signMessageWithCustomOptions.ts
|
|
38
56
|
/**
|
|
39
|
-
* Signs a message with custom options, like a specific address type or protocol
|
|
57
|
+
* Signs a message with custom options, like a specific address type or protocol.
|
|
40
58
|
*
|
|
41
|
-
* If the wallet provider does not support specifying an address type or protocol,
|
|
59
|
+
* If the wallet provider does not support specifying an address type or protocol,
|
|
60
|
+
* it will use the default values.
|
|
42
61
|
*
|
|
43
|
-
* @
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* const { signature } = await signMessageWithCustomOptions({
|
|
65
|
+
* walletAccount: btcAccount,
|
|
66
|
+
* message: 'Hello Bitcoin',
|
|
67
|
+
* protocol: 'bip322-simple',
|
|
68
|
+
* addressType: 'payment',
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @param params.addressType - The address type to use for signing ('ordinals' or 'payment').
|
|
73
|
+
* @param params.message - The message to sign.
|
|
74
|
+
* @param params.protocol - The protocol to use for signing ('ecdsa' or 'bip322-simple').
|
|
75
|
+
* @param params.walletAccount - The wallet account to sign the message with.
|
|
47
76
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
48
|
-
* @returns An object containing the signature
|
|
49
|
-
* @throws {MethodNotImplementedError} If the wallet provider does not implement the signMessage method
|
|
50
|
-
* @throws {NotBitcoinProviderError} If the wallet account is not a valid BitcoinWalletAccount
|
|
77
|
+
* @returns An object containing the signature.
|
|
78
|
+
* @throws {MethodNotImplementedError} If the wallet provider does not implement the signMessage method.
|
|
79
|
+
* @throws {NotBitcoinProviderError} If the wallet account is not a valid BitcoinWalletAccount.
|
|
80
|
+
* @see signPsbt
|
|
81
|
+
* @see sendBitcoin
|
|
51
82
|
* @notInstrumented
|
|
52
83
|
*/
|
|
53
84
|
const signMessageWithCustomOptions = async ({ walletAccount, message, protocol, addressType }, client = (0, _dynamic_labs_sdk_client.getDefaultClient)()) => {
|
|
@@ -65,11 +96,23 @@ const signMessageWithCustomOptions = async ({ walletAccount, message, protocol,
|
|
|
65
96
|
//#endregion
|
|
66
97
|
//#region src/signPsbt/signPsbt.ts
|
|
67
98
|
/**
|
|
68
|
-
* Signs a PSBT
|
|
69
|
-
*
|
|
70
|
-
* @
|
|
99
|
+
* Signs a Partially Signed Bitcoin Transaction (PSBT).
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* const { signedPsbt } = await signPsbt({
|
|
104
|
+
* walletAccount: btcAccount,
|
|
105
|
+
* request: { unsignedPsbtBase64: 'cHNidP8B...', allowedSighash: [1] },
|
|
106
|
+
* });
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* @param params.request - The request data including the PSBT and inputs to sign.
|
|
110
|
+
* @param params.walletAccount - The wallet account to sign the PSBT with.
|
|
71
111
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
72
|
-
* @returns An object containing the signed PSBT
|
|
112
|
+
* @returns An object containing the signed PSBT.
|
|
113
|
+
* @throws {NotBitcoinProviderError} If the wallet account is not a valid BitcoinWalletAccount.
|
|
114
|
+
* @see signPsbts
|
|
115
|
+
* @see sendBitcoin
|
|
73
116
|
* @notInstrumented
|
|
74
117
|
*/
|
|
75
118
|
const signPsbt = async ({ walletAccount, request }, client = (0, _dynamic_labs_sdk_client.getDefaultClient)()) => {
|
|
@@ -84,11 +127,26 @@ const signPsbt = async ({ walletAccount, request }, client = (0, _dynamic_labs_s
|
|
|
84
127
|
//#endregion
|
|
85
128
|
//#region src/signPsbts/signPsbts.ts
|
|
86
129
|
/**
|
|
87
|
-
* Signs multiple PSBTs
|
|
88
|
-
*
|
|
89
|
-
* @
|
|
130
|
+
* Signs multiple Partially Signed Bitcoin Transactions (PSBTs) in a single call.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* const { signedPsbts } = await signPsbts({
|
|
135
|
+
* walletAccount: btcAccount,
|
|
136
|
+
* requests: [
|
|
137
|
+
* { unsignedPsbtBase64: 'cHNidP8B...', allowedSighash: [1] },
|
|
138
|
+
* { unsignedPsbtBase64: 'cHNidP8C...', allowedSighash: [1] },
|
|
139
|
+
* ],
|
|
140
|
+
* });
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* @param params.requests - The list of request data to sign the PSBTs.
|
|
144
|
+
* @param params.walletAccount - The wallet account to sign the PSBTs with.
|
|
90
145
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
91
|
-
* @returns An object containing the signed
|
|
146
|
+
* @returns An object containing the array of signed PSBTs.
|
|
147
|
+
* @throws {NotBitcoinProviderError} If the wallet account is not a valid BitcoinWalletAccount.
|
|
148
|
+
* @see signPsbt
|
|
149
|
+
* @see sendBitcoin
|
|
92
150
|
* @notInstrumented
|
|
93
151
|
*/
|
|
94
152
|
const signPsbts = async ({ walletAccount, requests }, client = (0, _dynamic_labs_sdk_client.getDefaultClient)()) => {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["isBitcoinWalletProvider","NotBitcoinProviderError","MethodNotImplementedError","isBitcoinWalletProvider","NotBitcoinProviderError","isBitcoinWalletProvider","NotBitcoinProviderError","packageName","packageVersion"],"sources":["../src/addBitcoinExtension/addBitcoinExtension.ts","../src/isBitcoinNetworkProvider/isBitcoinNetworkProvider.ts","../src/signMessageWithCustomOptions/signMessageWithCustomOptions.ts","../src/signPsbt/signPsbt.ts","../src/signPsbts/signPsbts.ts","../src/exports/index.ts"],"sourcesContent":["import { getDefaultClient } from '@dynamic-labs-sdk/client/core';\n\nimport { addBitcoinInjectedWalletsExtension } from '../injected/addBitcoinInjectedWalletsExtension';\nimport { addWaasBitcoinExtension } from '../waas/addWaasBitcoinExtension';\n\n/**\n * Adds the Bitcoin extension to the Dynamic client.\n *\n * This is a convenience function that adds both the Bitcoin Injected Wallets extension\n * and the Dynamic WaaS Bitcoin extension, enabling support for all Bitcoin wallet types\n * including injected wallets (MagicEden, Xverse, Unisat, and more) and embedded wallets\n * managed by Dynamic's infrastructure.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @notInstrumented\n */\n\nexport const addBitcoinExtension = (client = getDefaultClient()): void => {\n addBitcoinInjectedWalletsExtension(client);\n addWaasBitcoinExtension(client);\n};\n","import type { NetworkProvider } from '@dynamic-labs-sdk/client';\n\nimport type { BitcoinNetworkProvider } from '../BitcoinNetworkProvider.types';\n\n/**\n * Type guard function to check if a network provider is a Bitcoin network provider.\n *\n * @param networkProvider - The network provider to check.\n * @returns True if the network provider is a Bitcoin network provider, false otherwise.\n * @notInstrumented\n */\nexport const isBitcoinNetworkProvider = (\n networkProvider: NetworkProvider\n): networkProvider is BitcoinNetworkProvider => networkProvider.chain === 'BTC';\n","import { getDefaultClient } from '@dynamic-labs-sdk/client';\nimport {\n MethodNotImplementedError,\n getWalletProviderFromWalletAccount,\n} from '@dynamic-labs-sdk/client/core';\n\nimport type { BitcoinWalletAccount } from '../BitcoinWalletAccount.types';\nimport type {\n BitcoinAddressType,\n BitcoinSignProtocol,\n} from '../BitcoinWalletProvider.types';\nimport { NotBitcoinProviderError } from '../errors/NotBitcoinProviderError';\nimport { isBitcoinWalletProvider } from '../isBitcoinWalletProvider';\n\ntype SignMessageWithCustomOptionsParams = {\n addressType?: BitcoinAddressType;\n message: string;\n protocol?: BitcoinSignProtocol;\n walletAccount: BitcoinWalletAccount;\n};\n\n/**\n * Signs a message with custom options, like a specific address type or protocol\n *\n * If the wallet provider does not support specifying an address type or protocol, it will use the default values.\n *\n * @param params.addressType - The address type to use for signing ('ordinals' or 'payment')\n * @param params.message - The message to sign\n * @param params.protocol - The protocol to use for signing ('ecdsa' or 'bip322-simple')\n * @param params.walletAccount - The wallet account to sign the message with\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns An object containing the signature\n * @throws {MethodNotImplementedError} If the wallet provider does not implement the signMessage method\n * @throws {NotBitcoinProviderError} If the wallet account is not a valid BitcoinWalletAccount\n * @notInstrumented\n */\nexport const signMessageWithCustomOptions = async (\n {\n walletAccount,\n message,\n protocol,\n addressType,\n }: SignMessageWithCustomOptionsParams,\n client = getDefaultClient()\n): Promise<{ signature: string }> => {\n const provider = getWalletProviderFromWalletAccount(\n {\n walletAccount,\n },\n client\n );\n\n if (!isBitcoinWalletProvider(provider)) {\n throw new NotBitcoinProviderError({ providerKey: provider.key });\n }\n\n if (!provider.signMessage) {\n throw new MethodNotImplementedError('signMessage');\n }\n\n return provider.signMessage({\n addressType,\n message,\n protocol,\n walletAccount,\n });\n};\n","import { getDefaultClient } from '@dynamic-labs-sdk/client';\nimport { getWalletProviderFromWalletAccount } from '@dynamic-labs-sdk/client/core';\n\nimport type { BitcoinWalletAccount } from '../BitcoinWalletAccount.types';\nimport type { BitcoinSignPsbtRequest } from '../BitcoinWalletProvider.types';\nimport { NotBitcoinProviderError } from '../errors/NotBitcoinProviderError';\nimport { isBitcoinWalletProvider } from '../isBitcoinWalletProvider';\n\ntype SignPsbtParams = {\n request: BitcoinSignPsbtRequest;\n walletAccount: BitcoinWalletAccount;\n};\n\n/**\n * Signs a PSBT\n * @param params.request - The request data to sign the PSBT\n * @param params.walletAccount - The wallet account to sign the PSBT with\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns An object containing the signed PSBT\n * @notInstrumented\n */\nexport const signPsbt = async (\n { walletAccount, request }: SignPsbtParams,\n client = getDefaultClient()\n): Promise<{ signedPsbt: string }> => {\n const provider = getWalletProviderFromWalletAccount(\n {\n walletAccount,\n },\n client\n );\n\n if (!isBitcoinWalletProvider(provider)) {\n throw new NotBitcoinProviderError({ providerKey: provider.key });\n }\n\n return provider.signPsbt({ request, walletAccount });\n};\n","import { getDefaultClient } from '@dynamic-labs-sdk/client';\nimport { getWalletProviderFromWalletAccount } from '@dynamic-labs-sdk/client/core';\n\nimport type { BitcoinWalletAccount } from '../BitcoinWalletAccount.types';\nimport type { BitcoinSignPsbtRequest } from '../BitcoinWalletProvider.types';\nimport { NotBitcoinProviderError } from '../errors/NotBitcoinProviderError';\nimport { isBitcoinWalletProvider } from '../isBitcoinWalletProvider';\n\ntype SignPsbtsParams = {\n requests: BitcoinSignPsbtRequest[];\n walletAccount: BitcoinWalletAccount;\n};\n\n/**\n * Signs multiple PSBTs\n * @param params.requests - The list of request data to sign the PSBTs\n * @param params.walletAccount - The wallet account to sign the PSBT with\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns An object containing the signed PSBT\n * @notInstrumented\n */\nexport const signPsbts = async (\n { walletAccount, requests }: SignPsbtsParams,\n client = getDefaultClient()\n): Promise<{ signedPsbts: string[] }> => {\n const provider = getWalletProviderFromWalletAccount(\n {\n walletAccount,\n },\n client\n );\n\n if (!isBitcoinWalletProvider(provider)) {\n throw new NotBitcoinProviderError({ providerKey: provider.key });\n }\n\n return provider.signPsbts({ requests, walletAccount });\n};\n","import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';\n\nimport {\n name as packageName,\n version as packageVersion,\n} from '../../package.json';\nassertPackageVersion(packageName, packageVersion);\n\nexport { addBitcoinExtension } from '../addBitcoinExtension';\nexport type { BitcoinNetworkProvider } from '../BitcoinNetworkProvider.types';\nexport type { BitcoinWalletAccount } from '../BitcoinWalletAccount.types';\nexport type {\n BitcoinAddressType,\n BitcoinSendTransactionResponse,\n BitcoinSignProtocol,\n BitcoinSignPsbtRequest,\n BitcoinTransaction,\n} from '../BitcoinWalletProvider.types';\nexport { InvalidPsbtError } from '../errors/InvalidPsbtError';\nexport { TransactionBroadcastFailedError } from '../errors/TransactionBroadcastFailedError';\nexport { TransactionRequiredError } from '../errors/TransactionRequiredError';\nexport { isBitcoinNetworkProvider } from '../isBitcoinNetworkProvider';\nexport { isBitcoinWalletAccount } from '../isBitcoinWalletAccount';\nexport { sendBitcoin } from '../sendBitcoin';\nexport { sendRawTransaction } from '../sendRawTransaction';\nexport { signMessageWithCustomOptions } from '../signMessageWithCustomOptions';\nexport { signPsbt } from '../signPsbt';\nexport { signPsbts } from '../signPsbts';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiBA,MAAa,uBAAuB,8DAA2B,KAAW;AACxE,+EAAmC,OAAO;AAC1C,yDAAwB,OAAO;;;;;;;;;;;;ACRjC,MAAa,4BACX,oBAC8C,gBAAgB,UAAU;;;;;;;;;;;;;;;;;;;ACuB1E,MAAa,+BAA+B,OAC1C,EACE,eACA,SACA,UACA,eAEF,yDAA2B,KACQ;CACnC,MAAM,iFACJ,EACE,eACD,EACD,OACD;AAED,KAAI,CAACA,sDAAwB,SAAS,CACpC,OAAM,IAAIC,sDAAwB,EAAE,aAAa,SAAS,KAAK,CAAC;AAGlE,KAAI,CAAC,SAAS,YACZ,OAAM,IAAIC,wDAA0B,cAAc;AAGpD,QAAO,SAAS,YAAY;EAC1B;EACA;EACA;EACA;EACD,CAAC;;;;;;;;;;;;;AC5CJ,MAAa,WAAW,OACtB,EAAE,eAAe,WACjB,yDAA2B,KACS;CACpC,MAAM,iFACJ,EACE,eACD,EACD,OACD;AAED,KAAI,CAACC,sDAAwB,SAAS,CACpC,OAAM,IAAIC,sDAAwB,EAAE,aAAa,SAAS,KAAK,CAAC;AAGlE,QAAO,SAAS,SAAS;EAAE;EAAS;EAAe,CAAC;;;;;;;;;;;;;ACftD,MAAa,YAAY,OACvB,EAAE,eAAe,YACjB,yDAA2B,KACY;CACvC,MAAM,iFACJ,EACE,eACD,EACD,OACD;AAED,KAAI,CAACC,sDAAwB,SAAS,CACpC,OAAM,IAAIC,sDAAwB,EAAE,aAAa,SAAS,KAAK,CAAC;AAGlE,QAAO,SAAS,UAAU;EAAE;EAAU;EAAe,CAAC;;;;;mEC9BnCC,oCAAaC,sCAAe"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["isBitcoinWalletProvider","NotBitcoinProviderError","MethodNotImplementedError","isBitcoinWalletProvider","NotBitcoinProviderError","isBitcoinWalletProvider","NotBitcoinProviderError","packageName","packageVersion"],"sources":["../src/addBitcoinExtension/addBitcoinExtension.ts","../src/isBitcoinNetworkProvider/isBitcoinNetworkProvider.ts","../src/signMessageWithCustomOptions/signMessageWithCustomOptions.ts","../src/signPsbt/signPsbt.ts","../src/signPsbts/signPsbts.ts","../src/exports/index.ts"],"sourcesContent":["import { getDefaultClient } from '@dynamic-labs-sdk/client/core';\n\nimport { addBitcoinInjectedWalletsExtension } from '../injected/addBitcoinInjectedWalletsExtension';\nimport { addWaasBitcoinExtension } from '../waas/addWaasBitcoinExtension';\n\n/**\n * Adds the Bitcoin extension to the Dynamic client.\n *\n * This is a convenience function that adds both the Bitcoin Injected Wallets extension\n * and the Dynamic WaaS Bitcoin extension, enabling support for all Bitcoin wallet types\n * including injected wallets (MagicEden, Xverse, Unisat, and more) and embedded wallets\n * managed by Dynamic's infrastructure.\n *\n * @example\n * ```ts\n * const client = createDynamicClient({ environmentId: 'env-123' });\n * addBitcoinExtension(client);\n * ```\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns Nothing. The Bitcoin extensions are registered on the client as a side effect.\n * @see isBitcoinWalletAccount\n * @see isBitcoinNetworkProvider\n * @notInstrumented\n */\n\nexport const addBitcoinExtension = (client = getDefaultClient()): void => {\n addBitcoinInjectedWalletsExtension(client);\n addWaasBitcoinExtension(client);\n};\n","import type { NetworkProvider } from '@dynamic-labs-sdk/client';\n\nimport type { BitcoinNetworkProvider } from '../BitcoinNetworkProvider.types';\n\n/**\n * Type guard function to check if a network provider is a Bitcoin network provider.\n *\n * @example\n * ```ts\n * if (isBitcoinNetworkProvider(networkProvider)) {\n * const { balance } = await networkProvider.getBalance({ address });\n * }\n * ```\n *\n * @param networkProvider - The network provider to check.\n * @returns True if the network provider is a Bitcoin network provider, false otherwise.\n * @see isBitcoinWalletAccount\n * @see addBitcoinExtension\n * @notInstrumented\n */\nexport const isBitcoinNetworkProvider = (\n networkProvider: NetworkProvider\n): networkProvider is BitcoinNetworkProvider => networkProvider.chain === 'BTC';\n","import { getDefaultClient } from '@dynamic-labs-sdk/client';\nimport {\n MethodNotImplementedError,\n getWalletProviderFromWalletAccount,\n} from '@dynamic-labs-sdk/client/core';\n\nimport type { BitcoinWalletAccount } from '../BitcoinWalletAccount.types';\nimport type {\n BitcoinAddressType,\n BitcoinSignProtocol,\n} from '../BitcoinWalletProvider.types';\nimport { NotBitcoinProviderError } from '../errors/NotBitcoinProviderError';\nimport { isBitcoinWalletProvider } from '../isBitcoinWalletProvider';\n\ntype SignMessageWithCustomOptionsParams = {\n addressType?: BitcoinAddressType;\n message: string;\n protocol?: BitcoinSignProtocol;\n walletAccount: BitcoinWalletAccount;\n};\n\n/**\n * Signs a message with custom options, like a specific address type or protocol.\n *\n * If the wallet provider does not support specifying an address type or protocol,\n * it will use the default values.\n *\n * @example\n * ```ts\n * const { signature } = await signMessageWithCustomOptions({\n * walletAccount: btcAccount,\n * message: 'Hello Bitcoin',\n * protocol: 'bip322-simple',\n * addressType: 'payment',\n * });\n * ```\n *\n * @param params.addressType - The address type to use for signing ('ordinals' or 'payment').\n * @param params.message - The message to sign.\n * @param params.protocol - The protocol to use for signing ('ecdsa' or 'bip322-simple').\n * @param params.walletAccount - The wallet account to sign the message with.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns An object containing the signature.\n * @throws {MethodNotImplementedError} If the wallet provider does not implement the signMessage method.\n * @throws {NotBitcoinProviderError} If the wallet account is not a valid BitcoinWalletAccount.\n * @see signPsbt\n * @see sendBitcoin\n * @notInstrumented\n */\nexport const signMessageWithCustomOptions = async (\n {\n walletAccount,\n message,\n protocol,\n addressType,\n }: SignMessageWithCustomOptionsParams,\n client = getDefaultClient()\n): Promise<{ signature: string }> => {\n const provider = getWalletProviderFromWalletAccount(\n {\n walletAccount,\n },\n client\n );\n\n if (!isBitcoinWalletProvider(provider)) {\n throw new NotBitcoinProviderError({ providerKey: provider.key });\n }\n\n if (!provider.signMessage) {\n throw new MethodNotImplementedError('signMessage');\n }\n\n return provider.signMessage({\n addressType,\n message,\n protocol,\n walletAccount,\n });\n};\n","import { getDefaultClient } from '@dynamic-labs-sdk/client';\nimport { getWalletProviderFromWalletAccount } from '@dynamic-labs-sdk/client/core';\n\nimport type { BitcoinWalletAccount } from '../BitcoinWalletAccount.types';\nimport type { BitcoinSignPsbtRequest } from '../BitcoinWalletProvider.types';\nimport { NotBitcoinProviderError } from '../errors/NotBitcoinProviderError';\nimport { isBitcoinWalletProvider } from '../isBitcoinWalletProvider';\n\ntype SignPsbtParams = {\n request: BitcoinSignPsbtRequest;\n walletAccount: BitcoinWalletAccount;\n};\n\n/**\n * Signs a Partially Signed Bitcoin Transaction (PSBT).\n *\n * @example\n * ```ts\n * const { signedPsbt } = await signPsbt({\n * walletAccount: btcAccount,\n * request: { unsignedPsbtBase64: 'cHNidP8B...', allowedSighash: [1] },\n * });\n * ```\n *\n * @param params.request - The request data including the PSBT and inputs to sign.\n * @param params.walletAccount - The wallet account to sign the PSBT with.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns An object containing the signed PSBT.\n * @throws {NotBitcoinProviderError} If the wallet account is not a valid BitcoinWalletAccount.\n * @see signPsbts\n * @see sendBitcoin\n * @notInstrumented\n */\nexport const signPsbt = async (\n { walletAccount, request }: SignPsbtParams,\n client = getDefaultClient()\n): Promise<{ signedPsbt: string }> => {\n const provider = getWalletProviderFromWalletAccount(\n {\n walletAccount,\n },\n client\n );\n\n if (!isBitcoinWalletProvider(provider)) {\n throw new NotBitcoinProviderError({ providerKey: provider.key });\n }\n\n return provider.signPsbt({ request, walletAccount });\n};\n","import { getDefaultClient } from '@dynamic-labs-sdk/client';\nimport { getWalletProviderFromWalletAccount } from '@dynamic-labs-sdk/client/core';\n\nimport type { BitcoinWalletAccount } from '../BitcoinWalletAccount.types';\nimport type { BitcoinSignPsbtRequest } from '../BitcoinWalletProvider.types';\nimport { NotBitcoinProviderError } from '../errors/NotBitcoinProviderError';\nimport { isBitcoinWalletProvider } from '../isBitcoinWalletProvider';\n\ntype SignPsbtsParams = {\n requests: BitcoinSignPsbtRequest[];\n walletAccount: BitcoinWalletAccount;\n};\n\n/**\n * Signs multiple Partially Signed Bitcoin Transactions (PSBTs) in a single call.\n *\n * @example\n * ```ts\n * const { signedPsbts } = await signPsbts({\n * walletAccount: btcAccount,\n * requests: [\n * { unsignedPsbtBase64: 'cHNidP8B...', allowedSighash: [1] },\n * { unsignedPsbtBase64: 'cHNidP8C...', allowedSighash: [1] },\n * ],\n * });\n * ```\n *\n * @param params.requests - The list of request data to sign the PSBTs.\n * @param params.walletAccount - The wallet account to sign the PSBTs with.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns An object containing the array of signed PSBTs.\n * @throws {NotBitcoinProviderError} If the wallet account is not a valid BitcoinWalletAccount.\n * @see signPsbt\n * @see sendBitcoin\n * @notInstrumented\n */\nexport const signPsbts = async (\n { walletAccount, requests }: SignPsbtsParams,\n client = getDefaultClient()\n): Promise<{ signedPsbts: string[] }> => {\n const provider = getWalletProviderFromWalletAccount(\n {\n walletAccount,\n },\n client\n );\n\n if (!isBitcoinWalletProvider(provider)) {\n throw new NotBitcoinProviderError({ providerKey: provider.key });\n }\n\n return provider.signPsbts({ requests, walletAccount });\n};\n","import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';\n\nimport {\n name as packageName,\n version as packageVersion,\n} from '../../package.json';\nassertPackageVersion(packageName, packageVersion);\n\nexport { addBitcoinExtension } from '../addBitcoinExtension';\nexport type { BitcoinNetworkProvider } from '../BitcoinNetworkProvider.types';\nexport type { BitcoinWalletAccount } from '../BitcoinWalletAccount.types';\nexport type {\n BitcoinAddressType,\n BitcoinSendTransactionResponse,\n BitcoinSignProtocol,\n BitcoinSignPsbtRequest,\n BitcoinTransaction,\n} from '../BitcoinWalletProvider.types';\nexport { InvalidPsbtError } from '../errors/InvalidPsbtError';\nexport { TransactionBroadcastFailedError } from '../errors/TransactionBroadcastFailedError';\nexport { TransactionRequiredError } from '../errors/TransactionRequiredError';\nexport { isBitcoinNetworkProvider } from '../isBitcoinNetworkProvider';\nexport { isBitcoinWalletAccount } from '../isBitcoinWalletAccount';\nexport { sendBitcoin } from '../sendBitcoin';\nexport { sendRawTransaction } from '../sendRawTransaction';\nexport { signMessageWithCustomOptions } from '../signMessageWithCustomOptions';\nexport { signPsbt } from '../signPsbt';\nexport { signPsbts } from '../signPsbts';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,uBAAuB,8DAA2B,KAAW;AACxE,+EAAmC,OAAO;AAC1C,yDAAwB,OAAO;;;;;;;;;;;;;;;;;;;;;ACRjC,MAAa,4BACX,oBAC8C,gBAAgB,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC2B1E,MAAa,+BAA+B,OAC1C,EACE,eACA,SACA,UACA,eAEF,yDAA2B,KACQ;CACnC,MAAM,iFACJ,EACE,eACD,EACD,OACD;AAED,KAAI,CAACA,sDAAwB,SAAS,CACpC,OAAM,IAAIC,sDAAwB,EAAE,aAAa,SAAS,KAAK,CAAC;AAGlE,KAAI,CAAC,SAAS,YACZ,OAAM,IAAIC,wDAA0B,cAAc;AAGpD,QAAO,SAAS,YAAY;EAC1B;EACA;EACA;EACA;EACD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;AC7CJ,MAAa,WAAW,OACtB,EAAE,eAAe,WACjB,yDAA2B,KACS;CACpC,MAAM,iFACJ,EACE,eACD,EACD,OACD;AAED,KAAI,CAACC,sDAAwB,SAAS,CACpC,OAAM,IAAIC,sDAAwB,EAAE,aAAa,SAAS,KAAK,CAAC;AAGlE,QAAO,SAAS,SAAS;EAAE;EAAS;EAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACZtD,MAAa,YAAY,OACvB,EAAE,eAAe,YACjB,yDAA2B,KACY;CACvC,MAAM,iFACJ,EACE,eACD,EACD,OACD;AAED,KAAI,CAACC,sDAAwB,SAAS,CACpC,OAAM,IAAIC,sDAAwB,EAAE,aAAa,SAAS,KAAK,CAAC;AAGlE,QAAO,SAAS,UAAU;EAAE;EAAU;EAAe,CAAC;;;;;mEC7CnCC,oCAAaC,sCAAe"}
|
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as sendRawTransaction, d as version, n as sendBitcoin, o as isBitcoinWalletProvider, r as NotBitcoinProviderError, s as isBitcoinWalletAccount, u as name } from "./bitcoinTransferAmount-
|
|
2
|
-
import { n as InvalidPsbtError, t as addBitcoinInjectedWalletsExtension } from "./addBitcoinInjectedWalletsExtension-
|
|
3
|
-
import { n as TransactionRequiredError, r as TransactionBroadcastFailedError, t as addWaasBitcoinExtension } from "./addWaasBitcoinExtension-
|
|
1
|
+
import { a as sendRawTransaction, d as version, n as sendBitcoin, o as isBitcoinWalletProvider, r as NotBitcoinProviderError, s as isBitcoinWalletAccount, u as name } from "./bitcoinTransferAmount-k4mPyiFn.esm.js";
|
|
2
|
+
import { n as InvalidPsbtError, t as addBitcoinInjectedWalletsExtension } from "./addBitcoinInjectedWalletsExtension-DE2jrn09.esm.js";
|
|
3
|
+
import { n as TransactionRequiredError, r as TransactionBroadcastFailedError, t as addWaasBitcoinExtension } from "./addWaasBitcoinExtension-BJ2N-I0D.esm.js";
|
|
4
4
|
import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
|
|
5
5
|
import { MethodNotImplementedError, getDefaultClient, getWalletProviderFromWalletAccount } from "@dynamic-labs-sdk/client/core";
|
|
6
6
|
import { getDefaultClient as getDefaultClient$1 } from "@dynamic-labs-sdk/client";
|
|
@@ -14,7 +14,16 @@ import { getDefaultClient as getDefaultClient$1 } from "@dynamic-labs-sdk/client
|
|
|
14
14
|
* including injected wallets (MagicEden, Xverse, Unisat, and more) and embedded wallets
|
|
15
15
|
* managed by Dynamic's infrastructure.
|
|
16
16
|
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* const client = createDynamicClient({ environmentId: 'env-123' });
|
|
20
|
+
* addBitcoinExtension(client);
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
17
23
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
24
|
+
* @returns Nothing. The Bitcoin extensions are registered on the client as a side effect.
|
|
25
|
+
* @see isBitcoinWalletAccount
|
|
26
|
+
* @see isBitcoinNetworkProvider
|
|
18
27
|
* @notInstrumented
|
|
19
28
|
*/
|
|
20
29
|
const addBitcoinExtension = (client = getDefaultClient()) => {
|
|
@@ -27,8 +36,17 @@ const addBitcoinExtension = (client = getDefaultClient()) => {
|
|
|
27
36
|
/**
|
|
28
37
|
* Type guard function to check if a network provider is a Bitcoin network provider.
|
|
29
38
|
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* if (isBitcoinNetworkProvider(networkProvider)) {
|
|
42
|
+
* const { balance } = await networkProvider.getBalance({ address });
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
30
46
|
* @param networkProvider - The network provider to check.
|
|
31
47
|
* @returns True if the network provider is a Bitcoin network provider, false otherwise.
|
|
48
|
+
* @see isBitcoinWalletAccount
|
|
49
|
+
* @see addBitcoinExtension
|
|
32
50
|
* @notInstrumented
|
|
33
51
|
*/
|
|
34
52
|
const isBitcoinNetworkProvider = (networkProvider) => networkProvider.chain === "BTC";
|
|
@@ -36,18 +54,31 @@ const isBitcoinNetworkProvider = (networkProvider) => networkProvider.chain ===
|
|
|
36
54
|
//#endregion
|
|
37
55
|
//#region src/signMessageWithCustomOptions/signMessageWithCustomOptions.ts
|
|
38
56
|
/**
|
|
39
|
-
* Signs a message with custom options, like a specific address type or protocol
|
|
57
|
+
* Signs a message with custom options, like a specific address type or protocol.
|
|
40
58
|
*
|
|
41
|
-
* If the wallet provider does not support specifying an address type or protocol,
|
|
59
|
+
* If the wallet provider does not support specifying an address type or protocol,
|
|
60
|
+
* it will use the default values.
|
|
42
61
|
*
|
|
43
|
-
* @
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* const { signature } = await signMessageWithCustomOptions({
|
|
65
|
+
* walletAccount: btcAccount,
|
|
66
|
+
* message: 'Hello Bitcoin',
|
|
67
|
+
* protocol: 'bip322-simple',
|
|
68
|
+
* addressType: 'payment',
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @param params.addressType - The address type to use for signing ('ordinals' or 'payment').
|
|
73
|
+
* @param params.message - The message to sign.
|
|
74
|
+
* @param params.protocol - The protocol to use for signing ('ecdsa' or 'bip322-simple').
|
|
75
|
+
* @param params.walletAccount - The wallet account to sign the message with.
|
|
47
76
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
48
|
-
* @returns An object containing the signature
|
|
49
|
-
* @throws {MethodNotImplementedError} If the wallet provider does not implement the signMessage method
|
|
50
|
-
* @throws {NotBitcoinProviderError} If the wallet account is not a valid BitcoinWalletAccount
|
|
77
|
+
* @returns An object containing the signature.
|
|
78
|
+
* @throws {MethodNotImplementedError} If the wallet provider does not implement the signMessage method.
|
|
79
|
+
* @throws {NotBitcoinProviderError} If the wallet account is not a valid BitcoinWalletAccount.
|
|
80
|
+
* @see signPsbt
|
|
81
|
+
* @see sendBitcoin
|
|
51
82
|
* @notInstrumented
|
|
52
83
|
*/
|
|
53
84
|
const signMessageWithCustomOptions = async ({ walletAccount, message, protocol, addressType }, client = getDefaultClient$1()) => {
|
|
@@ -65,11 +96,23 @@ const signMessageWithCustomOptions = async ({ walletAccount, message, protocol,
|
|
|
65
96
|
//#endregion
|
|
66
97
|
//#region src/signPsbt/signPsbt.ts
|
|
67
98
|
/**
|
|
68
|
-
* Signs a PSBT
|
|
69
|
-
*
|
|
70
|
-
* @
|
|
99
|
+
* Signs a Partially Signed Bitcoin Transaction (PSBT).
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* const { signedPsbt } = await signPsbt({
|
|
104
|
+
* walletAccount: btcAccount,
|
|
105
|
+
* request: { unsignedPsbtBase64: 'cHNidP8B...', allowedSighash: [1] },
|
|
106
|
+
* });
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* @param params.request - The request data including the PSBT and inputs to sign.
|
|
110
|
+
* @param params.walletAccount - The wallet account to sign the PSBT with.
|
|
71
111
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
72
|
-
* @returns An object containing the signed PSBT
|
|
112
|
+
* @returns An object containing the signed PSBT.
|
|
113
|
+
* @throws {NotBitcoinProviderError} If the wallet account is not a valid BitcoinWalletAccount.
|
|
114
|
+
* @see signPsbts
|
|
115
|
+
* @see sendBitcoin
|
|
73
116
|
* @notInstrumented
|
|
74
117
|
*/
|
|
75
118
|
const signPsbt = async ({ walletAccount, request }, client = getDefaultClient$1()) => {
|
|
@@ -84,11 +127,26 @@ const signPsbt = async ({ walletAccount, request }, client = getDefaultClient$1(
|
|
|
84
127
|
//#endregion
|
|
85
128
|
//#region src/signPsbts/signPsbts.ts
|
|
86
129
|
/**
|
|
87
|
-
* Signs multiple PSBTs
|
|
88
|
-
*
|
|
89
|
-
* @
|
|
130
|
+
* Signs multiple Partially Signed Bitcoin Transactions (PSBTs) in a single call.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* const { signedPsbts } = await signPsbts({
|
|
135
|
+
* walletAccount: btcAccount,
|
|
136
|
+
* requests: [
|
|
137
|
+
* { unsignedPsbtBase64: 'cHNidP8B...', allowedSighash: [1] },
|
|
138
|
+
* { unsignedPsbtBase64: 'cHNidP8C...', allowedSighash: [1] },
|
|
139
|
+
* ],
|
|
140
|
+
* });
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* @param params.requests - The list of request data to sign the PSBTs.
|
|
144
|
+
* @param params.walletAccount - The wallet account to sign the PSBTs with.
|
|
90
145
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
91
|
-
* @returns An object containing the signed
|
|
146
|
+
* @returns An object containing the array of signed PSBTs.
|
|
147
|
+
* @throws {NotBitcoinProviderError} If the wallet account is not a valid BitcoinWalletAccount.
|
|
148
|
+
* @see signPsbt
|
|
149
|
+
* @see sendBitcoin
|
|
92
150
|
* @notInstrumented
|
|
93
151
|
*/
|
|
94
152
|
const signPsbts = async ({ walletAccount, requests }, client = getDefaultClient$1()) => {
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","names":["getDefaultClient","getDefaultClient","getDefaultClient","packageName","packageVersion"],"sources":["../src/addBitcoinExtension/addBitcoinExtension.ts","../src/isBitcoinNetworkProvider/isBitcoinNetworkProvider.ts","../src/signMessageWithCustomOptions/signMessageWithCustomOptions.ts","../src/signPsbt/signPsbt.ts","../src/signPsbts/signPsbts.ts","../src/exports/index.ts"],"sourcesContent":["import { getDefaultClient } from '@dynamic-labs-sdk/client/core';\n\nimport { addBitcoinInjectedWalletsExtension } from '../injected/addBitcoinInjectedWalletsExtension';\nimport { addWaasBitcoinExtension } from '../waas/addWaasBitcoinExtension';\n\n/**\n * Adds the Bitcoin extension to the Dynamic client.\n *\n * This is a convenience function that adds both the Bitcoin Injected Wallets extension\n * and the Dynamic WaaS Bitcoin extension, enabling support for all Bitcoin wallet types\n * including injected wallets (MagicEden, Xverse, Unisat, and more) and embedded wallets\n * managed by Dynamic's infrastructure.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @notInstrumented\n */\n\nexport const addBitcoinExtension = (client = getDefaultClient()): void => {\n addBitcoinInjectedWalletsExtension(client);\n addWaasBitcoinExtension(client);\n};\n","import type { NetworkProvider } from '@dynamic-labs-sdk/client';\n\nimport type { BitcoinNetworkProvider } from '../BitcoinNetworkProvider.types';\n\n/**\n * Type guard function to check if a network provider is a Bitcoin network provider.\n *\n * @param networkProvider - The network provider to check.\n * @returns True if the network provider is a Bitcoin network provider, false otherwise.\n * @notInstrumented\n */\nexport const isBitcoinNetworkProvider = (\n networkProvider: NetworkProvider\n): networkProvider is BitcoinNetworkProvider => networkProvider.chain === 'BTC';\n","import { getDefaultClient } from '@dynamic-labs-sdk/client';\nimport {\n MethodNotImplementedError,\n getWalletProviderFromWalletAccount,\n} from '@dynamic-labs-sdk/client/core';\n\nimport type { BitcoinWalletAccount } from '../BitcoinWalletAccount.types';\nimport type {\n BitcoinAddressType,\n BitcoinSignProtocol,\n} from '../BitcoinWalletProvider.types';\nimport { NotBitcoinProviderError } from '../errors/NotBitcoinProviderError';\nimport { isBitcoinWalletProvider } from '../isBitcoinWalletProvider';\n\ntype SignMessageWithCustomOptionsParams = {\n addressType?: BitcoinAddressType;\n message: string;\n protocol?: BitcoinSignProtocol;\n walletAccount: BitcoinWalletAccount;\n};\n\n/**\n * Signs a message with custom options, like a specific address type or protocol\n *\n * If the wallet provider does not support specifying an address type or protocol, it will use the default values.\n *\n * @param params.addressType - The address type to use for signing ('ordinals' or 'payment')\n * @param params.message - The message to sign\n * @param params.protocol - The protocol to use for signing ('ecdsa' or 'bip322-simple')\n * @param params.walletAccount - The wallet account to sign the message with\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns An object containing the signature\n * @throws {MethodNotImplementedError} If the wallet provider does not implement the signMessage method\n * @throws {NotBitcoinProviderError} If the wallet account is not a valid BitcoinWalletAccount\n * @notInstrumented\n */\nexport const signMessageWithCustomOptions = async (\n {\n walletAccount,\n message,\n protocol,\n addressType,\n }: SignMessageWithCustomOptionsParams,\n client = getDefaultClient()\n): Promise<{ signature: string }> => {\n const provider = getWalletProviderFromWalletAccount(\n {\n walletAccount,\n },\n client\n );\n\n if (!isBitcoinWalletProvider(provider)) {\n throw new NotBitcoinProviderError({ providerKey: provider.key });\n }\n\n if (!provider.signMessage) {\n throw new MethodNotImplementedError('signMessage');\n }\n\n return provider.signMessage({\n addressType,\n message,\n protocol,\n walletAccount,\n });\n};\n","import { getDefaultClient } from '@dynamic-labs-sdk/client';\nimport { getWalletProviderFromWalletAccount } from '@dynamic-labs-sdk/client/core';\n\nimport type { BitcoinWalletAccount } from '../BitcoinWalletAccount.types';\nimport type { BitcoinSignPsbtRequest } from '../BitcoinWalletProvider.types';\nimport { NotBitcoinProviderError } from '../errors/NotBitcoinProviderError';\nimport { isBitcoinWalletProvider } from '../isBitcoinWalletProvider';\n\ntype SignPsbtParams = {\n request: BitcoinSignPsbtRequest;\n walletAccount: BitcoinWalletAccount;\n};\n\n/**\n * Signs a PSBT\n * @param params.request - The request data to sign the PSBT\n * @param params.walletAccount - The wallet account to sign the PSBT with\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns An object containing the signed PSBT\n * @notInstrumented\n */\nexport const signPsbt = async (\n { walletAccount, request }: SignPsbtParams,\n client = getDefaultClient()\n): Promise<{ signedPsbt: string }> => {\n const provider = getWalletProviderFromWalletAccount(\n {\n walletAccount,\n },\n client\n );\n\n if (!isBitcoinWalletProvider(provider)) {\n throw new NotBitcoinProviderError({ providerKey: provider.key });\n }\n\n return provider.signPsbt({ request, walletAccount });\n};\n","import { getDefaultClient } from '@dynamic-labs-sdk/client';\nimport { getWalletProviderFromWalletAccount } from '@dynamic-labs-sdk/client/core';\n\nimport type { BitcoinWalletAccount } from '../BitcoinWalletAccount.types';\nimport type { BitcoinSignPsbtRequest } from '../BitcoinWalletProvider.types';\nimport { NotBitcoinProviderError } from '../errors/NotBitcoinProviderError';\nimport { isBitcoinWalletProvider } from '../isBitcoinWalletProvider';\n\ntype SignPsbtsParams = {\n requests: BitcoinSignPsbtRequest[];\n walletAccount: BitcoinWalletAccount;\n};\n\n/**\n * Signs multiple PSBTs\n * @param params.requests - The list of request data to sign the PSBTs\n * @param params.walletAccount - The wallet account to sign the PSBT with\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns An object containing the signed PSBT\n * @notInstrumented\n */\nexport const signPsbts = async (\n { walletAccount, requests }: SignPsbtsParams,\n client = getDefaultClient()\n): Promise<{ signedPsbts: string[] }> => {\n const provider = getWalletProviderFromWalletAccount(\n {\n walletAccount,\n },\n client\n );\n\n if (!isBitcoinWalletProvider(provider)) {\n throw new NotBitcoinProviderError({ providerKey: provider.key });\n }\n\n return provider.signPsbts({ requests, walletAccount });\n};\n","import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';\n\nimport {\n name as packageName,\n version as packageVersion,\n} from '../../package.json';\nassertPackageVersion(packageName, packageVersion);\n\nexport { addBitcoinExtension } from '../addBitcoinExtension';\nexport type { BitcoinNetworkProvider } from '../BitcoinNetworkProvider.types';\nexport type { BitcoinWalletAccount } from '../BitcoinWalletAccount.types';\nexport type {\n BitcoinAddressType,\n BitcoinSendTransactionResponse,\n BitcoinSignProtocol,\n BitcoinSignPsbtRequest,\n BitcoinTransaction,\n} from '../BitcoinWalletProvider.types';\nexport { InvalidPsbtError } from '../errors/InvalidPsbtError';\nexport { TransactionBroadcastFailedError } from '../errors/TransactionBroadcastFailedError';\nexport { TransactionRequiredError } from '../errors/TransactionRequiredError';\nexport { isBitcoinNetworkProvider } from '../isBitcoinNetworkProvider';\nexport { isBitcoinWalletAccount } from '../isBitcoinWalletAccount';\nexport { sendBitcoin } from '../sendBitcoin';\nexport { sendRawTransaction } from '../sendRawTransaction';\nexport { signMessageWithCustomOptions } from '../signMessageWithCustomOptions';\nexport { signPsbt } from '../signPsbt';\nexport { signPsbts } from '../signPsbts';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiBA,MAAa,uBAAuB,SAAS,kBAAkB,KAAW;AACxE,oCAAmC,OAAO;AAC1C,yBAAwB,OAAO;;;;;;;;;;;;ACRjC,MAAa,4BACX,oBAC8C,gBAAgB,UAAU;;;;;;;;;;;;;;;;;;;ACuB1E,MAAa,+BAA+B,OAC1C,EACE,eACA,SACA,UACA,eAEF,SAASA,oBAAkB,KACQ;CACnC,MAAM,WAAW,mCACf,EACE,eACD,EACD,OACD;AAED,KAAI,CAAC,wBAAwB,SAAS,CACpC,OAAM,IAAI,wBAAwB,EAAE,aAAa,SAAS,KAAK,CAAC;AAGlE,KAAI,CAAC,SAAS,YACZ,OAAM,IAAI,0BAA0B,cAAc;AAGpD,QAAO,SAAS,YAAY;EAC1B;EACA;EACA;EACA;EACD,CAAC;;;;;;;;;;;;;AC5CJ,MAAa,WAAW,OACtB,EAAE,eAAe,WACjB,SAASC,oBAAkB,KACS;CACpC,MAAM,WAAW,mCACf,EACE,eACD,EACD,OACD;AAED,KAAI,CAAC,wBAAwB,SAAS,CACpC,OAAM,IAAI,wBAAwB,EAAE,aAAa,SAAS,KAAK,CAAC;AAGlE,QAAO,SAAS,SAAS;EAAE;EAAS;EAAe,CAAC;;;;;;;;;;;;;ACftD,MAAa,YAAY,OACvB,EAAE,eAAe,YACjB,SAASC,oBAAkB,KACY;CACvC,MAAM,WAAW,mCACf,EACE,eACD,EACD,OACD;AAED,KAAI,CAAC,wBAAwB,SAAS,CACpC,OAAM,IAAI,wBAAwB,EAAE,aAAa,SAAS,KAAK,CAAC;AAGlE,QAAO,SAAS,UAAU;EAAE;EAAU;EAAe,CAAC;;;;;AC9BxD,qBAAqBC,MAAaC,QAAe"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","names":["getDefaultClient","getDefaultClient","getDefaultClient","packageName","packageVersion"],"sources":["../src/addBitcoinExtension/addBitcoinExtension.ts","../src/isBitcoinNetworkProvider/isBitcoinNetworkProvider.ts","../src/signMessageWithCustomOptions/signMessageWithCustomOptions.ts","../src/signPsbt/signPsbt.ts","../src/signPsbts/signPsbts.ts","../src/exports/index.ts"],"sourcesContent":["import { getDefaultClient } from '@dynamic-labs-sdk/client/core';\n\nimport { addBitcoinInjectedWalletsExtension } from '../injected/addBitcoinInjectedWalletsExtension';\nimport { addWaasBitcoinExtension } from '../waas/addWaasBitcoinExtension';\n\n/**\n * Adds the Bitcoin extension to the Dynamic client.\n *\n * This is a convenience function that adds both the Bitcoin Injected Wallets extension\n * and the Dynamic WaaS Bitcoin extension, enabling support for all Bitcoin wallet types\n * including injected wallets (MagicEden, Xverse, Unisat, and more) and embedded wallets\n * managed by Dynamic's infrastructure.\n *\n * @example\n * ```ts\n * const client = createDynamicClient({ environmentId: 'env-123' });\n * addBitcoinExtension(client);\n * ```\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns Nothing. The Bitcoin extensions are registered on the client as a side effect.\n * @see isBitcoinWalletAccount\n * @see isBitcoinNetworkProvider\n * @notInstrumented\n */\n\nexport const addBitcoinExtension = (client = getDefaultClient()): void => {\n addBitcoinInjectedWalletsExtension(client);\n addWaasBitcoinExtension(client);\n};\n","import type { NetworkProvider } from '@dynamic-labs-sdk/client';\n\nimport type { BitcoinNetworkProvider } from '../BitcoinNetworkProvider.types';\n\n/**\n * Type guard function to check if a network provider is a Bitcoin network provider.\n *\n * @example\n * ```ts\n * if (isBitcoinNetworkProvider(networkProvider)) {\n * const { balance } = await networkProvider.getBalance({ address });\n * }\n * ```\n *\n * @param networkProvider - The network provider to check.\n * @returns True if the network provider is a Bitcoin network provider, false otherwise.\n * @see isBitcoinWalletAccount\n * @see addBitcoinExtension\n * @notInstrumented\n */\nexport const isBitcoinNetworkProvider = (\n networkProvider: NetworkProvider\n): networkProvider is BitcoinNetworkProvider => networkProvider.chain === 'BTC';\n","import { getDefaultClient } from '@dynamic-labs-sdk/client';\nimport {\n MethodNotImplementedError,\n getWalletProviderFromWalletAccount,\n} from '@dynamic-labs-sdk/client/core';\n\nimport type { BitcoinWalletAccount } from '../BitcoinWalletAccount.types';\nimport type {\n BitcoinAddressType,\n BitcoinSignProtocol,\n} from '../BitcoinWalletProvider.types';\nimport { NotBitcoinProviderError } from '../errors/NotBitcoinProviderError';\nimport { isBitcoinWalletProvider } from '../isBitcoinWalletProvider';\n\ntype SignMessageWithCustomOptionsParams = {\n addressType?: BitcoinAddressType;\n message: string;\n protocol?: BitcoinSignProtocol;\n walletAccount: BitcoinWalletAccount;\n};\n\n/**\n * Signs a message with custom options, like a specific address type or protocol.\n *\n * If the wallet provider does not support specifying an address type or protocol,\n * it will use the default values.\n *\n * @example\n * ```ts\n * const { signature } = await signMessageWithCustomOptions({\n * walletAccount: btcAccount,\n * message: 'Hello Bitcoin',\n * protocol: 'bip322-simple',\n * addressType: 'payment',\n * });\n * ```\n *\n * @param params.addressType - The address type to use for signing ('ordinals' or 'payment').\n * @param params.message - The message to sign.\n * @param params.protocol - The protocol to use for signing ('ecdsa' or 'bip322-simple').\n * @param params.walletAccount - The wallet account to sign the message with.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns An object containing the signature.\n * @throws {MethodNotImplementedError} If the wallet provider does not implement the signMessage method.\n * @throws {NotBitcoinProviderError} If the wallet account is not a valid BitcoinWalletAccount.\n * @see signPsbt\n * @see sendBitcoin\n * @notInstrumented\n */\nexport const signMessageWithCustomOptions = async (\n {\n walletAccount,\n message,\n protocol,\n addressType,\n }: SignMessageWithCustomOptionsParams,\n client = getDefaultClient()\n): Promise<{ signature: string }> => {\n const provider = getWalletProviderFromWalletAccount(\n {\n walletAccount,\n },\n client\n );\n\n if (!isBitcoinWalletProvider(provider)) {\n throw new NotBitcoinProviderError({ providerKey: provider.key });\n }\n\n if (!provider.signMessage) {\n throw new MethodNotImplementedError('signMessage');\n }\n\n return provider.signMessage({\n addressType,\n message,\n protocol,\n walletAccount,\n });\n};\n","import { getDefaultClient } from '@dynamic-labs-sdk/client';\nimport { getWalletProviderFromWalletAccount } from '@dynamic-labs-sdk/client/core';\n\nimport type { BitcoinWalletAccount } from '../BitcoinWalletAccount.types';\nimport type { BitcoinSignPsbtRequest } from '../BitcoinWalletProvider.types';\nimport { NotBitcoinProviderError } from '../errors/NotBitcoinProviderError';\nimport { isBitcoinWalletProvider } from '../isBitcoinWalletProvider';\n\ntype SignPsbtParams = {\n request: BitcoinSignPsbtRequest;\n walletAccount: BitcoinWalletAccount;\n};\n\n/**\n * Signs a Partially Signed Bitcoin Transaction (PSBT).\n *\n * @example\n * ```ts\n * const { signedPsbt } = await signPsbt({\n * walletAccount: btcAccount,\n * request: { unsignedPsbtBase64: 'cHNidP8B...', allowedSighash: [1] },\n * });\n * ```\n *\n * @param params.request - The request data including the PSBT and inputs to sign.\n * @param params.walletAccount - The wallet account to sign the PSBT with.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns An object containing the signed PSBT.\n * @throws {NotBitcoinProviderError} If the wallet account is not a valid BitcoinWalletAccount.\n * @see signPsbts\n * @see sendBitcoin\n * @notInstrumented\n */\nexport const signPsbt = async (\n { walletAccount, request }: SignPsbtParams,\n client = getDefaultClient()\n): Promise<{ signedPsbt: string }> => {\n const provider = getWalletProviderFromWalletAccount(\n {\n walletAccount,\n },\n client\n );\n\n if (!isBitcoinWalletProvider(provider)) {\n throw new NotBitcoinProviderError({ providerKey: provider.key });\n }\n\n return provider.signPsbt({ request, walletAccount });\n};\n","import { getDefaultClient } from '@dynamic-labs-sdk/client';\nimport { getWalletProviderFromWalletAccount } from '@dynamic-labs-sdk/client/core';\n\nimport type { BitcoinWalletAccount } from '../BitcoinWalletAccount.types';\nimport type { BitcoinSignPsbtRequest } from '../BitcoinWalletProvider.types';\nimport { NotBitcoinProviderError } from '../errors/NotBitcoinProviderError';\nimport { isBitcoinWalletProvider } from '../isBitcoinWalletProvider';\n\ntype SignPsbtsParams = {\n requests: BitcoinSignPsbtRequest[];\n walletAccount: BitcoinWalletAccount;\n};\n\n/**\n * Signs multiple Partially Signed Bitcoin Transactions (PSBTs) in a single call.\n *\n * @example\n * ```ts\n * const { signedPsbts } = await signPsbts({\n * walletAccount: btcAccount,\n * requests: [\n * { unsignedPsbtBase64: 'cHNidP8B...', allowedSighash: [1] },\n * { unsignedPsbtBase64: 'cHNidP8C...', allowedSighash: [1] },\n * ],\n * });\n * ```\n *\n * @param params.requests - The list of request data to sign the PSBTs.\n * @param params.walletAccount - The wallet account to sign the PSBTs with.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns An object containing the array of signed PSBTs.\n * @throws {NotBitcoinProviderError} If the wallet account is not a valid BitcoinWalletAccount.\n * @see signPsbt\n * @see sendBitcoin\n * @notInstrumented\n */\nexport const signPsbts = async (\n { walletAccount, requests }: SignPsbtsParams,\n client = getDefaultClient()\n): Promise<{ signedPsbts: string[] }> => {\n const provider = getWalletProviderFromWalletAccount(\n {\n walletAccount,\n },\n client\n );\n\n if (!isBitcoinWalletProvider(provider)) {\n throw new NotBitcoinProviderError({ providerKey: provider.key });\n }\n\n return provider.signPsbts({ requests, walletAccount });\n};\n","import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';\n\nimport {\n name as packageName,\n version as packageVersion,\n} from '../../package.json';\nassertPackageVersion(packageName, packageVersion);\n\nexport { addBitcoinExtension } from '../addBitcoinExtension';\nexport type { BitcoinNetworkProvider } from '../BitcoinNetworkProvider.types';\nexport type { BitcoinWalletAccount } from '../BitcoinWalletAccount.types';\nexport type {\n BitcoinAddressType,\n BitcoinSendTransactionResponse,\n BitcoinSignProtocol,\n BitcoinSignPsbtRequest,\n BitcoinTransaction,\n} from '../BitcoinWalletProvider.types';\nexport { InvalidPsbtError } from '../errors/InvalidPsbtError';\nexport { TransactionBroadcastFailedError } from '../errors/TransactionBroadcastFailedError';\nexport { TransactionRequiredError } from '../errors/TransactionRequiredError';\nexport { isBitcoinNetworkProvider } from '../isBitcoinNetworkProvider';\nexport { isBitcoinWalletAccount } from '../isBitcoinWalletAccount';\nexport { sendBitcoin } from '../sendBitcoin';\nexport { sendRawTransaction } from '../sendRawTransaction';\nexport { signMessageWithCustomOptions } from '../signMessageWithCustomOptions';\nexport { signPsbt } from '../signPsbt';\nexport { signPsbts } from '../signPsbts';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,uBAAuB,SAAS,kBAAkB,KAAW;AACxE,oCAAmC,OAAO;AAC1C,yBAAwB,OAAO;;;;;;;;;;;;;;;;;;;;;ACRjC,MAAa,4BACX,oBAC8C,gBAAgB,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC2B1E,MAAa,+BAA+B,OAC1C,EACE,eACA,SACA,UACA,eAEF,SAASA,oBAAkB,KACQ;CACnC,MAAM,WAAW,mCACf,EACE,eACD,EACD,OACD;AAED,KAAI,CAAC,wBAAwB,SAAS,CACpC,OAAM,IAAI,wBAAwB,EAAE,aAAa,SAAS,KAAK,CAAC;AAGlE,KAAI,CAAC,SAAS,YACZ,OAAM,IAAI,0BAA0B,cAAc;AAGpD,QAAO,SAAS,YAAY;EAC1B;EACA;EACA;EACA;EACD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;AC7CJ,MAAa,WAAW,OACtB,EAAE,eAAe,WACjB,SAASC,oBAAkB,KACS;CACpC,MAAM,WAAW,mCACf,EACE,eACD,EACD,OACD;AAED,KAAI,CAAC,wBAAwB,SAAS,CACpC,OAAM,IAAI,wBAAwB,EAAE,aAAa,SAAS,KAAK,CAAC;AAGlE,QAAO,SAAS,SAAS;EAAE;EAAS;EAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACZtD,MAAa,YAAY,OACvB,EAAE,eAAe,YACjB,SAASC,oBAAkB,KACY;CACvC,MAAM,WAAW,mCACf,EACE,eACD,EACD,OACD;AAED,KAAI,CAAC,wBAAwB,SAAS,CACpC,OAAM,IAAI,wBAAwB,EAAE,aAAa,SAAS,KAAK,CAAC;AAGlE,QAAO,SAAS,UAAU;EAAE;EAAU;EAAe,CAAC;;;;;AC7CxD,qBAAqBC,MAAaC,QAAe"}
|
package/dist/injected.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const require_addWaasBitcoinExtension = require('./addWaasBitcoinExtension-
|
|
2
|
-
const require_bitcoinTransferAmount = require('./bitcoinTransferAmount-
|
|
3
|
-
const require_addBitcoinInjectedWalletsExtension = require('./addBitcoinInjectedWalletsExtension-
|
|
1
|
+
const require_addWaasBitcoinExtension = require('./addWaasBitcoinExtension-D-cviSbW.cjs');
|
|
2
|
+
const require_bitcoinTransferAmount = require('./bitcoinTransferAmount-D6FaWJqj.cjs');
|
|
3
|
+
const require_addBitcoinInjectedWalletsExtension = require('./addBitcoinInjectedWalletsExtension-DBK8dr4V.cjs');
|
|
4
4
|
let _dynamic_labs_sdk_assert_package_version = require("@dynamic-labs-sdk/assert-package-version");
|
|
5
5
|
|
|
6
6
|
//#region src/exports/injected.ts
|
package/dist/injected.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as version, u as name } from "./bitcoinTransferAmount-
|
|
2
|
-
import { t as addBitcoinInjectedWalletsExtension } from "./addBitcoinInjectedWalletsExtension-
|
|
1
|
+
import { d as version, u as name } from "./bitcoinTransferAmount-k4mPyiFn.esm.js";
|
|
2
|
+
import { t as addBitcoinInjectedWalletsExtension } from "./addBitcoinInjectedWalletsExtension-DE2jrn09.esm.js";
|
|
3
3
|
import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
|
|
4
4
|
|
|
5
5
|
//#region src/exports/injected.ts
|
|
@@ -3,9 +3,18 @@ import type { BitcoinNetworkProvider } from '../BitcoinNetworkProvider.types';
|
|
|
3
3
|
/**
|
|
4
4
|
* Type guard function to check if a network provider is a Bitcoin network provider.
|
|
5
5
|
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* if (isBitcoinNetworkProvider(networkProvider)) {
|
|
9
|
+
* const { balance } = await networkProvider.getBalance({ address });
|
|
10
|
+
* }
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
6
13
|
* @param networkProvider - The network provider to check.
|
|
7
14
|
* @returns True if the network provider is a Bitcoin network provider, false otherwise.
|
|
8
|
-
|
|
15
|
+
* @see isBitcoinWalletAccount
|
|
16
|
+
* @see addBitcoinExtension
|
|
17
|
+
* @notInstrumented
|
|
9
18
|
*/
|
|
10
19
|
export declare const isBitcoinNetworkProvider: (networkProvider: NetworkProvider) => networkProvider is BitcoinNetworkProvider;
|
|
11
20
|
//# sourceMappingURL=isBitcoinNetworkProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isBitcoinNetworkProvider.d.ts","sourceRoot":"","sources":["../../src/isBitcoinNetworkProvider/isBitcoinNetworkProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAE9E
|
|
1
|
+
{"version":3,"file":"isBitcoinNetworkProvider.d.ts","sourceRoot":"","sources":["../../src/isBitcoinNetworkProvider/isBitcoinNetworkProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAE9E;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,wBAAwB,oBAClB,eAAe,KAC/B,eAAe,IAAI,sBAAyD,CAAC"}
|