@layerswap/widget 0.1.4 → 0.1.14
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/README.md +78 -3
- package/dist/Models/Theme.d.ts +7 -6
- package/dist/Models/Theme.js +7 -7
- package/dist/Models/WalletProvider.d.ts +0 -4
- package/dist/Models/WalletProvider.js +2 -0
- package/dist/components/Buttons/copyButton.js +4 -3
- package/dist/components/ColorSchema.js +79 -45
- package/dist/components/Common/AddressIcon.js +1 -0
- package/dist/components/Common/AverageCompletionTime.js +1 -1
- package/dist/components/Common/CountDownTimer.js +2 -2
- package/dist/components/Common/FormattedAverageCompletionTime.js +1 -1
- package/dist/components/HeaderWithMenu/index.js +1 -8
- package/dist/components/Input/Address/AddressNote.js +3 -2
- package/dist/components/Input/Address/AddressPicker/AddressWithIcon.js +2 -2
- package/dist/components/Input/Address/AddressPicker/ConnectedWallets/ConnectWalletButton.js +12 -5
- package/dist/components/Input/Address/AddressPicker/ExchangeNote.d.ts +1 -1
- package/dist/components/Input/Address/AddressPicker/ExchangeNote.js +1 -1
- package/dist/components/Input/RouteIcon.js +1 -1
- package/dist/components/LayerswapMenu/MenuList.js +2 -56
- package/dist/components/Pages/404/index.js +1 -0
- package/dist/components/Pages/Auth/Steps/CodeStep/VerifyEmailCode.js +1 -0
- package/dist/components/Pages/Auth/index.d.ts +1 -1
- package/dist/components/Pages/Auth/index.js +3 -2
- package/dist/components/Pages/Campaigns/Details/Leaderboard.js +1 -0
- package/dist/components/Pages/Campaigns/Details/index.d.ts +1 -1
- package/dist/components/Pages/Campaigns/Details/index.js +3 -2
- package/dist/components/Pages/Campaigns/index.d.ts +1 -1
- package/dist/components/Pages/Campaigns/index.js +3 -2
- package/dist/components/Pages/Maintanance/index.js +1 -0
- package/dist/components/Pages/NoCookies/index.js +1 -0
- package/dist/components/Pages/SwapHistory/History.js +1 -2
- package/dist/components/Pages/SwapHistory/index.d.ts +1 -1
- package/dist/components/Pages/SwapHistory/index.js +4 -3
- package/dist/components/Pages/SwapPages/Form/FeeDetails/Campaign.js +1 -0
- package/dist/components/Pages/SwapPages/Form/Form.js +1 -4
- package/dist/components/Pages/SwapPages/Form/SecondaryComponents/ValidationError.js +1 -1
- package/dist/components/Pages/SwapPages/Form/Select/Popover/PopoverSelect.js +1 -1
- package/dist/components/Pages/SwapPages/Form/index.js +1 -0
- package/dist/components/Pages/SwapPages/Withdraw/Coinbase/Carousel.js +8 -6
- package/dist/components/Pages/SwapPages/Withdraw/Processing/Processing.js +2 -2
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/FuelWalletWithdrawal.d.ts +0 -4
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/FuelWalletWithdrawal.js +159 -125
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/ImtblxWalletWithdrawStep.d.ts +0 -4
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/ImtblxWalletWithdrawStep.js +69 -51
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/Loopring/ActivationTokentPicker.d.ts +0 -8
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/Loopring/ActivationTokentPicker.js +87 -45
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/Loopring/hooks.d.ts +0 -40
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/Loopring/hooks.js +73 -46
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/Loopring/index.d.ts +0 -4
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/Loopring/index.js +175 -128
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/SVMWalletWithdraw/index.d.ts +0 -7
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/SVMWalletWithdraw/index.js +138 -116
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/SVMWalletWithdraw/transactionSender.d.ts +0 -8
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/SVMWalletWithdraw/transactionSender.js +96 -75
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/SophonWalletWithdraw.js +2 -2
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/StarknetWalletWithdraw.d.ts +0 -4
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/StarknetWalletWithdraw.js +88 -71
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/TonWalletWithdraw.d.ts +0 -4
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/TonWalletWithdraw.js +146 -136
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/TronWalletWithdraw.d.ts +0 -4
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/TronWalletWithdraw.js +120 -99
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/WalletTransfer/TransferToken.js +3 -3
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/WalletTransfer/buttons.js +1 -0
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/WalletTransfer/index.js +1 -1
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/WalletTransfer/transactionMessage.js +2 -2
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/WalletTransferContent.js +101 -33
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/paradex/Evm.d.ts +0 -4
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/paradex/Evm.js +60 -55
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/paradex/Starknet.d.ts +0 -4
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/paradex/Starknet.js +71 -55
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/paradex/buttons.js +1 -0
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/paradex/index.d.ts +0 -4
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/paradex/index.js +56 -52
- package/dist/components/Pages/SwapPages/Withdraw/index.d.ts +1 -1
- package/dist/components/Pages/SwapPages/Withdraw/index.js +3 -2
- package/dist/components/Wallet/WalletModal/Connector.js +1 -1
- package/dist/components/Wallet/WalletProviders/FuelProvider.d.ts +0 -5
- package/dist/components/Wallet/WalletProviders/FuelProvider.js +25 -20
- package/dist/components/Wallet/WalletProviders/ImtblPassportProvider.d.ts +0 -5
- package/dist/components/Wallet/WalletProviders/ImtblPassportProvider.js +39 -36
- package/dist/components/Wallet/WalletProviders/SolanaProvider.d.ts +0 -5
- package/dist/components/Wallet/WalletProviders/SolanaProvider.js +49 -38
- package/dist/components/Wallet/WalletProviders/StarknetProvider.d.ts +0 -5
- package/dist/components/Wallet/WalletProviders/StarknetProvider.js +112 -117
- package/dist/components/Wallet/WalletProviders/TonConnectProvider.d.ts +0 -6
- package/dist/components/Wallet/WalletProviders/TonConnectProvider.js +58 -50
- package/dist/components/Wallet/WalletProviders/TronProvider.d.ts +0 -3
- package/dist/components/Wallet/WalletProviders/TronProvider.js +23 -15
- package/dist/components/Wallet/WalletProviders/Wagmi.d.ts +1 -1
- package/dist/components/Wallet/WalletProviders/Wagmi.js +20 -10
- package/dist/components/Wallet/WalletProviders/index.js +13 -6
- package/dist/components/Widget/Footer.d.ts +2 -1
- package/dist/components/Widget/Footer.js +13 -4
- package/dist/components/Widget/Index.d.ts +1 -1
- package/dist/components/Widget/Index.js +1 -1
- package/dist/components/WidgetLoading.d.ts +1 -0
- package/dist/components/WidgetLoading.js +5 -0
- package/dist/components/Wizard/Wizard.js +1 -1
- package/dist/components/shadcn/command.js +1 -1
- package/dist/components/themeWrapper.js +3 -2
- package/dist/context/{LayerswapContext.d.ts → LayerswapProvider.d.ts} +3 -8
- package/dist/context/{LayerswapContext.js → LayerswapProvider.js} +8 -9
- package/dist/context/authContext.js +1 -0
- package/dist/context/walletHooksProvider.js +1 -0
- package/dist/hooks/useWallet.js +10 -14
- package/dist/index.css +1 -1
- package/dist/index.d.ts +3 -5
- package/dist/index.js +2 -4
- package/dist/index.mjs +19 -0
- package/dist/lib/AppSettings.d.ts +7 -3
- package/dist/lib/AppSettings.js +8 -7
- package/dist/lib/address/formatter/index.js +8 -9
- package/dist/lib/address/validator/index.js +18 -20
- package/dist/lib/axiosInterceptor.js +1 -2
- package/dist/lib/balances/balanceResolver.js +16 -16
- package/dist/lib/balances/providers/evmBalanceProvider.js +3 -3
- package/dist/lib/balances/providers/loopringBalanceProvider.d.ts +0 -6
- package/dist/lib/balances/providers/loopringBalanceProvider.js +56 -43
- package/dist/lib/balances/providers/paradexBalanceProvider.d.ts +0 -6
- package/dist/lib/balances/providers/paradexBalanceProvider.js +42 -42
- package/dist/lib/balances/providers/solanaBalanceProvider.d.ts +0 -6
- package/dist/lib/balances/providers/solanaBalanceProvider.js +70 -71
- package/dist/lib/balances/providers/starknetBalanceProvider.d.ts +0 -6
- package/dist/lib/balances/providers/starknetBalanceProvider.js +48 -45
- package/dist/lib/balances/providers/tonBalanceProvider.d.ts +0 -18
- package/dist/lib/balances/providers/tonBalanceProvider.js +104 -100
- package/dist/lib/balances/providers/tronBalanceResolver.js +2 -3
- package/dist/lib/fuels/common/FakeAccount.d.ts +0 -24
- package/dist/lib/fuels/common/FakeAccount.js +58 -36
- package/dist/lib/fuels/common/PredicateConnector.d.ts +0 -54
- package/dist/lib/fuels/common/PredicateConnector.js +292 -205
- package/dist/lib/fuels/common/PredicateFactory.d.ts +0 -29
- package/dist/lib/fuels/common/PredicateFactory.js +123 -76
- package/dist/lib/fuels/common/PredicateWalletAdapter.d.ts +0 -17
- package/dist/lib/fuels/common/PredicateWalletAdapter.js +44 -29
- package/dist/lib/fuels/common/index.d.ts +0 -4
- package/dist/lib/fuels/common/index.js +4 -4
- package/dist/lib/fuels/connectors/fuel-wallet/FuelWalletConnector.d.ts +0 -51
- package/dist/lib/fuels/connectors/fuel-wallet/FuelWalletConnector.js +268 -234
- package/dist/lib/fuels/connectors/fuel-wallet/index.d.ts +0 -2
- package/dist/lib/fuels/connectors/fuel-wallet/index.js +2 -2
- package/dist/lib/fuels/connectors/fuel-wallet/types.d.ts +0 -50
- package/dist/lib/fuels/connectors/fuel-wallet/types.js +53 -9
- package/dist/lib/fuels/connectors/fuelet-wallet/FueletWalletConnector.d.ts +0 -7
- package/dist/lib/fuels/connectors/fuelet-wallet/FueletWalletConnector.js +20 -19
- package/dist/lib/fuels/connectors/fuelet-wallet/index.d.ts +0 -1
- package/dist/lib/fuels/connectors/fuelet-wallet/index.js +1 -1
- package/dist/lib/gases/gasResolver.d.ts +1 -1
- package/dist/lib/gases/gasResolver.js +10 -10
- package/dist/lib/gases/providers/evmGasProvider.js +5 -4
- package/dist/lib/gases/providers/loopringGasProvider.d.ts +0 -6
- package/dist/lib/gases/providers/loopringGasProvider.js +27 -24
- package/dist/lib/gases/providers/solanaGasProvider.d.ts +0 -7
- package/dist/lib/gases/providers/solanaGasProvider.js +32 -31
- package/dist/lib/gases/providers/starknetGasProvider.d.ts +0 -7
- package/dist/lib/gases/providers/starknetGasProvider.js +34 -33
- package/dist/lib/imtbl.d.ts +0 -69
- package/dist/lib/imtbl.js +63 -60
- package/dist/lib/internalApiClient.d.ts +0 -2
- package/dist/lib/internalApiClient.js +1 -4
- package/dist/lib/layerSwapApiClient.js +3 -3
- package/dist/lib/logError.js +2 -2
- package/dist/lib/nft/nftBalanceResolver.js +1 -2
- package/dist/lib/nft/providers/starknetNftProvider.d.ts +0 -6
- package/dist/lib/nft/providers/starknetNftProvider.js +49 -50
- package/dist/lib/wallets/connectors/EthereumProvider.d.ts +2 -2
- package/dist/lib/wallets/connectors/useSyncProviders/store.d.ts +1 -4
- package/dist/lib/wallets/fuel/Bako.d.ts +0 -15
- package/dist/lib/wallets/fuel/Bako.js +34 -29
- package/dist/lib/wallets/fuel/Basko.d.ts +0 -15
- package/dist/lib/wallets/fuel/Basko.js +34 -29
- package/dist/lib/wallets/fuel/useFuel.d.ts +0 -2
- package/dist/lib/wallets/fuel/useFuel.js +211 -192
- package/dist/lib/wallets/imtblX/useImtblX.d.ts +0 -2
- package/dist/lib/wallets/imtblX/useImtblX.js +87 -87
- package/dist/lib/wallets/paradex/Authorize/Ethereum.d.ts +0 -2
- package/dist/lib/wallets/paradex/Authorize/Ethereum.js +24 -23
- package/dist/lib/wallets/paradex/Authorize/Starknet.d.ts +0 -2
- package/dist/lib/wallets/paradex/Authorize/Starknet.js +14 -13
- package/dist/lib/wallets/paradex/lib/account.d.ts +0 -28
- package/dist/lib/wallets/paradex/lib/account.js +102 -53
- package/dist/lib/wallets/paradex/lib/index.d.ts +0 -24
- package/dist/lib/wallets/paradex/lib/index.js +20 -20
- package/dist/lib/wallets/paradex/lib/paraclear-provider.d.ts +0 -6
- package/dist/lib/wallets/paradex/lib/paraclear-provider.js +13 -9
- package/dist/lib/wallets/paradex/lib/paraclear.d.ts +0 -137
- package/dist/lib/wallets/paradex/lib/paraclear.js +258 -131
- package/dist/lib/wallets/paradex/lib/starknet-account-support.d.ts +0 -22
- package/dist/lib/wallets/paradex/lib/starknet-account-support.js +296 -220
- package/dist/lib/wallets/paradex/lib/starknet-signer.d.ts +0 -15
- package/dist/lib/wallets/paradex/lib/starknet-signer.js +120 -94
- package/dist/lib/wallets/paradex/useParadex.d.ts +0 -7
- package/dist/lib/wallets/paradex/useParadex.js +197 -194
- package/dist/lib/wallets/solana/transactionBuilder.d.ts +0 -4
- package/dist/lib/wallets/solana/transactionBuilder.js +63 -39
- package/dist/lib/wallets/solana/useSVM.d.ts +0 -5
- package/dist/lib/wallets/solana/useSVM.js +139 -142
- package/dist/lib/wallets/starknet/useStarknet.d.ts +0 -2
- package/dist/lib/wallets/starknet/useStarknet.js +139 -139
- package/dist/lib/wallets/ton/client.d.ts +0 -3
- package/dist/lib/wallets/ton/client.js +7 -7
- package/dist/lib/wallets/ton/useTON.d.ts +0 -2
- package/dist/lib/wallets/ton/useTON.js +121 -122
- package/dist/lib/wallets/tron/connectors/bitkeep.d.ts +0 -61
- package/dist/lib/wallets/tron/connectors/bitkeep.js +326 -303
- package/dist/lib/wallets/tron/connectors/index.d.ts +0 -4
- package/dist/lib/wallets/tron/connectors/index.js +4 -4
- package/dist/lib/wallets/tron/connectors/okxWallet.d.ts +0 -66
- package/dist/lib/wallets/tron/connectors/okxWallet.js +364 -336
- package/dist/lib/wallets/tron/connectors/tokenPocket.d.ts +0 -72
- package/dist/lib/wallets/tron/connectors/tokenPocket.js +337 -308
- package/dist/lib/wallets/tron/connectors/tronLink/index.d.ts +0 -102
- package/dist/lib/wallets/tron/connectors/tronLink/index.js +560 -520
- package/dist/lib/wallets/tron/connectors/tronLink/types.d.ts +0 -56
- package/dist/lib/wallets/tron/connectors/tronLink/types.js +53 -1
- package/dist/lib/wallets/tron/connectors/tronLink/utils.d.ts +0 -14
- package/dist/lib/wallets/tron/connectors/tronLink/utils.js +64 -61
- package/dist/lib/wallets/tron/useTron.d.ts +0 -2
- package/dist/lib/wallets/tron/useTron.js +111 -111
- package/dist/lib/wallets/utils/resolveWalletIcon.js +1 -0
- package/package.json +26 -77
- package/dist/hooks/useCopyClipboard.d.ts +0 -1
- package/dist/hooks/useCopyClipboard.js +0 -21
- package/dist/index.cjs +0 -125
- package/dist/lib/abis/ERC20.json +0 -258
- package/dist/lib/fuels/connectors/walletConnect/WalletConnectConnector.d.ts +0 -42
- package/dist/lib/fuels/connectors/walletConnect/WalletConnectConnector.js +0 -357
- package/dist/lib/fuels/connectors/walletConnect/constants.d.ts +0 -6
- package/dist/lib/fuels/connectors/walletConnect/constants.js +0 -7
- package/dist/lib/fuels/connectors/walletConnect/index.d.ts +0 -3
- package/dist/lib/fuels/connectors/walletConnect/index.js +0 -3
- package/dist/lib/fuels/connectors/walletConnect/types.d.ts +0 -12
- package/dist/lib/fuels/connectors/walletConnect/types.js +0 -1
- package/dist/lib/fuels/connectors/walletConnect/utils/index.d.ts +0 -1
- package/dist/lib/fuels/connectors/walletConnect/utils/index.js +0 -1
- package/dist/lib/fuels/connectors/walletConnect/utils/subscribeAndEnforceChain.d.ts +0 -2
- package/dist/lib/fuels/connectors/walletConnect/utils/subscribeAndEnforceChain.js +0 -39
- package/dist/lib/fuels/connectors/walletConnect/web3Modal.d.ts +0 -10
- package/dist/lib/fuels/connectors/walletConnect/web3Modal.js +0 -38
- package/dist/lib/loopring/LoopringAPI.d.ts +0 -12
- package/dist/lib/loopring/LoopringAPI.js +0 -13
- package/dist/lib/loopring/defs.d.ts +0 -425
- package/dist/lib/loopring/defs.js +0 -217
- package/dist/lib/loopring/eddsa.d.ts +0 -29
- package/dist/lib/loopring/eddsa.js +0 -208
- package/dist/lib/loopring/field.d.ts +0 -17
- package/dist/lib/loopring/field.js +0 -61
- package/dist/lib/loopring/formatter.d.ts +0 -137
- package/dist/lib/loopring/formatter.js +0 -516
- package/dist/lib/loopring/helpers.d.ts +0 -36
- package/dist/lib/loopring/helpers.js +0 -140
- package/dist/lib/loopring/jubjub.d.ts +0 -19
- package/dist/lib/loopring/jubjub.js +0 -79
- package/dist/lib/loopring/permutation.d.ts +0 -22
- package/dist/lib/loopring/permutation.js +0 -198
- package/dist/lib/loopring/poseidon/EDDSAUtil.d.ts +0 -14
- package/dist/lib/loopring/poseidon/EDDSAUtil.js +0 -61
- package/dist/lib/loopring/poseidon/babyJub.d.ts +0 -6
- package/dist/lib/loopring/poseidon/babyJub.js +0 -51
- package/dist/lib/loopring/poseidon/eddsa.d.ts +0 -29
- package/dist/lib/loopring/poseidon/eddsa.js +0 -210
- package/dist/lib/loopring/utils.d.ts +0 -76
- package/dist/lib/loopring/utils.js +0 -230
- package/dist/styles/dialog-transition.css +0 -28
- package/dist/styles/globals.css +0 -372
- package/dist/styles/manual-trasnfer-svg.css +0 -299
- package/dist/styles/vaul.css +0 -256
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
import { ecrecover, fromRpcSig, hashPersonalMessage, hexToBytes, pubToAddress, } from '@ethereumjs/util';
|
|
2
|
-
import { hexlify, splitSignature } from '@ethersproject/bytes';
|
|
3
|
-
import { disconnect, getAccount, reconnect, watchAccount, } from '@wagmi/core';
|
|
4
|
-
// import type { Web3Modal } from '@web3modal/wagmi';
|
|
5
|
-
import { CHAIN_IDS, FuelConnectorEventTypes, LocalStorage, } from 'fuels';
|
|
6
|
-
// import {
|
|
7
|
-
// type EIP1193Provider,
|
|
8
|
-
// EthereumWalletAdapter,
|
|
9
|
-
// type Maybe,
|
|
10
|
-
// PredicateConnector,
|
|
11
|
-
// type PredicateVersion,
|
|
12
|
-
// type PredicateWalletAdapter,
|
|
13
|
-
// type ProviderDictionary,
|
|
14
|
-
// getMockedSignatureIndex,
|
|
15
|
-
// getOrThrow,
|
|
16
|
-
// getProviderUrl,
|
|
17
|
-
// } from '@fuel-connectors/common';
|
|
18
|
-
// import { ApiController } from '@web3modal/core';
|
|
19
|
-
import { ETHEREUM_ICON, HAS_WINDOW, SINGATURE_VALIDATION_TIMEOUT, WINDOW, } from './constants';
|
|
20
|
-
import { subscribeAndEnforceChain } from './utils';
|
|
21
|
-
// import { createWagmiConfig, createWeb3ModalInstance } from './web3Modal';
|
|
22
|
-
import { EthereumWalletAdapter, PredicateConnector, getMockedSignatureIndex, getOrThrow, getProviderUrl } from '../../common';
|
|
23
|
-
import { PREDICATE_VERSIONS } from '../../evm-predicates';
|
|
24
|
-
export class WalletConnectConnector extends PredicateConnector {
|
|
25
|
-
constructor(config) {
|
|
26
|
-
super();
|
|
27
|
-
this.name = 'Ethereum Wallets';
|
|
28
|
-
this.installed = true;
|
|
29
|
-
this.events = FuelConnectorEventTypes;
|
|
30
|
-
this.metadata = {
|
|
31
|
-
image: ETHEREUM_ICON,
|
|
32
|
-
install: {
|
|
33
|
-
action: 'Install',
|
|
34
|
-
description: 'Install Ethereum Wallet to connect to Fuel',
|
|
35
|
-
link: 'https://ethereum.org/en/wallets/find-wallet/',
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
this.config = {};
|
|
39
|
-
this.storage =
|
|
40
|
-
config.storage || new LocalStorage(WINDOW?.localStorage);
|
|
41
|
-
const wagmiConfig = config.wagmiConfig;
|
|
42
|
-
if (wagmiConfig._internal.syncConnectedChain !== false) {
|
|
43
|
-
subscribeAndEnforceChain(wagmiConfig);
|
|
44
|
-
}
|
|
45
|
-
this.customPredicate = config.predicateConfig || null;
|
|
46
|
-
if (HAS_WINDOW) {
|
|
47
|
-
this.configProviders({ ...config, wagmiConfig });
|
|
48
|
-
}
|
|
49
|
-
this.loadPersistedConnection();
|
|
50
|
-
}
|
|
51
|
-
async loadPersistedConnection() {
|
|
52
|
-
const wagmiConfig = this.getWagmiConfig();
|
|
53
|
-
if (!wagmiConfig)
|
|
54
|
-
return;
|
|
55
|
-
await this.config?.fuelProvider;
|
|
56
|
-
await this.requireConnection();
|
|
57
|
-
await this.handleConnect(getAccount(wagmiConfig), await this.getAccountAddress());
|
|
58
|
-
}
|
|
59
|
-
// createModal re-instanciates the modal to update singletons from web3modal
|
|
60
|
-
createModal() {
|
|
61
|
-
this.clearSubscriptions();
|
|
62
|
-
// this.appKit = this.modalFactory(this.config);
|
|
63
|
-
// ApiController.prefetch();
|
|
64
|
-
this.setupWatchers();
|
|
65
|
-
}
|
|
66
|
-
// private modalFactory(config: WalletConnectConfig) {
|
|
67
|
-
// return createWeb3ModalInstance({
|
|
68
|
-
// projectId: config.projectId,
|
|
69
|
-
// wagmiConfig: config.wagmiConfig,
|
|
70
|
-
// });
|
|
71
|
-
// }
|
|
72
|
-
async handleConnect(account, defaultAccount = null) {
|
|
73
|
-
const address = defaultAccount ?? account?.address;
|
|
74
|
-
if (!(await this.accountHasValidation(address)))
|
|
75
|
-
return;
|
|
76
|
-
if (!address)
|
|
77
|
-
return;
|
|
78
|
-
await this.setupPredicate();
|
|
79
|
-
this.emit(this.events.connection, true);
|
|
80
|
-
this.emit(this.events.currentAccount, this.predicateAccount?.getPredicateAddress(address));
|
|
81
|
-
this.emit(this.events.accounts, this.predicateAccount?.getPredicateAddresses(await this.walletAccounts()));
|
|
82
|
-
}
|
|
83
|
-
setupWatchers() {
|
|
84
|
-
const wagmiConfig = this.getWagmiConfig();
|
|
85
|
-
if (!wagmiConfig)
|
|
86
|
-
throw new Error('Wagmi config not found');
|
|
87
|
-
this.subscribe(watchAccount(wagmiConfig, {
|
|
88
|
-
onChange: async (account) => {
|
|
89
|
-
switch (account.status) {
|
|
90
|
-
case 'connected': {
|
|
91
|
-
await this.handleConnect(account);
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
case 'disconnected': {
|
|
95
|
-
this.emit(this.events.connection, false);
|
|
96
|
-
this.emit(this.events.currentAccount, null);
|
|
97
|
-
this.emit(this.events.accounts, []);
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
}));
|
|
103
|
-
}
|
|
104
|
-
getWagmiConfig() {
|
|
105
|
-
return this.config?.wagmiConfig;
|
|
106
|
-
}
|
|
107
|
-
getWalletAdapter() {
|
|
108
|
-
return new EthereumWalletAdapter();
|
|
109
|
-
}
|
|
110
|
-
getPredicateVersions() {
|
|
111
|
-
return PREDICATE_VERSIONS;
|
|
112
|
-
}
|
|
113
|
-
async configProviders(config) {
|
|
114
|
-
const network = getProviderUrl(config?.chainId ?? CHAIN_IDS.fuel.testnet);
|
|
115
|
-
// this.config = Object.assign(config, {
|
|
116
|
-
// fuelProvider: config.fuelProvider || FuelProvider.create(network),
|
|
117
|
-
// });
|
|
118
|
-
}
|
|
119
|
-
async walletAccounts() {
|
|
120
|
-
return Promise.resolve((await this.getAccountAddresses()));
|
|
121
|
-
}
|
|
122
|
-
async getAccountAddress() {
|
|
123
|
-
const wagmiConfig = this.getWagmiConfig();
|
|
124
|
-
if (!wagmiConfig)
|
|
125
|
-
return null;
|
|
126
|
-
const addresses = await this.getAccountAddresses();
|
|
127
|
-
if (!addresses)
|
|
128
|
-
return null;
|
|
129
|
-
const address = addresses[0];
|
|
130
|
-
if (!address)
|
|
131
|
-
return null;
|
|
132
|
-
if (!(await this.accountHasValidation(address)))
|
|
133
|
-
return null;
|
|
134
|
-
return address;
|
|
135
|
-
}
|
|
136
|
-
async getAccountAddresses() {
|
|
137
|
-
const wagmiConfig = this.getWagmiConfig();
|
|
138
|
-
if (!wagmiConfig)
|
|
139
|
-
return null;
|
|
140
|
-
const addresses = getAccount(wagmiConfig).addresses || [];
|
|
141
|
-
const accountsValidations = await this.getAccountValidations(addresses);
|
|
142
|
-
return addresses.filter((_, i) => accountsValidations[i]);
|
|
143
|
-
}
|
|
144
|
-
async requireConnection() {
|
|
145
|
-
const wagmiConfig = this.getWagmiConfig();
|
|
146
|
-
if (!this.appKit)
|
|
147
|
-
this.createModal();
|
|
148
|
-
if (this.config.skipAutoReconnect || !wagmiConfig)
|
|
149
|
-
return;
|
|
150
|
-
const { status, connections } = wagmiConfig.state;
|
|
151
|
-
if (status === 'disconnected' && connections.size > 0) {
|
|
152
|
-
await reconnect(wagmiConfig);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
async getProviders() {
|
|
156
|
-
if (this.fuelProvider && this.ethProvider) {
|
|
157
|
-
return {
|
|
158
|
-
fuelProvider: this.fuelProvider,
|
|
159
|
-
ethProvider: this.ethProvider,
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
if (!this.fuelProvider) {
|
|
163
|
-
this.fuelProvider = getOrThrow(await this.config.fuelProvider, 'Fuel provider is not available');
|
|
164
|
-
}
|
|
165
|
-
const wagmiConfig = this.getWagmiConfig();
|
|
166
|
-
const ethProvider = wagmiConfig
|
|
167
|
-
? (await getAccount(wagmiConfig).connector?.getProvider?.())
|
|
168
|
-
: undefined;
|
|
169
|
-
return {
|
|
170
|
-
fuelProvider: this.fuelProvider,
|
|
171
|
-
ethProvider,
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
async connect() {
|
|
175
|
-
this.createModal();
|
|
176
|
-
const result = await new Promise((resolve, reject) => {
|
|
177
|
-
this.config.wagmiConfig.connectors.find((c) => c.id === 'walletConnect')?.connect();
|
|
178
|
-
const wagmiConfig = this.getWagmiConfig();
|
|
179
|
-
const unsub = this.appKit.subscribeEvents(async (event) => {
|
|
180
|
-
const requestValidations = () => {
|
|
181
|
-
this.requestValidations()
|
|
182
|
-
.then(() => resolve(true))
|
|
183
|
-
.catch((err) => reject(err))
|
|
184
|
-
.finally(() => unsub());
|
|
185
|
-
};
|
|
186
|
-
switch (event.data.event) {
|
|
187
|
-
case 'MODAL_OPEN':
|
|
188
|
-
if (wagmiConfig) {
|
|
189
|
-
const account = getAccount(wagmiConfig);
|
|
190
|
-
if (account?.isConnected) {
|
|
191
|
-
unsub();
|
|
192
|
-
this.appKit.close();
|
|
193
|
-
requestValidations();
|
|
194
|
-
break;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
// Ensures that the WC Web3Modal config is applied over pre-existing states (e.g. Solan Connect Web3Modal)
|
|
198
|
-
this.createModal();
|
|
199
|
-
break;
|
|
200
|
-
case 'CONNECT_SUCCESS': {
|
|
201
|
-
requestValidations();
|
|
202
|
-
break;
|
|
203
|
-
}
|
|
204
|
-
case 'MODAL_CLOSE':
|
|
205
|
-
case 'CONNECT_ERROR': {
|
|
206
|
-
if (wagmiConfig) {
|
|
207
|
-
const account = getAccount(wagmiConfig);
|
|
208
|
-
if (account) {
|
|
209
|
-
requestValidations();
|
|
210
|
-
break;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
resolve(false);
|
|
214
|
-
unsub();
|
|
215
|
-
break;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
});
|
|
220
|
-
return result;
|
|
221
|
-
}
|
|
222
|
-
async getAccountValidations(accounts) {
|
|
223
|
-
return Promise.all(accounts.map(async (a) => {
|
|
224
|
-
const isValidated = await this.storage.getItem(`SIGNATURE_VALIDATION_${a}`);
|
|
225
|
-
return isValidated === 'true';
|
|
226
|
-
}));
|
|
227
|
-
}
|
|
228
|
-
async accountHasValidation(account) {
|
|
229
|
-
if (!account)
|
|
230
|
-
return false;
|
|
231
|
-
const [hasValidate] = await this.getAccountValidations([account]);
|
|
232
|
-
return hasValidate;
|
|
233
|
-
}
|
|
234
|
-
async requestValidations() {
|
|
235
|
-
const wagmiConfig = this.getWagmiConfig();
|
|
236
|
-
if (!wagmiConfig) {
|
|
237
|
-
throw new Error('Wagmi config not found');
|
|
238
|
-
}
|
|
239
|
-
const account = getAccount(wagmiConfig);
|
|
240
|
-
const { addresses } = account;
|
|
241
|
-
for (const address of addresses || []) {
|
|
242
|
-
await this.requestValidation(address)
|
|
243
|
-
.then(() => {
|
|
244
|
-
this.handleConnect(account);
|
|
245
|
-
})
|
|
246
|
-
.catch((err) => {
|
|
247
|
-
this.disconnect();
|
|
248
|
-
throw err;
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
async requestValidation(address) {
|
|
253
|
-
return new Promise(async (resolve, reject) => {
|
|
254
|
-
// Disconnect if user dosen't provide signature in time
|
|
255
|
-
const validationTimeout = setTimeout(() => {
|
|
256
|
-
reject(new Error("User didn't provide signature in less than 1 minute"));
|
|
257
|
-
}, SINGATURE_VALIDATION_TIMEOUT);
|
|
258
|
-
const { ethProvider } = await this.getProviders();
|
|
259
|
-
if (!ethProvider)
|
|
260
|
-
return;
|
|
261
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
262
|
-
this.signAndValidate(ethProvider, address)
|
|
263
|
-
.then(() => {
|
|
264
|
-
clearTimeout(validationTimeout);
|
|
265
|
-
this.storage.setItem(`SIGNATURE_VALIDATION_${address}`, 'true');
|
|
266
|
-
resolve(true);
|
|
267
|
-
})
|
|
268
|
-
.catch((err) => {
|
|
269
|
-
clearTimeout(validationTimeout);
|
|
270
|
-
reject(err);
|
|
271
|
-
});
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
async disconnect() {
|
|
275
|
-
const wagmiConfig = this.getWagmiConfig();
|
|
276
|
-
if (!wagmiConfig)
|
|
277
|
-
throw new Error('Wagmi config not found');
|
|
278
|
-
const { addresses, connector, isConnected } = getAccount(wagmiConfig);
|
|
279
|
-
await disconnect(wagmiConfig, {
|
|
280
|
-
connector,
|
|
281
|
-
});
|
|
282
|
-
addresses?.map((a) => this.storage.removeItem(`SIGNATURE_VALIDATION_${a}`));
|
|
283
|
-
return isConnected || false;
|
|
284
|
-
}
|
|
285
|
-
async sendTransaction(address, transaction) {
|
|
286
|
-
const { ethProvider, fuelProvider } = await this.getProviders();
|
|
287
|
-
const { request, transactionId, account, transactionRequest } = await this.prepareTransaction(address, transaction);
|
|
288
|
-
const signature = (await ethProvider?.request({
|
|
289
|
-
method: 'personal_sign',
|
|
290
|
-
params: [transactionId, account],
|
|
291
|
-
}));
|
|
292
|
-
const predicateSignatureIndex = getMockedSignatureIndex(transactionRequest.witnesses);
|
|
293
|
-
// Transform the signature into compact form for Sway to understand
|
|
294
|
-
const compactSignature = splitSignature(hexToBytes(signature)).compact;
|
|
295
|
-
transactionRequest.witnesses[predicateSignatureIndex] = compactSignature;
|
|
296
|
-
const transactionWithPredicateEstimated = await fuelProvider.estimatePredicates(request);
|
|
297
|
-
const response = await fuelProvider.operations.submit({
|
|
298
|
-
encodedTransaction: hexlify(transactionWithPredicateEstimated.toTransactionBytes()),
|
|
299
|
-
});
|
|
300
|
-
return response.submit.id;
|
|
301
|
-
}
|
|
302
|
-
validateSignature(account, message, signature) {
|
|
303
|
-
const msgBuffer = Uint8Array.from(Buffer.from(message));
|
|
304
|
-
const msgHash = hashPersonalMessage(msgBuffer);
|
|
305
|
-
const { v, r, s } = fromRpcSig(signature);
|
|
306
|
-
const pubKey = ecrecover(msgHash, v, r, s);
|
|
307
|
-
const recoveredAddress = Buffer.from(pubToAddress(pubKey)).toString('hex');
|
|
308
|
-
// The recovered address doesn't have the 0x prefix
|
|
309
|
-
return recoveredAddress.toLowerCase() === account.toLowerCase().slice(2);
|
|
310
|
-
}
|
|
311
|
-
async signAndValidate(ethProvider, account) {
|
|
312
|
-
try {
|
|
313
|
-
if (!ethProvider) {
|
|
314
|
-
throw new Error('No Ethereum provider found');
|
|
315
|
-
}
|
|
316
|
-
if (account && !account.startsWith('0x')) {
|
|
317
|
-
throw new Error('Invalid account address');
|
|
318
|
-
}
|
|
319
|
-
const currentAccount = account ||
|
|
320
|
-
(await ethProvider.request({
|
|
321
|
-
method: 'eth_requestAccounts',
|
|
322
|
-
}))[0];
|
|
323
|
-
if (!currentAccount) {
|
|
324
|
-
throw new Error('No Ethereum account selected');
|
|
325
|
-
}
|
|
326
|
-
const message = `Sign this message to verify the connected account: ${currentAccount}`;
|
|
327
|
-
const signature = (await ethProvider.request({
|
|
328
|
-
method: 'personal_sign',
|
|
329
|
-
params: [message, currentAccount],
|
|
330
|
-
}));
|
|
331
|
-
if (!this.validateSignature(currentAccount, message, signature)) {
|
|
332
|
-
throw new Error('Signature address validation failed');
|
|
333
|
-
}
|
|
334
|
-
return true;
|
|
335
|
-
}
|
|
336
|
-
catch (error) {
|
|
337
|
-
this.disconnect();
|
|
338
|
-
throw error;
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
async signMessageCustomCurve(message) {
|
|
342
|
-
const { ethProvider } = await this.getProviders();
|
|
343
|
-
if (!ethProvider)
|
|
344
|
-
throw new Error('Eth provider not found');
|
|
345
|
-
const accountAddress = await this.getAccountAddress();
|
|
346
|
-
if (!accountAddress)
|
|
347
|
-
throw new Error('No connected accounts');
|
|
348
|
-
const signature = await ethProvider.request({
|
|
349
|
-
method: 'personal_sign',
|
|
350
|
-
params: [accountAddress, message],
|
|
351
|
-
});
|
|
352
|
-
return {
|
|
353
|
-
curve: 'secp256k1',
|
|
354
|
-
signature: signature,
|
|
355
|
-
};
|
|
356
|
-
}
|
|
357
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const DEFAULT_PROJECT_ID = "00000000000000000000000000000000";
|
|
2
|
-
export declare const ETHEREUM_ICON = "data:image/svg+xml;utf8;base64,PHN2ZyB3aWR0aD0iNTEyIiBoZWlnaHQ9IjUxMiIgdmlld0JveD0iMCAwIDUxMiA1MTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGQ9Ik0yNTMgMzM1LjEyMkwyNTUuODg2IDMzOEwzODggMjU5Ljk4N0wyNTUuODg2IDQxTDI1MyA1MC43OTgzVjMzNS4xMjJaIiBmaWxsPSIjMzQzNDM0Ii8+CjxwYXRoIGQ9Ik0yNTYgMzM4VjQxTDEyNCAyNTkuOTg2TDI1NiAzMzhaIiBmaWxsPSIjOEM4QzhDIi8+CjxwYXRoIGQ9Ik0yNTQgNDY1LjI4MUwyNTUuNjI4IDQ3MEwzODggMjg1TDI1NS42MjkgMzYyLjU2M0wyNTQuMDAxIDM2NC41MzJMMjU0IDQ2NS4yODFaIiBmaWxsPSIjM0MzQzNCIi8+CjxwYXRoIGQ9Ik0xMjQgMjg1TDI1NiA0NzBWMzYyLjU2MkwxMjQgMjg1WiIgZmlsbD0iIzhDOEM4QyIvPgo8cGF0aCBkPSJNMjU2IDIwMFYzMzhMMzg4IDI1OS45ODhMMjU2IDIwMFoiIGZpbGw9IiMxNDE0MTQiLz4KPHBhdGggZD0iTTI1NiAyMDBMMTI0IDI1OS45ODhMMjU2IDMzOFYyMDBaIiBmaWxsPSIjMzkzOTM5Ii8+Cjwvc3ZnPgo=";
|
|
3
|
-
export declare const TESTNET_URL = "https://testnet.fuel.network/v1/graphql";
|
|
4
|
-
export declare const SINGATURE_VALIDATION_TIMEOUT: number;
|
|
5
|
-
export declare const HAS_WINDOW: boolean;
|
|
6
|
-
export declare const WINDOW: (Window & typeof globalThis) | null;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export const DEFAULT_PROJECT_ID = '00000000000000000000000000000000';
|
|
2
|
-
export const ETHEREUM_ICON = 'data:image/svg+xml;utf8;base64,PHN2ZyB3aWR0aD0iNTEyIiBoZWlnaHQ9IjUxMiIgdmlld0JveD0iMCAwIDUxMiA1MTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGQ9Ik0yNTMgMzM1LjEyMkwyNTUuODg2IDMzOEwzODggMjU5Ljk4N0wyNTUuODg2IDQxTDI1MyA1MC43OTgzVjMzNS4xMjJaIiBmaWxsPSIjMzQzNDM0Ii8+CjxwYXRoIGQ9Ik0yNTYgMzM4VjQxTDEyNCAyNTkuOTg2TDI1NiAzMzhaIiBmaWxsPSIjOEM4QzhDIi8+CjxwYXRoIGQ9Ik0yNTQgNDY1LjI4MUwyNTUuNjI4IDQ3MEwzODggMjg1TDI1NS42MjkgMzYyLjU2M0wyNTQuMDAxIDM2NC41MzJMMjU0IDQ2NS4yODFaIiBmaWxsPSIjM0MzQzNCIi8+CjxwYXRoIGQ9Ik0xMjQgMjg1TDI1NiA0NzBWMzYyLjU2MkwxMjQgMjg1WiIgZmlsbD0iIzhDOEM4QyIvPgo8cGF0aCBkPSJNMjU2IDIwMFYzMzhMMzg4IDI1OS45ODhMMjU2IDIwMFoiIGZpbGw9IiMxNDE0MTQiLz4KPHBhdGggZD0iTTI1NiAyMDBMMTI0IDI1OS45ODhMMjU2IDMzOFYyMDBaIiBmaWxsPSIjMzkzOTM5Ii8+Cjwvc3ZnPgo=';
|
|
3
|
-
export const TESTNET_URL = 'https://testnet.fuel.network/v1/graphql';
|
|
4
|
-
// 1 minute timeout for request signature
|
|
5
|
-
export const SINGATURE_VALIDATION_TIMEOUT = 1000 * 60;
|
|
6
|
-
export const HAS_WINDOW = typeof window !== 'undefined';
|
|
7
|
-
export const WINDOW = HAS_WINDOW ? window : null;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Config as WagmiConfig } from '@wagmi/core';
|
|
2
|
-
import type { Provider as FuelProvider, StorageAbstract } from 'fuels';
|
|
3
|
-
import { PredicateConfig } from '../../common';
|
|
4
|
-
export type WalletConnectConfig = {
|
|
5
|
-
fuelProvider?: FuelProvider | Promise<FuelProvider>;
|
|
6
|
-
projectId?: string;
|
|
7
|
-
wagmiConfig: WagmiConfig;
|
|
8
|
-
predicateConfig?: PredicateConfig;
|
|
9
|
-
storage?: StorageAbstract;
|
|
10
|
-
chainId?: number;
|
|
11
|
-
skipAutoReconnect?: boolean;
|
|
12
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './subscribeAndEnforceChain';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './subscribeAndEnforceChain';
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { disconnect, getChains, switchChain, } from '@wagmi/core';
|
|
2
|
-
function getCurrentChainId(state) {
|
|
3
|
-
return state.current
|
|
4
|
-
? state.connections.get(state.current)?.chainId
|
|
5
|
-
: undefined;
|
|
6
|
-
}
|
|
7
|
-
export function subscribeAndEnforceChain(config) {
|
|
8
|
-
if (!config)
|
|
9
|
-
throw new Error('config is required');
|
|
10
|
-
config.subscribe((state) => ({
|
|
11
|
-
connections: state.connections,
|
|
12
|
-
status: state.status,
|
|
13
|
-
current: state.current,
|
|
14
|
-
}), (state, _prev) => {
|
|
15
|
-
const chains = getChains(config);
|
|
16
|
-
if (state.status !== 'connected' || state.current == null)
|
|
17
|
-
return;
|
|
18
|
-
const connector = state.connections.get(state.current)?.connector;
|
|
19
|
-
const currentChain = getCurrentChainId(state);
|
|
20
|
-
if (currentChain != null &&
|
|
21
|
-
!chains.some((chain) => chain.id === currentChain)) {
|
|
22
|
-
// Some EVM Wallets (like MetaMask) will auto-reject calls made too quickly.
|
|
23
|
-
setTimeout(() => {
|
|
24
|
-
switchChain(config, {
|
|
25
|
-
chainId: chains[0].id,
|
|
26
|
-
connector,
|
|
27
|
-
}).catch((error) => {
|
|
28
|
-
console.log(error);
|
|
29
|
-
disconnect(config);
|
|
30
|
-
});
|
|
31
|
-
}, 2000);
|
|
32
|
-
}
|
|
33
|
-
}, {
|
|
34
|
-
equalityFn: (a, b) => {
|
|
35
|
-
return (getCurrentChainId(a) === getCurrentChainId(b) && a.status === b.status);
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
// wagmiCo
|
|
39
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type Config } from '@wagmi/core';
|
|
2
|
-
import { AppKit } from '@reown/appkit/react';
|
|
3
|
-
import { WagmiAdapter } from '@reown/appkit-adapter-wagmi';
|
|
4
|
-
export declare const createWagmiConfig: () => Config;
|
|
5
|
-
interface CreateWeb3ModalProps {
|
|
6
|
-
adapter: WagmiAdapter | undefined;
|
|
7
|
-
projectId?: string;
|
|
8
|
-
}
|
|
9
|
-
export declare function createWeb3ModalInstance({ adapter, projectId, }: CreateWeb3ModalProps): AppKit;
|
|
10
|
-
export {};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { http, createConfig, injected } from '@wagmi/core';
|
|
2
|
-
import { DEFAULT_PROJECT_ID } from './constants';
|
|
3
|
-
import { createAppKit } from '@reown/appkit/react';
|
|
4
|
-
import { arbitrum, mainnet, sepolia } from '@reown/appkit/networks';
|
|
5
|
-
export const createWagmiConfig = () => createConfig({
|
|
6
|
-
chains: [sepolia, mainnet],
|
|
7
|
-
syncConnectedChain: true,
|
|
8
|
-
transports: {
|
|
9
|
-
[mainnet.id]: http(),
|
|
10
|
-
[sepolia.id]: http(),
|
|
11
|
-
},
|
|
12
|
-
connectors: [injected({ shimDisconnect: false })],
|
|
13
|
-
});
|
|
14
|
-
export function createWeb3ModalInstance({ adapter, projectId = DEFAULT_PROJECT_ID, }) {
|
|
15
|
-
if (!projectId) {
|
|
16
|
-
console.warn('[WalletConnect Connector]: Get a project ID on https://cloud.walletconnect.com to use WalletConnect features.');
|
|
17
|
-
}
|
|
18
|
-
return createAppKit({
|
|
19
|
-
adapters: [adapter],
|
|
20
|
-
networks: [mainnet, arbitrum],
|
|
21
|
-
projectId,
|
|
22
|
-
allWallets: 'ONLY_MOBILE',
|
|
23
|
-
features: {
|
|
24
|
-
analytics: false,
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
// return createWeb3Modal({
|
|
28
|
-
// wagmiConfig: {
|
|
29
|
-
// ...wagmiConfig,
|
|
30
|
-
// // @ts-ignore
|
|
31
|
-
// enableWalletConnect: !!projectId,
|
|
32
|
-
// },
|
|
33
|
-
// allWallets: 'ONLY_MOBILE',
|
|
34
|
-
// enableAnalytics: false,
|
|
35
|
-
// allowUnsupportedChain: true,
|
|
36
|
-
// projectId: projectId,
|
|
37
|
-
// });
|
|
38
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ChainId } from "./defs";
|
|
2
|
-
import { activateAccount, getOffchainFeeAmt, transfer, unlockAccount } from "./helpers";
|
|
3
|
-
export declare const LoopringAPI: {
|
|
4
|
-
CHAIN: ChainId;
|
|
5
|
-
BaseApi: string;
|
|
6
|
-
userAPI: {
|
|
7
|
-
getOffchainFeeAmt: typeof getOffchainFeeAmt;
|
|
8
|
-
unlockAccount: typeof unlockAccount;
|
|
9
|
-
activateAccount: typeof activateAccount;
|
|
10
|
-
transfer: typeof transfer;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import AppSettings from "../AppSettings";
|
|
2
|
-
import { ChainId } from "./defs";
|
|
3
|
-
import { activateAccount, getOffchainFeeAmt, transfer, unlockAccount } from "./helpers";
|
|
4
|
-
export const LoopringAPI = {
|
|
5
|
-
CHAIN: AppSettings.ApiVersion === "sandbox" ? ChainId.SEPOLIA : ChainId.MAINNET,
|
|
6
|
-
BaseApi: AppSettings.ApiVersion === "sandbox" ? "https://uat2.loopring.io" : "https://api3.loopring.io",
|
|
7
|
-
userAPI: {
|
|
8
|
-
getOffchainFeeAmt,
|
|
9
|
-
unlockAccount,
|
|
10
|
-
activateAccount,
|
|
11
|
-
transfer
|
|
12
|
-
},
|
|
13
|
-
};
|