Skip to main content

Architecture

Preparations

In order to start indexing all whitelisted Flow contracts we need a genesis event. With Sablier Flow, there is no factory pattern so we couldn't rely on a data source contract. The next best things for a "genesis" point was to rely on the first event triggered by the earliest registered onchain contract

To reduce the number of dependencies required to kickstart a subgraph, we chose to rely on this approach instead of implementing a separate registry contract. You should extend the file described here with the following

packages/constants/.../sepolia.ts
...
export let startBlock_flow = 6618000;

/** Rule: keep addresses lowercased */

/**
* Keep aliases unique and always in sync with the frontend
* @example export let linear = [[address1, alias1, version1], [address2, alias2, version2]]
*/

...

export let flow: string[][] = [
["0x83dd52fca44e069020b58155b761a590f12b59d3", "FL", "V10"],
];

/**
* The initializer contract is used to trigger the indexing of all other contracts.
* It should be a linear contract, the oldest/first one deployed on this chain.
* ↪ 🚨 On any new chain, please create a Flow stream to kick-off the indexing flow
*/

export let initializer_flow = flow[0][0];

Configurations

Using this data, we'll call the yarn deploy:<chain_name> script. In turn it will:

  1. [Chain] Lock onto a specified chain
  2. [Setup] Clean artifacts and older files
  3. [Template] Convert TS files into JS for mustache to use in the next step
  4. [Template] Use mustache to create a specific subgraph.yaml (from subgraph.template.yaml) using the selected chain's details
  5. [Template] Duplicate the selected chain's configuration file as the "current" env.ts (for possible imports directly in Assembly Script)
  6. [Codegen] Run codegen using the files prepared above, as well as the handlers implementation
  7. [Deploy] Deploy the code to the endpoint selected based on the specified chain