Skip to content

Commit

Permalink
feat: add MsgDeposit
Browse files Browse the repository at this point in the history
  • Loading branch information
vien.nguyen2-tiki committed Jan 31, 2023
1 parent 605fc12 commit 05c393f
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pages/tx/[tx].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const TransactionDetailPage: React.FC<Props> = ({ errorMessage, data, evmHash, c
const { isMobile } = useMobileLayout('small')
const [items, extraItems, moreItems] = useConvertData({ data })
const hash = evmHash || cosmosHash
const isEvm = !!data.evmHash
const isEvm = data && !!data.evmHash
const isMainnet = window?.location?.hostname?.includes('.astranaut.io')
return (
<Layout>
Expand Down
16 changes: 16 additions & 0 deletions types/message.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,19 @@ interface TextProposalFullContent {
}
msgName: string
}

interface MsgDepositContent {
name: string
uuid: string
height: number
txHash: string
msgName: string
proposalId: string
amount: {
denom: string
amount: string
}[]
version: number
msgIndex: number
depositor: string
}
1 change: 1 addition & 0 deletions types/transactions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ interface TransactionDetail {
initialDepositValue?: number
initialDepositTokenSymbol?: string
textProposalContent?: TextProposalContent[]
depositor?: string

revertReason?: string
logs?: EvmLog[]
Expand Down
7 changes: 5 additions & 2 deletions utils/enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export enum TransactionTypeEnum {
MsgCreateValidator = '/cosmos.staking.v1beta1.MsgCreateValidator',
MsgUnjail = '/cosmos.slashing.v1beta1.MsgUnjail',
TextProposal = '/cosmos.gov.v1beta1.TextProposal',
MsgSubmitProposal = '/cosmos.params.v1beta1.ParameterChangeProposal'
MsgSubmitProposal = '/cosmos.params.v1beta1.ParameterChangeProposal',
MsgDeposit = '/cosmos.gov.v1beta1.MsgDeposit'
}

export enum AddressTypeEnum {
Expand Down Expand Up @@ -74,7 +75,9 @@ export enum CardInfoLabels {
//Text Proposal
textProposalContent = 'Content: ',
initialDepositValue = 'Initial Deposit:',
proposer = 'Proposer:'
proposer = 'Proposer:',
// MSG Deposit
depositor = 'Depositor:'
}

export enum ErcTypeEnum {
Expand Down
5 changes: 4 additions & 1 deletion views/transactions/hook/useConvertData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ export default function useConvertData({ data }: { data: TransactionDetail }) {

case 'voter':
case 'proposer':
case 'depositor':
if (data[key] !== undefined && data[key] !== null)
items.push({
label: CardInfoLabels[key],
Expand Down Expand Up @@ -398,7 +399,9 @@ export default function useConvertData({ data }: { data: TransactionDetail }) {
//MsgTextProposal
CardInfoLabels.textProposalContent,
CardInfoLabels.initialDepositValue,
CardInfoLabels.proposer
CardInfoLabels.proposer,
// Msg Deposit
CardInfoLabels.depositor
])

const moreItems = sortArrayFollowValue(items, 'label', [
Expand Down
10 changes: 10 additions & 0 deletions views/transactions/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export const cosmsTransactionDetail = (result: TransactionItem): TransactionDeta
_mapMsgWithdrawDelegatorReward(data as TransactionMsgWithdrawDelegatorRewardDetail, result?.messages)
_mapMsgCreateValidator(data as TransactionMsgCreateValidatorDetail, result?.messages)
_mapMsgTextProposal(data, result)
_mapMsgDeposit(data, result?.messages)
return data
}

Expand Down Expand Up @@ -410,3 +411,12 @@ const _mapMsgTextProposal = (data: TransactionDetail, result: TransactionItem) =
}
}
}

const _mapMsgDeposit = (data: TransactionDetail, messages: TransactionMessage[]) => {
const type: string = messages[0]?.type
if (type === TransactionTypeEnum.MsgDeposit) {
const content = messages[0].content as MsgDepositContent
data.depositor = content.depositor
data.proposalId = content.proposalId
}
}

0 comments on commit 05c393f

Please sign in to comment.