@dynamic-labs/bitcoin 2.2.0 → 2.2.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/CHANGELOG.md CHANGED
@@ -1,4 +1,12 @@
1
1
 
2
+ ### [2.2.1](https://github.com/dynamic-labs/DynamicAuth/compare/v2.2.0...v2.2.1) (2024-06-17)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * improve handling of bitcoin connected accounts ([#6049](https://github.com/dynamic-labs/DynamicAuth/issues/6049)) ([08cb8ba](https://github.com/dynamic-labs/DynamicAuth/commit/08cb8bae2b1521367234cbe2bb55a8c3766df3c1))
8
+ * improve wagmi hooks with embedded wallets ([#6044](https://github.com/dynamic-labs/DynamicAuth/issues/6044)) ([#6052](https://github.com/dynamic-labs/DynamicAuth/issues/6052)) ([28654e8](https://github.com/dynamic-labs/DynamicAuth/commit/28654e8a45b25c4fc3bb3abfa89b453808a55053))
9
+
2
10
  ## [2.2.0](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.5...v2.2.0) (2024-06-16)
3
11
 
4
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/bitcoin",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/dynamic-labs/dynamic-auth.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.2.0",
36
- "@dynamic-labs/wallet-book": "2.2.0",
37
- "@dynamic-labs/wallet-connector-core": "2.2.0",
35
+ "@dynamic-labs/utils": "2.2.1",
36
+ "@dynamic-labs/wallet-book": "2.2.1",
37
+ "@dynamic-labs/wallet-connector-core": "2.2.1",
38
38
  "stream": "0.0.2"
39
39
  },
40
40
  "peerDependencies": {}
@@ -6,7 +6,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
6
6
  var _tslib = require('../../../_virtual/_tslib.cjs');
7
7
  var bitcoinjsLib = require('bitcoinjs-lib');
8
8
  var satsConnect = require('sats-connect');
9
- var sdkApiCore = require('@dynamic-labs/sdk-api-core');
10
9
  var utils = require('@dynamic-labs/utils');
11
10
  var walletBook = require('@dynamic-labs/wallet-book');
12
11
  var _const = require('../../const.cjs');
@@ -21,14 +20,13 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector.BitcoinWalletCo
21
20
  constructor(opts) {
22
21
  super(opts);
23
22
  this.currentNetwork = satsConnect.BitcoinNetworkType.Mainnet;
24
- this.canFetchConnectedAccounts = true;
25
- // xverse does't support fetching connected accounts without prompting
26
- // for a connection, so we handle getConnectedAccounts differently
27
- this.canFetchConnectedAccounts = this.key !== 'xverse';
23
+ // satsconnect wallets don't support fetching connected accounts without prompting
24
+ // for a connection, so we handle getConnectedAccounts differently.
25
+ this.canFetchConnectedAccounts = false;
28
26
  }
29
27
  getAddress() {
30
28
  return _tslib.__awaiter(this, void 0, void 0, function* () {
31
- var _a, _b;
29
+ var _a;
32
30
  // xverse doesn't support wallet standard, so we won't have a wallet object,
33
31
  // but it's already the default provider for sats-connect, so it's ok
34
32
  // for getProvider in getAddress to return undefined
@@ -47,12 +45,6 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector.BitcoinWalletCo
47
45
  window.location.href = deepLink;
48
46
  return;
49
47
  }
50
- const cachedActiveAccount = yield this.cache.getActiveAccount();
51
- if (cachedActiveAccount) {
52
- const ordinalsAddress = cachedActiveAccount.additionalAddresses.find((address) => address.type === sdkApiCore.WalletAddressType.Ordinals);
53
- const paymentAddress = cachedActiveAccount.additionalAddresses.find((address) => address.type === sdkApiCore.WalletAddressType.Payment);
54
- return (_b = ordinalsAddress === null || ordinalsAddress === void 0 ? void 0 : ordinalsAddress.address) !== null && _b !== void 0 ? _b : paymentAddress === null || paymentAddress === void 0 ? void 0 : paymentAddress.address;
55
- }
56
48
  return new Promise((resolve, reject) => {
57
49
  satsConnect.getAddress({
58
50
  getProvider: () => _tslib.__awaiter(this, void 0, void 0, function* () {
@@ -2,7 +2,6 @@
2
2
  import { __awaiter } from '../../../_virtual/_tslib.js';
3
3
  import { Psbt } from 'bitcoinjs-lib';
4
4
  import { BitcoinNetworkType, getAddress, AddressPurpose, signMessage, sendBtcTransaction, signTransaction } from 'sats-connect';
5
- import { WalletAddressType } from '@dynamic-labs/sdk-api-core';
6
5
  import { isMobile, template } from '@dynamic-labs/utils';
7
6
  import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
8
7
  import { SATSCONNECT_FEATURE } from '../../const.js';
@@ -17,14 +16,13 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector {
17
16
  constructor(opts) {
18
17
  super(opts);
19
18
  this.currentNetwork = BitcoinNetworkType.Mainnet;
20
- this.canFetchConnectedAccounts = true;
21
- // xverse does't support fetching connected accounts without prompting
22
- // for a connection, so we handle getConnectedAccounts differently
23
- this.canFetchConnectedAccounts = this.key !== 'xverse';
19
+ // satsconnect wallets don't support fetching connected accounts without prompting
20
+ // for a connection, so we handle getConnectedAccounts differently.
21
+ this.canFetchConnectedAccounts = false;
24
22
  }
25
23
  getAddress() {
26
24
  return __awaiter(this, void 0, void 0, function* () {
27
- var _a, _b;
25
+ var _a;
28
26
  // xverse doesn't support wallet standard, so we won't have a wallet object,
29
27
  // but it's already the default provider for sats-connect, so it's ok
30
28
  // for getProvider in getAddress to return undefined
@@ -43,12 +41,6 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector {
43
41
  window.location.href = deepLink;
44
42
  return;
45
43
  }
46
- const cachedActiveAccount = yield this.cache.getActiveAccount();
47
- if (cachedActiveAccount) {
48
- const ordinalsAddress = cachedActiveAccount.additionalAddresses.find((address) => address.type === WalletAddressType.Ordinals);
49
- const paymentAddress = cachedActiveAccount.additionalAddresses.find((address) => address.type === WalletAddressType.Payment);
50
- return (_b = ordinalsAddress === null || ordinalsAddress === void 0 ? void 0 : ordinalsAddress.address) !== null && _b !== void 0 ? _b : paymentAddress === null || paymentAddress === void 0 ? void 0 : paymentAddress.address;
51
- }
52
44
  return new Promise((resolve, reject) => {
53
45
  getAddress({
54
46
  getProvider: () => __awaiter(this, void 0, void 0, function* () {
@@ -53,7 +53,10 @@ class BitcoinWalletConnector extends walletConnectorCore.WalletConnectorBase {
53
53
  }
54
54
  endSession() {
55
55
  return _tslib.__awaiter(this, void 0, void 0, function* () {
56
- yield this.cache.clearLastBalance();
56
+ yield Promise.all([
57
+ this.cache.clearConnectedAcccounts(),
58
+ this.cache.clearLastBalance(),
59
+ ]);
57
60
  });
58
61
  }
59
62
  getBalance() {
@@ -49,7 +49,10 @@ class BitcoinWalletConnector extends WalletConnectorBase {
49
49
  }
50
50
  endSession() {
51
51
  return __awaiter(this, void 0, void 0, function* () {
52
- yield this.cache.clearLastBalance();
52
+ yield Promise.all([
53
+ this.cache.clearConnectedAcccounts(),
54
+ this.cache.clearLastBalance(),
55
+ ]);
53
56
  });
54
57
  }
55
58
  getBalance() {
package/src/index.cjs CHANGED
@@ -9,7 +9,6 @@ require('sats-connect');
9
9
  require('bitcoinjs-lib');
10
10
  require('@dynamic-labs/wallet-connector-core');
11
11
  require('@dynamic-labs/utils');
12
- require('@dynamic-labs/sdk-api-core');
13
12
  require('@dynamic-labs/wallet-book');
14
13
  var fetchBtcKitConnectors = require('./utils/fetchBtcKitConnectors/fetchBtcKitConnectors.cjs');
15
14
  var fetchSatsConnectConnectors = require('./utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.cjs');
package/src/index.js CHANGED
@@ -5,7 +5,6 @@ import 'sats-connect';
5
5
  import 'bitcoinjs-lib';
6
6
  import '@dynamic-labs/wallet-connector-core';
7
7
  import '@dynamic-labs/utils';
8
- import '@dynamic-labs/sdk-api-core';
9
8
  import '@dynamic-labs/wallet-book';
10
9
  import { fetchBtcKitConnectors } from './utils/fetchBtcKitConnectors/fetchBtcKitConnectors.js';
11
10
  export { fetchBtcKitConnectors } from './utils/fetchBtcKitConnectors/fetchBtcKitConnectors.js';