Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nibiru
Submodule nibiru updated 505 files
53 changes: 38 additions & 15 deletions src/gql/heart-monitor/heart-monitor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ import {
defaultEvm,
defaultBybit,
defaultProxy,
GQLMarketing,
QueryMarketingArgs,
} from ".."

const nibiruUrl = "testnet-2"
Expand Down Expand Up @@ -135,6 +137,21 @@ test("distributionCommissions", async () => {
await testDistributionCommissions({}, defaultDistributionCommission)
})

const testEvm = async (fields: GQLEvm) => {
const resp = await heartMonitor.evm(fields)
expect(resp).toHaveProperty("evm")

if (resp.evm) {
const { evm } = resp

checkFields([evm], ["funTokens"])
}
}

test("evm", async () => {
await testEvm(defaultEvm)
})

const testFeatureFlags = async (fields: GQLFeatureFlags) => {
const resp = await heartMonitor.featureFlags(fields)
expect(resp).toHaveProperty("featureFlags")
Expand Down Expand Up @@ -288,6 +305,27 @@ test("inflation", async () => {
)
})

const testMarketing = async (
args: QueryMarketingArgs,
fields: GQLMarketing
) => {
const resp = await heartMonitor.marketing(args, fields)
expect(resp).toHaveProperty("marketing")

if (resp.marketing) {
const { marketing } = resp

checkFields([marketing], ["isTaskCompleted"])
}
}

test("marketing", async () => {
await testMarketing(
{ isTaskCompleted: { taskId: "task-123", userAddress: "nibi1xyz" } },
{ isTaskCompleted: true }
)
})

const testOracle = async (args: QueryOracleArgs, fields: OracleFields) => {
const resp = await heartMonitor.oracle(args, fields)
expect(resp).toHaveProperty("oracle")
Expand Down Expand Up @@ -380,21 +418,6 @@ test("proxies", async () => {
await testProxies({ bybit: defaultBybit })
})

const testEvm = async (fields: GQLEvm) => {
const resp = await heartMonitor.evm(fields)
expect(resp).toHaveProperty("evm")

if (resp.evm) {
const { evm } = resp

checkFields([evm], ["funTokens"])
}
}

test("evm", async () => {
await testEvm(defaultEvm)
})

test("queryBatchHandler", async () => {
// TODO: Make a partial type that includes all of these
const resp = await heartMonitor.GQLQueryGqlBatchHandler<{
Expand Down
36 changes: 25 additions & 11 deletions src/gql/heart-monitor/heart-monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ import {
GQLProxies,
GqlOutProxies,
proxies,
QueryMarketingArgs,
MarketingFields,
GqlOutMarketing,
marketing,
GQLStakingFields,
GqlOutStaking,
QueryStakingArgs,
Expand All @@ -65,6 +69,10 @@ export interface IHeartMonitor {
subscriptionClient?: Client
closeWebSocket: () => Promise<void | undefined>

readonly GQLQueryGqlBatchHandler: <T>(
queryQueryStrings: string[]
) => Promise<T>

readonly communityPool: (
args: GQLQueryGqlCommunityPoolArgs,
fields: DeepPartial<GQLToken>
Expand All @@ -75,6 +83,8 @@ export interface IHeartMonitor {
fields: DeepPartial<GQLDistributionCommission>
) => Promise<GqlOutDistributionCommissions>

readonly evm: (fields: DeepPartial<GQLEvm>) => Promise<GqlOutEvm>

readonly featureFlags: (
fields: DeepPartial<GQLFeatureFlags>
) => Promise<GqlOutFeatureFlags>
Expand All @@ -94,6 +104,11 @@ export interface IHeartMonitor {
fields: DeepPartial<InflationFields>
) => Promise<GqlOutInflation>

readonly marketing: (
args: QueryMarketingArgs,
fields: DeepPartial<MarketingFields>
) => Promise<GqlOutMarketing>

readonly oracle: (
args: QueryOracleArgs,
fields: DeepPartial<OracleFields>
Expand All @@ -111,12 +126,6 @@ export interface IHeartMonitor {
domainName?: string
) => Promise<GqlOutProxies>

readonly evm: (fields: DeepPartial<GQLEvm>) => Promise<GqlOutEvm>

readonly GQLQueryGqlBatchHandler: <T>(
queryQueryStrings: string[]
) => Promise<T>

readonly staking: (
args: QueryStakingArgs,
fields: DeepPartial<GQLStakingFields>
Expand Down Expand Up @@ -165,6 +174,9 @@ export class HeartMonitor implements IHeartMonitor {
}
}

GQLQueryGqlBatchHandler = async <T>(queryQueryStrings: string[]) =>
<T>queryBatchHandler(queryQueryStrings, this.gqlEndpt)

closeWebSocket = async () => this.subscriptionClient?.dispose()

communityPool = async (
Expand All @@ -177,6 +189,8 @@ export class HeartMonitor implements IHeartMonitor {
fields: DeepPartial<GQLDistributionCommission>
) => distributionCommissions(args, this.gqlEndpt, fields)

evm = async (fields: DeepPartial<GQLEvm>) => evm(this.gqlEndpt, fields)

featureFlags = async (fields: DeepPartial<GQLFeatureFlags>) =>
featureFlags(this.gqlEndpt, fields)

Expand All @@ -193,6 +207,11 @@ export class HeartMonitor implements IHeartMonitor {
fields: DeepPartial<InflationFields>
) => inflation(args, this.gqlEndpt, fields)

marketing = async (
args: QueryMarketingArgs,
fields: DeepPartial<MarketingFields>
) => marketing(args, this.gqlEndpt, fields)

oracle = async (args: QueryOracleArgs, fields: DeepPartial<OracleFields>) =>
oracle(args, this.gqlEndpt, fields)

Expand All @@ -204,11 +223,6 @@ export class HeartMonitor implements IHeartMonitor {
proxies = async (fields: DeepPartial<GQLProxies>, domainName?: string) =>
proxies(this.gqlEndpt, fields, domainName)

evm = async (fields: DeepPartial<GQLEvm>) => evm(this.gqlEndpt, fields)

GQLQueryGqlBatchHandler = async <T>(queryQueryStrings: string[]) =>
<T>queryBatchHandler(queryQueryStrings, this.gqlEndpt)

staking = async (
args: QueryStakingArgs,
fields: DeepPartial<GQLStakingFields>
Expand Down
1 change: 1 addition & 0 deletions src/gql/query/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export * from "./featureFlags"
export * from "./governance"
export * from "./ibc"
export * from "./inflation"
export * from "./marketing"
export * from "./oracle"
export * from "./proxies"
export * from "./staking"
Expand Down
53 changes: 53 additions & 0 deletions src/gql/query/marketing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import {
doGqlQuery,
GQLQuery,
DeepPartial,
GQLMarketing,
GQLMarketingGqlIsTaskCompletedArgs,
arg,
} from ".."

export type QueryMarketingArgs = {
isTaskCompleted?: GQLMarketingGqlIsTaskCompletedArgs
}

export interface GqlOutMarketing {
marketing?: GQLQuery["marketing"]
}

export type MarketingFields = DeepPartial<GQLMarketing>

export const marketingQueryString = (
args: QueryMarketingArgs,
fields: MarketingFields
) => {
const marketingQuery: string[] = []

if (fields.isTaskCompleted) {
const qArgs =
args.isTaskCompleted ?? ({} as GQLMarketingGqlIsTaskCompletedArgs)
const argList = [
arg("taskId", qArgs.taskId),
arg("userAddress", qArgs.userAddress),
]
marketingQuery.push(`isTaskCompleted(${argList.join(", ")})`)
}

return `
marketing {
${marketingQuery.join("\n")}
}
`
}

export const marketing = async (
args: QueryMarketingArgs,
endpt: string,
fields: MarketingFields
): Promise<GqlOutMarketing> =>
doGqlQuery(
`{
${marketingQueryString(args, fields)}
}`,
endpt
)
26 changes: 21 additions & 5 deletions src/gql/utils/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ export enum GQLCommunityPoolOrder {
}

export type GQLContractEventsFilter = {
readonly block?: InputMaybe<GQLIntFilter>;
readonly contractAddress?: InputMaybe<GQLStringFilter>;
readonly type?: InputMaybe<GQLStringFilter>;
readonly block: GQLIntFilter;
readonly contractAddress?: InputMaybe<GQLStringEqualsFilter>;
readonly type?: InputMaybe<GQLStringEqualsFilter>;
};

export enum GQLContractEventsOrder {
Expand Down Expand Up @@ -121,6 +121,7 @@ export type GQLEvent = {
readonly block: GQLBlock;
readonly contractAddress?: Maybe<Scalars['String']['output']>;
readonly eventSeqNo: Scalars['Int']['output'];
readonly txHash?: Maybe<Scalars['String']['output']>;
readonly txSeqNo: Scalars['Int']['output'];
readonly type: Scalars['String']['output'];
};
Expand Down Expand Up @@ -423,6 +424,17 @@ export type GQLInternalGqlEmployeeArgs = {
where: GQLEmployeeFilter;
};

export type GQLMarketing = {
readonly __typename?: 'Marketing';
readonly isTaskCompleted: Scalars['Boolean']['output'];
};


export type GQLMarketingGqlIsTaskCompletedArgs = {
taskId: Scalars['String']['input'];
userAddress: Scalars['String']['input'];
};

export type GQLMessage = {
readonly __typename?: 'Message';
readonly action?: Maybe<Scalars['String']['output']>;
Expand Down Expand Up @@ -533,6 +545,7 @@ export type GQLQuery = {
readonly ibc: GQLIbc;
readonly inflation: GQLInflation;
readonly internal: GQLInternal;
readonly marketing: GQLMarketing;
readonly messages: ReadonlyArray<GQLMessage>;
readonly oracle: GQLOracle;
readonly proxies: GQLProxies;
Expand Down Expand Up @@ -769,6 +782,10 @@ export enum GQLStatsVolumeOrder {
GQLPeriodStartTs = 'period_start_ts'
}

export type GQLStringEqualsFilter = {
readonly eq?: InputMaybe<Scalars['String']['input']>;
};

export type GQLStringFilter = {
readonly eq?: InputMaybe<Scalars['String']['input']>;
readonly like?: InputMaybe<Scalars['String']['input']>;
Expand Down Expand Up @@ -874,7 +891,6 @@ export type GQLUserContract = {
readonly __typename?: 'UserContract';
readonly contractAddress: Scalars['String']['output'];
readonly contractType: Scalars['String']['output'];
readonly events?: Maybe<ReadonlyArray<GQLEvent>>;
readonly user: GQLUser;
};

Expand Down Expand Up @@ -973,7 +989,7 @@ export type GQLWasmGqlContractEventsArgs = {
offset?: InputMaybe<Scalars['Int']['input']>;
order?: InputMaybe<GQLContractEventsOrder>;
orderDesc?: InputMaybe<Scalars['Boolean']['input']>;
where?: InputMaybe<GQLContractEventsFilter>;
where: GQLContractEventsFilter;
};


Expand Down
Loading