feat(nft): royalty splitting — startup validation, platform bps guard, combined protocol cap#519
Open
petahade wants to merge 1 commit into
Open
feat(nft): royalty splitting — startup validation, platform bps guard, combined protocol cap#519petahade wants to merge 1 commit into
petahade wants to merge 1 commit into
Conversation
Extend RoyaltyConfigurationService with platform royalty bps validation, combined creator+platform total guard against the 10 000 bps protocol cap, and a validateRoyaltyConfiguration() method used at bootstrap to reject misconfigured environments (missing/invalid platform wallet, negative or non-integer bps values, totals that exceed the protocol limit). buildRoyaltyMap() now enforces these constraints on every mint, so both the creator (1 000 bps default) and platform (100 bps default) royalty entries are always encoded, submitted, and persisted correctly on-chain.
|
@petahade 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! 🚀 |
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.
Closes #360
Summary
This PR completes the NFT royalty splitting implementation by adding the missing validation layer that ensures both creator and platform royalty entries are always valid before they are encoded into a mint transaction, and that a misconfigured environment fails fast at startup rather than silently at mint time.
The on-chain encoding of both royalty entries (creator + platform) in
buildRoyaltyMap()and themint()Soroban call were already in place. What was missing:PLATFORM_WALLET_ADDRESS/PLATFORM_ROYALTY_BPS/CREATOR_ROYALTY_BPSare validplatformRoyaltyBpswas read from env and passed directly tonativeToScValwith no validationChanges
src/nft/royalty-configuration.service.tsROYALTY_PROTOCOL_MAX_BPS = 10 000DEFAULT_ROYALTY_BPS_MAX)validatePlatformRoyaltyBps(bps)validateCombinedRoyaltyBps(creatorBps, platformBps)creator + platform > 10 000 bpsvalidateRoyaltyConfiguration()Error(notBadRequestException) so bootstrap can catch it cleanly.buildRoyaltyMap()updatedvalidatePlatformRoyaltyBpsandvalidateCombinedRoyaltyBpson every mint, so runtime bad configs are caught at the point of use too.src/main.tsAdds a royalty config validation block immediately after the existing BullMQ startup checks:
The process exits with code 1 (same as BullMQ config failures) if:
PLATFORM_WALLET_ADDRESSis absent or not a valid Stellar Ed25519 public keyPLATFORM_ROYALTY_BPSorCREATOR_ROYALTY_BPSis missing, non-integer, or negativeRoyalty flow (unchanged, now guarded)
Default configuration verified:
CREATOR_ROYALTY_BPS=1000(10%) +PLATFORM_ROYALTY_BPS=100(1%) = 1 100 bps total, well within the 10 000 bps protocol cap.Validation error examples
PLATFORM_WALLET_ADDRESSPLATFORM_WALLET_ADDRESS must be configuredPLATFORM_WALLET_ADDRESS "..." is not a valid Stellar Ed25519 public keyPLATFORM_ROYALTY_BPS=-1Invalid platformRoyaltyBps: -1. Must be a non-negative integer.CREATOR_ROYALTY_BPS=9950+PLATFORM_ROYALTY_BPS=100Combined royalty (10050 bps = 9950 creator + 100 platform) exceeds protocol maximum of 10000 bpsBackward compatibility
buildRoyaltyMap()signature is unchangedvalidateRoyaltyBps()(creator-only, 0–1500 cap) is unchangedgetCreatorRoyaltyBps()/getPlatformRoyaltyBps()/getPlatformWallet()are unchanged