@dynamic-labs/bitcoin 2.2.0-alpha.2 → 2.2.0-alpha.4

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,24 @@
1
1
 
2
+ ## [2.2.0-alpha.4](https://github.com/dynamic-labs/DynamicAuth/compare/v2.2.0-alpha.3...v2.2.0-alpha.4) (2024-06-06)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * btc getBalance should use ordinal address if payment not available ([#5882](https://github.com/dynamic-labs/DynamicAuth/issues/5882)) ([803a055](https://github.com/dynamic-labs/DynamicAuth/commit/803a05518ae9d2353d50f51b29047dff01136710))
8
+ * connect prompt when switching to xverse ([#5888](https://github.com/dynamic-labs/DynamicAuth/issues/5888)) ([181a7c4](https://github.com/dynamic-labs/DynamicAuth/commit/181a7c4af8217dab7ed2776d56ec2e3725a0ee6a))
9
+
10
+ ## [2.2.0-alpha.3](https://github.com/dynamic-labs/DynamicAuth/compare/v2.2.0-alpha.2...v2.2.0-alpha.3) (2024-06-05)
11
+
12
+
13
+ ### Features
14
+
15
+ * farcaster linking ([#5869](https://github.com/dynamic-labs/DynamicAuth/issues/5869)) ([191d1d2](https://github.com/dynamic-labs/DynamicAuth/commit/191d1d29e436e7d453d533c9c330ac5cef2e2a1c))
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * phone number in kyc step ([#5875](https://github.com/dynamic-labs/DynamicAuth/issues/5875)) ([d73f3b1](https://github.com/dynamic-labs/DynamicAuth/commit/d73f3b158e794727e7bed5d558a43d937951ce56))
21
+
2
22
  ## [2.2.0-alpha.2](https://github.com/dynamic-labs/DynamicAuth/compare/v2.2.0-alpha.1...v2.2.0-alpha.2) (2024-06-05)
3
23
 
4
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/bitcoin",
3
- "version": "2.2.0-alpha.2",
3
+ "version": "2.2.0-alpha.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
@@ -27,14 +27,14 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@btckit/types": "0.0.19",
30
- "@dynamic-labs/sdk-api-core": "0.0.453",
30
+ "@dynamic-labs/sdk-api-core": "0.0.460",
31
31
  "@wallet-standard/app": "1.0.1",
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-alpha.2",
36
- "@dynamic-labs/wallet-book": "2.2.0-alpha.2",
37
- "@dynamic-labs/wallet-connector-core": "2.2.0-alpha.2",
35
+ "@dynamic-labs/utils": "2.2.0-alpha.4",
36
+ "@dynamic-labs/wallet-book": "2.2.0-alpha.4",
37
+ "@dynamic-labs/wallet-connector-core": "2.2.0-alpha.4",
38
38
  "stream": "0.0.2"
39
39
  },
40
40
  "peerDependencies": {}
@@ -4,12 +4,13 @@
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var _tslib = require('../../../_virtual/_tslib.cjs');
7
- var satsConnect = require('sats-connect');
8
7
  var bitcoinjsLib = require('bitcoinjs-lib');
9
- var BitcoinWalletConnector = require('../BitcoinWalletConnector.cjs');
8
+ var satsConnect = require('sats-connect');
9
+ var sdkApiCore = require('@dynamic-labs/sdk-api-core');
10
10
  var _const = require('../../const.cjs');
11
11
  require('@dynamic-labs/utils');
12
12
  require('@dynamic-labs/wallet-connector-core');
13
+ var BitcoinWalletConnector = require('../BitcoinWalletConnector.cjs');
13
14
  var validatePsbt = require('../../utils/psbt/validator/validatePsbt.cjs');
14
15
  var getSigHashType = require('../../utils/psbt/getSigHashType.cjs');
15
16
  var bitcoinNetworkTypeToNetworks = require('../../utils/psbt/bitcoinNetworkTypeToNetworks.cjs');
@@ -26,6 +27,7 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector.BitcoinWalletCo
26
27
  }
27
28
  getAddress() {
28
29
  return _tslib.__awaiter(this, void 0, void 0, function* () {
30
+ var _a;
29
31
  // xverse doesn't support wallet standard, so we won't have a wallet object,
30
32
  // but it's already the default provider for sats-connect, so it's ok
31
33
  // for getProvider in getAddress to return undefined
@@ -34,6 +36,12 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector.BitcoinWalletCo
34
36
  if (!supportsSatsConnect.supportsSatsConnect(this)) {
35
37
  return;
36
38
  }
39
+ const cachedActiveAccount = yield this.cache.getActiveAccount();
40
+ if (cachedActiveAccount) {
41
+ const ordinalsAddress = cachedActiveAccount.additionalAddresses.find((address) => address.type === sdkApiCore.WalletAddressType.Ordinals);
42
+ const paymentAddress = cachedActiveAccount.additionalAddresses.find((address) => address.type === sdkApiCore.WalletAddressType.Payment);
43
+ return (_a = ordinalsAddress === null || ordinalsAddress === void 0 ? void 0 : ordinalsAddress.address) !== null && _a !== void 0 ? _a : paymentAddress === null || paymentAddress === void 0 ? void 0 : paymentAddress.address;
44
+ }
37
45
  return new Promise((resolve, reject) => {
38
46
  satsConnect.getAddress({
39
47
  getProvider: () => _tslib.__awaiter(this, void 0, void 0, function* () {
@@ -1,6 +1,6 @@
1
1
  import { BitcoinNetworkType, SignTransactionResponse } from 'sats-connect';
2
+ import { BitcoinSignPsbtRequest, BitcoinSignPsbtResponse, BitcoinTransaction, SatsConnectSignTransactionInput } from '../../types';
2
3
  import { BitcoinWalletConnector, BitcoinWalletConnectorOpts } from '../BitcoinWalletConnector';
3
- import { BitcoinTransaction, SatsConnectSignTransactionInput, BitcoinSignPsbtRequest, BitcoinSignPsbtResponse } from '../../types';
4
4
  export declare abstract class BitcoinSatsConnectConnector extends BitcoinWalletConnector {
5
5
  currentNetwork: BitcoinNetworkType;
6
6
  canFetchConnectedAccounts: boolean;
@@ -1,11 +1,12 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../../_virtual/_tslib.js';
3
- import { BitcoinNetworkType, getAddress, AddressPurpose, signMessage, sendBtcTransaction, signTransaction } from 'sats-connect';
4
3
  import { Psbt } from 'bitcoinjs-lib';
5
- import { BitcoinWalletConnector } from '../BitcoinWalletConnector.js';
4
+ import { BitcoinNetworkType, getAddress, AddressPurpose, signMessage, sendBtcTransaction, signTransaction } from 'sats-connect';
5
+ import { WalletAddressType } from '@dynamic-labs/sdk-api-core';
6
6
  import { SATSCONNECT_FEATURE } from '../../const.js';
7
7
  import '@dynamic-labs/utils';
8
8
  import '@dynamic-labs/wallet-connector-core';
9
+ import { BitcoinWalletConnector } from '../BitcoinWalletConnector.js';
9
10
  import { validatePsbt } from '../../utils/psbt/validator/validatePsbt.js';
10
11
  import { getSigHashType } from '../../utils/psbt/getSigHashType.js';
11
12
  import { convertNetworkTypeForPsbt } from '../../utils/psbt/bitcoinNetworkTypeToNetworks.js';
@@ -22,6 +23,7 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector {
22
23
  }
23
24
  getAddress() {
24
25
  return __awaiter(this, void 0, void 0, function* () {
26
+ var _a;
25
27
  // xverse doesn't support wallet standard, so we won't have a wallet object,
26
28
  // but it's already the default provider for sats-connect, so it's ok
27
29
  // for getProvider in getAddress to return undefined
@@ -30,6 +32,12 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector {
30
32
  if (!supportsSatsConnect(this)) {
31
33
  return;
32
34
  }
35
+ const cachedActiveAccount = yield this.cache.getActiveAccount();
36
+ if (cachedActiveAccount) {
37
+ const ordinalsAddress = cachedActiveAccount.additionalAddresses.find((address) => address.type === WalletAddressType.Ordinals);
38
+ const paymentAddress = cachedActiveAccount.additionalAddresses.find((address) => address.type === WalletAddressType.Payment);
39
+ return (_a = ordinalsAddress === null || ordinalsAddress === void 0 ? void 0 : ordinalsAddress.address) !== null && _a !== void 0 ? _a : paymentAddress === null || paymentAddress === void 0 ? void 0 : paymentAddress.address;
40
+ }
33
41
  return new Promise((resolve, reject) => {
34
42
  getAddress({
35
43
  getProvider: () => __awaiter(this, void 0, void 0, function* () {
@@ -56,13 +56,17 @@ class BitcoinWalletConnector extends walletConnectorCore.WalletConnectorBase {
56
56
  }
57
57
  getBalance() {
58
58
  return _tslib.__awaiter(this, void 0, void 0, function* () {
59
- var _a;
59
+ var _a, _b;
60
60
  const [connectedAddress] = yield this.getConnectedAccounts();
61
61
  if (!connectedAddress) {
62
62
  throw new utils.DynamicError('getBalance - No connected address found!');
63
63
  }
64
64
  const additionalAddresses = yield this.getAdditionalAddresses(connectedAddress);
65
- const paymentAddress = (_a = additionalAddresses.find((address) => address.type === sdkApiCore.WalletAddressType.Payment)) === null || _a === void 0 ? void 0 : _a.address;
65
+ const ordinalsAdditionalAddress = (_a = additionalAddresses.find((address) => address.type === sdkApiCore.WalletAddressType.Ordinals)) === null || _a === void 0 ? void 0 : _a.address;
66
+ const paymentAdditionalAddress = (_b = additionalAddresses.find((address) => address.type === sdkApiCore.WalletAddressType.Payment)) === null || _b === void 0 ? void 0 : _b.address;
67
+ // Some BTC wallet connectors only have 1 address type. when this is the case, it would always be `ordinals`
68
+ // if a BTC walletConnector does NOT have a payment address, just use the ordinal address
69
+ const paymentAddress = paymentAdditionalAddress !== null && paymentAdditionalAddress !== void 0 ? paymentAdditionalAddress : ordinalsAdditionalAddress;
66
70
  if (!paymentAddress) {
67
71
  throw new utils.DynamicError('getBalance - No payment address found!');
68
72
  }
@@ -52,13 +52,17 @@ class BitcoinWalletConnector extends WalletConnectorBase {
52
52
  }
53
53
  getBalance() {
54
54
  return __awaiter(this, void 0, void 0, function* () {
55
- var _a;
55
+ var _a, _b;
56
56
  const [connectedAddress] = yield this.getConnectedAccounts();
57
57
  if (!connectedAddress) {
58
58
  throw new DynamicError('getBalance - No connected address found!');
59
59
  }
60
60
  const additionalAddresses = yield this.getAdditionalAddresses(connectedAddress);
61
- const paymentAddress = (_a = additionalAddresses.find((address) => address.type === WalletAddressType.Payment)) === null || _a === void 0 ? void 0 : _a.address;
61
+ const ordinalsAdditionalAddress = (_a = additionalAddresses.find((address) => address.type === WalletAddressType.Ordinals)) === null || _a === void 0 ? void 0 : _a.address;
62
+ const paymentAdditionalAddress = (_b = additionalAddresses.find((address) => address.type === WalletAddressType.Payment)) === null || _b === void 0 ? void 0 : _b.address;
63
+ // Some BTC wallet connectors only have 1 address type. when this is the case, it would always be `ordinals`
64
+ // if a BTC walletConnector does NOT have a payment address, just use the ordinal address
65
+ const paymentAddress = paymentAdditionalAddress !== null && paymentAdditionalAddress !== void 0 ? paymentAdditionalAddress : ordinalsAdditionalAddress;
62
66
  if (!paymentAddress) {
63
67
  throw new DynamicError('getBalance - No payment address found!');
64
68
  }
package/src/index.cjs CHANGED
@@ -9,6 +9,7 @@ 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');
12
13
  var fetchBtcKitConnectors = require('./utils/fetchBtcKitConnectors/fetchBtcKitConnectors.cjs');
13
14
  var fetchSatsConnectConnectors = require('./utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.cjs');
14
15
  var hasSatsConnectFeature = require('./utils/hasSatsConnectFeature.cjs');
package/src/index.js CHANGED
@@ -5,6 +5,7 @@ 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';
8
9
  import { fetchBtcKitConnectors } from './utils/fetchBtcKitConnectors/fetchBtcKitConnectors.js';
9
10
  export { fetchBtcKitConnectors } from './utils/fetchBtcKitConnectors/fetchBtcKitConnectors.js';
10
11
  import { fetchSatsConnectConnectors } from './utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.js';