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

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,27 @@
1
1
 
2
+ ## [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)
3
+
4
+
5
+ ### ⚠ BREAKING CHANGES
6
+
7
+ * add selectedTabIndex and helpers (#6040)
8
+
9
+ ### Features
10
+
11
+ * add selectedTabIndex and helpers ([#6040](https://github.com/dynamic-labs/DynamicAuth/issues/6040)) ([ae20b80](https://github.com/dynamic-labs/DynamicAuth/commit/ae20b8081376dce97b18fa69c81c9ab73c1ff317))
12
+ * 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))
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * 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))
18
+ * 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))
19
+ * make account change idemopotent ([#6061](https://github.com/dynamic-labs/DynamicAuth/issues/6061)) ([8c87513](https://github.com/dynamic-labs/DynamicAuth/commit/8c8751390ea14888c4889679895e2f06d75717b9))
20
+ * 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))
21
+ * recompute multiwallet state after merging accounts ([#6078](https://github.com/dynamic-labs/DynamicAuth/issues/6078)) ([e08a274](https://github.com/dynamic-labs/DynamicAuth/commit/e08a274c4d848f2a8360be7106cfbfa00b9a8f9b))
22
+ * 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))
23
+ * 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))
24
+
2
25
  ## [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
26
 
4
27
 
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.7",
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.7",
36
+ "@dynamic-labs/wallet-book": "3.0.0-alpha.7",
37
+ "@dynamic-labs/wallet-connector-core": "3.0.0-alpha.7",
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];