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

feat: add close modal to remove signer #70

Closed
wants to merge 1 commit into from
Closed
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
21 changes: 14 additions & 7 deletions src/components/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,20 @@ const Settings = (props: { accountId: string }) => {
if (!txn) {
return;
}

const jwt = await getJwtToken(props.accountId);
if (!jwt) {
return;
}
await createMCTransactionDB(txn.toXDR(), jwt);
addTxnNotification({
title: 'Success',
message: 'Add a signer transaction has been submitted',
type: TxnResponse.Success,
timestamp: Date.now(),
});
const mcTxnRes = await createMCTransactionDB(txn.toXDR(), jwt);
if (mcTxnRes?.preimageHash) {
addTxnNotification({
title: 'Success',
message: 'Add a signer transaction has been submitted',
type: TxnResponse.Success,
timestamp: Date.now(),
});
}
} catch (err) {
handleErrors('Error in adding signer', err);
useLoadingModal.setAction({
Expand Down Expand Up @@ -167,6 +170,10 @@ const Settings = (props: { accountId: string }) => {
useLoadingModal.setAction({
type: 'CLOSE',
});
} finally {
useLoadingModal.setAction({
type: 'CLOSE',
});
}
};

Expand Down
14 changes: 7 additions & 7 deletions src/components/Transactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import dayjs from 'dayjs';
import { useEffect, useState } from 'react';

interface ITransactionsProps {
address?: string;
accountAddress?: string;
}

const StatusStepMap: Record<MultiSigTransactionStatus, number> = {
Expand All @@ -33,7 +33,7 @@ const StatusStepMap: Record<MultiSigTransactionStatus, number> = {
[MultiSigTransactionStatus.Executed]: 3,
};

const Transactions = ({ address }: ITransactionsProps) => {
const Transactions = ({ accountAddress }: ITransactionsProps) => {
const [jwt] = useMCStore((s) => [s.jwt]);
const { getJwtToken } = useMC();
const [activeAccordion, setActiveAccordion] = useState<number | null>(null);
Expand Down Expand Up @@ -62,27 +62,27 @@ const Transactions = ({ address }: ITransactionsProps) => {

useEffect(() => {
// fixme - change when we have a new jwt feature
if (address && jwt) {
if (accountAddress && jwt) {
listTransactions.call(
{
offset: Math.max(pagination.offset - 1, 0),
limit: 5,
search: debouncedSearchTerm,
multicliqueAccountAddress: `${address}`,
multicliqueAccountAddress: `${accountAddress}`,
},
jwt
);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [address, debouncedSearchTerm, JSON.stringify(pagination), jwt]);
}, [accountAddress, debouncedSearchTerm, JSON.stringify(pagination), jwt]);

const handleSearch = (e: any) => {
setSearchTerm(e.target.value);
};

const handleLoadTransactions = async () => {
if (address) {
await getJwtToken(address);
if (accountAddress) {
await getJwtToken(accountAddress);
}
};

Expand Down
13 changes: 9 additions & 4 deletions src/hooks/useMC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ const useMC = () => {
refresh: token.refresh,
});
}
console.log(refreshedToken);
updateJwt(refreshedToken);
return refreshedToken;
} catch (err) {
Expand Down Expand Up @@ -602,7 +601,7 @@ const useMC = () => {
return;
}

if (!isValidXDR(xdr.trim().toString(), MCConfig.networkPassphrase)) {
if (!isValidXDR(xdr, MCConfig.networkPassphrase)) {
handleErrors('Invalid XDR');
return null;
}
Expand All @@ -614,7 +613,7 @@ const useMC = () => {

const mcTxnRes = await TransactionService.createMultiCliqueTransaction(
{
xdr: xdr.trim().toString(),
xdr,
},
jwtToken
);
Expand All @@ -638,11 +637,17 @@ const useMC = () => {
jwtToken
);

console.log('updatedTxn', updatedTxn);
return updatedTxn;
} catch (err) {
handleErrors('Error in creating multiclique offchain transaction ', err);
loadingModal.setAction({
type: 'CLOSE',
});
return null;
} finally {
loadingModal.setAction({
type: 'CLOSE',
});
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/pages/account/[accountId]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const Account = () => {
<div className='grow space-y-4 p-6'>
{currentTab === 'Dashboard' && <Dashboard />}
{currentTab === 'Transactions' && (
<Transactions address={accountId?.toString()} />
<Transactions accountAddress={accountId?.toString()} />
)}
{currentTab === 'Settings' && (
<Settings accountId={accountId as string} />
Expand Down