From 5b49f0d4fc1c09b27ccb47cf4239d2a2836c5b67 Mon Sep 17 00:00:00 2001 From: crowetic Date: Sat, 5 Apr 2025 16:37:15 -0700 Subject: [PATCH] Added additional checks for expired transactions, and changed display on the MAM board, also added check for promotionCard so that previous promotions are kept separate. --- assets/js/ARBoard.js | 140 +++++++++++++++++++++++++++++---------- assets/js/AdminBoard.js | 3 +- assets/js/AdminTools.js | 15 +++-- assets/js/MinterBoard.js | 7 ++ 4 files changed, 121 insertions(+), 44 deletions(-) diff --git a/assets/js/ARBoard.js b/assets/js/ARBoard.js index f845922..5b59303 100644 --- a/assets/js/ARBoard.js +++ b/assets/js/ARBoard.js @@ -97,6 +97,7 @@ const loadAddRemoveAdminPage = async () => { document.getElementById("refresh-cards-button").addEventListener("click", async () => { const cardsContainer = document.getElementById("cards-container") cardsContainer.innerHTML = "

Refreshing cards...

" + await initializeCachedGroups() await loadCards(addRemoveIdentifierPrefix) }) @@ -168,51 +169,63 @@ const fetchAllARTxData = async () => { txGroupId: 694, }) - const { finalAddTxs, pendingAddTxs } = partitionAddTransactions(allAddTxs) - const { finalRemTxs, pendingRemTxs } = partitionRemoveTransactions(allRemTxs) + const { finalAddTxs, pendingAddTxs, expiredAddTxs } = partitionAddTransactions(allAddTxs) + const { finalRemTxs, pendingRemTxs, expiredRemTxs } = partitionRemoveTransactions(allRemTxs) // We are going to keep all transactions in order to filter more accurately for display purposes. - console.log('Final addAdminTxs:', finalAddTxs); - console.log('Pending addAdminTxs:', pendingAddTxs); - console.log('Final remAdminTxs:', finalRemTxs); - console.log('Pending remAdminTxs:', pendingRemTxs); + console.log('Final addAdminTxs:', finalAddTxs) + console.log('Pending addAdminTxs:', pendingAddTxs) + console.log('expired addAdminTxs', expiredAddTxs) + console.log('Final remAdminTxs:', finalRemTxs) + console.log('Pending remAdminTxs:', pendingRemTxs) + console.log('expired remAdminTxs', expiredRemTxs) return { finalAddTxs, pendingAddTxs, + expiredAddTxs, finalRemTxs, pendingRemTxs, + expiredRemTxs } } const partitionAddTransactions = (rawTransactions) => { - const finalAddTxs = [] - const pendingAddTxs = [] - - for (const tx of rawTransactions) { - if (tx.approvalStatus === 'PENDING') { - pendingAddTxs.push(tx) - } else { - finalAddTxs.push(tx) - } + const finalAddTxs = [] + const pendingAddTxs = [] + const expiredAddTxs = [] + + for (const tx of rawTransactions) { + if (tx.approvalStatus === 'PENDING') { + pendingAddTxs.push(tx) } - - return { finalAddTxs, pendingAddTxs }; + else if (tx.approvalStatus === 'EXPIRED'){ + expiredAddTxs.push(tx) + } else { + finalAddTxs.push(tx) + } + } + + return { finalAddTxs, pendingAddTxs, expiredAddTxs }; } const partitionRemoveTransactions = (rawTransactions) => { - const finalRemTxs = [] - const pendingRemTxs = [] + const finalRemTxs = [] + const pendingRemTxs = [] + const expiredRemTxs = [] - for (const tx of rawTransactions) { - if (tx.approvalStatus === 'PENDING') { + for (const tx of rawTransactions) { + if (tx.approvalStatus === 'PENDING') { pendingRemTxs.push(tx) - } else { + } + else if (tx.approvalStatus === 'EXPIRED'){ + expiredRemTxs.push(tx) + } else { finalRemTxs.push(tx) - } - } + } + } - return { finalRemTxs, pendingRemTxs } + return { finalRemTxs, pendingRemTxs, expiredRemTxs } } @@ -829,9 +842,9 @@ const createARCardHTML = async (cardData, pollResults, cardIdentifier, commentCo const actionsHtmlCheck = await checkAndDisplayActions(adminYes, verifiedName, cardIdentifier) actionsHtml = actionsHtmlCheck - const { finalAddTxs, pendingAddTxs, finalRemTxs, pendingRemTxs } = await fetchAllARTxData() + const { finalAddTxs, pendingAddTxs, expiredAddTxs, finalRemTxs, pendingRemTxs, expiredRemTxs } = await fetchAllARTxData() - const confirmedAdd = finalAddTxs.some( + const userConfirmedAdd = finalAddTxs.some( (tx) => tx.groupId === 694 && tx.member === accountAddress ) const userPendingAdd = pendingAddTxs.some( @@ -843,31 +856,88 @@ const createARCardHTML = async (cardData, pollResults, cardIdentifier, commentCo const userPendingRemove = pendingRemTxs.some( (tx) => tx.groupId === 694 && tx.admin === accountAddress ) + const userExpiredAdd = expiredAddTxs.some( + (tx) => tx.groupId === 694 && tx.member === accountAddress + ) + const userExpiredRem = expiredRemTxs.some( + (tx) => tx.groupId === 694 && tx.admin === accountAddress + ) + + const noExpired = (!userExpiredAdd && !userExpiredRem) // If user is definitely admin (finalAdd) and not pending removal - if (confirmedAdd && !userPendingRemove && existingAdmin) { + if (userConfirmedAdd && !userPendingRemove && !userPendingAdd && noExpired && existingAdmin && promotionCard) { console.warn(`account was already admin, final. no add/remove pending.`); cardColorCode = 'rgb(3, 11, 24)' - altText = `

PROMOTED to ADMIN

`; + altText = `

PROMOTED to ADMIN

`; actionsHtml = '' } - if (confirmedAdd && userPendingRemove && existingAdmin) { + if (userConfirmedAdd && !userPendingRemove && userExpiredRem && existingAdmin && promotionCard) { + console.warn(`Account has previously had a removal attempt expire`); + cardColorCode = 'rgb(33, 40, 11)' + altText = `

PROMOTED, (+Previous Failed Demotion).

`; + actionsHtml = '' + } + + if (userConfirmedAdd && !userPendingRemove && userExpiredAdd && existingAdmin && promotionCard) { + console.warn(`Account has previously had a removal attempt expire`); + cardColorCode = 'rgb(14, 3, 24)' + altText = `

PROMOTED, (+Previous Failed Promotion).

`; + actionsHtml = '' + } + + if (userConfirmedAdd && userPendingRemove && existingAdmin && noExpired && !promotionCard) { console.warn(`user is a previously approved an admin, but now has pending removals. Keeping html`) + altText = `

Pending REMOVAL in progress...

`; + } + + if (userConfirmedAdd && userPendingRemove && existingAdmin && userExpiredAdd && !promotionCard) { + console.warn(`user is a previously approved an admin, but now has pending removals. Keeping html`) + altText = `

Pending REMOVAL in progress... (+Previous Failed Promotion)

`; + } + + if (userConfirmedAdd && userPendingRemove && existingAdmin && userExpiredRem && !promotionCard) { + console.warn(`user is a previously approved an admin, but now has pending removals. Keeping html`) + altText = `

Pending REMOVAL in progress... (+Previous Failed Demotion)

`; } - // If user has a final "remove" and no pending additions or removals - if (confirmedRemove && !userPendingAdd && existingMinter) { - console.warn(`account was demoted, final. no add pending, existingMinter.`); + // If user has a final "remove" and no pending additions or removals and no expired transactions + if (confirmedRemove && !userPendingAdd && existingMinter && !existingAdmin && noExpired && !promotionCard) { + console.warn(`account was demoted, final. no add pending, existingMinter, no expired add/remove.`); cardColorCode = 'rgb(29, 4, 6)' altText = `

DEMOTED from ADMIN

` actionsHtml = '' } + + if (confirmedRemove && !userPendingAdd && existingMinter && !existingAdmin && userExpiredRem && !promotionCard) { + console.warn(`account was demoted, final. no add pending, existingMinter, no expired add/remove.`); + cardColorCode = 'rgb(29, 4, 6)' + altText = `

DEMOTED (+Previous Failed Demotion)

` + actionsHtml = '' + } + + if (confirmedRemove && !userPendingAdd && existingMinter && !existingAdmin && userExpiredAdd && !promotionCard) { + console.warn(`account was demoted, final. no add pending, existingMinter, no expired add/remove.`); + cardColorCode = 'rgb(29, 4, 6)' + altText = `

DEMOTED (+Previous Failed Promotion)

` + actionsHtml = '' + } // If user has both final remove and pending add, do something else - if (confirmedRemove && userPendingAdd && existingMinter) { + if (confirmedRemove && userPendingAdd && existingMinter && noExpired && promotionCard) { console.warn(`account was previously demoted, but also a pending re-add, allowing actions to show...`) - // Possibly show "DEMOTED but re-add in progress" or something + altText = `

Previously DEMOTED from ADMIN, attempted re-add in progress...

` + } + + if (confirmedRemove && userPendingAdd && existingMinter && userExpiredAdd && promotionCard) { + console.warn(`account was previously demoted, but also a pending re-add, allowing actions to show...`) + altText = `

Previously DEMOTED from ADMIN, attempted re-add in progress...(+Previous Failed Promotion)

` + } + + if (confirmedRemove && userPendingAdd && existingMinter && userExpiredRem && promotionCard) { + console.warn(`account was previously demoted, but also a pending re-add, allowing actions to show...`) + altText = `

Previously DEMOTED from ADMIN, attempted re-add in progress...(+Previous Failed Demotion)

` } } else if ( verifiedName && illegalDuplicate) { diff --git a/assets/js/AdminBoard.js b/assets/js/AdminBoard.js index ce7bc43..fdb5704 100644 --- a/assets/js/AdminBoard.js +++ b/assets/js/AdminBoard.js @@ -72,8 +72,7 @@ const loadAdminBoardPage = async () => { mainContent.innerHTML = `

AdminBoard

-

The Admin Board is an encrypted card publishing board to keep track of minter data for the Minter Admins. Any Admin may publish a card, and related data, make comments on existing cards, and vote on existing card data in support or not of the name on the card. It is essentially a 'project management' tool to assist the Minter Admins in keeping track of the data related to minters they are adding/removing from the minter group.

-

More functionality will be added over time. One of the first features will be the ability to output the existing card data 'decisions', to a json formatted list in order to allow crowetic to run his script easily until the final Mintership proposal changes are completed, and the MINTER group is transferred to 'null'.

+

The Admin Board was meant to be utilized for DECISIONS regarding Minters or would-be Minters, and is encrypted to the Admins so that the data for the DECISIONS remains private. However, it later became the location to REMOVE minters as well. This, not being the original intended purpose has become problematic, as the removal data SHOULD be public. In the future, this data WILL be made public. The Admin Board will continue to be utilized for decision-making, but will NOT be a place for hidden removal data only.