@dynamic-labs-sdk/bitcoin 1.28.0 → 1.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{bitcoinTransferAmount-C-iLhaL2.esm.js → InvalidPsbtError-BdHbd9wt.esm.js} +17 -3
- package/dist/InvalidPsbtError-BdHbd9wt.esm.js.map +1 -0
- package/dist/{bitcoinTransferAmount-BBFKRh00.cjs → InvalidPsbtError-DAnSIW2b.cjs} +23 -3
- package/dist/InvalidPsbtError-DAnSIW2b.cjs.map +1 -0
- package/dist/{addBitcoinInjectedWalletsExtension-CQwCjR49.esm.js → addBitcoinInjectedWalletsExtension-axP2bkxG.esm.js} +4 -18
- package/dist/addBitcoinInjectedWalletsExtension-axP2bkxG.esm.js.map +1 -0
- package/dist/{addBitcoinInjectedWalletsExtension-8Hg5XjUx.cjs → addBitcoinInjectedWalletsExtension-kKxSQ6oH.cjs} +31 -51
- package/dist/addBitcoinInjectedWalletsExtension-kKxSQ6oH.cjs.map +1 -0
- package/dist/{addWaasBitcoinExtension-4PAe_tOz.cjs → addWaasBitcoinExtension-B99fc1KQ.cjs} +63 -11
- package/dist/addWaasBitcoinExtension-B99fc1KQ.cjs.map +1 -0
- package/dist/{addWaasBitcoinExtension-IrLvQh8F.esm.js → addWaasBitcoinExtension-CckpDDh-.esm.js} +54 -2
- package/dist/addWaasBitcoinExtension-CckpDDh-.esm.js.map +1 -0
- package/dist/exports/index.d.ts +1 -0
- package/dist/exports/index.d.ts.map +1 -1
- package/dist/index.cjs +100 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +93 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/injected/utils/binance/getBinanceBitcoinInjectedProvider/getBinanceBitcoinInjectedProvider.d.ts.map +1 -1
- package/dist/injected/utils/bitget/getBitgetBitcoinInjectedProvider/getBitgetBitcoinInjectedProvider.d.ts.map +1 -1
- package/dist/injected/utils/leather/getLeatherBitcoinInjectedProvider/getLeatherBitcoinInjectedProvider.d.ts +2 -1
- package/dist/injected/utils/leather/getLeatherBitcoinInjectedProvider/getLeatherBitcoinInjectedProvider.d.ts.map +1 -1
- package/dist/injected/utils/magicEden/getMagicEdenInjectedProvider/getMagicEdenInjectedProvider.d.ts.map +1 -1
- package/dist/injected/utils/okx/getOkxBitcoinInjectedProvider/getOkxBitcoinInjectedProvider.d.ts.map +1 -1
- package/dist/injected/utils/oneKey/getOneKeyBitcoinInjectedProvider/getOneKeyBitcoinInjectedProvider.d.ts.map +1 -1
- package/dist/injected/utils/oyl/getOylBitcoinInjectedProvider/getOylBitcoinInjectedProvider.d.ts.map +1 -1
- package/dist/injected/utils/phantom/getPhantomInjectedProvider/getPhantomInjectedProvider.d.ts.map +1 -1
- package/dist/injected/utils/unisat/getUnisatInjectedProvider/getUnisatInjectedProvider.d.ts.map +1 -1
- package/dist/injected/utils/xverse/getXverseInjectedProvider/getXverseInjectedProvider.d.ts.map +1 -1
- package/dist/injected.cjs +4 -4
- package/dist/injected.cjs.map +1 -1
- package/dist/injected.esm.js +2 -2
- package/dist/screenBitcoinTransactions/index.d.ts +2 -0
- package/dist/screenBitcoinTransactions/index.d.ts.map +1 -0
- package/dist/screenBitcoinTransactions/screenBitcoinTransactions.d.ts +66 -0
- package/dist/screenBitcoinTransactions/screenBitcoinTransactions.d.ts.map +1 -0
- package/dist/sendRawTransaction/sendRawTransaction.d.ts +4 -3
- package/dist/sendRawTransaction/sendRawTransaction.d.ts.map +1 -1
- package/dist/signMessageWithCustomOptions/signMessageWithCustomOptions.d.ts +4 -3
- package/dist/signMessageWithCustomOptions/signMessageWithCustomOptions.d.ts.map +1 -1
- package/dist/signPsbt/signPsbt.d.ts +4 -3
- package/dist/signPsbt/signPsbt.d.ts.map +1 -1
- package/dist/signPsbts/signPsbts.d.ts +4 -3
- package/dist/signPsbts/signPsbts.d.ts.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/utils/bitcoinTransferAmount/bitcoinTransferAmount.d.ts +5 -3
- package/dist/utils/bitcoinTransferAmount/bitcoinTransferAmount.d.ts.map +1 -1
- package/dist/utils/convertNetworkIdForPsbt/convertNetworkIdForPsbt.d.ts.map +1 -1
- package/dist/utils/convertNetworkIdToSatsConnectNetworkType/convertNetworkIdToSatsConnectNetworkType.d.ts.map +1 -1
- package/dist/utils/createPsbtOptions/createPsbtOptions.d.ts +1 -1
- package/dist/utils/createPsbtOptions/createPsbtOptions.d.ts.map +1 -1
- package/dist/utils/getBitcoinScreeningChainId/getBitcoinScreeningChainId.d.ts +18 -0
- package/dist/utils/getBitcoinScreeningChainId/getBitcoinScreeningChainId.d.ts.map +1 -0
- package/dist/utils/getBitcoinScreeningChainId/index.d.ts +2 -0
- package/dist/utils/getBitcoinScreeningChainId/index.d.ts.map +1 -0
- package/dist/utils/getMempoolApiUrl/getMempoolApiUrl.d.ts +4 -1
- package/dist/utils/getMempoolApiUrl/getMempoolApiUrl.d.ts.map +1 -1
- package/dist/utils/getNetworkIdFromNetworkName/getNetworkIdFromNetworkName.d.ts +3 -2
- package/dist/utils/getNetworkIdFromNetworkName/getNetworkIdFromNetworkName.d.ts.map +1 -1
- package/dist/utils/getPsbtInputsToSignForSatsConnect/getPsbtInputsToSignForSatsConnect.d.ts +1 -1
- package/dist/utils/getPsbtInputsToSignForSatsConnect/getPsbtInputsToSignForSatsConnect.d.ts.map +1 -1
- package/dist/utils/getSigHashType/getSigHashType.d.ts +1 -1
- package/dist/utils/getSigHashType/getSigHashType.d.ts.map +1 -1
- package/dist/utils/parseBitcoinConnectionResult/parseBitcoinConnectionResult.d.ts +3 -2
- package/dist/utils/parseBitcoinConnectionResult/parseBitcoinConnectionResult.d.ts.map +1 -1
- package/dist/utils/satoshisToBtc/satoshisToBtc.d.ts.map +1 -1
- package/dist/utils/signMultipleTransactionsWithSatsConnect/signMultipleTransactionsWithSatsConnect.d.ts +4 -3
- package/dist/utils/signMultipleTransactionsWithSatsConnect/signMultipleTransactionsWithSatsConnect.d.ts.map +1 -1
- package/dist/utils/validatePsbt/validatePsbt.d.ts +1 -1
- package/dist/utils/validatePsbt/validatePsbt.d.ts.map +1 -1
- package/dist/utils/validatePsbt/validateSigHash/validateSigHash.d.ts.map +1 -1
- package/dist/utils/validatePsbt/validateSigningAddress/validateSigningAddress.d.ts.map +1 -1
- package/dist/waas/utils/createWalletProviderForWaasBitcoin/createWalletProviderForWaasBitcoin.d.ts.map +1 -1
- package/dist/waas/utils/getWaasAllowedSighash/getWaasAllowedSighash.d.ts +23 -0
- package/dist/waas/utils/getWaasAllowedSighash/getWaasAllowedSighash.d.ts.map +1 -0
- package/dist/waas/utils/getWaasAllowedSighash/index.d.ts +2 -0
- package/dist/waas/utils/getWaasAllowedSighash/index.d.ts.map +1 -0
- package/dist/waas/utils/getWaasSigningIndexes/getWaasSigningIndexes.d.ts +28 -0
- package/dist/waas/utils/getWaasSigningIndexes/getWaasSigningIndexes.d.ts.map +1 -0
- package/dist/waas/utils/getWaasSigningIndexes/index.d.ts +2 -0
- package/dist/waas/utils/getWaasSigningIndexes/index.d.ts.map +1 -0
- package/dist/waas/utils/selectUTXOsLargestFirst/selectUTXOsLargestFirst.d.ts +1 -1
- package/dist/waas/utils/selectUTXOsLargestFirst/selectUTXOsLargestFirst.d.ts.map +1 -1
- package/dist/waas/utils/validateAndSelectUTXOs/validateAndSelectUTXOs.d.ts +1 -1
- package/dist/waas/utils/validateAndSelectUTXOs/validateAndSelectUTXOs.d.ts.map +1 -1
- package/dist/waas.cjs +4 -4
- package/dist/waas.cjs.map +1 -1
- package/dist/waas.esm.js +2 -2
- package/package.json +4 -4
- package/dist/addBitcoinInjectedWalletsExtension-8Hg5XjUx.cjs.map +0 -1
- package/dist/addBitcoinInjectedWalletsExtension-CQwCjR49.esm.js.map +0 -1
- package/dist/addWaasBitcoinExtension-4PAe_tOz.cjs.map +0 -1
- package/dist/addWaasBitcoinExtension-IrLvQh8F.esm.js.map +0 -1
- package/dist/bitcoinTransferAmount-BBFKRh00.cjs.map +0 -1
- package/dist/bitcoinTransferAmount-C-iLhaL2.esm.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
const require_addWaasBitcoinExtension = require('./addWaasBitcoinExtension-
|
|
2
|
-
const
|
|
3
|
-
const require_addBitcoinInjectedWalletsExtension = require('./addBitcoinInjectedWalletsExtension-
|
|
1
|
+
const require_addWaasBitcoinExtension = require('./addWaasBitcoinExtension-B99fc1KQ.cjs');
|
|
2
|
+
const require_InvalidPsbtError = require('./InvalidPsbtError-DAnSIW2b.cjs');
|
|
3
|
+
const require_addBitcoinInjectedWalletsExtension = require('./addBitcoinInjectedWalletsExtension-kKxSQ6oH.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");
|
|
7
|
+
let _dynamic_labs_sdk_client_waas = require("@dynamic-labs-sdk/client/waas");
|
|
7
8
|
|
|
8
9
|
//#region src/addBitcoinExtension/addBitcoinExtension.ts
|
|
9
10
|
/**
|
|
@@ -51,6 +52,93 @@ const addBitcoinExtension = (client = (0, _dynamic_labs_sdk_client_core.getDefau
|
|
|
51
52
|
*/
|
|
52
53
|
const isBitcoinNetworkProvider = (networkProvider) => networkProvider.chain === "BTC";
|
|
53
54
|
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/utils/getBitcoinScreeningChainId/getBitcoinScreeningChainId.ts
|
|
57
|
+
/** Dynamic's network id for Bitcoin mainnet. */
|
|
58
|
+
const BITCOIN_MAINNET_NETWORK_ID = "1";
|
|
59
|
+
/** Network identifiers the transaction screening contract recognizes. */
|
|
60
|
+
const SCREENING_MAINNET_CHAIN_ID = "1";
|
|
61
|
+
const SCREENING_TESTNET_CHAIN_ID = "2";
|
|
62
|
+
/**
|
|
63
|
+
* Maps a Dynamic Bitcoin network id to the identifier the transaction
|
|
64
|
+
* screening contract uses.
|
|
65
|
+
*
|
|
66
|
+
* The contract only distinguishes mainnet from testnet, so signet — and any
|
|
67
|
+
* network id we cannot resolve — screens as testnet: neither is mainnet, and
|
|
68
|
+
* the value is recorded for audit rather than used to pick a provider.
|
|
69
|
+
*
|
|
70
|
+
* @param params.networkId - The wallet provider's active network id.
|
|
71
|
+
* @returns The screening chain identifier.
|
|
72
|
+
* @notInstrumented
|
|
73
|
+
*/
|
|
74
|
+
const getBitcoinScreeningChainId = ({ networkId }) => networkId === BITCOIN_MAINNET_NETWORK_ID ? SCREENING_MAINNET_CHAIN_ID : SCREENING_TESTNET_CHAIN_ID;
|
|
75
|
+
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/screenBitcoinTransactions/screenBitcoinTransactions.ts
|
|
78
|
+
/**
|
|
79
|
+
* Screens Bitcoin transactions' destinations against the environment's
|
|
80
|
+
* sanctions providers and returns one verdict per transaction.
|
|
81
|
+
*
|
|
82
|
+
* Builds the payload the screening API expects — including resolving the
|
|
83
|
+
* wallet's active network — so you do not need to know its shape, then defers
|
|
84
|
+
* to {@link screenTransaction}. Each transaction is screened independently, so
|
|
85
|
+
* the results are positional: `results[i]` is the verdict for `transactions[i]`.
|
|
86
|
+
*
|
|
87
|
+
* The screening contract only distinguishes mainnet from testnet, so the
|
|
88
|
+
* network is collapsed for the screen itself but recorded unchanged, keeping
|
|
89
|
+
* signet distinguishable from testnet in the audit record.
|
|
90
|
+
*
|
|
91
|
+
* Like the call it wraps, this imposes no policy: it does not consult project
|
|
92
|
+
* settings, does not throw on a `block` verdict, and rejects if screening
|
|
93
|
+
* fails. Gate it with `isExternalWalletScreeningEnabled` and decide for
|
|
94
|
+
* yourself what a block should do — for a batch, that usually means refusing
|
|
95
|
+
* to sign any of them if any one is blocked.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* if (isExternalWalletScreeningEnabled()) {
|
|
100
|
+
* const results = await screenBitcoinTransactions({
|
|
101
|
+
* transactions: [{ recipientAddress }],
|
|
102
|
+
* walletAccount,
|
|
103
|
+
* });
|
|
104
|
+
*
|
|
105
|
+
* if (results.some(({ decision }) => decision === 'block')) return;
|
|
106
|
+
* }
|
|
107
|
+
*
|
|
108
|
+
* await sendBitcoin({ walletAccount, transaction });
|
|
109
|
+
* ```
|
|
110
|
+
*
|
|
111
|
+
* @param params.transactions - The transactions about to be signed.
|
|
112
|
+
* @param params.walletAccount - The wallet account that would be prompted to sign.
|
|
113
|
+
* @param [params.networkId] - The network to record, e.g. `'3'` for signet. Resolved from the wallet provider when omitted.
|
|
114
|
+
* @param [params.senderAddress] - The sender to screen alongside the destinations. Defaults to the wallet account's address.
|
|
115
|
+
* @param [params.signal] - Cancels the in-flight requests, e.g. `AbortSignal.timeout(2000)`.
|
|
116
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
117
|
+
* @returns One verdict per transaction, in the order the transactions were given.
|
|
118
|
+
* @throws {ScreeningNotRequiredError} If the wallet account is a Dynamic embedded wallet, which signing already screens.
|
|
119
|
+
* @throws {NotBitcoinProviderError} If the wallet account is not a valid BitcoinWalletAccount.
|
|
120
|
+
* @see screenTransaction
|
|
121
|
+
* @see isExternalWalletScreeningEnabled
|
|
122
|
+
* @notInstrumented
|
|
123
|
+
*/
|
|
124
|
+
const screenBitcoinTransactions = async ({ networkId, senderAddress, signal, transactions, walletAccount }, client = (0, _dynamic_labs_sdk_client.getDefaultClient)()) => {
|
|
125
|
+
if ((0, _dynamic_labs_sdk_client_waas.isWaasWalletAccount)({ walletAccount })) throw new _dynamic_labs_sdk_client.ScreeningNotRequiredError();
|
|
126
|
+
const provider = (0, _dynamic_labs_sdk_client_core.getWalletProviderFromWalletAccount)({ walletAccount }, client);
|
|
127
|
+
if (!require_InvalidPsbtError.isBitcoinWalletProvider(provider)) throw new require_InvalidPsbtError.NotBitcoinProviderError({ providerKey: provider.key });
|
|
128
|
+
const activeNetworkId = networkId ?? (await provider.getActiveNetworkId()).networkId;
|
|
129
|
+
const chainId = getBitcoinScreeningChainId({ networkId: activeNetworkId });
|
|
130
|
+
return Promise.all(transactions.map((btcTransaction) => (0, _dynamic_labs_sdk_client.screenTransaction)({
|
|
131
|
+
chain: "BTC",
|
|
132
|
+
context: { btcTransaction: {
|
|
133
|
+
chainId,
|
|
134
|
+
...btcTransaction
|
|
135
|
+
} },
|
|
136
|
+
networkId: activeNetworkId,
|
|
137
|
+
senderAddress: senderAddress ?? walletAccount.address,
|
|
138
|
+
signal
|
|
139
|
+
}, client)));
|
|
140
|
+
};
|
|
141
|
+
|
|
54
142
|
//#endregion
|
|
55
143
|
//#region src/signMessageWithCustomOptions/signMessageWithCustomOptions.ts
|
|
56
144
|
/**
|
|
@@ -83,7 +171,7 @@ const isBitcoinNetworkProvider = (networkProvider) => networkProvider.chain ===
|
|
|
83
171
|
*/
|
|
84
172
|
const signMessageWithCustomOptions = async ({ walletAccount, message, protocol, addressType }, client = (0, _dynamic_labs_sdk_client.getDefaultClient)()) => {
|
|
85
173
|
const provider = (0, _dynamic_labs_sdk_client_core.getWalletProviderFromWalletAccount)({ walletAccount }, client);
|
|
86
|
-
if (!
|
|
174
|
+
if (!require_InvalidPsbtError.isBitcoinWalletProvider(provider)) throw new require_InvalidPsbtError.NotBitcoinProviderError({ providerKey: provider.key });
|
|
87
175
|
if (!provider.signMessage) throw new _dynamic_labs_sdk_client_core.MethodNotImplementedError("signMessage");
|
|
88
176
|
return provider.signMessage({
|
|
89
177
|
addressType,
|
|
@@ -117,7 +205,7 @@ const signMessageWithCustomOptions = async ({ walletAccount, message, protocol,
|
|
|
117
205
|
*/
|
|
118
206
|
const signPsbt = async ({ walletAccount, request }, client = (0, _dynamic_labs_sdk_client.getDefaultClient)()) => {
|
|
119
207
|
const provider = (0, _dynamic_labs_sdk_client_core.getWalletProviderFromWalletAccount)({ walletAccount }, client);
|
|
120
|
-
if (!
|
|
208
|
+
if (!require_InvalidPsbtError.isBitcoinWalletProvider(provider)) throw new require_InvalidPsbtError.NotBitcoinProviderError({ providerKey: provider.key });
|
|
121
209
|
return provider.signPsbt({
|
|
122
210
|
request,
|
|
123
211
|
walletAccount
|
|
@@ -151,7 +239,7 @@ const signPsbt = async ({ walletAccount, request }, client = (0, _dynamic_labs_s
|
|
|
151
239
|
*/
|
|
152
240
|
const signPsbts = async ({ walletAccount, requests }, client = (0, _dynamic_labs_sdk_client.getDefaultClient)()) => {
|
|
153
241
|
const provider = (0, _dynamic_labs_sdk_client_core.getWalletProviderFromWalletAccount)({ walletAccount }, client);
|
|
154
|
-
if (!
|
|
242
|
+
if (!require_InvalidPsbtError.isBitcoinWalletProvider(provider)) throw new require_InvalidPsbtError.NotBitcoinProviderError({ providerKey: provider.key });
|
|
155
243
|
return provider.signPsbts({
|
|
156
244
|
requests,
|
|
157
245
|
walletAccount
|
|
@@ -160,17 +248,18 @@ const signPsbts = async ({ walletAccount, requests }, client = (0, _dynamic_labs
|
|
|
160
248
|
|
|
161
249
|
//#endregion
|
|
162
250
|
//#region src/exports/index.ts
|
|
163
|
-
(0, _dynamic_labs_sdk_assert_package_version.assertPackageVersion)(
|
|
251
|
+
(0, _dynamic_labs_sdk_assert_package_version.assertPackageVersion)(require_InvalidPsbtError.name, require_InvalidPsbtError.version);
|
|
164
252
|
|
|
165
253
|
//#endregion
|
|
166
|
-
exports.InvalidPsbtError =
|
|
254
|
+
exports.InvalidPsbtError = require_InvalidPsbtError.InvalidPsbtError;
|
|
167
255
|
exports.TransactionBroadcastFailedError = require_addWaasBitcoinExtension.TransactionBroadcastFailedError;
|
|
168
256
|
exports.TransactionRequiredError = require_addWaasBitcoinExtension.TransactionRequiredError;
|
|
169
257
|
exports.addBitcoinExtension = addBitcoinExtension;
|
|
170
258
|
exports.isBitcoinNetworkProvider = isBitcoinNetworkProvider;
|
|
171
|
-
exports.isBitcoinWalletAccount =
|
|
172
|
-
exports.
|
|
173
|
-
exports.
|
|
259
|
+
exports.isBitcoinWalletAccount = require_InvalidPsbtError.isBitcoinWalletAccount;
|
|
260
|
+
exports.screenBitcoinTransactions = screenBitcoinTransactions;
|
|
261
|
+
exports.sendBitcoin = require_InvalidPsbtError.sendBitcoin;
|
|
262
|
+
exports.sendRawTransaction = require_InvalidPsbtError.sendRawTransaction;
|
|
174
263
|
exports.signMessageWithCustomOptions = signMessageWithCustomOptions;
|
|
175
264
|
exports.signPsbt = signPsbt;
|
|
176
265
|
exports.signPsbts = signPsbts;
|
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 * @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"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["ScreeningNotRequiredError","isBitcoinWalletProvider","NotBitcoinProviderError","isBitcoinWalletProvider","NotBitcoinProviderError","MethodNotImplementedError","isBitcoinWalletProvider","NotBitcoinProviderError","isBitcoinWalletProvider","NotBitcoinProviderError","packageName","packageVersion"],"sources":["../src/addBitcoinExtension/addBitcoinExtension.ts","../src/isBitcoinNetworkProvider/isBitcoinNetworkProvider.ts","../src/utils/getBitcoinScreeningChainId/getBitcoinScreeningChainId.ts","../src/screenBitcoinTransactions/screenBitcoinTransactions.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","/** Dynamic's network id for Bitcoin mainnet. */\nconst BITCOIN_MAINNET_NETWORK_ID = '1';\n\n/** Network identifiers the transaction screening contract recognizes. */\nconst SCREENING_MAINNET_CHAIN_ID = '1';\nconst SCREENING_TESTNET_CHAIN_ID = '2';\n\ntype GetBitcoinScreeningChainIdParams = {\n networkId: string | undefined;\n};\n\n/**\n * Maps a Dynamic Bitcoin network id to the identifier the transaction\n * screening contract uses.\n *\n * The contract only distinguishes mainnet from testnet, so signet — and any\n * network id we cannot resolve — screens as testnet: neither is mainnet, and\n * the value is recorded for audit rather than used to pick a provider.\n *\n * @param params.networkId - The wallet provider's active network id.\n * @returns The screening chain identifier.\n * @notInstrumented\n */\nexport const getBitcoinScreeningChainId = ({\n networkId,\n}: GetBitcoinScreeningChainIdParams): string =>\n networkId === BITCOIN_MAINNET_NETWORK_ID\n ? SCREENING_MAINNET_CHAIN_ID\n : SCREENING_TESTNET_CHAIN_ID;\n","import type { ScreenTransactionResponse } from '@dynamic-labs/sdk-api-core';\nimport {\n ScreeningNotRequiredError,\n getDefaultClient,\n screenTransaction,\n} from '@dynamic-labs-sdk/client';\nimport { getWalletProviderFromWalletAccount } from '@dynamic-labs-sdk/client/core';\nimport { isWaasWalletAccount } from '@dynamic-labs-sdk/client/waas';\n\nimport type { BitcoinWalletAccount } from '../BitcoinWalletAccount.types';\nimport { NotBitcoinProviderError } from '../errors/NotBitcoinProviderError';\nimport { isBitcoinWalletProvider } from '../isBitcoinWalletProvider';\nimport { getBitcoinScreeningChainId } from '../utils/getBitcoinScreeningChainId';\n\ntype ScreenBitcoinTransactionsParams = {\n /**\n * The network to record alongside the screen. Resolved from the wallet\n * provider when omitted.\n */\n networkId?: string;\n senderAddress?: string;\n signal?: AbortSignal;\n /** The destination of each transaction, as a recipient address or an unsigned PSBT. */\n transactions: { psbt?: string; recipientAddress?: string }[];\n walletAccount: BitcoinWalletAccount;\n};\n\n/**\n * Screens Bitcoin transactions' destinations against the environment's\n * sanctions providers and returns one verdict per transaction.\n *\n * Builds the payload the screening API expects — including resolving the\n * wallet's active network — so you do not need to know its shape, then defers\n * to {@link screenTransaction}. Each transaction is screened independently, so\n * the results are positional: `results[i]` is the verdict for `transactions[i]`.\n *\n * The screening contract only distinguishes mainnet from testnet, so the\n * network is collapsed for the screen itself but recorded unchanged, keeping\n * signet distinguishable from testnet in the audit record.\n *\n * Like the call it wraps, this imposes no policy: it does not consult project\n * settings, does not throw on a `block` verdict, and rejects if screening\n * fails. Gate it with `isExternalWalletScreeningEnabled` and decide for\n * yourself what a block should do — for a batch, that usually means refusing\n * to sign any of them if any one is blocked.\n *\n * @example\n * ```ts\n * if (isExternalWalletScreeningEnabled()) {\n * const results = await screenBitcoinTransactions({\n * transactions: [{ recipientAddress }],\n * walletAccount,\n * });\n *\n * if (results.some(({ decision }) => decision === 'block')) return;\n * }\n *\n * await sendBitcoin({ walletAccount, transaction });\n * ```\n *\n * @param params.transactions - The transactions about to be signed.\n * @param params.walletAccount - The wallet account that would be prompted to sign.\n * @param [params.networkId] - The network to record, e.g. `'3'` for signet. Resolved from the wallet provider when omitted.\n * @param [params.senderAddress] - The sender to screen alongside the destinations. Defaults to the wallet account's address.\n * @param [params.signal] - Cancels the in-flight requests, e.g. `AbortSignal.timeout(2000)`.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns One verdict per transaction, in the order the transactions were given.\n * @throws {ScreeningNotRequiredError} If the wallet account is a Dynamic embedded wallet, which signing already screens.\n * @throws {NotBitcoinProviderError} If the wallet account is not a valid BitcoinWalletAccount.\n * @see screenTransaction\n * @see isExternalWalletScreeningEnabled\n * @notInstrumented\n */\nexport const screenBitcoinTransactions = async (\n {\n networkId,\n senderAddress,\n signal,\n transactions,\n walletAccount,\n }: ScreenBitcoinTransactionsParams,\n client = getDefaultClient()\n): Promise<ScreenTransactionResponse[]> => {\n // Refused rather than screened: the signing ceremony already screens these\n // server-side, so going ahead would bill the project for a redundant screen.\n if (isWaasWalletAccount({ walletAccount })) {\n throw new ScreeningNotRequiredError();\n }\n\n // Resolved unconditionally so a wrong-chain wallet account is rejected the\n // same way whether or not the caller supplied a network. This is a local\n // registry lookup; only getActiveNetworkId below is a wallet round-trip.\n const provider = getWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n if (!isBitcoinWalletProvider(provider)) {\n throw new NotBitcoinProviderError({ providerKey: provider.key });\n }\n\n const activeNetworkId =\n networkId ?? (await provider.getActiveNetworkId()).networkId;\n\n const chainId = getBitcoinScreeningChainId({ networkId: activeNetworkId });\n\n return Promise.all(\n transactions.map((btcTransaction) =>\n screenTransaction(\n {\n chain: 'BTC',\n // The context carries the coarse mainnet/testnet id the screening\n // contract recognizes; networkId carries the real one, which is what\n // the audit record wants — collapsing it would make signet\n // indistinguishable from testnet.\n context: { btcTransaction: { chainId, ...btcTransaction } },\n networkId: activeNetworkId,\n senderAddress: senderAddress ?? walletAccount.address,\n signal,\n },\n client\n )\n )\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 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\ntype SignMessageWithCustomOptionsResult = { signature: string };\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<SignMessageWithCustomOptionsResult> => {\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\ntype SignPsbtResult = { signedPsbt: string };\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<SignPsbtResult> => {\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\ntype SignPsbtsResult = { signedPsbts: string[] };\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<SignPsbtsResult> => {\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 { screenBitcoinTransactions } from '../screenBitcoinTransactions';\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;;;;;ACrB1E,MAAM,6BAA6B;;AAGnC,MAAM,6BAA6B;AACnC,MAAM,6BAA6B;;;;;;;;;;;;;AAkBnC,MAAa,8BAA8B,EACzC,gBAEA,cAAc,6BACV,6BACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC6CN,MAAa,4BAA4B,OACvC,EACE,WACA,eACA,QACA,cACA,iBAEF,yDAA2B,KACc;AAGzC,4DAAwB,EAAE,eAAe,CAAC,CACxC,OAAM,IAAIA,oDAA2B;CAMvC,MAAM,iFACJ,EAAE,eAAe,EACjB,OACD;AAED,KAAI,CAACC,iDAAwB,SAAS,CACpC,OAAM,IAAIC,iDAAwB,EAAE,aAAa,SAAS,KAAK,CAAC;CAGlE,MAAM,kBACJ,cAAc,MAAM,SAAS,oBAAoB,EAAE;CAErD,MAAM,UAAU,2BAA2B,EAAE,WAAW,iBAAiB,CAAC;AAE1E,QAAO,QAAQ,IACb,aAAa,KAAK,mEAEd;EACE,OAAO;EAKP,SAAS,EAAE,gBAAgB;GAAE;GAAS,GAAG;GAAgB,EAAE;EAC3D,WAAW;EACX,eAAe,iBAAiB,cAAc;EAC9C;EACD,EACD,OACD,CACF,CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACxEH,MAAa,+BAA+B,OAC1C,EACE,eACA,SACA,UACA,eAEF,yDAA2B,KACqB;CAChD,MAAM,iFACJ,EACE,eACD,EACD,OACD;AAED,KAAI,CAACC,iDAAwB,SAAS,CACpC,OAAM,IAAIC,iDAAwB,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,KACC;CAC5B,MAAM,iFACJ,EACE,eACD,EACD,OACD;AAED,KAAI,CAACC,iDAAwB,SAAS,CACpC,OAAM,IAAIC,iDAAwB,EAAE,aAAa,SAAS,KAAK,CAAC;AAGlE,QAAO,SAAS,SAAS;EAAE;EAAS;EAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACZtD,MAAa,YAAY,OACvB,EAAE,eAAe,YACjB,yDAA2B,KACE;CAC7B,MAAM,iFACJ,EACE,eACD,EACD,OACD;AAED,KAAI,CAACC,iDAAwB,SAAS,CACpC,OAAM,IAAIC,iDAAwB,EAAE,aAAa,SAAS,KAAK,CAAC;AAGlE,QAAO,SAAS,UAAU;EAAE;EAAU;EAAe,CAAC;;;;;mEC/CnCC,+BAAaC,iCAAe"}
|
package/dist/index.esm.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { a as TransactionBroadcastFailedError, i as TransactionRequiredError, t as addWaasBitcoinExtension } from "./addWaasBitcoinExtension-
|
|
1
|
+
import { c as isBitcoinWalletAccount, h as version, i as NotBitcoinProviderError, m as name, o as sendRawTransaction, r as sendBitcoin, s as isBitcoinWalletProvider, t as InvalidPsbtError } from "./InvalidPsbtError-BdHbd9wt.esm.js";
|
|
2
|
+
import { t as addBitcoinInjectedWalletsExtension } from "./addBitcoinInjectedWalletsExtension-axP2bkxG.esm.js";
|
|
3
|
+
import { a as TransactionBroadcastFailedError, i as TransactionRequiredError, t as addWaasBitcoinExtension } from "./addWaasBitcoinExtension-CckpDDh-.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
|
-
import { getDefaultClient as getDefaultClient$1 } from "@dynamic-labs-sdk/client";
|
|
6
|
+
import { ScreeningNotRequiredError, getDefaultClient as getDefaultClient$1, screenTransaction } from "@dynamic-labs-sdk/client";
|
|
7
|
+
import { isWaasWalletAccount } from "@dynamic-labs-sdk/client/waas";
|
|
7
8
|
|
|
8
9
|
//#region src/addBitcoinExtension/addBitcoinExtension.ts
|
|
9
10
|
/**
|
|
@@ -51,6 +52,93 @@ const addBitcoinExtension = (client = getDefaultClient()) => {
|
|
|
51
52
|
*/
|
|
52
53
|
const isBitcoinNetworkProvider = (networkProvider) => networkProvider.chain === "BTC";
|
|
53
54
|
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/utils/getBitcoinScreeningChainId/getBitcoinScreeningChainId.ts
|
|
57
|
+
/** Dynamic's network id for Bitcoin mainnet. */
|
|
58
|
+
const BITCOIN_MAINNET_NETWORK_ID = "1";
|
|
59
|
+
/** Network identifiers the transaction screening contract recognizes. */
|
|
60
|
+
const SCREENING_MAINNET_CHAIN_ID = "1";
|
|
61
|
+
const SCREENING_TESTNET_CHAIN_ID = "2";
|
|
62
|
+
/**
|
|
63
|
+
* Maps a Dynamic Bitcoin network id to the identifier the transaction
|
|
64
|
+
* screening contract uses.
|
|
65
|
+
*
|
|
66
|
+
* The contract only distinguishes mainnet from testnet, so signet — and any
|
|
67
|
+
* network id we cannot resolve — screens as testnet: neither is mainnet, and
|
|
68
|
+
* the value is recorded for audit rather than used to pick a provider.
|
|
69
|
+
*
|
|
70
|
+
* @param params.networkId - The wallet provider's active network id.
|
|
71
|
+
* @returns The screening chain identifier.
|
|
72
|
+
* @notInstrumented
|
|
73
|
+
*/
|
|
74
|
+
const getBitcoinScreeningChainId = ({ networkId }) => networkId === BITCOIN_MAINNET_NETWORK_ID ? SCREENING_MAINNET_CHAIN_ID : SCREENING_TESTNET_CHAIN_ID;
|
|
75
|
+
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/screenBitcoinTransactions/screenBitcoinTransactions.ts
|
|
78
|
+
/**
|
|
79
|
+
* Screens Bitcoin transactions' destinations against the environment's
|
|
80
|
+
* sanctions providers and returns one verdict per transaction.
|
|
81
|
+
*
|
|
82
|
+
* Builds the payload the screening API expects — including resolving the
|
|
83
|
+
* wallet's active network — so you do not need to know its shape, then defers
|
|
84
|
+
* to {@link screenTransaction}. Each transaction is screened independently, so
|
|
85
|
+
* the results are positional: `results[i]` is the verdict for `transactions[i]`.
|
|
86
|
+
*
|
|
87
|
+
* The screening contract only distinguishes mainnet from testnet, so the
|
|
88
|
+
* network is collapsed for the screen itself but recorded unchanged, keeping
|
|
89
|
+
* signet distinguishable from testnet in the audit record.
|
|
90
|
+
*
|
|
91
|
+
* Like the call it wraps, this imposes no policy: it does not consult project
|
|
92
|
+
* settings, does not throw on a `block` verdict, and rejects if screening
|
|
93
|
+
* fails. Gate it with `isExternalWalletScreeningEnabled` and decide for
|
|
94
|
+
* yourself what a block should do — for a batch, that usually means refusing
|
|
95
|
+
* to sign any of them if any one is blocked.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* if (isExternalWalletScreeningEnabled()) {
|
|
100
|
+
* const results = await screenBitcoinTransactions({
|
|
101
|
+
* transactions: [{ recipientAddress }],
|
|
102
|
+
* walletAccount,
|
|
103
|
+
* });
|
|
104
|
+
*
|
|
105
|
+
* if (results.some(({ decision }) => decision === 'block')) return;
|
|
106
|
+
* }
|
|
107
|
+
*
|
|
108
|
+
* await sendBitcoin({ walletAccount, transaction });
|
|
109
|
+
* ```
|
|
110
|
+
*
|
|
111
|
+
* @param params.transactions - The transactions about to be signed.
|
|
112
|
+
* @param params.walletAccount - The wallet account that would be prompted to sign.
|
|
113
|
+
* @param [params.networkId] - The network to record, e.g. `'3'` for signet. Resolved from the wallet provider when omitted.
|
|
114
|
+
* @param [params.senderAddress] - The sender to screen alongside the destinations. Defaults to the wallet account's address.
|
|
115
|
+
* @param [params.signal] - Cancels the in-flight requests, e.g. `AbortSignal.timeout(2000)`.
|
|
116
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
117
|
+
* @returns One verdict per transaction, in the order the transactions were given.
|
|
118
|
+
* @throws {ScreeningNotRequiredError} If the wallet account is a Dynamic embedded wallet, which signing already screens.
|
|
119
|
+
* @throws {NotBitcoinProviderError} If the wallet account is not a valid BitcoinWalletAccount.
|
|
120
|
+
* @see screenTransaction
|
|
121
|
+
* @see isExternalWalletScreeningEnabled
|
|
122
|
+
* @notInstrumented
|
|
123
|
+
*/
|
|
124
|
+
const screenBitcoinTransactions = async ({ networkId, senderAddress, signal, transactions, walletAccount }, client = getDefaultClient$1()) => {
|
|
125
|
+
if (isWaasWalletAccount({ walletAccount })) throw new ScreeningNotRequiredError();
|
|
126
|
+
const provider = getWalletProviderFromWalletAccount({ walletAccount }, client);
|
|
127
|
+
if (!isBitcoinWalletProvider(provider)) throw new NotBitcoinProviderError({ providerKey: provider.key });
|
|
128
|
+
const activeNetworkId = networkId ?? (await provider.getActiveNetworkId()).networkId;
|
|
129
|
+
const chainId = getBitcoinScreeningChainId({ networkId: activeNetworkId });
|
|
130
|
+
return Promise.all(transactions.map((btcTransaction) => screenTransaction({
|
|
131
|
+
chain: "BTC",
|
|
132
|
+
context: { btcTransaction: {
|
|
133
|
+
chainId,
|
|
134
|
+
...btcTransaction
|
|
135
|
+
} },
|
|
136
|
+
networkId: activeNetworkId,
|
|
137
|
+
senderAddress: senderAddress ?? walletAccount.address,
|
|
138
|
+
signal
|
|
139
|
+
}, client)));
|
|
140
|
+
};
|
|
141
|
+
|
|
54
142
|
//#endregion
|
|
55
143
|
//#region src/signMessageWithCustomOptions/signMessageWithCustomOptions.ts
|
|
56
144
|
/**
|
|
@@ -163,5 +251,5 @@ const signPsbts = async ({ walletAccount, requests }, client = getDefaultClient$
|
|
|
163
251
|
assertPackageVersion(name, version);
|
|
164
252
|
|
|
165
253
|
//#endregion
|
|
166
|
-
export { InvalidPsbtError, TransactionBroadcastFailedError, TransactionRequiredError, addBitcoinExtension, isBitcoinNetworkProvider, isBitcoinWalletAccount, sendBitcoin, sendRawTransaction, signMessageWithCustomOptions, signPsbt, signPsbts };
|
|
254
|
+
export { InvalidPsbtError, TransactionBroadcastFailedError, TransactionRequiredError, addBitcoinExtension, isBitcoinNetworkProvider, isBitcoinWalletAccount, screenBitcoinTransactions, sendBitcoin, sendRawTransaction, signMessageWithCustomOptions, signPsbt, signPsbts };
|
|
167
255
|
//# sourceMappingURL=index.esm.js.map
|
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 * @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"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","names":["getDefaultClient","getDefaultClient","getDefaultClient","getDefaultClient","packageName","packageVersion"],"sources":["../src/addBitcoinExtension/addBitcoinExtension.ts","../src/isBitcoinNetworkProvider/isBitcoinNetworkProvider.ts","../src/utils/getBitcoinScreeningChainId/getBitcoinScreeningChainId.ts","../src/screenBitcoinTransactions/screenBitcoinTransactions.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","/** Dynamic's network id for Bitcoin mainnet. */\nconst BITCOIN_MAINNET_NETWORK_ID = '1';\n\n/** Network identifiers the transaction screening contract recognizes. */\nconst SCREENING_MAINNET_CHAIN_ID = '1';\nconst SCREENING_TESTNET_CHAIN_ID = '2';\n\ntype GetBitcoinScreeningChainIdParams = {\n networkId: string | undefined;\n};\n\n/**\n * Maps a Dynamic Bitcoin network id to the identifier the transaction\n * screening contract uses.\n *\n * The contract only distinguishes mainnet from testnet, so signet — and any\n * network id we cannot resolve — screens as testnet: neither is mainnet, and\n * the value is recorded for audit rather than used to pick a provider.\n *\n * @param params.networkId - The wallet provider's active network id.\n * @returns The screening chain identifier.\n * @notInstrumented\n */\nexport const getBitcoinScreeningChainId = ({\n networkId,\n}: GetBitcoinScreeningChainIdParams): string =>\n networkId === BITCOIN_MAINNET_NETWORK_ID\n ? SCREENING_MAINNET_CHAIN_ID\n : SCREENING_TESTNET_CHAIN_ID;\n","import type { ScreenTransactionResponse } from '@dynamic-labs/sdk-api-core';\nimport {\n ScreeningNotRequiredError,\n getDefaultClient,\n screenTransaction,\n} from '@dynamic-labs-sdk/client';\nimport { getWalletProviderFromWalletAccount } from '@dynamic-labs-sdk/client/core';\nimport { isWaasWalletAccount } from '@dynamic-labs-sdk/client/waas';\n\nimport type { BitcoinWalletAccount } from '../BitcoinWalletAccount.types';\nimport { NotBitcoinProviderError } from '../errors/NotBitcoinProviderError';\nimport { isBitcoinWalletProvider } from '../isBitcoinWalletProvider';\nimport { getBitcoinScreeningChainId } from '../utils/getBitcoinScreeningChainId';\n\ntype ScreenBitcoinTransactionsParams = {\n /**\n * The network to record alongside the screen. Resolved from the wallet\n * provider when omitted.\n */\n networkId?: string;\n senderAddress?: string;\n signal?: AbortSignal;\n /** The destination of each transaction, as a recipient address or an unsigned PSBT. */\n transactions: { psbt?: string; recipientAddress?: string }[];\n walletAccount: BitcoinWalletAccount;\n};\n\n/**\n * Screens Bitcoin transactions' destinations against the environment's\n * sanctions providers and returns one verdict per transaction.\n *\n * Builds the payload the screening API expects — including resolving the\n * wallet's active network — so you do not need to know its shape, then defers\n * to {@link screenTransaction}. Each transaction is screened independently, so\n * the results are positional: `results[i]` is the verdict for `transactions[i]`.\n *\n * The screening contract only distinguishes mainnet from testnet, so the\n * network is collapsed for the screen itself but recorded unchanged, keeping\n * signet distinguishable from testnet in the audit record.\n *\n * Like the call it wraps, this imposes no policy: it does not consult project\n * settings, does not throw on a `block` verdict, and rejects if screening\n * fails. Gate it with `isExternalWalletScreeningEnabled` and decide for\n * yourself what a block should do — for a batch, that usually means refusing\n * to sign any of them if any one is blocked.\n *\n * @example\n * ```ts\n * if (isExternalWalletScreeningEnabled()) {\n * const results = await screenBitcoinTransactions({\n * transactions: [{ recipientAddress }],\n * walletAccount,\n * });\n *\n * if (results.some(({ decision }) => decision === 'block')) return;\n * }\n *\n * await sendBitcoin({ walletAccount, transaction });\n * ```\n *\n * @param params.transactions - The transactions about to be signed.\n * @param params.walletAccount - The wallet account that would be prompted to sign.\n * @param [params.networkId] - The network to record, e.g. `'3'` for signet. Resolved from the wallet provider when omitted.\n * @param [params.senderAddress] - The sender to screen alongside the destinations. Defaults to the wallet account's address.\n * @param [params.signal] - Cancels the in-flight requests, e.g. `AbortSignal.timeout(2000)`.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns One verdict per transaction, in the order the transactions were given.\n * @throws {ScreeningNotRequiredError} If the wallet account is a Dynamic embedded wallet, which signing already screens.\n * @throws {NotBitcoinProviderError} If the wallet account is not a valid BitcoinWalletAccount.\n * @see screenTransaction\n * @see isExternalWalletScreeningEnabled\n * @notInstrumented\n */\nexport const screenBitcoinTransactions = async (\n {\n networkId,\n senderAddress,\n signal,\n transactions,\n walletAccount,\n }: ScreenBitcoinTransactionsParams,\n client = getDefaultClient()\n): Promise<ScreenTransactionResponse[]> => {\n // Refused rather than screened: the signing ceremony already screens these\n // server-side, so going ahead would bill the project for a redundant screen.\n if (isWaasWalletAccount({ walletAccount })) {\n throw new ScreeningNotRequiredError();\n }\n\n // Resolved unconditionally so a wrong-chain wallet account is rejected the\n // same way whether or not the caller supplied a network. This is a local\n // registry lookup; only getActiveNetworkId below is a wallet round-trip.\n const provider = getWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n if (!isBitcoinWalletProvider(provider)) {\n throw new NotBitcoinProviderError({ providerKey: provider.key });\n }\n\n const activeNetworkId =\n networkId ?? (await provider.getActiveNetworkId()).networkId;\n\n const chainId = getBitcoinScreeningChainId({ networkId: activeNetworkId });\n\n return Promise.all(\n transactions.map((btcTransaction) =>\n screenTransaction(\n {\n chain: 'BTC',\n // The context carries the coarse mainnet/testnet id the screening\n // contract recognizes; networkId carries the real one, which is what\n // the audit record wants — collapsing it would make signet\n // indistinguishable from testnet.\n context: { btcTransaction: { chainId, ...btcTransaction } },\n networkId: activeNetworkId,\n senderAddress: senderAddress ?? walletAccount.address,\n signal,\n },\n client\n )\n )\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 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\ntype SignMessageWithCustomOptionsResult = { signature: string };\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<SignMessageWithCustomOptionsResult> => {\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\ntype SignPsbtResult = { signedPsbt: string };\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<SignPsbtResult> => {\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\ntype SignPsbtsResult = { signedPsbts: string[] };\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<SignPsbtsResult> => {\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 { screenBitcoinTransactions } from '../screenBitcoinTransactions';\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;;;;;ACrB1E,MAAM,6BAA6B;;AAGnC,MAAM,6BAA6B;AACnC,MAAM,6BAA6B;;;;;;;;;;;;;AAkBnC,MAAa,8BAA8B,EACzC,gBAEA,cAAc,6BACV,6BACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC6CN,MAAa,4BAA4B,OACvC,EACE,WACA,eACA,QACA,cACA,iBAEF,SAASA,oBAAkB,KACc;AAGzC,KAAI,oBAAoB,EAAE,eAAe,CAAC,CACxC,OAAM,IAAI,2BAA2B;CAMvC,MAAM,WAAW,mCACf,EAAE,eAAe,EACjB,OACD;AAED,KAAI,CAAC,wBAAwB,SAAS,CACpC,OAAM,IAAI,wBAAwB,EAAE,aAAa,SAAS,KAAK,CAAC;CAGlE,MAAM,kBACJ,cAAc,MAAM,SAAS,oBAAoB,EAAE;CAErD,MAAM,UAAU,2BAA2B,EAAE,WAAW,iBAAiB,CAAC;AAE1E,QAAO,QAAQ,IACb,aAAa,KAAK,mBAChB,kBACE;EACE,OAAO;EAKP,SAAS,EAAE,gBAAgB;GAAE;GAAS,GAAG;GAAgB,EAAE;EAC3D,WAAW;EACX,eAAe,iBAAiB,cAAc;EAC9C;EACD,EACD,OACD,CACF,CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACxEH,MAAa,+BAA+B,OAC1C,EACE,eACA,SACA,UACA,eAEF,SAASC,oBAAkB,KACqB;CAChD,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,KACC;CAC5B,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,KACE;CAC7B,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;;;;;AC/CxD,qBAAqBC,MAAaC,QAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBinanceBitcoinInjectedProvider.d.ts","sourceRoot":"","sources":["../../../../../src/injected/utils/binance/getBinanceBitcoinInjectedProvider/getBinanceBitcoinInjectedProvider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AAI9F,uBAAuB;AACvB,eAAO,MAAM,iCAAiC,
|
|
1
|
+
{"version":3,"file":"getBinanceBitcoinInjectedProvider.d.ts","sourceRoot":"","sources":["../../../../../src/injected/utils/binance/getBinanceBitcoinInjectedProvider/getBinanceBitcoinInjectedProvider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AAI9F,uBAAuB;AACvB,eAAO,MAAM,iCAAiC,QACxC,8BAA8B,GAAG,IAIpC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBitgetBitcoinInjectedProvider.d.ts","sourceRoot":"","sources":["../../../../../src/injected/utils/bitget/getBitgetBitcoinInjectedProvider/getBitgetBitcoinInjectedProvider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AAMxF,uBAAuB;AACvB,eAAO,MAAM,gCAAgC,
|
|
1
|
+
{"version":3,"file":"getBitgetBitcoinInjectedProvider.d.ts","sourceRoot":"","sources":["../../../../../src/injected/utils/bitget/getBitgetBitcoinInjectedProvider/getBitgetBitcoinInjectedProvider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AAMxF,uBAAuB;AACvB,eAAO,MAAM,gCAAgC,QACvC,sBAAsB,GAAG,IAI5B,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LeatherProvider } from '@leather.io/rpc';
|
|
1
2
|
/** @notInstrumented */
|
|
2
|
-
export declare const getLeatherBitcoinInjectedProvider: () =>
|
|
3
|
+
export declare const getLeatherBitcoinInjectedProvider: () => LeatherProvider | null;
|
|
3
4
|
//# sourceMappingURL=getLeatherBitcoinInjectedProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLeatherBitcoinInjectedProvider.d.ts","sourceRoot":"","sources":["../../../../../src/injected/utils/leather/getLeatherBitcoinInjectedProvider/getLeatherBitcoinInjectedProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getLeatherBitcoinInjectedProvider.d.ts","sourceRoot":"","sources":["../../../../../src/injected/utils/leather/getLeatherBitcoinInjectedProvider/getLeatherBitcoinInjectedProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAMvD,uBAAuB;AACvB,eAAO,MAAM,iCAAiC,QAAO,eAAe,GAAG,IAItE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMagicEdenInjectedProvider.d.ts","sourceRoot":"","sources":["../../../../../src/injected/utils/magicEden/getMagicEdenInjectedProvider/getMagicEdenInjectedProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAIpD,uBAAuB;AACvB,eAAO,MAAM,4BAA4B,
|
|
1
|
+
{"version":3,"file":"getMagicEdenInjectedProvider.d.ts","sourceRoot":"","sources":["../../../../../src/injected/utils/magicEden/getMagicEdenInjectedProvider/getMagicEdenInjectedProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAIpD,uBAAuB;AACvB,eAAO,MAAM,4BAA4B,QAAO,eAAe,GAAG,IAIjE,CAAC"}
|
package/dist/injected/utils/okx/getOkxBitcoinInjectedProvider/getOkxBitcoinInjectedProvider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOkxBitcoinInjectedProvider.d.ts","sourceRoot":"","sources":["../../../../../src/injected/utils/okx/getOkxBitcoinInjectedProvider/getOkxBitcoinInjectedProvider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AAItF,uBAAuB;AACvB,eAAO,MAAM,6BAA6B,
|
|
1
|
+
{"version":3,"file":"getOkxBitcoinInjectedProvider.d.ts","sourceRoot":"","sources":["../../../../../src/injected/utils/okx/getOkxBitcoinInjectedProvider/getOkxBitcoinInjectedProvider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AAItF,uBAAuB;AACvB,eAAO,MAAM,6BAA6B,QACpC,0BAA0B,GAAG,IAIhC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOneKeyBitcoinInjectedProvider.d.ts","sourceRoot":"","sources":["../../../../../src/injected/utils/oneKey/getOneKeyBitcoinInjectedProvider/getOneKeyBitcoinInjectedProvider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AAI5F,uBAAuB;AACvB,eAAO,MAAM,gCAAgC,
|
|
1
|
+
{"version":3,"file":"getOneKeyBitcoinInjectedProvider.d.ts","sourceRoot":"","sources":["../../../../../src/injected/utils/oneKey/getOneKeyBitcoinInjectedProvider/getOneKeyBitcoinInjectedProvider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AAI5F,uBAAuB;AACvB,eAAO,MAAM,gCAAgC,QACvC,6BAA6B,GAAG,IAInC,CAAC"}
|
package/dist/injected/utils/oyl/getOylBitcoinInjectedProvider/getOylBitcoinInjectedProvider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOylBitcoinInjectedProvider.d.ts","sourceRoot":"","sources":["../../../../../src/injected/utils/oyl/getOylBitcoinInjectedProvider/getOylBitcoinInjectedProvider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AAItF,uBAAuB;AACvB,eAAO,MAAM,6BAA6B,
|
|
1
|
+
{"version":3,"file":"getOylBitcoinInjectedProvider.d.ts","sourceRoot":"","sources":["../../../../../src/injected/utils/oyl/getOylBitcoinInjectedProvider/getOylBitcoinInjectedProvider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AAItF,uBAAuB;AACvB,eAAO,MAAM,6BAA6B,QACpC,0BAA0B,GAAG,IAIhC,CAAC"}
|
package/dist/injected/utils/phantom/getPhantomInjectedProvider/getPhantomInjectedProvider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPhantomInjectedProvider.d.ts","sourceRoot":"","sources":["../../../../../src/injected/utils/phantom/getPhantomInjectedProvider/getPhantomInjectedProvider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AAI9F,uBAAuB;AACvB,eAAO,MAAM,0BAA0B,
|
|
1
|
+
{"version":3,"file":"getPhantomInjectedProvider.d.ts","sourceRoot":"","sources":["../../../../../src/injected/utils/phantom/getPhantomInjectedProvider/getPhantomInjectedProvider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AAI9F,uBAAuB;AACvB,eAAO,MAAM,0BAA0B,QACjC,8BAA8B,GAAG,IAIpC,CAAC"}
|
package/dist/injected/utils/unisat/getUnisatInjectedProvider/getUnisatInjectedProvider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUnisatInjectedProvider.d.ts","sourceRoot":"","sources":["../../../../../src/injected/utils/unisat/getUnisatInjectedProvider/getUnisatInjectedProvider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAM9E,uBAAuB;AACvB,eAAO,MAAM,yBAAyB,
|
|
1
|
+
{"version":3,"file":"getUnisatInjectedProvider.d.ts","sourceRoot":"","sources":["../../../../../src/injected/utils/unisat/getUnisatInjectedProvider/getUnisatInjectedProvider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAM9E,uBAAuB;AACvB,eAAO,MAAM,yBAAyB,QAAO,sBAAsB,GAAG,IAIrE,CAAC"}
|
package/dist/injected/utils/xverse/getXverseInjectedProvider/getXverseInjectedProvider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getXverseInjectedProvider.d.ts","sourceRoot":"","sources":["../../../../../src/injected/utils/xverse/getXverseInjectedProvider/getXverseInjectedProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAIpD,uBAAuB;AACvB,eAAO,MAAM,yBAAyB,
|
|
1
|
+
{"version":3,"file":"getXverseInjectedProvider.d.ts","sourceRoot":"","sources":["../../../../../src/injected/utils/xverse/getXverseInjectedProvider/getXverseInjectedProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAIpD,uBAAuB;AACvB,eAAO,MAAM,yBAAyB,QAAO,eAAe,GAAG,IAI9D,CAAC"}
|
package/dist/injected.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const require_addWaasBitcoinExtension = require('./addWaasBitcoinExtension-
|
|
2
|
-
const
|
|
3
|
-
const require_addBitcoinInjectedWalletsExtension = require('./addBitcoinInjectedWalletsExtension-
|
|
1
|
+
const require_addWaasBitcoinExtension = require('./addWaasBitcoinExtension-B99fc1KQ.cjs');
|
|
2
|
+
const require_InvalidPsbtError = require('./InvalidPsbtError-DAnSIW2b.cjs');
|
|
3
|
+
const require_addBitcoinInjectedWalletsExtension = require('./addBitcoinInjectedWalletsExtension-kKxSQ6oH.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
|
|
7
|
-
(0, _dynamic_labs_sdk_assert_package_version.assertPackageVersion)(
|
|
7
|
+
(0, _dynamic_labs_sdk_assert_package_version.assertPackageVersion)(require_InvalidPsbtError.name, require_InvalidPsbtError.version);
|
|
8
8
|
|
|
9
9
|
//#endregion
|
|
10
10
|
exports.addBitcoinInjectedWalletsExtension = require_addBitcoinInjectedWalletsExtension.addBitcoinInjectedWalletsExtension;
|
package/dist/injected.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injected.cjs","names":["packageName","packageVersion"],"sources":["../src/exports/injected.ts"],"sourcesContent":["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 { addBitcoinInjectedWalletsExtension } from '../injected/addBitcoinInjectedWalletsExtension';\n"],"mappings":";;;;;;mEAMqBA,
|
|
1
|
+
{"version":3,"file":"injected.cjs","names":["packageName","packageVersion"],"sources":["../src/exports/injected.ts"],"sourcesContent":["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 { addBitcoinInjectedWalletsExtension } from '../injected/addBitcoinInjectedWalletsExtension';\n"],"mappings":";;;;;;mEAMqBA,+BAAaC,iCAAe"}
|
package/dist/injected.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as addBitcoinInjectedWalletsExtension } from "./addBitcoinInjectedWalletsExtension-
|
|
1
|
+
import { h as version, m as name } from "./InvalidPsbtError-BdHbd9wt.esm.js";
|
|
2
|
+
import { t as addBitcoinInjectedWalletsExtension } from "./addBitcoinInjectedWalletsExtension-axP2bkxG.esm.js";
|
|
3
3
|
import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
|
|
4
4
|
|
|
5
5
|
//#region src/exports/injected.ts
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/screenBitcoinTransactions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { ScreenTransactionResponse } from '@dynamic-labs/sdk-api-core';
|
|
2
|
+
import type { BitcoinWalletAccount } from '../BitcoinWalletAccount.types';
|
|
3
|
+
type ScreenBitcoinTransactionsParams = {
|
|
4
|
+
/**
|
|
5
|
+
* The network to record alongside the screen. Resolved from the wallet
|
|
6
|
+
* provider when omitted.
|
|
7
|
+
*/
|
|
8
|
+
networkId?: string;
|
|
9
|
+
senderAddress?: string;
|
|
10
|
+
signal?: AbortSignal;
|
|
11
|
+
/** The destination of each transaction, as a recipient address or an unsigned PSBT. */
|
|
12
|
+
transactions: {
|
|
13
|
+
psbt?: string;
|
|
14
|
+
recipientAddress?: string;
|
|
15
|
+
}[];
|
|
16
|
+
walletAccount: BitcoinWalletAccount;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Screens Bitcoin transactions' destinations against the environment's
|
|
20
|
+
* sanctions providers and returns one verdict per transaction.
|
|
21
|
+
*
|
|
22
|
+
* Builds the payload the screening API expects — including resolving the
|
|
23
|
+
* wallet's active network — so you do not need to know its shape, then defers
|
|
24
|
+
* to {@link screenTransaction}. Each transaction is screened independently, so
|
|
25
|
+
* the results are positional: `results[i]` is the verdict for `transactions[i]`.
|
|
26
|
+
*
|
|
27
|
+
* The screening contract only distinguishes mainnet from testnet, so the
|
|
28
|
+
* network is collapsed for the screen itself but recorded unchanged, keeping
|
|
29
|
+
* signet distinguishable from testnet in the audit record.
|
|
30
|
+
*
|
|
31
|
+
* Like the call it wraps, this imposes no policy: it does not consult project
|
|
32
|
+
* settings, does not throw on a `block` verdict, and rejects if screening
|
|
33
|
+
* fails. Gate it with `isExternalWalletScreeningEnabled` and decide for
|
|
34
|
+
* yourself what a block should do — for a batch, that usually means refusing
|
|
35
|
+
* to sign any of them if any one is blocked.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* if (isExternalWalletScreeningEnabled()) {
|
|
40
|
+
* const results = await screenBitcoinTransactions({
|
|
41
|
+
* transactions: [{ recipientAddress }],
|
|
42
|
+
* walletAccount,
|
|
43
|
+
* });
|
|
44
|
+
*
|
|
45
|
+
* if (results.some(({ decision }) => decision === 'block')) return;
|
|
46
|
+
* }
|
|
47
|
+
*
|
|
48
|
+
* await sendBitcoin({ walletAccount, transaction });
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @param params.transactions - The transactions about to be signed.
|
|
52
|
+
* @param params.walletAccount - The wallet account that would be prompted to sign.
|
|
53
|
+
* @param [params.networkId] - The network to record, e.g. `'3'` for signet. Resolved from the wallet provider when omitted.
|
|
54
|
+
* @param [params.senderAddress] - The sender to screen alongside the destinations. Defaults to the wallet account's address.
|
|
55
|
+
* @param [params.signal] - Cancels the in-flight requests, e.g. `AbortSignal.timeout(2000)`.
|
|
56
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
57
|
+
* @returns One verdict per transaction, in the order the transactions were given.
|
|
58
|
+
* @throws {ScreeningNotRequiredError} If the wallet account is a Dynamic embedded wallet, which signing already screens.
|
|
59
|
+
* @throws {NotBitcoinProviderError} If the wallet account is not a valid BitcoinWalletAccount.
|
|
60
|
+
* @see screenTransaction
|
|
61
|
+
* @see isExternalWalletScreeningEnabled
|
|
62
|
+
* @notInstrumented
|
|
63
|
+
*/
|
|
64
|
+
export declare const screenBitcoinTransactions: ({ networkId, senderAddress, signal, transactions, walletAccount, }: ScreenBitcoinTransactionsParams, client?: import("@dynamic-labs-sdk/client").DynamicClient) => Promise<ScreenTransactionResponse[]>;
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=screenBitcoinTransactions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenBitcoinTransactions.d.ts","sourceRoot":"","sources":["../../src/screenBitcoinTransactions/screenBitcoinTransactions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAS5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAK1E,KAAK,+BAA+B,GAAG;IACrC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,uFAAuF;IACvF,YAAY,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC7D,aAAa,EAAE,oBAAoB,CAAC;CACrC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,eAAO,MAAM,yBAAyB,uEAOjC,+BAA+B,gEAEjC,OAAO,CAAC,yBAAyB,EAAE,CA0CrC,CAAC"}
|