@dynamic-labs/ethereum 1.4.4 → 1.4.6
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 +16 -0
- package/package.json +9 -9
- package/src/coinbase/client/client.cjs +12 -12
- package/src/coinbase/client/client.d.ts +3 -2
- package/src/coinbase/client/client.js +12 -12
- package/src/coinbase/client/types.d.ts +6 -3
- package/src/coinbase/coinbase.cjs +3 -7
- package/src/coinbase/coinbase.d.ts +1 -1
- package/src/coinbase/coinbase.js +4 -8
- package/src/injected/InjectedWalletBase.cjs +23 -13
- package/src/injected/InjectedWalletBase.js +23 -13
- package/src/injected/Zerion.d.ts +2 -15
- package/src/injected/fetchInjectedWalletConnectors.cjs +22 -0
- package/src/injected/fetchInjectedWalletConnectors.js +22 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
|
|
2
|
+
### [1.4.6](https://github.com/dynamic-labs/DynamicAuth/compare/v1.4.5...v1.4.6) (2024-04-09)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* coinbase improvements ([#5268](https://github.com/dynamic-labs/DynamicAuth/issues/5268)) ([#5273](https://github.com/dynamic-labs/DynamicAuth/issues/5273)) ([2d63dee](https://github.com/dynamic-labs/DynamicAuth/commit/2d63dee8679771d353b2ef4667a661c4a039a5c5))
|
|
8
|
+
* show qr code for metamask on desktop when not installed ([#5262](https://github.com/dynamic-labs/DynamicAuth/issues/5262)) ([#5263](https://github.com/dynamic-labs/DynamicAuth/issues/5263)) ([de8fdbe](https://github.com/dynamic-labs/DynamicAuth/commit/de8fdbeddf485d772f2d691d584fc3904dc5b5c9))
|
|
9
|
+
|
|
10
|
+
### [1.4.5](https://github.com/dynamic-labs/DynamicAuth/compare/v1.4.4...v1.4.5) (2024-04-05)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* use in-app browser deeplink for metamask ([#5176](https://github.com/dynamic-labs/DynamicAuth/issues/5176)) ([#5203](https://github.com/dynamic-labs/DynamicAuth/issues/5203)) ([63951d8](https://github.com/dynamic-labs/DynamicAuth/commit/63951d8896ea073e595e4a1e92bfe22731b012f4))
|
|
16
|
+
* clear user wallets immediately on logout ([#5238](https://github.com/dynamic-labs/DynamicAuth/issues/5238)) ([13b55a7](https://github.com/dynamic-labs/DynamicAuth/commit/13b55a7070f6f159504bf05b503848cc2c5ed445)), closes [#5211](https://github.com/dynamic-labs/DynamicAuth/issues/5211)
|
|
17
|
+
|
|
2
18
|
### [1.4.4](https://github.com/dynamic-labs/DynamicAuth/compare/v1.4.3...v1.4.4) (2024-04-01)
|
|
3
19
|
|
|
4
20
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/ethereum",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.6",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -26,18 +26,18 @@
|
|
|
26
26
|
"./package.json": "./package.json"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@coinbase/wallet-sdk": "3.9.2",
|
|
30
29
|
"@walletconnect/client": "1.8.0",
|
|
30
|
+
"@coinbase/wallet-sdk": "3.9.3",
|
|
31
31
|
"@walletconnect/ethereum-provider": "2.11.2",
|
|
32
32
|
"eventemitter3": "5.0.1",
|
|
33
33
|
"buffer": "6.0.3",
|
|
34
|
-
"@dynamic-labs/rpc-providers": "1.4.
|
|
35
|
-
"@dynamic-labs/turnkey": "1.4.
|
|
36
|
-
"@dynamic-labs/types": "1.4.
|
|
37
|
-
"@dynamic-labs/utils": "1.4.
|
|
38
|
-
"@dynamic-labs/viem-utils": "1.4.
|
|
39
|
-
"@dynamic-labs/wallet-book": "1.4.
|
|
40
|
-
"@dynamic-labs/wallet-connector-core": "1.4.
|
|
34
|
+
"@dynamic-labs/rpc-providers": "1.4.6",
|
|
35
|
+
"@dynamic-labs/turnkey": "1.4.6",
|
|
36
|
+
"@dynamic-labs/types": "1.4.6",
|
|
37
|
+
"@dynamic-labs/utils": "1.4.6",
|
|
38
|
+
"@dynamic-labs/viem-utils": "1.4.6",
|
|
39
|
+
"@dynamic-labs/wallet-book": "1.4.6",
|
|
40
|
+
"@dynamic-labs/wallet-connector-core": "1.4.6",
|
|
41
41
|
"stream": "0.0.2"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
@@ -10,11 +10,15 @@ var constants = require('../../constants.cjs');
|
|
|
10
10
|
|
|
11
11
|
const jsonRpcUrl = `https://mainnet.infura.io/v3/${constants.INFURA_ID}`;
|
|
12
12
|
const chainId = 1;
|
|
13
|
+
// storing a reference to the coinbase sdk so that we can call getQrUrl on it when we need a fresh qr code
|
|
14
|
+
let coinbaseSdk;
|
|
15
|
+
// storing a reference to the coinbase provider because the provider methods work better when
|
|
16
|
+
// they are called on the same instance
|
|
13
17
|
let coinbaseProvider;
|
|
14
|
-
const
|
|
18
|
+
const getCoinbaseClient = ({ opts: { appLogoUrl, appName = '', evmNetworks = [] } = {}, }) => {
|
|
15
19
|
var _a, _b;
|
|
16
20
|
if (!coinbaseProvider) {
|
|
17
|
-
|
|
21
|
+
coinbaseSdk = new walletSdk.CoinbaseWalletSDK({
|
|
18
22
|
appLogoUrl,
|
|
19
23
|
appName,
|
|
20
24
|
enableMobileWalletLink: true,
|
|
@@ -25,21 +29,17 @@ const getCoinbaseProvider = ({ opts: { appLogoUrl, appName = '', evmNetworks = [
|
|
|
25
29
|
const rpcUrl = ((_a = network === null || network === void 0 ? void 0 : network.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) ||
|
|
26
30
|
((_b = network === null || network === void 0 ? void 0 : network.rpcUrls) === null || _b === void 0 ? void 0 : _b[0]) ||
|
|
27
31
|
jsonRpcUrl;
|
|
28
|
-
coinbaseProvider =
|
|
32
|
+
coinbaseProvider = coinbaseSdk.makeWeb3Provider(rpcUrl, chainId);
|
|
29
33
|
}
|
|
30
|
-
return coinbaseProvider;
|
|
34
|
+
return { provider: coinbaseProvider, sdk: coinbaseSdk };
|
|
31
35
|
};
|
|
32
36
|
const killCoinbaseSession = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
33
37
|
yield (coinbaseProvider === null || coinbaseProvider === void 0 ? void 0 : coinbaseProvider.close());
|
|
34
|
-
coinbaseProvider === null || coinbaseProvider === void 0 ? void 0 : coinbaseProvider.disconnect();
|
|
35
|
-
// We needed to remove the provider, because after a disconnect the initial settings that
|
|
36
|
-
// were set in the SDK reset, and they need to be initialized again.
|
|
37
|
-
coinbaseProvider = undefined;
|
|
38
38
|
});
|
|
39
39
|
const fetchPublicAddress = (coinbaseProviderOpts, opts) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
40
40
|
var _a;
|
|
41
|
-
const provider =
|
|
42
|
-
const
|
|
41
|
+
const { provider, sdk } = getCoinbaseClient({ opts: coinbaseProviderOpts });
|
|
42
|
+
const qrUrl = sdk.getQrUrl();
|
|
43
43
|
if (!qrUrl) {
|
|
44
44
|
throw new utils.DynamicError('no qr url available');
|
|
45
45
|
}
|
|
@@ -50,7 +50,7 @@ const fetchPublicAddress = (coinbaseProviderOpts, opts) => _tslib.__awaiter(void
|
|
|
50
50
|
return address;
|
|
51
51
|
});
|
|
52
52
|
const signMessage = (coinbaseProviderOpts, messageToSign) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
-
const provider =
|
|
53
|
+
const { provider } = getCoinbaseClient({ opts: coinbaseProviderOpts });
|
|
54
54
|
const [address] = yield provider.request({
|
|
55
55
|
method: 'eth_requestAccounts',
|
|
56
56
|
});
|
|
@@ -67,6 +67,6 @@ const signMessage = (coinbaseProviderOpts, messageToSign) => _tslib.__awaiter(vo
|
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
exports.fetchPublicAddress = fetchPublicAddress;
|
|
70
|
-
exports.
|
|
70
|
+
exports.getCoinbaseClient = getCoinbaseClient;
|
|
71
71
|
exports.killCoinbaseSession = killCoinbaseSession;
|
|
72
72
|
exports.signMessage = signMessage;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FetchPublicAddressOpts } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
-
import {
|
|
3
|
-
export declare const
|
|
2
|
+
import { GetCoinbaseClient, GetCoinbaseProviderOpts } from './types';
|
|
3
|
+
export declare const clearClientVariables: () => void;
|
|
4
|
+
export declare const getCoinbaseClient: GetCoinbaseClient;
|
|
4
5
|
export declare const killCoinbaseSession: () => Promise<void>;
|
|
5
6
|
export declare const fetchPublicAddress: (coinbaseProviderOpts: GetCoinbaseProviderOpts, opts?: FetchPublicAddressOpts) => Promise<string | undefined>;
|
|
6
7
|
export declare const signMessage: (coinbaseProviderOpts: GetCoinbaseProviderOpts, messageToSign: string) => Promise<string | undefined>;
|
|
@@ -6,11 +6,15 @@ import { INFURA_ID } from '../../constants.js';
|
|
|
6
6
|
|
|
7
7
|
const jsonRpcUrl = `https://mainnet.infura.io/v3/${INFURA_ID}`;
|
|
8
8
|
const chainId = 1;
|
|
9
|
+
// storing a reference to the coinbase sdk so that we can call getQrUrl on it when we need a fresh qr code
|
|
10
|
+
let coinbaseSdk;
|
|
11
|
+
// storing a reference to the coinbase provider because the provider methods work better when
|
|
12
|
+
// they are called on the same instance
|
|
9
13
|
let coinbaseProvider;
|
|
10
|
-
const
|
|
14
|
+
const getCoinbaseClient = ({ opts: { appLogoUrl, appName = '', evmNetworks = [] } = {}, }) => {
|
|
11
15
|
var _a, _b;
|
|
12
16
|
if (!coinbaseProvider) {
|
|
13
|
-
|
|
17
|
+
coinbaseSdk = new CoinbaseWalletSDK({
|
|
14
18
|
appLogoUrl,
|
|
15
19
|
appName,
|
|
16
20
|
enableMobileWalletLink: true,
|
|
@@ -21,21 +25,17 @@ const getCoinbaseProvider = ({ opts: { appLogoUrl, appName = '', evmNetworks = [
|
|
|
21
25
|
const rpcUrl = ((_a = network === null || network === void 0 ? void 0 : network.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) ||
|
|
22
26
|
((_b = network === null || network === void 0 ? void 0 : network.rpcUrls) === null || _b === void 0 ? void 0 : _b[0]) ||
|
|
23
27
|
jsonRpcUrl;
|
|
24
|
-
coinbaseProvider =
|
|
28
|
+
coinbaseProvider = coinbaseSdk.makeWeb3Provider(rpcUrl, chainId);
|
|
25
29
|
}
|
|
26
|
-
return coinbaseProvider;
|
|
30
|
+
return { provider: coinbaseProvider, sdk: coinbaseSdk };
|
|
27
31
|
};
|
|
28
32
|
const killCoinbaseSession = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
33
|
yield (coinbaseProvider === null || coinbaseProvider === void 0 ? void 0 : coinbaseProvider.close());
|
|
30
|
-
coinbaseProvider === null || coinbaseProvider === void 0 ? void 0 : coinbaseProvider.disconnect();
|
|
31
|
-
// We needed to remove the provider, because after a disconnect the initial settings that
|
|
32
|
-
// were set in the SDK reset, and they need to be initialized again.
|
|
33
|
-
coinbaseProvider = undefined;
|
|
34
34
|
});
|
|
35
35
|
const fetchPublicAddress = (coinbaseProviderOpts, opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
36
|
var _a;
|
|
37
|
-
const provider =
|
|
38
|
-
const
|
|
37
|
+
const { provider, sdk } = getCoinbaseClient({ opts: coinbaseProviderOpts });
|
|
38
|
+
const qrUrl = sdk.getQrUrl();
|
|
39
39
|
if (!qrUrl) {
|
|
40
40
|
throw new DynamicError('no qr url available');
|
|
41
41
|
}
|
|
@@ -46,7 +46,7 @@ const fetchPublicAddress = (coinbaseProviderOpts, opts) => __awaiter(void 0, voi
|
|
|
46
46
|
return address;
|
|
47
47
|
});
|
|
48
48
|
const signMessage = (coinbaseProviderOpts, messageToSign) => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
-
const provider =
|
|
49
|
+
const { provider } = getCoinbaseClient({ opts: coinbaseProviderOpts });
|
|
50
50
|
const [address] = yield provider.request({
|
|
51
51
|
method: 'eth_requestAccounts',
|
|
52
52
|
});
|
|
@@ -62,4 +62,4 @@ const signMessage = (coinbaseProviderOpts, messageToSign) => __awaiter(void 0, v
|
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
export { fetchPublicAddress,
|
|
65
|
+
export { fetchPublicAddress, getCoinbaseClient, killCoinbaseSession, signMessage };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CoinbaseWalletProvider } from '@coinbase/wallet-sdk';
|
|
1
|
+
import CoinbaseWalletSDK, { CoinbaseWalletProvider } from '@coinbase/wallet-sdk';
|
|
2
2
|
import { GenericNetwork } from '@dynamic-labs/types';
|
|
3
3
|
export type GetCoinbaseProviderOpts = {
|
|
4
4
|
appLogoUrl?: string;
|
|
@@ -8,7 +8,10 @@ export type GetCoinbaseProviderOpts = {
|
|
|
8
8
|
export type CoinbaseProviderHandlerOpts = {
|
|
9
9
|
onDisconnect(): Promise<void>;
|
|
10
10
|
};
|
|
11
|
-
export type
|
|
11
|
+
export type GetCoinbaseClient = (args: {
|
|
12
12
|
handlers?: CoinbaseProviderHandlerOpts;
|
|
13
13
|
opts?: GetCoinbaseProviderOpts;
|
|
14
|
-
}) =>
|
|
14
|
+
}) => {
|
|
15
|
+
provider: CoinbaseWalletProvider;
|
|
16
|
+
sdk: CoinbaseWalletSDK;
|
|
17
|
+
};
|
|
@@ -6,12 +6,8 @@ var _tslib = require('../../_virtual/_tslib.cjs');
|
|
|
6
6
|
var viem = require('viem');
|
|
7
7
|
var walletBook = require('@dynamic-labs/wallet-book');
|
|
8
8
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
9
|
-
require('../polyfills.cjs');
|
|
10
|
-
require('@dynamic-labs/turnkey');
|
|
11
|
-
require('@dynamic-labs/utils');
|
|
12
9
|
var ethProviderHelper = require('../ethProviderHelper.cjs');
|
|
13
10
|
var EthWalletConnector = require('../EthWalletConnector.cjs');
|
|
14
|
-
require('../walletConnect/walletConnectV2.cjs');
|
|
15
11
|
var client = require('./client/client.cjs');
|
|
16
12
|
|
|
17
13
|
class Coinbase extends EthWalletConnector.EthWalletConnector {
|
|
@@ -53,9 +49,9 @@ class Coinbase extends EthWalletConnector.EthWalletConnector {
|
|
|
53
49
|
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findWalletClient(chainId);
|
|
54
50
|
}
|
|
55
51
|
return viem.createWalletClient({
|
|
56
|
-
transport: viem.custom(client.
|
|
52
|
+
transport: viem.custom(client.getCoinbaseClient({
|
|
57
53
|
opts: this.coinbaseProviderOpts,
|
|
58
|
-
})),
|
|
54
|
+
}).provider),
|
|
59
55
|
});
|
|
60
56
|
}
|
|
61
57
|
isInstalledOnBrowser() {
|
|
@@ -88,7 +84,7 @@ class Coinbase extends EthWalletConnector.EthWalletConnector {
|
|
|
88
84
|
});
|
|
89
85
|
}
|
|
90
86
|
setupCoinbaseProviderEventListeners() {
|
|
91
|
-
const provider = client.
|
|
87
|
+
const { provider } = client.getCoinbaseClient({
|
|
92
88
|
opts: this.coinbaseProviderOpts,
|
|
93
89
|
});
|
|
94
90
|
if (!provider) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Chain, FetchPublicAddressOpts } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
-
import { EthProviderHelper } from '
|
|
2
|
+
import { EthProviderHelper } from '../ethProviderHelper';
|
|
3
3
|
import { EthWalletConnector, EthWalletConnectorOpts } from '../EthWalletConnector';
|
|
4
4
|
type CoinbaseOpts = EthWalletConnectorOpts & {
|
|
5
5
|
appLogoUrl?: string;
|
package/src/coinbase/coinbase.js
CHANGED
|
@@ -2,13 +2,9 @@ import { __rest, __awaiter } from '../../_virtual/_tslib.js';
|
|
|
2
2
|
import { createWalletClient, custom } from 'viem';
|
|
3
3
|
import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
4
4
|
import { eventListenerHandlers } from '@dynamic-labs/wallet-connector-core';
|
|
5
|
-
import '../polyfills.js';
|
|
6
|
-
import '@dynamic-labs/turnkey';
|
|
7
|
-
import '@dynamic-labs/utils';
|
|
8
5
|
import { EthProviderHelper } from '../ethProviderHelper.js';
|
|
9
6
|
import { EthWalletConnector } from '../EthWalletConnector.js';
|
|
10
|
-
import '
|
|
11
|
-
import { getCoinbaseProvider, fetchPublicAddress, signMessage, killCoinbaseSession } from './client/client.js';
|
|
7
|
+
import { getCoinbaseClient, fetchPublicAddress, signMessage, killCoinbaseSession } from './client/client.js';
|
|
12
8
|
|
|
13
9
|
class Coinbase extends EthWalletConnector {
|
|
14
10
|
constructor(_a) {
|
|
@@ -49,9 +45,9 @@ class Coinbase extends EthWalletConnector {
|
|
|
49
45
|
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findWalletClient(chainId);
|
|
50
46
|
}
|
|
51
47
|
return createWalletClient({
|
|
52
|
-
transport: custom(
|
|
48
|
+
transport: custom(getCoinbaseClient({
|
|
53
49
|
opts: this.coinbaseProviderOpts,
|
|
54
|
-
})),
|
|
50
|
+
}).provider),
|
|
55
51
|
});
|
|
56
52
|
}
|
|
57
53
|
isInstalledOnBrowser() {
|
|
@@ -84,7 +80,7 @@ class Coinbase extends EthWalletConnector {
|
|
|
84
80
|
});
|
|
85
81
|
}
|
|
86
82
|
setupCoinbaseProviderEventListeners() {
|
|
87
|
-
const provider =
|
|
83
|
+
const { provider } = getCoinbaseClient({
|
|
88
84
|
opts: this.coinbaseProviderOpts,
|
|
89
85
|
});
|
|
90
86
|
if (!provider) {
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
4
4
|
var walletBook = require('@dynamic-labs/wallet-book');
|
|
5
|
+
var utils = require('@dynamic-labs/utils');
|
|
5
6
|
var ethProviderHelper = require('../ethProviderHelper.cjs');
|
|
6
7
|
var EthWalletConnector = require('../EthWalletConnector.cjs');
|
|
7
|
-
|
|
8
|
+
require('../walletConnect/walletConnectV2.cjs');
|
|
8
9
|
var walletConnect = require('../walletConnect/walletConnect.cjs');
|
|
9
10
|
|
|
10
11
|
class InjectedWalletBase extends EthWalletConnector.EthWalletConnector {
|
|
@@ -27,19 +28,28 @@ class InjectedWalletBase extends EthWalletConnector.EthWalletConnector {
|
|
|
27
28
|
return this.ethProviderHelper;
|
|
28
29
|
}
|
|
29
30
|
getMobileOrInstalledWallet() {
|
|
30
|
-
var _a, _b
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
var _a, _b;
|
|
32
|
+
if (!this.wallet) {
|
|
33
|
+
this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
|
|
34
|
+
}
|
|
35
|
+
if (this.isInstalledOnBrowser()) {
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
// this is to handle the case where the user is in a webview.
|
|
39
|
+
// when the user is in a webview, customers should set the deepLinkPreference prop to universal,
|
|
40
|
+
// in which case this condition will be false, and the SDK will use WalletConnect (if available)
|
|
41
|
+
if (((_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.mobile) === null || _b === void 0 ? void 0 : _b.inAppBrowser) &&
|
|
42
|
+
this.constructorProps.deepLinkPreference !== 'universal' &&
|
|
43
|
+
utils.isMobile()) {
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
// this is the case where the wallet is not installed on the browser and
|
|
47
|
+
// it does not support WalletConnect. in this case, the SDK will instruct
|
|
48
|
+
// the user to download the wallet extension
|
|
49
|
+
if (!this.walletConnectorFallback) {
|
|
50
|
+
return this;
|
|
41
51
|
}
|
|
42
|
-
return this;
|
|
52
|
+
return new walletConnect.WalletConnect(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
|
|
43
53
|
}
|
|
44
54
|
setupEventListeners() {
|
|
45
55
|
const provider = this.getWalletClient();
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
2
2
|
import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
3
|
+
import { isMobile } from '@dynamic-labs/utils';
|
|
3
4
|
import { EthProviderHelper } from '../ethProviderHelper.js';
|
|
4
5
|
import { EthWalletConnector } from '../EthWalletConnector.js';
|
|
5
|
-
import
|
|
6
|
+
import '../walletConnect/walletConnectV2.js';
|
|
6
7
|
import { WalletConnect } from '../walletConnect/walletConnect.js';
|
|
7
8
|
|
|
8
9
|
class InjectedWalletBase extends EthWalletConnector {
|
|
@@ -25,19 +26,28 @@ class InjectedWalletBase extends EthWalletConnector {
|
|
|
25
26
|
return this.ethProviderHelper;
|
|
26
27
|
}
|
|
27
28
|
getMobileOrInstalledWallet() {
|
|
28
|
-
var _a, _b
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
var _a, _b;
|
|
30
|
+
if (!this.wallet) {
|
|
31
|
+
this.wallet = findWalletBookWallet(this.walletBook, this.key);
|
|
32
|
+
}
|
|
33
|
+
if (this.isInstalledOnBrowser()) {
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
// this is to handle the case where the user is in a webview.
|
|
37
|
+
// when the user is in a webview, customers should set the deepLinkPreference prop to universal,
|
|
38
|
+
// in which case this condition will be false, and the SDK will use WalletConnect (if available)
|
|
39
|
+
if (((_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.mobile) === null || _b === void 0 ? void 0 : _b.inAppBrowser) &&
|
|
40
|
+
this.constructorProps.deepLinkPreference !== 'universal' &&
|
|
41
|
+
isMobile()) {
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
// this is the case where the wallet is not installed on the browser and
|
|
45
|
+
// it does not support WalletConnect. in this case, the SDK will instruct
|
|
46
|
+
// the user to download the wallet extension
|
|
47
|
+
if (!this.walletConnectorFallback) {
|
|
48
|
+
return this;
|
|
39
49
|
}
|
|
40
|
-
return this;
|
|
50
|
+
return new WalletConnect(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
|
|
41
51
|
}
|
|
42
52
|
setupEventListeners() {
|
|
43
53
|
const provider = this.getWalletClient();
|
package/src/injected/Zerion.d.ts
CHANGED
|
@@ -1,23 +1,10 @@
|
|
|
1
|
+
import { WalletSchema } from '@dynamic-labs/wallet-book';
|
|
1
2
|
import { EthWalletConnectorOpts } from '../EthWalletConnector';
|
|
2
3
|
import InjectedWalletBase from './InjectedWalletBase';
|
|
3
4
|
export declare class Zerion extends InjectedWalletBase {
|
|
4
5
|
name: string;
|
|
5
6
|
overrideKey: string;
|
|
6
|
-
wallet:
|
|
7
|
-
eip6963Config: {
|
|
8
|
-
rdns: string;
|
|
9
|
-
};
|
|
10
|
-
filterFromWalletConnect: boolean;
|
|
11
|
-
injectedConfig: {
|
|
12
|
-
chain: string;
|
|
13
|
-
extensionLocators: {
|
|
14
|
-
flag: string;
|
|
15
|
-
value: boolean;
|
|
16
|
-
}[];
|
|
17
|
-
windowLocations: string[];
|
|
18
|
-
}[];
|
|
19
|
-
name: string;
|
|
20
|
-
};
|
|
7
|
+
wallet: WalletSchema;
|
|
21
8
|
constructor(props: EthWalletConnectorOpts);
|
|
22
9
|
isInstalledOnBrowser(): boolean;
|
|
23
10
|
}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
6
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
5
7
|
var InjectedWalletBase = require('./InjectedWalletBase.cjs');
|
|
6
8
|
var PhantomEvm = require('./PhantomEvm.cjs');
|
|
7
9
|
var ExodusEvm = require('./ExodusEvm.cjs');
|
|
@@ -39,6 +41,26 @@ const fetchInjectedWalletConnector = ({ walletBook, }) => {
|
|
|
39
41
|
// this is the key from the wallet book entry so that we don't purely rely on the normalized name
|
|
40
42
|
this.overrideKey = key;
|
|
41
43
|
}
|
|
44
|
+
fetchPublicAddress() {
|
|
45
|
+
const _super = Object.create(null, {
|
|
46
|
+
fetchPublicAddress: { get: () => super.fetchPublicAddress }
|
|
47
|
+
});
|
|
48
|
+
var _a;
|
|
49
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
if (this.isInstalledOnBrowser()) {
|
|
51
|
+
return _super.fetchPublicAddress.call(this);
|
|
52
|
+
}
|
|
53
|
+
const inAppBrowserBase = (_a = this.wallet.mobile) === null || _a === void 0 ? void 0 : _a.inAppBrowser;
|
|
54
|
+
if (!inAppBrowserBase) {
|
|
55
|
+
const error = new Error(`No inAppBrowserBase found for ${this.name}.`);
|
|
56
|
+
walletConnectorCore.logger.error(error.message);
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
const cleanedTargetUrl = window.location.href.replace('https://', '');
|
|
60
|
+
window.location.href = `${inAppBrowserBase}/${cleanedTargetUrl}`;
|
|
61
|
+
return undefined;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
42
64
|
};
|
|
43
65
|
});
|
|
44
66
|
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
2
|
+
import { logger } from '@dynamic-labs/wallet-connector-core';
|
|
1
3
|
import InjectedWalletBase from './InjectedWalletBase.js';
|
|
2
4
|
import { PhantomEvm } from './PhantomEvm.js';
|
|
3
5
|
import { ExodusEvm } from './ExodusEvm.js';
|
|
@@ -35,6 +37,26 @@ const fetchInjectedWalletConnector = ({ walletBook, }) => {
|
|
|
35
37
|
// this is the key from the wallet book entry so that we don't purely rely on the normalized name
|
|
36
38
|
this.overrideKey = key;
|
|
37
39
|
}
|
|
40
|
+
fetchPublicAddress() {
|
|
41
|
+
const _super = Object.create(null, {
|
|
42
|
+
fetchPublicAddress: { get: () => super.fetchPublicAddress }
|
|
43
|
+
});
|
|
44
|
+
var _a;
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
if (this.isInstalledOnBrowser()) {
|
|
47
|
+
return _super.fetchPublicAddress.call(this);
|
|
48
|
+
}
|
|
49
|
+
const inAppBrowserBase = (_a = this.wallet.mobile) === null || _a === void 0 ? void 0 : _a.inAppBrowser;
|
|
50
|
+
if (!inAppBrowserBase) {
|
|
51
|
+
const error = new Error(`No inAppBrowserBase found for ${this.name}.`);
|
|
52
|
+
logger.error(error.message);
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
const cleanedTargetUrl = window.location.href.replace('https://', '');
|
|
56
|
+
window.location.href = `${inAppBrowserBase}/${cleanedTargetUrl}`;
|
|
57
|
+
return undefined;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
38
60
|
};
|
|
39
61
|
});
|
|
40
62
|
};
|