Flex
Flex exchange system
FlexClientStub.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 #include "FlexVersion.hpp"
15 #include "bind_info.hpp"
16 
17 namespace tvm {
18 
19 static constexpr unsigned FLEX_CLIENT_TIMESTAMP_DELAY = 1800;
20 using flex_client_replay_protection_t = replay_attack_protection::timestamp<FLEX_CLIENT_TIMESTAMP_DELAY>;
21 
23  address super_root;
24 };
25 
27 __interface IFlexClientStub {
29  [[internal, deploy]]
30  void onDeploy(
31  FlexVersion triplet,
32  bind_info binding,
33  cell flex_client_code,
34  cell auth_index_code,
35  cell user_id_index_code,
36  bytes signature
37  ) = 10;
38 
41  [[internal]]
42  resumable<void> unused() = 11;
43 };
44 using IFlexClientStubPtr = handle<IFlexClientStub>;
45 
48  uint256 owner_;
51  optcell auth_index_code_;
53  opt<bind_info> binding_;
54 };
55 
58 __interface EFlexClientStub {
59 };
60 
62 template<>
63 struct preparer<IFlexClientStub, DFlexClientStub> {
64  __always_inline
65  static std::pair<StateInit, uint256> execute(DFlexClientStub data, cell code) {
66  auto init_hdr = persistent_data_header<IFlexClientStub, flex_client_replay_protection_t>::init();
67  cell data_cl = prepare_persistent_data<IFlexClientStub, flex_client_replay_protection_t>(init_hdr, data);
68  StateInit init { {}, {}, code, data_cl, {} };
69  cell init_cl = build(init).make_cell();
70  return { init, uint256(tvm_hash(init_cl)) };
71  }
72 };
73 
74 } // namespace tvm
Flex version structure.
FlexClientStub persistent data struct.
Definition: FlexClientStub.hpp:47
uint256 owner_
Owner's public key. Used for address calculation.
Definition: FlexClientStub.hpp:48
optcell auth_index_code_
AuthIndex code (no salt)
Definition: FlexClientStub.hpp:51
opt< bind_info > binding_
Binding info for exchange.
Definition: FlexClientStub.hpp:53
FlexVersion ex_triplet_
Ex-version triplet (initialized during code upgrade)
Definition: FlexClientStub.hpp:50
optcell user_id_index_code_
UserIdIndex code (unsalted)
Definition: FlexClientStub.hpp:52
FlexVersion triplet_
Version triplet.
Definition: FlexClientStub.hpp:49
FlexClientStub events interface.
Definition: FlexClientStub.hpp:58
Definition: FlexClientStub.hpp:22
Flex version triplet.
Definition: FlexVersion.hpp:14
FlexClientStub is a placement contract to be setcoded to an actual FlexClient.
Definition: FlexClientStub.hpp:27
resumable< void > unused()
void onDeploy(FlexVersion triplet, bind_info binding, cell flex_client_code, cell auth_index_code, cell user_id_index_code, bytes signature)
Deploy notification.
Binding to allow orders only to specific flex root and with specific unsalted PriceXchg code hash.
Definition: bind_info.hpp:8