Skip to content

feat: add approved spender - #27

Merged
Kaylahray merged 3 commits into
learnault:mainfrom
Birdmannn:feat-#23
Mar 7, 2026
Merged

feat: add approved spender#27
Kaylahray merged 3 commits into
learnault:mainfrom
Birdmannn:feat-#23

Conversation

@Birdmannn

Copy link
Copy Markdown
Contributor

Reward Pool Contract

A Soroban smart contract for managing a reward pool with admin-controlled spender whitelisting.

Features

Initialize

Sets up the contract with an admin and reward token.

initialize(admin: Address, token: Address)
  • Stores admin address in instance storage
  • Stores token address in instance storage
  • Emits PoolInitialized event
  • Panics if already initialized or auth fails

Add Approved Spender

Whitelists a contract address to spend from the reward pool.

add_approved_spender(admin: Address, spender: Address)
  • Validates admin authorization
  • Stores spender in persistent storage
  • Emits SpenderAdded event
  • Panics if not initialized, unauthorized, or auth fails

Storage

  • Instance Storage: Admin, Token
  • Persistent Storage: Spender(Address)bool

Events

  • PoolInitialized(admin, token) - Emitted on initialization
  • SpenderAdded(spender) - Emitted when spender is whitelisted

Testing

Run tests:

cargo test

All tests include:

  • Initialization success/failure scenarios
  • Spender whitelisting with proper authorization
  • Unauthorized access prevention
  • Event emission verification

This PR closes #23

@Birdmannn

Copy link
Copy Markdown
Contributor Author

the cargo.toml was adjusted to tell rust-analyzer not to analyse the target folder. minor change.

@Kaylahray Kaylahray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing. Thanks

@Kaylahray
Kaylahray merged commit 31948e8 into learnault:main Mar 7, 2026
1 check 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

Development

Successfully merging this pull request may close these issues.

[RewardPool] Add Approved Spender (Whitelist)

2 participants