@web3jskit/walletkit 0.4.5 → 0.5.1
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 +494 -145
- package/README.zh.md +569 -0
- package/dist/assets/svg/browserWalletIcon.d.ts +2 -0
- package/dist/assets/svg/browserWalletIcon.d.ts.map +1 -0
- package/dist/{src/assets → assets}/svg/dataBase.d.ts +1 -1
- package/dist/assets/svg/dataBase.d.ts.map +1 -0
- package/dist/assets/svg/metaMaskWallet.d.ts +2 -0
- package/dist/assets/svg/metaMaskWallet.d.ts.map +1 -0
- package/dist/btcConnector-BPOSvvaA.js +1 -0
- package/dist/btcConnector-Bc6dNLGT.js +1 -0
- package/dist/btcConnector-CWSxooB_.mjs +68 -0
- package/dist/btcConnector-H4vacfvE.mjs +58 -0
- package/dist/components/ConnectButton/ConnectedInfo.d.ts +2 -0
- package/dist/components/ConnectButton/ConnectedInfo.d.ts.map +1 -0
- package/dist/components/ConnectButton/index.d.ts +9 -0
- package/dist/components/ConnectButton/index.d.ts.map +1 -0
- package/dist/components/ConnectModal/index.d.ts +7 -0
- package/dist/components/ConnectModal/index.d.ts.map +1 -0
- package/dist/{src/components → components}/Dropdown/index.d.ts +2 -7
- package/dist/components/Dropdown/index.d.ts.map +1 -0
- package/dist/components/InfoModal/index.d.ts +3 -0
- package/dist/components/InfoModal/index.d.ts.map +1 -0
- package/dist/components/Modal/index.d.ts +15 -0
- package/dist/components/Modal/index.d.ts.map +1 -0
- package/dist/components/ModalHeader/index.d.ts +8 -0
- package/dist/components/ModalHeader/index.d.ts.map +1 -0
- package/dist/{src/components → components}/SVGs/backArrowSvg.d.ts +1 -0
- package/dist/components/SVGs/backArrowSvg.d.ts.map +1 -0
- package/dist/{src/components → components}/SVGs/closeSvg.d.ts +1 -0
- package/dist/components/SVGs/closeSvg.d.ts.map +1 -0
- package/dist/{src/components → components}/SVGs/copiedSvg.d.ts +1 -0
- package/dist/components/SVGs/copiedSvg.d.ts.map +1 -0
- package/dist/{src/components → components}/SVGs/copySvg.d.ts +1 -0
- package/dist/components/SVGs/copySvg.d.ts.map +1 -0
- package/dist/{src/components → components}/SVGs/exitSvg.d.ts +1 -0
- package/dist/components/SVGs/exitSvg.d.ts.map +1 -0
- package/dist/components/SVGs/spinSvg.d.ts +5 -0
- package/dist/components/SVGs/spinSvg.d.ts.map +1 -0
- package/dist/{src/components → components}/SVGs/vectorSvg.d.ts +1 -0
- package/dist/components/SVGs/vectorSvg.d.ts.map +1 -0
- package/dist/{src/components → components}/Text/index.d.ts +3 -1
- package/dist/components/Text/index.d.ts.map +1 -0
- package/dist/components/ThemeToggle.d.ts +5 -0
- package/dist/components/ThemeToggle.d.ts.map +1 -0
- package/dist/components/WalletItem/index.d.ts +9 -0
- package/dist/components/WalletItem/index.d.ts.map +1 -0
- package/dist/components/WalletKitProvider/ChainProvider.d.ts +27 -0
- package/dist/components/WalletKitProvider/ChainProvider.d.ts.map +1 -0
- package/dist/components/WalletKitProvider/I18nProvider.d.ts +15 -0
- package/dist/components/WalletKitProvider/I18nProvider.d.ts.map +1 -0
- package/dist/components/WalletKitProvider/ThemeProvider.d.ts +25 -0
- package/dist/components/WalletKitProvider/ThemeProvider.d.ts.map +1 -0
- package/dist/components/WalletKitProvider/index.d.ts +23 -0
- package/dist/components/WalletKitProvider/index.d.ts.map +1 -0
- package/dist/config/iconDatabase.d.ts +11 -0
- package/dist/config/iconDatabase.d.ts.map +1 -0
- package/dist/config/netConfig.d.ts +16 -0
- package/dist/config/netConfig.d.ts.map +1 -0
- package/dist/config/walletConfig.d.ts +28 -0
- package/dist/config/walletConfig.d.ts.map +1 -0
- package/dist/core/connectors/Bitget_Wallet/btcConnector.d.ts +36 -0
- package/dist/core/connectors/Bitget_Wallet/btcConnector.d.ts.map +1 -0
- package/dist/core/connectors/Bitget_Wallet/deepLinkConnector.d.ts +15 -0
- package/dist/core/connectors/Bitget_Wallet/deepLinkConnector.d.ts.map +1 -0
- package/dist/core/connectors/Bitget_Wallet/solConnector.d.ts +13 -0
- package/dist/core/connectors/Bitget_Wallet/solConnector.d.ts.map +1 -0
- package/dist/core/connectors/GelWallet/evmConnector.d.ts +27 -0
- package/dist/core/connectors/GelWallet/evmConnector.d.ts.map +1 -0
- package/dist/core/connectors/GelWallet/solConnector.d.ts +15 -0
- package/dist/core/connectors/GelWallet/solConnector.d.ts.map +1 -0
- package/dist/core/connectors/GelWallet/tronConnector.d.ts +8 -0
- package/dist/core/connectors/GelWallet/tronConnector.d.ts.map +1 -0
- package/dist/core/connectors/MetaMask/deepLinkConnector.d.ts +15 -0
- package/dist/core/connectors/MetaMask/deepLinkConnector.d.ts.map +1 -0
- package/dist/core/connectors/OKX_Wallet/btcConnector.d.ts +40 -0
- package/dist/core/connectors/OKX_Wallet/btcConnector.d.ts.map +1 -0
- package/dist/core/connectors/OKX_Wallet/deepLinkConnector.d.ts +15 -0
- package/dist/core/connectors/OKX_Wallet/deepLinkConnector.d.ts.map +1 -0
- package/dist/core/connectors/OKX_Wallet/solConnector.d.ts +12 -0
- package/dist/core/connectors/OKX_Wallet/solConnector.d.ts.map +1 -0
- package/dist/core/connectors/OKX_Wallet/tronConnector.d.ts +12 -0
- package/dist/core/connectors/OKX_Wallet/tronConnector.d.ts.map +1 -0
- package/dist/core/connectors/Phantom/btcConnector.d.ts +32 -0
- package/dist/core/connectors/Phantom/btcConnector.d.ts.map +1 -0
- package/dist/core/connectors/Phantom/deepLinkConnector.d.ts +15 -0
- package/dist/core/connectors/Phantom/deepLinkConnector.d.ts.map +1 -0
- package/dist/core/connectors/Phantom/solConnector.d.ts +12 -0
- package/dist/core/connectors/Phantom/solConnector.d.ts.map +1 -0
- package/dist/core/connectors/TokenPocket/deepLinkConnector.d.ts +17 -0
- package/dist/core/connectors/TokenPocket/deepLinkConnector.d.ts.map +1 -0
- package/dist/core/connectors/TronLink/deepLinkConnector.d.ts +17 -0
- package/dist/core/connectors/TronLink/deepLinkConnector.d.ts.map +1 -0
- package/dist/core/connectors/TronLink/tronConnector.d.ts +13 -0
- package/dist/core/connectors/TronLink/tronConnector.d.ts.map +1 -0
- package/dist/core/connectors/Trust_Wallet/deepLinkConnector.d.ts +15 -0
- package/dist/core/connectors/Trust_Wallet/deepLinkConnector.d.ts.map +1 -0
- package/dist/core/connectors/_evm/createConnectors.d.ts +4 -0
- package/dist/core/connectors/_evm/createConnectors.d.ts.map +1 -0
- package/dist/core/connectors/_evm/createEmitter.d.ts +35 -0
- package/dist/core/connectors/_evm/createEmitter.d.ts.map +1 -0
- package/dist/core/connectors/_evm/evmConnector.d.ts +51 -0
- package/dist/core/connectors/_evm/evmConnector.d.ts.map +1 -0
- package/dist/core/connectors/_gelwallet/gelWalletConnector.d.ts +26 -0
- package/dist/core/connectors/_gelwallet/gelWalletConnector.d.ts.map +1 -0
- package/dist/core/connectors/_sol/resolveAddress.d.ts +2 -0
- package/dist/core/connectors/_sol/resolveAddress.d.ts.map +1 -0
- package/dist/core/connectors/_sol/solConnector.d.ts +32 -0
- package/dist/core/connectors/_sol/solConnector.d.ts.map +1 -0
- package/dist/core/connectors/_tron/tronConnector.d.ts +30 -0
- package/dist/core/connectors/_tron/tronConnector.d.ts.map +1 -0
- package/dist/core/connectors/baseConnector.d.ts +36 -0
- package/dist/core/connectors/baseConnector.d.ts.map +1 -0
- package/dist/core/connectors/createConnectors.d.ts +20 -0
- package/dist/core/connectors/createConnectors.d.ts.map +1 -0
- package/dist/core/errors/base.d.ts +24 -0
- package/dist/core/errors/base.d.ts.map +1 -0
- package/dist/core/errors/request.d.ts +80 -0
- package/dist/core/errors/request.d.ts.map +1 -0
- package/dist/core/errors/rpc.d.ts +290 -0
- package/dist/core/errors/rpc.d.ts.map +1 -0
- package/dist/core/errors/unit.d.ts +11 -0
- package/dist/core/errors/unit.d.ts.map +1 -0
- package/dist/core/errors/utils.d.ts +8 -0
- package/dist/core/errors/utils.d.ts.map +1 -0
- package/dist/core/types/chain.d.ts +49 -0
- package/dist/core/types/chain.d.ts.map +1 -0
- package/dist/core/types/config.d.ts +7 -0
- package/dist/core/types/config.d.ts.map +1 -0
- package/dist/core/types/connector.d.ts +104 -0
- package/dist/core/types/connector.d.ts.map +1 -0
- package/dist/core/types/events.d.ts +2 -0
- package/dist/core/types/events.d.ts.map +1 -0
- package/dist/core/types/unit.d.ts +2 -0
- package/dist/core/types/unit.d.ts.map +1 -0
- package/dist/core/types/utils.d.ts +61 -0
- package/dist/core/types/utils.d.ts.map +1 -0
- package/dist/core/utils/decodePhantom.d.ts +2 -0
- package/dist/core/utils/decodePhantom.d.ts.map +1 -0
- package/dist/core/utils/deepEqual.d.ts +3 -0
- package/dist/core/utils/deepEqual.d.ts.map +1 -0
- package/dist/core/utils/deserialize.d.ts +4 -0
- package/dist/core/utils/deserialize.d.ts.map +1 -0
- package/dist/core/utils/filterWallets.d.ts +4 -0
- package/dist/core/utils/filterWallets.d.ts.map +1 -0
- package/dist/core/utils/rpc.d.ts +21 -0
- package/dist/core/utils/rpc.d.ts.map +1 -0
- package/dist/core/utils/serialize.d.ts +16 -0
- package/dist/core/utils/serialize.d.ts.map +1 -0
- package/dist/core/utils/silentConnect.d.ts +5 -0
- package/dist/core/utils/silentConnect.d.ts.map +1 -0
- package/dist/core/utils/stringify.d.ts +5 -0
- package/dist/core/utils/stringify.d.ts.map +1 -0
- package/dist/core/utils/uid.d.ts +2 -0
- package/dist/core/utils/uid.d.ts.map +1 -0
- package/dist/core/utils/util.d.ts +11 -0
- package/dist/core/utils/util.d.ts.map +1 -0
- package/dist/dapp.es-BPGP9PnL.mjs +15917 -0
- package/dist/dapp.es-sLnregcu.js +103 -0
- package/dist/deepLinkConnector-BEhA9fXM.js +1 -0
- package/dist/deepLinkConnector-BoFKaohV.js +1 -0
- package/dist/deepLinkConnector-C9yLvhQ0.js +1 -0
- package/dist/deepLinkConnector-CJskbSoZ.mjs +43 -0
- package/dist/deepLinkConnector-COkumXeY.js +1 -0
- package/dist/deepLinkConnector-CeF0BGa0.mjs +43 -0
- package/dist/deepLinkConnector-Cv1mS_6-.mjs +34 -0
- package/dist/deepLinkConnector-DVJJth-5.mjs +34 -0
- package/dist/deepLinkConnector-Dd1GhvIt.mjs +33 -0
- package/dist/deepLinkConnector-DjP2afmX.js +1 -0
- package/dist/deepLinkConnector-DmY8duGW.mjs +42 -0
- package/dist/deepLinkConnector-JrGcvOeL.mjs +34 -0
- package/dist/deepLinkConnector-k6omMzz2.js +1 -0
- package/dist/deepLinkConnector-uAd7NNtg.js +1 -0
- package/dist/errors/index.d.ts +4 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/evmConnector-CCvp7d3d.js +1 -0
- package/dist/evmConnector-CoauAOGL.mjs +163 -0
- package/dist/gelWalletConnector-B3UtBzAC.mjs +76 -0
- package/dist/gelWalletConnector-DWtJW90d.js +1 -0
- package/dist/hooks/useWalletKit.d.ts +113 -0
- package/dist/hooks/useWalletKit.d.ts.map +1 -0
- package/dist/index-9qmfDVzH-C-zsxX98.mjs +25638 -0
- package/dist/index-9qmfDVzH-C6VVZD9P.js +28 -0
- package/dist/index-B3LF1VeP-58KzZv6u.js +1 -0
- package/dist/index-B3LF1VeP-IR-fSZI0.mjs +120 -0
- package/dist/index-CCHY2zSF-OxZZmzOg.mjs +45 -0
- package/dist/index-CCHY2zSF-ocS_tvXl.js +1 -0
- package/dist/index-CQkA0oWr.js +138 -0
- package/dist/index-CqeMS3Gf-C4g86ca5.js +1 -0
- package/dist/index-CqeMS3Gf-DXS8RsUh.mjs +67 -0
- package/dist/index-DGMGsMkJ-BTPPfxmS.js +1 -0
- package/dist/index-DGMGsMkJ-CHecRdpD.mjs +27 -0
- package/dist/index-djQ_DEqj.mjs +9254 -0
- package/dist/index-yUF_S07V-Cm9-qVkc.js +1 -0
- package/dist/index-yUF_S07V-DHeRsyE0.mjs +48 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +27 -0
- package/dist/index.js +1 -0
- package/dist/index.umd.js +57350 -0
- package/dist/locals/i18n.d.ts +5 -0
- package/dist/locals/i18n.d.ts.map +1 -0
- package/dist/locals/languages/en.json.d.ts +43 -0
- package/dist/locals/languages/ja.json.d.ts +43 -0
- package/dist/locals/languages/ko.json.d.ts +43 -0
- package/dist/locals/languages/ms.json.d.ts +43 -0
- package/dist/locals/languages/th.json.d.ts +43 -0
- package/dist/locals/languages/vi.json.d.ts +43 -0
- package/dist/locals/languages/zh.json.d.ts +43 -0
- package/dist/locals/languages/zhTW.json.d.ts +43 -0
- package/dist/locals/resources.d.ts +347 -0
- package/dist/locals/resources.d.ts.map +1 -0
- package/dist/solConnector-6iJX98IC.mjs +41 -0
- package/dist/solConnector-B0hCu-c0.js +1 -0
- package/dist/solConnector-BF2LX1V2.js +1 -0
- package/dist/solConnector-BJTonslk.mjs +11 -0
- package/dist/solConnector-BZeW9sSK.js +1 -0
- package/dist/solConnector-DiPxszBo.mjs +11 -0
- package/dist/solConnector-RfQtdzBT.js +1 -0
- package/dist/solConnector-uPbRCSOa.mjs +11 -0
- package/dist/stores/helperStore.d.ts +92 -0
- package/dist/stores/helperStore.d.ts.map +1 -0
- package/dist/{src/stores → stores}/index.d.ts +15 -6
- package/dist/stores/index.d.ts.map +1 -0
- package/dist/{src/stores → stores}/modalStore.d.ts +5 -4
- package/dist/stores/modalStore.d.ts.map +1 -0
- package/dist/style.css +492 -0
- package/dist/tronConnector-BlFA83pA.js +1 -0
- package/dist/tronConnector-BsjZsmAJ.js +1 -0
- package/dist/tronConnector-CUOxt6Cw.mjs +35 -0
- package/dist/tronConnector-DfZzS07Y.mjs +13 -0
- package/dist/tronConnector-fKlrodno.js +1 -0
- package/dist/tronConnector-ofdgn1lq.mjs +21 -0
- package/dist/types/chain.d.ts +12 -0
- package/dist/types/chain.d.ts.map +1 -0
- package/dist/types/configType.d.ts +3 -0
- package/dist/types/configType.d.ts.map +1 -0
- package/dist/{src/types → types}/error.d.ts +1 -0
- package/dist/types/error.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/{src/types → types}/store.d.ts +1 -0
- package/dist/types/store.d.ts.map +1 -0
- package/dist/{src/utils → utils}/formatter.d.ts +1 -0
- package/dist/utils/formatter.d.ts.map +1 -0
- package/dist/{src/utils → utils}/generateAvatar.d.ts +1 -0
- package/dist/utils/generateAvatar.d.ts.map +1 -0
- package/dist/utils/proxy.d.ts +5 -0
- package/dist/utils/proxy.d.ts.map +1 -0
- package/package.json +96 -45
- package/dist/package.json +0 -47
- package/dist/src/assets/svg/dataBase.js +0 -5
- package/dist/src/assets/svg/dataBase.js.map +0 -1
- package/dist/src/assets/svg/metaMaskWallet.d.ts +0 -1
- package/dist/src/assets/svg/metaMaskWallet.js +0 -35
- package/dist/src/assets/svg/metaMaskWallet.js.map +0 -1
- package/dist/src/components/ConnectButton/ConnectedInfo.d.ts +0 -1
- package/dist/src/components/ConnectButton/ConnectedInfo.js +0 -21
- package/dist/src/components/ConnectButton/ConnectedInfo.js.map +0 -1
- package/dist/src/components/ConnectButton/index.d.ts +0 -8
- package/dist/src/components/ConnectButton/index.js +0 -16
- package/dist/src/components/ConnectButton/index.js.map +0 -1
- package/dist/src/components/ConnectButton/style.d.ts +0 -2
- package/dist/src/components/ConnectButton/style.js +0 -13
- package/dist/src/components/ConnectButton/style.js.map +0 -1
- package/dist/src/components/Connecting/index.d.ts +0 -6
- package/dist/src/components/Connecting/index.js +0 -11
- package/dist/src/components/Connecting/index.js.map +0 -1
- package/dist/src/components/Connecting/style.d.ts +0 -2
- package/dist/src/components/Connecting/style.js +0 -52
- package/dist/src/components/Connecting/style.js.map +0 -1
- package/dist/src/components/Dropdown/index.js +0 -24
- package/dist/src/components/Dropdown/index.js.map +0 -1
- package/dist/src/components/Dropdown/style.d.ts +0 -15
- package/dist/src/components/Dropdown/style.js +0 -66
- package/dist/src/components/Dropdown/style.js.map +0 -1
- package/dist/src/components/GetWallet/index.d.ts +0 -7
- package/dist/src/components/GetWallet/index.js +0 -21
- package/dist/src/components/GetWallet/index.js.map +0 -1
- package/dist/src/components/GetWallet/style.d.ts +0 -2
- package/dist/src/components/GetWallet/style.js +0 -117
- package/dist/src/components/GetWallet/style.js.map +0 -1
- package/dist/src/components/Header/ModalHeader.d.ts +0 -8
- package/dist/src/components/Header/ModalHeader.js +0 -9
- package/dist/src/components/Header/ModalHeader.js.map +0 -1
- package/dist/src/components/Header/style.d.ts +0 -2
- package/dist/src/components/Header/style.js +0 -74
- package/dist/src/components/Header/style.js.map +0 -1
- package/dist/src/components/Icon/index.d.ts +0 -23
- package/dist/src/components/Icon/index.js +0 -48
- package/dist/src/components/Icon/index.js.map +0 -1
- package/dist/src/components/Introduce/index.d.ts +0 -6
- package/dist/src/components/Introduce/index.js +0 -11
- package/dist/src/components/Introduce/index.js.map +0 -1
- package/dist/src/components/Introduce/style.d.ts +0 -2
- package/dist/src/components/Introduce/style.js +0 -97
- package/dist/src/components/Introduce/style.js.map +0 -1
- package/dist/src/components/Modal/ConnectModal.d.ts +0 -7
- package/dist/src/components/Modal/ConnectModal.js +0 -123
- package/dist/src/components/Modal/ConnectModal.js.map +0 -1
- package/dist/src/components/Modal/WalletInfoModal.d.ts +0 -1
- package/dist/src/components/Modal/WalletInfoModal.js +0 -46
- package/dist/src/components/Modal/WalletInfoModal.js.map +0 -1
- package/dist/src/components/Modal/index.d.ts +0 -13
- package/dist/src/components/Modal/index.js +0 -55
- package/dist/src/components/Modal/index.js.map +0 -1
- package/dist/src/components/Modal/style.d.ts +0 -5
- package/dist/src/components/Modal/style.js +0 -187
- package/dist/src/components/Modal/style.js.map +0 -1
- package/dist/src/components/SVGs/backArrowSvg.js +0 -4
- package/dist/src/components/SVGs/backArrowSvg.js.map +0 -1
- package/dist/src/components/SVGs/closeSvg.js +0 -4
- package/dist/src/components/SVGs/closeSvg.js.map +0 -1
- package/dist/src/components/SVGs/copiedSvg.js +0 -4
- package/dist/src/components/SVGs/copiedSvg.js.map +0 -1
- package/dist/src/components/SVGs/copySvg.js +0 -4
- package/dist/src/components/SVGs/copySvg.js.map +0 -1
- package/dist/src/components/SVGs/exitSvg.js +0 -4
- package/dist/src/components/SVGs/exitSvg.js.map +0 -1
- package/dist/src/components/SVGs/spinSvg.d.ts +0 -4
- package/dist/src/components/SVGs/spinSvg.js +0 -4
- package/dist/src/components/SVGs/spinSvg.js.map +0 -1
- package/dist/src/components/SVGs/vectorSvg.js +0 -4
- package/dist/src/components/SVGs/vectorSvg.js.map +0 -1
- package/dist/src/components/Text/index.js +0 -32
- package/dist/src/components/Text/index.js.map +0 -1
- package/dist/src/components/WalletKitProvider/ChainProvider.d.ts +0 -23
- package/dist/src/components/WalletKitProvider/ChainProvider.js +0 -66
- package/dist/src/components/WalletKitProvider/ChainProvider.js.map +0 -1
- package/dist/src/components/WalletKitProvider/I18nProvider.d.ts +0 -13
- package/dist/src/components/WalletKitProvider/I18nProvider.js +0 -42
- package/dist/src/components/WalletKitProvider/I18nProvider.js.map +0 -1
- package/dist/src/components/WalletKitProvider/ThemeProvider.d.ts +0 -8
- package/dist/src/components/WalletKitProvider/ThemeProvider.js +0 -14
- package/dist/src/components/WalletKitProvider/ThemeProvider.js.map +0 -1
- package/dist/src/components/WalletKitProvider/index.d.ts +0 -18
- package/dist/src/components/WalletKitProvider/index.js +0 -14
- package/dist/src/components/WalletKitProvider/index.js.map +0 -1
- package/dist/src/components/WalletList/index.d.ts +0 -8
- package/dist/src/components/WalletList/index.js +0 -18
- package/dist/src/components/WalletList/index.js.map +0 -1
- package/dist/src/components/WalletList/style.d.ts +0 -2
- package/dist/src/components/WalletList/style.js +0 -102
- package/dist/src/components/WalletList/style.js.map +0 -1
- package/dist/src/components/WalletTriggerButton/index.d.ts +0 -13
- package/dist/src/components/WalletTriggerButton/index.js +0 -37
- package/dist/src/components/WalletTriggerButton/index.js.map +0 -1
- package/dist/src/components/WalletTriggerButton/style.d.ts +0 -2
- package/dist/src/components/WalletTriggerButton/style.js +0 -63
- package/dist/src/components/WalletTriggerButton/style.js.map +0 -1
- package/dist/src/errors/index.d.ts +0 -2
- package/dist/src/errors/index.js +0 -6
- package/dist/src/errors/index.js.map +0 -1
- package/dist/src/hooks/useWalletKit.d.ts +0 -80
- package/dist/src/hooks/useWalletKit.js +0 -38
- package/dist/src/hooks/useWalletKit.js.map +0 -1
- package/dist/src/index.d.ts +0 -9
- package/dist/src/index.js +0 -10
- package/dist/src/index.js.map +0 -1
- package/dist/src/locals/i18n.d.ts +0 -2
- package/dist/src/locals/i18n.js +0 -17
- package/dist/src/locals/i18n.js.map +0 -1
- package/dist/src/locals/languages/en.json +0 -30
- package/dist/src/locals/languages/zh.json +0 -30
- package/dist/src/locals/resources.d.ts +0 -66
- package/dist/src/locals/resources.js +0 -11
- package/dist/src/locals/resources.js.map +0 -1
- package/dist/src/modals/connectModal/index.d.ts +0 -0
- package/dist/src/modals/connectModal/index.js +0 -2
- package/dist/src/modals/connectModal/index.js.map +0 -1
- package/dist/src/stores/SlotsWalletStore.d.ts +0 -18
- package/dist/src/stores/SlotsWalletStore.js +0 -33
- package/dist/src/stores/SlotsWalletStore.js.map +0 -1
- package/dist/src/stores/index.js +0 -25
- package/dist/src/stores/index.js.map +0 -1
- package/dist/src/stores/modalStore.js +0 -41
- package/dist/src/stores/modalStore.js.map +0 -1
- package/dist/src/styled/index.d.ts +0 -17
- package/dist/src/styled/index.js +0 -76
- package/dist/src/styled/index.js.map +0 -1
- package/dist/src/test/getwalletprovider.test.d.ts +0 -1
- package/dist/src/test/getwalletprovider.test.js +0 -10
- package/dist/src/test/getwalletprovider.test.js.map +0 -1
- package/dist/src/test/setup.d.ts +0 -1
- package/dist/src/test/setup.js +0 -7
- package/dist/src/test/setup.js.map +0 -1
- package/dist/src/theme/index.d.ts +0 -61
- package/dist/src/theme/index.js +0 -99
- package/dist/src/theme/index.js.map +0 -1
- package/dist/src/types/configType.d.ts +0 -2
- package/dist/src/types/configType.js +0 -2
- package/dist/src/types/configType.js.map +0 -1
- package/dist/src/types/error.js +0 -5
- package/dist/src/types/error.js.map +0 -1
- package/dist/src/types/slotsType.d.ts +0 -23
- package/dist/src/types/slotsType.js +0 -2
- package/dist/src/types/slotsType.js.map +0 -1
- package/dist/src/types/store.js +0 -2
- package/dist/src/types/store.js.map +0 -1
- package/dist/src/utils/formatter.js +0 -6
- package/dist/src/utils/formatter.js.map +0 -1
- package/dist/src/utils/generateAvatar.js +0 -32
- package/dist/src/utils/generateAvatar.js.map +0 -1
- package/dist/src/wallets/GelWallet/index.d.ts +0 -0
- package/dist/src/wallets/GelWallet/index.js +0 -2
- package/dist/src/wallets/GelWallet/index.js.map +0 -1
- package/dist/src/wallets/SlotsWallets/index.d.ts +0 -3
- package/dist/src/wallets/SlotsWallets/index.js +0 -26
- package/dist/src/wallets/SlotsWallets/index.js.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
package/README.md
CHANGED
|
@@ -1,213 +1,562 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @web3jskit/walletkit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A powerful React component library for multi-chain wallet connections, supporting EVM, Solana, Tron, and BTC blockchains with a unified API interface.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Features
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- 🔗 **Multi-Chain Support**: EVM, Solana, Tron, and BTC blockchains
|
|
8
|
+
- 💼 **Wallet Connectors**: Support for MetaMask, OKX Wallet, Phantom, TronLink, Trust Wallet, Bitget Wallet, TokenPocket, and GelWallet
|
|
9
|
+
- 🎨 **Theme & i18n**: Built-in dark/light theme switching and multilingual support (8 languages)
|
|
10
|
+
- 📱 **Responsive Design**: Mobile-first design with desktop optimization
|
|
11
|
+
- 🔄 **Auto Reconnection**: Automatic wallet reconnection on page refresh
|
|
12
|
+
- 📝 **Contract Interaction**: Built-in contract read/write and multicall support
|
|
13
|
+
- 🌐 **RPC Support**: Direct RPC calls without wallet connection
|
|
14
|
+
- 🌍 **Domain Resolution**: ENS domain name resolution and reverse lookup
|
|
15
|
+
- 🎯 **TypeScript**: Full TypeScript support with comprehensive type definitions
|
|
16
|
+
- ⚡ **Performance**: Optimized bundle size with tree-shaking support
|
|
8
17
|
|
|
9
|
-
|
|
18
|
+
## Installation
|
|
10
19
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
- 多链支持 / Multi-chain support (EVM, PUT, SOL, Tron, BTC)
|
|
14
|
-
- 钱包检测和连接 / Wallet detection and connection
|
|
15
|
-
- 统一的交易接口 / Unified transaction interface
|
|
16
|
-
- 状态管理 / State management
|
|
17
|
-
|
|
18
|
-
2. **@web3jskit/walletkit**: React 组件库,提供开箱即用的 UI 组件 / React component library providing ready-to-use UI components
|
|
19
|
-
- 钱包连接按钮 / Wallet connection button
|
|
20
|
-
- 钱包选择模态框 / Wallet selection modal
|
|
21
|
-
- 链切换组件 / Chain switching component
|
|
22
|
-
- 自定义 Hooks / Custom hooks
|
|
23
|
-
|
|
24
|
-
## 安装 Installation
|
|
25
|
-
|
|
26
|
-
通过 npm、yarn 或 pnpm 安装 / Install via npm, yarn, or pnpm:
|
|
20
|
+
### NPM Install
|
|
27
21
|
|
|
28
22
|
```bash
|
|
29
|
-
# npm
|
|
30
23
|
npm install @web3jskit/walletkit
|
|
31
|
-
|
|
32
|
-
# yarn
|
|
24
|
+
# or
|
|
33
25
|
yarn add @web3jskit/walletkit
|
|
34
|
-
|
|
35
|
-
# pnpm
|
|
26
|
+
# or
|
|
36
27
|
pnpm add @web3jskit/walletkit
|
|
37
28
|
```
|
|
38
29
|
|
|
39
|
-
|
|
30
|
+
### CDN Import (UMD Format)
|
|
31
|
+
|
|
32
|
+
```html
|
|
33
|
+
<!-- Import styles -->
|
|
34
|
+
<link rel="stylesheet" href="https://unpkg.com/@web3jskit/walletkit@latest/dist/style.css">
|
|
35
|
+
|
|
36
|
+
<!-- Import React and ReactDOM -->
|
|
37
|
+
<script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
|
|
38
|
+
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
|
|
39
|
+
|
|
40
|
+
<!-- Import WalletKit UMD version -->
|
|
41
|
+
<script src="https://unpkg.com/@web3jskit/walletkit@latest/dist/index.umd.js"></script>
|
|
42
|
+
|
|
43
|
+
<script>
|
|
44
|
+
const { WalletKitProvider, ConnectButton, useWalletKit, ChainType } = WalletKit;
|
|
45
|
+
|
|
46
|
+
// Use WalletKit components
|
|
47
|
+
function App() {
|
|
48
|
+
const { walletAddress, connect, disconnect } = useWalletKit();
|
|
49
|
+
|
|
50
|
+
return React.createElement('div', null, [
|
|
51
|
+
React.createElement('h1', null, 'WalletKit Example'),
|
|
52
|
+
React.createElement('p', null, `Wallet Address: ${walletAddress || 'Not Connected'}`),
|
|
53
|
+
React.createElement(ConnectButton)
|
|
54
|
+
]);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
ReactDOM.render(
|
|
58
|
+
React.createElement(WalletKitProvider, {
|
|
59
|
+
language: 'en',
|
|
60
|
+
defaultChainType: ChainType.EVM
|
|
61
|
+
}, React.createElement(App)),
|
|
62
|
+
document.getElementById('root')
|
|
63
|
+
);
|
|
64
|
+
</script>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Quick Start
|
|
40
68
|
|
|
41
|
-
###
|
|
69
|
+
### Basic Usage
|
|
42
70
|
|
|
43
|
-
```
|
|
44
|
-
import { WalletKitProvider, ConnectButton } from '@web3jskit/walletkit';
|
|
71
|
+
```tsx
|
|
72
|
+
import { WalletKitProvider, ConnectButton, useWalletKit } from '@web3jskit/walletkit';
|
|
73
|
+
// Import styles (required)
|
|
74
|
+
import '@web3jskit/walletkit/style.css';
|
|
45
75
|
|
|
46
76
|
function App() {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
77
|
+
return (
|
|
78
|
+
<WalletKitProvider>
|
|
79
|
+
<YourApp />
|
|
80
|
+
</WalletKitProvider>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function YourApp() {
|
|
85
|
+
const { connect, walletAddress, currentChainType, disconnect } = useWalletKit();
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<div>
|
|
89
|
+
<ConnectButton />
|
|
90
|
+
{walletAddress ? (
|
|
91
|
+
<div>
|
|
92
|
+
<p>Wallet connected: {walletAddress}</p>
|
|
93
|
+
<button onClick={disconnect}>Disconnect</button>
|
|
94
|
+
</div>
|
|
95
|
+
) : (
|
|
96
|
+
<button onClick={connect}>Connect Wallet</button>
|
|
97
|
+
)}
|
|
98
|
+
<div>Current chain type: {currentChainType}</div>
|
|
99
|
+
</div>
|
|
100
|
+
);
|
|
53
101
|
}
|
|
54
102
|
```
|
|
55
103
|
|
|
56
|
-
|
|
104
|
+
> ⚠️ **Important**: Always import the CSS file `@web3jskit/walletkit/style.css` for proper styling.
|
|
57
105
|
|
|
58
|
-
|
|
59
|
-
|
|
106
|
+
## Styling
|
|
107
|
+
|
|
108
|
+
The library includes built-in styles that are automatically loaded when you import the CSS file. The styles support both light and dark themes and are fully responsive.
|
|
109
|
+
|
|
110
|
+
### CSS Import Methods
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
// Method 1: Direct import (recommended)
|
|
114
|
+
import '@web3jskit/walletkit/style.css';
|
|
115
|
+
|
|
116
|
+
// Method 2: Import from dist
|
|
117
|
+
import '@web3jskit/walletkit/dist/style.css';
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Theme Variables
|
|
60
121
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
// 断开连接 Disconnect
|
|
70
|
-
const handleDisconnect = () => {
|
|
71
|
-
currentConnector?.disconnect();
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
return (
|
|
75
|
-
<div>
|
|
76
|
-
<div>Chain: {currentChainType}</div>
|
|
77
|
-
<div>Wallet: {currentConnector?.name}</div>
|
|
78
|
-
<div>Address: {walletAddress}</div>
|
|
79
|
-
</div>
|
|
80
|
-
);
|
|
122
|
+
The library uses CSS custom properties for theming. You can override these variables to customize the appearance:
|
|
123
|
+
|
|
124
|
+
```css
|
|
125
|
+
:root {
|
|
126
|
+
--walletkit-primary-color: #1890ff;
|
|
127
|
+
--walletkit-text-color: rgba(0, 0, 0, 0.88);
|
|
128
|
+
--walletkit-background-color: #ffffff;
|
|
129
|
+
/* ... more variables */
|
|
81
130
|
}
|
|
82
131
|
```
|
|
83
132
|
|
|
84
|
-
##
|
|
133
|
+
## API Documentation
|
|
134
|
+
|
|
135
|
+
### Components
|
|
136
|
+
|
|
137
|
+
#### WalletKitProvider
|
|
138
|
+
|
|
139
|
+
Provides wallet connection context. Must wrap your app at the top level.
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
<WalletKitProvider
|
|
143
|
+
language="en" // Language: supports zh, en, ja, ko, ms, th, vi, zhTW
|
|
144
|
+
theme="light" // Theme: supports dark, light
|
|
145
|
+
defaultChainType={ChainType.EVM}
|
|
146
|
+
defaultChainId={1}
|
|
147
|
+
reconnect={true}
|
|
148
|
+
supportWallets={[]}
|
|
149
|
+
customEvmNetworks={[]}
|
|
150
|
+
showNetwork={true}
|
|
151
|
+
allowSwitchWallet={true}
|
|
152
|
+
productName="My App"
|
|
153
|
+
>
|
|
154
|
+
<YourApp />
|
|
155
|
+
</WalletKitProvider>
|
|
156
|
+
```
|
|
85
157
|
|
|
86
|
-
|
|
158
|
+
##### Props
|
|
87
159
|
|
|
88
|
-
|
|
89
|
-
|
|
160
|
+
| Name | Type | Default | Description |
|
|
161
|
+
|---------------------|---------------------------------------------------|-----------------|------------------------------|
|
|
162
|
+
| language | 'zh'\|'en'\|'ja'\|'ko'\|'ms'\|'th'\|'vi'\|'zhTW' | 'zh' | UI language |
|
|
163
|
+
| theme | 'dark'\|'light' | 'light' | Theme |
|
|
164
|
+
| defaultChainType | ChainType | ChainType.EVM | Default chain type |
|
|
165
|
+
| defaultChainId | number | 1 | Default chain ID |
|
|
166
|
+
| reconnect | boolean | true | Auto reconnect last wallet |
|
|
167
|
+
| supportWallets | SupportWallet[] | all supported | Supported wallet types |
|
|
168
|
+
| customEvmNetworks | NetworkInfo[] | [] | Custom EVM network list |
|
|
169
|
+
| showNetwork | boolean | false | Show network switch |
|
|
170
|
+
| allowSwitchWallet | boolean | false | Allow switching wallet |
|
|
171
|
+
| productName | string | undefined | Product name for powered by |
|
|
90
172
|
|
|
91
|
-
|
|
92
|
-
await currentConnector.connect();
|
|
173
|
+
#### ConnectButton
|
|
93
174
|
|
|
94
|
-
|
|
95
|
-
await currentConnector.disconnect();
|
|
175
|
+
Built-in wallet connect button component with responsive design.
|
|
96
176
|
|
|
97
|
-
|
|
98
|
-
|
|
177
|
+
```tsx
|
|
178
|
+
<ConnectButton />
|
|
99
179
|
```
|
|
100
180
|
|
|
101
|
-
|
|
181
|
+
#### ConnectModal
|
|
102
182
|
|
|
103
|
-
|
|
104
|
-
const { setChainType, currentChainType } = useWalletKit();
|
|
183
|
+
Modal component for wallet selection and connection.
|
|
105
184
|
|
|
106
|
-
|
|
107
|
-
|
|
185
|
+
```tsx
|
|
186
|
+
<ConnectModal />
|
|
108
187
|
```
|
|
109
188
|
|
|
110
|
-
|
|
189
|
+
#### ThemeToggle
|
|
111
190
|
|
|
112
|
-
|
|
113
|
-
const { currentConnector } = useWalletKit();
|
|
191
|
+
Theme switching component.
|
|
114
192
|
|
|
115
|
-
|
|
116
|
-
|
|
193
|
+
```tsx
|
|
194
|
+
<ThemeToggle />
|
|
195
|
+
```
|
|
117
196
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
197
|
+
- See below for `ChainType`, `SupportWallet`, and `NetworkInfo` type definitions.
|
|
198
|
+
|
|
199
|
+
### Hooks
|
|
200
|
+
|
|
201
|
+
#### useWalletKit
|
|
202
|
+
|
|
203
|
+
Provides all wallet connection state and methods.
|
|
204
|
+
|
|
205
|
+
```tsx
|
|
206
|
+
const {
|
|
207
|
+
connect, // Connect wallet
|
|
208
|
+
disconnect, // Disconnect wallet
|
|
209
|
+
currentChainType, // Current chain type
|
|
210
|
+
setChainType, // Set chain type
|
|
211
|
+
currentConnector, // Current connector instance
|
|
212
|
+
theme, // Current theme
|
|
213
|
+
toggleTheme, // Switch theme
|
|
214
|
+
language, // Current language
|
|
215
|
+
setLanguage, // Set language
|
|
216
|
+
walletAddress, // Wallet address
|
|
217
|
+
currentNetwork, // Current network info
|
|
218
|
+
setCurrentNetwork, // Set current network
|
|
219
|
+
getProvider, // Get provider
|
|
220
|
+
provider, // Provider instance
|
|
221
|
+
showWalletInfo, // Show wallet info modal
|
|
222
|
+
signMessage, // Sign message
|
|
223
|
+
signTransaction, // Sign transaction
|
|
224
|
+
sendTransaction, // Send transaction
|
|
225
|
+
readContract, // Read contract
|
|
226
|
+
writeContract, // Write contract
|
|
227
|
+
multicall, // Batch contract calls
|
|
228
|
+
switchNetwork, // Switch network
|
|
229
|
+
waitForTransactionReceipt, // Wait for transaction receipt
|
|
230
|
+
getSupportNets // Get supported network list
|
|
231
|
+
} = useWalletKit();
|
|
232
|
+
```
|
|
123
233
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
234
|
+
### Main API
|
|
235
|
+
|
|
236
|
+
#### Connect & Disconnect
|
|
237
|
+
|
|
238
|
+
- `connect()`: Connect wallet, returns Promise`<Connector>`
|
|
239
|
+
- `disconnect()`: Disconnect wallet
|
|
240
|
+
- `getProvider()`: Get current provider instance
|
|
241
|
+
|
|
242
|
+
#### Chain & Network Management
|
|
243
|
+
|
|
244
|
+
- `currentChainType`: Current chain type (EVM, SOL, Tron, BTC)
|
|
245
|
+
- `setChainType(chainType)`: Set chain type
|
|
246
|
+
- `currentNetwork`: Current network info
|
|
247
|
+
- `setCurrentNetwork(networkId)`: Set current network
|
|
248
|
+
- `switchNetwork(chainId)`: Switch network
|
|
249
|
+
- `getSupportNets()`: Get supported network list
|
|
250
|
+
|
|
251
|
+
#### Transaction & Contract
|
|
252
|
+
|
|
253
|
+
- `signMessage(message)`: Sign message
|
|
254
|
+
- `signTransaction(tx)`: Sign transaction
|
|
255
|
+
- `sendTransaction(tx)`: Send transaction
|
|
256
|
+
- `readContract(params)`: Read contract data
|
|
257
|
+
- `writeContract(params)`: Write contract data
|
|
258
|
+
- `multicall(calls, option)`: Batch contract calls
|
|
259
|
+
- `waitForTransactionReceipt(hash, timeout?)`: Wait for transaction receipt
|
|
260
|
+
|
|
261
|
+
#### UI Related
|
|
262
|
+
|
|
263
|
+
- `theme`: Current theme
|
|
264
|
+
- `toggleTheme()`: Switch theme
|
|
265
|
+
- `language`: Current language
|
|
266
|
+
- `setLanguage(lang)`: Set language
|
|
267
|
+
- `showWalletInfo()`: Show wallet info modal
|
|
268
|
+
|
|
269
|
+
#### Advanced Usage
|
|
270
|
+
|
|
271
|
+
- `readContractRpc(params)`: Read contract directly via RPC (no wallet connection required)
|
|
272
|
+
- `multicallRpc(calls, option)`: Batch read contracts via RPC
|
|
273
|
+
- `evmSilentConnect(walletType, chainId)`: EVM silent connect
|
|
274
|
+
- `getWalletKit()`: Get global walletKit instance (for non-React usage)
|
|
275
|
+
|
|
276
|
+
## Type Definitions
|
|
277
|
+
|
|
278
|
+
### Theme Type
|
|
279
|
+
|
|
280
|
+
- `Theme`: 'dark' | 'light'
|
|
281
|
+
|
|
282
|
+
### Language Type
|
|
283
|
+
|
|
284
|
+
- `Locals`: 'zh' | 'en' | 'ja' | 'ko' | 'ms' | 'th' | 'vi' | 'zhTW'
|
|
285
|
+
|
|
286
|
+
### Chain Type
|
|
287
|
+
|
|
288
|
+
```ts
|
|
289
|
+
import { ChainType } from '@web3jskit/walletkit';
|
|
290
|
+
// ChainType.EVM // EVM-compatible chains
|
|
291
|
+
// ChainType.SOL // Solana chain
|
|
292
|
+
// ChainType.Tron // Tron chain
|
|
293
|
+
// ChainType.BTC // Bitcoin chain
|
|
131
294
|
```
|
|
132
295
|
|
|
133
|
-
|
|
296
|
+
### Wallet Type
|
|
134
297
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
- OKX Wallet (EVM)
|
|
140
|
-
- Trust Wallet (EVM)
|
|
141
|
-
- TokenPocket (EVM)
|
|
142
|
-
- Bitget Wallet (EVM)
|
|
143
|
-
- Coinbase Wallet (EVM)
|
|
298
|
+
```ts
|
|
299
|
+
import { SupportWallet } from '@web3jskit/walletkit';
|
|
300
|
+
// e.g. SupportWallet.METAMASK, SupportWallet.OKX_WALLET, etc.
|
|
301
|
+
```
|
|
144
302
|
|
|
145
|
-
|
|
303
|
+
### Network Type
|
|
146
304
|
|
|
147
|
-
|
|
305
|
+
```ts
|
|
306
|
+
import type { NetworkInfo } from '@web3jskit/walletkit';
|
|
307
|
+
// chainId, chainName, rpcUrls, nativeCurrency, blockExplorerUrls, etc.
|
|
308
|
+
```
|
|
148
309
|
|
|
149
|
-
|
|
150
|
-
| ------------------------- | --------------------------------------- |
|
|
151
|
-
| `currentChainType` | 当前链类型 Current chain type |
|
|
152
|
-
| `setChainType` | 切换链类型 Switch chain type |
|
|
153
|
-
| `currentConnector` | 当前钱包连接器 Current wallet connector |
|
|
154
|
-
| `connectStatus` | 连接状态 Connection status |
|
|
155
|
-
| `walletAddress` | 钱包地址 Wallet address |
|
|
156
|
-
| `getProvider` | 获取 Provider Get provider |
|
|
157
|
-
| `openModal` | 打开模态框 Open modal |
|
|
158
|
-
| `closeModal` | 关闭模态框 Close modal |
|
|
310
|
+
## Supported Wallets
|
|
159
311
|
|
|
160
|
-
###
|
|
312
|
+
### EVM Wallets
|
|
161
313
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
| `writeContract(params)` | 合约写入 Write contract |
|
|
169
|
-
| `readContract(params)` | 合约读取 Read contract |
|
|
314
|
+
- MetaMask
|
|
315
|
+
- OKX Wallet
|
|
316
|
+
- Trust Wallet
|
|
317
|
+
- Bitget Wallet
|
|
318
|
+
- TokenPocket
|
|
319
|
+
- GelWallet
|
|
170
320
|
|
|
171
|
-
|
|
321
|
+
### Solana Wallets
|
|
172
322
|
|
|
173
|
-
|
|
323
|
+
- Phantom
|
|
324
|
+
- OKX Wallet
|
|
325
|
+
- Bitget Wallet
|
|
326
|
+
- GelWallet
|
|
174
327
|
|
|
175
|
-
|
|
328
|
+
### Tron Wallets
|
|
176
329
|
|
|
177
|
-
|
|
178
|
-
|
|
330
|
+
- TronLink
|
|
331
|
+
- OKX Wallet
|
|
332
|
+
- GelWallet
|
|
179
333
|
|
|
180
|
-
|
|
181
|
-
|
|
334
|
+
### Bitcoin Wallets
|
|
335
|
+
|
|
336
|
+
- Phantom
|
|
337
|
+
|
|
338
|
+
## Examples
|
|
339
|
+
|
|
340
|
+
### Switch Chain Type
|
|
341
|
+
|
|
342
|
+
```tsx
|
|
343
|
+
import { ChainType, useWalletKit } from '@web3jskit/walletkit';
|
|
344
|
+
|
|
345
|
+
function ChainSwitcher() {
|
|
346
|
+
const { setChainType, currentChainType } = useWalletKit();
|
|
347
|
+
return (
|
|
348
|
+
<div>
|
|
349
|
+
<button onClick={() => setChainType(ChainType.EVM)}>Switch to EVM</button>
|
|
350
|
+
<button onClick={() => setChainType(ChainType.SOL)}>Switch to Solana</button>
|
|
351
|
+
<button onClick={() => setChainType(ChainType.Tron)}>Switch to Tron</button>
|
|
352
|
+
<button onClick={() => setChainType(ChainType.BTC)}>Switch to BTC</button>
|
|
353
|
+
<div>Current chain type: {currentChainType}</div>
|
|
354
|
+
</div>
|
|
355
|
+
);
|
|
356
|
+
}
|
|
182
357
|
```
|
|
183
358
|
|
|
184
|
-
|
|
359
|
+
### Switch Network
|
|
185
360
|
|
|
186
|
-
```
|
|
187
|
-
|
|
361
|
+
```tsx
|
|
362
|
+
import { useWalletKit } from '@web3jskit/walletkit';
|
|
363
|
+
|
|
364
|
+
function NetworkSwitcher() {
|
|
365
|
+
const { getSupportNets, switchNetwork, setCurrentNetwork, provider, currentNetwork } = useWalletKit();
|
|
366
|
+
return (
|
|
367
|
+
<div>
|
|
368
|
+
<h3>Switch Network</h3>
|
|
369
|
+
<div>
|
|
370
|
+
{getSupportNets().map((net) => (
|
|
371
|
+
<button
|
|
372
|
+
key={net.chainId}
|
|
373
|
+
onClick={async () => {
|
|
374
|
+
if (provider) {
|
|
375
|
+
await switchNetwork(net.chainId);
|
|
376
|
+
} else {
|
|
377
|
+
setCurrentNetwork(net.chainId);
|
|
378
|
+
}
|
|
379
|
+
}}
|
|
380
|
+
>
|
|
381
|
+
Switch to {net.chainName}
|
|
382
|
+
</button>
|
|
383
|
+
))}
|
|
384
|
+
</div>
|
|
385
|
+
<div>Current network: {currentNetwork?.chainName}</div>
|
|
386
|
+
</div>
|
|
387
|
+
);
|
|
388
|
+
}
|
|
188
389
|
```
|
|
189
390
|
|
|
190
|
-
|
|
391
|
+
### Contract Interaction
|
|
191
392
|
|
|
192
|
-
```
|
|
193
|
-
|
|
393
|
+
```tsx
|
|
394
|
+
import { useWalletKit } from '@web3jskit/walletkit';
|
|
395
|
+
|
|
396
|
+
function ContractInteraction() {
|
|
397
|
+
const { readContract, writeContract, multicall } = useWalletKit();
|
|
398
|
+
|
|
399
|
+
const handleReadContract = async () => {
|
|
400
|
+
const result = await readContract({
|
|
401
|
+
address: '0x...', // Contract address
|
|
402
|
+
abi: [...], // Contract ABI
|
|
403
|
+
functionName: 'balanceOf',
|
|
404
|
+
args: ['0x...'] // Arguments
|
|
405
|
+
});
|
|
406
|
+
console.log('Read result:', result);
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
const handleWriteContract = async () => {
|
|
410
|
+
const result = await writeContract({
|
|
411
|
+
address: '0x...', // Contract address
|
|
412
|
+
abi: [...], // Contract ABI
|
|
413
|
+
functionName: 'transfer',
|
|
414
|
+
args: ['0x...', 1000000] // Arguments
|
|
415
|
+
});
|
|
416
|
+
console.log('Write result:', result);
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
const handleMulticall = async () => {
|
|
420
|
+
const result = await multicall(
|
|
421
|
+
[
|
|
422
|
+
{
|
|
423
|
+
address: '0x...',
|
|
424
|
+
abi: [...],
|
|
425
|
+
functionName: 'balanceOf',
|
|
426
|
+
args: ['0x...']
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
address: '0x...',
|
|
430
|
+
abi: [...],
|
|
431
|
+
functionName: 'totalSupply'
|
|
432
|
+
}
|
|
433
|
+
],
|
|
434
|
+
{
|
|
435
|
+
multicallAddress: '0x...',
|
|
436
|
+
multicallAbi: [...]
|
|
437
|
+
}
|
|
438
|
+
);
|
|
439
|
+
console.log('Batch call result:', result);
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
return (
|
|
443
|
+
<div>
|
|
444
|
+
<button onClick={handleReadContract}>Read Contract</button>
|
|
445
|
+
<button onClick={handleWriteContract}>Write Contract</button>
|
|
446
|
+
<button onClick={handleMulticall}>Batch Call</button>
|
|
447
|
+
</div>
|
|
448
|
+
);
|
|
449
|
+
}
|
|
194
450
|
```
|
|
195
451
|
|
|
196
|
-
|
|
452
|
+
### Direct RPC Contract Calls
|
|
453
|
+
|
|
454
|
+
```tsx
|
|
455
|
+
import { readContractRpc, multicallRpc } from '@web3jskit/walletkit';
|
|
197
456
|
|
|
198
|
-
|
|
457
|
+
// Single contract read
|
|
458
|
+
const res = await readContractRpc({
|
|
459
|
+
abi: [...],
|
|
460
|
+
address: '0x...',
|
|
461
|
+
functionName: 'balanceOf',
|
|
462
|
+
args: ['0x...'],
|
|
463
|
+
rpcUrl: 'https://<your-rpc-url>'
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
// Batch contract read
|
|
467
|
+
const res2 = await multicallRpc(
|
|
468
|
+
[
|
|
469
|
+
{
|
|
470
|
+
address: '0x...',
|
|
471
|
+
abi: [...],
|
|
472
|
+
functionName: 'totalSupply'
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
address: '0x...',
|
|
476
|
+
abi: [...],
|
|
477
|
+
functionName: 'balanceOf',
|
|
478
|
+
args: ['0x...']
|
|
479
|
+
}
|
|
480
|
+
],
|
|
481
|
+
{
|
|
482
|
+
multicallAddress: '0x...',
|
|
483
|
+
multicallAbi: [...],
|
|
484
|
+
rpcUrl: 'https://<your-rpc-url>'
|
|
485
|
+
}
|
|
486
|
+
);
|
|
487
|
+
```
|
|
199
488
|
|
|
200
|
-
|
|
489
|
+
### Theme & Language (i18n)
|
|
490
|
+
|
|
491
|
+
```tsx
|
|
492
|
+
import { useWalletKit, supportedLanguages } from '@web3jskit/walletkit';
|
|
493
|
+
import type { Locals } from '@web3jskit/walletkit';
|
|
494
|
+
|
|
495
|
+
function ThemeAndLanguage() {
|
|
496
|
+
const { theme, toggleTheme, language, setLanguage } = useWalletKit();
|
|
497
|
+
return (
|
|
498
|
+
<div>
|
|
499
|
+
<div>Current theme: {theme}, current language: {language}</div>
|
|
500
|
+
<div>
|
|
501
|
+
<button onClick={() => toggleTheme()}>Switch Theme</button>
|
|
502
|
+
<select
|
|
503
|
+
value={language}
|
|
504
|
+
onChange={e => setLanguage(e.target.value as Locals)}
|
|
505
|
+
>
|
|
506
|
+
{supportedLanguages.map(lng => (
|
|
507
|
+
<option key={lng} value={lng}>
|
|
508
|
+
{lng}
|
|
509
|
+
</option>
|
|
510
|
+
))}
|
|
511
|
+
</select>
|
|
512
|
+
</div>
|
|
513
|
+
</div>
|
|
514
|
+
);
|
|
515
|
+
}
|
|
516
|
+
```
|
|
201
517
|
|
|
202
|
-
|
|
518
|
+
> `supportedLanguages` is the built-in language list, suitable for rendering language selection options dynamically.
|
|
203
519
|
|
|
204
|
-
|
|
520
|
+
### Event Listening
|
|
205
521
|
|
|
206
|
-
|
|
522
|
+
```tsx
|
|
523
|
+
import { useEffect } from 'react';
|
|
524
|
+
import { useWalletKit } from '@web3jskit/walletkit';
|
|
207
525
|
|
|
208
|
-
|
|
209
|
-
|
|
526
|
+
function EventListener() {
|
|
527
|
+
const { currentConnector } = useWalletKit();
|
|
528
|
+
useEffect(() => {
|
|
529
|
+
const handleConnect = (address) => {
|
|
530
|
+
console.log('Wallet connected:', address);
|
|
531
|
+
};
|
|
532
|
+
const handleChainChanged = (chainId) => {
|
|
533
|
+
console.log('Chain changed:', chainId);
|
|
534
|
+
};
|
|
535
|
+
const handleAccountChanged = (address) => {
|
|
536
|
+
console.log('Account changed:', address);
|
|
537
|
+
};
|
|
538
|
+
const handleDisconnect = () => {
|
|
539
|
+
console.log('Wallet disconnected');
|
|
540
|
+
};
|
|
541
|
+
if (currentConnector) {
|
|
542
|
+
currentConnector.on('connect', handleConnect);
|
|
543
|
+
currentConnector.on('chainChanged', handleChainChanged);
|
|
544
|
+
currentConnector.on('accountsChanged', handleAccountChanged);
|
|
545
|
+
currentConnector.on('disconnect', handleDisconnect);
|
|
546
|
+
}
|
|
547
|
+
return () => {
|
|
548
|
+
if (currentConnector) {
|
|
549
|
+
currentConnector.off('connect', handleConnect);
|
|
550
|
+
currentConnector.off('chainChanged', handleChainChanged);
|
|
551
|
+
currentConnector.off('accountsChanged', handleAccountChanged);
|
|
552
|
+
currentConnector.off('disconnect', handleDisconnect);
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
}, [currentConnector]);
|
|
556
|
+
return <div>Event listener example</div>;
|
|
557
|
+
}
|
|
558
|
+
```
|
|
210
559
|
|
|
211
|
-
|
|
560
|
+
## License
|
|
212
561
|
|
|
213
|
-
|
|
562
|
+
MIT
|