Skip to content

Commit f551395

Browse files
authored
Merge pull request #114 from Hallab7/feat/readonly-fee-recipient
feat: add read-only protocol fee recipient method
2 parents db41a7c + 0e8ee07 commit f551395

10 files changed

+1140
-0
lines changed

creator-keys/src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ pub mod constants {
9595
pub const KEY_PRICE: DataKey = DataKey::KeyPrice;
9696
pub const TREASURY_ADDRESS: DataKey = DataKey::TreasuryAddress;
9797
pub const ADMIN_ADDRESS: DataKey = DataKey::AdminAddress;
98+
pub const PROTOCOL_FEE_RECIPIENT: DataKey = DataKey::ProtocolFeeRecipient;
9899

99100
pub fn creator(creator: &Address) -> DataKey {
100101
creator_key(creator)
@@ -213,6 +214,7 @@ pub enum DataKey {
213214
KeyBalance(Address, Address),
214215
TreasuryAddress,
215216
AdminAddress,
217+
ProtocolFeeRecipient,
216218
}
217219

218220
#[derive(Clone, Debug, PartialEq)]
@@ -690,6 +692,17 @@ impl CreatorKeysContract {
690692
.get(&constants::storage::ADMIN_ADDRESS)
691693
}
692694

695+
/// Read-only view: returns the current protocol fee recipient address.
696+
///
697+
/// Returns `None` if no protocol fee recipient address has been configured.
698+
/// Use this method for indexers and read-only callers that need the current
699+
/// protocol fee recipient address.
700+
pub fn get_protocol_fee_recipient(env: Env) -> Option<Address> {
701+
env.storage()
702+
.persistent()
703+
.get(&constants::storage::PROTOCOL_FEE_RECIPIENT)
704+
}
705+
693706
/// Read-only view: returns whether protocol configuration has been initialized.
694707
///
695708
/// Returns `true` once a protocol fee configuration has been stored and `false`
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
{
2+
"generators": {
3+
"address": 3,
4+
"nonce": 0
5+
},
6+
"auth": [
7+
[],
8+
[
9+
[
10+
"CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4",
11+
{
12+
"function": {
13+
"contract_fn": {
14+
"contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM",
15+
"function_name": "set_treasury_address",
16+
"args": [
17+
{
18+
"address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4"
19+
},
20+
{
21+
"address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M"
22+
}
23+
]
24+
}
25+
},
26+
"sub_invocations": []
27+
}
28+
]
29+
],
30+
[]
31+
],
32+
"ledger": {
33+
"protocol_version": 22,
34+
"sequence_number": 0,
35+
"timestamp": 0,
36+
"network_id": "0000000000000000000000000000000000000000000000000000000000000000",
37+
"base_reserve": 0,
38+
"min_persistent_entry_ttl": 4096,
39+
"min_temp_entry_ttl": 16,
40+
"max_entry_ttl": 6312000,
41+
"ledger_entries": [
42+
[
43+
{
44+
"contract_data": {
45+
"contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM",
46+
"key": {
47+
"vec": [
48+
{
49+
"symbol": "TreasuryAddress"
50+
}
51+
]
52+
},
53+
"durability": "persistent"
54+
}
55+
},
56+
[
57+
{
58+
"last_modified_ledger_seq": 0,
59+
"data": {
60+
"contract_data": {
61+
"ext": "v0",
62+
"contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM",
63+
"key": {
64+
"vec": [
65+
{
66+
"symbol": "TreasuryAddress"
67+
}
68+
]
69+
},
70+
"durability": "persistent",
71+
"val": {
72+
"address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M"
73+
}
74+
}
75+
},
76+
"ext": "v0"
77+
},
78+
4095
79+
]
80+
],
81+
[
82+
{
83+
"contract_data": {
84+
"contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM",
85+
"key": "ledger_key_contract_instance",
86+
"durability": "persistent"
87+
}
88+
},
89+
[
90+
{
91+
"last_modified_ledger_seq": 0,
92+
"data": {
93+
"contract_data": {
94+
"ext": "v0",
95+
"contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM",
96+
"key": "ledger_key_contract_instance",
97+
"durability": "persistent",
98+
"val": {
99+
"contract_instance": {
100+
"executable": {
101+
"wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
102+
},
103+
"storage": null
104+
}
105+
}
106+
}
107+
},
108+
"ext": "v0"
109+
},
110+
4095
111+
]
112+
],
113+
[
114+
{
115+
"contract_data": {
116+
"contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4",
117+
"key": {
118+
"ledger_key_nonce": {
119+
"nonce": 801925984706572462
120+
}
121+
},
122+
"durability": "temporary"
123+
}
124+
},
125+
[
126+
{
127+
"last_modified_ledger_seq": 0,
128+
"data": {
129+
"contract_data": {
130+
"ext": "v0",
131+
"contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4",
132+
"key": {
133+
"ledger_key_nonce": {
134+
"nonce": 801925984706572462
135+
}
136+
},
137+
"durability": "temporary",
138+
"val": "void"
139+
}
140+
},
141+
"ext": "v0"
142+
},
143+
6311999
144+
]
145+
],
146+
[
147+
{
148+
"contract_code": {
149+
"hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
150+
}
151+
},
152+
[
153+
{
154+
"last_modified_ledger_seq": 0,
155+
"data": {
156+
"contract_code": {
157+
"ext": "v0",
158+
"hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
159+
"code": ""
160+
}
161+
},
162+
"ext": "v0"
163+
},
164+
4095
165+
]
166+
]
167+
]
168+
},
169+
"events": []
170+
}

0 commit comments

Comments
 (0)