@exodus/bitcoin-api 2.13.0 → 2.14.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.13.0",
3
+ "version": "2.14.1",
4
4
  "description": "Exodus bitcoin-api",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -57,5 +57,5 @@
57
57
  "jest-when": "^3.5.1",
58
58
  "safe-buffer": "^5.2.1"
59
59
  },
60
- "gitHead": "9d296fc0875749545bc95b2a976e93739d63553b"
60
+ "gitHead": "2af27ab114d53d02eb1c324150a847e894cdcc20"
61
61
  }
@@ -14,8 +14,13 @@ const getTextFromResponse = async (response) => {
14
14
  }
15
15
  }
16
16
 
17
- const fetchJson = async (url, fetchOptions) => {
17
+ const fetchJson = async (url, fetchOptions, nullWhen404) => {
18
18
  const response = await fetch(url, fetchOptions)
19
+
20
+ if (nullWhen404 && response.status === 404) {
21
+ return null
22
+ }
23
+
19
24
  if (!response.ok)
20
25
  throw new Error(
21
26
  `${url} returned ${response.status}: ${
@@ -93,19 +98,13 @@ export default class InsightAPIClient {
93
98
  async fetchTx(txId) {
94
99
  const encodedTxId = encodeURIComponent(txId)
95
100
  const url = urlJoin(this._baseURL, `/tx/${encodedTxId}`)
96
- const response = await fetch(url)
97
-
98
- if (response.status === 404) return null
99
- return response.json()
101
+ return fetchJson(url, undefined, true)
100
102
  }
101
103
 
102
104
  async fetchTxObject(txId) {
103
105
  const url = urlJoin(this._baseURL, `/fulltx?${new URLSearchParams({ hash: txId })}`)
104
- const response = await fetch(url)
105
-
106
- if (response.status === 404) return null
107
- const object = await response.json()
108
- if (isEmpty(object)) {
106
+ const object = await fetchJson(url, undefined, true)
107
+ if (!object || isEmpty(object)) {
109
108
  return null
110
109
  }
111
110
 
@@ -1,3 +1,4 @@
1
1
  export { signTxFactory } from './default-create-tx'
2
2
  export { serializeTx } from './common'
3
3
  export { signHardwareFactory } from './default-sign-hardware'
4
+ export { createPrepareForSigning } from './default-prepare-for-signing'