@multiplatform.one/web3 7.25.0 → 7.28.0
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 +157 -8
- package/dist/cjs/bridge/base58.cjs +48 -0
- package/dist/cjs/bridge/base58.native.js +51 -0
- package/dist/cjs/bridge/base58.native.js.map +1 -0
- package/dist/cjs/bridge/core.cjs +5 -1
- package/dist/cjs/bridge/core.native.js +5 -1
- package/dist/cjs/bridge/core.native.js.map +1 -1
- package/dist/cjs/bridge/drivers.cjs +141 -0
- package/dist/cjs/bridge/drivers.native.js +161 -0
- package/dist/cjs/bridge/drivers.native.js.map +1 -0
- package/dist/cjs/bridge/nativeHost.cjs +49 -9
- package/dist/cjs/bridge/nativeHost.native.js +56 -9
- package/dist/cjs/bridge/nativeHost.native.js.map +1 -1
- package/dist/cjs/clients/adapter.native.js.map +1 -1
- package/dist/cjs/clients/connector.native.js.map +1 -1
- package/dist/cjs/clients/evm.cjs +1 -0
- package/dist/cjs/clients/evm.native.js +1 -0
- package/dist/cjs/clients/evm.native.js.map +1 -1
- package/dist/cjs/clients/evmRead.cjs +104 -0
- package/dist/cjs/clients/evmRead.native.js +124 -0
- package/dist/cjs/clients/evmRead.native.js.map +1 -0
- package/dist/cjs/clients/hooks.cjs +37 -7
- package/dist/cjs/clients/hooks.native.js +43 -5
- package/dist/cjs/clients/hooks.native.js.map +1 -1
- package/dist/cjs/clients/index.cjs +5 -0
- package/dist/cjs/clients/index.native.js +5 -0
- package/dist/cjs/clients/index.native.js.map +1 -1
- package/dist/cjs/clients/types.cjs +7 -0
- package/dist/cjs/clients/types.native.js +14 -0
- package/dist/cjs/clients/types.native.js.map +1 -1
- package/dist/cjs/connectkit/adapters/BitcoinAdapter.cjs +44 -2
- package/dist/cjs/connectkit/adapters/BitcoinAdapter.native.js +73 -5
- package/dist/cjs/connectkit/adapters/BitcoinAdapter.native.js.map +1 -1
- package/dist/cjs/connectkit/adapters/SolanaAdapter.cjs +46 -0
- package/dist/cjs/connectkit/adapters/SolanaAdapter.native.js +55 -0
- package/dist/cjs/connectkit/adapters/SolanaAdapter.native.js.map +1 -1
- package/dist/cjs/connectkit/adapters/SuiAdapter.cjs +40 -0
- package/dist/cjs/connectkit/adapters/SuiAdapter.native.js +50 -0
- package/dist/cjs/connectkit/adapters/SuiAdapter.native.js.map +1 -1
- package/dist/cjs/connectkit/connectors/ensureWalletConnectors.cjs +4 -1
- package/dist/cjs/connectkit/connectors/ensureWalletConnectors.native.js +8 -1
- package/dist/cjs/connectkit/connectors/ensureWalletConnectors.native.js.map +1 -1
- package/dist/cjs/connectkit/connectors/getWalletConnectors.native.js.map +1 -1
- package/dist/cjs/connectkit/connectors/syntheticChains.native.js.map +1 -1
- package/dist/cjs/connectkit/connectors/walletAdapterConnector.native.js.map +1 -1
- package/dist/cjs/connectkit/defaultConfig.cjs +5 -2
- package/dist/cjs/connectkit/defaultConfig.native.js +9 -2
- package/dist/cjs/connectkit/defaultConfig.native.js.map +1 -1
- package/dist/cjs/connectkit/siwe/SIWEContext.native.js.map +1 -1
- package/dist/cjs/connectkit/siwe/SIWEProvider.cjs +6 -4
- package/dist/cjs/connectkit/siwe/SIWEProvider.native.js +8 -4
- package/dist/cjs/connectkit/siwe/SIWEProvider.native.js.map +1 -1
- package/dist/cjs/connectkit/siwe/connectIntent.cjs +56 -16
- package/dist/cjs/connectkit/siwe/connectIntent.native.js +100 -16
- package/dist/cjs/connectkit/siwe/connectIntent.native.js.map +1 -1
- package/dist/cjs/connectkit/siwe/useSIWE.native.js.map +1 -1
- package/dist/cjs/connectkit/web3Bridge.cjs +58 -12
- package/dist/cjs/connectkit/web3Bridge.native.js +64 -14
- package/dist/cjs/connectkit/web3Bridge.native.js.map +1 -1
- package/dist/cjs/core/family.cjs +105 -0
- package/dist/cjs/core/family.native.js +132 -0
- package/dist/cjs/core/family.native.js.map +1 -0
- package/dist/cjs/core/index.cjs +50 -0
- package/dist/cjs/core/index.native.js +53 -0
- package/dist/cjs/core/index.native.js.map +1 -0
- package/dist/cjs/core/lightDriver.cjs +182 -0
- package/dist/cjs/core/lightDriver.native.js +260 -0
- package/dist/cjs/core/lightDriver.native.js.map +1 -0
- package/dist/cjs/core/message.cjs +89 -0
- package/dist/cjs/core/message.native.js +104 -0
- package/dist/cjs/core/message.native.js.map +1 -0
- package/dist/cjs/core/names.cjs +51 -0
- package/dist/cjs/core/names.native.js +95 -0
- package/dist/cjs/core/names.native.js.map +1 -0
- package/dist/cjs/core/react.cjs +59 -0
- package/dist/cjs/core/react.native.js +67 -0
- package/dist/cjs/core/react.native.js.map +1 -0
- package/dist/cjs/core/signIn.cjs +201 -0
- package/dist/cjs/core/signIn.native.js +240 -0
- package/dist/cjs/core/signIn.native.js.map +1 -0
- package/dist/cjs/core/store.cjs +495 -0
- package/dist/cjs/core/store.native.js +684 -0
- package/dist/cjs/core/store.native.js.map +1 -0
- package/dist/cjs/core/types.cjs +18 -0
- package/dist/cjs/core/types.native.js +21 -0
- package/dist/cjs/core/types.native.js.map +1 -0
- package/dist/cjs/families/btc.cjs +44 -0
- package/dist/cjs/families/btc.native.js +49 -0
- package/dist/cjs/families/btc.native.js.map +1 -0
- package/dist/cjs/families/eth.cjs +57 -0
- package/dist/cjs/families/eth.native.js +61 -0
- package/dist/cjs/families/eth.native.js.map +1 -0
- package/dist/cjs/families/gpg.cjs +40 -0
- package/dist/cjs/families/gpg.native.js +43 -0
- package/dist/cjs/families/gpg.native.js.map +1 -0
- package/dist/cjs/families/host.cjs +38 -0
- package/dist/cjs/families/host.native.js +41 -0
- package/dist/cjs/families/host.native.js.map +1 -0
- package/dist/cjs/families/index.cjs +53 -0
- package/dist/cjs/families/index.native.js +56 -0
- package/dist/cjs/families/index.native.js.map +1 -0
- package/dist/cjs/families/messages.cjs +61 -0
- package/dist/cjs/families/messages.native.js +66 -0
- package/dist/cjs/families/messages.native.js.map +1 -0
- package/dist/cjs/families/sol.cjs +55 -0
- package/dist/cjs/families/sol.native.js +64 -0
- package/dist/cjs/families/sol.native.js.map +1 -0
- package/dist/cjs/families/sui.cjs +48 -0
- package/dist/cjs/families/sui.native.js +53 -0
- package/dist/cjs/families/sui.native.js.map +1 -0
- package/dist/cjs/index.cjs +23 -2
- package/dist/cjs/index.native.js +22 -1
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/keycloak/keycloakWallet.cjs +13 -0
- package/dist/cjs/keycloak/keycloakWallet.native.js +15 -0
- package/dist/cjs/keycloak/keycloakWallet.native.js.map +1 -1
- package/dist/cjs/keycloak/useDirectLogin.cjs +10 -5
- package/dist/cjs/keycloak/useDirectLogin.native.js +12 -5
- package/dist/cjs/keycloak/useDirectLogin.native.js.map +1 -1
- package/dist/cjs/keycloak/useWalletLogin.cjs +16 -8
- package/dist/cjs/light/drivers.cjs +73 -0
- package/dist/cjs/light/drivers.native.js +97 -0
- package/dist/cjs/light/drivers.native.js.map +1 -0
- package/dist/cjs/light/index.cjs +30 -0
- package/dist/cjs/light/index.native.js +33 -0
- package/dist/cjs/light/index.native.js.map +1 -0
- package/dist/cjs/providers/WalletProvider.cjs +59 -17
- package/dist/cjs/providers/WalletProvider.native.js +99 -56
- package/dist/cjs/providers/WalletProvider.native.js.map +1 -1
- package/dist/cjs/providers/families.cjs +53 -0
- package/dist/cjs/providers/families.native.js +59 -0
- package/dist/cjs/providers/families.native.js.map +1 -0
- package/dist/cjs/providers/index.cjs +1 -0
- package/dist/cjs/providers/index.native.js +1 -0
- package/dist/cjs/providers/index.native.js.map +1 -1
- package/dist/cjs/providers/walletConfig.cjs +41 -0
- package/dist/cjs/providers/walletConfig.native.js +68 -0
- package/dist/cjs/providers/walletConfig.native.js.map +1 -1
- package/dist/cjs/wagmi/driver.cjs +257 -0
- package/dist/cjs/wagmi/driver.native.js +331 -0
- package/dist/cjs/wagmi/driver.native.js.map +1 -0
- package/dist/cjs/wagmi/host.cjs +239 -0
- package/dist/cjs/wagmi/host.native.js +320 -0
- package/dist/cjs/wagmi/host.native.js.map +1 -0
- package/dist/cjs/wagmi/index.cjs +28 -0
- package/dist/cjs/wagmi/index.native.js +31 -0
- package/dist/cjs/wagmi/index.native.js.map +1 -0
- package/dist/cjs/web.cjs +84 -0
- package/dist/esm/bridge/base58.mjs +23 -0
- package/dist/esm/bridge/base58.mjs.map +1 -0
- package/dist/esm/bridge/base58.native.js +23 -0
- package/dist/esm/bridge/base58.native.js.map +1 -0
- package/dist/esm/bridge/core.mjs +3 -2
- package/dist/esm/bridge/core.mjs.map +1 -1
- package/dist/esm/bridge/core.native.js +3 -2
- package/dist/esm/bridge/core.native.js.map +1 -1
- package/dist/esm/bridge/drivers.mjs +113 -0
- package/dist/esm/bridge/drivers.mjs.map +1 -0
- package/dist/esm/bridge/drivers.native.js +130 -0
- package/dist/esm/bridge/drivers.native.js.map +1 -0
- package/dist/esm/bridge/nativeHost.mjs +50 -11
- package/dist/esm/bridge/nativeHost.mjs.map +1 -1
- package/dist/esm/bridge/nativeHost.native.js +57 -11
- package/dist/esm/bridge/nativeHost.native.js.map +1 -1
- package/dist/esm/clients/adapter.mjs.map +1 -1
- package/dist/esm/clients/adapter.native.js.map +1 -1
- package/dist/esm/clients/connector.mjs.map +1 -1
- package/dist/esm/clients/connector.native.js.map +1 -1
- package/dist/esm/clients/evm.mjs +1 -0
- package/dist/esm/clients/evm.mjs.map +1 -1
- package/dist/esm/clients/evm.native.js +1 -0
- package/dist/esm/clients/evm.native.js.map +1 -1
- package/dist/esm/clients/evmRead.mjs +78 -0
- package/dist/esm/clients/evmRead.mjs.map +1 -0
- package/dist/esm/clients/evmRead.native.js +95 -0
- package/dist/esm/clients/evmRead.native.js.map +1 -0
- package/dist/esm/clients/hooks.mjs +38 -9
- package/dist/esm/clients/hooks.mjs.map +1 -1
- package/dist/esm/clients/hooks.native.js +44 -7
- package/dist/esm/clients/hooks.native.js.map +1 -1
- package/dist/esm/clients/index.mjs +4 -3
- package/dist/esm/clients/index.mjs.map +1 -1
- package/dist/esm/clients/index.native.js +4 -3
- package/dist/esm/clients/index.native.js.map +1 -1
- package/dist/esm/clients/types.mjs +7 -1
- package/dist/esm/clients/types.mjs.map +1 -1
- package/dist/esm/clients/types.native.js +14 -1
- package/dist/esm/clients/types.native.js.map +1 -1
- package/dist/esm/connectkit/adapters/BitcoinAdapter.mjs +44 -2
- package/dist/esm/connectkit/adapters/BitcoinAdapter.mjs.map +1 -1
- package/dist/esm/connectkit/adapters/BitcoinAdapter.native.js +73 -5
- package/dist/esm/connectkit/adapters/BitcoinAdapter.native.js.map +1 -1
- package/dist/esm/connectkit/adapters/SolanaAdapter.mjs +46 -0
- package/dist/esm/connectkit/adapters/SolanaAdapter.mjs.map +1 -1
- package/dist/esm/connectkit/adapters/SolanaAdapter.native.js +55 -0
- package/dist/esm/connectkit/adapters/SolanaAdapter.native.js.map +1 -1
- package/dist/esm/connectkit/adapters/SuiAdapter.mjs +40 -0
- package/dist/esm/connectkit/adapters/SuiAdapter.mjs.map +1 -1
- package/dist/esm/connectkit/adapters/SuiAdapter.native.js +50 -0
- package/dist/esm/connectkit/adapters/SuiAdapter.native.js.map +1 -1
- package/dist/esm/connectkit/connectors/ensureWalletConnectors.mjs +4 -1
- package/dist/esm/connectkit/connectors/ensureWalletConnectors.mjs.map +1 -1
- package/dist/esm/connectkit/connectors/ensureWalletConnectors.native.js +8 -1
- package/dist/esm/connectkit/connectors/ensureWalletConnectors.native.js.map +1 -1
- package/dist/esm/connectkit/connectors/getWalletConnectors.mjs.map +1 -1
- package/dist/esm/connectkit/connectors/getWalletConnectors.native.js.map +1 -1
- package/dist/esm/connectkit/connectors/syntheticChains.mjs.map +1 -1
- package/dist/esm/connectkit/connectors/syntheticChains.native.js.map +1 -1
- package/dist/esm/connectkit/connectors/walletAdapterConnector.mjs.map +1 -1
- package/dist/esm/connectkit/connectors/walletAdapterConnector.native.js.map +1 -1
- package/dist/esm/connectkit/defaultConfig.mjs +6 -3
- package/dist/esm/connectkit/defaultConfig.mjs.map +1 -1
- package/dist/esm/connectkit/defaultConfig.native.js +10 -3
- package/dist/esm/connectkit/defaultConfig.native.js.map +1 -1
- package/dist/esm/connectkit/siwe/SIWEContext.mjs.map +1 -1
- package/dist/esm/connectkit/siwe/SIWEContext.native.js.map +1 -1
- package/dist/esm/connectkit/siwe/SIWEProvider.mjs +6 -4
- package/dist/esm/connectkit/siwe/SIWEProvider.mjs.map +1 -1
- package/dist/esm/connectkit/siwe/SIWEProvider.native.js +8 -4
- package/dist/esm/connectkit/siwe/SIWEProvider.native.js.map +1 -1
- package/dist/esm/connectkit/siwe/connectIntent.mjs +54 -16
- package/dist/esm/connectkit/siwe/connectIntent.mjs.map +1 -1
- package/dist/esm/connectkit/siwe/connectIntent.native.js +98 -16
- package/dist/esm/connectkit/siwe/connectIntent.native.js.map +1 -1
- package/dist/esm/connectkit/siwe/useSIWE.mjs.map +1 -1
- package/dist/esm/connectkit/siwe/useSIWE.native.js.map +1 -1
- package/dist/esm/connectkit/web3Bridge.mjs +61 -16
- package/dist/esm/connectkit/web3Bridge.mjs.map +1 -1
- package/dist/esm/connectkit/web3Bridge.native.js +67 -18
- package/dist/esm/connectkit/web3Bridge.native.js.map +1 -1
- package/dist/esm/core/family.mjs +79 -0
- package/dist/esm/core/family.mjs.map +1 -0
- package/dist/esm/core/family.native.js +103 -0
- package/dist/esm/core/family.native.js.map +1 -0
- package/dist/esm/core/index.mjs +9 -0
- package/dist/esm/core/index.mjs.map +1 -0
- package/dist/esm/core/index.native.js +9 -0
- package/dist/esm/core/index.native.js.map +1 -0
- package/dist/esm/core/lightDriver.mjs +157 -0
- package/dist/esm/core/lightDriver.mjs.map +1 -0
- package/dist/esm/core/lightDriver.native.js +232 -0
- package/dist/esm/core/lightDriver.native.js.map +1 -0
- package/dist/esm/core/message.mjs +63 -0
- package/dist/esm/core/message.mjs.map +1 -0
- package/dist/esm/core/message.native.js +75 -0
- package/dist/esm/core/message.native.js.map +1 -0
- package/dist/esm/core/names.mjs +25 -0
- package/dist/esm/core/names.mjs.map +1 -0
- package/dist/esm/core/names.native.js +66 -0
- package/dist/esm/core/names.native.js.map +1 -0
- package/dist/esm/core/react.mjs +30 -0
- package/dist/esm/core/react.mjs.map +1 -0
- package/dist/esm/core/react.native.js +35 -0
- package/dist/esm/core/react.native.js.map +1 -0
- package/dist/esm/core/signIn.mjs +173 -0
- package/dist/esm/core/signIn.mjs.map +1 -0
- package/dist/esm/core/signIn.native.js +209 -0
- package/dist/esm/core/signIn.native.js.map +1 -0
- package/dist/esm/core/store.mjs +469 -0
- package/dist/esm/core/store.mjs.map +1 -0
- package/dist/esm/core/store.native.js +655 -0
- package/dist/esm/core/store.native.js.map +1 -0
- package/dist/esm/core/types.mjs +2 -0
- package/dist/esm/core/types.mjs.map +1 -0
- package/dist/esm/core/types.native.js +2 -0
- package/dist/esm/core/types.native.js.map +1 -0
- package/dist/esm/families/btc.mjs +19 -0
- package/dist/esm/families/btc.mjs.map +1 -0
- package/dist/esm/families/btc.native.js +21 -0
- package/dist/esm/families/btc.native.js.map +1 -0
- package/dist/esm/families/eth.mjs +32 -0
- package/dist/esm/families/eth.mjs.map +1 -0
- package/dist/esm/families/eth.native.js +33 -0
- package/dist/esm/families/eth.native.js.map +1 -0
- package/dist/esm/families/gpg.mjs +15 -0
- package/dist/esm/families/gpg.mjs.map +1 -0
- package/dist/esm/families/gpg.native.js +15 -0
- package/dist/esm/families/gpg.native.js.map +1 -0
- package/dist/esm/families/host.mjs +12 -0
- package/dist/esm/families/host.mjs.map +1 -0
- package/dist/esm/families/host.native.js +12 -0
- package/dist/esm/families/host.native.js.map +1 -0
- package/dist/esm/families/index.mjs +23 -0
- package/dist/esm/families/index.mjs.map +1 -0
- package/dist/esm/families/index.native.js +23 -0
- package/dist/esm/families/index.native.js.map +1 -0
- package/dist/esm/families/messages.mjs +32 -0
- package/dist/esm/families/messages.mjs.map +1 -0
- package/dist/esm/families/messages.native.js +34 -0
- package/dist/esm/families/messages.native.js.map +1 -0
- package/dist/esm/families/sol.mjs +30 -0
- package/dist/esm/families/sol.mjs.map +1 -0
- package/dist/esm/families/sol.native.js +36 -0
- package/dist/esm/families/sol.native.js.map +1 -0
- package/dist/esm/families/sui.mjs +23 -0
- package/dist/esm/families/sui.mjs.map +1 -0
- package/dist/esm/families/sui.native.js +25 -0
- package/dist/esm/families/sui.native.js.map +1 -0
- package/dist/esm/index.mjs +7 -3
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +7 -3
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/keycloak/keycloakWallet.mjs +13 -0
- package/dist/esm/keycloak/keycloakWallet.mjs.map +1 -1
- package/dist/esm/keycloak/keycloakWallet.native.js +15 -0
- package/dist/esm/keycloak/keycloakWallet.native.js.map +1 -1
- package/dist/esm/keycloak/useDirectLogin.mjs +10 -5
- package/dist/esm/keycloak/useDirectLogin.mjs.map +1 -1
- package/dist/esm/keycloak/useDirectLogin.native.js +12 -5
- package/dist/esm/keycloak/useDirectLogin.native.js.map +1 -1
- package/dist/esm/keycloak/useWalletLogin.mjs +16 -8
- package/dist/esm/keycloak/useWalletLogin.mjs.map +1 -1
- package/dist/esm/light/drivers.mjs +46 -0
- package/dist/esm/light/drivers.mjs.map +1 -0
- package/dist/esm/light/drivers.native.js +67 -0
- package/dist/esm/light/drivers.native.js.map +1 -0
- package/dist/esm/light/index.mjs +3 -0
- package/dist/esm/light/index.mjs.map +1 -0
- package/dist/esm/light/index.native.js +3 -0
- package/dist/esm/light/index.native.js.map +1 -0
- package/dist/esm/providers/WalletProvider.mjs +60 -19
- package/dist/esm/providers/WalletProvider.mjs.map +1 -1
- package/dist/esm/providers/WalletProvider.native.js +101 -59
- package/dist/esm/providers/WalletProvider.native.js.map +1 -1
- package/dist/esm/providers/families.mjs +27 -0
- package/dist/esm/providers/families.mjs.map +1 -0
- package/dist/esm/providers/families.native.js +30 -0
- package/dist/esm/providers/families.native.js.map +1 -0
- package/dist/esm/providers/index.mjs +2 -2
- package/dist/esm/providers/index.mjs.map +1 -1
- package/dist/esm/providers/index.native.js +2 -2
- package/dist/esm/providers/index.native.js.map +1 -1
- package/dist/esm/providers/walletConfig.mjs +40 -1
- package/dist/esm/providers/walletConfig.mjs.map +1 -1
- package/dist/esm/providers/walletConfig.native.js +67 -1
- package/dist/esm/providers/walletConfig.native.js.map +1 -1
- package/dist/esm/wagmi/driver.mjs +232 -0
- package/dist/esm/wagmi/driver.mjs.map +1 -0
- package/dist/esm/wagmi/driver.native.js +303 -0
- package/dist/esm/wagmi/driver.native.js.map +1 -0
- package/dist/esm/wagmi/host.mjs +213 -0
- package/dist/esm/wagmi/host.mjs.map +1 -0
- package/dist/esm/wagmi/host.native.js +291 -0
- package/dist/esm/wagmi/host.native.js.map +1 -0
- package/dist/esm/wagmi/index.mjs +3 -0
- package/dist/esm/wagmi/index.mjs.map +1 -0
- package/dist/esm/wagmi/index.native.js +3 -0
- package/dist/esm/wagmi/index.native.js.map +1 -0
- package/dist/esm/web.mjs +13 -0
- package/dist/esm/web.mjs.map +1 -0
- package/dist/jsx/bridge/base58.mjs +23 -0
- package/dist/jsx/bridge/base58.mjs.map +1 -0
- package/dist/jsx/bridge/base58.native.js +51 -0
- package/dist/jsx/bridge/base58.native.js.map +1 -0
- package/dist/jsx/bridge/core.mjs +3 -2
- package/dist/jsx/bridge/core.mjs.map +1 -1
- package/dist/jsx/bridge/core.native.js +5 -1
- package/dist/jsx/bridge/core.native.js.map +1 -1
- package/dist/jsx/bridge/drivers.mjs +113 -0
- package/dist/jsx/bridge/drivers.mjs.map +1 -0
- package/dist/jsx/bridge/drivers.native.js +161 -0
- package/dist/jsx/bridge/drivers.native.js.map +1 -0
- package/dist/jsx/bridge/nativeHost.mjs +50 -11
- package/dist/jsx/bridge/nativeHost.mjs.map +1 -1
- package/dist/jsx/bridge/nativeHost.native.js +56 -9
- package/dist/jsx/bridge/nativeHost.native.js.map +1 -1
- package/dist/jsx/clients/adapter.mjs.map +1 -1
- package/dist/jsx/clients/adapter.native.js.map +1 -1
- package/dist/jsx/clients/connector.mjs.map +1 -1
- package/dist/jsx/clients/connector.native.js.map +1 -1
- package/dist/jsx/clients/evm.mjs +1 -0
- package/dist/jsx/clients/evm.mjs.map +1 -1
- package/dist/jsx/clients/evm.native.js +1 -0
- package/dist/jsx/clients/evm.native.js.map +1 -1
- package/dist/jsx/clients/evmRead.mjs +78 -0
- package/dist/jsx/clients/evmRead.mjs.map +1 -0
- package/dist/jsx/clients/evmRead.native.js +124 -0
- package/dist/jsx/clients/evmRead.native.js.map +1 -0
- package/dist/jsx/clients/hooks.mjs +38 -9
- package/dist/jsx/clients/hooks.mjs.map +1 -1
- package/dist/jsx/clients/hooks.native.js +43 -5
- package/dist/jsx/clients/hooks.native.js.map +1 -1
- package/dist/jsx/clients/index.mjs +4 -3
- package/dist/jsx/clients/index.mjs.map +1 -1
- package/dist/jsx/clients/index.native.js +5 -0
- package/dist/jsx/clients/index.native.js.map +1 -1
- package/dist/jsx/clients/types.mjs +7 -1
- package/dist/jsx/clients/types.mjs.map +1 -1
- package/dist/jsx/clients/types.native.js +14 -0
- package/dist/jsx/clients/types.native.js.map +1 -1
- package/dist/jsx/connectkit/adapters/BitcoinAdapter.mjs +44 -2
- package/dist/jsx/connectkit/adapters/BitcoinAdapter.mjs.map +1 -1
- package/dist/jsx/connectkit/adapters/BitcoinAdapter.native.js +73 -5
- package/dist/jsx/connectkit/adapters/BitcoinAdapter.native.js.map +1 -1
- package/dist/jsx/connectkit/adapters/SolanaAdapter.mjs +46 -0
- package/dist/jsx/connectkit/adapters/SolanaAdapter.mjs.map +1 -1
- package/dist/jsx/connectkit/adapters/SolanaAdapter.native.js +55 -0
- package/dist/jsx/connectkit/adapters/SolanaAdapter.native.js.map +1 -1
- package/dist/jsx/connectkit/adapters/SuiAdapter.mjs +40 -0
- package/dist/jsx/connectkit/adapters/SuiAdapter.mjs.map +1 -1
- package/dist/jsx/connectkit/adapters/SuiAdapter.native.js +50 -0
- package/dist/jsx/connectkit/adapters/SuiAdapter.native.js.map +1 -1
- package/dist/jsx/connectkit/connectors/ensureWalletConnectors.mjs +4 -1
- package/dist/jsx/connectkit/connectors/ensureWalletConnectors.mjs.map +1 -1
- package/dist/jsx/connectkit/connectors/ensureWalletConnectors.native.js +8 -1
- package/dist/jsx/connectkit/connectors/ensureWalletConnectors.native.js.map +1 -1
- package/dist/jsx/connectkit/connectors/getWalletConnectors.mjs.map +1 -1
- package/dist/jsx/connectkit/connectors/getWalletConnectors.native.js.map +1 -1
- package/dist/jsx/connectkit/connectors/syntheticChains.mjs.map +1 -1
- package/dist/jsx/connectkit/connectors/syntheticChains.native.js.map +1 -1
- package/dist/jsx/connectkit/connectors/walletAdapterConnector.mjs.map +1 -1
- package/dist/jsx/connectkit/connectors/walletAdapterConnector.native.js.map +1 -1
- package/dist/jsx/connectkit/defaultConfig.mjs +6 -3
- package/dist/jsx/connectkit/defaultConfig.mjs.map +1 -1
- package/dist/jsx/connectkit/defaultConfig.native.js +9 -2
- package/dist/jsx/connectkit/defaultConfig.native.js.map +1 -1
- package/dist/jsx/connectkit/siwe/SIWEContext.mjs.map +1 -1
- package/dist/jsx/connectkit/siwe/SIWEContext.native.js.map +1 -1
- package/dist/jsx/connectkit/siwe/SIWEProvider.mjs +6 -4
- package/dist/jsx/connectkit/siwe/SIWEProvider.mjs.map +1 -1
- package/dist/jsx/connectkit/siwe/SIWEProvider.native.js +8 -4
- package/dist/jsx/connectkit/siwe/SIWEProvider.native.js.map +1 -1
- package/dist/jsx/connectkit/siwe/connectIntent.mjs +54 -16
- package/dist/jsx/connectkit/siwe/connectIntent.mjs.map +1 -1
- package/dist/jsx/connectkit/siwe/connectIntent.native.js +100 -16
- package/dist/jsx/connectkit/siwe/connectIntent.native.js.map +1 -1
- package/dist/jsx/connectkit/siwe/useSIWE.mjs.map +1 -1
- package/dist/jsx/connectkit/siwe/useSIWE.native.js.map +1 -1
- package/dist/jsx/connectkit/web3Bridge.mjs +61 -16
- package/dist/jsx/connectkit/web3Bridge.mjs.map +1 -1
- package/dist/jsx/connectkit/web3Bridge.native.js +64 -14
- package/dist/jsx/connectkit/web3Bridge.native.js.map +1 -1
- package/dist/jsx/core/family.mjs +79 -0
- package/dist/jsx/core/family.mjs.map +1 -0
- package/dist/jsx/core/family.native.js +132 -0
- package/dist/jsx/core/family.native.js.map +1 -0
- package/dist/jsx/core/index.mjs +9 -0
- package/dist/jsx/core/index.mjs.map +1 -0
- package/dist/jsx/core/index.native.js +53 -0
- package/dist/jsx/core/index.native.js.map +1 -0
- package/dist/jsx/core/lightDriver.mjs +157 -0
- package/dist/jsx/core/lightDriver.mjs.map +1 -0
- package/dist/jsx/core/lightDriver.native.js +260 -0
- package/dist/jsx/core/lightDriver.native.js.map +1 -0
- package/dist/jsx/core/message.mjs +63 -0
- package/dist/jsx/core/message.mjs.map +1 -0
- package/dist/jsx/core/message.native.js +104 -0
- package/dist/jsx/core/message.native.js.map +1 -0
- package/dist/jsx/core/names.mjs +25 -0
- package/dist/jsx/core/names.mjs.map +1 -0
- package/dist/jsx/core/names.native.js +95 -0
- package/dist/jsx/core/names.native.js.map +1 -0
- package/dist/jsx/core/react.mjs +30 -0
- package/dist/jsx/core/react.mjs.map +1 -0
- package/dist/jsx/core/react.native.js +67 -0
- package/dist/jsx/core/react.native.js.map +1 -0
- package/dist/jsx/core/signIn.mjs +173 -0
- package/dist/jsx/core/signIn.mjs.map +1 -0
- package/dist/jsx/core/signIn.native.js +240 -0
- package/dist/jsx/core/signIn.native.js.map +1 -0
- package/dist/jsx/core/store.mjs +469 -0
- package/dist/jsx/core/store.mjs.map +1 -0
- package/dist/jsx/core/store.native.js +684 -0
- package/dist/jsx/core/store.native.js.map +1 -0
- package/dist/jsx/core/types.mjs +2 -0
- package/dist/jsx/core/types.mjs.map +1 -0
- package/dist/jsx/core/types.native.js +21 -0
- package/dist/jsx/core/types.native.js.map +1 -0
- package/dist/jsx/families/btc.mjs +19 -0
- package/dist/jsx/families/btc.mjs.map +1 -0
- package/dist/jsx/families/btc.native.js +49 -0
- package/dist/jsx/families/btc.native.js.map +1 -0
- package/dist/jsx/families/eth.mjs +32 -0
- package/dist/jsx/families/eth.mjs.map +1 -0
- package/dist/jsx/families/eth.native.js +61 -0
- package/dist/jsx/families/eth.native.js.map +1 -0
- package/dist/jsx/families/gpg.mjs +15 -0
- package/dist/jsx/families/gpg.mjs.map +1 -0
- package/dist/jsx/families/gpg.native.js +43 -0
- package/dist/jsx/families/gpg.native.js.map +1 -0
- package/dist/jsx/families/host.mjs +12 -0
- package/dist/jsx/families/host.mjs.map +1 -0
- package/dist/jsx/families/host.native.js +41 -0
- package/dist/jsx/families/host.native.js.map +1 -0
- package/dist/jsx/families/index.mjs +23 -0
- package/dist/jsx/families/index.mjs.map +1 -0
- package/dist/jsx/families/index.native.js +56 -0
- package/dist/jsx/families/index.native.js.map +1 -0
- package/dist/jsx/families/messages.mjs +32 -0
- package/dist/jsx/families/messages.mjs.map +1 -0
- package/dist/jsx/families/messages.native.js +66 -0
- package/dist/jsx/families/messages.native.js.map +1 -0
- package/dist/jsx/families/sol.mjs +30 -0
- package/dist/jsx/families/sol.mjs.map +1 -0
- package/dist/jsx/families/sol.native.js +64 -0
- package/dist/jsx/families/sol.native.js.map +1 -0
- package/dist/jsx/families/sui.mjs +23 -0
- package/dist/jsx/families/sui.mjs.map +1 -0
- package/dist/jsx/families/sui.native.js +53 -0
- package/dist/jsx/families/sui.native.js.map +1 -0
- package/dist/jsx/index.js +7 -3
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +7 -3
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/index.native.js +22 -1
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/keycloak/keycloakWallet.mjs +13 -0
- package/dist/jsx/keycloak/keycloakWallet.mjs.map +1 -1
- package/dist/jsx/keycloak/keycloakWallet.native.js +15 -0
- package/dist/jsx/keycloak/keycloakWallet.native.js.map +1 -1
- package/dist/jsx/keycloak/useDirectLogin.mjs +10 -5
- package/dist/jsx/keycloak/useDirectLogin.mjs.map +1 -1
- package/dist/jsx/keycloak/useDirectLogin.native.js +12 -5
- package/dist/jsx/keycloak/useDirectLogin.native.js.map +1 -1
- package/dist/jsx/keycloak/useWalletLogin.mjs +16 -8
- package/dist/jsx/keycloak/useWalletLogin.mjs.map +1 -1
- package/dist/jsx/light/drivers.mjs +46 -0
- package/dist/jsx/light/drivers.mjs.map +1 -0
- package/dist/jsx/light/drivers.native.js +97 -0
- package/dist/jsx/light/drivers.native.js.map +1 -0
- package/dist/jsx/light/index.mjs +3 -0
- package/dist/jsx/light/index.mjs.map +1 -0
- package/dist/jsx/light/index.native.js +33 -0
- package/dist/jsx/light/index.native.js.map +1 -0
- package/dist/jsx/providers/WalletProvider.mjs +60 -19
- package/dist/jsx/providers/WalletProvider.mjs.map +1 -1
- package/dist/jsx/providers/WalletProvider.native.js +99 -56
- package/dist/jsx/providers/WalletProvider.native.js.map +1 -1
- package/dist/jsx/providers/families.mjs +27 -0
- package/dist/jsx/providers/families.mjs.map +1 -0
- package/dist/jsx/providers/families.native.js +59 -0
- package/dist/jsx/providers/families.native.js.map +1 -0
- package/dist/jsx/providers/index.mjs +2 -2
- package/dist/jsx/providers/index.mjs.map +1 -1
- package/dist/jsx/providers/index.native.js +1 -0
- package/dist/jsx/providers/index.native.js.map +1 -1
- package/dist/jsx/providers/walletConfig.mjs +40 -1
- package/dist/jsx/providers/walletConfig.mjs.map +1 -1
- package/dist/jsx/providers/walletConfig.native.js +68 -0
- package/dist/jsx/providers/walletConfig.native.js.map +1 -1
- package/dist/jsx/wagmi/driver.mjs +232 -0
- package/dist/jsx/wagmi/driver.mjs.map +1 -0
- package/dist/jsx/wagmi/driver.native.js +331 -0
- package/dist/jsx/wagmi/driver.native.js.map +1 -0
- package/dist/jsx/wagmi/host.mjs +213 -0
- package/dist/jsx/wagmi/host.mjs.map +1 -0
- package/dist/jsx/wagmi/host.native.js +320 -0
- package/dist/jsx/wagmi/host.native.js.map +1 -0
- package/dist/jsx/wagmi/index.mjs +3 -0
- package/dist/jsx/wagmi/index.mjs.map +1 -0
- package/dist/jsx/wagmi/index.native.js +31 -0
- package/dist/jsx/wagmi/index.native.js.map +1 -0
- package/dist/jsx/web.mjs +13 -0
- package/dist/jsx/web.mjs.map +1 -0
- package/dist/keycloak/login.iife.js +449 -443
- package/docs/bridge-protocol.md +41 -14
- package/package.json +13 -6
- package/src/bridge/base58.spec.ts +18 -0
- package/src/bridge/base58.ts +25 -0
- package/src/bridge/core.ts +2 -0
- package/src/bridge/drivers.spec.ts +283 -0
- package/src/bridge/drivers.ts +155 -0
- package/src/bridge/index.spec.ts +3 -0
- package/src/bridge/nativeHost.spec.ts +139 -15
- package/src/bridge/nativeHost.ts +84 -14
- package/src/bundler/metaMaskConnectTimeouts.spec.ts +3 -0
- package/src/clients/adapter.ts +5 -1
- package/src/clients/connector.ts +2 -0
- package/src/clients/evm.spec.ts +8 -0
- package/src/clients/evm.ts +3 -0
- package/src/clients/evmRead.spec.ts +180 -0
- package/src/clients/evmRead.ts +140 -0
- package/src/clients/hooks.spec.tsx +58 -0
- package/src/clients/hooks.ts +73 -14
- package/src/clients/index.ts +11 -1
- package/src/clients/types.ts +15 -1
- package/src/clients/useEvmReadClient.spec.tsx +93 -0
- package/src/connectkit/adapters/BitcoinAdapter.ts +64 -4
- package/src/connectkit/adapters/SolanaAdapter.ts +49 -0
- package/src/connectkit/adapters/SuiAdapter.ts +47 -1
- package/src/connectkit/connectors/ensureWalletConnectors.ts +10 -1
- package/src/connectkit/connectors/getWalletConnectors.ts +2 -0
- package/src/connectkit/connectors/syntheticChains.ts +8 -0
- package/src/connectkit/connectors/walletAdapterConnector.ts +2 -0
- package/src/connectkit/defaultConfig.ts +21 -7
- package/src/connectkit/siwe/SIWEContext.tsx +3 -0
- package/src/connectkit/siwe/SIWEProvider.spec.tsx +109 -0
- package/src/connectkit/siwe/SIWEProvider.tsx +16 -7
- package/src/connectkit/siwe/connectIntent.spec.ts +100 -30
- package/src/connectkit/siwe/connectIntent.ts +99 -25
- package/src/connectkit/siwe/useSIWE.ts +4 -1
- package/src/connectkit/web3Bridge.tsx +75 -15
- package/src/core/family.spec.ts +136 -0
- package/src/core/family.ts +146 -0
- package/src/core/imports.spec.ts +82 -0
- package/src/core/index.ts +70 -0
- package/src/core/lightDriver.spec.ts +284 -0
- package/src/core/lightDriver.ts +235 -0
- package/src/core/message.spec.ts +178 -0
- package/src/core/message.ts +119 -0
- package/src/core/names.ts +29 -0
- package/src/core/react.spec.tsx +75 -0
- package/src/core/react.ts +52 -0
- package/src/core/signIn.spec.tsx +305 -0
- package/src/core/signIn.ts +282 -0
- package/src/core/store.spec.ts +973 -0
- package/src/core/store.ts +609 -0
- package/src/core/types.ts +110 -0
- package/src/families/btc.ts +16 -0
- package/src/families/eth.ts +35 -0
- package/src/families/families.spec.ts +180 -0
- package/src/families/gpg.ts +13 -0
- package/src/families/host.ts +34 -0
- package/src/families/index.ts +32 -0
- package/src/families/messages.ts +39 -0
- package/src/families/sol.ts +25 -0
- package/src/families/sui.ts +17 -0
- package/src/index.ts +42 -1
- package/src/keycloak/KeycloakWalletLogin.spec.tsx +211 -4
- package/src/keycloak/keycloakWallet.spec.ts +81 -1
- package/src/keycloak/keycloakWallet.ts +24 -2
- package/src/keycloak/useDirectLogin.spec.tsx +77 -4
- package/src/keycloak/useDirectLogin.ts +23 -11
- package/src/keycloak/useWalletLogin.spec.tsx +52 -0
- package/src/keycloak/useWalletLogin.ts +24 -6
- package/src/light/drivers.spec.ts +330 -0
- package/src/light/drivers.ts +54 -0
- package/src/light/index.ts +1 -0
- package/src/light/native.spec.ts +22 -0
- package/src/providers/WalletProvider.native.spec.tsx +288 -0
- package/src/providers/WalletProvider.native.tsx +132 -59
- package/src/providers/WalletProvider.spec.tsx +521 -0
- package/src/providers/WalletProvider.tsx +90 -19
- package/src/providers/families.tsx +39 -0
- package/src/providers/index.ts +3 -0
- package/src/providers/walletConfig.spec.ts +19 -1
- package/src/providers/walletConfig.ts +80 -2
- package/src/wagmi/driver.spec.ts +407 -0
- package/src/wagmi/driver.ts +303 -0
- package/src/wagmi/host.spec.tsx +416 -0
- package/src/wagmi/host.tsx +260 -0
- package/src/wagmi/index.ts +1 -0
- package/src/web.spec.ts +58 -0
- package/src/web.ts +82 -0
- package/types/bridge/base58.d.ts +2 -0
- package/types/bridge/base58.d.ts.map +1 -0
- package/types/bridge/core.d.ts +2 -1
- package/types/bridge/core.d.ts.map +1 -1
- package/types/bridge/drivers.d.ts +24 -0
- package/types/bridge/drivers.d.ts.map +1 -0
- package/types/bridge/nativeHost.d.ts +34 -4
- package/types/bridge/nativeHost.d.ts.map +1 -1
- package/types/clients/adapter.d.ts +5 -1
- package/types/clients/adapter.d.ts.map +1 -1
- package/types/clients/connector.d.ts +2 -0
- package/types/clients/connector.d.ts.map +1 -1
- package/types/clients/evm.d.ts +2 -0
- package/types/clients/evm.d.ts.map +1 -1
- package/types/clients/evmRead.d.ts +54 -0
- package/types/clients/evmRead.d.ts.map +1 -0
- package/types/clients/hooks.d.ts +23 -3
- package/types/clients/hooks.d.ts.map +1 -1
- package/types/clients/index.d.ts +4 -2
- package/types/clients/index.d.ts.map +1 -1
- package/types/clients/types.d.ts +11 -1
- package/types/clients/types.d.ts.map +1 -1
- package/types/connectkit/adapters/BitcoinAdapter.d.ts +9 -0
- package/types/connectkit/adapters/BitcoinAdapter.d.ts.map +1 -1
- package/types/connectkit/adapters/SolanaAdapter.d.ts +12 -0
- package/types/connectkit/adapters/SolanaAdapter.d.ts.map +1 -1
- package/types/connectkit/adapters/SuiAdapter.d.ts +8 -0
- package/types/connectkit/adapters/SuiAdapter.d.ts.map +1 -1
- package/types/connectkit/connectors/ensureWalletConnectors.d.ts +3 -0
- package/types/connectkit/connectors/ensureWalletConnectors.d.ts.map +1 -1
- package/types/connectkit/connectors/getWalletConnectors.d.ts +2 -0
- package/types/connectkit/connectors/getWalletConnectors.d.ts.map +1 -1
- package/types/connectkit/connectors/syntheticChains.d.ts +8 -0
- package/types/connectkit/connectors/syntheticChains.d.ts.map +1 -1
- package/types/connectkit/connectors/walletAdapterConnector.d.ts +2 -0
- package/types/connectkit/connectors/walletAdapterConnector.d.ts.map +1 -1
- package/types/connectkit/defaultConfig.d.ts +2 -1
- package/types/connectkit/defaultConfig.d.ts.map +1 -1
- package/types/connectkit/siwe/SIWEContext.d.ts.map +1 -1
- package/types/connectkit/siwe/SIWEProvider.d.ts +6 -0
- package/types/connectkit/siwe/SIWEProvider.d.ts.map +1 -1
- package/types/connectkit/siwe/connectIntent.d.ts +16 -5
- package/types/connectkit/siwe/connectIntent.d.ts.map +1 -1
- package/types/connectkit/siwe/useSIWE.d.ts +4 -0
- package/types/connectkit/siwe/useSIWE.d.ts.map +1 -1
- package/types/connectkit/web3Bridge.d.ts +2 -0
- package/types/connectkit/web3Bridge.d.ts.map +1 -1
- package/types/core/family.d.ts +70 -0
- package/types/core/family.d.ts.map +1 -0
- package/types/core/index.d.ts +9 -0
- package/types/core/index.d.ts.map +1 -0
- package/types/core/lightDriver.d.ts +52 -0
- package/types/core/lightDriver.d.ts.map +1 -0
- package/types/core/message.d.ts +44 -0
- package/types/core/message.d.ts.map +1 -0
- package/types/core/names.d.ts +7 -0
- package/types/core/names.d.ts.map +1 -0
- package/types/core/react.d.ts +18 -0
- package/types/core/react.d.ts.map +1 -0
- package/types/core/signIn.d.ts +85 -0
- package/types/core/signIn.d.ts.map +1 -0
- package/types/core/store.d.ts +73 -0
- package/types/core/store.d.ts.map +1 -0
- package/types/core/types.d.ts +101 -0
- package/types/core/types.d.ts.map +1 -0
- package/types/families/btc.d.ts +4 -0
- package/types/families/btc.d.ts.map +1 -0
- package/types/families/eth.d.ts +13 -0
- package/types/families/eth.d.ts.map +1 -0
- package/types/families/gpg.d.ts +4 -0
- package/types/families/gpg.d.ts.map +1 -0
- package/types/families/host.d.ts +24 -0
- package/types/families/host.d.ts.map +1 -0
- package/types/families/index.d.ts +14 -0
- package/types/families/index.d.ts.map +1 -0
- package/types/families/messages.d.ts +7 -0
- package/types/families/messages.d.ts.map +1 -0
- package/types/families/sol.d.ts +9 -0
- package/types/families/sol.d.ts.map +1 -0
- package/types/families/sui.d.ts +4 -0
- package/types/families/sui.d.ts.map +1 -0
- package/types/index.d.ts +6 -2
- package/types/index.d.ts.map +1 -1
- package/types/keycloak/keycloakWallet.d.ts +15 -2
- package/types/keycloak/keycloakWallet.d.ts.map +1 -1
- package/types/keycloak/useDirectLogin.d.ts +11 -6
- package/types/keycloak/useDirectLogin.d.ts.map +1 -1
- package/types/keycloak/useWalletLogin.d.ts +8 -1
- package/types/keycloak/useWalletLogin.d.ts.map +1 -1
- package/types/light/drivers.d.ts +13 -0
- package/types/light/drivers.d.ts.map +1 -0
- package/types/light/index.d.ts +2 -0
- package/types/light/index.d.ts.map +1 -0
- package/types/providers/WalletProvider.d.ts +37 -6
- package/types/providers/WalletProvider.d.ts.map +1 -1
- package/types/providers/WalletProvider.native.d.ts +32 -3
- package/types/providers/WalletProvider.native.d.ts.map +1 -1
- package/types/providers/families.d.ts +12 -0
- package/types/providers/families.d.ts.map +1 -0
- package/types/providers/index.d.ts +1 -1
- package/types/providers/index.d.ts.map +1 -1
- package/types/providers/walletConfig.d.ts +32 -2
- package/types/providers/walletConfig.d.ts.map +1 -1
- package/types/wagmi/driver.d.ts +44 -0
- package/types/wagmi/driver.d.ts.map +1 -0
- package/types/wagmi/host.d.ts +31 -0
- package/types/wagmi/host.d.ts.map +1 -0
- package/types/wagmi/index.d.ts +2 -0
- package/types/wagmi/index.d.ts.map +1 -0
- package/types/web.d.ts +13 -0
- package/types/web.d.ts.map +1 -0
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
3
|
+
import { act, cleanup, render, waitFor } from "@testing-library/react";
|
|
4
|
+
import { connect, createConnector, disconnect } from "@wagmi/core";
|
|
5
|
+
import { StrictMode, type ReactNode } from "react";
|
|
6
|
+
import { getAddress, verifyMessage, type Hex } from "viem";
|
|
7
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
8
|
+
import { WagmiProvider, type Config } from "wagmi";
|
|
9
|
+
import { createWallets } from "../../tests/core/driverContract";
|
|
10
|
+
import { deferred, testDriver } from "../../tests/core/testDriver";
|
|
11
|
+
import { accountFor, keys, scriptedConnector, wagmiConfig } from "../../tests/core/wagmiWallets";
|
|
12
|
+
import { walletAdapterConnector } from "../connectkit/connectors/walletAdapterConnector";
|
|
13
|
+
import { defineWalletFamily } from "../core/family";
|
|
14
|
+
import { useConnection, useConnectionStore } from "../core/react";
|
|
15
|
+
import type { ConnectionStore } from "../core/store";
|
|
16
|
+
import type { ConnectionState } from "../core/types";
|
|
17
|
+
import { eth, gpg, sol } from "../families";
|
|
18
|
+
import { WagmiConnectionHost, hostFamiliesOnWagmi } from "./host";
|
|
19
|
+
|
|
20
|
+
const signers = Object.values(keys).map(accountFor);
|
|
21
|
+
const byAddress = Object.fromEntries(signers.map((signer) => [signer.address, signer]));
|
|
22
|
+
const [one, two, three] = signers as [
|
|
23
|
+
(typeof signers)[number],
|
|
24
|
+
(typeof signers)[number],
|
|
25
|
+
(typeof signers)[number],
|
|
26
|
+
];
|
|
27
|
+
const phantomAddress = "7EcDhSYGxXyscszYEp35KHN8vvw3svAuLKTzXwCFLtV";
|
|
28
|
+
|
|
29
|
+
function solanaAdapter() {
|
|
30
|
+
const adapter = {
|
|
31
|
+
chain: "solana",
|
|
32
|
+
address: null as string | null,
|
|
33
|
+
networkId: null,
|
|
34
|
+
isConnected: false,
|
|
35
|
+
connect: vi.fn(async () => {
|
|
36
|
+
adapter.address = phantomAddress;
|
|
37
|
+
adapter.isConnected = true;
|
|
38
|
+
}),
|
|
39
|
+
disconnect: vi.fn(async () => {
|
|
40
|
+
adapter.address = null;
|
|
41
|
+
adapter.isConnected = false;
|
|
42
|
+
}),
|
|
43
|
+
buildMessage: async () => "",
|
|
44
|
+
signMessage: vi.fn(async (message: string) => `signed:${message}`),
|
|
45
|
+
};
|
|
46
|
+
return adapter;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function setup() {
|
|
50
|
+
const wallets = createWallets({
|
|
51
|
+
"wallet.one": one.address,
|
|
52
|
+
"wallet.two": two.address,
|
|
53
|
+
"wallet.three": three.address,
|
|
54
|
+
});
|
|
55
|
+
const adapter = solanaAdapter();
|
|
56
|
+
const config = wagmiConfig([
|
|
57
|
+
scriptedConnector(wallets, "wallet.one", byAddress),
|
|
58
|
+
scriptedConnector(wallets, "wallet.two", byAddress),
|
|
59
|
+
walletAdapterConnector({
|
|
60
|
+
id: "wallet:solana:phantom",
|
|
61
|
+
name: "Phantom",
|
|
62
|
+
ecosystem: "solana",
|
|
63
|
+
adapter,
|
|
64
|
+
}) as ReturnType<typeof scriptedConnector>,
|
|
65
|
+
]);
|
|
66
|
+
const connector = (id: string) => config.connectors.find((entry) => entry.id === id)!;
|
|
67
|
+
return { wallets, adapter, config, connector };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Like setup(), but wallet.one's close hangs until `closeOne.resolve()`, as a relay wallet's can. */
|
|
71
|
+
function slowSetup() {
|
|
72
|
+
const wallets = createWallets({ "wallet.one": one.address, "wallet.two": two.address });
|
|
73
|
+
const adapter = solanaAdapter();
|
|
74
|
+
const closeOne = deferred<void>();
|
|
75
|
+
const inner = scriptedConnector(wallets, "wallet.one", byAddress);
|
|
76
|
+
const slowOne = createConnector((config) => {
|
|
77
|
+
const connector = inner(config as never);
|
|
78
|
+
return {
|
|
79
|
+
...connector,
|
|
80
|
+
async disconnect() {
|
|
81
|
+
await closeOne.promise;
|
|
82
|
+
await connector.disconnect();
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}) as ReturnType<typeof scriptedConnector>;
|
|
86
|
+
const config = wagmiConfig([
|
|
87
|
+
slowOne,
|
|
88
|
+
scriptedConnector(wallets, "wallet.two", byAddress),
|
|
89
|
+
walletAdapterConnector({
|
|
90
|
+
id: "wallet:solana:phantom",
|
|
91
|
+
name: "Phantom",
|
|
92
|
+
ecosystem: "solana",
|
|
93
|
+
adapter,
|
|
94
|
+
}) as ReturnType<typeof scriptedConnector>,
|
|
95
|
+
]);
|
|
96
|
+
const connector = (id: string) => config.connectors.find((entry) => entry.id === id)!;
|
|
97
|
+
const ids = () => [...config.state.connections.values()].map((entry) => entry.connector.id);
|
|
98
|
+
return { wallets, adapter, config, connector, closeOne, ids };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const pause = (ms: number) => act(() => new Promise<void>((resolve) => setTimeout(resolve, ms)));
|
|
102
|
+
|
|
103
|
+
type Live = { state?: ConnectionState; store?: ConnectionStore };
|
|
104
|
+
|
|
105
|
+
function Probe({ live }: { live: Live }) {
|
|
106
|
+
live.state = useConnection();
|
|
107
|
+
live.store = useConnectionStore();
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const queryClient = new QueryClient();
|
|
112
|
+
|
|
113
|
+
function Tree({ config, children }: { config: Config; children: ReactNode }) {
|
|
114
|
+
return (
|
|
115
|
+
<WagmiProvider config={config} reconnectOnMount={false}>
|
|
116
|
+
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
|
117
|
+
</WagmiProvider>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function mount(config: Config, families = [eth(), sol(), gpg()]) {
|
|
122
|
+
const live: Live = {};
|
|
123
|
+
render(
|
|
124
|
+
<Tree config={config}>
|
|
125
|
+
<WagmiConnectionHost families={families}>
|
|
126
|
+
<Probe live={live} />
|
|
127
|
+
</WagmiConnectionHost>
|
|
128
|
+
</Tree>,
|
|
129
|
+
);
|
|
130
|
+
return live;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
afterEach(() => {
|
|
134
|
+
cleanup();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
describe("hostFamiliesOnWagmi", () => {
|
|
138
|
+
it("puts the built-in families on the wagmi config and leaves the app's own and GPG alone", () => {
|
|
139
|
+
const { config } = setup();
|
|
140
|
+
const own = testDriver("gpg", [{ id: "own", name: "Own" }], {});
|
|
141
|
+
const custom = defineWalletFamily({
|
|
142
|
+
id: "cosmos",
|
|
143
|
+
label: "Cosmos",
|
|
144
|
+
message: { header: "wants you to sign in:", statement: null, chainId: null },
|
|
145
|
+
driver: () => own,
|
|
146
|
+
});
|
|
147
|
+
const hosted = hostFamiliesOnWagmi([eth(), sol(), custom, gpg()], config);
|
|
148
|
+
expect(hosted.map((family) => family.id)).toEqual(["eth", "sol", "cosmos", "gpg"]);
|
|
149
|
+
expect(
|
|
150
|
+
hosted[0]!.driver!()
|
|
151
|
+
.connectors()
|
|
152
|
+
.map((entry) => entry.id),
|
|
153
|
+
).toEqual(["wallet.one", "wallet.two"]);
|
|
154
|
+
expect(
|
|
155
|
+
hosted[1]!.driver!()
|
|
156
|
+
.connectors()
|
|
157
|
+
.map((entry) => entry.id),
|
|
158
|
+
).toEqual(["wallet:solana:phantom"]);
|
|
159
|
+
expect(hosted[2]).toBe(custom);
|
|
160
|
+
expect(hosted[3]!.connectionless).toBe(true);
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
describe("WagmiConnectionHost", () => {
|
|
165
|
+
it("takes the connection wagmi opens, with no second prompt, and signs through it", async () => {
|
|
166
|
+
const { wallets, config, connector } = setup();
|
|
167
|
+
const live = mount(config);
|
|
168
|
+
expect(live.state?.status).toBe("disconnected");
|
|
169
|
+
await act(() => connect(config, { connector: connector("wallet.one") }));
|
|
170
|
+
await waitFor(() =>
|
|
171
|
+
expect(live.state).toMatchObject({
|
|
172
|
+
status: "connected",
|
|
173
|
+
family: "eth",
|
|
174
|
+
connector: { id: "wallet.one" },
|
|
175
|
+
address: getAddress(one.address),
|
|
176
|
+
chainId: 1,
|
|
177
|
+
}),
|
|
178
|
+
);
|
|
179
|
+
expect(wallets.get("wallet.one").prompts).toBe(1);
|
|
180
|
+
await waitFor(() => expect(live.state?.client).not.toBeNull());
|
|
181
|
+
const signature = await live.state!.client!.signMessage("hello");
|
|
182
|
+
expect(
|
|
183
|
+
await verifyMessage({ address: one.address, message: "hello", signature: signature as Hex }),
|
|
184
|
+
).toBe(true);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it("follows a wallet from another family, closing the first connection", async () => {
|
|
188
|
+
const { wallets, adapter, config, connector } = setup();
|
|
189
|
+
const live = mount(config);
|
|
190
|
+
await act(() => connect(config, { connector: connector("wallet.one") }));
|
|
191
|
+
await waitFor(() => expect(live.state?.family).toBe("eth"));
|
|
192
|
+
await act(() => connect(config, { connector: connector("wallet:solana:phantom") }));
|
|
193
|
+
await waitFor(() =>
|
|
194
|
+
expect(live.state).toMatchObject({
|
|
195
|
+
status: "connected",
|
|
196
|
+
family: "sol",
|
|
197
|
+
connector: { id: "wallet:solana:phantom" },
|
|
198
|
+
address: phantomAddress,
|
|
199
|
+
chainId: "solana:mainnet",
|
|
200
|
+
}),
|
|
201
|
+
);
|
|
202
|
+
expect(adapter.connect).toHaveBeenCalledTimes(1);
|
|
203
|
+
expect([...config.state.connections.values()].map((entry) => entry.connector.id)).toEqual([
|
|
204
|
+
"wallet:solana:phantom",
|
|
205
|
+
]);
|
|
206
|
+
expect(wallets.get("wallet.one").open).toBe(false);
|
|
207
|
+
await waitFor(() => expect(live.state?.client).not.toBeNull());
|
|
208
|
+
expect(await live.state!.client!.signMessage("hi")).toBe("signed:hi");
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it("follows a switch between two wallets of one family without closing either", async () => {
|
|
212
|
+
const { wallets, config, connector } = setup();
|
|
213
|
+
const live = mount(config);
|
|
214
|
+
await act(() => connect(config, { connector: connector("wallet.one") }));
|
|
215
|
+
await waitFor(() => expect(live.state?.connector?.id).toBe("wallet.one"));
|
|
216
|
+
await act(() => connect(config, { connector: connector("wallet.two") }));
|
|
217
|
+
await waitFor(() =>
|
|
218
|
+
expect(live.state).toMatchObject({
|
|
219
|
+
family: "eth",
|
|
220
|
+
connector: { id: "wallet.two" },
|
|
221
|
+
address: getAddress(two.address),
|
|
222
|
+
}),
|
|
223
|
+
);
|
|
224
|
+
expect(config.state.connections.size).toBe(2);
|
|
225
|
+
expect(wallets.get("wallet.one").open).toBe(true);
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
it("clears when wagmi disconnects", async () => {
|
|
229
|
+
const { config, connector } = setup();
|
|
230
|
+
const live = mount(config);
|
|
231
|
+
await act(() => connect(config, { connector: connector("wallet.one") }));
|
|
232
|
+
await waitFor(() => expect(live.state?.status).toBe("connected"));
|
|
233
|
+
await act(() => disconnect(config));
|
|
234
|
+
await waitFor(() => expect(live.state?.status).toBe("disconnected"));
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
it("a connect through the store is wagmi's, so the modal sees it", async () => {
|
|
238
|
+
const { wallets, config, connector } = setup();
|
|
239
|
+
const live = mount(config);
|
|
240
|
+
await act(async () => {
|
|
241
|
+
await live.store!.connect("eth", "wallet.two");
|
|
242
|
+
});
|
|
243
|
+
expect(config.state.status).toBe("connected");
|
|
244
|
+
expect(config.state.current).toBe(connector("wallet.two").uid);
|
|
245
|
+
expect(live.state).toMatchObject({ family: "eth", connector: { id: "wallet.two" } });
|
|
246
|
+
expect(wallets.get("wallet.two").prompts).toBe(1);
|
|
247
|
+
await act(() => live.store!.disconnect());
|
|
248
|
+
expect(config.state.status).toBe("disconnected");
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
it("takes a connection wagmi already holds when it mounts", async () => {
|
|
252
|
+
const { config, connector } = setup();
|
|
253
|
+
await connect(config, { connector: connector("wallet.one") });
|
|
254
|
+
const live = mount(config);
|
|
255
|
+
await waitFor(() =>
|
|
256
|
+
expect(live.state).toMatchObject({ status: "connected", connector: { id: "wallet.one" } }),
|
|
257
|
+
);
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it("leaves a wallet of a family the app did not register alone", async () => {
|
|
261
|
+
const { config, connector } = setup();
|
|
262
|
+
const live = mount(config, [eth()]);
|
|
263
|
+
await act(() => connect(config, { connector: connector("wallet:solana:phantom") }));
|
|
264
|
+
await act(async () => {
|
|
265
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
266
|
+
});
|
|
267
|
+
expect(live.state?.status).toBe("disconnected");
|
|
268
|
+
expect(config.state.status).toBe("connected");
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
it("an inner host on the same config shares the outer store; one on another config has its own", async () => {
|
|
272
|
+
const { config } = setup();
|
|
273
|
+
const other = setup().config;
|
|
274
|
+
const outer: Live = {};
|
|
275
|
+
const same: Live = {};
|
|
276
|
+
const nested: Live = {};
|
|
277
|
+
render(
|
|
278
|
+
<Tree config={config}>
|
|
279
|
+
<WagmiConnectionHost>
|
|
280
|
+
<Probe live={outer} />
|
|
281
|
+
<WagmiConnectionHost>
|
|
282
|
+
<Probe live={same} />
|
|
283
|
+
</WagmiConnectionHost>
|
|
284
|
+
<Tree config={other}>
|
|
285
|
+
<WagmiConnectionHost>
|
|
286
|
+
<Probe live={nested} />
|
|
287
|
+
</WagmiConnectionHost>
|
|
288
|
+
</Tree>
|
|
289
|
+
</WagmiConnectionHost>
|
|
290
|
+
</Tree>,
|
|
291
|
+
);
|
|
292
|
+
expect(same.store).toBe(outer.store);
|
|
293
|
+
expect(nested.store).not.toBe(outer.store);
|
|
294
|
+
expect(outer.store?.registry.families.map((family) => family.id)).toEqual([
|
|
295
|
+
"eth",
|
|
296
|
+
"sol",
|
|
297
|
+
"sui",
|
|
298
|
+
"btc",
|
|
299
|
+
"gpg",
|
|
300
|
+
]);
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
it("survives StrictMode's unmount and remount with a live store", async () => {
|
|
304
|
+
const { config, connector } = setup();
|
|
305
|
+
const live: Live = {};
|
|
306
|
+
render(
|
|
307
|
+
<StrictMode>
|
|
308
|
+
<Tree config={config}>
|
|
309
|
+
<WagmiConnectionHost>
|
|
310
|
+
<Probe live={live} />
|
|
311
|
+
</WagmiConnectionHost>
|
|
312
|
+
</Tree>
|
|
313
|
+
</StrictMode>,
|
|
314
|
+
);
|
|
315
|
+
await act(() => connect(config, { connector: connector("wallet.one") }));
|
|
316
|
+
await waitFor(() =>
|
|
317
|
+
expect(live.state).toMatchObject({ status: "connected", connector: { id: "wallet.one" } }),
|
|
318
|
+
);
|
|
319
|
+
await act(() => live.store!.disconnect());
|
|
320
|
+
expect(live.state?.status).toBe("disconnected");
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
it("leaves wagmi's connection open when the store cannot take it", async () => {
|
|
324
|
+
const { wallets, config } = setup();
|
|
325
|
+
const live = mount(config);
|
|
326
|
+
// wagmi's connect({ connector: injected() }) form: a connector the config does not list.
|
|
327
|
+
await act(() =>
|
|
328
|
+
connect(config, { connector: scriptedConnector(wallets, "wallet.three", byAddress) }),
|
|
329
|
+
);
|
|
330
|
+
await act(() => new Promise((resolve) => setTimeout(resolve, 50)));
|
|
331
|
+
|
|
332
|
+
expect(live.state?.status).toBe("disconnected");
|
|
333
|
+
expect(config.state.status).toBe("connected");
|
|
334
|
+
expect(wallets.get("wallet.three").open).toBe(true);
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
it("closes a wallet the modal opened while the store's own connect was on its way", async () => {
|
|
338
|
+
const { wallets, adapter, config, connector } = setup();
|
|
339
|
+
const live = mount(config);
|
|
340
|
+
const gate = wallets.hold("wallet.two");
|
|
341
|
+
let storeConnect!: Promise<unknown>;
|
|
342
|
+
act(() => {
|
|
343
|
+
storeConnect = live.store!.connect("eth", "wallet.two");
|
|
344
|
+
});
|
|
345
|
+
await act(() => new Promise((resolve) => setTimeout(resolve, 10)));
|
|
346
|
+
await act(() => connect(config, { connector: connector("wallet:solana:phantom") }));
|
|
347
|
+
gate.approve();
|
|
348
|
+
await act(async () => {
|
|
349
|
+
await storeConnect;
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
await waitFor(() => expect(adapter.isConnected).toBe(false));
|
|
353
|
+
expect(live.state).toMatchObject({ status: "connected", family: "eth" });
|
|
354
|
+
await act(() => live.store!.disconnect());
|
|
355
|
+
await act(() => new Promise((resolve) => setTimeout(resolve, 50)));
|
|
356
|
+
expect(live.state?.status).toBe("disconnected");
|
|
357
|
+
expect(config.state.status).toBe("disconnected");
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
it("lets go of such a wallet at once, however long its close takes", async () => {
|
|
361
|
+
const { adapter, config, connector, closeOne, ids } = slowSetup();
|
|
362
|
+
const live = mount(config);
|
|
363
|
+
const prompt = deferred<void>();
|
|
364
|
+
const connectPhantom = adapter.connect.getMockImplementation()!;
|
|
365
|
+
adapter.connect.mockImplementationOnce(async () => {
|
|
366
|
+
await prompt.promise;
|
|
367
|
+
await connectPhantom();
|
|
368
|
+
});
|
|
369
|
+
let storeConnect!: Promise<unknown>;
|
|
370
|
+
act(() => {
|
|
371
|
+
storeConnect = live.store!.connect("sol", "wallet:solana:phantom");
|
|
372
|
+
});
|
|
373
|
+
await pause(10);
|
|
374
|
+
await act(() => connect(config, { connector: connector("wallet.one") }));
|
|
375
|
+
prompt.resolve();
|
|
376
|
+
await act(async () => {
|
|
377
|
+
await storeConnect;
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
await waitFor(() => expect(ids()).toEqual(["wallet:solana:phantom"]));
|
|
381
|
+
expect(live.state).toMatchObject({ status: "connected", family: "sol" });
|
|
382
|
+
|
|
383
|
+
await act(() => live.store!.disconnect());
|
|
384
|
+
await pause(30);
|
|
385
|
+
closeOne.resolve();
|
|
386
|
+
await pause(50);
|
|
387
|
+
expect(live.state?.status).toBe("disconnected");
|
|
388
|
+
expect(ids()).toEqual([]);
|
|
389
|
+
expect(adapter.isConnected).toBe(false);
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
it("a wallet picked while a handover waits on a slow close takes over, and the older one goes", async () => {
|
|
393
|
+
const { wallets, adapter, config, connector, closeOne, ids } = slowSetup();
|
|
394
|
+
const live = mount(config);
|
|
395
|
+
await act(() => connect(config, { connector: connector("wallet.one") }));
|
|
396
|
+
await waitFor(() =>
|
|
397
|
+
expect(live.state).toMatchObject({ status: "connected", connector: { id: "wallet.one" } }),
|
|
398
|
+
);
|
|
399
|
+
|
|
400
|
+
// Phantom from the modal: the handover waits on wallet.one's close.
|
|
401
|
+
await act(() => connect(config, { connector: connector("wallet:solana:phantom") }));
|
|
402
|
+
await pause(10);
|
|
403
|
+
expect(live.state?.status).toBe("connecting");
|
|
404
|
+
// wallet.two from the modal while it waits: the user's latest pick.
|
|
405
|
+
await act(() => connect(config, { connector: connector("wallet.two") }));
|
|
406
|
+
closeOne.resolve();
|
|
407
|
+
|
|
408
|
+
await waitFor(() =>
|
|
409
|
+
expect(live.state).toMatchObject({ status: "connected", connector: { id: "wallet.two" } }),
|
|
410
|
+
);
|
|
411
|
+
await waitFor(() => expect(adapter.isConnected).toBe(false));
|
|
412
|
+
expect(ids()).toEqual(["wallet.two"]);
|
|
413
|
+
expect(wallets.get("wallet.two").open).toBe(true);
|
|
414
|
+
expect(wallets.get("wallet.one").open).toBe(false);
|
|
415
|
+
});
|
|
416
|
+
});
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import type { Connector } from "@wagmi/core";
|
|
2
|
+
import { createContext, useContext, useEffect, useState, type ReactNode } from "react";
|
|
3
|
+
import { type Config, useConfig } from "wagmi";
|
|
4
|
+
import { connectorAdapter } from "../clients/adapter";
|
|
5
|
+
import { clientForConnector } from "../clients/connector";
|
|
6
|
+
import { defineWalletFamily, type WalletFamily } from "../core/family";
|
|
7
|
+
import { ConnectionProvider, useOptionalConnectionStore } from "../core/react";
|
|
8
|
+
import { createConnectionStore, type ConnectionStore } from "../core/store";
|
|
9
|
+
import type { ConnectionDriver } from "../core/types";
|
|
10
|
+
import { walletFamilies } from "../families";
|
|
11
|
+
import { wagmiHosting, type HostedEcosystem } from "../families/host";
|
|
12
|
+
import { wagmiDriver } from "./driver";
|
|
13
|
+
|
|
14
|
+
const ecosystemOf = (connector: Connector): HostedEcosystem =>
|
|
15
|
+
connectorAdapter(connector) === null
|
|
16
|
+
? "evm"
|
|
17
|
+
: (connector as unknown as { ecosystem: HostedEcosystem }).ecosystem;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Puts the built-in families on one wagmi config: eth over its EVM
|
|
21
|
+
* connectors, sol, sui and btc over the Solana, Sui and Bitcoin shims the
|
|
22
|
+
* config lists, each reporting its own chain id and signing through its
|
|
23
|
+
* shim's adapter. GPG and a family of the app's own keep what they have.
|
|
24
|
+
* While the ConnectKit modal connects every wallet through wagmi, this makes
|
|
25
|
+
* the connection store and the modal see one connection (MPO-385 step 5).
|
|
26
|
+
*/
|
|
27
|
+
export function hostFamiliesOnWagmi(
|
|
28
|
+
families: readonly WalletFamily[],
|
|
29
|
+
config: Config,
|
|
30
|
+
): WalletFamily[] {
|
|
31
|
+
return families.map((family) => {
|
|
32
|
+
const hosting = wagmiHosting(family);
|
|
33
|
+
if (!hosting) return family;
|
|
34
|
+
const { ecosystem, chainId, solanaChain } = hosting;
|
|
35
|
+
if (ecosystem === "evm")
|
|
36
|
+
return defineWalletFamily({ ...family, driver: () => wagmiDriver(config) });
|
|
37
|
+
return defineWalletFamily({
|
|
38
|
+
...family,
|
|
39
|
+
driver: () =>
|
|
40
|
+
wagmiDriver(config, {
|
|
41
|
+
filter: (connector) => connectorAdapter(connector, ecosystem) !== null,
|
|
42
|
+
...(chainId === undefined ? {} : { chainId }),
|
|
43
|
+
client: (connector) => clientForConnector(connector, solanaChain ? { solanaChain } : {}),
|
|
44
|
+
}),
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const HostedConfig = createContext<Config | null>(null);
|
|
50
|
+
const destroyed = new WeakSet<ConnectionStore>();
|
|
51
|
+
|
|
52
|
+
interface Owned {
|
|
53
|
+
readonly config: Config;
|
|
54
|
+
readonly families: readonly WalletFamily[];
|
|
55
|
+
readonly store: ConnectionStore;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function own(config: Config, families: readonly WalletFamily[]): Owned {
|
|
59
|
+
// wagmi remembers and restores the connection, so the store keeps nothing.
|
|
60
|
+
const store = createConnectionStore({
|
|
61
|
+
families: hostFamiliesOnWagmi(families, config),
|
|
62
|
+
storage: null,
|
|
63
|
+
});
|
|
64
|
+
return { config, families, store };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* One store per config and families, destroyed on unmount. StrictMode's
|
|
69
|
+
* rehearsal unmount destroys the first, so the remount builds another.
|
|
70
|
+
*/
|
|
71
|
+
function useOwnedStore(config: Config, families: readonly WalletFamily[]): ConnectionStore {
|
|
72
|
+
const [owned, setOwned] = useState(() => own(config, families));
|
|
73
|
+
let current = owned;
|
|
74
|
+
if (owned.config !== config || owned.families !== families) {
|
|
75
|
+
current = own(config, families);
|
|
76
|
+
setOwned(current);
|
|
77
|
+
}
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (destroyed.has(current.store)) {
|
|
80
|
+
setOwned(own(current.config, current.families));
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
return () => {
|
|
84
|
+
destroyed.add(current.store);
|
|
85
|
+
current.store.destroy();
|
|
86
|
+
};
|
|
87
|
+
}, [current]);
|
|
88
|
+
return current.store;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Hands the store every connection wagmi opens outside it: the ConnectKit
|
|
93
|
+
* modal's, a wagmi hook's, wagmi's own restore on load. Only a wallet of
|
|
94
|
+
* another family is taken over, which closes the family that was active; the
|
|
95
|
+
* active family's own driver follows a switch between its wallets. A wallet
|
|
96
|
+
* the store just let go of is not taken back while wagmi is still closing it,
|
|
97
|
+
* and a handover the wallet refuses is not asked again until wagmi's
|
|
98
|
+
* connection changes. A wallet wagmi opens while a handover waits is the
|
|
99
|
+
* user's later pick and takes over from it.
|
|
100
|
+
*/
|
|
101
|
+
function useWagmiHandover(
|
|
102
|
+
config: Config,
|
|
103
|
+
store: ConnectionStore,
|
|
104
|
+
families: readonly WalletFamily[],
|
|
105
|
+
) {
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
const hosted = new Map<HostedEcosystem, string>();
|
|
108
|
+
for (const family of families) {
|
|
109
|
+
const hosting = wagmiHosting(family);
|
|
110
|
+
if (hosting && !hosted.has(hosting.ecosystem)) hosted.set(hosting.ecosystem, family.id);
|
|
111
|
+
}
|
|
112
|
+
const held = () => {
|
|
113
|
+
const { status, family, connector } = store.getState();
|
|
114
|
+
return status === "connected" && family && connector ? `${family}\n${connector.id}` : null;
|
|
115
|
+
};
|
|
116
|
+
let holding = held();
|
|
117
|
+
let released: string | null = null;
|
|
118
|
+
let pending: string | null = null;
|
|
119
|
+
// What the pending handover asked the store for, and the connections wagmi
|
|
120
|
+
// held when it asked: one wagmi opens after that is newer.
|
|
121
|
+
let asked: { family: string; connectorId: string; known: Set<string> } | null = null;
|
|
122
|
+
let refused: string | null = null;
|
|
123
|
+
const check = () => {
|
|
124
|
+
const { current, connections, status } = config.state;
|
|
125
|
+
const connection = status === "connected" && current ? connections.get(current) : undefined;
|
|
126
|
+
const address = connection?.accounts[0];
|
|
127
|
+
const family = connection && hosted.get(ecosystemOf(connection.connector));
|
|
128
|
+
const wallet = connection && family ? `${family}\n${connection.connector.id}` : null;
|
|
129
|
+
if (wallet !== released) released = null;
|
|
130
|
+
if (!connection || !address) refused = null;
|
|
131
|
+
if (!connection || !address || !family || wallet === released) return;
|
|
132
|
+
const state = store.getState();
|
|
133
|
+
if (state.status === "connecting" || state.status === "reconnecting") {
|
|
134
|
+
const waiting =
|
|
135
|
+
asked !== null &&
|
|
136
|
+
state.family === asked.family &&
|
|
137
|
+
state.connector?.id === asked.connectorId;
|
|
138
|
+
if (!waiting || asked!.known.has(connection.connector.uid)) return;
|
|
139
|
+
} else if (state.status === "connected" && state.family === family) return;
|
|
140
|
+
const key = `${wallet}\n${connection.connector.uid}\n${address}`;
|
|
141
|
+
if (key === pending || key === refused) return;
|
|
142
|
+
pending = key;
|
|
143
|
+
asked = {
|
|
144
|
+
family,
|
|
145
|
+
connectorId: connection.connector.id,
|
|
146
|
+
known: new Set(connections.keys()),
|
|
147
|
+
};
|
|
148
|
+
store.connect(family, connection.connector.id, { silent: true }).then(
|
|
149
|
+
() => {
|
|
150
|
+
if (pending !== key) return;
|
|
151
|
+
pending = null;
|
|
152
|
+
asked = null;
|
|
153
|
+
},
|
|
154
|
+
() => {
|
|
155
|
+
refused = key;
|
|
156
|
+
if (pending !== key) return;
|
|
157
|
+
pending = null;
|
|
158
|
+
asked = null;
|
|
159
|
+
},
|
|
160
|
+
);
|
|
161
|
+
};
|
|
162
|
+
// A wallet of another family that wagmi still holds once the store's own
|
|
163
|
+
// connect lands, such as one the modal opened while that connect was on
|
|
164
|
+
// its way: one connection at a time, so it goes. It closes the way the
|
|
165
|
+
// driver closes, out of wagmi's state first, since wagmi's own disconnect
|
|
166
|
+
// action keeps a wallet whose close hangs and later writes back
|
|
167
|
+
// connections that closed meanwhile.
|
|
168
|
+
const closers = new Map<HostedEcosystem, ConnectionDriver>();
|
|
169
|
+
const closerFor = (ecosystem: HostedEcosystem) => {
|
|
170
|
+
let closer = closers.get(ecosystem);
|
|
171
|
+
if (!closer) {
|
|
172
|
+
closer = wagmiDriver(config, {
|
|
173
|
+
filter: (connector) => ecosystemOf(connector) === ecosystem,
|
|
174
|
+
});
|
|
175
|
+
closers.set(ecosystem, closer);
|
|
176
|
+
}
|
|
177
|
+
return closer;
|
|
178
|
+
};
|
|
179
|
+
const closeLeftovers = () => {
|
|
180
|
+
const { status, family } = store.getState();
|
|
181
|
+
if (status !== "connected" || !family) return;
|
|
182
|
+
const others = new Set<HostedEcosystem>();
|
|
183
|
+
for (const connection of config.state.connections.values()) {
|
|
184
|
+
const ecosystem = ecosystemOf(connection.connector);
|
|
185
|
+
const other = hosted.get(ecosystem);
|
|
186
|
+
if (other && other !== family) others.add(ecosystem);
|
|
187
|
+
}
|
|
188
|
+
for (const ecosystem of others) {
|
|
189
|
+
void closerFor(ecosystem)
|
|
190
|
+
.disconnect()
|
|
191
|
+
.catch(() => undefined);
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
const onStore = () => {
|
|
195
|
+
const now = held();
|
|
196
|
+
if (holding !== null && now !== holding) released = holding;
|
|
197
|
+
if (now !== null && now !== holding) closeLeftovers();
|
|
198
|
+
holding = now;
|
|
199
|
+
check();
|
|
200
|
+
};
|
|
201
|
+
check();
|
|
202
|
+
const stopConfig = config.subscribe((state) => state, check);
|
|
203
|
+
const stopStore = store.subscribe(onStore);
|
|
204
|
+
return () => {
|
|
205
|
+
stopConfig();
|
|
206
|
+
stopStore();
|
|
207
|
+
};
|
|
208
|
+
}, [config, store, families]);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function OwnedHost({
|
|
212
|
+
config,
|
|
213
|
+
families,
|
|
214
|
+
children,
|
|
215
|
+
}: {
|
|
216
|
+
config: Config;
|
|
217
|
+
families: readonly WalletFamily[];
|
|
218
|
+
children?: ReactNode;
|
|
219
|
+
}) {
|
|
220
|
+
const store = useOwnedStore(config, families);
|
|
221
|
+
useWagmiHandover(config, store, families);
|
|
222
|
+
return (
|
|
223
|
+
<HostedConfig.Provider value={config}>
|
|
224
|
+
<ConnectionProvider store={store}>{children}</ConnectionProvider>
|
|
225
|
+
</HostedConfig.Provider>
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export interface WagmiConnectionHostProps {
|
|
230
|
+
/**
|
|
231
|
+
* The families to register, in the connect list's order. Kept by identity:
|
|
232
|
+
* pass a stable array. Left out, the host reuses the store of a host above
|
|
233
|
+
* on the same wagmi config, or any ConnectionProvider the app mounted, and
|
|
234
|
+
* otherwise registers every built-in family.
|
|
235
|
+
*/
|
|
236
|
+
families?: readonly WalletFamily[];
|
|
237
|
+
children?: ReactNode;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Mounts a connection store over the WagmiProvider above it, so
|
|
242
|
+
* `useConnection()` reports what the ConnectKit modal and wagmi's hooks
|
|
243
|
+
* connect, and `useConnectionStore().connect()` goes through wagmi where the
|
|
244
|
+
* modal sees it. Web3Provider mounts one; so does ConnectKitProvider when no
|
|
245
|
+
* store is above it.
|
|
246
|
+
*/
|
|
247
|
+
export function WagmiConnectionHost({ families, children }: WagmiConnectionHostProps) {
|
|
248
|
+
const config = useConfig();
|
|
249
|
+
const hostedConfig = useContext(HostedConfig);
|
|
250
|
+
const above = useOptionalConnectionStore();
|
|
251
|
+
const [implicit] = useState(walletFamilies);
|
|
252
|
+
if (families === undefined && (hostedConfig === config || (hostedConfig === null && above))) {
|
|
253
|
+
return <>{children}</>;
|
|
254
|
+
}
|
|
255
|
+
return (
|
|
256
|
+
<OwnedHost config={config} families={families ?? implicit}>
|
|
257
|
+
{children}
|
|
258
|
+
</OwnedHost>
|
|
259
|
+
);
|
|
260
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { wagmiDriver, type WagmiDriverOptions } from "./driver";
|