Skip to content

Commit f4ac1ab

Browse files
authored
Merge branch 'main' into feat/834-key-deprecation-buyback
2 parents cc6660d + 3428d29 commit f4ac1ab

243 files changed

Lines changed: 34932 additions & 2007 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

creator-keys/src/events.rs

Lines changed: 107 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ use crate::{
2525
CreatorKeysContractArgs, CreatorKeysContractClient,
2626
};
2727
use soroban_sdk::{
28-
contracterror, contractimpl, contracttype, symbol_short, Address, Env, String, Symbol, Vec,
28+
contracterror, contractimpl, contracttype, symbol_short, Address, Bytes, Env, String, Symbol,
29+
Vec,
2930
};
3031

3132
/// Event name for protocol trade fee collected on a buy or sell.
@@ -196,6 +197,8 @@ pub struct KeysSoldEvent {
196197
pub quantity: u32,
197198
/// Net proceeds received by the seller after fees.
198199
pub proceeds: i128,
200+
/// Total supply of keys for this creator after the sale.
201+
pub new_supply: u32,
199202
/// Ledger sequence number at the time of the sale.
200203
pub ledger: u32,
201204
}
@@ -251,6 +254,9 @@ pub const CREATOR_FEE_RECIPIENT_UPDATED_EVENT_NAME: Symbol = symbol_short!("c_fe
251254
/// Event name for co-creator fee accrual.
252255
pub const CO_CREATOR_FEE_EARNED_EVENT_NAME: Symbol = symbol_short!("co_fee");
253256

257+
/// Event name for a creator (re)designating their co-creator split (issue #782).
258+
pub const CO_CREATOR_SET_EVENT_NAME: Symbol = symbol_short!("co_set");
259+
254260
/// Stable field order for dividend distributed event payloads.
255261
pub const DIVIDEND_DISTRIBUTED_DATA_FIELDS: [&str; 4] =
256262
["creator", "total_amount", "snapshot_supply", "ledger"];
@@ -372,6 +378,78 @@ pub fn co_creator_fee_earned_topics(
372378
)
373379
}
374380

381+
/// Emitted by `set_co_creator` whenever a creator designates or updates their
382+
/// co-creator split (issue #782).
383+
#[derive(Clone, Debug, Eq, PartialEq)]
384+
#[contracttype]
385+
pub struct CoCreatorSetEvent {
386+
pub creator_id: Address,
387+
pub co_creator: Address,
388+
pub split_bps: u32,
389+
}
390+
391+
pub fn co_creator_set_topics(
392+
creator_id: &Address,
393+
co_creator: &Address,
394+
) -> (Symbol, Address, Address) {
395+
(
396+
CO_CREATOR_SET_EVENT_NAME,
397+
creator_id.clone(),
398+
co_creator.clone(),
399+
)
400+
}
401+
402+
/// Event name for a completed holder snapshot (issue #778).
403+
pub const SNAPSHOT_TAKEN_EVENT_NAME: Symbol = symbol_short!("snap_take");
404+
405+
#[derive(Clone, Debug, Eq, PartialEq)]
406+
#[contracttype]
407+
pub struct SnapshotTakenEvent {
408+
pub creator_id: Address,
409+
pub snapshot_id: u32,
410+
pub snapshot_ledger: u32,
411+
pub total_holders: u32,
412+
}
413+
414+
pub fn snapshot_taken_topics(creator_id: &Address, snapshot_id: u32) -> (Symbol, Address, u32) {
415+
(SNAPSHOT_TAKEN_EVENT_NAME, creator_id.clone(), snapshot_id)
416+
}
417+
418+
/// Event name for creator key identity initialization (issue #779).
419+
pub const KEY_INITIALISED_EVENT_NAME: Symbol = symbol_short!("key_init");
420+
421+
#[derive(Clone, Debug, Eq, PartialEq)]
422+
#[contracttype]
423+
pub struct KeyInitialisedEvent {
424+
pub creator_id: Address,
425+
pub name: Bytes,
426+
pub bio: Bytes,
427+
pub avatar_uri: Bytes,
428+
}
429+
430+
pub fn key_initialised_topics(creator_id: &Address) -> (Symbol, Address) {
431+
(KEY_INITIALISED_EVENT_NAME, creator_id.clone())
432+
}
433+
434+
/// Event name for a blocked same-ledger buy-then-sell attempt (issue #781).
435+
pub const FLASH_LOAN_BLOCKED_EVENT_NAME: Symbol = symbol_short!("fl_block");
436+
437+
#[derive(Clone, Debug, Eq, PartialEq)]
438+
#[contracttype]
439+
pub struct FlashLoanBlockedEvent {
440+
pub wallet: Address,
441+
pub key_id: Address,
442+
pub ledger: u32,
443+
}
444+
445+
pub fn flash_loan_blocked_topics(wallet: &Address, key_id: &Address) -> (Symbol, Address, Address) {
446+
(
447+
FLASH_LOAN_BLOCKED_EVENT_NAME,
448+
wallet.clone(),
449+
key_id.clone(),
450+
)
451+
}
452+
375453
/// Stable referral fee earned event payload for downstream indexers.
376454
///
377455
/// Event shape:
@@ -754,42 +832,6 @@ pub fn keys_burned_topics(key_id: &Address) -> (Symbol, Address) {
754832
(KEYS_BURNED_EVENT_NAME, key_id.clone())
755833
}
756834

