@exodus/bitcoin-api 2.4.0 → 2.4.1

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-api",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "description": "Exodus bitcoin-api",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -40,6 +40,5 @@
40
40
  "devDependencies": {
41
41
  "@exodus/bitcoin-meta": "^1.0.1",
42
42
  "jest-when": "^3.5.1"
43
- },
44
- "gitHead": "de21cbd727cb6cbe4fac07b58cc6e3fa8af318ff"
43
+ }
45
44
  }
@@ -31,7 +31,7 @@ export class GetFeeResolver {
31
31
  assert(!brc20, 'brc20 must not be provided when nft is provided!!!')
32
32
  }
33
33
  if (brc20) {
34
- assert(!amount, 'amount must not be provided when brc20 is provided!!!')
34
+ // assert(!amount, 'amount must not be provided when brc20 is provided!!!')
35
35
  assert(!isSendAll, 'isSendAll must not be provided when brc20 is provided!!!')
36
36
  assert(!nft, 'nft must not be provided when brc20 is provided!!!')
37
37
  }
@@ -43,7 +43,7 @@ export class GetFeeResolver {
43
43
  accountState,
44
44
  txSet,
45
45
  feeData,
46
- amount,
46
+ amount: brc20 ? undefined : amount,
47
47
  customFee,
48
48
  isSendAll,
49
49
  inscriptionIds,
@@ -132,7 +132,10 @@ export const createAndBroadcastTXFactory = ({
132
132
  getFeeEstimator,
133
133
  getSizeAndChangeScript = getSizeAndChangeScriptFactory(), // for decred customizations
134
134
  allowUnconfirmedRbfEnabledUtxos,
135
- }) => async ({ asset, walletAccount, address, amount, options }, { assetClientInterface }) => {
135
+ }) => async (
136
+ { asset: maybeToken, walletAccount, address, amount: tokenAmount, options },
137
+ { assetClientInterface }
138
+ ) => {
136
139
  const {
137
140
  multipleAddressesEnabled,
138
141
  feePerKB,
@@ -143,9 +146,21 @@ export const createAndBroadcastTXFactory = ({
143
146
  bumpTxId,
144
147
  isRbfAllowed = true,
145
148
  nft,
146
- brc20,
149
+ feeOpts,
147
150
  } = options
148
151
 
152
+ const brc20 = options.brc20 || feeOpts?.brc20 // feeOpts is the only way I've found atm to pass brc20 param without changing the tx-send hydra module
153
+
154
+ const asset = maybeToken.baseAsset
155
+
156
+ const isToken = maybeToken.name !== asset.name
157
+
158
+ if (isToken) {
159
+ assert(brc20, 'brc20 is required when sending bitcoin token')
160
+ }
161
+
162
+ const amount = isToken ? asset.currency.ZERO : tokenAmount
163
+
149
164
  const assetName = asset.name
150
165
 
151
166
  const accountState = await assetClientInterface.getAccountState({ assetName, walletAccount })
@@ -458,15 +473,21 @@ export const createAndBroadcastTXFactory = ({
458
473
  ? replaceTx.data.sent.concat([{ address: displayReceiveAddress, amount }])
459
474
  : [{ address: displayReceiveAddress, amount }]
460
475
 
476
+ const coinAmount = selfSend
477
+ ? maybeToken.currency.ZERO
478
+ : isToken
479
+ ? tokenAmount.abs().negate()
480
+ : totalAmount.abs().negate()
481
+
461
482
  await assetClientInterface.updateTxLogAndNotify({
462
- assetName,
483
+ assetName: maybeToken.name,
463
484
  walletAccount,
464
485
  txs: [
465
486
  {
466
487
  txId,
467
488
  confirmations: 0,
468
- coinAmount: selfSend ? currency.ZERO : totalAmount.abs().negate(),
469
- coinName: assetName,
489
+ coinAmount,
490
+ coinName: maybeToken.name,
470
491
  feeAmount: fee,
471
492
  feeCoinName: assetName,
472
493
  selfSend,