levana_perpswap_cosmos/contracts/tracker/entry.rs
1use crate::prelude::*;
2use cosmwasm_schema::QueryResponses;
3
4#[cw_serde]
5pub struct InstantiateMsg {}
6
7#[cw_serde]
8pub struct MigrateMsg {}
9
10#[cw_serde]
11pub enum ExecuteMsg {
12 /// Track the upload of a WASM file
13 CodeId {
14 /// User friendly string describing the contract
15 contract_type: String,
16 /// Code ID of the uploaded file
17 code_id: u64,
18 /// SHA256 hash to uniquely identify a file
19 hash: String,
20 /// Git commit that generated this code, if known
21 gitrev: Option<String>,
22 },
23 /// Track the instantiation of a new contract
24 ///
25 /// Will automatically assign a unique identifier from the deployment family
26 Instantiate {
27 code_id: u64,
28 address: String,
29 /// Family of the deployment.
30 ///
31 /// This can be things like osmodev or dragonci. The idea would be that there
32 /// can be a series of contracts in this family, and the latest one is the
33 /// current true deployment.
34 ///
35 /// Each individual instantiation will get a unique identifier based on this name.
36 family: String,
37 },
38 /// Track the migration of an existing contract to a new code ID.
39 ///
40 /// This information is already tracked on the blockchain, it's just
41 /// convenient to have it here too.
42 Migrate { new_code_id: u64, address: String },
43 /// Add an administrator address
44 AddAdmin { address: String },
45 /// Remove an administrator address
46 RemoveAdmin { address: String },
47}
48
49#[cw_serde]
50#[derive(QueryResponses)]
51pub enum QueryMsg {
52 /// Lookup the code by ID
53 #[returns(CodeIdResp)]
54 CodeById { code_id: u64 },
55 /// Lookup the code by hash
56 #[returns(CodeIdResp)]
57 CodeByHash { hash: String },
58 /// Get the contract information for the given contract address
59 #[returns(ContractResp)]
60 ContractByAddress { address: String },
61 /// Get the contract information for the latest contract in a family
62 #[returns(ContractResp)]
63 ContractByFamily {
64 /// This is derived from the Code ID during the Instantiate call
65 contract_type: String,
66 family: String,
67 /// Unique identifier within the series to look up.
68 ///
69 /// If omitted, gets the most recent
70 sequence: Option<u32>,
71 },
72}
73
74#[cw_serde]
75pub enum CodeIdResp {
76 NotFound {},
77 Found {
78 contract_type: String,
79 code_id: u64,
80 hash: String,
81 tracked_at: Timestamp,
82 gitrev: Option<String>,
83 },
84}
85
86#[cw_serde]
87pub enum ContractResp {
88 NotFound {},
89 Found {
90 address: String,
91 contract_type: String,
92 original_code_id: u64,
93 /// When we received the Instantiate call
94 original_tracked_at: Timestamp,
95 current_code_id: u64,
96 /// When we received the most recent instantiate or migrate
97 current_tracked_at: Timestamp,
98 family: String,
99 sequence: u32,
100 /// How many times have we been migrated?
101 migrate_count: u32,
102 },
103}