Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
37247d0
basic migration testing
bonedaddy Aug 5, 2023
4d1a8cb
alter contract version numbers depending on test environment...
bonedaddy Aug 6, 2023
406ba4c
enable cargo workspace settings
bonedaddy Aug 6, 2023
cdd96af
cleanup contract test functions
bonedaddy Aug 7, 2023
6af13c4
restructure migration helpers
bonedaddy Aug 7, 2023
42ed219
add rate limit rollover helper functions
bonedaddy Aug 8, 2023
105fdde
wip period rollover functionality
bonedaddy Aug 9, 2023
0ef16de
update precompiled wasm code
bonedaddy Aug 11, 2023
f0733f2
update rate limiter
bonedaddy Aug 11, 2023
8669c56
fix rollover sudo usage
bonedaddy Aug 11, 2023
86822ac
contract cleanup
bonedaddy Aug 11, 2023
e315c5d
wip rollover testing
bonedaddy Aug 11, 2023
6384afa
fix rate limit query test
bonedaddy Aug 13, 2023
a9ad59f
reset channel value on rollover
bonedaddy Aug 13, 2023
4c2a95f
wip middleware testing
bonedaddy Aug 13, 2023
eff6bde
update precompiled wasm bytecode
bonedaddy Aug 13, 2023
73696aa
update rollover tests
bonedaddy Aug 13, 2023
322e291
wip decay two period average
bonedaddy Aug 13, 2023
e17fae3
wip basic decay two period contract tests
bonedaddy Aug 14, 2023
abc0726
add send + query to decay two period test
bonedaddy Aug 14, 2023
6ec4053
format contract tests
bonedaddy Aug 14, 2023
196e5da
fix invalid rule copy
bonedaddy Aug 15, 2023
0bcbdaa
test updates
bonedaddy Aug 15, 2023
0844935
wip rate limit testing
bonedaddy Aug 15, 2023
c3d4e9f
add monthly decay tests
bonedaddy Aug 16, 2023
a48c4d6
cherrypick
bonedaddy Aug 17, 2023
c94d5b3
fix test issues from previous commits
bonedaddy Aug 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
919 changes: 919 additions & 0 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[workspace]
resolver = "2"
members = [
"x/ibc-rate-limit/contracts/rate-limiter"
]
7 changes: 7 additions & 0 deletions x/ibc-rate-limit/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified x/ibc-rate-limit/bytecode/rate_limiter.wasm
Binary file not shown.
4 changes: 3 additions & 1 deletion x/ibc-rate-limit/contracts/rate-limiter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ optimize = """docker run --rm -v "$(pwd)":/code \
cosmwasm-std = { version = "1.1.5", features = ["stargate", "cosmwasm_1_1"]}
cosmwasm-schema = "1.1.5"
cosmwasm-storage = "1.1.5"
cw-storage-plus = "0.16.0"
cw-storage-plus = {version = "0.16.0", features = ["iterator"]}
cw2 = "0.13.2"
schemars = "0.8.8"
serde = { version = "1.0.137", default-features = false, features = ["derive"] }
Expand All @@ -45,6 +45,8 @@ osmosis-std-derive = {version = "0.12.0"}
osmosis-std = "0.12.0"
sha2 = "0.10.6"
hex = "0.4.3"
semver = "1"


[dev-dependencies]
cw-multi-test = "0.13.2"
Expand Down
25 changes: 19 additions & 6 deletions x/ibc-rate-limit/contracts/rate-limiter/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult};
use cw2::set_contract_version;
use cosmwasm_std::{Binary, Deps, DepsMut, Env, Event, MessageInfo, Response, StdError, StdResult};
use cw2::{get_contract_version, set_contract_version, ContractVersion};

use crate::error::ContractError;
use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg, SudoMsg};
use crate::state::{FlowType, GOVMODULE, IBCMODULE};
use crate::{execute, query, sudo};

// version info for migration info
const CONTRACT_NAME: &str = "crates.io:rate-limiter";
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");
pub(crate) const CONTRACT_NAME: &str = "crates.io:rate-limiter";

pub(crate) const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");



#[cfg_attr(not(feature = "library"), entry_point)]
pub fn instantiate(
Expand All @@ -19,7 +22,13 @@ pub fn instantiate(
_info: MessageInfo,
msg: InstantiateMsg,
) -> Result<Response, ContractError> {
// for testing purposes always set version to 0.1.0
#[cfg(test)]
set_contract_version(deps.storage, CONTRACT_NAME, "0.1.0")?;

#[cfg(not(test))]
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;

IBCMODULE.save(deps.storage, &msg.ibc_module)?;
GOVMODULE.save(deps.storage, &msg.gov_module)?;

Expand Down Expand Up @@ -90,6 +99,10 @@ pub fn sudo(deps: DepsMut, env: Env, msg: SudoMsg) -> Result<Response, ContractE
channel_value_mock,
),
SudoMsg::UndoSend { packet } => sudo::undo_send(deps, packet),
SudoMsg::RolloverRules => {
crate::sudo::rollover_expired_rate_limits(deps, env)?;
Ok(Response::default())
},
}
}

Expand All @@ -101,6 +114,6 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn migrate(_deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result<Response, ContractError> {
unimplemented!()
pub fn migrate(deps: DepsMut, env: Env, msg: MigrateMsg) -> Result<Response, ContractError> {
crate::migrations::migrate_internal(deps, env, msg)
}
Loading