Flex
Flex exchange system
WrappersConfig.hpp
Go to the documentation of this file.
1 
71 #pragma once
72 
73 #include <tvm/schema/message.hpp>
74 #include <tvm/smart_switcher.hpp>
75 #include <tvm/contract_handle.hpp>
76 #include <tvm/replay_attack_protection/timestamp.hpp>
77 #include "WICCloneEvers.hpp"
78 
79 namespace tvm {
80 
83  address super_root;
84  cell wic_code;
85 };
86 
89  uint32 token_version;
90  dict_array<address> wrapper_deployers;
91  address_opt first_wic;
92  address_opt last_wic;
93  uint32 wic_count;
94  uint256 salted_wic_hash;
95 };
96 
99  address deployer;
102 };
103 
108 __interface IWrappersConfig {
109 
111  [[deploy, internal]]
112  void onDeploy(
113  uint128 keep_evers,
114  opt<WICCloneEvers> evers,
115  opt<uint32> old_token_version,
116  dict_array<address> wrapper_deployers,
117  address_opt first_wic,
118  address_opt last_wic,
119  uint32 wic_count
120  );
121 
123  [[internal]]
125  address_opt first_wic,
126  address_opt last_wic,
127  uint32 wic_count
128  );
129 
131  [[internal]]
133  uint128 keep_evers,
134  uint8 type,
135  address wrapper_deployer
136  );
137 
139  [[internal]]
141  uint128 keep_evers,
142  WICCloneEvers evers,
143  string symbol,
144  uint8 type,
145  cell init_args
146  );
147 
149  [[internal]]
151  address wic
152  );
153 
157  [[internal, answer_id]]
158  address cloneUpgrade(
159  address_opt answer_addr,
160  uint128 keep_evers,
161  uint128 clone_deploy_evers,
162  WICCloneEvers evers,
163  uint32 new_token_version,
164  dict_array<address> wrapper_deployers
165  );
166 
168  [[getter]]
170 
172  [[getter]]
174 };
175 using IWrappersConfigPtr = handle<IWrappersConfig>;
176 
179  uint32 token_version_;
180  // ^^^ Fields defined at deploy (used for address calculation) ^^^
181  bool_t deployed_;
182  uint128 keep_evers_;
184  dict_array<address> wrapper_deployers_;
185  address_opt first_wic_;
186  address_opt last_wic_;
188  uint32 wic_count_;
189 };
190 
193 __interface EWrappersConfig {
194 };
195 
197 template<>
198 struct preparer<IWrappersConfig, DWrappersConfig> {
199  __always_inline
200  static std::pair<StateInit, uint256> execute(DWrappersConfig data, cell code) {
201  cell data_cl = prepare_persistent_data<IWrappersConfig, void>({}, data);
202  StateInit init { {}, {}, code, data_cl, {} };
203  cell init_cl = build(init).make_cell();
204  return { init, uint256(tvm_hash(init_cl)) };
205  }
206 };
207 
209 template<>
210 struct expecter<IWrappersConfig, DWrappersConfig> {
211  __always_inline
212  static uint256 execute(DWrappersConfig data, uint256 code_hash, uint16 code_depth) {
213  cell data_cl = prepare_persistent_data<IWrappersConfig, void>({}, data);
214  return tvm_state_init_hash(code_hash, uint256(tvm_hash(data_cl)), code_depth, uint16(data_cl.cdepth()));
215  }
216 };
217 
218 } // namespace tvm
WIC clone evers configuration structure.
WrappersConfig persistent data struct.
Definition: WrappersConfig.hpp:178
address_opt last_wic_
Definition: WrappersConfig.hpp:186
uint32 wic_count_
WIC count.
Definition: WrappersConfig.hpp:188
uint32 token_version_
Tokens update group version. Used for address calculation.
Definition: WrappersConfig.hpp:179
address_opt first_wic_
First Wrapper Index Contract.
Definition: WrappersConfig.hpp:185
bool_t deployed_
onDeploy call processed
Definition: WrappersConfig.hpp:181
dict_array< address > wrapper_deployers_
Wrapper deployers for different types of Wrappers.
Definition: WrappersConfig.hpp:184
int8 workchain_id_
Workchain id.
Definition: WrappersConfig.hpp:183
uint128 keep_evers_
Keep evers in the contract before returning the rest to SuperConfig.
Definition: WrappersConfig.hpp:182
WrappersConfig events interface.
Definition: WrappersConfig.hpp:193
WrappersConfig contract interface. WrappersConfig keeps wrappers configuration for specific token ver...
Definition: WrappersConfig.hpp:108
void unlistWrapper(address wic)
Unlist Wrapper.
void onDeploy(uint128 keep_evers, opt< WICCloneEvers > evers, opt< uint32 > old_token_version, dict_array< address > wrapper_deployers, address_opt first_wic, address_opt last_wic, uint32 wic_count)
Deploy processing.
WrappersConfigDetails getDetails()
Get info about contract state details.
WrappersConfigSalt getConfig()
Get config from code salt.
void addWrapperType(uint128 keep_evers, uint8 type, address wrapper_deployer)
Add Wrapper type.
void onWICsCloned(address_opt first_wic, address_opt last_wic, uint32 wic_count)
Notification from last WIC (old) about completion of WICs cloning procedure to the new WrappersConfig...
void addWrapper(uint128 keep_evers, WICCloneEvers evers, string symbol, uint8 type, cell init_args)
Add Wrapper of already registered type.
address cloneUpgrade(address_opt answer_addr, uint128 keep_evers, uint128 clone_deploy_evers, WICCloneEvers evers, uint32 new_token_version, dict_array< address > wrapper_deployers)
Evers configuration for clone procedure.
Definition: WICCloneEvers.hpp:12
Wrapper deployer info.
Definition: WrappersConfig.hpp:98
uint256 wallet_code_hash
Wallet code hash.
Definition: WrappersConfig.hpp:101
address deployer
Deployer address.
Definition: WrappersConfig.hpp:99
uint256 wrapper_code_hash
Wrapper code hash.
Definition: WrappersConfig.hpp:100
WrappersConfig details for getter.
Definition: WrappersConfig.hpp:88
uint256 salted_wic_hash
Salted WIC code hash.
Definition: WrappersConfig.hpp:94
address_opt last_wic
Last Wrapper Index Contract.
Definition: WrappersConfig.hpp:92
uint32 wic_count
WIC count.
Definition: WrappersConfig.hpp:93
dict_array< address > wrapper_deployers
Wrapper deployers for different types of Wrappers.
Definition: WrappersConfig.hpp:90
address_opt first_wic
First Wrapper Index Contract.
Definition: WrappersConfig.hpp:91
uint32 token_version
Tokens update group version.
Definition: WrappersConfig.hpp:89
WrappersConfig configuration in code salt.
Definition: WrappersConfig.hpp:82
cell wic_code
WIC code (unsalted)
Definition: WrappersConfig.hpp:84
address super_root
Flex SuperRoot address.
Definition: WrappersConfig.hpp:83