@exodus/bitcoin-plugin 1.10.1 → 1.11.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/bitcoin-plugin",
3
- "version": "1.10.1",
3
+ "version": "1.11.0",
4
4
  "description": "Exodus bitcoin-plugin",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -22,7 +22,7 @@
22
22
  "@exodus/basic-utils": "^2.1.0",
23
23
  "@exodus/bip32": "^1.1.2",
24
24
  "@exodus/bip44-constants": "^195.0.0",
25
- "@exodus/bitcoin-api": "^2.10.1",
25
+ "@exodus/bitcoin-api": "^2.11.0",
26
26
  "@exodus/bitcoin-lib": "^2.3.0",
27
27
  "@exodus/bitcoin-meta": "^1.0.2",
28
28
  "@exodus/bitcoinjs-lib": "^6.1.5-exodus.1",
@@ -48,5 +48,5 @@
48
48
  "@scure/btc-signer": "^1.1.0",
49
49
  "jest-when": "^3.5.1"
50
50
  },
51
- "gitHead": "59489f1962adac06d14642120d7fe97e2a4f6d43"
51
+ "gitHead": "58f3aa71419faa3d2680bfbd65659cc9fcc5d223"
52
52
  }
@@ -20,6 +20,7 @@ import {
20
20
  parseUnsignedTx,
21
21
  signTxFactory,
22
22
  signHardwareFactory,
23
+ getPrepareSendTransaction,
23
24
  } from '@exodus/bitcoin-api'
24
25
  import { bitcoinFeeDataFactory } from './fee-data'
25
26
  import BitcoinFeeMonitor from './fee-monitor'
@@ -38,23 +39,28 @@ import { getDefaultAddressPath, getSupportedPurposes } from './compatibility-mod
38
39
  const DEFAULT_TICKS_BETWEEN_BRC20_FETCHES = 30
39
40
 
40
41
  export const createBitcoinAssetFactory =
41
- ({ asset, apiUrl: defaultApiUrl, coinInfoNetwork }) =>
42
- ({
43
- apiUrl: customApiUrl,
44
- allowUnconfirmedRbfEnabledUtxos = false,
45
- ordinalChainIndex = DEFAULT_ORDINAL_CHAIN_INDEX,
46
- ordinalsEnabled = false,
47
- brc20Enabled = false,
48
- brc20Url = DEFAULT_BRC_20_URL,
49
- brc20TickInterval = DEFAULT_TICKS_BETWEEN_BRC20_FETCHES,
50
- gapLimit = 10,
51
- refreshGapLimit = 25,
52
- overrideCallback = ({ asset }) => asset,
53
- feeDataCustomValues,
54
- isTestnet = false,
55
- utxosDescendingOrder = false,
56
- } = {}) => {
42
+ ({ asset, apiUrl: defaultApiUrl, coinInfoNetwork, isTestnet = false }) =>
43
+ (
44
+ {
45
+ assetClientInterface,
46
+ overrideCallback = ({ asset }) => asset,
47
+ config: {
48
+ apiUrl: customApiUrl,
49
+ allowUnconfirmedRbfEnabledUtxos = false,
50
+ ordinalChainIndex = DEFAULT_ORDINAL_CHAIN_INDEX,
51
+ ordinalsEnabled = false,
52
+ brc20Enabled = false,
53
+ brc20Url = DEFAULT_BRC_20_URL,
54
+ brc20TickInterval = DEFAULT_TICKS_BETWEEN_BRC20_FETCHES,
55
+ gapLimit = 10,
56
+ refreshGapLimit = 25,
57
+ feeDataCustomValues,
58
+ utxosDescendingOrder = false,
59
+ } = Object.create(null),
60
+ } = Object.create(null)
61
+ ) => {
57
62
  const apiUrl = customApiUrl || defaultApiUrl
63
+ assert(assetClientInterface, 'assetClientInterface is required')
58
64
  assert(asset, 'asset is required')
59
65
  assert(typeof ordinalChainIndex === 'number', 'ordinalChainIndex must be a number')
60
66
  assert(apiUrl, 'apiUrl is required')
@@ -124,6 +130,13 @@ export const createBitcoinAssetFactory =
124
130
  ? tickInscriptionIdIndexerFactory({ brc20Client })
125
131
  : undefined
126
132
 
133
+ const baseGetPrepareSendTx = getPrepareSendTransaction({
134
+ getFeeEstimator,
135
+ allowUnconfirmedRbfEnabledUtxos,
136
+ ordinalsEnabled,
137
+ utxosDescendingOrder,
138
+ })
139
+
127
140
  const baseSendTx = createAndBroadcastTXFactory({
128
141
  getFeeEstimator,
129
142
  allowUnconfirmedRbfEnabledUtxos,
@@ -147,12 +160,15 @@ export const createBitcoinAssetFactory =
147
160
  sendTx: baseSendTx,
148
161
  tickInscriptionIdIndexer,
149
162
  })
150
- : { ...baseFeeResolver, getBalances: baseGetBalances, sendTx: baseSendTx }
163
+ : {
164
+ ...baseFeeResolver,
165
+ getBalances: baseGetBalances,
166
+ sendTx: baseSendTx,
167
+ }
151
168
 
152
169
  const signTx = signTxFactory({
153
170
  assetName: asset.name,
154
171
  resolvePurpose: address.resolvePurpose,
155
- keys,
156
172
  coinInfo,
157
173
  })
158
174
 
@@ -178,7 +194,9 @@ export const createBitcoinAssetFactory =
178
194
 
179
195
  const accountStateClass = createAccountState({ asset, ordinalsEnabled, brc20Enabled })
180
196
 
181
- const nfts = ordinalsEnabled ? nftsApiFactory({ ordinalChainIndex, asset }) : undefined
197
+ const nfts = ordinalsEnabled
198
+ ? nftsApiFactory({ ordinalChainIndex, asset, assetClientInterface })
199
+ : undefined
182
200
 
183
201
  const { createToken, getTokens, validateAssetId } = brc20Enabled
184
202
  ? createTokenFactory({ address, bip44, keys, getBalances }, [])
@@ -195,9 +213,6 @@ export const createBitcoinAssetFactory =
195
213
  ...args,
196
214
  })
