From 7701504a1781878945be286f9ee2f18476921b56 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sat, 20 Jul 2024 16:03:21 +0200 Subject: [PATCH 1/9] feat: move kyc to events --- .../devhub/components/molecule/Button.jsx | 1 + .../entity/proposal/CommentsAndLogs.jsx | 19 +++++- .../widget/devhub/entity/proposal/Editor.jsx | 1 + .../devhub/entity/proposal/Proposal.jsx | 66 ++++++++++++------- .../tests/events/proposals.spec.js | 51 +++++++++----- .../tests/proposal/proposals.spec.js | 3 +- 6 files changed, 97 insertions(+), 44 deletions(-) diff --git a/instances/events-committee.near/widget/devhub/components/molecule/Button.jsx b/instances/events-committee.near/widget/devhub/components/molecule/Button.jsx index 7d83e2edc..d61e096e3 100644 --- a/instances/events-committee.near/widget/devhub/components/molecule/Button.jsx +++ b/instances/events-committee.near/widget/devhub/components/molecule/Button.jsx @@ -145,6 +145,7 @@ const Button = ({ disabled ? "disabled" : "", ].join(" ")} style={{ width: "fit-content" }} + disabled={disabled} {...restProps} data-testid={props.testId ?? "button"} > diff --git a/instances/events-committee.near/widget/devhub/entity/proposal/CommentsAndLogs.jsx b/instances/events-committee.near/widget/devhub/entity/proposal/CommentsAndLogs.jsx index 386049776..18c236149 100644 --- a/instances/events-committee.near/widget/devhub/entity/proposal/CommentsAndLogs.jsx +++ b/instances/events-committee.near/widget/devhub/entity/proposal/CommentsAndLogs.jsx @@ -93,6 +93,15 @@ 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), @@ -270,8 +279,12 @@ function parseTimelineKeyAndValue(timeline, originalValue, modifiedValue) { ) ); - case "sponsor_requested_review": - return !oldValue && newValue && completed review; + case "sponsor_requested_review": { + if (!oldValue && newValue) { + return completed review; + } else if (oldValue && !newValue) return unmarked review; + return null; + } case "reviewer_completed_attestation": return !oldValue && newValue && completed attestation; case "kyc_verified": @@ -317,7 +330,7 @@ const parseProposalKeyAndValue = (key, modifiedValue, originalValue) => { accepted diff --git a/instances/events-committee.near/widget/devhub/entity/proposal/Editor.jsx b/instances/events-committee.near/widget/devhub/entity/proposal/Editor.jsx index 6ac9c3a19..2c5d985f1 100644 --- a/instances/events-committee.near/widget/devhub/entity/proposal/Editor.jsx +++ b/instances/events-committee.near/widget/devhub/entity/proposal/Editor.jsx @@ -737,6 +737,7 @@ const onSubmit = ({ isDraft, isCancel }) => { status: "CANCELLED", sponsor_requested_review: false, reviewer_completed_attestation: false, + kyc_verified: false, } : isDraft ? { status: "DRAFT" } diff --git a/instances/events-committee.near/widget/devhub/entity/proposal/Proposal.jsx b/instances/events-committee.near/widget/devhub/entity/proposal/Proposal.jsx index 573edbdc6..22c1c5209 100644 --- a/instances/events-committee.near/widget/devhub/entity/proposal/Proposal.jsx +++ b/instances/events-committee.near/widget/devhub/entity/proposal/Proposal.jsx @@ -345,12 +345,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, }, @@ -359,6 +361,7 @@ const proposalStatusOptions = [ label: "Approved-Conditionally", value: { status: TIMELINE_STATUS.APPROVED_CONDITIONALLY, + kyc_verified: true, sponsor_requested_review: true, reviewer_completed_attestation: false, }, @@ -369,6 +372,7 @@ const proposalStatusOptions = [ status: TIMELINE_STATUS.REJECTED, sponsor_requested_review: true, reviewer_completed_attestation: false, + kyc_verified: true, }, }, { @@ -377,13 +381,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, @@ -432,9 +437,11 @@ const LinkedProposals = () => { }} />
- - {item.snapshot.name} - +
+ + {item.snapshot.name} + +
created on {readableDate(item.snapshot.timestamp / 1000000)}
@@ -451,6 +458,7 @@ const CheckBox = ({ value, isChecked, label, disabled, onClick }) => { return (
{ 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, }, @@ -1143,6 +1151,21 @@ return ( .reviewer_completed_attestation } /> + + setUpdatedProposalStatus((prevState) => ({ + ...prevState, + value: { + ...prevState.value, + kyc_verified: value, + }, + })) + } + isChecked={updatedProposalStatus.value.kyc_verified} + />
- - setUpdatedProposalStatus((prevState) => ({ - ...prevState, - value: { - ...prevState.value, - kyc_verified: value, - }, - })) - } - isChecked={updatedProposalStatus.value.kyc_verified} - /> + { if (snapshot.supervisor !== supervisor) { diff --git a/playwright-tests/tests/events/proposals.spec.js b/playwright-tests/tests/events/proposals.spec.js index 7dcbb6729..bcc4c86df 100644 --- a/playwright-tests/tests/events/proposals.spec.js +++ b/playwright-tests/tests/events/proposals.spec.js @@ -1,9 +1,6 @@ import { test as base, expect } from "@playwright/test"; import { modifySocialNearGetRPCResponsesInsteadOfGettingWidgetsFromBOSLoader } from "../../util/bos-loader.js"; -import { - pauseIfVideoRecording, - waitForSelectorToBeVisible, -} from "../../testUtils.js"; +import { pauseIfVideoRecording } from "../../testUtils.js"; import { setCommitWritePermissionDontAskAgainCacheValues, setDontAskAgainCacheValues, @@ -14,7 +11,6 @@ import { encodeResultJSON, } from "../../util/transaction.js"; import { mockRpcRequest } from "../../util/rpcmock.js"; -import { mockSocialIndexResponses } from "../../util/socialapi.js"; const test = base.extend({ // Define an option and provide a default value. @@ -27,6 +23,26 @@ test.afterEach( async ({ page }) => await page.unrouteAll({ behavior: "ignoreErrors" }) ); +let acceptedTermsVersion = 122927956; +async function getCurrentBlockHeight(page) { + // set current block height for accepted terms and conditions + await page.route(`http://localhost:20000/`, async (route) => { + const request = route.request(); + const requestPostData = request.postDataJSON(); + if ( + requestPostData?.method === "block" && + requestPostData?.params?.finality === "optimistic" + ) { + const response = await route.fetch(); + const json = await response.json(); + json.result.header.height = acceptedTermsVersion; + await route.fulfill({ response, json }); + } else { + await route.continue(); + } + }); +} + test.describe("Wallet is connected, but not KYC verified", () => { test.use({ storageState: @@ -251,7 +267,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", @@ -309,11 +325,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", }); @@ -334,9 +350,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(); @@ -348,7 +364,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(); @@ -401,8 +418,8 @@ test.describe("Wallet is connected", () => { account, }) => { 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(); @@ -441,7 +458,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, @@ -479,7 +499,7 @@ test.describe("Wallet is connected", () => { null, 1 ); - await expect(transactionText).toEqual( + expect(transactionText).toEqual( JSON.stringify( { labels: ["Bounty booster"], @@ -500,7 +520,7 @@ test.describe("Wallet is connected", () => { status: "DRAFT", }, }, - // accepted_terms_and_conditions_version: 122927956, + accepted_terms_and_conditions_version: acceptedTermsVersion, }, null, 1 @@ -598,6 +618,7 @@ test.describe("Wallet is connected", () => { account, }) => { test.setTimeout(120000); + await getCurrentBlockHeight(page); await page.goto(`/${account}/widget/app?page=create-proposal`); await page.route( "https://near-queryapi.api.pagoda.co/v1/graphql", diff --git a/playwright-tests/tests/proposal/proposals.spec.js b/playwright-tests/tests/proposal/proposals.spec.js index 558ddbaf0..f8aba463f 100644 --- a/playwright-tests/tests/proposal/proposals.spec.js +++ b/playwright-tests/tests/proposal/proposals.spec.js @@ -87,7 +87,6 @@ test.describe("Don't ask again enabled", () => { await modifySocialNearGetRPCResponsesInsteadOfGettingWidgetsFromBOSLoader( page ); - console.log({ account }); await page.goto(`/${account}/widget/app?page=proposals`); const widgetSrc = `${account}/widget/devhub.entity.proposal.Editor`; @@ -211,6 +210,7 @@ test.describe('Moderator with "Don\'t ask again" enabled', () => { }, modifyOriginalResultFunction: (originalResult) => { originalResult.snapshot.timeline.status = "REVIEW"; + if (isTransactionCompleted) { const lastSnapshot = originalResult.snapshot_history[ @@ -246,6 +246,7 @@ test.describe('Moderator with "Don\'t ask again" enabled', () => { ); await page.goto(`/${account}/widget/app?page=proposal&id=17`); + await setDontAskAgainCacheValues({ page, contractId: account, From 95c62f1816fd14819b2e0712c5655ff4560dbf40 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sat, 20 Jul 2024 17:03:38 +0200 Subject: [PATCH 2/9] wip: laggy test doesn't work --- .../devhub/entity/proposal/CommentsAndLogs.jsx | 1 + .../widget/devhub/entity/proposal/Editor.jsx | 6 ++++++ playwright-tests/tests/events/proposals.spec.js | 13 +++---------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/instances/events-committee.near/widget/devhub/entity/proposal/CommentsAndLogs.jsx b/instances/events-committee.near/widget/devhub/entity/proposal/CommentsAndLogs.jsx index 18c236149..fce79b846 100644 --- a/instances/events-committee.near/widget/devhub/entity/proposal/CommentsAndLogs.jsx +++ b/instances/events-committee.near/widget/devhub/entity/proposal/CommentsAndLogs.jsx @@ -102,6 +102,7 @@ function sortTimelineAndComments() { ) { startingPoint.timeline.kyc_verified = false; } + return { editorId: item.editor_id, ...getDifferentKeysWithValues(startingPoint, item), diff --git a/instances/events-committee.near/widget/devhub/entity/proposal/Editor.jsx b/instances/events-committee.near/widget/devhub/entity/proposal/Editor.jsx index 2c5d985f1..5576b2c88 100644 --- a/instances/events-committee.near/widget/devhub/entity/proposal/Editor.jsx +++ b/instances/events-committee.near/widget/devhub/entity/proposal/Editor.jsx @@ -741,6 +741,8 @@ const onSubmit = ({ isDraft, isCancel }) => { } : isDraft ? { status: "DRAFT" } + : isEditPage + ? editProposalData.snapshot.timeline : { status: "REVIEW", sponsor_requested_review: false, @@ -750,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([ diff --git a/playwright-tests/tests/events/proposals.spec.js b/playwright-tests/tests/events/proposals.spec.js index bcc4c86df..478069132 100644 --- a/playwright-tests/tests/events/proposals.spec.js +++ b/playwright-tests/tests/events/proposals.spec.js @@ -618,23 +618,14 @@ test.describe("Wallet is connected", () => { account, }) => { test.setTimeout(120000); - await getCurrentBlockHeight(page); await page.goto(`/${account}/widget/app?page=create-proposal`); 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: { thomasguntenaar_near_events_committee_proposals_2_proposals_with_latest_snapshot: @@ -693,6 +684,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(); @@ -780,7 +773,7 @@ test.describe("Wallet is connected", () => { status: "DRAFT", }, }, - // accepted_terms_and_conditions_version: 122927956, + accepted_terms_and_conditions_version: acceptedTermsVersion, }, null, 1 From d2098d901c82654af936ad9b2dc1504a350466c3 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sat, 20 Jul 2024 17:24:27 +0200 Subject: [PATCH 3/9] add REPL_PROPOSAL_FEED_INDEXER_QUERY_NAME and REPL_INDEXER_HASURA_ROLE --- .../aliases.mainnet.json | 6 +- .../devhub/components/molecule/SimpleMDE.jsx | 7 +- .../devhub/entity/proposal/AcceptedTerms.jsx | 89 +++++++++++++++++++ .../widget/devhub/entity/proposal/Feed.jsx | 13 +-- .../proposal/LinkedProposalsDropdown.jsx | 9 +- 5 files changed, 103 insertions(+), 21 deletions(-) create mode 100644 instances/events-committee.near/widget/devhub/entity/proposal/AcceptedTerms.jsx diff --git a/instances/events-committee.near/aliases.mainnet.json b/instances/events-committee.near/aliases.mainnet.json index 163d84e8a..43f1da591 100644 --- a/instances/events-committee.near/aliases.mainnet.json +++ b/instances/events-committee.near/aliases.mainnet.json @@ -9,5 +9,7 @@ "REPL_EFIZ": "efiz.near", "REPL_DEVS": "devs.near", "REPL_SOCIAL_CONTRACT": "social.near", - "REPL_RPC_URL": "https://rpc.mainnet.near.org" -} + "REPL_RPC_URL": "https://rpc.mainnet.near.org", + "REPL_PROPOSAL_FEED_INDEXER_QUERY_NAME": "thomasguntenaar_near_events_committee_proposals_2_proposals_with_latest_snapshot", + "REPL_INDEXER_HASURA_ROLE": "thomasguntenaar_near" +} \ No newline at end of file diff --git a/instances/events-committee.near/widget/devhub/components/molecule/SimpleMDE.jsx b/instances/events-committee.near/widget/devhub/components/molecule/SimpleMDE.jsx index 8c2283b43..ae6027ea1 100644 --- a/instances/events-committee.near/widget/devhub/components/molecule/SimpleMDE.jsx +++ b/instances/events-committee.near/widget/devhub/components/molecule/SimpleMDE.jsx @@ -31,8 +31,7 @@ const showAccountAutoComplete = props.showAutoComplete ?? false; const showProposalIdAutoComplete = props.showProposalIdAutoComplete ?? false; const autoFocus = props.autoFocus ?? false; -const queryName = - "thomasguntenaar_near_events_committee_proposals_2_proposals_with_latest_snapshot"; +const queryName = "${REPL_PROPOSAL_FEED_INDEXER_QUERY_NAME}"; const query = `query GetLatestSnapshot($offset: Int = 0, $limit: Int = 10, $where: ${queryName}_bool_exp = {}) { ${queryName}( offset: $offset @@ -231,7 +230,7 @@ async function getSuggestedProposals(id) { } await asyncFetch("https://near-queryapi.api.pagoda.co/v1/graphql", { method: "POST", - headers: { "x-hasura-role": "thomasguntenaar_near" }, + headers: { "x-hasura-role": "${REPL_INDEXER_HASURA_ROLE}" }, body: JSON.stringify({ query: query, variables: variables, @@ -241,7 +240,7 @@ async function getSuggestedProposals(id) { .then((res) => { const proposals = res?.data?.[ - "thomasguntenaar_near_events_committee_proposals_2_proposals_with_latest_snapshot" + "${REPL_PROPOSAL_FEED_INDEXER_QUERY_NAME}" ]; results = proposals; }) diff --git a/instances/events-committee.near/widget/devhub/entity/proposal/AcceptedTerms.jsx b/instances/events-committee.near/widget/devhub/entity/proposal/AcceptedTerms.jsx new file mode 100644 index 000000000..0686ddfae --- /dev/null +++ b/instances/events-committee.near/widget/devhub/entity/proposal/AcceptedTerms.jsx @@ -0,0 +1,89 @@ +const { getLinkUsingCurrentGateway } = VM.require( + "${REPL_DEVHUB}/widget/core.lib.url" +) || { getLinkUsingCurrentGateway: () => {} }; + +State.init({ + proposalBlockHeight: null, +}); + +const proposalId = props.proposalId; + +const QUERYAPI_ENDPOINT = `https://near-queryapi.api.pagoda.co/v1/graphql`; +const fetchGraphQL = (operationsDoc, operationName, variables) => { + return asyncFetch(QUERYAPI_ENDPOINT, { + method: "POST", + headers: { "x-hasura-role": "${REPL_INDEXER_HASURA_ROLE}" }, + body: JSON.stringify({ + query: operationsDoc, + variables: variables, + operationName: operationName, + }), + }); +}; + +const queryName = "${REPL_PROPOSAL_FEED_INDEXER_QUERY_NAME}"; +const query = `query GetLatestSnapshot($offset: Int = 0, $limit: Int = 10, $where: ${queryName}_bool_exp = {}) { + ${queryName}( + offset: $offset + limit: $limit + order_by: {proposal_id: desc} + where: $where + ) { + block_height + } + }`; + +const variables = { + limit: 10, + offset, + where: { proposal_id: { _eq: proposalId } }, +}; + +fetchGraphQL(query, "GetLatestSnapshot", variables).then(async (result) => { + if (result.status === 200) { + if (result.body.data) { + const data = result.body.data?.[queryName]; + State.update({ proposalBlockHeight: data[0].block_height }); + } + } +}); + +let acceptedTermsVersion = Near.block().header.height; + +if (state.proposalBlockHeight !== null) { + const data = fetch( + `https://mainnet.neardata.xyz/v0/block/${state.proposalBlockHeight}` + ); + if (Array.isArray(data?.body?.shards)) { + data.body.shards.map((shard) => { + const data = (shard?.chunk?.transactions ?? []).filter( + (txn) => + txn?.transaction?.receiver_id === "devhub.near" && + txn?.transaction?.actions?.[0]?.FunctionCall?.method_name === + "add_proposal" + ); + if (data?.length) { + const args = JSON.parse( + Buffer.from( + data[0].transaction.actions[0].FunctionCall.args, + "base64" + ).toString("utf8") + ); + acceptedTermsVersion = args.accepted_terms_and_conditions_version; + } + }); + } +} + +return ( + + DevHub’s Terms and Conditions + +); diff --git a/instances/events-committee.near/widget/devhub/entity/proposal/Feed.jsx b/instances/events-committee.near/widget/devhub/entity/proposal/Feed.jsx index 3ce5a40cf..536d583a1 100644 --- a/instances/events-committee.near/widget/devhub/entity/proposal/Feed.jsx +++ b/instances/events-committee.near/widget/devhub/entity/proposal/Feed.jsx @@ -211,8 +211,7 @@ const FeedPage = () => { currentlyDisplaying: 0, }); - const queryName = - "thomasguntenaar_near_events_committee_proposals_2_proposals_with_latest_snapshot"; + const queryName = "${REPL_PROPOSAL_FEED_INDEXER_QUERY_NAME}"; const query = `query GetLatestSnapshot($offset: Int = 0, $limit: Int = 10, $where: ${queryName}_bool_exp = {}) { ${queryName}( offset: $offset @@ -245,7 +244,7 @@ const FeedPage = () => { function fetchGraphQL(operationsDoc, operationName, variables) { return asyncFetch(QUERYAPI_ENDPOINT, { method: "POST", - headers: { "x-hasura-role": `thomasguntenaar_near` }, + headers: { "x-hasura-role": `${REPL_INDEXER_HASURA_ROLE}` }, body: JSON.stringify({ query: operationsDoc, variables: variables, @@ -332,12 +331,8 @@ const FeedPage = () => { fetchGraphQL(query, "GetLatestSnapshot", variables).then(async (result) => { if (result.status === 200) { if (result.body.data) { - const data = - result.body.data - .thomasguntenaar_near_events_committee_proposals_2_proposals_with_latest_snapshot; - const totalResult = - result.body.data - .thomasguntenaar_near_events_committee_proposals_2_proposals_with_latest_snapshot_aggregate; + const data = result.body.data[queryName]; + const totalResult = result.body.data[`${queryName}_aggregate`]; State.update({ aggregatedCount: totalResult.aggregate.count }); // Parse timeline fetchBlockHeights(data, offset); diff --git a/instances/events-committee.near/widget/devhub/entity/proposal/LinkedProposalsDropdown.jsx b/instances/events-committee.near/widget/devhub/entity/proposal/LinkedProposalsDropdown.jsx index 4aa73cf65..c9cf2dd18 100644 --- a/instances/events-committee.near/widget/devhub/entity/proposal/LinkedProposalsDropdown.jsx +++ b/instances/events-committee.near/widget/devhub/entity/proposal/LinkedProposalsDropdown.jsx @@ -7,8 +7,7 @@ const [selectedProposals, setSelectedProposals] = useState(linkedProposals); const [proposalsOptions, setProposalsOptions] = useState([]); const [searchProposalId, setSearchProposalId] = useState(""); const QUERYAPI_ENDPOINT = `https://near-queryapi.api.pagoda.co/v1/graphql`; -const queryName = - "thomasguntenaar_near_events_committee_proposals_2_proposals_with_latest_snapshot"; +const queryName = "${REPL_PROPOSAL_FEED_INDEXER_QUERY_NAME}"; const query = `query GetLatestSnapshot($offset: Int = 0, $limit: Int = 10, $where: ${queryName}_bool_exp = {}) { ${queryName}( offset: $offset @@ -63,7 +62,7 @@ const buildWhereClause = () => { function fetchGraphQL(operationsDoc, operationName, variables) { return asyncFetch(QUERYAPI_ENDPOINT, { method: "POST", - headers: { "x-hasura-role": `thomasguntenaar_near` }, + headers: { "x-hasura-role": `${REPL_INDEXER_HASURA_ROLE}` }, body: JSON.stringify({ query: operationsDoc, variables: variables, @@ -82,9 +81,7 @@ const fetchProposals = () => { fetchGraphQL(query, "GetLatestSnapshot", variables).then(async (result) => { if (result.status === 200) { if (result.body.data) { - const proposalsData = - result.body.data - .thomasguntenaar_near_events_committee_proposals_2_proposals_with_latest_snapshot; + const proposalsData = result.body.data[queryName]; const data = []; for (const prop of proposalsData) { From 023f89b8aab50bb524910dad675de1f86f190b70 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 21 Jul 2024 03:52:01 +0200 Subject: [PATCH 4/9] revert this change later deploy --- .github/workflows/deploy-prod-mainnet-devhub.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/deploy-prod-mainnet-devhub.yml b/.github/workflows/deploy-prod-mainnet-devhub.yml index 5dc31fee3..0f6f982bf 100644 --- a/.github/workflows/deploy-prod-mainnet-devhub.yml +++ b/.github/workflows/deploy-prod-mainnet-devhub.yml @@ -41,9 +41,4 @@ jobs: run: | BRANCH="$(git rev-parse --abbrev-ref HEAD)" echo "on branch $BRANCH" - if [[ "$BRANCH" != "main" ]]; then - echo "Not on main branch, dry run by diff with devhub.near" - bos components diff devhub.near network-config mainnet - else - bos components deploy "$NEAR_SOCIAL_DEPLOY_ID" sign-as "$NEAR_SOCIAL_ACCOUNT_ID" network-config mainnet sign-with-plaintext-private-key --signer-public-key "$NEAR_SOCIAL_ACCOUNT_PUBLIC_KEY" --signer-private-key "$NEAR_SOCIAL_ACCOUNT_PRIVATE_KEY" send - fi + bos components deploy "$NEAR_SOCIAL_DEPLOY_ID" sign-as "$NEAR_SOCIAL_ACCOUNT_ID" network-config mainnet sign-with-plaintext-private-key --signer-public-key "$NEAR_SOCIAL_ACCOUNT_PUBLIC_KEY" --signer-private-key "$NEAR_SOCIAL_ACCOUNT_PRIVATE_KEY" send From d712252ab4192b3c170f8e3f3f422f0231375b4d Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 23 Jul 2024 14:42:51 +0200 Subject: [PATCH 5/9] revert change --- .github/workflows/deploy-prod-mainnet-devhub.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy-prod-mainnet-devhub.yml b/.github/workflows/deploy-prod-mainnet-devhub.yml index 0f6f982bf..5dc31fee3 100644 --- a/.github/workflows/deploy-prod-mainnet-devhub.yml +++ b/.github/workflows/deploy-prod-mainnet-devhub.yml @@ -41,4 +41,9 @@ jobs: run: | BRANCH="$(git rev-parse --abbrev-ref HEAD)" echo "on branch $BRANCH" - bos components deploy "$NEAR_SOCIAL_DEPLOY_ID" sign-as "$NEAR_SOCIAL_ACCOUNT_ID" network-config mainnet sign-with-plaintext-private-key --signer-public-key "$NEAR_SOCIAL_ACCOUNT_PUBLIC_KEY" --signer-private-key "$NEAR_SOCIAL_ACCOUNT_PRIVATE_KEY" send + if [[ "$BRANCH" != "main" ]]; then + echo "Not on main branch, dry run by diff with devhub.near" + bos components diff devhub.near network-config mainnet + else + bos components deploy "$NEAR_SOCIAL_DEPLOY_ID" sign-as "$NEAR_SOCIAL_ACCOUNT_ID" network-config mainnet sign-with-plaintext-private-key --signer-public-key "$NEAR_SOCIAL_ACCOUNT_PUBLIC_KEY" --signer-private-key "$NEAR_SOCIAL_ACCOUNT_PRIVATE_KEY" send + fi From f6f91e3339b007eff3180257e80ba80a5768ed9f Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 24 Jul 2024 13:10:12 +0200 Subject: [PATCH 6/9] reuse accepted terms component from devhub --- .../widget/devhub/entity/proposal/Editor.jsx | 2 +- .../aliases.mainnet.json | 2 +- .../devhub/entity/proposal/AcceptedTerms.jsx | 89 ------------------- .../entity/proposal/CommentsAndLogs.jsx | 2 +- .../widget/devhub/entity/proposal/Editor.jsx | 14 ++- 5 files changed, 8 insertions(+), 101 deletions(-) delete mode 100644 instances/events-committee.near/widget/devhub/entity/proposal/AcceptedTerms.jsx diff --git a/instances/devhub.near/widget/devhub/entity/proposal/Editor.jsx b/instances/devhub.near/widget/devhub/entity/proposal/Editor.jsx index 31fb566cb..50bc35fc5 100644 --- a/instances/devhub.near/widget/devhub/entity/proposal/Editor.jsx +++ b/instances/devhub.near/widget/devhub/entity/proposal/Editor.jsx @@ -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 diff --git a/instances/events-committee.near/aliases.mainnet.json b/instances/events-committee.near/aliases.mainnet.json index 43f1da591..7c520ef83 100644 --- a/instances/events-committee.near/aliases.mainnet.json +++ b/instances/events-committee.near/aliases.mainnet.json @@ -12,4 +12,4 @@ "REPL_RPC_URL": "https://rpc.mainnet.near.org", "REPL_PROPOSAL_FEED_INDEXER_QUERY_NAME": "thomasguntenaar_near_events_committee_proposals_2_proposals_with_latest_snapshot", "REPL_INDEXER_HASURA_ROLE": "thomasguntenaar_near" -} \ No newline at end of file +} diff --git a/instances/events-committee.near/widget/devhub/entity/proposal/AcceptedTerms.jsx b/instances/events-committee.near/widget/devhub/entity/proposal/AcceptedTerms.jsx deleted file mode 100644 index 0686ddfae..000000000 --- a/instances/events-committee.near/widget/devhub/entity/proposal/AcceptedTerms.jsx +++ /dev/null @@ -1,89 +0,0 @@ -const { getLinkUsingCurrentGateway } = VM.require( - "${REPL_DEVHUB}/widget/core.lib.url" -) || { getLinkUsingCurrentGateway: () => {} }; - -State.init({ - proposalBlockHeight: null, -}); - -const proposalId = props.proposalId; - -const QUERYAPI_ENDPOINT = `https://near-queryapi.api.pagoda.co/v1/graphql`; -const fetchGraphQL = (operationsDoc, operationName, variables) => { - return asyncFetch(QUERYAPI_ENDPOINT, { - method: "POST", - headers: { "x-hasura-role": "${REPL_INDEXER_HASURA_ROLE}" }, - body: JSON.stringify({ - query: operationsDoc, - variables: variables, - operationName: operationName, - }), - }); -}; - -const queryName = "${REPL_PROPOSAL_FEED_INDEXER_QUERY_NAME}"; -const query = `query GetLatestSnapshot($offset: Int = 0, $limit: Int = 10, $where: ${queryName}_bool_exp = {}) { - ${queryName}( - offset: $offset - limit: $limit - order_by: {proposal_id: desc} - where: $where - ) { - block_height - } - }`; - -const variables = { - limit: 10, - offset, - where: { proposal_id: { _eq: proposalId } }, -}; - -fetchGraphQL(query, "GetLatestSnapshot", variables).then(async (result) => { - if (result.status === 200) { - if (result.body.data) { - const data = result.body.data?.[queryName]; - State.update({ proposalBlockHeight: data[0].block_height }); - } - } -}); - -let acceptedTermsVersion = Near.block().header.height; - -if (state.proposalBlockHeight !== null) { - const data = fetch( - `https://mainnet.neardata.xyz/v0/block/${state.proposalBlockHeight}` - ); - if (Array.isArray(data?.body?.shards)) { - data.body.shards.map((shard) => { - const data = (shard?.chunk?.transactions ?? []).filter( - (txn) => - txn?.transaction?.receiver_id === "devhub.near" && - txn?.transaction?.actions?.[0]?.FunctionCall?.method_name === - "add_proposal" - ); - if (data?.length) { - const args = JSON.parse( - Buffer.from( - data[0].transaction.actions[0].FunctionCall.args, - "base64" - ).toString("utf8") - ); - acceptedTermsVersion = args.accepted_terms_and_conditions_version; - } - }); - } -} - -return ( - - DevHub’s Terms and Conditions - -); diff --git a/instances/events-committee.near/widget/devhub/entity/proposal/CommentsAndLogs.jsx b/instances/events-committee.near/widget/devhub/entity/proposal/CommentsAndLogs.jsx index fce79b846..bf8887eea 100644 --- a/instances/events-committee.near/widget/devhub/entity/proposal/CommentsAndLogs.jsx +++ b/instances/events-committee.near/widget/devhub/entity/proposal/CommentsAndLogs.jsx @@ -331,7 +331,7 @@ const parseProposalKeyAndValue = (key, modifiedValue, originalValue) => { accepted diff --git a/instances/events-committee.near/widget/devhub/entity/proposal/Editor.jsx b/instances/events-committee.near/widget/devhub/entity/proposal/Editor.jsx index 5576b2c88..41e43f38f 100644 --- a/instances/events-committee.near/widget/devhub/entity/proposal/Editor.jsx +++ b/instances/events-committee.near/widget/devhub/entity/proposal/Editor.jsx @@ -897,16 +897,12 @@ const ConsentComponent = useMemo(() => { label: ( <> I’ve agree to{" "} - - Event Committee’s Terms and Conditions - + props={{ proposalId: proposalId, portal: "Event Committee" }} + /> and commit to honoring it ), From 777e4535a57c7ecdf4cede13d6d6e1fafefec37b Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 25 Jul 2024 15:28:46 +0200 Subject: [PATCH 7/9] spell: event committee -> events committee --- .../widget/devhub/entity/proposal/Editor.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/instances/events-committee.near/widget/devhub/entity/proposal/Editor.jsx b/instances/events-committee.near/widget/devhub/entity/proposal/Editor.jsx index 41e43f38f..e991ac55c 100644 --- a/instances/events-committee.near/widget/devhub/entity/proposal/Editor.jsx +++ b/instances/events-committee.near/widget/devhub/entity/proposal/Editor.jsx @@ -901,7 +901,7 @@ const ConsentComponent = useMemo(() => { src={ "${REPL_DEVHUB}/widget/devhub.entity.proposal.AcceptedTerms" } - props={{ proposalId: proposalId, portal: "Event Committee" }} + props={{ proposalId: proposalId, portal: "Events Committee" }} /> and commit to honoring it @@ -929,7 +929,7 @@ const ConsentComponent = useMemo(() => { target="_blank" rel="noopener noreferrer" > - Event Committee’s Code of Conduct + Events Committee’s Code of Conduct and commit to honoring it From e0a66198feb522a39454e7036e2ff05f8a556a83 Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 25 Jul 2024 15:34:39 +0200 Subject: [PATCH 8/9] change the indexer --- instances/events-committee.near/aliases.mainnet.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instances/events-committee.near/aliases.mainnet.json b/instances/events-committee.near/aliases.mainnet.json index 7c520ef83..efd479a11 100644 --- a/instances/events-committee.near/aliases.mainnet.json +++ b/instances/events-committee.near/aliases.mainnet.json @@ -10,6 +10,6 @@ "REPL_DEVS": "devs.near", "REPL_SOCIAL_CONTRACT": "social.near", "REPL_RPC_URL": "https://rpc.mainnet.near.org", - "REPL_PROPOSAL_FEED_INDEXER_QUERY_NAME": "thomasguntenaar_near_events_committee_proposals_2_proposals_with_latest_snapshot", + "REPL_PROPOSAL_FEED_INDEXER_QUERY_NAME": "thomasguntenaar_near_event_committee_prod_v1_proposals_with_latest_snapshot", "REPL_INDEXER_HASURA_ROLE": "thomasguntenaar_near" } From 8a9f9f0a00a346aadbf0c9af3d1edcc836881e07 Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 25 Jul 2024 16:03:10 +0200 Subject: [PATCH 9/9] fix test --- playwright-tests/tests/events/proposals.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/playwright-tests/tests/events/proposals.spec.js b/playwright-tests/tests/events/proposals.spec.js index 384f45310..33bfcf9b9 100644 --- a/playwright-tests/tests/events/proposals.spec.js +++ b/playwright-tests/tests/events/proposals.spec.js @@ -550,7 +550,7 @@ test.describe("Wallet is connected", () => { const json = { data: { - thomasguntenaar_near_events_committee_proposals_2_proposals_with_latest_snapshot: + thomasguntenaar_near_event_committee_prod_v1_proposals_with_latest_snapshot: [ { author_id: "meghagoel.near", @@ -593,7 +593,7 @@ test.describe("Wallet is connected", () => { labels: [], }, ], - thomasguntenaar_near_events_committee_proposals_2_proposals_with_latest_snapshot_aggregate: + thomasguntenaar_near_event_committee_prod_v1_proposals_with_latest_snapshot_aggregate: { aggregate: { count: 7,