@dynamic-labs/ethereum 4.0.0-alpha.50 → 4.0.0-alpha.51
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,12 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.0.0-alpha.51](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.50...v4.0.0-alpha.51) (2024-12-30)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* changing copy of linking same wallet ([#7489](https://github.com/dynamic-labs/dynamic-auth/issues/7489)) ([e7d6b95](https://github.com/dynamic-labs/dynamic-auth/commit/e7d6b957043eaf8c06a4e8ef480ec9b027abdb5e))
|
|
8
|
+
* normalize user reject error from Rainbow and BitGet ([#7721](https://github.com/dynamic-labs/dynamic-auth/issues/7721)) ([78a2e41](https://github.com/dynamic-labs/dynamic-auth/commit/78a2e41e235743f0c652be746a8bee74d4e06629))
|
|
9
|
+
|
|
2
10
|
## [4.0.0-alpha.50](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.49...v4.0.0-alpha.50) (2024-12-28)
|
|
3
11
|
|
|
4
12
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/ethereum",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.51",
|
|
4
4
|
"description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"eventemitter3": "5.0.1",
|
|
25
25
|
"buffer": "6.0.3",
|
|
26
26
|
"@metamask/sdk": "0.30.1",
|
|
27
|
-
"@dynamic-labs/assert-package-version": "4.0.0-alpha.
|
|
28
|
-
"@dynamic-labs/embedded-wallet-evm": "4.0.0-alpha.
|
|
29
|
-
"@dynamic-labs/ethereum-core": "4.0.0-alpha.
|
|
30
|
-
"@dynamic-labs/logger": "4.0.0-alpha.
|
|
31
|
-
"@dynamic-labs/types": "4.0.0-alpha.
|
|
32
|
-
"@dynamic-labs/utils": "4.0.0-alpha.
|
|
33
|
-
"@dynamic-labs/wallet-book": "4.0.0-alpha.
|
|
34
|
-
"@dynamic-labs/wallet-connector-core": "4.0.0-alpha.
|
|
27
|
+
"@dynamic-labs/assert-package-version": "4.0.0-alpha.51",
|
|
28
|
+
"@dynamic-labs/embedded-wallet-evm": "4.0.0-alpha.51",
|
|
29
|
+
"@dynamic-labs/ethereum-core": "4.0.0-alpha.51",
|
|
30
|
+
"@dynamic-labs/logger": "4.0.0-alpha.51",
|
|
31
|
+
"@dynamic-labs/types": "4.0.0-alpha.51",
|
|
32
|
+
"@dynamic-labs/utils": "4.0.0-alpha.51",
|
|
33
|
+
"@dynamic-labs/wallet-book": "4.0.0-alpha.51",
|
|
34
|
+
"@dynamic-labs/wallet-connector-core": "4.0.0-alpha.51"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"viem": "^2.7.12"
|
|
@@ -11,10 +11,41 @@ var viem = require('viem');
|
|
|
11
11
|
*/
|
|
12
12
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
13
|
const normalizeRpcError = (err) => {
|
|
14
|
-
|
|
15
|
-
|
|
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;
|
|
16
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
|
+
*/
|
|
17
33
|
throw err;
|
|
18
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
|
+
};
|
|
19
50
|
|
|
20
51
|
exports.normalizeRpcError = normalizeRpcError;
|
|
@@ -7,10 +7,41 @@ import { UserRejectedRequestError } from 'viem';
|
|
|
7
7
|
*/
|
|
8
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
9
|
const normalizeRpcError = (err) => {
|
|
10
|
-
|
|
11
|
-
|
|
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;
|
|
12
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
|
+
*/
|
|
13
29
|
throw err;
|
|
14
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
|
+
};
|
|
15
46
|
|
|
16
47
|
export { normalizeRpcError };
|