Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix multisig issues #987

Merged
merged 4 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 29 additions & 14 deletions frontend/src/app/(routes)/multisig/components/AccountInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Image from 'next/image';
import { useRouter } from 'next/navigation';
import React, { useEffect, useState } from 'react';
import DialogDeleteMultisig from './DialogDeleteMultisig';
import { copyToClipboard } from '@/utils/copyToClipboard';

interface AccountInfoProps {
chainID: string;
Expand Down Expand Up @@ -110,7 +111,7 @@ const AccountDetails = ({
const dispatch = useAppDispatch();
const deleteMultisigRes = useAppSelector(
(state: RootState) => state.multisig.deleteMultisigRes
)
);

const router = useRouter();

Expand All @@ -122,22 +123,24 @@ const AccountDetails = ({
setDeleteDialogOpen(false);
};

useEffect(()=>{
useEffect(() => {
if (deleteMultisigRes?.status === 'idle') {
handleDeleteDialogClose();
handleGoBack();
}
}, [deleteMultisigRes?.status])
}, [deleteMultisigRes?.status]);

const handleDelete = () => {
dispatch(deleteMultisig({
data: { address: multisigAccount?.account?.address },
queryParams: { address: '', signature: '' }
}))
}
dispatch(
deleteMultisig({
data: { address: multisigAccount?.account?.address },
queryParams: { address: '', signature: '' },
})
);
};

return (
<div className="rounded-2xl w-full bg-[#0E0B26] h-full">
<div className="flex flex-col rounded-2xl w-full bg-[#0E0B26] h-full">
<div className="multisig-info-title">
<Image
src="/printed-color.png"
Expand All @@ -151,7 +154,7 @@ const AccountDetails = ({
<h3 className="text-[14px] font-bold">{getLocalDate(created_at)}</h3>
</div>
</div>
<div className="p-6 space-y-6">
<div className="flex-1 p-6 space-y-6 flex flex-col h-full">
<div className="grid grid-cols-2 gap-6">
<AccountInfoItem
icon={'/address-icon.svg'}
Expand Down Expand Up @@ -200,9 +203,12 @@ const AccountDetails = ({
</div>
</div>
<div>
<button
onClick={() => setDeleteDialogOpen(true)}
className="delete-multisig-btn">Delete Multisig</button>
<button
onClick={() => setDeleteDialogOpen(true)}
className="delete-multisig-btn"
>
Delete Multisig
</button>
</div>
</div>

Expand Down Expand Up @@ -239,7 +245,16 @@ const MemberAddress = ({ address }: { address: string }) => {
return (
<div className="member-address">
<div className="overflow-hidden">{shortenAddress(address, 28)}</div>
<Image src="/copy.svg" width={24} height={24} alt="copy" />
<Image
onClick={() => {
copyToClipboard(address);
}}
className="cursor-pointer"
src="/copy.svg"
width={24}
height={24}
alt="copy"
/>
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -446,12 +446,12 @@ const DialogCreateMultisig: React.FC<DialogCreateMultisigProps> = (props) => {
</>
))}
<div className="text-center text-[12px] font-light">
<span
className="border-b cursor-pointer"
<button
className="create-multisig-btn cursor-pointer"
onClick={handleAddPubKey}
>
Add New Member
</span>
</button>
</div>
<div className="my-6 flex items-center gap-4">
<TextField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const DelegateMessage: React.FC<TxnMsgProps> = (props) => {
<span>Delegate&nbsp;</span>
<span>
{parseBalance(
msg.value.amount,
[msg.value.amount],
currency.coinDecimals,
currency.coinMinimalDenom
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ const RedelegateMessage: React.FC<TxnMsgProps> = (props) => {
alt=""
/>
<div className="truncate max-w-[280px]">
<span>ReDelegate1111&nbsp;</span>
<span>ReDelegate&nbsp;</span>
<span>
{parseBalance(
msg.value.amount,
[msg.value.amount],
currency.coinDecimals,
currency.coinMinimalDenom
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const UndelegateMessage: React.FC<TxnMsgProps> = (props) => {
<span>UnDelegate&nbsp;</span>
<span>
{parseBalance(
msg.value.amount,
[msg.value.amount],
currency.coinDecimals,
currency.coinMinimalDenom
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ const Delegate: React.FC<DelegateProps> = (props) => {
const msgDelegate = {
delegatorAddress: data.delegator,
validatorAddress: data.validator?.value,
amount: [{
amount: {
amount: baseAmount,
denom: currency?.coinMinimalDenom,
}],
},
};

onDelegate({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,11 @@ const ReDelegate: React.FC<ReDelegateProps> = (props) => {
delegatorAddress: data.delegator,
validatorSrcAddress: data.validatorSrcAddress?.value,
validatorDstAddress: data.validatorDstAddress?.value,
amount: [
amount:
{
amount: baseAmount,
denom: currency?.coinMinimalDenom,
},
],
};

onDelegate({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ const UnDelegate: React.FC<UnDelegateProps> = (props) => {
const msgUnDelegate = {
delegatorAddress: data.delegator,
validatorAddress: data.validator?.value,
amount: [{
amount: {
amount: baseAmount,
denom: currency?.coinMinimalDenom,
}],
},
};

onDelegate({
Expand Down Expand Up @@ -194,7 +194,7 @@ const UnDelegate: React.FC<UnDelegateProps> = (props) => {
className="text-[12px] text-[#FFFFFF80] text-right cursor-pointer hover:underline underline-offset-2"
onClick={setAmountValue}
>
{formatCoin(Number(selectedValBal?.amount), selectedValBal?.denom)}
{formatCoin(Number(selectedValBal?.amount), currency?.coinDenom)}
</div>
<Controller
name="amount"
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/(routes)/multisig/multisig.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
}

.account-members {
@apply min-h-[216px] p-2 pb-4 flex flex-col gap-2 rounded-2xl bg-[#FFFFFF0D];
@apply flex-1 p-2 pb-4 flex flex-col gap-2 rounded-2xl bg-[#FFFFFF0D];
}

.member-address {
@apply text-[12px] font-medium h-8 flex gap-[10px] justify-center items-center p-1 rounded-lg;
@apply text-[12px] font-medium h-[36px] flex gap-[10px] justify-center items-center p-2 rounded-lg;
background: linear-gradient(
180deg,
rgba(74, 162, 156, 0.1) 0%,
Expand Down
12 changes: 10 additions & 2 deletions frontend/src/components/SelectNetwork.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';
import { useAppDispatch, useAppSelector } from '@/custom-hooks/StateHooks';
import { setSelectedNetwork } from '@/store/features/common/commonSlice';
import { setError, setSelectedNetwork } from '@/store/features/common/commonSlice';
import { RootState } from '@/store/store';
import { Avatar, Dialog, DialogContent } from '@mui/material';
import Image from 'next/image';
Expand All @@ -10,6 +10,7 @@ import React, { useEffect, useState } from 'react';
import DialogAddNetwork from './DialogAddNetwork';
import { resetConnectWalletStatus } from '@/store/features/wallet/walletSlice';
import { allNetworksLink, changeNetworkRoute } from '@/utils/util';
import { copyToClipboard } from '@/utils/copyToClipboard';

const ALL_NETWORKS_LOGO = '/all-networks-icon.png';

Expand Down Expand Up @@ -73,7 +74,14 @@ const SelectNetwork = () => {
{walletAddress ? (
<div className="wallet-address">
<span className="truncate">{walletAddress}</span>
<Image src="/copy.svg" width={16} height={16} alt="copy" />
<Image onClick={(e) => {
copyToClipboard(walletAddress);
dispatch(setError({
type: 'success',
message: "Copied"
}))
e.stopPropagation();
}} src="/copy.svg" width={24} height={24} alt="copy" />
</div>
) : (
<>
Expand Down
Loading