Skip to content

fix+feat: credit auth fix, participation fee, state dump/restore, leaderboard embed - #1491

Merged
joelpeace48-cell merged 5 commits into
FinesseStudioLab:mainfrom
AbelOsaretin:fix/issues-1370-1371-1372-1419
Oct 20, 2026
Merged

joelpeace48-cell merged 5 commits into
FinesseStudioLab:mainfrom
AbelOsaretin:fix/issues-1370-1371-1372-1419

Conversation

@AbelOsaretin

Copy link
Copy Markdown

Closes #1370 , Closes #1371 , Closes #1372 , Closes #1419

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring (no functional or behavioral changes)
  • Performance improvement
  • Documentation update
  • Build / CI configuration change
  • Dependency update
  • Other:

Summary

Four assigned issues in one PR. Critical first: credit()/batch_credit()/credit_vested() accepted any self-authenticated caller, so a roleless account could mint points and redeem them against the SAC reserve — those mint paths now require admin/co-admin (#1419). Campaigns can charge a configurable token entry fee forwarded to the reward pool (#1371). Campaign instance state can be exported/imported as JSON for offline inspection and local testnet seeding (#1372). Third-party blogs can paste a single HTML/JS <script> tag that mounts a live campaign leaderboard (#1370). Also repairs a broken-merge compile failure in the rewards contract that blocked all of the above.

Motivation / Context

Closes #1419 (unauthorized point minting → reserve drain), #1371 (campaign entry fees in custom tokens), #1372 (state dump/restore for local migration), #1370 (leaderboard embed for blogs).

Closes #1370, Closes #1371, Closes #1372, Closes #1419

Changes

Issue Area Change
#1419 contracts/rewards require_credit_authority on credit/batch_credit/credit_vested; default MAX_CREDIT_PER_CALL = 1,000,000 (was 0 = unlimited)
#1371 contracts/campaign set_participation_fee / participation_fee; fee transfer to reward pool on new registration
#1372 contracts/campaign + cli export_state / import_state; trivela state dump|restore JSON helper
#1370 frontend embed.js data-widget/data-limit; buildScriptSnippet(); HTML/JS format in EmbedSnippetGenerator
compile contracts/rewards Dedup Error enum, add missing variants, u8→u32, SHA-256 airdrop Merkle verifier, fix stale tests

Testing

  • cargo test -p trivela-rewards-contract --lib → 153 passed, 0 failed
  • cargo test -p trivela-campaign-contract --lib → 96 passed, 0 failed
  • cd cli && npm test → 6 passed (stateDump round-trip)
  • cd frontend && npx vitest run src/lib/embedSnippet.test.js src/components/TrivelaCampaignWidget.test.jsx → 13 passed
  • New regression tests: unauthorized credit/batch_credit/credit_vested rejected; default credit cap enforced; co-admin can credit; fee charged once per new registration; export/import state round-trip; script snippet contents

Tradeoffs

  • Generic mint paths allow admin + co-admin only; campaign-scoped operators use the existing credit_as_operator (delegation + budget). This closes the hole without enumerating operator delegations on-chain.
  • import_state restores instance-storage configuration only — participant records are out of scope (cannot enumerate persistent keys from a contract).
  • Re-registration remains blocked by the existing Contracts: Nullifier to prevent re-registration / double-claim after merkle root rotation #740 participation barrier; related tests were aligned with that behavior rather than changing the barrier.

Out of scope

  • Participant/persistent-entry full-state migration
  • Frontend UI for configuring the participation fee (contract API only)
  • Backend changes for the embed widget (existing /embed/v1/leaderboard/:id route is reused)

Deduplicate Error enum variants left by a conflicting merge, add missing
staking/timelock error codes, replace unsupported u8 contract types with
u32, route boosted-amount math through Self::, and give claim_airdrop a
production SHA-256 Merkle verifier so it no longer depends on test-only
poseidon modules. Align outdated unit tests with the current API so the
suite compiles and passes (148/148).
…sseStudioLab#1419)

credit(), batch_credit(), and credit_vested() previously accepted any
self-authenticated caller, letting a roleless account mint points and
redeem them against the SAC reserve. All three generic mint paths now
require admin or co-admin via require_credit_authority; campaign-scoped
operators continue to use credit_as_operator. Also default
MAX_CREDIT_PER_CALL to 1_000_000 instead of 0 (unlimited).

Closes FinesseStudioLab#1419
…inesseStudioLab#1371)

Campaigns can now charge a small entry fee in any SEP-41/SAC token that
is forwarded to the reward pool on each new registration. Admin configures
the fee via set_participation_fee (amount=0 clears it); registration is
unchanged when no fee is set. Also aligns re-registration tests with the
existing FinesseStudioLab#740 participation barrier.

Closes FinesseStudioLab#1371
…inesseStudioLab#1372)

Campaign contract gains export_state/import_state for its instance-storage
configuration (admin, window, cap, merkle root, privacy mode, fee, schema).
A new 'trivela state dump|restore' CLI command serialises that snapshot to
JSON for offline inspection and reads it back for local testnet seeding.

Closes FinesseStudioLab#1372
…inesseStudioLab#1370)

embed.js now accepts data-widget="leaderboard|card|progress" and data-limit
so third-party blogs can paste a single <script> tag that mounts a live
campaign leaderboard via /embed/v1/leaderboard/:id. Adds
buildScriptSnippet() to the snippet library and surfaces an HTML/JS format
option (defaulting to leaderboard) in EmbedSnippetGenerator.

Closes FinesseStudioLab#1370
@drips-wave

drips-wave Bot commented Oct 20, 2026

Copy link
Copy Markdown

@AbelOsaretin 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

@joelpeace48-cell
joelpeace48-cell merged commit 4380a74 into FinesseStudioLab:main Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants