@dynamic-labs/global-wallet-client 4.0.1 → 4.2.0

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,31 @@
1
1
 
2
+ ## [4.2.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.1.0...v4.2.0) (2025-01-14)
3
+
4
+
5
+ ### Features
6
+
7
+ * add EthereumWalletConnectorsWithConfig ([#7796](https://github.com/dynamic-labs/dynamic-auth/issues/7796)) ([52146c3](https://github.com/dynamic-labs/dynamic-auth/commit/52146c38acbbe9ad31d5f047527b06ea44846065))
8
+ * add new userWalletsChanged event that aggregates all user wallet events ([#7797](https://github.com/dynamic-labs/dynamic-auth/issues/7797)) ([058e629](https://github.com/dynamic-labs/dynamic-auth/commit/058e629f0e760ad9dff2b03f86354355c6f8bffe))
9
+ * add support for connect with OKX Wallet on Eclipse ([#7793](https://github.com/dynamic-labs/dynamic-auth/issues/7793)) ([b6cd047](https://github.com/dynamic-labs/dynamic-auth/commit/b6cd04781402868443b02cbce269dd3c02c358b5))
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * getWalletClient method not returning client with chain for Coinbase ([#7799](https://github.com/dynamic-labs/dynamic-auth/issues/7799)) ([e075493](https://github.com/dynamic-labs/dynamic-auth/commit/e0754936582c19850c905fc3d62c3621df7c274c))
15
+
16
+ ## [4.1.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.1...v4.1.0) (2025-01-14)
17
+
18
+
19
+ ### Features
20
+
21
+ * add hook for upgrading embedded wallets ([#7743](https://github.com/dynamic-labs/dynamic-auth/issues/7743)) ([f0f49b3](https://github.com/dynamic-labs/dynamic-auth/commit/f0f49b335fcf99402fcd8722ae0af137d6f313d1))
22
+ * add setting to require transaction confirmation ([#7770](https://github.com/dynamic-labs/dynamic-auth/issues/7770)) ([0a92485](https://github.com/dynamic-labs/dynamic-auth/commit/0a924852b241e786ad608c55e593d7363c1661c1))
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * correctly detect MetaMask installation in the browser ([#7789](https://github.com/dynamic-labs/dynamic-auth/issues/7789)) ([d499497](https://github.com/dynamic-labs/dynamic-auth/commit/d499497c0b9e052962b3f16fc418a7de99e3bb34))
28
+
2
29
  ### [4.0.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0...v4.0.1) (2025-01-10)
3
30
 
4
31
 
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.0.1";
6
+ var version = "4.2.0";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.0.1";
2
+ var version = "4.2.0";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/global-wallet-client",
3
- "version": "4.0.1",
3
+ "version": "4.2.0",
4
4
  "description": "Core package for building Dynamic's Global Wallet",
5
5
  "author": "Dynamic Labs, Inc.",
6
6
  "license": "MIT",
@@ -13,6 +13,9 @@
13
13
  "*": {
14
14
  "ethereum": [
15
15
  "./src/ethereum.d.ts"
16
+ ],
17
+ "solana": [
18
+ "./src/solana.d.ts"
16
19
  ]
17
20
  }
18
21
  },
@@ -27,15 +30,20 @@
27
30
  "import": "./src/ethereum.js",
28
31
  "default": "./src/ethereum.cjs"
29
32
  },
33
+ "./solana": {
34
+ "types": "./src/solana.d.ts",
35
+ "import": "./src/solana.js",
36
+ "default": "./src/solana.cjs"
37
+ },
30
38
  "./package.json": "./package.json"
31
39
  },
32
40
  "homepage": "https://www.dynamic.xyz/",
33
41
  "dependencies": {
34
- "@dynamic-labs/assert-package-version": "4.0.1",
35
- "@dynamic-labs/logger": "4.0.1",
36
- "@dynamic-labs/store": "4.0.1",
37
- "@dynamic-labs/types": "4.0.1",
38
- "@dynamic-labs/utils": "4.0.1",
42
+ "@dynamic-labs/assert-package-version": "4.2.0",
43
+ "@dynamic-labs/logger": "4.2.0",
44
+ "@dynamic-labs/store": "4.2.0",
45
+ "@dynamic-labs/types": "4.2.0",
46
+ "@dynamic-labs/utils": "4.2.0",
39
47
  "eventemitter3": "5.0.1"
40
48
  },
41
49
  "peerDependencies": {
@@ -8,6 +8,7 @@ var utils = require('@dynamic-labs/utils');
8
8
  var waitForPopupResponse = require('../waitForPopupResponse/waitForPopupResponse.cjs');
9
9
  var onPopupClose = require('../onPopupClose/onPopupClose.cjs');
10
10
  var mergeAndEncryptParams = require('../mergeAndEncryptParams/mergeAndEncryptParams.cjs');
11
+ var getCenteredPopupFeatures = require('../getCenteredPopupFeatures/getCenteredPopupFeatures.cjs');
11
12
 
12
13
  const createPopupOpener = ({ environmentId, popupInfo, store, popupActionTimeout = 1000, // Wait page up to 1 second for new actions before closing
13
14
  }) => {
@@ -34,14 +35,18 @@ const createPopupOpener = ({ environmentId, popupInfo, store, popupActionTimeout
34
35
  popupFinalUrl.hash = `/${pathname}`;
35
36
  popupFinalUrl.searchParams.set('provider_env_id', environmentId);
36
37
  popupFinalUrl.searchParams.set('requester_origin', window.location.origin);
38
+ if (popup === null) {
39
+ const features = getCenteredPopupFeatures.getCenteredPopupFeatures({
40
+ height: popupHeight,
41
+ width: popupWidth,
42
+ });
43
+ // Open popup
44
+ popup = window.open('', '_blank', features);
45
+ }
37
46
  // Encrypt params if active connection is present
38
47
  if (params) {
39
48
  yield mergeAndEncryptParams.mergeAndEncryptParams(popupFinalUrl, params, activeConnection);
40
49
  }
41
- if (popup === null) {
42
- // Open popup
43
- popup = window.open('', '_blank', `width=${popupWidth},height=${popupHeight}`);
44
- }
45
50
  if (popup === null) {
46
51
  throw new Error('Failed to open popup');
47
52
  }
@@ -71,7 +76,7 @@ const createPopupOpener = ({ environmentId, popupInfo, store, popupActionTimeout
71
76
  }
72
77
  else {
73
78
  // Load popup
74
- popup.location.assign(popupFinalUrl.toString());
79
+ popup.location = popupFinalUrl.href;
75
80
  }
76
81
  didOpenPopup = true;
77
82
  return resultDeferredPromise.promise.finally(() => {
@@ -4,6 +4,7 @@ import { DeferredPromise, isEncryptedMessage, decryptMessage } from '@dynamic-la
4
4
  import { waitForPopupResponse } from '../waitForPopupResponse/waitForPopupResponse.js';
5
5
  import { onPopupClose } from '../onPopupClose/onPopupClose.js';
6
6
  import { mergeAndEncryptParams } from '../mergeAndEncryptParams/mergeAndEncryptParams.js';
7
+ import { getCenteredPopupFeatures } from '../getCenteredPopupFeatures/getCenteredPopupFeatures.js';
7
8
 
8
9
  const createPopupOpener = ({ environmentId, popupInfo, store, popupActionTimeout = 1000, // Wait page up to 1 second for new actions before closing
9
10
  }) => {
@@ -30,14 +31,18 @@ const createPopupOpener = ({ environmentId, popupInfo, store, popupActionTimeout
30
31
  popupFinalUrl.hash = `/${pathname}`;
31
32
  popupFinalUrl.searchParams.set('provider_env_id', environmentId);
32
33
  popupFinalUrl.searchParams.set('requester_origin', window.location.origin);
34
+ if (popup === null) {
35
+ const features = getCenteredPopupFeatures({
36
+ height: popupHeight,
37
+ width: popupWidth,
38
+ });
39
+ // Open popup
40
+ popup = window.open('', '_blank', features);
41
+ }
33
42
  // Encrypt params if active connection is present
34
43
  if (params) {
35
44
  yield mergeAndEncryptParams(popupFinalUrl, params, activeConnection);
36
45
  }
37
- if (popup === null) {
38
- // Open popup
39
- popup = window.open('', '_blank', `width=${popupWidth},height=${popupHeight}`);
40
- }
41
46
  if (popup === null) {
42
47
  throw new Error('Failed to open popup');
43
48
  }
@@ -67,7 +72,7 @@ const createPopupOpener = ({ environmentId, popupInfo, store, popupActionTimeout
67
72
  }
68
73
  else {
69
74
  // Load popup
70
- popup.location.assign(popupFinalUrl.toString());
75
+ popup.location = popupFinalUrl.href;
71
76
  }
72
77
  didOpenPopup = true;
73
78
  return resultDeferredPromise.promise.finally(() => {
@@ -0,0 +1,24 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ /**
7
+ * Get the centered position of the popup so it opens in the center of the screen
8
+ */
9
+ const getCenteredPopupFeatures = ({ height, width, }) => {
10
+ var _a, _b, _c, _d;
11
+ // Get the screen offsets of the current window
12
+ const screenLeft = (_a = window.screenLeft) !== null && _a !== void 0 ? _a : window.screenX;
13
+ const screenTop = (_b = window.screenTop) !== null && _b !== void 0 ? _b : window.screenY;
14
+ // Get the dimensions of the current browser window
15
+ const innerWidth = (_c = window.innerWidth) !== null && _c !== void 0 ? _c : document.documentElement.clientWidth;
16
+ const innerHeight = (_d = window.innerHeight) !== null && _d !== void 0 ? _d : document.documentElement.clientHeight;
17
+ // Calculate the centered position
18
+ const left = screenLeft + (innerWidth - width) / 2;
19
+ const top = screenTop + (innerHeight - height) / 2;
20
+ // Return the popup feature string
21
+ return `toolbar=0,location=0,menubar=0,resizable=1,scrollbars=1,width=${width},height=${height},left=${left},top=${top}`;
22
+ };
23
+
24
+ exports.getCenteredPopupFeatures = getCenteredPopupFeatures;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Get the centered position of the popup so it opens in the center of the screen
3
+ */
4
+ export declare const getCenteredPopupFeatures: ({ height, width, }: {
5
+ width: number;
6
+ height: number;
7
+ }) => string;
@@ -0,0 +1,20 @@
1
+ 'use client'
2
+ /**
3
+ * Get the centered position of the popup so it opens in the center of the screen
4
+ */
5
+ const getCenteredPopupFeatures = ({ height, width, }) => {
6
+ var _a, _b, _c, _d;
7
+ // Get the screen offsets of the current window
8
+ const screenLeft = (_a = window.screenLeft) !== null && _a !== void 0 ? _a : window.screenX;
9
+ const screenTop = (_b = window.screenTop) !== null && _b !== void 0 ? _b : window.screenY;
10
+ // Get the dimensions of the current browser window
11
+ const innerWidth = (_c = window.innerWidth) !== null && _c !== void 0 ? _c : document.documentElement.clientWidth;
12
+ const innerHeight = (_d = window.innerHeight) !== null && _d !== void 0 ? _d : document.documentElement.clientHeight;
13
+ // Calculate the centered position
14
+ const left = screenLeft + (innerWidth - width) / 2;
15
+ const top = screenTop + (innerHeight - height) / 2;
16
+ // Return the popup feature string
17
+ return `toolbar=0,location=0,menubar=0,resizable=1,scrollbars=1,width=${width},height=${height},left=${left},top=${top}`;
18
+ };
19
+
20
+ export { getCenteredPopupFeatures };
@@ -0,0 +1 @@
1
+ export { getCenteredPopupFeatures } from './getCenteredPopupFeatures';
@@ -4,9 +4,24 @@
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var _tslib = require('../../../../../_virtual/_tslib.cjs');
7
+ var utils = require('@dynamic-labs/utils');
7
8
 
8
- const createSolanaSignAndSendTransactionFeature = () => ({
9
- signAndSendTransaction: () => _tslib.__awaiter(void 0, void 0, void 0, function* () { return []; }),
9
+ const createSolanaSignAndSendTransactionFeature = (client) => ({
10
+ signAndSendTransaction: (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ account, transaction, chain }) {
11
+ const { signature } = yield client.invoke({
12
+ params: {
13
+ address: account.address,
14
+ chain: chain,
15
+ transaction: utils.uint8ArrayToBase64(transaction),
16
+ },
17
+ pathname: 'solana_signAndSendTransaction',
18
+ });
19
+ return [
20
+ {
21
+ signature: new TextEncoder().encode(signature),
22
+ },
23
+ ];
24
+ }),
10
25
  supportedTransactionVersions: ['legacy', 0],
11
26
  version: '1.0.0',
12
27
  });
@@ -1,2 +1,3 @@
1
1
  import { SolanaSignAndSendTransactionFeature } from '@solana/wallet-standard-features';
2
- export declare const createSolanaSignAndSendTransactionFeature: () => SolanaSignAndSendTransactionFeature['solana:signAndSendTransaction'];
2
+ import { GlobalWalletClient } from '../../../createGlobalWalletClient';
3
+ export declare const createSolanaSignAndSendTransactionFeature: (client: GlobalWalletClient) => SolanaSignAndSendTransactionFeature['solana:signAndSendTransaction'];
@@ -1,8 +1,23 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../../../../_virtual/_tslib.js';
3
+ import { uint8ArrayToBase64 } from '@dynamic-labs/utils';
3
4
 
4
- const createSolanaSignAndSendTransactionFeature = () => ({
5
- signAndSendTransaction: () => __awaiter(void 0, void 0, void 0, function* () { return []; }),
5
+ const createSolanaSignAndSendTransactionFeature = (client) => ({
6
+ signAndSendTransaction: (_a) => __awaiter(void 0, [_a], void 0, function* ({ account, transaction, chain }) {
7
+ const { signature } = yield client.invoke({
8
+ params: {
9
+ address: account.address,
10
+ chain: chain,
11
+ transaction: uint8ArrayToBase64(transaction),
12
+ },
13
+ pathname: 'solana_signAndSendTransaction',
14
+ });
15
+ return [
16
+ {
17
+ signature: new TextEncoder().encode(signature),
18
+ },
19
+ ];
20
+ }),
6
21
  supportedTransactionVersions: ['legacy', 0],
7
22
  version: '1.0.0',
8
23
  });
@@ -4,9 +4,24 @@
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var _tslib = require('../../../../../_virtual/_tslib.cjs');
7
+ var utils = require('@dynamic-labs/utils');
7
8
 
8
- const createSolanaSignTransactionFeature = () => ({
9
- signTransaction: () => _tslib.__awaiter(void 0, void 0, void 0, function* () { return []; }),
9
+ const createSolanaSignTransactionFeature = (client) => ({
10
+ signTransaction: (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ account, transaction, chain }) {
11
+ const { signedTransaction } = yield client.invoke({
12
+ params: {
13
+ address: account.address,
14
+ chain: chain,
15
+ transaction: utils.uint8ArrayToBase64(transaction),
16
+ },
17
+ pathname: 'solana_signTransaction',
18
+ });
19
+ return [
20
+ {
21
+ signedTransaction: utils.uint8ArrayFromBase64(signedTransaction),
22
+ },
23
+ ];
24
+ }),
10
25
  supportedTransactionVersions: ['legacy', 0],
11
26
  version: '1.0.0',
12
27
  });
@@ -1,2 +1,3 @@
1
1
  import { SolanaSignTransactionFeature } from '@solana/wallet-standard-features';
2
- export declare const createSolanaSignTransactionFeature: () => SolanaSignTransactionFeature['solana:signTransaction'];
2
+ import { GlobalWalletClient } from '../../../createGlobalWalletClient';
3
+ export declare const createSolanaSignTransactionFeature: (client: GlobalWalletClient) => SolanaSignTransactionFeature['solana:signTransaction'];
@@ -1,8 +1,23 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../../../../_virtual/_tslib.js';
3
+ import { uint8ArrayToBase64, uint8ArrayFromBase64 } from '@dynamic-labs/utils';
3
4
 
4
- const createSolanaSignTransactionFeature = () => ({
5
- signTransaction: () => __awaiter(void 0, void 0, void 0, function* () { return []; }),
5
+ const createSolanaSignTransactionFeature = (client) => ({
6
+ signTransaction: (_a) => __awaiter(void 0, [_a], void 0, function* ({ account, transaction, chain }) {
7
+ const { signedTransaction } = yield client.invoke({
8
+ params: {
9
+ address: account.address,
10
+ chain: chain,
11
+ transaction: uint8ArrayToBase64(transaction),
12
+ },
13
+ pathname: 'solana_signTransaction',
14
+ });
15
+ return [
16
+ {
17
+ signedTransaction: uint8ArrayFromBase64(signedTransaction),
18
+ },
19
+ ];
20
+ }),
6
21
  supportedTransactionVersions: ['legacy', 0],
7
22
  version: '1.0.0',
8
23
  });
@@ -23,9 +23,9 @@ var createSolanaSignAndSendTransactionFeature = require('../createSolanaSignAndS
23
23
  */
24
24
  const createSolanaWallet = ({ icon, name }, client) => {
25
25
  const features = {
26
- 'solana:signAndSendTransaction': createSolanaSignAndSendTransactionFeature.createSolanaSignAndSendTransactionFeature(),
26
+ 'solana:signAndSendTransaction': createSolanaSignAndSendTransactionFeature.createSolanaSignAndSendTransactionFeature(client),
27
27
  'solana:signMessage': createSolanaSignMessageFeature.createSolanaSignMessageFeature(client),
28
- 'solana:signTransaction': createSolanaSignTransactionFeature.createSolanaSignTransactionFeature(),
28
+ 'solana:signTransaction': createSolanaSignTransactionFeature.createSolanaSignTransactionFeature(client),
29
29
  'standard:connect': createStandardConnectFeature.createStandardConnectFeature(client),
30
30
  'standard:disconnect': createStandardDisconnectFeature.createStandardDisconnectFeature(client),
31
31
  'standard:events': createStandardEventsFeature.createStandardEventsFeature(client),
@@ -19,9 +19,9 @@ import { createSolanaSignAndSendTransactionFeature } from '../createSolanaSignAn
19
19
  */
20
20
  const createSolanaWallet = ({ icon, name }, client) => {
21
21
  const features = {
22
- 'solana:signAndSendTransaction': createSolanaSignAndSendTransactionFeature(),
22
+ 'solana:signAndSendTransaction': createSolanaSignAndSendTransactionFeature(client),
23
23
  'solana:signMessage': createSolanaSignMessageFeature(client),
24
- 'solana:signTransaction': createSolanaSignTransactionFeature(),
24
+ 'solana:signTransaction': createSolanaSignTransactionFeature(client),
25
25
  'standard:connect': createStandardConnectFeature(client),
26
26
  'standard:disconnect': createStandardDisconnectFeature(client),
27
27
  'standard:events': createStandardEventsFeature(client),