@dynamic-labs/ethereum 2.0.0-alpha.9 → 2.0.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 +328 -0
- package/package.json +11 -9
- package/src/EthWalletConnector.cjs +27 -27
- package/src/EthWalletConnector.d.ts +13 -10
- package/src/EthWalletConnector.js +27 -27
- package/src/coinbase/client/client.cjs +14 -14
- package/src/coinbase/client/client.d.ts +5 -4
- package/src/coinbase/client/client.js +13 -13
- package/src/coinbase/client/types.d.ts +6 -3
- package/src/coinbase/coinbase.cjs +32 -15
- package/src/coinbase/coinbase.d.ts +5 -4
- package/src/coinbase/coinbase.js +33 -16
- package/src/ethProviderHelper.cjs +11 -6
- package/src/ethProviderHelper.d.ts +6 -4
- package/src/ethProviderHelper.js +11 -6
- package/src/index.cjs +5 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +4 -2
- package/src/injected/InjectedWalletBase.cjs +32 -15
- package/src/injected/InjectedWalletBase.d.ts +2 -2
- package/src/injected/InjectedWalletBase.js +32 -15
- package/src/injected/PhantomEvm.cjs +3 -3
- package/src/injected/PhantomEvm.d.ts +1 -1
- package/src/injected/PhantomEvm.js +3 -3
- package/src/injected/Zerion.cjs +38 -0
- package/src/injected/Zerion.d.ts +10 -0
- package/src/injected/Zerion.js +34 -0
- package/src/injected/fetchInjectedWalletConnectors.cjs +25 -0
- package/src/injected/fetchInjectedWalletConnectors.js +25 -0
- package/src/types.d.ts +1 -0
- package/src/utils/findEvmNetwork.d.ts +2 -2
- package/src/utils/getNameservice.cjs +45 -0
- package/src/utils/getNameservice.d.ts +6 -0
- package/src/utils/getNameservice.js +41 -0
- package/src/utils/index.d.ts +2 -0
- package/src/utils/isEthWalletConnector/index.d.ts +1 -0
- package/src/utils/isEthWalletConnector/isEthWalletConnector.cjs +7 -0
- package/src/utils/isEthWalletConnector/isEthWalletConnector.d.ts +3 -0
- package/src/utils/isEthWalletConnector/isEthWalletConnector.js +3 -0
- package/src/walletConnect/index.d.ts +1 -1
- package/src/walletConnect/walletConnect.cjs +118 -79
- package/src/walletConnect/walletConnect.d.ts +19 -18
- package/src/walletConnect/walletConnect.js +117 -78
package/src/index.cjs
CHANGED
|
@@ -14,12 +14,14 @@ require('@dynamic-labs/rpc-provider-ethereum');
|
|
|
14
14
|
var EthWalletConnector = require('./EthWalletConnector.cjs');
|
|
15
15
|
var ethProviderHelper = require('./ethProviderHelper.cjs');
|
|
16
16
|
var constants = require('./constants.cjs');
|
|
17
|
+
var isEthWalletConnector = require('./utils/isEthWalletConnector/isEthWalletConnector.cjs');
|
|
18
|
+
var getNameservice = require('./utils/getNameservice.cjs');
|
|
17
19
|
|
|
18
20
|
const EthereumWalletConnectors = (props) => [
|
|
19
21
|
...fetchInjectedWalletConnectors.injectedWalletOverrides,
|
|
20
22
|
...fetchInjectedWalletConnectors.fetchInjectedWalletConnector(props),
|
|
21
23
|
...fetchWalletConnectWallets.fetchWalletConnectWallets(props),
|
|
22
|
-
...turnkey.
|
|
24
|
+
...turnkey.TurnkeyEVMWalletConnectors(props),
|
|
23
25
|
coinbase.Coinbase,
|
|
24
26
|
fetchWalletConnectWallets.getWalletConnectConnector(),
|
|
25
27
|
];
|
|
@@ -31,4 +33,6 @@ exports.injectedWalletOverrides = fetchInjectedWalletConnectors.injectedWalletOv
|
|
|
31
33
|
exports.EthWalletConnector = EthWalletConnector.EthWalletConnector;
|
|
32
34
|
exports.EthProviderHelper = ethProviderHelper.EthProviderHelper;
|
|
33
35
|
exports.INFURA_ID = constants.INFURA_ID;
|
|
36
|
+
exports.isEthWalletConnector = isEthWalletConnector.isEthWalletConnector;
|
|
37
|
+
exports.getNameservice = getNameservice.getNameservice;
|
|
34
38
|
exports.EthereumWalletConnectors = EthereumWalletConnectors;
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import './polyfills.js';
|
|
2
|
-
import {
|
|
2
|
+
import { TurnkeyEVMWalletConnectors } from '@dynamic-labs/turnkey';
|
|
3
3
|
export { PhantomEvm } from './injected/PhantomEvm.js';
|
|
4
4
|
export { ExodusEvm } from './injected/ExodusEvm.js';
|
|
5
5
|
import { injectedWalletOverrides, fetchInjectedWalletConnector } from './injected/fetchInjectedWalletConnectors.js';
|
|
@@ -11,12 +11,14 @@ import '@dynamic-labs/rpc-provider-ethereum';
|
|
|
11
11
|
export { EthWalletConnector } from './EthWalletConnector.js';
|
|
12
12
|
export { EthProviderHelper } from './ethProviderHelper.js';
|
|
13
13
|
export { INFURA_ID } from './constants.js';
|
|
14
|
+
export { isEthWalletConnector } from './utils/isEthWalletConnector/isEthWalletConnector.js';
|
|
15
|
+
export { getNameservice } from './utils/getNameservice.js';
|
|
14
16
|
|
|
15
17
|
const EthereumWalletConnectors = (props) => [
|
|
16
18
|
...injectedWalletOverrides,
|
|
17
19
|
...fetchInjectedWalletConnector(props),
|
|
18
20
|
...fetchWalletConnectWallets(props),
|
|
19
|
-
...
|
|
21
|
+
...TurnkeyEVMWalletConnectors(props),
|
|
20
22
|
Coinbase,
|
|
21
23
|
getWalletConnectConnector(),
|
|
22
24
|
];
|
|
@@ -2,6 +2,7 @@
|
|
|
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
|
var walletConnect = require('../walletConnect/walletConnect.cjs');
|
|
@@ -20,18 +21,34 @@ class InjectedWalletBase extends EthWalletConnector.EthWalletConnector {
|
|
|
20
21
|
this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
|
|
21
22
|
}
|
|
22
23
|
if (this.wallet && !this.ethProviderHelper) {
|
|
23
|
-
this.ethProviderHelper = new ethProviderHelper.EthProviderHelper(this.wallet);
|
|
24
|
+
this.ethProviderHelper = new ethProviderHelper.EthProviderHelper(this.wallet, this);
|
|
24
25
|
}
|
|
25
26
|
// this.ethProviderHelper is undefined if the wallet is not installed or found in walletbook
|
|
26
27
|
return this.ethProviderHelper;
|
|
27
28
|
}
|
|
28
29
|
getMobileOrInstalledWallet() {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
var _a, _b;
|
|
31
|
+
if (!this.wallet) {
|
|
32
|
+
this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
|
|
33
|
+
}
|
|
34
|
+
if (this.isInstalledOnBrowser()) {
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
// this is to handle the case where the user is in a webview.
|
|
38
|
+
// when the user is in a webview, customers should set the deepLinkPreference prop to universal,
|
|
39
|
+
// in which case this condition will be false, and the SDK will use WalletConnect (if available)
|
|
40
|
+
if (((_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.mobile) === null || _b === void 0 ? void 0 : _b.inAppBrowser) &&
|
|
41
|
+
this.constructorProps.deepLinkPreference !== 'universal' &&
|
|
42
|
+
utils.isMobile()) {
|
|
43
|
+
return this;
|
|
33
44
|
}
|
|
34
|
-
|
|
45
|
+
// this is the case where the wallet is not installed on the browser and
|
|
46
|
+
// it does not support WalletConnect. in this case, the SDK will instruct
|
|
47
|
+
// the user to download the wallet extension
|
|
48
|
+
if (!this.walletConnectorFallback) {
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
return new walletConnect.WalletConnect(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
|
|
35
52
|
}
|
|
36
53
|
setupEventListeners() {
|
|
37
54
|
const provider = this.getWalletClient();
|
|
@@ -43,28 +60,28 @@ class InjectedWalletBase extends EthWalletConnector.EthWalletConnector {
|
|
|
43
60
|
const { tearDownEventListeners } = ethProviderHelper._setupEventListeners(this);
|
|
44
61
|
this.teardownEventListeners = tearDownEventListeners;
|
|
45
62
|
}
|
|
46
|
-
getWalletClient() {
|
|
63
|
+
getWalletClient(chainId) {
|
|
47
64
|
var _a;
|
|
48
|
-
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.findWalletClient();
|
|
65
|
+
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.findWalletClient(chainId);
|
|
49
66
|
}
|
|
50
67
|
isInstalledOnBrowser() {
|
|
51
68
|
var _a;
|
|
52
69
|
return ((_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.findProvider()) !== undefined;
|
|
53
70
|
}
|
|
54
|
-
|
|
55
|
-
var _a;
|
|
71
|
+
getAddress() {
|
|
56
72
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
|
|
73
|
+
var _a;
|
|
74
|
+
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.getAddress();
|
|
58
75
|
});
|
|
59
76
|
}
|
|
60
77
|
connect() {
|
|
61
78
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
yield this.
|
|
79
|
+
yield this.getAddress();
|
|
63
80
|
});
|
|
64
81
|
}
|
|
65
82
|
signMessage(messageToSign) {
|
|
66
|
-
var _a;
|
|
67
83
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
var _a;
|
|
68
85
|
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.signMessage(messageToSign);
|
|
69
86
|
});
|
|
70
87
|
}
|
|
@@ -79,11 +96,11 @@ class InjectedWalletBase extends EthWalletConnector.EthWalletConnector {
|
|
|
79
96
|
return;
|
|
80
97
|
});
|
|
81
98
|
}
|
|
82
|
-
providerSwitchNetwork(
|
|
99
|
+
providerSwitchNetwork(_a) {
|
|
83
100
|
const _super = Object.create(null, {
|
|
84
101
|
providerSwitchNetwork: { get: () => super.providerSwitchNetwork }
|
|
85
102
|
});
|
|
86
|
-
return _tslib.__awaiter(this,
|
|
103
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ network, provider, }) {
|
|
87
104
|
return _super.providerSwitchNetwork.call(this, { network, provider });
|
|
88
105
|
});
|
|
89
106
|
}
|
|
@@ -14,9 +14,9 @@ declare abstract class InjectedWalletBase extends EthWalletConnector {
|
|
|
14
14
|
getEthProviderHelper(): EthProviderHelper | undefined;
|
|
15
15
|
getMobileOrInstalledWallet(): InjectedWalletBase;
|
|
16
16
|
setupEventListeners(): void;
|
|
17
|
-
getWalletClient(): WalletClient | undefined;
|
|
17
|
+
getWalletClient(chainId?: string): WalletClient | undefined;
|
|
18
18
|
isInstalledOnBrowser(): boolean;
|
|
19
|
-
|
|
19
|
+
getAddress(): Promise<string | undefined>;
|
|
20
20
|
connect(): Promise<void>;
|
|
21
21
|
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
22
22
|
proveOwnership(messageToSign: string): Promise<string | undefined>;
|
|
@@ -1,5 +1,6 @@
|
|
|
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
6
|
import { WalletConnect } from '../walletConnect/walletConnect.js';
|
|
@@ -18,18 +19,34 @@ class InjectedWalletBase extends EthWalletConnector {
|
|
|
18
19
|
this.wallet = findWalletBookWallet(this.walletBook, this.key);
|
|
19
20
|
}
|
|
20
21
|
if (this.wallet && !this.ethProviderHelper) {
|
|
21
|
-
this.ethProviderHelper = new EthProviderHelper(this.wallet);
|
|
22
|
+
this.ethProviderHelper = new EthProviderHelper(this.wallet, this);
|
|
22
23
|
}
|
|
23
24
|
// this.ethProviderHelper is undefined if the wallet is not installed or found in walletbook
|
|
24
25
|
return this.ethProviderHelper;
|
|
25
26
|
}
|
|
26
27
|
getMobileOrInstalledWallet() {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
var _a, _b;
|
|
29
|
+
if (!this.wallet) {
|
|
30
|
+
this.wallet = findWalletBookWallet(this.walletBook, this.key);
|
|
31
|
+
}
|
|
32
|
+
if (this.isInstalledOnBrowser()) {
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
// this is to handle the case where the user is in a webview.
|
|
36
|
+
// when the user is in a webview, customers should set the deepLinkPreference prop to universal,
|
|
37
|
+
// in which case this condition will be false, and the SDK will use WalletConnect (if available)
|
|
38
|
+
if (((_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.mobile) === null || _b === void 0 ? void 0 : _b.inAppBrowser) &&
|
|
39
|
+
this.constructorProps.deepLinkPreference !== 'universal' &&
|
|
40
|
+
isMobile()) {
|
|
41
|
+
return this;
|
|
31
42
|
}
|
|
32
|
-
|
|
43
|
+
// this is the case where the wallet is not installed on the browser and
|
|
44
|
+
// it does not support WalletConnect. in this case, the SDK will instruct
|
|
45
|
+
// the user to download the wallet extension
|
|
46
|
+
if (!this.walletConnectorFallback) {
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
return new WalletConnect(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
|
|
33
50
|
}
|
|
34
51
|
setupEventListeners() {
|
|
35
52
|
const provider = this.getWalletClient();
|
|
@@ -41,28 +58,28 @@ class InjectedWalletBase extends EthWalletConnector {
|
|
|
41
58
|
const { tearDownEventListeners } = ethProviderHelper._setupEventListeners(this);
|
|
42
59
|
this.teardownEventListeners = tearDownEventListeners;
|
|
43
60
|
}
|
|
44
|
-
getWalletClient() {
|
|
61
|
+
getWalletClient(chainId) {
|
|
45
62
|
var _a;
|
|
46
|
-
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.findWalletClient();
|
|
63
|
+
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.findWalletClient(chainId);
|
|
47
64
|
}
|
|
48
65
|
isInstalledOnBrowser() {
|
|
49
66
|
var _a;
|
|
50
67
|
return ((_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.findProvider()) !== undefined;
|
|
51
68
|
}
|
|
52
|
-
|
|
53
|
-
var _a;
|
|
69
|
+
getAddress() {
|
|
54
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
|
|
71
|
+
var _a;
|
|
72
|
+
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.getAddress();
|
|
56
73
|
});
|
|
57
74
|
}
|
|
58
75
|
connect() {
|
|
59
76
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
yield this.
|
|
77
|
+
yield this.getAddress();
|
|
61
78
|
});
|
|
62
79
|
}
|
|
63
80
|
signMessage(messageToSign) {
|
|
64
|
-
var _a;
|
|
65
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
var _a;
|
|
66
83
|
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.signMessage(messageToSign);
|
|
67
84
|
});
|
|
68
85
|
}
|
|
@@ -77,11 +94,11 @@ class InjectedWalletBase extends EthWalletConnector {
|
|
|
77
94
|
return;
|
|
78
95
|
});
|
|
79
96
|
}
|
|
80
|
-
providerSwitchNetwork(
|
|
97
|
+
providerSwitchNetwork(_a) {
|
|
81
98
|
const _super = Object.create(null, {
|
|
82
99
|
providerSwitchNetwork: { get: () => super.providerSwitchNetwork }
|
|
83
100
|
});
|
|
84
|
-
return __awaiter(this,
|
|
101
|
+
return __awaiter(this, arguments, void 0, function* ({ network, provider, }) {
|
|
85
102
|
return _super.providerSwitchNetwork.call(this, { network, provider });
|
|
86
103
|
});
|
|
87
104
|
}
|
|
@@ -14,13 +14,13 @@ class PhantomEvm extends InjectedWalletBase {
|
|
|
14
14
|
this.overrideKey = 'phantomevm';
|
|
15
15
|
this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
getAddress() {
|
|
18
18
|
const _super = Object.create(null, {
|
|
19
|
-
|
|
19
|
+
getAddress: { get: () => super.getAddress }
|
|
20
20
|
});
|
|
21
21
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
22
22
|
if (this.isInstalledOnBrowser()) {
|
|
23
|
-
return _super.
|
|
23
|
+
return _super.getAddress.call(this);
|
|
24
24
|
}
|
|
25
25
|
if (utils.isMobile()) {
|
|
26
26
|
utils.handleMobileWalletRedirect({
|
|
@@ -10,13 +10,13 @@ class PhantomEvm extends InjectedWalletBase {
|
|
|
10
10
|
this.overrideKey = 'phantomevm';
|
|
11
11
|
this.wallet = findWalletBookWallet(this.walletBook, this.key);
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
getAddress() {
|
|
14
14
|
const _super = Object.create(null, {
|
|
15
|
-
|
|
15
|
+
getAddress: { get: () => super.getAddress }
|
|
16
16
|
});
|
|
17
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
18
|
if (this.isInstalledOnBrowser()) {
|
|
19
|
-
return _super.
|
|
19
|
+
return _super.getAddress.call(this);
|
|
20
20
|
}
|
|
21
21
|
if (isMobile()) {
|
|
22
22
|
handleMobileWalletRedirect({
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var InjectedWalletBase = require('./InjectedWalletBase.cjs');
|
|
6
|
+
|
|
7
|
+
// on desktop, we use EIP-6963 to connect to the wallet so the injectedConfig
|
|
8
|
+
// is not needed.
|
|
9
|
+
const zerionWalletBookConfig = {
|
|
10
|
+
eip6963Config: {
|
|
11
|
+
rdns: 'io.zerion.wallet',
|
|
12
|
+
},
|
|
13
|
+
filterFromWalletConnect: true,
|
|
14
|
+
injectedConfig: [
|
|
15
|
+
{
|
|
16
|
+
chain: 'evm',
|
|
17
|
+
// adds isMetaMask flag to the wallet connector so that the window provider works
|
|
18
|
+
// in the zerion in-app browser.
|
|
19
|
+
extensionLocators: [{ flag: 'isMetaMask', value: true }],
|
|
20
|
+
windowLocations: ['zerionWallet', 'zerionwallet.ethereum'],
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
name: 'Zerion',
|
|
24
|
+
};
|
|
25
|
+
class Zerion extends InjectedWalletBase {
|
|
26
|
+
constructor(props) {
|
|
27
|
+
super(props);
|
|
28
|
+
this.name = 'Zerion';
|
|
29
|
+
this.overrideKey = 'zerion';
|
|
30
|
+
this.wallet = zerionWalletBookConfig;
|
|
31
|
+
}
|
|
32
|
+
isInstalledOnBrowser() {
|
|
33
|
+
var _a;
|
|
34
|
+
return Boolean(window.zerionWallet || ((_a = window.zerionwallet) === null || _a === void 0 ? void 0 : _a.ethereum));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
exports.Zerion = Zerion;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { WalletSchema } from '@dynamic-labs/wallet-book';
|
|
2
|
+
import { EthWalletConnectorOpts } from '../EthWalletConnector';
|
|
3
|
+
import InjectedWalletBase from './InjectedWalletBase';
|
|
4
|
+
export declare class Zerion extends InjectedWalletBase {
|
|
5
|
+
name: string;
|
|
6
|
+
overrideKey: string;
|
|
7
|
+
wallet: WalletSchema;
|
|
8
|
+
constructor(props: EthWalletConnectorOpts);
|
|
9
|
+
isInstalledOnBrowser(): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import InjectedWalletBase from './InjectedWalletBase.js';
|
|
2
|
+
|
|
3
|
+
// on desktop, we use EIP-6963 to connect to the wallet so the injectedConfig
|
|
4
|
+
// is not needed.
|
|
5
|
+
const zerionWalletBookConfig = {
|
|
6
|
+
eip6963Config: {
|
|
7
|
+
rdns: 'io.zerion.wallet',
|
|
8
|
+
},
|
|
9
|
+
filterFromWalletConnect: true,
|
|
10
|
+
injectedConfig: [
|
|
11
|
+
{
|
|
12
|
+
chain: 'evm',
|
|
13
|
+
// adds isMetaMask flag to the wallet connector so that the window provider works
|
|
14
|
+
// in the zerion in-app browser.
|
|
15
|
+
extensionLocators: [{ flag: 'isMetaMask', value: true }],
|
|
16
|
+
windowLocations: ['zerionWallet', 'zerionwallet.ethereum'],
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
name: 'Zerion',
|
|
20
|
+
};
|
|
21
|
+
class Zerion extends InjectedWalletBase {
|
|
22
|
+
constructor(props) {
|
|
23
|
+
super(props);
|
|
24
|
+
this.name = 'Zerion';
|
|
25
|
+
this.overrideKey = 'zerion';
|
|
26
|
+
this.wallet = zerionWalletBookConfig;
|
|
27
|
+
}
|
|
28
|
+
isInstalledOnBrowser() {
|
|
29
|
+
var _a;
|
|
30
|
+
return Boolean(window.zerionWallet || ((_a = window.zerionwallet) === null || _a === void 0 ? void 0 : _a.ethereum));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { Zerion };
|
|
@@ -2,18 +2,23 @@
|
|
|
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');
|
|
10
|
+
var Zerion = require('./Zerion.cjs');
|
|
8
11
|
|
|
9
12
|
const injectedWalletOverrides = [
|
|
10
13
|
PhantomEvm.PhantomEvm,
|
|
11
14
|
ExodusEvm.ExodusEvm,
|
|
15
|
+
Zerion.Zerion,
|
|
12
16
|
];
|
|
13
17
|
const filteredInjectedWalletKeysOverrides = [
|
|
14
18
|
'phantomevm',
|
|
15
19
|
'coinbase',
|
|
16
20
|
'exodusevm',
|
|
21
|
+
'zerion',
|
|
17
22
|
];
|
|
18
23
|
const fetchInjectedWalletConnector = ({ walletBook, }) => {
|
|
19
24
|
var _a;
|
|
@@ -36,6 +41,26 @@ const fetchInjectedWalletConnector = ({ walletBook, }) => {
|
|
|
36
41
|
// this is the key from the wallet book entry so that we don't purely rely on the normalized name
|
|
37
42
|
this.overrideKey = key;
|
|
38
43
|
}
|
|
44
|
+
getAddress() {
|
|
45
|
+
const _super = Object.create(null, {
|
|
46
|
+
getAddress: { get: () => super.getAddress }
|
|
47
|
+
});
|
|
48
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
var _a;
|
|
50
|
+
if (this.isInstalledOnBrowser()) {
|
|
51
|
+
return _super.getAddress.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
|
+
}
|
|
39
64
|
};
|
|
40
65
|
});
|
|
41
66
|
};
|
|
@@ -1,15 +1,20 @@
|
|
|
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';
|
|
6
|
+
import { Zerion } from './Zerion.js';
|
|
4
7
|
|
|
5
8
|
const injectedWalletOverrides = [
|
|
6
9
|
PhantomEvm,
|
|
7
10
|
ExodusEvm,
|
|
11
|
+
Zerion,
|
|
8
12
|
];
|
|
9
13
|
const filteredInjectedWalletKeysOverrides = [
|
|
10
14
|
'phantomevm',
|
|
11
15
|
'coinbase',
|
|
12
16
|
'exodusevm',
|
|
17
|
+
'zerion',
|
|
13
18
|
];
|
|
14
19
|
const fetchInjectedWalletConnector = ({ walletBook, }) => {
|
|
15
20
|
var _a;
|
|
@@ -32,6 +37,26 @@ const fetchInjectedWalletConnector = ({ walletBook, }) => {
|
|
|
32
37
|
// this is the key from the wallet book entry so that we don't purely rely on the normalized name
|
|
33
38
|
this.overrideKey = key;
|
|
34
39
|
}
|
|
40
|
+
getAddress() {
|
|
41
|
+
const _super = Object.create(null, {
|
|
42
|
+
getAddress: { get: () => super.getAddress }
|
|
43
|
+
});
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
var _a;
|
|
46
|
+
if (this.isInstalledOnBrowser()) {
|
|
47
|
+
return _super.getAddress.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
|
+
}
|
|
35
60
|
};
|
|
36
61
|
});
|
|
37
62
|
};
|
package/src/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EvmNetwork } from '@dynamic-labs/types';
|
|
2
2
|
export declare const findEvmNetwork: ({ chainId, name, networks, }: {
|
|
3
|
-
chainId?: number
|
|
4
|
-
name?: string
|
|
3
|
+
chainId?: number;
|
|
4
|
+
name?: string;
|
|
5
5
|
networks: EvmNetwork[];
|
|
6
6
|
}) => EvmNetwork | undefined;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
6
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
7
|
+
|
|
8
|
+
const getNameservice = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ rpcProvider, address, }) {
|
|
9
|
+
var _b;
|
|
10
|
+
const nsData = {
|
|
11
|
+
avatar: undefined,
|
|
12
|
+
name: undefined,
|
|
13
|
+
};
|
|
14
|
+
const network = yield rpcProvider.getChainId();
|
|
15
|
+
if (!network) {
|
|
16
|
+
return nsData;
|
|
17
|
+
}
|
|
18
|
+
// Handle Base name service requests
|
|
19
|
+
if (network === 8453) {
|
|
20
|
+
try {
|
|
21
|
+
const response = yield fetch(`https://resolver-api.basename.app/v1/addresses/${address}`);
|
|
22
|
+
if (response.ok) {
|
|
23
|
+
const data = yield response.json();
|
|
24
|
+
nsData.name = (_b = data.name) !== null && _b !== void 0 ? _b : undefined;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
walletConnectorCore.logger.debug('Failed to fetch ens data', e);
|
|
29
|
+
}
|
|
30
|
+
return nsData;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
nsData.name = (yield rpcProvider.getEnsName({
|
|
34
|
+
address: address,
|
|
35
|
+
}));
|
|
36
|
+
nsData.avatar = nsData.name
|
|
37
|
+
? (yield rpcProvider.getEnsAvatar({
|
|
38
|
+
name: nsData.name,
|
|
39
|
+
}))
|
|
40
|
+
: undefined;
|
|
41
|
+
}
|
|
42
|
+
return nsData;
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
exports.getNameservice = getNameservice;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
2
|
+
import { logger } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
+
|
|
4
|
+
const getNameservice = (_a) => __awaiter(void 0, [_a], void 0, function* ({ rpcProvider, address, }) {
|
|
5
|
+
var _b;
|
|
6
|
+
const nsData = {
|
|
7
|
+
avatar: undefined,
|
|
8
|
+
name: undefined,
|
|
9
|
+
};
|
|
10
|
+
const network = yield rpcProvider.getChainId();
|
|
11
|
+
if (!network) {
|
|
12
|
+
return nsData;
|
|
13
|
+
}
|
|
14
|
+
// Handle Base name service requests
|
|
15
|
+
if (network === 8453) {
|
|
16
|
+
try {
|
|
17
|
+
const response = yield fetch(`https://resolver-api.basename.app/v1/addresses/${address}`);
|
|
18
|
+
if (response.ok) {
|
|
19
|
+
const data = yield response.json();
|
|
20
|
+
nsData.name = (_b = data.name) !== null && _b !== void 0 ? _b : undefined;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
logger.debug('Failed to fetch ens data', e);
|
|
25
|
+
}
|
|
26
|
+
return nsData;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
nsData.name = (yield rpcProvider.getEnsName({
|
|
30
|
+
address: address,
|
|
31
|
+
}));
|
|
32
|
+
nsData.avatar = nsData.name
|
|
33
|
+
? (yield rpcProvider.getEnsAvatar({
|
|
34
|
+
name: nsData.name,
|
|
35
|
+
}))
|
|
36
|
+
: undefined;
|
|
37
|
+
}
|
|
38
|
+
return nsData;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export { getNameservice };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { isEthWalletConnector } from './isEthWalletConnector';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const isEthWalletConnector = (connector) => Boolean(connector === null || connector === void 0 ? void 0 : connector.getActiveAccount);
|
|
6
|
+
|
|
7
|
+
exports.isEthWalletConnector = isEthWalletConnector;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { WalletConnect
|
|
1
|
+
export { WalletConnect } from './walletConnect';
|
|
2
2
|
export { fetchWalletConnectWallets } from './fetchWalletConnectWallets';
|