Skip to content

Back dividend claims with real token transfers and authorize valuation and distribution - #1859

Merged
yusuftomilola merged 11 commits into
DistinctCodes:mainfrom
devrabiuhussain:feature/dividend-payouts-and-authorization
Nov 24, 2026
Merged

yusuftomilola merged 11 commits into
DistinctCodes:mainfrom
devrabiuhussain:feature/dividend-payouts-and-authorization

Conversation

@devrabiuhussain

Copy link
Copy Markdown
Contributor

Summary

This change backs dividend claims with real token transfers, requires authorization for
distribution and valuation updates, and tightens the next/image remote-host policy.

#1785 — Dividend claims now pay tokens

dividends::claim_dividends previously cleared unclaimed_dividends and emitted an event
without moving any funds. A per-asset payment token is now stored under a new
TokenDataKey::DividendToken(u64) variant, configured by an admin/tokenizer-only
set_dividend_token entrypoint. Claims transfer the configured token from the contract to
the holder before zeroing the ledger; a failed transfer reverts the invocation, leaving
the holder's accrued dividends intact. The Stellar Asset Contract testutils are used to
prove the holder's balance increases and that a failed payout leaves the ledger unchanged.

#1784 — Distribution is authorized and funded

distribute_dividends now takes a caller that must authenticate and be the asset's
tokenizer or the contract admin (via a shared require_asset_admin_or_tokenizer helper),
returning Error::Unauthorized otherwise. The full total_amount of the configured payment
token is pulled from that caller into the contract in the same invocation before any holder
is credited, so dividend liabilities are always backed. With no token configured the call
fails with the typed InvalidInput error. Tests cover funded distribution (contract balance
equals the distributed amount), missing-token rejection, unauthenticated rejection and an
authenticated non-privileged caller rejection.

#1783 — Valuation updates are authorized

update_valuation now takes a caller that must authenticate and be the asset's tokenizer or
the contract admin; anonymous and non-privileged callers get Error::Unauthorized. Oracle
auth was deliberately not added because assetsup has no oracle registry — this decision is
documented in contracts/AUTHORIZATION.md, which also replaces the "no auth" rows for the
two affected entrypoints and records the new set_dividend_token signer. All affected Rust
test call sites were updated.

#1779 — next/image remote patterns are an allowlist

frontend/next.config.ts no longer uses hostname: "**". Remote hosts are now built at
config load from a comma-separated NEXT_PUBLIC_IMAGE_HOSTS environment variable, the
protocol is fixed to https, and the default is an empty allowlist — no remote hosts are
permitted unless explicitly configured.

Tests were not run locally per the task instructions.

Closes #1785
Closes #1784
Closes #1783
Closes #1779

Closes DistinctCodes#1785: claim_dividends now transfers the configured payment token from the contract to the holder before zeroing the ledger. A failed transfer reverts the invocation, leaving unclaimed dividends intact.
Closes DistinctCodes#1784: distribute_dividends now requires tokenizer/admin authentication, pulls the configured payment token from the caller into the contract before crediting holders, and fails with InvalidInput when no dividend token is configured. Adds set_dividend_token and a get_dividend_token read.
Closes DistinctCodes#1783: update_valuation now takes a caller that must authenticate and be either the asset's tokenizer or the contract admin; anonymous and non-privileged callers fail with Unauthorized.
Closes DistinctCodes#1785, Closes DistinctCodes#1784, Closes DistinctCodes#1783: adds client-level tests with a Stellar Asset Contract covering real transfers on claim, failed-transfer ledger preservation, caller-funded distribution, no-token and unauthorized failures, and tokenizer/admin-only valuation updates.
Closes DistinctCodes#1779: replace the hostname '**' wildcard with a comma-separated NEXT_PUBLIC_IMAGE_HOSTS allowlist read at build time. Protocol is fixed to https and the default allows no remote hosts.
@vercel

vercel Bot commented Nov 23, 2026

Copy link
Copy Markdown

@devrabiuhussain is attempting to deploy a commit to the naijabuz's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Nov 23, 2026

Copy link
Copy Markdown

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

@yusuftomilola
yusuftomilola merged commit 7b85b98 into DistinctCodes:main Nov 24, 2026
1 of 14 checks passed
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