From 0f87267ac8885f7c8bc3bb80b074c379bf776dce Mon Sep 17 00:00:00 2001 From: Megha-Dev-19 Date: Tue, 23 Jan 2024 19:27:42 +0530 Subject: [PATCH] remove files --- src/devhub/entity/trustee/approvals.jsx | 223 ------------------------ src/devhub/entity/trustee/dashboard.jsx | 93 ---------- src/devhub/entity/trustee/history.jsx | 207 ---------------------- src/devhub/entity/trustee/login.jsx | 35 ---- src/devhub/entity/trustee/treasury.jsx | 80 --------- 5 files changed, 638 deletions(-) delete mode 100644 src/devhub/entity/trustee/approvals.jsx delete mode 100644 src/devhub/entity/trustee/dashboard.jsx delete mode 100644 src/devhub/entity/trustee/history.jsx delete mode 100644 src/devhub/entity/trustee/login.jsx delete mode 100644 src/devhub/entity/trustee/treasury.jsx diff --git a/src/devhub/entity/trustee/approvals.jsx b/src/devhub/entity/trustee/approvals.jsx deleted file mode 100644 index c624c6e5f..000000000 --- a/src/devhub/entity/trustee/approvals.jsx +++ /dev/null @@ -1,223 +0,0 @@ -const { getRelativeTime } = VM.require( - "${REPL_DEVHUB}/widget/core.lib.timeUtils" -); - -getRelativeTime || (getRelativeTime = () => {}); -const treasuryDaoID = "${REPL_TREASURY_CONTRACT}"; -const resPerPage = 50; -const [currentPage, setPage] = useState(0); -const [expandSummaryIndex, setExpandSummary] = useState({}); -const proposals = Near.view(treasuryDaoID, "get_proposals", { - from_index: currentPage === 0 ? currentPage : (currentPage - 1) * resPerPage, - limit: resPerPage, -}); - -const lastProposalID = Near.view(treasuryDaoID, "get_last_proposal_id", {}); -if (proposals === null || lastProposalID === null) { - return <>; -} - -const onPay = (id) => { - Near.call({ - contractName: treasuryDaoID, - methodName: "act_proposal", - args: { - id: id, - action: "VoteApprove", - memo: "", - }, - gas: Big(10).pow(14), - }); -}; - -const Container = styled.div` - font-size: 13px; - - .text-grey { - color: #b9b9b9 !important; - } - - .card-custom { - border-radius: 5px; - background-color: white; - } - - .text-size-2 { - font-size: 15px; - } - - .text-dark-grey { - color: #687076; - } - - .text-grey-100 { - background-color: #f5f5f5; - } - - td { - padding: 0.5rem; - color: inherit; - } - - .overflow { - overflow: auto; - } - - .max-w-100 { - max-width: 100%; - } - - button { - background-color: #04a46e; - color: white; - border: none; - font-weight: 600; - font-size: 14px; - } -`; - -// filter transfer proposals -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 = () => { - 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} - /> -
-
- - - {treasuryDaoID} - - - {args.receiver_id} - - - {isReceiverkycbVerified ? ( - - ) : ( - "Need icon" - )} - - {item.token} - - {parseFloat(args.amount).toLocaleString("en-US")} - - - {getRelativeTime(item.submission_time)} - - - - - - ); - })} - - ); -}; - -return ( - -
-
Need Approvals
- -
-
- - - - - - - - - - - - - - - -
IDPROPOSALFROMTOKYC/B VERIFIEDTOKENAMOUNTCREATEDPAY
-
-
- setPage(v), - }} - /> -
-
-); diff --git a/src/devhub/entity/trustee/dashboard.jsx b/src/devhub/entity/trustee/dashboard.jsx deleted file mode 100644 index 68a3991cf..000000000 --- a/src/devhub/entity/trustee/dashboard.jsx +++ /dev/null @@ -1,93 +0,0 @@ -const { normalize } = VM.require("${REPL_DEVHUB}/widget/core.lib.stringUtils"); -const { href } = VM.require("${REPL_DEVHUB}/widget/core.lib.url"); - -href || (href = () => {}); - -normalize || (normalize = () => {}); - -const { tab, ...passProps } = props; - -const NavUnderline = styled.ul` - cursor: pointer; - - a { - text-decoration: none; - color: #939597; - } - - a.active { - font-weight: bolder; - color: #151515; - border-bottom: 3px solid black; - } - - a:hover { - color: #151515; - } - - .nav-item { - font-size: 15px; - } -`; - -const tabs = [ - { - title: "Need Approvals", - view: "Approvals", - props: {}, - }, - { - title: "Payment History", - view: "History", - props: {}, - }, - { - title: "Treasury", - view: "Treasury", - props: {}, - }, -]; - -if (!tab) { - tab = normalize("Need Approvals"); -} - -let currentTab = tabs.find((it) => normalize(it.title) === tab); - -return ( -
- - {tabs.map( - ({ title }) => - title && ( -
  • - - {title} - -
  • - ) - )} -
    - {currentTab && ( -
    - -
    - )} -
    -); diff --git a/src/devhub/entity/trustee/history.jsx b/src/devhub/entity/trustee/history.jsx deleted file mode 100644 index 1ee91d04a..000000000 --- a/src/devhub/entity/trustee/history.jsx +++ /dev/null @@ -1,207 +0,0 @@ -const { getRelativeTime } = VM.require( - "${REPL_DEVHUB}/widget/core.lib.timeUtils" -); - -getRelativeTime || (getRelativeTime = () => {}); - -const treasuryDaoID = "${REPL_TREASURY_CONTRACT}"; -const resPerPage = 50; -const [currentPage, setPage] = useState(0); - -const [expandSummaryIndex, setExpandSummary] = useState({}); -const proposals = Near.view(treasuryDaoID, "get_proposals", { - from_index: currentPage === 0 ? currentPage : (currentPage - 1) * resPerPage, - limit: resPerPage, -}); - -const lastProposalID = Near.view(treasuryDaoID, "get_last_proposal_id", {}); -if (proposals === null || lastProposalID === null) { - return <>; -} - -const Container = styled.div` - font-size: 13px; - .text-grey { - color: #b9b9b9 !important; - } - - .card-custom { - border-radius: 5px; - background-color: white; - } - - .text-size-2 { - font-size: 15px; - } - - .text-dark-grey { - color: #687076; - } - - .text-grey-100 { - background-color: #f5f5f5; - } - - td { - padding: 0.5rem; - color: inherit; - } - - .overflow { - overflow: auto; - } - - .max-w-100 { - max-width: 100%; - } -`; - -// filter approved proposals -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 = () => { - 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} - /> -
    -
    - - - {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)} - - ); - })} - - ); -}; -return ( - -
    -
    Payment History
    - {/* currently we don't support any filter */} - {/*
    - -
    */} -
    -
    - - - - - - - - - - - - - - - - - -
    IDPROPOSALFROMTOKYC/B VERIFIEDTOKENAMOUNTAPPROVERTRANSACTIONWHEN
    -
    -
    - setPage(v), - }} - /> -
    -
    -); diff --git a/src/devhub/entity/trustee/login.jsx b/src/devhub/entity/trustee/login.jsx deleted file mode 100644 index 573e18d80..000000000 --- a/src/devhub/entity/trustee/login.jsx +++ /dev/null @@ -1,35 +0,0 @@ -const Container = styled.div` - width: 80vw; - .card-custom { - box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2); - border-radius: 5px; - background-color: white; - } - - .bg-grey { - background-color: #f3f3f2; - } - - .cursor { - cursor: pointer; - } -`; - -return ( - -
    -
    - -
    Login Below
    -
    {}} // 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 }} - > - - Connect Wallet -
    -
    -
    -
    -); diff --git a/src/devhub/entity/trustee/treasury.jsx b/src/devhub/entity/trustee/treasury.jsx deleted file mode 100644 index a1d4788fc..000000000 --- a/src/devhub/entity/trustee/treasury.jsx +++ /dev/null @@ -1,80 +0,0 @@ -const Container = styled.div` - .bg-dark-grey { - background-color: #7e868c; - } - .text-white { - color: white; - } - - .py-3 { - padding-block: 1rem !important; - } - - .flex-item { - flex: 1; - } - - .text-small { - font-size: 12px; - font-weight: 400; - } - - .gap-10 { - gap: 5rem; - } -`; - -function convertYoctoToNear(yoctoNear) { - return ( -
    - {Big(yoctoNear).div(Big(10).pow(24)).toFixed(3)} - -
    - ); -} - -const accountId = "devhub.near"; -const res = fetch(`https://api.nearblocks.io/v1/account/${accountId}`); -const txns = fetch( - `https://api.nearblocks.io/v1/account/${accountId}/ft-txns/count` -); - -if (res === null || txns === null) { - return <>Loading; -} - -return ( - -
    Treasury
    -
    -
    -
    {accountId}
    - clipboard.writeText(accountId)} - > -
    -
    -
    -

    Balance

    -

    - {convertYoctoToNear(res.body?.account[0]?.amount)} -

    -
    -
    -

    Transactions

    -

    {txns?.body?.txns?.[0]?.count}

    -
    -
    -
    - -
    -
    -
    -);