From a6e3ddf2d91aa8e626076c8c68114edb53c5b35c Mon Sep 17 00:00:00 2001 From: Megha-Dev-19 Date: Sun, 21 Jan 2024 13:18:36 +0530 Subject: [PATCH] made few contract integration updates --- src/devhub/entity/trustee/approvals.jsx | 196 ++++++++++++----------- src/devhub/entity/trustee/history.jsx | 197 +++++++++++++----------- src/devhub/entity/trustee/login.jsx | 2 +- 3 files changed, 208 insertions(+), 187 deletions(-) diff --git a/src/devhub/entity/trustee/approvals.jsx b/src/devhub/entity/trustee/approvals.jsx index 4fb15e3e7..c624c6e5f 100644 --- a/src/devhub/entity/trustee/approvals.jsx +++ b/src/devhub/entity/trustee/approvals.jsx @@ -77,99 +77,113 @@ const Container = styled.div` `; // filter transfer proposals -const transferProposals = proposals.filter( - (item) => item.kind?.FunctionCall?.actions?.[0]?.method_name === "ft_transfer" -); +const transferProposals = proposals.filter((item) => { + if (item.kind?.FunctionCall?.actions?.[0]?.method_name) { + return ( + item.kind.FunctionCall.actions[0].method_name === "ft_transfer" && + item.status === "InProgress" + ); + } + return false; +}); const ProposalsComponent = () => { - transferProposals?.map((item, index) => { - // decode args - const actions = item.kind?.FunctionCall?.actions?.[0]; - const args = JSON.parse(atob(actions?.args ?? "")); - const isReceiverkycbVerified = true; - const isNEAR = true; - const address = item.token; - let ftMetadata = { - symbol: "NEAR", - decimals: 24, - }; - if (!isNEAR) { - ftMetadata = Near.view(address, "ft_metadata", {}); - if (ftMetadata === null) return null; - } - let amount = amountWithDecimals; - if (amountWithoutDecimals !== undefined) { - amount = Big(amountWithoutDecimals) - .div(Big(10).pow(ftMetadata.decimals)) - .toString(); - } - - return ( - - {item.id} - -
-
-
- {args.title} + return ( + + {transferProposals?.map((item, index) => { + // decode args + const actions = item.kind?.FunctionCall?.actions?.[0]; + const args = JSON.parse(atob(actions?.args ?? "")); + const isReceiverkycbVerified = true; + const isNEAR = true; + const address = item.token; + let ftMetadata = { + symbol: "NEAR", + decimals: 24, + }; + if (!isNEAR) { + ftMetadata = Near.view(address, "ft_metadata", {}); + if (ftMetadata === null) return null; + } + // let amount = amountWithDecimals; + // if (amountWithoutDecimals !== undefined) { + // amount = Big(amountWithoutDecimals) + // .div(Big(10).pow(ftMetadata.decimals)) + // .toString(); + // } + + return ( + + {item.id} + +
+
+
+ {args.title} +
+ {expandSummaryIndex[index] && ( +
+ {args.summary} +
+ )} +
+
+ + setExpandSummary((prevState) => ({ + ...prevState, + [index]: !prevState[index], + })) + } + height={20} + /> +
- {expandSummaryIndex[index] && ( -
{args.summary}
+ + + {treasuryDaoID} + + + {args.receiver_id} + + + {isReceiverkycbVerified ? ( + + ) : ( + "Need icon" )} -
-
- - setExpandSummary((prevState) => ({ - ...prevState, - [index]: !prevState[index], - })) - } - height={20} - /> -
-
- - - {treasuryDaoID} - - - {args.receiver_id} - - - {isReceiverkycbVerified ? ( - - ) : ( - "Need icon" - )} - - {item.token} - - {parseFloat(args.amount).toLocaleString("en-US")} - - {getRelativeTime(item.submission_time)} - - - - - ); - }); + + {item.token} + + {parseFloat(args.amount).toLocaleString("en-US")} + + + {getRelativeTime(item.submission_time)} + + + + + + ); + })} + + ); }; return ( @@ -193,9 +207,7 @@ return ( PAY - - - +
diff --git a/src/devhub/entity/trustee/history.jsx b/src/devhub/entity/trustee/history.jsx index b27b8c366..1ee91d04a 100644 --- a/src/devhub/entity/trustee/history.jsx +++ b/src/devhub/entity/trustee/history.jsx @@ -57,101 +57,111 @@ const Container = styled.div` `; // filter approved proposals -const historyProposals = proposals.filter( - (item) => - item.kind?.FunctionCall?.actions?.[0]?.method_name === "ft_transfer" && - item.status === "Approved" -); +const historyProposals = proposals.filter((item) => { + if (item.kind?.FunctionCall?.actions?.[0]?.method_name) { + return ( + item.kind?.FunctionCall?.actions?.[0]?.method_name === "ft_transfer" && + item.status === "Approved" + ); + } + return false; +}); const ProposalsComponent = () => { - historyProposals?.map((item, index) => { - // decode args - const actions = item.kind?.FunctionCall?.actions?.[0]; - const args = JSON.parse(atob(actions?.args ?? "")); - const isReceiverkycbVerified = true; - const isNEAR = true; - const address = item.token; - let ftMetadata = { - symbol: "NEAR", - decimals: 24, - }; - if (!isNEAR) { - ftMetadata = Near.view(address, "ft_metadata", {}); - if (ftMetadata === null) return null; - } - let amount = amountWithDecimals; - if (amountWithoutDecimals !== undefined) { - amount = Big(amountWithoutDecimals) - .div(Big(10).pow(ftMetadata.decimals)) - .toString(); - } - return ( - - {item.id} - -
-
-
- {args.title} + return ( + + {historyProposals?.map((item, index) => { + // decode args + const actions = item.kind?.FunctionCall?.actions?.[0]; + const args = JSON.parse(atob(actions?.args ?? "")); + const isReceiverkycbVerified = true; + const isNEAR = true; + const address = item.token; + let ftMetadata = { + symbol: "NEAR", + decimals: 24, + }; + if (!isNEAR) { + ftMetadata = Near.view(address, "ft_metadata", {}); + if (ftMetadata === null) return null; + } + let amount = amountWithDecimals; + if (amountWithoutDecimals !== undefined) { + amount = Big(amountWithoutDecimals) + .div(Big(10).pow(ftMetadata.decimals)) + .toString(); + } + return ( + + {item.id} + +
+
+
+ {args.title} +
+ {expandSummaryIndex[index] && ( +
+ {args.summary} +
+ )} +
+
+ + setExpandSummary((prevState) => ({ + ...prevState, + [index]: !prevState[index], + })) + } + height={20} + /> +
- {expandSummaryIndex[index] && ( -
{args.summary}
+ + + {treasuryDaoID} + + + {args.receiver_id} + + + {isReceiverkycbVerified ? ( + + ) : ( + "Need icon" )} -
-
- - setExpandSummary((prevState) => ({ - ...prevState, - [index]: !prevState[index], - })) - } - height={20} - /> -
-
- - - {treasuryDaoID} - - - {args.receiver_id} - - - {isReceiverkycbVerified ? ( - - ) : ( - "Need icon" - )} - - {item.token} - - {parseFloat(args.amount).toLocaleString("en-US")} - - {Object.keys(item.votes ?? {}).join(", ")} - - {item.txnHash} - - {getRelativeTime(item.approvedAt)} - - ); - }); + + {item.token} + + {parseFloat(args.amount).toLocaleString("en-US")} + + {Object.keys(item.votes ?? {}).join(", ")} + + {item.txnHash} + + {getRelativeTime(item.approvedAt)} + + ); + })} + + ); }; return ( @@ -180,9 +190,8 @@ return ( WHEN - - - + +
diff --git a/src/devhub/entity/trustee/login.jsx b/src/devhub/entity/trustee/login.jsx index b224d97a8..573e18d80 100644 --- a/src/devhub/entity/trustee/login.jsx +++ b/src/devhub/entity/trustee/login.jsx @@ -22,7 +22,7 @@ return (
Login Below
props.setIsTrustee(true)} + onClick={() => {}} // do login? className="rounded-4 bg-grey p-2 text-center d-flex gap-2 flex-row justify-content-center align-items-center cursor" style={{ width: 230 }} >