Skip to content

feat: emit contract events for create_prompt, buy_prompt, and price updates (#406) - #527

Open
opratem wants to merge 1 commit into
PromptMintLabs:mainfrom
opratem:issue-406-emit-contract-events
Open

feat: emit contract events for create_prompt, buy_prompt, and price updates (#406)#527
opratem wants to merge 1 commit into
PromptMintLabs:mainfrom
opratem:issue-406-emit-contract-events

Conversation

@opratem

@opratem opratem commented Aug 28, 2026

Copy link
Copy Markdown

Description

Implements structured Soroban event emissions and off-chain wiring for core marketplace actions so indexers, webhooks, and the frontend can react in real time instead of relying solely on polling get_all_prompts. The change adds explicit contract event coverage for prompt creation, purchases, and price updates, and connects those events to the existing webhook dispatcher and email notification services.

Related Issue

Closes #406

Type of Change

New feature
Documentation update

Changes Made

Added contract-level event assertions in `contracts/prompt-hash/src/test.rs` to verify that `create_prompt` emits `PromptCreated` and `buy_prompt` emits `PromptPurchased`.
Extended `server/src/controllers/webhookControllers.ts` allowed event list to include `PromptCreated` and `PromptPriceUpdated` so creators can subscribe to newly created listings and price changes.
Wired `server/src/services/indexer.ts` to dispatch webhooks and send purchase notifications for `PromptCreated`, `PromptPurchased`, and `PromptPriceUpdated` events decoded from Soroban RPC streams.
Preserved existing indexer database behavior and added fail-open error logging so webhook/email failures never block the indexing loop.

Testing

Added Rust unit tests covering:
    `PromptCreated` emission on `create_prompt`.
    `PromptPurchased` emission on `buy_prompt`.
Verified that existing event coverage for price updates and sale-status changes remains intact.
Confirmed TypeScript source compiles without new type errors in the modified server files.

Checklist

Code follows Soroban SDK and server-side TypeScript best practices
Self-reviewed my code
Added comprehensive unit tests
Updated documentation where applicable
Proper error handling and non-blocking side effects in the indexer
No breaking changes to existing contract APIs or indexer database flow

Screenshots

N/A � Smart contract and server service changes only.

Additional Notes

The event emissions already existed on-chain for these actions; this work closes the gap by ensuring they are explicitly tested and that the off-chain indexer reacts to them. The frontend useContractSync hook already polls all contract events, so no client-side changes are required for real-time invalidation to begin using the new events.

@drips-wave

drips-wave Bot commented Aug 28, 2026

Copy link
Copy Markdown

@opratem Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Emit contract events for create_prompt, buy_prompt, and price updates

1 participant