Skip to content

Commit

Permalink
Merge pull request #23 from CoreumFoundation/update/final-changes-big…
Browse files Browse the repository at this point in the history
…Dipper

Update/final changes big dipper
  • Loading branch information
jccifuentes21 authored Mar 13, 2023
2 parents e66ff48 + 113710f commit 0be9656
Show file tree
Hide file tree
Showing 16 changed files with 63 additions and 35 deletions.
3 changes: 1 addition & 2 deletions apps/web-coreum/codegen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ generates:
./src/graphql/types/general_types.ts:
documents:
- 'src/graphql/general/*'
# schema: https://gql.desmos.forbole.com/v1/graphql
schema: https://hasura.testnet-1.coreum.dev/v1/graphql
schema: https://hasura.devnet-1.coreum.dev/v1/graphql
config:
# omitOperationSuffix: true
skipTypeNameForRoot: true
Expand Down
2 changes: 1 addition & 1 deletion apps/web-coreum/public/locales/en/message_contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@
"MsgRevokeAllowance": "<0>{{granter}}</0> revoked allowance for <1>{{grantee}}</1>",
"MsgCreateVestingAccount": "Vesting account created for <0>{{toAddress}}</0>",
"MsgCreatePeriodicVestingAccount": "Periodic vesting account created for <0>{{toAddress}}</0>",
"msgIssueContent": "<0>{{issuer}}</0> issued <1>{{amount}}</1> units of <1>{{symbol}}</1> "
"msgIssueContent": "<0>{{issuer}}</0> issued <1>{{amount}}</1> units of <1>{{subunit}}</1> "
}
2 changes: 2 additions & 0 deletions apps/web-coreum/public/locales/en/params.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"maxEntries": "Max Entries",
"historicalEntries": "Historical Entries",
"maxValidators": "Max Validators",
"minSelfDelegation": "Min Self Delegation",
"slashing": "Slashing",
"downtimeJailDuration": "Downtime Jail Duration",
"minSignedPerWindow": "Min Signed Per Window",
Expand All @@ -33,6 +34,7 @@
"threshold": "Threshold",
"vetoThreshold": "Veto Threshold",
"votingPeriod": "Voting Period",
"feeModel": "Fee Model",
"maxDiscount": "Max Discount",
"maxBlockGas": "Max Block Gas",
"initialGasPrice": "Initial Gas Price",
Expand Down
6 changes: 5 additions & 1 deletion apps/web-coreum/src/graphql/types/general_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11763,7 +11763,7 @@ 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', depositParams: any, tallyParams: any, votingParams: any }>, feeModelParams: Array<{__typename?: 'feemodel_params', params: any}>, customParams: Array<{__typename?: 'custom_params', customStakingParams: any }> };

