From 893606131380196396397b71abd6492e10341179 Mon Sep 17 00:00:00 2001 From: Oleksandr Khlopiachyi Date: Wed, 8 Jan 2025 13:49:05 +0200 Subject: [PATCH] feat: add support for custom messages, add dex params --- .../public/locales/en/message_contents.json | 10 ++- apps/web-coreum/public/locales/en/params.json | 7 +- .../src/graphql/types/general_types.ts | 83 +++++++++++-------- .../msg/asset/clear_admin/index.tsx | 26 ++++++ .../msg/asset/transfer_admin/index.tsx | 27 ++++++ .../msg/asset/update_data/index.tsx | 27 ++++++ .../update_dex_unified_ref_amount/index.tsx | 27 ++++++ .../update_dex_whitelisted_denoms/index.tsx | 27 ++++++ .../components/msg/dex/cancel_order/index.tsx | 26 ++++++ .../msg/dex/cancel_orders_by_denom/index.tsx | 26 ++++++ .../components/msg/dex/place_order/index.tsx | 31 +++++++ packages/ui/src/components/msg/index.ts | 8 ++ packages/ui/src/components/msg/utils.tsx | 48 +++++++++++ .../ui/src/graphql/general/params.graphql | 3 + .../ui/src/graphql/types/general_types.ts | 56 ++++++++----- packages/ui/src/models/dex_params/index.ts | 32 +++++++ packages/ui/src/models/index.ts | 8 ++ .../src/models/msg/asset/msg_clear_admin.ts | 31 +++++++ .../models/msg/asset/msg_transfer_admin.ts | 35 ++++++++ .../src/models/msg/asset/msg_update_data.ts | 44 ++++++++++ .../msg_update_dex_unified_ref_amount.ts | 35 ++++++++ .../msg_update_dex_whitelisted_denoms.ts | 35 ++++++++ .../ui/src/models/msg/dex/msg_cancel_order.ts | 31 +++++++ .../msg/dex/msg_cancel_orders_by_denom.ts | 35 ++++++++ .../ui/src/models/msg/dex/msg_place_order.ts | 62 ++++++++++++++ packages/ui/src/models/msg/types/index.ts | 2 +- packages/ui/src/screens/params/hooks.ts | 14 +++- packages/ui/src/screens/params/index.tsx | 9 ++ packages/ui/src/screens/params/types.ts | 11 +++ packages/ui/src/screens/params/utils.tsx | 24 ++++++ 30 files changed, 781 insertions(+), 59 deletions(-) create mode 100644 packages/ui/src/components/msg/asset/clear_admin/index.tsx create mode 100644 packages/ui/src/components/msg/asset/transfer_admin/index.tsx create mode 100644 packages/ui/src/components/msg/asset/update_data/index.tsx create mode 100644 packages/ui/src/components/msg/asset/update_dex_unified_ref_amount/index.tsx create mode 100644 packages/ui/src/components/msg/asset/update_dex_whitelisted_denoms/index.tsx create mode 100644 packages/ui/src/components/msg/dex/cancel_order/index.tsx create mode 100644 packages/ui/src/components/msg/dex/cancel_orders_by_denom/index.tsx create mode 100644 packages/ui/src/components/msg/dex/place_order/index.tsx create mode 100644 packages/ui/src/models/dex_params/index.ts create mode 100644 packages/ui/src/models/msg/asset/msg_clear_admin.ts create mode 100644 packages/ui/src/models/msg/asset/msg_transfer_admin.ts create mode 100644 packages/ui/src/models/msg/asset/msg_update_data.ts create mode 100644 packages/ui/src/models/msg/asset/msg_update_dex_unified_ref_amount.ts create mode 100644 packages/ui/src/models/msg/asset/msg_update_dex_whitelisted_denoms.ts create mode 100644 packages/ui/src/models/msg/dex/msg_cancel_order.ts create mode 100644 packages/ui/src/models/msg/dex/msg_cancel_orders_by_denom.ts create mode 100644 packages/ui/src/models/msg/dex/msg_place_order.ts diff --git a/apps/web-coreum/public/locales/en/message_contents.json b/apps/web-coreum/public/locales/en/message_contents.json index 521fc9ea99..b63597a378 100644 --- a/apps/web-coreum/public/locales/en/message_contents.json +++ b/apps/web-coreum/public/locales/en/message_contents.json @@ -73,5 +73,13 @@ "msgNftUnfreezeContent": "Account <0>{{sender}} has unfrozen NFT <1>{{id}} with class <2>{{class_id}}", "msgNftIssueClassContent": "A new NFT Class <0>{{name}} has been issued by <1>{{issuer}}", "msgNftSendContent": "Account <0>{{sender}} has sent NFT <1>{{id}} with class <2>{{class_id}} to <3>{{recipient}}", - "msgUpgradeTokenContent": "<0>{{sender}} has set the IBC for the token <1>{{denom}} to {{ibc_enabled}}" + "msgUpgradeTokenContent": "<0>{{sender}} has set the IBC for the token <1>{{denom}} to {{ibc_enabled}}", + "msgUpdateDexWhitelistedDenoms": "<0>{{sender}} has set whitelisted denoms for the token <1>{{denom}} to {{whitelisted_denoms}}", + "msgUpdateDEXUnifiedRefAmount": "<0>{{sender}} has set unified ref amount for the token <1>{{denom}} to {{unified_ref_amount}}", + "msgPlaceOrder": "<0>{{sender}} placed an order with id <1>{{id}} where base denom is <1>{{base_denom}}, quote_denom is <1>{{quote_denom}}, price - <1>{{price}}, quantity - <1>{{quantity}}, side - <1>{{side}}", + "msgCancelOrder": "<0>{{sender}} canceled the order with id <1>{{id}}", + "msgCancelOrdersByDenom": "<0>{{sender}} canceled all opened order for the token <1>{{denom}}", + "msgUpdateData": "<0>{{sender}} updated data for nft with id - <1>{{id}} of nft class <1>{{class_id}}", + "msgTransferAdmin": "<0>{{sender}} set as admin account <0>{{account}} for the token <1>{{denom}}", + "msgClearAdmin": "<0>{{sender}} cleared the list of admins for the token <1>{{denom}}" } diff --git a/apps/web-coreum/public/locales/en/params.json b/apps/web-coreum/public/locales/en/params.json index 4d31c89760..01a627ed71 100644 --- a/apps/web-coreum/public/locales/en/params.json +++ b/apps/web-coreum/public/locales/en/params.json @@ -53,5 +53,10 @@ "maxMemoCharacters": "Max memo characters", "txSizeCostPerByte": "Tx Size cost per byte", "sigVerifyCostEd25519": "Signature verify cost ed25519", - "sigVerifyCostSecp256k1": "Signature verify cost secp256k1" + "sigVerifyCostSecp256k1": "Signature verify cost secp256k1", + "dex": "DEX", + "defaultUnifiedRefAmount": "Default Unified Ref Amount", + "maxOrdersPerDenom": "Max Orders Per Denom", + "priceTickExponent": "Price Tick Exponent", + "orderReserve": "Order Reserve" } diff --git a/apps/web-coreum/src/graphql/types/general_types.ts b/apps/web-coreum/src/graphql/types/general_types.ts index 8dca540b17..00196331e4 100644 --- a/apps/web-coreum/src/graphql/types/general_types.ts +++ b/apps/web-coreum/src/graphql/types/general_types.ts @@ -11758,7 +11758,19 @@ 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', params: any }>, authParams: Array<{ __typename?: 'auth_params', params: any }>, feeModelParams: Array<{__typename?: 'feemodel_params', params: any}>, customParams: Array<{__typename?: 'custom_params', customStakingParams: any }>, nftParams: Array<{ __typename?: 'assetnft_params', params: any }>, ftParams: Array<{ __typename?: 'assetft_params', params: any, token_upgrade_grace_period: any, token_upgrade_decision_timeout: 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', params: any }>, + authParams: Array<{ __typename?: 'auth_params', params: any }>, + feeModelParams: Array<{__typename?: 'feemodel_params', params: any}>, + customParams: Array<{__typename?: 'custom_params', customStakingParams: any }>, + nftParams: Array<{ __typename?: 'assetnft_params', params: any }>, + ftParams: Array<{ __typename?: 'assetft_params', params: any, token_upgrade_grace_period: any, token_upgrade_decision_timeout: any }>, + dexParams: Array<{ __typename?: 'dex_params', params: any }>, +}; export type ProposalDetailsQueryVariables = Exact<{ proposalId?: InputMaybe; @@ -12751,40 +12763,43 @@ export type OnlineVotingPowerQueryHookResult = ReturnType; export type OnlineVotingPowerQueryResult = Apollo.QueryResult; export const ParamsDocument = gql` - query Params { - stakingParams: staking_params(limit: 1, order_by: {height: desc}) { - params - } - slashingParams: slashing_params(limit: 1, order_by: {height: desc}) { - params - } - mintParams: mint_params(limit: 1, order_by: {height: desc}) { - params - } - distributionParams: distribution_params(limit: 1, order_by: {height: desc}) { - params - } - govParams: gov_params(limit: 1, order_by: {height: desc, params: asc}) { - 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 - } - nftParams: assetnft_params { - params - } - ftParams: assetft_params{ - params - } - authParams: auth_params(limit: 1, order_by: {height: desc, params: asc }) { - params + query Params { + stakingParams: staking_params(limit: 1, order_by: {height: desc}) { + params + } + slashingParams: slashing_params(limit: 1, order_by: {height: desc}) { + params + } + mintParams: mint_params(limit: 1, order_by: {height: desc}) { + params + } + distributionParams: distribution_params(limit: 1, order_by: {height: desc}) { + params + } + govParams: gov_params(limit: 1, order_by: {height: desc, params: asc}) { + 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 + } + nftParams: assetnft_params { + params + } + ftParams: assetft_params{ + params + } + authParams: auth_params(limit: 1, order_by: {height: desc, params: asc }) { + params + } + dexParams: dex_params(limit: 1, order_by: {height: desc, params: asc }) { + params + } } -} - `; +`; /** * __useParamsQuery__ diff --git a/packages/ui/src/components/msg/asset/clear_admin/index.tsx b/packages/ui/src/components/msg/asset/clear_admin/index.tsx new file mode 100644 index 0000000000..1ba9b13163 --- /dev/null +++ b/packages/ui/src/components/msg/asset/clear_admin/index.tsx @@ -0,0 +1,26 @@ +import { FC } from 'react'; +import { useProfileRecoil } from '@/recoil/profiles'; +import { Typography } from '@mui/material'; +import { Trans } from 'react-i18next'; +import Name from '@/components/name'; +import { MsgClearAdmin } from '@/models'; + +const ClearAdmin: FC<{ message: MsgClearAdmin }> = (props) => { + const { message } = props; + const sender = useProfileRecoil(message.sender); + + return ( + + , ]} + values={{ + sender: message.sender, + denom: message.denom.toUpperCase(), + }} + /> + + ); +}; + +export default ClearAdmin; diff --git a/packages/ui/src/components/msg/asset/transfer_admin/index.tsx b/packages/ui/src/components/msg/asset/transfer_admin/index.tsx new file mode 100644 index 0000000000..54e981a741 --- /dev/null +++ b/packages/ui/src/components/msg/asset/transfer_admin/index.tsx @@ -0,0 +1,27 @@ +import { FC } from 'react'; +import { useProfileRecoil } from '@/recoil/profiles'; +import { Typography } from '@mui/material'; +import { Trans } from 'react-i18next'; +import Name from '@/components/name'; +import { MsgTransferAdmin } from '@/models'; + +const TransferAdmin: FC<{ message: MsgTransferAdmin }> = (props) => { + const { message } = props; + const sender = useProfileRecoil(message.sender); + + return ( + + , ]} + values={{ + sender: message.sender, + denom: message.denom.toUpperCase(), + account: message.account, + }} + /> + + ); +}; + +export default TransferAdmin; diff --git a/packages/ui/src/components/msg/asset/update_data/index.tsx b/packages/ui/src/components/msg/asset/update_data/index.tsx new file mode 100644 index 0000000000..7575bcefcc --- /dev/null +++ b/packages/ui/src/components/msg/asset/update_data/index.tsx @@ -0,0 +1,27 @@ +import { FC } from 'react'; +import { useProfileRecoil } from '@/recoil/profiles'; +import { Typography } from '@mui/material'; +import { Trans } from 'react-i18next'; +import Name from '@/components/name'; +import { MsgUpdateData } from '@/models'; + +const UpdateData: FC<{ message: MsgUpdateData }> = (props) => { + const { message } = props; + const sender = useProfileRecoil(message.sender); + + return ( + + , ]} + values={{ + sender: message.sender, + class_id: message.class_id, + id: message.id, + }} + /> + + ); +}; + +export default UpdateData; diff --git a/packages/ui/src/components/msg/asset/update_dex_unified_ref_amount/index.tsx b/packages/ui/src/components/msg/asset/update_dex_unified_ref_amount/index.tsx new file mode 100644 index 0000000000..648c434f4f --- /dev/null +++ b/packages/ui/src/components/msg/asset/update_dex_unified_ref_amount/index.tsx @@ -0,0 +1,27 @@ +import { FC } from 'react'; +import { useProfileRecoil } from '@/recoil/profiles'; +import { Typography } from '@mui/material'; +import { Trans } from 'react-i18next'; +import Name from '@/components/name'; +import { MsgUpdateDEXUnifiedRefAmount } from '@/models'; + +const UpdateDEXWUnifiedRefAmount: FC<{ message: MsgUpdateDEXUnifiedRefAmount }> = (props) => { + const { message } = props; + const sender = useProfileRecoil(message.sender); + + return ( + + , ]} + values={{ + sender: message.sender, + denom: message.denom.toUpperCase(), + unified_ref_amount: message.unified_ref_amount, + }} + /> + + ); +}; + +export default UpdateDEXWUnifiedRefAmount; diff --git a/packages/ui/src/components/msg/asset/update_dex_whitelisted_denoms/index.tsx b/packages/ui/src/components/msg/asset/update_dex_whitelisted_denoms/index.tsx new file mode 100644 index 0000000000..2a3f2fe266 --- /dev/null +++ b/packages/ui/src/components/msg/asset/update_dex_whitelisted_denoms/index.tsx @@ -0,0 +1,27 @@ +import { FC } from 'react'; +import { useProfileRecoil } from '@/recoil/profiles'; +import { Typography } from '@mui/material'; +import { Trans } from 'react-i18next'; +import Name from '@/components/name'; +import { MsgUpdateDEXWhitelistedDenoms } from '@/models'; + +const UpdateDEXWhitelistedDenoms: FC<{ message: MsgUpdateDEXWhitelistedDenoms }> = (props) => { + const { message } = props; + const sender = useProfileRecoil(message.sender); + + return ( + + , ]} + values={{ + sender: message.sender, + denom: message.denom.toUpperCase(), + whitelisted_denoms: message.whitelisted_denoms.toString(), + }} + /> + + ); +}; + +export default UpdateDEXWhitelistedDenoms; diff --git a/packages/ui/src/components/msg/dex/cancel_order/index.tsx b/packages/ui/src/components/msg/dex/cancel_order/index.tsx new file mode 100644 index 0000000000..535432e972 --- /dev/null +++ b/packages/ui/src/components/msg/dex/cancel_order/index.tsx @@ -0,0 +1,26 @@ +import { FC } from 'react'; +import { useProfileRecoil } from '@/recoil/profiles'; +import { Typography } from '@mui/material'; +import { Trans } from 'react-i18next'; +import Name from '@/components/name'; +import { MsgCancelOrder } from '@/models'; + +const CancelOrder: FC<{ message: MsgCancelOrder }> = (props) => { + const { message } = props; + const sender = useProfileRecoil(message.sender); + + return ( + + , ]} + values={{ + sender: message.sender, + id: message.id, + }} + /> + + ); +}; + +export default CancelOrder; diff --git a/packages/ui/src/components/msg/dex/cancel_orders_by_denom/index.tsx b/packages/ui/src/components/msg/dex/cancel_orders_by_denom/index.tsx new file mode 100644 index 0000000000..1e7e6a0ae2 --- /dev/null +++ b/packages/ui/src/components/msg/dex/cancel_orders_by_denom/index.tsx @@ -0,0 +1,26 @@ +import { FC } from 'react'; +import { useProfileRecoil } from '@/recoil/profiles'; +import { Typography } from '@mui/material'; +import { Trans } from 'react-i18next'; +import Name from '@/components/name'; +import { MsgCancelOrdersByDenom } from '@/models'; + +const CancelOrdersByDenom: FC<{ message: MsgCancelOrdersByDenom }> = (props) => { + const { message } = props; + const sender = useProfileRecoil(message.sender); + + return ( + + , ]} + values={{ + sender: message.sender, + denom: message.denom, + }} + /> + + ); +}; + +export default CancelOrdersByDenom; diff --git a/packages/ui/src/components/msg/dex/place_order/index.tsx b/packages/ui/src/components/msg/dex/place_order/index.tsx new file mode 100644 index 0000000000..9527c985b0 --- /dev/null +++ b/packages/ui/src/components/msg/dex/place_order/index.tsx @@ -0,0 +1,31 @@ +import { FC } from 'react'; +import { useProfileRecoil } from '@/recoil/profiles'; +import { Typography } from '@mui/material'; +import { Trans } from 'react-i18next'; +import Name from '@/components/name'; +import { MsgPlaceOrder } from '@/models'; + +const PlaceOrder: FC<{ message: MsgPlaceOrder }> = (props) => { + const { message } = props; + const sender = useProfileRecoil(message.sender); + + return ( + + , ]} + values={{ + sender: message.sender, + id: message.id, + base_denom: message.base_denom, + quote_denom: message.quote_denom, + price: message.price, + quantity: message.quantity, + side: message.side, + }} + /> + + ); +}; + +export default PlaceOrder; diff --git a/packages/ui/src/components/msg/index.ts b/packages/ui/src/components/msg/index.ts index 3fed54e991..0544a5b9d3 100644 --- a/packages/ui/src/components/msg/index.ts +++ b/packages/ui/src/components/msg/index.ts @@ -77,3 +77,11 @@ export { default as NftIssueClass } from '@/components/msg/asset/nft_issue_class export { default as NftSend } from '@/components/msg/nft/send'; export { default as NftAddToWhitelist } from '@/components/msg/asset/nft_add_whitelist'; export { default as NftRemoveFromWhitelist } from '@/components/msg/asset/nft_remove_whitelist'; +export { default as UpdateDEXWhitelistedDenoms } from '@/components/msg/asset/update_dex_whitelisted_denoms'; +export { default as UpdateDEXUnifiedRefAmount } from '@/components/msg/asset/update_dex_unified_ref_amount'; +export { default as PlaceOrder } from '@/components/msg/dex/place_order'; +export { default as CancelOrder } from '@/components/msg/dex/cancel_order'; +export { default as CancelOrdersByDenom } from '@/components/msg/dex/cancel_orders_by_denom'; +export { default as TransferAdmin } from '@/components/msg/asset/transfer_admin'; +export { default as ClearAdmin } from '@/components/msg/asset/clear_admin'; +export { default as UpdateData } from '@/components/msg/asset/update_data'; diff --git a/packages/ui/src/components/msg/utils.tsx b/packages/ui/src/components/msg/utils.tsx index c7d2fe70c6..163374d965 100644 --- a/packages/ui/src/components/msg/utils.tsx +++ b/packages/ui/src/components/msg/utils.tsx @@ -515,6 +515,54 @@ const customTypeToModel = { tagTheme: 'six', tagDisplay: 'msgUpgradeTokenLabel', }, + '/coreum.asset.ft.v1.MsgUpdateDEXUnifiedRefAmount': { + model: MODELS.MsgUpdateDEXUnifiedRefAmount, + content: COMPONENTS.UpdateDEXUnifiedRefAmount, + tagTheme: 'six', + tagDisplay: 'msgUpdateDEXUnifiedRefAmount', + }, + '/coreum.asset.ft.v1.MsgUpdateDEXWhitelistedDenoms': { + model: MODELS.MsgUpdateDEXWhitelistedDenoms, + content: COMPONENTS.UpdateDEXWhitelistedDenoms, + tagTheme: 'six', + tagDisplay: 'msgUpdateDexWhitelistedDenoms', + }, + '/coreum.dex.v1.MsgPlaceOrder': { + model: MODELS.MsgPlaceOrder, + content: COMPONENTS.PlaceOrder, + tagTheme: 'six', + tagDisplay: 'msgPlaceOrder', + }, + '/coreum.dex.v1.MsgCancelOrder': { + model: MODELS.MsgCancelOrder, + content: COMPONENTS.CancelOrder, + tagTheme: 'six', + tagDisplay: 'msgCancelOrder', + }, + '/coreum.dex.v1.MsgCancelOrdersByDenom': { + model: MODELS.MsgCancelOrdersByDenom, + content: COMPONENTS.CancelOrdersByDenom, + tagTheme: 'six', + tagDisplay: 'msgCancelOrdersByDenom', + }, + '/coreum.asset.ft.v1.MsgTransferAdmin': { + model: MODELS.MsgTransferAdmin, + content: COMPONENTS.TransferAdmin, + tagTheme: 'six', + tagDisplay: 'msgTransferAdmin', + }, + '/coreum.asset.ft.v1.MsgClearAdmin': { + model: MODELS.MsgClearAdmin, + content: COMPONENTS.ClearAdmin, + tagTheme: 'six', + tagDisplay: 'msgClearAdmin', + }, + '/coreum.asset.nft.v1.MsgUpdateData': { + model: MODELS.MsgUpdateData, + content: COMPONENTS.UpdateData, + tagTheme: 'six', + tagDisplay: 'msgUpdateData', + }, }; type CustomTypeToModel = typeof customTypeToModel; diff --git a/packages/ui/src/graphql/general/params.graphql b/packages/ui/src/graphql/general/params.graphql index 66ff7ca438..3a8db64936 100644 --- a/packages/ui/src/graphql/general/params.graphql +++ b/packages/ui/src/graphql/general/params.graphql @@ -20,4 +20,7 @@ query Params { authParams: auth_params(limit: 1, order_by: {height: desc, params: asc }) { params } + dexParams: dex_params(limit: 1, order_by: {height: desc, params: asc }) { + params + } } diff --git a/packages/ui/src/graphql/types/general_types.ts b/packages/ui/src/graphql/types/general_types.ts index 66d5f4a93a..f14bd53861 100644 --- a/packages/ui/src/graphql/types/general_types.ts +++ b/packages/ui/src/graphql/types/general_types.ts @@ -11759,7 +11759,18 @@ 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', params: any }>, authParams: Array<{ __typename?: 'auth_params', params: any }>, feeModelParams: Array<{__typename?: 'feemodel_params', params: any}>, customParams: Array<{__typename?: 'custom_params', customStakingParams: any }> , nftParams: Array<{ __typename?: 'nft_params', params: any }>, ftParams: Array<{ __typename?: 'ft_params', params: any, token_upgrade_grace_period: any, token_upgrade_decision_timeout: 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', params: any }>, + authParams: Array<{ __typename?: 'auth_params', params: any }>, + feeModelParams: Array<{__typename?: 'feemodel_params', params: any}>, + customParams: Array<{__typename?: 'custom_params', customStakingParams: any }> , + nftParams: Array<{ __typename?: 'nft_params', params: any }>, + ftParams: Array<{ __typename?: 'ft_params', params: any, token_upgrade_grace_period: any, token_upgrade_decision_timeout: any }>, + dexParams: Array<{ __typename?: 'dex_params', params: any }>, }; export type ProposalDetailsQueryVariables = Exact<{ @@ -12756,27 +12767,30 @@ export type OnlineVotingPowerQueryHookResult = ReturnType; export type OnlineVotingPowerQueryResult = Apollo.QueryResult; export const ParamsDocument = gql` - query Params { - stakingParams: staking_params(limit: 1, order_by: {height: desc}) { - params - } - slashingParams: slashing_params(limit: 1, order_by: {height: desc}) { - params - } - mintParams: mint_params(limit: 1, order_by: {height: desc}) { - params - } - distributionParams: distribution_params(limit: 1, order_by: {height: desc}) { - params - } - govParams: gov_params(limit: 1, order_by: {height: desc, params: asc}) { - params - } - authParams: auth_params(limit: 1, order_by: {height: desc, params: asc }) { - params + query Params { + stakingParams: staking_params(limit: 1, order_by: {height: desc}) { + params + } + slashingParams: slashing_params(limit: 1, order_by: {height: desc}) { + params + } + mintParams: mint_params(limit: 1, order_by: {height: desc}) { + params + } + distributionParams: distribution_params(limit: 1, order_by: {height: desc}) { + params + } + govParams: gov_params(limit: 1, order_by: {height: desc, params: asc}) { + params + } + authParams: auth_params(limit: 1, order_by: {height: desc, params: asc }) { + params + } + dexParams: dex_params(limit: 1, order_by: {height: desc, params: asc }) { + params + } } -} - `; +`; /** * __useParamsQuery__ diff --git a/packages/ui/src/models/dex_params/index.ts b/packages/ui/src/models/dex_params/index.ts new file mode 100644 index 0000000000..f3cab73ad2 --- /dev/null +++ b/packages/ui/src/models/dex_params/index.ts @@ -0,0 +1,32 @@ +import * as R from 'ramda'; + +class DexParams { + public order_reserve: { + denom: string; + amount: string; + }; + + public price_tick_exponent: number; + + public max_orders_per_denom: number; + + public default_unified_ref_amount: string; + + constructor(payload: object) { + this.order_reserve = R.pathOr({ denom: '', amount: '' }, ['order_reserve'], payload); + this.price_tick_exponent = R.pathOr(0, ['price_tick_exponent'], payload); + this.max_orders_per_denom = R.pathOr(0, ['max_orders_per_denom'], payload); + this.default_unified_ref_amount = R.pathOr('', ['default_unified_ref_amount'], payload); + } + + static fromJson(data: object): DexParams { + return { + order_reserve: R.pathOr({ denom: '', amount: '' }, ['order_reserve'], data), + price_tick_exponent: R.pathOr(0, ['price_tick_exponent'], data), + max_orders_per_denom: R.pathOr(0, ['max_orders_per_denom'], data), + default_unified_ref_amount: R.pathOr('', ['default_unified_ref_amount'], data), + }; + } +} + +export default DexParams; diff --git a/packages/ui/src/models/index.ts b/packages/ui/src/models/index.ts index 6b0f146245..d47cf4d6c4 100644 --- a/packages/ui/src/models/index.ts +++ b/packages/ui/src/models/index.ts @@ -88,3 +88,11 @@ export { default as MsgNftIssueClass } from '@/models/msg/asset/msg_nft_issue_cl export { default as MsgNftSend } from '@/models/msg/nft/msg_send'; export { default as MsgNftAddToWhitelist } from '@/models/msg/asset/msg_nft_add_to_whitelist'; export { default as MsgNftRemoveFromWhitelist } from '@/models/msg/asset/msg_nft_remove_from_whitelist'; +export { default as MsgUpdateDEXWhitelistedDenoms } from '@/models/msg/asset/msg_update_dex_whitelisted_denoms'; +export { default as MsgUpdateDEXUnifiedRefAmount } from '@/models/msg/asset/msg_update_dex_unified_ref_amount'; +export { default as MsgPlaceOrder } from '@/models/msg/dex/msg_place_order'; +export { default as MsgCancelOrder } from '@/models/msg/dex/msg_cancel_order'; +export { default as MsgCancelOrdersByDenom } from '@/models/msg/dex/msg_cancel_orders_by_denom'; +export { default as MsgTransferAdmin } from '@/models/msg/asset/msg_transfer_admin'; +export { default as MsgClearAdmin } from '@/models/msg/asset/msg_clear_admin'; +export { default as MsgUpdateData } from '@/models/msg/asset/msg_update_data'; diff --git a/packages/ui/src/models/msg/asset/msg_clear_admin.ts b/packages/ui/src/models/msg/asset/msg_clear_admin.ts new file mode 100644 index 0000000000..8d2761fc41 --- /dev/null +++ b/packages/ui/src/models/msg/asset/msg_clear_admin.ts @@ -0,0 +1,31 @@ +/* eslint-disable camelcase */ +import * as R from 'ramda'; +import { Categories } from '../types'; + +class MsgClearAdmin { + public category: Categories; + + public type: string; + + public sender: string; + + public denom: string; + + constructor(payload: any) { + this.category = 'asset'; + this.type = R.pathOr('', ['type'], payload); + this.sender = R.pathOr('', ['sender'], payload.json); + this.denom = R.pathOr('', ['denom'], payload.json); + } + + static fromJson(json: any) { + return new MsgClearAdmin({ + category: 'asset', + type: R.pathOr('', ['@type'], json), + sender: R.pathOr('', ['sender'], json), + denom: R.pathOr('', ['denom'], json), + }); + } +} + +export default MsgClearAdmin; diff --git a/packages/ui/src/models/msg/asset/msg_transfer_admin.ts b/packages/ui/src/models/msg/asset/msg_transfer_admin.ts new file mode 100644 index 0000000000..95e5b598b9 --- /dev/null +++ b/packages/ui/src/models/msg/asset/msg_transfer_admin.ts @@ -0,0 +1,35 @@ +/* eslint-disable camelcase */ +import * as R from 'ramda'; +import { Categories } from '../types'; + +class MsgTransferAdmin { + public category: Categories; + + public type: string; + + public sender: string; + + public denom: string; + + public account: string; + + constructor(payload: any) { + this.category = 'asset'; + this.type = R.pathOr('', ['type'], payload); + this.sender = R.pathOr('', ['sender'], payload.json); + this.denom = R.pathOr('', ['denom'], payload.json); + this.account = R.pathOr('', ['account'], payload); + } + + static fromJson(json: any) { + return new MsgTransferAdmin({ + category: 'asset', + type: R.pathOr('', ['@type'], json), + sender: R.pathOr('', ['sender'], json), + denom: R.pathOr('', ['denom'], json), + account: R.pathOr('', ['account'], json), + }); + } +} + +export default MsgTransferAdmin; diff --git a/packages/ui/src/models/msg/asset/msg_update_data.ts b/packages/ui/src/models/msg/asset/msg_update_data.ts new file mode 100644 index 0000000000..549bfd7835 --- /dev/null +++ b/packages/ui/src/models/msg/asset/msg_update_data.ts @@ -0,0 +1,44 @@ +/* eslint-disable camelcase */ +import * as R from 'ramda'; +import { Categories } from '../types'; + +interface MsgUpdateDataItems { + index: number; + data: string; +} + +class MsgUpdateData { + public category: Categories; + + public type: string; + + public sender: string; + + public class_id: string; + + public id: string; + + public items: MsgUpdateDataItems[]; + + constructor(payload: any) { + this.category = 'asset'; + this.type = R.pathOr('', ['type'], payload); + this.sender = R.pathOr('', ['sender'], payload.json); + this.class_id = R.pathOr('', ['class_id'], payload.json); + this.id = R.pathOr('', ['id'], payload.json); + this.items = R.pathOr([], ['items'], payload.json); + } + + static fromJson(json: any) { + return new MsgUpdateData({ + category: 'asset', + type: R.pathOr('', ['@type'], json), + sender: R.pathOr('', ['sender'], json), + class_id: R.pathOr('', ['class_id'], json), + id: R.pathOr('', ['id'], json), + items: R.pathOr([], ['items'], json), + }); + } +} + +export default MsgUpdateData; diff --git a/packages/ui/src/models/msg/asset/msg_update_dex_unified_ref_amount.ts b/packages/ui/src/models/msg/asset/msg_update_dex_unified_ref_amount.ts new file mode 100644 index 0000000000..1a5aacd0b7 --- /dev/null +++ b/packages/ui/src/models/msg/asset/msg_update_dex_unified_ref_amount.ts @@ -0,0 +1,35 @@ +/* eslint-disable camelcase */ +import * as R from 'ramda'; +import { Categories } from '../types'; + +class MsgUpdateDEXUnifiedRefAmount { + public category: Categories; + + public type: string; + + public sender: string; + + public denom: string; + + public unified_ref_amount: string; + + constructor(payload: any) { + this.category = 'asset'; + this.type = R.pathOr('', ['type'], payload); + this.sender = R.pathOr('', ['sender'], payload.json); + this.denom = R.pathOr('', ['denom'], payload.json); + this.unified_ref_amount = R.pathOr('', ['unified_ref_amount'], payload); + } + + static fromJson(json: any) { + return new MsgUpdateDEXUnifiedRefAmount({ + category: 'asset', + type: R.pathOr('', ['@type'], json), + sender: R.pathOr('', ['sender'], json), + denom: R.pathOr('', ['denom'], json), + unified_ref_amount: R.pathOr('', ['unified_ref_amount'], json), + }); + } +} + +export default MsgUpdateDEXUnifiedRefAmount; diff --git a/packages/ui/src/models/msg/asset/msg_update_dex_whitelisted_denoms.ts b/packages/ui/src/models/msg/asset/msg_update_dex_whitelisted_denoms.ts new file mode 100644 index 0000000000..e1743c91fe --- /dev/null +++ b/packages/ui/src/models/msg/asset/msg_update_dex_whitelisted_denoms.ts @@ -0,0 +1,35 @@ +/* eslint-disable camelcase */ +import * as R from 'ramda'; +import { Categories } from '../types'; + +class MsgUpdateDEXWhitelistedDenoms { + public category: Categories; + + public type: string; + + public sender: string; + + public denom: string; + + public whitelisted_denoms: string[]; + + constructor(payload: any) { + this.category = 'asset'; + this.type = R.pathOr('', ['type'], payload); + this.sender = R.pathOr('', ['sender'], payload.json); + this.denom = R.pathOr('', ['denom'], payload.json); + this.whitelisted_denoms = R.pathOr([], ['whitelisted_denoms'], payload); + } + + static fromJson(json: any) { + return new MsgUpdateDEXWhitelistedDenoms({ + category: 'asset', + type: R.pathOr('', ['@type'], json), + sender: R.pathOr('', ['sender'], json), + denom: R.pathOr('', ['denom'], json), + whitelisted_denoms: R.pathOr([], ['whitelisted_denoms'], json), + }); + } +} + +export default MsgUpdateDEXWhitelistedDenoms; diff --git a/packages/ui/src/models/msg/dex/msg_cancel_order.ts b/packages/ui/src/models/msg/dex/msg_cancel_order.ts new file mode 100644 index 0000000000..03c6ce9e28 --- /dev/null +++ b/packages/ui/src/models/msg/dex/msg_cancel_order.ts @@ -0,0 +1,31 @@ +/* eslint-disable camelcase */ +import * as R from 'ramda'; +import { Categories } from '../types'; + +class MsgCancelOrder { + public category: Categories; + + public type: string; + + public sender: string; + + public id: string; + + constructor(payload: any) { + this.category = 'dex'; + this.type = R.pathOr('', ['type'], payload); + this.sender = R.pathOr('', ['sender'], payload.json); + this.id = R.pathOr('', ['id'], payload.json); + } + + static fromJson(json: any) { + return new MsgCancelOrder({ + category: 'asset', + type: R.pathOr('', ['@type'], json), + sender: R.pathOr('', ['sender'], json), + id: R.pathOr('', ['id'], json), + }); + } +} + +export default MsgCancelOrder; diff --git a/packages/ui/src/models/msg/dex/msg_cancel_orders_by_denom.ts b/packages/ui/src/models/msg/dex/msg_cancel_orders_by_denom.ts new file mode 100644 index 0000000000..295191690d --- /dev/null +++ b/packages/ui/src/models/msg/dex/msg_cancel_orders_by_denom.ts @@ -0,0 +1,35 @@ +/* eslint-disable camelcase */ +import * as R from 'ramda'; +import { Categories } from '../types'; + +class MsgCancelOrdersByDenom { + public category: Categories; + + public type: string; + + public sender: string; + + public account: string; + + public denom: string; + + constructor(payload: any) { + this.category = 'dex'; + this.type = R.pathOr('', ['type'], payload); + this.sender = R.pathOr('', ['sender'], payload.json); + this.account = R.pathOr('', ['account'], payload.json); + this.denom = R.pathOr('', ['denom'], payload.json); + } + + static fromJson(json: any) { + return new MsgCancelOrdersByDenom({ + category: 'asset', + type: R.pathOr('', ['@type'], json), + sender: R.pathOr('', ['sender'], json), + account: R.pathOr('', ['account'], json), + denom: R.pathOr('', ['denom'], json), + }); + } +} + +export default MsgCancelOrdersByDenom; diff --git a/packages/ui/src/models/msg/dex/msg_place_order.ts b/packages/ui/src/models/msg/dex/msg_place_order.ts new file mode 100644 index 0000000000..acd358ef8a --- /dev/null +++ b/packages/ui/src/models/msg/dex/msg_place_order.ts @@ -0,0 +1,62 @@ +/* eslint-disable camelcase */ +import * as R from 'ramda'; +import { Categories } from '../types'; + +class MsgPlaceOrder { + public category: Categories; + + public type: string; + + public sender: string; + + public id: string; + + public base_denom: string; + + public quote_denom: string; + + public price: string; + + public quantity: string; + + public side: string; + + public good_till: { + good_til_block_height: string; + good_til_block_time: string; + } | null; + + public time_in_force: string; + + constructor(payload: any) { + this.category = 'dex'; + this.type = R.pathOr('', ['type'], payload); + this.sender = R.pathOr('', ['sender'], payload.json); + this.id = R.pathOr('', ['id'], payload.json); + this.base_denom = R.pathOr('', ['base_denom'], payload.json); + this.quote_denom = R.pathOr('', ['quote_denom'], payload.json); + this.price = R.pathOr('', ['price'], payload.json); + this.quantity = R.pathOr('', ['quantity'], payload.json); + this.side = R.pathOr('', ['side'], payload.json); + this.good_till = R.pathOr(null, ['good_till'], payload.json); + this.time_in_force = R.pathOr('', ['time_in_force'], payload.json); + } + + static fromJson(json: any) { + return new MsgPlaceOrder({ + category: 'asset', + type: R.pathOr('', ['@type'], json), + sender: R.pathOr('', ['sender'], json), + id: R.pathOr('', ['id'], json), + base_denom: R.pathOr('', ['base_denom'], json), + quote_denom: R.pathOr('', ['quote_denom'], json), + price: R.pathOr('', ['price'], json), + quantity: R.pathOr('', ['quantity'], json), + side: R.pathOr('', ['side'], json), + good_till: R.pathOr(null, ['good_till'], json), + time_in_force: R.pathOr('', ['time_in_force'], json), + }); + } +} + +export default MsgPlaceOrder; diff --git a/packages/ui/src/models/msg/types/index.ts b/packages/ui/src/models/msg/types/index.ts index 1b24983347..bb4db5d21a 100644 --- a/packages/ui/src/models/msg/types/index.ts +++ b/packages/ui/src/models/msg/types/index.ts @@ -12,7 +12,7 @@ export type BaseCategories = | 'feegrant' | 'vesting' | 'others'; -export type CustomCategories = 'asset' | 'nft'; // custom modules +export type CustomCategories = 'asset' | 'nft' | 'dex'; // custom modules export type Categories = BaseCategories | CustomCategories; export interface Log { events?: Array<{ diff --git a/packages/ui/src/screens/params/hooks.ts b/packages/ui/src/screens/params/hooks.ts index 3758a2a6cf..f5bab2757e 100644 --- a/packages/ui/src/screens/params/hooks.ts +++ b/packages/ui/src/screens/params/hooks.ts @@ -13,9 +13,10 @@ import { TokenParams, } from '@/models'; import { customStakingParams } from '@/models/staking_params'; -import type { Auth, ParamsState } from '@/screens/params/types'; +import type { Auth, Dex, ParamsState } from '@/screens/params/types'; import { formatToken } from '@/utils/format_token'; import AuthParams from '@/models/auth_params'; +import DexParams from '@/models/dex_params'; const { primaryTokenUnit } = chainConfig(); @@ -31,6 +32,7 @@ const initialState: ParamsState = { nft: null, ft: null, auth: null, + dex: null, }; // ================================ @@ -212,6 +214,14 @@ const formatAuthParams = (data: ParamsQuery): Auth | null => { return null; }; +const formatDEXParams = (data: ParamsQuery): Dex | null => { + if (data.dexParams?.length) { + return DexParams.fromJson(data.dexParams?.[0]?.params ?? {}); + } + + return null; +}; + const formatParam = (data: ParamsQuery) => { const results: Partial = {}; @@ -233,6 +243,8 @@ const formatParam = (data: ParamsQuery) => { results.auth = formatAuthParams(data); + results.dex = formatDEXParams(data); + return results; }; diff --git a/packages/ui/src/screens/params/index.tsx b/packages/ui/src/screens/params/index.tsx index 564fe783ca..b5fbe5b74c 100644 --- a/packages/ui/src/screens/params/index.tsx +++ b/packages/ui/src/screens/params/index.tsx @@ -16,6 +16,7 @@ import { formatFT, formatNFT, formatAuth, + formatDex, } from '@/screens/params/utils'; const Params = () => { @@ -72,6 +73,13 @@ const Params = () => { } : null; + const dex = state.dex + ? { + title: t('dex') ?? undefined, + details: formatDex(state.dex, t), + } + : null; + const ft = state.ft ? { title: t('ft') ?? undefined, details: formatFT(state.ft, t) } : null; const nft = state.nft ? { title: t('nft') ?? undefined, details: formatNFT(state.nft, t) } : null; @@ -98,6 +106,7 @@ const Params = () => { {ft && } {nft && } {auth && } + {dex && } diff --git a/packages/ui/src/screens/params/types.ts b/packages/ui/src/screens/params/types.ts index 027da5b421..6ec2d47fe8 100644 --- a/packages/ui/src/screens/params/types.ts +++ b/packages/ui/src/screens/params/types.ts @@ -66,6 +66,16 @@ export interface Auth { sigVerifyCostSecp256k1: number | undefined; } +export interface Dex { + order_reserve: { + amount: string; + denom: string; + }; + price_tick_exponent: number; + max_orders_per_denom: number; + default_unified_ref_amount: string; +} + export interface ParamsState { loading: boolean; exists: boolean; @@ -78,4 +88,5 @@ export interface ParamsState { nft: NFT | null; ft: FT | null; auth: Auth | null; + dex: Dex | null; } diff --git a/packages/ui/src/screens/params/utils.tsx b/packages/ui/src/screens/params/utils.tsx index 8537cf07a5..57742b9fd6 100644 --- a/packages/ui/src/screens/params/utils.tsx +++ b/packages/ui/src/screens/params/utils.tsx @@ -8,6 +8,7 @@ import type { NFT, FT, Auth, + Dex, } from '@/screens/params/types'; import { nanoToSeconds, secondsToDays } from '@/utils/time'; import { TFunction } from 'next-i18next'; @@ -280,3 +281,26 @@ export const formatAuth = (data: Auth, t: TFunction) => [ detail: numeral(data.sigVerifyCostSecp256k1).format('0,0'), }, ]; + +export const formatDex = (data: Dex, t: TFunction) => [ + { + key: 'defaultUnifiedRefAmount', + label: t('defaultUnifiedRefAmount'), + detail: numeral(data.default_unified_ref_amount).format('0,0'), + }, + { + key: 'maxOrdersPerDenom', + label: t('maxOrdersPerDenom'), + detail: numeral(data.max_orders_per_denom).format('0,0'), + }, + { + key: 'priceTickExponent', + label: t('priceTickExponent'), + detail: numeral(data.price_tick_exponent).format('0,0'), + }, + { + key: 'orderReserve', + label: t('orderReserve'), + detail: `${data.order_reserve.amount} ${data.order_reserve.denom.toUpperCase()}`, + }, +];