Skip to content

Commit

Permalink
[SKIP CI] Feat/sync with contract changes (#215)
Browse files Browse the repository at this point in the history
* Update `contract-sdk`

* Update `DeploymentIndexer` entity

* Update project query

* Further updates

* Ignore deployment ts error

* Try use the staging endpoint

* Fix schema issue in the gql queries

* Fix the final build issue

* Fix query client test

* Add `develop` branch to github action
  • Loading branch information
mzxyz authored Oct 31, 2023
1 parent cc8fbc0 commit ed5da7e
Show file tree
Hide file tree
Showing 17 changed files with 83 additions and 85 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ name: "CodeQL"

on:
push:
branches: [ "main" ]
branches: [ "main", "develop" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
branches: [ "main", "develop" ]
schedule:
- cron: '21 0 * * 0'

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- main
- develop
paths-ignore:
- '.github/workflows/**'
workflow_dispatch:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- main
- develop
paths-ignore:
- '.github/workflows/**'
workflow_dispatch:
Expand Down
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.16.2",
"@subql/contract-sdk": "^0.100.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.16.2",
"@subql/contract-sdk": "^0.100.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.serviceAgreementRegistry.threshold();
const threshold = await this._sdk.serviceAgreementExtra.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.serviceAgreementRegistry.sumDailyReward(indexer);
const sumDailyReward = await this._sdk.serviceAgreementExtra.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.16.2",
"@subql/contract-sdk": "^0.100.2",
"ipfs-http-client": "^53.0.1"
},
"stableVersion": "0.3.17-1"
Expand Down
4 changes: 3 additions & 1 deletion 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 mainnetDeploymentDetails from '@subql/contract-sdk/publish/mainnet.json';
import keplerDeploymentDetails from '@subql/contract-sdk/publish/kepler.json';
import mainnetDeploymentDetails from '@subql/contract-sdk/publish/mainnet.json';
import testnetDeploymentDetails from '@subql/contract-sdk/publish/testnet.json';

export interface NetworkConfig {
Expand All @@ -26,6 +26,8 @@ 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: 2 additions & 1 deletion packages/network-config/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ 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',
[SQNetworks.TESTNET]: 'https://api.subquery.network/sq/subquery/kepler-testnet',
// TODO: change back to testnet-prod endpoint
[SQNetworks.TESTNET]: 'https://api.subquery.network/sq/subquery/kepler-testnet__c3Vic',
};

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
version
metadata
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 DeploymentIndexerFields on DeploymentIndexer {
fragment indexerDeploymentFields on IndexerDeployment {
id
indexerId
deploymentId
Expand All @@ -12,8 +12,8 @@ fragment DeploymentIndexerFields on DeploymentIndexer {
}
}

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

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

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

query GetDeploymentIndexersDeploymentByIndexer($indexerAddress: String!) {
deploymentIndexers(filter: { indexerId: { equalTo: $indexerAddress } }) {
indexerDeployments(filter: { indexerId: { equalTo: $indexerAddress } }) {
nodes {
...DeploymentIndexerNodeFields
...IndexerDeploymentNodeFields
}
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/network-query/queries/network/offers.gql
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ 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) {
deploymentIndexers(filter: { indexerId: { equalTo: $address } }) {
indexerDeployments(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
currentVersion
currentDeployment
deploymentMetadata
deploymentId
updatedTimestamp
createdTimestamp
deployments {
Expand Down Expand Up @@ -78,7 +78,7 @@ query GetProjectDeployments($projectId: String!) {
totalCount
nodes {
id
version
metadata
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.16.2",
"@subql/contract-sdk": "^0.100.2",
"graphql": "^16.5.0",
"react": "^18"
},
Expand Down
Loading

0 comments on commit ed5da7e

Please sign in to comment.