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

Setup new portal instance for templar #983

Merged
merged 83 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
7b9242d
fix solution action
Megha-Dev-19 Dec 7, 2023
a9fee68
Merge branch 'main' of https://github.com/Megha-Dev-19/neardevhub-wid…
Megha-Dev-19 Dec 8, 2023
7c6ee84
Merge branch 'near:main' into main
Megha-Dev-19 Dec 18, 2023
218a120
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Dec 18, 2023
ac0bd6e
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Dec 19, 2023
6d31741
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Dec 29, 2023
1fd7eb1
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Dec 30, 2023
9a4c7a2
Merge branch 'main' of https://github.com/Megha-Dev-19/neardevhub-wid…
Megha-Dev-19 Jan 3, 2024
07c55a3
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jan 4, 2024
fa8d436
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jan 5, 2024
4b75fa1
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jan 8, 2024
2b5e027
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jan 19, 2024
d2bae2d
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jan 23, 2024
57b6e52
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jan 31, 2024
2d33aef
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Feb 27, 2024
71a8a62
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Mar 1, 2024
6cd1c40
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Mar 4, 2024
8bdc2ce
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Mar 5, 2024
d6a282d
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Mar 12, 2024
955cc35
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Mar 13, 2024
120ac1a
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Mar 22, 2024
86bed07
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Mar 23, 2024
3807a10
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Mar 23, 2024
769373b
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Mar 25, 2024
8252826
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Mar 30, 2024
7d59bc0
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Apr 1, 2024
263522f
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Apr 2, 2024
ad0520e
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Apr 4, 2024
b36c120
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Apr 11, 2024
f91491c
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Apr 17, 2024
60c60a2
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Apr 22, 2024
c31e5ca
fix preview for proposals
Megha-Dev-19 Apr 22, 2024
86d21ae
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Apr 22, 2024
081fe73
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Apr 24, 2024
951d09f
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Apr 27, 2024
be358eb
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 May 13, 2024
cabd08c
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 May 21, 2024
97063f2
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 May 30, 2024
4468c0e
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jun 4, 2024
214f884
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jun 7, 2024
234de81
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jun 8, 2024
6c65260
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jun 16, 2024
6932cab
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jun 26, 2024
552a573
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jul 7, 2024
4ce2676
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jul 8, 2024
62aa5b5
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jul 8, 2024
9b0b1a2
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jul 9, 2024
c87e751
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jul 10, 2024
77926c2
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jul 11, 2024
1f87031
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jul 13, 2024
ee2e830
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jul 17, 2024
4787c7d
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jul 20, 2024
9d2849a
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jul 20, 2024
50a5684
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jul 20, 2024
1488e93
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jul 23, 2024
90d9b91
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jul 25, 2024
6fd6e70
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jul 26, 2024
9534b54
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jul 30, 2024
38d44a0
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Aug 9, 2024
8e06659
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Aug 20, 2024
0ec0766
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Aug 28, 2024
362a643
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Sep 23, 2024
6d607fc
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Sep 24, 2024
9c47547
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Sep 24, 2024
5ec0299
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Sep 26, 2024
8d8f7a3
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Sep 29, 2024
b8cdd47
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Oct 1, 2024
46abb64
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Oct 8, 2024
f6769fb
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Oct 15, 2024
c24c989
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Nov 27, 2024
d6dee9d
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Dec 10, 2024
be83d05
setup new portal instance for templar
Megha-Dev-19 Nov 14, 2024
50b4710
add indexer
Megha-Dev-19 Nov 15, 2024
b44473b
changes as per indexer
Megha-Dev-19 Nov 15, 2024
5a4f2bc
fix filter
Megha-Dev-19 Nov 15, 2024
5302630
fix search filter
Megha-Dev-19 Nov 15, 2024
33a8ae2
rename `app` to `portal`
Megha-Dev-19 Nov 15, 2024
e8aba08
hide about
Megha-Dev-19 Nov 15, 2024
ac27031
added templar t&c
Megha-Dev-19 Nov 22, 2024
081d804
updated terms and condition
Megha-Dev-19 Nov 22, 2024
5a95d4a
fix issues with snapshot history
Megha-Dev-19 Dec 10, 2024
3b2772e
skip announcement related tests
Megha-Dev-19 Dec 10, 2024
eb6fae4
skip sunset tests
Megha-Dev-19 Dec 10, 2024
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
1 change: 1 addition & 0 deletions instances/devhub.near/widget/config/data.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const categoryOptions = [
];

