@dynamic-labs/ethereum-core 4.19.0 → 4.19.2

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,18 @@
1
1
 
2
+ ### [4.19.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.19.1...v4.19.2) (2025-05-27)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * always set the current wallet address when creating WalletClient for that wallet ([#8800](https://github.com/dynamic-labs/dynamic-auth/issues/8800)) ([3282902](https://github.com/dynamic-labs/dynamic-auth/commit/3282902581d429b66c91c533f5573964174e43d6))
8
+
9
+ ### [4.19.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.19.0...v4.19.1) (2025-05-26)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * **react-native:** reload webview when disconnected ([#8765](https://github.com/dynamic-labs/dynamic-auth/issues/8765)) ([addf90b](https://github.com/dynamic-labs/dynamic-auth/commit/addf90b6fccbe4b883e9778cf7a07e0471f85318))
15
+
2
16
  ## [4.19.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.18.8...v4.19.0) (2025-05-23)
3
17
 
4
18
 
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.19.0";
6
+ var version = "4.19.2";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.19.0";
2
+ var version = "4.19.2";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/ethereum-core",
3
- "version": "4.19.0",
3
+ "version": "4.19.2",
4
4
  "description": "Core package for utilities and types for viem",
5
5
  "author": "Dynamic Labs, Inc.",
6
6
  "license": "MIT",
@@ -19,13 +19,13 @@
19
19
  "homepage": "https://www.dynamic.xyz/",
