update README file.

This commit is contained in:
ssallam 2020-12-09 15:03:40 +01:00
parent 0c4c3a5f2a
commit 61238ab624
3 changed files with 57 additions and 13 deletions

View File

@ -1,7 +1,13 @@
# Ocean Protocol Subgraph # Ocean Protocol Subgraph
## Running locally ## Running locally
* Install the Graph: `https://thegraph.com/docs/quick-start`
* Install Graph CLI globally with npm
```bash
npm install -g @graphprotocol/graph-cli
```
* Install/run the Graph: `https://thegraph.com/docs/quick-start`
* You can skip running ganache-cli and connect directly to `mainnet` using Infura * You can skip running ganache-cli and connect directly to `mainnet` using Infura
```bash ```bash
@ -14,9 +20,24 @@ docker-compose up
``` ```
* Install Graph CLI globally with npm Note: making contract calls using Infura fails with `missing trie node` errors.
```bash The fix requires editing `ethereum_adapter.rs` line 434 to use the latest block
npm install -g @graphprotocol/graph-cli instead of a specific block number.
Replace:
`web3.eth().call(req, Some(block_id)).then(|result| {`
with `web3.eth().call(req, Some(BlockNumber::Latest.into())).then(|result| {`
To run the graph-node with this fix it must be run from source.
First, delete the `graph-node` container from the `docker-compose.yml` file
then run `docker-compose up` to get the postgresql and ipfs services running.
Now you can build and run the graph-node from source
```
cargo run -p graph-node --release > graphnode.log --
--postgres-url postgres://graph-node:let-me-in@localhost:5432/graph-node
--ethereum-rpc mainnet:https://mainnet.infura.io/v3/INFURA_PROJECT_ID
--ipfs 127.0.0.1:5001
``` ```
* Once the graph node is ready, do the following to deploy the ocean-subgraph to the local graph-node * Once the graph node is ready, do the following to deploy the ocean-subgraph to the local graph-node
@ -29,3 +50,12 @@ npm run create:local
npm run deploy:local npm run deploy:local
``` ```
* You can edit the event handler code and then run `npm run deploy:local`
* Running deploy will fail if the code has no changes
* Sometimes deploy will fail no matter what, in this case:
* Stop the docker-compose run (`docker-compose down`)
* Delete the `ipfs` and `postgres` folders in `graph-node/docker/data`
* Restart docker-compose
* Run `npm run create:local` to create the ocean-subgraph
* Run `npm run deploy:local` to deploy the ocean-subgraph

View File

@ -1,16 +1,13 @@
import { Address, BigInt, BigDecimal } from '@graphprotocol/graph-ts' import { BigInt, BigDecimal } from '@graphprotocol/graph-ts'
import { BPoolRegistered } from '../types/Factory/Factory' import { BPoolRegistered } from '../types/Factory/Factory'
import { PoolFactory, Pool } from '../types/schema' import { PoolFactory, Pool } from '../types/schema'
import { Pool as PoolContract } from '../types/templates' import { Pool as PoolContract } from '../types/templates'
import { import { ZERO_BD } from './helpers'
ZERO_BD,
} from './helpers'
import { log } from '@graphprotocol/graph-ts' import { log } from '@graphprotocol/graph-ts'
export function handleNewPool(event: BPoolRegistered): void { export function handleNewPool(event: BPoolRegistered): void {
let factory = PoolFactory.load('1') let factory = PoolFactory.load('1')
// if no factory yet, set up blank initial
if (factory == null) { if (factory == null) {
factory = new PoolFactory('1') factory = new PoolFactory('1')
factory.totalLiquidity = ZERO_BD factory.totalLiquidity = ZERO_BD
@ -22,7 +19,7 @@ export function handleNewPool(event: BPoolRegistered): void {
} }
let pool = new Pool(event.params.bpoolAddress.toHexString()) let pool = new Pool(event.params.bpoolAddress.toHexString())
log.error('************************ handleNewPool: poolId {}', [pool.id.toString()]) log.info('************************ handleNewPool: poolId {}', [pool.id.toString()])
pool.factoryID = event.address.toHexString() pool.factoryID = event.address.toHexString()
pool.controller = event.params.registeredBy pool.controller = event.params.registeredBy

View File

@ -1,6 +1,23 @@
{ {
"extends": "./node_modules/@graphprotocol/graph-ts/tsconfig.json", "extends": "./node_modules/@graphprotocol/graph-ts/tsconfig.json",
"compilerOptions": { "compilerOptions": {
"types": ["@graphprotocol/graph-ts"] "types": ["@graphprotocol/graph-ts"],
} "resolveJsonModule": true,
"moduleResolution": "node",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"lib": ["es5", "dom"],
"declaration": true,
"module": "commonjs",
"target": "es5",
"removeComments": true,
"experimentalDecorators": true,
"preserveConstEnums": true,
"outDir": "./dist/node/",
"rootDir": "./src/",
"sourceMap": true,
"typeRoots": ["node_modules/@types"]
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/*.test.ts"]
} }