197
215
  const assetClientInterface = args.assetClientInterface
198
- if (ordinalsEnabled) {
199
- nfts.initialize({ assetClientInterface })
200
- }
201
216
 
202
217
  if (brc20Enabled) {
203
218
  monitor.addHook('after-tick', async ({ walletAccount }) => {
@@ -300,7 +315,6 @@ export const createBitcoinAssetFactory =
300
315
  hasFeature: (feature) => !!features[feature], // @deprecated use api.features instead
301
316
  createAccountState: () => accountStateClass,
302
317
  parseUnsignedTx,
303
- parseTx: ({ unsignedTx }) => parseUnsignedTx(unsignedTx),
304
318
  signUnsignedTx: (unsignedTx, privateKey, opts) => signTx({ unsignedTx, privateKey, ...opts }), // legacy
305
319
  sendTx,
306
320
  signTx,
@@ -328,6 +342,7 @@ export const createBitcoinAssetFactory =
328
342
  getAvailableBalance,
329
343
  getSpendableBalance,
330
344
  inscriptions: inscriptionsService,
345
+ prepareSendTx: baseGetPrepareSendTx,
331
346
  }
332
347
  return overrideCallback({ asset: fullAsset })
333
348
  }
@@ -4,10 +4,10 @@ import { isNftBrc20 } from './nft-utils'
4
4
  import { getOrdinalAddress, getOrdinalsUtxos, getUtxos, partitionUtxos } from '@exodus/bitcoin-api'
5
5
  import { uniq, isEqual } from 'lodash'
6
6
 
7
- export const nftsApiFactory = ({ ordinalChainIndex, asset }) => {
7
+ export const nftsApiFactory = ({ ordinalChainIndex, asset, assetClientInterface: aci }) => {
8
8
  assert(asset, 'asset is required')
9
+ assert(aci, 'aci is required')
9
10
  assert(typeof ordinalChainIndex === 'number', 'ordinalChainIndex must be a number')
10
- let aci // convert to constructor argument when wallet send aci at createAsset time
11
11
 
12
12
  const processAdditionalInscriptions = async function ({ walletAccount, nfts }) {
13
13
  const ordinalAddress = await getOrdinalAddress({
@@ -65,17 +65,8 @@ export const nftsApiFactory = ({ ordinalChainIndex, asset }) => {
65
65
  }
66
66
 
67
67
  return {
68
- initialize: ({ assetClientInterface }) => {
69
- aci = assetClientInterface
70
- },
71
-
72
68
  // this extension returns all possible addresses that may contain nfts
73
69
  getNftsAddresses: async ({ walletAccount: walletAccountInstance }) => {
74
- if (!aci) {
75
- console.warn('bitcoin nfts not initialized yet')
76
- return []
77
- }
78
-
79
70
  return getInscriptionAddresses({
80
71
  assetClientInterface: aci,
81
72
  walletAccount: walletAccountInstance.toString(),
@@ -89,11 +80,6 @@ export const nftsApiFactory = ({ ordinalChainIndex, asset }) => {
89
80
  It removes nfts that have brc20 content
90
81
  */
91
82
  postProcessNfts: async ({ nfts, walletAccount: walletAccountInstance, nftsProxy }) => {
92
- if (!aci) {
93
- console.warn('bitcoin nfts not initialized yet')
94
- return []
95
- }
96
-
97
83
  const walletAccount = walletAccountInstance.toString()
98
84
 
99
85
  const storedOrdinalsUtxos = await processAdditionalInscriptions({
@@ -189,7 +175,6 @@ export const nftsApiFactory = ({ ordinalChainIndex, asset }) => {
189
175
  mustAvoidUtxoIds: newMustAvoidUtxoIds,
190
176
  prune = false,
191
177
  }) => {
192
- assert(aci, 'bitcoin nfts not initialized yet')
193
178
  assert(walletAccountInstance, 'walletAccount is required')
194
179
  assert(newMustAvoidUtxoIds, 'mustAvoidUtxoIds is required')
195
180