Skip to content

Commit

Permalink
add getter to all chain data
Browse files Browse the repository at this point in the history
  • Loading branch information
clbrge committed Nov 11, 2021
1 parent 719b07d commit 9ef5f9d
Show file tree
Hide file tree
Showing 4 changed files with 300 additions and 12 deletions.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions examples/svelte-app-template-web3/src/MonoChain.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script>
import { makeChainStore, defaultChainStore, web3, connected, selectedAccount, chainId, chainData } from '../../../dist/index.js'
//import { defaultChainStore, web3, selectedAccount, connected, chainId, chainData } from 'svelte-web3'
//import { allChainsData makeChainStore, defaultChainStore, web3, connected, selectedAccount, chainId, chainData } from '../../../dist/index.js'
import { allChainsData, makeChainStore, defaultChainStore, web3, selectedAccount, connected, chainId, chainData } from 'svelte-web3'
export let name
Expand Down
Loading

0 comments on commit 9ef5f9d

Please sign in to comment.