Skip to content

Commit 318cd7c

Browse files
committed
fix: use correct Soroban event publishing (tuples, no contractevent)
1 parent 93c0052 commit 318cd7c

1 file changed

Lines changed: 22 additions & 45 deletions

File tree

contract/src/lib.rs

Lines changed: 22 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![no_std]
22

3-
use soroban_sdk::{contract, contractevent, contractimpl, contracttype, Address, Env};
3+
use soroban_sdk::{contract, contractimpl, contracttype, symbol_short, Address, Env};
44

55
// ── Storage Keys ──────────────────────────────────────────────────────────────
66

@@ -13,29 +13,6 @@ pub enum DataKey {
1313
Initialized,
1414
}
1515

16-
// ── Events ────────────────────────────────────────────────────────────────────
17-
18-
#[contractevent]
19-
pub struct Initialized {
20-
pub admin: Address,
21-
pub treasury: Address,
22-
}
23-
24-
#[contractevent]
25-
pub struct PlatformFeeUpdated {
26-
pub new_fee_bps: u32,
27-
}
28-
29-
#[contractevent]
30-
pub struct TreasuryUpdated {
31-
pub new_treasury: Address,
32-
}
33-
34-
#[contractevent]
35-
pub struct DisputeWindowUpdated {
36-
pub window_ledgers: u32,
37-
}
38-
3916
// ── Contract ──────────────────────────────────────────────────────────────────
4017

4118
#[contract]
@@ -45,23 +22,23 @@ pub struct SkillSyncContract;
4522
impl SkillSyncContract {
4623
// ── Issue #748: initialize ────────────────────────────────────────────────
4724

48-
/// Sets up the initial contract state. Can only be called once.
25+
/// Sets up initial contract state. Can only be called once.
4926
pub fn initialize(env: Env, admin: Address, treasury: Address) {
5027
if env.storage().persistent().has(&DataKey::Initialized) {
5128
panic!("already initialized");
5229
}
53-
5430
admin.require_auth();
5531

5632
env.storage().persistent().set(&DataKey::Admin, &admin);
5733
env.storage().persistent().set(&DataKey::Treasury, &treasury);
5834
env.storage().persistent().set(&DataKey::PlatformFeeBps, &0u32);
59-
env.storage()
60-
.persistent()
61-
.set(&DataKey::DisputeWindow, &1000u32);
35+
env.storage().persistent().set(&DataKey::DisputeWindow, &1000u32);
6236
env.storage().persistent().set(&DataKey::Initialized, &true);
6337

64-
env.events().publish(("SkillSync",), Initialized { admin, treasury });
38+
env.events().publish(
39+
(symbol_short!("init"),),
40+
(admin, treasury),
41+
);
6542
}
6643

6744
// ── Issue #749: platform fee ──────────────────────────────────────────────
@@ -70,11 +47,11 @@ impl SkillSyncContract {
7047
pub fn set_platform_fee(env: Env, new_fee_bps: u32) {
7148
Self::require_admin(&env);
7249
assert!(new_fee_bps <= 1000, "fee exceeds 10%");
73-
env.storage()
74-
.persistent()
75-
.set(&DataKey::PlatformFeeBps, &new_fee_bps);
76-
env.events()
77-
.publish(("SkillSync",), PlatformFeeUpdated { new_fee_bps });
50+
env.storage().persistent().set(&DataKey::PlatformFeeBps, &new_fee_bps);
51+
env.events().publish(
52+
(symbol_short!("fee_upd"),),
53+
new_fee_bps,
54+
);
7855
}
7956

8057
/// Returns the current platform fee in basis points.
@@ -90,11 +67,11 @@ impl SkillSyncContract {
9067
/// Updates the treasury wallet address. Admin only.
9168
pub fn set_treasury(env: Env, new_treasury: Address) {
9269
Self::require_admin(&env);
93-
env.storage()
94-
.persistent()
95-
.set(&DataKey::Treasury, &new_treasury);
96-
env.events()
97-
.publish(("SkillSync",), TreasuryUpdated { new_treasury });
70+
env.storage().persistent().set(&DataKey::Treasury, &new_treasury);
71+
env.events().publish(
72+
(symbol_short!("treas"),),
73+
new_treasury,
74+
);
9875
}
9976

10077
/// Returns the current treasury wallet address.
@@ -110,11 +87,11 @@ impl SkillSyncContract {
11087
/// Sets the dispute resolution window in ledgers. Admin only.
11188
pub fn set_dispute_window(env: Env, window_ledgers: u32) {
11289
Self::require_admin(&env);
113-
env.storage()
114-
.persistent()
115-
.set(&DataKey::DisputeWindow, &window_ledgers);
116-
env.events()
117-
.publish(("SkillSync",), DisputeWindowUpdated { window_ledgers });
90+
env.storage().persistent().set(&DataKey::DisputeWindow, &window_ledgers);
91+
env.events().publish(
92+
(symbol_short!("disp_win"),),
93+
window_ledgers,
94+
);
11895
}
11996

12097
/// Returns the current dispute window in ledgers (default: 1000).

0 commit comments

Comments
 (0)