return {
portalName: "Devhub",
contract: "devhub.near",
proposalFeedIndexerQueryName:
"polyprogrammist_near_devhub_prod_v1_proposals_with_latest_snapshot",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ State.init({

const instance = props.instance ?? "";

const { cacheUrl } = VM.require(`${instance}/widget/config.data`);
const { cacheUrl, portalName } = VM.require(`${instance}/widget/config.data`);

const fetchAndSetProposalSnapshot = () => {
if (!props.proposalId) {
Expand Down Expand Up @@ -81,6 +81,6 @@ return (
target="_blank"
rel="noopener noreferrer"
>
DevHub’s Terms and Conditions
{portalName}'s Terms and Conditions
</a>
);
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ const { getLinkUsingCurrentGateway } = VM.require(
const snapshotHistory = props.snapshotHistory;
const proposalId = props.id;
const instanceAccount = props.item.path.split("/")[0];
const acceptedTermsComponent = props.acceptedTermsComponent ?? (
<Widget
src={"${REPL_DEVHUB}/widget/devhub.entity.proposal.AcceptedTerms"}
props={{ proposalId: proposalId, instance: instanceAccount }}
/>
);

const Wrapper = styled.div`
position: relative;
Expand Down Expand Up @@ -95,6 +101,7 @@ function sortTimelineAndComments() {
.map((item, index) => {
const startingPoint = snapshotHistory[index]; // Set comparison to the previous item
// we don't show timeline_version in logs
delete startingPoint.block_height;
delete startingPoint.timeline.timeline_version;
delete item.timeline.timeline_version;
if (
Expand Down Expand Up @@ -332,10 +339,7 @@ const parseProposalKeyAndValue = (key, modifiedValue, originalValue) => {
return (
<span>
accepted
<Widget
src={"${REPL_DEVHUB}/widget/devhub.entity.proposal.AcceptedTerms"}
props={{ ...props, proposalId: proposalId }}
/>
{acceptedTermsComponent}
</span>
);
}
Expand Down
1 change: 1 addition & 0 deletions instances/events-committee.near/widget/config/data.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const categoryOptions = [
];

return {
portalName: "Events Committee",
contract: "events-committee.near",
proposalFeedIndexerQueryName:
"thomasguntenaar_near_event_committee_prod_v1_proposals_with_latest_snapshot",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -861,8 +861,7 @@ return (
...props,
id: proposal.id,
item: item,
snapshotHistory: snapshotHistory,
latestSnapshot: snapshot,
snapshotHistory: [...proposal.snapshot_history, snapshot],
}}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,12 @@ State.init({
function sortTimelineAndComments() {
const comments = Social.index("comment", props.item, { subscribe: true });

if (state.changedKeysListWithValues === null) {
if (state.changedKeysListWithValues === null && snapshotHistory.length > 0) {
const changedKeysListWithValues = snapshotHistory
.slice(1)
.map((item, index) => {
const startingPoint = snapshotHistory[index]; // Set comparison to the previous item
delete startingPoint.block_height;
return {
editorId: item.editor_id,
...getDifferentKeysWithValues(startingPoint, item),
Expand Down Expand Up @@ -135,9 +136,11 @@ function sortTimelineAndComments() {
});
}

if (Array.isArray(snapshotHistory)) {
sortTimelineAndComments();
}
useEffect(() => {
if (Array.isArray(snapshotHistory)) {
sortTimelineAndComments();
}
}, [snapshotHistory]);

const Comment = ({ commentItem }) => {
const { accountId, blockHeight } = commentItem;
Expand Down Expand Up @@ -288,7 +291,10 @@ function parseTimelineKeyAndValue(timeline, originalValue, modifiedValue) {

const AccountProfile = ({ accountId }) => {
return (
<span className="inline-flex fw-bold text-black">
<span
className="inline-flex fw-bold text-black"
style={{ verticalAlign: "top" }}
>
<Widget
src={`${REPL_DEVHUB}/widget/devhub.entity.proposal.Profile`}
props={{
Expand Down Expand Up @@ -326,6 +332,13 @@ const LinkToProposal = ({ id, children }) => {
);
};

function formatDate(nanoseconds) {
const milliseconds = nanoseconds / 1_000_000; // Convert nanoseconds to milliseconds
const date = new Date(milliseconds);

return date.toISOString().split("T")[0];
}

const parseProposalKeyAndValue = (key, modifiedValue, originalValue) => {
switch (key) {
case "name":
Expand All @@ -335,6 +348,13 @@ const parseProposalKeyAndValue = (key, modifiedValue, originalValue) => {
return <span>changed {key}</span>;
case "labels":
return <span>changed labels to {(modifiedValue ?? []).join(", ")}</span>;
case "submission_deadline":
return (
<span>
changed submission deadline to {formatDate(modifiedValue)} to{" "}
{formatDate(originalValue)}{" "}
</span>
);
case "linked_proposals": {
const newProposals = modifiedValue || [];
const oldProposals = originalValue || [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ const fetchSnapshotHistory = () => {
delete rfpData.ts;
return rfpData;
});
setSnapshotHistory(history);
setSnapshotHistory([...history].reverse());
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const categoryOptions = [
];

return {
portalName: "Infrastructure Committee",
contract: "infrastructure-committee.near",
proposalFeedIndexerQueryName:
"polyprogrammist_near_devhub_ic_v1_proposals_with_latest_snapshot",
Expand Down
2 changes: 2 additions & 0 deletions instances/treasury-templar.near/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
dist
10 changes: 10 additions & 0 deletions instances/treasury-templar.near/aliases.mainnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"REPL_DEVHUB": "devhub.near",
"REPL_TREASURY_TEMPLAR": "treasury-templar.near",
"REPL_TREASURY_TEMPLAR_CONTRACT": "treasury-templar.near",
"REPL_TREASURY_BASE_DEPLOYMENT_ACCOUNT": "treasury-templar.near",
"REPL_NEAR": "near",
"REPL_RPC_URL": "https://rpc.mainnet.near.org",
"REPL_RFP_IMAGE": "https://ipfs.near.social/ipfs/bafkreicbygt4kajytlxij24jj6tkg2ppc2dw3dlqhkermkjjfgdfnlizzy",
"REPL_CACHE_URL": "https://templar-cache-api-rs.fly.dev"
}
6 changes: 6 additions & 0 deletions instances/treasury-templar.near/bos.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"account": "treasury-templar.near",
"aliasPrefix": "REPL",
"aliasesContainsPrefix": true,
"aliases": ["./aliases.mainnet.json"]
}
3 changes: 3 additions & 0 deletions instances/treasury-templar.near/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"treasury-templar.near": {}
}
1 change: 1 addition & 0 deletions instances/treasury-templar.near/src
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
const { Tile } = VM.require(
`${REPL_DEVHUB}/widget/devhub.components.molecule.Tile`
) || { Tile: () => <></> };

const item = {
path: `${REPL_TREASURY_TEMPLAR_CONTRACT}/profile/**`,
};

const profile = Social.get(item.path);

if (!profile.description) {
<div
style={{ height: "50vh" }}
className="d-flex justify-content-center align-items-center w-100"
>
<Widget src={`${REPL_DEVHUB}/widget/devhub.components.molecule.Spinner`} />
</div>;
}

const initialData = profile.description;
const [content, setContent] = useState(null);
const [showCommentToast, setCommentToast] = useState(false);
const [handler, setHandler] = useState(null);
const [isTxnCreated, setTxnCreated] = useState(false);

const Container = styled.div`
width: 100%;
margin: 0 auto;
padding: 20px;
text-align: left;
`;

const hasDataChanged = () => {
return content !== initialData;
};

const handlePublish = () => {
setTxnCreated(true);
Near.call([
{
contractName: "${REPL_TREASURY_TEMPLAR_CONTRACT}",
methodName: "set_social_db_profile_description",
args: { description: content },
gas: 270000000000000,
},
]);
};

useEffect(() => {
if (isTxnCreated) {
const checkForAboutInSocialDB = () => {
Near.asyncView(REPL_SOCIAL_CONTRACT, "get", {
keys: [item.path],
}).then((result) => {
try {
const submittedAboutText = content;
const lastAboutTextFromSocialDB =
result["${REPL_TREASURY_TEMPLAR_CONTRACT}"].profile.description;
if (submittedAboutText === lastAboutTextFromSocialDB) {
setTxnCreated(false);
setCommentToast(true);
return;
}
} catch (e) {}
setTimeout(() => checkForAboutInSocialDB(), 2000);
});
};
checkForAboutInSocialDB();
}
}, [isTxnCreated]);

useEffect(() => {
if (!content && initialData) {
setContent(initialData);
setHandler("update");
}
}, [initialData]);

function Preview() {
return (
<Tile className="p-3" style={{ background: "white", minHeight: "500px" }}>
<Widget
src={`${REPL_DEVHUB}/widget/devhub.components.molecule.SimpleMDEViewer`}
props={{
content: content,
height: "500px",
}}
/>
</Tile>
);
}

return (
<Container>
<Widget
src={`${REPL_NEAR}/widget/DIG.Toast`}
props={{
title: "About page updated successfully",
type: "success",
open: showCommentToast,
onOpenChange: (v) => setCommentToast(v),
trigger: <></>,
providerProps: { duration: 3000 },
}}
/>
<ul className="nav nav-tabs" id="editPreviewTabs" role="tablist">
<li className="nav-item" role="presentation">
<button
className="nav-link active"
id="edit-tab"
data-bs-toggle="tab"
data-bs-target="#edit"
type="button"
role="tab"
aria-controls="edit"
aria-selected="true"
>
Edit
</button>
</li>
<li className="nav-item" role="presentation">
<button
className="nav-link"
id="preview-tab"
data-bs-toggle="tab"
data-bs-target="#preview"
type="button"
role="tab"
aria-controls="preview"
aria-selected="false"
>
Preview
</button>
</li>
</ul>
<div className="tab-content" id="editPreviewTabsContent">
<div
className="tab-pane show active py-4"
id="edit"
role="tabpanel"
aria-labelledby="edit-tab"
>
<Widget
src={`${REPL_TREASURY_TEMPLAR}/widget/components.molecule.SimpleMDE`}
props={{
data: { handler: handler, content: content },
onChangeKeyup: (v) => {
setContent(v);
},
showAutoComplete: true,
}}
/>

<div
className={"d-flex align-items-center justify-content-end gap-3 mt-4"}
>
<Widget
src={`${REPL_DEVHUB}/widget/devhub.components.molecule.Button`}
props={{
classNames: { root: "btn-success" },
disabled: !hasDataChanged(),
icon: {
type: "bootstrap_icon",
variant: "bi-check-circle-fill",
},
label: "Publish",
onClick: handlePublish,
}}
/>
</div>
</div>
<div
className="tab-pane"
id="preview"
role="tabpanel"
aria-labelledby="preview-tab"
style={{ position: "relative" }}
>
<div className="w-100 h-100 py-4">
<Preview />
</div>
</div>
</div>
</Container>
);
Loading
Loading