@dynamic-labs/bitcoin 2.0.6 → 2.0.8

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/CHANGELOG.md CHANGED
@@ -1,4 +1,22 @@
1
1
 
2
+ ### [2.0.8](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.7...v2.0.8) (2024-05-27)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * allow leather to show up in wallet list even when not installed … ([#5626](https://github.com/dynamic-labs/DynamicAuth/issues/5626)) ([e757679](https://github.com/dynamic-labs/DynamicAuth/commit/e757679a05feee628392c7c9042080b53e743694))
8
+ * btc balance calculation ([#5740](https://github.com/dynamic-labs/DynamicAuth/issues/5740)) ([f8e01bb](https://github.com/dynamic-labs/DynamicAuth/commit/f8e01bb5d8d404f041797f10f27dfea1ddbfccdf)), closes [#5716](https://github.com/dynamic-labs/DynamicAuth/issues/5716)
9
+ * init ethers web3provider without a network if selected network is unsupported ([#5653](https://github.com/dynamic-labs/DynamicAuth/issues/5653)) ([91095c2](https://github.com/dynamic-labs/DynamicAuth/commit/91095c2aa45e57847e3852fbcde7fe926b2e581a))
10
+ * show phone number in use error message ([#5684](https://github.com/dynamic-labs/DynamicAuth/issues/5684)) ([add08e4](https://github.com/dynamic-labs/DynamicAuth/commit/add08e490749af4852efaddae83b43f227442756)), closes [#5681](https://github.com/dynamic-labs/DynamicAuth/issues/5681)
11
+ * use PromptModal when using the DynamicMultiWalletPromptsWidget f… ([#5628](https://github.com/dynamic-labs/DynamicAuth/issues/5628)) ([310a92c](https://github.com/dynamic-labs/DynamicAuth/commit/310a92cfe6386747b7327fa3853d970a75b996cd))
12
+
13
+ ### [2.0.7](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.6...v2.0.7) (2024-05-15)
14
+
15
+
16
+ ### Features
17
+
18
+ * add authFailure and authInit events ([#5461](https://github.com/dynamic-labs/DynamicAuth/issues/5461)) ([e02e1ad](https://github.com/dynamic-labs/DynamicAuth/commit/e02e1ad36b378e3b2c609fe5bfb2d37aa6a363e0))
19
+
2
20
  ### [2.0.6](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.5...v2.0.6) (2024-05-03)
3
21
 
4
22
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/bitcoin",
3
- "version": "2.0.6",
3
+ "version": "2.0.8",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -32,9 +32,9 @@
32
32
  "@wallet-standard/base": "1.0.1",
33
33
  "bitcoinjs-lib": "6.1.5",
34
34
  "sats-connect": "2.0.0",
35
- "@dynamic-labs/utils": "2.0.6",
36
- "@dynamic-labs/wallet-book": "2.0.6",
37
- "@dynamic-labs/wallet-connector-core": "2.0.6",
35
+ "@dynamic-labs/utils": "2.0.8",
36
+ "@dynamic-labs/wallet-book": "2.0.8",
37
+ "@dynamic-labs/wallet-connector-core": "2.0.8",
38
38
  "stream": "0.0.2"
39
39
  },
40
40
  "peerDependencies": {}
@@ -11,6 +11,7 @@ var bitcoinProviderHelper = require('./bitcoinProviderHelper.cjs');
11
11
  var BitcoinLocalStorageCache = require('./BitcoinLocalStorageCache.cjs');
12
12
  var getMempoolApiUrl = require('./utils/getMempoolApiUrl.cjs');
13
13
  var _const = require('./const.cjs');
14
+ var satoshisToBtc = require('./utils/satoshisToBtc/satoshisToBtc.cjs');
14
15
 
15
16
  class BitcoinWalletConnector extends walletConnectorCore.WalletConnectorBase {
16
17
  constructor(opts) {
@@ -67,12 +68,14 @@ class BitcoinWalletConnector extends walletConnectorCore.WalletConnectorBase {
67
68
  return undefined;
68
69
  }
69
70
  const addressInfo = yield response.json();
70
- if (!(addressInfo === null || addressInfo === void 0 ? void 0 : addressInfo.chain_stats)) {
71
+ if (!(addressInfo === null || addressInfo === void 0 ? void 0 : addressInfo.chain_stats) || !(addressInfo === null || addressInfo === void 0 ? void 0 : addressInfo.mempool_stats)) {
71
72
  return undefined;
72
73
  }
73
- const balance = (Number(addressInfo.chain_stats.funded_txo_sum) -
74
- Number(addressInfo.chain_stats.spent_txo_sum)) /
75
- 100000000;
74
+ const confirmedBalanceInSats = Number(addressInfo.chain_stats.funded_txo_sum) -
75
+ Number(addressInfo.chain_stats.spent_txo_sum);
76
+ const unconfirmedBalanceInSats = Number(addressInfo.mempool_stats.funded_txo_sum) -
77
+ Number(addressInfo.mempool_stats.spent_txo_sum);
78
+ const balance = satoshisToBtc.satoshisToBtc(confirmedBalanceInSats + unconfirmedBalanceInSats);
76
79
  yield this.cache.setLastBalance(balance.toString());
77
80
  return balance.toString();
78
81
  });
@@ -7,6 +7,7 @@ import { BitcoinProviderHelper } from './bitcoinProviderHelper.js';
7
7
  import { BitcoinLocalStorageCache } from './BitcoinLocalStorageCache.js';
8
8
  import { getMempoolApiUrl } from './utils/getMempoolApiUrl.js';
9
9
  import { HTTP_STATUS_TOO_MANY_REQUESTS, HTTP_STATUS_NOT_FOUND } from './const.js';
10
+ import { satoshisToBtc } from './utils/satoshisToBtc/satoshisToBtc.js';
10
11
 
11
12
  class BitcoinWalletConnector extends WalletConnectorBase {
12
13
  constructor(opts) {
@@ -63,12 +64,14 @@ class BitcoinWalletConnector extends WalletConnectorBase {
63
64
  return undefined;
64
65
  }
65
66
  const addressInfo = yield response.json();
66
- if (!(addressInfo === null || addressInfo === void 0 ? void 0 : addressInfo.chain_stats)) {
67
+ if (!(addressInfo === null || addressInfo === void 0 ? void 0 : addressInfo.chain_stats) || !(addressInfo === null || addressInfo === void 0 ? void 0 : addressInfo.mempool_stats)) {
67
68
  return undefined;
68
69
  }
69
- const balance = (Number(addressInfo.chain_stats.funded_txo_sum) -
70
- Number(addressInfo.chain_stats.spent_txo_sum)) /
71
- 100000000;
70
+ const confirmedBalanceInSats = Number(addressInfo.chain_stats.funded_txo_sum) -
71
+ Number(addressInfo.chain_stats.spent_txo_sum);
72
+ const unconfirmedBalanceInSats = Number(addressInfo.mempool_stats.funded_txo_sum) -
73
+ Number(addressInfo.mempool_stats.spent_txo_sum);
74
+ const balance = satoshisToBtc(confirmedBalanceInSats + unconfirmedBalanceInSats);
72
75
  yield this.cache.setLastBalance(balance.toString());
73
76
  return balance.toString();
74
77
  });
@@ -16,11 +16,9 @@ const fetchBtcKitConnectors = ({ walletBook, }) => {
16
16
  if (!((_b = injectedConfig === null || injectedConfig === void 0 ? void 0 : injectedConfig.windowLocations) === null || _b === void 0 ? void 0 : _b.length))
17
17
  return undefined;
18
18
  const providers = utils.getProvidersFromWindow(injectedConfig.windowLocations[0]);
19
- if (!providers.length)
20
- return undefined;
21
19
  return class extends BitcoinBtcKitConnector.BitcoinBtcKitConnector {
22
20
  constructor(props) {
23
- super(Object.assign(Object.assign({}, props), { overrideKey: key, walletData: wallet }), providers[0]);
21
+ super(Object.assign(Object.assign({}, props), { overrideKey: key, walletData: wallet }), providers === null || providers === void 0 ? void 0 : providers[0]);
24
22
  this.name = wallet.shortName || wallet.name;
25
23
  }
26
24
  };
@@ -12,11 +12,9 @@ const fetchBtcKitConnectors = ({ walletBook, }) => {
12
12
  if (!((_b = injectedConfig === null || injectedConfig === void 0 ? void 0 : injectedConfig.windowLocations) === null || _b === void 0 ? void 0 : _b.length))
13
13
  return undefined;
14
14
  const providers = getProvidersFromWindow(injectedConfig.windowLocations[0]);
15
- if (!providers.length)
16
- return undefined;
17
15
  return class extends BitcoinBtcKitConnector {
18
16
  constructor(props) {
19
- super(Object.assign(Object.assign({}, props), { overrideKey: key, walletData: wallet }), providers[0]);
17
+ super(Object.assign(Object.assign({}, props), { overrideKey: key, walletData: wallet }), providers === null || providers === void 0 ? void 0 : providers[0]);
20
18
  this.name = wallet.shortName || wallet.name;
21
19
  }
22
20
  };
@@ -0,0 +1 @@
1
+ export * from './satoshisToBtc';
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const satoshisToBtc = (satoshis) => satoshis / 100000000;
6
+
7
+ exports.satoshisToBtc = satoshisToBtc;
@@ -0,0 +1 @@
1
+ export declare const satoshisToBtc: (satoshis: number) => number;
@@ -0,0 +1,3 @@
1
+ const satoshisToBtc = (satoshis) => satoshis / 100000000;
2
+
3
+ export { satoshisToBtc };