@dynamic-labs/multi-wallet 0.17.0-RC.0 → 0.17.0-RC.10
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 +137 -0
- package/package.json +11 -14
- package/src/index.cjs +2 -66
- package/src/index.d.ts +1 -16
- package/src/index.js +2 -21
- package/src/multi-wallet.cjs +46 -159
- package/src/multi-wallet.d.ts +0 -3
- package/src/multi-wallet.js +44 -156
- package/src/types.d.ts +9 -49
- package/src/utils/convertors.cjs +0 -7
- package/src/utils/convertors.d.ts +0 -1
- package/src/utils/convertors.js +1 -7
- package/src/utils/getApiProviders.cjs +15 -0
- package/src/utils/getApiProviders.d.ts +10 -0
- package/src/utils/getApiProviders.js +11 -0
- package/src/utils/message.cjs +4 -5
- package/src/utils/message.d.ts +2 -2
- package/src/utils/message.js +2 -3
- package/src/wallets/constants.cjs +0 -2
- package/src/wallets/constants.js +1 -2
- package/src/wallets/cosmos/{keplrWalletConnect.cjs → KeplrWalletConnect.cjs} +27 -43
- package/src/wallets/cosmos/{keplrWalletConnect.d.ts → KeplrWalletConnect.d.ts} +16 -20
- package/src/wallets/cosmos/{keplrWalletConnect.js → KeplrWalletConnect.js} +20 -36
- package/src/wallets/cosmos/{keplr.cjs → KeplrWalletConnector.cjs} +24 -21
- package/src/wallets/cosmos/{keplr.d.ts → KeplrWalletConnector.d.ts} +14 -18
- package/src/wallets/cosmos/{keplr.js → KeplrWalletConnector.js} +23 -20
- package/src/wallets/cosmos/index.d.ts +1 -1
- package/src/wallets/{clients/walletConnect/walletConnect.cjs → cosmos/wcClient.lib.cjs} +38 -101
- package/src/wallets/{clients/walletConnect/walletConnect.d.ts → cosmos/wcClient.lib.d.ts} +8 -10
- package/src/wallets/{clients/walletConnect/walletConnect.js → cosmos/wcClient.lib.js} +36 -97
- package/src/wallets/flow/{flow-provider.cjs → FlowWalletConnector.cjs} +13 -41
- package/src/wallets/flow/{flow-provider.d.ts → FlowWalletConnector.d.ts} +4 -11
- package/src/wallets/flow/{flow-provider.js → FlowWalletConnector.js} +7 -35
- package/src/wallets/flow/blocto.cjs +2 -10
- package/src/wallets/flow/blocto.d.ts +2 -8
- package/src/wallets/flow/blocto.js +2 -10
- package/src/wallets/flow/dapper.cjs +2 -10
- package/src/wallets/flow/dapper.d.ts +2 -8
- package/src/wallets/flow/dapper.js +2 -10
- package/src/wallets/flow/lilico.cjs +4 -13
- package/src/wallets/flow/lilico.d.ts +2 -9
- package/src/wallets/flow/lilico.js +3 -12
- package/src/wallets/starknet/argentx.cjs +2 -2
- package/src/wallets/starknet/argentx.d.ts +1 -1
- package/src/wallets/starknet/argentx.js +2 -2
- package/src/wallets/starknet/braavos.cjs +4 -4
- package/src/wallets/starknet/braavos.d.ts +1 -1
- package/src/wallets/starknet/braavos.js +3 -3
- package/src/wallets/starknet/{starknetProvider.cjs → starknetWalletConnector.cjs} +9 -40
- package/src/wallets/starknet/{starknetProvider.d.ts → starknetWalletConnector.d.ts} +3 -14
- package/src/wallets/starknet/{starknetProvider.js → starknetWalletConnector.js} +5 -36
- package/src/wallets/window.d.ts +0 -77
- package/src/errors.cjs +0 -65
- package/src/errors.d.ts +0 -30
- package/src/errors.js +0 -53
- 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/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/myalgo.cjs +0 -187
- package/src/wallets/algorand/myalgo.d.ts +0 -36
- package/src/wallets/algorand/myalgo.js +0 -181
- 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 -77
- 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/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/ethereum/BloctoEvm.cjs +0 -140
- package/src/wallets/ethereum/BloctoEvm.d.ts +0 -34
- package/src/wallets/ethereum/BloctoEvm.js +0 -134
- package/src/wallets/ethereum/MagicConnector/EmailMagicWalletConnector/EmailMagicWalletConnector.cjs +0 -58
- package/src/wallets/ethereum/MagicConnector/EmailMagicWalletConnector/EmailMagicWalletConnector.d.ts +0 -12
- package/src/wallets/ethereum/MagicConnector/EmailMagicWalletConnector/EmailMagicWalletConnector.js +0 -54
- 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 -103
- package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/MagicClientNetworkHandler.d.ts +0 -34
- package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/MagicClientNetworkHandler.js +0 -99
- package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/index.d.ts +0 -2
- package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/MagicSocialWalletConnector.cjs +0 -56
- package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/MagicSocialWalletConnector.d.ts +0 -12
- package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/MagicSocialWalletConnector.js +0 -52
- package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/index.d.ts +0 -1
- package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/MagicWalletConnector.cjs +0 -182
- package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/MagicWalletConnector.d.ts +0 -60
- package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/MagicWalletConnector.js +0 -178
- 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 -81
- package/src/wallets/ethereum/coinbase.d.ts +0 -31
- package/src/wallets/ethereum/coinbase.js +0 -79
- package/src/wallets/ethereum/ethProvider.cjs +0 -171
- package/src/wallets/ethereum/ethProvider.d.ts +0 -35
- package/src/wallets/ethereum/ethProvider.js +0 -167
- package/src/wallets/ethereum/ethProviderHelper.cjs +0 -190
- package/src/wallets/ethereum/ethProviderHelper.d.ts +0 -40
- package/src/wallets/ethereum/ethProviderHelper.js +0 -186
- 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 -98
- package/src/wallets/ethereum/fortmatic.d.ts +0 -34
- package/src/wallets/ethereum/fortmatic.js +0 -92
- 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 -70
- package/src/wallets/ethereum/meta-mask.d.ts +0 -30
- package/src/wallets/ethereum/meta-mask.js +0 -68
- package/src/wallets/getMobileOrInjectedWallet.cjs +0 -26
- package/src/wallets/getMobileOrInjectedWallet.d.ts +0 -10
- package/src/wallets/getMobileOrInjectedWallet.js +0 -22
- package/src/wallets/getWalletConnectConnector.cjs +0 -18
- package/src/wallets/getWalletConnectConnector.d.ts +0 -7
- package/src/wallets/getWalletConnectConnector.js +0 -14
- package/src/wallets/initializeWalletProviders.cjs +0 -14
- package/src/wallets/initializeWalletProviders.d.ts +0 -6
- package/src/wallets/initializeWalletProviders.js +0 -10
- package/src/wallets/solana/CoinbaseSolana.cjs +0 -77
- package/src/wallets/solana/CoinbaseSolana.d.ts +0 -26
- package/src/wallets/solana/CoinbaseSolana.js +0 -75
- package/src/wallets/solana/glow.cjs +0 -74
- package/src/wallets/solana/glow.d.ts +0 -25
- package/src/wallets/solana/glow.js +0 -72
- 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 -97
- package/src/wallets/solana/phantom.d.ts +0 -26
- package/src/wallets/solana/phantom.js +0 -95
- package/src/wallets/solana/slope.cjs +0 -125
- package/src/wallets/solana/slope.d.ts +0 -39
- package/src/wallets/solana/slope.js +0 -123
- package/src/wallets/solana/solProvider.cjs +0 -62
- package/src/wallets/solana/solProvider.d.ts +0 -18
- package/src/wallets/solana/solProvider.js +0 -58
- 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/solflare.cjs +0 -94
- package/src/wallets/solana/solflare.d.ts +0 -26
- package/src/wallets/solana/solflare.js +0 -92
- package/src/wallets/walletConnect/index.d.ts +0 -2
- package/src/wallets/walletConnect/walletConnect.cjs +0 -147
- package/src/wallets/walletConnect/walletConnect.d.ts +0 -39
- package/src/wallets/walletConnect/walletConnect.js +0 -141
- package/src/wallets/walletConnect/walletConnectV2.cjs +0 -282
- package/src/wallets/walletConnect/walletConnectV2.d.ts +0 -40
- package/src/wallets/walletConnect/walletConnectV2.js +0 -273
- package/src/wallets/walletConnect/zerion.d.ts +0 -8
|
@@ -4,9 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
6
|
var Client = require('@walletconnect/client');
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var logger = require('../../../utils/logger.cjs');
|
|
7
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
8
|
+
var utils = require('@dynamic-labs/utils');
|
|
10
9
|
|
|
11
10
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
11
|
|
|
@@ -20,14 +19,25 @@ const initClient = (name, settings) => {
|
|
|
20
19
|
: { bridge: 'https://bridge.walletconnect.org', storageId };
|
|
21
20
|
return new Client__default["default"](Object.assign(Object.assign({}, clientArgs), settings));
|
|
22
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* Initialize a client from a stored session and terminate the connection.
|
|
24
|
+
*/
|
|
25
|
+
const killWalletConnectSession = (client) => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
try {
|
|
27
|
+
if (client === null || client === void 0 ? void 0 : client.connected) {
|
|
28
|
+
yield client.killSession();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
walletConnectorCore.logger.debug(e);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
23
35
|
/**
|
|
24
36
|
* Attach event handlers to WalletConnect events.
|
|
25
37
|
*/
|
|
26
38
|
const setupWalletConnectEventListeners = (opts, client) => {
|
|
27
39
|
if (!client) {
|
|
28
|
-
return
|
|
29
|
-
// nothing to teardown
|
|
30
|
-
};
|
|
40
|
+
return;
|
|
31
41
|
}
|
|
32
42
|
let prevAccount;
|
|
33
43
|
let prevChain;
|
|
@@ -44,7 +54,7 @@ const setupWalletConnectEventListeners = (opts, client) => {
|
|
|
44
54
|
var _b, _c;
|
|
45
55
|
// eslint-disable-next-line prefer-destructuring
|
|
46
56
|
const { accounts, chainId } = payload.params[0];
|
|
47
|
-
const didAccountChange = !
|
|
57
|
+
const didAccountChange = !walletConnectorCore.isSameAddress(prevAccount || '', accounts[0], 'eip155');
|
|
48
58
|
const didChainChange = prevChain !== chainId;
|
|
49
59
|
// eslint-disable-next-line prefer-destructuring
|
|
50
60
|
prevAccount = accounts[0];
|
|
@@ -56,31 +66,27 @@ const setupWalletConnectEventListeners = (opts, client) => {
|
|
|
56
66
|
yield ((_c = opts.onChainChange) === null || _c === void 0 ? void 0 : _c.call(opts, String(chainId)));
|
|
57
67
|
}
|
|
58
68
|
}));
|
|
59
|
-
return () => {
|
|
60
|
-
client.off('disconnect');
|
|
61
|
-
client.off('session_update');
|
|
62
|
-
};
|
|
63
69
|
};
|
|
64
70
|
const teardownWalletConnectEventListeners = (client) => {
|
|
65
71
|
client.off('disconnect');
|
|
66
72
|
client.off('session_update');
|
|
67
73
|
};
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if (client === null || client === void 0 ? void 0 : client.connected) {
|
|
74
|
-
yield client.killSession();
|
|
75
|
-
}
|
|
74
|
+
const useDeepLink = (metadata, wcClient, opts) => {
|
|
75
|
+
var _a, _b, _c;
|
|
76
|
+
const deepLink = getDeepLink(wcClient.uri, metadata);
|
|
77
|
+
if (utils.isMobile()) {
|
|
78
|
+
window.location.href = deepLink;
|
|
76
79
|
}
|
|
77
|
-
|
|
78
|
-
|
|
80
|
+
else {
|
|
81
|
+
if ((_a = metadata === null || metadata === void 0 ? void 0 : metadata.desktop) === null || _a === void 0 ? void 0 : _a.native) {
|
|
82
|
+
(_b = opts === null || opts === void 0 ? void 0 : opts.onDesktopUri) === null || _b === void 0 ? void 0 : _b.call(opts, deepLink);
|
|
83
|
+
}
|
|
84
|
+
(_c = opts === null || opts === void 0 ? void 0 : opts.onDisplayUri) === null || _c === void 0 ? void 0 : _c.call(opts, wcClient.uri);
|
|
79
85
|
}
|
|
80
|
-
}
|
|
86
|
+
};
|
|
81
87
|
const getDeepLink = (uri, metadata, { removeWCUri = false, } = {}) => {
|
|
82
88
|
var _a, _b, _c, _d;
|
|
83
|
-
if (!
|
|
89
|
+
if (!utils.isMobile()) {
|
|
84
90
|
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
91
|
if (removeWCUri)
|
|
86
92
|
return origin || '';
|
|
@@ -88,7 +94,7 @@ const getDeepLink = (uri, metadata, { removeWCUri = false, } = {}) => {
|
|
|
88
94
|
}
|
|
89
95
|
// deeplinks for ios require special treatment
|
|
90
96
|
// see: https://docs.walletconnect.com/mobile-linking#for-ios
|
|
91
|
-
else if (
|
|
97
|
+
else if (utils.isIOS()) {
|
|
92
98
|
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
99
|
if (removeWCUri)
|
|
94
100
|
return origin || '';
|
|
@@ -100,34 +106,16 @@ const getDeepLink = (uri, metadata, { removeWCUri = false, } = {}) => {
|
|
|
100
106
|
};
|
|
101
107
|
const createSession = (client) => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
102
108
|
return new Promise((resolve, reject) => {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
catch (e) {
|
|
114
|
-
reject(e);
|
|
115
|
-
}
|
|
109
|
+
client.on('connect', (error, payload) => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
110
|
+
if (error)
|
|
111
|
+
throw error;
|
|
112
|
+
resolve(payload);
|
|
113
|
+
}));
|
|
114
|
+
client.on('disconnect', (error, payload) => {
|
|
115
|
+
reject(error || payload.params[0].message);
|
|
116
|
+
});
|
|
116
117
|
});
|
|
117
118
|
});
|
|
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
119
|
const fetchWalletConnectCosmosPublicAddress = (metadata, wcClient, provider, opts) => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
132
120
|
var _a;
|
|
133
121
|
if (wcClient.connected) {
|
|
@@ -141,64 +129,13 @@ const fetchWalletConnectCosmosPublicAddress = (metadata, wcClient, provider, opt
|
|
|
141
129
|
(_a = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _a === void 0 ? void 0 : _a.call(opts, payload);
|
|
142
130
|
wcClient.accounts = [key.bech32Address];
|
|
143
131
|
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
132
|
});
|
|
194
133
|
|
|
195
134
|
exports.createSession = createSession;
|
|
196
135
|
exports.fetchWalletConnectCosmosPublicAddress = fetchWalletConnectCosmosPublicAddress;
|
|
197
|
-
exports.fetchWalletConnectEVMPublicAddress = fetchWalletConnectEVMPublicAddress;
|
|
198
136
|
exports.getDeepLink = getDeepLink;
|
|
199
137
|
exports.initClient = initClient;
|
|
200
138
|
exports.killWalletConnectSession = killWalletConnectSession;
|
|
201
139
|
exports.setupWalletConnectEventListeners = setupWalletConnectEventListeners;
|
|
202
|
-
exports.signWalletConnectPersonalMessage = signWalletConnectPersonalMessage;
|
|
203
140
|
exports.teardownWalletConnectEventListeners = teardownWalletConnectEventListeners;
|
|
204
141
|
exports.useDeepLink = useDeepLink;
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import Client from '@walletconnect/client';
|
|
2
|
-
import { FetchPublicAddressOpts, PayloadParams, WalletEventListeners } from '@dynamic-labs/wallet-connector-core';
|
|
3
2
|
import { WalletSchema } from '@dynamic-labs/wallet-book';
|
|
4
|
-
import {
|
|
3
|
+
import { FetchPublicAddressOpts, PayloadParams, WalletEventListeners } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
+
import { KeplrWalletConnectV1 } from './wcClient';
|
|
5
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
6
|
/**
|
|
12
7
|
* Initialize a client from a stored session and terminate the connection.
|
|
13
8
|
*/
|
|
14
9
|
export declare const killWalletConnectSession: (client: Client) => Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Attach event handlers to WalletConnect events.
|
|
12
|
+
*/
|
|
13
|
+
export declare const setupWalletConnectEventListeners: (opts: WalletEventListeners, client: Client) => void;
|
|
14
|
+
export declare const teardownWalletConnectEventListeners: (client: Client) => void;
|
|
15
|
+
export declare const useDeepLink: (metadata: WalletSchema, wcClient: Client, opts?: FetchPublicAddressOpts) => void;
|
|
15
16
|
export declare const getDeepLink: (uri: string, metadata: WalletSchema, { removeWCUri, }?: {
|
|
16
17
|
removeWCUri?: boolean | undefined;
|
|
17
18
|
}) => string;
|
|
18
19
|
export declare const createSession: (client: Client) => Promise<PayloadParams>;
|
|
19
|
-
export declare const useDeepLink: (metadata: WalletSchema, wcClient: Client, opts?: FetchPublicAddressOpts) => void;
|
|
20
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,8 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from 'tslib';
|
|
2
2
|
import Client from '@walletconnect/client';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { logger } from '../../../utils/logger.js';
|
|
3
|
+
import { logger, isSameAddress } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
+
import { isMobile, isIOS } from '@dynamic-labs/utils';
|
|
6
5
|
|
|
7
6
|
const initClient = (name, settings) => {
|
|
8
7
|
const storageId = `walletconnect-${name}`;
|
|
@@ -12,14 +11,25 @@ const initClient = (name, settings) => {
|
|
|
12
11
|
: { bridge: 'https://bridge.walletconnect.org', storageId };
|
|
13
12
|
return new Client(Object.assign(Object.assign({}, clientArgs), settings));
|
|
14
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* Initialize a client from a stored session and terminate the connection.
|
|
16
|
+
*/
|
|
17
|
+
const killWalletConnectSession = (client) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
try {
|
|
19
|
+
if (client === null || client === void 0 ? void 0 : client.connected) {
|
|
20
|
+
yield client.killSession();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
logger.debug(e);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
15
27
|
/**
|
|
16
28
|
* Attach event handlers to WalletConnect events.
|
|
17
29
|
*/
|
|
18
30
|
const setupWalletConnectEventListeners = (opts, client) => {
|
|
19
31
|
if (!client) {
|
|
20
|
-
return
|
|
21
|
-
// nothing to teardown
|
|
22
|
-
};
|
|
32
|
+
return;
|
|
23
33
|
}
|
|
24
34
|
let prevAccount;
|
|
25
35
|
let prevChain;
|
|
@@ -48,28 +58,24 @@ const setupWalletConnectEventListeners = (opts, client) => {
|
|
|
48
58
|
yield ((_c = opts.onChainChange) === null || _c === void 0 ? void 0 : _c.call(opts, String(chainId)));
|
|
49
59
|
}
|
|
50
60
|
}));
|
|
51
|
-
return () => {
|
|
52
|
-
client.off('disconnect');
|
|
53
|
-
client.off('session_update');
|
|
54
|
-
};
|
|
55
61
|
};
|
|
56
62
|
const teardownWalletConnectEventListeners = (client) => {
|
|
57
63
|
client.off('disconnect');
|
|
58
64
|
client.off('session_update');
|
|
59
65
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (client === null || client === void 0 ? void 0 : client.connected) {
|
|
66
|
-
yield client.killSession();
|
|
67
|
-
}
|
|
66
|
+
const useDeepLink = (metadata, wcClient, opts) => {
|
|
67
|
+
var _a, _b, _c;
|
|
68
|
+
const deepLink = getDeepLink(wcClient.uri, metadata);
|
|
69
|
+
if (isMobile()) {
|
|
70
|
+
window.location.href = deepLink;
|
|
68
71
|
}
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
else {
|
|
73
|
+
if ((_a = metadata === null || metadata === void 0 ? void 0 : metadata.desktop) === null || _a === void 0 ? void 0 : _a.native) {
|
|
74
|
+
(_b = opts === null || opts === void 0 ? void 0 : opts.onDesktopUri) === null || _b === void 0 ? void 0 : _b.call(opts, deepLink);
|
|
75
|
+
}
|
|
76
|
+
(_c = opts === null || opts === void 0 ? void 0 : opts.onDisplayUri) === null || _c === void 0 ? void 0 : _c.call(opts, wcClient.uri);
|
|
71
77
|
}
|
|
72
|
-
}
|
|
78
|
+
};
|
|
73
79
|
const getDeepLink = (uri, metadata, { removeWCUri = false, } = {}) => {
|
|
74
80
|
var _a, _b, _c, _d;
|
|
75
81
|
if (!isMobile()) {
|
|
@@ -92,34 +98,16 @@ const getDeepLink = (uri, metadata, { removeWCUri = false, } = {}) => {
|
|
|
92
98
|
};
|
|
93
99
|
const createSession = (client) => __awaiter(void 0, void 0, void 0, function* () {
|
|
94
100
|
return new Promise((resolve, reject) => {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
catch (e) {
|
|
106
|
-
reject(e);
|
|
107
|
-
}
|
|
101
|
+
client.on('connect', (error, payload) => __awaiter(void 0, void 0, void 0, function* () {
|
|
102
|
+
if (error)
|
|
103
|
+
throw error;
|
|
104
|
+
resolve(payload);
|
|
105
|
+
}));
|
|
106
|
+
client.on('disconnect', (error, payload) => {
|
|
107
|
+
reject(error || payload.params[0].message);
|
|
108
|
+
});
|
|
108
109
|
});
|
|
109
110
|
});
|
|
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
111
|
const fetchWalletConnectCosmosPublicAddress = (metadata, wcClient, provider, opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
124
112
|
var _a;
|
|
125
113
|
if (wcClient.connected) {
|
|
@@ -133,55 +121,6 @@ const fetchWalletConnectCosmosPublicAddress = (metadata, wcClient, provider, opt
|
|
|
133
121
|
(_a = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _a === void 0 ? void 0 : _a.call(opts, payload);
|
|
134
122
|
wcClient.accounts = [key.bech32Address];
|
|
135
123
|
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
124
|
});
|
|
186
125
|
|
|
187
|
-
export { createSession, fetchWalletConnectCosmosPublicAddress,
|
|
126
|
+
export { createSession, fetchWalletConnectCosmosPublicAddress, getDeepLink, initClient, killWalletConnectSession, setupWalletConnectEventListeners, teardownWalletConnectEventListeners, useDeepLink };
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
6
|
var fcl = require('@onflow/fcl');
|
|
7
|
-
var
|
|
8
|
-
var
|
|
7
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
8
|
+
var utils = require('@dynamic-labs/utils');
|
|
9
9
|
|
|
10
10
|
const get = (key) => {
|
|
11
11
|
if (typeof window === 'undefined') {
|
|
@@ -18,7 +18,7 @@ const get = (key) => {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
catch (e) {
|
|
21
|
-
|
|
21
|
+
walletConnectorCore.logger.error(e);
|
|
22
22
|
}
|
|
23
23
|
return undefined;
|
|
24
24
|
};
|
|
@@ -32,23 +32,14 @@ const LOCAL_STORAGE = {
|
|
|
32
32
|
get: (key) => tslib.__awaiter(void 0, void 0, void 0, function* () { return get(key); }),
|
|
33
33
|
put: (key, value) => tslib.__awaiter(void 0, void 0, void 0, function* () { return set(key, value); }),
|
|
34
34
|
};
|
|
35
|
-
class
|
|
35
|
+
class FlowWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
36
36
|
constructor({ appName, appLogoUrl, }) {
|
|
37
|
-
|
|
37
|
+
super();
|
|
38
|
+
this.connectedChain = 'FLOW';
|
|
39
|
+
this.supportedChains = ['FLOW'];
|
|
38
40
|
this.appName = appName;
|
|
39
41
|
this.appLogoUrl = appLogoUrl;
|
|
40
42
|
}
|
|
41
|
-
isInstalledOnBrowser() {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
getNetwork() {
|
|
45
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
return undefined;
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
teardownEventListeners() {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
43
|
connect() {
|
|
53
44
|
var _a;
|
|
54
45
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -73,9 +64,6 @@ class FlowProvider {
|
|
|
73
64
|
.put('flow.network', 'mainnet')
|
|
74
65
|
.put('fcl.storage', LOCAL_STORAGE);
|
|
75
66
|
}
|
|
76
|
-
getDeepLink() {
|
|
77
|
-
return undefined;
|
|
78
|
-
}
|
|
79
67
|
fetchPublicAddress() {
|
|
80
68
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
81
69
|
try {
|
|
@@ -84,7 +72,7 @@ class FlowProvider {
|
|
|
84
72
|
return user.addr;
|
|
85
73
|
}
|
|
86
74
|
catch (error) {
|
|
87
|
-
|
|
75
|
+
walletConnectorCore.logger.error(error);
|
|
88
76
|
return undefined;
|
|
89
77
|
}
|
|
90
78
|
});
|
|
@@ -105,7 +93,7 @@ class FlowProvider {
|
|
|
105
93
|
return JSON.stringify(data);
|
|
106
94
|
}
|
|
107
95
|
catch (error) {
|
|
108
|
-
|
|
96
|
+
walletConnectorCore.logger.error(error);
|
|
109
97
|
return undefined;
|
|
110
98
|
}
|
|
111
99
|
});
|
|
@@ -115,24 +103,11 @@ class FlowProvider {
|
|
|
115
103
|
const message = Buffer.from(messageToSign).toString('hex');
|
|
116
104
|
const signedMessage = yield fcl.currentUser().signUserMessage(message);
|
|
117
105
|
if (signedMessage.includes('Declined')) {
|
|
118
|
-
throw new
|
|
106
|
+
throw new utils.DynamicError('User declined the signature');
|
|
119
107
|
}
|
|
120
108
|
return JSON.stringify(signedMessage);
|
|
121
109
|
});
|
|
122
110
|
}
|
|
123
|
-
getWeb3Provider() {
|
|
124
|
-
return undefined;
|
|
125
|
-
}
|
|
126
|
-
getRpcProvider() {
|
|
127
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
128
|
-
return;
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
getSigner() {
|
|
132
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
133
|
-
return undefined;
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
111
|
getBalance() {
|
|
137
112
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
138
113
|
this.baseConfig();
|
|
@@ -148,7 +123,7 @@ class FlowProvider {
|
|
|
148
123
|
return yield fcl.send([fcl.script(code)]).then(fcl.decode);
|
|
149
124
|
}
|
|
150
125
|
catch (error) {
|
|
151
|
-
|
|
126
|
+
walletConnectorCore.logger.error(error);
|
|
152
127
|
return undefined;
|
|
153
128
|
}
|
|
154
129
|
}
|
|
@@ -162,12 +137,9 @@ class FlowProvider {
|
|
|
162
137
|
fcl.currentUser().unauthenticate();
|
|
163
138
|
});
|
|
164
139
|
}
|
|
165
|
-
supportsNetworkSwitching() {
|
|
166
|
-
return false;
|
|
167
|
-
}
|
|
168
140
|
switchNetwork() {
|
|
169
141
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
170
|
-
throw new
|
|
142
|
+
throw new utils.DynamicError('Not supported');
|
|
171
143
|
});
|
|
172
144
|
}
|
|
173
145
|
getConnectedAccounts() {
|
|
@@ -186,5 +158,5 @@ class FlowProvider {
|
|
|
186
158
|
}
|
|
187
159
|
}
|
|
188
160
|
|
|
189
|
-
exports.
|
|
161
|
+
exports.FlowWalletConnector = FlowWalletConnector;
|
|
190
162
|
exports.LOCAL_STORAGE = LOCAL_STORAGE;
|
|
@@ -1,35 +1,28 @@
|
|
|
1
|
-
import { WalletEventListeners } from '@dynamic-labs/wallet-connector-core';
|
|
1
|
+
import { Chain, WalletConnectorBase, WalletEventListeners } from '@dynamic-labs/wallet-connector-core';
|
|
2
2
|
export declare const LOCAL_STORAGE: {
|
|
3
3
|
can: boolean;
|
|
4
4
|
get: (key: string) => Promise<any>;
|
|
5
5
|
put: (key: string, value: any) => Promise<void>;
|
|
6
6
|
};
|
|
7
|
-
export declare class
|
|
8
|
-
canConnectViaSocial: boolean;
|
|
7
|
+
export declare abstract class FlowWalletConnector extends WalletConnectorBase {
|
|
9
8
|
protected appName?: string;
|
|
10
9
|
protected appLogoUrl?: string;
|
|
11
10
|
protected onAccountChange?: (address: string[]) => Promise<void>;
|
|
11
|
+
connectedChain: Chain;
|
|
12
|
+
supportedChains: Chain[];
|
|
12
13
|
constructor({ appName, appLogoUrl, }: {
|
|
13
14
|
appLogoUrl?: string;
|
|
14
15
|
appName?: string;
|
|
15
16
|
});
|
|
16
|
-
isInstalledOnBrowser(): boolean;
|
|
17
|
-
getNetwork(): Promise<number | undefined>;
|
|
18
|
-
teardownEventListeners(): void;
|
|
19
17
|
connect(): Promise<void>;
|
|
20
18
|
setupEventListeners(listeners: WalletEventListeners): void;
|
|
21
19
|
setupConfig(): void;
|
|
22
20
|
baseConfig(): void;
|
|
23
|
-
getDeepLink(): string | undefined;
|
|
24
21
|
fetchPublicAddress(): Promise<string | undefined>;
|
|
25
22
|
proveOwnership(messageToSign: string): Promise<string | undefined>;
|
|
26
23
|
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
27
|
-
getWeb3Provider(): undefined;
|
|
28
|
-
getRpcProvider(): Promise<void>;
|
|
29
|
-
getSigner(): Promise<undefined>;
|
|
30
24
|
getBalance(): Promise<string | undefined>;
|
|
31
25
|
endSession(): Promise<void>;
|
|
32
|
-
supportsNetworkSwitching(): boolean;
|
|
33
26
|
switchNetwork(): Promise<void>;
|
|
34
27
|
getConnectedAccounts(): Promise<string[]>;
|
|
35
28
|
signDelay(): Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from 'tslib';
|
|
2
2
|
import { currentUser, config, send, script, decode } from '@onflow/fcl';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { WalletConnectorBase, logger } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
+
import { DynamicError } from '@dynamic-labs/utils';
|
|
5
5
|
|
|
6
6
|
const get = (key) => {
|
|
7
7
|
if (typeof window === 'undefined') {
|
|
@@ -28,23 +28,14 @@ const LOCAL_STORAGE = {
|
|
|
28
28
|
get: (key) => __awaiter(void 0, void 0, void 0, function* () { return get(key); }),
|
|
29
29
|
put: (key, value) => __awaiter(void 0, void 0, void 0, function* () { return set(key, value); }),
|
|
30
30
|
};
|
|
31
|
-
class
|
|
31
|
+
class FlowWalletConnector extends WalletConnectorBase {
|
|
32
32
|
constructor({ appName, appLogoUrl, }) {
|
|
33
|
-
|
|
33
|
+
super();
|
|
34
|
+
this.connectedChain = 'FLOW';
|
|
35
|
+
this.supportedChains = ['FLOW'];
|
|
34
36
|
this.appName = appName;
|
|
35
37
|
this.appLogoUrl = appLogoUrl;
|
|
36
38
|
}
|
|
37
|
-
isInstalledOnBrowser() {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
getNetwork() {
|
|
41
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
return undefined;
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
teardownEventListeners() {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
39
|
connect() {
|
|
49
40
|
var _a;
|
|
50
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -69,9 +60,6 @@ class FlowProvider {
|
|
|
69
60
|
.put('flow.network', 'mainnet')
|
|
70
61
|
.put('fcl.storage', LOCAL_STORAGE);
|
|
71
62
|
}
|
|
72
|
-
getDeepLink() {
|
|
73
|
-
return undefined;
|
|
74
|
-
}
|
|
75
63
|
fetchPublicAddress() {
|
|
76
64
|
return __awaiter(this, void 0, void 0, function* () {
|
|
77
65
|
try {
|
|
@@ -116,19 +104,6 @@ class FlowProvider {
|
|
|
116
104
|
return JSON.stringify(signedMessage);
|
|
117
105
|
});
|
|
118
106
|
}
|
|
119
|
-
getWeb3Provider() {
|
|
120
|
-
return undefined;
|
|
121
|
-
}
|
|
122
|
-
getRpcProvider() {
|
|
123
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
-
return;
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
getSigner() {
|
|
128
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
-
return undefined;
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
107
|
getBalance() {
|
|
133
108
|
return __awaiter(this, void 0, void 0, function* () {
|
|
134
109
|
this.baseConfig();
|
|
@@ -158,9 +133,6 @@ class FlowProvider {
|
|
|
158
133
|
currentUser().unauthenticate();
|
|
159
134
|
});
|
|
160
135
|
}
|
|
161
|
-
supportsNetworkSwitching() {
|
|
162
|
-
return false;
|
|
163
|
-
}
|
|
164
136
|
switchNetwork() {
|
|
165
137
|
return __awaiter(this, void 0, void 0, function* () {
|
|
166
138
|
throw new DynamicError('Not supported');
|
|
@@ -182,4 +154,4 @@ class FlowProvider {
|
|
|
182
154
|
}
|
|
183
155
|
}
|
|
184
156
|
|
|
185
|
-
export {
|
|
157
|
+
export { FlowWalletConnector, LOCAL_STORAGE };
|