From 3c903e4ae7cb106f176f79164fa47037e92e7e99 Mon Sep 17 00:00:00 2001 From: Alfreedom <00tango.bromine@icloud.com> Date: Tue, 5 Nov 2024 11:27:09 +0100 Subject: [PATCH] Non EVM support --- docs/appkit/flutter/core/custom-chains.mdx | 94 +++++++++++++++------- docs/appkit/flutter/core/events.mdx | 6 ++ docs/appkit/flutter/core/installation.mdx | 7 +- docs/appkit/flutter/core/link-mode.mdx | 6 ++ docs/appkit/flutter/core/options.mdx | 20 +++-- docs/appkit/flutter/core/siwe.mdx | 7 +- docs/appkit/flutter/core/usage.mdx | 18 ++++- 7 files changed, 117 insertions(+), 41 deletions(-) diff --git a/docs/appkit/flutter/core/custom-chains.mdx b/docs/appkit/flutter/core/custom-chains.mdx index 023f704b..71b40b01 100644 --- a/docs/appkit/flutter/core/custom-chains.mdx +++ b/docs/appkit/flutter/core/custom-chains.mdx @@ -2,46 +2,80 @@ ## Custom Networks addition and selection -AppKit already comes with a list of supported networks inside of `ReownAppKitModalNetworks` class. You can get default supported EVM networks by selecting `ReownAppKitModalNetworks.supported['eip155']` and, currently, only EVM Networks are supported (non-EVM support will come soon). Check the list of [supported networks](https://github.com/walletconnect/blockchain-api/blob/master/SUPPORTED_CHAINS.md#list-of-supported-chains) +AppKit already comes with a list of supported mainnets (including Solana mainnet) and testnets (including Solana testnet) inside of `ReownAppKitModalNetworks` class. This means that if you are looking to support EVM chains + Solana then there's nothing more you should tweak. -This class also comes with extra networks `ReownAppKitModalNetworks.extra['eip155']` and test networks `ReownAppKitModalNetworks.test['eip155']`, however, these are not included in the supported list by default. - -If these chains are not enough for you or you don't want to support some of them you can modify the list associated to the namespace. - -:::info note -It is important that this is done before AppKitModal configuration. -::: - -### Adding extra and/or test networks to the supported list +However, this class can be modified in order to achieve the following results, and more: ```javascript -// Adding extra networks -final extraNetworks = ReownAppKitModalNetworks.extra['eip155'] ?? []; -ReownAppKitModalNetworks.addNetworks('eip155', extraNetworks); - -// Adding test networks -final testNetworks = ReownAppKitModalNetworks.test['eip155'] ?? []; -ReownAppKitModalNetworks.addNetworks('eip155', testNetworks); +// You can add more EVM networks +List extraChains = [...]; +ReownAppKitModalNetworks.addSupportedNetworks('eip155', extraChains); ``` -### Removing Aurora network from the list +_Note: If you are adding a test network, set `isTestNetwork` property of `ReownAppKitModalNetworkInfo` to `true`_ ```javascript -ReownAppKitModalNetworks.removeNetworks('eip155', ['1313161554']); +// Remove Solana networks (supports only EVM networks): +ReownAppKitModalNetworks.removeSupportedNetworks('solana'); ``` -### Adding a custom network +```javascript +// Remove every test network +ReownAppKitModalNetworks.removeTestNetworks(); +``` ```javascript -final customNetwork = ReownAppKitModalNetworkInfo( - name: 'Ethereum', - chainId: '1', - currency: 'ETH', - rpcUrl: 'https://ethereum-rpc.publicnode.com', - explorerUrl: 'https://etherscan.io', - isTestNetwork: false, -); - -ReownAppKitModalNetworks.addNetworks('eip155', [customNetwork]); +// Add more non-EVM networls, such as Polkadot +ReownAppKitModalNetworks.addSupportedNetworks('polkadot', [ + ReownAppKitModalNetworkInfo( + name: 'Polkadot', + chainId: '91b171bb158e2d3848fa23a9f1c25182', + chainIcon: 'https://cryptologos.cc/logos/polkadot-new-dot-logo.png', + currency: 'DOT', + rpcUrl: 'https://rpc.polkadot.io', + explorerUrl: 'https://polkadot.subscan.io', + ), + ReownAppKitModalNetworkInfo( + name: 'Westend', + chainId: 'e143f23803ac50e8f6f8e62695d1ce9e', + currency: 'DOT', + rpcUrl: 'https://westend-rpc.polkadot.io', + explorerUrl: 'https://westend.subscan.io', + isTestNetwork: true, + ), +]); ``` +As said before, if you plan to support just EVM and Solana networks you should already have everything in place, out of the box, inside AppKit configuration. However, if you are looking to support more non-EVM networks, such as Polkadot, then further configuration must be done: + +Example: If you want to support EVM + Solana + Polkadot then, along with the networks list modification, you should also pass the the following `optionalNamespaces:` in AppKit instance: + +```javascript +optionalNamespaces: { + 'eip155': RequiredNamespace.fromJson({ + 'chains': ReownAppKitModalNetworks.getAllSupportedNetworks( + namespace: 'eip155', + ).map((chain) => 'eip155:${chain.chainId}').toList(), + 'methods': NetworkUtils.defaultNetworkMethods['eip155']!.toList(), + 'events': NetworkUtils.defaultNetworkEvents['eip155']!.toList(), + }), + 'solana': RequiredNamespace.fromJson({ + 'chains': ReownAppKitModalNetworks.getAllSupportedNetworks( + namespace: 'solana', + ).map((chain) => 'solana:${chain.chainId}').toList(), + 'methods': NetworkUtils.defaultNetworkMethods['solana']!.toList(), + 'events': [], + }), + 'polkadot': RequiredNamespace.fromJson({ + 'chains': [ + 'polkadot:91b171bb158e2d3848fa23a9f1c25182', + 'polkadot:e143f23803ac50e8f6f8e62695d1ce9e' + ], + 'methods': [ + 'polkadot_signMessage', + 'polkadot_signTransaction', + ], + 'events': [] + }), +}, +``` \ No newline at end of file diff --git a/docs/appkit/flutter/core/events.mdx b/docs/appkit/flutter/core/events.mdx index 3a6f5eee..0cf25f8b 100644 --- a/docs/appkit/flutter/core/events.mdx +++ b/docs/appkit/flutter/core/events.mdx @@ -16,6 +16,12 @@ _appKitModal.onModalDisconnect.subscribe((ModalDisconnect? event) {}); _appKitModal.onModalError.subscribe((ModalError? event) {}); ``` +------ + +:::info +The follwing events are available only through WalletConnect protocol, meaning that they won't be throwing events when connected to Coinbase Wallet nor Email or Social Login. +::: + #### Session specific events ```javascript diff --git a/docs/appkit/flutter/core/installation.mdx b/docs/appkit/flutter/core/installation.mdx index 8c68cdae..04261164 100644 --- a/docs/appkit/flutter/core/installation.mdx +++ b/docs/appkit/flutter/core/installation.mdx @@ -85,9 +85,14 @@ Example: ### Enable Coinbase Wallet -Since Coinbase Wallet uses its own SDK, there are a few extra but simply steps to do if you are planning to include and support it. +:::info note +Coinbase Wallet does not use the WalletConnect protocol for communication between the dApp and the wallet. This means that pairing topic, session topic, and other session data are not used when connected to Coinbase Wallet.\n +However, you can still enable it to seamlessly connect with your dApp with these additional but simple steps. +::: +On your iOS and Android native side make the following changes: + com.example.yourBundleId CFBundleURLSchemes - + + + exampleapp @@ -127,7 +137,9 @@ But in order for the redirect mechanism to work you would also need to add the f - + + + ```