From 9ef5f9d6cac8064631dde37e2c0ae16c13fa9903 Mon Sep 17 00:00:00 2001 From: Christophe Le Bars Date: Thu, 11 Nov 2021 12:02:38 -0500 Subject: [PATCH] add getter to all chain data --- README.md | 21 +- .../src/MonoChain.svelte | 4 +- src/chains.js | 285 +++++++++++++++++- src/web3-store.js | 2 + 4 files changed, 300 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 9427931..c0a23b6 100644 --- a/README.md +++ b/README.md @@ -112,8 +112,15 @@ stores. `chainData` is a store returning the current JavaScript [CAIP-2 representation](https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-2.md) object. +### Example -### Example of information available (vary depending on the chain) +The information returned by the `chainData` store depends (like all +other web3 stores) on which chain the current provider is +connected. If the store has not yet been connected (with `setProvider` +or `setBrowserProvider`), the store value will be `undefined`. + +Below is the CAIP-2 formatted information when the default store is +connected with the Ethereum Mainnet : ```json { @@ -144,6 +151,18 @@ stores. } ``` + +You might want to access all chains CAIP-2 data directly without using the +`chainData` store. In this case, use the getter `allChainsData`, it returns +the list of all CAIP-2 data available. + +```js +import { allChainsData } from 'svelte-web3' + +console.log( allChainsData ) +``` + + ## Create contract stores The function `makeContractStore` allows you to create a Svelte derived diff --git a/examples/svelte-app-template-web3/src/MonoChain.svelte b/examples/svelte-app-template-web3/src/MonoChain.svelte index eb4a65f..ccbcc4e 100644 --- a/examples/svelte-app-template-web3/src/MonoChain.svelte +++ b/examples/svelte-app-template-web3/src/MonoChain.svelte @@ -1,6 +1,6 @@