20
20
  "dependencies": {
21
21
  "@dynamic-labs/sdk-api-core": "0.0.672",
22
- "@dynamic-labs/assert-package-version": "4.19.0",
23
- "@dynamic-labs/logger": "4.19.0",
24
- "@dynamic-labs/rpc-providers": "4.19.0",
25
- "@dynamic-labs/types": "4.19.0",
26
- "@dynamic-labs/utils": "4.19.0",
27
- "@dynamic-labs/wallet-book": "4.19.0",
28
- "@dynamic-labs/wallet-connector-core": "4.19.0"
22
+ "@dynamic-labs/assert-package-version": "4.19.2",
23
+ "@dynamic-labs/logger": "4.19.2",
24
+ "@dynamic-labs/rpc-providers": "4.19.2",
25
+ "@dynamic-labs/types": "4.19.2",
26
+ "@dynamic-labs/utils": "4.19.2",
27
+ "@dynamic-labs/wallet-book": "4.19.2",
28
+ "@dynamic-labs/wallet-connector-core": "4.19.2"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "viem": "^2.21.60"
package/src/index.cjs CHANGED
@@ -28,6 +28,7 @@ var findEvmNetwork = require('./utils/findEvmNetwork/findEvmNetwork.cjs');
28
28
  var getNameservice = require('./utils/getNameservice/getNameservice.cjs');
29
29
  var validateAddressFormat = require('./utils/validateAddressFormat/validateAddressFormat.cjs');
30
30
  var parseAddress = require('./utils/parseAddress/parseAddress.cjs');
31
+ var normalizeRpcError = require('./utils/normalizeRpcError/normalizeRpcError.cjs');
31
32
  var EthereumWallet = require('./wallet/EthereumWallet.cjs');
32
33
  var isEthereumWallet = require('./wallet/isEthereumWallet/isEthereumWallet.cjs');
33
34
 
@@ -56,6 +57,7 @@ exports.findEvmNetwork = findEvmNetwork.findEvmNetwork;
56
57
  exports.getNameservice = getNameservice.getNameservice;
57
58
  exports.validateAddressFormat = validateAddressFormat.validateAddressFormat;
58
59
  exports.parseAddress = parseAddress.parseAddress;
60
+ exports.normalizeRpcError = normalizeRpcError.normalizeRpcError;
59
61
  exports.EthereumWallet = EthereumWallet.EthereumWallet;
60
62
  exports.isEthereumWallet = isEthereumWallet.isEthereumWallet;
61
63
  Object.keys(rpcProviders).forEach(function (k) {
package/src/index.js CHANGED
@@ -24,6 +24,7 @@ export { findEvmNetwork } from './utils/findEvmNetwork/findEvmNetwork.js';
24
24
  export { getNameservice } from './utils/getNameservice/getNameservice.js';
25
25
  export { validateAddressFormat } from './utils/validateAddressFormat/validateAddressFormat.js';
26
26
  export { parseAddress } from './utils/parseAddress/parseAddress.js';
27
+ export { normalizeRpcError } from './utils/normalizeRpcError/normalizeRpcError.js';
27
28
  export { EthereumWallet } from './wallet/EthereumWallet.js';
28
29
  export { isEthereumWallet } from './wallet/isEthereumWallet/isEthereumWallet.js';
29
30
 
@@ -3,3 +3,4 @@ export { findEvmNetwork } from './findEvmNetwork';
3
3
  export { getNameservice } from './getNameservice';
4
4
  export { validateAddressFormat } from './validateAddressFormat';
5
5
  export { parseAddress } from './parseAddress';
6
+ export { normalizeRpcError } from './normalizeRpcError';
@@ -0,0 +1 @@
1
+ export { normalizeRpcError } from './normalizeRpcError';
@@ -0,0 +1,51 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var viem = require('viem');
7
+
8
+ /**
9
+ * Some wallets may not reject some operations following the EIP-1193 standard.
10
+ * This function normalizes the errors to follow the EIP-1193 standard.
11
+ */
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
+ const normalizeRpcError = (err) => {
14
+ /**
15
+ * When the error already comply with the EIP-1193 standard, we don't need to normalize it
16
+ */
17
+ if (err.code === 4001) {
18
+ throw err;
19
+ }
20
+ let mappedError = null;
21
+ try {
22
+ mappedError = mapRpcError(err);
23
+ }
24
+ catch (e) {
25
+ // ignore errors when mapping
26
+ }
27
+ if (mappedError) {
28
+ throw mappedError;
29
+ }
30
+ /**
31
+ * If no error is mapped, we rethrow the original error
32
+ */
33
+ throw err;
34
+ };
35
+ const mapRpcError = (err) => {
36
+ /**
37
+ * Checks for user rejection error message
38
+ * Rainbow Extension will return a message like "User rejected the request"
39
+ * BitGet will return a message like "user reject this request"
40
+ * Keplr will return a message that matches "Request rejected"
41
+ */
42
+ if (typeof err.message === 'string' &&
43
+ (err.message.includes('User rejected the request') ||
44
+ err.message.includes('user reject this request') ||
45
+ err.message === 'Request rejected')) {
46
+ return new viem.UserRejectedRequestError(err);
47
+ }
48
+ return null;
49
+ };
50
+
51
+ exports.normalizeRpcError = normalizeRpcError;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Some wallets may not reject some operations following the EIP-1193 standard.
3
+ * This function normalizes the errors to follow the EIP-1193 standard.
4
+ */
5
+ export declare const normalizeRpcError: (err: any) => never;
@@ -0,0 +1,47 @@
1
+ 'use client'
2
+ import { UserRejectedRequestError } from 'viem';
3
+
4
+ /**
5
+ * Some wallets may not reject some operations following the EIP-1193 standard.
6
+ * This function normalizes the errors to follow the EIP-1193 standard.
7
+ */
8
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
+ const normalizeRpcError = (err) => {
10
+ /**
11
+ * When the error already comply with the EIP-1193 standard, we don't need to normalize it
12
+ */
13
+ if (err.code === 4001) {
14
+ throw err;
15
+ }
16
+ let mappedError = null;
17
+ try {
18
+ mappedError = mapRpcError(err);
19
+ }
20
+ catch (e) {
21
+ // ignore errors when mapping
22
+ }
23
+ if (mappedError) {
24
+ throw mappedError;
25
+ }
26
+ /**
27
+ * If no error is mapped, we rethrow the original error
28
+ */
29
+ throw err;
30
+ };
31
+ const mapRpcError = (err) => {
32
+ /**
33
+ * Checks for user rejection error message
34
+ * Rainbow Extension will return a message like "User rejected the request"
35
+ * BitGet will return a message like "user reject this request"
36
+ * Keplr will return a message that matches "Request rejected"
37
+ */
38
+ if (typeof err.message === 'string' &&
39
+ (err.message.includes('User rejected the request') ||
40
+ err.message.includes('user reject this request') ||
41
+ err.message === 'Request rejected')) {
42
+ return new UserRejectedRequestError(err);
43
+ }
44
+ return null;
45
+ };
46
+
47
+ export { normalizeRpcError };
@@ -78,7 +78,6 @@ class EthereumWallet extends walletConnectorCore.Wallet {
78
78
  */
79
79
  getWalletClient(chainId) {
80
80
  return _tslib.__awaiter(this, void 0, void 0, function* () {
81
- var _a;
82
81
  // Set active account if connector supports it, not AA atm
83
82
  if ('setActiveAccount' in this._connector) {
84
83
  this._connector.setActiveAccount(this.address);
@@ -88,18 +87,18 @@ class EthereumWallet extends walletConnectorCore.Wallet {
88
87
  throw new Error('Unable to retrieve WalletClient');
89
88
  }
90
89
  return viem.createWalletClient({
91
- account: (_a = walletClient.account) !== null && _a !== void 0 ? _a : this.address,
90
+ account: this.address,
92
91
  chain: walletClient.chain,
93
92
  transport: interceptTransport.interceptTransport({
94
- onPersonalSign: (_b) => _tslib.__awaiter(this, [_b], void 0, function* ({ provider, args }) {
93
+ onPersonalSign: (_a) => _tslib.__awaiter(this, [_a], void 0, function* ({ provider, args }) {
95
94
  yield this.sync();
96
95
  return provider.request(args);
97
96
  }),
98
- onSendTransaction: (_c) => _tslib.__awaiter(this, [_c], void 0, function* ({ provider, args }) {
97
+ onSendTransaction: (_b) => _tslib.__awaiter(this, [_b], void 0, function* ({ provider, args }) {
99
98
  yield this.sync();
100
99
  return provider.request(args);
101
100
  }),
102
- onSignTypedData: (_d) => _tslib.__awaiter(this, [_d], void 0, function* ({ provider, args }) {
101
+ onSignTypedData: (_c) => _tslib.__awaiter(this, [_c], void 0, function* ({ provider, args }) {
103
102
  yield this.sync();
104
103
  return provider.request(args);
105
104
  }),
@@ -74,7 +74,6 @@ class EthereumWallet extends Wallet {
74
74
  */
75
75
  getWalletClient(chainId) {
76
76
  return __awaiter(this, void 0, void 0, function* () {
77
- var _a;
78
77
  // Set active account if connector supports it, not AA atm
79
78
  if ('setActiveAccount' in this._connector) {
80
79
  this._connector.setActiveAccount(this.address);
@@ -84,18 +83,18 @@ class EthereumWallet extends Wallet {
84
83
  throw new Error('Unable to retrieve WalletClient');
85
84
  }
86
85
  return createWalletClient({
87
- account: (_a = walletClient.account) !== null && _a !== void 0 ? _a : this.address,
86
+ account: this.address,
88
87
  chain: walletClient.chain,
89
88
  transport: interceptTransport({
90
- onPersonalSign: (_b) => __awaiter(this, [_b], void 0, function* ({ provider, args }) {
89
+ onPersonalSign: (_a) => __awaiter(this, [_a], void 0, function* ({ provider, args }) {
91
90
  yield this.sync();
92
91
  return provider.request(args);
93
92
  }),
94
- onSendTransaction: (_c) => __awaiter(this, [_c], void 0, function* ({ provider, args }) {
93
+ onSendTransaction: (_b) => __awaiter(this, [_b], void 0, function* ({ provider, args }) {
95
94
  yield this.sync();
96
95
  return provider.request(args);
97
96
  }),
98
- onSignTypedData: (_d) => __awaiter(this, [_d], void 0, function* ({ provider, args }) {
97
+ onSignTypedData: (_c) => __awaiter(this, [_c], void 0, function* ({ provider, args }) {
99
98
  yield this.sync();
100
99
  return provider.request(args);
101
100
  }),