@bestinslot/wallet-kit 0.7.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.
Files changed (66) hide show
  1. package/README.md +108 -0
  2. package/dist/balances-BQiaAIaq.js +9627 -0
  3. package/dist/browser.js +205 -0
  4. package/dist/core.js +39 -0
  5. package/dist/mint-BXVHw4CQ.js +70722 -0
  6. package/dist/node.js +1787 -0
  7. package/dist/react.js +14 -0
  8. package/dist/register-browser-providers-CLLT6W6P.js +499 -0
  9. package/dist/types/adapters/react/use-network.d.ts +8 -0
  10. package/dist/types/adapters/react/use-wallet.d.ts +15 -0
  11. package/dist/types/adapters/vue/use-network.d.ts +12 -0
  12. package/dist/types/api/balances.d.ts +52 -0
  13. package/dist/types/api/brc20.d.ts +110 -0
  14. package/dist/types/api/helpers.d.ts +3 -0
  15. package/dist/types/api/mint.d.ts +57 -0
  16. package/dist/types/api/modal.d.ts +3 -0
  17. package/dist/types/api/swap.d.ts +122 -0
  18. package/dist/types/api/wallet.browser.d.ts +2 -0
  19. package/dist/types/api/wallet.d.ts +6 -0
  20. package/dist/types/api/wallet.node.d.ts +4 -0
  21. package/dist/types/browser.d.ts +10 -0
  22. package/dist/types/components/Dev.vue.d.ts +11 -0
  23. package/dist/types/components/connect-modal-view.d.ts +28 -0
  24. package/dist/types/components/dev/BRC20.vue.d.ts +2 -0
  25. package/dist/types/components/dev/Button.vue.d.ts +17 -0
  26. package/dist/types/components/dev/Input.vue.d.ts +12 -0
  27. package/dist/types/components/dev/Label.vue.d.ts +17 -0
  28. package/dist/types/components/dev/Select.vue.d.ts +17 -0
  29. package/dist/types/components/dev/SessionInfo.vue.d.ts +6 -0
  30. package/dist/types/core/bis.d.ts +21 -0
  31. package/dist/types/core/bis_swap.d.ts +622 -0
  32. package/dist/types/core/brc20.d.ts +229 -0
  33. package/dist/types/core/connect-modal.d.ts +15 -0
  34. package/dist/types/core/helpers.d.ts +212 -0
  35. package/dist/types/core/mint.d.ts +364 -0
  36. package/dist/types/core/modal.d.ts +21 -0
  37. package/dist/types/core/providers.d.ts +90 -0
  38. package/dist/types/core/register-browser-providers.d.ts +1 -0
  39. package/dist/types/core/register-local-provider.d.ts +1 -0
  40. package/dist/types/core/storage.d.ts +19 -0
  41. package/dist/types/core/store-network.d.ts +20 -0
  42. package/dist/types/core/store.d.ts +39 -0
  43. package/dist/types/core.d.ts +10 -0
  44. package/dist/types/lib/bitcoin.d.ts +8 -0
  45. package/dist/types/lib/dev-worker.d.ts +1 -0
  46. package/dist/types/lib/dev.d.ts +9 -0
  47. package/dist/types/lib/swap-constants.d.ts +7 -0
  48. package/dist/types/lib/swap-reporting.d.ts +80 -0
  49. package/dist/types/lib/uniswap_ops.d.ts +238 -0
  50. package/dist/types/lib/web3.d.ts +7 -0
  51. package/dist/types/node.d.ts +9 -0
  52. package/dist/types/provider/api.d.ts +97 -0
  53. package/dist/types/provider/leather.d.ts +2 -0
  54. package/dist/types/provider/local.d.ts +39 -0
  55. package/dist/types/provider/okx.d.ts +2 -0
  56. package/dist/types/provider/unisat.d.ts +2 -0
  57. package/dist/types/provider/xverse.d.ts +2 -0
  58. package/dist/types/react.d.ts +3 -0
  59. package/dist/types/types/common.d.ts +33 -0
  60. package/dist/types/types/global.d.ts +26 -0
  61. package/dist/types/types/inscription.d.ts +147 -0
  62. package/dist/types/types/vite-env.d.ts +7 -0
  63. package/dist/types/types/wallet.d.ts +50 -0
  64. package/dist/types/vue.d.ts +2 -0
  65. package/dist/vue.js +13 -0
  66. package/package.json +133 -0
