@exodus/bitcoin-plugin 1.16.4 → 1.16.5

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.16.4",
3
+ "version": "1.16.5",
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.14.0",
25
+ "@exodus/bitcoin-api": "^2.14.1",
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",
@@ -49,5 +49,5 @@
49
49
  "@scure/btc-signer": "^1.1.0",
50
50
  "jest-when": "^3.5.1"
51
51
  },
52
- "gitHead": "b78e98b2a63dfce6b64b45869cba86fb36022a5e"
52
+ "gitHead": "2af27ab114d53d02eb1c324150a847e894cdcc20"
53
53
  }
@@ -2,6 +2,8 @@ import assert from 'minimalistic-assert'
2
2
  import { BumpType } from '@exodus/bitcoin-lib'
3
3
  import { brc20Utils } from './brc-20-utils'
4
4
  import { createBrc20Command } from './create-brc-20-command'
5
+ import { Address, UtxoCollection } from '@exodus/models'
6
+ import { getOrdinalsUtxos } from '@exodus/bitcoin-api'
5
7
 
6
8
  export const brc20BalancesAndFeeAdapterFactory = ({
7
9
  assetClientInterface,
@@ -26,13 +28,13 @@ export const brc20BalancesAndFeeAdapterFactory = ({
26
28
  const { isToken, getTokenBalance } = brc20Utils
27
29
 
28
30
  const isInscription = ({ options }) => {
29
- return !options.feeOpts.inscriptionIds?.length
31
+ return !options?.feeOpts?.inscriptionIds?.length
30
32
  }
31
33
 
32
34
  const sendBrc20 = async ({ asset: token, walletAccount, address, amount, options }) => {
33
35
  const { broadcastInscription, createBrc20Inscription } = inscriptionsService
34
36
 
35
- const { customFee, isSendAll } = options
37
+ const { customFee, isSendAll } = options || {}
36
38
 
37
39
  const asset = token.baseAsset
38
40
  const accountState = await assetClientInterface.getAccountState({
@@ -120,6 +122,7 @@ export const brc20BalancesAndFeeAdapterFactory = ({
120
122
 
121
123
  const newInscriptionFees = []
122
124
 
125
+ let index = 0
123
126
  for (const newInscription of newInscriptions) {
124
127
  const inscription = createBrc20Inscription({
125
128
  op: 'transfer',
@@ -136,12 +139,35 @@ export const brc20BalancesAndFeeAdapterFactory = ({
136
139
  feeData,
137
140
  })
138
141
  newInscriptionFees.push(newInscriptionFee)
139
- inscriptionIds.push(`new_inscription`) // this is just to count how many utxos needs to be send in the last txs
142
+ const inscriptionId = `new_inscription_${index++}`
143
+ newInscription.inscriptionId = inscriptionId
144
+ inscriptionIds.push(inscriptionId) // this is just to count how many utxos needs to be send in the last txs
140
145
  }
141
146
 
147
+ const ordinalsUtxos = getOrdinalsUtxos({ accountState, asset })
148
+
149
+ const mockedOrdinalsUtxos = ordinalsUtxos.union(
150
+ UtxoCollection.fromArray(
151
+ newInscriptions.map(({ address, inscriptionId }, index) => {
152
+ return {
153
+ address: Address.create(address),
154
+ txId: inscriptionId,
155
+ confirmations: 1,
156
+ value: '600 satoshis',
157
+ vout: 0,
158
+ script: '5120d96a4516786abc536ac4445887262770134f2ab139012856c1f3fdd13c1b02ac', // dummy taproot script
159
+ inscriptions: [{ inscriptionId, offset: 0 }],
160
+ }
161
+ }),
162
+ { currency: asset.currency }
163
+ )
164
+ )
142
165
  const { fee: lastSendingFee } = getFee({
143
166
  asset,
144
- accountState,
167
+ accountState: {
168
+ ...accountState,
169
+ ordinalsUtxos: mockedOrdinalsUtxos,
170
+ },
145
171
  txSet,
146
172
  feeData,
147
173
  amount: asset.currency.ZERO,