@exodus/bitcoin-plugin 1.6.15 → 1.6.16

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.6.15",
3
+ "version": "1.6.16",
4
4
  "description": "Exodus bitcoin-plugin",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -29,5 +29,5 @@
29
29
  "devDependencies": {
30
30
  "@exodus/nfts-proxy": "^2.10.1"
31
31
  },
32
- "gitHead": "5b42d1ffc18052f588f3602e8737767a6f12449b"
32
+ "gitHead": "79ecc918b12dc473b5f293ee50dbf054756e1a55"
33
33
  }
@@ -2,6 +2,7 @@ import assert from 'minimalistic-assert'
2
2
  import { getInscriptionAddresses } from './get-inscription-addresses'
3
3
  import { isNftBrc20 } from './nft-utils'
4
4
  import { getOrdinalsUtxos } from '@exodus/bitcoin-api'
5
+ import { uniq } from 'lodash'
5
6
 
6
7
  export const nftsApiFactory = ({ ordinalChainIndex, asset }) => {
7
8
  assert(asset, 'asset is required')
@@ -47,31 +48,37 @@ export const nftsApiFactory = ({ ordinalChainIndex, asset }) => {
47
48
  const unconfirmedUtxosArray = storedOrdinalsUtxos
48
49
  .toArray()
49
50
  .filter((utxo) => !utxo.confirmations)
51
+
52
+ const inscriptionIds = unconfirmedUtxosArray.flatMap(({ inscriptions }) =>
53
+ inscriptions.map(({ inscriptionId }) => inscriptionId)
54
+ )
55
+ const uniqueInscriptionIds = uniq(inscriptionIds)
56
+
50
57
  try {
51
58
  const retrievedNfts = await Promise.all(
52
- unconfirmedUtxosArray.map(async (utxo) => {
53
- const inscriptions = utxo.inscriptions || []
54
- return Promise.all(
55
- inscriptions.map(async ({ inscriptionId }) => {
56
- if (nfts.find((nft) => nft.tokenId === inscriptionId)) {
57
- return undefined
58
- }
59
- try {
60
- const json = await nftsProxy.getNft(inscriptionId)
61
- return {
62
- ...json,
63
- receiving: true,
64
- output: `${utxo.txId}:${utxo.vout}`,
65
- pendingTxId: utxo.txId,
66
- }
67
- } catch (e) {
68
- console.warn(
69
- `Cannot load ${asset.name} nft ${inscriptionId} from proxy server. Error: ${e.message}`
70
- )
71
- return undefined
72
- }
73
- })
74
- )
59
+ uniqueInscriptionIds.map(async (inscriptionId) => {
60
+ if (nfts.find((nft) => nft.tokenId === inscriptionId)) {
61
+ return undefined
62
+ }
63
+ try {
64
+ const json = await nftsProxy.getNft(inscriptionId)
65
+ const utxo = unconfirmedUtxosArray.find((utxo) =>
66
+ utxo.inscriptions
67
+ .map(({ inscriptionId }) => inscriptionId)
68
+ .includes(inscriptionId)
69
+ )
70
+ return {
71
+ ...json,
72
+ receiving: true,
73
+ output: `${utxo.txId}:${utxo.vout}`,
74
+ pendingTxId: utxo.txId,
75
+ }
76
+ } catch (e) {
77
+ console.warn(
78
+ `Cannot load ${asset.name} nft ${inscriptionId} from proxy server. Error: ${e.message}`
79
+ )
80
+ return undefined
81
+ }
75
82
  })
76
83
  )
77
84
  const unconfirmedNfts = retrievedNfts.flat().filter((i) => i)