Skip to content

Commit

Permalink
readmes
Browse files Browse the repository at this point in the history
  • Loading branch information
YaroShkvorets committed Nov 20, 2024
1 parent daf15a2 commit eafb6b7
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 17 deletions.
21 changes: 20 additions & 1 deletion packages/golang/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Documentation available [here](https://pkg.go.dev/github.com/pinax-network/graph
$ go get github.com/pinax-network/graph-networks-libs/packages/golang@latest
```

### Fetching the latest registry
```go
package main
import (
Expand All @@ -21,7 +22,7 @@ import (
)

func main() {
// Fetch the latest compatible version of the registry
// Fetch the latest compatible version of the registry from registry.thegraph.com
reg, err := registry.FromLatestVersion()
if err != nil {
log.Fatalf("Failed to fetch registry: %v", err)
Expand All @@ -36,6 +37,24 @@ func main() {
}
```

### Fetching from a local file
```go
package main
import (
"fmt"
"log"
registry "github.com/pinax-network/graph-networks-libs/packages/golang/lib"
)

func main() {
reg, err := registry.FromFile("TheGraphNetworksRegistry_v0_6_0.json")
if err != nil {
log.Fatalf("Failed to load registry: %v", err)
}
fmt.Printf("Successfully loaded %d networks\n", len(reg.Networks))
}
```

## API Reference

See reference on [pkg.go.dev](https://pkg.go.dev/github.com/pinax-network/graph-networks-libs/packages/golang/lib)
Expand Down
4 changes: 2 additions & 2 deletions packages/rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn main() {

### Fetching the latest registry

To fetch the latest registry version from the official source
To fetch the latest compatible registry version from registry.thegraph.com


```rust
Expand All @@ -59,5 +59,5 @@ If you don't need to fetch the registry from the network, you can turn off the `

```toml
[dependencies]
graph-networks-registry = { version = "0.6.0", default-features = false }
graph-networks-registry = { version = "0.6.1", default-features = false }
```
28 changes: 14 additions & 14 deletions packages/typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,27 @@ Documentation available [here](https://pinax-network.github.io/graph-networks-li
npm install @pinax/graph-networks-registry
```

## Features

- Type-safe interfaces for The Graph Networks Registry
- Helper methods to load registry data from various sources
- Network lookup by ID and alias

## Usage

### Loading the Registry

```typescript
import { NetworksRegistry } from '@pinax/graph-networks-registry';
// Load from latest version. Always compatible. Make sure you update the package to get the latest data.

// Load from the latest compatible registry JSON at registry.thegraph.com
const registry = await NetworksRegistry.fromLatestVersion();
// Load from specific version. Might throw if schema is not compatible.

// Load from specific version tag at registry.thegraph.com
const registry = await NetworksRegistry.fromExactVersion('0.6.0');
// Load from URL. Might throw if schema is not compatible.
const registry = await NetworksRegistry.fromExactVersion('0.6.x');

// Load from URL
const registry = await NetworksRegistry.fromUrl('https://registry.thegraph.com/TheGraphNetworksRegistry.json');
// Load from local file. Might throw if file is not found or schema is not compatible.

// Load from local file
const registry = NetworksRegistry.fromFile('./TheGraphNetworksRegistry.json');
// Load from JSON string. Might throw if schema is not compatible.

// Load from JSON string
const registry = NetworksRegistry.fromJson(jsonString);
```

Expand All @@ -46,8 +46,8 @@ if (mainnet) {
console.log(mainnet.caip2Id); // "eip155:1"
}
// Find network by alias
const ethereum = registry.getNetworkByAlias('eth');
if (ethereum) {
console.log(ethereum.fullName); // "Ethereum Mainnet"
const mainnet = registry.getNetworkByAlias('eth');
if (mainnet) {
console.log(mainnet.fullName); // "Ethereum Mainnet"
}
```

0 comments on commit eafb6b7

Please sign in to comment.