Code Monkey home page Code Monkey logo

fcl-discovery's Introduction

Discovery

When building an dapp on Flow using @onflow/fcl, Discovery eliminates the need for dapp developers to write code to integrate their user's preferred wallet into their application. Instead, @onflow/fcl and this repo uses a secure discovery protocol that wallets can implement to connect to @onflow/fcl. The end result is dapps using @onflow/fcl automatically integrate all compatible wallets without their developers needing to write any custom code!

To read more about consuming/using this repo via FCL, visit the Discovery docs.

Getting Started

First, run the development server:

npm run dev
# or
yarn dev

Then add Discovery to your FCL app:

import * as fcl from "@onflow/fcl"

fcl.config({
  "discovery.wallet": "https://fcl-discovery.onflow.org/testnet/authn",
  "discovery.authn.endpoint": "https://fcl-discovery.onflow.org/api/testnet/authn"
})

Networks

Discovery UI URLs

Environment Example
Mainnet http://localhost:3002/authn or http://localhost:3002/mainnet/authn
Testnet http://localhost:3002/testnet/authn
Previewnet http://localhost:3002/previewnet/authn
Local http://localhost:3002/local/authn
Emulator http://localhost:3002/emulator/authn

Discovery API Endpoints

Environment Example
Mainnet http://localhost:3002/api/authn or http://localhost:3002/api/mainnet/authn
Testnet http://localhost:3002/api/testnet/authn
Previewnet http://localhost:3002/api/previewnet/authn
Local http://localhost:3002/api/local/authn
Emulator http://localhost:3002/api/emulator/authn

Note: Local and emulator will return Dev Wallet as a service for developing locally with the default port of 8701. If you'd like to override the default port add ?port=0000 with the port being whatever you'd like to override it to.

More Configuration

For more configuration options, please see the documentation.

Adding a Wallet to Discovery

Flow compatible wallets wanting to add their wallets to Discovery can do so by creating a PR with the following:

  • Add your wallet's service information to the services data file
  • Please provide any metadata related to your service if required (see metadata docs)
  • Provide a demo of your wallet that can be tested and is connected to Testnet
  • Specify if your wallet is opt-in or not. Opt-in wallets are those that don't have support for authentication, authorization, and user signature services.

Before adding your wallet to Discovery, ensure your wallet meets the minimum acceptance criteria.

For more information/examples on how to build a Flow compatible wallet, check out the following links:

Documentation

To learn more about the repo, take a look at the following resources:

  • Discovery - Documentation for using Discovery with FCL.
  • FCL - Learn more about Flow's FCL
  • Next.js Documentation - This app is built with Next. Learn about Next.js features and API.

fcl-discovery's People

Contributors

andrew54068 avatar boczeratul avatar bthaile avatar chasefleming avatar cybercent avatar gregsantos avatar gyorgy-kurucz-vacuum avatar jacksonconrad avatar jeffreydoyle avatar jey-t avatar jribbink avatar justinbarry avatar lmcmz avatar nialexsan avatar nickdapper avatar orodio avatar psiemens avatar refi93 avatar zzggo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fcl-discovery's Issues

Get extensions from new client config

Starting in FCL 1.0, extensions will now come from client config. See this PR

  • Grab extensions from client config
  • Support existing way of grabbing extensions for apps using an older version

Create emulator environment returning dev wallet

Problem

When developing locally with emulator and using the Discovery API, you cannot test the UI you are building around authentication because you need to point directly at the dev wallet running in the emulator instead of services returned from testnet and mainnet.

Proposed Solution

Create an endpoint for emulator and return "Dev Wallet" as a service if emulator services are requested. This service's endpoint will point to the dev wallet localhost url running in the emulator.

https://fcl-discovery.onflow.org/local/authn
https://fcl-discovery.onflow.org/api/local/authn

There should also be a way to override the port if dev wallet is running on a different port than that setup by the emulator. To do this, let's add a query param to the url for port:

https://fcl-discovery.onflow.org/local/authn?port=8702
https://fcl-discovery.onflow.org/api/local/authn?port=8702

Setup CI for repo

Setup CI for repo

  • Add Github actions
  • Run tests on pull request
  • Run build on pull request

UI updates to fit more services

There are now a lot services that are listed in Discovery and more are coming. There is currently a scroll for the iFrame/rpc, but we need a more versatile and better looking solution across other methods like pop/rpc and tab/rpc for when a large number of services are listed. We need a UI update to address this.

This also needs to address the issue of layout for when a service may have multiple sub-services (e.g. WalletConnect has different pairings for each wallet).

Add WC support for native dapps

In order to support the following view:
image.png

We need to collect wallet information from available Flow wallets native to iOS and Android. They should provide the same information as they do on WC such as universal, deep links, etc. and we can serve this via the API.

The API should filter based on user-agent such that a native dapp can show just Flow WC wallets and nothing else OR if they don't have WC configured, the safari browser can be used instead.

Google Analytics Support

In order to track analytics of who is using FCL-Discovery, and which applications they're using it with, we should enable Google Analytics support.

We should track:

  • Who is using FCL-Discover through enabling Google Analytics.
  • Which applications they're using FCL-Discovery, if possible.

Create more informational home page if pointing incorrectly

Issue

If an app points directly to the root of Discovery they may be confused that it's not working. It's not clear that they are pointing to the wrong path.

Suggested Solution

Add route options for iFrame and put more information on the page.

Show WC Pairings

