@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,73 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var tslib = require('tslib');
|
|
6
|
-
var walletSdk = require('@coinbase/wallet-sdk');
|
|
7
|
-
var utils = require('ethers/lib/utils');
|
|
8
|
-
var errors = require('../../../errors.cjs');
|
|
9
|
-
var constants = require('../../constants.cjs');
|
|
10
|
-
|
|
11
|
-
const jsonRpcUrl = `https://mainnet.infura.io/v3/${constants.infuraId}`;
|
|
12
|
-
const chainId = 1;
|
|
13
|
-
const getCoinbaseProvider = ({ opts: { appLogoUrl, appName = '', evmNetworks = [] } = {}, handlers, }) => {
|
|
14
|
-
var _a, _b;
|
|
15
|
-
const coinbaseWalletSDK = new walletSdk.CoinbaseWalletSDK({
|
|
16
|
-
appLogoUrl,
|
|
17
|
-
appName,
|
|
18
|
-
eventListener: {
|
|
19
|
-
onEvent: (eventType) => {
|
|
20
|
-
if (eventType === 'walletlink_sdk.disconnected') {
|
|
21
|
-
handlers === null || handlers === void 0 ? void 0 : handlers.onDisconnect();
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
headlessMode: true,
|
|
26
|
-
reloadOnDisconnect: false,
|
|
27
|
-
});
|
|
28
|
-
const network = evmNetworks === null || evmNetworks === void 0 ? void 0 : evmNetworks.find((network) => network.chainId === chainId);
|
|
29
|
-
const rpcUrl = ((_a = network === null || network === void 0 ? void 0 : network.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) || ((_b = network === null || network === void 0 ? void 0 : network.rpcUrls) === null || _b === void 0 ? void 0 : _b[0]) || jsonRpcUrl;
|
|
30
|
-
return coinbaseWalletSDK.makeWeb3Provider(rpcUrl, chainId);
|
|
31
|
-
};
|
|
32
|
-
const killCoinbaseSession = () => {
|
|
33
|
-
const provider = getCoinbaseProvider({
|
|
34
|
-
opts: { appLogoUrl: '', appName: '' },
|
|
35
|
-
});
|
|
36
|
-
if (provider.connected) {
|
|
37
|
-
provider.close();
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
const fetchPublicAddress = (coinbaseProviderOpts, opts) => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
-
var _a;
|
|
42
|
-
const provider = getCoinbaseProvider({ opts: coinbaseProviderOpts });
|
|
43
|
-
const { qrUrl } = provider;
|
|
44
|
-
if (!qrUrl) {
|
|
45
|
-
throw new errors.DynamicError('no qr url available');
|
|
46
|
-
}
|
|
47
|
-
(_a = opts === null || opts === void 0 ? void 0 : opts.onDisplayUri) === null || _a === void 0 ? void 0 : _a.call(opts, qrUrl);
|
|
48
|
-
const [address] = yield provider.request({
|
|
49
|
-
method: 'eth_requestAccounts',
|
|
50
|
-
});
|
|
51
|
-
return address;
|
|
52
|
-
});
|
|
53
|
-
const signMessage = (coinbaseProviderOpts, messageToSign) => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
-
const provider = getCoinbaseProvider({ opts: coinbaseProviderOpts });
|
|
55
|
-
const [address] = yield provider.request({
|
|
56
|
-
method: 'eth_requestAccounts',
|
|
57
|
-
});
|
|
58
|
-
try {
|
|
59
|
-
return yield provider.request({
|
|
60
|
-
method: 'personal_sign',
|
|
61
|
-
params: [utils.hexlify(utils.toUtf8Bytes(messageToSign)), address.toLowerCase()],
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
catch (err) {
|
|
65
|
-
yield provider.close();
|
|
66
|
-
return undefined;
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
exports.fetchPublicAddress = fetchPublicAddress;
|
|
71
|
-
exports.getCoinbaseProvider = getCoinbaseProvider;
|
|
72
|
-
exports.killCoinbaseSession = killCoinbaseSession;
|
|
73
|
-
exports.signMessage = signMessage;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { FetchPublicAddressOpts } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
-
import { GetCoinbaseProvider, GetCoinbaseProviderOpts } from './types';
|
|
3
|
-
export declare const getCoinbaseProvider: GetCoinbaseProvider;
|
|
4
|
-
export declare const killCoinbaseSession: () => void;
|
|
5
|
-
export declare const fetchPublicAddress: (coinbaseProviderOpts: GetCoinbaseProviderOpts, opts?: FetchPublicAddressOpts) => Promise<string | undefined>;
|
|
6
|
-
export declare const signMessage: (coinbaseProviderOpts: GetCoinbaseProviderOpts, messageToSign: string) => Promise<string | undefined>;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from 'tslib';
|
|
2
|
-
import { CoinbaseWalletSDK } from '@coinbase/wallet-sdk';
|
|
3
|
-
import { hexlify, toUtf8Bytes } from 'ethers/lib/utils.js';
|
|
4
|
-
import { DynamicError } from '../../../errors.js';
|
|
5
|
-
import { infuraId } from '../../constants.js';
|
|
6
|
-
|
|
7
|
-
const jsonRpcUrl = `https://mainnet.infura.io/v3/${infuraId}`;
|
|
8
|
-
const chainId = 1;
|
|
9
|
-
const getCoinbaseProvider = ({ opts: { appLogoUrl, appName = '', evmNetworks = [] } = {}, handlers, }) => {
|
|
10
|
-
var _a, _b;
|
|
11
|
-
const coinbaseWalletSDK = new CoinbaseWalletSDK({
|
|
12
|
-
appLogoUrl,
|
|
13
|
-
appName,
|
|
14
|
-
eventListener: {
|
|
15
|
-
onEvent: (eventType) => {
|
|
16
|
-
if (eventType === 'walletlink_sdk.disconnected') {
|
|
17
|
-
handlers === null || handlers === void 0 ? void 0 : handlers.onDisconnect();
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
headlessMode: true,
|
|
22
|
-
reloadOnDisconnect: false,
|
|
23
|
-
});
|
|
24
|
-
const network = evmNetworks === null || evmNetworks === void 0 ? void 0 : evmNetworks.find((network) => network.chainId === chainId);
|
|
25
|
-
const rpcUrl = ((_a = network === null || network === void 0 ? void 0 : network.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) || ((_b = network === null || network === void 0 ? void 0 : network.rpcUrls) === null || _b === void 0 ? void 0 : _b[0]) || jsonRpcUrl;
|
|
26
|
-
return coinbaseWalletSDK.makeWeb3Provider(rpcUrl, chainId);
|
|
27
|
-
};
|
|
28
|
-
const killCoinbaseSession = () => {
|
|
29
|
-
const provider = getCoinbaseProvider({
|
|
30
|
-
opts: { appLogoUrl: '', appName: '' },
|
|
31
|
-
});
|
|
32
|
-
if (provider.connected) {
|
|
33
|
-
provider.close();
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
const fetchPublicAddress = (coinbaseProviderOpts, opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
-
var _a;
|
|
38
|
-
const provider = getCoinbaseProvider({ opts: coinbaseProviderOpts });
|
|
39
|
-
const { qrUrl } = provider;
|
|
40
|
-
if (!qrUrl) {
|
|
41
|
-
throw new DynamicError('no qr url available');
|
|
42
|
-
}
|
|
43
|
-
(_a = opts === null || opts === void 0 ? void 0 : opts.onDisplayUri) === null || _a === void 0 ? void 0 : _a.call(opts, qrUrl);
|
|
44
|
-
const [address] = yield provider.request({
|
|
45
|
-
method: 'eth_requestAccounts',
|
|
46
|
-
});
|
|
47
|
-
return address;
|
|
48
|
-
});
|
|
49
|
-
const signMessage = (coinbaseProviderOpts, messageToSign) => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
-
const provider = getCoinbaseProvider({ opts: coinbaseProviderOpts });
|
|
51
|
-
const [address] = yield provider.request({
|
|
52
|
-
method: 'eth_requestAccounts',
|
|
53
|
-
});
|
|
54
|
-
try {
|
|
55
|
-
return yield provider.request({
|
|
56
|
-
method: 'personal_sign',
|
|
57
|
-
params: [hexlify(toUtf8Bytes(messageToSign)), address.toLowerCase()],
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
catch (err) {
|
|
61
|
-
yield provider.close();
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
export { fetchPublicAddress, getCoinbaseProvider, killCoinbaseSession, signMessage };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { CoinbaseWalletProvider } from '@coinbase/wallet-sdk';
|
|
2
|
-
import { EvmNetwork } from '../../ethereum/evm-network';
|
|
3
|
-
export type GetCoinbaseProviderOpts = {
|
|
4
|
-
appLogoUrl?: string;
|
|
5
|
-
appName?: string;
|
|
6
|
-
evmNetworks?: EvmNetwork[];
|
|
7
|
-
};
|
|
8
|
-
export type CoinbaseProviderHandlerOpts = {
|
|
9
|
-
onDisconnect(): Promise<void>;
|
|
10
|
-
};
|
|
11
|
-
export type GetCoinbaseProvider = (args: {
|
|
12
|
-
handlers?: CoinbaseProviderHandlerOpts;
|
|
13
|
-
opts?: GetCoinbaseProviderOpts;
|
|
14
|
-
}) => CoinbaseWalletProvider;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './walletConnect';
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var tslib = require('tslib');
|
|
6
|
-
var Client = require('@walletconnect/client');
|
|
7
|
-
var isMobile = require('../../../utils/isMobile.cjs');
|
|
8
|
-
var isSameAddress = require('../../../utils/isSameAddress/isSameAddress.cjs');
|
|
9
|
-
var logger = require('../../../utils/logger.cjs');
|
|
10
|
-
|
|
11
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
|
-
|
|
13
|
-
var Client__default = /*#__PURE__*/_interopDefaultLegacy(Client);
|
|
14
|
-
|
|
15
|
-
const initClient = (name, settings) => {
|
|
16
|
-
const storageId = `walletconnect-${name}`;
|
|
17
|
-
const session = localStorage.getItem(storageId);
|
|
18
|
-
const clientArgs = session
|
|
19
|
-
? { session: JSON.parse(session), storageId }
|
|
20
|
-
: { bridge: 'https://bridge.walletconnect.org', storageId };
|
|
21
|
-
return new Client__default["default"](Object.assign(Object.assign({}, clientArgs), settings));
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Attach event handlers to WalletConnect events.
|
|
25
|
-
*/
|
|
26
|
-
const setupWalletConnectEventListeners = (opts, client) => {
|
|
27
|
-
if (!client) {
|
|
28
|
-
return () => {
|
|
29
|
-
// nothing to teardown
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
let prevAccount;
|
|
33
|
-
let prevChain;
|
|
34
|
-
if (client.connected) {
|
|
35
|
-
// eslint-disable-next-line prefer-destructuring
|
|
36
|
-
prevAccount = client.accounts[0];
|
|
37
|
-
prevChain = client.chainId;
|
|
38
|
-
}
|
|
39
|
-
client.on('disconnect', () => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
-
var _a;
|
|
41
|
-
yield ((_a = opts.onDisconnect) === null || _a === void 0 ? void 0 : _a.call(opts));
|
|
42
|
-
}));
|
|
43
|
-
client.on('session_update', (_, payload) => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
-
var _b, _c;
|
|
45
|
-
// eslint-disable-next-line prefer-destructuring
|
|
46
|
-
const { accounts, chainId } = payload.params[0];
|
|
47
|
-
const didAccountChange = !isSameAddress.isSameAddress(prevAccount || '', accounts[0], 'eip155');
|
|
48
|
-
const didChainChange = prevChain !== chainId;
|
|
49
|
-
// eslint-disable-next-line prefer-destructuring
|
|
50
|
-
prevAccount = accounts[0];
|
|
51
|
-
prevChain = chainId;
|
|
52
|
-
if (didAccountChange) {
|
|
53
|
-
yield ((_b = opts.onAccountChange) === null || _b === void 0 ? void 0 : _b.call(opts, accounts));
|
|
54
|
-
}
|
|
55
|
-
if (didChainChange) {
|
|
56
|
-
yield ((_c = opts.onChainChange) === null || _c === void 0 ? void 0 : _c.call(opts, String(chainId)));
|
|
57
|
-
}
|
|
58
|
-
}));
|
|
59
|
-
return () => {
|
|
60
|
-
client.off('disconnect');
|
|
61
|
-
client.off('session_update');
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
const teardownWalletConnectEventListeners = (client) => {
|
|
65
|
-
client.off('disconnect');
|
|
66
|
-
client.off('session_update');
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* Initialize a client from a stored session and terminate the connection.
|
|
70
|
-
*/
|
|
71
|
-
const killWalletConnectSession = (client) => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
72
|
-
try {
|
|
73
|
-
if (client === null || client === void 0 ? void 0 : client.connected) {
|
|
74
|
-
yield client.killSession();
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
catch (e) {
|
|
78
|
-
logger.logger.debug(e);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
const getDeepLink = (uri, metadata, { removeWCUri = false, } = {}) => {
|
|
82
|
-
var _a, _b, _c, _d;
|
|
83
|
-
if (!isMobile.isMobile()) {
|
|
84
|
-
const origin = ((_a = metadata.desktop) === null || _a === void 0 ? void 0 : _a.universal) || ((_b = metadata.desktop) === null || _b === void 0 ? void 0 : _b.native);
|
|
85
|
-
if (removeWCUri)
|
|
86
|
-
return origin || '';
|
|
87
|
-
return `${origin}?uri=${encodeURIComponent(uri !== null && uri !== void 0 ? uri : '')}`;
|
|
88
|
-
}
|
|
89
|
-
// deeplinks for ios require special treatment
|
|
90
|
-
// see: https://docs.walletconnect.com/mobile-linking#for-ios
|
|
91
|
-
else if (isMobile.isIOS()) {
|
|
92
|
-
const origin = ((_c = metadata.mobile) === null || _c === void 0 ? void 0 : _c.universal) || ((_d = metadata.mobile) === null || _d === void 0 ? void 0 : _d.native);
|
|
93
|
-
if (removeWCUri)
|
|
94
|
-
return origin || '';
|
|
95
|
-
return `${origin}?uri=${encodeURIComponent(uri !== null && uri !== void 0 ? uri : '')}`;
|
|
96
|
-
}
|
|
97
|
-
// on android, the deeplink is simply the uri
|
|
98
|
-
// see: https://docs.walletconnect.com/mobile-linking#for-android
|
|
99
|
-
return uri;
|
|
100
|
-
};
|
|
101
|
-
const createSession = (client) => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
102
|
-
return new Promise((resolve, reject) => {
|
|
103
|
-
try {
|
|
104
|
-
client.on('connect', (error, payload) => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
105
|
-
if (error)
|
|
106
|
-
throw error;
|
|
107
|
-
resolve(payload);
|
|
108
|
-
}));
|
|
109
|
-
client.on('disconnect', (error, payload) => {
|
|
110
|
-
throw error || payload.params[0].message;
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
catch (e) {
|
|
114
|
-
reject(e);
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
const useDeepLink = (metadata, wcClient, opts) => {
|
|
119
|
-
var _a, _b, _c;
|
|
120
|
-
const deepLink = getDeepLink(wcClient.uri, metadata);
|
|
121
|
-
if (isMobile.isMobile()) {
|
|
122
|
-
window.location.href = deepLink;
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
if ((_a = metadata === null || metadata === void 0 ? void 0 : metadata.desktop) === null || _a === void 0 ? void 0 : _a.native) {
|
|
126
|
-
(_b = opts === null || opts === void 0 ? void 0 : opts.onDesktopUri) === null || _b === void 0 ? void 0 : _b.call(opts, deepLink);
|
|
127
|
-
}
|
|
128
|
-
(_c = opts === null || opts === void 0 ? void 0 : opts.onDisplayUri) === null || _c === void 0 ? void 0 : _c.call(opts, wcClient.uri);
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
const fetchWalletConnectCosmosPublicAddress = (metadata, wcClient, provider, opts) => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
132
|
-
var _a;
|
|
133
|
-
if (wcClient.connected) {
|
|
134
|
-
const key = yield provider.getKey(opts.chainId);
|
|
135
|
-
return key.bech32Address;
|
|
136
|
-
}
|
|
137
|
-
yield wcClient.createSession();
|
|
138
|
-
useDeepLink(metadata, wcClient, opts);
|
|
139
|
-
const payload = yield createSession(wcClient);
|
|
140
|
-
const key = yield provider.getKey(opts.chainId);
|
|
141
|
-
(_a = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _a === void 0 ? void 0 : _a.call(opts, payload);
|
|
142
|
-
wcClient.accounts = [key.bech32Address];
|
|
143
|
-
return key.bech32Address;
|
|
144
|
-
});
|
|
145
|
-
const fetchWalletConnectEVMPublicAddress = (metadata, wcClient, opts) => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
146
|
-
var _b;
|
|
147
|
-
if (wcClient.connected) {
|
|
148
|
-
const [accountPublicAddress] = wcClient.accounts;
|
|
149
|
-
return accountPublicAddress;
|
|
150
|
-
}
|
|
151
|
-
// createSession will trigger the QR code...
|
|
152
|
-
yield wcClient.createSession();
|
|
153
|
-
useDeepLink(metadata, wcClient, opts);
|
|
154
|
-
const payload = yield createSession(wcClient);
|
|
155
|
-
(_b = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _b === void 0 ? void 0 : _b.call(opts, payload);
|
|
156
|
-
const [accountPublicAddress] = payload.params[0].accounts;
|
|
157
|
-
return accountPublicAddress;
|
|
158
|
-
});
|
|
159
|
-
const signWalletConnectPersonalMessage = (messageToSign, metadata, client) => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
160
|
-
var _c, _d;
|
|
161
|
-
const isCryptoWallet = ((_c = client === null || client === void 0 ? void 0 : client.peerMeta) === null || _c === void 0 ? void 0 : _c.name) === 'Crypto.com | DeFi Wallet' ||
|
|
162
|
-
((_d = client === null || client === void 0 ? void 0 : client.peerMeta) === null || _d === void 0 ? void 0 : _d.name) === 'DeFi Wallet';
|
|
163
|
-
if (!client || !client.connected) {
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
167
|
-
const [accountPublicAddress] = client.accounts;
|
|
168
|
-
if (isMobile.isMobile()) {
|
|
169
|
-
const deepLink = getDeepLink(client.uri, metadata, {
|
|
170
|
-
removeWCUri: isMobile.isIOS() && isCryptoWallet,
|
|
171
|
-
});
|
|
172
|
-
window.location.href = deepLink;
|
|
173
|
-
}
|
|
174
|
-
try {
|
|
175
|
-
// This delay is required for Crypto.com DeFi wallet, when there is no delay the app
|
|
176
|
-
// will not open the pop-up to sign. That seems to be a limitation in the standalone client
|
|
177
|
-
// so the delay is required to allow the users to sign the message
|
|
178
|
-
if (isCryptoWallet && isMobile.isMobile()) {
|
|
179
|
-
yield sleep(4000);
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
// The delay of 1 second is necessary for some of the wallets to open the sign UI in the
|
|
183
|
-
// correct order, without this some wallets like Trust or OKX will no open properly,
|
|
184
|
-
// and not allowing the user to sign the message
|
|
185
|
-
yield sleep(1000);
|
|
186
|
-
}
|
|
187
|
-
return client.signPersonalMessage([messageToSign, accountPublicAddress]);
|
|
188
|
-
}
|
|
189
|
-
catch (e) {
|
|
190
|
-
logger.logger.debug(e);
|
|
191
|
-
throw e;
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
exports.createSession = createSession;
|
|
196
|
-
exports.fetchWalletConnectCosmosPublicAddress = fetchWalletConnectCosmosPublicAddress;
|
|
197
|
-
exports.fetchWalletConnectEVMPublicAddress = fetchWalletConnectEVMPublicAddress;
|
|
198
|
-
exports.getDeepLink = getDeepLink;
|
|
199
|
-
exports.initClient = initClient;
|
|
200
|
-
exports.killWalletConnectSession = killWalletConnectSession;
|
|
201
|
-
exports.setupWalletConnectEventListeners = setupWalletConnectEventListeners;
|
|
202
|
-
exports.signWalletConnectPersonalMessage = signWalletConnectPersonalMessage;
|
|
203
|
-
exports.teardownWalletConnectEventListeners = teardownWalletConnectEventListeners;
|
|
204
|
-
exports.useDeepLink = useDeepLink;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import Client from '@walletconnect/client';
|
|
2
|
-
import { FetchPublicAddressOpts, PayloadParams, WalletEventListeners } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
-
import { WalletSchema } from '@dynamic-labs/wallet-book';
|
|
4
|
-
import { KeplrWalletConnectV1 } from '../../cosmos/wcClient';
|
|
5
|
-
export declare const initClient: (name: string, settings?: any) => Client;
|
|
6
|
-
/**
|
|
7
|
-
* Attach event handlers to WalletConnect events.
|
|
8
|
-
*/
|
|
9
|
-
export declare const setupWalletConnectEventListeners: (opts: WalletEventListeners, client: Client) => (() => void);
|
|
10
|
-
export declare const teardownWalletConnectEventListeners: (client: Client) => void;
|
|
11
|
-
/**
|
|
12
|
-
* Initialize a client from a stored session and terminate the connection.
|
|
13
|
-
*/
|
|
14
|
-
export declare const killWalletConnectSession: (client: Client) => Promise<void>;
|
|
15
|
-
export declare const getDeepLink: (uri: string, metadata: WalletSchema, { removeWCUri, }?: {
|
|
16
|
-
removeWCUri?: boolean | undefined;
|
|
17
|
-
}) => string;
|
|
18
|
-
export declare const createSession: (client: Client) => Promise<PayloadParams>;
|
|
19
|
-
export declare const useDeepLink: (metadata: WalletSchema, wcClient: Client, opts?: FetchPublicAddressOpts) => void;
|
|
20
|
-
export declare const fetchWalletConnectCosmosPublicAddress: (metadata: WalletSchema, wcClient: Client, provider: KeplrWalletConnectV1, opts: FetchPublicAddressOpts & Required<Pick<FetchPublicAddressOpts, 'chainId'>>) => Promise<string>;
|
|
21
|
-
export declare const fetchWalletConnectEVMPublicAddress: (metadata: WalletSchema, wcClient: Client, opts?: FetchPublicAddressOpts) => Promise<string | undefined>;
|
|
22
|
-
export declare const signWalletConnectPersonalMessage: (messageToSign: string, metadata: WalletSchema, client: Client) => Promise<string | undefined>;
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from 'tslib';
|
|
2
|
-
import Client from '@walletconnect/client';
|
|
3
|
-
import { isMobile, isIOS } from '../../../utils/isMobile.js';
|
|
4
|
-
import { isSameAddress } from '../../../utils/isSameAddress/isSameAddress.js';
|
|
5
|
-
import { logger } from '../../../utils/logger.js';
|
|
6
|
-
|
|
7
|
-
const initClient = (name, settings) => {
|
|
8
|
-
const storageId = `walletconnect-${name}`;
|
|
9
|
-
const session = localStorage.getItem(storageId);
|
|
10
|
-
const clientArgs = session
|
|
11
|
-
? { session: JSON.parse(session), storageId }
|
|
12
|
-
: { bridge: 'https://bridge.walletconnect.org', storageId };
|
|
13
|
-
return new Client(Object.assign(Object.assign({}, clientArgs), settings));
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Attach event handlers to WalletConnect events.
|
|
17
|
-
*/
|
|
18
|
-
const setupWalletConnectEventListeners = (opts, client) => {
|
|
19
|
-
if (!client) {
|
|
20
|
-
return () => {
|
|
21
|
-
// nothing to teardown
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
let prevAccount;
|
|
25
|
-
let prevChain;
|
|
26
|
-
if (client.connected) {
|
|
27
|
-
// eslint-disable-next-line prefer-destructuring
|
|
28
|
-
prevAccount = client.accounts[0];
|
|
29
|
-
prevChain = client.chainId;
|
|
30
|
-
}
|
|
31
|
-
client.on('disconnect', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
-
var _a;
|
|
33
|
-
yield ((_a = opts.onDisconnect) === null || _a === void 0 ? void 0 : _a.call(opts));
|
|
34
|
-
}));
|
|
35
|
-
client.on('session_update', (_, payload) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
-
var _b, _c;
|
|
37
|
-
// eslint-disable-next-line prefer-destructuring
|
|
38
|
-
const { accounts, chainId } = payload.params[0];
|
|
39
|
-
const didAccountChange = !isSameAddress(prevAccount || '', accounts[0], 'eip155');
|
|
40
|
-
const didChainChange = prevChain !== chainId;
|
|
41
|
-
// eslint-disable-next-line prefer-destructuring
|
|
42
|
-
prevAccount = accounts[0];
|
|
43
|
-
prevChain = chainId;
|
|
44
|
-
if (didAccountChange) {
|
|
45
|
-
yield ((_b = opts.onAccountChange) === null || _b === void 0 ? void 0 : _b.call(opts, accounts));
|
|
46
|
-
}
|
|
47
|
-
if (didChainChange) {
|
|
48
|
-
yield ((_c = opts.onChainChange) === null || _c === void 0 ? void 0 : _c.call(opts, String(chainId)));
|
|
49
|
-
}
|
|
50
|
-
}));
|
|
51
|
-
return () => {
|
|
52
|
-
client.off('disconnect');
|
|
53
|
-
client.off('session_update');
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
const teardownWalletConnectEventListeners = (client) => {
|
|
57
|
-
client.off('disconnect');
|
|
58
|
-
client.off('session_update');
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Initialize a client from a stored session and terminate the connection.
|
|
62
|
-
*/
|
|
63
|
-
const killWalletConnectSession = (client) => __awaiter(void 0, void 0, void 0, function* () {
|
|
64
|
-
try {
|
|
65
|
-
if (client === null || client === void 0 ? void 0 : client.connected) {
|
|
66
|
-
yield client.killSession();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
catch (e) {
|
|
70
|
-
logger.debug(e);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
const getDeepLink = (uri, metadata, { removeWCUri = false, } = {}) => {
|
|
74
|
-
var _a, _b, _c, _d;
|
|
75
|
-
if (!isMobile()) {
|
|
76
|
-
const origin = ((_a = metadata.desktop) === null || _a === void 0 ? void 0 : _a.universal) || ((_b = metadata.desktop) === null || _b === void 0 ? void 0 : _b.native);
|
|
77
|
-
if (removeWCUri)
|
|
78
|
-
return origin || '';
|
|
79
|
-
return `${origin}?uri=${encodeURIComponent(uri !== null && uri !== void 0 ? uri : '')}`;
|
|
80
|
-
}
|
|
81
|
-
// deeplinks for ios require special treatment
|
|
82
|
-
// see: https://docs.walletconnect.com/mobile-linking#for-ios
|
|
83
|
-
else if (isIOS()) {
|
|
84
|
-
const origin = ((_c = metadata.mobile) === null || _c === void 0 ? void 0 : _c.universal) || ((_d = metadata.mobile) === null || _d === void 0 ? void 0 : _d.native);
|
|
85
|
-
if (removeWCUri)
|
|
86
|
-
return origin || '';
|
|
87
|
-
return `${origin}?uri=${encodeURIComponent(uri !== null && uri !== void 0 ? uri : '')}`;
|
|
88
|
-
}
|
|
89
|
-
// on android, the deeplink is simply the uri
|
|
90
|
-
// see: https://docs.walletconnect.com/mobile-linking#for-android
|
|
91
|
-
return uri;
|
|
92
|
-
};
|
|
93
|
-
const createSession = (client) => __awaiter(void 0, void 0, void 0, function* () {
|
|
94
|
-
return new Promise((resolve, reject) => {
|
|
95
|
-
try {
|
|
96
|
-
client.on('connect', (error, payload) => __awaiter(void 0, void 0, void 0, function* () {
|
|
97
|
-
if (error)
|
|
98
|
-
throw error;
|
|
99
|
-
resolve(payload);
|
|
100
|
-
}));
|
|
101
|
-
client.on('disconnect', (error, payload) => {
|
|
102
|
-
throw error || payload.params[0].message;
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
catch (e) {
|
|
106
|
-
reject(e);
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
const useDeepLink = (metadata, wcClient, opts) => {
|
|
111
|
-
var _a, _b, _c;
|
|
112
|
-
const deepLink = getDeepLink(wcClient.uri, metadata);
|
|
113
|
-
if (isMobile()) {
|
|
114
|
-
window.location.href = deepLink;
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
if ((_a = metadata === null || metadata === void 0 ? void 0 : metadata.desktop) === null || _a === void 0 ? void 0 : _a.native) {
|
|
118
|
-
(_b = opts === null || opts === void 0 ? void 0 : opts.onDesktopUri) === null || _b === void 0 ? void 0 : _b.call(opts, deepLink);
|
|
119
|
-
}
|
|
120
|
-
(_c = opts === null || opts === void 0 ? void 0 : opts.onDisplayUri) === null || _c === void 0 ? void 0 : _c.call(opts, wcClient.uri);
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
const fetchWalletConnectCosmosPublicAddress = (metadata, wcClient, provider, opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
124
|
-
var _a;
|
|
125
|
-
if (wcClient.connected) {
|
|
126
|
-
const key = yield provider.getKey(opts.chainId);
|
|
127
|
-
return key.bech32Address;
|
|
128
|
-
}
|
|
129
|
-
yield wcClient.createSession();
|
|
130
|
-
useDeepLink(metadata, wcClient, opts);
|
|
131
|
-
const payload = yield createSession(wcClient);
|
|
132
|
-
const key = yield provider.getKey(opts.chainId);
|
|
133
|
-
(_a = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _a === void 0 ? void 0 : _a.call(opts, payload);
|
|
134
|
-
wcClient.accounts = [key.bech32Address];
|
|
135
|
-
return key.bech32Address;
|
|
136
|
-
});
|
|
137
|
-
const fetchWalletConnectEVMPublicAddress = (metadata, wcClient, opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
138
|
-
var _b;
|
|
139
|
-
if (wcClient.connected) {
|
|
140
|
-
const [accountPublicAddress] = wcClient.accounts;
|
|
141
|
-
return accountPublicAddress;
|
|
142
|
-
}
|
|
143
|
-
// createSession will trigger the QR code...
|
|
144
|
-
yield wcClient.createSession();
|
|
145
|
-
useDeepLink(metadata, wcClient, opts);
|
|
146
|
-
const payload = yield createSession(wcClient);
|
|
147
|
-
(_b = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _b === void 0 ? void 0 : _b.call(opts, payload);
|
|
148
|
-
const [accountPublicAddress] = payload.params[0].accounts;
|
|
149
|
-
return accountPublicAddress;
|
|
150
|
-
});
|
|
151
|
-
const signWalletConnectPersonalMessage = (messageToSign, metadata, client) => __awaiter(void 0, void 0, void 0, function* () {
|
|
152
|
-
var _c, _d;
|
|
153
|
-
const isCryptoWallet = ((_c = client === null || client === void 0 ? void 0 : client.peerMeta) === null || _c === void 0 ? void 0 : _c.name) === 'Crypto.com | DeFi Wallet' ||
|
|
154
|
-
((_d = client === null || client === void 0 ? void 0 : client.peerMeta) === null || _d === void 0 ? void 0 : _d.name) === 'DeFi Wallet';
|
|
155
|
-
if (!client || !client.connected) {
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
159
|
-
const [accountPublicAddress] = client.accounts;
|
|
160
|
-
if (isMobile()) {
|
|
161
|
-
const deepLink = getDeepLink(client.uri, metadata, {
|
|
162
|
-
removeWCUri: isIOS() && isCryptoWallet,
|
|
163
|
-
});
|
|
164
|
-
window.location.href = deepLink;
|
|
165
|
-
}
|
|
166
|
-
try {
|
|
167
|
-
// This delay is required for Crypto.com DeFi wallet, when there is no delay the app
|
|
168
|
-
// will not open the pop-up to sign. That seems to be a limitation in the standalone client
|
|
169
|
-
// so the delay is required to allow the users to sign the message
|
|
170
|
-
if (isCryptoWallet && isMobile()) {
|
|
171
|
-
yield sleep(4000);
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
// The delay of 1 second is necessary for some of the wallets to open the sign UI in the
|
|
175
|
-
// correct order, without this some wallets like Trust or OKX will no open properly,
|
|
176
|
-
// and not allowing the user to sign the message
|
|
177
|
-
yield sleep(1000);
|
|
178
|
-
}
|
|
179
|
-
return client.signPersonalMessage([messageToSign, accountPublicAddress]);
|
|
180
|
-
}
|
|
181
|
-
catch (e) {
|
|
182
|
-
logger.debug(e);
|
|
183
|
-
throw e;
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
export { createSession, fetchWalletConnectCosmosPublicAddress, fetchWalletConnectEVMPublicAddress, getDeepLink, initClient, killWalletConnectSession, setupWalletConnectEventListeners, signWalletConnectPersonalMessage, teardownWalletConnectEventListeners, useDeepLink };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const infuraId = '87939db78f824920ada5c872db3e56b8';
|
|
6
|
-
const ETH_STARKNET_ADDRESS = '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7';
|
|
7
|
-
const DEFAULT_STARKNET_TYPED_DATA_DOMAIN = {
|
|
8
|
-
domain: {
|
|
9
|
-
name: 'Dynamic Sample dApp',
|
|
10
|
-
version: '0.0.1',
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
exports.DEFAULT_STARKNET_TYPED_DATA_DOMAIN = DEFAULT_STARKNET_TYPED_DATA_DOMAIN;
|
|
15
|
-
exports.ETH_STARKNET_ADDRESS = ETH_STARKNET_ADDRESS;
|
|
16
|
-
exports.infuraId = infuraId;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { TypedData } from 'starknet/dist/utils/typedData';
|
|
2
|
-
export declare const infuraId = "87939db78f824920ada5c872db3e56b8";
|
|
3
|
-
export declare const ETH_STARKNET_ADDRESS = "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7";
|
|
4
|
-
export declare const DEFAULT_STARKNET_TYPED_DATA_DOMAIN: Partial<TypedData>;
|
package/src/wallets/constants.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
const infuraId = '87939db78f824920ada5c872db3e56b8';
|
|
2
|
-
const ETH_STARKNET_ADDRESS = '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7';
|
|
3
|
-
const DEFAULT_STARKNET_TYPED_DATA_DOMAIN = {
|
|
4
|
-
domain: {
|
|
5
|
-
name: 'Dynamic Sample dApp',
|
|
6
|
-
version: '0.0.1',
|
|
7
|
-
},
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export { DEFAULT_STARKNET_TYPED_DATA_DOMAIN, ETH_STARKNET_ADDRESS, infuraId };
|