export type ProposalDetailsQueryVariables = Exact<{
proposalId?: InputMaybe<Scalars['Int']>;
Expand Down Expand Up @@ -12766,9 +12766,13 @@ export const ParamsDocument = gql`
tallyParams: tally_params
votingParams: voting_params
}
#Commented Out until backed is updated
#feeModelParams: feemodel_params (limit: 1, order_by: {height: desc}) {
# params
#}
#customParams: customparams_params (limit: 1, order_by: {height: desc}) {
# customStakingParams: staking_params
#}
}
`;

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"test:ci": "yarn turbo:setup -- turbo run test --continue",
"e2e": "playwright test",
"e2e:install": "playwright install --with-deps",
"graphql:codegen": "turbo:setup -- turbo run graphql:codegen --continue",
"graphql:codegen": "turbo run graphql:codegen --continue --trace-warnings",
"postinstall": "husky install",
"dotenv:setup": "dotenv -v TURBO_BINARY_PATH=$(yarn turbo:env)",
"turbo:setup": "dotenv -v TURBO_BINARY_PATH=$(yarn turbo:env) -e /dev/null",
Expand Down
1 change: 1 addition & 0 deletions packages/ui/public/locales/en/params.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"maxEntries": "Max Entries",
"historicalEntries": "Historical Entries",
"maxValidators": "Max Validators",
"minSelfDelegation": "Min Self Delegation",
"slashing": "Slashing",
"downtimeJailDuration": "Downtime Jail Duration",
"minSignedPerWindow": "Min Signed Per Window",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/msg/asset/issue/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const Issue: FC<{ message: MsgIssue }> = (props) => {
values={{
issuer: message.issuer,
amount: message.initial_amount,
symbol: message.symbol,
subunit: message.subunit,
}}
/>
</Typography>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const Desktop: FC<TransactionsListState> = ({
className,
itemCount,
loadMoreItems,
hasNextPage,
isNextPageLoading,
isItemLoaded,
transactions,
}) => {
Expand All @@ -46,14 +48,19 @@ const Desktop: FC<TransactionsListState> = ({
),
type: (
<div>
<Tag value={x.type?.[0] ?? ''} theme="six" />
{x.messages.count > 1 && ` + ${x.messages.count - 1}`}
<Tag value={x.type?.[0] ? x.type[0] : ''} theme="six" />
{x.messages.count > 1 ? ` + ${x.messages.count - 1}` : ''}
</div>
),
result: <Result success={x.success} />,
time: <Timestamp timestamp={x.timestamp} />,
messages: numeral(x.messages.count).format('0,0'),
}));

if (itemCount < 10 && hasNextPage && !isNextPageLoading && loadMoreItems) {
loadMoreItems();
}

return (
<div className={cx(classes.root, className)}>
<AutoSizer onResize={onResize}>
Expand Down Expand Up @@ -121,7 +128,11 @@ const Desktop: FC<TransactionsListState> = ({
className="scrollbar"
>
{({ columnIndex, rowIndex, style }) => {
if (!isItemLoaded?.(rowIndex) && columnIndex === 0) {
if (
!isItemLoaded?.(rowIndex) &&
columnIndex === 0
// rowIndex < transactions.length
) {
return (
<div
style={{
Expand Down
5 changes: 1 addition & 4 deletions packages/ui/src/graphql/types/general_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11763,7 +11763,7 @@ 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 }>, feeModelParams: Array<{__typename?: 'feemodel_params', params: 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', depositParams: any, tallyParams: any, votingParams: any }>, feeModelParams: Array<{__typename?: 'feemodel_params', params: any}>, customParams: Array<{__typename?: 'custom_params', customStakingParams: any }> };

export type ProposalDetailsQueryVariables = Exact<{
proposalId?: InputMaybe<Scalars['Int']>;
Expand Down Expand Up @@ -12766,9 +12766,6 @@ export const ParamsDocument = gql`
tallyParams: tally_params
votingParams: voting_params
}
feeModelParams: feemodel_params (limit: 1, order_by: {height: desc}) {
params
}
}
`;

Expand Down
12 changes: 12 additions & 0 deletions packages/ui/src/models/staking_params/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,17 @@ class StakingParams {
};
}
}
export class customStakingParams {
public minSelfDelegation: number;

constructor(payload: object) {
this.minSelfDelegation = R.pathOr(0, ['minSelfDelegation'], payload);
}
static fromJson(data: object): customStakingParams {
return {
minSelfDelegation: R.pathOr(0, ['min_self_delegation'], data),
};
}
}

export default StakingParams;
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import {
import type { TransactionState } from '@/screens/account_details/components/transactions/types';
import { convertMsgType } from '@/utils/convert_msg_type';

const LIMIT = 50;
const LIMIT = 100;
const LIMITPlusOne = LIMIT + 1;

const formatTransactions = (data: GetMessagesByAddressQuery): Transactions[] => {
let formattedData = data.messagesByAddress;
if (data.messagesByAddress.length === 51) {
formattedData = data.messagesByAddress.slice(0, 51);
if (data.messagesByAddress.length === LIMITPlusOne) {
formattedData = data.messagesByAddress.slice(0, LIMITPlusOne);
}
return formattedData.map((x) => {
const { transaction } = x;
Expand Down Expand Up @@ -67,9 +68,10 @@ export function useTransactions() {
onCompleted: (data) => {
const itemsLength = data.messagesByAddress.length;
const newItems = R.uniq([...state.data, ...formatTransactions(data)]);

const stateChange: TransactionState = {
data: newItems,
hasNextPage: itemsLength === 51,
hasNextPage: itemsLength === LIMITPlusOne,
isNextPageLoading: false,
offsetCount: state.offsetCount + LIMIT,
};
Expand All @@ -85,15 +87,15 @@ export function useTransactions() {
.fetchMore({
variables: {
offset: state.offsetCount,
limit: LIMIT + 1,
limit: LIMITPlusOne,
},
})
.then(({ data }) => {
const itemsLength = data.messagesByAddress.length;
const newItems = R.uniq([...state.data, ...formatTransactions(data)]);
const stateChange: TransactionState = {
data: newItems,
hasNextPage: itemsLength === 51,
hasNextPage: itemsLength === LIMITPlusOne,
isNextPageLoading: false,
offsetCount: state.offsetCount + LIMIT,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ const useStyles = makeStyles<{ percentage: number | string }>()((theme, { percen
alignItems: 'center',
justifyContent: 'space-between',
padding: theme.spacing(1),
borderBottom: `1px solid ${theme.palette.divider}`,
'&:last-child': {
borderBottom: 'none',
},
'& .label': {
color: theme.palette.custom.fonts.fontThree,
},
Expand Down
9 changes: 1 addition & 8 deletions packages/ui/src/screens/home/components/tokenomics/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,8 @@ const Tokenomics: FC<ComponentDefault> = ({ className }) => {
</Pie>
<Tooltip content={customToolTip} />
</DynamicPieChart>
{/* <div className={classes.legends}>
{data.map((x) => (
<div className="legends__item" key={x.legendKey}>
<Typography variant="caption">{t(x.legendKey)}</Typography>
</div>
))}
</div> */}
</div>
{/* */}

<div className={classes.data}>
{data.slice(0, 2).map((x) => (
<div className="data__item" key={x.percentKey}>
Expand Down
8 changes: 6 additions & 2 deletions packages/ui/src/screens/params/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
StakingParams,
FeeModelParams,
} from '@/models';
import { customStakingParams } from '@/models/staking_params';
import type { ParamsState } from '@/screens/params/types';
import { formatToken } from '@/utils/format_token';

Expand All @@ -33,12 +34,16 @@ const initialState: ParamsState = {
const formatStaking = (data: ParamsQuery) => {
if (data.stakingParams.length) {
const stakingParamsRaw = StakingParams.fromJson(data?.stakingParams?.[0]?.params ?? {});
const customStakingParamsRaw = customStakingParams.fromJson(
data?.customParams?.[0]?.customStakingParams ?? {}
);
return {
bondDenom: stakingParamsRaw.bondDenom,
unbondingTime: stakingParamsRaw.unbondingTime,
maxEntries: stakingParamsRaw.maxEntries,
historicalEntries: stakingParamsRaw.historicalEntries,
maxValidators: stakingParamsRaw.maxValidators,
minSelfDelegation: customStakingParamsRaw.minSelfDelegation,
};
}

Expand Down Expand Up @@ -130,9 +135,8 @@ const formatGov = (data: ParamsQuery) => {
// fee model params
// ================================
const formatFeeModel = (data: ParamsQuery) => {
console.log(data);
if (data.feeModelParams?.length) {
const feeModelParamsRaw = FeeModelParams.fromJson(data?.feeModelParams?.[0] ?? {});
const feeModelParamsRaw = FeeModelParams.fromJson(data?.feeModelParams?.[0].params.model ?? {});

return {
maxDiscount: feeModelParamsRaw.maxDiscount,
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/screens/params/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface Staking {
maxEntries: number;
historicalEntries: number;
maxValidators: number;
minSelfDelegation?: number;
}

export interface Slashing {
Expand Down
10 changes: 8 additions & 2 deletions packages/ui/src/screens/params/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ export const formatStaking = (data: Staking, t: TFunction) => [
label: t('maxValidators'),
detail: numeral(data.maxValidators).format('0,0'),
},
// commented out until backend is updated
// {
// key: 'minSelfDelegation',
// label: t('minSelfDelegation'),
// detail: `${numeral(data.minSelfDelegation).format('0,0')} ${data.bondDenom}`,
// },
];

export const formatSlashing = (data: Slashing, t: TFunction) => [
Expand Down Expand Up @@ -182,7 +188,7 @@ export const formatFeeModel = (data: FeeModel, t: TFunction) => [
{
key: 'initialGasPrice',
label: t('initialGasPrice'),
detail: numeral(data.initialGasPrice).format('0,0'),
detail: numeral(data.initialGasPrice).format('0.[0000]'),
},
{
key: 'longEmaBlockLength',
Expand All @@ -202,6 +208,6 @@ export const formatFeeModel = (data: FeeModel, t: TFunction) => [
{
key: 'escalationStartFraction',
label: t('escalationStartFraction'),
detail: numeral(data.escalationStartFraction).format('0,0'),
detail: numeral(data.escalationStartFraction).format('0.[000]'),
},
];

0 comments on commit 0be9656

Please sign in to comment.