Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(data-access): thegraph-data-access package #931

Merged
merged 13 commits into from
Oct 6, 2022

Conversation

benjlevesque
Copy link
Contributor

@benjlevesque benjlevesque commented Oct 5, 2022

Description

Introduce a new package to easily re-use thegraph data access.
Move non-graph logic to their relevant places

Usage

Full

import { RequestNetworkBase } from '@requestnetwork/request-client.js';
import { TheGraphDataAccess } from '@requestnetwork/thegraph-data-access';
import { Wallet } from 'ethers';
import { IpfsStorage, EthereumStorageEthers } from '@requestnetwork/ethereum-storage';

const signer = Wallet.createRandom();
const storage = new EthereumStorageEthers({
  ipfsStorage: new IpfsStorage({}),
  signer,
  network: 'private',
});
const dataAccess = new TheGraphDataAccess({
  graphql: { url: 'http://localhost:8000/subgraphs/name/RequestNetwork/request-storage' },
  network: 'private',
  storage,
});
const rn = new RequestNetworkBase({ dataAccess });

const { requestId } = await rn.createRequest(...)

const request = await rn.fromRequestId(requestId);

await request.accept(...)

Read only

import { RequestNetworkBase } from '@requestnetwork/request-client.js';
import { TheGraphDataAccess } from '@requestnetwork/thegraph-data-access';
import { Wallet } from 'ethers';

const dataAccess = new TheGraphDataAccess({
  graphql: { url: 'http://localhost:8000/subgraphs/name/RequestNetwork/request-storage' },
  network: 'private',
});
const rn = new RequestNetworkBase({ dataAccess });

// Cannot create request
// await rn.createRequest()

const request = await rn.fromRequestId('...');
console.log(request.requestId);

// Cannot modify request
// await request.accept(...)

@benjlevesque benjlevesque changed the base branch from master to refactor/payment-network-factory October 5, 2022 17:19
@benjlevesque benjlevesque changed the title refactor/storage/the graph data access refactor(storage): the graph data access Oct 5, 2022
@coveralls
Copy link

coveralls commented Oct 5, 2022

Coverage Status

Coverage increased (+1.04%) to 89.295% when pulling 5886f41 on refactor/storage/the-graph-data-access into 400b0d5 on master.

@benjlevesque benjlevesque marked this pull request as ready for review October 5, 2022 18:41
@benjlevesque benjlevesque changed the title refactor(storage): the graph data access refactor(data-access): thegraph-data-access package Oct 5, 2022
packages/request-node/src/thegraph-node.ts Show resolved Hide resolved
packages/thegraph-data-access/.nycrc Show resolved Hide resolved
}

/** Interface of the storage */
export interface IStorage extends IStorageRead, IStorageWrite {
Copy link
Member

Choose a reason for hiding this comment

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

💅

@benjlevesque benjlevesque force-pushed the refactor/payment-network-factory branch from 772e5de to fd82335 Compare October 6, 2022 15:23
@benjlevesque benjlevesque force-pushed the refactor/storage/the-graph-data-access branch from ec51d27 to 30896bc Compare October 6, 2022 15:24
Base automatically changed from refactor/payment-network-factory to master October 6, 2022 17:25
@benjlevesque benjlevesque force-pushed the refactor/storage/the-graph-data-access branch from 30896bc to 5886f41 Compare October 6, 2022 17:26
@benjlevesque benjlevesque enabled auto-merge (squash) October 6, 2022 17:27
@benjlevesque benjlevesque merged commit cd4f55d into master Oct 6, 2022
@benjlevesque benjlevesque deleted the refactor/storage/the-graph-data-access branch October 6, 2022 17:34
Copy link
Member

@alexandre-abrioux alexandre-abrioux left a comment

Choose a reason for hiding this comment

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

Nice 😀

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.

5 participants