Skip to content

Commit

Permalink
Revert "[SKIP CI] sync with contract changes (#213)"
Browse files Browse the repository at this point in the history
This reverts commit bd16b2c.
  • Loading branch information
mzxyz authored Oct 31, 2023
1 parent bd16b2c commit ed66dd8
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 79 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@apollo/client": "^3.7.0",
"@metamask/eth-sig-util": "^4.0.1",
"@octokit/request": "^5.6.3",
"@subql/contract-sdk": "^0.100.2",
"@subql/contract-sdk": "^0.16.2",
"@testing-library/react": "^14.0.0",
"@types/jest": "^28.1.6",
"@types/react": "^18.2.28",
Expand Down
2 changes: 1 addition & 1 deletion packages/network-clients/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"typescript": "^4.6.4"
},
"peerDependencies": {
"@subql/contract-sdk": "^0.100.2",
"@subql/contract-sdk": "^0.16.2",
"ipfs-http-client": "^53.0.1"
},
"stableVersion": "0.3.15"
Expand Down
4 changes: 2 additions & 2 deletions packages/network-clients/src/clients/contractClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class ContractClient {
public async dailyRewardCap(indexer: string): Promise<BigNumber> {
if (!utils.isAddress(indexer)) throw new Error(`Invalid address: ${indexer}`);

const threshold = await this._sdk.serviceAgreementExtra.threshold();
const threshold = await this._sdk.serviceAgreementRegistry.threshold();
const totalStakingAmount = await this._sdk.stakingManager.getTotalStakingAmount(indexer);

if (!threshold || threshold.eq(0)) return BigNumber.from(0);
Expand All @@ -54,7 +54,7 @@ export class ContractClient {
if (!utils.isAddress(indexer)) throw new Error(`Invalid address: ${indexer}`);

const dailyRewardCap = await this.dailyRewardCap(indexer);
const sumDailyReward = await this._sdk.serviceAgreementExtra.sumDailyReward(indexer);
const sumDailyReward = await this._sdk.serviceAgreementRegistry.sumDailyReward(indexer);

return dailyRewardCap.gt(sumDailyReward)
? dailyRewardCap.sub(sumDailyReward)
Expand Down
2 changes: 1 addition & 1 deletion packages/network-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"typescript": "^4.8.4"
},
"peerDependencies": {
"@subql/contract-sdk": "^0.100.2",
"@subql/contract-sdk": "^0.16.2",
"ipfs-http-client": "^53.0.1"
},
"stableVersion": "0.3.17-1"
Expand Down
4 changes: 1 addition & 3 deletions packages/network-config/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { GQLEndpoint, IPFS_URLS, RPC_ENDPOINTS, SQNetworks, gqlEndpoints } from

import { SdkOptions } from '@subql/contract-sdk/types';

import keplerDeploymentDetails from '@subql/contract-sdk/publish/kepler.json';
import mainnetDeploymentDetails from '@subql/contract-sdk/publish/mainnet.json';
import keplerDeploymentDetails from '@subql/contract-sdk/publish/kepler.json';
import testnetDeploymentDetails from '@subql/contract-sdk/publish/testnet.json';

export interface NetworkConfig {
Expand All @@ -26,8 +26,6 @@ export const NETWORK_CONFIGS: Record<SQNetworks, NetworkConfig> = {
},
[SQNetworks.KEPLER]: {
defaultEndpoint: RPC_ENDPOINTS.kepler,
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
sdkOptions: { network: 'kepler', deploymentDetails: keplerDeploymentDetails },
gql: gqlEndpoints(SQNetworks.KEPLER),
},
Expand Down
3 changes: 1 addition & 2 deletions packages/network-config/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ export const RPC_ENDPOINTS = {
export const NETWORK_SUBQL_ENDPOINTS = {
[SQNetworks.MAINNET]: 'https://api.subquery.network/sq/subquery/kepler-network',
[SQNetworks.KEPLER]: 'https://api.subquery.network/sq/subquery/kepler-network',
// TODO: change back to testnet-prod endpoint
[SQNetworks.TESTNET]: 'https://api.subquery.network/sq/subquery/kepler-testnet__c3Vic',
[SQNetworks.TESTNET]: 'https://api.subquery.network/sq/subquery/kepler-testnet',
};

export const LEADERBOARD_SUBQL_ENDPOINTS = {
Expand Down
2 changes: 1 addition & 1 deletion packages/network-query/queries/network/agreements.gql
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fragment ServiceAgreementFields on ServiceAgreement {
endTime
deployment {
id
metadata
version
project {
id
metadata
Expand Down
34 changes: 17 additions & 17 deletions packages/network-query/queries/network/deployments.gql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2020-2022 SubQuery Pte Ltd authors & contributors
# SPDX-License-Identifier: Apache-2.0

fragment indexerDeploymentFields on IndexerDeployment {
fragment DeploymentIndexerFields on DeploymentIndexer {
id
indexerId
deploymentId
Expand All @@ -12,8 +12,8 @@ fragment indexerDeploymentFields on IndexerDeployment {
}
}

fragment IndexerDeploymentNodeFields on IndexerDeployment {
...indexerDeploymentFields
fragment DeploymentIndexerNodeFields on DeploymentIndexer {
...DeploymentIndexerFields
deployment {
id
project {
Expand All @@ -26,7 +26,7 @@ fragment IndexerDeploymentNodeFields on IndexerDeployment {
query GetDeployment($deploymentId: String!) {
deployment(id: $deploymentId) {
id
metadata
version
project {
id
metadata
Expand All @@ -38,17 +38,17 @@ query GetDeploymentIndexers(
$first: Int = 20
$offset: Int
$deploymentId: String!
$orderby: [IndexerDeploymentsOrderBy!] = LAST_EVENT_ASC
$orderby: [DeploymentIndexersOrderBy!] = LAST_EVENT_ASC
) {
indexerDeployments(
deploymentIndexers(
first: $first
offset: $offset
orderBy: $orderby
filter: { deploymentId: { equalTo: $deploymentId }, status: { notEqualTo: TERMINATED } }
) {
totalCount
nodes {
...indexerDeploymentFields
...DeploymentIndexerFields
}
}
}
Expand All @@ -57,10 +57,10 @@ query GetDeploymentIndexersBySearch(
$first: Int = 20
$offset: Int
$deploymentId: String!
$orderby: [IndexerDeploymentsOrderBy!] = LAST_EVENT_ASC
$orderby: [DeploymentIndexersOrderBy!] = LAST_EVENT_ASC
$indexerId: String! = ""
) {
indexerDeployments(
deploymentIndexers(
first: $first
offset: $offset
orderBy: $orderby
Expand All @@ -72,32 +72,32 @@ query GetDeploymentIndexersBySearch(
) {
totalCount
nodes {
...indexerDeploymentFields
...DeploymentIndexerFields
}
}
}

query GetIndexerDeployment($indexerAddress: String!, $deploymentId: String!) {
indexerDeployments(
query GetDeploymentIndexer($indexerAddress: String!, $deploymentId: String!) {
deploymentIndexers(
filter: { indexerId: { equalTo: $indexerAddress }, deploymentId: { equalTo: $deploymentId } }
) {
totalCount
nodes {
...indexerDeploymentFields
...DeploymentIndexerFields
}
}
}

query GetDeploymentIndexersByIndexer($indexerAddress: String!) {
indexerDeployments(filter: { indexerId: { equalTo: $indexerAddress } }) {
deploymentIndexers(filter: { indexerId: { equalTo: $indexerAddress } }) {
totalCount
pageInfo {
startCursor
endCursor
hasNextPage
}
nodes {
...indexerDeploymentFields
...DeploymentIndexerFields
deployment {
id
project {
Expand All @@ -110,9 +110,9 @@ query GetDeploymentIndexersByIndexer($indexerAddress: String!) {
}

query GetDeploymentIndexersDeploymentByIndexer($indexerAddress: String!) {
indexerDeployments(filter: { indexerId: { equalTo: $indexerAddress } }) {
deploymentIndexers(filter: { indexerId: { equalTo: $indexerAddress } }) {
nodes {
...IndexerDeploymentNodeFields
...DeploymentIndexerNodeFields
}
}
}
Expand Down
1 change: 0 additions & 1 deletion packages/network-query/queries/network/offers.gql
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ fragment OfferFields on Offer {
}
deposit
minimumAcceptHeight
minimumStakingAmount
expireDate
limit # indexer cap
accepted # accepted indexer amount
Expand Down
2 changes: 1 addition & 1 deletion packages/network-query/queries/network/plans.gql
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ query GetPlans($address: String!) {
}

query GetSpecificPlans($address: String) {
indexerDeployments(filter: { indexerId: { equalTo: $address } }) {
deploymentIndexers(filter: { indexerId: { equalTo: $address } }) {
totalCount
nodes {
deployment {
Expand Down
6 changes: 3 additions & 3 deletions packages/network-query/queries/network/project.gql
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ fragment ProjectFields on Project {
id
owner
metadata
deploymentMetadata
deploymentId
currentVersion
currentDeployment
updatedTimestamp
createdTimestamp
deployments {
Expand Down Expand Up @@ -78,7 +78,7 @@ query GetProjectDeployments($projectId: String!) {
totalCount
nodes {
id
metadata
version
createdTimestamp
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"typescript": "^4.6.4"
},
"peerDependencies": {
"@subql/contract-sdk": "^0.100.2",
"@subql/contract-sdk": "^0.16.2",
"graphql": "^16.5.0",
"react": "^18"
},
Expand Down
73 changes: 36 additions & 37 deletions test/queryClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,51 @@

import { ApolloClient } from '@apollo/client/core';
import assert from 'assert';
import { constants } from 'ethers';
import { GraphqlQueryClient, NETWORK_CONFIGS } from '../packages/network-clients/src';
import {
GetAcceptedOffers,
GetAggregatesEraRewards,
GetAggregatesEraRewardsByIndexer,
GetAirdrops,
GetAirdropsByAccount,
GetAllDelegations,
GetAllOpenOffers,
GetConsumerClosedFlexPlans,
GetConsumerOngoingFlexPlans,
GetDashboard,
GetDelegation,
GetIndexer,
GetIndexers,
GetDelegator,
GetIndexerDelegators,
GetExpiredServiceAgreements,
GetOngoingServiceAgreements,
GetProjectOngoingServiceAgreements,
GetAcceptedOffers,
GetDeployment,
GetDeploymentIndexers,
GetDeploymentIndexersByIndexer,
GetDeploymentPlans,
GetEraQuery,
GetEraRewardsByIndexerAndPage,
GetExpiredServiceAgreements,
GetAllDelegations,
GetFilteredDelegations,
GetIndexer,
GetIndexerClosedFlexPlans,
GetIndexerDelegators,
GetIndexerOngoingFlexPlans,
GetIndexerRewards,
GetIndexerStakesByEras,
GetIndexerStakesByIndexer,
GetIndexerUnfinalisedPlans,
GetIndexers,
GetOngoingServiceAgreements,
GetOrders,
GetDeploymentIndexersByIndexer,
GetAllOpenOffers,
GetOwnExpiredOffers,
GetOwnOpenOffers,
GetSpecificOpenOffers,
GetDeploymentPlans,
GetPlanTemplates,
GetPlans,
GetProject,
GetProjectDeployments,
GetProjectOngoingServiceAgreements,
GetProjects,
GetIndexerRewards,
GetRewards,
GetSpecificOpenOffers,
GetStateChannels,
GetWithdrawls,
GetStateChannels,
GetConsumerOngoingFlexPlans,
GetConsumerClosedFlexPlans,
GetIndexerOngoingFlexPlans,
GetIndexerUnfinalisedPlans,
GetIndexerClosedFlexPlans,
GetDashboard,
GetIndexerStakesByIndexer,
GetIndexerStakesByEras,
GetAggregatesEraRewards,
GetAggregatesEraRewardsByIndexer,
GetEraRewardsByIndexerAndPage,
GetOrders,
GetAirdrops,
GetAirdropsByAccount,
GetEraQuery,
} from '../packages/network-query';

function deepAssert(obj: any) {
Expand All @@ -65,8 +64,8 @@ describe('query client', () => {
const address1 = '0xCef192586b70e3Fc2FAD76Dd1D77983a30d38D04';
const address2 = '0xa40987037547C2cc5df0b06fFe52B7FdCCB7D4FC';
const address3 = '0xf9e4E6307a3186991F153249294815228D3a4634';
const projectId = 'QmNYsNZvM9XZuzkF3n6XcqFVxvMLfWYtEQHzszMFfNCkgt';
const projectId2 = 'QmZGAZQ7e1oZgfuK4V29Fa5gveYK3G2zEwvUzTZKNvSBsm';
const projectId = 'QmZGAZQ7e1oZgfuK4V29Fa5gveYK3G2zEwvUzTZKNvSBsm';
const projectId2 = 'QmPemHcmAJ6BRyV13FN91miLCHNtqXLLacsqYjSaTmbFmr';
const consumer = '0xD5d48b83389150FFaa0B897ffC88817622abce58';
const pId = '0x01';

Expand Down Expand Up @@ -188,7 +187,7 @@ describe('query client', () => {
variables: { indexerAddress: address3 },
});
assert(result, 'cannot request query GET_DEPLOYMENT_INDEXERS_WITH_INDEXER');
expect(result.data.indexerDeployments).toBeTruthy();
expect(result.data.deploymentIndexers).toBeTruthy();
});

it('can query get accepted offer', async () => {
Expand Down Expand Up @@ -485,7 +484,7 @@ describe('query client', () => {
const result = await client.query({
query: GetOrders,
variables: {
swapFrom: constants.AddressZero,
swapFrom: '0x0000',
now: new Date(),
},
});
Expand All @@ -505,7 +504,7 @@ describe('query client', () => {
const result = await client.query({
query: GetAirdropsByAccount,
variables: {
account: constants.AddressZero,
account: '0x000000',
},
});

Expand All @@ -516,7 +515,7 @@ describe('query client', () => {
const result = await client.query({
query: GetAirdropsByAccount,
variables: {
account: constants.AddressZero,
account: '0x000000',
},
});

Expand All @@ -527,7 +526,7 @@ describe('query client', () => {
const result = await client.query({
query: GetEraQuery,
variables: {
account: constants.AddressZero,
account: '0x000000',
},
});

Expand Down
Loading

0 comments on commit ed66dd8

Please sign in to comment.