757-
#[derive(Clone, Debug, Eq, PartialEq)]
758-
#[contracttype]
759-
pub struct FeeCollectedEvent {
760-
/// Treasury address that received the fee.
761-
pub treasury: Address,
762-
/// Fee amount deducted from the trade.
763-
pub amount: i128,
764-
/// Ledger sequence number at the time of the trade.
765-
pub ledger: u32,
766-
}
767-
768-
/// Shared fee collected event topics tuple.
769-
pub fn fee_collected_topics(treasury: &Address) -> (Symbol, Address) {
770-
(FEE_COLLECTED_EVENT_NAME, treasury.clone())
771-
}
772-
773-
#[derive(Clone, Debug, Eq, PartialEq)]
774-
#[contracttype]
775-
pub struct LockupBlockedEvent {
776-
/// Creator whose keys the seller attempted to sell.
777-
pub creator_id: Address,
778-
/// Seller whose sale was rejected.
779-
pub seller: Address,
780-
/// Ledger timestamp of the seller's most recent buy.
781-
pub last_buy_timestamp: u64,
782-
/// Timestamp at which the lockup expires (exclusive).
783-
pub unlock_at: u64,
784-
/// Ledger timestamp at rejection.
785-
pub current_timestamp: u64,
786-
}
787-
788-
/// Shared lockup blocked event topics tuple.
789-
pub fn lockup_blocked_topics(creator: &Address, seller: &Address) -> (Symbol, Address, Address) {
790-
(LOCKUP_BLOCKED_EVENT_NAME, creator.clone(), seller.clone())
791-
}
792-
793835
#[derive(Clone, Debug, Eq, PartialEq)]
794836
#[contracttype]
795837
pub struct QuorumUpdatedEvent {
@@ -1196,12 +1238,6 @@ pub fn royalty_updated_topics(creator: &Address) -> (Symbol, Address) {
11961238
(ROYALTY_UPDATED_EVENT_NAME, creator.clone())
11971239
}
11981240

1199-
/// Event name for the protocol trade fee collected on a buy or sell.
1200-
pub const FEE_COLLECTED_EVENT_NAME: Symbol = symbol_short!("fee_coll");
1201-
1202-
/// Event name for a sell rejected by the anti-flash-trade lockup window.
1203-
pub const LOCKUP_BLOCKED_EVENT_NAME: Symbol = symbol_short!("lck_blk");
1204-
12051241
/// Stable fee collection event payload for downstream indexers.
12061242
///
12071243
/// Event shape:
@@ -1287,7 +1323,11 @@ pub struct StakeEvent {
12871323
}
12881324

12891325
/// Shared stake event topics tuple.
1290-
pub fn stake_topics(creator: &Address, holder: &Address, stake_id: u32) -> (Symbol, Address, Address, u32) {
1326+
pub fn stake_topics(
1327+
creator: &Address,
1328+
holder: &Address,
1329+
stake_id: u32,
1330+
) -> (Symbol, Address, Address, u32) {
12911331
(STAKE_EVENT_NAME, creator.clone(), holder.clone(), stake_id)
12921332
}
12931333

@@ -1317,7 +1357,12 @@ pub fn stake_extended_topics(
13171357
holder: &Address,
13181358
stake_id: u32,
13191359
) -> (Symbol, Address, Address, u32) {
1320-
(STAKE_EXTENDED_EVENT_NAME, creator.clone(), holder.clone(), stake_id)
1360+
(
1361+
STAKE_EXTENDED_EVENT_NAME,
1362+
creator.clone(),
1363+
holder.clone(),
1364+
stake_id,
1365+
)
13211366
}
13221367

13231368
/// Stable early-unstake event payload for downstream indexers.
@@ -1350,7 +1395,12 @@ pub fn early_unstake_topics(
13501395
holder: &Address,
13511396
stake_id: u32,
13521397
) -> (Symbol, Address, Address, u32) {
1353-
(EARLY_UNSTAKE_EVENT_NAME, creator.clone(), holder.clone(), stake_id)
1398+
(
1399+
EARLY_UNSTAKE_EVENT_NAME,
1400+
creator.clone(),
1401+
holder.clone(),
1402+
stake_id,
1403+
)
13541404
}
13551405

13561406
/// Stable stake-reward-claim event payload for downstream indexers.
@@ -1383,10 +1433,14 @@ pub fn stake_reward_claimed_topics(
13831433
holder: &Address,
13841434
stake_id: u32,
13851435
) -> (Symbol, Address, Address, u32) {
1386-
(STAKE_REWARD_CLAIMED_EVENT_NAME, creator.clone(), holder.clone(), stake_id)
1436+
(
1437+
STAKE_REWARD_CLAIMED_EVENT_NAME,
1438+
creator.clone(),
1439+
holder.clone(),
1440+
stake_id,
1441+
)
13871442
}
13881443

1389-
13901444
// ============================================================================
13911445
// Launch Penalty (#798)
13921446
// ============================================================================
@@ -1415,7 +1469,11 @@ pub fn launch_penalty_applied_topics(
14151469
creator: &Address,
14161470
seller: &Address,
14171471
) -> (Symbol, Address, Address) {
1418-
(LAUNCH_PENALTY_APPLIED_EVENT_NAME, creator.clone(), seller.clone())
1472+
(
1473+
LAUNCH_PENALTY_APPLIED_EVENT_NAME,
1474+
creator.clone(),
1475+
seller.clone(),
1476+
)
14191477
}
14201478

14211479
/// Event name for set_launch_penalty.

0 commit comments

Comments
 (0)