Skip to content

Conversation

tmigone
Copy link
Member

@tmigone tmigone commented Jul 19, 2022

Motivation

This PR refactors the Graph Runtime Environment extension on hardhat. Currently most functionality is not using GRE and is instead using loadEnv which is a similar concept but inherited from the CLI.

In the future we should think about supporting a single environment for our tooling (CLI vs hardhat), the changes proposed to GRE here assume that future is built using hardhat tooling. New features should use GRE and hardhat environment, and we should aim towards slowly integrating the CLI functionality.

Changes

GRE now exposes and instanced address book, graph config and contracts:

// Use env vars to determine addressBook (ADDRESS_BOOK) and graphConfig (GRAPH_CONFIG) files 
const { addressBook, contracts, graphConfig } = hre.graph()

const graphTokenEntry = addressBook.getEntry("GraphToken")
console.log(`GraphToken address: ${graphTokenEntry.address}`)

const GraphToken = contracts.GraphToken
const totalSupply = await GraphToken.totalSupply()
console.log(`GRT totalSupply is ${totalSupply}`)

You can also specify paths to the graph config and address book files:

// Use custom addressBook and graphConfig files
const { addressBook, graphConfig } = hre.graph({
  addressBook: args.addressBook,
  graphConfig: args.graphConfig,
})

Signed-off-by: Tomás Migone tomas@edgeandnode.com

@tmigone tmigone requested a review from abarmat July 19, 2022 13:16
@codecov
Copy link

codecov bot commented Jul 19, 2022

Codecov Report

Merging #636 (4acc4b1) into dev (bcb9876) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##              dev     #636   +/-   ##
=======================================
  Coverage   90.29%   90.29%           
=======================================
  Files          35       35           
  Lines        1752     1752           
  Branches      293      293           
=======================================
  Hits         1582     1582           
  Misses        170      170           
Flag Coverage Δ
unittests 90.29% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bcb9876...4acc4b1. Read the comment docs.

@tmigone tmigone marked this pull request as draft July 19, 2022 14:00
abarmat
abarmat previously approved these changes Jul 19, 2022
Copy link
Contributor

@abarmat abarmat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good refactor

tmigone added 3 commits July 19, 2022 17:45
Signed-off-by: Tomás Migone <tomas@edgeandnode.com>
Signed-off-by: Tomás Migone <tomas@edgeandnode.com>
Signed-off-by: Tomás Migone <tomas@edgeandnode.com>
@tmigone tmigone force-pushed the tmigone/gre-update branch from ec8022a to 1d8faf6 Compare July 19, 2022 15:46
@tmigone tmigone marked this pull request as ready for review July 19, 2022 15:47
@tmigone tmigone requested a review from abarmat July 19, 2022 15:47
Signed-off-by: Tomás Migone <tomas@edgeandnode.com>
Copy link
Contributor

@abarmat abarmat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥇

@tmigone tmigone merged commit b44769d into dev Jul 21, 2022
@tmigone tmigone deleted the tmigone/gre-update branch July 21, 2022 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants