Skip to content

Commit

Permalink
update gov_params metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiong-stratos committed Jun 11, 2024
1 parent 11fbb8b commit 80246d0
Show file tree
Hide file tree
Showing 8 changed files with 450 additions and 57 deletions.
8 changes: 4 additions & 4 deletions apps/web-stratos/src/graphql/general/params.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ query Params {
distributionParams: distribution_params(limit: 1, order_by: {height: desc}) {
params
}
govParams: gov_params (limit: 1, order_by: {height: desc}) {
depositParams: deposit_params
tallyParams: tally_params
votingParams: voting_params
govParams: gov_params(limit: 1, order_by: {height: desc}) {
one_row_id
params
height
}
}
4 changes: 2 additions & 2 deletions apps/web-stratos/src/graphql/general/proposal_details.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ query ProposalDetails($proposalId: Int) {
content
proposalId: id
submitTime: submit_time
proposalType: proposal_type
#proposalType: proposal_type
depositEndTime: deposit_end_time
votingStartTime: voting_start_time
votingEndTime: voting_end_time
Expand All @@ -25,7 +25,7 @@ query ProposalDetailsTally($proposalId: Int) {
bondedTokens: bonded_tokens
}
quorum: gov_params (limit: 1, order_by: {height: desc}) {
tallyParams: tally_params
tallyParams: params
}
}

Expand Down
70 changes: 19 additions & 51 deletions apps/web-stratos/src/graphql/types/general_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2444,28 +2444,14 @@ export type Genesis_Variance_Fields = {
/** columns and relationships of "gov_params" */
export type Gov_Params = {
__typename?: 'gov_params';
deposit_params: Scalars['jsonb'];
height: Scalars['bigint'];
one_row_id: Scalars['Boolean'];
tally_params: Scalars['jsonb'];
voting_params: Scalars['jsonb'];
};


/** columns and relationships of "gov_params" */
export type Gov_ParamsDeposit_ParamsArgs = {
path?: InputMaybe<Scalars['String']>;
};


/** columns and relationships of "gov_params" */
export type Gov_ParamsTally_ParamsArgs = {
path?: InputMaybe<Scalars['String']>;
params: Scalars['jsonb'];
};


/** columns and relationships of "gov_params" */
export type Gov_ParamsVoting_ParamsArgs = {
export type Gov_ParamsParamsArgs = {
path?: InputMaybe<Scalars['String']>;
};

Expand Down Expand Up @@ -2510,11 +2496,9 @@ export type Gov_Params_Bool_Exp = {
_and?: InputMaybe<Array<Gov_Params_Bool_Exp>>;
_not?: InputMaybe<Gov_Params_Bool_Exp>;
_or?: InputMaybe<Array<Gov_Params_Bool_Exp>>;
deposit_params?: InputMaybe<Jsonb_Comparison_Exp>;
height?: InputMaybe<Bigint_Comparison_Exp>;
one_row_id?: InputMaybe<Boolean_Comparison_Exp>;
tally_params?: InputMaybe<Jsonb_Comparison_Exp>;
voting_params?: InputMaybe<Jsonb_Comparison_Exp>;
params?: InputMaybe<Jsonb_Comparison_Exp>;
};

/** aggregate max on columns */
Expand All @@ -2531,25 +2515,19 @@ export type Gov_Params_Min_Fields = {

/** Ordering options when selecting data from "gov_params". */
export type Gov_Params_Order_By = {
deposit_params?: InputMaybe<Order_By>;
height?: InputMaybe<Order_By>;
one_row_id?: InputMaybe<Order_By>;
tally_params?: InputMaybe<Order_By>;
voting_params?: InputMaybe<Order_By>;
params?: InputMaybe<Order_By>;
};

/** select columns of table "gov_params" */
export enum Gov_Params_Select_Column {
/** column name */
DepositParams = 'deposit_params',
/** column name */
Height = 'height',
/** column name */
OneRowId = 'one_row_id',
/** column name */
TallyParams = 'tally_params',
/** column name */
VotingParams = 'voting_params'
Params = 'params'
}

/** aggregate stddev on columns */
Expand Down Expand Up @@ -3421,18 +3399,17 @@ export type Proposal = {
deposit_end_time?: Maybe<Scalars['timestamp']>;
description: Scalars['String'];
id: Scalars['Int'];
metadata: Scalars['String'];
/** An array relationship */
proposal_deposits: Array<Proposal_Deposit>;
/** An aggregate relationship */
proposal_deposits_aggregate: Proposal_Deposit_Aggregate;
proposal_route: Scalars['String'];
/** An object relationship */
proposal_tally_result?: Maybe<Proposal_Tally_Result>;
/** An array relationship */
proposal_tally_results: Array<Proposal_Tally_Result>;
/** An aggregate relationship */
proposal_tally_results_aggregate: Proposal_Tally_Result_Aggregate;
proposal_type: Scalars['String'];
/** An array relationship */
proposal_votes: Array<Proposal_Vote>;
/** An aggregate relationship */
Expand Down Expand Up @@ -3604,11 +3581,10 @@ export type Proposal_Bool_Exp = {
deposit_end_time?: InputMaybe<Timestamp_Comparison_Exp>;
description?: InputMaybe<String_Comparison_Exp>;
id?: InputMaybe<Int_Comparison_Exp>;
metadata?: InputMaybe<String_Comparison_Exp>;
proposal_deposits?: InputMaybe<Proposal_Deposit_Bool_Exp>;
proposal_route?: InputMaybe<String_Comparison_Exp>;
proposal_tally_result?: InputMaybe<Proposal_Tally_Result_Bool_Exp>;
proposal_tally_results?: InputMaybe<Proposal_Tally_Result_Bool_Exp>;
proposal_type?: InputMaybe<String_Comparison_Exp>;
proposal_votes?: InputMaybe<Proposal_Vote_Bool_Exp>;
proposer?: InputMaybe<Account_Bool_Exp>;
proposer_address?: InputMaybe<String_Comparison_Exp>;
Expand Down Expand Up @@ -3858,8 +3834,7 @@ export type Proposal_Max_Fields = {
deposit_end_time?: Maybe<Scalars['timestamp']>;
description?: Maybe<Scalars['String']>;
id?: Maybe<Scalars['Int']>;
proposal_route?: Maybe<Scalars['String']>;
proposal_type?: Maybe<Scalars['String']>;
metadata?: Maybe<Scalars['String']>;
proposer_address?: Maybe<Scalars['String']>;
status?: Maybe<Scalars['String']>;
submit_time?: Maybe<Scalars['timestamp']>;
Expand All @@ -3873,8 +3848,7 @@ export type Proposal_Max_Order_By = {
deposit_end_time?: InputMaybe<Order_By>;
description?: InputMaybe<Order_By>;
id?: InputMaybe<Order_By>;
proposal_route?: InputMaybe<Order_By>;
proposal_type?: InputMaybe<Order_By>;
metadata?: InputMaybe<Order_By>;
proposer_address?: InputMaybe<Order_By>;
status?: InputMaybe<Order_By>;
submit_time?: InputMaybe<Order_By>;
Expand All @@ -3889,8 +3863,7 @@ export type Proposal_Min_Fields = {
deposit_end_time?: Maybe<Scalars['timestamp']>;
description?: Maybe<Scalars['String']>;
id?: Maybe<Scalars['Int']>;
proposal_route?: Maybe<Scalars['String']>;
proposal_type?: Maybe<Scalars['String']>;
metadata?: Maybe<Scalars['String']>;
proposer_address?: Maybe<Scalars['String']>;
status?: Maybe<Scalars['String']>;
submit_time?: Maybe<Scalars['timestamp']>;
Expand All @@ -3904,8 +3877,7 @@ export type Proposal_Min_Order_By = {
deposit_end_time?: InputMaybe<Order_By>;
description?: InputMaybe<Order_By>;
id?: InputMaybe<Order_By>;
proposal_route?: InputMaybe<Order_By>;
proposal_type?: InputMaybe<Order_By>;
metadata?: InputMaybe<Order_By>;
proposer_address?: InputMaybe<Order_By>;
status?: InputMaybe<Order_By>;
submit_time?: InputMaybe<Order_By>;
Expand All @@ -3920,11 +3892,10 @@ export type Proposal_Order_By = {
deposit_end_time?: InputMaybe<Order_By>;
description?: InputMaybe<Order_By>;
id?: InputMaybe<Order_By>;
metadata?: InputMaybe<Order_By>;
proposal_deposits_aggregate?: InputMaybe<Proposal_Deposit_Aggregate_Order_By>;
proposal_route?: InputMaybe<Order_By>;
proposal_tally_result?: InputMaybe<Proposal_Tally_Result_Order_By>;
proposal_tally_results_aggregate?: InputMaybe<Proposal_Tally_Result_Aggregate_Order_By>;
proposal_type?: InputMaybe<Order_By>;
proposal_votes_aggregate?: InputMaybe<Proposal_Vote_Aggregate_Order_By>;
proposer?: InputMaybe<Account_Order_By>;
proposer_address?: InputMaybe<Order_By>;
Expand All @@ -3950,9 +3921,7 @@ export enum Proposal_Select_Column {
/** column name */
ProposalRoute = 'proposal_route',
/** column name */
ProposalType = 'proposal_type',
/** column name */
ProposerAddress = 'proposer_address',
Metadata = 'metadata',
/** column name */
Status = 'status',
/** column name */
Expand Down Expand Up @@ -11331,14 +11300,14 @@ export type OnlineVotingPowerQuery = { activeTotal: { __typename?: 'validator_st
export type ParamsQueryVariables = Exact<{ [key: string]: never; }>;


export type ParamsQuery = { stakingParams: Array<{ __typename?: 'staking_params', params: any }>, slashingParams: Array<{ __typename?: 'slashing_params', params: any }>, mintParams: Array<{ __typename?: 'mint_params', params: any }>, distributionParams: Array<{ __typename?: 'distribution_params', params: any }>, govParams: Array<{ __typename?: 'gov_params', depositParams: any, tallyParams: any, votingParams: any }> };
export type ParamsQuery = { stakingParams: Array<{ __typename?: 'staking_params', params: any }>, slashingParams: Array<{ __typename?: 'slashing_params', params: any }>, mintParams: Array<{ __typename?: 'mint_params', params: any }>, distributionParams: Array<{ __typename?: 'distribution_params', params: any }>, govParams: Array<{ __typename?: 'gov_params', one_row_id: boolean, params: any, height: any }> };

export type ProposalDetailsQueryVariables = Exact<{
proposalId?: InputMaybe<Scalars['Int']>;
}>;


export type ProposalDetailsQuery = { proposal: Array<{ __typename?: 'proposal', title: string, description: string, status?: string | null, content: any, proposer: string, proposalId: number, submitTime: any, proposalType: string, depositEndTime?: any | null, votingStartTime?: any | null, votingEndTime?: any | null }> };
export type ProposalDetailsQuery = { proposal: Array<{ __typename?: 'proposal', title: string, description: string, status?: string | null, content: any, proposer: string, proposalId: number, submitTime: any, depositEndTime?: any | null, votingStartTime?: any | null, votingEndTime?: any | null }> };

export type ProposalDetailsTallyQueryVariables = Exact<{
proposalId?: InputMaybe<Scalars['Int']>;
Expand Down Expand Up @@ -12330,9 +12299,9 @@ export const ParamsDocument = gql`
params
}
govParams: gov_params(limit: 1, order_by: {height: desc}) {
depositParams: deposit_params
tallyParams: tally_params
votingParams: voting_params
one_row_id
params
height
}
}
`;
Expand Down Expand Up @@ -12373,7 +12342,6 @@ export const ProposalDetailsDocument = gql`
content
proposalId: id
submitTime: submit_time
proposalType: proposal_type
depositEndTime: deposit_end_time
votingStartTime: voting_start_time
votingEndTime: voting_end_time
Expand Down Expand Up @@ -12424,7 +12392,7 @@ export const ProposalDetailsTallyDocument = gql`
bondedTokens: bonded_tokens
}
quorum: gov_params(limit: 1, order_by: {height: desc}) {
tallyParams: tally_params
tallyParams: params
}
}
`;
Expand Down
74 changes: 74 additions & 0 deletions apps/web-stratos/src/models/gov_params/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import * as R from 'ramda';

class GovParams {
public depositParams: {
minDeposit: Array<{
denom: string;
amount: string;
}>;
maxDepositPeriod: number;
};

public tallyParams: {
quorum: string;
threshold: string;
vetoThreshold: string;
};

public votingParams: {
votingPeriod: number;
};

constructor(payload: object) {
this.depositParams = R.pathOr(
{
minDeposit: [],
maxDepositPeriod: 0,
},
['depositParams'],
payload
);
this.tallyParams = R.pathOr(
{
quorum: '',
threshold: '',
vetoThreshold: '',
},
['tallyParams'],
payload
);
this.votingParams = R.pathOr(
{
votingPeriod: 0,
},
['votingParams'],
payload
);
}

static fromJson(data: object): GovParams {
return {
depositParams: {
minDeposit: R.pathOr<GovParams['depositParams']['minDeposit']>(
[],
['params', 'min_deposit'],
data
).map((x) => ({
denom: x.denom,
amount: String(x.amount),
})),
maxDepositPeriod: R.pathOr(0, ['params', 'max_deposit_period'], data),
},
tallyParams: {
quorum: R.pathOr('0', ['params', 'quorum'], data),
threshold: R.pathOr('0', ['params', 'threshold'], data),
vetoThreshold: R.pathOr('0', ['params', 'veto_threshold'], data),
},
votingParams: {
votingPeriod: R.pathOr(0, ['params', 'voting_period'], data),
},
};
}
}

export default GovParams;
Loading

0 comments on commit 80246d0

Please sign in to comment.