Skip to content

Commit

Permalink
feat: move kyc to events (#891)
Browse files Browse the repository at this point in the history
* feat: move kyc to events

* wip: laggy test doesn't work

* add REPL_PROPOSAL_FEED_INDEXER_QUERY_NAME and REPL_INDEXER_HASURA_ROLE

* revert this change later deploy

* revert change

* reuse accepted terms component from devhub

* spell: event committee -> events committee

* change the indexer

* fix test
  • Loading branch information
Tguntenaar authored Jul 25, 2024
1 parent 5b7f735 commit 401ac11
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ const ConsentComponent = useMemo(() => {
src={
"${REPL_DEVHUB}/widget/devhub.entity.proposal.AcceptedTerms"
}
props={{ proposalId: proposalId }}
props={{ proposalId: proposalId, portal: "DevHub" }}
/>
and commit to honoring it
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ const Button = ({
disabled ? "disabled" : "",
].join(" ")}
style={{ width: "fit-content" }}
disabled={disabled}
{...restProps}
data-testid={props.testId ?? "button"}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ function sortTimelineAndComments() {
.slice(1)
.map((item, index) => {
const startingPoint = snapshotHistory[index]; // Set comparison to the previous item
// we don't show timeline_version in logs
delete startingPoint.timeline.timeline_version;
delete item.timeline.timeline_version;
if (
startingPoint.timeline.kyc_verified === undefined &&
item.timeline.kyc_verified === false
) {
startingPoint.timeline.kyc_verified = false;
}

return {
editorId: item.editor_id,
...getDifferentKeysWithValues(startingPoint, item),
Expand Down Expand Up @@ -270,8 +280,12 @@ function parseTimelineKeyAndValue(timeline, originalValue, modifiedValue) {
</span>
)
);
case "sponsor_requested_review":
return !oldValue && newValue && <span>completed review</span>;
case "sponsor_requested_review": {
if (!oldValue && newValue) {
return <span>completed review</span>;
} else if (oldValue && !newValue) return <span>unmarked review</span>;
return null;
}
case "reviewer_completed_attestation":
return !oldValue && newValue && <span>completed attestation</span>;
case "kyc_verified":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -737,9 +737,12 @@ const onSubmit = ({ isDraft, isCancel }) => {
status: "CANCELLED",
sponsor_requested_review: false,
reviewer_completed_attestation: false,
kyc_verified: false,
}
: isDraft
? { status: "DRAFT" }
: isEditPage
? editProposalData.snapshot.timeline
: {
status: "REVIEW",
sponsor_requested_review: false,
Expand All @@ -749,6 +752,10 @@ const onSubmit = ({ isDraft, isCancel }) => {
const args = { labels: (labels ?? []).map((i) => i.value), body: body };
if (isEditPage) {
args["id"] = editProposalData.id;
} else {
args["accepted_terms_and_conditions_version"] = parseInt(
Near.block().header.height
);
}

Near.call([
Expand Down Expand Up @@ -890,16 +897,12 @@ const ConsentComponent = useMemo(() => {
label: (
<>
I’ve agree to{" "}
<a
href={
"https://docs.google.com/document/d/1nRGy7LhpLj56SjN9MseV1x-ubH8O_c6B9DOAZ9qTwMU/edit?usp=sharing"
<Widget
src={
"${REPL_DEVHUB}/widget/devhub.entity.proposal.AcceptedTerms"
}
className="text-decoration-underline"
target="_blank"
rel="noopener noreferrer"
>
Event Committee’s Terms and Conditions
</a>
props={{ proposalId: proposalId, portal: "Events Committee" }}
/>
and commit to honoring it
</>
),
Expand All @@ -926,7 +929,7 @@ const ConsentComponent = useMemo(() => {
target="_blank"
rel="noopener noreferrer"
>
Event Committee’s Code of Conduct
Events Committee’s Code of Conduct
</a>
and commit to honoring it
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,14 @@ const proposalStatusOptions = [
status: TIMELINE_STATUS.REVIEW,
sponsor_requested_review: false,
reviewer_completed_attestation: false,
kyc_verified: false,
},
},
{
label: "Approved",
value: {
status: TIMELINE_STATUS.APPROVED,
kyc_verified: true,
sponsor_requested_review: true,
reviewer_completed_attestation: false,
},
Expand All @@ -365,6 +367,7 @@ const proposalStatusOptions = [
label: "Approved-Conditionally",
value: {
status: TIMELINE_STATUS.APPROVED_CONDITIONALLY,
kyc_verified: true,
sponsor_requested_review: true,
reviewer_completed_attestation: false,
},
Expand All @@ -375,6 +378,7 @@ const proposalStatusOptions = [
status: TIMELINE_STATUS.REJECTED,
sponsor_requested_review: true,
reviewer_completed_attestation: false,
kyc_verified: true,
},
},
{
Expand All @@ -383,13 +387,14 @@ const proposalStatusOptions = [
status: TIMELINE_STATUS.CANCELED,
sponsor_requested_review: false,
reviewer_completed_attestation: false,
kyc_verified: true,
},
},
{
label: "Payment-processing",
value: {
status: TIMELINE_STATUS.PAYMENT_PROCESSING,
kyc_verified: false,
kyc_verified: true,
test_transaction_sent: false,
request_for_trustees_created: false,
sponsor_requested_review: true,
Expand Down Expand Up @@ -438,9 +443,11 @@ const LinkedProposals = () => {
}}
/>
<div className="d-flex flex-column" style={{ maxWidth: 250 }}>
<LinkProfile account={item.snapshot.name}>
<b className="text-truncate">{item.snapshot.name}</b>
</LinkProfile>
<div className="text-truncate">
<LinkProfile account={item.snapshot.name}>
<b>{item.snapshot.name}</b>
</LinkProfile>
</div>
<div className="text-sm text-muted">
created on {readableDate(item.snapshot.timestamp / 1000000)}
</div>
Expand Down Expand Up @@ -532,10 +539,10 @@ const editProposalStatus = ({ timeline }) => {
Near.call([
{
contractName: "${REPL_EVENTS_CONTRACT}",
methodName: "edit_proposal_timeline",
methodName: "edit_proposal_versioned_timeline",
args: {
id: proposal.id,
timeline: timeline,
timeline: { timeline_version: "V1", ...timeline },
},
gas: 270000000000000,
},
Expand Down Expand Up @@ -1156,6 +1163,21 @@ return (
.reviewer_completed_attestation
}
/>
<CheckBox
value={updatedProposalStatus.value.kyc_verified}
label="Sponsor verifies KYC/KYB"
disabled={selectedStatusIndex !== 1}
onClick={(value) =>
setUpdatedProposalStatus((prevState) => ({
...prevState,
value: {
...prevState.value,
kyc_verified: value,
},
}))
}
isChecked={updatedProposalStatus.value.kyc_verified}
/>
</div>
</TimelineItems>
<TimelineItems
Expand Down Expand Up @@ -1221,21 +1243,6 @@ return (
value={TIMELINE_STATUS.PAYMENT_PROCESSING}
>
<div className="d-flex flex-column gap-2">
<CheckBox
value={updatedProposalStatus.value.kyc_verified}
label="Sponsor verifies KYC/KYB"
disabled={selectedStatusIndex !== 6}
onClick={(value) =>
setUpdatedProposalStatus((prevState) => ({
...prevState,
value: {
...prevState.value,
kyc_verified: value,
},
}))
}
isChecked={updatedProposalStatus.value.kyc_verified}
/>
<CheckBox
value={
updatedProposalStatus.value.test_transaction_sent
Expand Down Expand Up @@ -1430,17 +1437,25 @@ return (
},
}}
/>

<Widget
src={
"${REPL_EVENTS}/widget/devhub.components.molecule.Button"
}
props={{
label: "Save",
disabled:
!supervisor &&
DecisionStage.includes(
updatedProposalStatus.value.status
),
((updatedProposalStatus.value.status ===
TIMELINE_STATUS.APPROVED ||
updatedProposalStatus.value.status ===
TIMELINE_STATUS.APPROVED_CONDITIONALLY ||
updatedProposalStatus.value.status ===
TIMELINE_STATUS.PAYMENT_PROCESSING) &&
!updatedProposalStatus.value.kyc_verified) ||
(!supervisor &&
DecisionStage.includes(
updatedProposalStatus.value.status
)),
classNames: { root: "green-btn btn-sm" },
onClick: () => {
if (snapshot.supervisor !== supervisor) {
Expand Down
38 changes: 17 additions & 21 deletions playwright-tests/tests/events/proposals.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async function getCurrentBlockHeight(page) {
});
}

test.describe.skip("Wallet is connected, but not KYC verified", () => {
test.describe("Wallet is connected, but not KYC verified", () => {
test.use({
storageState:
"playwright-tests/storage-states/wallet-connected-not-kyc-verified-account.json",
Expand Down Expand Up @@ -188,7 +188,7 @@ test.describe("Don't ask again enabled", () => {
});
});

test.describe.skip('Moderator with "Don\'t ask again" enabled', () => {
test.describe('Moderator with "Don\'t ask again" enabled', () => {
test.use({
storageState:
"playwright-tests/storage-states/wallet-connected-with-devhub-moderator-access-key.json",
Expand Down Expand Up @@ -246,11 +246,11 @@ test.describe.skip('Moderator with "Don\'t ask again" enabled', () => {
);

await page.goto(`/${account}/widget/app?page=proposal&id=17`);
console.log({ account });

await setDontAskAgainCacheValues({
page,
contractId: account,
widgetSrc: `/${account}/widget/devhub.entity.proposal.Proposal`,
widgetSrc: `${account}/widget/devhub.entity.proposal.Proposal`,
methodName: "edit_proposal_versioned_timeline",
});

Expand All @@ -271,9 +271,9 @@ test.describe.skip('Moderator with "Don\'t ask again" enabled', () => {

const callContractToast = await page.getByText("Sending transaction");
await expect(callContractToast).toBeVisible();
await expect(callContractToast).not.toBeAttached({ timeout: 10000 });
await expect(callContractToast).not.toBeAttached();
const timeLineStatusSubmittedToast = await page
.getByText("Timeline status submitted")
.getByText("Timeline status submitted successfully")
.first();
await expect(timeLineStatusSubmittedToast).toBeVisible();

Expand All @@ -285,7 +285,8 @@ test.describe.skip('Moderator with "Don\'t ask again" enabled', () => {
{ hasText: /.*s ago/ }
);
await expect(lastLogItem).toContainText(
"moved proposal from REVIEW to APPROVED"
"moved proposal from REVIEW to APPROVED",
{ timeout: 10000 }
);
await lastLogItem.scrollIntoViewIfNeeded();
await expect(timeLineStatusSubmittedToast).not.toBeAttached();
Expand Down Expand Up @@ -340,7 +341,6 @@ test.describe("Wallet is connected", () => {
test.setTimeout(120000);
await getCurrentBlockHeight(page);
await page.goto(`/${account}/widget/app?page=create-proposal`);

const delay_milliseconds_between_keypress_when_typing = 0;
const titleArea = await page.getByRole("textbox").first();
await expect(titleArea).toBeEditable();
Expand Down Expand Up @@ -379,7 +379,10 @@ test.describe("Wallet is connected", () => {

await pauseIfVideoRecording(page);

await page.frameLocator("iframe").getByText("petersalomonsen.near").click();
await page
.frameLocator("iframe")
.getByText("petersalomonsen.near")
.click({ timeout: 10000 });

await descriptionArea.pressSequentially(`. Also mentioning @m`, {
delay: delay_milliseconds_between_keypress_when_typing,
Expand Down Expand Up @@ -417,7 +420,7 @@ test.describe("Wallet is connected", () => {
null,
1
);
await expect(transactionText).toEqual(
expect(transactionText).toEqual(
JSON.stringify(
{
labels: ["Bounty booster"],
Expand All @@ -438,7 +441,7 @@ test.describe("Wallet is connected", () => {
status: "DRAFT",
},
},
// accepted_terms_and_conditions_version: 122927956,
accepted_terms_and_conditions_version: acceptedTermsVersion,
},
null,
1
Expand Down Expand Up @@ -541,18 +544,9 @@ test.describe("Wallet is connected", () => {
await page.route(
"https://near-queryapi.api.pagoda.co/v1/graphql",
async (route) => {
// const request = await route.request();
// const requestPostData = request.postDataJSON();

const response = await route.fetch({
url: "https://near-queryapi.api.pagoda.co/v1/graphql",
});
// const json = await response.json();

// let proposal2 =
// json.data.thomasguntenaar_near_events_committee_proposals_2_proposals_with_latest_snapshot.find(
// (proposal) => proposal.proposal_id === 2
// );

const json = {
data: {
Expand Down Expand Up @@ -612,6 +606,8 @@ test.describe("Wallet is connected", () => {
await route.fulfill({ response, json });
}
);
await getCurrentBlockHeight(page);

const delay_milliseconds_between_keypress_when_typing = 100;
const titleArea = await page.getByRole("textbox").first();
await expect(titleArea).toBeEditable();
Expand Down Expand Up @@ -698,7 +694,7 @@ test.describe("Wallet is connected", () => {
status: "DRAFT",
},
},
// accepted_terms_and_conditions_version: 122927956,
accepted_terms_and_conditions_version: acceptedTermsVersion,
},
null,
1
Expand Down

0 comments on commit 401ac11

Please sign in to comment.