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

support custom score api url as function param (and removed unused provider param) #403

Merged
merged 9 commits into from
Nov 2, 2021
9 changes: 3 additions & 6 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import fetch from 'cross-fetch';
import { Interface } from '@ethersproject/abi';
import { Contract } from '@ethersproject/contracts';
import { StaticJsonRpcProvider } from '@ethersproject/providers';
import { jsonToGraphQLQuery } from 'json-to-graphql-query';
import Ajv from 'ajv';
import addFormats from 'ajv-formats';
Expand All @@ -19,8 +18,6 @@ export const SNAPSHOT_SUBGRAPH_URL = {
'42': 'https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-kovan'
};

export const SNAPSHOT_SCORE_API = 'https://score.snapshot.org/api/scores';

export async function call(provider, abi: any[], call: any[], options?) {
const contract = new Contract(call[0], abi, provider);
try {
Expand Down Expand Up @@ -116,9 +113,9 @@ export async function getScores(
space: string,
strategies: any[],
network: string,
provider: StaticJsonRpcProvider | string,
addresses: string[],
snapshot: number | string = 'latest'
snapshot: number | string = 'latest',
scoreApiUrl: string = 'https://score.snapshot.org'
mktcode marked this conversation as resolved.
Show resolved Hide resolved
) {
try {
const params = {
Expand All @@ -128,7 +125,7 @@ export async function getScores(
strategies,
addresses
};
const res = await fetch(SNAPSHOT_SCORE_API, {
const res = await fetch(`${scoreApiUrl}/api/scores`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ params })
Expand Down
1 change: 0 additions & 1 deletion src/validations/aave/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export default async function validate(
space.id || space.key,
strategies,
space.network,
'',
[author]
);
const totalScore: any = scores
Expand Down
1 change: 0 additions & 1 deletion src/validations/basic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export default async function validate(
space.id || space.key,
strategies,
space.network,
'',
[author]
);
const totalScore: any = scores
Expand Down