Feat/implement missing features - #365
Merged
DeFiVC merged 7 commits intoAug 30, 2026
Merged
Conversation
|
@devwallaydev 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! 🚀 |
3 tasks
DeFiVC
added a commit
that referenced
this pull request
Aug 30, 2026
…ddress minting, claim history, and pause (#373) * fix(learn-token): remove duplicate is_paused/set_paused definitions storage.rs defined is_paused/set_paused twice with identical bodies -- once under the original Emergency Pause section (#189) and again under the pause-events section (#238), added by two PRs merged back to back without either noticing the other had already added the same pair. Rust rejects the duplicate definitions (E0428), so main currently fails to build. Keep the original definitions and drop the redundant pair; both events and pause/unpause logic already call through the one storage.rs API surface, so nothing else changes. * fix(learn-token): repair test suite broken by role-gated mint/pause PR #365 added Minter/Pauser role checks to mint(), pause(), and unpause(), giving each an extra caller: Address parameter, and updated the call sites that existed at the time. It landed back to back with two other PRs (#363, #366) that added their own tests calling the pre-refactor 2-and-0-argument signatures, or referencing an admin binding some of those same tests never captured (destructured as _ or _admin because they didn't need it before). None of the three PRs conflicted at the git-diff level, so all three merged cleanly and the test suite has been failing to compile since. Capture admin from setup() wherever a fixed test now needs it as the mint/pause/unpause caller, and fix one unrelated pre-existing get_proposal(prop_id) call that needed a borrow. No behavioral changes -- cargo test -p learn-token now compiles and all 63 tests pass. * feat(learn-token): add persistent storage entry-count tracking Soroban prices persistent storage by entry count and size but gives a contract no host API to enumerate or count its own keys, so there is currently no way to answer "how much storage is this contract using" short of an off-chain state export. Add get_storage_size(), backed by a StorageEntryCount counter that storage.rs increments/decrements around every write to a per-entity key -- reward claims, claim history, roles, whitelist entries, snapshots, vesting schedules and claimed amounts, proposals, votes, allowance-spender registries, permit nonces, and per-address minting totals -- guarded by a has() check so overwriting an existing entry never double-counts it. Deliberately excluded: singleton config (admin, name/symbol/decimal, total/max supply, metadata, transfer restriction, wasm hash, upgrade version, paused flag, proposal counter) since those don't grow with usage, and Balance/Allowance since balances are written on every transfer/mint/burn (the issue's "no performance impact" criterion argues against adding a has() check to that path) and allowances live in temporary rather than persistent storage. Closes #254 * test(learn-token): extend coverage for per-address minting, claim history, and pause total_minted_to() (#251), get_claim_history() (#252), and pause/unpause (#253) were already implemented and tested on main (merged in #363 for near-duplicate issues #236/#237/#238, before this repo's issue numbers #251-253 were filed against the same scope). Add the edge cases their existing coverage didn't reach: - total_minted_to: a zero-amount mint is allowed (only negative amounts are rejected) and should leave the queryable total at 0. - get_claim_history: existing tests only covered multiple quizzes within one course; verify records also stay correctly distinguished by course_id when a learner claims across different courses. - pause: existing coverage only exercised transfer and mint; burn, claim_reward, and claim_vested are also gated by require_not_paused() and hadn't been exercised while paused. Closes #251, Closes #252, Closes #253 --------- Co-authored-by: DeFiVC <136683573+DeFiVC@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR implements several missing features across the ChainLearn smart contracts to improve security, authorization, and the reward claiming experience, while also introducing end-to-end integration tests.
Changes Included
tests/integration/full_flow.rs) that cover a full learner journey, including course creation, enrollment, module completion, batch claiming rewards fromlearn-token, and minting viacredential-nft.batch_claim_rewardin thelearn-tokencontract. This enables a user to claim rewards for multiple completed quizzes in a single transaction. It processes successfully claimed quizzes while gracefully skipping invalid or already-claimed ones.learn-token,credential-nft,progress-tracker). All state-changing methods are guarded by arequire_not_pausedmodifier.learn-tokento support fine-grained roles (Admin,Minter, andPauser). Only assignedMinters can mint new tokens, and onlyPausers can trigger the emergency pause.Related Issues
Closes #187
Closes #188
Closes #189
Closes #190
Type of Change
Verification
cargo test --allexecutes cleanly with no warnings or errors.