@exodus/bitcoin-plugin 1.10.1 → 1.12.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 +3 -3
- package/src/create-asset.js +40 -23
- package/src/ordinals/nfts.js +2 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/bitcoin-plugin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.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.
|
|
25
|
+
"@exodus/bitcoin-api": "^2.12.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": "
|
|
51
|
+
"gitHead": "49a0b40b825c556ea08538c5cedf64754dd35369"
|
|
52
52
|
}
|
package/src/create-asset.js
CHANGED
|
@@ -20,6 +20,8 @@ import {
|
|
|
20
20
|
parseUnsignedTx,
|
|
21
21
|
signTxFactory,
|
|
22
22
|
signHardwareFactory,
|
|
23
|
+
signMessage,
|
|
24
|
+
getPrepareSendTransaction,
|
|
23
25
|
} from '@exodus/bitcoin-api'
|
|
24
26
|
import { bitcoinFeeDataFactory } from './fee-data'
|
|
25
27
|
import BitcoinFeeMonitor from './fee-monitor'
|
|
@@ -38,23 +40,28 @@ import { getDefaultAddressPath, getSupportedPurposes } from './compatibility-mod
|
|
|
38
40
|
const DEFAULT_TICKS_BETWEEN_BRC20_FETCHES = 30
|
|
39
41
|
|
|
40
42
|
export const createBitcoinAssetFactory =
|
|
41
|
-
({ asset, apiUrl: defaultApiUrl, coinInfoNetwork }) =>
|
|
42
|
-
(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
43
|
+
({ asset, apiUrl: defaultApiUrl, coinInfoNetwork, isTestnet = false }) =>
|
|
44
|
+
(
|
|
45
|
+
{
|
|
46
|
+
assetClientInterface,
|
|
47
|
+
overrideCallback = ({ asset }) => asset,
|
|
48
|
+
config: {
|
|
49
|
+
apiUrl: customApiUrl,
|
|
50
|
+
allowUnconfirmedRbfEnabledUtxos = false,
|
|
51
|
+
ordinalChainIndex = DEFAULT_ORDINAL_CHAIN_INDEX,
|
|
52
|
+
ordinalsEnabled = false,
|
|
53
|
+
brc20Enabled = false,
|
|
54
|
+
brc20Url = DEFAULT_BRC_20_URL,
|
|
55
|
+
brc20TickInterval = DEFAULT_TICKS_BETWEEN_BRC20_FETCHES,
|
|
56
|
+
gapLimit = 10,
|
|
57
|
+
refreshGapLimit = 25,
|
|
58
|
+
feeDataCustomValues,
|
|
59
|
+
utxosDescendingOrder = false,
|
|
60
|
+
} = Object.create(null),
|
|
61
|
+
} = Object.create(null)
|
|
62
|
+
) => {
|
|
57
63
|
const apiUrl = customApiUrl || defaultApiUrl
|
|
64
|
+
assert(assetClientInterface, 'assetClientInterface is required')
|
|
58
65
|
assert(asset, 'asset is required')
|
|
59
66
|
assert(typeof ordinalChainIndex === 'number', 'ordinalChainIndex must be a number')
|
|
60
67
|
assert(apiUrl, 'apiUrl is required')
|
|
@@ -124,6 +131,13 @@ export const createBitcoinAssetFactory =
|
|
|
124
131
|
? tickInscriptionIdIndexerFactory({ brc20Client })
|
|
125
132
|
: undefined
|
|
126
133
|
|
|
134
|
+
const baseGetPrepareSendTx = getPrepareSendTransaction({
|
|
135
|
+
getFeeEstimator,
|
|
136
|
+
allowUnconfirmedRbfEnabledUtxos,
|
|
137
|
+
ordinalsEnabled,
|
|
138
|
+
utxosDescendingOrder,
|
|
139
|
+
})
|
|
140
|
+
|
|
127
141
|
const baseSendTx = createAndBroadcastTXFactory({
|
|
128
142
|
getFeeEstimator,
|
|
129
143
|
allowUnconfirmedRbfEnabledUtxos,
|
|
@@ -147,12 +161,15 @@ export const createBitcoinAssetFactory =
|
|
|
147
161
|
sendTx: baseSendTx,
|
|
148
162
|
tickInscriptionIdIndexer,
|
|
149
163
|
})
|
|
150
|
-
: {
|
|
164
|
+
: {
|
|
165
|
+
...baseFeeResolver,
|
|
166
|
+
getBalances: baseGetBalances,
|
|
167
|
+
sendTx: baseSendTx,
|
|
168
|
+
}
|
|
151
169
|
|
|
152
170
|
const signTx = signTxFactory({
|
|
153
171
|
assetName: asset.name,
|
|
154
172
|
resolvePurpose: address.resolvePurpose,
|
|
155
|
-
keys,
|
|
156
173
|
coinInfo,
|
|
157
174
|
})
|
|
158
175
|
|
|
@@ -178,7 +195,9 @@ export const createBitcoinAssetFactory =
|
|
|
178
195
|
|
|
179
196
|
const accountStateClass = createAccountState({ asset, ordinalsEnabled, brc20Enabled })
|
|
180
197
|
|
|
181
|
-
const nfts = ordinalsEnabled
|
|
198
|
+
const nfts = ordinalsEnabled
|
|
199
|
+
? nftsApiFactory({ ordinalChainIndex, asset, assetClientInterface })
|
|
200
|
+
: undefined
|
|
182
201
|
|
|
183
202
|
const { createToken, getTokens, validateAssetId } = brc20Enabled
|
|
184
203
|
? createTokenFactory({ address, bip44, keys, getBalances }, [])
|
|
@@ -195,9 +214,6 @@ export const createBitcoinAssetFactory =
|
|
|
195
214
|
...args,
|
|
196
215
|
})
|
|
197
216
|
const assetClientInterface = args.assetClientInterface
|
|
198
|
-
if (ordinalsEnabled) {
|
|
199
|
-
nfts.initialize({ assetClientInterface })
|
|
200
|
-
}
|
|
201
217
|
|
|
202
218
|
if (brc20Enabled) {
|
|
203
219
|
monitor.addHook('after-tick', async ({ walletAccount }) => {
|
|
@@ -300,11 +316,11 @@ export const createBitcoinAssetFactory =
|
|
|
300
316
|
hasFeature: (feature) => !!features[feature], // @deprecated use api.features instead
|
|
301
317
|
createAccountState: () => accountStateClass,
|
|
302
318
|
parseUnsignedTx,
|
|
303
|
-
parseTx: ({ unsignedTx }) => parseUnsignedTx(unsignedTx),
|
|
304
319
|
signUnsignedTx: (unsignedTx, privateKey, opts) => signTx({ unsignedTx, privateKey, ...opts }), // legacy
|
|
305
320
|
sendTx,
|
|
306
321
|
signTx,
|
|
307
322
|
signHardware,
|
|
323
|
+
signMessage,
|
|
308
324
|
getFee,
|
|
309
325
|
moveFunds,
|
|
310
326
|
nfts,
|
|
@@ -328,6 +344,7 @@ export const createBitcoinAssetFactory =
|
|
|
328
344
|
getAvailableBalance,
|
|
329
345
|
getSpendableBalance,
|
|
330
346
|
inscriptions: inscriptionsService,
|
|
347
|
+
prepareSendTx: baseGetPrepareSendTx,
|
|
331
348
|
}
|
|
332
349
|
return overrideCallback({ asset: fullAsset })
|
|
333
350
|
}
|
package/src/ordinals/nfts.js
CHANGED
|
@@ -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
|
|