@exodus/bitcoin-plugin 1.16.0 → 1.16.2

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.0",
3
+ "version": "1.16.2",
4
4
  "description": "Exodus bitcoin-plugin",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -49,5 +49,5 @@
49
49
  "@scure/btc-signer": "^1.1.0",
50
50
  "jest-when": "^3.5.1"
51
51
  },
52
- "gitHead": "e5132a9674de7cc87a4392e18007c77dc7532894"
52
+ "gitHead": "0f08592c1cf03d33312f0fca501187dc21ea1b45"
53
53
  }
@@ -21,7 +21,7 @@ export const getSupportedPurposes = ({ compatibilityMode, isMultisig, walletAcco
21
21
  }
22
22
 
23
23
  if (walletAccount?.source === WalletAccount.TREZOR_SRC || compatibilityMode === trezor) {
24
- return [84, 49, 44]
24
+ return [84, 49]
25
25
  }
26
26
 
27
27
  if (compatibilityMode === ledger) {
@@ -1,26 +1,34 @@
1
- import { createSimulateTransactions } from '@exodus/web3-bitcoin-utils'
1
+ import { createSimulateTransactions as createSimulateBitcoinTransactions } from '@exodus/web3-bitcoin-utils'
2
2
  import { Psbt } from '@exodus/bitcoinjs-lib'
3
3
 
4
4
  import assert from 'minimalistic-assert'
5
5
 
6
- // This function accepts either a transaction created by a wallet (unsignedTx) or a web3 transaction (transactionBuffer).
7
- export const createSimulateTransaction = ({ prepareForSigning }) => {
6
+ // This function accepts either a list of transactions created by a wallet (unsignedTxs) or a web3 transaction (transactionBuffers).
7
+ export const createSimulateTransactions = ({ prepareForSigning }) => {
8
8
  assert('prepareForSigning', '"prepareForSigning" should be passed')
9
9
 
10
- return function simulateTransaction({ transactionBuffer, unsignedTx, ...restParameters }) {
11
- if (transactionBuffer && unsignedTx) {
10
+ return function simulateTransaction({ transactionBuffers, unsignedTxs, ...restParameters }) {
11
+ if (transactionBuffers && unsignedTxs) {
12
12
  throw new Error('Can not supply both "transactionBuffer" and "unsignedTx".')
13
13
  }
14
14
 
15
- const simulateTransaction = createSimulateTransactions()
15
+ const simulateTransactions = createSimulateBitcoinTransactions()
16
16
 
17
- if (transactionBuffer) {
18
- const psbtBase64 = Psbt.fromBuffer(transactionBuffer).toBase64()
17
+ if (transactionBuffers) {
18
+ assert(
19
+ transactionBuffers.length === 1,
20
+ 'Simulation for multiple transactions is not supported.'
21
+ )
22
+
23
+ const psbtBase64 = Psbt.fromBuffer(transactionBuffers[0]).toBase64()
19
24
 
20
- return simulateTransaction({ transactions: [psbtBase64], ...restParameters })
25
+ return simulateTransactions({ transactions: [psbtBase64], ...restParameters })
21
26
  }
22
27
 
23
- if (unsignedTx) {
28
+ if (unsignedTxs) {
29
+ assert(unsignedTxs.length === 1, 'Simulation for multiple transactions is not supported.')
30
+
31
+ const unsignedTx = unsignedTxs[0]
24
32
  const psbtBase64 = prepareForSigning(unsignedTx).toBase64()
25
33
  const walletAddresses = Object.keys(unsignedTx.txMeta.addressPathsMap).reduce(
26
34
  (acc, current) => {
@@ -40,7 +48,7 @@ export const createSimulateTransaction = ({ prepareForSigning }) => {
40
48
  return acc
41
49
  }, {})
42
50
 
43
- return simulateTransaction({
51
+ return simulateTransactions({
44
52
  transactions: [psbtBase64],
45
53
  walletAddresses,
46
54
  indexToAddressRecord,
package/src/web3/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { createSimulateTransaction } from './createSimulateTransaction'
1
+ import { createSimulateTransactions } from './createSimulateTransaction'
2
2
 
3
3
  export const createWeb3API = (deps) => {
4
4
  return {
5
- simulateTransaction: createSimulateTransaction(deps),
5
+ simulateTransactions: createSimulateTransactions(deps),
6
6
  }
7
7
  }