Fix for kick/ban transactions on AdminBoard, and fix for tx creation showing up improperly.

This commit is contained in:
2025-02-05 20:01:01 -08:00
parent f5ce634ff5
commit 51921992e2
5 changed files with 27 additions and 20 deletions

View File

@@ -1078,7 +1078,7 @@ const createRemoveButtonHtml = (name, cardIdentifier) => {
const handleKickMinter = async (minterName) => {
try {
isAddress = await getAddressInfo(minterName)
let isAddress = await getAddressInfo(minterName)
// Optional block check
let txGroupId = 0
@@ -1091,7 +1091,7 @@ const handleKickMinter = async (minterName) => {
// Get the minter address from name info
let minterAddress
if (!isAddress){
if (!isAddress.address || !isAddress.address != minterName){
const minterNameInfo = await getNameInfo(minterName)
minterAddress = minterNameInfo?.owner
} else {
@@ -1107,7 +1107,7 @@ const handleKickMinter = async (minterName) => {
const reason = 'Kicked by Minter Admins'
const fee = 0.01
const rawKickTransaction = await createGroupKickTransaction(minterAddress, adminPublicKey, 694, minterAddress, reason, txGroupId, fee)
const rawKickTransaction = await createGroupKickTransaction(adminPublicKey, 694, minterAddress, reason, txGroupId, fee)
const signedKickTransaction = await qortalRequest({
action: "SIGN_TRANSACTION",
@@ -1138,7 +1138,7 @@ const handleKickMinter = async (minterName) => {
}
const handleBanMinter = async (minterName) => {
isAddress = await getAddressInfo(minterName)
let isAddress = await getAddressInfo(minterName)
try {
let txGroupId = 0
// const { height: currentHeight } = await getLatestBlockInfo()
@@ -1151,9 +1151,9 @@ const handleBanMinter = async (minterName) => {
txGroupId = 694
}
let minterAddress
if (!isAddress) {
if (!isAddress.address || !isAddress.address != minterName){
const minterNameInfo = await getNameInfo(minterName)
const minterAddress = minterNameInfo?.owner
minterAddress = minterNameInfo?.owner
} else {
minterAddress = minterName
}

View File

@@ -1534,7 +1534,7 @@ const checkAndDisplayInviteButton = async (adminYes, creator, cardIdentifier) =>
// fetch all final KICK/BAN tx
const { finalKickTxs, finalBanTxs } = await fetchAllKickBanTxData()
const { finalInviteTxs, pendingInviteTxs } = await fetchAllInviteTransactions()
// check if there's a final (non-pending) KICK or BAN for this user
// check if there's a KICK or BAN for this user.
const priorKick = finalKickTxs.some(tx => tx.member === minterAddress)
const priorBan = finalBanTxs.some(tx => tx.offender === minterAddress)
const existingInvite = finalInviteTxs.some(tx => tx.invitee === minterAddress)
@@ -1545,10 +1545,12 @@ const checkAndDisplayInviteButton = async (adminYes, creator, cardIdentifier) =>
// build the normal invite button & groupApprovalHtml
let inviteButtonHtml = ""
if (existingInvite || pendingInvite){
console.warn(`There is an EXISTING INVITE for this user! No invite button being created... existing: (${existingInvite}, pending: ${pendingInvite})`)
console.warn(`There is an EXISTING or PENDING INVITE for this user! No invite button being created... existing: (${existingInvite}, pending: ${pendingInvite})`)
inviteButtonHtml = ''
} else {
inviteButtonHtml = isSomeTypaAdmin ? createInviteButtonHtml(creator, cardIdentifier) : ""
}
inviteButtonHtml = isSomeTypaAdmin ? createInviteButtonHtml(creator, cardIdentifier) : ""
const groupApprovalHtml = await checkGroupApprovalAndCreateButton(minterAddress, cardIdentifier, "GROUP_INVITE")
// if user had no prior KICK/BAN

View File

@@ -1,4 +1,4 @@
const Q_MINTERSHIP_VERSION = "1.06.1"
const Q_MINTERSHIP_VERSION = "1.06.2"
const messageIdentifierPrefix = `mintership-forum-message`
const messageAttachmentIdentifierPrefix = `mintership-forum-attachment`

View File

@@ -224,6 +224,12 @@ const getUserAddress = async () => {
}
const getAddressInfo = async (address) => {
const qortalAddressPattern = /^Q[A-Za-z0-9]{33}$/ // Q + 33 almum = 34 total length
if (!qortalAddressPattern.test(address)) {
console.warn(`Not a valid Qortal address format, returning same thing that was passed to not break other functions: ${address}`)
return address
}
try {
const response = await fetch (`${baseUrl}/addresses/${address}`, {
headers: { 'Accept': 'application/json' },
@@ -1395,16 +1401,16 @@ const createGroupInviteTransaction = async (recipientAddress, adminPublicKey, gr
}
}
const createGroupKickTransaction = async (recipientAddress, adminPublicKey, groupId=694, member, reason='Kicked by admins', txGroupId, fee) => {
const createGroupKickTransaction = async (adminPublicKey, groupId=694, member, reason='Kicked by admins', txGroupId=694, fee=0.01) => {
try {
// Fetch account reference correctly
const accountInfo = await getAddressInfo(recipientAddress)
const accountInfo = await getAddressInfo(member)
const accountReference = accountInfo.reference
// Validate inputs before making the request
if (!adminPublicKey || !accountReference || !recipientAddress) {
throw new Error("Missing required parameters for group invite transaction.")
if (!adminPublicKey || !accountReference || !member) {
throw new Error("Missing required parameters for group kick transaction.")
}
const payload = {
@@ -1412,11 +1418,10 @@ const createGroupKickTransaction = async (recipientAddress, adminPublicKey, grou
reference: accountReference,
fee,
txGroupId,
recipient: null,
adminPublicKey,
groupId: groupId,
member: member || recipientAddress,
reason: reason
groupId,
member,
reason
}
console.log("Sending GROUP_KICK transaction payload:", payload)