Skip to content

Feat(SC): Implement News Contract#331

Closed
victorkl400 wants to merge 25 commits intomainfrom
feat/news-sc
Closed

Feat(SC): Implement News Contract#331
victorkl400 wants to merge 25 commits intomainfrom
feat/news-sc

Conversation

@victorkl400
Copy link
Copy Markdown
Contributor

@victorkl400 victorkl400 commented Jun 5, 2025

Description

This PR introduces the News contract, allowing X2EarnApp admins and the vebetter DAO to emit news events and save it on storage. These events/storage can be consumed by client-side apps like the vebetter frontend, vechain-kit, and other internal tools by querying by appId for storage or filtering events by app id.

TODOs

  • Basic Tests
  • Implement publish function
  • Helper: check if sender is an app or DAO admin
  • Add storage for recent news counters
  • Reset counter on new round
  • Add limit per app per week to prevent spam (depends on cooldown period to be set)
  • Decide: store full message on IPFS (emit CID) or on-chain? It was decided to be raw values on chain
  • Make publish not tied to appId
  • Deployment script
  • Paginate app news on getter
  • Implement moderate function so VBD admin could remove published news or at least flag them as invalid
  • Track how many news items an app has published
  • Improve the way "publishers" could interact with the contract
  • Improve the handling of removed news

Current Implementation deployed at https://insight.vecha.in/#/test/accounts/0x4b73A87567841cC261d1663499986488a21d4Ba0/

Updated packages (if any):

  • next-template
  • homepage
  • vechain-kit
  • contracts

Base automatically changed from feat/setup-contracts-package to main June 5, 2025 14:13
@victorkl400 victorkl400 self-assigned this Jun 5, 2025
@victorkl400 victorkl400 changed the base branch from main to chore/move-contracts-workspace June 6, 2025 12:24
@victorkl400 victorkl400 linked an issue Jun 6, 2025 that may be closed by this pull request
Base automatically changed from chore/move-contracts-workspace to main June 19, 2025 08:33
Comment on lines +209 to +232
function assignPublisherToCustomApp(
bytes32 appId,
address user
) external onlyRoleOrAdmin(MODERATOR_ROLE) {
NewsStorage storage $ = _getNewsStorage();
require(
!$.x2EarnApps.appExists(appId),
'News: cannot assign publisher to VeBetterDAO app'
);
_grantRole(PUBLISHER_ROLE, user);
$.appIdOfPublisher[user] = appId;
}

/**
* @dev Removes a publisher from an app
* @param user - the publisher address
*/
function removePublisherFromCustomApp(
address user
) external onlyRoleOrAdmin(MODERATOR_ROLE) {
NewsStorage storage $ = _getNewsStorage();
_revokeRole(PUBLISHER_ROLE, user);
delete $.appIdOfPublisher[user];
}
Copy link
Copy Markdown
Contributor Author

@victorkl400 victorkl400 Jun 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not totally sure about this one. It would allow anyone with a publisher role to publish by specifying an app ID which must not be an existing VBD app. The idea is to let VBD, vechain-kit, or anyone else publish their own news without needing to deploy or participate in VBD.

But it might be confusing in terms of smart contract validation and UX. The client could get revert reasons like “News: app does not exist” or “News: not app admin, creator or moderator,” which might be hard to interpret.

Comment on lines +42 to +59
function copySelectedFiles() {
filesToCopy.forEach((file) => {
const sourceFile = path.join(sourcePath, file.source);
const targetFile = path.join(targetPath, file.target);

if (!fs.existsSync(sourceFile)) {
throw new Error(`Source file not found: '${file.source}'`);
}

const targetDir = path.dirname(targetFile);
if (!fs.existsSync(targetDir)) {
throw new Error(`Target directory not found: '${targetDir}'`);
}

fs.copyFileSync(sourceFile, targetFile);
console.log(`✅ Copied ${file.source} to vechain-kit`);
});
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is the best approach , right now it's just copying the types to the static folder in vechain-kit right after compile. Maybe it'd make more sense to have a shared npm package with all the types we need, so it’s cleaner and avoid confusion. We could also use TypeChain’s externalArtifacts to get from external sources when needed.

@victorkl400 victorkl400 requested a review from Agilulfo1820 July 2, 2025 17:53
@victorkl400
Copy link
Copy Markdown
Contributor Author

Closing this for now since it’s not a priority. If needed, we can always reopen and continue from there.

@Agilulfo1820 Agilulfo1820 deleted the feat/news-sc branch February 3, 2026 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

💡 [REQUEST] - add "news" section in ecosystem content

1 participant