# snowcone-subgraph

> ## Overview

Latest version **0.1.0** (published 2023-07-10) · UNLICENSED license · 0 weekly downloads

## Install

```sh
npm install snowcone-subgraph
pnpm add snowcone-subgraph
yarn add snowcone-subgraph
bun add snowcone-subgraph
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2023-07-10 |
| First published | 2023-07-10 |
| Weekly downloads | 0 |
| License | UNLICENSED |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 447.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | sirbenchalot |

## Links

- npm: https://www.npmjs.com/package/snowcone-subgraph
- npm.io page: https://npm.io/package/snowcone-subgraph

## Dependencies (4)

- [mustache](https://npm.io/package/mustache.md) ^4.0.1
- [@snowcone/contracts](https://npm.io/package/@snowcone/contracts.md) npm:@snowcone/contracts@9.0.7
- [@graphprotocol/graph-ts](https://npm.io/package/@graphprotocol/graph-ts.md) ^0.27.0
- [@graphprotocol/graph-cli](https://npm.io/package/@graphprotocol/graph-cli.md) ^0.33.0

## Recent versions

- 0.1.0 (latest) — 2023-07-10

## README

# SnowCone Subgraph

## Overview

Multiple subgraphs are maintained by [Peel](https://discord.gg/b4rpjgGPHX) in a Graph Studio owned by the [Peel Gnosis safe](https://gnosis-safe.io/app/eth:0x0e9D15e28e3De9bB3CF64FFbC2f2F49Da9Ac545B).

SnowCone mainnet subgraph is published here: https://thegraph.com/explorer/subgraph?id=FVmuv3TndQDNd2BWARV8Y27yuKKukryKXPzvAS5E7htC&view=Overview

Contract addresses and startBlocks are defined in `config/<network>.json`

Subgraph data sources (contract definitions and event handlers) are defined in `subgraph.template.yaml`

_`subgraph.yaml` is gitignored and should not be edited._

## Getting started

```bash
yarn install

yarn global add @graphprotocol/graph-cli
```

## Config

`config/*.json` files define addresses and start blocks for contracts on specific networks. Usually, a contract's start block should be the block where that contract was deployed.

## Generating subgraph.yaml

Subgraphs are defined by a `subgraph.yaml` file, which is generated from `*.template.yaml` files. To make it easier to support multiple contract versions, there is a template file for each version as well as "shared".

Running `yarn prep <network>` will run `scripts/prepare.js` to construct a `subgraph.yaml` file for that network, using yaml template files and the contracts defined in `config/<network>.json`.

The `prepare.js` script also performs a safety check for mismatches between the generated `subgraph.yaml` and the mapping files. Warnings will be shown if:

- a function is referenced in the `subgraph.yaml` that isn't defined in any mapping files
- a function defined in a mapping file isn't referenced in the `subgraph.yaml`

## Deploying

To deploy a new subgraph version, first prepare the subgraph for the intended network:

```bash
#network must match manifest format https://thegraph.com/docs/en/developing/supported-networks/  e.g. arbitrum-goerli
yarn prep <network-name> # mainnet, goerli
```

- Generates TS types for the schema defined in `schema.graphql`
- Compiles new gitignored `subgraph.yaml`

First you will need to authenticate with the proper deploy key for the given network (you'll only need to do this once).

```bash
graph auth --studio ${your-key}
```

Once authenticated:

```bash
graph deploy --studio <subgraph-name>
```

> Note: previous subgraph versions will be automatically archived when new versions are deployed, and must be manually unarchived if needed.

To check health of a deployed subgraph:

```
curl -X POST -d '{ "query": "{indexingStatuses(subgraphs: [\"<deployment-id>\"]) {synced health fatalError {message block { number } handler } subgraph chains { chainHeadBlock { number } latestBlock { number }}}}"}' https://api.thegraph.com/index-node/graphql
```

---
_Source: https://npm.io/package/snowcone-subgraph · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
