Skip to content

Commit a14ada4

Browse files
committed
ref: data storage
1 parent 4004994 commit a14ada4

File tree

25 files changed

+174
-156
lines changed

25 files changed

+174
-156
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contracts/data-storage/andromeda-boolean/src/execute.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub fn set_value(
4444
let addr = sender.as_str();
4545
let is_operator = ADOContract::default().is_owner_or_operator(ctx.deps.storage, addr)?;
4646
let allowed = match DATA_OWNER.load(ctx.deps.storage).ok() {
47-
Some(owner) => addr == owner,
47+
Some(owner) => sender == owner,
4848
None => true,
4949
};
5050
ensure!(is_operator || allowed, ContractError::Unauthorized {});
@@ -91,7 +91,7 @@ pub fn delete_value(mut ctx: ExecuteContext) -> Result<Response, ContractError>
9191
let addr = sender.as_str();
9292
let is_operator = ADOContract::default().is_owner_or_operator(ctx.deps.storage, addr)?;
9393
let allowed = match DATA_OWNER.load(ctx.deps.storage).ok() {
94-
Some(owner) => addr == owner,
94+
Some(owner) => sender == owner,
9595
None => true,
9696
};
9797
ensure!(is_operator || allowed, ContractError::Unauthorized {});

contracts/data-storage/andromeda-boolean/src/testing/mock.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use andromeda_std::{
88
};
99
use cosmwasm_std::{
1010
from_json,
11-
testing::{mock_env, message_info, MockApi, MockStorage},
12-
Coin, Deps, DepsMut, MessageInfo, OwnedDeps, Response,
11+
testing::{message_info, mock_env, MockApi, MockStorage},
12+
Addr, Coin, Deps, DepsMut, MessageInfo, OwnedDeps, Response,
1313
};
1414

1515
pub type MockDeps = OwnedDeps<MockStorage, MockApi, WasmMockQuerier>;
@@ -38,7 +38,8 @@ pub fn query_value(deps: Deps) -> Result<GetValueResponse, ContractError> {
3838

3939
pub fn set_value(deps: DepsMut<'_>, value: &bool, sender: &str) -> Result<Response, ContractError> {
4040
let msg = ExecuteMsg::SetValue { value: *value };
41-
let info = message_info(sender, &[]);
41+
42+
let info = message_info(&Addr::unchecked(sender), &[]);
4243
execute(deps, mock_env(), info, msg)
4344
}
4445

@@ -49,12 +50,12 @@ pub fn set_value_with_funds(
4950
coin: Coin,
5051
) -> Result<Response, ContractError> {
5152
let msg = ExecuteMsg::SetValue { value: *value };
52-
let info = message_info(sender, &[coin]);
53+
let info = message_info(&Addr::unchecked(sender), &[coin]);
5354
execute(deps, mock_env(), info, msg)
5455
}
5556

5657
pub fn delete_value(deps: DepsMut<'_>, sender: &str) -> Result<Response, ContractError> {
5758
let msg = ExecuteMsg::DeleteValue {};
58-
let info = message_info(sender, &[]);
59+
let info = message_info(&Addr::unchecked(sender), &[]);
5960
execute(deps, mock_env(), info, msg)
6061
}

contracts/data-storage/andromeda-form/src/execute.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub fn execute_submit_form(
5555
true => {
5656
submissions().save(
5757
ctx.deps.storage,
58-
&(new_id.u64(), sender.clone()),
58+
(new_id.u64(), sender.clone()),
5959
&SubmissionInfo {
6060
submission_id: new_id.u64(),
6161
wallet_address: sender.clone(),
@@ -77,7 +77,7 @@ pub fn execute_submit_form(
7777
if submissions_by_address.is_empty() {
7878
submissions().save(
7979
ctx.deps.storage,
80-
&(new_id.u64(), sender.clone()),
80+
(new_id.u64(), sender.clone()),
8181
&SubmissionInfo {
8282
submission_id: new_id.u64(),
8383
wallet_address: sender.clone(),
@@ -112,14 +112,14 @@ pub fn execute_delete_submission(
112112
let sender = ctx.info.sender;
113113
let address = wallet_address.get_raw_address(&ctx.deps.as_ref())?;
114114
submissions()
115-
.load(ctx.deps.storage, &(submission_id, address.clone()))
115+
.load(ctx.deps.storage, (submission_id, address.clone()))
116116
.map_err(|_| ContractError::CustomError {
117117
msg: format!(
118118
"Submission does not exist - Submission_id {:?}, Wallet_address {:?}",
119119
submission_id, wallet_address
120120
),
121121
})?;
122-
submissions().remove(ctx.deps.storage, &(submission_id, address.clone()))?;
122+
submissions().remove(ctx.deps.storage, (submission_id, address.clone()))?;
123123

124124
let response = Response::new()
125125
.add_attribute("method", "delete_submission")
@@ -165,7 +165,7 @@ pub fn execute_edit_submission(
165165
let wallet_address = wallet_address.get_raw_address(&ctx.deps.as_ref())?;
166166

167167
if submissions()
168-
.may_load(ctx.deps.storage, &(submission_id, wallet_address.clone()))?
168+
.may_load(ctx.deps.storage, (submission_id, wallet_address.clone()))?
169169
.is_some()
170170
{
171171
ensure!(
@@ -177,7 +177,7 @@ pub fn execute_edit_submission(
177177
ValidateDataResponse::Valid => {
178178
submissions().save(
179179
ctx.deps.storage,
180-
&(submission_id, wallet_address),
180+
(submission_id, wallet_address),
181181
&SubmissionInfo {
182182
submission_id,
183183
wallet_address: sender.clone(),

contracts/data-storage/andromeda-form/src/query.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub fn get_submission(
5353
) -> Result<GetSubmissionResponse, ContractError> {
5454
let wallet_address = wallet_address.get_raw_address(&deps)?;
5555
let submission =
56-
submissions().may_load(deps.storage, &(submission_id, wallet_address.clone()))?;
56+
submissions().may_load(deps.storage, (submission_id, wallet_address.clone()))?;
5757
Ok(GetSubmissionResponse { submission })
5858
}
5959

contracts/data-storage/andromeda-form/src/state.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl IndexList<SubmissionInfo> for SubmissionIndexes<'_> {
3535
}
3636
}
3737

38-
pub fn submissions<'a>() -> IndexedMap<'a, &'a (u64, Addr), SubmissionInfo, SubmissionIndexes<'a>> {
38+
pub fn submissions<'a>() -> IndexedMap<(u64, Addr), SubmissionInfo, SubmissionIndexes<'static>> {
3939
let indexes = SubmissionIndexes {
4040
submission_id: MultiIndex::new(
4141
|_pk: &[u8], r| r.submission_id,

contracts/data-storage/andromeda-form/src/testing/mock.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ use andromeda_data_storage::form::{
66
use andromeda_std::{
77
amp::AndrAddr, error::ContractError, testing::mock_querier::MOCK_KERNEL_CONTRACT,
88
};
9+
use cosmwasm_std::Addr;
910
use cosmwasm_std::{
1011
from_json,
11-
testing::{mock_env, message_info, MockApi, MockStorage},
12+
testing::{message_info, mock_env, MockApi, MockStorage},
1213
Deps, DepsMut, MessageInfo, OwnedDeps, Response, Timestamp,
1314
};
1415

@@ -74,7 +75,7 @@ pub fn submit_form(
7475
timestamp_nanos: u64,
7576
) -> Result<Response, ContractError> {
7677
let msg = ExecuteMsg::SubmitForm { data };
77-
let info = message_info(sender, &[]);
78+
let info = message_info(&Addr::unchecked(sender), &[]);
7879
let mut env = mock_env();
7980
env.block.time = Timestamp::from_nanos(timestamp_nanos);
8081
execute(deps, env, info, msg)
@@ -90,7 +91,8 @@ pub fn delete_submission(
9091
submission_id,
9192
wallet_address,
9293
};
93-
let info = message_info(sender, &[]);
94+
95+
let info = message_info(&Addr::unchecked(sender), &[]);
9496
let env = mock_env();
9597
execute(deps, env, info, msg)
9698
}
@@ -107,7 +109,7 @@ pub fn edit_submission(
107109
wallet_address,
108110
data,
109111
};
110-
let info = message_info(sender, &[]);
112+
let info = message_info(&Addr::unchecked(sender), &[]);
111113
let env = mock_env();
112114
execute(deps, env, info, msg)
113115
}
@@ -118,7 +120,7 @@ pub fn open_form(
118120
timestamp_nanos: u64,
119121
) -> Result<Response, ContractError> {
120122
let msg = ExecuteMsg::OpenForm {};
121-
let info = message_info(sender, &[]);
123+
let info = message_info(&Addr::unchecked(sender), &[]);
122124
let mut env = mock_env();
123125
env.block.time = Timestamp::from_nanos(timestamp_nanos);
124126
execute(deps, env, info, msg)
@@ -130,7 +132,7 @@ pub fn close_form(
130132
timestamp_nanos: u64,
131133
) -> Result<Response, ContractError> {
132134
let msg = ExecuteMsg::CloseForm {};
133-
let info = message_info(sender, &[]);
135+
let info = message_info(&Addr::unchecked(sender), &[]);
134136
let mut env = mock_env();
135137
env.block.time = Timestamp::from_nanos(timestamp_nanos);
136138
execute(deps, env, info, msg)

contracts/data-storage/andromeda-form/src/testing/mock_querier.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use andromeda_std::{
88
use cosmwasm_std::QuerierWrapper;
99
use cosmwasm_std::{
1010
from_json,
11-
testing::{mock_env, message_info, MockApi, MockQuerier, MockStorage, MOCK_CONTRACT_ADDR},
11+
testing::{message_info, mock_env, MockApi, MockQuerier, MockStorage, MOCK_CONTRACT_ADDR},
1212
Coin, OwnedDeps, Querier, QuerierResult, QueryRequest, SystemError, SystemResult, WasmQuery,
1313
};
1414
use cosmwasm_std::{to_json_binary, Binary, ContractResult};
@@ -30,13 +30,14 @@ pub fn mock_dependencies_custom(
3030
querier: custom_querier,
3131
custom_query_type: std::marker::PhantomData,
3232
};
33+
let sender = deps.api.addr_make("sender");
3334
ADOContract::default()
3435
.instantiate(
3536
&mut deps.storage,
3637
mock_env(),
3738
&deps.api,
3839
&QuerierWrapper::new(&deps.querier),
39-
message_info("sender", &[]),
40+
message_info(&sender, &[]),
4041
InstantiateMsg {
4142
ado_type: "form".to_string(),
4243
ado_version: "test".to_string(),

contracts/data-storage/andromeda-string-storage/src/testing/mock.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use andromeda_std::{
77
};
88
use cosmwasm_std::{
99
from_json,
10-
testing::{mock_env, message_info, MockApi, MockStorage},
11-
Coin, Deps, DepsMut, MessageInfo, OwnedDeps, Response,
10+
testing::{message_info, mock_env, MockApi, MockStorage},
11+
Addr, Coin, Deps, DepsMut, MessageInfo, OwnedDeps, Response,
1212
};
1313

1414
use crate::contract::{execute, instantiate, query};
@@ -45,7 +45,7 @@ pub fn set_value(
4545
let msg = ExecuteMsg::SetValue {
4646
value: value.clone(),
4747
};
48-
let info = message_info(sender, &[]);
48+
let info = message_info(&Addr::unchecked(sender), &[]);
4949
execute(deps, mock_env(), info, msg)
5050
}
5151

@@ -58,12 +58,12 @@ pub fn set_value_with_funds(
5858
let msg = ExecuteMsg::SetValue {
5959
value: value.clone(),
6060
};
61-
let info = message_info(sender, &[coin]);
61+
let info = message_info(&Addr::unchecked(sender), &[coin]);
6262
execute(deps, mock_env(), info, msg)
6363
}
6464

6565
pub fn delete_value(deps: DepsMut<'_>, sender: &str) -> Result<Response, ContractError> {
6666
let msg = ExecuteMsg::DeleteValue {};
67-
let info = message_info(sender, &[]);
67+
let info = message_info(&Addr::unchecked(sender), &[]);
6868
execute(deps, mock_env(), info, msg)
6969
}

contracts/finance/andromeda-timelock/src/state.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ impl IndexList<Escrow> for EscrowIndexes<'_> {
1818
}
1919
}
2020

21-
pub fn escrows<'a>() -> IndexedMap<'a, Vec<u8>, Escrow, EscrowIndexes<'a>> {
21+
pub fn escrows() -> IndexedMap<Vec<u8>, Escrow, EscrowIndexes<'static>> {
2222
let indexes = EscrowIndexes {
2323
owner: MultiIndex::new(
2424
|_pk: &[u8], e| e.recipient_addr.clone(),

contracts/os/andromeda-economics/src/tests/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ fn test_pay_fee() {
174174
// let mut deps = mock_dependencies_custom(&[]);
175175
// let env = mock_env();
176176
// let creator = deps.api.addr_make("creator");
177-
let info = message_info(&creator, &[]);
177+
// let info = message_info(&creator, &[]);
178178
// let payee = "payee";
179179

180180
// let msg = ExecuteMsg::PayFee {
@@ -212,7 +212,7 @@ fn test_pay_fee() {
212212
// let mut deps = mock_dependencies_custom(&[]);
213213
// let env = mock_env();
214214
// let creator = deps.api.addr_make("creator");
215-
let info = message_info(&creator, &[]);
215+
// let info = message_info(&creator, &[]);
216216
// let payee = "payee";
217217

218218
// let msg = ExecuteMsg::PayFee {
@@ -251,7 +251,7 @@ fn test_pay_fee() {
251251
// let mut deps = mock_dependencies_custom(&[]);
252252
// let env = mock_env();
253253
// let creator = deps.api.addr_make("creator");
254-
let info = message_info(&creator, &[]);
254+
// let info = message_info(&creator, &[]);
255255
// let payee = "payee";
256256

257257
// let msg = ExecuteMsg::PayFee {

contracts/os/andromeda-kernel/src/ibc.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,14 @@ pub fn generate_ibc_hook_transfer_message(
372372

373373
let ts = time.plus_seconds(PACKET_LIFETIME);
374374

375+
let osmosis_coin = osmosis_std::types::cosmos::base::v1beta1::Coin {
376+
denom: fund.denom.to_string(),
377+
amount: fund.amount.to_string(),
378+
};
375379
Ok(MsgTransfer {
376380
source_port: TRANSFER_PORT.into(),
377381
source_channel: channel.to_string(),
378-
token: Some(fund.clone()),
382+
token: Some(osmosis_coin),
379383
sender: from_addr.to_string(),
380384
receiver: to_addr.to_string(),
381385
timeout_height: None,

contracts/os/andromeda-kernel/src/proto.rs

+11-18
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Original: https://github.com/osmosis-labs/osmosis/blob/main/cosmwasm/packages/registry/src/proto.rs
33
// All credit goes to Osmosis Labs
44

5+
use cosmwasm_schema::cw_serde;
56
use osmosis_std_derive::CosmwasmExt;
67

78
#[derive(
@@ -20,32 +21,24 @@ pub struct IbcCounterpartyHeight {
2021
revision_height: Option<u64>,
2122
}
2223

23-
#[derive(
24-
Clone,
25-
PartialEq,
26-
::prost::Message,
27-
serde::Serialize,
28-
serde::Deserialize,
29-
schemars::JsonSchema,
30-
CosmwasmExt,
31-
)]
32-
#[proto_message(type_url = "/ibc.applications.transfer.v1.MsgTransfer")]
24+
#[cw_serde]
25+
// #[proto_message(type_url = "/ibc.applications.transfer.v1.MsgTransfer")]
3326
pub struct MsgTransfer {
34-
#[prost(string, tag = "1")]
27+
// #[prost(string, tag = "1")]
3528
pub source_port: String,
36-
#[prost(string, tag = "2")]
29+
// #[prost(string, tag = "2")]
3730
pub source_channel: String,
38-
#[prost(message, optional, tag = "3")]
31+
// #[prost(message, optional, tag = "3")]
3932
pub token: ::core::option::Option<osmosis_std::types::cosmos::base::v1beta1::Coin>,
40-
#[prost(string, tag = "4")]
33+
// #[prost(string, tag = "4")]
4134
pub sender: String,
42-
#[prost(string, tag = "5")]
35+
// #[prost(string, tag = "5")]
4336
pub receiver: String,
44-
#[prost(message, optional, tag = "6")]
37+
// #[prost(message, optional, tag = "6")]
4538
pub timeout_height: Option<IbcCounterpartyHeight>,
46-
#[prost(uint64, optional, tag = "7")]
39+
// #[prost(uint64, optional, tag = "7")]
4740
pub timeout_timestamp: ::core::option::Option<u64>,
48-
#[prost(string, tag = "8")]
41+
// #[prost(string, tag = "8")]
4942
pub memo: String,
5043
}
5144

0 commit comments

Comments
 (0)