@dynamic-labs/multi-wallet 0.17.0-RC.2 → 0.17.0-RC.21
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 +242 -0
- package/package.json +10 -26
- package/src/index.cjs +0 -69
- package/src/index.d.ts +0 -18
- package/src/index.js +1 -23
- package/src/multi-wallet.cjs +38 -182
- package/src/multi-wallet.d.ts +1 -4
- package/src/multi-wallet.js +37 -180
- package/src/types.d.ts +12 -50
- package/src/utils/getApiProviders.cjs +15 -0
- package/src/utils/getApiProviders.d.ts +17 -0
- package/src/utils/getApiProviders.js +11 -0
- package/src/utils/message.cjs +3 -4
- package/src/utils/message.d.ts +2 -2
- package/src/utils/message.js +1 -2
- package/src/errors.cjs +0 -65
- package/src/errors.d.ts +0 -30
- package/src/errors.js +0 -53
- package/src/polyfills.cjs +0 -16
- package/src/polyfills.d.ts +0 -1
- package/src/polyfills.js +0 -14
- package/src/rpcProviders.cjs +0 -76
- package/src/rpcProviders.d.ts +0 -5
- package/src/rpcProviders.js +0 -69
- package/src/utils/CancellablePromise/CancellablePromise.cjs +0 -33
- package/src/utils/CancellablePromise/CancellablePromise.d.ts +0 -9
- package/src/utils/CancellablePromise/CancellablePromise.js +0 -29
- package/src/utils/CancellablePromise/index.d.ts +0 -1
- 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/convertors.cjs +0 -43
- package/src/utils/convertors.d.ts +0 -3
- package/src/utils/convertors.js +0 -38
- 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/extractNonce.cjs +0 -13
- package/src/utils/extractNonce.d.ts +0 -1
- package/src/utils/extractNonce.js +0 -9
- 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/localStorageAsync.cjs +0 -28
- package/src/utils/localStorageAsync.d.ts +0 -3
- package/src/utils/localStorageAsync.js +0 -22
- package/src/utils/logger.cjs +0 -9
- package/src/utils/logger.d.ts +0 -2
- package/src/utils/logger.js +0 -5
- 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 -30
- package/src/utils/walletConnect.d.ts +0 -4
- package/src/utils/walletConnect.js +0 -26
- 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/algorand/MyAlgoWalletConnector.cjs +0 -149
- package/src/wallets/algorand/MyAlgoWalletConnector.d.ts +0 -21
- package/src/wallets/algorand/MyAlgoWalletConnector.js +0 -143
- package/src/wallets/algorand/myalgoSigner.cjs +0 -24
- package/src/wallets/algorand/myalgoSigner.d.ts +0 -21
- package/src/wallets/algorand/myalgoSigner.js +0 -20
- 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 -204
- package/src/wallets/clients/walletConnect/walletConnect.d.ts +0 -22
- package/src/wallets/clients/walletConnect/walletConnect.js +0 -187
- package/src/wallets/constants.cjs +0 -16
- package/src/wallets/constants.d.ts +0 -4
- package/src/wallets/constants.js +0 -10
- package/src/wallets/cosmos/KeplrWalletConnect.cjs +0 -196
- package/src/wallets/cosmos/KeplrWalletConnect.d.ts +0 -46
- package/src/wallets/cosmos/KeplrWalletConnect.js +0 -194
- package/src/wallets/cosmos/KeplrWalletConnector.cjs +0 -193
- package/src/wallets/cosmos/KeplrWalletConnector.d.ts +0 -70
- package/src/wallets/cosmos/KeplrWalletConnector.js +0 -189
- package/src/wallets/cosmos/getKeplrConnector.cjs +0 -18
- package/src/wallets/cosmos/getKeplrConnector.d.ts +0 -6
- package/src/wallets/cosmos/getKeplrConnector.js +0 -14
- package/src/wallets/cosmos/index.d.ts +0 -1
- package/src/wallets/cosmos/utils/indexDB.cjs +0 -97
- package/src/wallets/cosmos/utils/indexDB.d.ts +0 -18
- package/src/wallets/cosmos/utils/indexDB.js +0 -93
- package/src/wallets/cosmos/wcClient.cjs +0 -333
- package/src/wallets/cosmos/wcClient.d.ts +0 -104
- package/src/wallets/cosmos/wcClient.js +0 -325
- package/src/wallets/ethereum/BloctoEvm.cjs +0 -111
- package/src/wallets/ethereum/BloctoEvm.d.ts +0 -25
- package/src/wallets/ethereum/BloctoEvm.js +0 -105
- package/src/wallets/ethereum/EthWalletConnector.cjs +0 -191
- package/src/wallets/ethereum/EthWalletConnector.d.ts +0 -35
- package/src/wallets/ethereum/EthWalletConnector.js +0 -187
- package/src/wallets/ethereum/MagicConnector/EmailMagicWalletConnector/EmailMagicWalletConnector.cjs +0 -63
- package/src/wallets/ethereum/MagicConnector/EmailMagicWalletConnector/EmailMagicWalletConnector.d.ts +0 -12
- package/src/wallets/ethereum/MagicConnector/EmailMagicWalletConnector/EmailMagicWalletConnector.js +0 -59
- 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 -102
- package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/MagicClientNetworkHandler.d.ts +0 -33
- package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/MagicClientNetworkHandler.js +0 -98
- package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/index.d.ts +0 -2
- package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/MagicSocialWalletConnector.cjs +0 -55
- package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/MagicSocialWalletConnector.d.ts +0 -12
- package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/MagicSocialWalletConnector.js +0 -51
- package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/index.d.ts +0 -1
- package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/MagicWalletConnector.cjs +0 -175
- package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/MagicWalletConnector.d.ts +0 -53
- package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/MagicWalletConnector.js +0 -171
- 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 -65
- package/src/wallets/ethereum/coinbase.d.ts +0 -26
- package/src/wallets/ethereum/coinbase.js +0 -63
- package/src/wallets/ethereum/ethProviderHelper.cjs +0 -197
- package/src/wallets/ethereum/ethProviderHelper.d.ts +0 -40
- package/src/wallets/ethereum/ethProviderHelper.js +0 -193
- package/src/wallets/ethereum/evm-network.cjs +0 -20
- package/src/wallets/ethereum/evm-network.d.ts +0 -22
- package/src/wallets/ethereum/evm-network.js +0 -16
- package/src/wallets/ethereum/fortmatic.cjs +0 -75
- package/src/wallets/ethereum/fortmatic.d.ts +0 -26
- package/src/wallets/ethereum/fortmatic.js +0 -69
- package/src/wallets/ethereum/injected/BloctoInjected.cjs +0 -13
- package/src/wallets/ethereum/injected/BloctoInjected.d.ts +0 -6
- package/src/wallets/ethereum/injected/BloctoInjected.js +0 -11
- package/src/wallets/ethereum/injected/BraveEvm.cjs +0 -13
- package/src/wallets/ethereum/injected/BraveEvm.d.ts +0 -6
- package/src/wallets/ethereum/injected/BraveEvm.js +0 -11
- package/src/wallets/ethereum/injected/Dawn.cjs +0 -13
- package/src/wallets/ethereum/injected/Dawn.d.ts +0 -6
- package/src/wallets/ethereum/injected/Dawn.js +0 -11
- package/src/wallets/ethereum/injected/ExodusEvm.cjs +0 -13
- package/src/wallets/ethereum/injected/ExodusEvm.d.ts +0 -6
- package/src/wallets/ethereum/injected/ExodusEvm.js +0 -11
- package/src/wallets/ethereum/injected/Frame.cjs +0 -13
- package/src/wallets/ethereum/injected/Frame.d.ts +0 -6
- package/src/wallets/ethereum/injected/Frame.js +0 -11
- package/src/wallets/ethereum/injected/GameStop.cjs +0 -13
- package/src/wallets/ethereum/injected/GameStop.d.ts +0 -6
- package/src/wallets/ethereum/injected/GameStop.js +0 -11
- package/src/wallets/ethereum/injected/Opera.cjs +0 -13
- package/src/wallets/ethereum/injected/Opera.d.ts +0 -6
- package/src/wallets/ethereum/injected/Opera.js +0 -11
- package/src/wallets/ethereum/injected/PhantomEvm.cjs +0 -37
- package/src/wallets/ethereum/injected/PhantomEvm.d.ts +0 -7
- package/src/wallets/ethereum/injected/PhantomEvm.js +0 -35
- 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 -13
- package/src/wallets/ethereum/injected/UnknownInjectedWallet.d.ts +0 -6
- package/src/wallets/ethereum/injected/UnknownInjectedWallet.js +0 -11
- 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/ethereum/meta-mask.cjs +0 -63
- package/src/wallets/ethereum/meta-mask.d.ts +0 -26
- package/src/wallets/ethereum/meta-mask.js +0 -61
- package/src/wallets/flow/FlowWalletConnector.cjs +0 -163
- package/src/wallets/flow/FlowWalletConnector.d.ts +0 -29
- package/src/wallets/flow/FlowWalletConnector.js +0 -158
- package/src/wallets/flow/blocto.cjs +0 -22
- package/src/wallets/flow/blocto.d.ts +0 -7
- package/src/wallets/flow/blocto.js +0 -20
- package/src/wallets/flow/dapper.cjs +0 -22
- package/src/wallets/flow/dapper.d.ts +0 -7
- package/src/wallets/flow/dapper.js +0 -20
- package/src/wallets/flow/lilico.cjs +0 -42
- package/src/wallets/flow/lilico.d.ts +0 -8
- package/src/wallets/flow/lilico.js +0 -40
- package/src/wallets/getMobileOrInjectedWallet.cjs +0 -26
- package/src/wallets/getMobileOrInjectedWallet.d.ts +0 -8
- package/src/wallets/getMobileOrInjectedWallet.js +0 -22
- package/src/wallets/getWalletConnectConnector.cjs +0 -19
- package/src/wallets/getWalletConnectConnector.d.ts +0 -8
- package/src/wallets/getWalletConnectConnector.js +0 -15
- package/src/wallets/solana/CoinbaseSolana.cjs +0 -54
- package/src/wallets/solana/CoinbaseSolana.d.ts +0 -17
- package/src/wallets/solana/CoinbaseSolana.js +0 -52
- package/src/wallets/solana/glow.cjs +0 -51
- package/src/wallets/solana/glow.d.ts +0 -16
- package/src/wallets/solana/glow.js +0 -49
- package/src/wallets/solana/injected/BraveSol.cjs +0 -18
- package/src/wallets/solana/injected/BraveSol.d.ts +0 -6
- package/src/wallets/solana/injected/BraveSol.js +0 -16
- package/src/wallets/solana/injected/ExodusSol.cjs +0 -12
- package/src/wallets/solana/injected/ExodusSol.d.ts +0 -5
- package/src/wallets/solana/injected/ExodusSol.js +0 -10
- package/src/wallets/solana/phantom-ledger.cjs +0 -71
- package/src/wallets/solana/phantom-ledger.d.ts +0 -16
- package/src/wallets/solana/phantom-ledger.js +0 -65
- package/src/wallets/solana/phantom.cjs +0 -74
- package/src/wallets/solana/phantom.d.ts +0 -17
- package/src/wallets/solana/phantom.js +0 -72
- package/src/wallets/solana/slope.cjs +0 -96
- package/src/wallets/solana/slope.d.ts +0 -27
- package/src/wallets/solana/slope.js +0 -94
- package/src/wallets/solana/solProviderHelper.cjs +0 -164
- package/src/wallets/solana/solProviderHelper.d.ts +0 -29
- package/src/wallets/solana/solProviderHelper.js +0 -160
- package/src/wallets/solana/solWalletConnector.cjs +0 -57
- package/src/wallets/solana/solWalletConnector.d.ts +0 -18
- package/src/wallets/solana/solWalletConnector.js +0 -53
- package/src/wallets/solana/solflare.cjs +0 -65
- package/src/wallets/solana/solflare.d.ts +0 -14
- package/src/wallets/solana/solflare.js +0 -63
- package/src/wallets/starknet/argentx.cjs +0 -20
- package/src/wallets/starknet/argentx.d.ts +0 -7
- package/src/wallets/starknet/argentx.js +0 -18
- package/src/wallets/starknet/braavos.cjs +0 -33
- package/src/wallets/starknet/braavos.d.ts +0 -7
- package/src/wallets/starknet/braavos.js +0 -31
- package/src/wallets/starknet/ethereumContractAbi.cjs +0 -357
- package/src/wallets/starknet/ethereumContractAbi.js +0 -355
- package/src/wallets/starknet/starknetWalletConnector.cjs +0 -171
- package/src/wallets/starknet/starknetWalletConnector.d.ts +0 -34
- package/src/wallets/starknet/starknetWalletConnector.js +0 -169
- package/src/wallets/walletConnect/index.d.ts +0 -2
- package/src/wallets/walletConnect/walletConnect.cjs +0 -130
- package/src/wallets/walletConnect/walletConnect.d.ts +0 -34
- package/src/wallets/walletConnect/walletConnect.js +0 -124
- 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 -8
- package/src/wallets/window.d.ts +0 -95
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from 'tslib';
|
|
2
|
-
import { logger } from '../../../../utils/logger.js';
|
|
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,102 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var tslib = require('tslib');
|
|
6
|
-
|
|
7
|
-
// these are based off of Magic's EthNetworkName type
|
|
8
|
-
const chainNameToChainIdMap = {
|
|
9
|
-
arbitrum: 42161,
|
|
10
|
-
avalance: 43114,
|
|
11
|
-
bsc: 56,
|
|
12
|
-
gnosis: 100,
|
|
13
|
-
goerli: 5,
|
|
14
|
-
mainnet: 1,
|
|
15
|
-
optimism: 10,
|
|
16
|
-
polygon: 137,
|
|
17
|
-
sepolia: 11155111,
|
|
18
|
-
};
|
|
19
|
-
class MagicClientNetworkHandler {
|
|
20
|
-
constructor({ createClient, evmNetworks, config, }) {
|
|
21
|
-
var _a, _b;
|
|
22
|
-
this._clients = {};
|
|
23
|
-
this.evmNetworks = [];
|
|
24
|
-
this._config = config;
|
|
25
|
-
this.evmNetworks = evmNetworks;
|
|
26
|
-
this._networkId =
|
|
27
|
-
typeof (config === null || config === void 0 ? void 0 : config.network) === 'string'
|
|
28
|
-
? chainNameToChainIdMap[config.network]
|
|
29
|
-
: (_b = (_a = config === null || config === void 0 ? void 0 : config.network) === null || _a === void 0 ? void 0 : _a.chainId) !== null && _b !== void 0 ? _b : 1;
|
|
30
|
-
this._createClient = createClient;
|
|
31
|
-
}
|
|
32
|
-
setListeners(listeners) {
|
|
33
|
-
this._listeners = listeners;
|
|
34
|
-
}
|
|
35
|
-
onChainChanged(networkChainId) {
|
|
36
|
-
var _a, _b;
|
|
37
|
-
(_b = (_a = this._listeners) === null || _a === void 0 ? void 0 : _a.onChainChange) === null || _b === void 0 ? void 0 : _b.call(_a, networkChainId.toString());
|
|
38
|
-
}
|
|
39
|
-
selectNetwork(networkChainId) {
|
|
40
|
-
var _a;
|
|
41
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
this._networkId = networkChainId;
|
|
43
|
-
(_a = this.onChainChanged) === null || _a === void 0 ? void 0 : _a.call(this, networkChainId);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
get networkId() {
|
|
47
|
-
return this._networkId;
|
|
48
|
-
}
|
|
49
|
-
get config() {
|
|
50
|
-
return this._config;
|
|
51
|
-
}
|
|
52
|
-
getClient() {
|
|
53
|
-
const networkId = this._networkId;
|
|
54
|
-
const client = this._clients[networkId];
|
|
55
|
-
if (client) {
|
|
56
|
-
return client;
|
|
57
|
-
}
|
|
58
|
-
const config = this.getConfigForNetwork(networkId);
|
|
59
|
-
const newClient = this._createClient(config);
|
|
60
|
-
this._clients[networkId] = newClient;
|
|
61
|
-
return newClient;
|
|
62
|
-
}
|
|
63
|
-
getConfigForNetwork(networkId) {
|
|
64
|
-
const rpcUrl = this._getRpcUrlByNetworkId(networkId);
|
|
65
|
-
// Should prioritize custom rpc config form dashboard
|
|
66
|
-
if (rpcUrl) {
|
|
67
|
-
return Object.assign(Object.assign({}, this._config), { network: {
|
|
68
|
-
chainId: this._getChainIdByNetworkId(networkId),
|
|
69
|
-
rpcUrl,
|
|
70
|
-
} });
|
|
71
|
-
}
|
|
72
|
-
// Next should return configuration provided through settings
|
|
73
|
-
if (this.configNetworkId === networkId) {
|
|
74
|
-
return this._config;
|
|
75
|
-
}
|
|
76
|
-
if (networkId === 1) {
|
|
77
|
-
return Object.assign(Object.assign({}, this._config), { network: 'mainnet' });
|
|
78
|
-
}
|
|
79
|
-
if (networkId === 5) {
|
|
80
|
-
return Object.assign(Object.assign({}, this._config), { network: 'goerli' });
|
|
81
|
-
}
|
|
82
|
-
return this._config;
|
|
83
|
-
}
|
|
84
|
-
get configNetworkId() {
|
|
85
|
-
var _a, _b, _c;
|
|
86
|
-
if (typeof ((_a = this._config) === null || _a === void 0 ? void 0 : _a.network) !== 'string') {
|
|
87
|
-
return (_c = (_b = this._config) === null || _b === void 0 ? void 0 : _b.network) === null || _c === void 0 ? void 0 : _c.chainId;
|
|
88
|
-
}
|
|
89
|
-
return undefined;
|
|
90
|
-
}
|
|
91
|
-
_getRpcUrlByNetworkId(networkId) {
|
|
92
|
-
var _a;
|
|
93
|
-
const evm = this.evmNetworks.find((evmNetwork) => evmNetwork.networkId === networkId);
|
|
94
|
-
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]);
|
|
95
|
-
}
|
|
96
|
-
_getChainIdByNetworkId(networkId) {
|
|
97
|
-
var _a;
|
|
98
|
-
return (_a = this.evmNetworks.find((evmNetwork) => evmNetwork.networkId === networkId)) === null || _a === void 0 ? void 0 : _a.chainId;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
exports.MagicClientNetworkHandler = MagicClientNetworkHandler;
|
package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/MagicClientNetworkHandler.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { MagicSDKAdditionalConfiguration, MagicSDKExtensionsOption } from 'magic-sdk';
|
|
2
|
-
import { WalletEventListeners } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
-
import { MagicConnectorProps } from '../MagicWalletConnector';
|
|
4
|
-
import { EvmNetwork } from '../../evm-network';
|
|
5
|
-
export type MagicLinkConfig = Pick<MagicSDKAdditionalConfiguration<string, MagicSDKExtensionsOption<string>>, 'network' | 'testMode' | 'locale'> & {
|
|
6
|
-
redirectURI?: string;
|
|
7
|
-
};
|
|
8
|
-
type ConfigForNetwork = MagicSDKAdditionalConfiguration<string, MagicSDKExtensionsOption<string>> | undefined;
|
|
9
|
-
export type MagicClientNetworkHandlerProps<TClient> = Pick<MagicConnectorProps, 'config' | 'evmNetworks'> & {
|
|
10
|
-
createClient: (config: ConfigForNetwork) => TClient;
|
|
11
|
-
};
|
|
12
|
-
export declare class MagicClientNetworkHandler<TClient = unknown> {
|
|
13
|
-
protected _clients: {
|
|
14
|
-
[chainId: number]: TClient;
|
|
15
|
-
};
|
|
16
|
-
protected _networkId: number;
|
|
17
|
-
protected _config: MagicLinkConfig | undefined;
|
|
18
|
-
protected _listeners: WalletEventListeners | undefined;
|
|
19
|
-
evmNetworks: EvmNetwork[];
|
|
20
|
-
protected _createClient: MagicClientNetworkHandlerProps<TClient>['createClient'];
|
|
21
|
-
constructor({ createClient, evmNetworks, config, }: MagicClientNetworkHandlerProps<TClient>);
|
|
22
|
-
setListeners(listeners: WalletEventListeners | undefined): void;
|
|
23
|
-
onChainChanged(networkChainId: number): void;
|
|
24
|
-
selectNetwork(networkChainId: number): Promise<void>;
|
|
25
|
-
get networkId(): number;
|
|
26
|
-
get config(): MagicLinkConfig | undefined;
|
|
27
|
-
getClient(): TClient;
|
|
28
|
-
getConfigForNetwork(networkId: number): MagicSDKAdditionalConfiguration<string, MagicSDKExtensionsOption<string>> | undefined;
|
|
29
|
-
private get configNetworkId();
|
|
30
|
-
private _getRpcUrlByNetworkId;
|
|
31
|
-
private _getChainIdByNetworkId;
|
|
32
|
-
}
|
|
33
|
-
export {};
|
package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/MagicClientNetworkHandler.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from 'tslib';
|
|
2
|
-
|
|
3
|
-
// these are based off of Magic's EthNetworkName type
|
|
4
|
-
const chainNameToChainIdMap = {
|
|
5
|
-
arbitrum: 42161,
|
|
6
|
-
avalance: 43114,
|
|
7
|
-
bsc: 56,
|
|
8
|
-
gnosis: 100,
|
|
9
|
-
goerli: 5,
|
|
10
|
-
mainnet: 1,
|
|
11
|
-
optimism: 10,
|
|
12
|
-
polygon: 137,
|
|
13
|
-
sepolia: 11155111,
|
|
14
|
-
};
|
|
15
|
-
class MagicClientNetworkHandler {
|
|
16
|
-
constructor({ createClient, evmNetworks, config, }) {
|
|
17
|
-
var _a, _b;
|
|
18
|
-
this._clients = {};
|
|
19
|
-
this.evmNetworks = [];
|
|
20
|
-
this._config = config;
|
|
21
|
-
this.evmNetworks = evmNetworks;
|
|
22
|
-
this._networkId =
|
|
23
|
-
typeof (config === null || config === void 0 ? void 0 : config.network) === 'string'
|
|
24
|
-
? chainNameToChainIdMap[config.network]
|
|
25
|
-
: (_b = (_a = config === null || config === void 0 ? void 0 : config.network) === null || _a === void 0 ? void 0 : _a.chainId) !== null && _b !== void 0 ? _b : 1;
|
|
26
|
-
this._createClient = createClient;
|
|
27
|
-
}
|
|
28
|
-
setListeners(listeners) {
|
|
29
|
-
this._listeners = listeners;
|
|
30
|
-
}
|
|
31
|
-
onChainChanged(networkChainId) {
|
|
32
|
-
var _a, _b;
|
|
33
|
-
(_b = (_a = this._listeners) === null || _a === void 0 ? void 0 : _a.onChainChange) === null || _b === void 0 ? void 0 : _b.call(_a, networkChainId.toString());
|
|
34
|
-
}
|
|
35
|
-
selectNetwork(networkChainId) {
|
|
36
|
-
var _a;
|
|
37
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
this._networkId = networkChainId;
|
|
39
|
-
(_a = this.onChainChanged) === null || _a === void 0 ? void 0 : _a.call(this, networkChainId);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
get networkId() {
|
|
43
|
-
return this._networkId;
|
|
44
|
-
}
|
|
45
|
-
get config() {
|
|
46
|
-
return this._config;
|
|
47
|
-
}
|
|
48
|
-
getClient() {
|
|
49
|
-
const networkId = this._networkId;
|
|
50
|
-
const client = this._clients[networkId];
|
|
51
|
-
if (client) {
|
|
52
|
-
return client;
|
|
53
|
-
}
|
|
54
|
-
const config = this.getConfigForNetwork(networkId);
|
|
55
|
-
const newClient = this._createClient(config);
|
|
56
|
-
this._clients[networkId] = newClient;
|
|
57
|
-
return newClient;
|
|
58
|
-
}
|
|
59
|
-
getConfigForNetwork(networkId) {
|
|
60
|
-
const rpcUrl = this._getRpcUrlByNetworkId(networkId);
|
|
61
|
-
// Should prioritize custom rpc config form dashboard
|
|
62
|
-
if (rpcUrl) {
|
|
63
|
-
return Object.assign(Object.assign({}, this._config), { network: {
|
|
64
|
-
chainId: this._getChainIdByNetworkId(networkId),
|
|
65
|
-
rpcUrl,
|
|
66
|
-
} });
|
|
67
|
-
}
|
|
68
|
-
// Next should return configuration provided through settings
|
|
69
|
-
if (this.configNetworkId === networkId) {
|
|
70
|
-
return this._config;
|
|
71
|
-
}
|
|
72
|
-
if (networkId === 1) {
|
|
73
|
-
return Object.assign(Object.assign({}, this._config), { network: 'mainnet' });
|
|
74
|
-
}
|
|
75
|
-
if (networkId === 5) {
|
|
76
|
-
return Object.assign(Object.assign({}, this._config), { network: 'goerli' });
|
|
77
|
-
}
|
|
78
|
-
return this._config;
|
|
79
|
-
}
|
|
80
|
-
get configNetworkId() {
|
|
81
|
-
var _a, _b, _c;
|
|
82
|
-
if (typeof ((_a = this._config) === null || _a === void 0 ? void 0 : _a.network) !== 'string') {
|
|
83
|
-
return (_c = (_b = this._config) === null || _b === void 0 ? void 0 : _b.network) === null || _c === void 0 ? void 0 : _c.chainId;
|
|
84
|
-
}
|
|
85
|
-
return undefined;
|
|
86
|
-
}
|
|
87
|
-
_getRpcUrlByNetworkId(networkId) {
|
|
88
|
-
var _a;
|
|
89
|
-
const evm = this.evmNetworks.find((evmNetwork) => evmNetwork.networkId === networkId);
|
|
90
|
-
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]);
|
|
91
|
-
}
|
|
92
|
-
_getChainIdByNetworkId(networkId) {
|
|
93
|
-
var _a;
|
|
94
|
-
return (_a = this.evmNetworks.find((evmNetwork) => evmNetwork.networkId === networkId)) === null || _a === void 0 ? void 0 : _a.chainId;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export { MagicClientNetworkHandler };
|
|
@@ -1,55 +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 MagicWalletConnector = require('../MagicWalletConnector/MagicWalletConnector.cjs');
|
|
9
|
-
var logger = require('../../../../utils/logger.cjs');
|
|
10
|
-
var MagicClientNetworkHandler = require('../MagicClientNetworkHandler/MagicClientNetworkHandler.cjs');
|
|
11
|
-
|
|
12
|
-
class MagicSocialWalletConnector extends MagicWalletConnector.MagicWalletConnector {
|
|
13
|
-
constructor(opts) {
|
|
14
|
-
super(opts);
|
|
15
|
-
this.canConnectViaSocial = true;
|
|
16
|
-
this._magicClient = new MagicClientNetworkHandler.MagicClientNetworkHandler({
|
|
17
|
-
config: opts.config,
|
|
18
|
-
createClient: (config) => new magicSdk.Magic(opts.apiKey, Object.assign(Object.assign({}, config), { extensions: [new oauth.OAuthExtension()] })),
|
|
19
|
-
evmNetworks: opts.evmNetworks,
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
connect(provider) {
|
|
23
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
yield this.loginWithMagic(provider);
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
loginWithMagic(provider) {
|
|
28
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
const client = this._magicClient.getClient();
|
|
30
|
-
if (yield client.user.isLoggedIn()) {
|
|
31
|
-
return (yield client.user.getMetadata()).publicAddress;
|
|
32
|
-
}
|
|
33
|
-
yield client.oauth.loginWithRedirect({
|
|
34
|
-
provider,
|
|
35
|
-
redirectURI: window.location.href,
|
|
36
|
-
});
|
|
37
|
-
return undefined;
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
getSession() {
|
|
41
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
const client = this._magicClient.getClient();
|
|
43
|
-
try {
|
|
44
|
-
const result = yield client.oauth.getRedirectResult();
|
|
45
|
-
return result.oauth;
|
|
46
|
-
}
|
|
47
|
-
catch (e) {
|
|
48
|
-
logger.logger.error(e);
|
|
49
|
-
return undefined;
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
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,51 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from 'tslib';
|
|
2
|
-
import { OAuthExtension } from '@magic-ext/oauth';
|
|
3
|
-
import { Magic } from 'magic-sdk';
|
|
4
|
-
import { MagicWalletConnector } from '../MagicWalletConnector/MagicWalletConnector.js';
|
|
5
|
-
import { logger } from '../../../../utils/logger.js';
|
|
6
|
-
import { MagicClientNetworkHandler } from '../MagicClientNetworkHandler/MagicClientNetworkHandler.js';
|
|
7
|
-
|
|
8
|
-
class MagicSocialWalletConnector extends MagicWalletConnector {
|
|
9
|
-
constructor(opts) {
|
|
10
|
-
super(opts);
|
|
11
|
-
this.canConnectViaSocial = true;
|
|
12
|
-
this._magicClient = new MagicClientNetworkHandler({
|
|
13
|
-
config: opts.config,
|
|
14
|
-
createClient: (config) => new Magic(opts.apiKey, Object.assign(Object.assign({}, config), { extensions: [new OAuthExtension()] })),
|
|
15
|
-
evmNetworks: opts.evmNetworks,
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
connect(provider) {
|
|
19
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
yield this.loginWithMagic(provider);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
loginWithMagic(provider) {
|
|
24
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
const client = this._magicClient.getClient();
|
|
26
|
-
if (yield client.user.isLoggedIn()) {
|
|
27
|
-
return (yield client.user.getMetadata()).publicAddress;
|
|
28
|
-
}
|
|
29
|
-
yield client.oauth.loginWithRedirect({
|
|
30
|
-
provider,
|
|
31
|
-
redirectURI: window.location.href,
|
|
32
|
-
});
|
|
33
|
-
return undefined;
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
getSession() {
|
|
37
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
const client = this._magicClient.getClient();
|
|
39
|
-
try {
|
|
40
|
-
const result = yield client.oauth.getRedirectResult();
|
|
41
|
-
return result.oauth;
|
|
42
|
-
}
|
|
43
|
-
catch (e) {
|
|
44
|
-
logger.error(e);
|
|
45
|
-
return undefined;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export { MagicSocialWalletConnector };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './MagicSocialWalletConnector';
|
|
@@ -1,175 +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 errors = require('../../../../errors.cjs');
|
|
10
|
-
var logger = require('../../../../utils/logger.cjs');
|
|
11
|
-
var assignConfirmationScreenToProvider = require('../../../../utils/assignConfirmationScreenToProvider/assignConfirmationScreenToProvider.cjs');
|
|
12
|
-
var CancellablePromise = require('../../../../utils/CancellablePromise/CancellablePromise.cjs');
|
|
13
|
-
var MagicClientNetworkHandler = require('../MagicClientNetworkHandler/MagicClientNetworkHandler.cjs');
|
|
14
|
-
|
|
15
|
-
const storedAddressKey = 'dynamic_magic_address';
|
|
16
|
-
class MagicWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
17
|
-
get key() {
|
|
18
|
-
return 'magiclink';
|
|
19
|
-
}
|
|
20
|
-
constructor({ apiKey, walletUiUtils, evmNetworks, config, }) {
|
|
21
|
-
super();
|
|
22
|
-
this.canConnectViaCustodialService = true;
|
|
23
|
-
this.connectedChain = 'EVM';
|
|
24
|
-
this.supportedChains = ['ETH', 'EVM'];
|
|
25
|
-
this.name = 'Magic Link';
|
|
26
|
-
this._magicClient = new MagicClientNetworkHandler.MagicClientNetworkHandler({
|
|
27
|
-
config,
|
|
28
|
-
createClient: (config) => new magicSdk.Magic(apiKey, config),
|
|
29
|
-
evmNetworks,
|
|
30
|
-
});
|
|
31
|
-
this.evmNetworks = evmNetworks;
|
|
32
|
-
this._walletUiUtils = walletUiUtils;
|
|
33
|
-
}
|
|
34
|
-
getDeepLink() {
|
|
35
|
-
return undefined;
|
|
36
|
-
}
|
|
37
|
-
connect() {
|
|
38
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
yield this.fetchPublicAddress();
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
endSession() {
|
|
43
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
localStorage.removeItem(storedAddressKey);
|
|
45
|
-
const client = this._magicClient.getClient();
|
|
46
|
-
yield client.user.logout();
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
getUserMetadata() {
|
|
50
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
if (yield this._isLoggedIn()) {
|
|
52
|
-
const client = this._magicClient.getClient();
|
|
53
|
-
return client.user.getMetadata();
|
|
54
|
-
}
|
|
55
|
-
return undefined;
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
fetchPublicAddress() {
|
|
59
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
const address = localStorage.getItem(storedAddressKey);
|
|
61
|
-
if (address)
|
|
62
|
-
return address;
|
|
63
|
-
const client = this._magicClient.getClient();
|
|
64
|
-
try {
|
|
65
|
-
try {
|
|
66
|
-
this._currentAuthCancellablePromise = CancellablePromise.CancellablePromise.fromPromise(this.loginWithMagic());
|
|
67
|
-
yield this._currentAuthCancellablePromise;
|
|
68
|
-
}
|
|
69
|
-
catch (err) {
|
|
70
|
-
logger.logger.error(err);
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
const metadata = yield client.user.getMetadata();
|
|
74
|
-
if (!metadata || !metadata.publicAddress) {
|
|
75
|
-
throw new Error('No public address');
|
|
76
|
-
}
|
|
77
|
-
if (metadata.issuer) {
|
|
78
|
-
this.providerResources = [`magic-auth:issuer:${metadata.issuer}`];
|
|
79
|
-
}
|
|
80
|
-
localStorage.setItem(storedAddressKey, metadata.publicAddress);
|
|
81
|
-
return metadata.publicAddress;
|
|
82
|
-
}
|
|
83
|
-
catch (err) {
|
|
84
|
-
return undefined;
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
getBalance() {
|
|
89
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
const provider = yield this.getWeb3Provider();
|
|
91
|
-
if (!provider)
|
|
92
|
-
throw new errors.DynamicError('No provider');
|
|
93
|
-
const signer = provider.getSigner();
|
|
94
|
-
const userAddress = yield signer.getAddress();
|
|
95
|
-
return ethers.ethers.utils.formatEther(yield provider.getBalance(userAddress));
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
getConnectedAccounts() {
|
|
99
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
100
|
-
const address = localStorage.getItem(storedAddressKey);
|
|
101
|
-
if (!address)
|
|
102
|
-
return [];
|
|
103
|
-
return [address];
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
getNetwork() {
|
|
107
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
108
|
-
return this._magicClient.networkId;
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
getRpcProvider() {
|
|
112
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
return undefined;
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
getSigner() {
|
|
117
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
118
|
-
const provider = yield this.getWeb3Provider();
|
|
119
|
-
return provider.getSigner();
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
getWeb3Provider() {
|
|
123
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
124
|
-
const client = this._magicClient.getClient();
|
|
125
|
-
const provider = new ethers.ethers.providers.Web3Provider(client.rpcProvider);
|
|
126
|
-
assignConfirmationScreenToProvider.assignConfirmationScreenToProvider(provider, this._walletUiUtils);
|
|
127
|
-
return provider;
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
setupEventListeners(listeners) {
|
|
131
|
-
this._listeners = listeners;
|
|
132
|
-
this._magicClient.setListeners(listeners);
|
|
133
|
-
this._checkIfLoggedIn();
|
|
134
|
-
}
|
|
135
|
-
signMessage(messageToSign) {
|
|
136
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
137
|
-
const provider = yield this.getWeb3Provider();
|
|
138
|
-
return provider.getSigner().signMessage(messageToSign);
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
supportsNetworkSwitching() {
|
|
142
|
-
return true;
|
|
143
|
-
}
|
|
144
|
-
switchNetwork({ networkChainId, }) {
|
|
145
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
146
|
-
if (!networkChainId) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
this._magicClient.selectNetwork(networkChainId);
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
teardownEventListeners() {
|
|
153
|
-
this._listeners = undefined;
|
|
154
|
-
this._magicClient.setListeners(undefined);
|
|
155
|
-
}
|
|
156
|
-
_isLoggedIn() {
|
|
157
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
158
|
-
const client = this._magicClient.getClient();
|
|
159
|
-
return client.user.isLoggedIn();
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
_checkIfLoggedIn() {
|
|
163
|
-
var _a, _b;
|
|
164
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
165
|
-
const isLoggedIn = yield this._isLoggedIn();
|
|
166
|
-
if (!isLoggedIn) {
|
|
167
|
-
localStorage.removeItem(storedAddressKey);
|
|
168
|
-
(_b = (_a = this._listeners) === null || _a === void 0 ? void 0 : _a.onDisconnect) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
169
|
-
}
|
|
170
|
-
return isLoggedIn;
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
exports.MagicWalletConnector = MagicWalletConnector;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { LoginWithMagicLinkEvents, Magic, MagicUserMetadata, PromiEvent } from 'magic-sdk';
|
|
2
|
-
import { ethers } from 'ethers';
|
|
3
|
-
import { OAuthExtension, OAuthProvider } from '@magic-ext/oauth';
|
|
4
|
-
import { Chain, WalletConnectorBase, WalletEventListeners } from '@dynamic-labs/wallet-connector-core';
|
|
5
|
-
import { WalletUiUtils } from '../../../../types';
|
|
6
|
-
import { CancellablePromise } from '../../../../utils/CancellablePromise';
|
|
7
|
-
import { MagicLinkConfig, MagicClientNetworkHandler } from '../MagicClientNetworkHandler';
|
|
8
|
-
import { EvmNetwork } from './../../evm-network';
|
|
9
|
-
export type MagicConnectorProps = {
|
|
10
|
-
apiKey: string;
|
|
11
|
-
config?: MagicLinkConfig;
|
|
12
|
-
evmNetworks: EvmNetwork[];
|
|
13
|
-
walletUiUtils: WalletUiUtils;
|
|
14
|
-
};
|
|
15
|
-
export type MagicPromiEvent = PromiEvent<string | null, LoginWithMagicLinkEvents & {
|
|
16
|
-
done: (result: string | null) => void;
|
|
17
|
-
error: (reason: any) => void;
|
|
18
|
-
settled: () => void;
|
|
19
|
-
}>;
|
|
20
|
-
export declare abstract class MagicWalletConnector extends WalletConnectorBase {
|
|
21
|
-
get key(): string;
|
|
22
|
-
canConnectViaCustodialService: boolean;
|
|
23
|
-
connectedChain: Chain;
|
|
24
|
-
supportedChains: Chain[];
|
|
25
|
-
name: string;
|
|
26
|
-
evmNetworks: EvmNetwork[];
|
|
27
|
-
_walletUiUtils: WalletUiUtils;
|
|
28
|
-
_listeners: WalletEventListeners | undefined;
|
|
29
|
-
_currentAuthCancellablePromise: CancellablePromise<MagicPromiEvent | undefined> | undefined;
|
|
30
|
-
protected _magicClient: MagicClientNetworkHandler<Magic | Magic<OAuthExtension[]>>;
|
|
31
|
-
constructor({ apiKey, walletUiUtils, evmNetworks, config, }: MagicConnectorProps);
|
|
32
|
-
abstract loginWithMagic(provider?: OAuthProvider): Promise<MagicPromiEvent | undefined>;
|
|
33
|
-
getDeepLink(): string | undefined;
|
|
34
|
-
connect(provider?: OAuthProvider): Promise<void>;
|
|
35
|
-
endSession(): Promise<void>;
|
|
36
|
-
getUserMetadata(): Promise<MagicUserMetadata | undefined>;
|
|
37
|
-
fetchPublicAddress(): Promise<string | undefined>;
|
|
38
|
-
getBalance(): Promise<string | undefined>;
|
|
39
|
-
getConnectedAccounts(): Promise<string[]>;
|
|
40
|
-
getNetwork(): Promise<number | undefined>;
|
|
41
|
-
getRpcProvider(): Promise<void | ethers.providers.JsonRpcProvider | undefined>;
|
|
42
|
-
getSigner(): Promise<ethers.providers.JsonRpcSigner | undefined>;
|
|
43
|
-
getWeb3Provider(): Promise<ethers.providers.Web3Provider>;
|
|
44
|
-
setupEventListeners(listeners: WalletEventListeners): void;
|
|
45
|
-
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
46
|
-
supportsNetworkSwitching(): boolean;
|
|
47
|
-
switchNetwork({ networkChainId, }: {
|
|
48
|
-
networkChainId?: number;
|
|
49
|
-
}): Promise<void>;
|
|
50
|
-
teardownEventListeners(): void;
|
|
51
|
-
_isLoggedIn(): Promise<boolean>;
|
|
52
|
-
_checkIfLoggedIn(): Promise<boolean>;
|
|
53
|
-
}
|