Flex
Flex exchange system
WIC.hpp
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include "WrappersConfig.hpp"
10 
11 #include <tvm/schema/message.hpp>
12 #include <tvm/smart_switcher.hpp>
13 #include <tvm/contract_handle.hpp>
14 
15 namespace tvm {
16 
18 struct WICSalt {
19  address super_root;
20  address wrappers_cfg;
23 };
24 
26 struct WICDetails {
27  string symbol;
28  int8 workchain_id;
29  opt<address> deployer;
30  opt<address> wrapper;
31  opt<uint8> type;
32  opt<cell> init_args;
33  opt<address> next;
34  bool unlisted;
35 };
36 
41 __interface IWIC {
42  [[deploy, internal]]
43  resumable<void> onDeploy(
44  uint128 keep_evers,
45  address_opt old_wrappers_cfg,
46  address_opt old_wrapper,
47  bool keep_wrapper,
48  address deployer,
49  uint8 type,
50  cell init_args
51  ) = 10;
52 
54  [[internal]]
55  void setNext(
56  address_opt old_wrappers_cfg,
57  opt<string> next_symbol,
58  address next
59  ) = 11;
60 
63  [[internal]]
65  WICCloneEvers evers,
66  opt<address> first_clone,
67  opt<address> last_clone,
68  opt<string> prev_symbol,
69  uint32 wic_count,
70  uint32 token_version,
71  address new_wrappers_cfg,
72  dict_array<address> wrapper_deployers
73  ) = 12;
74 
76  [[internal]]
77  void unlist() = 13;
78 
80  [[getter]]
82 };
83 using IWICPtr = handle<IWIC>;
84 
86 struct DWIC {
87  string symbol_;
88  // ^^^ Fields defined at deploy (used for address calculation) ^^^
90  opt<address> deployer_;
91  opt<address> wrapper_;
92  opt<uint8> type_;
93  opt<cell> init_args_;
94  opt<address> next_;
95  bool_t unlisted_;
96 };
97 
100 __interface EWIC {
101 };
102 
104 template<>
105 struct preparer<IWIC, DWIC> {
106  __always_inline
107  static std::pair<StateInit, uint256> execute(DWIC data, cell code) {
108  cell data_cl = prepare_persistent_data<IWIC, void>({}, data);
109  StateInit init { {}, {}, code, data_cl, {} };
110  cell init_cl = build(init).make_cell();
111  return { init, uint256(tvm_hash(init_cl)) };
112  }
113 };
114 
115 } // namespace tvm
WrappersConfig contract interfaces and data-structs.
Wrapper Index Contract persistent data struct.
Definition: WIC.hpp:86
opt< address > wrapper_
Wrapper address.
Definition: WIC.hpp:91
string symbol_
Token symbol. Used for address calculation.
Definition: WIC.hpp:87
opt< address > next_
Next WIC address.
Definition: WIC.hpp:94
opt< cell > init_args_
Init args.
Definition: WIC.hpp:93
opt< uint8 > type_
Wrapper type.
Definition: WIC.hpp:92
bool_t unlisted_
Wrapper is unlisted and should not be cloned during cloneUpgrade.
Definition: WIC.hpp:95
int8 workchain_id_
Workchain id.
Definition: WIC.hpp:89
opt< address > deployer_
Wrapper deployer used to deploy the wrapper.
Definition: WIC.hpp:90
Wrapper Index Contract events interface.
Definition: WIC.hpp:100
Wrapper Index Contract interface. WIC is a contract to index (enumerate) wrappers.
Definition: WIC.hpp:41
WICDetails getDetails()
Get info about contract state details.
void setNext(address_opt old_wrappers_cfg, opt< string > next_symbol, address next)
Set next WIC address.
void cloneUpgrade(WICCloneEvers evers, opt< address > first_clone, opt< address > last_clone, opt< string > prev_symbol, uint32 wic_count, uint32 token_version, address new_wrappers_cfg, dict_array< address > wrapper_deployers)
resumable< void > onDeploy(uint128 keep_evers, address_opt old_wrappers_cfg, address_opt old_wrapper, bool keep_wrapper, address deployer, uint8 type, cell init_args)
void unlist()
Mark this WIC/Wrapper as unlisted. Unlisted WIC will not be cloned during cloneUpgrade.
Evers configuration for clone procedure.
Definition: WICCloneEvers.hpp:12
WIC details for getter.
Definition: WIC.hpp:26
opt< address > wrapper
Wrapper address.
Definition: WIC.hpp:30
opt< address > deployer
Wrapper deployer used to deploy the wrapper.
Definition: WIC.hpp:29
bool unlisted
Wrapper is unlisted and should not be cloned during cloneUpgrade.
Definition: WIC.hpp:34
opt< cell > init_args
Init args.
Definition: WIC.hpp:32
opt< uint8 > type
Wrapper type.
Definition: WIC.hpp:31
string symbol
Token symbol.
Definition: WIC.hpp:27
opt< address > next
Next WIC address.
Definition: WIC.hpp:33
int8 workchain_id
Workchain id.
Definition: WIC.hpp:28
Wrapper Index Contract configuration in code salt.
Definition: WIC.hpp:18
uint16 wrappers_cfg_code_depth
WrappersConfig salted code depth (for recognition of the next WrappersConfig)
Definition: WIC.hpp:22
address super_root
SuperRoot address.
Definition: WIC.hpp:19
address wrappers_cfg
WrappersConfig address.
Definition: WIC.hpp:20
uint256 wrappers_cfg_code_hash
WrappersConfig salted code hash (for recognition of the next WrappersConfig)
Definition: WIC.hpp:21