@dynamic-labs/bitcoin 3.0.0-alpha.6 → 3.0.0-alpha.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,48 @@
1
1
 
2
+ ## [3.0.0-alpha.8](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.7...v3.0.0-alpha.8) (2024-06-21)
3
+
4
+
5
+ ### ⚠ BREAKING CHANGES
6
+
7
+ * break out turnkey package into 3 separate packages (#6015)
8
+
9
+ ### Features
10
+
11
+ * add reinitialize hook ([#6098](https://github.com/dynamic-labs/DynamicAuth/issues/6098)) ([d978baa](https://github.com/dynamic-labs/DynamicAuth/commit/d978baa404d34064c36cc549229b1fcea1f20df0))
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * always reconnect the wallet provider when calling getAddress ([#6097](https://github.com/dynamic-labs/DynamicAuth/issues/6097)) ([0f3d497](https://github.com/dynamic-labs/DynamicAuth/commit/0f3d497cedb38239fa9ada2bb25c6b4eaa72d7b1))
17
+ * break out turnkey package into 3 separate packages ([#6015](https://github.com/dynamic-labs/DynamicAuth/issues/6015)) ([a86fbef](https://github.com/dynamic-labs/DynamicAuth/commit/a86fbefe97558363b085e6f752af32d2943f91fa)), closes [#6017](https://github.com/dynamic-labs/DynamicAuth/issues/6017) [#6059](https://github.com/dynamic-labs/DynamicAuth/issues/6059)
18
+ * set latest blockhash on solana transactions if tx confirmation ui is disabled ([#6102](https://github.com/dynamic-labs/DynamicAuth/issues/6102)) ([b8035a3](https://github.com/dynamic-labs/DynamicAuth/commit/b8035a328e47409bf0416d3a01b2f17914488748))
19
+ * silently query unisat accounts ([#6101](https://github.com/dynamic-labs/DynamicAuth/issues/6101)) ([#6104](https://github.com/dynamic-labs/DynamicAuth/issues/6104)) ([643e704](https://github.com/dynamic-labs/DynamicAuth/commit/643e7048ff8610b31e6397e10b160ad456a45d11))
20
+ * stop querying magiceden solana accounts ([#6103](https://github.com/dynamic-labs/DynamicAuth/issues/6103)) ([#6108](https://github.com/dynamic-labs/DynamicAuth/issues/6108)) ([3cfdbc3](https://github.com/dynamic-labs/DynamicAuth/commit/3cfdbc3bc82bfe9bf53bf4236f7892a5440fcb86))
21
+ * trigger sign when linking an already linked unknown wallet ([#6105](https://github.com/dynamic-labs/DynamicAuth/issues/6105)) ([9e9c03b](https://github.com/dynamic-labs/DynamicAuth/commit/9e9c03bf615991c4f1183bf85c4d75c9a7773c85))
22
+
23
+ ## [3.0.0-alpha.7](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.6...v3.0.0-alpha.7) (2024-06-19)
24
+
25
+
26
+ ### ⚠ BREAKING CHANGES
27
+
28
+ * add selectedTabIndex and helpers (#6040)
29
+
30
+ ### Features
31
+
32
+ * add selectedTabIndex and helpers ([#6040](https://github.com/dynamic-labs/DynamicAuth/issues/6040)) ([ae20b80](https://github.com/dynamic-labs/DynamicAuth/commit/ae20b8081376dce97b18fa69c81c9ab73c1ff317))
33
+ * add useRefreshUser to trigger a user state refresh ([#6079](https://github.com/dynamic-labs/DynamicAuth/issues/6079)) ([1236d35](https://github.com/dynamic-labs/DynamicAuth/commit/1236d35fe9fab44ed2114ad9f3c8c6dca7ec27be))
34
+
35
+
36
+ ### Bug Fixes
37
+
38
+ * always return userWallets when available ([#6080](https://github.com/dynamic-labs/DynamicAuth/issues/6080)) ([#6083](https://github.com/dynamic-labs/DynamicAuth/issues/6083)) ([11992d2](https://github.com/dynamic-labs/DynamicAuth/commit/11992d2af5a401ba4ff1dc6904e2a9f8ef5904ca))
39
+ * less solana rpc calls and improve fee fetching ([#6019](https://github.com/dynamic-labs/DynamicAuth/issues/6019)) ([e2609db](https://github.com/dynamic-labs/DynamicAuth/commit/e2609db962c7708ff5b127cb23260a25bc5032e3))
40
+ * make account change idemopotent ([#6061](https://github.com/dynamic-labs/DynamicAuth/issues/6061)) ([8c87513](https://github.com/dynamic-labs/DynamicAuth/commit/8c8751390ea14888c4889679895e2f06d75717b9))
41
+ * only run multi wallet prompt when user profile or auth flow are open ([#6073](https://github.com/dynamic-labs/DynamicAuth/issues/6073)) ([d48ca10](https://github.com/dynamic-labs/DynamicAuth/commit/d48ca105359018457a78588fd8d9aa8a91583a02))
42
+ * recompute multiwallet state after merging accounts ([#6078](https://github.com/dynamic-labs/DynamicAuth/issues/6078)) ([e08a274](https://github.com/dynamic-labs/DynamicAuth/commit/e08a274c4d848f2a8360be7106cfbfa00b9a8f9b))
43
+ * stop querying okx for accounts while locked ([#6081](https://github.com/dynamic-labs/DynamicAuth/issues/6081)) ([#6084](https://github.com/dynamic-labs/DynamicAuth/issues/6084)) ([34365ac](https://github.com/dynamic-labs/DynamicAuth/commit/34365ac1981fe020b03e666c24535a247645d2ad))
44
+ * update copy for primary wallet not connected modal ([#6069](https://github.com/dynamic-labs/DynamicAuth/issues/6069)) ([4a3f43c](https://github.com/dynamic-labs/DynamicAuth/commit/4a3f43ce5585983f7fea0c5b97e812c0ade80e2c))
45
+
2
46
  ## [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
47
 
4
48
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/bitcoin",
3
- "version": "3.0.0-alpha.6",
3
+ "version": "3.0.0-alpha.8",
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": "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",
35
+ "@dynamic-labs/utils": "3.0.0-alpha.8",
36
+ "@dynamic-labs/wallet-book": "3.0.0-alpha.8",
37
+ "@dynamic-labs/wallet-connector-core": "3.0.0-alpha.8",
38
38
  "stream": "0.0.2"
39
39
  },
40
40
  "peerDependencies": {}
@@ -33,6 +33,12 @@ class BitcoinWalletConnector extends walletConnectorCore.WalletConnectorBase {
33
33
  }
34
34
  this.cache = new BitcoinLocalStorageCache.BitcoinLocalStorageCache(this.overrideKey);
35
35
  }
36
+ isSameAccountChangeRequest(to) {
37
+ return this.lastAccountChange === to;
38
+ }
39
+ setLastAccountChangeRequest(to) {
40
+ this.lastAccountChange = to;
41
+ }
36
42
  clearConnectedAccounts() {
37
43
  return _tslib.__awaiter(this, void 0, void 0, function* () {
38
44
  yield this.cache.clearConnectedAcccounts();
@@ -237,9 +243,14 @@ class BitcoinWalletConnector extends walletConnectorCore.WalletConnectorBase {
237
243
  }
238
244
  const currentConnectedAccounts = yield this.getConnectedAccountsFromCache();
239
245
  // don't do anything if the connected accounts haven't changed
240
- if (currentConnectedAccounts[0] === connectedAccounts[0]) {
246
+ // or if the account change request is the same as previous request
247
+ if (currentConnectedAccounts[0] === connectedAccounts[0] ||
248
+ this.isSameAccountChangeRequest(connectedAccounts[0])) {
241
249
  return;
242
250
  }
251
+ // set the last account change request with the from and to addresses
252
+ // to ensure that the requests are not duplicated
253
+ this.setLastAccountChangeRequest(connectedAccounts[0]);
243
254
  handleAccountChange(connectedAccounts);
244
255
  });
245
256
  provider.on('accountsChanged', handleBitcoinAccountChange);
@@ -23,7 +23,10 @@ export declare abstract class BitcoinWalletConnector extends WalletConnectorBase
23
23
  canFetchConnectedAccounts: boolean;
24
24
  isHardwareWalletEnabled: boolean;
25
25
  verifiedCredentials: JwtVerifiedCredential[];
26
+ private lastAccountChange;
26
27
  constructor(opts: BitcoinWalletConnectorOpts);
28
+ private isSameAccountChangeRequest;
29
+ private setLastAccountChangeRequest;
27
30
  clearConnectedAccounts(): Promise<void>;
28
31
  canConnectWithHardwareWallet(): boolean;
29
32
  isInstalledOnBrowser(): boolean;
@@ -29,6 +29,12 @@ class BitcoinWalletConnector extends WalletConnectorBase {
29
29
  }
30
30
  this.cache = new BitcoinLocalStorageCache(this.overrideKey);
31
31
  }
32
+ isSameAccountChangeRequest(to) {
33
+ return this.lastAccountChange === to;
34
+ }
35
+ setLastAccountChangeRequest(to) {
36
+ this.lastAccountChange = to;
37
+ }
32
38
  clearConnectedAccounts() {
33
39
  return __awaiter(this, void 0, void 0, function* () {
34
40
  yield this.cache.clearConnectedAcccounts();
@@ -233,9 +239,14 @@ class BitcoinWalletConnector extends WalletConnectorBase {
233
239
  }
234
240
  const currentConnectedAccounts = yield this.getConnectedAccountsFromCache();
235
241
  // don't do anything if the connected accounts haven't changed
236
- if (currentConnectedAccounts[0] === connectedAccounts[0]) {
242
+ // or if the account change request is the same as previous request
243
+ if (currentConnectedAccounts[0] === connectedAccounts[0] ||
244
+ this.isSameAccountChangeRequest(connectedAccounts[0])) {
237
245
  return;
238
246
  }
247
+ // set the last account change request with the from and to addresses
248
+ // to ensure that the requests are not duplicated
249
+ this.setLastAccountChangeRequest(connectedAccounts[0]);
239
250
  handleAccountChange(connectedAccounts);
240
251
  });
241
252
  provider.on('accountsChanged', handleBitcoinAccountChange);
@@ -13,7 +13,7 @@ class OkxConnector extends BitcoinWalletConnector.BitcoinWalletConnector {
13
13
  constructor(opts) {
14
14
  super(Object.assign(Object.assign({}, opts), { overrideKey: 'okxwalletbtc' }));
15
15
  this.name = 'OKX Wallet';
16
- this.canFetchConnectedAccounts = true;
16
+ this.canFetchConnectedAccounts = false;
17
17
  }
18
18
  get walletBookWallet() {
19
19
  return this.walletBook.wallets[this.key];
@@ -9,7 +9,7 @@ class OkxConnector extends BitcoinWalletConnector {
9
9
  constructor(opts) {
10
10
  super(Object.assign(Object.assign({}, opts), { overrideKey: 'okxwalletbtc' }));
11
11
  this.name = 'OKX Wallet';
12
- this.canFetchConnectedAccounts = true;
12
+ this.canFetchConnectedAccounts = false;
13
13
  }
14
14
  get walletBookWallet() {
15
15
  return this.walletBook.wallets[this.key];
@@ -65,6 +65,15 @@ class UnisatConnector extends BitcoinWalletConnector.BitcoinWalletConnector {
65
65
  return { signedPsbt: bitcoinjsLib.Psbt.fromHex(signedPsbtHex).toBase64() };
66
66
  });
67
67
  }
68
+ getConnectedAccounts() {
69
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
70
+ const provider = this.getProvider();
71
+ if (!provider) {
72
+ return [];
73
+ }
74
+ return provider.getAccounts();
75
+ });
76
+ }
68
77
  }
69
78
 
70
79
  exports.UnisatConnector = UnisatConnector;
@@ -9,4 +9,5 @@ export declare class UnisatConnector extends BitcoinWalletConnector {
9
9
  signMessage(messageToSign: string): Promise<string | undefined>;
10
10
  sendBitcoin(transaction: BitcoinTransaction): Promise<string | undefined>;
11
11
  signPsbt(request: BitcoinSignPsbtRequest): Promise<BitcoinSignPsbtResponse | undefined>;
12
+ getConnectedAccounts(): Promise<string[]>;
12
13
  }
@@ -61,6 +61,15 @@ class UnisatConnector extends BitcoinWalletConnector {
61
61
  return { signedPsbt: Psbt.fromHex(signedPsbtHex).toBase64() };
62
62
  });
63
63
  }
64
+ getConnectedAccounts() {
65
+ return __awaiter(this, void 0, void 0, function* () {
66
+ const provider = this.getProvider();
67
+ if (!provider) {
68
+ return [];
69
+ }
70
+ return provider.getAccounts();
71
+ });
72
+ }
64
73
  }
65
74
 
66
75
  export { UnisatConnector };