@dynamic-labs/ethereum-core 4.19.0 → 4.19.1
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 +7 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -8
- package/src/index.cjs +2 -0
- package/src/index.js +1 -0
- package/src/utils/index.d.ts +1 -0
- package/src/utils/normalizeRpcError/index.d.ts +1 -0
- package/src/utils/normalizeRpcError/normalizeRpcError.cjs +51 -0
- package/src/utils/normalizeRpcError/normalizeRpcError.d.ts +5 -0
- package/src/utils/normalizeRpcError/normalizeRpcError.js +47 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.19.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.19.0...v4.19.1) (2025-05-26)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* **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))
|
|
8
|
+
|
|
2
9
|
## [4.19.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.18.8...v4.19.0) (2025-05-23)
|
|
3
10
|
|
|
4
11
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/ethereum-core",
|
|
3
|
-
"version": "4.19.
|
|
3
|
+
"version": "4.19.1",
|
|
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.
|
|
23
|
-
"@dynamic-labs/logger": "4.19.
|
|
24
|
-
"@dynamic-labs/rpc-providers": "4.19.
|
|
25
|
-
"@dynamic-labs/types": "4.19.
|
|
26
|
-
"@dynamic-labs/utils": "4.19.
|
|
27
|
-
"@dynamic-labs/wallet-book": "4.19.
|
|
28
|
-
"@dynamic-labs/wallet-connector-core": "4.19.
|
|
22
|
+
"@dynamic-labs/assert-package-version": "4.19.1",
|
|
23
|
+
"@dynamic-labs/logger": "4.19.1",
|
|
24
|
+
"@dynamic-labs/rpc-providers": "4.19.1",
|
|
25
|
+
"@dynamic-labs/types": "4.19.1",
|
|
26
|
+
"@dynamic-labs/utils": "4.19.1",
|
|
27
|
+
"@dynamic-labs/wallet-book": "4.19.1",
|
|
28
|
+
"@dynamic-labs/wallet-connector-core": "4.19.1"
|
|
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
|
|
package/src/utils/index.d.ts
CHANGED
|
@@ -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,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 };
|