Skip to content

Commit

Permalink
Merge pull request #77 from AstraProtocol/feat/add-msg-grant
Browse files Browse the repository at this point in the history
feat: add msg grant
  • Loading branch information
Tien Dao authored Mar 2, 2023
2 parents 934d31c + e6ecf44 commit b211d6d
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 14 deletions.
2 changes: 1 addition & 1 deletion components/Card/CardInfo/Components/CardTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default function CardTabs({ tabTitles, tabContent }: CardTabsProps) {
<Tabs
tabs={_title}
contents={_content}
classes="padding-top-xs aaa"
classes="padding-top-xs"
headerBorder={false}
headerPadding="padding-left-sm flex-wrap"
/>
Expand Down
9 changes: 9 additions & 0 deletions components/Card/CardInfo/style.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
.leftColumn {
}
.rightColumn {
table {
display: table;
text-align: left;
td,
th {
padding-left: 10px !important;
width: 2%;
}
}
}
}
.smallCard {
Expand Down
2 changes: 2 additions & 0 deletions types/transactions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ interface CosmosTxMessage {
funderAddress?: string
accountAddress?: string
destAddress?: string

granter?: string
}

interface TransactionDetail {
Expand Down
5 changes: 4 additions & 1 deletion utils/enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ export enum CardInfoLabels {

funderAddress = 'Funder Address:',
accountAddress = 'Account Address: ',
destAddress = 'Dest Address:'
destAddress = 'Dest Address:',

grant = 'Grant: ',
granter = 'Granter: '
}

export enum ErcTypeEnum {
Expand Down
26 changes: 14 additions & 12 deletions views/transactions/cosmosMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export const handleCosmosMsg = (messages: TransactionMessage[]) => {
case TransactionTypeEnum.MsgExec:
messageData.push(_mapMsgExec(msg, messages))
break
// case TransactionTypeEnum.MsgGrant:
// messageData.push(_mapMsgGrant(msg))
// break
case TransactionTypeEnum.MsgGrant:
messageData.push(_mapMsgGrant(msg))
break
case TransactionTypeEnum.MsgWithdrawDelegatorReward:
messageData.push(_mapMsgWithdrawDelegatorReward(msg))
break
Expand Down Expand Up @@ -207,15 +207,17 @@ const _mapMsgExec = (msg: TransactionMessage, messages: TransactionMessage[]): C
}
}
}
// const _mapMsgGrant = (msg: TransactionMessage): CosmosTxMessage => {
// const content = msg.content as unknown as MsgExecContent
// if (msg && content) {
// return {
// type: msg.type,
// grantee: content.params.grantee
// }
// }
// }
const _mapMsgGrant = (msg: TransactionMessage): CosmosTxMessage => {
const content = msg.content as unknown as MsgGrantContent
if (msg && content) {
return {
type: msg.type,
granter: content.params.maybeGenericGrant.granter,
grantee: content.params.maybeGenericGrant.grantee,
dynamicRender: [{ grant: content.params.maybeGenericGrant.grant }]
}
}
}

const _mapMsgWithdrawDelegatorReward = (msg: TransactionMessage): CosmosTxMessage => {
const content = msg.content as unknown as MsgWithdrawDelegatorRewardContent
Expand Down
2 changes: 2 additions & 0 deletions views/transactions/hook/convertDataConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ export const COSMOS_MESSAGE_SORT_FIELD = [
CardInfoLabels.validatorSrcAddress,
CardInfoLabels.validatorDstAddress,
//MsgExec
CardInfoLabels.granter,
CardInfoLabels.grantee,
CardInfoLabels.grant,
//MsgCreateValidator
CardInfoLabels.validatorDescription,
CardInfoLabels.commissionRates,
Expand Down
1 change: 1 addition & 0 deletions views/transactions/hook/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ export const _cardData = (data: TransactionDetail, astraPrice: string) => {
case 'delegatorAddress':
case 'recipientAddress':
case 'grantee':
case 'granter':
if (!isEmpty(data[key])) {
const evmAddress = key === 'grantee' ? data[key] : astraToEth(data[key])
items.push({
Expand Down

0 comments on commit b211d6d

Please sign in to comment.