@exodus/bitcoin-plugin 1.16.3 → 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.3",
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": "8f0211c5cbdc7117872f2f910c9b31d7e4e106f0"
52
+ "gitHead": "2af27ab114d53d02eb1c324150a847e894cdcc20"
53
53
  }
@@ -343,7 +343,7 @@ export const createBitcoinAssetFactory =
343
343
  createToken,
344
344
  getTokens,
345
345
  validateAssetId,
346
- web3: createWeb3API({ prepareForSigning }),
346
+ web3: createWeb3API({ asset, prepareForSigning }),
347
347
  }
348
348
 
349
349
  const fullAsset = {
@@ -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,
@@ -4,7 +4,7 @@ import { Psbt } from '@exodus/bitcoinjs-lib'
4
4
  import assert from 'minimalistic-assert'
5
5
 
6
6
  // This function accepts either a list of transactions created by a wallet (unsignedTxs) or a web3 transaction (transactionBuffers).
7
- export const createSimulateTransactions = ({ prepareForSigning }) => {
7
+ export const createSimulateTransactions = ({ asset, prepareForSigning }) => {
8
8
  assert('prepareForSigning', '"prepareForSigning" should be passed')
9
9
 
10
10
  return function simulateTransaction({ transactionBuffers, unsignedTxs, ...restParameters }) {
@@ -29,7 +29,7 @@ export const createSimulateTransactions = ({ prepareForSigning }) => {
29
29
  assert(unsignedTxs.length === 1, 'Simulation for multiple transactions is not supported.')
30
30
 
31
31
  const unsignedTx = unsignedTxs[0]
32
- const psbtBase64 = prepareForSigning(unsignedTx).toBase64()
32
+ const psbtBase64 = prepareForSigning({ unsignedTx }).toBase64()
33
33
  const walletAddresses = Object.keys(unsignedTx.txMeta.addressPathsMap).reduce(
34
34
  (acc, current) => {
35
35
  acc[current] = true
@@ -49,6 +49,7 @@ export const createSimulateTransactions = ({ prepareForSigning }) => {
49
49
  }, {})
50
50
 
51
51
  return simulateTransactions({
52
+ asset,
52
53
  transactions: [psbtBase64],
53
54
  walletAddresses,
54
55
  indexToAddressRecord,