@dynamic-labs/bitcoin 3.0.0-alpha.4 → 3.0.0-alpha.6

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,45 @@
1
1
 
2
+ ## [3.0.0-alpha.6](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.5...v3.0.0-alpha.6) (2024-06-18)
3
+
4
+
5
+ ### Features
6
+
7
+ * implement useExternalAuth hook to signin using external jwt auth ([#6039](https://github.com/dynamic-labs/DynamicAuth/issues/6039)) ([ba90908](https://github.com/dynamic-labs/DynamicAuth/commit/ba90908509ec21f708a4a0782a7f94861fc3b484))
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * allow sign-in with different ME BTC wallet after initial connection ([a527b46](https://github.com/dynamic-labs/DynamicAuth/commit/a527b464f321b4fc27730f57c3812e996b5ed878))
13
+ * close sign modal when signing in with a wallet when embedded wallet is enabled ([#6013](https://github.com/dynamic-labs/DynamicAuth/issues/6013)) ([0f4f3c8](https://github.com/dynamic-labs/DynamicAuth/commit/0f4f3c83db162f7a1794a3549b60bbad6b03e2c0))
14
+ * custom network without a valid icon should still display its name in network picker ([#6018](https://github.com/dynamic-labs/DynamicAuth/issues/6018)) ([0b10df6](https://github.com/dynamic-labs/DynamicAuth/commit/0b10df68950bfc9b8492443158a6bb030dc1122c))
15
+ * e2e: remove page pause ([#6045](https://github.com/dynamic-labs/DynamicAuth/issues/6045)) ([55bba00](https://github.com/dynamic-labs/DynamicAuth/commit/55bba0034255055d6ae266b1296542f47ed48e2b))
16
+ * more fixes for connect starknet button ([#6046](https://github.com/dynamic-labs/DynamicAuth/issues/6046)) ([0fb570a](https://github.com/dynamic-labs/DynamicAuth/commit/0fb570a44e65f8dd6d4d2bf5edb2ee54985ec9d4))
17
+ * set verified credentials on embedded wallet creation ([#6044](https://github.com/dynamic-labs/DynamicAuth/issues/6044)) ([b52a96d](https://github.com/dynamic-labs/DynamicAuth/commit/b52a96d321e7efdb30dce9cdb3f6f176c24ceb81))
18
+
19
+ ## [3.0.0-alpha.5](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.4...v3.0.0-alpha.5) (2024-06-14)
20
+
21
+
22
+ ### ⚠ BREAKING CHANGES
23
+
24
+ * remove viem dependency from non-evm packages (#5508)
25
+ * move rpc providers into their own packages (#5981)
26
+
27
+ ### Features
28
+
29
+ * add in-app browser navigation support for sats-connect ([#5988](https://github.com/dynamic-labs/DynamicAuth/issues/5988)) ([be27d2d](https://github.com/dynamic-labs/DynamicAuth/commit/be27d2d4030bbe2157e879497d8e6a00b4a3e404))
30
+ * move rpc providers into their own packages ([#5981](https://github.com/dynamic-labs/DynamicAuth/issues/5981)) ([d7a62d6](https://github.com/dynamic-labs/DynamicAuth/commit/d7a62d60e79dfa6d6651b0fa103e90b6f8a9ccf3))
31
+
32
+
33
+ ### Bug Fixes
34
+
35
+ * embedded solana wallets can send SPL tokens and estimate gas ([#5982](https://github.com/dynamic-labs/DynamicAuth/issues/5982)) ([36623eb](https://github.com/dynamic-labs/DynamicAuth/commit/36623eb99d1d1dfebfd8b6f3194eeff31e7de2bf))
36
+ * improve logic related to turnkey and emailVerifcation ([#5946](https://github.com/dynamic-labs/DynamicAuth/issues/5946)) ([dd0b2dc](https://github.com/dynamic-labs/DynamicAuth/commit/dd0b2dc6d93a8bbbcb6eef88732e62b747005bb3))
37
+ * show linked wallets with unavailable providers in user wallets list ([#5992](https://github.com/dynamic-labs/DynamicAuth/issues/5992)) ([996079c](https://github.com/dynamic-labs/DynamicAuth/commit/996079ced360651c7b1eb5273548e0548f6f9f3a))
38
+ * switch network modal not closing after switching to a supported network ([#5979](https://github.com/dynamic-labs/DynamicAuth/issues/5979)) ([f239952](https://github.com/dynamic-labs/DynamicAuth/commit/f2399523dd82bb28046992cac4582688b688bdc0))
39
+
40
+
41
+ * remove viem dependency from non-evm packages ([#5508](https://github.com/dynamic-labs/DynamicAuth/issues/5508)) ([0299dc3](https://github.com/dynamic-labs/DynamicAuth/commit/0299dc3cbb611182d763e9a89d1270c2e2f32df5))
42
+
2
43
  ## [3.0.0-alpha.4](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.3...v3.0.0-alpha.4) (2024-06-12)
3
44
 
4
45
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/bitcoin",
3
- "version": "3.0.0-alpha.4",
3
+ "version": "3.0.0-alpha.6",
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.461",
30
+ "@dynamic-labs/sdk-api-core": "0.0.470",
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": "3.0.0-alpha.4",
36
- "@dynamic-labs/wallet-book": "3.0.0-alpha.4",
37
- "@dynamic-labs/wallet-connector-core": "3.0.0-alpha.4",
35
+ "@dynamic-labs/utils": "3.0.0-alpha.6",
36
+ "@dynamic-labs/wallet-book": "3.0.0-alpha.6",
37
+ "@dynamic-labs/wallet-connector-core": "3.0.0-alpha.6",
38
38
  "stream": "0.0.2"
39
39
  },
40
40
  "peerDependencies": {}
@@ -15,6 +15,10 @@ export declare class BitcoinProviderHelper {
15
15
  features: string[];
16
16
  name: string;
17
17
  } | undefined;
18
+ walletStandardLocators?: {
19
+ name: string;
20
+ locator: string;
21
+ }[] | undefined;
18
22
  windowLocations?: string[] | undefined;
19
23
  } | undefined;
20
24
  getProvider(): any;
@@ -6,9 +6,9 @@ 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');
9
+ var utils = require('@dynamic-labs/utils');
10
+ var walletBook = require('@dynamic-labs/wallet-book');
10
11
  var _const = require('../../const.cjs');
11
- require('@dynamic-labs/utils');
12
12
  require('@dynamic-labs/wallet-connector-core');
13
13
  var BitcoinWalletConnector = require('../BitcoinWalletConnector.cjs');
14
14
  var validatePsbt = require('../../utils/psbt/validator/validatePsbt.cjs');
@@ -20,10 +20,9 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector.BitcoinWalletCo
20
20
  constructor(opts) {
21
21
  super(opts);
22
22
  this.currentNetwork = satsConnect.BitcoinNetworkType.Mainnet;
23
- this.canFetchConnectedAccounts = true;
24
- // xverse does't support fetching connected accounts without prompting
25
- // for a connection, so we handle getConnectedAccounts differently
26
- 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;
27
26
  }
28
27
  getAddress() {
29
28
  return _tslib.__awaiter(this, void 0, void 0, function* () {
@@ -36,11 +35,15 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector.BitcoinWalletCo
36
35
  if (!supportsSatsConnect.supportsSatsConnect(this)) {
37
36
  return;
38
37
  }
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;
38
+ const wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
39
+ const inAppBrowserUrl = (_a = wallet === null || wallet === void 0 ? void 0 : wallet.mobile) === null || _a === void 0 ? void 0 : _a.inAppBrowser;
40
+ if (utils.isMobile() && !this.isInstalledOnBrowser() && inAppBrowserUrl) {
41
+ const inAppBrowserTemplate = utils.template(inAppBrowserUrl);
42
+ const deepLink = inAppBrowserTemplate({
43
+ encodedDappURI: encodeURIComponent(window.location.toString()),
44
+ });
45
+ window.location.href = deepLink;
46
+ return;
44
47
  }
45
48
  return new Promise((resolve, reject) => {
46
49
  satsConnect.getAddress({
@@ -2,9 +2,9 @@
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';
5
+ import { isMobile, template } from '@dynamic-labs/utils';
6
+ import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
6
7
  import { SATSCONNECT_FEATURE } from '../../const.js';
7
- import '@dynamic-labs/utils';
8
8
  import '@dynamic-labs/wallet-connector-core';
9
9
  import { BitcoinWalletConnector } from '../BitcoinWalletConnector.js';
10
10
  import { validatePsbt } from '../../utils/psbt/validator/validatePsbt.js';
@@ -16,10 +16,9 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector {
16
16
  constructor(opts) {
17
17
  super(opts);
18
18
  this.currentNetwork = BitcoinNetworkType.Mainnet;
19
- this.canFetchConnectedAccounts = true;
20
- // xverse does't support fetching connected accounts without prompting
21
- // for a connection, so we handle getConnectedAccounts differently
22
- 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;
23
22
  }
24
23
  getAddress() {
25
24
  return __awaiter(this, void 0, void 0, function* () {
@@ -32,11 +31,15 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector {
32
31
  if (!supportsSatsConnect(this)) {
33
32
  return;
34
33
  }
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;
34
+ const wallet = findWalletBookWallet(this.walletBook, this.key);
35
+ const inAppBrowserUrl = (_a = wallet === null || wallet === void 0 ? void 0 : wallet.mobile) === null || _a === void 0 ? void 0 : _a.inAppBrowser;
36
+ if (isMobile() && !this.isInstalledOnBrowser() && inAppBrowserUrl) {
37
+ const inAppBrowserTemplate = template(inAppBrowserUrl);
38
+ const deepLink = inAppBrowserTemplate({
39
+ encodedDappURI: encodeURIComponent(window.location.toString()),
40
+ });
41
+ window.location.href = deepLink;
42
+ return;
40
43
  }
41
44
  return new Promise((resolve, reject) => {
42
45
  getAddress({
@@ -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() {
@@ -0,0 +1,38 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var _tslib = require('../../../_virtual/_tslib.cjs');
7
+ var BitcoinWalletConnector = require('../BitcoinWalletConnector.cjs');
8
+
9
+ class FallbackBitcoinConnector extends BitcoinWalletConnector.BitcoinWalletConnector {
10
+ constructor(opts) {
11
+ super(Object.assign(Object.assign({}, opts), { overrideKey: 'fallbackconnector' }));
12
+ this.name = 'Fallback Connector';
13
+ this.overrideKey = 'fallbackconnector';
14
+ this.isAvailable = false;
15
+ this.canFetchConnectedAccounts = false;
16
+ }
17
+ getAddress() {
18
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
19
+ return;
20
+ });
21
+ }
22
+ signPsbt(
23
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
24
+ _request) {
25
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
26
+ return;
27
+ });
28
+ }
29
+ sendBitcoin(
30
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
31
+ _transaction) {
32
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
33
+ return;
34
+ });
35
+ }
36
+ }
37
+
38
+ exports.FallbackBitcoinConnector = FallbackBitcoinConnector;
@@ -0,0 +1,12 @@
1
+ import { BitcoinSignPsbtRequest, BitcoinSignPsbtResponse, BitcoinTransaction } from '../../types';
2
+ import { BitcoinWalletConnector, BitcoinWalletConnectorOpts } from '../BitcoinWalletConnector';
3
+ export declare class FallbackBitcoinConnector extends BitcoinWalletConnector {
4
+ name: string;
5
+ overrideKey: string;
6
+ isAvailable: boolean;
7
+ canFetchConnectedAccounts: boolean;
8
+ constructor(opts: BitcoinWalletConnectorOpts);
9
+ getAddress(): Promise<string | undefined>;
10
+ signPsbt(_request: BitcoinSignPsbtRequest): Promise<BitcoinSignPsbtResponse | undefined>;
11
+ sendBitcoin(_transaction: BitcoinTransaction): Promise<string | undefined>;
12
+ }
@@ -0,0 +1,34 @@
1
+ 'use client'
2
+ import { __awaiter } from '../../../_virtual/_tslib.js';
3
+ import { BitcoinWalletConnector } from '../BitcoinWalletConnector.js';
4
+
5
+ class FallbackBitcoinConnector extends BitcoinWalletConnector {
6
+ constructor(opts) {
7
+ super(Object.assign(Object.assign({}, opts), { overrideKey: 'fallbackconnector' }));
8
+ this.name = 'Fallback Connector';
9
+ this.overrideKey = 'fallbackconnector';
10
+ this.isAvailable = false;
11
+ this.canFetchConnectedAccounts = false;
12
+ }
13
+ getAddress() {
14
+ return __awaiter(this, void 0, void 0, function* () {
15
+ return;
16
+ });
17
+ }
18
+ signPsbt(
19
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
20
+ _request) {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ return;
23
+ });
24
+ }
25
+ sendBitcoin(
26
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
27
+ _transaction) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ return;
30
+ });
31
+ }
32
+ }
33
+
34
+ export { FallbackBitcoinConnector };
@@ -0,0 +1 @@
1
+ export { FallbackBitcoinConnector } from './FallbackBitcoinConnector';
@@ -5,3 +5,4 @@ export * from './PhantomConnector';
5
5
  export * from './OkxConnector';
6
6
  export * from './UnisatConnector';
7
7
  export * from './UnknownInjected';
8
+ export * from './FallbackBitcoinConnector';
package/src/index.cjs CHANGED
@@ -9,7 +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
+ require('@dynamic-labs/wallet-book');
13
13
  var fetchBtcKitConnectors = require('./utils/fetchBtcKitConnectors/fetchBtcKitConnectors.cjs');
14
14
  var fetchSatsConnectConnectors = require('./utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.cjs');
15
15
  var hasSatsConnectFeature = require('./utils/hasSatsConnectFeature.cjs');
@@ -19,6 +19,7 @@ var PhantomConnector = require('./connectors/PhantomConnector/PhantomConnector.c
19
19
  var OkxConnector = require('./connectors/OkxConnector/OkxConnector.cjs');
20
20
  var UnisatConnector = require('./connectors/UnisatConnector/UnisatConnector.cjs');
21
21
  var UnknownInjected = require('./connectors/UnknownInjected/UnknownInjected.cjs');
22
+ var FallbackBitcoinConnector = require('./connectors/FallbackBitcoinConnector/FallbackBitcoinConnector.cjs');
22
23
 
23
24
  const BitcoinWalletConnectors = (props) => [
24
25
  ...fetchSatsConnectConnectors.fetchSatsConnectConnectors(props),
@@ -27,6 +28,7 @@ const BitcoinWalletConnectors = (props) => [
27
28
  OkxConnector.OkxConnector,
28
29
  UnisatConnector.UnisatConnector,
29
30
  UnknownInjected.UnknownInjectedConnector,
31
+ FallbackBitcoinConnector.FallbackBitcoinConnector,
30
32
  ];
31
33
 
32
34
  exports.BitcoinWalletConnector = BitcoinWalletConnector.BitcoinWalletConnector;
package/src/index.js CHANGED
@@ -5,7 +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
+ import '@dynamic-labs/wallet-book';
9
9
  import { fetchBtcKitConnectors } from './utils/fetchBtcKitConnectors/fetchBtcKitConnectors.js';
10
10
  export { fetchBtcKitConnectors } from './utils/fetchBtcKitConnectors/fetchBtcKitConnectors.js';
11
11
  import { fetchSatsConnectConnectors } from './utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.js';
@@ -17,6 +17,7 @@ import { PhantomConnector } from './connectors/PhantomConnector/PhantomConnector
17
17
  import { OkxConnector } from './connectors/OkxConnector/OkxConnector.js';
18
18
  import { UnisatConnector } from './connectors/UnisatConnector/UnisatConnector.js';
19
19
  import { UnknownInjectedConnector } from './connectors/UnknownInjected/UnknownInjected.js';
20
+ import { FallbackBitcoinConnector } from './connectors/FallbackBitcoinConnector/FallbackBitcoinConnector.js';
20
21
 
21
22
  const BitcoinWalletConnectors = (props) => [
22
23
  ...fetchSatsConnectConnectors(props),
@@ -25,6 +26,7 @@ const BitcoinWalletConnectors = (props) => [
25
26
  OkxConnector,
26
27
  UnisatConnector,
27
28
  UnknownInjectedConnector,
29
+ FallbackBitcoinConnector,
28
30
  ];
29
31
 
30
32
  export { BitcoinWalletConnectors };