@dynamic-labs/multi-wallet 0.17.0-RC.8 → 0.17.0-RC.9
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 +15 -0
- package/package.json +7 -12
- package/src/index.cjs +0 -44
- package/src/index.d.ts +0 -11
- package/src/index.js +1 -16
- package/src/multi-wallet.cjs +16 -64
- package/src/multi-wallet.d.ts +0 -1
- package/src/multi-wallet.js +12 -59
- package/src/types.d.ts +0 -2
- package/src/utils/message.cjs +1 -2
- package/src/utils/message.js +1 -2
- package/src/wallets/constants.cjs +0 -2
- package/src/wallets/constants.js +1 -2
- package/src/wallets/cosmos/KeplrWalletConnect.cjs +4 -6
- package/src/wallets/cosmos/KeplrWalletConnect.d.ts +4 -1
- package/src/wallets/cosmos/KeplrWalletConnect.js +2 -4
- package/src/wallets/cosmos/KeplrWalletConnector.d.ts +1 -2
- package/src/wallets/cosmos/wcClient.lib.cjs +45 -4
- package/src/wallets/cosmos/wcClient.lib.js +42 -3
- package/src/wallets/flow/lilico.cjs +2 -2
- package/src/wallets/flow/lilico.js +1 -1
- package/src/wallets/solana/phantom.cjs +3 -3
- package/src/wallets/solana/phantom.js +1 -1
- package/src/wallets/solana/solProviderHelper.cjs +3 -4
- package/src/wallets/solana/solProviderHelper.d.ts +3 -3
- package/src/wallets/solana/solProviderHelper.js +1 -2
- package/src/wallets/starknet/braavos.cjs +2 -2
- package/src/wallets/starknet/braavos.js +1 -1
- package/src/wallets/window.d.ts +10 -22
- package/src/utils/assignConfirmationScreenToProvider/assignConfirmationScreenToProvider.cjs +0 -54
- package/src/utils/assignConfirmationScreenToProvider/assignConfirmationScreenToProvider.d.ts +0 -3
- package/src/utils/assignConfirmationScreenToProvider/assignConfirmationScreenToProvider.js +0 -50
- package/src/utils/assignConfirmationScreenToProvider/index.d.ts +0 -1
- package/src/utils/encoding.cjs +0 -18
- package/src/utils/encoding.d.ts +0 -4
- package/src/utils/encoding.js +0 -12
- package/src/utils/getChainInfo/getChainInfo.cjs +0 -59
- package/src/utils/getChainInfo/getChainInfo.d.ts +0 -2
- package/src/utils/getChainInfo/getChainInfo.js +0 -55
- package/src/utils/getChainInfo/index.d.ts +0 -1
- package/src/utils/getWalletConnectorByName.cjs +0 -19
- package/src/utils/getWalletConnectorByName.d.ts +0 -2
- package/src/utils/getWalletConnectorByName.js +0 -15
- package/src/utils/isEmailOTPWalletConnector/index.d.ts +0 -1
- package/src/utils/isEmailOTPWalletConnector/isEmailOTPWalletConnector.cjs +0 -7
- package/src/utils/isEmailOTPWalletConnector/isEmailOTPWalletConnector.d.ts +0 -2
- package/src/utils/isEmailOTPWalletConnector/isEmailOTPWalletConnector.js +0 -3
- package/src/utils/isEmailWalletConnector/index.d.ts +0 -1
- package/src/utils/isEmailWalletConnector/isEmailWalletConnector.cjs +0 -7
- package/src/utils/isEmailWalletConnector/isEmailWalletConnector.d.ts +0 -2
- package/src/utils/isEmailWalletConnector/isEmailWalletConnector.js +0 -3
- package/src/utils/isFunction/index.d.ts +0 -1
- package/src/utils/isFunction/isFunction.cjs +0 -8
- package/src/utils/isFunction/isFunction.d.ts +0 -1
- package/src/utils/isFunction/isFunction.js +0 -4
- package/src/utils/isMobile.cjs +0 -54
- package/src/utils/isMobile.d.ts +0 -13
- package/src/utils/isMobile.js +0 -46
- package/src/utils/isSameAddress/index.d.ts +0 -1
- package/src/utils/isSameAddress/isSameAddress.cjs +0 -9
- package/src/utils/isSameAddress/isSameAddress.d.ts +0 -1
- package/src/utils/isSameAddress/isSameAddress.js +0 -5
- package/src/utils/isSameAddress/utils/index.d.ts +0 -1
- package/src/utils/isSameAddress/utils/normalizeAddress/index.d.ts +0 -1
- package/src/utils/isSameAddress/utils/normalizeAddress/normalizeAddress.cjs +0 -17
- package/src/utils/isSameAddress/utils/normalizeAddress/normalizeAddress.d.ts +0 -1
- package/src/utils/isSameAddress/utils/normalizeAddress/normalizeAddress.js +0 -13
- package/src/utils/isSocialWalletConnector/index.d.ts +0 -1
- package/src/utils/isSocialWalletConnector/isSocialWalletConnector.cjs +0 -7
- package/src/utils/isSocialWalletConnector/isSocialWalletConnector.d.ts +0 -2
- package/src/utils/isSocialWalletConnector/isSocialWalletConnector.js +0 -3
- package/src/utils/isUnsupportedProviderError/index.d.ts +0 -1
- package/src/utils/isUnsupportedProviderError/isUnsupportedProviderError.cjs +0 -13
- package/src/utils/isUnsupportedProviderError/isUnsupportedProviderError.d.ts +0 -6
- package/src/utils/isUnsupportedProviderError/isUnsupportedProviderError.js +0 -9
- package/src/utils/normalizeWalletName/index.d.ts +0 -1
- package/src/utils/normalizeWalletName/normalizeWalletName.cjs +0 -7
- package/src/utils/normalizeWalletName/normalizeWalletName.d.ts +0 -1
- package/src/utils/normalizeWalletName/normalizeWalletName.js +0 -3
- package/src/utils/shouldLowercaseAddress.cjs +0 -11
- package/src/utils/shouldLowercaseAddress.d.ts +0 -1
- package/src/utils/shouldLowercaseAddress.js +0 -7
- package/src/utils/walletConnect.cjs +0 -33
- package/src/utils/walletConnect.d.ts +0 -4
- package/src/utils/walletConnect.js +0 -29
- package/src/wallets/ProviderLookup.cjs +0 -18
- package/src/wallets/ProviderLookup.d.ts +0 -4
- package/src/wallets/ProviderLookup.js +0 -14
- package/src/wallets/clients/coinbase/coinbase.cjs +0 -73
- package/src/wallets/clients/coinbase/coinbase.d.ts +0 -6
- package/src/wallets/clients/coinbase/coinbase.js +0 -66
- package/src/wallets/clients/coinbase/index.d.ts +0 -2
- package/src/wallets/clients/coinbase/types.d.ts +0 -14
- package/src/wallets/clients/walletConnect/index.d.ts +0 -1
- package/src/wallets/clients/walletConnect/types.d.ts +0 -4
- package/src/wallets/clients/walletConnect/walletConnect.cjs +0 -229
- package/src/wallets/clients/walletConnect/walletConnect.d.ts +0 -21
- package/src/wallets/clients/walletConnect/walletConnect.js +0 -213
- package/src/wallets/ethereum/BloctoEvm.cjs +0 -109
- package/src/wallets/ethereum/BloctoEvm.d.ts +0 -20
- package/src/wallets/ethereum/BloctoEvm.js +0 -103
- package/src/wallets/ethereum/EthWalletConnector.cjs +0 -206
- package/src/wallets/ethereum/EthWalletConnector.d.ts +0 -39
- package/src/wallets/ethereum/EthWalletConnector.js +0 -202
- package/src/wallets/ethereum/MagicConnector/EmailMagicWalletConnector/EmailMagicWalletConnector.cjs +0 -61
- package/src/wallets/ethereum/MagicConnector/EmailMagicWalletConnector/EmailMagicWalletConnector.d.ts +0 -12
- package/src/wallets/ethereum/MagicConnector/EmailMagicWalletConnector/EmailMagicWalletConnector.js +0 -57
- package/src/wallets/ethereum/MagicConnector/EmailMagicWalletConnector/index.d.ts +0 -1
- package/src/wallets/ethereum/MagicConnector/EmailOTPMagicWalletConnector/EmailOTPMagicWalletConnector.cjs +0 -62
- package/src/wallets/ethereum/MagicConnector/EmailOTPMagicWalletConnector/EmailOTPMagicWalletConnector.d.ts +0 -11
- package/src/wallets/ethereum/MagicConnector/EmailOTPMagicWalletConnector/EmailOTPMagicWalletConnector.js +0 -58
- package/src/wallets/ethereum/MagicConnector/EmailOTPMagicWalletConnector/index.d.ts +0 -1
- package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/MagicClientNetworkHandler.cjs +0 -78
- package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/MagicClientNetworkHandler.d.ts +0 -31
- package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/MagicClientNetworkHandler.js +0 -74
- package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/index.d.ts +0 -2
- package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/MagicSocialWalletConnector.cjs +0 -61
- package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/MagicSocialWalletConnector.d.ts +0 -12
- package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/MagicSocialWalletConnector.js +0 -57
- package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/index.d.ts +0 -1
- package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/MagicWalletConnector.cjs +0 -179
- package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/MagicWalletConnector.d.ts +0 -54
- package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/MagicWalletConnector.js +0 -175
- package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/index.d.ts +0 -2
- package/src/wallets/ethereum/MagicConnector/index.d.ts +0 -5
- package/src/wallets/ethereum/coinbase.cjs +0 -63
- package/src/wallets/ethereum/coinbase.d.ts +0 -22
- package/src/wallets/ethereum/coinbase.js +0 -61
- package/src/wallets/ethereum/ethProviderHelper.cjs +0 -199
- package/src/wallets/ethereum/ethProviderHelper.d.ts +0 -33
- package/src/wallets/ethereum/ethProviderHelper.js +0 -195
- package/src/wallets/ethereum/evm-network.cjs +0 -20
- package/src/wallets/ethereum/evm-network.d.ts +0 -6
- package/src/wallets/ethereum/evm-network.js +0 -16
- package/src/wallets/ethereum/injected/BloctoInjected.cjs +0 -12
- package/src/wallets/ethereum/injected/BloctoInjected.d.ts +0 -5
- package/src/wallets/ethereum/injected/BloctoInjected.js +0 -10
- package/src/wallets/ethereum/injected/BraveEvm.cjs +0 -12
- package/src/wallets/ethereum/injected/BraveEvm.d.ts +0 -5
- package/src/wallets/ethereum/injected/BraveEvm.js +0 -10
- package/src/wallets/ethereum/injected/Dawn.cjs +0 -12
- package/src/wallets/ethereum/injected/Dawn.d.ts +0 -5
- package/src/wallets/ethereum/injected/Dawn.js +0 -10
- package/src/wallets/ethereum/injected/ExodusEvm.cjs +0 -12
- package/src/wallets/ethereum/injected/ExodusEvm.d.ts +0 -5
- package/src/wallets/ethereum/injected/ExodusEvm.js +0 -10
- package/src/wallets/ethereum/injected/Frame.cjs +0 -12
- package/src/wallets/ethereum/injected/Frame.d.ts +0 -5
- package/src/wallets/ethereum/injected/Frame.js +0 -10
- package/src/wallets/ethereum/injected/GameStop.cjs +0 -12
- package/src/wallets/ethereum/injected/GameStop.d.ts +0 -5
- package/src/wallets/ethereum/injected/GameStop.js +0 -10
- package/src/wallets/ethereum/injected/InjectedWalletBase.cjs +0 -74
- package/src/wallets/ethereum/injected/InjectedWalletBase.d.ts +0 -24
- package/src/wallets/ethereum/injected/InjectedWalletBase.js +0 -72
- package/src/wallets/ethereum/injected/MetaMask.cjs +0 -13
- package/src/wallets/ethereum/injected/MetaMask.d.ts +0 -6
- package/src/wallets/ethereum/injected/MetaMask.js +0 -11
- package/src/wallets/ethereum/injected/Opera.cjs +0 -12
- package/src/wallets/ethereum/injected/Opera.d.ts +0 -5
- package/src/wallets/ethereum/injected/Opera.js +0 -10
- package/src/wallets/ethereum/injected/PhantomEvm.cjs +0 -36
- package/src/wallets/ethereum/injected/PhantomEvm.d.ts +0 -6
- package/src/wallets/ethereum/injected/PhantomEvm.js +0 -34
- package/src/wallets/ethereum/injected/Trust.cjs +0 -13
- package/src/wallets/ethereum/injected/Trust.d.ts +0 -6
- package/src/wallets/ethereum/injected/Trust.js +0 -11
- package/src/wallets/ethereum/injected/UnknownInjectedWallet.cjs +0 -12
- package/src/wallets/ethereum/injected/UnknownInjectedWallet.d.ts +0 -5
- package/src/wallets/ethereum/injected/UnknownInjectedWallet.js +0 -10
- package/src/wallets/ethereum/injected/Zerion.cjs +0 -13
- package/src/wallets/ethereum/injected/Zerion.d.ts +0 -6
- package/src/wallets/ethereum/injected/Zerion.js +0 -11
- package/src/wallets/getWalletConnectConnector.cjs +0 -16
- package/src/wallets/getWalletConnectConnector.d.ts +0 -5
- package/src/wallets/getWalletConnectConnector.js +0 -12
- package/src/wallets/walletConnect/index.d.ts +0 -2
- package/src/wallets/walletConnect/walletConnect.cjs +0 -133
- package/src/wallets/walletConnect/walletConnect.d.ts +0 -34
- package/src/wallets/walletConnect/walletConnect.js +0 -127
- package/src/wallets/walletConnect/walletConnectV2.cjs +0 -268
- package/src/wallets/walletConnect/walletConnectV2.d.ts +0 -38
- package/src/wallets/walletConnect/walletConnectV2.js +0 -262
- package/src/wallets/walletConnect/zerion.d.ts +0 -6
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var tslib = require('tslib');
|
|
6
|
-
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
7
|
-
var EmailMagicWalletConnector = require('../EmailMagicWalletConnector/EmailMagicWalletConnector.cjs');
|
|
8
|
-
|
|
9
|
-
class EmailOTPMagicWalletConnector extends EmailMagicWalletConnector.EmailMagicWalletConnector {
|
|
10
|
-
verifyOneTimePassword(otp) {
|
|
11
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
12
|
-
const handle = this._handle;
|
|
13
|
-
const timeoutMs = 1000 * 10;
|
|
14
|
-
const invalidOTPError = new Error('Please double check your code and try again');
|
|
15
|
-
if (!handle) {
|
|
16
|
-
throw new Error('Login with email OTP before verifying');
|
|
17
|
-
}
|
|
18
|
-
const timeoutPromise = new Promise((resolve, reject) => {
|
|
19
|
-
setTimeout(() => {
|
|
20
|
-
reject(invalidOTPError);
|
|
21
|
-
}, timeoutMs);
|
|
22
|
-
});
|
|
23
|
-
const promise = new Promise((resolve, reject) => {
|
|
24
|
-
handle
|
|
25
|
-
.on('done', () => resolve(true))
|
|
26
|
-
.on('invalid-email-otp', () => reject(invalidOTPError))
|
|
27
|
-
.on('error', reject)
|
|
28
|
-
.catch(reject)
|
|
29
|
-
.emit('verify-email-otp', otp);
|
|
30
|
-
});
|
|
31
|
-
return Promise.race([promise, timeoutPromise]);
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
loginWithMagic() {
|
|
35
|
-
var _a;
|
|
36
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
const client = this._magicClient.getClient();
|
|
38
|
-
const user = yield this.getUserMetadata();
|
|
39
|
-
if (user && user.publicAddress) {
|
|
40
|
-
this.setEmail(user === null || user === void 0 ? void 0 : user.email);
|
|
41
|
-
return user.publicAddress;
|
|
42
|
-
}
|
|
43
|
-
const { email } = this;
|
|
44
|
-
if (!email)
|
|
45
|
-
return;
|
|
46
|
-
(_a = this._handle) === null || _a === void 0 ? void 0 : _a.emit('cancel');
|
|
47
|
-
try {
|
|
48
|
-
yield this._handle;
|
|
49
|
-
}
|
|
50
|
-
catch (err) {
|
|
51
|
-
walletConnectorCore.logger.error(err);
|
|
52
|
-
}
|
|
53
|
-
this._handle = client.auth.loginWithEmailOTP({
|
|
54
|
-
email,
|
|
55
|
-
showUI: false,
|
|
56
|
-
});
|
|
57
|
-
return this._handle;
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
exports.EmailOTPMagicWalletConnector = EmailOTPMagicWalletConnector;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Magic } from 'magic-sdk';
|
|
2
|
-
import { IEmailOTPWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
-
import { EmailMagicWalletConnector } from '../EmailMagicWalletConnector';
|
|
4
|
-
import { MagicPromiEvent } from '../MagicWalletConnector';
|
|
5
|
-
type LoginWithEmailOTPPromiEvent = ReturnType<Magic['auth']['loginWithEmailOTP']>;
|
|
6
|
-
export declare class EmailOTPMagicWalletConnector extends EmailMagicWalletConnector implements IEmailOTPWalletConnector {
|
|
7
|
-
_handle: LoginWithEmailOTPPromiEvent | undefined;
|
|
8
|
-
verifyOneTimePassword(otp: string): Promise<boolean>;
|
|
9
|
-
loginWithMagic(): Promise<MagicPromiEvent | undefined>;
|
|
10
|
-
}
|
|
11
|
-
export {};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from 'tslib';
|
|
2
|
-
import { logger } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
-
import { EmailMagicWalletConnector } from '../EmailMagicWalletConnector/EmailMagicWalletConnector.js';
|
|
4
|
-
|
|
5
|
-
class EmailOTPMagicWalletConnector extends EmailMagicWalletConnector {
|
|
6
|
-
verifyOneTimePassword(otp) {
|
|
7
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
8
|
-
const handle = this._handle;
|
|
9
|
-
const timeoutMs = 1000 * 10;
|
|
10
|
-
const invalidOTPError = new Error('Please double check your code and try again');
|
|
11
|
-
if (!handle) {
|
|
12
|
-
throw new Error('Login with email OTP before verifying');
|
|
13
|
-
}
|
|
14
|
-
const timeoutPromise = new Promise((resolve, reject) => {
|
|
15
|
-
setTimeout(() => {
|
|
16
|
-
reject(invalidOTPError);
|
|
17
|
-
}, timeoutMs);
|
|
18
|
-
});
|
|
19
|
-
const promise = new Promise((resolve, reject) => {
|
|
20
|
-
handle
|
|
21
|
-
.on('done', () => resolve(true))
|
|
22
|
-
.on('invalid-email-otp', () => reject(invalidOTPError))
|
|
23
|
-
.on('error', reject)
|
|
24
|
-
.catch(reject)
|
|
25
|
-
.emit('verify-email-otp', otp);
|
|
26
|
-
});
|
|
27
|
-
return Promise.race([promise, timeoutPromise]);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
loginWithMagic() {
|
|
31
|
-
var _a;
|
|
32
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
const client = this._magicClient.getClient();
|
|
34
|
-
const user = yield this.getUserMetadata();
|
|
35
|
-
if (user && user.publicAddress) {
|
|
36
|
-
this.setEmail(user === null || user === void 0 ? void 0 : user.email);
|
|
37
|
-
return user.publicAddress;
|
|
38
|
-
}
|
|
39
|
-
const { email } = this;
|
|
40
|
-
if (!email)
|
|
41
|
-
return;
|
|
42
|
-
(_a = this._handle) === null || _a === void 0 ? void 0 : _a.emit('cancel');
|
|
43
|
-
try {
|
|
44
|
-
yield this._handle;
|
|
45
|
-
}
|
|
46
|
-
catch (err) {
|
|
47
|
-
logger.error(err);
|
|
48
|
-
}
|
|
49
|
-
this._handle = client.auth.loginWithEmailOTP({
|
|
50
|
-
email,
|
|
51
|
-
showUI: false,
|
|
52
|
-
});
|
|
53
|
-
return this._handle;
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export { EmailOTPMagicWalletConnector };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { EmailOTPMagicWalletConnector } from './EmailOTPMagicWalletConnector';
|
package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/MagicClientNetworkHandler.cjs
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var tslib = require('tslib');
|
|
6
|
-
var utils = require('@dynamic-labs/utils');
|
|
7
|
-
|
|
8
|
-
class MagicClientNetworkHandler {
|
|
9
|
-
constructor({ createClient, evmNetworks, defaultChainId, }) {
|
|
10
|
-
this._clients = {};
|
|
11
|
-
this.evmNetworks = [];
|
|
12
|
-
this.evmNetworks = utils.parseEvmNetworks(evmNetworks);
|
|
13
|
-
this._networkId = defaultChainId !== null && defaultChainId !== void 0 ? defaultChainId : 1;
|
|
14
|
-
this._createClient = createClient;
|
|
15
|
-
}
|
|
16
|
-
setListeners(listeners) {
|
|
17
|
-
this._listeners = listeners;
|
|
18
|
-
}
|
|
19
|
-
onChainChanged(networkChainId) {
|
|
20
|
-
var _a, _b;
|
|
21
|
-
(_b = (_a = this._listeners) === null || _a === void 0 ? void 0 : _a.onChainChange) === null || _b === void 0 ? void 0 : _b.call(_a, networkChainId.toString());
|
|
22
|
-
}
|
|
23
|
-
selectNetwork(networkChainId) {
|
|
24
|
-
var _a;
|
|
25
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
this._networkId = networkChainId;
|
|
27
|
-
(_a = this.onChainChanged) === null || _a === void 0 ? void 0 : _a.call(this, networkChainId);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
get networkId() {
|
|
31
|
-
return this._networkId;
|
|
32
|
-
}
|
|
33
|
-
getClient() {
|
|
34
|
-
const networkId = this._networkId;
|
|
35
|
-
const client = this._clients[networkId];
|
|
36
|
-
if (client) {
|
|
37
|
-
return client;
|
|
38
|
-
}
|
|
39
|
-
const config = this.getConfigForNetwork(networkId);
|
|
40
|
-
const newClient = this._createClient(config);
|
|
41
|
-
this._clients[networkId] = newClient;
|
|
42
|
-
return newClient;
|
|
43
|
-
}
|
|
44
|
-
getConfigForNetwork(networkId) {
|
|
45
|
-
const rpcUrl = this._getRpcUrlByNetworkId(networkId);
|
|
46
|
-
// Should prioritize custom rpc config form dashboard
|
|
47
|
-
if (rpcUrl) {
|
|
48
|
-
return {
|
|
49
|
-
network: {
|
|
50
|
-
chainId: this._getChainIdByNetworkId(networkId),
|
|
51
|
-
rpcUrl,
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
if (networkId === 1) {
|
|
56
|
-
return {
|
|
57
|
-
network: 'mainnet',
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
if (networkId === 5) {
|
|
61
|
-
return {
|
|
62
|
-
network: 'goerli',
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
return undefined;
|
|
66
|
-
}
|
|
67
|
-
_getRpcUrlByNetworkId(networkId) {
|
|
68
|
-
var _a;
|
|
69
|
-
const evm = this.evmNetworks.find((evmNetwork) => evmNetwork.networkId === networkId);
|
|
70
|
-
return ((_a = evm === null || evm === void 0 ? void 0 : evm.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) || (evm === null || evm === void 0 ? void 0 : evm.rpcUrls[0]);
|
|
71
|
-
}
|
|
72
|
-
_getChainIdByNetworkId(networkId) {
|
|
73
|
-
var _a;
|
|
74
|
-
return (_a = this.evmNetworks.find((evmNetwork) => evmNetwork.networkId === networkId)) === null || _a === void 0 ? void 0 : _a.chainId;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
exports.MagicClientNetworkHandler = MagicClientNetworkHandler;
|
package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/MagicClientNetworkHandler.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { MagicSDKAdditionalConfiguration, MagicSDKExtensionsOption } from 'magic-sdk';
|
|
2
|
-
import { WalletEventListeners } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
-
import { EvmNetwork, GenericNetwork } from '@dynamic-labs/types';
|
|
4
|
-
export type MagicLinkConfig = Pick<MagicSDKAdditionalConfiguration<string, MagicSDKExtensionsOption<string>>, 'network' | 'testMode' | 'locale'> & {
|
|
5
|
-
redirectURI?: string;
|
|
6
|
-
};
|
|
7
|
-
type ConfigForNetwork = MagicSDKAdditionalConfiguration<string, MagicSDKExtensionsOption<string>> | undefined;
|
|
8
|
-
export type MagicClientNetworkHandlerProps<TClient> = {
|
|
9
|
-
createClient: (config: ConfigForNetwork) => TClient;
|
|
10
|
-
defaultChainId?: number;
|
|
11
|
-
evmNetworks: GenericNetwork[];
|
|
12
|
-
};
|
|
13
|
-
export declare class MagicClientNetworkHandler<TClient = unknown> {
|
|
14
|
-
protected _clients: {
|
|
15
|
-
[chainId: number]: TClient;
|
|
16
|
-
};
|
|
17
|
-
protected _networkId: number;
|
|
18
|
-
protected _listeners: WalletEventListeners | undefined;
|
|
19
|
-
evmNetworks: EvmNetwork[];
|
|
20
|
-
protected _createClient: MagicClientNetworkHandlerProps<TClient>['createClient'];
|
|
21
|
-
constructor({ createClient, evmNetworks, defaultChainId, }: MagicClientNetworkHandlerProps<TClient>);
|
|
22
|
-
setListeners(listeners: WalletEventListeners | undefined): void;
|
|
23
|
-
onChainChanged(networkChainId: number): void;
|
|
24
|
-
selectNetwork(networkChainId: number): Promise<void>;
|
|
25
|
-
get networkId(): number;
|
|
26
|
-
getClient(): TClient;
|
|
27
|
-
getConfigForNetwork(networkId: number): MagicSDKAdditionalConfiguration<string, MagicSDKExtensionsOption<string>> | undefined;
|
|
28
|
-
private _getRpcUrlByNetworkId;
|
|
29
|
-
private _getChainIdByNetworkId;
|
|
30
|
-
}
|
|
31
|
-
export {};
|
package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/MagicClientNetworkHandler.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from 'tslib';
|
|
2
|
-
import { parseEvmNetworks } from '@dynamic-labs/utils';
|
|
3
|
-
|
|
4
|
-
class MagicClientNetworkHandler {
|
|
5
|
-
constructor({ createClient, evmNetworks, defaultChainId, }) {
|
|
6
|
-
this._clients = {};
|
|
7
|
-
this.evmNetworks = [];
|
|
8
|
-
this.evmNetworks = parseEvmNetworks(evmNetworks);
|
|
9
|
-
this._networkId = defaultChainId !== null && defaultChainId !== void 0 ? defaultChainId : 1;
|
|
10
|
-
this._createClient = createClient;
|
|
11
|
-
}
|
|
12
|
-
setListeners(listeners) {
|
|
13
|
-
this._listeners = listeners;
|
|
14
|
-
}
|
|
15
|
-
onChainChanged(networkChainId) {
|
|
16
|
-
var _a, _b;
|
|
17
|
-
(_b = (_a = this._listeners) === null || _a === void 0 ? void 0 : _a.onChainChange) === null || _b === void 0 ? void 0 : _b.call(_a, networkChainId.toString());
|
|
18
|
-
}
|
|
19
|
-
selectNetwork(networkChainId) {
|
|
20
|
-
var _a;
|
|
21
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
this._networkId = networkChainId;
|
|
23
|
-
(_a = this.onChainChanged) === null || _a === void 0 ? void 0 : _a.call(this, networkChainId);
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
get networkId() {
|
|
27
|
-
return this._networkId;
|
|
28
|
-
}
|
|
29
|
-
getClient() {
|
|
30
|
-
const networkId = this._networkId;
|
|
31
|
-
const client = this._clients[networkId];
|
|
32
|
-
if (client) {
|
|
33
|
-
return client;
|
|
34
|
-
}
|
|
35
|
-
const config = this.getConfigForNetwork(networkId);
|
|
36
|
-
const newClient = this._createClient(config);
|
|
37
|
-
this._clients[networkId] = newClient;
|
|
38
|
-
return newClient;
|
|
39
|
-
}
|
|
40
|
-
getConfigForNetwork(networkId) {
|
|
41
|
-
const rpcUrl = this._getRpcUrlByNetworkId(networkId);
|
|
42
|
-
// Should prioritize custom rpc config form dashboard
|
|
43
|
-
if (rpcUrl) {
|
|
44
|
-
return {
|
|
45
|
-
network: {
|
|
46
|
-
chainId: this._getChainIdByNetworkId(networkId),
|
|
47
|
-
rpcUrl,
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
if (networkId === 1) {
|
|
52
|
-
return {
|
|
53
|
-
network: 'mainnet',
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
if (networkId === 5) {
|
|
57
|
-
return {
|
|
58
|
-
network: 'goerli',
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
return undefined;
|
|
62
|
-
}
|
|
63
|
-
_getRpcUrlByNetworkId(networkId) {
|
|
64
|
-
var _a;
|
|
65
|
-
const evm = this.evmNetworks.find((evmNetwork) => evmNetwork.networkId === networkId);
|
|
66
|
-
return ((_a = evm === null || evm === void 0 ? void 0 : evm.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) || (evm === null || evm === void 0 ? void 0 : evm.rpcUrls[0]);
|
|
67
|
-
}
|
|
68
|
-
_getChainIdByNetworkId(networkId) {
|
|
69
|
-
var _a;
|
|
70
|
-
return (_a = this.evmNetworks.find((evmNetwork) => evmNetwork.networkId === networkId)) === null || _a === void 0 ? void 0 : _a.chainId;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export { MagicClientNetworkHandler };
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var tslib = require('tslib');
|
|
6
|
-
var oauth = require('@magic-ext/oauth');
|
|
7
|
-
var magicSdk = require('magic-sdk');
|
|
8
|
-
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
9
|
-
var MagicWalletConnector = require('../MagicWalletConnector/MagicWalletConnector.cjs');
|
|
10
|
-
var MagicClientNetworkHandler = require('../MagicClientNetworkHandler/MagicClientNetworkHandler.cjs');
|
|
11
|
-
|
|
12
|
-
class MagicSocialWalletConnector extends MagicWalletConnector.MagicWalletConnector {
|
|
13
|
-
constructor(opts) {
|
|
14
|
-
var _a, _b, _c, _d;
|
|
15
|
-
super(opts);
|
|
16
|
-
this.canConnectViaSocial = true;
|
|
17
|
-
const apiKey = (_b = (_a = opts.apiProviders) === null || _a === void 0 ? void 0 : _a.magicLink) === null || _b === void 0 ? void 0 : _b.providerProjectId;
|
|
18
|
-
const defaultChainId = (_d = (_c = opts.apiProviders) === null || _c === void 0 ? void 0 : _c.magicLink) === null || _d === void 0 ? void 0 : _d.defaultChainId;
|
|
19
|
-
if (!apiKey) {
|
|
20
|
-
throw new Error('Missing MagicLink configuration. Add your MagicLink API key to your project configuration via the Dynamic Labs dashboard.');
|
|
21
|
-
}
|
|
22
|
-
this._magicClient = new MagicClientNetworkHandler.MagicClientNetworkHandler({
|
|
23
|
-
createClient: (config) => new magicSdk.Magic(apiKey, Object.assign(Object.assign({}, config), { extensions: [new oauth.OAuthExtension()] })),
|
|
24
|
-
defaultChainId: defaultChainId,
|
|
25
|
-
evmNetworks: opts.evmNetworks,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
connect(provider) {
|
|
29
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
yield this.loginWithMagic(provider);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
loginWithMagic(provider) {
|
|
34
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
const client = this._magicClient.getClient();
|
|
36
|
-
if (yield client.user.isLoggedIn()) {
|
|
37
|
-
return (yield client.user.getMetadata()).publicAddress;
|
|
38
|
-
}
|
|
39
|
-
yield client.oauth.loginWithRedirect({
|
|
40
|
-
provider,
|
|
41
|
-
redirectURI: window.location.href,
|
|
42
|
-
});
|
|
43
|
-
return undefined;
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
getSession() {
|
|
47
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
const client = this._magicClient.getClient();
|
|
49
|
-
try {
|
|
50
|
-
const result = yield client.oauth.getRedirectResult();
|
|
51
|
-
return result.oauth;
|
|
52
|
-
}
|
|
53
|
-
catch (e) {
|
|
54
|
-
walletConnectorCore.logger.error(e);
|
|
55
|
-
return undefined;
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
exports.MagicSocialWalletConnector = MagicSocialWalletConnector;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { OAuthExtension, OAuthProvider, OAuthRedirectResult } from '@magic-ext/oauth';
|
|
2
|
-
import { Magic } from 'magic-sdk';
|
|
3
|
-
import { MagicConnectorProps, MagicPromiEvent, MagicWalletConnector } from '../MagicWalletConnector';
|
|
4
|
-
import { MagicClientNetworkHandler } from '../MagicClientNetworkHandler';
|
|
5
|
-
export declare class MagicSocialWalletConnector extends MagicWalletConnector {
|
|
6
|
-
canConnectViaSocial: boolean;
|
|
7
|
-
_magicClient: MagicClientNetworkHandler<Magic<OAuthExtension[]>>;
|
|
8
|
-
constructor(opts: MagicConnectorProps);
|
|
9
|
-
connect(provider: OAuthProvider): Promise<void>;
|
|
10
|
-
loginWithMagic(provider: OAuthProvider): Promise<MagicPromiEvent | undefined>;
|
|
11
|
-
getSession(): Promise<OAuthRedirectResult['oauth'] | undefined>;
|
|
12
|
-
}
|
package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/MagicSocialWalletConnector.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from 'tslib';
|
|
2
|
-
import { OAuthExtension } from '@magic-ext/oauth';
|
|
3
|
-
import { Magic } from 'magic-sdk';
|
|
4
|
-
import { logger } from '@dynamic-labs/wallet-connector-core';
|
|
5
|
-
import { MagicWalletConnector } from '../MagicWalletConnector/MagicWalletConnector.js';
|
|
6
|
-
import { MagicClientNetworkHandler } from '../MagicClientNetworkHandler/MagicClientNetworkHandler.js';
|
|
7
|
-
|
|
8
|
-
class MagicSocialWalletConnector extends MagicWalletConnector {
|
|
9
|
-
constructor(opts) {
|
|
10
|
-
var _a, _b, _c, _d;
|
|
11
|
-
super(opts);
|
|
12
|
-
this.canConnectViaSocial = true;
|
|
13
|
-
const apiKey = (_b = (_a = opts.apiProviders) === null || _a === void 0 ? void 0 : _a.magicLink) === null || _b === void 0 ? void 0 : _b.providerProjectId;
|
|
14
|
-
const defaultChainId = (_d = (_c = opts.apiProviders) === null || _c === void 0 ? void 0 : _c.magicLink) === null || _d === void 0 ? void 0 : _d.defaultChainId;
|
|
15
|
-
if (!apiKey) {
|
|
16
|
-
throw new Error('Missing MagicLink configuration. Add your MagicLink API key to your project configuration via the Dynamic Labs dashboard.');
|
|
17
|
-
}
|
|
18
|
-
this._magicClient = new MagicClientNetworkHandler({
|
|
19
|
-
createClient: (config) => new Magic(apiKey, Object.assign(Object.assign({}, config), { extensions: [new OAuthExtension()] })),
|
|
20
|
-
defaultChainId: defaultChainId,
|
|
21
|
-
evmNetworks: opts.evmNetworks,
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
connect(provider) {
|
|
25
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
yield this.loginWithMagic(provider);
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
loginWithMagic(provider) {
|
|
30
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
const client = this._magicClient.getClient();
|
|
32
|
-
if (yield client.user.isLoggedIn()) {
|
|
33
|
-
return (yield client.user.getMetadata()).publicAddress;
|
|
34
|
-
}
|
|
35
|
-
yield client.oauth.loginWithRedirect({
|
|
36
|
-
provider,
|
|
37
|
-
redirectURI: window.location.href,
|
|
38
|
-
});
|
|
39
|
-
return undefined;
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
getSession() {
|
|
43
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
const client = this._magicClient.getClient();
|
|
45
|
-
try {
|
|
46
|
-
const result = yield client.oauth.getRedirectResult();
|
|
47
|
-
return result.oauth;
|
|
48
|
-
}
|
|
49
|
-
catch (e) {
|
|
50
|
-
logger.error(e);
|
|
51
|
-
return undefined;
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export { MagicSocialWalletConnector };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './MagicSocialWalletConnector';
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var tslib = require('tslib');
|
|
6
|
-
var magicSdk = require('magic-sdk');
|
|
7
|
-
var ethers = require('ethers');
|
|
8
|
-
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
9
|
-
var utils = require('@dynamic-labs/utils');
|
|
10
|
-
var assignConfirmationScreenToProvider = require('../../../../utils/assignConfirmationScreenToProvider/assignConfirmationScreenToProvider.cjs');
|
|
11
|
-
var MagicClientNetworkHandler = require('../MagicClientNetworkHandler/MagicClientNetworkHandler.cjs');
|
|
12
|
-
|
|
13
|
-
const storedAddressKey = 'dynamic_magic_address';
|
|
14
|
-
class MagicWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
15
|
-
get key() {
|
|
16
|
-
return 'magiclink';
|
|
17
|
-
}
|
|
18
|
-
constructor(opts) {
|
|
19
|
-
var _a, _b, _c, _d;
|
|
20
|
-
super();
|
|
21
|
-
this.canConnectViaCustodialService = true;
|
|
22
|
-
this.connectedChain = 'EVM';
|
|
23
|
-
this.supportedChains = ['ETH', 'EVM'];
|
|
24
|
-
this.name = 'Magic Link';
|
|
25
|
-
const apiKey = (_b = (_a = opts.apiProviders) === null || _a === void 0 ? void 0 : _a.magicLink) === null || _b === void 0 ? void 0 : _b.providerProjectId;
|
|
26
|
-
const defaultChainId = (_d = (_c = opts.apiProviders) === null || _c === void 0 ? void 0 : _c.magicLink) === null || _d === void 0 ? void 0 : _d.defaultChainId;
|
|
27
|
-
if (!apiKey) {
|
|
28
|
-
throw new Error('Missing MagicLink configuration. Add your MagicLink API key to your project configuration via the Dynamic Labs dashboard.');
|
|
29
|
-
}
|
|
30
|
-
this._magicClient = new MagicClientNetworkHandler.MagicClientNetworkHandler({
|
|
31
|
-
createClient: (config) => new magicSdk.Magic(apiKey, config),
|
|
32
|
-
defaultChainId,
|
|
33
|
-
evmNetworks: opts.evmNetworks,
|
|
34
|
-
});
|
|
35
|
-
this.evmNetworks = utils.parseEvmNetworks(opts.evmNetworks);
|
|
36
|
-
this._walletUiUtils = opts.walletUiUtils;
|
|
37
|
-
}
|
|
38
|
-
getDeepLink() {
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
|
-
connect() {
|
|
42
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
yield this.fetchPublicAddress();
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
endSession() {
|
|
47
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
localStorage.removeItem(storedAddressKey);
|
|
49
|
-
const client = this._magicClient.getClient();
|
|
50
|
-
yield client.user.logout();
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
getUserMetadata() {
|
|
54
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
if (yield this._isLoggedIn()) {
|
|
56
|
-
const client = this._magicClient.getClient();
|
|
57
|
-
return client.user.getMetadata();
|
|
58
|
-
}
|
|
59
|
-
return undefined;
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
fetchPublicAddress() {
|
|
63
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
const address = localStorage.getItem(storedAddressKey);
|
|
65
|
-
if (address)
|
|
66
|
-
return address;
|
|
67
|
-
const client = this._magicClient.getClient();
|
|
68
|
-
try {
|
|
69
|
-
try {
|
|
70
|
-
this._currentAuthCancellablePromise = utils.CancellablePromise.fromPromise(this.loginWithMagic());
|
|
71
|
-
yield this._currentAuthCancellablePromise;
|
|
72
|
-
}
|
|
73
|
-
catch (err) {
|
|
74
|
-
walletConnectorCore.logger.error(err);
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const metadata = yield client.user.getMetadata();
|
|
78
|
-
if (!metadata || !metadata.publicAddress) {
|
|
79
|
-
throw new Error('No public address');
|
|
80
|
-
}
|
|
81
|
-
if (metadata.issuer) {
|
|
82
|
-
this.providerResources = [`magic-auth:issuer:${metadata.issuer}`];
|
|
83
|
-
}
|
|
84
|
-
localStorage.setItem(storedAddressKey, metadata.publicAddress);
|
|
85
|
-
return metadata.publicAddress;
|
|
86
|
-
}
|
|
87
|
-
catch (err) {
|
|
88
|
-
return undefined;
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
getBalance() {
|
|
93
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
94
|
-
const provider = yield this.getWeb3Provider();
|
|
95
|
-
if (!provider)
|
|
96
|
-
throw new utils.DynamicError('No provider');
|
|
97
|
-
const signer = provider.getSigner();
|
|
98
|
-
const userAddress = yield signer.getAddress();
|
|
99
|
-
return ethers.ethers.utils.formatEther(yield provider.getBalance(userAddress));
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
getConnectedAccounts() {
|
|
103
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
104
|
-
const address = localStorage.getItem(storedAddressKey);
|
|
105
|
-
if (!address)
|
|
106
|
-
return [];
|
|
107
|
-
return [address];
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
getNetwork() {
|
|
111
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
112
|
-
return this._magicClient.networkId;
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
getRpcProvider() {
|
|
116
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
117
|
-
return undefined;
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
getSigner() {
|
|
121
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
122
|
-
const provider = yield this.getWeb3Provider();
|
|
123
|
-
return provider.getSigner();
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
getWeb3Provider() {
|
|
127
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
128
|
-
const client = this._magicClient.getClient();
|
|
129
|
-
const provider = new ethers.ethers.providers.Web3Provider(client.rpcProvider);
|
|
130
|
-
assignConfirmationScreenToProvider.assignConfirmationScreenToProvider(provider, this._walletUiUtils);
|
|
131
|
-
return provider;
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
setupEventListeners(listeners) {
|
|
135
|
-
this._listeners = listeners;
|
|
136
|
-
this._magicClient.setListeners(listeners);
|
|
137
|
-
this._checkIfLoggedIn();
|
|
138
|
-
}
|
|
139
|
-
signMessage(messageToSign) {
|
|
140
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
141
|
-
const provider = yield this.getWeb3Provider();
|
|
142
|
-
return provider.getSigner().signMessage(messageToSign);
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
supportsNetworkSwitching() {
|
|
146
|
-
return true;
|
|
147
|
-
}
|
|
148
|
-
switchNetwork({ networkChainId, }) {
|
|
149
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
150
|
-
if (!networkChainId) {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
this._magicClient.selectNetwork(networkChainId);
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
teardownEventListeners() {
|
|
157
|
-
this._listeners = undefined;
|
|
158
|
-
this._magicClient.setListeners(undefined);
|
|
159
|
-
}
|
|
160
|
-
_isLoggedIn() {
|
|
161
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
162
|
-
const client = this._magicClient.getClient();
|
|
163
|
-
return client.user.isLoggedIn();
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
_checkIfLoggedIn() {
|
|
167
|
-
var _a, _b;
|
|
168
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
169
|
-
const isLoggedIn = yield this._isLoggedIn();
|
|
170
|
-
if (!isLoggedIn) {
|
|
171
|
-
localStorage.removeItem(storedAddressKey);
|
|
172
|
-
(_b = (_a = this._listeners) === null || _a === void 0 ? void 0 : _a.onDisconnect) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
173
|
-
}
|
|
174
|
-
return isLoggedIn;
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
exports.MagicWalletConnector = MagicWalletConnector;
|