@dynamic-labs/multi-wallet 0.17.0-RC.1 → 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 +114 -0
- package/package.json +11 -14
- package/src/index.cjs +0 -64
- package/src/index.d.ts +0 -15
- package/src/index.js +1 -20
- package/src/multi-wallet.cjs +45 -155
- package/src/multi-wallet.d.ts +0 -3
- package/src/multi-wallet.js +43 -152
- 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 +3 -4
- package/src/utils/message.d.ts +2 -2
- package/src/utils/message.js +1 -2
- package/src/wallets/constants.cjs +0 -2
- package/src/wallets/constants.js +1 -2
- package/src/wallets/cosmos/KeplrWalletConnect.cjs +21 -21
- package/src/wallets/cosmos/KeplrWalletConnect.d.ts +11 -7
- package/src/wallets/cosmos/KeplrWalletConnect.js +13 -13
- package/src/wallets/cosmos/KeplrWalletConnector.cjs +21 -6
- package/src/wallets/cosmos/KeplrWalletConnector.d.ts +10 -6
- package/src/wallets/cosmos/KeplrWalletConnector.js +21 -6
- 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/FlowWalletConnector.cjs +7 -8
- package/src/wallets/flow/FlowWalletConnector.js +2 -3
- package/src/wallets/flow/lilico.cjs +2 -2
- package/src/wallets/flow/lilico.js +1 -1
- package/src/wallets/starknet/braavos.cjs +2 -2
- package/src/wallets/starknet/braavos.js +1 -1
- package/src/wallets/starknet/starknetWalletConnector.cjs +5 -6
- package/src/wallets/starknet/starknetWalletConnector.js +2 -3
- 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/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/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 -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/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/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
|
@@ -5,8 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
6
|
var fcl = require('@onflow/fcl');
|
|
7
7
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
8
|
-
var
|
|
9
|
-
var logger = require('../../utils/logger.cjs');
|
|
8
|
+
var utils = require('@dynamic-labs/utils');
|
|
10
9
|
|
|
11
10
|
const get = (key) => {
|
|
12
11
|
if (typeof window === 'undefined') {
|
|
@@ -19,7 +18,7 @@ const get = (key) => {
|
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
20
|
catch (e) {
|
|
22
|
-
|
|
21
|
+
walletConnectorCore.logger.error(e);
|
|
23
22
|
}
|
|
24
23
|
return undefined;
|
|
25
24
|
};
|
|
@@ -73,7 +72,7 @@ class FlowWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
73
72
|
return user.addr;
|
|
74
73
|
}
|
|
75
74
|
catch (error) {
|
|
76
|
-
|
|
75
|
+
walletConnectorCore.logger.error(error);
|
|
77
76
|
return undefined;
|
|
78
77
|
}
|
|
79
78
|
});
|
|
@@ -94,7 +93,7 @@ class FlowWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
94
93
|
return JSON.stringify(data);
|
|
95
94
|
}
|
|
96
95
|
catch (error) {
|
|
97
|
-
|
|
96
|
+
walletConnectorCore.logger.error(error);
|
|
98
97
|
return undefined;
|
|
99
98
|
}
|
|
100
99
|
});
|
|
@@ -104,7 +103,7 @@ class FlowWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
104
103
|
const message = Buffer.from(messageToSign).toString('hex');
|
|
105
104
|
const signedMessage = yield fcl.currentUser().signUserMessage(message);
|
|
106
105
|
if (signedMessage.includes('Declined')) {
|
|
107
|
-
throw new
|
|
106
|
+
throw new utils.DynamicError('User declined the signature');
|
|
108
107
|
}
|
|
109
108
|
return JSON.stringify(signedMessage);
|
|
110
109
|
});
|
|
@@ -124,7 +123,7 @@ class FlowWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
124
123
|
return yield fcl.send([fcl.script(code)]).then(fcl.decode);
|
|
125
124
|
}
|
|
126
125
|
catch (error) {
|
|
127
|
-
|
|
126
|
+
walletConnectorCore.logger.error(error);
|
|
128
127
|
return undefined;
|
|
129
128
|
}
|
|
130
129
|
}
|
|
@@ -140,7 +139,7 @@ class FlowWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
140
139
|
}
|
|
141
140
|
switchNetwork() {
|
|
142
141
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
143
|
-
throw new
|
|
142
|
+
throw new utils.DynamicError('Not supported');
|
|
144
143
|
});
|
|
145
144
|
}
|
|
146
145
|
getConnectedAccounts() {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from 'tslib';
|
|
2
2
|
import { currentUser, config, send, script, decode } from '@onflow/fcl';
|
|
3
|
-
import { WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
-
import { DynamicError } from '
|
|
5
|
-
import { logger } from '../../utils/logger.js';
|
|
3
|
+
import { WalletConnectorBase, logger } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
+
import { DynamicError } from '@dynamic-labs/utils';
|
|
6
5
|
|
|
7
6
|
const get = (key) => {
|
|
8
7
|
if (typeof window === 'undefined') {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var tslib = require('tslib');
|
|
4
4
|
var fcl = require('@onflow/fcl');
|
|
5
|
-
var
|
|
5
|
+
var utils = require('@dynamic-labs/utils');
|
|
6
6
|
var FlowWalletConnector = require('./FlowWalletConnector.cjs');
|
|
7
7
|
|
|
8
8
|
class Lilico extends FlowWalletConnector.FlowWalletConnector {
|
|
@@ -27,7 +27,7 @@ class Lilico extends FlowWalletConnector.FlowWalletConnector {
|
|
|
27
27
|
}
|
|
28
28
|
signDelay() {
|
|
29
29
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
if (
|
|
30
|
+
if (utils.isMobile()) {
|
|
31
31
|
return Promise.resolve();
|
|
32
32
|
}
|
|
33
33
|
return new Promise((resolve) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from 'tslib';
|
|
2
2
|
import { config } from '@onflow/fcl';
|
|
3
|
-
import { isMobile } from '
|
|
3
|
+
import { isMobile } from '@dynamic-labs/utils';
|
|
4
4
|
import { FlowWalletConnector } from './FlowWalletConnector.js';
|
|
5
5
|
|
|
6
6
|
class Lilico extends FlowWalletConnector {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var tslib = require('tslib');
|
|
4
|
-
var
|
|
4
|
+
var utils = require('@dynamic-labs/utils');
|
|
5
5
|
var starknetWalletConnector = require('./starknetWalletConnector.cjs');
|
|
6
6
|
|
|
7
7
|
class Braavos extends starknetWalletConnector {
|
|
@@ -22,7 +22,7 @@ class Braavos extends starknetWalletConnector {
|
|
|
22
22
|
*/
|
|
23
23
|
const url = window.location.toString().replace(/http(s)?:\/\//, '');
|
|
24
24
|
const targetUrl = `starknet://dapp/${url}`;
|
|
25
|
-
if (
|
|
25
|
+
if (utils.isMobile()) {
|
|
26
26
|
window.location.assign(targetUrl);
|
|
27
27
|
}
|
|
28
28
|
return Promise.resolve(undefined);
|
|
@@ -6,8 +6,7 @@ var starknet = require('starknet');
|
|
|
6
6
|
var constants = require('starknet/constants');
|
|
7
7
|
var uint256 = require('starknet/dist/utils/uint256');
|
|
8
8
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
9
|
-
var
|
|
10
|
-
var logger = require('../../utils/logger.cjs');
|
|
9
|
+
var utils = require('@dynamic-labs/utils');
|
|
11
10
|
var convertors = require('../../utils/convertors.cjs');
|
|
12
11
|
var constants$1 = require('../constants.cjs');
|
|
13
12
|
var ethereumContractAbi = require('./ethereumContractAbi.cjs');
|
|
@@ -31,7 +30,7 @@ class StarknetWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
catch (err) {
|
|
34
|
-
|
|
33
|
+
walletConnectorCore.logger.error(err);
|
|
35
34
|
}
|
|
36
35
|
});
|
|
37
36
|
}
|
|
@@ -68,7 +67,7 @@ class StarknetWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
68
67
|
const wallet = yield this.getWallet();
|
|
69
68
|
const walletAddress = yield this.fetchPublicAddress();
|
|
70
69
|
if (!walletAddress || !wallet) {
|
|
71
|
-
|
|
70
|
+
walletConnectorCore.logger.error('Could not fetch wallet address for signing message');
|
|
72
71
|
return undefined;
|
|
73
72
|
}
|
|
74
73
|
const { account } = wallet;
|
|
@@ -83,7 +82,7 @@ class StarknetWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
83
82
|
const walletAddress = yield this.fetchPublicAddress();
|
|
84
83
|
const provider = yield this.getWeb3Provider();
|
|
85
84
|
if (!walletAddress || !provider) {
|
|
86
|
-
|
|
85
|
+
walletConnectorCore.logger.error('Could not fetch wallet address for getting balance');
|
|
87
86
|
return undefined;
|
|
88
87
|
}
|
|
89
88
|
const contract = new starknet.Contract(ethereumContractAbi, constants$1.ETH_STARKNET_ADDRESS, provider);
|
|
@@ -97,7 +96,7 @@ class StarknetWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
97
96
|
return (gweiBalance / 1e18).toFixed(6);
|
|
98
97
|
}
|
|
99
98
|
catch (error) {
|
|
100
|
-
throw new
|
|
99
|
+
throw new utils.DynamicError('Something went wrong');
|
|
101
100
|
}
|
|
102
101
|
});
|
|
103
102
|
}
|
|
@@ -3,9 +3,8 @@ import { getInstalledWallets, disconnect } from 'get-starknet';
|
|
|
3
3
|
import { Contract } from 'starknet';
|
|
4
4
|
import { StarknetChainId } from 'starknet/constants.js';
|
|
5
5
|
import { uint256ToBN } from 'starknet/dist/utils/uint256.js';
|
|
6
|
-
import { WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
|
|
7
|
-
import { DynamicError } from '
|
|
8
|
-
import { logger } from '../../utils/logger.js';
|
|
6
|
+
import { WalletConnectorBase, logger } from '@dynamic-labs/wallet-connector-core';
|
|
7
|
+
import { DynamicError } from '@dynamic-labs/utils';
|
|
9
8
|
import { formatTypedDataMessage } from '../../utils/convertors.js';
|
|
10
9
|
import { ETH_STARKNET_ADDRESS } from '../constants.js';
|
|
11
10
|
import ETH_CONTRACT_ABI from './ethereumContractAbi.js';
|
package/src/wallets/window.d.ts
CHANGED
|
@@ -5,91 +5,14 @@
|
|
|
5
5
|
* Coinbase adds itself to window.coinbaseWalletExtension
|
|
6
6
|
* and also provider and previousProvider
|
|
7
7
|
*/
|
|
8
|
-
import { Transaction } from '@solana/web3.js';
|
|
9
8
|
import { IStarknetWindowObject } from 'get-starknet';
|
|
10
|
-
export interface IProvider {
|
|
11
|
-
isBlocto?: boolean;
|
|
12
|
-
isBraveWallet?: boolean;
|
|
13
|
-
isCoinbaseWallet?: boolean;
|
|
14
|
-
isDawn?: boolean;
|
|
15
|
-
isExodus?: boolean;
|
|
16
|
-
isFrame?: boolean;
|
|
17
|
-
isGamestop?: boolean;
|
|
18
|
-
isGlow?: boolean;
|
|
19
|
-
isMetaMask?: boolean;
|
|
20
|
-
isOpera?: boolean;
|
|
21
|
-
isPhantom?: boolean;
|
|
22
|
-
isSolflare?: boolean;
|
|
23
|
-
isTrustWallet?: boolean;
|
|
24
|
-
isZerion?: boolean;
|
|
25
|
-
}
|
|
26
|
-
export type ProviderFlag = 'isDawn' | 'isBraveWallet' | 'isCoinbaseWallet' | 'isFrame' | 'isGamestop' | 'isMetaMask' | 'isExodus' | 'isOpera' | 'isBlocto' | 'isTrustWallet' | 'isZerion';
|
|
27
|
-
export type ProviderCondition = {
|
|
28
|
-
flag: ProviderFlag | SolProviderFlag;
|
|
29
|
-
value: boolean;
|
|
30
|
-
};
|
|
31
|
-
export type SolProviderFlag = 'isBraveWallet' | 'isGlow' | 'isPhantom' | 'isSolflare';
|
|
32
9
|
export interface IWindow {
|
|
33
|
-
Slope: {
|
|
34
|
-
new (): ISolana;
|
|
35
|
-
};
|
|
36
|
-
coinbaseSolana: ISolana;
|
|
37
|
-
coinbaseWalletExtension: IEthereum;
|
|
38
|
-
ethereum: IEthereum;
|
|
39
10
|
fcl_extensions: IFclProvider[] | undefined;
|
|
40
|
-
glowSolana: ISolana;
|
|
41
11
|
location: Window['location'];
|
|
42
|
-
phantom: IPhantom;
|
|
43
|
-
solana: ISolana;
|
|
44
|
-
solflare: ISolana;
|
|
45
12
|
starknet: IStarknetWindowObject;
|
|
46
13
|
starknet_argentX: IStarknetWindowObject;
|
|
47
14
|
starknet_braavos: IStarknetWindowObject;
|
|
48
|
-
zerionWallet: IEthereum;
|
|
49
|
-
}
|
|
50
|
-
export interface IEthereum {
|
|
51
|
-
isBraveWallet: boolean;
|
|
52
|
-
isCoinbaseWallet: boolean;
|
|
53
|
-
isDawn: boolean;
|
|
54
|
-
isMetaMask: boolean;
|
|
55
|
-
isOpera: boolean;
|
|
56
|
-
isPhantom: boolean;
|
|
57
|
-
isTrustWallet: boolean;
|
|
58
|
-
isZerion: boolean;
|
|
59
|
-
providers: object[];
|
|
60
|
-
request: <T extends string>(params: {
|
|
61
|
-
method: T;
|
|
62
|
-
} | object) => Promise<T extends 'eth_requestAccounts' ? [string] : object>;
|
|
63
|
-
}
|
|
64
|
-
type PublicKey = {
|
|
65
|
-
toString: () => string;
|
|
66
|
-
};
|
|
67
|
-
export type ConnectionResult = {
|
|
68
|
-
address?: string;
|
|
69
|
-
publicKey?: PublicKey;
|
|
70
|
-
} | undefined;
|
|
71
|
-
export interface ISolana {
|
|
72
|
-
connect: (args?: {
|
|
73
|
-
onlyIfTrusted: boolean;
|
|
74
|
-
}) => Promise<ConnectionResult>;
|
|
75
|
-
disconnect: () => Promise<void | object>;
|
|
76
|
-
isBraveWallet: boolean;
|
|
77
|
-
isGlow: boolean;
|
|
78
|
-
isPhantom: boolean;
|
|
79
|
-
isSolflare: boolean;
|
|
80
|
-
on: (eventMessage: string, callback?: (publickey: string) => void) => Promise<void | object>;
|
|
81
|
-
providers: object[];
|
|
82
|
-
publicKey: PublicKey;
|
|
83
|
-
removeAllListeners: () => void;
|
|
84
|
-
removeListener: (eventMessage: string, callback?: (publickey: string) => void) => Promise<void | object>;
|
|
85
|
-
signMessage: (message: Uint8Array, encoding?: string) => Promise<void | object>;
|
|
86
|
-
signTransaction: (transaction: Transaction) => Promise<Transaction>;
|
|
87
15
|
}
|
|
88
16
|
export interface IFclProvider {
|
|
89
17
|
id: string;
|
|
90
18
|
}
|
|
91
|
-
export interface IPhantom {
|
|
92
|
-
ethereum: IEthereum;
|
|
93
|
-
solana: ISolana;
|
|
94
|
-
}
|
|
95
|
-
export {};
|
package/src/errors.cjs
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
class DynamicError extends Error {
|
|
6
|
-
}
|
|
7
|
-
class NotSupportedError extends DynamicError {
|
|
8
|
-
}
|
|
9
|
-
class EmailVerificationError extends DynamicError {
|
|
10
|
-
constructor(code) {
|
|
11
|
-
super();
|
|
12
|
-
this.name = 'EmailVerificationError';
|
|
13
|
-
this.code = code;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
class NoAccessError extends DynamicError {
|
|
17
|
-
constructor(walletPublicKey) {
|
|
18
|
-
super('User does not have access');
|
|
19
|
-
this.name = 'NoAccessError';
|
|
20
|
-
this.walletPublicKey = walletPublicKey;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
class ChainalysisError extends DynamicError {
|
|
24
|
-
constructor(walletPublicKey) {
|
|
25
|
-
super('This address is not approved for access');
|
|
26
|
-
this.name = 'ChainalysisError';
|
|
27
|
-
this.walletPublicKey = walletPublicKey;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
class EmailAlreadyExistsError extends DynamicError {
|
|
31
|
-
constructor() {
|
|
32
|
-
super('Email already exists');
|
|
33
|
-
this.name = 'EmailAlreadyExistsError';
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
class UsernameAlreadyExistsError extends DynamicError {
|
|
37
|
-
constructor() {
|
|
38
|
-
super('Username already exists');
|
|
39
|
-
this.name = 'UsernameAlreadyExistsError';
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
class WalletNotDeployedError extends DynamicError {
|
|
43
|
-
constructor() {
|
|
44
|
-
super('Wallet has not been deployed');
|
|
45
|
-
this.name = 'WalletNotDeployedError';
|
|
46
|
-
this.code = 'wallet_not_deployed';
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
class WalletUsedError extends DynamicError {
|
|
50
|
-
constructor(code) {
|
|
51
|
-
super();
|
|
52
|
-
this.name = 'WalletUsedError';
|
|
53
|
-
this.code = code;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
exports.ChainalysisError = ChainalysisError;
|
|
58
|
-
exports.DynamicError = DynamicError;
|
|
59
|
-
exports.EmailAlreadyExistsError = EmailAlreadyExistsError;
|
|
60
|
-
exports.EmailVerificationError = EmailVerificationError;
|
|
61
|
-
exports.NoAccessError = NoAccessError;
|
|
62
|
-
exports.NotSupportedError = NotSupportedError;
|
|
63
|
-
exports.UsernameAlreadyExistsError = UsernameAlreadyExistsError;
|
|
64
|
-
exports.WalletNotDeployedError = WalletNotDeployedError;
|
|
65
|
-
exports.WalletUsedError = WalletUsedError;
|
package/src/errors.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export declare class DynamicError extends Error {
|
|
2
|
-
}
|
|
3
|
-
export declare class NotSupportedError extends DynamicError {
|
|
4
|
-
}
|
|
5
|
-
export declare class EmailVerificationError extends DynamicError {
|
|
6
|
-
code: string | undefined;
|
|
7
|
-
constructor(code: string);
|
|
8
|
-
}
|
|
9
|
-
export declare class NoAccessError extends DynamicError {
|
|
10
|
-
walletPublicKey: string | undefined;
|
|
11
|
-
constructor(walletPublicKey: string);
|
|
12
|
-
}
|
|
13
|
-
export declare class ChainalysisError extends DynamicError {
|
|
14
|
-
walletPublicKey: string | undefined;
|
|
15
|
-
constructor(walletPublicKey: string);
|
|
16
|
-
}
|
|
17
|
-
export declare class EmailAlreadyExistsError extends DynamicError {
|
|
18
|
-
constructor();
|
|
19
|
-
}
|
|
20
|
-
export declare class UsernameAlreadyExistsError extends DynamicError {
|
|
21
|
-
constructor();
|
|
22
|
-
}
|
|
23
|
-
export declare class WalletNotDeployedError extends DynamicError {
|
|
24
|
-
code: string | undefined;
|
|
25
|
-
constructor();
|
|
26
|
-
}
|
|
27
|
-
export declare class WalletUsedError extends DynamicError {
|
|
28
|
-
code: string | undefined;
|
|
29
|
-
constructor(code: string);
|
|
30
|
-
}
|
package/src/errors.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
class DynamicError extends Error {
|
|
2
|
-
}
|
|
3
|
-
class NotSupportedError extends DynamicError {
|
|
4
|
-
}
|
|
5
|
-
class EmailVerificationError extends DynamicError {
|
|
6
|
-
constructor(code) {
|
|
7
|
-
super();
|
|
8
|
-
this.name = 'EmailVerificationError';
|
|
9
|
-
this.code = code;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
class NoAccessError extends DynamicError {
|
|
13
|
-
constructor(walletPublicKey) {
|
|
14
|
-
super('User does not have access');
|
|
15
|
-
this.name = 'NoAccessError';
|
|
16
|
-
this.walletPublicKey = walletPublicKey;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
class ChainalysisError extends DynamicError {
|
|
20
|
-
constructor(walletPublicKey) {
|
|
21
|
-
super('This address is not approved for access');
|
|
22
|
-
this.name = 'ChainalysisError';
|
|
23
|
-
this.walletPublicKey = walletPublicKey;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
class EmailAlreadyExistsError extends DynamicError {
|
|
27
|
-
constructor() {
|
|
28
|
-
super('Email already exists');
|
|
29
|
-
this.name = 'EmailAlreadyExistsError';
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
class UsernameAlreadyExistsError extends DynamicError {
|
|
33
|
-
constructor() {
|
|
34
|
-
super('Username already exists');
|
|
35
|
-
this.name = 'UsernameAlreadyExistsError';
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
class WalletNotDeployedError extends DynamicError {
|
|
39
|
-
constructor() {
|
|
40
|
-
super('Wallet has not been deployed');
|
|
41
|
-
this.name = 'WalletNotDeployedError';
|
|
42
|
-
this.code = 'wallet_not_deployed';
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
class WalletUsedError extends DynamicError {
|
|
46
|
-
constructor(code) {
|
|
47
|
-
super();
|
|
48
|
-
this.name = 'WalletUsedError';
|
|
49
|
-
this.code = code;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export { ChainalysisError, DynamicError, EmailAlreadyExistsError, EmailVerificationError, NoAccessError, NotSupportedError, UsernameAlreadyExistsError, WalletNotDeployedError, WalletUsedError };
|
package/src/rpcProviders.cjs
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var web3_js = require('@solana/web3.js');
|
|
6
|
-
var ethers = require('ethers');
|
|
7
|
-
|
|
8
|
-
const getRpcProviders = (configurations) => {
|
|
9
|
-
const rpcProviders = {};
|
|
10
|
-
if (configurations === null || configurations === void 0 ? void 0 : configurations.evm) {
|
|
11
|
-
rpcProviders.evm = configurations.evm.map((network) => {
|
|
12
|
-
var _a;
|
|
13
|
-
const rpcUrl = ((_a = network.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) || network.rpcUrls[0];
|
|
14
|
-
const provider = new ethers.ethers.providers.JsonRpcProvider(rpcUrl, network.chainId);
|
|
15
|
-
return {
|
|
16
|
-
chainId: network.chainId,
|
|
17
|
-
chainName: network.chainName,
|
|
18
|
-
provider,
|
|
19
|
-
};
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
if (configurations === null || configurations === void 0 ? void 0 : configurations.solana) {
|
|
23
|
-
rpcProviders.solana = configurations.solana.map((network) => {
|
|
24
|
-
var _a;
|
|
25
|
-
const rpcUrl = ((_a = network.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) || network.rpcUrls[0];
|
|
26
|
-
const provider = new web3_js.Connection(rpcUrl);
|
|
27
|
-
return {
|
|
28
|
-
chainId: parseInt(network.chainId),
|
|
29
|
-
chainName: network.name,
|
|
30
|
-
provider,
|
|
31
|
-
};
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
if (Object.keys(rpcProviders).length === 0) {
|
|
35
|
-
return undefined;
|
|
36
|
-
}
|
|
37
|
-
return rpcProviders;
|
|
38
|
-
};
|
|
39
|
-
const getEvmDefaultRpcProvider = (configurations) => {
|
|
40
|
-
const rpcProviders = getRpcProviders(configurations);
|
|
41
|
-
if (!rpcProviders) {
|
|
42
|
-
return undefined;
|
|
43
|
-
}
|
|
44
|
-
if (!rpcProviders.evm) {
|
|
45
|
-
return undefined;
|
|
46
|
-
}
|
|
47
|
-
const defaultProvider = rpcProviders.evm.find((provider) => provider.chainId === 1);
|
|
48
|
-
return defaultProvider;
|
|
49
|
-
};
|
|
50
|
-
const getSolanaDefaultRpcProvider = (configurations) => {
|
|
51
|
-
const rpcProviders = getRpcProviders(configurations);
|
|
52
|
-
if (!rpcProviders) {
|
|
53
|
-
return undefined;
|
|
54
|
-
}
|
|
55
|
-
if (!rpcProviders.solana) {
|
|
56
|
-
return undefined;
|
|
57
|
-
}
|
|
58
|
-
const defaultProvider = rpcProviders.solana.find((provider) => provider.chainId === 101);
|
|
59
|
-
return defaultProvider;
|
|
60
|
-
};
|
|
61
|
-
const getEvmRpcProviderByChainId = (configurations, chainId) => {
|
|
62
|
-
const rpcProviders = getRpcProviders(configurations);
|
|
63
|
-
if (!rpcProviders) {
|
|
64
|
-
return undefined;
|
|
65
|
-
}
|
|
66
|
-
if (rpcProviders.evm) {
|
|
67
|
-
const evmRpcProvider = rpcProviders.evm.find((rpcProvider) => rpcProvider.chainId === chainId);
|
|
68
|
-
return evmRpcProvider;
|
|
69
|
-
}
|
|
70
|
-
return undefined;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
exports.getEvmDefaultRpcProvider = getEvmDefaultRpcProvider;
|
|
74
|
-
exports.getEvmRpcProviderByChainId = getEvmRpcProviderByChainId;
|
|
75
|
-
exports.getRpcProviders = getRpcProviders;
|
|
76
|
-
exports.getSolanaDefaultRpcProvider = getSolanaDefaultRpcProvider;
|
package/src/rpcProviders.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { EvmRpcProvider, NetworkConfigurationMap, RpcProviders, SolanaRpcProvider } from './types';
|
|
2
|
-
export declare const getRpcProviders: (configurations: NetworkConfigurationMap) => RpcProviders | undefined;
|
|
3
|
-
export declare const getEvmDefaultRpcProvider: (configurations: NetworkConfigurationMap) => EvmRpcProvider | undefined;
|
|
4
|
-
export declare const getSolanaDefaultRpcProvider: (configurations: NetworkConfigurationMap) => SolanaRpcProvider | undefined;
|
|
5
|
-
export declare const getEvmRpcProviderByChainId: (configurations: NetworkConfigurationMap, chainId: number) => EvmRpcProvider | undefined;
|
package/src/rpcProviders.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { Connection } from '@solana/web3.js';
|
|
2
|
-
import { ethers } from 'ethers';
|
|
3
|
-
|
|
4
|
-
const getRpcProviders = (configurations) => {
|
|
5
|
-
const rpcProviders = {};
|
|
6
|
-
if (configurations === null || configurations === void 0 ? void 0 : configurations.evm) {
|
|
7
|
-
rpcProviders.evm = configurations.evm.map((network) => {
|
|
8
|
-
var _a;
|
|
9
|
-
const rpcUrl = ((_a = network.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) || network.rpcUrls[0];
|
|
10
|
-
const provider = new ethers.providers.JsonRpcProvider(rpcUrl, network.chainId);
|
|
11
|
-
return {
|
|
12
|
-
chainId: network.chainId,
|
|
13
|
-
chainName: network.chainName,
|
|
14
|
-
provider,
|
|
15
|
-
};
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
if (configurations === null || configurations === void 0 ? void 0 : configurations.solana) {
|
|
19
|
-
rpcProviders.solana = configurations.solana.map((network) => {
|
|
20
|
-
var _a;
|
|
21
|
-
const rpcUrl = ((_a = network.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) || network.rpcUrls[0];
|
|
22
|
-
const provider = new Connection(rpcUrl);
|
|
23
|
-
return {
|
|
24
|
-
chainId: parseInt(network.chainId),
|
|
25
|
-
chainName: network.name,
|
|
26
|
-
provider,
|
|
27
|
-
};
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
if (Object.keys(rpcProviders).length === 0) {
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
|
-
return rpcProviders;
|
|
34
|
-
};
|
|
35
|
-
const getEvmDefaultRpcProvider = (configurations) => {
|
|
36
|
-
const rpcProviders = getRpcProviders(configurations);
|
|
37
|
-
if (!rpcProviders) {
|
|
38
|
-
return undefined;
|
|
39
|
-
}
|
|
40
|
-
if (!rpcProviders.evm) {
|
|
41
|
-
return undefined;
|
|
42
|
-
}
|
|
43
|
-
const defaultProvider = rpcProviders.evm.find((provider) => provider.chainId === 1);
|
|
44
|
-
return defaultProvider;
|
|
45
|
-
};
|
|
46
|
-
const getSolanaDefaultRpcProvider = (configurations) => {
|
|
47
|
-
const rpcProviders = getRpcProviders(configurations);
|
|
48
|
-
if (!rpcProviders) {
|
|
49
|
-
return undefined;
|
|
50
|
-
}
|
|
51
|
-
if (!rpcProviders.solana) {
|
|
52
|
-
return undefined;
|
|
53
|
-
}
|
|
54
|
-
const defaultProvider = rpcProviders.solana.find((provider) => provider.chainId === 101);
|
|
55
|
-
return defaultProvider;
|
|
56
|
-
};
|
|
57
|
-
const getEvmRpcProviderByChainId = (configurations, chainId) => {
|
|
58
|
-
const rpcProviders = getRpcProviders(configurations);
|
|
59
|
-
if (!rpcProviders) {
|
|
60
|
-
return undefined;
|
|
61
|
-
}
|
|
62
|
-
if (rpcProviders.evm) {
|
|
63
|
-
const evmRpcProvider = rpcProviders.evm.find((rpcProvider) => rpcProvider.chainId === chainId);
|
|
64
|
-
return evmRpcProvider;
|
|
65
|
-
}
|
|
66
|
-
return undefined;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export { getEvmDefaultRpcProvider, getEvmRpcProviderByChainId, getRpcProviders, getSolanaDefaultRpcProvider };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
class CancellablePromise extends Promise {
|
|
6
|
-
constructor(executor) {
|
|
7
|
-
super((resolve, reject) => {
|
|
8
|
-
executor((val) => {
|
|
9
|
-
if (this.isCancelled)
|
|
10
|
-
return;
|
|
11
|
-
resolve(val);
|
|
12
|
-
}, (err) => {
|
|
13
|
-
if (this.isCancelled)
|
|
14
|
-
return;
|
|
15
|
-
reject(err);
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
this._controller = new AbortController();
|
|
19
|
-
}
|
|
20
|
-
get isCancelled() {
|
|
21
|
-
return this._controller.signal.aborted;
|
|
22
|
-
}
|
|
23
|
-
cancel() {
|
|
24
|
-
this._controller.abort();
|
|
25
|
-
}
|
|
26
|
-
static fromPromise(promise) {
|
|
27
|
-
return new CancellablePromise((resolve, reject) => {
|
|
28
|
-
promise.then(resolve).catch(reject);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
exports.CancellablePromise = CancellablePromise;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
type Executor<T> = (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: unknown) => void) => void;
|
|
2
|
-
export declare class CancellablePromise<T> extends Promise<T> {
|
|
3
|
-
_controller: AbortController;
|
|
4
|
-
constructor(executor: Executor<T>);
|
|
5
|
-
get isCancelled(): boolean;
|
|
6
|
-
cancel(): void;
|
|
7
|
-
static fromPromise<T>(promise: Promise<T>): CancellablePromise<T>;
|
|
8
|
-
}
|
|
9
|
-
export {};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
class CancellablePromise extends Promise {
|
|
2
|
-
constructor(executor) {
|
|
3
|
-
super((resolve, reject) => {
|
|
4
|
-
executor((val) => {
|
|
5
|
-
if (this.isCancelled)
|
|
6
|
-
return;
|
|
7
|
-
resolve(val);
|
|
8
|
-
}, (err) => {
|
|
9
|
-
if (this.isCancelled)
|
|
10
|
-
return;
|
|
11
|
-
reject(err);
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
this._controller = new AbortController();
|
|
15
|
-
}
|
|
16
|
-
get isCancelled() {
|
|
17
|
-
return this._controller.signal.aborted;
|
|
18
|
-
}
|
|
19
|
-
cancel() {
|
|
20
|
-
this._controller.abort();
|
|
21
|
-
}
|
|
22
|
-
static fromPromise(promise) {
|
|
23
|
-
return new CancellablePromise((resolve, reject) => {
|
|
24
|
-
promise.then(resolve).catch(reject);
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export { CancellablePromise };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { CancellablePromise } from './CancellablePromise';
|