Show active pairings via a label like 'installed' and sort to the top if paired for any WC wallet.

Installed extensions (not for development) return in local mode

Problem

We need installed extensions to show in any environment because you may have an extension not listed in Discovery services you want to use, you are developing with a wallet that has a network switcher, or you are developing a wallet locally you want to test. If you have say an extension that supports testnet and mainnet in your browser, but does not work with emulator it will still show in Discovery because you have chosen as a user to install it. This is confusing to people who may not know this or have forgotten extensions they have and see them listed when running locally but they don't work.

Make Limited Functionality Wallets Opt-In

Issue To Be Solved

Not all wallets support all functionality an app needs. For a better user experience, apps need the ability to only list wallets as options if they have the said support. This way a user doesn't wind up using a wallet with limited functionality only to find out later they can't complete actions in the application.

Suggest A Solution

Add a property to services called optIn. This means that when a wallet with limited functionality registers their service they should mark it as an opt-in wallet. We will not return opt-in wallets by default, but if an app wants to show a specific wallet they can explicitly say so in their FCL config by specifying the service account address:

import { config } from "@onflow/fcl"

config({
  "accessNode.api": "https://access-testnet.onflow.org",
  "discovery.authn.endpoint": "https://fcl-discovery.onflow.org/api/testnet/authn",
  "discovery.authn.optIn": ["0x123"]
})

FCL then turns that filter into a query param for the API which we can then filter on. We need to create the filtering functionality from those query params.

Show Uninstalled Extensions

Right now an extension has to be installed to show in Discovery. Let's:

  • Show extensions if listed in services
  • Make sure not to show two (installed and uninstalled from list)
  • Open install link if not installed
  • Mark service card as not installed if not
  • Detect platform and only show extensions for correct platform
  • Handle both UI and API side

Fix Discovery version check

Discovery is checking for version in config, except that's only available on the next release.

Solution:

  • Implement old version check from fclVersion if it doesn't exist on config.client
  • Change header check to use appVersion

Rethink service and metadata files

Wallets who add themselves to Discovery may also eventually be discoverable through different plugins. We currently filter out duplicates since we needed a way to handle an extension being sent from FCL and an extension having added themselves to show as uninstalled. Service and metadata fields are also starting to become bloated since install links are required for different platforms. It's time to rethink how this is structured.

Add event tracking

  • Track how many API requests are being made
  • Differentiate between UI vs API requests
  • Differentiate between networks

Visibility of registered plugin services

If a plugin service has added itself to Discovery, show the service rather than the plugin method. This would work similar to extensions in that any extension will work with Discovery, but if an extension has added itself to the service list then we can show the uninstalled extension as an option as well.

Allowed Extensions List

Issue To Be Solved

Currently, anyone can inject an extension wit FCL and have it show in Discovery. We want to only show wallets that have been merged into the Discovery services list to show in Discovery.

Suggest A Solution

After getting the extensions from FCL, filter out any extensions that are listed with platform: "web/extension" unless that service object is included in the Discovery service list.

Improve the default Wallet Discovery UI

Problem:
The current design of the discovery page is not very appealing to developers and often doesn't fit well design-wise into dapps. We should also take advantage of local storage to offer a more appealing user experience, especially for new users to crypto who may not understand what a wallet is.

Solution:
I mocked up a design that aims to do the following:

  • Follow similar patterns to existing wallet selection UI on other dapps and chains
  • Utilize some basic local storage features to surface the most recently used wallet first
  • Indicate installed extensions and put them at top of the list of selections if installed
  • Design generically and with a minimized color palette to fit a broader range of dapp designs
  • Offer visual cues and help to the user to understand wallets and which wallets are being offered
  • Provide user the information about the dapp that is trying to connect in a visual way
  • Have it be flexible to fit only 2 wallets but also work well when it could expand to 5+ on both desktop and mobile
  • Offer reasonable defaults for missing configurations from the dapp (ie. image, name)

Note:

  • The following page on the docs site will need to be updated so that the "What is a wallet" can be accurately linked.

Figma Files - In page "Final UI"

image

Add information on how to add a wallet to Discovery

Documentation required on how to add a new wallet to be included in Discovery.

Should note to:

  • Make a PR into the services.json list
  • Provide a correct Flow account address in the provider information (used as a unique identifier)
  • Provide a live link connected to testnet to test out

Support new plugins services

Like with other Discovery features, we need to know at which version FCL will begin sending plugin services. We need to:

  • Create a supported version for plugin services
  • Handle new plugin services in the pipeline
  • Keep backwards compatibility

Testing for version checks

The app changes based on FCL version and configuration. Need to figure out a more thorough test plan around changing configuration and version.

Support explicit mainnet path in routes and APIs

Currently, routes look like this:

Discovery Routes

Environment Example
Mainnet http://localhost:3002/authn
Testnet http://localhost:3002/testnet/authn
Local http://localhost:3002/local/authn

Discovery API Endpoints

Environment Example
Mainnet http://localhost:3002/api/authn
Testnet http://localhost:3002/api/testnet/authn
Local http://localhost:3002/api/local/authn

TODO

Add mainnet an explicit mainnet path for both API and UI to support if it is specified.

  • http://localhost:3002/mainnet/authn
  • http://localhost:3002/api/mainnet/authn

Add supported strategies filter for services

Only display (UI) and return (API) services with methods matching client supported strategies

  • These are now sent from client as part of config client.config.supportedStrategies

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.