admin.gno
0.78 Kb ยท 39 lines
1package gnopensea2
2
3import (
4 "chain/banker"
5 "chain/runtime"
6)
7
8// ============= ADMIN =============
9
10func SetMarketplaceFee(newFee int64) {
11 caller := runtime.PreviousRealm().Address()
12 if caller != admin {
13 panic("Only admin can modify fees")
14 }
15
16 if newFee < 0 || newFee > 1000 { // Max 10%
17 panic("Fees must be between 0% and 10%")
18 }
19
20 marketplaceFee = newFee
21}
22
23func WithdrawFees() {
24 caller := runtime.PreviousRealm().Address()
25 if caller != admin {
26 panic("Only admin can withdraw fees")
27 }
28
29 // Use NewBanker instead of GetBanker
30 bnkr := banker.NewBanker(banker.BankerTypeRealmSend)
31 realmAddr := runtime.CurrentRealm().Address()
32
33 // Get balance of the realm
34 balance := bnkr.GetCoins(realmAddr)
35
36 if balance.AmountOf("ugnot") > 0 {
37 bnkr.SendCoins(realmAddr, admin, balance)
38 }
39}