@@ -0,0 +1,229 @@
1
+ /**
2
+ * Compresses the input hex string using both Zstd and Nada compression algorithms, and returns the shortest result encoded in base64 without padding.
3
+ *
4
+ * @param inputHex - The input data in hexadecimal string format to be compressed.
5
+ * @returns A base64 encoded string representing the compressed data, prefixed with a byte indicating the compression method used (0x00 for uncompressed, 0x01 for Nada, 0x02 for Zstd), and without any padding characters.
6
+ */
7
+ export declare function compressSmartContractData(inputHex: string): Promise<string>;
8
+ /**
9
+ * Encodes a function call to a smart contract using the provided ABI and function name, along with the parameters for the function call. This function uses the Web3 library to create a contract instance and encode the function call data according to the ABI specification. It also includes error handling to ensure that the specified function exists in the ABI and that the parameters are correctly formatted.
10
+ *
11
+ * @param abi - The ABI of the smart contract, which defines the functions and their parameters.
12
+ * @param functionName - The name of the function to call on the smart contract.
13
+ * @param params - An array of parameters to be passed to the function call, which should match the types defined in the ABI for the specified function.
14
+ * @returns A hexadecimal string representing the encoded function call data, which can be included in a transaction to call the smart contract function. The encoding is done according to the ABI specification, and the resulting string can be used as the calldata for a transaction.
15
+ * @throws Will throw an error if the specified function name does not exist in the ABI or if the parameters do not match the expected types defined in the ABI for that function. It will also throw an error if there is an issue with the Web3 library during encoding.
16
+ */
17
+ export declare function evmEncodeFunctionCall(abi: any, functionName: string, params: any): string;
18
+ export declare function getEvmAddressFromBitcoinAddress(bitcoinAddress: string): string;
19
+ export declare function getEvmAddressFromPkScript(pkscript: string): string;
20
+ /**
21
+ * Deploys a smart contract by creating an inscription with the provided input data and sending it to the OP_RETURN output. The function first compresses the input data, then creates an inscription with the compressed data and mints it. After minting, it sends the inscription to an OP_RETURN output with a specific format. The function also handles optional payment parameters and allows for a dry run mode where the transaction hexes are returned without broadcasting.
22
+ *
23
+ * @param inputHex - The input data for the smart contract deployment, represented as a hexadecimal string. This data will be compressed and included in the inscription.
24
+ * @param estimatedGas - The estimated gas required for the smart contract deployment, used to determine if padding is needed for the inscription content.
25
+ * @param gasPerVbyte - The gas cost per virtual byte, used to calculate the total gas cost of the inscription content and determine if padding is needed.
26
+ * @param feeRate - The fee rate in sats/vbyte to be used for the transactions involved in the deployment process.
27
+ * @param postage - An optional parameter representing the postage to be included in the minting transaction, specified in sats. If null, no postage will be included.
28
+ * @param paymentAddr - An optional parameter representing the Bitcoin address to which payment should be sent for the minting transaction. If null, no payment will be made.
29
+ * @param payment - An optional parameter representing the amount of payment to be sent for the minting transaction, specified in sats. If null or less than or equal to 0, no payment will be made.
30
+ * @param dryRun - A boolean flag indicating whether to perform a dry run. If true, the function will return the transaction hexes without broadcasting them to the network. If false, the transactions will be broadcasted after creation.
31
+ *
32
+ * @returns An object containing details of the deployment process, including transaction IDs, signed transaction hexes, inscription ID, postage, and secret used in the minting process. If dryRun is true, the transactions will not be broadcasted and the hexes will be returned for inspection.
33
+ */
34
+ export declare function deploySmartContract(inputHex: string, estimatedGas: number, gasPerVbyte: number, feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, dryRun: boolean): Promise<{
35
+ commitTxId: string;
36
+ signedCommitTxHex: string;
37
+ revealTxId: string;
38
+ signedRevealTxHex: string;
39
+ inscriptionId: string;
40
+ postage: number;
41
+ secret: string;
42
+ sendToOpReturnTxId: string;
43
+ signedSendToOpReturnTxHex: string;
44
+ }>;
45
+ /**
46
+ * Deploys a smart contract using the provided bytecode and ABI by creating an inscription with the encoded deployment data and sending it to the OP_RETURN output. The function first encodes the deployment data using the ABI and bytecode, then creates an inscription with the encoded data and mints it. After minting, it sends the inscription to an OP_RETURN output with a specific format. The function also handles optional payment parameters and allows for a dry run mode where the transaction hexes are returned without broadcasting.
47
+ *
48
+ * @param bytecode - The bytecode of the smart contract to be deployed, represented as a hexadecimal string. This bytecode will be encoded with the ABI and included in the inscription.
49
+ * @param abi - The ABI of the smart contract, used to encode the deployment data along with the bytecode.
50
+ * @param params - An array of parameters to be passed to the contract constructor, which will be encoded along with the bytecode using the ABI.
51
+ * @param estimatedGas - The estimated gas required for the smart contract deployment, used to determine if padding is needed for the inscription content.
52
+ * @param gasPerVbyte - The gas cost per virtual byte, used to calculate the total gas cost of the inscription content and determine if padding is needed.
53
+ * @param feeRate - The fee rate in sats/vbyte to be used for the transactions involved in the deployment process.
54
+ * @param postage - An optional parameter representing the postage to be included in the minting transaction, specified in sats. If null, no postage will be included.
55
+ * @param paymentAddr - An optional parameter representing the Bitcoin address to which payment should be sent for the minting transaction. If null, no payment will be made.
56
+ * @param payment - An optional parameter representing the amount of payment to be sent for the minting transaction, specified in sats. If null or less than or equal to 0, no payment will be made.
57
+ * @param dryRun - A boolean flag indicating whether to perform a dry run. If true, the function will return the transaction hexes without broadcasting them to the network. If false, the transactions will be broadcasted after creation.
58
+ *
59
+ * @returns An object containing details of the deployment process, including transaction IDs, signed transaction hexes, inscription ID, postage, and secret used in the minting process. If dryRun is true, the transactions will not be broadcasted and the hexes will be returned for inspection.
60
+ */
61
+ export declare function deploySmartContractAbi(bytecode: string, abi: any, params: any, estimatedGas: number, gasPerVbyte: number, feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, dryRun: boolean): Promise<{
62
+ commitTxId: string;
63
+ signedCommitTxHex: string;
64
+ revealTxId: string;
65
+ signedRevealTxHex: string;
66
+ inscriptionId: string;
67
+ postage: number;
68
+ secret: string;
69
+ sendToOpReturnTxId: string;
70
+ signedSendToOpReturnTxHex: string;
71
+ }>;
72
+ /**
73
+ * Calls a smart contract function by creating an inscription with the provided input data and sending it to the OP_RETURN output. The function first compresses the input data, then creates an inscription with the compressed data and mints it. After minting, it sends the inscription to an OP_RETURN output with a specific format. The function also handles optional payment parameters and allows for a dry run mode where the transaction hexes are returned without broadcasting.
74
+ *
75
+ * @param smartContractContractAddr - The address of the smart contract to call, represented as a string. This address will be included in the inscription content to indicate which contract function is being called.
76
+ * @param inputHex - The input data for the smart contract function call, represented as a hexadecimal string. This data will be compressed and included in the inscription.
77
+ * @param estimatedGas - The estimated gas required for the smart contract function call, used to determine if padding is needed for the inscription content.
78
+ * @param gasPerVbyte - The gas cost per virtual byte, used to calculate the total gas cost of the inscription content and determine if padding is needed.
79
+ * @param feeRate - The fee rate in sats/vbyte to be used for the transactions involved in the function call process.
80
+ * @param postage - An optional parameter representing the postage to be included in the minting transaction, specified in sats. If null, no postage will be included.
81
+ * @param paymentAddr - An optional parameter representing the Bitcoin address to which payment should be sent for the minting transaction. If null, no payment will be made.
82
+ * @param payment - An optional parameter representing the amount of payment to be sent for the minting transaction, specified in sats. If null or less than or equal to 0, no payment will be made.
83
+ * @param dryRun - A boolean flag indicating whether to perform a dry run. If true, the function will return the transaction hexes without broadcasting them to the network. If false, the transactions will be broadcasted after creation.
84
+ *
85
+ * @returns An object containing details of the function call process, including transaction IDs, signed transaction hexes, inscription ID, postage, and secret used in the minting process. If dryRun is true, the transactions will not be broadcasted and the hexes will be returned for inspection.
86
+ */
87
+ export declare function callSmartContract(smartContractContractAddr: string, inputHex: string, estimatedGas: number, gasPerVbyte: number, feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, dryRun: boolean): Promise<{
88
+ commitTxId: string;
89
+ signedCommitTxHex: string;
90
+ revealTxId: string;
91
+ signedRevealTxHex: string;
92
+ inscriptionId: string;
93
+ postage: number;
94
+ secret: string;
95
+ sendToOpReturnTxId: string;
96
+ signedSendToOpReturnTxHex: string;
97
+ }>;
98
+ /**
99
+ * Calls a smart contract function by creating an inscription with the encoded function call data and sending it to the OP_RETURN output. The function takes the smart contract address, ABI, function name, and parameters, encodes the function call using the ABI, and then follows a similar process as `deploySmartContract` to create and send the inscription. It also handles optional payment parameters and allows for a dry run mode where the transaction hexes are returned without broadcasting.
100
+ *
101
+ * @param smartContractContractAddr - The address of the smart contract to call, represented as a string. This address will be included in the inscription content to indicate which contract function is being called.
102
+ * @param abi - The ABI of the smart contract, used to encode the function call data along with the function name and parameters.
103
+ * @param funcName - The name of the function to call on the smart contract, represented as a string. This will be used along with the ABI to encode the function call data.
104
+ * @param params - An array of parameters to be passed to the contract function, which will be encoded using the ABI along with the function name.
105
+ * @param estimatedGas - The estimated gas required for the smart contract function call, used to determine if padding is needed for the inscription content.
106
+ * @param gasPerVbyte - The gas cost per virtual byte, used to calculate the total gas cost of the inscription content and determine if padding is needed.
107
+ * @param feeRate - The fee rate in sats/vbyte to be used for the transactions involved in the function call process.
108
+ * @param postage - An optional parameter representing the postage to be included in the minting transaction, specified in sats. If null, no postage will be included.
109
+ * @param paymentAddr - An optional parameter representing the Bitcoin address to which payment should be sent for the minting transaction. If null, no payment will be made.
110
+ * @param payment - An optional parameter representing the amount of payment to be sent for the minting transaction, specified in sats. If null or less than or equal to 0, no payment will be made.
111
+ * @param dryRun - A boolean flag indicating whether to perform a dry run. If true, the function will return the transaction hexes without broadcasting them to the network. If false, the transactions will be broadcasted after creation.
112
+ *
113
+ * @returns An object containing details of the function call process, including transaction IDs, signed transaction hexes, inscription ID, postage, and secret used in the minting process. If dryRun is true, the transactions will not be broadcasted and the hexes will be returned for inspection.
114
+ */
115
+ export declare function callSmartContractAbi(smartContractContractAddr: string, abi: any, funcName: string, params: any, estimatedGas: number, gasPerVbyte: number, feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, dryRun: boolean): Promise<{
116
+ commitTxId: string;
117
+ signedCommitTxHex: string;
118
+ revealTxId: string;
119
+ signedRevealTxHex: string;
120
+ inscriptionId: string;
121
+ postage: number;
122
+ secret: string;
123
+ sendToOpReturnTxId: string;
124
+ signedSendToOpReturnTxHex: string;
125
+ }>;
126
+ /**
127
+ * Calls a smart contract function by creating an inscription with the provided input data and sending it to the OP_RETURN output. The function first compresses the input data, then creates an inscription with the compressed data and mints it. After minting, it sends the inscription to an OP_RETURN output with a specific format. The function also handles optional payment parameters and allows for a dry run mode where the transaction hexes are returned without broadcasting.
128
+ *
129
+ * @param smartContractContractAddr - The address of the smart contract to call, represented as a string. This address will be included in the inscription content to indicate which contract function is being called.
130
+ * @param inputHex - The input data for the smart contract function call, represented as a hexadecimal string. This data will be compressed and included in the inscription.
131
+ * @param estimatedGas - The estimated gas required for the smart contract function call, used to determine if padding is needed for the inscription content.
132
+ * @param gasPerVbyte - The gas cost per virtual byte, used to calculate the total gas cost of the inscription content and determine if padding is needed.
133
+ * @param feeRate - The fee rate in sats/vbyte to be used for the transactions involved in the function call process.
134
+ * @param postage - An optional parameter representing the postage to be included in the minting transaction, specified in sats. If null, no postage will be included.
135
+ * @param paymentAddr - An optional parameter representing the Bitcoin address to which payment should be sent for the minting transaction. If null, no payment will be made.
136
+ * @param payment - An optional parameter representing the amount of payment to be sent for the minting transaction, specified in sats. If null or less than or equal to 0, no payment will be made.
137
+ * @param dryRun - A boolean flag indicating whether to perform a dry run. If true, the function will return the transaction hexes without broadcasting them to the network. If false, the transactions will be broadcasted after creation.
138
+ *
139
+ * @returns An object containing details of the function call process, including transaction IDs, signed transaction hexes, inscription ID, postage, and secret used in the minting process. If dryRun is true, the transactions will not be broadcasted and the hexes will be returned for inspection.
140
+ * @throws Will throw an error if the wallet is not connected, if the input parameters are of incorrect types, or if there is a failure in creating or sending the inscription.
141
+ */
142
+ export declare function callSmartContractFromPaymentWallet(smartContractContractAddr: string, inputHex: string, estimatedGas: number, gasPerVbyte: number, feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, dryRun: boolean): Promise<{
143
+ commitTxId: string;
144
+ signedCommitTxHex: string;
145
+ revealTxId: string;
146
+ signedRevealTxHex: string;
147
+ inscriptionId: string;
148
+ postage: number;
149
+ secret: string;
150
+ sendToOpReturnTxId: string;
151
+ signedSendToOpReturnTxHex: string;
152
+ }>;
153
+ /**
154
+ * Calls a smart contract function using the provided ABI and function name by encoding the function call data, creating an inscription with the encoded data, and sending it to the OP_RETURN output. The function takes the smart contract address, ABI, function name, and parameters, encodes the function call using the ABI, and then follows a similar process as `callSmartContract` to create and send the inscription. It also handles optional payment parameters and allows for a dry run mode where the transaction hexes are returned without broadcasting.
155
+ *
156
+ * @param smartContractContractAddr - The address of the smart contract to call, represented as a string. This address will be included in the inscription content to indicate which contract function is being called.
157
+ * @param abi - The ABI of the smart contract, used to encode the function call data along with the function name and parameters.
158
+ * @param funcName - The name of the function to call on the smart contract, represented as a string. This will be used along with the ABI to encode the function call data.
159
+ * @param params - An array of parameters to be passed to the contract function, which will be encoded using the ABI along with the function name.
160
+ * @param estimatedGas - The estimated gas required for the smart contract function call, used to determine if padding is needed for the inscription content.
161
+ * @param gasPerVbyte - The gas cost per virtual byte, used to calculate the total gas cost of the inscription content and determine if padding is needed.
162
+ * @param feeRate - The fee rate in sats/vbyte to be used for the transactions involved in the function call process.
163
+ * @param postage - An optional parameter representing the postage to be included in the minting transaction, specified in sats. If null, no postage will be included.
164
+ * @param paymentAddr - An optional parameter representing the Bitcoin address to which payment should be sent for the minting transaction. If null, no payment will be made.
165
+ * @param payment - An optional parameter representing the amount of payment to be sent for the minting transaction, specified in sats. If null or less than or equal to 0, no payment will be made.
166
+ * @param dryRun - A boolean flag indicating whether to perform a dry run. If true, the function will return the transaction hexes without broadcasting them to the network. If false, the transactions will be broadcasted after creation.
167
+ *
168
+ * @returns An object containing details of the function call process, including transaction IDs, signed transaction hexes, inscription ID, postage, and secret used in the minting process. If dryRun is true, the transactions will not be broadcasted and the hexes will be returned for inspection.
169
+ */
170
+ export declare function callSmartContractAbiFromPaymentWallet(smartContractContractAddr: string, abi: any, funcName: string, params: any, estimatedGas: number, gasPerVbyte: number, feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, dryRun: boolean): Promise<{
171
+ commitTxId: string;
172
+ signedCommitTxHex: string;
173
+ revealTxId: string;
174
+ signedRevealTxHex: string;
175
+ inscriptionId: string;
176
+ postage: number;
177
+ secret: string;
178
+ sendToOpReturnTxId: string;
179
+ signedSendToOpReturnTxHex: string;
180
+ }>;
181
+ /**
182
+ * Deposits a BRC-20 token into the BRC2.0 programmable module by creating an inscription with the transfer operation and sending it to the OP_RETURN output. The function takes the token tick, amount, fee rate, and optional payment parameters, creates an inscription with the transfer operation, mints it, and then sends it to an OP_RETURN output with a specific format. It also allows for a dry run mode where the transaction hexes are returned without broadcasting.
183
+ *
184
+ * @param tick - The tick of the BRC-20 token to be deposited, represented as a string. This will be included in the inscription content to indicate which token is being transferred.
185
+ * @param amount - The amount of the BRC-20 token to be deposited, represented as a string. This will be included in the inscription content to indicate how many tokens are being transferred.
186
+ * @param feeRate - The fee rate in sats/vbyte to be used for the transactions involved in the deposit process.
187
+ * @param postage - An optional parameter representing the postage to be included in the minting transaction, specified in sats. If null, no postage will be included.
188
+ * @param paymentAddr - An optional parameter representing the Bitcoin address to which payment should be sent for the minting transaction. If null, no payment will be made.
189
+ * @param payment - An optional parameter representing the amount of payment to be sent for the minting transaction, specified in sats. If null or less than or equal to 0, no payment will be made.
190
+ * @param dryRun - A boolean flag indicating whether to perform a dry run. If true, the function will return the transaction hexes without broadcasting them to the network. If false, the transactions will be broadcasted after creation.
191
+ *
192
+ * @returns An object containing details of the deposit process, including transaction IDs, signed transaction hexes, inscription ID, postage, and secret used in the minting process. If dryRun is true, the transactions will not be broadcasted and the hexes will be returned for inspection.
193
+ */
194
+ export declare function depositToBrc20Prog(tick: string, amount: string, feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, dryRun: boolean): Promise<{
195
+ commitTxId: string;
196
+ signedCommitTxHex: string;
197
+ revealTxId: string;
198
+ signedRevealTxHex: string;
199
+ inscriptionId: string;
200
+ postage: number;
201
+ secret: string;
202
+ sendToOpReturnTxId: string;
203
+ signedSendToOpReturnTxHex: string;
204
+ }>;
205
+ /**
206
+ * Withdraws a BRC-20 token from the BRC2.0 programmable module by creating an inscription with the transfer operation and sending it to the target address. The function takes the token tick, amount, target address, fee rate, and optional payment parameters, creates an inscription with the transfer operation, mints it, and then sends it to the target address. It also allows for a dry run mode where the transaction hexes are returned without broadcasting.
207
+ *
208
+ * @param tick - The tick of the BRC-20 token to be withdrawn, represented as a string. This will be included in the inscription content to indicate which token is being transferred.
209
+ * @param amount - The amount of the BRC-20 token to be withdrawn, represented as a string. This will be included in the inscription content to indicate how many tokens are being transferred.
210
+ * @param targetAddr - The Bitcoin address to which the withdrawn BRC-20 tokens should be sent, represented as a string. This will be used as the destination for the inscription after minting.
211
+ * @param feeRate - The fee rate in sats/vbyte to be used for the transactions involved in the withdrawal process.
212
+ * @param postage - An optional parameter representing the postage to be included in the minting transaction, specified in sats. If null, no postage will be included.
213
+ * @param paymentAddr - An optional parameter representing the Bitcoin address to which payment should be sent for the minting transaction. If null, no payment will be made.
214
+ * @param payment - An optional parameter representing the amount of payment to be sent for the minting transaction, specified in sats. If null or less than or equal to 0, no payment will be made.
215
+ * @param dryRun - A boolean flag indicating whether to perform a dry run. If true, the function will return the transaction hexes without broadcasting them to the network. If false, the transactions will be broadcasted after creation.
216
+ *
217
+ * @returns An object containing details of the withdrawal process, including transaction IDs, signed transaction hexes, inscription ID, postage, and secret used in the minting process. If dryRun is true, the transactions will not be broadcasted and the hexes will be returned for inspection.
218
+ */
219
+ export declare function withdrawFromBrc20Prog(tick: string, amount: string, targetAddr: string, feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, dryRun: boolean): Promise<{
220
+ commitTxId: string;
221
+ signedCommitTxHex: string;
222
+ revealTxId: string;
223
+ signedRevealTxHex: string;
224
+ inscriptionId: string;
225
+ postage: number;
226
+ secret: string;
227
+ transferTxId: string;
228
+ signedTransferTxHex: string;
229
+ }>;
@@ -0,0 +1,15 @@
1
+ import { BISSession } from '../types/common';
2
+ /**
3
+ * Creates the modal instance without showing it.
4
+ */
5
+ export declare function init(): void;
6
+ /**
7
+ * Shows the connect modal and resolves with the selected wallet session.
8
+ *
9
+ * @returns A promise that resolves with the session when a wallet connects, or rejects on error.
10
+ */
11
+ export declare function connect(): Promise<BISSession>;
12
+ /**
13
+ * Disconnects the current wallet: hides the modal and clears the stored session.
14
+ */
15
+ export declare function disconnect(): void;
@@ -0,0 +1,212 @@
1
+ import * as bitcoinjs from 'bitcoinjs-lib';
2
+ export declare const txHexByIdCache: {
3
+ [txid: string]: any;
4
+ };
5
+ /**
6
+ * Creates an unsecured JWT token with the given payload.
7
+ *
8
+ * @param payload - The payload to include in the token.
9
+ * @returns The unsecured JWT token as a string.
10
+ */
11
+ export declare function createUnsecuredToken(payload: any): string;
12
+ /**
13
+ * Converts a base64-encoded string to a hexadecimal string.
14
+ * @param str The base64-encoded string to convert.
15
+ * @returns The hexadecimal representation of the input string.
16
+ */
17
+ export declare function base64ToHex(str: string): string;
18
+ /**
19
+ * Converts a hexadecimal string to a base64-encoded string.
20
+ *
21
+ * @param hexstring The hexadecimal string to convert.
22
+ * @returns The base64-encoded representation of the input hexadecimal string.
23
+ */
24
+ export declare function hexToBase64(hexstring: string): string;
25
+ /**
26
+ * Finalizes every input of a signed PSBT, skipping the given indexes. Throws if
27
+ * an input cannot be finalized, so an incompletely-finalized (invalid) PSBT is
28
+ * never extracted and broadcast.
29
+ *
30
+ * @param psbt The signed PSBT to finalize in place.
31
+ * @param noSignIdxes Input indexes to skip (intentionally left unfinalized).
32
+ */
33
+ export declare function finalizePsbtInputs(psbt: bitcoinjs.Psbt, noSignIdxes?: number[]): void;
34
+ /**
35
+ * Saves extra UTXOs that are currently being used in transactions but not yet confirmed on the blockchain.
36
+ *
37
+ * @param txHexes An array of transaction hex strings representing the transactions that are currently being processed.
38
+ * @param inscription An optional array containing inscription details, where the first element is the inscription ID and the second element is the satpoint.
39
+ */
40
+ export declare function saveExtraUtxos(txHexes: string[], inscription: string[] | null): void;
41
+ /**
42
+ * Retrieves the currently saved extra UTXOs that are being used in transactions but not yet confirmed on the blockchain.
43
+ */
44
+ export declare function clearExtraUtxos(): void;
45
+ /**
46
+ * Determines the type of a UTXO output based on its output script and the Bitcoin network parameters.
47
+ *
48
+ * @param output The output script of the UTXO to analyze.
49
+ * @param network The Bitcoin network parameters to use for interpreting the output script (e.g., mainnet, testnet).
50
+ * @returns A string representing the type of the UTXO output, such as 'pubkeyhash', 'scripthash', 'witness_v0_keyhash', 'witness_v0_scripthash', 'witness_v1_taproot', 'pubkey', 'anchor', 'witness_unknown', 'nulldata', 'multisig', or 'nonstandard'.
51
+ */
52
+ export declare function utxoOutputTypeFromOutputScript(output: any, network: any): 'pubkeyhash' | 'scripthash' | 'witness_v0_keyhash' | 'witness_v0_scripthash' | 'witness_v1_taproot' | 'pubkey' | 'anchor' | 'witness_unknown' | 'nulldata' | 'multisig' | 'nonstandard';
53
+ /**
54
+ * Converts a witness stack to a script witness format that can be used in Bitcoin transactions.
55
+ * @param witness An array representing the witness stack, where each element is a buffer or a string that can be converted to a buffer.
56
+ * @returns A buffer containing the script witness data that can be included in a Bitcoin transaction input.
57
+ */
58
+ export declare function witnessStackToScriptWitness(witness: any[]): any;
59
+ export interface APIUtxoInfo {
60
+ address: string;
61
+ amounts: number[] | null;
62
+ block_height: number | null;
63
+ inscription_ids: string[] | null;
64
+ rune_ids: string[] | null;
65
+ satpoints: string[] | null;
66
+ script: string;
67
+ script_type: 'pubkeyhash' | 'scripthash' | 'witness_v0_keyhash' | 'witness_v0_scripthash' | 'witness_v1_taproot' | 'pubkey' | 'anchor' | 'witness_unknown' | 'nulldata' | 'multisig' | 'nonstandard';
68
+ txfee: number | null;
69
+ txid: string;
70
+ utxo: string;
71
+ value: number;
72
+ vout: number;
73
+ vsize: number | null;
74
+ }
75
+ /**
76
+ * Fetches the UTXOs associated with a given address from the backend API and applies fixes to include any extra UTXOs that are currently in the process of being used in transactions but not yet confirmed on the blockchain.
77
+ *
78
+ * @param addr The address for which to fetch the UTXOs.
79
+ * @returns A promise that resolves to an array of UTXO information objects.
80
+ */
81
+ export declare function getCardinalUtxos(addr: string): Promise<APIUtxoInfo[]>;
82
+ /**
83
+ * This function gets the balance of a given address by fetching its UTXOs from the backend and summing
84
+ * their values. It also applies fixes to include any extra UTXOs that are currently in the process of
85
+ * being used in transactions but not yet confirmed on the blockchain.
86
+ *
87
+ * @param address The address for which to fetch the balance.
88
+ * @returns The total balance of the address in satoshis.
89
+ */
90
+ export declare function getCardinalBalance(address: string): Promise<number>;
91
+ export interface AllBalanceDetails {
92
+ confirmed_balance: number;
93
+ mempool_balance: number;
94
+ }
95
+ /**
96
+ * Fetches the balance details of a given address from the backend API, including both confirmed and mempool balances. It also applies fixes to include any extra UTXOs that are currently in the process of being used in transactions but not yet confirmed on the blockchain.
97
+ *
98
+ * @param addr The address for which to fetch the balance details.
99
+ * @returns A promise that resolves to an object containing the confirmed balance and mempool balance of the address in satoshis.
100
+ */
101
+ export declare function getAllBalanceDetails(addr: string): Promise<AllBalanceDetails>;
102
+ /**
103
+ * Represents the structure of UTXO information returned by the backend API for ordinal UTXOs. It includes details such as the address, amounts, block height, inscription IDs, rune IDs, satpoints, script, script type, transaction fee, transaction ID, UTXO identifier, value, vout index, and virtual size of the UTXO.
104
+ */
105
+ export interface APIOrdinalUtxoInfo {
106
+ address: string;
107
+ amounts: number[] | null;
108
+ block_height: number | null;
109
+ inscription_ids: string[];
110
+ rune_ids: string[] | null;
111
+ satpoints: string[];
112
+ script: string;
113
+ script_type: 'pubkeyhash' | 'scripthash' | 'witness_v0_keyhash' | 'witness_v0_scripthash' | 'witness_v1_taproot' | 'pubkey' | 'anchor' | 'witness_unknown' | 'nulldata' | 'multisig' | 'nonstandard';
114
+ txfee: number | null;
115
+ txid: string;
116
+ utxo: string;
117
+ value: number;
118
+ vout: number;
119
+ vsize: number | null;
120
+ }
121
+ /**
122
+ * Fetches the ordinal UTXOs associated with a given address from the backend API and applies fixes to include any extra UTXOs that are currently in the process of being used in transactions but not yet confirmed on the blockchain.
123
+ *
124
+ * @param addr The address for which to fetch the ordinal UTXOs.
125
+ *
126
+ * @returns A promise that resolves to an array of ordinal UTXO information objects.
127
+ */
128
+ export declare function getOrdinalUtxos(addr: string): Promise<APIOrdinalUtxoInfo[]>;
129
+ /**
130
+ * Fetches the raw transaction hex for a given transaction ID from the backend API. It caches the result to avoid redundant network requests.
131
+ *
132
+ * @param txid The transaction ID for which to fetch the raw transaction hex.
133
+ * @returns A promise that resolves to the raw transaction hex string.
134
+ */
135
+ export declare function getTxhex(txid: string): Promise<string>;
136
+ /**
137
+ * Validates a list of transaction hexes by sending them to the backend API for testing their acceptance into the mempool. The function combines the provided transaction hexes with any currently saved extra transaction hexes and sends them to the backend for validation.
138
+ *
139
+ * @param txHexes An array of transaction hex strings representing the transactions to be validated.
140
+ * @returns A promise that resolves to the validation result returned by the backend API, or null if the validation request fails.
141
+ */
142
+ export declare function validateTxes(txHexes: string[]): Promise<any>;
143
+ /**
144
+ * Broadcasts a list of transaction hexes to the network by sending them to the backend API. The function throws an error if there are any extra transaction hexes currently set, as broadcasting is not allowed in that state.
145
+ *
146
+ * @param txHexes An array of transaction hex strings representing the transactions to be broadcasted.
147
+ * @returns A promise that resolves to the result of the broadcast request returned by the backend API, or null if the broadcast request fails.
148
+ * @throws An error if there are extra transaction hexes currently set, as broadcasting is not allowed in that state.
149
+ */
150
+ export declare function broadcastTxes(txHexes: string[]): Promise<any>;
151
+ /**
152
+ * Verifies a signature for a given message, signature, and address by sending the verification request to the backend API. The function constructs the necessary parameters for the verification request, including converting the message to hexadecimal format and generating the pkscript from the provided address, and then sends the request to the backend for verification.
153
+ *
154
+ * @param message The message for which the signature needs to be verified.
155
+ * @param signatureHex The signature in hexadecimal format that needs to be verified against the message and address.
156
+ * @param address The Bitcoin address that is claimed to have produced the signature for the given message.
157
+ * @returns A promise that resolves to a boolean indicating whether the signature is valid for the given message and address, or throws an error if the verification process fails.
158
+ * @throws An error if the verification process fails, such as due to network issues or invalid input parameters.
159
+ */
160
+ export declare function verifySignature(message: string, signatureHex: string, address: string): Promise<boolean>;
161
+ /**
162
+ * Locally verifies a signature for a given message, signature, and address using the bip322-js library. The function converts the signature from hexadecimal to base64 format and then uses the Verifier class from the bip322-js library to perform the verification against the provided message and address.
163
+ *
164
+ * @param message The message for which the signature needs to be verified.
165
+ * @param signatureHex The signature in hexadecimal format that needs to be verified against the message and address.
166
+ * @param address The Bitcoin address that is claimed to have produced the signature for the given message.
167
+ * @returns A boolean indicating whether the signature is valid for the given message and address.
168
+ * @throws An error if the verification process fails, such as due to invalid input parameters.
169
+ */
170
+ export declare function verifySignatureLocal(message: string, signatureHex: string, address: string): boolean;
171
+ /**
172
+ * Fetches the current chain tip (the latest block height) from the backend API. The function sends a request to the backend to retrieve the current chain tip and returns it as a number. If the request fails, it throws an error indicating that the chain tip could not be retrieved.
173
+ *
174
+ * @returns A promise that resolves to the current chain tip (latest block height) as a number, or throws an error if the request fails.
175
+ * @throws An error if the request to fetch the chain tip fails, indicating that the chain tip could not be retrieved.
176
+ */
177
+ export declare function getChainTip(): Promise<number>;
178
+ /**
179
+ * A generic helper function to handle fetch requests with consistent error handling.
180
+ * It automatically checks for non-ok HTTP responses and for an 'error' field
181
+ * in the JSON response body, throwing a descriptive error in either case.
182
+ *
183
+ * @param url The URL to fetch.
184
+ * @param options The standard RequestInit options for the fetch call.
185
+ * @returns A promise that resolves with the parsed JSON data of type T.
186
+ * @throws {Error} Throws an error if the network request fails, the HTTP
187
+ * status is not ok, or the response body contains an error field.
188
+ */
189
+ export declare function fetchWithErrors<T>(url: string, options: RequestInit): Promise<T>;
190
+ /**
191
+ * Retrieves the appropriate BRC2.0 public RPC URL based on the current network (signet or mainnet). The function checks the current network using the getNetwork function and returns the corresponding public RPC URL for that network. If the network is not supported, it throws an error indicating that the network is unsupported for the public RPC URL.
192
+ *
193
+ * @returns The public RPC URL corresponding to the current network (signet or mainnet).
194
+ */
195
+ export declare function getPublicRpcUrl(): string;
196
+ /**
197
+ * Executes an eth_call on the appropriate public RPC URL based on the current network (signet or mainnet). The function constructs the JSON-RPC request payload with the provided data and sends it to the public RPC URL for execution. It returns a promise that resolves to the result of the eth_call, or throws an error if the request fails.
198
+ *
199
+ * @param to The address of the contract to call.
200
+ * @param abi The ABI of the contract to call.
201
+ * @param functionName The name of the function to call on the contract.
202
+ * @param params The parameters to pass to the function being called on the contract.
203
+ * @returns A promise that resolves to the result of the eth_call as a string, or throws an error if the request fails.
204
+ */
205
+ export declare function ethCallOnPublicRpc(to: string, abi: any, functionName: string, params: any): Promise<string>;
206
+ /**
207
+ * Constructs the appropriate backend URL for a given API path based on the current network (signet or mainnet). The function checks the current network using the getNetwork function and returns the corresponding URL for the swap backend API. If the network is not supported, it throws an error indicating that the network is unsupported for the orderbook backend URL.
208
+ *
209
+ * @param path The specific API path to append to the base URL for the swap backend.
210
+ * @returns The full URL for the swap backend API corresponding to the current network and the provided path.
211
+ */
212
+ export declare function getSwapBackendUrl(path: string): string;