@dynamic-labs/ethereum 4.92.0 → 4.92.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 +11 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +11 -11
- package/src/EthereumWalletConnectors.cjs +1 -1
- package/src/EthereumWalletConnectors.js +1 -1
- package/src/injected/InjectedWalletBase.cjs +32 -0
- package/src/injected/InjectedWalletBase.d.ts +8699 -0
- package/src/injected/InjectedWalletBase.js +32 -0
- package/src/injected/PhantomEvm.cjs +9 -17
- package/src/injected/PhantomEvm.d.ts +1 -1
- package/src/injected/PhantomEvm.js +9 -17
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
3
|
import { EthereumWalletConnector } from '@dynamic-labs/ethereum-core';
|
|
4
|
+
import { isMobile, WalletRequiresInAppBrowserError } from '@dynamic-labs/utils';
|
|
4
5
|
import { EthProviderHelper } from '../ethProviderHelper.js';
|
|
5
6
|
import { logger } from '../utils/logger.js';
|
|
6
7
|
import { WalletConnectConnector } from '../walletConnect/WalletConnectConnector/WalletConnectConnector.js';
|
|
@@ -68,9 +69,40 @@ class InjectedWalletBase extends EthereumWalletConnector {
|
|
|
68
69
|
yield this.getAddress();
|
|
69
70
|
});
|
|
70
71
|
}
|
|
72
|
+
getSigner() {
|
|
73
|
+
const _super = Object.create(null, {
|
|
74
|
+
getSigner: { get: () => super.getSigner }
|
|
75
|
+
});
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
const signer = yield _super.getSigner.call(this);
|
|
78
|
+
if (signer) {
|
|
79
|
+
return signer;
|
|
80
|
+
}
|
|
81
|
+
// On mobile web (outside the wallet's in-app browser) there is no injected
|
|
82
|
+
// provider for these wallets, so signing silently returns nothing. Redirect
|
|
83
|
+
// into the wallet's in-app browser so signing can continue there, or throw a
|
|
84
|
+
// clear error when neither a provider nor a redirect is possible.
|
|
85
|
+
if (isMobile() && !this.isInstalledOnBrowser()) {
|
|
86
|
+
const didOpenInAppBrowser = this.openInAppBrowserIfRequired();
|
|
87
|
+
if (!didOpenInAppBrowser) {
|
|
88
|
+
throw new WalletRequiresInAppBrowserError(this.name);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return undefined;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
71
94
|
signMessage(messageToSign) {
|
|
72
95
|
return __awaiter(this, void 0, void 0, function* () {
|
|
73
96
|
var _a;
|
|
97
|
+
// Trigger the in-app-browser redirect up front (mirroring getAddress) so
|
|
98
|
+
// that on mobile web an in-app-browser wallet redirects into its in-app
|
|
99
|
+
// browser instead of silently signing nothing. Delegating to the helper
|
|
100
|
+
// afterwards keeps signing to a single address request (no duplicate wallet
|
|
101
|
+
// prompt), since the helper resolves the address itself.
|
|
102
|
+
const didOpenInAppBrowser = this.openInAppBrowserIfRequired();
|
|
103
|
+
if (didOpenInAppBrowser) {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
74
106
|
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.signMessage(messageToSign);
|
|
75
107
|
});
|
|
76
108
|
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
6
|
var utils = require('@dynamic-labs/utils');
|
|
8
7
|
var InjectedWalletBase = require('./InjectedWalletBase.cjs');
|
|
9
8
|
|
|
@@ -13,22 +12,15 @@ class PhantomEvm extends InjectedWalletBase.InjectedWalletBase {
|
|
|
13
12
|
this.name = 'Phantom';
|
|
14
13
|
this.overrideKey = 'phantomevm';
|
|
15
14
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
utils.handleMobileWalletRedirect({
|
|
26
|
-
nativeLink: 'phantom://browse',
|
|
27
|
-
universalLink: 'https://phantom.app/ul/browse',
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
return undefined;
|
|
31
|
-
});
|
|
15
|
+
openInAppBrowserIfRequired() {
|
|
16
|
+
if (utils.isMobile() && !this.isInstalledOnBrowser()) {
|
|
17
|
+
utils.handleMobileWalletRedirect({
|
|
18
|
+
nativeLink: 'phantom://browse',
|
|
19
|
+
universalLink: 'https://phantom.app/ul/browse',
|
|
20
|
+
});
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
return false;
|
|
32
24
|
}
|
|
33
25
|
canGetChainAddress() {
|
|
34
26
|
var _a, _b;
|
|
@@ -2,6 +2,6 @@ import { InjectedWalletBase } from './InjectedWalletBase';
|
|
|
2
2
|
export declare class PhantomEvm extends InjectedWalletBase {
|
|
3
3
|
name: string;
|
|
4
4
|
overrideKey: string;
|
|
5
|
-
|
|
5
|
+
openInAppBrowserIfRequired(): boolean;
|
|
6
6
|
canGetChainAddress(): boolean;
|
|
7
7
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
2
|
import { isMobile, handleMobileWalletRedirect } from '@dynamic-labs/utils';
|
|
4
3
|
import { InjectedWalletBase } from './InjectedWalletBase.js';
|
|
5
4
|
|
|
@@ -9,22 +8,15 @@ class PhantomEvm extends InjectedWalletBase {
|
|
|
9
8
|
this.name = 'Phantom';
|
|
10
9
|
this.overrideKey = 'phantomevm';
|
|
11
10
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
handleMobileWalletRedirect({
|
|
22
|
-
nativeLink: 'phantom://browse',
|
|
23
|
-
universalLink: 'https://phantom.app/ul/browse',
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
return undefined;
|
|
27
|
-
});
|
|
11
|
+
openInAppBrowserIfRequired() {
|
|
12
|
+
if (isMobile() && !this.isInstalledOnBrowser()) {
|
|
13
|
+
handleMobileWalletRedirect({
|
|
14
|
+
nativeLink: 'phantom://browse',
|
|
15
|
+
universalLink: 'https://phantom.app/ul/browse',
|
|
16
|
+
});
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
28
20
|
}
|
|
29
21
|
canGetChainAddress() {
|
|
30
22
|
var _a, _b;
|