Flex
Flex exchange system
All Classes Files Functions Variables Typedefs Enumerations Pages
UserIdIndex.hpp
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include <tvm/schema/message.hpp>
10 #include <tvm/smart_switcher.hpp>
11 #include <tvm/contract_handle.hpp>
12 #include <tvm/replay_attack_protection/timestamp.hpp>
13 
14 namespace tvm {
15 
16 static constexpr unsigned USERID_TIMESTAMP_DELAY = 1800;
17 using userid_replay_protection_t = replay_attack_protection::timestamp<USERID_TIMESTAMP_DELAY>;
18 
21  address owner;
23 };
24 
31 __interface IUserIdIndex {
32 
34  [[deploy, internal]]
35  void onDeploy(
36  uint256 lend_pubkey,
37  string name,
38  uint128 evers_to_auth_idx,
39  uint128 refill_wallet,
40  uint128 min_refill
41  ) = 10;
42 
44  [[internal]]
46  uint256 new_lend_pubkey,
47  uint128 evers_to_remove,
48  uint128 evers_to_auth_idx
49  ) = 11;
50 
53  [[internal]]
54  void remove() = 12;
55 
57  [[internal, answer_id]]
59  uint128 evers_balance
60  ) = 13;
61 
63  [[external]]
64  void transfer(
65  address dest,
66  uint128 value,
67  bool bounce
68  ) = 14;
69 
71  [[external]]
73  uint128 refill_wallet,
74  uint128 min_refill
75  ) = 15;
76 
78  [[getter]]
80 };
81 using IUserIdIndexPtr = handle<IUserIdIndex>;
82 
84 struct DUserIdIndex {
85  int8 workchain_id_;
86  uint256 user_id_;
87  uint256 lend_pubkey_;
89  opt<string> name_;
90  uint128 refill_wallet_;
91  uint128 min_refill_;
92 };
93 
96 __interface EUserIdIndex {
97 };
98 
100 template<>
101 struct preparer<IUserIdIndex, DUserIdIndex> {
102  __always_inline
103  static std::pair<StateInit, uint256> execute(DUserIdIndex data, cell code) {
104  auto init_hdr = persistent_data_header<IUserIdIndex, userid_replay_protection_t>::init();
105  cell data_cl = prepare_persistent_data<IUserIdIndex, userid_replay_protection_t>(init_hdr, data);
106  StateInit init { {}, {}, code, data_cl, {} };
107  cell init_cl = build(init).make_cell();
108  return { init, uint256(tvm_hash(init_cl)) };
109  }
110 };
111 
112 } // namespace tvm
113 
UserIdIndex persistent data struct.
Definition: UserIdIndex.hpp:84
uint128 refill_wallet_
Re-fill wallet on transfer received.
Definition: UserIdIndex.hpp:90
uint256 user_id_
User id, it is used for address calculation.
Definition: UserIdIndex.hpp:86
uint256 lend_pubkey_
Definition: UserIdIndex.hpp:87
uint128 min_refill_
Minimum refill value.
Definition: UserIdIndex.hpp:91
opt< string > name_
Encrypted login. We use naclbox for encryption.
Definition: UserIdIndex.hpp:89
UserIdIndex events interface.
Definition: UserIdIndex.hpp:96
UserIdIndex contract interface. There is no way to understand which wallets were created for some Fle...
Definition: UserIdIndex.hpp:31
UserIdIndexSalt getConfig()
Get config from code salt.
void onDeploy(uint256 lend_pubkey, string name, uint128 evers_to_auth_idx, uint128 refill_wallet, uint128 min_refill)
Check that msg.sender is an owner (from configuration salt). Deploy AuthIndex with lend_pubkey.
uint256 requestLendPubkey(uint128 evers_balance)
Request lend pubkey (current app pubkey).
void transfer(address dest, uint128 value, bool bounce)
Transfer evers.
void reLendPubkey(uint256 new_lend_pubkey, uint128 evers_to_remove, uint128 evers_to_auth_idx)
Remove AuthIndex with lend_pubkey. Deploy AuthIndex with new_lend_pubkey. Set lend_pubkey = new_lend_...
void setRefillWallet(uint128 refill_wallet, uint128 min_refill)
Set re-fill wallet value.
UserIdIndex configuration data (code salt)
Definition: UserIdIndex.hpp:20
cell auth_index_code
Code of AuthIndex (no salt)
Definition: UserIdIndex.hpp:22
address owner
Address that can send command messages to UserIdIndex. It is address of FlexClient.
Definition: UserIdIndex.hpp:21