From 8d886e03f0477c48fad5de97cf6d0e0744daf371 Mon Sep 17 00:00:00 2001 From: cowboy0015 Date: Mon, 25 Mar 2024 15:35:10 -0400 Subject: [PATCH 1/9] adjusted auction contract to accept unauthorized cw721 based on the authorized_token_addresses provided by the instantiate msg --- .../andromeda-auction/src/contract.rs | 6 ++- .../andromeda-auction/src/testing/tests.rs | 37 +++++++++++++++++-- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/contracts/non-fungible-tokens/andromeda-auction/src/contract.rs b/contracts/non-fungible-tokens/andromeda-auction/src/contract.rs index d54980048..dbb52847d 100644 --- a/contracts/non-fungible-tokens/andromeda-auction/src/contract.rs +++ b/contracts/non-fungible-tokens/andromeda-auction/src/contract.rs @@ -63,6 +63,10 @@ pub fn instantiate( contract.register_modules(info.sender.as_str(), deps.storage, msg.modules)?; if let Some(authorized_token_addresses) = msg.authorized_token_addresses { + if !authorized_token_addresses.is_empty() { + ADOContract::default().permission_action(SEND_NFT_ACTION, deps.storage)?; + } + for token_address in authorized_token_addresses { let addr = token_address.get_raw_address(&deps.as_ref())?; ADOContract::set_permission( @@ -170,7 +174,7 @@ fn handle_receive_cw721( ctx: ExecuteContext, msg: Cw721ReceiveMsg, ) -> Result { - ADOContract::default().is_permissioned_strict( + ADOContract::default().is_permissioned( ctx.deps.storage, ctx.env.clone(), SEND_NFT_ACTION, diff --git a/contracts/non-fungible-tokens/andromeda-auction/src/testing/tests.rs b/contracts/non-fungible-tokens/andromeda-auction/src/testing/tests.rs index 0f3c20737..f1db53cd3 100644 --- a/contracts/non-fungible-tokens/andromeda-auction/src/testing/tests.rs +++ b/contracts/non-fungible-tokens/andromeda-auction/src/testing/tests.rs @@ -38,7 +38,23 @@ fn init(deps: DepsMut, modules: Option>) -> Response { owner: None, modules, kernel_address: MOCK_KERNEL_CONTRACT.to_string(), - authorized_token_addresses: Some(vec![AndrAddr::from_string(MOCK_TOKEN_ADDR)]), + authorized_token_addresses: None, + }; + + let info = mock_info("owner", &[]); + instantiate(deps, mock_env(), info, msg).unwrap() +} + +fn init_with_authorized_token_addresses( + deps: DepsMut, + modules: Option>, + authorized_token_addresses: Option>, +) -> Response { + let msg = InstantiateMsg { + owner: None, + modules, + kernel_address: MOCK_KERNEL_CONTRACT.to_string(), + authorized_token_addresses, }; let info = mock_info("owner", &[]); @@ -471,9 +487,6 @@ fn execute_place_bid_auction_cancelled() { #[test] fn test_execute_start_auction() { - let mut deps = mock_dependencies_custom(&[]); - let _res = init(deps.as_mut(), None); - let hook_msg = Cw721HookMsg::StartAuction { start_time: 100000, duration: 100000, @@ -490,6 +503,22 @@ fn test_execute_start_auction() { env.block.time = Timestamp::from_seconds(0u64); let info = mock_info(MOCK_TOKEN_ADDR, &[]); + + // Test when auction is permissioned + let mut deps = mock_dependencies_custom(&[]); + let authorized_token_addresses = Some(vec![AndrAddr::from_string("some_other_nft")]); + init_with_authorized_token_addresses(deps.as_mut(), None, authorized_token_addresses); + let err = execute(deps.as_mut(), env.clone(), info.clone(), msg.clone()).unwrap_err(); + assert_eq!(ContractError::Unauthorized {}, err,); + + let authorized_token_addresses = Some(vec![AndrAddr::from_string(MOCK_TOKEN_ADDR)]); + init_with_authorized_token_addresses(deps.as_mut(), None, authorized_token_addresses); + let res = execute(deps.as_mut(), env.clone(), info.clone(), msg.clone()).unwrap(); + assert_eq!(res.messages.len(), 1); + + // Unpermissioned Contract + let mut deps = mock_dependencies_custom(&[]); + let _res = init(deps.as_mut(), None); let res = execute(deps.as_mut(), env, info, msg).unwrap(); assert_eq!( From 9ea65c0dd94085c6033f70b0d9592181bd514c91 Mon Sep 17 00:00:00 2001 From: cowboy0015 Date: Tue, 26 Mar 2024 14:05:06 -0400 Subject: [PATCH 2/9] addded query to get the authorized addressses for an auction --- .../andromeda-auction/src/contract.rs | 10 +++- .../src/auction.rs | 9 ++++ .../std/src/ado_contract/permissioning.rs | 50 +++++++++++++++++++ 3 files changed, 67 insertions(+), 2 deletions(-) diff --git a/contracts/non-fungible-tokens/andromeda-auction/src/contract.rs b/contracts/non-fungible-tokens/andromeda-auction/src/contract.rs index dbb52847d..07f6783c0 100644 --- a/contracts/non-fungible-tokens/andromeda-auction/src/contract.rs +++ b/contracts/non-fungible-tokens/andromeda-auction/src/contract.rs @@ -2,8 +2,9 @@ use crate::state::{ auction_infos, read_auction_infos, read_bids, BIDS, NEXT_AUCTION_ID, TOKEN_AUCTION_STATE, }; use andromeda_non_fungible_tokens::auction::{ - AuctionIdsResponse, AuctionInfo, AuctionStateResponse, Bid, BidsResponse, Cw721HookMsg, - ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg, TokenAuctionState, + AuctionIdsResponse, AuctionInfo, AuctionStateResponse, AuthorizedAddressesResponse, Bid, + BidsResponse, Cw721HookMsg, ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg, + TokenAuctionState, }; use andromeda_std::{ ado_base::{ @@ -738,6 +739,7 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> Result encode_binary(&query_is_closed(deps, env, token_id, token_address)?), + QueryMsg::AuthorizedAddresses {} => encode_binary(&query_authorized_addresses(deps)?), _ => ADOContract::default().query(deps, env, msg), } } @@ -870,6 +872,10 @@ fn query_owner_of( Ok(res) } +fn query_authorized_addresses(deps: Deps) -> Result { + let addresses = ADOContract::default().query_permissioned_actors(deps, SEND_NFT_ACTION)?; + Ok(AuthorizedAddressesResponse { addresses }) +} #[cfg_attr(not(feature = "library"), entry_point)] pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result { // New version diff --git a/packages/andromeda-non-fungible-tokens/src/auction.rs b/packages/andromeda-non-fungible-tokens/src/auction.rs index 1204bf883..75480dc5d 100644 --- a/packages/andromeda-non-fungible-tokens/src/auction.rs +++ b/packages/andromeda-non-fungible-tokens/src/auction.rs @@ -93,6 +93,10 @@ pub enum QueryMsg { start_after: Option, limit: Option, }, + /// Gets all of the authorized addresses for the auction + #[returns(AuthorizedAddressesResponse)] + AuthorizedAddresses {}, + /// Gets the bids for the given auction id. Start_after starts indexing at 0. #[returns(BidsResponse)] Bids { @@ -192,6 +196,11 @@ pub struct AuctionStateResponse { pub is_cancelled: bool, } +#[cw_serde] +pub struct AuthorizedAddressesResponse { + pub addresses: Vec, +} + #[cw_serde] pub struct AuctionIdsResponse { pub auction_ids: Vec, diff --git a/packages/std/src/ado_contract/permissioning.rs b/packages/std/src/ado_contract/permissioning.rs index 599a0c5ba..2c441d2b4 100644 --- a/packages/std/src/ado_contract/permissioning.rs +++ b/packages/std/src/ado_contract/permissioning.rs @@ -345,6 +345,24 @@ impl<'a> ADOContract<'a> { .collect::>(); Ok(actions) } + + pub fn query_permissioned_actors( + &self, + deps: Deps, + action: impl Into, + ) -> Result, ContractError> { + let action_string: String = action.into(); + let actors = permissions() + .keys(deps.storage, None, None, Order::Ascending) + .filter(|item| item.as_ref().unwrap().starts_with(&action_string)) + .map(|item| { + let actor: String = item.unwrap_or_default()[action_string.len()..].to_string(); + actor + }) + .collect::>(); + + Ok(actors) + } } /// Checks if the provided context is authorised to perform the provided action. @@ -978,4 +996,36 @@ mod tests { assert_eq!(actions.len(), 1); assert_eq!(actions[0], "action"); } + + #[test] + fn test_query_permissioned_actors() { + let mut deps = mock_dependencies(); + let env = mock_env(); + let info = mock_info("owner", &[]); + let ctx = ExecuteContext { + deps: deps.as_mut(), + env, + info: info.clone(), + amp_ctx: None, + }; + + let contract = ADOContract::default(); + + contract.owner.save(ctx.deps.storage, &info.sender).unwrap(); + + let actor = "actor"; + let action = "action"; + ADOContract::default() + .execute_permission_action(ctx, action) + .unwrap(); + + ADOContract::set_permission(deps.as_mut().storage, action, actor, Permission::default()) + .unwrap(); + let actors = ADOContract::default() + .query_permissioned_actors(deps.as_ref(), action) + .unwrap(); + + assert_eq!(actors.len(), 1); + assert_eq!(actors[0], actor); + } } From 904e5f753053fb574c53d30913f6cb70137cdc92 Mon Sep 17 00:00:00 2001 From: cowboy0015 Date: Tue, 26 Mar 2024 15:03:53 -0400 Subject: [PATCH 3/9] added pagination to permissioned actors query --- .../andromeda-auction/src/contract.rs | 26 +++++++++++++-- .../src/auction.rs | 6 +++- .../std/src/ado_contract/permissioning.rs | 32 ++++++++++++++++--- 3 files changed, 56 insertions(+), 8 deletions(-) diff --git a/contracts/non-fungible-tokens/andromeda-auction/src/contract.rs b/contracts/non-fungible-tokens/andromeda-auction/src/contract.rs index 07f6783c0..74bd9b313 100644 --- a/contracts/non-fungible-tokens/andromeda-auction/src/contract.rs +++ b/contracts/non-fungible-tokens/andromeda-auction/src/contract.rs @@ -739,7 +739,16 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> Result encode_binary(&query_is_closed(deps, env, token_id, token_address)?), - QueryMsg::AuthorizedAddresses {} => encode_binary(&query_authorized_addresses(deps)?), + QueryMsg::AuthorizedAddresses { + start_after, + limit, + order_by, + } => encode_binary(&query_authorized_addresses( + deps, + start_after, + limit, + order_by, + )?), _ => ADOContract::default().query(deps, env, msg), } } @@ -872,8 +881,19 @@ fn query_owner_of( Ok(res) } -fn query_authorized_addresses(deps: Deps) -> Result { - let addresses = ADOContract::default().query_permissioned_actors(deps, SEND_NFT_ACTION)?; +fn query_authorized_addresses( + deps: Deps, + start_after: Option, + limit: Option, + order_by: Option, +) -> Result { + let addresses = ADOContract::default().query_permissioned_actors( + deps, + SEND_NFT_ACTION, + start_after, + limit, + order_by, + )?; Ok(AuthorizedAddressesResponse { addresses }) } #[cfg_attr(not(feature = "library"), entry_point)] diff --git a/packages/andromeda-non-fungible-tokens/src/auction.rs b/packages/andromeda-non-fungible-tokens/src/auction.rs index 75480dc5d..f98c71636 100644 --- a/packages/andromeda-non-fungible-tokens/src/auction.rs +++ b/packages/andromeda-non-fungible-tokens/src/auction.rs @@ -95,7 +95,11 @@ pub enum QueryMsg { }, /// Gets all of the authorized addresses for the auction #[returns(AuthorizedAddressesResponse)] - AuthorizedAddresses {}, + AuthorizedAddresses { + start_after: Option, + limit: Option, + order_by: Option, + }, /// Gets the bids for the given auction id. Start_after starts indexing at 0. #[returns(BidsResponse)] diff --git a/packages/std/src/ado_contract/permissioning.rs b/packages/std/src/ado_contract/permissioning.rs index 2c441d2b4..7f449a381 100644 --- a/packages/std/src/ado_contract/permissioning.rs +++ b/packages/std/src/ado_contract/permissioning.rs @@ -1,7 +1,9 @@ +use std::cmp; + use crate::{ ado_base::permissioning::{Permission, PermissionInfo, PermissioningMessage}, amp::{messages::AMPPkt, AndrAddr}, - common::context::ExecuteContext, + common::{context::ExecuteContext, OrderBy}, error::ContractError, }; use cosmwasm_std::{ensure, Deps, Env, MessageInfo, Order, Response, Storage}; @@ -350,9 +352,13 @@ impl<'a> ADOContract<'a> { &self, deps: Deps, action: impl Into, + start_after: Option, + limit: Option, + order_by: Option, ) -> Result, ContractError> { let action_string: String = action.into(); - let actors = permissions() + + let mut actors = permissions() .keys(deps.storage, None, None, Order::Ascending) .filter(|item| item.as_ref().unwrap().starts_with(&action_string)) .map(|item| { @@ -361,7 +367,25 @@ impl<'a> ADOContract<'a> { }) .collect::>(); - Ok(actors) + let start = start_after.unwrap_or(0) as usize; + let limit = limit.unwrap_or(DEFAULT_QUERY_LIMIT).min(MAX_QUERY_LIMIT) as usize; + + let (start, end) = match order_by { + Some(OrderBy::Desc) => ( + actors.len().saturating_sub(cmp::min(actors.len(), start + limit)), + actors.len().saturating_sub(cmp::min(start, actors.len())), + ), + // Default ordering is Ascending. + _ => ( + cmp::min(actors.len(), start), + cmp::min(start + limit, actors.len()), + ), + }; + let slice = &mut actors[start..end]; + if order_by == Some(OrderBy::Desc) { + slice.reverse(); + } + Ok(slice.to_vec()) } } @@ -1022,7 +1046,7 @@ mod tests { ADOContract::set_permission(deps.as_mut().storage, action, actor, Permission::default()) .unwrap(); let actors = ADOContract::default() - .query_permissioned_actors(deps.as_ref(), action) + .query_permissioned_actors(deps.as_ref(), action, None, None, None) .unwrap(); assert_eq!(actors.len(), 1); From 94b83aa7e1843762dd8e3bb590cc5d4fd2c08203 Mon Sep 17 00:00:00 2001 From: cowboy0015 Date: Tue, 26 Mar 2024 15:08:59 -0400 Subject: [PATCH 4/9] fixed lint err --- packages/std/src/ado_contract/permissioning.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/std/src/ado_contract/permissioning.rs b/packages/std/src/ado_contract/permissioning.rs index 7f449a381..539eeb366 100644 --- a/packages/std/src/ado_contract/permissioning.rs +++ b/packages/std/src/ado_contract/permissioning.rs @@ -372,7 +372,9 @@ impl<'a> ADOContract<'a> { let (start, end) = match order_by { Some(OrderBy::Desc) => ( - actors.len().saturating_sub(cmp::min(actors.len(), start + limit)), + actors + .len() + .saturating_sub(cmp::min(actors.len(), start + limit)), actors.len().saturating_sub(cmp::min(start, actors.len())), ), // Default ordering is Ascending. From 7184d5af10ede2689e784c20713e3ab28703a7df Mon Sep 17 00:00:00 2001 From: cowboy0015 Date: Thu, 28 Mar 2024 09:33:13 -0400 Subject: [PATCH 5/9] removed unused state from storage --- contracts/non-fungible-tokens/andromeda-auction/src/state.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/contracts/non-fungible-tokens/andromeda-auction/src/state.rs b/contracts/non-fungible-tokens/andromeda-auction/src/state.rs index 309547ac1..90cad1d7a 100644 --- a/contracts/non-fungible-tokens/andromeda-auction/src/state.rs +++ b/contracts/non-fungible-tokens/andromeda-auction/src/state.rs @@ -1,6 +1,6 @@ use andromeda_non_fungible_tokens::auction::{AuctionInfo, Bid, TokenAuctionState}; use andromeda_std::{common::OrderBy, error::ContractError}; -use cosmwasm_std::{Addr, Order, StdResult, Storage, Uint128}; +use cosmwasm_std::{Order, StdResult, Storage, Uint128}; use cw_storage_plus::{Bound, Index, IndexList, IndexedMap, Item, Map, MultiIndex}; @@ -15,8 +15,6 @@ pub const BIDS: Map> = Map::new("bids"); // auction_id -> [bids] pub const TOKEN_AUCTION_STATE: Map = Map::new("auction_token_state"); -pub const VALID_TOKEN_CONTRACTS: Map = Map::new("valid_token_contracts"); - pub struct AuctionIdIndices<'a> { /// PK: token_id + token_address /// Secondary key: token_address From afe8966228a70ba4614f16597d2436a84c0ac1f8 Mon Sep 17 00:00:00 2001 From: cowboy0015 Date: Thu, 28 Mar 2024 14:21:35 -0400 Subject: [PATCH 6/9] resolved conflict with rc branch --- Cargo.lock | 2 + .../schema/andromeda-app-contract.json | 10 +- .../schema/raw/execute.json | 2 +- .../schema/raw/instantiate.json | 2 +- .../schema/raw/query.json | 2 +- .../response_to_get_addresses_with_names.json | 2 +- .../raw/response_to_get_components.json | 2 +- .../andromeda-app-contract/src/contract.rs | 140 +++--- .../app/andromeda-app-contract/src/execute.rs | 112 ++--- .../app/andromeda-app-contract/src/reply.rs | 33 +- .../app/andromeda-app-contract/src/state.rs | 2 +- .../andromeda-app-contract/src/testing/mod.rs | 450 ++++++++---------- .../schema/andromeda-primitive.json | 4 +- .../schema/raw/execute.json | 2 +- .../andromeda-primitive/schema/raw/query.json | 2 +- .../andromeda-primitive/src/contract.rs | 3 +- .../schema/andromeda-vault.json | 4 +- .../andromeda-vault/schema/raw/execute.json | 2 +- .../andromeda-vault/schema/raw/query.json | 2 +- .../ecosystem/andromeda-vault/src/contract.rs | 13 +- .../src/testing/mock_querier.rs | 26 +- .../andromeda-vault/src/testing/mod.rs | 29 +- .../schema/andromeda-cross-chain-swap.json | 8 +- .../schema/raw/execute.json | 2 +- .../schema/raw/instantiate.json | 2 +- .../schema/raw/query.json | 2 +- .../raw/response_to_get_splitter_config.json | 2 +- .../src/contract.rs | 3 +- .../src/testing/mock_querier.rs | 2 + .../examples/schema.rs | 2 +- .../andromeda-rate-limiting-withdrawals.json | 396 ++++++++------- .../schema/raw/execute.json | 104 +--- .../schema/raw/instantiate.json | 130 ++--- .../schema/raw/query.json | 30 +- .../raw/response_to_account_details.json | 49 ++ .../response_to_coin_allowance_details.json | 45 ++ .../raw/response_to_get_splitter_config.json | 2 +- .../schema/raw/response_to_module.json | 2 +- .../src/contract.rs | 19 +- .../src/testing/mock_querier.rs | 4 +- .../schema/andromeda-splitter.json | 10 +- .../schema/raw/execute.json | 2 +- .../schema/raw/instantiate.json | 2 +- .../andromeda-splitter/schema/raw/query.json | 2 +- .../raw/response_to_get_splitter_config.json | 2 +- .../schema/raw/response_to_module.json | 2 +- .../andromeda-splitter/src/contract.rs | 3 +- .../src/testing/mock_querier.rs | 3 +- .../schema/andromeda-timelock.json | 12 +- .../schema/raw/execute.json | 2 +- .../schema/raw/instantiate.json | 2 +- .../andromeda-timelock/schema/raw/query.json | 2 +- .../raw/response_to_get_locked_funds.json | 2 +- ...nse_to_get_locked_funds_for_recipient.json | 2 +- .../schema/raw/response_to_module.json | 2 +- .../andromeda-timelock/src/contract.rs | 3 +- .../src/testing/mock_querier.rs | 3 +- .../schema/andromeda-vesting.json | 8 +- .../andromeda-vesting/schema/raw/execute.json | 2 +- .../schema/raw/instantiate.json | 2 +- .../andromeda-vesting/schema/raw/query.json | 2 +- .../schema/raw/response_to_config.json | 2 +- .../finance/andromeda-vesting/src/contract.rs | 3 +- .../src/testing/mock_querier.rs | 3 +- .../andromeda-vesting/src/testing/tests.rs | 4 +- ...romeda-weighted-distribution-splitter.json | 8 +- .../schema/raw/execute.json | 2 +- .../schema/raw/instantiate.json | 2 +- .../schema/raw/query.json | 2 +- .../raw/response_to_get_splitter_config.json | 2 +- .../src/contract.rs | 3 +- .../src/testing/tests.rs | 35 +- .../schema/andromeda-cw20-exchange.json | 6 +- .../schema/raw/execute.json | 2 +- .../schema/raw/instantiate.json | 2 +- .../schema/raw/query.json | 2 +- .../andromeda-cw20-exchange/src/contract.rs | 54 +-- .../src/testing/mock_querier.rs | 3 +- .../src/testing/tests.rs | 10 +- .../schema/andromeda-cw20-staking.json | 31 +- .../schema/raw/execute.json | 2 +- .../schema/raw/instantiate.json | 2 +- .../schema/raw/query.json | 16 +- .../schema/raw/response_to_config.json | 2 +- .../schema/raw/response_to_module.json | 2 +- .../andromeda-cw20-staking/src/contract.rs | 8 +- .../src/testing/mock_querier.rs | 2 + .../src/testing/tests.rs | 4 +- .../andromeda-cw20/schema/andromeda-cw20.json | 8 +- .../andromeda-cw20/schema/raw/execute.json | 2 +- .../schema/raw/instantiate.json | 2 +- .../andromeda-cw20/schema/raw/query.json | 2 +- .../schema/raw/response_to_module.json | 2 +- .../andromeda-cw20/src/contract.rs | 13 +- .../src/testing/mock_querier.rs | 5 +- .../andromeda-cw20/src/testing/tests.rs | 6 +- .../schema/andromeda-lockdrop.json | 8 +- .../schema/raw/execute.json | 2 +- .../schema/raw/instantiate.json | 2 +- .../andromeda-lockdrop/schema/raw/query.json | 2 +- .../schema/raw/response_to_module.json | 2 +- .../andromeda-lockdrop/src/contract.rs | 5 +- .../src/testing/mock_querier.rs | 3 +- .../andromeda-lockdrop/src/testing/tests.rs | 4 +- .../schema/andromeda-merkle-airdrop.json | 8 +- .../schema/raw/execute.json | 2 +- .../schema/raw/instantiate.json | 2 +- .../schema/raw/query.json | 2 +- .../schema/raw/response_to_module.json | 2 +- .../andromeda-merkle-airdrop/src/contract.rs | 3 +- .../src/testing/mock_querier.rs | 3 +- .../schema/andromeda-address-list.json | 4 +- .../schema/raw/execute.json | 2 +- .../schema/raw/query.json | 2 +- .../andromeda-address-list/src/contract.rs | 5 +- .../src/testing/mock_querier.rs | 8 +- .../schema/andromeda-rates.json | 8 +- .../andromeda-rates/schema/raw/execute.json | 2 +- .../schema/raw/instantiate.json | 2 +- .../andromeda-rates/schema/raw/query.json | 2 +- .../schema/raw/response_to_payments.json | 2 +- .../modules/andromeda-rates/src/contract.rs | 3 +- .../src/testing/mock_querier.rs | 3 +- .../schema/andromeda-auction.json | 14 +- .../schema/cw721receive.json | 8 +- .../andromeda-auction/schema/raw/execute.json | 8 +- .../schema/raw/instantiate.json | 2 +- .../andromeda-auction/schema/raw/query.json | 2 +- .../schema/raw/response_to_module.json | 2 +- .../andromeda-auction/src/contract.rs | 80 ++-- .../andromeda-auction/src/mock.rs | 5 +- .../src/testing/mock_querier.rs | 5 +- .../andromeda-auction/src/testing/tests.rs | 307 +++++------- .../schema/andromeda-crowdfund.json | 102 +++- .../schema/raw/execute.json | 23 +- .../schema/raw/instantiate.json | 2 +- .../andromeda-crowdfund/schema/raw/query.json | 2 +- .../schema/raw/response_to_config.json | 2 +- .../schema/raw/response_to_module.json | 2 +- .../schema/raw/response_to_state.json | 71 ++- .../andromeda-crowdfund/src/contract.rs | 47 +- .../andromeda-crowdfund/src/mock.rs | 7 +- .../src/testing/mock_querier.rs | 3 +- .../andromeda-crowdfund/src/testing/tests.rs | 168 +++++-- .../schema/andromeda-cw721.json | 8 +- .../andromeda-cw721/schema/raw/execute.json | 2 +- .../schema/raw/instantiate.json | 2 +- .../andromeda-cw721/schema/raw/query.json | 2 +- .../schema/raw/response_to_module.json | 2 +- .../andromeda-cw721/src/contract.rs | 3 +- .../schema/andromeda-marketplace.json | 8 +- .../schema/raw/execute.json | 2 +- .../schema/raw/instantiate.json | 2 +- .../schema/raw/query.json | 2 +- .../schema/raw/response_to_module.json | 2 +- .../andromeda-marketplace/src/contract.rs | 42 +- .../src/testing/mock_querier.rs | 4 +- .../src/testing/tests.rs | 46 +- contracts/os/andromeda-adodb/src/contract.rs | 3 +- contracts/os/andromeda-adodb/src/execute.rs | 2 +- contracts/os/andromeda-adodb/src/query.rs | 4 +- contracts/os/andromeda-adodb/src/state.rs | 12 +- .../schema/andromeda-economics.json | 4 +- .../schema/raw/execute.json | 2 +- .../andromeda-economics/schema/raw/query.json | 2 +- .../os/andromeda-economics/src/contract.rs | 3 +- .../src/tests/mock_querier.rs | 1 + .../schema/andromeda-kernel.json | 2 +- .../andromeda-kernel/schema/raw/execute.json | 2 +- contracts/os/andromeda-kernel/src/contract.rs | 5 +- .../andromeda-vfs/schema/andromeda-vfs.json | 56 ++- .../os/andromeda-vfs/schema/raw/execute.json | 8 +- .../os/andromeda-vfs/schema/raw/query.json | 46 +- .../raw/response_to_resolve_symlink.json | 2 +- contracts/os/andromeda-vfs/src/contract.rs | 3 +- contracts/os/andromeda-vfs/src/execute.rs | 4 +- contracts/os/andromeda-vfs/src/query.rs | 6 +- contracts/os/andromeda-vfs/src/state.rs | 10 +- .../os/andromeda-vfs/src/testing/tests.rs | 2 +- packages/andromeda-app/Cargo.toml | 5 +- packages/andromeda-app/src/app.rs | 197 +++++++- .../src/rate_limiting_withdrawals.rs | 2 +- .../src/cw20_exchange.rs | 5 +- .../src/cw20_staking.rs | 3 - .../src/auction.rs | 10 +- .../src/crowdfund.rs | 7 +- .../src/marketplace.rs | 8 +- packages/andromeda-testing/src/mock.rs | 56 ++- .../andromeda-testing/src/mock_contract.rs | 16 +- packages/std/Cargo.toml | 5 +- packages/std/src/ado_base/mod.rs | 4 +- packages/std/src/ado_base/permissioning.rs | 5 + packages/std/src/ado_contract/execute.rs | 63 ++- packages/std/src/ado_contract/ownership.rs | 8 + packages/std/src/amp/addresses.rs | 3 +- packages/std/src/common/expiration.rs | 42 +- packages/std/src/error.rs | 8 +- packages/std/src/os/aos_querier.rs | 8 +- packages/std/src/os/vfs.rs | 23 +- packages/std/src/testing/mock_querier.rs | 39 +- tests-integration/Cargo.toml | 8 +- tests-integration/tests/auction_app.rs | 118 +++-- tests-integration/tests/crowdfund_app.rs | 110 ++--- tests-integration/tests/cw20_staking.rs | 168 ++----- tests-integration/tests/kernel.rs | 92 ++-- tests-integration/tests/lockdrop.rs | 68 ++- tests-integration/tests/marketplace_app.rs | 66 +-- tests-integration/tests/primtive.rs | 33 +- 208 files changed, 2395 insertions(+), 2020 deletions(-) create mode 100644 contracts/finance/andromeda-rate-limiting-withdrawals/schema/raw/response_to_account_details.json create mode 100644 contracts/finance/andromeda-rate-limiting-withdrawals/schema/raw/response_to_coin_allowance_details.json diff --git a/Cargo.lock b/Cargo.lock index 135e3f350..d6917cc24 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -50,6 +50,7 @@ dependencies = [ "andromeda-std", "cosmwasm-schema", "cosmwasm-std", + "cw-multi-test", "serde", ] @@ -453,6 +454,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-asset", + "cw-multi-test", "cw-storage-plus 1.2.0", "cw-utils 1.0.3", "cw2 1.1.2", diff --git a/contracts/app/andromeda-app-contract/schema/andromeda-app-contract.json b/contracts/app/andromeda-app-contract/schema/andromeda-app-contract.json index 0bc438e35..16dd2ccfe 100644 --- a/contracts/app/andromeda-app-contract/schema/andromeda-app-contract.json +++ b/contracts/app/andromeda-app-contract/schema/andromeda-app-contract.json @@ -45,7 +45,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AppComponent": { "type": "object", @@ -467,7 +467,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AppComponent": { "type": "object", @@ -1132,7 +1132,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } }, @@ -1253,7 +1253,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AppComponent": { "type": "object", @@ -1334,7 +1334,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/app/andromeda-app-contract/schema/raw/execute.json b/contracts/app/andromeda-app-contract/schema/raw/execute.json index b1645b208..cdadb08a6 100644 --- a/contracts/app/andromeda-app-contract/schema/raw/execute.json +++ b/contracts/app/andromeda-app-contract/schema/raw/execute.json @@ -348,7 +348,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AppComponent": { "type": "object", diff --git a/contracts/app/andromeda-app-contract/schema/raw/instantiate.json b/contracts/app/andromeda-app-contract/schema/raw/instantiate.json index 7aaa9e3ff..c4f55b95c 100644 --- a/contracts/app/andromeda-app-contract/schema/raw/instantiate.json +++ b/contracts/app/andromeda-app-contract/schema/raw/instantiate.json @@ -41,7 +41,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AppComponent": { "type": "object", diff --git a/contracts/app/andromeda-app-contract/schema/raw/query.json b/contracts/app/andromeda-app-contract/schema/raw/query.json index 95ebd4af0..ccb4241b4 100644 --- a/contracts/app/andromeda-app-contract/schema/raw/query.json +++ b/contracts/app/andromeda-app-contract/schema/raw/query.json @@ -261,7 +261,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } } diff --git a/contracts/app/andromeda-app-contract/schema/raw/response_to_get_addresses_with_names.json b/contracts/app/andromeda-app-contract/schema/raw/response_to_get_addresses_with_names.json index 5f08da62b..85570290c 100644 --- a/contracts/app/andromeda-app-contract/schema/raw/response_to_get_addresses_with_names.json +++ b/contracts/app/andromeda-app-contract/schema/raw/response_to_get_addresses_with_names.json @@ -9,7 +9,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AppComponent": { "type": "object", diff --git a/contracts/app/andromeda-app-contract/schema/raw/response_to_get_components.json b/contracts/app/andromeda-app-contract/schema/raw/response_to_get_components.json index 11a1b4695..18971adc0 100644 --- a/contracts/app/andromeda-app-contract/schema/raw/response_to_get_components.json +++ b/contracts/app/andromeda-app-contract/schema/raw/response_to_get_components.json @@ -23,7 +23,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/app/andromeda-app-contract/src/contract.rs b/contracts/app/andromeda-app-contract/src/contract.rs index dc1f8d397..9588117c1 100644 --- a/contracts/app/andromeda-app-contract/src/contract.rs +++ b/contracts/app/andromeda-app-contract/src/contract.rs @@ -1,9 +1,6 @@ use crate::reply::on_component_instantiation; -use crate::state::{create_cross_chain_message, get_chain_info, APP_NAME}; -use andromeda_app::app::{ - AppComponent, ComponentType, CrossChainComponent, ExecuteMsg, InstantiateMsg, MigrateMsg, - QueryMsg, -}; +use crate::state::{add_app_component, create_cross_chain_message, ADO_ADDRESSES, APP_NAME}; +use andromeda_app::app::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; use andromeda_std::ado_contract::ADOContract; use andromeda_std::amp::AndrAddr; use andromeda_std::common::context::ExecuteContext; @@ -17,8 +14,8 @@ use andromeda_std::{ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - ensure, to_json_binary, Binary, CosmosMsg, Deps, DepsMut, Empty, Env, MessageInfo, Reply, - Response, StdError, SubMsg, WasmMsg, + ensure, wasm_execute, Addr, Binary, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdError, + SubMsg, }; use cw2::{get_contract_version, set_contract_version}; @@ -36,7 +33,6 @@ pub fn instantiate( info: MessageInfo, msg: InstantiateMsg, ) -> Result { - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; APP_NAME.save(deps.storage, &msg.name)?; ensure!( @@ -50,85 +46,95 @@ pub fn instantiate( deps.storage, env.clone(), deps.api, + &deps.querier, info.clone(), BaseInstantiateMsg { - ado_type: "app-contract".to_string(), + ado_type: CONTRACT_NAME.to_string(), ado_version: CONTRACT_VERSION.to_string(), - kernel_address: msg.kernel_address.clone(), owner: msg.owner.clone(), }, )? - .add_attribute("owner", msg.owner.clone().unwrap_or(sender.clone())) .add_attribute("andr_app", msg.name.clone()); - let mut msgs: Vec = vec![]; - let app_name = msg.name; + let vfs_address = ADOContract::default().get_vfs_address(deps.storage, &deps.querier)?; + let adodb_addr = ADOContract::default().get_adodb_address(deps.storage, &deps.querier)?; + + let mut vfs_msgs: Vec = vec![]; + for component in msg.app_components.clone() { + ensure!( + !ADO_ADDRESSES.has(deps.storage, &component.name), + ContractError::NameAlreadyTaken {} + ); component.verify(&deps.as_ref()).unwrap(); - match component.component_type { - ComponentType::CrossChain(CrossChainComponent { chain, .. }) => { - let chain_info = get_chain_info(chain.clone(), msg.chain_info.clone()); - ensure!( - chain_info.is_some(), - ContractError::InvalidComponent { - name: component.name.clone() - } - ); - let owner_addr = chain_info.unwrap().owner; - let name = component.name; - let new_component = AppComponent { - name: name.clone(), - ado_type: component.ado_type, - component_type: ComponentType::Symlink(AndrAddr::from_string(format!( - "ibc://{chain}/home/{owner_addr}/{app_name}/{name}" - ))), - }; - let comp_resp = execute::handle_add_app_component( - &deps.querier, - deps.storage, - &sender, - new_component, - )?; - msgs.extend(comp_resp.messages); - } - _ => { - let comp_resp = execute::handle_add_app_component( - &deps.querier, - deps.storage, - &sender, - component, - )?; - msgs.extend(comp_resp.messages); - } + + // Generate addresses and store expected address in state + let new_addr = component.get_new_addr( + deps.api, + &adodb_addr, + &deps.querier, + env.contract.address.clone(), + )?; + ADO_ADDRESSES.save( + deps.storage, + &component.name, + &new_addr.clone().unwrap_or(Addr::unchecked("")), + )?; + + // Register components with VFS + // Sub message is optional as component may be hidden (Starts with a '.') + let register_submsg = component.generate_vfs_registration( + new_addr.clone(), + &env.contract.address, + &msg.name, + msg.chain_info.clone(), + &adodb_addr, + &vfs_address, + )?; + + if let Some(register_submsg) = register_submsg { + vfs_msgs.push(register_submsg); + } + + let event = component.generate_event(new_addr); + resp = resp.add_event(event); + } + + let mut inst_msgs = vec![]; + + // This is done in a separate loop to ensure ordering, VFS registration first then instantiation after + for component in msg.app_components.clone() { + // Generate an ID for the component to help with tracking + let idx = add_app_component(deps.storage, &component)?; + + // Generate an instantiation message if required + let inst_msg = component.generate_instantiation_message( + &deps.querier, + &adodb_addr, + &env.contract.address, + &sender, + idx, + )?; + + if let Some(inst_msg) = inst_msg { + inst_msgs.push(inst_msg) } } - let vfs_address = ADOContract::default().get_vfs_address(deps.storage, &deps.querier)?; + // Register app under parent + let app_name = msg.name; let add_path_msg = VFSExecuteMsg::AddChild { name: convert_component_name(&app_name), parent_address: AndrAddr::from_string(sender), }; - let cosmos_msg: CosmosMsg = CosmosMsg::Wasm(WasmMsg::Execute { - contract_addr: vfs_address.to_string(), - msg: to_json_binary(&add_path_msg)?, - funds: vec![], - }); - + let cosmos_msg = wasm_execute(vfs_address.to_string(), &add_path_msg, vec![])?; let register_msg = SubMsg::reply_on_error(cosmos_msg, ReplyId::RegisterPath.repr()); - let assign_app_msg = ExecuteMsg::AssignAppToComponents {}; - let assign_app_msg = SubMsg::reply_on_error( - CosmosMsg::Wasm::(WasmMsg::Execute { - contract_addr: env.contract.address.to_string(), - msg: to_json_binary(&assign_app_msg)?, - funds: vec![], - }), - ReplyId::AssignApp.repr(), - ); + resp = resp .add_submessage(register_msg) - .add_submessages(msgs) - .add_submessage(assign_app_msg); + .add_submessages(vfs_msgs) + .add_submessages(inst_msgs); if let Some(chain_info) = msg.chain_info { for chain in chain_info.clone() { @@ -183,6 +189,8 @@ pub fn handle_execute(ctx: ExecuteContext, msg: ExecuteMsg) -> Result execute::handle_add_app_component( &ctx.deps.querier, ctx.deps.storage, + ctx.deps.api, + ctx.env, ctx.info.sender.as_str(), component, ), diff --git a/contracts/app/andromeda-app-contract/src/execute.rs b/contracts/app/andromeda-app-contract/src/execute.rs index 5989a1774..3b7c2ec12 100644 --- a/contracts/app/andromeda-app-contract/src/execute.rs +++ b/contracts/app/andromeda-app-contract/src/execute.rs @@ -1,6 +1,6 @@ use crate::state::{ add_app_component, generate_assign_app_message, generate_ownership_message, - load_component_addresses, ADO_ADDRESSES, + load_component_addresses, ADO_ADDRESSES, APP_NAME, }; use andromeda_app::app::{AppComponent, ComponentType}; use andromeda_std::common::{context::ExecuteContext, reply::ReplyId}; @@ -10,102 +10,72 @@ use andromeda_std::os::vfs::ExecuteMsg as VFSExecuteMsg; use andromeda_std::{ado_contract::ADOContract, amp::AndrAddr}; use cosmwasm_std::{ - ensure, to_json_binary, Addr, Binary, CosmosMsg, Order, QuerierWrapper, ReplyOn, Response, + ensure, to_json_binary, Addr, Api, Binary, CosmosMsg, Env, QuerierWrapper, ReplyOn, Response, Storage, SubMsg, WasmMsg, }; pub fn handle_add_app_component( querier: &QuerierWrapper, storage: &mut dyn Storage, + api: &dyn Api, + env: Env, sender: &str, component: AppComponent, ) -> Result { + ensure!( + !matches!(component.component_type, ComponentType::CrossChain(..)), + ContractError::CrossChainComponentsCurrentlyDisabled {} + ); let contract = ADOContract::default(); ensure!( contract.is_contract_owner(storage, sender)?, ContractError::Unauthorized {} ); - let amount = ADO_ADDRESSES - .keys(storage, None, None, Order::Ascending) - .count(); - ensure!(amount < 50, ContractError::TooManyAppComponents {}); - - let current_addr = ADO_ADDRESSES.may_load(storage, &component.name)?; - ensure!(current_addr.is_none(), ContractError::NameAlreadyTaken {}); - let idx = add_app_component(storage, &component)?; + ensure!(idx < 50, ContractError::TooManyAppComponents {}); + + let adodb_addr = ADOContract::default().get_adodb_address(storage, querier)?; + let vfs_addr = ADOContract::default().get_vfs_address(storage, querier)?; let mut resp = Response::new() .add_attribute("method", "add_app_component") .add_attribute("name", component.name.clone()) .add_attribute("type", component.ado_type.clone()); - match component.component_type { - ComponentType::New(instantiate_msg) => { - let inst_msg = generate_instantiate_msg( - storage, - querier, - idx, - instantiate_msg, - component.ado_type.clone(), - sender.to_string(), - )?; - resp = resp.add_submessage(inst_msg); - ADO_ADDRESSES.save(storage, &component.name, &Addr::unchecked(""))?; - } - ComponentType::Symlink(symlink) => { - let msg = VFSExecuteMsg::AddSymlink { - name: component.name, - symlink, - parent_address: None, - }; - let cosmos_msg = CosmosMsg::Wasm(WasmMsg::Execute { - contract_addr: AOSQuerier::vfs_address_getter( - querier, - &contract.get_kernel_address(storage)?, - )? - .to_string(), - msg: to_json_binary(&msg)?, - funds: vec![], - }); - let sub_msg = SubMsg::reply_on_error(cosmos_msg, ReplyId::RegisterPath.repr()); - resp = resp.add_submessage(sub_msg); - } - _ => return Err(ContractError::Unauthorized {}), + let app_name = APP_NAME.load(storage)?; + let new_addr = + component.get_new_addr(api, &adodb_addr, querier, env.contract.address.clone())?; + let registration_msg = component.generate_vfs_registration( + new_addr.clone(), + &env.contract.address, + &app_name, + // TODO: Fix this in future for x-chain components + None, + &adodb_addr, + &vfs_addr, + )?; + + if let Some(registration_msg) = registration_msg { + resp = resp.add_submessage(registration_msg); } - Ok(resp) -} + let inst_msg = component.generate_instantiation_message( + querier, + &adodb_addr, + &env.contract.address, + sender, + idx, + )?; -fn generate_instantiate_msg( - storage: &mut dyn Storage, - querier: &QuerierWrapper, - msg_id: u64, - msg: Binary, - ado_type: String, - sender: String, -) -> Result { - let adodb_addr = ADOContract::default().get_adodb_address(storage, querier)?; - match AOSQuerier::code_id_getter(querier, &adodb_addr, &ado_type) { - Err(_) => Err(ContractError::InvalidModule { - msg: Some(String::from( - "ADO type provided does not have a valid Code Id", - )), - }), - Ok(code_id) => Ok(SubMsg { - id: msg_id, - reply_on: ReplyOn::Always, - msg: CosmosMsg::Wasm(WasmMsg::Instantiate { - admin: Some(sender), - code_id, - msg, - funds: vec![], - label: format!("Instantiate: {ado_type}"), - }), - gas_limit: None, - }), + if let Some(inst_msg) = inst_msg { + resp = resp.add_submessage(inst_msg); } + + let event = component.generate_event(new_addr); + resp = resp.add_event(event); + + Ok(resp) } pub fn claim_ownership( diff --git a/contracts/app/andromeda-app-contract/src/reply.rs b/contracts/app/andromeda-app-contract/src/reply.rs index a7651f507..c9e5259c2 100644 --- a/contracts/app/andromeda-app-contract/src/reply.rs +++ b/contracts/app/andromeda-app-contract/src/reply.rs @@ -1,9 +1,6 @@ -use andromeda_std::{ - ado_contract::ADOContract, common::response::get_reply_address, error::ContractError, -}; -use cosmwasm_std::{DepsMut, Reply, Response}; +use andromeda_std::{common::response::get_reply_address, error::ContractError}; +use cosmwasm_std::{ensure_eq, Addr, DepsMut, Reply, Response}; -use crate::execute; use crate::state::{ADO_ADDRESSES, ADO_DESCRIPTORS}; pub fn on_component_instantiation(deps: DepsMut, msg: Reply) -> Result { @@ -13,21 +10,17 @@ pub fn on_component_instantiation(deps: DepsMut, msg: Reply) -> Result, ) -> Result, ContractError> { - let min = Some(Bound::inclusive(min.unwrap_or("1"))); + let min = Some(Bound::inclusive(min.unwrap_or("0"))); let addresses: Vec = ADO_ADDRESSES .range(storage, min, None, Order::Ascending) .flatten() diff --git a/contracts/app/andromeda-app-contract/src/testing/mod.rs b/contracts/app/andromeda-app-contract/src/testing/mod.rs index 722bd1737..1dcc1a60e 100644 --- a/contracts/app/andromeda-app-contract/src/testing/mod.rs +++ b/contracts/app/andromeda-app-contract/src/testing/mod.rs @@ -1,11 +1,11 @@ -use crate::state::ADO_DESCRIPTORS; +use crate::state::{ADO_DESCRIPTORS, ADO_IDX}; use super::{contract::*, state::ADO_ADDRESSES}; use andromeda_app::app::{AppComponent, ComponentType, ExecuteMsg, InstantiateMsg}; use andromeda_std::ado_base::ownership::OwnershipMessage; -use andromeda_std::amp::AndrAddr; -use andromeda_std::common::reply::ReplyId; -use andromeda_std::os::vfs::{convert_component_name, ExecuteMsg as VFSExecuteMsg}; +// use andromeda_std::amp::AndrAddr; +// use andromeda_std::common::reply::ReplyId; +// use andromeda_std::os::vfs::{convert_component_name, ExecuteMsg as VFSExecuteMsg}; use andromeda_std::testing::mock_querier::{ mock_dependencies_custom, MOCK_ANCHOR_CONTRACT, MOCK_CW20_CONTRACT, MOCK_KERNEL_CONTRACT, }; @@ -34,111 +34,113 @@ fn test_empty_instantiation() { // we can just call .unwrap() to assert this was a success let res = instantiate(deps.as_mut(), mock_env(), info, msg).unwrap(); - assert_eq!(2, res.messages.len()); + assert_eq!(1, res.messages.len()); } -#[test] -fn test_instantiation() { - let mut deps = mock_dependencies_custom(&[]); +//TODO: Fix post CosmWasm 2.0 - let msg = InstantiateMsg { - app_components: vec![AppComponent { - name: "token".to_string(), - ado_type: "cw721".to_string(), - component_type: ComponentType::New(to_json_binary(&true).unwrap()), - }], - name: String::from("Some App"), - kernel_address: MOCK_KERNEL_CONTRACT.to_string(), - owner: None, - chain_info: None, - }; - let info = mock_info("creator", &[]); - - let res = instantiate(deps.as_mut(), mock_env(), info.clone(), msg).unwrap(); - assert_eq!(3, res.messages.len()); - let inst_submsg: SubMsg = SubMsg { - id: 1, - msg: CosmosMsg::Wasm(WasmMsg::Instantiate { - code_id: 1, - msg: to_json_binary(&true).unwrap(), - funds: vec![], - label: "Instantiate: cw721".to_string(), - admin: Some("creator".to_string()), - }), - reply_on: ReplyOn::Always, - gas_limit: None, - }; - let sender = info.sender; - let register_submsg: SubMsg = SubMsg { - id: ReplyId::RegisterPath.repr(), - msg: CosmosMsg::Wasm(WasmMsg::Execute { - contract_addr: "vfs_contract".to_string(), - msg: to_json_binary(&VFSExecuteMsg::AddChild { - name: convert_component_name("Some App"), - parent_address: AndrAddr::from_string(format!("{sender}")), - }) - .unwrap(), - funds: vec![], - }), - reply_on: ReplyOn::Error, - gas_limit: None, - }; - let assign_msg: SubMsg = SubMsg { - id: ReplyId::AssignApp.repr(), - msg: CosmosMsg::Wasm(WasmMsg::Execute { - contract_addr: "cosmos2contract".to_string(), - msg: to_json_binary(&ExecuteMsg::AssignAppToComponents {}).unwrap(), - funds: vec![], - }), - reply_on: ReplyOn::Error, - gas_limit: None, - }; - let expected = Response::new() - .add_submessage(register_submsg) - .add_submessage(inst_submsg) - .add_submessage(assign_msg) - .add_attributes(vec![ - attr("method", "instantiate"), - attr("type", "app-contract"), - attr("owner", "creator"), - attr("andr_app", "Some App"), - ]); - - assert_eq!(expected, res); +// #[test] +// fn test_instantiation() { +// let mut deps = mock_dependencies_custom(&[]); - assert_eq!( - Addr::unchecked(""), - ADO_ADDRESSES.load(deps.as_ref().storage, "token").unwrap() - ); -} +// let msg = InstantiateMsg { +// app_components: vec![AppComponent { +// name: "token".to_string(), +// ado_type: "cw721".to_string(), +// component_type: ComponentType::New(to_json_binary(&true).unwrap()), +// }], +// name: String::from("Some App"), +// kernel_address: MOCK_KERNEL_CONTRACT.to_string(), +// owner: None, +// chain_info: None, +// }; +// let info = mock_info("creator", &[]); + +// let res = instantiate(deps.as_mut(), mock_env(), info.clone(), msg).unwrap(); +// assert_eq!(3, res.messages.len()); +// let inst_submsg: SubMsg = SubMsg { +// id: 1, +// msg: CosmosMsg::Wasm(WasmMsg::Instantiate { +// code_id: 1, +// msg: to_json_binary(&true).unwrap(), +// funds: vec![], +// label: "Instantiate: cw721".to_string(), +// admin: Some("creator".to_string()), +// }), +// reply_on: ReplyOn::Always, +// gas_limit: None, +// }; +// let sender = info.sender; +// let register_submsg: SubMsg = SubMsg { +// id: ReplyId::RegisterPath.repr(), +// msg: CosmosMsg::Wasm(WasmMsg::Execute { +// contract_addr: "vfs_contract".to_string(), +// msg: to_json_binary(&VFSExecuteMsg::AddChild { +// name: convert_component_name("Some App"), +// parent_address: AndrAddr::from_string(format!("{sender}")), +// }) +// .unwrap(), +// funds: vec![], +// }), +// reply_on: ReplyOn::Error, +// gas_limit: None, +// }; +// let assign_msg: SubMsg = SubMsg { +// id: ReplyId::AssignApp.repr(), +// msg: CosmosMsg::Wasm(WasmMsg::Execute { +// contract_addr: "cosmos2contract".to_string(), +// msg: to_json_binary(&ExecuteMsg::AssignAppToComponents {}).unwrap(), +// funds: vec![], +// }), +// reply_on: ReplyOn::Error, +// gas_limit: None, +// }; +// let expected = Response::new() +// .add_submessage(register_submsg) +// .add_submessage(inst_submsg) +// .add_submessage(assign_msg) +// .add_attributes(vec![ +// attr("method", "instantiate"), +// attr("type", "app-contract"), +// attr("owner", "creator"), +// attr("andr_app", "Some App"), +// ]); + +// assert_eq!(expected, res); + +// assert_eq!( +// Addr::unchecked(""), +// ADO_ADDRESSES.load(deps.as_ref().storage, "token").unwrap() +// ); +// } -#[test] -fn test_instantiation_duplicate_components() { - let mut deps = mock_dependencies_custom(&[]); +// #[test] +// fn test_instantiation_duplicate_components() { +// let mut deps = mock_dependencies_custom(&[]); - let msg = InstantiateMsg { - app_components: vec![ - AppComponent { - name: "component".to_string(), - ado_type: "cw721".to_string(), - component_type: ComponentType::New(to_json_binary(&true).unwrap()), - }, - AppComponent { - name: "component".to_string(), - ado_type: "cw20".to_string(), - component_type: ComponentType::New(to_json_binary(&true).unwrap()), - }, - ], - name: String::from("Some App"), - kernel_address: MOCK_KERNEL_CONTRACT.to_string(), - owner: None, - chain_info: None, - }; - let info = mock_info("creator", &[]); +// let msg = InstantiateMsg { +// app_components: vec![ +// AppComponent { +// name: "component".to_string(), +// ado_type: "cw721".to_string(), +// component_type: ComponentType::New(to_json_binary(&true).unwrap()), +// }, +// AppComponent { +// name: "component".to_string(), +// ado_type: "cw20".to_string(), +// component_type: ComponentType::New(to_json_binary(&true).unwrap()), +// }, +// ], +// name: String::from("Some App"), +// kernel_address: MOCK_KERNEL_CONTRACT.to_string(), +// owner: None, +// chain_info: None, +// }; +// let info = mock_info("creator", &[]); - let res = instantiate(deps.as_mut(), mock_env(), info, msg); - assert_eq!(ContractError::NameAlreadyTaken {}, res.unwrap_err()); -} +// let res = instantiate(deps.as_mut(), mock_env(), info, msg); +// assert_eq!(ContractError::NameAlreadyTaken {}, res.unwrap_err()); +// } #[test] fn test_add_app_component_unauthorized() { @@ -168,96 +170,96 @@ fn test_add_app_component_unauthorized() { assert_eq!(ContractError::Unauthorized {}, err); } -#[test] -fn test_add_app_component_duplicate_name() { - let mut deps = mock_dependencies_custom(&[]); - let env = mock_env(); - let info = mock_info("creator", &[]); - let inst_msg = InstantiateMsg { - app_components: vec![AppComponent { - name: "token".to_string(), - ado_type: "cw721".to_string(), - component_type: ComponentType::New(to_json_binary(&true).unwrap()), - }], - name: String::from("Some App"), - kernel_address: MOCK_KERNEL_CONTRACT.to_string(), - owner: None, - chain_info: None, - }; - - instantiate(deps.as_mut(), env.clone(), info.clone(), inst_msg).unwrap(); - ADO_ADDRESSES - .save( - deps.as_mut().storage, - "token", - &Addr::unchecked("someaddress"), - ) - .unwrap(); - - let msg = ExecuteMsg::AddAppComponent { - component: AppComponent { - name: "token".to_string(), - ado_type: "cw721".to_string(), - component_type: ComponentType::New(to_json_binary(&true).unwrap()), - }, - }; +// #[test] +// fn test_add_app_component_duplicate_name() { +// let mut deps = mock_dependencies_custom(&[]); +// let env = mock_env(); +// let info = mock_info("creator", &[]); +// let inst_msg = InstantiateMsg { +// app_components: vec![AppComponent { +// name: "token".to_string(), +// ado_type: "cw721".to_string(), +// component_type: ComponentType::New(to_json_binary(&true).unwrap()), +// }], +// name: String::from("Some App"), +// kernel_address: MOCK_KERNEL_CONTRACT.to_string(), +// owner: None, +// chain_info: None, +// }; - let err = execute(deps.as_mut(), env, info, msg).unwrap_err(); - assert_eq!(ContractError::NameAlreadyTaken {}, err); -} +// instantiate(deps.as_mut(), env.clone(), info.clone(), inst_msg).unwrap(); +// ADO_ADDRESSES +// .save( +// deps.as_mut().storage, +// "token", +// &Addr::unchecked("someaddress"), +// ) +// .unwrap(); -#[test] -fn test_add_app_component() { - let mut deps = mock_dependencies_custom(&[]); - let env = mock_env(); - let info = mock_info("creator", &[]); - let inst_msg = InstantiateMsg { - app_components: vec![], - name: String::from("Some App"), - kernel_address: MOCK_KERNEL_CONTRACT.to_string(), - owner: None, - chain_info: None, - }; +// let msg = ExecuteMsg::AddAppComponent { +// component: AppComponent { +// name: "token".to_string(), +// ado_type: "cw721".to_string(), +// component_type: ComponentType::New(to_json_binary(&true).unwrap()), +// }, +// }; - instantiate(deps.as_mut(), env.clone(), info.clone(), inst_msg).unwrap(); +// let err = execute(deps.as_mut(), env, info, msg).unwrap_err(); +// assert_eq!(ContractError::NameAlreadyTaken {}, err); +// } - let msg = ExecuteMsg::AddAppComponent { - component: AppComponent { - name: "token".to_string(), - ado_type: "cw721".to_string(), - component_type: ComponentType::New(to_json_binary(&true).unwrap()), - }, - }; +// #[test] +// fn test_add_app_component() { +// let mut deps = mock_dependencies_custom(&[]); +// let env = mock_env(); +// let info = mock_info("creator", &[]); +// let inst_msg = InstantiateMsg { +// app_components: vec![], +// name: String::from("Some App"), +// kernel_address: MOCK_KERNEL_CONTRACT.to_string(), +// owner: None, +// chain_info: None, +// }; - let res = execute(deps.as_mut(), env, info, msg).unwrap(); - assert_eq!(1, res.messages.len()); - let inst_submsg: SubMsg = SubMsg { - id: 1, - msg: CosmosMsg::Wasm(WasmMsg::Instantiate { - code_id: 1, - msg: to_json_binary(&true).unwrap(), - funds: vec![], - label: "Instantiate: cw721".to_string(), - admin: Some("creator".to_string()), - }), - reply_on: ReplyOn::Always, - gas_limit: None, - }; - let expected = Response::new() - .add_submessage(inst_submsg) - .add_attributes(vec![ - attr("method", "add_app_component"), - attr("name", "token"), - attr("type", "cw721"), - ]); +// instantiate(deps.as_mut(), env.clone(), info.clone(), inst_msg).unwrap(); - assert_eq!(expected, res); +// let msg = ExecuteMsg::AddAppComponent { +// component: AppComponent { +// name: "token".to_string(), +// ado_type: "cw721".to_string(), +// component_type: ComponentType::New(to_json_binary(&true).unwrap()), +// }, +// }; - assert_eq!( - Addr::unchecked(""), - ADO_ADDRESSES.load(deps.as_ref().storage, "token").unwrap() - ); -} +// let res = execute(deps.as_mut(), env, info, msg).unwrap(); +// assert_eq!(1, res.messages.len()); +// // let inst_submsg: SubMsg = SubMsg { +// // id: 1, +// // msg: CosmosMsg::Wasm(WasmMsg::Instantiate { +// // code_id: 1, +// // msg: to_json_binary(&true).unwrap(), +// // funds: vec![], +// // label: "Instantiate: cw721".to_string(), +// // admin: Some("creator".to_string()), +// // }), +// // reply_on: ReplyOn::Always, +// // gas_limit: None, +// // }; +// // let expected = Response::new() +// // .add_submessage(inst_submsg) +// // .add_attributes(vec![ +// // attr("method", "add_app_component"), +// // attr("name", "token"), +// // attr("type", "cw721"), +// // ]); + +// // assert_eq!(expected, res); + +// // assert_eq!( +// // Addr::unchecked(""), +// // ADO_ADDRESSES.load(deps.as_ref().storage, "token").unwrap() +// // ); +// } #[test] fn test_claim_ownership_unauth() { @@ -653,6 +655,7 @@ fn test_add_app_component_limit() { .save(deps.as_mut().storage, &i.to_string(), &Addr::unchecked("")) .unwrap(); } + ADO_IDX.save(deps.as_mut().storage, &50).unwrap(); let msg = ExecuteMsg::AddAppComponent { component: AppComponent { @@ -666,24 +669,6 @@ fn test_add_app_component_limit() { assert_eq!(ContractError::TooManyAppComponents {}, err); } -// TODO: UPDATE WITH 1.2 CHANGES -// #[test] -// fn test_reply_assign_app() { -// let mut deps = mock_dependencies_custom(&[]); -// let env = mock_env(); -// let mock_app_component = AppComponent { -// ado_type: "cw721".to_string(), -// name: "token".to_string(), -// instantiate_msg: to_json_binary(&true).unwrap(), -// }; -// let component_idx = 1; -// ADO_DESCRIPTORS -// .save( -// deps.as_mut().storage, -// &component_idx.to_string(), -// &mock_app_component, -// ) -// .unwrap(); #[test] fn test_reply_assign_app() { let mut deps = mock_dependencies_custom(&[]); @@ -701,22 +686,19 @@ fn test_reply_assign_app() { &mock_app_component, ) .unwrap(); + ADO_ADDRESSES + .save( + deps.as_mut().storage, + &mock_app_component.name, + &Addr::unchecked("cosmos2contract"), + ) + .unwrap(); let mock_reply_event = Event::new("instantiate").add_attribute( "contract_address".to_string(), "cosmos2contract".to_string(), ); - // let instantiate_reply = MsgInstantiateContractResponse { - // contract_address: "tokenaddress".to_string(), - // data: vec![], - // }; - // let mut encoded_instantiate_reply = Vec::::with_capacity(instantiate_reply.encoded_len()); - - // instantiate_reply - // .encode(&mut encoded_instantiate_reply) - // .unwrap(); - let reply_resp = "Cg9jb3Ntb3MyY29udHJhY3QSAA=="; let mock_reply = Reply { id: component_idx, @@ -726,44 +708,6 @@ fn test_reply_assign_app() { }), }; - let res = reply(deps.as_mut(), env.clone(), mock_reply).unwrap(); - assert_eq!(1, res.messages.len()); - - // let exec_submsg: SubMsg = SubMsg { - // id: 103, - // msg: CosmosMsg::Wasm(WasmMsg::Execute { - // contract_addr: "tokenaddress".to_string(), - // msg: to_json_binary(&AndromedaMsg::UpdateAppContract { - // address: env.contract.address.to_string(), - // }) - // .unwrap(), - // funds: vec![], - // }), - // reply_on: ReplyOn::Error, - // gas_limit: None, - // }; - let new_exec_submsg: SubMsg = SubMsg { - id: 202, - msg: CosmosMsg::Wasm(WasmMsg::Execute { - contract_addr: "vfs_contract".to_string(), - msg: to_json_binary(&VFSExecuteMsg::AddPath { - address: env.contract.address, - name: "token".to_string(), - parent_address: None, - }) - .unwrap(), - funds: vec![], - }), - reply_on: ReplyOn::Error, - gas_limit: None, - }; - // let expected = Response::new().add_submessage(exec_submsg); - let new_expected = Response::new().add_submessage(new_exec_submsg); - - assert_eq!(new_expected, res); - - assert_eq!( - Addr::unchecked("cosmos2contract"), - ADO_ADDRESSES.load(deps.as_ref().storage, "token").unwrap() - ); + let res = reply(deps.as_mut(), env, mock_reply).unwrap(); + assert!(res.messages.is_empty()); } diff --git a/contracts/data-storage/andromeda-primitive/schema/andromeda-primitive.json b/contracts/data-storage/andromeda-primitive/schema/andromeda-primitive.json index db8fa7c65..75c8b998c 100644 --- a/contracts/data-storage/andromeda-primitive/schema/andromeda-primitive.json +++ b/contracts/data-storage/andromeda-primitive/schema/andromeda-primitive.json @@ -342,7 +342,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -1075,7 +1075,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AndromedaHook": { "oneOf": [ diff --git a/contracts/data-storage/andromeda-primitive/schema/raw/execute.json b/contracts/data-storage/andromeda-primitive/schema/raw/execute.json index 577df7c42..cf4bbb560 100644 --- a/contracts/data-storage/andromeda-primitive/schema/raw/execute.json +++ b/contracts/data-storage/andromeda-primitive/schema/raw/execute.json @@ -304,7 +304,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/data-storage/andromeda-primitive/schema/raw/query.json b/contracts/data-storage/andromeda-primitive/schema/raw/query.json index a47743545..c09c04ed3 100644 --- a/contracts/data-storage/andromeda-primitive/schema/raw/query.json +++ b/contracts/data-storage/andromeda-primitive/schema/raw/query.json @@ -247,7 +247,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AndromedaHook": { "oneOf": [ diff --git a/contracts/data-storage/andromeda-primitive/src/contract.rs b/contracts/data-storage/andromeda-primitive/src/contract.rs index b1712d83b..6e89decca 100644 --- a/contracts/data-storage/andromeda-primitive/src/contract.rs +++ b/contracts/data-storage/andromeda-primitive/src/contract.rs @@ -34,9 +34,10 @@ pub fn instantiate( deps.storage, env, deps.api, + &deps.querier, info, BaseInstantiateMsg { - ado_type: "primitive".to_string(), + ado_type: CONTRACT_NAME.to_string(), ado_version: CONTRACT_VERSION.to_string(), kernel_address: msg.kernel_address, owner: msg.owner, diff --git a/contracts/ecosystem/andromeda-vault/schema/andromeda-vault.json b/contracts/ecosystem/andromeda-vault/schema/andromeda-vault.json index 6d34ddb8c..24b78e4cc 100644 --- a/contracts/ecosystem/andromeda-vault/schema/andromeda-vault.json +++ b/contracts/ecosystem/andromeda-vault/schema/andromeda-vault.json @@ -395,7 +395,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -1082,7 +1082,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "StrategyType": { "type": "string", diff --git a/contracts/ecosystem/andromeda-vault/schema/raw/execute.json b/contracts/ecosystem/andromeda-vault/schema/raw/execute.json index e7e3f0712..c4e88c4c9 100644 --- a/contracts/ecosystem/andromeda-vault/schema/raw/execute.json +++ b/contracts/ecosystem/andromeda-vault/schema/raw/execute.json @@ -371,7 +371,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/ecosystem/andromeda-vault/schema/raw/query.json b/contracts/ecosystem/andromeda-vault/schema/raw/query.json index 645e99882..81b5f6141 100644 --- a/contracts/ecosystem/andromeda-vault/schema/raw/query.json +++ b/contracts/ecosystem/andromeda-vault/schema/raw/query.json @@ -238,7 +238,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "StrategyType": { "type": "string", diff --git a/contracts/ecosystem/andromeda-vault/src/contract.rs b/contracts/ecosystem/andromeda-vault/src/contract.rs index 5888dc5e3..9518c74de 100644 --- a/contracts/ecosystem/andromeda-vault/src/contract.rs +++ b/contracts/ecosystem/andromeda-vault/src/contract.rs @@ -10,7 +10,7 @@ use andromeda_std::amp::{AndrAddr, Recipient}; use andromeda_std::common::context::ExecuteContext; use andromeda_std::{ ado_base::withdraw::{Withdrawal, WithdrawalType}, - ado_base::{AndromedaQuery, InstantiateMsg as BaseInstantiateMsg}, + ado_base::InstantiateMsg as BaseInstantiateMsg, error::{from_semver, ContractError}, }; @@ -40,9 +40,10 @@ pub fn instantiate( deps.storage, env, deps.api, + &deps.querier, info, BaseInstantiateMsg { - ado_type: "vault".to_string(), + ado_type: CONTRACT_NAME.to_string(), ado_version: CONTRACT_VERSION.to_string(), owner: msg.owner, kernel_address: msg.kernel_address, @@ -435,10 +436,16 @@ fn query_balance( ) -> Result { if let Some(strategy) = strategy { let strategy_addr = STRATEGY_CONTRACT_ADDRESSES.load(deps.storage, strategy.to_string())?; + ensure!(false, ContractError::TemporarilyDisabled {}); // DEV NOTE: Why does this ensure! a generic type when not using custom query? + // let query: QueryRequest = QueryRequest::Wasm(WasmQuery::Smart { + // contract_addr: strategy_addr, + // msg: to_json_binary(&AndromedaQuery::WithdrawableBalance { address })?, + // }); + // TODO: Below code to be replaced with above code once WithdrawableBalance is re-enabled let query: QueryRequest = QueryRequest::Wasm(WasmQuery::Smart { contract_addr: strategy_addr, - msg: to_json_binary(&AndromedaQuery::WithdrawableBalance { address })?, + msg: to_json_binary(&Binary::default())?, }); match deps.querier.raw_query(&to_json_binary(&query)?) { SystemResult::Ok(ContractResult::Ok(value)) => Ok(value), diff --git a/contracts/ecosystem/andromeda-vault/src/testing/mock_querier.rs b/contracts/ecosystem/andromeda-vault/src/testing/mock_querier.rs index 05d467481..2b1801f00 100644 --- a/contracts/ecosystem/andromeda-vault/src/testing/mock_querier.rs +++ b/contracts/ecosystem/andromeda-vault/src/testing/mock_querier.rs @@ -1,19 +1,20 @@ use andromeda_std::ado_base::ownership::ContractOwnerResponse; +use andromeda_std::ado_base::AndromedaQuery; //use andromeda_ecosystem::anchor_earn::PositionResponse; use andromeda_std::testing::mock_querier::MockAndromedaQuerier; use andromeda_std::{ - ado_base::{AndromedaQuery, InstantiateMsg}, - ado_contract::ADOContract, - amp::Recipient, + ado_base::InstantiateMsg, ado_contract::ADOContract, amp::Recipient, testing::mock_querier::MOCK_KERNEL_CONTRACT, }; use cosmwasm_schema::cw_serde; +use cosmwasm_std::QuerierWrapper; use cosmwasm_std::{ from_json, testing::{mock_env, mock_info, MockApi, MockQuerier, MockStorage, MOCK_CONTRACT_ADDR}, - to_json_binary, Binary, Coin, ContractResult, OwnedDeps, Querier, QuerierResult, QueryRequest, - SystemError, SystemResult, Uint128, WasmQuery, + Coin, OwnedDeps, Querier, QuerierResult, QueryRequest, SystemError, SystemResult, Uint128, + WasmQuery, }; +use cosmwasm_std::{to_json_binary, Binary, ContractResult}; // This is here since anchor_earn is defunct now. #[cw_serde] @@ -45,6 +46,7 @@ pub fn mock_dependencies_custom( &mut deps.storage, mock_env(), &deps.api, + &QuerierWrapper::new(&deps.querier), mock_info("sender", &[]), InstantiateMsg { ado_type: "vault".to_string(), @@ -91,13 +93,13 @@ impl WasmMockQuerier { fn handle_anchor_balance_query(&self, msg: &Binary) -> QuerierResult { match from_json(msg).unwrap() { - AndromedaQuery::WithdrawableBalance { address } => { - let msg_response = PositionResponse { - recipient: Recipient::from_string(address), - aust_amount: Uint128::from(10u128), - }; - SystemResult::Ok(ContractResult::Ok(to_json_binary(&msg_response).unwrap())) - } + // AndromedaQuery::WithdrawableBalance { address } => { + // let msg_response = PositionResponse { + // recipient: Recipient::from_string(address), + // aust_amount: Uint128::from(10u128), + // }; + // SystemResult::Ok(ContractResult::Ok(to_json_binary(&msg_response).unwrap())) + // } AndromedaQuery::Owner {} => { let msg_response = ContractOwnerResponse { owner: MOCK_VAULT_CONTRACT.to_owned(), diff --git a/contracts/ecosystem/andromeda-vault/src/testing/mod.rs b/contracts/ecosystem/andromeda-vault/src/testing/mod.rs index bb3675840..3b08b09d4 100644 --- a/contracts/ecosystem/andromeda-vault/src/testing/mod.rs +++ b/contracts/ecosystem/andromeda-vault/src/testing/mod.rs @@ -2,7 +2,7 @@ mod mock_querier; use self::mock_querier::{MOCK_ANCHOR_CONTRACT, MOCK_VAULT_CONTRACT}; use crate::contract::*; -use crate::testing::mock_querier::{mock_dependencies_custom, PositionResponse}; +use crate::testing::mock_querier::mock_dependencies_custom; use andromeda_ecosystem::vault::{ DepositMsg, ExecuteMsg, InstantiateMsg, QueryMsg, StrategyAddressResponse, StrategyType, YieldStrategy, BALANCES, STRATEGY_CONTRACT_ADDRESSES, @@ -847,18 +847,21 @@ fn test_query_strategy_balance() { strategy: Some(StrategyType::Anchor), denom: None, }; - - let resp = query(deps.as_ref(), env, single_query).unwrap(); - let balance: PositionResponse = from_json(resp).unwrap(); - assert_eq!(Uint128::from(10u128), balance.aust_amount); - assert_eq!( - "depositor".to_string(), - balance - .recipient - .address - .get_raw_address(&deps.as_ref()) - .unwrap() - ); + let resp = query(deps.as_ref(), env, single_query).unwrap_err(); + assert_eq!(resp, ContractError::TemporarilyDisabled {}); + + // let resp = query(deps.as_ref(), env, single_query).unwrap(); + + // let balance: PositionResponse = from_json(resp).unwrap(); + // assert_eq!(Uint128::from(10u128), balance.aust_amount); + // assert_eq!( + // "depositor".to_string(), + // balance + // .recipient + // .address + // .get_raw_address(&deps.as_ref()) + // .unwrap() + // ); } #[test] diff --git a/contracts/finance/andromeda-cross-chain-swap/schema/andromeda-cross-chain-swap.json b/contracts/finance/andromeda-cross-chain-swap/schema/andromeda-cross-chain-swap.json index 637f8d984..7c59f9c94 100644 --- a/contracts/finance/andromeda-cross-chain-swap/schema/andromeda-cross-chain-swap.json +++ b/contracts/finance/andromeda-cross-chain-swap/schema/andromeda-cross-chain-swap.json @@ -59,7 +59,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -422,7 +422,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -1015,7 +1015,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } }, @@ -1130,7 +1130,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/finance/andromeda-cross-chain-swap/schema/raw/execute.json b/contracts/finance/andromeda-cross-chain-swap/schema/raw/execute.json index dc0550f13..6524c9724 100644 --- a/contracts/finance/andromeda-cross-chain-swap/schema/raw/execute.json +++ b/contracts/finance/andromeda-cross-chain-swap/schema/raw/execute.json @@ -310,7 +310,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/finance/andromeda-cross-chain-swap/schema/raw/instantiate.json b/contracts/finance/andromeda-cross-chain-swap/schema/raw/instantiate.json index 26231037a..6ead203e7 100644 --- a/contracts/finance/andromeda-cross-chain-swap/schema/raw/instantiate.json +++ b/contracts/finance/andromeda-cross-chain-swap/schema/raw/instantiate.json @@ -55,7 +55,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/finance/andromeda-cross-chain-swap/schema/raw/query.json b/contracts/finance/andromeda-cross-chain-swap/schema/raw/query.json index c2092822f..6e5e34e71 100644 --- a/contracts/finance/andromeda-cross-chain-swap/schema/raw/query.json +++ b/contracts/finance/andromeda-cross-chain-swap/schema/raw/query.json @@ -194,7 +194,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } } diff --git a/contracts/finance/andromeda-cross-chain-swap/schema/raw/response_to_get_splitter_config.json b/contracts/finance/andromeda-cross-chain-swap/schema/raw/response_to_get_splitter_config.json index f1e9946e3..4942b3e04 100644 --- a/contracts/finance/andromeda-cross-chain-swap/schema/raw/response_to_get_splitter_config.json +++ b/contracts/finance/andromeda-cross-chain-swap/schema/raw/response_to_get_splitter_config.json @@ -31,7 +31,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/finance/andromeda-cross-chain-swap/src/contract.rs b/contracts/finance/andromeda-cross-chain-swap/src/contract.rs index 54bd36244..9799f6aaa 100644 --- a/contracts/finance/andromeda-cross-chain-swap/src/contract.rs +++ b/contracts/finance/andromeda-cross-chain-swap/src/contract.rs @@ -42,9 +42,10 @@ pub fn instantiate( deps.storage, env, deps.api, + &deps.querier, info, BaseInstantiateMsg { - ado_type: "andromeda-cross-chain-swap".to_string(), + ado_type: CONTRACT_NAME.to_string(), ado_version: CONTRACT_VERSION.to_string(), kernel_address: msg.kernel_address, owner: msg.owner, diff --git a/contracts/finance/andromeda-cross-chain-swap/src/testing/mock_querier.rs b/contracts/finance/andromeda-cross-chain-swap/src/testing/mock_querier.rs index 5ed6783b0..904360a60 100644 --- a/contracts/finance/andromeda-cross-chain-swap/src/testing/mock_querier.rs +++ b/contracts/finance/andromeda-cross-chain-swap/src/testing/mock_querier.rs @@ -2,6 +2,7 @@ use andromeda_std::ado_base::InstantiateMsg; use andromeda_std::ado_contract::ADOContract; use andromeda_std::testing::mock_querier::MockAndromedaQuerier; use cosmwasm_std::testing::mock_info; +use cosmwasm_std::QuerierWrapper; use cosmwasm_std::{ from_json, testing::{mock_env, MockApi, MockQuerier, MockStorage, MOCK_CONTRACT_ADDR}, @@ -32,6 +33,7 @@ pub fn mock_dependencies_custom( &mut deps.storage, mock_env(), &deps.api, + &QuerierWrapper::new(&deps.querier), mock_info("sender", &[]), InstantiateMsg { ado_type: "splitter".to_string(), diff --git a/contracts/finance/andromeda-rate-limiting-withdrawals/examples/schema.rs b/contracts/finance/andromeda-rate-limiting-withdrawals/examples/schema.rs index fb68c826a..c31553900 100644 --- a/contracts/finance/andromeda-rate-limiting-withdrawals/examples/schema.rs +++ b/contracts/finance/andromeda-rate-limiting-withdrawals/examples/schema.rs @@ -1,4 +1,4 @@ -use andromeda_finance::splitter::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use andromeda_finance::rate_limiting_withdrawals::{ExecuteMsg, InstantiateMsg, QueryMsg}; use cosmwasm_schema::write_api; fn main() { diff --git a/contracts/finance/andromeda-rate-limiting-withdrawals/schema/andromeda-rate-limiting-withdrawals.json b/contracts/finance/andromeda-rate-limiting-withdrawals/schema/andromeda-rate-limiting-withdrawals.json index a01c8f58f..42442f128 100644 --- a/contracts/finance/andromeda-rate-limiting-withdrawals/schema/andromeda-rate-limiting-withdrawals.json +++ b/contracts/finance/andromeda-rate-limiting-withdrawals/schema/andromeda-rate-limiting-withdrawals.json @@ -7,51 +7,61 @@ "title": "InstantiateMsg", "type": "object", "required": [ + "allowed_coin", "kernel_address", - "recipients" + "minimal_withdrawal_frequency" ], "properties": { + "allowed_coin": { + "$ref": "#/definitions/CoinAndLimit" + }, "kernel_address": { "type": "string" }, - "lock_time": { - "anyOf": [ - { - "$ref": "#/definitions/Milliseconds" - }, - { - "type": "null" - } - ] + "minimal_withdrawal_frequency": { + "$ref": "#/definitions/MinimumFrequency" + }, + "modules": { + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Module" + } }, "owner": { "type": [ "string", "null" ] - }, - "recipients": { - "description": "The vector of recipients for the contract. Anytime a `Send` execute message is sent the amount sent will be divided amongst these recipients depending on their assigned percentage.", - "type": "array", - "items": { - "$ref": "#/definitions/AddressPercent" - } } }, "additionalProperties": false, "definitions": { - "AddressPercent": { + "AndrAddr": { + "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", + "type": "string", + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + }, + "CoinAndLimit": { "type": "object", "required": [ - "percent", - "recipient" + "coin", + "limit" ], "properties": { - "percent": { - "$ref": "#/definitions/Decimal" + "coin": { + "description": "Sets the accepted coin denom", + "type": "string" }, - "recipient": { - "$ref": "#/definitions/Recipient" + "limit": { + "description": "Sets the withdrawal limit in terms of amount", + "allOf": [ + { + "$ref": "#/definitions/Uint128" + } + ] } }, "additionalProperties": false @@ -59,7 +69,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -75,38 +85,57 @@ "format": "uint64", "minimum": 0.0 }, - "Recipient": { - "description": "A simple struct used for inter-contract communication. The struct can be used in two ways:\n\n1. Simply just providing an `AndrAddr` which will treat the communication as a transfer of any related funds 2. Providing an `AndrAddr` and a `Binary` message which will be sent to the contract at the resolved address\n\nThe `Binary` message can be any message that the contract at the resolved address can handle.", + "MinimumFrequency": { + "oneOf": [ + { + "type": "object", + "required": [ + "time" + ], + "properties": { + "time": { + "type": "object", + "required": [ + "time" + ], + "properties": { + "time": { + "$ref": "#/definitions/Milliseconds" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + } + ] + }, + "Module": { + "description": "A struct describing a token module, provided with the instantiation message this struct is used to record the info about the module and how/if it should be instantiated", "type": "object", "required": [ - "address" + "address", + "is_mutable" ], "properties": { "address": { "$ref": "#/definitions/AndrAddr" }, - "ibc_recovery_address": { - "anyOf": [ - { - "$ref": "#/definitions/AndrAddr" - }, - { - "type": "null" - } - ] + "is_mutable": { + "type": "boolean" }, - "msg": { - "anyOf": [ - { - "$ref": "#/definitions/Binary" - }, - { - "type": "null" - } + "name": { + "type": [ + "string", + "null" ] } }, "additionalProperties": false + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" } } }, @@ -115,23 +144,19 @@ "title": "ExecuteMsg", "oneOf": [ { - "description": "Update the recipients list. Only executable by the contract owner when the contract is not locked.", "type": "object", "required": [ - "update_recipients" + "deposits" ], "properties": { - "update_recipients": { + "deposits": { "type": "object", - "required": [ - "recipients" - ], "properties": { - "recipients": { - "type": "array", - "items": { - "$ref": "#/definitions/AddressPercent" - } + "recipient": { + "type": [ + "string", + "null" + ] } }, "additionalProperties": false @@ -140,20 +165,19 @@ "additionalProperties": false }, { - "description": "Used to lock/unlock the contract allowing the config to be updated.", "type": "object", "required": [ - "update_lock" + "withdraw_funds" ], "properties": { - "update_lock": { + "withdraw_funds": { "type": "object", "required": [ - "lock_time" + "amount" ], "properties": { - "lock_time": { - "$ref": "#/definitions/Milliseconds" + "amount": { + "$ref": "#/definitions/Uint128" } }, "additionalProperties": false @@ -161,20 +185,6 @@ }, "additionalProperties": false }, - { - "description": "Divides any attached funds to the message amongst the recipients list.", - "type": "object", - "required": [ - "send" - ], - "properties": { - "send": { - "type": "object", - "additionalProperties": false - } - }, - "additionalProperties": false - }, { "type": "object", "required": [ @@ -470,26 +480,10 @@ "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", "type": "string" }, - "AddressPercent": { - "type": "object", - "required": [ - "percent", - "recipient" - ], - "properties": { - "percent": { - "$ref": "#/definitions/Decimal" - }, - "recipient": { - "$ref": "#/definitions/Recipient" - } - }, - "additionalProperties": false - }, "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -510,10 +504,6 @@ } } }, - "Decimal": { - "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", - "type": "string" - }, "Expiration": { "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", "oneOf": [ @@ -577,12 +567,6 @@ }, "additionalProperties": false }, - "Milliseconds": { - "description": "Represents time in milliseconds.", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, "Module": { "description": "A struct describing a token module, provided with the instantiation message this struct is used to record the info about the module and how/if it should be instantiated", "type": "object", @@ -825,39 +809,6 @@ } ] }, - "Recipient": { - "description": "A simple struct used for inter-contract communication. The struct can be used in two ways:\n\n1. Simply just providing an `AndrAddr` which will treat the communication as a transfer of any related funds 2. Providing an `AndrAddr` and a `Binary` message which will be sent to the contract at the resolved address\n\nThe `Binary` message can be any message that the contract at the resolved address can handle.", - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "$ref": "#/definitions/AndrAddr" - }, - "ibc_recovery_address": { - "anyOf": [ - { - "$ref": "#/definitions/AndrAddr" - }, - { - "type": "null" - } - ] - }, - "msg": { - "anyOf": [ - { - "$ref": "#/definitions/Binary" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false - }, "ReplyOn": { "description": "Use this to define when the contract gets a response callback. If you only need it for errors or success you can select just those in order to save gas.", "oneOf": [ @@ -914,14 +865,36 @@ "title": "QueryMsg", "oneOf": [ { - "description": "The current config of the Splitter contract", + "description": "Provides the allowed coin and limits for withdrawal size and frequency", + "type": "object", + "required": [ + "coin_allowance_details" + ], + "properties": { + "coin_allowance_details": { + "type": "object", + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "Shows the balance and latest withdrawal time", "type": "object", "required": [ - "get_splitter_config" + "account_details" ], "properties": { - "get_splitter_config": { + "account_details": { "type": "object", + "required": [ + "account" + ], + "properties": { + "account": { + "type": "string" + } + }, "additionalProperties": false } }, @@ -1151,7 +1124,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AndromedaHook": { "oneOf": [ @@ -1316,6 +1289,55 @@ "migrate": null, "sudo": null, "responses": { + "account_details": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "AccountDetails", + "description": "Keeps track of the account's balance and time of latest withdrawal", + "type": "object", + "required": [ + "balance" + ], + "properties": { + "balance": { + "description": "Account balance, no need for denom since only one is allowed", + "allOf": [ + { + "$ref": "#/definitions/Uint128" + } + ] + }, + "latest_withdrawal": { + "description": "Timestamp of latest withdrawal", + "anyOf": [ + { + "$ref": "#/definitions/Timestamp" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false, + "definitions": { + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } + }, "andr_hook": { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Binary", @@ -1397,16 +1419,35 @@ }, "additionalProperties": false }, - "get_splitter_config": { + "coin_allowance_details": { "$schema": "http://json-schema.org/draft-07/schema#", - "title": "GetSplitterConfigResponse", + "title": "CoinAllowance", "type": "object", "required": [ - "config" + "coin", + "limit", + "minimal_withdrawal_frequency" ], "properties": { - "config": { - "$ref": "#/definitions/Splitter" + "coin": { + "description": "Sets the accepted coin denom", + "type": "string" + }, + "limit": { + "description": "Sets the withdrawal limit in terms of amount", + "allOf": [ + { + "$ref": "#/definitions/Uint128" + } + ] + }, + "minimal_withdrawal_frequency": { + "description": "Sets the minimum amount of time required between withdrawals in seconds", + "allOf": [ + { + "$ref": "#/definitions/Milliseconds" + } + ] } }, "additionalProperties": false, @@ -1430,7 +1471,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -1446,64 +1487,9 @@ "format": "uint64", "minimum": 0.0 }, - "Recipient": { - "description": "A simple struct used for inter-contract communication. The struct can be used in two ways:\n\n1. Simply just providing an `AndrAddr` which will treat the communication as a transfer of any related funds 2. Providing an `AndrAddr` and a `Binary` message which will be sent to the contract at the resolved address\n\nThe `Binary` message can be any message that the contract at the resolved address can handle.", - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "$ref": "#/definitions/AndrAddr" - }, - "ibc_recovery_address": { - "anyOf": [ - { - "$ref": "#/definitions/AndrAddr" - }, - { - "type": "null" - } - ] - }, - "msg": { - "anyOf": [ - { - "$ref": "#/definitions/Binary" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false - }, - "Splitter": { - "description": "A config struct for a `Splitter` contract.", - "type": "object", - "required": [ - "lock", - "recipients" - ], - "properties": { - "lock": { - "description": "Whether or not the contract is currently locked. This restricts updating any config related fields.", - "allOf": [ - { - "$ref": "#/definitions/Milliseconds" - } - ] - }, - "recipients": { - "description": "The vector of recipients for the contract. Anytime a `Send` execute message is sent the amount sent will be divided amongst these recipients depending on their assigned percentage.", - "type": "array", - "items": { - "$ref": "#/definitions/AddressPercent" - } - } - }, - "additionalProperties": false + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" } } }, @@ -1555,7 +1541,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } }, diff --git a/contracts/finance/andromeda-rate-limiting-withdrawals/schema/raw/execute.json b/contracts/finance/andromeda-rate-limiting-withdrawals/schema/raw/execute.json index 81938f927..7a80cf6d9 100644 --- a/contracts/finance/andromeda-rate-limiting-withdrawals/schema/raw/execute.json +++ b/contracts/finance/andromeda-rate-limiting-withdrawals/schema/raw/execute.json @@ -3,23 +3,19 @@ "title": "ExecuteMsg", "oneOf": [ { - "description": "Update the recipients list. Only executable by the contract owner when the contract is not locked.", "type": "object", "required": [ - "update_recipients" + "deposits" ], "properties": { - "update_recipients": { + "deposits": { "type": "object", - "required": [ - "recipients" - ], "properties": { - "recipients": { - "type": "array", - "items": { - "$ref": "#/definitions/AddressPercent" - } + "recipient": { + "type": [ + "string", + "null" + ] } }, "additionalProperties": false @@ -28,20 +24,19 @@ "additionalProperties": false }, { - "description": "Used to lock/unlock the contract allowing the config to be updated.", "type": "object", "required": [ - "update_lock" + "withdraw_funds" ], "properties": { - "update_lock": { + "withdraw_funds": { "type": "object", "required": [ - "lock_time" + "amount" ], "properties": { - "lock_time": { - "$ref": "#/definitions/Milliseconds" + "amount": { + "$ref": "#/definitions/Uint128" } }, "additionalProperties": false @@ -49,20 +44,6 @@ }, "additionalProperties": false }, - { - "description": "Divides any attached funds to the message amongst the recipients list.", - "type": "object", - "required": [ - "send" - ], - "properties": { - "send": { - "type": "object", - "additionalProperties": false - } - }, - "additionalProperties": false - }, { "type": "object", "required": [ @@ -358,26 +339,10 @@ "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", "type": "string" }, - "AddressPercent": { - "type": "object", - "required": [ - "percent", - "recipient" - ], - "properties": { - "percent": { - "$ref": "#/definitions/Decimal" - }, - "recipient": { - "$ref": "#/definitions/Recipient" - } - }, - "additionalProperties": false - }, "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -398,10 +363,6 @@ } } }, - "Decimal": { - "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", - "type": "string" - }, "Expiration": { "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", "oneOf": [ @@ -465,12 +426,6 @@ }, "additionalProperties": false }, - "Milliseconds": { - "description": "Represents time in milliseconds.", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, "Module": { "description": "A struct describing a token module, provided with the instantiation message this struct is used to record the info about the module and how/if it should be instantiated", "type": "object", @@ -713,39 +668,6 @@ } ] }, - "Recipient": { - "description": "A simple struct used for inter-contract communication. The struct can be used in two ways:\n\n1. Simply just providing an `AndrAddr` which will treat the communication as a transfer of any related funds 2. Providing an `AndrAddr` and a `Binary` message which will be sent to the contract at the resolved address\n\nThe `Binary` message can be any message that the contract at the resolved address can handle.", - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "$ref": "#/definitions/AndrAddr" - }, - "ibc_recovery_address": { - "anyOf": [ - { - "$ref": "#/definitions/AndrAddr" - }, - { - "type": "null" - } - ] - }, - "msg": { - "anyOf": [ - { - "$ref": "#/definitions/Binary" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false - }, "ReplyOn": { "description": "Use this to define when the contract gets a response callback. If you only need it for errors or success you can select just those in order to save gas.", "oneOf": [ diff --git a/contracts/finance/andromeda-rate-limiting-withdrawals/schema/raw/instantiate.json b/contracts/finance/andromeda-rate-limiting-withdrawals/schema/raw/instantiate.json index 26231037a..9fc53284b 100644 --- a/contracts/finance/andromeda-rate-limiting-withdrawals/schema/raw/instantiate.json +++ b/contracts/finance/andromeda-rate-limiting-withdrawals/schema/raw/instantiate.json @@ -3,106 +3,122 @@ "title": "InstantiateMsg", "type": "object", "required": [ + "allowed_coin", "kernel_address", - "recipients" + "minimal_withdrawal_frequency" ], "properties": { + "allowed_coin": { + "$ref": "#/definitions/CoinAndLimit" + }, "kernel_address": { "type": "string" }, - "lock_time": { - "anyOf": [ - { - "$ref": "#/definitions/Milliseconds" - }, - { - "type": "null" - } - ] + "minimal_withdrawal_frequency": { + "$ref": "#/definitions/MinimumFrequency" + }, + "modules": { + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Module" + } }, "owner": { "type": [ "string", "null" ] - }, - "recipients": { - "description": "The vector of recipients for the contract. Anytime a `Send` execute message is sent the amount sent will be divided amongst these recipients depending on their assigned percentage.", - "type": "array", - "items": { - "$ref": "#/definitions/AddressPercent" - } } }, "additionalProperties": false, "definitions": { - "AddressPercent": { + "AndrAddr": { + "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", + "type": "string", + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + }, + "CoinAndLimit": { "type": "object", "required": [ - "percent", - "recipient" + "coin", + "limit" ], "properties": { - "percent": { - "$ref": "#/definitions/Decimal" + "coin": { + "description": "Sets the accepted coin denom", + "type": "string" }, - "recipient": { - "$ref": "#/definitions/Recipient" + "limit": { + "description": "Sets the withdrawal limit in terms of amount", + "allOf": [ + { + "$ref": "#/definitions/Uint128" + } + ] } }, "additionalProperties": false }, - "AndrAddr": { - "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", - "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" - }, - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", - "type": "string" - }, - "Decimal": { - "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", - "type": "string" - }, "Milliseconds": { "description": "Represents time in milliseconds.", "type": "integer", "format": "uint64", "minimum": 0.0 }, - "Recipient": { - "description": "A simple struct used for inter-contract communication. The struct can be used in two ways:\n\n1. Simply just providing an `AndrAddr` which will treat the communication as a transfer of any related funds 2. Providing an `AndrAddr` and a `Binary` message which will be sent to the contract at the resolved address\n\nThe `Binary` message can be any message that the contract at the resolved address can handle.", + "MinimumFrequency": { + "oneOf": [ + { + "type": "object", + "required": [ + "time" + ], + "properties": { + "time": { + "type": "object", + "required": [ + "time" + ], + "properties": { + "time": { + "$ref": "#/definitions/Milliseconds" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + } + ] + }, + "Module": { + "description": "A struct describing a token module, provided with the instantiation message this struct is used to record the info about the module and how/if it should be instantiated", "type": "object", "required": [ - "address" + "address", + "is_mutable" ], "properties": { "address": { "$ref": "#/definitions/AndrAddr" }, - "ibc_recovery_address": { - "anyOf": [ - { - "$ref": "#/definitions/AndrAddr" - }, - { - "type": "null" - } - ] + "is_mutable": { + "type": "boolean" }, - "msg": { - "anyOf": [ - { - "$ref": "#/definitions/Binary" - }, - { - "type": "null" - } + "name": { + "type": [ + "string", + "null" ] } }, "additionalProperties": false + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" } } } diff --git a/contracts/finance/andromeda-rate-limiting-withdrawals/schema/raw/query.json b/contracts/finance/andromeda-rate-limiting-withdrawals/schema/raw/query.json index 9273998f4..eeec24e62 100644 --- a/contracts/finance/andromeda-rate-limiting-withdrawals/schema/raw/query.json +++ b/contracts/finance/andromeda-rate-limiting-withdrawals/schema/raw/query.json @@ -3,19 +3,41 @@ "title": "QueryMsg", "oneOf": [ { - "description": "The current config of the Splitter contract", + "description": "Provides the allowed coin and limits for withdrawal size and frequency", "type": "object", "required": [ - "get_splitter_config" + "coin_allowance_details" ], "properties": { - "get_splitter_config": { + "coin_allowance_details": { "type": "object", "additionalProperties": false } }, "additionalProperties": false }, + { + "description": "Shows the balance and latest withdrawal time", + "type": "object", + "required": [ + "account_details" + ], + "properties": { + "account_details": { + "type": "object", + "required": [ + "account" + ], + "properties": { + "account": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, { "type": "object", "required": [ @@ -240,7 +262,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AndromedaHook": { "oneOf": [ diff --git a/contracts/finance/andromeda-rate-limiting-withdrawals/schema/raw/response_to_account_details.json b/contracts/finance/andromeda-rate-limiting-withdrawals/schema/raw/response_to_account_details.json new file mode 100644 index 000000000..ee070b57e --- /dev/null +++ b/contracts/finance/andromeda-rate-limiting-withdrawals/schema/raw/response_to_account_details.json @@ -0,0 +1,49 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "AccountDetails", + "description": "Keeps track of the account's balance and time of latest withdrawal", + "type": "object", + "required": [ + "balance" + ], + "properties": { + "balance": { + "description": "Account balance, no need for denom since only one is allowed", + "allOf": [ + { + "$ref": "#/definitions/Uint128" + } + ] + }, + "latest_withdrawal": { + "description": "Timestamp of latest withdrawal", + "anyOf": [ + { + "$ref": "#/definitions/Timestamp" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false, + "definitions": { + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/contracts/finance/andromeda-rate-limiting-withdrawals/schema/raw/response_to_coin_allowance_details.json b/contracts/finance/andromeda-rate-limiting-withdrawals/schema/raw/response_to_coin_allowance_details.json new file mode 100644 index 000000000..0b340fd9d --- /dev/null +++ b/contracts/finance/andromeda-rate-limiting-withdrawals/schema/raw/response_to_coin_allowance_details.json @@ -0,0 +1,45 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "CoinAllowance", + "type": "object", + "required": [ + "coin", + "limit", + "minimal_withdrawal_frequency" + ], + "properties": { + "coin": { + "description": "Sets the accepted coin denom", + "type": "string" + }, + "limit": { + "description": "Sets the withdrawal limit in terms of amount", + "allOf": [ + { + "$ref": "#/definitions/Uint128" + } + ] + }, + "minimal_withdrawal_frequency": { + "description": "Sets the minimum amount of time required between withdrawals in seconds", + "allOf": [ + { + "$ref": "#/definitions/Milliseconds" + } + ] + } + }, + "additionalProperties": false, + "definitions": { + "Milliseconds": { + "description": "Represents time in milliseconds.", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + } + } +} diff --git a/contracts/finance/andromeda-rate-limiting-withdrawals/schema/raw/response_to_get_splitter_config.json b/contracts/finance/andromeda-rate-limiting-withdrawals/schema/raw/response_to_get_splitter_config.json index f1e9946e3..4942b3e04 100644 --- a/contracts/finance/andromeda-rate-limiting-withdrawals/schema/raw/response_to_get_splitter_config.json +++ b/contracts/finance/andromeda-rate-limiting-withdrawals/schema/raw/response_to_get_splitter_config.json @@ -31,7 +31,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/finance/andromeda-rate-limiting-withdrawals/schema/raw/response_to_module.json b/contracts/finance/andromeda-rate-limiting-withdrawals/schema/raw/response_to_module.json index 33d4a115b..c7b506914 100644 --- a/contracts/finance/andromeda-rate-limiting-withdrawals/schema/raw/response_to_module.json +++ b/contracts/finance/andromeda-rate-limiting-withdrawals/schema/raw/response_to_module.json @@ -26,7 +26,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } } diff --git a/contracts/finance/andromeda-rate-limiting-withdrawals/src/contract.rs b/contracts/finance/andromeda-rate-limiting-withdrawals/src/contract.rs index 14914f060..60935385f 100644 --- a/contracts/finance/andromeda-rate-limiting-withdrawals/src/contract.rs +++ b/contracts/finance/andromeda-rate-limiting-withdrawals/src/contract.rs @@ -47,14 +47,14 @@ pub fn instantiate( }, )?, //NOTE temporary until a replacement for primitive is implemented - _ => ALLOWED_COIN.save( - deps.storage, - &CoinAllowance { - coin: msg.allowed_coin.coin, - limit: msg.allowed_coin.limit, - minimal_withdrawal_frequency: Milliseconds::zero(), - }, - )?, + // _ => ALLOWED_COIN.save( + // deps.storage, + // &CoinAllowance { + // coin: msg.allowed_coin.coin, + // limit: msg.allowed_coin.limit, + // minimal_withdrawal_frequency: Milliseconds::zero(), + // }, + // )?, // MinimumFrequency::AddressAndKey { address_and_key } => ALLOWED_COIN.save( // deps.storage, // &CoinAllowance { @@ -75,9 +75,10 @@ pub fn instantiate( deps.storage, env, deps.api, + &deps.querier, info.clone(), BaseInstantiateMsg { - ado_type: "rate-limiting-withdrawals".to_string(), + ado_type: CONTRACT_NAME.to_string(), ado_version: CONTRACT_VERSION.to_string(), kernel_address: msg.kernel_address, owner: msg.owner, diff --git a/contracts/finance/andromeda-rate-limiting-withdrawals/src/testing/mock_querier.rs b/contracts/finance/andromeda-rate-limiting-withdrawals/src/testing/mock_querier.rs index 746f02c23..703a6e1e4 100644 --- a/contracts/finance/andromeda-rate-limiting-withdrawals/src/testing/mock_querier.rs +++ b/contracts/finance/andromeda-rate-limiting-withdrawals/src/testing/mock_querier.rs @@ -10,7 +10,7 @@ use cosmwasm_std::{ to_json_binary, Binary, Coin, ContractResult, OwnedDeps, Querier, QuerierResult, QueryRequest, SystemError, SystemResult, WasmQuery, }; -use cosmwasm_std::{BankMsg, CosmosMsg, Response, SubMsg, Uint128}; +use cosmwasm_std::{BankMsg, CosmosMsg, QuerierWrapper, Response, SubMsg, Uint128}; pub use andromeda_std::testing::mock_querier::{ MOCK_ADDRESS_LIST_CONTRACT, MOCK_APP_CONTRACT, MOCK_KERNEL_CONTRACT, MOCK_RATES_CONTRACT, @@ -39,11 +39,11 @@ pub fn mock_dependencies_custom( &mut deps.storage, mock_env(), &deps.api, + &QuerierWrapper::new(&deps.querier), mock_info("sender", &[]), InstantiateMsg { ado_type: "splitter".to_string(), ado_version: "test".to_string(), - kernel_address: MOCK_KERNEL_CONTRACT.to_string(), owner: None, }, diff --git a/contracts/finance/andromeda-splitter/schema/andromeda-splitter.json b/contracts/finance/andromeda-splitter/schema/andromeda-splitter.json index daed4aa83..2653786bb 100644 --- a/contracts/finance/andromeda-splitter/schema/andromeda-splitter.json +++ b/contracts/finance/andromeda-splitter/schema/andromeda-splitter.json @@ -59,7 +59,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -489,7 +489,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -1151,7 +1151,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AndromedaHook": { "oneOf": [ @@ -1430,7 +1430,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -1555,7 +1555,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } }, diff --git a/contracts/finance/andromeda-splitter/schema/raw/execute.json b/contracts/finance/andromeda-splitter/schema/raw/execute.json index 81938f927..4df8a897c 100644 --- a/contracts/finance/andromeda-splitter/schema/raw/execute.json +++ b/contracts/finance/andromeda-splitter/schema/raw/execute.json @@ -377,7 +377,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/finance/andromeda-splitter/schema/raw/instantiate.json b/contracts/finance/andromeda-splitter/schema/raw/instantiate.json index 26231037a..6ead203e7 100644 --- a/contracts/finance/andromeda-splitter/schema/raw/instantiate.json +++ b/contracts/finance/andromeda-splitter/schema/raw/instantiate.json @@ -55,7 +55,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/finance/andromeda-splitter/schema/raw/query.json b/contracts/finance/andromeda-splitter/schema/raw/query.json index 9273998f4..9fbf266a6 100644 --- a/contracts/finance/andromeda-splitter/schema/raw/query.json +++ b/contracts/finance/andromeda-splitter/schema/raw/query.json @@ -240,7 +240,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AndromedaHook": { "oneOf": [ diff --git a/contracts/finance/andromeda-splitter/schema/raw/response_to_get_splitter_config.json b/contracts/finance/andromeda-splitter/schema/raw/response_to_get_splitter_config.json index f1e9946e3..4942b3e04 100644 --- a/contracts/finance/andromeda-splitter/schema/raw/response_to_get_splitter_config.json +++ b/contracts/finance/andromeda-splitter/schema/raw/response_to_get_splitter_config.json @@ -31,7 +31,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/finance/andromeda-splitter/schema/raw/response_to_module.json b/contracts/finance/andromeda-splitter/schema/raw/response_to_module.json index 33d4a115b..c7b506914 100644 --- a/contracts/finance/andromeda-splitter/schema/raw/response_to_module.json +++ b/contracts/finance/andromeda-splitter/schema/raw/response_to_module.json @@ -26,7 +26,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } } diff --git a/contracts/finance/andromeda-splitter/src/contract.rs b/contracts/finance/andromeda-splitter/src/contract.rs index 4863dd6af..ba7798524 100644 --- a/contracts/finance/andromeda-splitter/src/contract.rs +++ b/contracts/finance/andromeda-splitter/src/contract.rs @@ -72,9 +72,10 @@ pub fn instantiate( deps.storage, env, deps.api, + &deps.querier, info, BaseInstantiateMsg { - ado_type: "splitter".to_string(), + ado_type: CONTRACT_NAME.to_string(), ado_version: CONTRACT_VERSION.to_string(), kernel_address: msg.kernel_address, owner: msg.owner, diff --git a/contracts/finance/andromeda-splitter/src/testing/mock_querier.rs b/contracts/finance/andromeda-splitter/src/testing/mock_querier.rs index 746f02c23..c4099d4a8 100644 --- a/contracts/finance/andromeda-splitter/src/testing/mock_querier.rs +++ b/contracts/finance/andromeda-splitter/src/testing/mock_querier.rs @@ -10,7 +10,7 @@ use cosmwasm_std::{ to_json_binary, Binary, Coin, ContractResult, OwnedDeps, Querier, QuerierResult, QueryRequest, SystemError, SystemResult, WasmQuery, }; -use cosmwasm_std::{BankMsg, CosmosMsg, Response, SubMsg, Uint128}; +use cosmwasm_std::{BankMsg, CosmosMsg, QuerierWrapper, Response, SubMsg, Uint128}; pub use andromeda_std::testing::mock_querier::{ MOCK_ADDRESS_LIST_CONTRACT, MOCK_APP_CONTRACT, MOCK_KERNEL_CONTRACT, MOCK_RATES_CONTRACT, @@ -39,6 +39,7 @@ pub fn mock_dependencies_custom( &mut deps.storage, mock_env(), &deps.api, + &QuerierWrapper::new(&deps.querier), mock_info("sender", &[]), InstantiateMsg { ado_type: "splitter".to_string(), diff --git a/contracts/finance/andromeda-timelock/schema/andromeda-timelock.json b/contracts/finance/andromeda-timelock/schema/andromeda-timelock.json index 5493083b2..c3b4f9449 100644 --- a/contracts/finance/andromeda-timelock/schema/andromeda-timelock.json +++ b/contracts/finance/andromeda-timelock/schema/andromeda-timelock.json @@ -34,7 +34,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Module": { "description": "A struct describing a token module, provided with the instantiation message this struct is used to record the info about the module and how/if it should be instantiated", @@ -462,7 +462,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -1202,7 +1202,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AndromedaHook": { "oneOf": [ @@ -1469,7 +1469,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -1631,7 +1631,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -1821,7 +1821,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } }, diff --git a/contracts/finance/andromeda-timelock/schema/raw/execute.json b/contracts/finance/andromeda-timelock/schema/raw/execute.json index bc6091441..ba8952848 100644 --- a/contracts/finance/andromeda-timelock/schema/raw/execute.json +++ b/contracts/finance/andromeda-timelock/schema/raw/execute.json @@ -399,7 +399,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/finance/andromeda-timelock/schema/raw/instantiate.json b/contracts/finance/andromeda-timelock/schema/raw/instantiate.json index 6c3418b88..953991c5c 100644 --- a/contracts/finance/andromeda-timelock/schema/raw/instantiate.json +++ b/contracts/finance/andromeda-timelock/schema/raw/instantiate.json @@ -30,7 +30,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Module": { "description": "A struct describing a token module, provided with the instantiation message this struct is used to record the info about the module and how/if it should be instantiated", diff --git a/contracts/finance/andromeda-timelock/schema/raw/query.json b/contracts/finance/andromeda-timelock/schema/raw/query.json index 105412b39..c200d6f1b 100644 --- a/contracts/finance/andromeda-timelock/schema/raw/query.json +++ b/contracts/finance/andromeda-timelock/schema/raw/query.json @@ -288,7 +288,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AndromedaHook": { "oneOf": [ diff --git a/contracts/finance/andromeda-timelock/schema/raw/response_to_get_locked_funds.json b/contracts/finance/andromeda-timelock/schema/raw/response_to_get_locked_funds.json index 80fca52d7..d696295c9 100644 --- a/contracts/finance/andromeda-timelock/schema/raw/response_to_get_locked_funds.json +++ b/contracts/finance/andromeda-timelock/schema/raw/response_to_get_locked_funds.json @@ -19,7 +19,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/finance/andromeda-timelock/schema/raw/response_to_get_locked_funds_for_recipient.json b/contracts/finance/andromeda-timelock/schema/raw/response_to_get_locked_funds_for_recipient.json index b1cdaa0bb..0523a35e5 100644 --- a/contracts/finance/andromeda-timelock/schema/raw/response_to_get_locked_funds_for_recipient.json +++ b/contracts/finance/andromeda-timelock/schema/raw/response_to_get_locked_funds_for_recipient.json @@ -18,7 +18,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/finance/andromeda-timelock/schema/raw/response_to_module.json b/contracts/finance/andromeda-timelock/schema/raw/response_to_module.json index 33d4a115b..c7b506914 100644 --- a/contracts/finance/andromeda-timelock/schema/raw/response_to_module.json +++ b/contracts/finance/andromeda-timelock/schema/raw/response_to_module.json @@ -26,7 +26,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } } diff --git a/contracts/finance/andromeda-timelock/src/contract.rs b/contracts/finance/andromeda-timelock/src/contract.rs index 3e55e26bb..50ba1ba64 100644 --- a/contracts/finance/andromeda-timelock/src/contract.rs +++ b/contracts/finance/andromeda-timelock/src/contract.rs @@ -37,9 +37,10 @@ pub fn instantiate( deps.storage, env, deps.api, + &deps.querier, info, BaseInstantiateMsg { - ado_type: "timelock".to_string(), + ado_type: CONTRACT_NAME.to_string(), ado_version: CONTRACT_VERSION.to_string(), kernel_address: msg.kernel_address, owner: msg.owner, diff --git a/contracts/finance/andromeda-timelock/src/testing/mock_querier.rs b/contracts/finance/andromeda-timelock/src/testing/mock_querier.rs index 746f02c23..c4099d4a8 100644 --- a/contracts/finance/andromeda-timelock/src/testing/mock_querier.rs +++ b/contracts/finance/andromeda-timelock/src/testing/mock_querier.rs @@ -10,7 +10,7 @@ use cosmwasm_std::{ to_json_binary, Binary, Coin, ContractResult, OwnedDeps, Querier, QuerierResult, QueryRequest, SystemError, SystemResult, WasmQuery, }; -use cosmwasm_std::{BankMsg, CosmosMsg, Response, SubMsg, Uint128}; +use cosmwasm_std::{BankMsg, CosmosMsg, QuerierWrapper, Response, SubMsg, Uint128}; pub use andromeda_std::testing::mock_querier::{ MOCK_ADDRESS_LIST_CONTRACT, MOCK_APP_CONTRACT, MOCK_KERNEL_CONTRACT, MOCK_RATES_CONTRACT, @@ -39,6 +39,7 @@ pub fn mock_dependencies_custom( &mut deps.storage, mock_env(), &deps.api, + &QuerierWrapper::new(&deps.querier), mock_info("sender", &[]), InstantiateMsg { ado_type: "splitter".to_string(), diff --git a/contracts/finance/andromeda-vesting/schema/andromeda-vesting.json b/contracts/finance/andromeda-vesting/schema/andromeda-vesting.json index a1c2b4b30..a7a75b1c4 100644 --- a/contracts/finance/andromeda-vesting/schema/andromeda-vesting.json +++ b/contracts/finance/andromeda-vesting/schema/andromeda-vesting.json @@ -62,7 +62,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -651,7 +651,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -1298,7 +1298,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } }, @@ -1669,7 +1669,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/finance/andromeda-vesting/schema/raw/execute.json b/contracts/finance/andromeda-vesting/schema/raw/execute.json index 5691b42cc..8531f00a3 100644 --- a/contracts/finance/andromeda-vesting/schema/raw/execute.json +++ b/contracts/finance/andromeda-vesting/schema/raw/execute.json @@ -489,7 +489,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/finance/andromeda-vesting/schema/raw/instantiate.json b/contracts/finance/andromeda-vesting/schema/raw/instantiate.json index 6dea7cd17..76d46a046 100644 --- a/contracts/finance/andromeda-vesting/schema/raw/instantiate.json +++ b/contracts/finance/andromeda-vesting/schema/raw/instantiate.json @@ -58,7 +58,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/finance/andromeda-vesting/schema/raw/query.json b/contracts/finance/andromeda-vesting/schema/raw/query.json index 2398c74d1..5048c12ab 100644 --- a/contracts/finance/andromeda-vesting/schema/raw/query.json +++ b/contracts/finance/andromeda-vesting/schema/raw/query.json @@ -250,7 +250,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } } diff --git a/contracts/finance/andromeda-vesting/schema/raw/response_to_config.json b/contracts/finance/andromeda-vesting/schema/raw/response_to_config.json index b8e91ea59..39f3021a9 100644 --- a/contracts/finance/andromeda-vesting/schema/raw/response_to_config.json +++ b/contracts/finance/andromeda-vesting/schema/raw/response_to_config.json @@ -39,7 +39,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/finance/andromeda-vesting/src/contract.rs b/contracts/finance/andromeda-vesting/src/contract.rs index 5cc84cb7c..9c2ae44b5 100644 --- a/contracts/finance/andromeda-vesting/src/contract.rs +++ b/contracts/finance/andromeda-vesting/src/contract.rs @@ -52,9 +52,10 @@ pub fn instantiate( deps.storage, env, deps.api, + &deps.querier, info, BaseInstantiateMsg { - ado_type: "vesting".to_string(), + ado_type: CONTRACT_NAME.to_string(), ado_version: CONTRACT_VERSION.to_string(), kernel_address: msg.kernel_address, owner: msg.owner, diff --git a/contracts/finance/andromeda-vesting/src/testing/mock_querier.rs b/contracts/finance/andromeda-vesting/src/testing/mock_querier.rs index 3f271441d..212b8c216 100644 --- a/contracts/finance/andromeda-vesting/src/testing/mock_querier.rs +++ b/contracts/finance/andromeda-vesting/src/testing/mock_querier.rs @@ -10,7 +10,7 @@ use cosmwasm_std::{ to_json_binary, Binary, Coin, ContractResult, OwnedDeps, Querier, QuerierResult, QueryRequest, SystemError, SystemResult, WasmQuery, }; -use cosmwasm_std::{BankMsg, CosmosMsg, Response, SubMsg, Uint128}; +use cosmwasm_std::{BankMsg, CosmosMsg, QuerierWrapper, Response, SubMsg, Uint128}; pub use andromeda_std::testing::mock_querier::{ MOCK_ADDRESS_LIST_CONTRACT, MOCK_APP_CONTRACT, MOCK_KERNEL_CONTRACT, MOCK_RATES_CONTRACT, @@ -39,6 +39,7 @@ pub fn mock_dependencies_custom( &mut deps.storage, mock_env(), &deps.api, + &QuerierWrapper::new(&deps.querier), mock_info("sender", &[]), InstantiateMsg { ado_type: "lockdrop".to_string(), diff --git a/contracts/finance/andromeda-vesting/src/testing/tests.rs b/contracts/finance/andromeda-vesting/src/testing/tests.rs index 6c38d10bd..55bff8589 100644 --- a/contracts/finance/andromeda-vesting/src/testing/tests.rs +++ b/contracts/finance/andromeda-vesting/src/testing/tests.rs @@ -92,7 +92,9 @@ fn test_instantiate() { assert_eq!( Response::new() .add_attribute("method", "instantiate") - .add_attribute("type", "vesting"), + .add_attribute("type", "vesting") + .add_attribute("kernel_address", MOCK_KERNEL_CONTRACT) + .add_attribute("owner", "owner"), res ); diff --git a/contracts/finance/andromeda-weighted-distribution-splitter/schema/andromeda-weighted-distribution-splitter.json b/contracts/finance/andromeda-weighted-distribution-splitter/schema/andromeda-weighted-distribution-splitter.json index 759b306dc..72ffcd9e4 100644 --- a/contracts/finance/andromeda-weighted-distribution-splitter/schema/andromeda-weighted-distribution-splitter.json +++ b/contracts/finance/andromeda-weighted-distribution-splitter/schema/andromeda-weighted-distribution-splitter.json @@ -66,7 +66,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -514,7 +514,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -1119,7 +1119,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -1271,7 +1271,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/finance/andromeda-weighted-distribution-splitter/schema/raw/execute.json b/contracts/finance/andromeda-weighted-distribution-splitter/schema/raw/execute.json index 70ef35c8a..1b2df42b3 100644 --- a/contracts/finance/andromeda-weighted-distribution-splitter/schema/raw/execute.json +++ b/contracts/finance/andromeda-weighted-distribution-splitter/schema/raw/execute.json @@ -378,7 +378,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/finance/andromeda-weighted-distribution-splitter/schema/raw/instantiate.json b/contracts/finance/andromeda-weighted-distribution-splitter/schema/raw/instantiate.json index 7feeb00bc..6cb7835cc 100644 --- a/contracts/finance/andromeda-weighted-distribution-splitter/schema/raw/instantiate.json +++ b/contracts/finance/andromeda-weighted-distribution-splitter/schema/raw/instantiate.json @@ -62,7 +62,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/finance/andromeda-weighted-distribution-splitter/schema/raw/query.json b/contracts/finance/andromeda-weighted-distribution-splitter/schema/raw/query.json index 599fc2968..7a71ae8b9 100644 --- a/contracts/finance/andromeda-weighted-distribution-splitter/schema/raw/query.json +++ b/contracts/finance/andromeda-weighted-distribution-splitter/schema/raw/query.json @@ -216,7 +216,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/finance/andromeda-weighted-distribution-splitter/schema/raw/response_to_get_splitter_config.json b/contracts/finance/andromeda-weighted-distribution-splitter/schema/raw/response_to_get_splitter_config.json index ccfcb11b6..6b69ec72d 100644 --- a/contracts/finance/andromeda-weighted-distribution-splitter/schema/raw/response_to_get_splitter_config.json +++ b/contracts/finance/andromeda-weighted-distribution-splitter/schema/raw/response_to_get_splitter_config.json @@ -31,7 +31,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/finance/andromeda-weighted-distribution-splitter/src/contract.rs b/contracts/finance/andromeda-weighted-distribution-splitter/src/contract.rs index 57aa4d26d..cdf95df86 100644 --- a/contracts/finance/andromeda-weighted-distribution-splitter/src/contract.rs +++ b/contracts/finance/andromeda-weighted-distribution-splitter/src/contract.rs @@ -73,9 +73,10 @@ pub fn instantiate( deps.storage, env, deps.api, + &deps.querier, info, BaseInstantiateMsg { - ado_type: "weighted-distribution-splitter".to_string(), + ado_type: CONTRACT_NAME.to_string(), ado_version: CONTRACT_VERSION.to_string(), kernel_address: msg.kernel_address, owner: msg.owner, diff --git a/contracts/finance/andromeda-weighted-distribution-splitter/src/testing/tests.rs b/contracts/finance/andromeda-weighted-distribution-splitter/src/testing/tests.rs index 448108ff0..0f4e6cd12 100644 --- a/contracts/finance/andromeda-weighted-distribution-splitter/src/testing/tests.rs +++ b/contracts/finance/andromeda-weighted-distribution-splitter/src/testing/tests.rs @@ -8,6 +8,7 @@ use andromeda_std::{ amp::{recipient::Recipient, AndrAddr}, error::ContractError, }; +use cosmwasm_std::QuerierWrapper; use cosmwasm_std::{ attr, testing::{mock_env, mock_info}, @@ -35,7 +36,7 @@ fn test_update_app_contract() { is_mutable: false, }]; - let info = mock_info("app_contract", &[]); + let info = mock_info("owner", &[]); let msg = InstantiateMsg { modules: Some(modules), recipients: vec![ @@ -144,12 +145,12 @@ fn test_execute_update_lock() { SPLITTER.save(deps.as_mut().storage, &splitter).unwrap(); let msg = ExecuteMsg::UpdateLock { lock_time }; - let deps_mut = deps.as_mut(); ADOContract::default() .instantiate( - deps_mut.storage, + &mut deps.storage, mock_env(), - deps_mut.api, + &deps.api, + &QuerierWrapper::new(&deps.querier), mock_info(owner, &[]), BaseInstantiateMsg { ado_type: "splitter".to_string(), @@ -197,12 +198,12 @@ fn test_execute_update_lock_too_short() { SPLITTER.save(deps.as_mut().storage, &splitter).unwrap(); let msg = ExecuteMsg::UpdateLock { lock_time }; - let deps_mut = deps.as_mut(); ADOContract::default() .instantiate( - deps_mut.storage, + &mut deps.storage, mock_env(), - deps_mut.api, + &deps.api, + &QuerierWrapper::new(&deps.querier), mock_info(owner, &[]), BaseInstantiateMsg { ado_type: "splitter".to_string(), @@ -244,6 +245,7 @@ fn test_execute_update_lock_too_long() { deps_mut.storage, mock_env(), deps_mut.api, + &deps_mut.querier, mock_info(owner, &[]), BaseInstantiateMsg { ado_type: "splitter".to_string(), @@ -285,6 +287,7 @@ fn test_execute_update_lock_already_locked() { deps_mut.storage, mock_env(), deps_mut.api, + &deps_mut.querier, mock_info(owner, &[]), BaseInstantiateMsg { ado_type: "splitter".to_string(), @@ -326,6 +329,7 @@ fn test_execute_update_lock_unauthorized() { deps_mut.storage, mock_env(), deps_mut.api, + &deps_mut.querier, mock_info(owner, &[]), BaseInstantiateMsg { ado_type: "splitter".to_string(), @@ -370,6 +374,7 @@ fn test_execute_remove_recipient() { deps_mut.storage, mock_env(), deps_mut.api, + &deps_mut.querier, mock_info(owner, &[]), BaseInstantiateMsg { ado_type: "splitter".to_string(), @@ -461,6 +466,7 @@ fn test_execute_remove_recipient_not_on_list() { deps_mut.storage, mock_env(), deps_mut.api, + &deps_mut.querier, mock_info(owner, &[]), BaseInstantiateMsg { ado_type: "splitter".to_string(), @@ -523,6 +529,7 @@ fn test_execute_remove_recipient_contract_locked() { deps_mut.storage, mock_env(), deps_mut.api, + &deps_mut.querier, mock_info(owner, &[]), BaseInstantiateMsg { ado_type: "splitter".to_string(), @@ -593,6 +600,7 @@ fn test_execute_remove_recipient_unauthorized() { deps_mut.storage, mock_env(), deps_mut.api, + &deps_mut.querier, mock_info(owner, &[]), BaseInstantiateMsg { ado_type: "splitter".to_string(), @@ -639,6 +647,7 @@ fn test_update_recipient_weight() { deps_mut.storage, mock_env(), deps_mut.api, + &deps_mut.querier, mock_info(owner, &[]), BaseInstantiateMsg { ado_type: "splitter".to_string(), @@ -734,6 +743,7 @@ fn test_update_recipient_weight_locked_contract() { deps_mut.storage, mock_env(), deps_mut.api, + &deps_mut.querier, mock_info(owner, &[]), BaseInstantiateMsg { ado_type: "splitter".to_string(), @@ -807,6 +817,7 @@ fn test_update_recipient_weight_user_not_found() { deps_mut.storage, mock_env(), deps_mut.api, + &deps_mut.querier, mock_info(owner, &[]), BaseInstantiateMsg { ado_type: "splitter".to_string(), @@ -878,6 +889,7 @@ fn test_update_recipient_weight_invalid_weight() { deps_mut.storage, mock_env(), deps_mut.api, + &deps_mut.querier, mock_info(owner, &[]), BaseInstantiateMsg { ado_type: "splitter".to_string(), @@ -945,6 +957,7 @@ fn test_execute_add_recipient() { deps_mut.storage, mock_env(), deps_mut.api, + &deps_mut.querier, mock_info(owner, &[]), BaseInstantiateMsg { ado_type: "splitter".to_string(), @@ -1049,6 +1062,7 @@ fn test_execute_add_recipient_duplicate_recipient() { deps_mut.storage, mock_env(), deps_mut.api, + &deps_mut.querier, mock_info(owner, &[]), BaseInstantiateMsg { ado_type: "splitter".to_string(), @@ -1126,6 +1140,7 @@ fn test_execute_add_recipient_invalid_weight() { deps_mut.storage, mock_env(), deps_mut.api, + &deps_mut.querier, mock_info(owner, &[]), BaseInstantiateMsg { ado_type: "splitter".to_string(), @@ -1195,6 +1210,7 @@ fn test_execute_add_recipient_locked_contract() { deps_mut.storage, mock_env(), deps_mut.api, + &deps_mut.querier, mock_info(owner, &[]), BaseInstantiateMsg { ado_type: "splitter".to_string(), @@ -1247,6 +1263,7 @@ fn test_execute_add_recipient_unauthorized() { deps_mut.storage, mock_env(), deps_mut.api, + &deps_mut.querier, mock_info(owner, &[]), BaseInstantiateMsg { ado_type: "splitter".to_string(), @@ -1282,6 +1299,7 @@ fn test_execute_update_recipients() { deps_mut.storage, mock_env(), deps_mut.api, + &deps_mut.querier, mock_info(owner, &[]), BaseInstantiateMsg { ado_type: "splitter".to_string(), @@ -1352,6 +1370,7 @@ fn test_execute_update_recipients_invalid_weight() { deps_mut.storage, mock_env(), deps_mut.api, + &deps_mut.querier, mock_info(owner, &[]), BaseInstantiateMsg { ado_type: "splitter".to_string(), @@ -1406,6 +1425,7 @@ fn test_execute_update_recipients_contract_locked() { deps_mut.storage, mock_env(), deps_mut.api, + &deps_mut.querier, mock_info(owner, &[]), BaseInstantiateMsg { ado_type: "splitter".to_string(), @@ -1458,6 +1478,7 @@ fn test_execute_update_recipients_unauthorized() { deps_mut.storage, mock_env(), deps_mut.api, + &deps_mut.querier, mock_info(owner, &[]), BaseInstantiateMsg { ado_type: "splitter".to_string(), diff --git a/contracts/fungible-tokens/andromeda-cw20-exchange/schema/andromeda-cw20-exchange.json b/contracts/fungible-tokens/andromeda-cw20-exchange/schema/andromeda-cw20-exchange.json index 6261569fe..5950d8828 100644 --- a/contracts/fungible-tokens/andromeda-cw20-exchange/schema/andromeda-cw20-exchange.json +++ b/contracts/fungible-tokens/andromeda-cw20-exchange/schema/andromeda-cw20-exchange.json @@ -43,7 +43,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Module": { "description": "A struct describing a token module, provided with the instantiation message this struct is used to record the info about the module and how/if it should be instantiated", @@ -362,7 +362,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AssetInfoBase_for_Addr": { "description": "Represents the type of an fungible asset.\n\nEach **asset info** instance can be one of three variants:\n\n- Native SDK coins. To create an **asset info** instance of this type, provide the denomination. - CW20 tokens. To create an **asset info** instance of this type, provide the contract address.", @@ -1017,7 +1017,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AssetInfoBase_for_Addr": { "description": "Represents the type of an fungible asset.\n\nEach **asset info** instance can be one of three variants:\n\n- Native SDK coins. To create an **asset info** instance of this type, provide the denomination. - CW20 tokens. To create an **asset info** instance of this type, provide the contract address.", diff --git a/contracts/fungible-tokens/andromeda-cw20-exchange/schema/raw/execute.json b/contracts/fungible-tokens/andromeda-cw20-exchange/schema/raw/execute.json index 3070ae9cb..b569024c8 100644 --- a/contracts/fungible-tokens/andromeda-cw20-exchange/schema/raw/execute.json +++ b/contracts/fungible-tokens/andromeda-cw20-exchange/schema/raw/execute.json @@ -290,7 +290,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AssetInfoBase_for_Addr": { "description": "Represents the type of an fungible asset.\n\nEach **asset info** instance can be one of three variants:\n\n- Native SDK coins. To create an **asset info** instance of this type, provide the denomination. - CW20 tokens. To create an **asset info** instance of this type, provide the contract address.", diff --git a/contracts/fungible-tokens/andromeda-cw20-exchange/schema/raw/instantiate.json b/contracts/fungible-tokens/andromeda-cw20-exchange/schema/raw/instantiate.json index 88c571195..9b3b16fba 100644 --- a/contracts/fungible-tokens/andromeda-cw20-exchange/schema/raw/instantiate.json +++ b/contracts/fungible-tokens/andromeda-cw20-exchange/schema/raw/instantiate.json @@ -39,7 +39,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Module": { "description": "A struct describing a token module, provided with the instantiation message this struct is used to record the info about the module and how/if it should be instantiated", diff --git a/contracts/fungible-tokens/andromeda-cw20-exchange/schema/raw/query.json b/contracts/fungible-tokens/andromeda-cw20-exchange/schema/raw/query.json index 06a5fe78b..585878350 100644 --- a/contracts/fungible-tokens/andromeda-cw20-exchange/schema/raw/query.json +++ b/contracts/fungible-tokens/andromeda-cw20-exchange/schema/raw/query.json @@ -249,7 +249,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AssetInfoBase_for_Addr": { "description": "Represents the type of an fungible asset.\n\nEach **asset info** instance can be one of three variants:\n\n- Native SDK coins. To create an **asset info** instance of this type, provide the denomination. - CW20 tokens. To create an **asset info** instance of this type, provide the contract address.", diff --git a/contracts/fungible-tokens/andromeda-cw20-exchange/src/contract.rs b/contracts/fungible-tokens/andromeda-cw20-exchange/src/contract.rs index 96da29169..f8db39bbd 100644 --- a/contracts/fungible-tokens/andromeda-cw20-exchange/src/contract.rs +++ b/contracts/fungible-tokens/andromeda-cw20-exchange/src/contract.rs @@ -8,14 +8,14 @@ use andromeda_std::{ common::{ actions::call_action, context::ExecuteContext, - expiration::{expiration_from_milliseconds, MILLISECONDS_TO_NANOSECONDS_RATIO}, + expiration::{expiration_from_milliseconds, get_and_validate_start_time}, + Milliseconds, }, error::{from_semver, ContractError}, }; use cosmwasm_std::{ attr, coin, ensure, entry_point, from_json, to_json_binary, wasm_execute, BankMsg, Binary, - BlockInfo, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdError, SubMsg, - Uint128, + CosmosMsg, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdError, SubMsg, Uint128, }; use cw2::{get_contract_version, set_contract_version}; use cw20::{Cw20ExecuteMsg, Cw20ReceiveMsg}; @@ -52,9 +52,10 @@ pub fn instantiate( deps.storage, env, deps.api, + &deps.querier, info, BaseInstantiateMsg { - ado_type: "cw20-exchange".to_string(), + ado_type: CONTRACT_NAME.to_string(), ado_version: CONTRACT_VERSION.to_string(), kernel_address: msg.kernel_address, owner: msg.owner, @@ -167,10 +168,12 @@ pub fn execute_start_sale( sender: String, // The recipient of the sale proceeds recipient: Option, - start_time: Option, - duration: Option, + start_time: Option, + duration: Option, ) -> Result { - let ExecuteContext { deps, info, .. } = ctx; + let ExecuteContext { + deps, env, info, .. + } = ctx; let token_addr = TOKEN_ADDRESS .load(deps.storage)? @@ -198,28 +201,17 @@ pub fn execute_start_sale( } ); - let current_time = ctx.env.block.time.nanos() / MILLISECONDS_TO_NANOSECONDS_RATIO; - - let start_expiration = if let Some(start_time) = start_time { - expiration_from_milliseconds(start_time)? - } else { - // Set as current time + 1 so that it isn't expired from the very start - expiration_from_milliseconds(current_time + 1)? - }; - - // Validate start time - let block_time = block_to_expiration(&ctx.env.block, start_expiration).unwrap(); - ensure!( - start_expiration.gt(&block_time), - ContractError::StartTimeInThePast { - current_time, - current_block: ctx.env.block.height, - } - ); + // If start time wasn't provided, it will be set as the current_time + let (start_expiration, current_time) = get_and_validate_start_time(&env, start_time)?; let end_expiration = if let Some(duration) = duration { - // If there's no start time, consider it as now - expiration_from_milliseconds(start_time.unwrap_or(current_time) + duration)? + // If there's no start time, consider it as now + 1 + ensure!(!duration.is_zero(), ContractError::InvalidExpiration {}); + expiration_from_milliseconds( + start_time + .unwrap_or(current_time.plus_seconds(1)) + .plus_milliseconds(duration), + )? } else { Expiration::Never {} }; @@ -431,14 +423,6 @@ pub fn execute_cancel_sale( ])) } -fn block_to_expiration(block: &BlockInfo, model: Expiration) -> Option { - match model { - Expiration::AtTime(_) => Some(Expiration::AtTime(block.time)), - Expiration::AtHeight(_) => Some(Expiration::AtHeight(block.height)), - Expiration::Never {} => None, - } -} - #[cfg_attr(not(feature = "library"), entry_point)] pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result { // New version diff --git a/contracts/fungible-tokens/andromeda-cw20-exchange/src/testing/mock_querier.rs b/contracts/fungible-tokens/andromeda-cw20-exchange/src/testing/mock_querier.rs index 862e1003e..8af252c9e 100644 --- a/contracts/fungible-tokens/andromeda-cw20-exchange/src/testing/mock_querier.rs +++ b/contracts/fungible-tokens/andromeda-cw20-exchange/src/testing/mock_querier.rs @@ -6,7 +6,7 @@ use cosmwasm_std::testing::{ }; use cosmwasm_std::{ from_json, to_json_binary, Coin, ContractResult, Empty, OwnedDeps, Querier, QuerierResult, - QueryRequest, SystemError, SystemResult, Uint128, WasmQuery, + QuerierWrapper, QueryRequest, SystemError, SystemResult, Uint128, WasmQuery, }; use cw20::{BalanceResponse as Cw20BalanceResponse, Cw20QueryMsg}; use std::collections::HashMap; @@ -28,6 +28,7 @@ pub fn mock_dependencies_custom( &mut deps.storage, mock_env(), &deps.api, + &QuerierWrapper::new(&deps.querier), mock_info("sender", &[]), InstantiateMsg { ado_type: "cw20-staking".to_string(), diff --git a/contracts/fungible-tokens/andromeda-cw20-exchange/src/testing/tests.rs b/contracts/fungible-tokens/andromeda-cw20-exchange/src/testing/tests.rs index cd125d76a..02afae4a5 100644 --- a/contracts/fungible-tokens/andromeda-cw20-exchange/src/testing/tests.rs +++ b/contracts/fungible-tokens/andromeda-cw20-exchange/src/testing/tests.rs @@ -3,7 +3,9 @@ use andromeda_fungible_tokens::cw20_exchange::{ TokenAddressResponse, }; use andromeda_std::{ - amp::AndrAddr, common::expiration::MILLISECONDS_TO_NANOSECONDS_RATIO, error::ContractError, + amp::AndrAddr, + common::{expiration::MILLISECONDS_TO_NANOSECONDS_RATIO, Milliseconds}, + error::ContractError, testing::mock_querier::MOCK_KERNEL_CONTRACT, }; use cosmwasm_std::{ @@ -162,8 +164,8 @@ pub fn test_start_sale() { exchange_rate, recipient: None, // A start time ahead of the current time - start_time: Some(current_time + 10), - duration: Some(1), + start_time: Some(Milliseconds(current_time + 10)), + duration: Some(Milliseconds(1)), }; let receive_msg = Cw20ReceiveMsg { sender: owner.to_string(), @@ -253,7 +255,7 @@ pub fn test_start_sale_invalid_start_time() { asset: exchange_asset, exchange_rate, recipient: None, - start_time: Some(1), + start_time: Some(Milliseconds(1)), duration: None, }; let receive_msg = Cw20ReceiveMsg { diff --git a/contracts/fungible-tokens/andromeda-cw20-staking/schema/andromeda-cw20-staking.json b/contracts/fungible-tokens/andromeda-cw20-staking/schema/andromeda-cw20-staking.json index f4a3f4a97..b2024c9bd 100644 --- a/contracts/fungible-tokens/andromeda-cw20-staking/schema/andromeda-cw20-staking.json +++ b/contracts/fungible-tokens/andromeda-cw20-staking/schema/andromeda-cw20-staking.json @@ -99,7 +99,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AssetInfoBase_for_String": { "description": "Represents the type of an fungible asset.\n\nEach **asset info** instance can be one of three variants:\n\n- Native SDK coins. To create an **asset info** instance of this type, provide the denomination. - CW20 tokens. To create an **asset info** instance of this type, provide the contract address.", @@ -642,7 +642,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AssetInfoBase_for_String": { "description": "Represents the type of an fungible asset.\n\nEach **asset info** instance can be one of three variants:\n\n- Native SDK coins. To create an **asset info** instance of this type, provide the denomination. - CW20 tokens. To create an **asset info** instance of this type, provide the contract address.", @@ -1189,20 +1189,6 @@ }, "additionalProperties": false }, - { - "description": "Queries the current timestamp.", - "type": "object", - "required": [ - "timestamp" - ], - "properties": { - "timestamp": { - "type": "object", - "additionalProperties": false - } - }, - "additionalProperties": false - }, { "type": "object", "required": [ @@ -1427,7 +1413,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AndromedaHook": { "oneOf": [ @@ -1702,7 +1688,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } }, @@ -1754,7 +1740,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } }, @@ -2136,13 +2122,6 @@ } } }, - "timestamp": { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "uint64", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, "type": { "$schema": "http://json-schema.org/draft-07/schema#", "title": "TypeResponse", diff --git a/contracts/fungible-tokens/andromeda-cw20-staking/schema/raw/execute.json b/contracts/fungible-tokens/andromeda-cw20-staking/schema/raw/execute.json index 55766a6a8..82cf1d22b 100644 --- a/contracts/fungible-tokens/andromeda-cw20-staking/schema/raw/execute.json +++ b/contracts/fungible-tokens/andromeda-cw20-staking/schema/raw/execute.json @@ -445,7 +445,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AssetInfoBase_for_String": { "description": "Represents the type of an fungible asset.\n\nEach **asset info** instance can be one of three variants:\n\n- Native SDK coins. To create an **asset info** instance of this type, provide the denomination. - CW20 tokens. To create an **asset info** instance of this type, provide the contract address.", diff --git a/contracts/fungible-tokens/andromeda-cw20-staking/schema/raw/instantiate.json b/contracts/fungible-tokens/andromeda-cw20-staking/schema/raw/instantiate.json index 3bb1d98e5..ab36bb4c8 100644 --- a/contracts/fungible-tokens/andromeda-cw20-staking/schema/raw/instantiate.json +++ b/contracts/fungible-tokens/andromeda-cw20-staking/schema/raw/instantiate.json @@ -95,7 +95,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AssetInfoBase_for_String": { "description": "Represents the type of an fungible asset.\n\nEach **asset info** instance can be one of three variants:\n\n- Native SDK coins. To create an **asset info** instance of this type, provide the denomination. - CW20 tokens. To create an **asset info** instance of this type, provide the contract address.", diff --git a/contracts/fungible-tokens/andromeda-cw20-staking/schema/raw/query.json b/contracts/fungible-tokens/andromeda-cw20-staking/schema/raw/query.json index 935ffa69b..0ee0febf4 100644 --- a/contracts/fungible-tokens/andromeda-cw20-staking/schema/raw/query.json +++ b/contracts/fungible-tokens/andromeda-cw20-staking/schema/raw/query.json @@ -82,20 +82,6 @@ }, "additionalProperties": false }, - { - "description": "Queries the current timestamp.", - "type": "object", - "required": [ - "timestamp" - ], - "properties": { - "timestamp": { - "type": "object", - "additionalProperties": false - } - }, - "additionalProperties": false - }, { "type": "object", "required": [ @@ -320,7 +306,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AndromedaHook": { "oneOf": [ diff --git a/contracts/fungible-tokens/andromeda-cw20-staking/schema/raw/response_to_config.json b/contracts/fungible-tokens/andromeda-cw20-staking/schema/raw/response_to_config.json index d82052cd9..3cf450fa7 100644 --- a/contracts/fungible-tokens/andromeda-cw20-staking/schema/raw/response_to_config.json +++ b/contracts/fungible-tokens/andromeda-cw20-staking/schema/raw/response_to_config.json @@ -27,7 +27,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } } diff --git a/contracts/fungible-tokens/andromeda-cw20-staking/schema/raw/response_to_module.json b/contracts/fungible-tokens/andromeda-cw20-staking/schema/raw/response_to_module.json index 33d4a115b..c7b506914 100644 --- a/contracts/fungible-tokens/andromeda-cw20-staking/schema/raw/response_to_module.json +++ b/contracts/fungible-tokens/andromeda-cw20-staking/schema/raw/response_to_module.json @@ -26,7 +26,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } } diff --git a/contracts/fungible-tokens/andromeda-cw20-staking/src/contract.rs b/contracts/fungible-tokens/andromeda-cw20-staking/src/contract.rs index 9fb86a580..86550a8b2 100644 --- a/contracts/fungible-tokens/andromeda-cw20-staking/src/contract.rs +++ b/contracts/fungible-tokens/andromeda-cw20-staking/src/contract.rs @@ -96,9 +96,10 @@ pub fn instantiate( deps.storage, env, deps.api, + &deps.querier, info.clone(), BaseInstantiateMsg { - ado_type: "cw20-staking".to_string(), + ado_type: CONTRACT_NAME.to_string(), ado_version: CONTRACT_VERSION.to_string(), kernel_address: msg.kernel_address, owner: msg.owner, @@ -653,7 +654,6 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> Result { encode_binary(&query_stakers(deps, env, start_after, limit)?) } - QueryMsg::Timestamp {} => encode_binary(&query_timestamp(env)), _ => ADOContract::default().query(deps, env, msg), } } @@ -729,10 +729,6 @@ fn query_stakers( get_stakers(deps, &deps.querier, deps.api, &env, start, limit) } -fn query_timestamp(env: Env) -> u64 { - env.block.time.seconds() -} - #[cfg_attr(not(feature = "library"), entry_point)] pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result { // New version diff --git a/contracts/fungible-tokens/andromeda-cw20-staking/src/testing/mock_querier.rs b/contracts/fungible-tokens/andromeda-cw20-staking/src/testing/mock_querier.rs index 697de377b..93c022502 100644 --- a/contracts/fungible-tokens/andromeda-cw20-staking/src/testing/mock_querier.rs +++ b/contracts/fungible-tokens/andromeda-cw20-staking/src/testing/mock_querier.rs @@ -8,6 +8,7 @@ use cosmwasm_std::testing::{ mock_env, mock_info, MockApi, MockQuerier, MockStorage, MOCK_CONTRACT_ADDR, }; +use cosmwasm_std::QuerierWrapper; use cosmwasm_std::{ from_json, to_json_binary, Coin, ContractResult, Empty, OwnedDeps, Querier, QuerierResult, QueryRequest, SystemError, SystemResult, Uint128, WasmQuery, @@ -32,6 +33,7 @@ pub fn mock_dependencies_custom( &mut deps.storage, mock_env(), &deps.api, + &QuerierWrapper::new(&deps.querier), mock_info("sender", &[]), InstantiateMsg { ado_type: "cw20-staking".to_string(), diff --git a/contracts/fungible-tokens/andromeda-cw20-staking/src/testing/tests.rs b/contracts/fungible-tokens/andromeda-cw20-staking/src/testing/tests.rs index 00c6e3826..4250d20b4 100644 --- a/contracts/fungible-tokens/andromeda-cw20-staking/src/testing/tests.rs +++ b/contracts/fungible-tokens/andromeda-cw20-staking/src/testing/tests.rs @@ -82,7 +82,9 @@ fn test_instantiate() { assert_eq!( Response::new() .add_attribute("method", "instantiate") - .add_attribute("type", "cw20-staking"), + .add_attribute("type", "cw20-staking") + .add_attribute("kernel_address", MOCK_KERNEL_CONTRACT) + .add_attribute("owner", "owner"), res ); diff --git a/contracts/fungible-tokens/andromeda-cw20/schema/andromeda-cw20.json b/contracts/fungible-tokens/andromeda-cw20/schema/andromeda-cw20.json index 3b2a24e49..283eb860d 100644 --- a/contracts/fungible-tokens/andromeda-cw20/schema/andromeda-cw20.json +++ b/contracts/fungible-tokens/andromeda-cw20/schema/andromeda-cw20.json @@ -75,7 +75,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -863,7 +863,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -1678,7 +1678,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AndromedaHook": { "oneOf": [ @@ -2301,7 +2301,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } }, diff --git a/contracts/fungible-tokens/andromeda-cw20/schema/raw/execute.json b/contracts/fungible-tokens/andromeda-cw20/schema/raw/execute.json index c3e4671ba..73b2a417f 100644 --- a/contracts/fungible-tokens/andromeda-cw20/schema/raw/execute.json +++ b/contracts/fungible-tokens/andromeda-cw20/schema/raw/execute.json @@ -616,7 +616,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/fungible-tokens/andromeda-cw20/schema/raw/instantiate.json b/contracts/fungible-tokens/andromeda-cw20/schema/raw/instantiate.json index 947612b87..54bb26408 100644 --- a/contracts/fungible-tokens/andromeda-cw20/schema/raw/instantiate.json +++ b/contracts/fungible-tokens/andromeda-cw20/schema/raw/instantiate.json @@ -71,7 +71,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/fungible-tokens/andromeda-cw20/schema/raw/query.json b/contracts/fungible-tokens/andromeda-cw20/schema/raw/query.json index 0050f7ba4..8962244d4 100644 --- a/contracts/fungible-tokens/andromeda-cw20/schema/raw/query.json +++ b/contracts/fungible-tokens/andromeda-cw20/schema/raw/query.json @@ -374,7 +374,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AndromedaHook": { "oneOf": [ diff --git a/contracts/fungible-tokens/andromeda-cw20/schema/raw/response_to_module.json b/contracts/fungible-tokens/andromeda-cw20/schema/raw/response_to_module.json index 33d4a115b..c7b506914 100644 --- a/contracts/fungible-tokens/andromeda-cw20/schema/raw/response_to_module.json +++ b/contracts/fungible-tokens/andromeda-cw20/schema/raw/response_to_module.json @@ -26,7 +26,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } } diff --git a/contracts/fungible-tokens/andromeda-cw20/src/contract.rs b/contracts/fungible-tokens/andromeda-cw20/src/contract.rs index 3692b4dca..55b2224c6 100644 --- a/contracts/fungible-tokens/andromeda-cw20/src/contract.rs +++ b/contracts/fungible-tokens/andromeda-cw20/src/contract.rs @@ -34,23 +34,22 @@ pub fn instantiate( msg: InstantiateMsg, ) -> Result { let contract = ADOContract::default(); + let cw20_resp = cw20_instantiate(deps.branch(), env.clone(), info.clone(), msg.clone().into())?; let resp = contract.instantiate( deps.storage, - env.clone(), + env, deps.api, + &deps.querier, info.clone(), BaseInstantiateMsg { - ado_type: "cw20".to_string(), + ado_type: CONTRACT_NAME.to_string(), ado_version: CONTRACT_VERSION.to_string(), - kernel_address: msg.clone().kernel_address, + kernel_address: msg.kernel_address.clone(), owner: msg.clone().owner, }, )?; let modules_resp = - contract.register_modules(info.sender.as_str(), deps.storage, msg.clone().modules)?; - - let cw20_resp = cw20_instantiate(deps.branch(), env, info, msg.into())?; - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; + contract.register_modules(info.sender.as_str(), deps.storage, msg.modules)?; Ok(resp .add_submessages(modules_resp.messages) diff --git a/contracts/fungible-tokens/andromeda-cw20/src/testing/mock_querier.rs b/contracts/fungible-tokens/andromeda-cw20/src/testing/mock_querier.rs index 06280d647..4c115edab 100644 --- a/contracts/fungible-tokens/andromeda-cw20/src/testing/mock_querier.rs +++ b/contracts/fungible-tokens/andromeda-cw20/src/testing/mock_querier.rs @@ -10,8 +10,8 @@ pub use andromeda_std::testing::mock_querier::{MOCK_ADDRESS_LIST_CONTRACT, MOCK_ use cosmwasm_std::testing::{mock_env, mock_info, MockApi, MockQuerier, MockStorage}; use cosmwasm_std::{ from_json, to_json_binary, BankMsg, Binary, Coin, ContractResult, CosmosMsg, OwnedDeps, - Querier, QuerierResult, QueryRequest, Response, SubMsg, SystemError, SystemResult, Uint128, - WasmQuery, + Querier, QuerierResult, QuerierWrapper, QueryRequest, Response, SubMsg, SystemError, + SystemResult, Uint128, WasmQuery, }; pub const MOCK_CW20_CONTRACT: &str = "mock_cw20_contract"; @@ -36,6 +36,7 @@ pub fn mock_dependencies_custom( &mut deps.storage, mock_env(), &deps.api, + &QuerierWrapper::new(&deps.querier), mock_info("sender", &[]), InstantiateMsg { ado_type: "cw20".to_string(), diff --git a/contracts/fungible-tokens/andromeda-cw20/src/testing/tests.rs b/contracts/fungible-tokens/andromeda-cw20/src/testing/tests.rs index 1b36677f0..ba657affd 100644 --- a/contracts/fungible-tokens/andromeda-cw20/src/testing/tests.rs +++ b/contracts/fungible-tokens/andromeda-cw20/src/testing/tests.rs @@ -63,6 +63,8 @@ fn test_transfer() { Response::new() .add_attribute("method", "instantiate") .add_attribute("type", "cw20") + .add_attribute("kernel_address", MOCK_KERNEL_CONTRACT) + .add_attribute("owner", "owner") .add_attribute("action", "register_module") .add_attribute("module_idx", "1"), res @@ -138,7 +140,9 @@ fn test_send() { assert_eq!( Response::new() .add_attribute("method", "instantiate") - .add_attribute("type", "cw20"), + .add_attribute("type", "cw20") + .add_attribute("kernel_address", MOCK_KERNEL_CONTRACT) + .add_attribute("owner", "owner"), res ); diff --git a/contracts/fungible-tokens/andromeda-lockdrop/schema/andromeda-lockdrop.json b/contracts/fungible-tokens/andromeda-lockdrop/schema/andromeda-lockdrop.json index a457efd71..9bf12190c 100644 --- a/contracts/fungible-tokens/andromeda-lockdrop/schema/andromeda-lockdrop.json +++ b/contracts/fungible-tokens/andromeda-lockdrop/schema/andromeda-lockdrop.json @@ -71,7 +71,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Milliseconds": { "description": "Represents time in milliseconds.", @@ -486,7 +486,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -1188,7 +1188,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AndromedaHook": { "oneOf": [ @@ -1556,7 +1556,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } }, diff --git a/contracts/fungible-tokens/andromeda-lockdrop/schema/raw/execute.json b/contracts/fungible-tokens/andromeda-lockdrop/schema/raw/execute.json index bf318de55..dcb4e2758 100644 --- a/contracts/fungible-tokens/andromeda-lockdrop/schema/raw/execute.json +++ b/contracts/fungible-tokens/andromeda-lockdrop/schema/raw/execute.json @@ -380,7 +380,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/fungible-tokens/andromeda-lockdrop/schema/raw/instantiate.json b/contracts/fungible-tokens/andromeda-lockdrop/schema/raw/instantiate.json index 5b21a7a22..00f3090aa 100644 --- a/contracts/fungible-tokens/andromeda-lockdrop/schema/raw/instantiate.json +++ b/contracts/fungible-tokens/andromeda-lockdrop/schema/raw/instantiate.json @@ -67,7 +67,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Milliseconds": { "description": "Represents time in milliseconds.", diff --git a/contracts/fungible-tokens/andromeda-lockdrop/schema/raw/query.json b/contracts/fungible-tokens/andromeda-lockdrop/schema/raw/query.json index 4dcd71f7d..b8184eab9 100644 --- a/contracts/fungible-tokens/andromeda-lockdrop/schema/raw/query.json +++ b/contracts/fungible-tokens/andromeda-lockdrop/schema/raw/query.json @@ -302,7 +302,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AndromedaHook": { "oneOf": [ diff --git a/contracts/fungible-tokens/andromeda-lockdrop/schema/raw/response_to_module.json b/contracts/fungible-tokens/andromeda-lockdrop/schema/raw/response_to_module.json index 33d4a115b..c7b506914 100644 --- a/contracts/fungible-tokens/andromeda-lockdrop/schema/raw/response_to_module.json +++ b/contracts/fungible-tokens/andromeda-lockdrop/schema/raw/response_to_module.json @@ -26,7 +26,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } } diff --git a/contracts/fungible-tokens/andromeda-lockdrop/src/contract.rs b/contracts/fungible-tokens/andromeda-lockdrop/src/contract.rs index 8ed6ad1b8..cac09c29f 100644 --- a/contracts/fungible-tokens/andromeda-lockdrop/src/contract.rs +++ b/contracts/fungible-tokens/andromeda-lockdrop/src/contract.rs @@ -28,7 +28,7 @@ use cw_utils::nonpayable; use semver::Version; // version info for migration info -const CONTRACT_NAME: &str = "andromeda-lockdrop"; +const CONTRACT_NAME: &str = "crates.io:andromeda-lockdrop"; const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); //---------------------------------------------------------------------------------------- @@ -78,9 +78,10 @@ pub fn instantiate( deps.storage, env, deps.api, + &deps.querier, info.clone(), BaseInstantiateMsg { - ado_type: "lockdrop".to_string(), + ado_type: CONTRACT_NAME.to_string(), ado_version: CONTRACT_VERSION.to_string(), kernel_address: msg.kernel_address, owner: msg.owner, diff --git a/contracts/fungible-tokens/andromeda-lockdrop/src/testing/mock_querier.rs b/contracts/fungible-tokens/andromeda-lockdrop/src/testing/mock_querier.rs index 5b7338a67..40bd3984d 100644 --- a/contracts/fungible-tokens/andromeda-lockdrop/src/testing/mock_querier.rs +++ b/contracts/fungible-tokens/andromeda-lockdrop/src/testing/mock_querier.rs @@ -10,7 +10,7 @@ use cosmwasm_std::{ to_json_binary, Binary, Coin, ContractResult, OwnedDeps, Querier, QuerierResult, QueryRequest, SystemError, SystemResult, WasmQuery, }; -use cosmwasm_std::{BankMsg, CosmosMsg, Response, SubMsg, Uint128}; +use cosmwasm_std::{BankMsg, CosmosMsg, QuerierWrapper, Response, SubMsg, Uint128}; pub use andromeda_std::testing::mock_querier::{ MOCK_ADDRESS_LIST_CONTRACT, MOCK_APP_CONTRACT, MOCK_KERNEL_CONTRACT, MOCK_RATES_CONTRACT, @@ -47,6 +47,7 @@ pub fn mock_dependencies_custom( &mut deps.storage, mock_env(), &deps.api, + &QuerierWrapper::new(&deps.querier), mock_info("sender", &[]), InstantiateMsg { ado_type: "lockdrop".to_string(), diff --git a/contracts/fungible-tokens/andromeda-lockdrop/src/testing/tests.rs b/contracts/fungible-tokens/andromeda-lockdrop/src/testing/tests.rs index 82724bf35..cfb09e26b 100644 --- a/contracts/fungible-tokens/andromeda-lockdrop/src/testing/tests.rs +++ b/contracts/fungible-tokens/andromeda-lockdrop/src/testing/tests.rs @@ -54,7 +54,9 @@ fn test_instantiate() { assert_eq!( Response::new() .add_attribute("method", "instantiate") - .add_attribute("type", "lockdrop"), + .add_attribute("type", "lockdrop") + .add_attribute("kernel_address", MOCK_KERNEL_CONTRACT) + .add_attribute("owner", "owner"), res ); diff --git a/contracts/fungible-tokens/andromeda-merkle-airdrop/schema/andromeda-merkle-airdrop.json b/contracts/fungible-tokens/andromeda-merkle-airdrop/schema/andromeda-merkle-airdrop.json index 1942440ba..e7af2a70f 100644 --- a/contracts/fungible-tokens/andromeda-merkle-airdrop/schema/andromeda-merkle-airdrop.json +++ b/contracts/fungible-tokens/andromeda-merkle-airdrop/schema/andromeda-merkle-airdrop.json @@ -38,7 +38,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AssetInfoBase_for_String": { "description": "Represents the type of an fungible asset.\n\nEach **asset info** instance can be one of three variants:\n\n- Native SDK coins. To create an **asset info** instance of this type, provide the denomination. - CW20 tokens. To create an **asset info** instance of this type, provide the contract address.", @@ -498,7 +498,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -1202,7 +1202,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AndromedaHook": { "oneOf": [ @@ -1669,7 +1669,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } }, diff --git a/contracts/fungible-tokens/andromeda-merkle-airdrop/schema/raw/execute.json b/contracts/fungible-tokens/andromeda-merkle-airdrop/schema/raw/execute.json index ec9efb57d..85ac5f8b3 100644 --- a/contracts/fungible-tokens/andromeda-merkle-airdrop/schema/raw/execute.json +++ b/contracts/fungible-tokens/andromeda-merkle-airdrop/schema/raw/execute.json @@ -402,7 +402,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/fungible-tokens/andromeda-merkle-airdrop/schema/raw/instantiate.json b/contracts/fungible-tokens/andromeda-merkle-airdrop/schema/raw/instantiate.json index e53a7f8c1..4c1d2ce55 100644 --- a/contracts/fungible-tokens/andromeda-merkle-airdrop/schema/raw/instantiate.json +++ b/contracts/fungible-tokens/andromeda-merkle-airdrop/schema/raw/instantiate.json @@ -34,7 +34,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AssetInfoBase_for_String": { "description": "Represents the type of an fungible asset.\n\nEach **asset info** instance can be one of three variants:\n\n- Native SDK coins. To create an **asset info** instance of this type, provide the denomination. - CW20 tokens. To create an **asset info** instance of this type, provide the contract address.", diff --git a/contracts/fungible-tokens/andromeda-merkle-airdrop/schema/raw/query.json b/contracts/fungible-tokens/andromeda-merkle-airdrop/schema/raw/query.json index 043947466..a7e3096ab 100644 --- a/contracts/fungible-tokens/andromeda-merkle-airdrop/schema/raw/query.json +++ b/contracts/fungible-tokens/andromeda-merkle-airdrop/schema/raw/query.json @@ -325,7 +325,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AndromedaHook": { "oneOf": [ diff --git a/contracts/fungible-tokens/andromeda-merkle-airdrop/schema/raw/response_to_module.json b/contracts/fungible-tokens/andromeda-merkle-airdrop/schema/raw/response_to_module.json index 33d4a115b..c7b506914 100644 --- a/contracts/fungible-tokens/andromeda-merkle-airdrop/schema/raw/response_to_module.json +++ b/contracts/fungible-tokens/andromeda-merkle-airdrop/schema/raw/response_to_module.json @@ -26,7 +26,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } } diff --git a/contracts/fungible-tokens/andromeda-merkle-airdrop/src/contract.rs b/contracts/fungible-tokens/andromeda-merkle-airdrop/src/contract.rs index cd4d5f38e..76d4db1c3 100644 --- a/contracts/fungible-tokens/andromeda-merkle-airdrop/src/contract.rs +++ b/contracts/fungible-tokens/andromeda-merkle-airdrop/src/contract.rs @@ -56,9 +56,10 @@ pub fn instantiate( deps.storage, env, deps.api, + &deps.querier, info, BaseInstantiateMsg { - ado_type: "merkle-airdrop".to_string(), + ado_type: CONTRACT_NAME.to_string(), ado_version: CONTRACT_VERSION.to_string(), kernel_address: msg.kernel_address, owner: msg.owner, diff --git a/contracts/fungible-tokens/andromeda-merkle-airdrop/src/testing/mock_querier.rs b/contracts/fungible-tokens/andromeda-merkle-airdrop/src/testing/mock_querier.rs index 862e1003e..8af252c9e 100644 --- a/contracts/fungible-tokens/andromeda-merkle-airdrop/src/testing/mock_querier.rs +++ b/contracts/fungible-tokens/andromeda-merkle-airdrop/src/testing/mock_querier.rs @@ -6,7 +6,7 @@ use cosmwasm_std::testing::{ }; use cosmwasm_std::{ from_json, to_json_binary, Coin, ContractResult, Empty, OwnedDeps, Querier, QuerierResult, - QueryRequest, SystemError, SystemResult, Uint128, WasmQuery, + QuerierWrapper, QueryRequest, SystemError, SystemResult, Uint128, WasmQuery, }; use cw20::{BalanceResponse as Cw20BalanceResponse, Cw20QueryMsg}; use std::collections::HashMap; @@ -28,6 +28,7 @@ pub fn mock_dependencies_custom( &mut deps.storage, mock_env(), &deps.api, + &QuerierWrapper::new(&deps.querier), mock_info("sender", &[]), InstantiateMsg { ado_type: "cw20-staking".to_string(), diff --git a/contracts/modules/andromeda-address-list/schema/andromeda-address-list.json b/contracts/modules/andromeda-address-list/schema/andromeda-address-list.json index c528dee9c..758245c8a 100644 --- a/contracts/modules/andromeda-address-list/schema/andromeda-address-list.json +++ b/contracts/modules/andromeda-address-list/schema/andromeda-address-list.json @@ -330,7 +330,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -913,7 +913,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AndromedaHook": { "oneOf": [ diff --git a/contracts/modules/andromeda-address-list/schema/raw/execute.json b/contracts/modules/andromeda-address-list/schema/raw/execute.json index 44de22018..3ab5d8c1d 100644 --- a/contracts/modules/andromeda-address-list/schema/raw/execute.json +++ b/contracts/modules/andromeda-address-list/schema/raw/execute.json @@ -302,7 +302,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/modules/andromeda-address-list/schema/raw/query.json b/contracts/modules/andromeda-address-list/schema/raw/query.json index 36e672330..886d9e953 100644 --- a/contracts/modules/andromeda-address-list/schema/raw/query.json +++ b/contracts/modules/andromeda-address-list/schema/raw/query.json @@ -227,7 +227,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AndromedaHook": { "oneOf": [ diff --git a/contracts/modules/andromeda-address-list/src/contract.rs b/contracts/modules/andromeda-address-list/src/contract.rs index 376335516..0e672b8fb 100644 --- a/contracts/modules/andromeda-address-list/src/contract.rs +++ b/contracts/modules/andromeda-address-list/src/contract.rs @@ -16,7 +16,7 @@ use semver::Version; use crate::state::{add_address, includes_address, remove_address, IS_INCLUSIVE}; // version info for migration info -const CONTRACT_NAME: &str = "crates.io:andromeda-addresslist"; +const CONTRACT_NAME: &str = "crates.io:andromeda-address-list"; const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); #[cfg_attr(not(feature = "library"), entry_point)] @@ -33,9 +33,10 @@ pub fn instantiate( deps.storage, env, deps.api, + &deps.querier, info, BaseInstantiateMsg { - ado_type: "address-list".to_string(), + ado_type: CONTRACT_NAME.to_string(), ado_version: CONTRACT_VERSION.to_string(), kernel_address: msg.kernel_address, owner: msg.owner, diff --git a/contracts/modules/andromeda-address-list/src/testing/mock_querier.rs b/contracts/modules/andromeda-address-list/src/testing/mock_querier.rs index 12c015323..d61aedf1a 100644 --- a/contracts/modules/andromeda-address-list/src/testing/mock_querier.rs +++ b/contracts/modules/andromeda-address-list/src/testing/mock_querier.rs @@ -3,13 +3,13 @@ use andromeda_std::ado_base::InstantiateMsg; use andromeda_std::ado_contract::ADOContract; use andromeda_std::testing::mock_querier::MockAndromedaQuerier; use cosmwasm_std::testing::mock_info; -use cosmwasm_std::Response; use cosmwasm_std::{ from_json, testing::{mock_env, MockApi, MockQuerier, MockStorage, MOCK_CONTRACT_ADDR}, to_json_binary, Binary, Coin, ContractResult, OwnedDeps, Querier, QuerierResult, QueryRequest, SystemError, SystemResult, WasmQuery, }; +use cosmwasm_std::{QuerierWrapper, Response}; pub use andromeda_std::testing::mock_querier::{MOCK_ADDRESS_LIST_CONTRACT, MOCK_KERNEL_CONTRACT}; @@ -33,11 +33,11 @@ pub fn mock_dependencies_custom( &mut deps.storage, mock_env(), &deps.api, + &QuerierWrapper::new(&deps.querier), mock_info("sender", &[]), InstantiateMsg { - ado_type: "rates".to_string(), - ado_version: "test".to_string(), - + ado_type: "address-list".to_string(), + ado_version: "1.0.0".to_string(), kernel_address: MOCK_KERNEL_CONTRACT.to_string(), owner: None, }, diff --git a/contracts/modules/andromeda-rates/schema/andromeda-rates.json b/contracts/modules/andromeda-rates/schema/andromeda-rates.json index d0b798af4..ffd5eb053 100644 --- a/contracts/modules/andromeda-rates/schema/andromeda-rates.json +++ b/contracts/modules/andromeda-rates/schema/andromeda-rates.json @@ -32,7 +32,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -427,7 +427,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -1097,7 +1097,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AndromedaHook": { "oneOf": [ @@ -1431,7 +1431,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/modules/andromeda-rates/schema/raw/execute.json b/contracts/modules/andromeda-rates/schema/raw/execute.json index 715f770f6..62f41ba9b 100644 --- a/contracts/modules/andromeda-rates/schema/raw/execute.json +++ b/contracts/modules/andromeda-rates/schema/raw/execute.json @@ -257,7 +257,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/modules/andromeda-rates/schema/raw/instantiate.json b/contracts/modules/andromeda-rates/schema/raw/instantiate.json index 59123d0d7..59290a4db 100644 --- a/contracts/modules/andromeda-rates/schema/raw/instantiate.json +++ b/contracts/modules/andromeda-rates/schema/raw/instantiate.json @@ -28,7 +28,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/modules/andromeda-rates/schema/raw/query.json b/contracts/modules/andromeda-rates/schema/raw/query.json index f1beed8a3..5eb8cad0e 100644 --- a/contracts/modules/andromeda-rates/schema/raw/query.json +++ b/contracts/modules/andromeda-rates/schema/raw/query.json @@ -205,7 +205,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AndromedaHook": { "oneOf": [ diff --git a/contracts/modules/andromeda-rates/schema/raw/response_to_payments.json b/contracts/modules/andromeda-rates/schema/raw/response_to_payments.json index 45992cddd..bc2fcfe24 100644 --- a/contracts/modules/andromeda-rates/schema/raw/response_to_payments.json +++ b/contracts/modules/andromeda-rates/schema/raw/response_to_payments.json @@ -18,7 +18,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/modules/andromeda-rates/src/contract.rs b/contracts/modules/andromeda-rates/src/contract.rs index 55a04ed89..0519ea93d 100644 --- a/contracts/modules/andromeda-rates/src/contract.rs +++ b/contracts/modules/andromeda-rates/src/contract.rs @@ -41,9 +41,10 @@ pub fn instantiate( deps.storage, env, deps.api, + &deps.querier, info, BaseInstantiateMsg { - ado_type: "rates".to_string(), + ado_type: CONTRACT_NAME.to_string(), ado_version: CONTRACT_VERSION.to_string(), kernel_address: msg.kernel_address, owner: msg.owner, diff --git a/contracts/modules/andromeda-rates/src/testing/mock_querier.rs b/contracts/modules/andromeda-rates/src/testing/mock_querier.rs index a6ade2526..a3a36f27b 100644 --- a/contracts/modules/andromeda-rates/src/testing/mock_querier.rs +++ b/contracts/modules/andromeda-rates/src/testing/mock_querier.rs @@ -10,7 +10,7 @@ use cosmwasm_std::{ to_json_binary, Binary, Coin, ContractResult, OwnedDeps, Querier, QuerierResult, QueryRequest, SystemError, SystemResult, WasmQuery, }; -use cosmwasm_std::{BankMsg, CosmosMsg, Response, SubMsg, Uint128}; +use cosmwasm_std::{BankMsg, CosmosMsg, QuerierWrapper, Response, SubMsg, Uint128}; pub use andromeda_std::testing::mock_querier::{ MOCK_APP_CONTRACT, MOCK_KERNEL_CONTRACT, MOCK_RATES_CONTRACT, @@ -41,6 +41,7 @@ pub fn mock_dependencies_custom( &mut deps.storage, mock_env(), &deps.api, + &QuerierWrapper::new(&deps.querier), mock_info("sender", &[]), InstantiateMsg { ado_type: "rates".to_string(), diff --git a/contracts/non-fungible-tokens/andromeda-auction/schema/andromeda-auction.json b/contracts/non-fungible-tokens/andromeda-auction/schema/andromeda-auction.json index 751d37f94..79e09a6ad 100644 --- a/contracts/non-fungible-tokens/andromeda-auction/schema/andromeda-auction.json +++ b/contracts/non-fungible-tokens/andromeda-auction/schema/andromeda-auction.json @@ -43,7 +43,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Module": { "description": "A struct describing a token module, provided with the instantiation message this struct is used to record the info about the module and how/if it should be instantiated", @@ -149,7 +149,6 @@ "required": [ "coin_denom", "duration", - "start_time", "token_address", "token_id" ], @@ -173,7 +172,10 @@ ] }, "start_time": { - "type": "integer", + "type": [ + "integer", + "null" + ], "format": "uint64", "minimum": 0.0 }, @@ -575,7 +577,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -1423,7 +1425,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "OrderBy": { "type": "string", @@ -1944,7 +1946,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } }, diff --git a/contracts/non-fungible-tokens/andromeda-auction/schema/cw721receive.json b/contracts/non-fungible-tokens/andromeda-auction/schema/cw721receive.json index e20b8eafd..20a4aab53 100644 --- a/contracts/non-fungible-tokens/andromeda-auction/schema/cw721receive.json +++ b/contracts/non-fungible-tokens/andromeda-auction/schema/cw721receive.json @@ -13,8 +13,7 @@ "type": "object", "required": [ "coin_denom", - "duration", - "start_time" + "duration" ], "properties": { "coin_denom": { @@ -38,7 +37,10 @@ }, "start_time": { "description": "Start time in milliseconds since epoch", - "type": "integer", + "type": [ + "integer", + "null" + ], "format": "uint64", "minimum": 0.0 }, diff --git a/contracts/non-fungible-tokens/andromeda-auction/schema/raw/execute.json b/contracts/non-fungible-tokens/andromeda-auction/schema/raw/execute.json index c66d7dee3..da7e83181 100644 --- a/contracts/non-fungible-tokens/andromeda-auction/schema/raw/execute.json +++ b/contracts/non-fungible-tokens/andromeda-auction/schema/raw/execute.json @@ -77,7 +77,6 @@ "required": [ "coin_denom", "duration", - "start_time", "token_address", "token_id" ], @@ -101,7 +100,10 @@ ] }, "start_time": { - "type": "integer", + "type": [ + "integer", + "null" + ], "format": "uint64", "minimum": 0.0 }, @@ -503,7 +505,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/non-fungible-tokens/andromeda-auction/schema/raw/instantiate.json b/contracts/non-fungible-tokens/andromeda-auction/schema/raw/instantiate.json index 67e40eb63..71a33c4c4 100644 --- a/contracts/non-fungible-tokens/andromeda-auction/schema/raw/instantiate.json +++ b/contracts/non-fungible-tokens/andromeda-auction/schema/raw/instantiate.json @@ -39,7 +39,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Module": { "description": "A struct describing a token module, provided with the instantiation message this struct is used to record the info about the module and how/if it should be instantiated", diff --git a/contracts/non-fungible-tokens/andromeda-auction/schema/raw/query.json b/contracts/non-fungible-tokens/andromeda-auction/schema/raw/query.json index 41352f127..75b6c3910 100644 --- a/contracts/non-fungible-tokens/andromeda-auction/schema/raw/query.json +++ b/contracts/non-fungible-tokens/andromeda-auction/schema/raw/query.json @@ -448,7 +448,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "OrderBy": { "type": "string", diff --git a/contracts/non-fungible-tokens/andromeda-auction/schema/raw/response_to_module.json b/contracts/non-fungible-tokens/andromeda-auction/schema/raw/response_to_module.json index 33d4a115b..c7b506914 100644 --- a/contracts/non-fungible-tokens/andromeda-auction/schema/raw/response_to_module.json +++ b/contracts/non-fungible-tokens/andromeda-auction/schema/raw/response_to_module.json @@ -26,7 +26,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } } diff --git a/contracts/non-fungible-tokens/andromeda-auction/src/contract.rs b/contracts/non-fungible-tokens/andromeda-auction/src/contract.rs index 74bd9b313..7bcbcc453 100644 --- a/contracts/non-fungible-tokens/andromeda-auction/src/contract.rs +++ b/contracts/non-fungible-tokens/andromeda-auction/src/contract.rs @@ -15,25 +15,25 @@ use andromeda_std::{ common::{ actions::call_action, encode_binary, - expiration::{expiration_from_milliseconds, MILLISECONDS_TO_NANOSECONDS_RATIO}, + expiration::{expiration_from_milliseconds, get_and_validate_start_time}, rates::get_tax_amount, - Funds, OrderBy, + Funds, Milliseconds, OrderBy, }, error::{from_semver, ContractError}, }; use andromeda_std::{ado_contract::ADOContract, common::context::ExecuteContext}; use cosmwasm_std::{ - attr, coins, ensure, entry_point, from_json, Addr, BankMsg, Binary, BlockInfo, Coin, CosmosMsg, - Deps, DepsMut, Env, MessageInfo, QuerierWrapper, QueryRequest, Response, Storage, SubMsg, - Uint128, WasmMsg, WasmQuery, + attr, coins, ensure, entry_point, from_json, Addr, BankMsg, Binary, Coin, CosmosMsg, Deps, + DepsMut, Env, MessageInfo, QuerierWrapper, QueryRequest, Response, Storage, SubMsg, Uint128, + WasmMsg, WasmQuery, }; use cw2::{get_contract_version, set_contract_version}; use cw721::{Cw721ExecuteMsg, Cw721QueryMsg, Cw721ReceiveMsg, Expiration, OwnerOfResponse}; use cw_utils::nonpayable; use semver::Version; -const CONTRACT_NAME: &str = "crates.io:andromeda_auction"; +const CONTRACT_NAME: &str = "crates.io:andromeda-auction"; const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); const SEND_NFT_ACTION: &str = "SEND_NFT"; @@ -52,9 +52,10 @@ pub fn instantiate( deps.storage, env, deps.api, + &deps.querier, info.clone(), BaseInstantiateMsg { - ado_type: "auction".to_string(), + ado_type: CONTRACT_NAME.to_string(), ado_version: CONTRACT_VERSION.to_string(), kernel_address: msg.kernel_address, owner: msg.owner, @@ -219,32 +220,26 @@ fn execute_start_auction( ctx: ExecuteContext, sender: String, token_id: String, - start_time: u64, - duration: u64, + start_time: Option, + duration: Milliseconds, coin_denom: String, whitelist: Option>, min_bid: Option, ) -> Result { validate_denom(&ctx.deps.querier, coin_denom.clone())?; - ensure!( - start_time > 0 && duration > 0, - ContractError::InvalidExpiration {} - ); + ensure!(!duration.is_zero(), ContractError::InvalidExpiration {}); let ExecuteContext { deps, info, env, .. } = ctx; - let start_expiration = expiration_from_milliseconds(start_time)?; - let end_expiration = expiration_from_milliseconds(start_time + duration)?; + // If start time wasn't provided, it will be set as the current_time + let (start_expiration, current_time) = get_and_validate_start_time(&env, start_time)?; - let block_time = block_to_expiration(&env.block, start_expiration).unwrap(); - ensure!( - start_expiration.gt(&block_time), - ContractError::StartTimeInThePast { - current_time: env.block.time.nanos() / MILLISECONDS_TO_NANOSECONDS_RATIO, - current_block: env.block.height, - } - ); + let end_expiration = expiration_from_milliseconds( + start_time + .unwrap_or(current_time) + .plus_milliseconds(duration), + )?; let token_address = info.sender.to_string(); @@ -286,8 +281,8 @@ fn execute_update_auction( ctx: ExecuteContext, token_id: String, token_address: String, - start_time: u64, - duration: u64, + start_time: Option, + duration: Milliseconds, coin_denom: String, whitelist: Option>, min_bid: Option, @@ -308,22 +303,21 @@ fn execute_update_auction( ContractError::AuctionAlreadyStarted {} ); ensure!( - start_time > 0 && duration > 0, + duration > Milliseconds::zero(), ContractError::InvalidExpiration {} ); - let start_exp = expiration_from_milliseconds(start_time)?; - let end_exp = expiration_from_milliseconds(start_time + duration)?; - ensure!( - !start_exp.is_expired(&env.block), - ContractError::StartTimeInThePast { - current_time: env.block.time.nanos() / MILLISECONDS_TO_NANOSECONDS_RATIO, - current_block: env.block.height, - } - ); + // If start time wasn't provided, it will be set as the current_time + let (start_expiration, current_time) = get_and_validate_start_time(&env, start_time)?; + + let end_expiration = expiration_from_milliseconds( + start_time + .unwrap_or(current_time) + .plus_milliseconds(duration), + )?; - token_auction_state.start_time = start_exp; - token_auction_state.end_time = end_exp; + token_auction_state.start_time = start_expiration; + token_auction_state.end_time = end_expiration; token_auction_state.whitelist = whitelist.clone(); token_auction_state.coin_denom = coin_denom.clone(); token_auction_state.min_bid = min_bid; @@ -334,8 +328,8 @@ fn execute_update_auction( )?; Ok(Response::new().add_attributes(vec![ attr("action", "update_auction"), - attr("start_time", start_time.to_string()), - attr("end_time", end_exp.to_string()), + attr("start_time", start_expiration.to_string()), + attr("end_time", end_expiration.to_string()), attr("coin_denom", coin_denom), attr("auction_id", token_auction_state.auction_id.to_string()), attr("whitelist", format!("{:?}", &whitelist)), @@ -668,14 +662,6 @@ fn get_existing_token_auction_state( Ok(token_auction_state) } -fn block_to_expiration(block: &BlockInfo, model: Expiration) -> Option { - match model { - Expiration::AtTime(_) => Some(Expiration::AtTime(block.time)), - Expiration::AtHeight(_) => Some(Expiration::AtHeight(block.height)), - Expiration::Never {} => None, - } -} - fn get_and_increment_next_auction_id( storage: &mut dyn Storage, token_id: &str, diff --git a/contracts/non-fungible-tokens/andromeda-auction/src/mock.rs b/contracts/non-fungible-tokens/andromeda-auction/src/mock.rs index 81cb5b2f9..8658c9951 100644 --- a/contracts/non-fungible-tokens/andromeda-auction/src/mock.rs +++ b/contracts/non-fungible-tokens/andromeda-auction/src/mock.rs @@ -4,6 +4,7 @@ use crate::contract::{execute, instantiate, query}; use andromeda_non_fungible_tokens::auction::{Cw721HookMsg, ExecuteMsg, InstantiateMsg, QueryMsg}; use andromeda_std::ado_base::permissioning::{Permission, PermissioningMessage}; use andromeda_std::amp::messages::AMPPkt; +use andromeda_std::common::Milliseconds; use andromeda_std::{ado_base::modules::Module, amp::AndrAddr}; use cosmwasm_std::{Addr, Empty, Uint128}; use cw_multi_test::{Contract, ContractWrapper}; @@ -29,8 +30,8 @@ pub fn mock_auction_instantiate_msg( } pub fn mock_start_auction( - start_time: u64, - duration: u64, + start_time: Option, + duration: Milliseconds, coin_denom: String, min_bid: Option, whitelist: Option>, diff --git a/contracts/non-fungible-tokens/andromeda-auction/src/testing/mock_querier.rs b/contracts/non-fungible-tokens/andromeda-auction/src/testing/mock_querier.rs index ea8271f52..8320916bd 100644 --- a/contracts/non-fungible-tokens/andromeda-auction/src/testing/mock_querier.rs +++ b/contracts/non-fungible-tokens/andromeda-auction/src/testing/mock_querier.rs @@ -12,7 +12,9 @@ use cosmwasm_std::{ to_json_binary, Binary, Coin, ContractResult, OwnedDeps, Querier, QuerierResult, QueryRequest, SystemError, SystemResult, WasmQuery, }; -use cosmwasm_std::{BankMsg, CosmosMsg, DenomMetadata, DenomUnit, Response, SubMsg}; +use cosmwasm_std::{ + BankMsg, CosmosMsg, DenomMetadata, DenomUnit, QuerierWrapper, Response, SubMsg, +}; use cw721::{Cw721QueryMsg, OwnerOfResponse, TokensResponse}; pub use andromeda_std::testing::mock_querier::{ @@ -51,6 +53,7 @@ pub fn mock_dependencies_custom( &mut deps.storage, mock_env(), &deps.api, + &QuerierWrapper::new(&deps.querier), mock_info("sender", &[]), InstantiateMsg { ado_type: "crowdfund".to_string(), diff --git a/contracts/non-fungible-tokens/andromeda-auction/src/testing/tests.rs b/contracts/non-fungible-tokens/andromeda-auction/src/testing/tests.rs index f1db53cd3..5c8a78492 100644 --- a/contracts/non-fungible-tokens/andromeda-auction/src/testing/tests.rs +++ b/contracts/non-fungible-tokens/andromeda-auction/src/testing/tests.rs @@ -16,7 +16,9 @@ use andromeda_non_fungible_tokens::{ use andromeda_std::{ ado_base::modules::Module, amp::AndrAddr, - common::{encode_binary, expiration::MILLISECONDS_TO_NANOSECONDS_RATIO, reply::ReplyId}, + common::{ + encode_binary, expiration::MILLISECONDS_TO_NANOSECONDS_RATIO, reply::ReplyId, Milliseconds, + }, error::ContractError, os::economics::ExecuteMsg as EconomicsExecuteMsg, testing::mock_querier::MOCK_KERNEL_CONTRACT, @@ -30,31 +32,12 @@ use cosmwasm_std::{ use cw721::Cw721ReceiveMsg; use cw_utils::Expiration; -// const ADDRESS_LIST: &str = "addresslist"; -// const RATES: &str = "rates"; - fn init(deps: DepsMut, modules: Option>) -> Response { let msg = InstantiateMsg { owner: None, modules, kernel_address: MOCK_KERNEL_CONTRACT.to_string(), - authorized_token_addresses: None, - }; - - let info = mock_info("owner", &[]); - instantiate(deps, mock_env(), info, msg).unwrap() -} - -fn init_with_authorized_token_addresses( - deps: DepsMut, - modules: Option>, - authorized_token_addresses: Option>, -) -> Response { - let msg = InstantiateMsg { - owner: None, - modules, - kernel_address: MOCK_KERNEL_CONTRACT.to_string(), - authorized_token_addresses, + authorized_token_addresses: Some(vec![AndrAddr::from_string(MOCK_TOKEN_ADDR)]), }; let info = mock_info("owner", &[]); @@ -71,8 +54,8 @@ fn query_latest_auction_state_helper(deps: Deps, env: Env) -> AuctionStateRespon fn start_auction(deps: DepsMut, whitelist: Option>, min_bid: Option) { let hook_msg = Cw721HookMsg::StartAuction { - start_time: 100000, - duration: 100000, + start_time: None, + duration: Milliseconds(10_000), coin_denom: "uusd".to_string(), whitelist, min_bid, @@ -82,18 +65,21 @@ fn start_auction(deps: DepsMut, whitelist: Option>, min_bid: Option>, min_bid: Option) { + let current_time = mock_env().block.time.nanos() / MILLISECONDS_TO_NANOSECONDS_RATIO; + let duration = 10_000; assert_eq!( TokenAuctionState { - start_time: Expiration::AtTime(Timestamp::from_seconds(100)), - end_time: Expiration::AtTime(Timestamp::from_seconds(200)), + start_time: Expiration::AtTime(Timestamp::from_nanos((current_time + 1) * 1_000_000)), + end_time: Expiration::AtTime(Timestamp::from_nanos( + (current_time + duration) * 1_000_000 + )), high_bidder_addr: Addr::unchecked(""), high_bidder_amount: Uint128::zero(), coin_denom: "uusd".to_string(), @@ -180,7 +166,7 @@ fn execute_place_bid_auction_ended() { token_address: MOCK_TOKEN_ADDR.to_string(), }; - env.block.time = Timestamp::from_seconds(300); + env.block.time = env.block.time.plus_days(1); let info = mock_info("sender", &coins(100, "uusd".to_string())); let res = execute(deps.as_mut(), env, info, msg); @@ -200,9 +186,7 @@ fn execute_place_bid_token_owner_cannot_bid() { token_id: MOCK_UNCLAIMED_TOKEN.to_owned(), token_address: MOCK_TOKEN_ADDR.to_string(), }; - - env.block.time = Timestamp::from_seconds(150); - + env.block.time = env.block.time.plus_seconds(1); let info = mock_info(MOCK_TOKEN_OWNER, &coins(100, "uusd".to_string())); let res = execute(deps.as_mut(), env, info, msg); assert_eq!(ContractError::TokenOwnerCannotBid {}, res.unwrap_err()); @@ -222,8 +206,8 @@ fn execute_place_bid_whitelist() { token_address: MOCK_TOKEN_ADDR.to_string(), }; - env.block.time = Timestamp::from_seconds(150); let info = mock_info("not_sender", &coins(100, "uusd".to_string())); + env.block.time = env.block.time.plus_seconds(1); let res = execute(deps.as_mut(), env.clone(), info, msg.clone()); assert_eq!(ContractError::Unauthorized {}, res.unwrap_err()); @@ -245,11 +229,10 @@ fn execute_place_bid_highest_bidder_cannot_outbid() { token_address: MOCK_TOKEN_ADDR.to_string(), }; - env.block.time = Timestamp::from_seconds(150); + env.block.time = env.block.time.plus_seconds(1); let info = mock_info("sender", &coins(100, "uusd".to_string())); let _res = execute(deps.as_mut(), env.clone(), info, msg.clone()).unwrap(); - - env.block.time = Timestamp::from_seconds(160); + env.block.time = env.block.time.plus_seconds(2); let info = mock_info("sender", &coins(200, "uusd".to_string())); let res = execute(deps.as_mut(), env, info, msg); assert_eq!( @@ -272,11 +255,11 @@ fn execute_place_bid_bid_smaller_than_highest_bid() { token_address: MOCK_TOKEN_ADDR.to_string(), }; - env.block.time = Timestamp::from_seconds(150); + env.block.time = env.block.time.plus_seconds(1); let info = mock_info("sender", &coins(100, "uusd".to_string())); let _res = execute(deps.as_mut(), env.clone(), info, msg.clone()).unwrap(); - env.block.time = Timestamp::from_seconds(160); + env.block.time = env.block.time.plus_seconds(2); let info = mock_info("other", &coins(50, "uusd".to_string())); let res = execute(deps.as_mut(), env, info, msg); assert_eq!(ContractError::BidSmallerThanHighestBid {}, res.unwrap_err()); @@ -291,8 +274,6 @@ fn execute_place_bid_invalid_coins_sent() { start_auction(deps.as_mut(), None, None); assert_auction_created(deps.as_ref(), None, None); - env.block.time = Timestamp::from_seconds(150); - let error = ContractError::InvalidFunds { msg: "Auctions ensure! exactly one coin to be sent.".to_string(), }; @@ -300,6 +281,7 @@ fn execute_place_bid_invalid_coins_sent() { token_id: MOCK_UNCLAIMED_TOKEN.to_string(), token_address: MOCK_TOKEN_ADDR.to_string(), }; + env.block.time = env.block.time.plus_seconds(1); // No coins sent let info = mock_info("sender", &[]); @@ -339,9 +321,7 @@ fn execute_place_bid_multiple_bids() { token_id: MOCK_UNCLAIMED_TOKEN.to_owned(), token_address: MOCK_TOKEN_ADDR.to_string(), }; - - env.block.time = Timestamp::from_seconds(150); - + env.block.time = env.block.time.plus_seconds(1); let info = mock_info("sender", &coins(100, "uusd".to_string())); let res = execute(deps.as_mut(), env.clone(), info.clone(), msg.clone()).unwrap(); @@ -369,8 +349,8 @@ fn execute_place_bid_multiple_bids() { res ); let mut expected_response = AuctionStateResponse { - start_time: Expiration::AtTime(Timestamp::from_seconds(100)), - end_time: Expiration::AtTime(Timestamp::from_seconds(200)), + start_time: Expiration::AtTime(Timestamp::from_nanos(1571797419880000000)), + end_time: Expiration::AtTime(Timestamp::from_nanos(1571797429879000000)), high_bidder_addr: "sender".to_string(), high_bidder_amount: Uint128::from(100u128), auction_id: Uint128::from(1u128), @@ -383,7 +363,7 @@ fn execute_place_bid_multiple_bids() { let res = query_latest_auction_state_helper(deps.as_ref(), env.clone()); assert_eq!(expected_response, res); - env.block.time = Timestamp::from_seconds(160); + env.block.time = env.block.time.plus_seconds(2); let info = mock_info("other", &coins(200, "uusd".to_string())); let res = execute(deps.as_mut(), env.clone(), info.clone(), msg.clone()).unwrap(); assert_eq!( @@ -419,7 +399,7 @@ fn execute_place_bid_multiple_bids() { let res = query_latest_auction_state_helper(deps.as_ref(), env.clone()); assert_eq!(expected_response, res); - env.block.time = Timestamp::from_seconds(170); + env.block.time = env.block.time.plus_seconds(3); let info = mock_info("sender", &coins(250, "uusd".to_string())); let res = execute(deps.as_mut(), env.clone(), info.clone(), msg).unwrap(); @@ -460,7 +440,7 @@ fn execute_place_bid_multiple_bids() { #[test] fn execute_place_bid_auction_cancelled() { let mut deps = mock_dependencies_custom(&[]); - let mut env = mock_env(); + let env = mock_env(); let _res = init(deps.as_mut(), None); start_auction(deps.as_mut(), None, None); @@ -471,7 +451,6 @@ fn execute_place_bid_auction_cancelled() { token_address: MOCK_TOKEN_ADDR.to_string(), }; - env.block.time = Timestamp::from_seconds(150); let info = mock_info(MOCK_TOKEN_OWNER, &[]); let _res = execute(deps.as_mut(), env.clone(), info, msg).unwrap(); @@ -487,65 +466,9 @@ fn execute_place_bid_auction_cancelled() { #[test] fn test_execute_start_auction() { - let hook_msg = Cw721HookMsg::StartAuction { - start_time: 100000, - duration: 100000, - coin_denom: "uusd".to_string(), - whitelist: None, - min_bid: None, - }; - let msg = ExecuteMsg::ReceiveNft(Cw721ReceiveMsg { - sender: MOCK_TOKEN_OWNER.to_owned(), - token_id: MOCK_UNCLAIMED_TOKEN.to_owned(), - msg: encode_binary(&hook_msg).unwrap(), - }); - let mut env = mock_env(); - env.block.time = Timestamp::from_seconds(0u64); - - let info = mock_info(MOCK_TOKEN_ADDR, &[]); - - // Test when auction is permissioned - let mut deps = mock_dependencies_custom(&[]); - let authorized_token_addresses = Some(vec![AndrAddr::from_string("some_other_nft")]); - init_with_authorized_token_addresses(deps.as_mut(), None, authorized_token_addresses); - let err = execute(deps.as_mut(), env.clone(), info.clone(), msg.clone()).unwrap_err(); - assert_eq!(ContractError::Unauthorized {}, err,); - - let authorized_token_addresses = Some(vec![AndrAddr::from_string(MOCK_TOKEN_ADDR)]); - init_with_authorized_token_addresses(deps.as_mut(), None, authorized_token_addresses); - let res = execute(deps.as_mut(), env.clone(), info.clone(), msg.clone()).unwrap(); - assert_eq!(res.messages.len(), 1); - - // Unpermissioned Contract let mut deps = mock_dependencies_custom(&[]); let _res = init(deps.as_mut(), None); - let res = execute(deps.as_mut(), env, info, msg).unwrap(); - - assert_eq!( - res, - Response::new() - .add_attributes(vec![ - attr("action", "start_auction"), - attr("start_time", "expiration time: 100.000000000"), - attr("end_time", "expiration time: 200.000000000"), - attr("coin_denom", "uusd"), - attr("auction_id", "1"), - attr("whitelist", "None"), - ]) - // Economics message - .add_submessage(SubMsg::reply_on_error( - CosmosMsg::Wasm(WasmMsg::Execute { - contract_addr: "economics_contract".to_string(), - msg: to_json_binary(&EconomicsExecuteMsg::PayFee { - payee: Addr::unchecked(MOCK_TOKEN_ADDR), - action: "ReceiveNft".to_string() - }) - .unwrap(), - funds: vec![], - }), - ReplyId::PayFee.repr(), - )), - ); + start_auction(deps.as_mut(), None, None); assert_auction_created(deps.as_ref(), None, None); } @@ -626,8 +549,8 @@ fn execute_start_auction_start_time_in_past() { let _res = init(deps.as_mut(), None); let hook_msg = Cw721HookMsg::StartAuction { - start_time: 100000, - duration: 100000, + start_time: Some(Milliseconds(100000)), + duration: Milliseconds(100000), coin_denom: "uusd".to_string(), whitelist: None, min_bid: None, @@ -637,8 +560,7 @@ fn execute_start_auction_start_time_in_past() { token_id: MOCK_UNCLAIMED_TOKEN.to_owned(), msg: encode_binary(&hook_msg).unwrap(), }); - let mut env = mock_env(); - env.block.time = Timestamp::from_seconds(150); + let env = mock_env(); let info = mock_info(MOCK_TOKEN_ADDR, &[]); let res = execute(deps.as_mut(), env.clone(), info, msg); @@ -658,8 +580,8 @@ fn execute_start_auction_zero_start_time() { let _res = init(deps.as_mut(), None); let hook_msg = Cw721HookMsg::StartAuction { - start_time: 0, - duration: 1, + start_time: Some(Milliseconds::zero()), + duration: Milliseconds(1), coin_denom: "uusd".to_string(), whitelist: None, min_bid: None, @@ -669,13 +591,40 @@ fn execute_start_auction_zero_start_time() { token_id: MOCK_UNCLAIMED_TOKEN.to_owned(), msg: encode_binary(&hook_msg).unwrap(), }); - let mut env = mock_env(); - env.block.time = Timestamp::from_seconds(0); let info = mock_info(MOCK_TOKEN_ADDR, &[]); - let res = execute(deps.as_mut(), env, info, msg); + let res = execute(deps.as_mut(), mock_env(), info, msg); - assert_eq!(ContractError::InvalidExpiration {}, res.unwrap_err()); + assert_eq!( + ContractError::StartTimeInThePast { + current_time: 1571797419879, + current_block: 12345 + }, + res.unwrap_err() + ); +} + +#[test] +fn execute_start_auction_start_time_not_provided() { + let mut deps = mock_dependencies_custom(&[]); + let _res = init(deps.as_mut(), None); + + let hook_msg = Cw721HookMsg::StartAuction { + start_time: None, + duration: Milliseconds(1), + coin_denom: "uusd".to_string(), + whitelist: None, + min_bid: None, + }; + let msg = ExecuteMsg::ReceiveNft(Cw721ReceiveMsg { + sender: MOCK_TOKEN_OWNER.to_owned(), + token_id: MOCK_UNCLAIMED_TOKEN.to_owned(), + msg: encode_binary(&hook_msg).unwrap(), + }); + + let info = mock_info(MOCK_TOKEN_ADDR, &[]); + let res = execute(deps.as_mut(), mock_env(), info, msg); + assert!(res.is_ok()) } #[test] @@ -684,8 +633,8 @@ fn execute_start_auction_zero_duration() { let _res = init(deps.as_mut(), None); let hook_msg = Cw721HookMsg::StartAuction { - start_time: 100, - duration: 0, + start_time: Some(Milliseconds(100)), + duration: Milliseconds::zero(), coin_denom: "uusd".to_string(), whitelist: None, min_bid: None, @@ -743,49 +692,22 @@ fn execute_update_auction_zero_start() { let msg = ExecuteMsg::UpdateAuction { token_id: MOCK_UNCLAIMED_TOKEN.to_owned(), token_address: MOCK_TOKEN_ADDR.to_string(), - start_time: 0, - duration: 1, + start_time: Some(Milliseconds::zero()), + duration: Milliseconds(1), coin_denom: "uusd".to_string(), whitelist: None, min_bid: None, }; let mut env = mock_env(); - env.block.height = 0; - env.block.time = Timestamp::from_seconds(0); + env.block.time = env.block.time.minus_days(1); let info = mock_info(MOCK_TOKEN_OWNER, &[]); let res = execute(deps.as_mut(), env, info, msg); - assert_eq!(ContractError::InvalidExpiration {}, res.unwrap_err()); -} - -#[test] -fn execute_update_auction_start_time_in_past() { - let mut deps = mock_dependencies_custom(&[]); - let _res = init(deps.as_mut(), None); - - start_auction(deps.as_mut(), None, None); - - let msg = ExecuteMsg::UpdateAuction { - token_id: MOCK_UNCLAIMED_TOKEN.to_owned(), - token_address: MOCK_TOKEN_ADDR.to_string(), - start_time: 1, - duration: 1, - coin_denom: "uusd".to_string(), - whitelist: None, - min_bid: None, - }; - let mut env = mock_env(); - env.block.height = 150; - env.block.time = Timestamp::from_seconds(10); - - let info = mock_info(MOCK_TOKEN_OWNER, &[]); - let res = execute(deps.as_mut(), env.clone(), info, msg); - assert_eq!( ContractError::StartTimeInThePast { - current_time: env.block.time.nanos() / MILLISECONDS_TO_NANOSECONDS_RATIO, - current_block: env.block.height, + current_time: 1571711019879, + current_block: 12345 }, res.unwrap_err() ); @@ -801,8 +723,8 @@ fn execute_update_auction_zero_duration() { let msg = ExecuteMsg::UpdateAuction { token_id: MOCK_UNCLAIMED_TOKEN.to_owned(), token_address: MOCK_TOKEN_ADDR.to_string(), - start_time: 100000, - duration: 0, + start_time: Some(Milliseconds(100000)), + duration: Milliseconds::zero(), coin_denom: "uusd".to_string(), whitelist: None, min_bid: None, @@ -826,15 +748,13 @@ fn execute_update_auction_unauthorized() { let msg = ExecuteMsg::UpdateAuction { token_id: MOCK_UNCLAIMED_TOKEN.to_owned(), token_address: MOCK_TOKEN_ADDR.to_string(), - start_time: 100000, - duration: 100, + start_time: Some(Milliseconds(100000)), + duration: Milliseconds(100), coin_denom: "uluna".to_string(), whitelist: Some(vec![Addr::unchecked("user")]), min_bid: None, }; - let mut env = mock_env(); - env.block.time = Timestamp::from_seconds(150); - env.block.height = 0; + let env = mock_env(); let info = mock_info("not_owner", &[]); let res = execute(deps.as_mut(), env, info, msg); @@ -851,17 +771,17 @@ fn execute_update_auction_auction_started() { let msg = ExecuteMsg::UpdateAuction { token_id: MOCK_UNCLAIMED_TOKEN.to_owned(), token_address: MOCK_TOKEN_ADDR.to_string(), - start_time: 100000, - duration: 100, + start_time: Some(Milliseconds(100000)), + duration: Milliseconds(100), coin_denom: "uluna".to_string(), whitelist: Some(vec![Addr::unchecked("user")]), min_bid: None, }; let mut env = mock_env(); - env.block.time = Timestamp::from_seconds(150); - env.block.height = 0; let info = mock_info(MOCK_TOKEN_OWNER, &[]); + env.block.time = env.block.time.plus_days(1); + let res = execute(deps.as_mut(), env, info, msg); assert_eq!(ContractError::AuctionAlreadyStarted {}, res.unwrap_err()); } @@ -876,22 +796,22 @@ fn execute_update_auction() { let msg = ExecuteMsg::UpdateAuction { token_id: MOCK_UNCLAIMED_TOKEN.to_owned(), token_address: MOCK_TOKEN_ADDR.to_string(), - start_time: 100000, - duration: 100000, + start_time: Some(Milliseconds(1571711019879 + 1)), + duration: Milliseconds(100000), coin_denom: "uluna".to_string(), whitelist: Some(vec![Addr::unchecked("user")]), min_bid: None, }; let mut env = mock_env(); - env.block.time = Timestamp::from_seconds(0); - env.block.height = 0; + + env.block.time = env.block.time.minus_days(1); let info = mock_info(MOCK_TOKEN_OWNER, &[]); let _res = execute(deps.as_mut(), env, info, msg).unwrap(); assert_eq!( TokenAuctionState { - start_time: Expiration::AtTime(Timestamp::from_seconds(100)), - end_time: Expiration::AtTime(Timestamp::from_seconds(200)), + start_time: Expiration::AtTime(Timestamp::from_nanos(1571711019880000000)), + end_time: Expiration::AtTime(Timestamp::from_nanos(1571711119880000000)), high_bidder_addr: Addr::unchecked(""), high_bidder_amount: Uint128::zero(), coin_denom: "uluna".to_string(), @@ -918,8 +838,8 @@ fn execute_start_auction_after_previous_finished() { start_auction(deps.as_mut(), None, None); let hook_msg = Cw721HookMsg::StartAuction { - start_time: 300000, - duration: 100000, + start_time: None, + duration: Milliseconds(100000), coin_denom: "uusd".to_string(), whitelist: None, min_bid: None, @@ -930,7 +850,8 @@ fn execute_start_auction_after_previous_finished() { msg: encode_binary(&hook_msg).unwrap(), }); let mut env = mock_env(); - env.block.time = Timestamp::from_seconds(250); + // Auction ended by that time + env.block.time = env.block.time.plus_days(1); let info = mock_info(MOCK_TOKEN_ADDR, &[]); let res = execute(deps.as_mut(), env, info, msg).unwrap(); @@ -938,13 +859,12 @@ fn execute_start_auction_after_previous_finished() { Response::new() .add_attributes(vec![ attr("action", "start_auction"), - attr("start_time", "expiration time: 300.000000000"), - attr("end_time", "expiration time: 400.000000000"), + attr("start_time", "expiration time: 1571883819.880000000"), + attr("end_time", "expiration time: 1571883919.879000000"), attr("coin_denom", "uusd"), attr("auction_id", "2"), attr("whitelist", "None"), - ]) - // Economics message + ]) // Economics message .add_submessage(SubMsg::reply_on_error( CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: "economics_contract".to_string(), @@ -969,7 +889,8 @@ fn execute_claim_no_bids() { start_auction(deps.as_mut(), None, None); - env.block.time = Timestamp::from_seconds(250); + // Auction ended by that time + env.block.time = env.block.time.plus_days(1); let msg = ExecuteMsg::Claim { token_id: MOCK_UNCLAIMED_TOKEN.to_owned(), @@ -1025,12 +946,13 @@ fn execute_claim() { token_address: MOCK_TOKEN_ADDR.to_string(), }; - env.block.time = Timestamp::from_seconds(150); - let info = mock_info("sender", &coins(100, "uusd".to_string())); + env.block.time = env.block.time.plus_seconds(1); + let _res = execute(deps.as_mut(), env.clone(), info, msg).unwrap(); - env.block.time = Timestamp::from_seconds(250); + // Auction ended by that time + env.block.time = env.block.time.plus_days(1); let msg = ExecuteMsg::Claim { token_id: MOCK_UNCLAIMED_TOKEN.to_owned(), @@ -1090,9 +1012,9 @@ fn execute_claim_auction_not_ended() { token_address: MOCK_TOKEN_ADDR.to_string(), }; - env.block.time = Timestamp::from_seconds(150); - let info = mock_info("sender", &coins(100, "uusd".to_string())); + env.block.time = env.block.time.plus_seconds(1); + let _res = execute(deps.as_mut(), env.clone(), info, msg).unwrap(); let msg = ExecuteMsg::Claim { @@ -1111,8 +1033,8 @@ fn execute_claim_auction_already_claimed() { let _res = init(deps.as_mut(), None); let hook_msg = Cw721HookMsg::StartAuction { - start_time: 100000, - duration: 100000, + start_time: None, + duration: Milliseconds(100000), coin_denom: "uusd".to_string(), whitelist: None, min_bid: None, @@ -1123,13 +1045,12 @@ fn execute_claim_auction_already_claimed() { msg: encode_binary(&hook_msg).unwrap(), }); let mut env = mock_env(); - env.block.time = Timestamp::from_seconds(0u64); let info = mock_info(MOCK_TOKEN_ADDR, &[]); let _res = execute(deps.as_mut(), env.clone(), info, msg).unwrap(); // Auction is over. - env.block.time = Timestamp::from_seconds(300); + env.block.time = env.block.time.plus_days(1); let msg = ExecuteMsg::Claim { token_id: "claimed_token".to_string(), @@ -1144,7 +1065,7 @@ fn execute_claim_auction_already_claimed() { #[test] fn execute_cancel_no_bids() { let mut deps = mock_dependencies_custom(&[]); - let mut env = mock_env(); + let env = mock_env(); let _res = init(deps.as_mut(), None); start_auction(deps.as_mut(), None, None); @@ -1154,9 +1075,6 @@ fn execute_cancel_no_bids() { token_address: MOCK_TOKEN_ADDR.to_string(), }; - // Auction start and end are 100 and 200. - env.block.time = Timestamp::from_seconds(150); - let info = mock_info(MOCK_TOKEN_OWNER, &[]); let res = execute(deps.as_mut(), env, info, msg).unwrap(); @@ -1207,10 +1125,10 @@ fn execute_cancel_with_bids() { token_id: MOCK_UNCLAIMED_TOKEN.to_owned(), token_address: MOCK_TOKEN_ADDR.to_string(), }; - // Auction start and end are 100 and 200. - env.block.time = Timestamp::from_seconds(150); let info = mock_info("bidder", &coins(100, "uusd")); + env.block.time = env.block.time.plus_seconds(1); + let _res = execute(deps.as_mut(), env.clone(), info, msg).unwrap(); let msg = ExecuteMsg::CancelAuction { @@ -1263,7 +1181,7 @@ fn execute_cancel_with_bids() { #[test] fn execute_cancel_not_token_owner() { let mut deps = mock_dependencies_custom(&[]); - let mut env = mock_env(); + let env = mock_env(); let _res = init(deps.as_mut(), None); start_auction(deps.as_mut(), None, None); @@ -1273,9 +1191,6 @@ fn execute_cancel_not_token_owner() { token_address: MOCK_TOKEN_ADDR.to_string(), }; - // Auction start and end are 100 and 200. - env.block.time = Timestamp::from_seconds(150); - let info = mock_info("anyone", &[]); let res = execute(deps.as_mut(), env, info, msg); assert_eq!(ContractError::Unauthorized {}, res.unwrap_err()); @@ -1294,8 +1209,7 @@ fn execute_cancel_auction_ended() { token_address: MOCK_TOKEN_ADDR.to_string(), }; - // Auction start and end are 100 and 200. - env.block.time = Timestamp::from_seconds(300); + env.block.time = env.block.time.plus_days(1); let info = mock_info(MOCK_TOKEN_OWNER, &[]); let res = execute(deps.as_mut(), env, info, msg); @@ -1314,10 +1228,9 @@ fn execute_bid_below_min_price() { token_id: MOCK_UNCLAIMED_TOKEN.to_owned(), token_address: MOCK_TOKEN_ADDR.to_string(), }; - // Auction start and end are 100 and 200. - env.block.time = Timestamp::from_seconds(150); let info = mock_info("bidder", &coins(10, "uusd")); + env.block.time = env.block.time.plus_seconds(1); let res = execute(deps.as_mut(), env.clone(), info, msg.clone()).unwrap_err(); assert_eq!( diff --git a/contracts/non-fungible-tokens/andromeda-crowdfund/schema/andromeda-crowdfund.json b/contracts/non-fungible-tokens/andromeda-crowdfund/schema/andromeda-crowdfund.json index 0221369ef..1401b1a4b 100644 --- a/contracts/non-fungible-tokens/andromeda-crowdfund/schema/andromeda-crowdfund.json +++ b/contracts/non-fungible-tokens/andromeda-crowdfund/schema/andromeda-crowdfund.json @@ -42,7 +42,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Module": { "description": "A struct describing a token module, provided with the instantiation message this struct is used to record the info about the module and how/if it should be instantiated", @@ -99,17 +99,17 @@ "start_sale": { "type": "object", "required": [ - "expiration", + "end_time", "min_tokens_sold", "price", "recipient" ], "properties": { - "expiration": { + "end_time": { "description": "When the sale ends.", "allOf": [ { - "$ref": "#/definitions/Milliseconds" + "$ref": "#/definitions/Expiration" } ] }, @@ -145,6 +145,15 @@ "$ref": "#/definitions/Recipient" } ] + }, + "start_time": { + "description": "When the sale start. Defaults to current time.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 } }, "additionalProperties": false @@ -556,7 +565,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -676,12 +685,6 @@ }, "additionalProperties": false }, - "Milliseconds": { - "description": "Represents time in milliseconds.", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, "Module": { "description": "A struct describing a token module, provided with the instantiation message this struct is used to record the info about the module and how/if it should be instantiated", "type": "object", @@ -1326,7 +1329,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AndromedaHook": { "oneOf": [ @@ -1607,7 +1610,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } }, @@ -1664,7 +1667,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } }, @@ -1909,7 +1912,7 @@ "amount_sold", "amount_to_send", "amount_transferred", - "expiration", + "end_time", "max_amount_per_wallet", "min_tokens_sold", "price", @@ -1940,11 +1943,11 @@ } ] }, - "expiration": { + "end_time": { "description": "The expiration denoting when the sale ends.", "allOf": [ { - "$ref": "#/definitions/Milliseconds" + "$ref": "#/definitions/Expiration" } ] }, @@ -1984,7 +1987,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -2005,11 +2008,52 @@ } } }, - "Milliseconds": { - "description": "Represents time in milliseconds.", - "type": "integer", - "format": "uint64", - "minimum": 0.0 + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object", + "additionalProperties": false + } + }, + "additionalProperties": false + } + ] }, "Recipient": { "description": "A simple struct used for inter-contract communication. The struct can be used in two ways:\n\n1. Simply just providing an `AndrAddr` which will treat the communication as a transfer of any related funds 2. Providing an `AndrAddr` and a `Binary` message which will be sent to the contract at the resolved address\n\nThe `Binary` message can be any message that the contract at the resolved address can handle.", @@ -2044,9 +2088,21 @@ }, "additionalProperties": false }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, "Uint128": { "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" } } }, diff --git a/contracts/non-fungible-tokens/andromeda-crowdfund/schema/raw/execute.json b/contracts/non-fungible-tokens/andromeda-crowdfund/schema/raw/execute.json index 0455b1e02..ee41b03d0 100644 --- a/contracts/non-fungible-tokens/andromeda-crowdfund/schema/raw/execute.json +++ b/contracts/non-fungible-tokens/andromeda-crowdfund/schema/raw/execute.json @@ -28,17 +28,17 @@ "start_sale": { "type": "object", "required": [ - "expiration", + "end_time", "min_tokens_sold", "price", "recipient" ], "properties": { - "expiration": { + "end_time": { "description": "When the sale ends.", "allOf": [ { - "$ref": "#/definitions/Milliseconds" + "$ref": "#/definitions/Expiration" } ] }, @@ -74,6 +74,15 @@ "$ref": "#/definitions/Recipient" } ] + }, + "start_time": { + "description": "When the sale start. Defaults to current time.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 } }, "additionalProperties": false @@ -485,7 +494,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -605,12 +614,6 @@ }, "additionalProperties": false }, - "Milliseconds": { - "description": "Represents time in milliseconds.", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, "Module": { "description": "A struct describing a token module, provided with the instantiation message this struct is used to record the info about the module and how/if it should be instantiated", "type": "object", diff --git a/contracts/non-fungible-tokens/andromeda-crowdfund/schema/raw/instantiate.json b/contracts/non-fungible-tokens/andromeda-crowdfund/schema/raw/instantiate.json index c71ca6479..65f0a6b35 100644 --- a/contracts/non-fungible-tokens/andromeda-crowdfund/schema/raw/instantiate.json +++ b/contracts/non-fungible-tokens/andromeda-crowdfund/schema/raw/instantiate.json @@ -38,7 +38,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Module": { "description": "A struct describing a token module, provided with the instantiation message this struct is used to record the info about the module and how/if it should be instantiated", diff --git a/contracts/non-fungible-tokens/andromeda-crowdfund/schema/raw/query.json b/contracts/non-fungible-tokens/andromeda-crowdfund/schema/raw/query.json index a9f993afb..43b96b1c9 100644 --- a/contracts/non-fungible-tokens/andromeda-crowdfund/schema/raw/query.json +++ b/contracts/non-fungible-tokens/andromeda-crowdfund/schema/raw/query.json @@ -302,7 +302,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "AndromedaHook": { "oneOf": [ diff --git a/contracts/non-fungible-tokens/andromeda-crowdfund/schema/raw/response_to_config.json b/contracts/non-fungible-tokens/andromeda-crowdfund/schema/raw/response_to_config.json index 028c82104..d2d054655 100644 --- a/contracts/non-fungible-tokens/andromeda-crowdfund/schema/raw/response_to_config.json +++ b/contracts/non-fungible-tokens/andromeda-crowdfund/schema/raw/response_to_config.json @@ -25,7 +25,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } } diff --git a/contracts/non-fungible-tokens/andromeda-crowdfund/schema/raw/response_to_module.json b/contracts/non-fungible-tokens/andromeda-crowdfund/schema/raw/response_to_module.json index 33d4a115b..c7b506914 100644 --- a/contracts/non-fungible-tokens/andromeda-crowdfund/schema/raw/response_to_module.json +++ b/contracts/non-fungible-tokens/andromeda-crowdfund/schema/raw/response_to_module.json @@ -26,7 +26,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } } diff --git a/contracts/non-fungible-tokens/andromeda-crowdfund/schema/raw/response_to_state.json b/contracts/non-fungible-tokens/andromeda-crowdfund/schema/raw/response_to_state.json index d5d7f93bc..2036e07c7 100644 --- a/contracts/non-fungible-tokens/andromeda-crowdfund/schema/raw/response_to_state.json +++ b/contracts/non-fungible-tokens/andromeda-crowdfund/schema/raw/response_to_state.json @@ -6,7 +6,7 @@ "amount_sold", "amount_to_send", "amount_transferred", - "expiration", + "end_time", "max_amount_per_wallet", "min_tokens_sold", "price", @@ -37,11 +37,11 @@ } ] }, - "expiration": { + "end_time": { "description": "The expiration denoting when the sale ends.", "allOf": [ { - "$ref": "#/definitions/Milliseconds" + "$ref": "#/definitions/Expiration" } ] }, @@ -81,7 +81,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -102,11 +102,52 @@ } } }, - "Milliseconds": { - "description": "Represents time in milliseconds.", - "type": "integer", - "format": "uint64", - "minimum": 0.0 + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object", + "additionalProperties": false + } + }, + "additionalProperties": false + } + ] }, "Recipient": { "description": "A simple struct used for inter-contract communication. The struct can be used in two ways:\n\n1. Simply just providing an `AndrAddr` which will treat the communication as a transfer of any related funds 2. Providing an `AndrAddr` and a `Binary` message which will be sent to the contract at the resolved address\n\nThe `Binary` message can be any message that the contract at the resolved address can handle.", @@ -141,9 +182,21 @@ }, "additionalProperties": false }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, "Uint128": { "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" } } } diff --git a/contracts/non-fungible-tokens/andromeda-crowdfund/src/contract.rs b/contracts/non-fungible-tokens/andromeda-crowdfund/src/contract.rs index 2b22570c2..fafad9c9a 100644 --- a/contracts/non-fungible-tokens/andromeda-crowdfund/src/contract.rs +++ b/contracts/non-fungible-tokens/andromeda-crowdfund/src/contract.rs @@ -11,7 +11,7 @@ use andromeda_non_fungible_tokens::{ use andromeda_std::{ ado_base::ownership::OwnershipMessage, amp::{messages::AMPPkt, recipient::Recipient, AndrAddr}, - common::{actions::call_action, Milliseconds}, + common::{actions::call_action, expiration::get_and_validate_start_time, Milliseconds}, }; use andromeda_std::{ado_contract::ADOContract, common::context::ExecuteContext}; @@ -30,7 +30,7 @@ use cosmwasm_std::{ Order, QuerierWrapper, QueryRequest, Reply, Response, StdError, Storage, SubMsg, Uint128, WasmMsg, WasmQuery, }; -use cw721::{ContractInfoResponse, TokensResponse}; +use cw721::{ContractInfoResponse, Expiration, TokensResponse}; use cw_utils::nonpayable; use std::cmp; @@ -47,7 +47,6 @@ pub fn instantiate( info: MessageInfo, msg: InstantiateMsg, ) -> Result { - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; CONFIG.save( deps.storage, &Config { @@ -61,16 +60,18 @@ pub fn instantiate( deps.storage, env, deps.api, - info.clone(), + &deps.querier, + info, BaseInstantiateMsg { - ado_type: "crowdfund".to_string(), + ado_type: CONTRACT_NAME.to_string(), ado_version: CONTRACT_VERSION.to_string(), kernel_address: msg.kernel_address, owner: msg.owner, }, )?; + let owner = ADOContract::default().owner(deps.storage)?; let mod_resp = - ADOContract::default().register_modules(info.sender.as_str(), deps.storage, msg.modules)?; + ADOContract::default().register_modules(owner.as_str(), deps.storage, msg.modules)?; Ok(inst_resp .add_attributes(mod_resp.attributes) @@ -131,14 +132,16 @@ pub fn handle_execute(mut ctx: ExecuteContext, msg: ExecuteMsg) -> Result execute_mint(ctx, mint_msgs), ExecuteMsg::StartSale { - expiration, + start_time, + end_time, price, min_tokens_sold, max_amount_per_wallet, recipient, } => execute_start_sale( ctx, - expiration, + start_time, + end_time, price, min_tokens_sold, max_amount_per_wallet, @@ -282,7 +285,8 @@ fn execute_update_token_contract( #[allow(clippy::too_many_arguments)] fn execute_start_sale( ctx: ExecuteContext, - expiration: Milliseconds, + start_time: Option, + end_time: Expiration, price: Coin, min_tokens_sold: Uint128, max_amount_per_wallet: Option, @@ -300,10 +304,18 @@ fn execute_start_sale( ADOContract::default().is_contract_owner(deps.storage, info.sender.as_str())?, ContractError::Unauthorized {} ); + // If start time wasn't provided, it will be set as the current_time + let (start_expiration, _current_time) = get_and_validate_start_time(&env, start_time)?; + + ensure!( + end_time > start_expiration, + ContractError::StartTimeAfterEndTime {} + ); ensure!( - !expiration.is_in_past(&env.block), - ContractError::ExpirationInPast {} + !matches!(end_time, Expiration::Never {}), + ContractError::ExpirationMustNotBeNever {} ); + SALE_CONDUCTED.save(deps.storage, &true)?; let state = STATE.may_load(deps.storage)?; ensure!(state.is_none(), ContractError::SaleStarted {}); @@ -314,7 +326,7 @@ fn execute_start_sale( STATE.save( deps.storage, &State { - expiration, + end_time, price, min_tokens_sold, max_amount_per_wallet, @@ -329,7 +341,8 @@ fn execute_start_sale( Ok(Response::new() .add_attribute("action", "start_sale") - .add_attribute("expiration", expiration.to_string()) + .add_attribute("start_time", start_expiration.to_string()) + .add_attribute("end_time", end_time.to_string()) .add_attribute("price", price_str) .add_attribute("min_tokens_sold", min_tokens_sold) .add_attribute("max_amount_per_wallet", max_amount_per_wallet.to_string())) @@ -353,7 +366,7 @@ fn execute_purchase_by_token_id( let mut state = state.unwrap(); ensure!( - !state.expiration.is_expired(&env.block), + !state.end_time.is_expired(&env.block), ContractError::NoOngoingSale {} ); @@ -405,7 +418,7 @@ fn execute_purchase( let mut state = state.unwrap(); ensure!( - !state.expiration.is_expired(&env.block), + !state.end_time.is_expired(&env.block), ContractError::NoOngoingSale {} ); @@ -541,7 +554,7 @@ fn execute_claim_refund(ctx: ExecuteContext) -> Result ensure!(state.is_some(), ContractError::NoOngoingSale {}); let state = state.unwrap(); ensure!( - state.expiration.is_expired(&env.block), + state.end_time.is_expired(&env.block), ContractError::SaleNotEnded {} ); ensure!( @@ -581,7 +594,7 @@ fn execute_end_sale(ctx: ExecuteContext, limit: Option) -> Result Box> { @@ -32,14 +33,16 @@ pub fn mock_crowdfund_instantiate_msg( } pub fn mock_start_crowdfund_msg( - expiration: Milliseconds, + start_time: Option, + end_time: Expiration, price: Coin, min_tokens_sold: Uint128, max_amount_per_wallet: Option, recipient: Recipient, ) -> ExecuteMsg { ExecuteMsg::StartSale { - expiration, + start_time, + end_time, price, min_tokens_sold, max_amount_per_wallet, diff --git a/contracts/non-fungible-tokens/andromeda-crowdfund/src/testing/mock_querier.rs b/contracts/non-fungible-tokens/andromeda-crowdfund/src/testing/mock_querier.rs index 40d566139..439c620bf 100644 --- a/contracts/non-fungible-tokens/andromeda-crowdfund/src/testing/mock_querier.rs +++ b/contracts/non-fungible-tokens/andromeda-crowdfund/src/testing/mock_querier.rs @@ -10,7 +10,7 @@ use cosmwasm_std::{ to_json_binary, Binary, Coin, ContractResult, OwnedDeps, Querier, QuerierResult, QueryRequest, SystemError, SystemResult, WasmQuery, }; -use cosmwasm_std::{BankMsg, CosmosMsg, Response, SubMsg, Uint128}; +use cosmwasm_std::{BankMsg, CosmosMsg, QuerierWrapper, Response, SubMsg, Uint128}; use cw721::{ContractInfoResponse, Cw721QueryMsg, TokensResponse}; pub use andromeda_std::testing::mock_querier::{ @@ -48,6 +48,7 @@ pub fn mock_dependencies_custom( &mut deps.storage, mock_env(), &deps.api, + &QuerierWrapper::new(&deps.querier), mock_info("sender", &[]), InstantiateMsg { ado_type: "crowdfund".to_string(), diff --git a/contracts/non-fungible-tokens/andromeda-crowdfund/src/testing/tests.rs b/contracts/non-fungible-tokens/andromeda-crowdfund/src/testing/tests.rs index e5c2d1ecf..6e7108f28 100644 --- a/contracts/non-fungible-tokens/andromeda-crowdfund/src/testing/tests.rs +++ b/contracts/non-fungible-tokens/andromeda-crowdfund/src/testing/tests.rs @@ -17,15 +17,21 @@ use andromeda_non_fungible_tokens::{ use andromeda_std::{ ado_base::modules::Module, amp::{addresses::AndrAddr, recipient::Recipient}, - common::{encode_binary, Milliseconds}, + common::{ + encode_binary, + expiration::{expiration_from_milliseconds, MILLISECONDS_TO_NANOSECONDS_RATIO}, + Milliseconds, + }, error::ContractError, }; use andromeda_testing::economics_msg::generate_economics_message; use cosmwasm_std::{ coin, coins, from_json, testing::{mock_env, mock_info}, - Addr, BankMsg, Coin, CosmosMsg, DepsMut, Response, StdError, SubMsg, Uint128, WasmMsg, + Addr, BankMsg, Coin, CosmosMsg, DepsMut, Response, StdError, SubMsg, Timestamp, Uint128, + WasmMsg, }; +use cw_utils::Expiration; use super::mock_querier::MOCK_KERNEL_CONTRACT; @@ -115,6 +121,8 @@ fn test_instantiate() { Response::new() .add_attribute("method", "instantiate") .add_attribute("type", "crowdfund") + .add_attribute("kernel_address", MOCK_KERNEL_CONTRACT) + .add_attribute("owner", "owner") .add_attribute("action", "register_module") .add_attribute("module_idx", "1"), res @@ -174,9 +182,11 @@ fn test_mint_owner_not_crowdfund() { fn test_mint_sale_started() { let mut deps = mock_dependencies_custom(&[]); init(deps.as_mut(), None); + let current_time = mock_env().block.time.nanos() / MILLISECONDS_TO_NANOSECONDS_RATIO; let msg = ExecuteMsg::StartSale { - expiration: Milliseconds::from_seconds(mock_env().block.time.seconds() + 1), + start_time: None, + end_time: Expiration::AtTime(Timestamp::from_nanos((current_time + 2) * 1_000_000)), price: coin(100, "uusd"), min_tokens_sold: Uint128::from(1u128), max_amount_per_wallet: Some(5), @@ -362,30 +372,35 @@ fn test_mint_multiple_exceeds_limit() { } #[test] -fn test_start_sale_expiration_in_past() { +fn test_start_sale_end_time_never() { let mut deps = mock_dependencies_custom(&[]); init(deps.as_mut(), None); + let one_minute_in_future = + mock_env().block.time.plus_minutes(1).nanos() / MILLISECONDS_TO_NANOSECONDS_RATIO; let msg = ExecuteMsg::StartSale { - expiration: Milliseconds::from_seconds(mock_env().block.time.seconds() - 1), + start_time: Some(Milliseconds(one_minute_in_future)), + end_time: Expiration::Never {}, price: coin(100, "uusd"), min_tokens_sold: Uint128::from(1u128), max_amount_per_wallet: None, - recipient: Recipient::from_string("recipient"), + recipient: Recipient::from_string("recipient".to_string()), }; let info = mock_info("owner", &[]); let res = execute(deps.as_mut(), mock_env(), info, msg); - assert_eq!(ContractError::ExpirationInPast {}, res.unwrap_err()); + assert_eq!(ContractError::ExpirationMustNotBeNever {}, res.unwrap_err()); } #[test] fn test_start_sale_unauthorized() { let mut deps = mock_dependencies_custom(&[]); init(deps.as_mut(), None); + let current_time = mock_env().block.time.nanos() / MILLISECONDS_TO_NANOSECONDS_RATIO; let msg = ExecuteMsg::StartSale { - expiration: Milliseconds::from_seconds(mock_env().block.time.seconds() + 1), + start_time: None, + end_time: Expiration::AtTime(Timestamp::from_nanos((current_time + 1) * 1_000_000)), price: coin(100, "uusd"), min_tokens_sold: Uint128::from(1u128), max_amount_per_wallet: None, @@ -397,13 +412,67 @@ fn test_start_sale_unauthorized() { assert_eq!(ContractError::Unauthorized {}, res.unwrap_err()); } +#[test] +fn test_start_sale_start_time_in_past() { + let mut deps = mock_dependencies_custom(&[]); + let env = mock_env(); + init(deps.as_mut(), None); + let current_time = mock_env().block.time.nanos() / MILLISECONDS_TO_NANOSECONDS_RATIO; + + let one_minute_in_past = env.block.time.minus_minutes(1).seconds(); + let msg = ExecuteMsg::StartSale { + start_time: Some(Milliseconds(one_minute_in_past)), + end_time: Expiration::AtTime(Timestamp::from_nanos((current_time + 2) * 1_000_000)), + price: coin(100, "uusd"), + min_tokens_sold: Uint128::from(1u128), + max_amount_per_wallet: None, + recipient: Recipient::from_string("recipient"), + }; + + let info = mock_info("owner", &[]); + let res = execute(deps.as_mut(), mock_env(), info, msg); + assert_eq!( + ContractError::StartTimeInThePast { + current_time: env.block.time.nanos() / MILLISECONDS_TO_NANOSECONDS_RATIO, + current_block: env.block.height, + }, + res.unwrap_err() + ); +} + +#[test] +fn test_start_sale_start_time_in_future() { + let mut deps = mock_dependencies_custom(&[]); + let env = mock_env(); + init(deps.as_mut(), None); + + let one_minute_in_future = + env.block.time.plus_minutes(1).nanos() / MILLISECONDS_TO_NANOSECONDS_RATIO; + let msg = ExecuteMsg::StartSale { + start_time: Some(Milliseconds(one_minute_in_future)), + end_time: Expiration::AtTime(Timestamp::from_nanos( + (one_minute_in_future + 2) * 1_000_000, + )), + price: coin(100, "uusd"), + min_tokens_sold: Uint128::from(1u128), + max_amount_per_wallet: None, + recipient: Recipient::from_string("recipient"), + }; + + let info = mock_info("owner", &[]); + let res = execute(deps.as_mut(), mock_env(), info, msg); + assert!(res.is_ok()) +} + #[test] fn test_start_sale_max_default() { let mut deps = mock_dependencies_custom(&[]); init(deps.as_mut(), None); + let current_time = mock_env().block.time.nanos() / MILLISECONDS_TO_NANOSECONDS_RATIO; let msg = ExecuteMsg::StartSale { - expiration: Milliseconds::from_seconds(mock_env().block.time.seconds() + 1), + start_time: None, + end_time: Expiration::AtTime(Timestamp::from_nanos((current_time + 2) * 1_000_000)), price: coin(100, "uusd"), min_tokens_sold: Uint128::from(1u128), max_amount_per_wallet: None, @@ -412,10 +481,16 @@ fn test_start_sale_max_default() { let info = mock_info("owner", &[]); let res = execute(deps.as_mut(), mock_env(), info.clone(), msg.clone()).unwrap(); + // Using current time since start time wasn't provided + let current_time = mock_env().block.time.nanos() / MILLISECONDS_TO_NANOSECONDS_RATIO; + let start_expiration = expiration_from_milliseconds(Milliseconds(current_time + 1)).unwrap(); + let end_expiration = expiration_from_milliseconds(Milliseconds(current_time + 2)).unwrap(); + assert_eq!( Response::new() .add_attribute("action", "start_sale") - .add_attribute("expiration", "1571797420000") + .add_attribute("start_time", start_expiration.to_string()) + .add_attribute("end_time", end_expiration.to_string()) .add_attribute("price", "100uusd") .add_attribute("min_tokens_sold", "1") .add_attribute("max_amount_per_wallet", "1") @@ -425,7 +500,7 @@ fn test_start_sale_max_default() { assert_eq!( State { - expiration: Milliseconds::from_seconds(mock_env().block.time.seconds() + 1), + end_time: end_expiration, price: coin(100, "uusd"), min_tokens_sold: Uint128::from(1u128), max_amount_per_wallet: 1, @@ -447,21 +522,28 @@ fn test_start_sale_max_default() { fn test_start_sale_max_modified() { let mut deps = mock_dependencies_custom(&[]); init(deps.as_mut(), None); + let current_time = mock_env().block.time.nanos() / MILLISECONDS_TO_NANOSECONDS_RATIO; let msg = ExecuteMsg::StartSale { - expiration: Milliseconds::from_seconds(mock_env().block.time.seconds() + 1), + start_time: None, + end_time: Expiration::AtTime(Timestamp::from_nanos((current_time + 2) * 1_000_000)), price: coin(100, "uusd"), min_tokens_sold: Uint128::from(1u128), max_amount_per_wallet: Some(5), recipient: Recipient::from_string("recipient"), }; + // Using current time since start time wasn't provided + let current_time = mock_env().block.time.nanos() / MILLISECONDS_TO_NANOSECONDS_RATIO; + let start_expiration = expiration_from_milliseconds(Milliseconds(current_time + 1)).unwrap(); + let end_expiration = expiration_from_milliseconds(Milliseconds(current_time + 2)).unwrap(); let info = mock_info("owner", &[]); let res = execute(deps.as_mut(), mock_env(), info, msg).unwrap(); assert_eq!( Response::new() .add_attribute("action", "start_sale") - .add_attribute("expiration", "1571797420000") + .add_attribute("start_time", start_expiration.to_string()) + .add_attribute("end_time", end_expiration.to_string()) .add_attribute("price", "100uusd") .add_attribute("min_tokens_sold", "1") .add_attribute("max_amount_per_wallet", "5") @@ -471,7 +553,7 @@ fn test_start_sale_max_modified() { assert_eq!( State { - expiration: Milliseconds::from_seconds(mock_env().block.time.seconds() + 1), + end_time: end_expiration, price: coin(100, "uusd"), min_tokens_sold: Uint128::from(1u128), max_amount_per_wallet: 5, @@ -514,7 +596,7 @@ fn test_purchase_sale_not_ended() { .save( deps.as_mut().storage, &State { - expiration: Milliseconds::from_seconds(mock_env().block.time.seconds() - 1), + end_time: Expiration::AtHeight(mock_env().block.height - 1), price: coin(100, "uusd"), min_tokens_sold: Uint128::from(1u128), max_amount_per_wallet: 5, @@ -554,7 +636,7 @@ fn test_purchase_no_funds() { .save( deps.as_mut().storage, &State { - expiration: Milliseconds::from_seconds(mock_env().block.time.seconds() + 1), + end_time: Expiration::AtHeight(mock_env().block.height + 1), price: coin(100, "uusd"), min_tokens_sold: Uint128::from(1u128), max_amount_per_wallet: 5, @@ -592,7 +674,7 @@ fn test_purchase_wrong_denom() { .save( deps.as_mut().storage, &State { - expiration: Milliseconds::from_seconds(mock_env().block.time.seconds() + 1), + end_time: Expiration::AtHeight(mock_env().block.height + 1), price: coin(100, "uusd"), min_tokens_sold: Uint128::from(1u128), max_amount_per_wallet: 5, @@ -635,7 +717,7 @@ fn test_purchase_not_enough_for_price() { .save( deps.as_mut().storage, &State { - expiration: Milliseconds::from_seconds(mock_env().block.time.seconds() + 1), + end_time: Expiration::AtHeight(mock_env().block.height + 1), price: coin(100, "uusd"), min_tokens_sold: Uint128::from(1u128), max_amount_per_wallet: 5, @@ -682,7 +764,7 @@ fn test_purchase_not_enough_for_tax() { .save( deps.as_mut().storage, &State { - expiration: Milliseconds::from_seconds(mock_env().block.time.seconds() + 1), + end_time: Expiration::AtHeight(mock_env().block.height + 1), price: coin(100, "uusd"), min_tokens_sold: Uint128::from(1u128), max_amount_per_wallet: 5, @@ -733,7 +815,7 @@ fn test_purchase_by_token_id_not_available() { .save( deps.as_mut().storage, &State { - expiration: Milliseconds::from_seconds(mock_env().block.time.seconds() + 1), + end_time: Expiration::AtHeight(mock_env().block.height + 1), price: coin(100, "uusd"), min_tokens_sold: Uint128::from(1u128), max_amount_per_wallet: 5, @@ -768,7 +850,7 @@ fn test_purchase_by_token_id() { mint(deps.as_mut(), MOCK_TOKENS_FOR_SALE[1]).unwrap(); let mut state = State { - expiration: Milliseconds::from_seconds(mock_env().block.time.seconds() + 1), + end_time: Expiration::AtHeight(mock_env().block.height + 1), price: coin(100, "uusd"), min_tokens_sold: Uint128::from(1u128), max_amount_per_wallet: 1, @@ -868,7 +950,7 @@ fn test_multiple_purchases() { }; let mut state = State { - expiration: Milliseconds::from_seconds(mock_env().block.time.seconds() + 1), + end_time: Expiration::AtHeight(mock_env().block.height + 1), price: coin(100, "uusd"), min_tokens_sold: Uint128::from(1u128), max_amount_per_wallet: 3, @@ -1022,7 +1104,7 @@ fn test_purchase_more_than_allowed_per_wallet() { }; let state = State { - expiration: Milliseconds::from_seconds(mock_env().block.time.seconds() + 1), + end_time: Expiration::AtHeight(mock_env().block.height + 1), price: coin(100, "uusd"), min_tokens_sold: Uint128::from(1u128), max_amount_per_wallet: 3, @@ -1057,7 +1139,7 @@ fn test_end_sale_not_expired() { init(deps.as_mut(), None); let state = State { - expiration: Milliseconds::from_seconds(mock_env().block.time.seconds() + 1), + end_time: Expiration::AtHeight(mock_env().block.height + 1), price: coin(100, "uusd"), min_tokens_sold: Uint128::from(1u128), max_amount_per_wallet: 2, @@ -1111,9 +1193,11 @@ fn test_integration_conditions_not_met() { .unwrap(), Uint128::new(7) ); + let current_time = mock_env().block.time.nanos() / MILLISECONDS_TO_NANOSECONDS_RATIO; let msg = ExecuteMsg::StartSale { - expiration: Milliseconds::from_seconds(mock_env().block.time.seconds() + 1), + start_time: None, + end_time: Expiration::AtTime(Timestamp::from_nanos((current_time + 2) * 1_000_000)), price: coin(100, "uusd"), min_tokens_sold: Uint128::from(5u128), max_amount_per_wallet: Some(2), @@ -1150,8 +1234,12 @@ fn test_integration_conditions_not_met() { let info = mock_info("C", &coins(150, "uusd")); let _res = execute(deps.as_mut(), mock_env(), info, msg).unwrap(); + // Using current time since start time wasn't provided + let current_time = mock_env().block.time.nanos() / MILLISECONDS_TO_NANOSECONDS_RATIO; + let end_expiration = expiration_from_milliseconds(Milliseconds(current_time + 2)).unwrap(); + let state = State { - expiration: Milliseconds::from_seconds(mock_env().block.time.seconds() + 1), + end_time: end_expiration, price: coin(100, "uusd"), min_tokens_sold: Uint128::from(5u128), max_amount_per_wallet: 2, @@ -1192,7 +1280,7 @@ fn test_integration_conditions_not_met() { ); let mut env = mock_env(); - env.block.time = Milliseconds::from_seconds(env.block.time.seconds() + 1).into(); + env.block.time = env.block.time.plus_hours(1); // User B claims their own refund. let msg = ExecuteMsg::ClaimRefund {}; @@ -1284,9 +1372,11 @@ fn test_integration_conditions_met() { let _res = mint(deps.as_mut(), token_id).unwrap(); assert!(AVAILABLE_TOKENS.has(deps.as_ref().storage, token_id)); } + let current_time = mock_env().block.time.nanos() / MILLISECONDS_TO_NANOSECONDS_RATIO; let msg = ExecuteMsg::StartSale { - expiration: Milliseconds::from_seconds(mock_env().block.time.seconds() + 1), + start_time: None, + end_time: Expiration::AtTime(Timestamp::from_nanos((current_time + 2) * 1_000_000)), price: coin(100, "uusd"), min_tokens_sold: Uint128::from(3u128), max_amount_per_wallet: Some(2), @@ -1324,9 +1414,11 @@ fn test_integration_conditions_met() { }; let info = mock_info("D", &coins(150, "uusd")); let _res = execute(deps.as_mut(), env.clone(), info, msg).unwrap(); - + // Using current time since start time wasn't provided + let current_time = env.block.time.nanos() / MILLISECONDS_TO_NANOSECONDS_RATIO; + let end_expiration = expiration_from_milliseconds(Milliseconds(current_time + 2)).unwrap(); let mut state = State { - expiration: Milliseconds::from_seconds(mock_env().block.time.seconds() + 1), + end_time: end_expiration, price: coin(100, "uusd"), min_tokens_sold: Uint128::from(3u128), max_amount_per_wallet: 2, @@ -1363,7 +1455,7 @@ fn test_integration_conditions_met() { assert!(!AVAILABLE_TOKENS.has(deps.as_ref().storage, MOCK_TOKENS_FOR_SALE[3])); assert!(!AVAILABLE_TOKENS.has(deps.as_ref().storage, MOCK_TOKENS_FOR_SALE[4])); - env.block.time = Milliseconds::from_seconds(env.block.time.seconds() + 1).into(); + env.block.time = env.block.time.plus_hours(1); env.contract.address = Addr::unchecked(MOCK_CONDITIONS_MET_CONTRACT); let msg = ExecuteMsg::EndSale { limit: Some(1) }; @@ -1503,7 +1595,7 @@ fn test_end_sale_single_purchase() { .save( deps.as_mut().storage, &State { - expiration: Milliseconds::from_seconds(0), + end_time: Expiration::AtHeight(mock_env().block.height - 1), price: coin(100, "uusd"), min_tokens_sold: Uint128::from(1u128), max_amount_per_wallet: 5, @@ -1552,7 +1644,7 @@ fn test_end_sale_all_tokens_sold() { deps.as_mut().storage, &State { // Sale has not expired yet. - expiration: Milliseconds::from_seconds(mock_env().block.time.seconds() + 1), + end_time: Expiration::AtHeight(mock_env().block.height + 1), price: coin(100, "uusd"), min_tokens_sold: Uint128::from(1u128), max_amount_per_wallet: 5, @@ -1605,7 +1697,7 @@ fn test_end_sale_some_tokens_sold_threshold_met() { deps.as_mut().storage, &State { // Sale has not expired yet. - expiration: Milliseconds::from_seconds(mock_env().block.time.seconds() + 1), + end_time: Expiration::AtHeight(mock_env().block.height + 1), price: coin(100, "uusd"), min_tokens_sold: Uint128::from(1u128), max_amount_per_wallet: 5, @@ -1664,7 +1756,7 @@ fn test_end_sale_some_tokens_sold_threshold_not_met() { deps.as_mut().storage, &State { // Sale has not expired yet. - expiration: Milliseconds::from_seconds(mock_env().block.time.seconds() + 1), + end_time: Expiration::AtHeight(mock_env().block.height + 1), price: coin(100, "uusd"), min_tokens_sold: Uint128::from(2u128), max_amount_per_wallet: 5, @@ -1710,7 +1802,7 @@ fn test_end_sale_limit_zero() { .save( deps.as_mut().storage, &State { - expiration: Milliseconds::from_seconds(0), + end_time: Expiration::AtHeight(mock_env().block.height - 1), price: coin(100, "uusd"), min_tokens_sold: Uint128::from(1u128), max_amount_per_wallet: 5, @@ -1790,7 +1882,7 @@ fn test_addresslist() { kernel_address: MOCK_KERNEL_CONTRACT.to_string(), }; - let info = mock_info("app_contract", &[]); + let info = mock_info("owner", &[]); let _res = instantiate(deps.as_mut(), mock_env(), info, msg).unwrap(); // Not whitelisted user @@ -1819,7 +1911,7 @@ fn test_update_token_contract() { kernel_address: MOCK_KERNEL_CONTRACT.to_string(), }; - let info = mock_info("app_contract", &[]); + let info = mock_info("owner", &[]); let _res = instantiate(deps.as_mut(), mock_env(), info.clone(), msg).unwrap(); let msg = ExecuteMsg::UpdateTokenContract { diff --git a/contracts/non-fungible-tokens/andromeda-cw721/schema/andromeda-cw721.json b/contracts/non-fungible-tokens/andromeda-cw721/schema/andromeda-cw721.json index b126e7463..6fc6fb830 100644 --- a/contracts/non-fungible-tokens/andromeda-cw721/schema/andromeda-cw721.json +++ b/contracts/non-fungible-tokens/andromeda-cw721/schema/andromeda-cw721.json @@ -53,7 +53,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Module": { "description": "A struct describing a token module, provided with the instantiation message this struct is used to record the info about the module and how/if it should be instantiated", @@ -699,7 +699,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -1693,7 +1693,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Uint64": { "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", @@ -2350,7 +2350,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } }, diff --git a/contracts/non-fungible-tokens/andromeda-cw721/schema/raw/execute.json b/contracts/non-fungible-tokens/andromeda-cw721/schema/raw/execute.json index d4f596645..e76834e6a 100644 --- a/contracts/non-fungible-tokens/andromeda-cw721/schema/raw/execute.json +++ b/contracts/non-fungible-tokens/andromeda-cw721/schema/raw/execute.json @@ -617,7 +617,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/non-fungible-tokens/andromeda-cw721/schema/raw/instantiate.json b/contracts/non-fungible-tokens/andromeda-cw721/schema/raw/instantiate.json index 3e401c5f4..ca682fc2a 100644 --- a/contracts/non-fungible-tokens/andromeda-cw721/schema/raw/instantiate.json +++ b/contracts/non-fungible-tokens/andromeda-cw721/schema/raw/instantiate.json @@ -49,7 +49,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Module": { "description": "A struct describing a token module, provided with the instantiation message this struct is used to record the info about the module and how/if it should be instantiated", diff --git a/contracts/non-fungible-tokens/andromeda-cw721/schema/raw/query.json b/contracts/non-fungible-tokens/andromeda-cw721/schema/raw/query.json index eae77ca52..d76e6167d 100644 --- a/contracts/non-fungible-tokens/andromeda-cw721/schema/raw/query.json +++ b/contracts/non-fungible-tokens/andromeda-cw721/schema/raw/query.json @@ -544,7 +544,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Uint64": { "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", diff --git a/contracts/non-fungible-tokens/andromeda-cw721/schema/raw/response_to_module.json b/contracts/non-fungible-tokens/andromeda-cw721/schema/raw/response_to_module.json index 33d4a115b..c7b506914 100644 --- a/contracts/non-fungible-tokens/andromeda-cw721/schema/raw/response_to_module.json +++ b/contracts/non-fungible-tokens/andromeda-cw721/schema/raw/response_to_module.json @@ -26,7 +26,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } } diff --git a/contracts/non-fungible-tokens/andromeda-cw721/src/contract.rs b/contracts/non-fungible-tokens/andromeda-cw721/src/contract.rs index d7f1ae37b..77e7dc480 100644 --- a/contracts/non-fungible-tokens/andromeda-cw721/src/contract.rs +++ b/contracts/non-fungible-tokens/andromeda-cw721/src/contract.rs @@ -60,9 +60,10 @@ pub fn instantiate( deps.storage, env, deps.api, + &deps.querier, info.clone(), BaseInstantiateMsg { - ado_type: "cw721".to_string(), + ado_type: CONTRACT_NAME.to_string(), ado_version: CONTRACT_VERSION.to_string(), kernel_address: msg.kernel_address, owner: msg.owner, diff --git a/contracts/non-fungible-tokens/andromeda-marketplace/schema/andromeda-marketplace.json b/contracts/non-fungible-tokens/andromeda-marketplace/schema/andromeda-marketplace.json index 379d67f04..6e4f70163 100644 --- a/contracts/non-fungible-tokens/andromeda-marketplace/schema/andromeda-marketplace.json +++ b/contracts/non-fungible-tokens/andromeda-marketplace/schema/andromeda-marketplace.json @@ -34,7 +34,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Module": { "description": "A struct describing a token module, provided with the instantiation message this struct is used to record the info about the module and how/if it should be instantiated", @@ -460,7 +460,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -1184,7 +1184,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Uint128": { "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", @@ -1430,7 +1430,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } }, diff --git a/contracts/non-fungible-tokens/andromeda-marketplace/schema/raw/execute.json b/contracts/non-fungible-tokens/andromeda-marketplace/schema/raw/execute.json index cbf3641b3..b256076e6 100644 --- a/contracts/non-fungible-tokens/andromeda-marketplace/schema/raw/execute.json +++ b/contracts/non-fungible-tokens/andromeda-marketplace/schema/raw/execute.json @@ -397,7 +397,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/non-fungible-tokens/andromeda-marketplace/schema/raw/instantiate.json b/contracts/non-fungible-tokens/andromeda-marketplace/schema/raw/instantiate.json index 6c3418b88..953991c5c 100644 --- a/contracts/non-fungible-tokens/andromeda-marketplace/schema/raw/instantiate.json +++ b/contracts/non-fungible-tokens/andromeda-marketplace/schema/raw/instantiate.json @@ -30,7 +30,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Module": { "description": "A struct describing a token module, provided with the instantiation message this struct is used to record the info about the module and how/if it should be instantiated", diff --git a/contracts/non-fungible-tokens/andromeda-marketplace/schema/raw/query.json b/contracts/non-fungible-tokens/andromeda-marketplace/schema/raw/query.json index 79a244bcb..03629bc78 100644 --- a/contracts/non-fungible-tokens/andromeda-marketplace/schema/raw/query.json +++ b/contracts/non-fungible-tokens/andromeda-marketplace/schema/raw/query.json @@ -324,7 +324,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Uint128": { "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", diff --git a/contracts/non-fungible-tokens/andromeda-marketplace/schema/raw/response_to_module.json b/contracts/non-fungible-tokens/andromeda-marketplace/schema/raw/response_to_module.json index 33d4a115b..c7b506914 100644 --- a/contracts/non-fungible-tokens/andromeda-marketplace/schema/raw/response_to_module.json +++ b/contracts/non-fungible-tokens/andromeda-marketplace/schema/raw/response_to_module.json @@ -26,7 +26,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } } diff --git a/contracts/non-fungible-tokens/andromeda-marketplace/src/contract.rs b/contracts/non-fungible-tokens/andromeda-marketplace/src/contract.rs index 645df5e47..c31544f8c 100644 --- a/contracts/non-fungible-tokens/andromeda-marketplace/src/contract.rs +++ b/contracts/non-fungible-tokens/andromeda-marketplace/src/contract.rs @@ -12,8 +12,9 @@ use andromeda_std::ado_contract::ADOContract; use andromeda_std::common::actions::call_action; use andromeda_std::common::context::ExecuteContext; use andromeda_std::common::expiration::{ - expiration_from_milliseconds, MILLISECONDS_TO_NANOSECONDS_RATIO, + expiration_from_milliseconds, get_and_validate_start_time, }; +use andromeda_std::common::Milliseconds; use andromeda_std::{ ado_base::{hooks::AndromedaHook, InstantiateMsg as BaseInstantiateMsg}, common::{encode_binary, rates::get_tax_amount, Funds}, @@ -42,22 +43,23 @@ pub fn instantiate( info: MessageInfo, msg: InstantiateMsg, ) -> Result { - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; NEXT_SALE_ID.save(deps.storage, &Uint128::from(1u128))?; let inst_resp = ADOContract::default().instantiate( deps.storage, env, deps.api, - info.clone(), + &deps.querier, + info, BaseInstantiateMsg { - ado_type: "marketplace".to_string(), + ado_type: CONTRACT_NAME.to_string(), ado_version: CONTRACT_VERSION.to_string(), kernel_address: msg.kernel_address, owner: msg.owner, }, )?; + let owner = ADOContract::default().owner(deps.storage)?; let mod_resp = - ADOContract::default().register_modules(info.sender.as_str(), deps.storage, msg.modules)?; + ADOContract::default().register_modules(owner.as_str(), deps.storage, msg.modules)?; Ok(inst_resp .add_attributes(mod_resp.attributes) @@ -166,38 +168,26 @@ fn execute_start_sale( token_address: String, price: Uint128, coin_denom: String, - start_time: Option, - duration: Option, + start_time: Option, + duration: Option, ) -> Result { // Price can't be zero ensure!(price > Uint128::zero(), ContractError::InvalidZeroAmount {}); - let current_time = env.block.time.nanos() / MILLISECONDS_TO_NANOSECONDS_RATIO; // If start time wasn't provided, it will be set as the current_time - let start_expiration = if let Some(start_time) = start_time { - expiration_from_milliseconds(start_time)? - } else { - expiration_from_milliseconds(current_time)? - }; + let (start_expiration, current_time) = get_and_validate_start_time(&env, start_time)?; // If no duration is provided, the exipration will be set as Never let end_expiration = if let Some(duration) = duration { - expiration_from_milliseconds(start_time.unwrap_or(current_time) + duration)? + ensure!(!duration.is_zero(), ContractError::InvalidExpiration {}); + expiration_from_milliseconds( + start_time + .unwrap_or(current_time.plus_seconds(1)) + .plus_milliseconds(duration), + )? } else { Expiration::Never {} }; - // To guard against misleading start times - // Subtracting one second from the current block because the unit tests fail otherwise. The current time slightly differed from the block time. - let recent_past_timestamp = env.block.time.minus_seconds(1); - let recent_past_expiration = expiration_from_milliseconds(recent_past_timestamp.seconds())?; - ensure!( - start_expiration.gt(&recent_past_expiration), - ContractError::StartTimeInThePast { - current_time: env.block.time.nanos() / MILLISECONDS_TO_NANOSECONDS_RATIO, - current_block: env.block.height, - } - ); - let sale_id = get_and_increment_next_sale_id(deps.storage, &token_id, &token_address)?; TOKEN_SALE_STATE.save( diff --git a/contracts/non-fungible-tokens/andromeda-marketplace/src/testing/mock_querier.rs b/contracts/non-fungible-tokens/andromeda-marketplace/src/testing/mock_querier.rs index d36e23ef2..f6f604a5b 100644 --- a/contracts/non-fungible-tokens/andromeda-marketplace/src/testing/mock_querier.rs +++ b/contracts/non-fungible-tokens/andromeda-marketplace/src/testing/mock_querier.rs @@ -10,7 +10,8 @@ use cosmwasm_std::{ from_json, testing::{mock_env, mock_info, MockApi, MockQuerier, MockStorage, MOCK_CONTRACT_ADDR}, to_json_binary, BankMsg, Binary, Coin, ContractResult, CosmosMsg, OwnedDeps, Querier, - QuerierResult, QueryRequest, Response, SubMsg, SystemError, SystemResult, Uint128, WasmQuery, + QuerierResult, QuerierWrapper, QueryRequest, Response, SubMsg, SystemError, SystemResult, + Uint128, WasmQuery, }; use cw721::{Cw721QueryMsg, OwnerOfResponse}; @@ -46,6 +47,7 @@ pub fn mock_dependencies_custom( &mut deps.storage, mock_env(), &deps.api, + &QuerierWrapper::new(&deps.querier), mock_info("sender", &[]), InstantiateMsg { ado_type: "crowdfund".to_string(), diff --git a/contracts/non-fungible-tokens/andromeda-marketplace/src/testing/tests.rs b/contracts/non-fungible-tokens/andromeda-marketplace/src/testing/tests.rs index 04fd22425..012914916 100644 --- a/contracts/non-fungible-tokens/andromeda-marketplace/src/testing/tests.rs +++ b/contracts/non-fungible-tokens/andromeda-marketplace/src/testing/tests.rs @@ -8,6 +8,7 @@ use andromeda_std::{ encode_binary, expiration::{expiration_from_milliseconds, MILLISECONDS_TO_NANOSECONDS_RATIO}, reply::ReplyId, + Milliseconds, }, error::ContractError, os::economics::ExecuteMsg as EconomicsExecuteMsg, @@ -55,7 +56,7 @@ fn start_sale_future_start(deps: DepsMut, env: Env) { coin_denom: "uusd".to_string(), price: Uint128::new(100), // Add one to the current time to have it set in the future - start_time: Some(current_time + 1), + start_time: Some(Milliseconds(current_time + 1)), duration: None, }; let msg = ExecuteMsg::ReceiveNft(Cw721ReceiveMsg { @@ -75,9 +76,9 @@ fn start_sale_future_start_with_duration(deps: DepsMut, env: Env) { coin_denom: "uusd".to_string(), price: Uint128::new(100), // Add one to the current time to have it set in the future - start_time: Some(current_time + 1), + start_time: Some(Milliseconds(current_time + 1)), // Add duration, the end time's expiration will be current time + duration - duration: Some(1), + duration: Some(Milliseconds(1)), }; let msg = ExecuteMsg::ReceiveNft(Cw721ReceiveMsg { sender: MOCK_TOKEN_OWNER.to_owned(), @@ -103,7 +104,8 @@ fn init(deps: DepsMut, modules: Option>) -> Response { fn assert_sale_created(deps: Deps, env: Env) { let current_time = env.block.time.nanos() / MILLISECONDS_TO_NANOSECONDS_RATIO; - let start_time_expiration = expiration_from_milliseconds(current_time).unwrap(); + let start_time_expiration = + expiration_from_milliseconds(Milliseconds(current_time + 1)).unwrap(); assert_eq!( TokenSaleState { coin_denom: "uusd".to_string(), @@ -138,7 +140,8 @@ fn assert_sale_created(deps: Deps, env: Env) { fn assert_sale_created_future_start(deps: Deps, env: Env) { let current_time = env.block.time.nanos() / MILLISECONDS_TO_NANOSECONDS_RATIO; // Add one to the current time to have it set in the future - let start_time_expiration = expiration_from_milliseconds(current_time + 1).unwrap(); + let start_time_expiration = + expiration_from_milliseconds(Milliseconds(current_time + 1)).unwrap(); assert_eq!( TokenSaleState { coin_denom: "uusd".to_string(), @@ -203,7 +206,7 @@ fn test_execute_buy_non_existing_sale() { #[test] fn test_execute_buy_sale_not_open_already_bought() { let mut deps = mock_dependencies_custom(&[]); - let env = mock_env(); + let mut env = mock_env(); let _res = init(deps.as_mut(), None); start_sale(deps.as_mut()); @@ -215,6 +218,8 @@ fn test_execute_buy_sale_not_open_already_bought() { }; let info = mock_info("sender", &coins(100, "uusd".to_string())); + // Add one second so that the start_time expires + env.block.time = env.block.time.plus_seconds(1); let _res = execute(deps.as_mut(), env.clone(), info, msg).unwrap(); let msg = ExecuteMsg::Buy { @@ -257,7 +262,7 @@ fn test_execute_buy_sale_not_open_cancelled() { #[test] fn test_execute_buy_token_owner_cannot_buy() { let mut deps = mock_dependencies_custom(&[]); - let env = mock_env(); + let mut env = mock_env(); let _res = init(deps.as_mut(), None); @@ -268,6 +273,8 @@ fn test_execute_buy_token_owner_cannot_buy() { token_id: MOCK_UNCLAIMED_TOKEN.to_owned(), token_address: MOCK_TOKEN_ADDR.to_string(), }; + // Add one second so that the start_time expires + env.block.time = env.block.time.plus_seconds(1); let info = mock_info(MOCK_TOKEN_OWNER, &coins(100, "uusd".to_string())); let res = execute(deps.as_mut(), env, info, msg); @@ -277,7 +284,7 @@ fn test_execute_buy_token_owner_cannot_buy() { #[test] fn test_execute_buy_invalid_coins_sent() { let mut deps = mock_dependencies_custom(&[]); - let env = mock_env(); + let mut env = mock_env(); let _res = init(deps.as_mut(), None); @@ -294,6 +301,8 @@ fn test_execute_buy_invalid_coins_sent() { // No coins sent let info = mock_info("sender", &[]); + // Add one second so that the start_time expires + env.block.time = env.block.time.plus_seconds(1); let res = execute(deps.as_mut(), env.clone(), info, msg.clone()); assert_eq!(error, res.unwrap_err()); @@ -321,7 +330,7 @@ fn test_execute_buy_invalid_coins_sent() { #[test] fn test_execute_buy_works() { let mut deps = mock_dependencies_custom(&[]); - let env = mock_env(); + let mut env = mock_env(); let _res = init(deps.as_mut(), None); @@ -334,6 +343,8 @@ fn test_execute_buy_works() { }; let info = mock_info("someone", &coins(100, "uusd".to_string())); + // Add one second so that the start_time expires + env.block.time = env.block.time.plus_seconds(1); let _res = execute(deps.as_mut(), env, info, msg).unwrap(); } @@ -464,9 +475,11 @@ fn test_execute_buy_with_tax_and_royalty_insufficient_funds() { token_id: MOCK_UNCLAIMED_TOKEN.to_owned(), token_address: MOCK_TOKEN_ADDR.to_string(), }; - + let mut env = mock_env(); + // Add one second so that the start_time expires + env.block.time = env.block.time.plus_seconds(1); let info = mock_info("someone", &coins(100, "uusd".to_string())); - let err = execute(deps.as_mut(), mock_env(), info, msg).unwrap_err(); + let err = execute(deps.as_mut(), env, info, msg).unwrap_err(); assert!(matches!(err, ContractError::InvalidFunds { .. })); } @@ -487,9 +500,12 @@ fn execute_buy_with_tax_and_royalty_too_many_funds() { token_id: MOCK_UNCLAIMED_TOKEN.to_owned(), token_address: MOCK_TOKEN_ADDR.to_string(), }; + let mut env = mock_env(); + // Add one second so that the start_time expires + env.block.time = env.block.time.plus_seconds(1); let info = mock_info("someone", &coins(200, "uusd".to_string())); - let err = execute(deps.as_mut(), mock_env(), info, msg).unwrap_err(); + let err = execute(deps.as_mut(), env, info, msg).unwrap_err(); assert!(matches!(err, ContractError::InvalidFunds { .. })); } @@ -512,7 +528,11 @@ fn test_execute_buy_with_tax_and_royalty_works() { }; let info = mock_info("someone", &coins(150, "uusd".to_string())); - let res = execute(deps.as_mut(), mock_env(), info.clone(), msg).unwrap(); + let mut env = mock_env(); + // Add one second so that the start_time expires + env.block.time = env.block.time.plus_seconds(1); + + let res = execute(deps.as_mut(), env, info.clone(), msg).unwrap(); let expected: Vec> = vec![ SubMsg::new(CosmosMsg::Bank(BankMsg::Send { to_address: "royalty_recipient".to_string(), diff --git a/contracts/os/andromeda-adodb/src/contract.rs b/contracts/os/andromeda-adodb/src/contract.rs index abf8831ce..784c7bbf7 100644 --- a/contracts/os/andromeda-adodb/src/contract.rs +++ b/contracts/os/andromeda-adodb/src/contract.rs @@ -27,9 +27,10 @@ pub fn instantiate( deps.storage, env, deps.api, + &deps.querier, info, BaseInstantiateMsg { - ado_type: "adodb".to_string(), + ado_type: CONTRACT_NAME.to_string(), ado_version: CONTRACT_VERSION.to_string(), kernel_address: msg.kernel_address, owner: msg.owner, diff --git a/contracts/os/andromeda-adodb/src/execute.rs b/contracts/os/andromeda-adodb/src/execute.rs index 48a88d294..242501112 100644 --- a/contracts/os/andromeda-adodb/src/execute.rs +++ b/contracts/os/andromeda-adodb/src/execute.rs @@ -142,7 +142,7 @@ pub fn unpublish( // Verify Code ID exists ADO_TYPE - .load(deps.storage, code_id) + .load(deps.storage, &code_id.to_string()) .ok() .ok_or(ContractError::InvalidCodeID { msg: Some("Code ID not already published".to_string()), diff --git a/contracts/os/andromeda-adodb/src/query.rs b/contracts/os/andromeda-adodb/src/query.rs index f214ff31c..2173c4afc 100644 --- a/contracts/os/andromeda-adodb/src/query.rs +++ b/contracts/os/andromeda-adodb/src/query.rs @@ -36,7 +36,7 @@ pub fn is_unpublished_code_id( } pub fn ado_type(deps: Deps, code_id: u64) -> Result, ContractError> { - let ado_version = ADO_TYPE.may_load(deps.storage, code_id)?; + let ado_version = ADO_TYPE.may_load(deps.storage, &code_id.to_string())?; Ok(ado_version) } @@ -124,6 +124,6 @@ pub fn action_fee_by_code_id( code_id: u64, action: String, ) -> Result, ContractError> { - let ado_version = ADO_TYPE.load(deps.storage, code_id)?; + let ado_version = ADO_TYPE.load(deps.storage, &code_id.to_string())?; Ok(ACTION_FEES.may_load(deps.storage, &(ado_version.get_type(), action))?) } diff --git a/contracts/os/andromeda-adodb/src/state.rs b/contracts/os/andromeda-adodb/src/state.rs index 09a73a76a..999189b80 100644 --- a/contracts/os/andromeda-adodb/src/state.rs +++ b/contracts/os/andromeda-adodb/src/state.rs @@ -14,7 +14,7 @@ pub const UNPUBLISHED_VERSIONS: Map<(&str, &str), bool> = Map::new("unpublished_ /// Stores the latest version for a given ADO pub const LATEST_VERSION: Map<&str, (String, u64)> = Map::new("latest_version"); /// Stores a mapping from code ID to ADO -pub const ADO_TYPE: Map = Map::new("ado_type"); +pub const ADO_TYPE: Map<&str, ADOVersion> = Map::new("ado_type"); /// Stores a mapping from ADO to its publisher pub const PUBLISHER: Map<&str, String> = Map::new("publisher"); /// Stores a mapping from an (ADO,Action) to its action fees @@ -25,12 +25,14 @@ pub fn store_code_id( ado_version: &ADOVersion, code_id: u64, ) -> Result<(), ContractError> { - let curr_type = ADO_TYPE.may_load(storage, code_id)?; + let curr_type = ADO_TYPE.may_load(storage, &code_id.to_string())?; ensure!( curr_type.is_none() || &curr_type.unwrap() == ado_version, ContractError::Unauthorized {} ); - ADO_TYPE.save(storage, code_id, ado_version).unwrap(); + ADO_TYPE + .save(storage, &code_id.to_string(), ado_version) + .unwrap(); LATEST_VERSION .save( storage, @@ -50,12 +52,12 @@ pub fn remove_code_id( ado_version: &ADOVersion, code_id: u64, ) -> Result<(), ContractError> { - let curr_type = ADO_TYPE.may_load(storage, code_id)?; + let curr_type = ADO_TYPE.may_load(storage, &code_id.to_string())?; ensure!( curr_type.is_none() || &curr_type.unwrap() == ado_version, ContractError::Unauthorized {} ); - ADO_TYPE.remove(storage, code_id); + ADO_TYPE.remove(storage, &code_id.to_string()); let version_code = LATEST_VERSION.may_load(storage, &ado_version.get_type())?; if let Some(version_code) = version_code { // This means that the code_id we're trying to unpublish is also the latest diff --git a/contracts/os/andromeda-economics/schema/andromeda-economics.json b/contracts/os/andromeda-economics/schema/andromeda-economics.json index f59aacdcf..99e20b4c6 100644 --- a/contracts/os/andromeda-economics/schema/andromeda-economics.json +++ b/contracts/os/andromeda-economics/schema/andromeda-economics.json @@ -176,7 +176,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", @@ -398,7 +398,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } }, diff --git a/contracts/os/andromeda-economics/schema/raw/execute.json b/contracts/os/andromeda-economics/schema/raw/execute.json index 0ba8f9b3d..62f166ae5 100644 --- a/contracts/os/andromeda-economics/schema/raw/execute.json +++ b/contracts/os/andromeda-economics/schema/raw/execute.json @@ -151,7 +151,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/os/andromeda-economics/schema/raw/query.json b/contracts/os/andromeda-economics/schema/raw/query.json index 932982e1e..96971e085 100644 --- a/contracts/os/andromeda-economics/schema/raw/query.json +++ b/contracts/os/andromeda-economics/schema/raw/query.json @@ -85,7 +85,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } } } diff --git a/contracts/os/andromeda-economics/src/contract.rs b/contracts/os/andromeda-economics/src/contract.rs index cfbd3c5a8..0b62d5de2 100644 --- a/contracts/os/andromeda-economics/src/contract.rs +++ b/contracts/os/andromeda-economics/src/contract.rs @@ -32,9 +32,10 @@ pub fn instantiate( deps.storage, env, deps.api, + &deps.querier, info, BaseInstantiateMsg { - ado_type: "economics".to_string(), + ado_type: CONTRACT_NAME.to_string(), ado_version: CONTRACT_VERSION.to_string(), kernel_address: msg.kernel_address, owner: msg.owner, diff --git a/contracts/os/andromeda-economics/src/tests/mock_querier.rs b/contracts/os/andromeda-economics/src/tests/mock_querier.rs index 7bf27a850..b1dfe6f49 100644 --- a/contracts/os/andromeda-economics/src/tests/mock_querier.rs +++ b/contracts/os/andromeda-economics/src/tests/mock_querier.rs @@ -44,6 +44,7 @@ pub fn mock_dependencies_custom( &mut deps.storage, mock_env(), &deps.api, + &deps.querier, mock_info("sender", &[]), InstantiateMsg { ado_type: "vault".to_string(), diff --git a/contracts/os/andromeda-kernel/schema/andromeda-kernel.json b/contracts/os/andromeda-kernel/schema/andromeda-kernel.json index 7c9f3240d..f818b39c3 100644 --- a/contracts/os/andromeda-kernel/schema/andromeda-kernel.json +++ b/contracts/os/andromeda-kernel/schema/andromeda-kernel.json @@ -380,7 +380,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/os/andromeda-kernel/schema/raw/execute.json b/contracts/os/andromeda-kernel/schema/raw/execute.json index 9a0eee7aa..f60a83a15 100644 --- a/contracts/os/andromeda-kernel/schema/raw/execute.json +++ b/contracts/os/andromeda-kernel/schema/raw/execute.json @@ -356,7 +356,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Binary": { "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", diff --git a/contracts/os/andromeda-kernel/src/contract.rs b/contracts/os/andromeda-kernel/src/contract.rs index 7e75629a3..75acb17a8 100644 --- a/contracts/os/andromeda-kernel/src/contract.rs +++ b/contracts/os/andromeda-kernel/src/contract.rs @@ -28,17 +28,16 @@ pub fn instantiate( info: MessageInfo, msg: InstantiateMsg, ) -> Result { - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - CURR_CHAIN.save(deps.storage, &msg.chain_name)?; ADOContract::default().instantiate( deps.storage, env.clone(), deps.api, + &deps.querier, info, BaseInstantiateMsg { - ado_type: "kernel".to_string(), + ado_type: CONTRACT_NAME.to_string(), ado_version: CONTRACT_VERSION.to_string(), kernel_address: env.contract.address.to_string(), owner: msg.owner, diff --git a/contracts/os/andromeda-vfs/schema/andromeda-vfs.json b/contracts/os/andromeda-vfs/schema/andromeda-vfs.json index db6d4be96..aac875791 100644 --- a/contracts/os/andromeda-vfs/schema/andromeda-vfs.json +++ b/contracts/os/andromeda-vfs/schema/andromeda-vfs.json @@ -45,7 +45,7 @@ }, "name": { "type": "string", - "pattern": "^[A-Za-z0-9.\\-_]{2,40}$" + "pattern": "^[A-Za-z0-9.\\-_]{2,80}$" }, "parent_address": { "anyOf": [ @@ -78,7 +78,7 @@ "properties": { "name": { "type": "string", - "pattern": "^[A-Za-z0-9.\\-_]{2,40}$" + "pattern": "^[A-Za-z0-9.\\-_]{2,80}$" }, "parent_address": { "anyOf": [ @@ -114,7 +114,7 @@ "properties": { "name": { "type": "string", - "pattern": "^[A-Za-z0-9.\\-_]{2,40}$" + "pattern": "^[A-Za-z0-9.\\-_]{2,80}$" }, "parent_address": { "$ref": "#/definitions/AndrAddr" @@ -230,7 +230,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Expiration": { "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", @@ -382,36 +382,24 @@ "minimum": 0.0 }, "max": { - "type": [ - "array", - "null" - ], - "items": [ + "anyOf": [ { - "$ref": "#/definitions/Addr" + "$ref": "#/definitions/SubDirBound" }, { - "type": "string" + "type": "null" } - ], - "maxItems": 2, - "minItems": 2 + ] }, "min": { - "type": [ - "array", - "null" - ], - "items": [ + "anyOf": [ { - "$ref": "#/definitions/Addr" + "$ref": "#/definitions/SubDirBound" }, { - "type": "string" + "type": "null" } - ], - "maxItems": 2, - "minItems": 2 + ] }, "path": { "$ref": "#/definitions/AndrAddr" @@ -567,7 +555,23 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + }, + "SubDirBound": { + "type": "object", + "required": [ + "address", + "name" + ], + "properties": { + "address": { + "$ref": "#/definitions/Addr" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } } }, @@ -637,7 +641,7 @@ "title": "AndrAddr", "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "sub_dir": { "$schema": "http://json-schema.org/draft-07/schema#", diff --git a/contracts/os/andromeda-vfs/schema/raw/execute.json b/contracts/os/andromeda-vfs/schema/raw/execute.json index 412e29390..d46854515 100644 --- a/contracts/os/andromeda-vfs/schema/raw/execute.json +++ b/contracts/os/andromeda-vfs/schema/raw/execute.json @@ -20,7 +20,7 @@ }, "name": { "type": "string", - "pattern": "^[A-Za-z0-9.\\-_]{2,40}$" + "pattern": "^[A-Za-z0-9.\\-_]{2,80}$" }, "parent_address": { "anyOf": [ @@ -53,7 +53,7 @@ "properties": { "name": { "type": "string", - "pattern": "^[A-Za-z0-9.\\-_]{2,40}$" + "pattern": "^[A-Za-z0-9.\\-_]{2,80}$" }, "parent_address": { "anyOf": [ @@ -89,7 +89,7 @@ "properties": { "name": { "type": "string", - "pattern": "^[A-Za-z0-9.\\-_]{2,40}$" + "pattern": "^[A-Za-z0-9.\\-_]{2,80}$" }, "parent_address": { "$ref": "#/definitions/AndrAddr" @@ -205,7 +205,7 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" }, "Expiration": { "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", diff --git a/contracts/os/andromeda-vfs/schema/raw/query.json b/contracts/os/andromeda-vfs/schema/raw/query.json index e97f2ab97..48d2c63ee 100644 --- a/contracts/os/andromeda-vfs/schema/raw/query.json +++ b/contracts/os/andromeda-vfs/schema/raw/query.json @@ -44,36 +44,24 @@ "minimum": 0.0 }, "max": { - "type": [ - "array", - "null" - ], - "items": [ + "anyOf": [ { - "$ref": "#/definitions/Addr" + "$ref": "#/definitions/SubDirBound" }, { - "type": "string" + "type": "null" } - ], - "maxItems": 2, - "minItems": 2 + ] }, "min": { - "type": [ - "array", - "null" - ], - "items": [ + "anyOf": [ { - "$ref": "#/definitions/Addr" + "$ref": "#/definitions/SubDirBound" }, { - "type": "string" + "type": "null" } - ], - "maxItems": 2, - "minItems": 2 + ] }, "path": { "$ref": "#/definitions/AndrAddr" @@ -229,7 +217,23 @@ "AndrAddr": { "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + }, + "SubDirBound": { + "type": "object", + "required": [ + "address", + "name" + ], + "properties": { + "address": { + "$ref": "#/definitions/Addr" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false } } } diff --git a/contracts/os/andromeda-vfs/schema/raw/response_to_resolve_symlink.json b/contracts/os/andromeda-vfs/schema/raw/response_to_resolve_symlink.json index 36e7fbcf2..cbafa9a20 100644 --- a/contracts/os/andromeda-vfs/schema/raw/response_to_resolve_symlink.json +++ b/contracts/os/andromeda-vfs/schema/raw/response_to_resolve_symlink.json @@ -3,5 +3,5 @@ "title": "AndrAddr", "description": "An address that can be used within the Andromeda ecosystem. Inspired by the cosmwasm-std `Addr` type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33\n\nThis address can be one of two things: 1. A valid human readable address e.g. `cosmos1...` 2. A valid Andromeda VFS path e.g. `/home/user/app/component`\n\nVFS paths can be local in the case of an app and can be done by referencing `./component` they can also contain protocols for cross chain communication. A VFS path is usually structured as so:\n\n`:///` or `ibc://cosmoshub-4/user/app/component`", "type": "string", - "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" + "pattern": "(^((([A-Za-z0-9]+://)?([A-Za-z0-9.\\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?)$)|(^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\\-_]{2,80}?)*(/)?$)|(^[a-z0-9]{2,}$)|(^\\.(/[A-Za-z0-9.\\-_]{2,40}?)*(/)?$)" } diff --git a/contracts/os/andromeda-vfs/src/contract.rs b/contracts/os/andromeda-vfs/src/contract.rs index 6e28b951f..f9cca0c85 100644 --- a/contracts/os/andromeda-vfs/src/contract.rs +++ b/contracts/os/andromeda-vfs/src/contract.rs @@ -27,9 +27,10 @@ pub fn instantiate( deps.storage, env, deps.api, + &deps.querier, info, BaseInstantiateMsg { - ado_type: "vfs".to_string(), + ado_type: CONTRACT_NAME.to_string(), ado_version: CONTRACT_VERSION.to_string(), kernel_address: msg.kernel_address, owner: msg.owner, diff --git a/contracts/os/andromeda-vfs/src/execute.rs b/contracts/os/andromeda-vfs/src/execute.rs index b0f861242..2b27a5a04 100644 --- a/contracts/os/andromeda-vfs/src/execute.rs +++ b/contracts/os/andromeda-vfs/src/execute.rs @@ -117,7 +117,7 @@ pub fn add_child( )?; // Sender must be an app contract ensure!( - ado_type.is_some() && ado_type.unwrap() == "app-contract", + ado_type.is_some() && ado_type.unwrap().contains("app-contract"), ContractError::Unauthorized {} ); @@ -146,6 +146,8 @@ pub fn register_user( username: String, address: Option, ) -> Result { + #[cfg(not(test))] + ensure!(false, ContractError::TemporarilyDisabled {}); ensure!( username.len() as u64 <= MAX_USERNAME_LENGTH, ContractError::InvalidUsername { diff --git a/contracts/os/andromeda-vfs/src/query.rs b/contracts/os/andromeda-vfs/src/query.rs index 1cbdc69f1..d6cb8b4d8 100644 --- a/contracts/os/andromeda-vfs/src/query.rs +++ b/contracts/os/andromeda-vfs/src/query.rs @@ -1,4 +1,4 @@ -use andromeda_std::os::vfs::validate_path_name; +use andromeda_std::os::vfs::{validate_path_name, SubDirBound}; use andromeda_std::{amp::AndrAddr, error::ContractError}; use cosmwasm_std::{Addr, Deps}; @@ -14,8 +14,8 @@ pub fn resolve_path(deps: Deps, path: AndrAddr) -> Result { pub fn subdir( deps: Deps, path: AndrAddr, - min: Option<(Addr, String)>, - max: Option<(Addr, String)>, + min: Option, + max: Option, limit: Option, ) -> Result, ContractError> { validate_path_name(deps.api, path.to_string())?; diff --git a/contracts/os/andromeda-vfs/src/state.rs b/contracts/os/andromeda-vfs/src/state.rs index 2079344b1..7e2378ac7 100644 --- a/contracts/os/andromeda-vfs/src/state.rs +++ b/contracts/os/andromeda-vfs/src/state.rs @@ -1,4 +1,8 @@ -use andromeda_std::{amp::AndrAddr, error::ContractError, os::vfs::validate_path_name}; +use andromeda_std::{ + amp::AndrAddr, + error::ContractError, + os::vfs::{validate_path_name, SubDirBound}, +}; use cosmwasm_std::{ensure, Addr, Api, Storage}; use cw_storage_plus::{Bound, Index, IndexList, IndexedMap, Map, MultiIndex}; use serde::{Deserialize, Serialize}; @@ -210,8 +214,8 @@ pub fn get_subdir( storage: &dyn Storage, api: &dyn Api, pathname: AndrAddr, - min: Option<(Addr, String)>, - max: Option<(Addr, String)>, + min: Option, + max: Option, limit: Option, ) -> Result, ContractError> { let address = resolve_pathname(storage, api, pathname, &mut vec![])?; diff --git a/contracts/os/andromeda-vfs/src/testing/tests.rs b/contracts/os/andromeda-vfs/src/testing/tests.rs index d18d08b3f..e6369b1cb 100644 --- a/contracts/os/andromeda-vfs/src/testing/tests.rs +++ b/contracts/os/andromeda-vfs/src/testing/tests.rs @@ -181,7 +181,6 @@ fn test_register_user_valid_cosmwasm_address_user() { }; instantiate_contract(deps.as_mut(), env.clone(), info.clone()); execute(deps.as_mut(), env, info, msg).unwrap(); - let saved = USERS.load(deps.as_ref().storage, username).unwrap(); assert_eq!(saved, sender) } @@ -260,6 +259,7 @@ fn test_register_user_foreign_chain() { username: username.to_string(), address: None, }; + let err = execute(deps.as_mut(), env.clone(), info, msg).unwrap_err(); assert_eq!(err, ContractError::Unauthorized {}); diff --git a/packages/andromeda-app/Cargo.toml b/packages/andromeda-app/Cargo.toml index 519d13649..7d11583b3 100644 --- a/packages/andromeda-app/Cargo.toml +++ b/packages/andromeda-app/Cargo.toml @@ -12,7 +12,10 @@ backtraces = ["cosmwasm-std/backtraces"] crate-type = ["cdylib", "rlib"] [dependencies] -cosmwasm-std = { workspace = true } +cosmwasm-std = { workspace = true, features = ["cosmwasm_1_2"] } cosmwasm-schema = { workspace = true } serde = { workspace = true } andromeda-std = { workspace = true } + +[dev-dependencies] +cw-multi-test = { version = "1.0.0" } diff --git a/packages/andromeda-app/src/app.rs b/packages/andromeda-app/src/app.rs index 55e214ae0..377c9af88 100644 --- a/packages/andromeda-app/src/app.rs +++ b/packages/andromeda-app/src/app.rs @@ -1,8 +1,32 @@ -use andromeda_std::{amp::AndrAddr, andr_exec, andr_instantiate, andr_query, error::ContractError}; +use andromeda_std::{ + amp::AndrAddr, + andr_exec, andr_instantiate, andr_query, + common::reply::ReplyId, + error::ContractError, + os::{ + aos_querier::AOSQuerier, + vfs::{convert_component_name, ExecuteMsg as VFSExecuteMsg}, + }, +}; use cosmwasm_schema::{cw_serde, QueryResponses}; -use cosmwasm_std::{to_json_binary, Binary, Deps}; +use cosmwasm_std::{ + attr, ensure, instantiate2_address, to_json_binary, wasm_execute, Addr, Api, Binary, + CodeInfoResponse, Deps, Event, QuerierWrapper, SubMsg, WasmMsg, +}; use serde::Serialize; +pub fn get_chain_info(chain_name: String, chain_info: Option>) -> Option { + match chain_info { + Some(chain_info) => { + let idx = chain_info + .iter() + .position(|info| info.chain_name == chain_name)?; + Some(chain_info[idx].clone()) + } + None => None, + } +} + #[cw_serde] pub struct CrossChainComponent { pub instantiate_msg: Binary, @@ -79,6 +103,170 @@ impl AppComponent { self.component_type.verify()?; Ok(()) } + + #[inline] + pub fn get_salt(&self, _parent_addr: Addr) -> Binary { + Binary::from(self.name.as_bytes()) + } + + /// Generates an `Instantiate2` address for the component. + /// + /// Returns `None` for `Symlink` and `CrossChain` components. + pub fn get_new_addr( + &self, + api: &dyn Api, + adodb_addr: &Addr, + querier: &QuerierWrapper, + parent_addr: Addr, + ) -> Result, ContractError> { + if !matches!(self.component_type, ComponentType::New(..)) { + return Ok(None); + } + + let code_id = AOSQuerier::code_id_getter(querier, adodb_addr, &self.ado_type)?; + let CodeInfoResponse { checksum, .. } = querier.query_wasm_code_info(code_id)?; + + let salt = self.get_salt(parent_addr.clone()); + let creator = api.addr_canonicalize(parent_addr.as_str())?; + let new_addr = instantiate2_address(&checksum, &creator, &salt).unwrap(); + + Ok(Some(api.addr_humanize(&new_addr)?)) + } + + #[inline] + pub fn get_msg_binary(&self) -> Result { + match self.component_type.clone() { + ComponentType::New(msg) => Ok(msg), + _ => Err(ContractError::InvalidComponent { + name: self.name.clone(), + }), + } + } + + /// Generates a VFS registration message for the component. + pub fn generate_vfs_registration( + &self, + // New addr is provided to prevent duplicate queries + new_addr: Option, + _app_addr: &Addr, + app_name: &str, + chain_info: Option>, + _adodb_addr: &Addr, + vfs_addr: &Addr, + ) -> Result, ContractError> { + if self.name.starts_with('.') { + return Ok(None); + } + match self.component_type.clone() { + ComponentType::New(_) => { + let new_addr = new_addr.unwrap(); + let register_msg = wasm_execute( + vfs_addr.clone(), + &VFSExecuteMsg::AddPath { + name: convert_component_name(&self.name), + address: new_addr, + parent_address: None, + }, + vec![], + )?; + let register_submsg = + SubMsg::reply_always(register_msg, ReplyId::RegisterPath.repr()); + + Ok(Some(register_submsg)) + } + ComponentType::Symlink(symlink) => { + let msg = VFSExecuteMsg::AddSymlink { + name: self.name.clone(), + symlink, + parent_address: None, + }; + let cosmos_msg = wasm_execute(vfs_addr, &msg, vec![])?; + let sub_msg = SubMsg::reply_on_error(cosmos_msg, ReplyId::RegisterPath.repr()); + Ok(Some(sub_msg)) + } + ComponentType::CrossChain(CrossChainComponent { chain, .. }) => { + let curr_chain_info = get_chain_info(chain.clone(), chain_info.clone()); + ensure!( + curr_chain_info.is_some(), + ContractError::InvalidComponent { + name: self.name.clone() + } + ); + let owner_addr = curr_chain_info.unwrap().owner; + let name = self.name.clone(); + + // Register the component as a symlink for the receiving chain + let new_component = AppComponent { + name: name.clone(), + ado_type: self.ado_type.clone(), + component_type: ComponentType::Symlink(AndrAddr::from_string(format!( + "ibc://{chain}/home/{owner_addr}/{app_name}/{name}" + ))), + }; + new_component.generate_vfs_registration( + new_addr, + _app_addr, + app_name, + chain_info, + _adodb_addr, + vfs_addr, + ) + } + } + } + + /// Generates an instantiation message for the component. + /// + /// Returns `None` for `Symlink` and `CrossChain` components. + pub fn generate_instantiation_message( + &self, + querier: &QuerierWrapper, + adodb_addr: &Addr, + parent_addr: &Addr, + sender: &str, + idx: u64, + ) -> Result, ContractError> { + if let ComponentType::New(instantiate_msg) = self.component_type.clone() { + let code_id = AOSQuerier::code_id_getter(querier, adodb_addr, &self.ado_type)?; + let salt = self.get_salt(parent_addr.clone()); + let inst_msg = WasmMsg::Instantiate2 { + admin: Some(sender.to_string()), + code_id, + label: format!("Instantiate: {}", self.ado_type), + msg: instantiate_msg, + funds: vec![], + salt, + }; + Ok(Some(SubMsg::reply_always(inst_msg, idx))) + } else { + Ok(None) + } + } + + /// Generates an event for the app component. + /// + /// Includes the name and type of the component plus the following for each type: + /// - `New` - the address of the component + /// - `CrossChain` - the receiving chain of the component + /// - `Symlink` - the created symlink for the component + pub fn generate_event(&self, addr: Option) -> Event { + let mut ev = Event::new("add_app_component").add_attributes(vec![ + attr("name", self.name.clone()), + attr("ado_type", self.ado_type.clone()), + ]); + + match self.component_type.clone() { + ComponentType::New(_) => { + ev = ev.add_attribute("address", addr.unwrap().to_string()); + } + ComponentType::CrossChain(chain_component) => { + ev = ev.add_attribute("chain", chain_component.chain); + } + ComponentType::Symlink(link) => ev = ev.add_attribute("symlink", link), + } + + ev + } } #[cw_serde] @@ -147,8 +335,3 @@ pub struct ComponentAddress { pub name: String, pub address: String, } - -#[cfg(test)] -mod tests { - // use super::*; -} diff --git a/packages/andromeda-finance/src/rate_limiting_withdrawals.rs b/packages/andromeda-finance/src/rate_limiting_withdrawals.rs index 01fe43ab6..f46283fe1 100644 --- a/packages/andromeda-finance/src/rate_limiting_withdrawals.rs +++ b/packages/andromeda-finance/src/rate_limiting_withdrawals.rs @@ -47,7 +47,7 @@ pub struct InstantiateMsg { #[cw_serde] pub enum MinimumFrequency { Time { time: Milliseconds }, - AddressAndKey { address_and_key: ContractAndKey }, + // AddressAndKey { address_and_key: ContractAndKey }, } #[andr_exec] diff --git a/packages/andromeda-fungible-tokens/src/cw20_exchange.rs b/packages/andromeda-fungible-tokens/src/cw20_exchange.rs index 61ce001f7..79b2bb50d 100644 --- a/packages/andromeda-fungible-tokens/src/cw20_exchange.rs +++ b/packages/andromeda-fungible-tokens/src/cw20_exchange.rs @@ -1,5 +1,6 @@ use andromeda_std::{ amp::AndrAddr, andr_exec, andr_instantiate, andr_instantiate_modules, andr_query, + common::Milliseconds, }; use cosmwasm_schema::{cw_serde, QueryResponses}; use cosmwasm_std::Uint128; @@ -54,8 +55,8 @@ pub enum Cw20HookMsg { /// The recipient of the sale proceeds /// Sender is used if `None` provided recipient: Option, - start_time: Option, - duration: Option, + start_time: Option, + duration: Option, }, /// Purchases tokens Purchase { diff --git a/packages/andromeda-fungible-tokens/src/cw20_staking.rs b/packages/andromeda-fungible-tokens/src/cw20_staking.rs index 524553e78..2852a74c3 100644 --- a/packages/andromeda-fungible-tokens/src/cw20_staking.rs +++ b/packages/andromeda-fungible-tokens/src/cw20_staking.rs @@ -71,9 +71,6 @@ pub enum QueryMsg { start_after: Option, limit: Option, }, - /// Queries the current timestamp. - #[returns(u64)] - Timestamp {}, } #[cw_serde] diff --git a/packages/andromeda-non-fungible-tokens/src/auction.rs b/packages/andromeda-non-fungible-tokens/src/auction.rs index f98c71636..3bc8ea1aa 100644 --- a/packages/andromeda-non-fungible-tokens/src/auction.rs +++ b/packages/andromeda-non-fungible-tokens/src/auction.rs @@ -1,5 +1,5 @@ use andromeda_std::amp::AndrAddr; -use andromeda_std::common::OrderBy; +use andromeda_std::common::{Milliseconds, OrderBy}; use andromeda_std::{andr_exec, andr_instantiate, andr_instantiate_modules, andr_query}; use cosmwasm_schema::{cw_serde, QueryResponses}; @@ -31,8 +31,8 @@ pub enum ExecuteMsg { UpdateAuction { token_id: String, token_address: String, - start_time: u64, - duration: u64, + start_time: Option, + duration: Milliseconds, coin_denom: String, whitelist: Option>, min_bid: Option, @@ -58,9 +58,9 @@ pub enum Cw721HookMsg { /// has started but is immutable after that. StartAuction { /// Start time in milliseconds since epoch - start_time: u64, + start_time: Option, /// Duration in milliseconds - duration: u64, + duration: Milliseconds, coin_denom: String, min_bid: Option, whitelist: Option>, diff --git a/packages/andromeda-non-fungible-tokens/src/crowdfund.rs b/packages/andromeda-non-fungible-tokens/src/crowdfund.rs index 2e7df747d..4706f4005 100644 --- a/packages/andromeda-non-fungible-tokens/src/crowdfund.rs +++ b/packages/andromeda-non-fungible-tokens/src/crowdfund.rs @@ -4,6 +4,7 @@ use andromeda_std::common::Milliseconds; use andromeda_std::{andr_exec, andr_instantiate, andr_instantiate_modules, andr_query}; use cosmwasm_schema::{cw_serde, QueryResponses}; use cosmwasm_std::{Coin, Uint128}; +use cw721::Expiration; #[andr_instantiate] #[andr_instantiate_modules] @@ -20,8 +21,10 @@ pub enum ExecuteMsg { Mint(Vec), /// Starts the sale if one is not already ongoing. StartSale { + /// When the sale start. Defaults to current time. + start_time: Option, /// When the sale ends. - expiration: Milliseconds, + end_time: Expiration, /// The price per token. price: Coin, /// The minimum amount of tokens sold to go through with the sale. @@ -73,7 +76,7 @@ pub struct Config { #[cw_serde] pub struct State { /// The expiration denoting when the sale ends. - pub expiration: Milliseconds, + pub end_time: Expiration, /// The price of each token. pub price: Coin, /// The minimum number of tokens sold for the sale to go through. diff --git a/packages/andromeda-non-fungible-tokens/src/marketplace.rs b/packages/andromeda-non-fungible-tokens/src/marketplace.rs index f22d876fd..40d9b1eee 100644 --- a/packages/andromeda-non-fungible-tokens/src/marketplace.rs +++ b/packages/andromeda-non-fungible-tokens/src/marketplace.rs @@ -1,4 +1,6 @@ -use andromeda_std::{andr_exec, andr_instantiate, andr_instantiate_modules, andr_query}; +use andromeda_std::{ + andr_exec, andr_instantiate, andr_instantiate_modules, andr_query, common::Milliseconds, +}; use cosmwasm_schema::{cw_serde, QueryResponses}; use cosmwasm_std::Uint128; use cw721::{Cw721ReceiveMsg, Expiration}; @@ -39,8 +41,8 @@ pub enum Cw721HookMsg { StartSale { price: Uint128, coin_denom: String, - start_time: Option, - duration: Option, + start_time: Option, + duration: Option, }, } #[cw_serde] diff --git a/packages/andromeda-testing/src/mock.rs b/packages/andromeda-testing/src/mock.rs index 086c5cfb5..c8b168914 100644 --- a/packages/andromeda-testing/src/mock.rs +++ b/packages/andromeda-testing/src/mock.rs @@ -13,11 +13,39 @@ use andromeda_vfs::mock::{ mock_add_path, mock_andromeda_vfs, mock_register_user, mock_resolve_path_query, mock_vfs_instantiate_message, }; -use cosmwasm_std::{Addr, Empty}; -use cw_multi_test::{App, Contract, Executor}; +use cosmwasm_std::{coin, Addr, Coin, Empty}; +use cw_multi_test::{ + App, AppBuilder, BankKeeper, Contract, Executor, MockAddressGenerator, MockApiBech32, + WasmKeeper, +}; pub const ADMIN_USERNAME: &str = "am"; +pub type MockApp = App; + +pub fn mock_app() -> MockApp { + AppBuilder::new() + .with_api(MockApiBech32::new("andr")) + .with_wasm(WasmKeeper::new().with_address_generator(MockAddressGenerator)) + .build(|router, _api, storage| { + router + .bank + .init_balance( + storage, + &Addr::unchecked("owner"), + [coin(9999999, "uandr"), coin(999999, "uusd")].to_vec(), + ) + .unwrap(); + }) +} + +pub fn init_balances(app: &mut MockApp, balances: Vec<(Addr, &[Coin])>) { + for (addr, coins) in balances { + app.send_tokens(Addr::unchecked("owner"), addr, coins) + .unwrap(); + } +} + pub struct MockAndromeda { pub admin_address: Addr, pub adodb_address: Addr, @@ -25,7 +53,8 @@ pub struct MockAndromeda { } impl MockAndromeda { - pub fn new(app: &mut App, admin_address: &Addr) -> MockAndromeda { + pub fn new(app: &mut MockApp, admin_address: &Addr) -> MockAndromeda { + let admin_address = app.api().addr_make(admin_address.as_str()); // Store contract codes let adodb_code_id = app.store_code(mock_andromeda_adodb()); let kernel_code_id = app.store_code(mock_andromeda_kernel()); @@ -120,20 +149,21 @@ impl MockAndromeda { let mock_andr = MockAndromeda { adodb_address: adodb_address.clone(), - admin_address: admin_address.clone(), + admin_address, kernel_address, }; mock_andr.register_kernel_key_address(app, "adodb", adodb_address); mock_andr.register_kernel_key_address(app, "vfs", vfs_address); mock_andr.register_kernel_key_address(app, "economics", economics_address); - mock_andr.register_user(app, admin_address.clone(), ADMIN_USERNAME); + // TODO: Uncomment once Register User is reenabled + // mock_andr.register_user(app, admin_address.clone(), ADMIN_USERNAME); mock_andr } /// Stores a given Code ID under the given key in the ADO DB contract - pub fn store_code_id(&self, app: &mut App, key: &str, code_id: u64) { + pub fn store_code_id(&self, app: &mut MockApp, key: &str, code_id: u64) { let msg = mock_publish(code_id, key, "0.1.0", None, None); app.execute_contract( @@ -147,7 +177,7 @@ impl MockAndromeda { pub fn store_ado( &self, - app: &mut App, + app: &mut MockApp, contract: Box>, ado_type: impl Into, ) { @@ -156,7 +186,7 @@ impl MockAndromeda { } /// Gets the Code ID for a given key from the ADO DB contract - pub fn get_code_id(&self, app: &mut App, key: impl Into) -> u64 { + pub fn get_code_id(&self, app: &mut MockApp, key: impl Into) -> u64 { let msg = mock_get_code_id_msg(key.into()); app.wrap() @@ -167,7 +197,7 @@ impl MockAndromeda { /// Registers a key address for the kernel pub fn register_kernel_key_address( &self, - app: &mut App, + app: &mut MockApp, key: impl Into, address: Addr, ) { @@ -182,7 +212,7 @@ impl MockAndromeda { } /// Registers a user on the VFS - pub fn register_user(&self, app: &mut App, sender: Addr, username: impl Into) { + pub fn register_user(&self, app: &mut MockApp, sender: Addr, username: impl Into) { let vfs_address_query = mock_get_key_address("vfs"); let vfs_address: Addr = app .wrap() @@ -198,7 +228,7 @@ impl MockAndromeda { /// Adds a path to resolve to the VFS pub fn vfs_add_path( &self, - app: &mut App, + app: &mut MockApp, sender: Addr, name: impl Into, address: Addr, @@ -214,7 +244,7 @@ impl MockAndromeda { .unwrap(); } - pub fn vfs_resolve_path(&self, app: &mut App, path: impl Into) -> Addr { + pub fn vfs_resolve_path(&self, app: &mut MockApp, path: impl Into) -> Addr { let vfs_address_query = mock_get_key_address("vfs"); let vfs_address: Addr = app .wrap() @@ -228,7 +258,7 @@ impl MockAndromeda { /// Accepts ownership of the given contract for the given sender pub fn accept_ownership( &self, - app: &mut App, + app: &mut MockApp, address: impl Into, sender: impl Into, ) { diff --git a/packages/andromeda-testing/src/mock_contract.rs b/packages/andromeda-testing/src/mock_contract.rs index cef6101b4..27efeacd1 100644 --- a/packages/andromeda-testing/src/mock_contract.rs +++ b/packages/andromeda-testing/src/mock_contract.rs @@ -5,11 +5,13 @@ use andromeda_std::ado_base::{ AndromedaMsg, AndromedaQuery, }; use cosmwasm_std::{Addr, Coin}; -use cw_multi_test::{App, AppResponse, Executor}; +use cw_multi_test::{AppResponse, Executor}; use serde::{de::DeserializeOwned, Serialize}; pub use anyhow::Result as AnyResult; +use crate::mock::MockApp; + pub struct MockContract(Addr); impl MockContract { @@ -23,7 +25,7 @@ impl MockContract { pub fn execute( &self, - app: &mut App, + app: &mut MockApp, msg: M, sender: Addr, funds: &[Coin], @@ -31,18 +33,22 @@ impl MockContract { app.execute_contract(sender, self.addr().clone(), &msg, funds) } - pub fn query(&self, app: &App, msg: M) -> T { + pub fn query( + &self, + app: &MockApp, + msg: M, + ) -> T { app.wrap() .query_wasm_smart::(self.addr().clone(), &msg) .unwrap() } - pub fn query_owner(&self, app: &App) -> String { + pub fn query_owner(&self, app: &MockApp) -> String { self.query::(app, AndromedaQuery::Owner {}) .owner } - pub fn accept_ownership(&self, app: &mut App, sender: Addr) -> AnyResult { + pub fn accept_ownership(&self, app: &mut MockApp, sender: Addr) -> AnyResult { self.execute( app, AndromedaMsg::Ownership(OwnershipMessage::AcceptOwnership {}), diff --git a/packages/std/Cargo.toml b/packages/std/Cargo.toml index 31e4d607d..5cb037d3a 100644 --- a/packages/std/Cargo.toml +++ b/packages/std/Cargo.toml @@ -15,7 +15,7 @@ module_hooks = ["andromeda-macros/module_hooks"] crate-type = ["cdylib", "rlib"] [dependencies] -cosmwasm-std = { workspace = true, features = ["ibc3"] } +cosmwasm-std = { workspace = true, features = ["ibc3", "cosmwasm_1_2"] } cosmwasm-schema = { workspace = true } cw-storage-plus = { workspace = true } schemars = "0.8.10" @@ -36,3 +36,6 @@ strum_macros = { workspace = true } cw721 = { workspace = true } serde-json-wasm = "0.5.0" enum-repr = { workspace = true } + +[dev-dependencies] +cw-multi-test = { version = "1.0.0" } diff --git a/packages/std/src/ado_base/mod.rs b/packages/std/src/ado_base/mod.rs index 8afb7d125..60c782770 100644 --- a/packages/std/src/ado_base/mod.rs +++ b/packages/std/src/ado_base/mod.rs @@ -81,14 +81,12 @@ pub enum AndromedaQuery { #[cfg(feature = "modules")] #[returns(Vec)] ModuleIds {}, - #[returns(::cosmwasm_std::BalanceResponse)] - WithdrawableBalance { address: AndrAddr }, #[returns(Vec)] Permissions { actor: AndrAddr, limit: Option, start_after: Option, }, - #[returns(Vec)] + #[returns(Vec)] PermissionedActions {}, } diff --git a/packages/std/src/ado_base/permissioning.rs b/packages/std/src/ado_base/permissioning.rs index c3244f293..cf25027af 100644 --- a/packages/std/src/ado_base/permissioning.rs +++ b/packages/std/src/ado_base/permissioning.rs @@ -32,6 +32,11 @@ pub struct PermissionInfo { pub actor: String, } +#[cw_serde] +pub struct PermissionedActionsResponse { + pub actions: Vec, +} + /// An enum to represent a user's permission for an action /// /// - **Blacklisted** - The user cannot perform the action until after the provided expiration diff --git a/packages/std/src/ado_contract/execute.rs b/packages/std/src/ado_contract/execute.rs index 27bd5ca80..486b8d0c9 100644 --- a/packages/std/src/ado_contract/execute.rs +++ b/packages/std/src/ado_contract/execute.rs @@ -9,8 +9,8 @@ use crate::{ error::ContractError, }; use cosmwasm_std::{ - attr, ensure, from_json, to_json_binary, Addr, Api, CosmosMsg, Deps, DepsMut, Env, MessageInfo, - QuerierWrapper, Response, Storage, SubMsg, WasmMsg, + attr, ensure, from_json, to_json_binary, Addr, Api, ContractInfoResponse, CosmosMsg, Deps, + DepsMut, Env, MessageInfo, QuerierWrapper, Response, Storage, SubMsg, WasmMsg, }; use serde::de::DeserializeOwned; use serde::Serialize; @@ -23,19 +23,61 @@ impl<'a> ADOContract<'a> { storage: &mut dyn Storage, env: Env, api: &dyn Api, + querier: &QuerierWrapper, info: MessageInfo, msg: InstantiateMsg, ) -> Result { - self.owner.save( - storage, - &api.addr_validate(&msg.owner.unwrap_or(info.sender.to_string()))?, - )?; + let ado_type = if msg.ado_type.starts_with("crates.io:andromeda-") { + msg.ado_type.strip_prefix("crates.io:andromeda-").unwrap() + } else if msg.ado_type.starts_with("crates.io:") { + msg.ado_type.strip_prefix("crates.io:").unwrap() + } else { + &msg.ado_type + }; + cw2::set_contract_version(storage, ado_type, msg.ado_version)?; + let mut owner = api.addr_validate(&msg.owner.unwrap_or(info.sender.to_string()))?; self.original_publisher.save(storage, &info.sender)?; self.block_height.save(storage, &env.block.height)?; - self.ado_type.save(storage, &msg.ado_type)?; + self.ado_type.save(storage, &ado_type.to_string())?; self.kernel_address .save(storage, &api.addr_validate(&msg.kernel_address)?)?; - let attributes = [attr("method", "instantiate"), attr("type", &msg.ado_type)]; + let mut attributes = vec![ + attr("method", "instantiate"), + attr("type", ado_type), + attr("kernel_address", msg.kernel_address), + ]; + + // We do not want to store app contracts for the kernel, exit early if current contract is kernel + let is_kernel_contract = ado_type.contains("kernel"); + if is_kernel_contract { + self.owner.save(storage, &owner)?; + attributes.push(attr("owner", owner)); + return Ok(Response::new().add_attributes(attributes)); + } + + // Check if the sender is an app contract to allow for automatic storage of app contrcat reference + let maybe_contract_info = querier.query_wasm_contract_info(info.sender.clone()); + let is_sender_contract = maybe_contract_info.is_ok(); + if is_sender_contract { + let ContractInfoResponse { code_id, .. } = maybe_contract_info?; + let sender_ado_type = AOSQuerier::ado_type_getter( + querier, + &self.get_adodb_address(storage, querier)?, + code_id, + )?; + let is_sender_app = Some("app-contract".to_string()) == sender_ado_type; + // Automatically save app contract reference if creator is an app contract + if is_sender_app { + self.app_contract + .save(storage, &Addr::unchecked(info.sender.to_string()))?; + let app_owner = AOSQuerier::ado_owner_getter(querier, &info.sender)?; + owner = app_owner; + attributes.push(attr("app_contract", info.sender.to_string())); + } + } + + self.owner.save(storage, &owner)?; + attributes.push(attr("owner", owner)); Ok(Response::new().add_attributes(attributes)) } @@ -264,6 +306,7 @@ mod tests { deps_mut.storage, mock_env(), deps_mut.api, + &deps_mut.querier, info.clone(), InstantiateMsg { ado_type: "type".to_string(), @@ -301,6 +344,7 @@ mod tests { deps_mut.storage, mock_env(), deps_mut.api, + &deps_mut.querier, info.clone(), InstantiateMsg { ado_type: "type".to_string(), @@ -347,6 +391,7 @@ mod tests { deps_mut.storage, mock_env(), deps_mut.api, + &deps_mut.querier, info.clone(), InstantiateMsg { ado_type: "type".to_string(), @@ -389,6 +434,7 @@ mod tests { deps_mut.storage, mock_env(), deps_mut.api, + &deps_mut.querier, info.clone(), InstantiateMsg { ado_type: "type".to_string(), @@ -420,6 +466,7 @@ mod tests { deps_mut.storage, mock_env(), deps_mut.api, + &deps_mut.querier, info.clone(), InstantiateMsg { ado_type: "type".to_string(), diff --git a/packages/std/src/ado_contract/ownership.rs b/packages/std/src/ado_contract/ownership.rs index cf22fb8ed..4fda20171 100644 --- a/packages/std/src/ado_contract/ownership.rs +++ b/packages/std/src/ado_contract/ownership.rs @@ -109,6 +109,14 @@ impl<'a> ADOContract<'a> { Ok(Response::new().add_attributes(vec![attr("action", "disown")])) } + /// Helper function to query if a given address is the current contract owner. + /// + /// Returns a boolean value indicating if the given address is the contract owner. + pub fn owner(&self, storage: &dyn Storage) -> Result { + let owner = self.owner.load(storage)?; + Ok(owner) + } + /// Helper function to query if a given address is the current contract owner. /// /// Returns a boolean value indicating if the given address is the contract owner. diff --git a/packages/std/src/amp/addresses.rs b/packages/std/src/amp/addresses.rs index 57fa7716f..e9e878811 100644 --- a/packages/std/src/amp/addresses.rs +++ b/packages/std/src/amp/addresses.rs @@ -131,8 +131,7 @@ impl AndrAddr { match app_contract { None => Err(ContractError::AppContractNotSpecified {}), Some(app_contract) => { - let replaced = - AndrAddr(self.0.replace("./", &format!("/home/{app_contract}/"))); + let replaced = AndrAddr(self.0.replace("./", &format!("~{app_contract}/"))); vfs_resolve_symlink(replaced, vfs_contract, querier) } } diff --git a/packages/std/src/common/expiration.rs b/packages/std/src/common/expiration.rs index 395018633..ff77c9447 100644 --- a/packages/std/src/common/expiration.rs +++ b/packages/std/src/common/expiration.rs @@ -1,8 +1,10 @@ -use cosmwasm_std::{ensure, BlockInfo, Timestamp}; +use cosmwasm_std::{ensure, BlockInfo, Env, Timestamp}; use cw_utils::Expiration; use crate::error::ContractError; +use super::Milliseconds; + pub const MILLISECONDS_TO_NANOSECONDS_RATIO: u64 = 1_000_000; /// Creates a CosmWasm Expiration struct given a time in milliseconds @@ -11,16 +13,14 @@ pub const MILLISECONDS_TO_NANOSECONDS_RATIO: u64 = 1_000_000; /// * `time` - The expiration time in milliseconds since the Epoch /// /// Returns a `cw_utils::Expiration::AtTime` struct with the given expiration time -pub fn expiration_from_milliseconds(time: u64) -> Result { +pub fn expiration_from_milliseconds(time: Milliseconds) -> Result { // Make sure that multiplying by above ratio does not exceed u64 limit ensure!( - time <= u64::MAX / MILLISECONDS_TO_NANOSECONDS_RATIO, + time.milliseconds() <= u64::MAX / MILLISECONDS_TO_NANOSECONDS_RATIO, ContractError::InvalidExpirationTime {} ); - Ok(Expiration::AtTime(Timestamp::from_nanos( - time * MILLISECONDS_TO_NANOSECONDS_RATIO, - ))) + Ok(Expiration::AtTime(Timestamp::from_nanos(time.nanos()))) } pub fn block_to_expiration(block: &BlockInfo, model: Expiration) -> Option { @@ -31,6 +31,32 @@ pub fn block_to_expiration(block: &BlockInfo, model: Expiration) -> Option, +) -> Result<(Expiration, Milliseconds), ContractError> { + let current_time = Milliseconds::from_nanos(env.block.time.nanos()).milliseconds(); + + let start_expiration = if let Some(start_time) = start_time { + expiration_from_milliseconds(start_time)? + } else { + // Set as current time + 1 so that it isn't expired from the very start + expiration_from_milliseconds(Milliseconds(current_time + 1))? + }; + + // Validate start time + let block_time = block_to_expiration(&env.block, start_expiration).unwrap(); + ensure!( + start_expiration.gt(&block_time), + ContractError::StartTimeInThePast { + current_time, + current_block: env.block.height, + } + ); + + Ok((start_expiration, Milliseconds(current_time))) +} + #[cfg(test)] mod tests { use super::*; @@ -38,11 +64,11 @@ mod tests { #[test] fn test_expiration_from_milliseconds() { let time = u64::MAX; - let result = expiration_from_milliseconds(time).unwrap_err(); + let result = expiration_from_milliseconds(Milliseconds(time)).unwrap_err(); assert_eq!(result, ContractError::InvalidExpirationTime {}); let valid_time = 100; - let result = expiration_from_milliseconds(valid_time).unwrap(); + let result = expiration_from_milliseconds(Milliseconds(valid_time)).unwrap(); assert_eq!( Expiration::AtTime(Timestamp::from_nanos(100000000u64)), result diff --git a/packages/std/src/error.rs b/packages/std/src/error.rs index b5a2be381..111fe63b1 100644 --- a/packages/std/src/error.rs +++ b/packages/std/src/error.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{OverflowError, StdError}; +use cosmwasm_std::{Addr, OverflowError, StdError}; use cw20_base::ContractError as Cw20ContractError; use cw721_base::ContractError as Cw721ContractError; use cw_asset::AssetError; @@ -221,6 +221,9 @@ pub enum ContractError { #[error("NoReceivingAddress")] NoReceivingAddress {}, + #[error("TemporarilyDisabled")] + TemporarilyDisabled {}, + #[error("AccountNotFound")] AccountNotFound {}, @@ -402,6 +405,9 @@ pub enum ContractError { #[error("Invalid png header")] InvalidPngHeader {}, + #[error("Instantiate2 Address Mistmatch: expected: {expected}, received: {received}")] + Instantiate2AddressMismatch { expected: Addr, received: Addr }, + #[error("Duplicate initial balance addresses")] DuplicateInitialBalanceAddresses {}, diff --git a/packages/std/src/os/aos_querier.rs b/packages/std/src/os/aos_querier.rs index fe160a7f1..7d20283b1 100644 --- a/packages/std/src/os/aos_querier.rs +++ b/packages/std/src/os/aos_querier.rs @@ -54,7 +54,7 @@ impl AOSQuerier { adodb_addr: &Addr, code_id: u64, ) -> Result, ContractError> { - let key = AOSQuerier::get_map_storage_key("ado_type", &[&code_id.to_be_bytes()])?; + let key = AOSQuerier::get_map_storage_key("ado_type", &[code_id.to_string().as_bytes()])?; let ado_type: Option = AOSQuerier::query_storage(querier, adodb_addr, &key)?; Ok(ado_type.map(|v| v.get_type())) } @@ -65,8 +65,8 @@ impl AOSQuerier { code_id: u64, ) -> Result, ContractError> { let query = ADODBQueryMsg::ADOType { code_id }; - let ado_type: Option = querier.query_wasm_smart(adodb_addr, &query)?; - Ok(ado_type) + let ado_type: Option = querier.query_wasm_smart(adodb_addr, &query)?; + Ok(ado_type.map(|v| v.get_type())) } pub fn ado_publisher_getter( @@ -89,7 +89,7 @@ impl AOSQuerier { adodb_addr: &Addr, code_id: u64, ) -> Result<(), ContractError> { - let key = AOSQuerier::get_map_storage_key("ado_type", &[&code_id.to_be_bytes()])?; + let key = AOSQuerier::get_map_storage_key("ado_type", &[code_id.to_string().as_bytes()])?; let verify: Option = AOSQuerier::query_storage(querier, adodb_addr, &key)?; if verify.is_some() { diff --git a/packages/std/src/os/vfs.rs b/packages/std/src/os/vfs.rs index 8fb4b350d..02f6fdaf9 100644 --- a/packages/std/src/os/vfs.rs +++ b/packages/std/src/os/vfs.rs @@ -12,11 +12,11 @@ use cosmwasm_schema::{cw_serde, QueryResponses}; use cosmwasm_std::{ensure, Addr, Api, QuerierWrapper}; use regex::Regex; -pub const COMPONENT_NAME_REGEX: &str = r"^[A-Za-z0-9.\-_]{2,40}$"; +pub const COMPONENT_NAME_REGEX: &str = r"^[A-Za-z0-9.\-_]{2,80}$"; pub const USERNAME_REGEX: &str = r"^[a-z0-9]{2,30}$"; -pub const PATH_REGEX: &str = r"^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\-_]{2,40}?)*(/)?$"; -pub const PROTOCOL_PATH_REGEX: &str = r"^((([A-Za-z0-9]+://)?([A-Za-z0-9.\-_]{2,40}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\-_]{2,40}?)*(/)?)$"; +pub const PATH_REGEX: &str = r"^(~[a-z0-9]{2,}|/(lib|home))(/[A-Za-z0-9.\-_]{2,80}?)*(/)?$"; +pub const PROTOCOL_PATH_REGEX: &str = r"^((([A-Za-z0-9]+://)?([A-Za-z0-9.\-_]{2,80}/)))?((~[a-z0-9]{2,}|(lib|home))(/[A-Za-z0-9.\-_]{2,80}?)*(/)?)$"; pub fn convert_component_name(path: &str) -> String { path.trim() @@ -208,6 +208,17 @@ pub enum ExecuteMsg { #[cw_serde] pub struct MigrateMsg {} +#[cw_serde] +pub struct SubDirBound { + address: Addr, + name: String, +} +impl From for (Addr, String) { + fn from(val: SubDirBound) -> Self { + (val.address, val.name) + } +} + #[cw_serde] #[derive(QueryResponses)] pub enum QueryMsg { @@ -216,8 +227,8 @@ pub enum QueryMsg { #[returns(Vec)] SubDir { path: AndrAddr, - min: Option<(Addr, String)>, - max: Option<(Addr, String)>, + min: Option, + max: Option, limit: Option, }, #[returns(Vec)] @@ -538,7 +549,7 @@ mod test { }, ValidatePathNameTestCase { name: "Path with very long name", - path: "/home/username/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + path: "/home/username/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", should_err: true, }, ValidatePathNameTestCase { diff --git a/packages/std/src/testing/mock_querier.rs b/packages/std/src/testing/mock_querier.rs index 4be32bcc5..ec46c4876 100644 --- a/packages/std/src/testing/mock_querier.rs +++ b/packages/std/src/testing/mock_querier.rs @@ -14,8 +14,9 @@ use cosmwasm_std::SubMsg; use cosmwasm_std::{ from_json, testing::{MockApi, MockQuerier, MockStorage, MOCK_CONTRACT_ADDR}, - to_json_binary, Addr, Binary, Coin, ContractInfoResponse, ContractResult, OwnedDeps, Querier, - QuerierResult, QueryRequest, SystemError, SystemResult, Uint128, WasmQuery, + to_json_binary, Addr, Binary, CodeInfoResponse, Coin, ContractInfoResponse, ContractResult, + HexBinary, OwnedDeps, Querier, QuerierResult, QueryRequest, SystemError, SystemResult, Uint128, + WasmQuery, }; #[cfg(feature = "primitive")] use cosmwasm_std::{Decimal, Uint128}; @@ -60,6 +61,8 @@ pub const MOCK_ACTION: &str = "action"; pub const UNWHITELISTED_ADDRESS: &str = "unwhitelisted_address"; pub const RATES_EXCLUDED_ADDRESS: &str = "rates_excluded_address"; +pub const MOCK_CHECKSUM: &str = "9af782a3a1bcbcd22dbb6a45c751551d9af782a3a1bcbcd22dbb6a45c751551d"; + pub const MOCK_WALLET: &str = "mock_wallet"; pub struct WasmMockQuerier { @@ -163,7 +166,7 @@ impl MockAndromedaQuerier { MOCK_CW20_CONTRACT => self.handle_cw20_owner_query(key), MOCK_ANCHOR_CONTRACT => self.handle_anchor_owner_query(key), - _ => panic!("Unsupported query for contract: {contract_addr}"), + _ => self.handle_ado_raw_query(key, &Addr::unchecked(contract_addr)), } } // Defaults to code ID 1, returns 2 for `INVALID_CONTRACT` which is considered an invalid ADODB code id @@ -181,6 +184,14 @@ impl MockAndromedaQuerier { }; SystemResult::Ok(ContractResult::Ok(to_json_binary(&resp).unwrap())) } + QueryRequest::Wasm(WasmQuery::CodeInfo { code_id }) => { + if *code_id == 2u64 { + return SystemResult::Ok(ContractResult::Err("Invalid Code ID".to_string())); + } + let mut resp = CodeInfoResponse::default(); + resp.checksum = HexBinary::from_hex(MOCK_CHECKSUM).unwrap(); + SystemResult::Ok(ContractResult::Ok(to_json_binary(&resp).unwrap())) + } _ => querier.handle_query(request), } } @@ -271,6 +282,7 @@ impl MockAndromedaQuerier { fn handle_adodb_query(&self, msg: &Binary) -> QuerierResult { match from_json(msg).unwrap() { ADODBQueryMsg::ADOType { code_id } => match code_id { + 3 => SystemResult::Ok(ContractResult::Ok(to_json_binary(&"app-contract").unwrap())), 1 => SystemResult::Ok(ContractResult::Ok(to_json_binary(&"ADOType").unwrap())), _ => SystemResult::Ok(ContractResult::Err("Invalid Code ID".to_string())), }, @@ -411,6 +423,19 @@ impl MockAndromedaQuerier { } } + pub fn handle_ado_raw_query(&self, key: &Binary, contract_addr: &Addr) -> QuerierResult { + let key_vec = key.as_slice(); + let key_str = String::from_utf8(key_vec.to_vec()).unwrap(); + + if key_str.contains("owner") { + return SystemResult::Ok(ContractResult::Ok( + to_json_binary(&Addr::unchecked("owner".to_string())).unwrap(), + )); + } + + panic!("Unsupported query for contract: {contract_addr}") + } + pub fn handle_kernel_raw_query(&self, key: &Binary, fake: bool) -> QuerierResult { let key_vec = key.as_slice(); let key_str = String::from_utf8(key_vec.to_vec()).unwrap(); @@ -499,12 +524,12 @@ impl MockAndromedaQuerier { } else if key_str.contains("ado_type") { let split = key_str.split("ado_type"); let key = split.last(); - let app_contract_key = String::from_utf8(3u64.to_be_bytes().to_vec()).unwrap(); - let generic_contract_key = String::from_utf8(1u64.to_be_bytes().to_vec()).unwrap(); + // let app_contract_key = String::from_utf8(3u64.to_be_bytes().to_vec()).unwrap(); + // let generic_contract_key = String::from_utf8(1u64.to_be_bytes().to_vec()).unwrap(); if let Some(key) = key { - if key == app_contract_key { + if key == "3" { SystemResult::Ok(ContractResult::Ok(to_json_binary("app-contract").unwrap())) - } else if key == generic_contract_key { + } else if key == "1" { SystemResult::Ok(ContractResult::Ok(to_json_binary("ADOType").unwrap())) } else { SystemResult::Ok(ContractResult::Ok(Binary::default())) diff --git a/tests-integration/Cargo.toml b/tests-integration/Cargo.toml index d718b36f6..7d223d786 100644 --- a/tests-integration/Cargo.toml +++ b/tests-integration/Cargo.toml @@ -95,7 +95,7 @@ andromeda-vfs = { path = "../contracts/os/andromeda-vfs", features = [ andromeda-testing = { workspace = true, features = ["testing"] } #Cosmwasm Crates -cosmwasm-std = { workspace = true} +cosmwasm-std = { workspace = true } cosmwasm-schema = { workspace = true } cw721-base = { workspace = true } cw721 = { workspace = true } @@ -108,8 +108,12 @@ cw-asset = { workspace = true } andromeda-std = { workspace = true } + [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -cw-multi-test = { version = "1.0.0", features=["cosmwasm_1_3"] } +cw-multi-test = { version = "1.0.0", features = [ + "cosmwasm_1_3", + "cosmwasm_1_2", +] } # [[test]] diff --git a/tests-integration/tests/auction_app.rs b/tests-integration/tests/auction_app.rs index 5118298fc..7ac0357cd 100644 --- a/tests-integration/tests/auction_app.rs +++ b/tests-integration/tests/auction_app.rs @@ -2,8 +2,7 @@ use andromeda_app::app::AppComponent; use andromeda_app_contract::mock::{ - mock_andromeda_app, mock_app_instantiate_msg, mock_claim_ownership_msg, mock_get_address_msg, - mock_get_components_msg, + mock_andromeda_app, mock_app_instantiate_msg, mock_get_address_msg, mock_get_components_msg, }; use andromeda_auction::mock::{ mock_andromeda_auction, mock_auction_instantiate_msg, mock_authorize_token_address, @@ -17,55 +16,59 @@ use andromeda_cw721::mock::{ use andromeda_non_fungible_tokens::auction::{ AuctionIdsResponse, AuctionStateResponse, BidsResponse, }; -use andromeda_std::ado_base::permissioning::Permission; use andromeda_std::amp::AndrAddr; use andromeda_std::common::expiration::MILLISECONDS_TO_NANOSECONDS_RATIO; use andromeda_std::error::ContractError; +use andromeda_std::{ado_base::permissioning::Permission, common::Milliseconds}; use andromeda_testing::mock::MockAndromeda; use cosmwasm_std::{coin, to_json_binary, Addr, BlockInfo, Timestamp, Uint128}; use cw721::OwnerOfResponse; -use cw_multi_test::{App, Executor}; - -fn mock_app() -> App { - App::new(|router, _api, storage| { - router - .bank - .init_balance( - storage, - &Addr::unchecked("owner"), - [coin(999999, "uandr")].to_vec(), - ) - .unwrap(); - router - .bank - .init_balance( - storage, - &Addr::unchecked("buyer_one"), - [coin(100, "uandr")].to_vec(), - ) - .unwrap(); - router - .bank - .init_balance( - storage, - &Addr::unchecked("buyer_two"), - [coin(100, "uandr")].to_vec(), - ) - .unwrap(); - }) +use cw_multi_test::{ + App, AppBuilder, BankKeeper, Executor, MockAddressGenerator, MockApiBech32, WasmKeeper, +}; + +fn mock_app() -> App { + AppBuilder::new() + .with_api(MockApiBech32::new("andr")) + .with_wasm(WasmKeeper::new().with_address_generator(MockAddressGenerator)) + .build(|router, _api, storage| { + router + .bank + .init_balance( + storage, + &Addr::unchecked("owner"), + [coin(9999999, "uandr")].to_vec(), + ) + .unwrap(); + }) } -fn mock_andromeda(app: &mut App, admin_address: Addr) -> MockAndromeda { +fn mock_andromeda(app: &mut App, admin_address: Addr) -> MockAndromeda { MockAndromeda::new(app, &admin_address) } #[test] fn test_auction_app() { - let owner = Addr::unchecked("owner"); - let buyer_one = Addr::unchecked("buyer_one"); - let buyer_two = Addr::unchecked("buyer_two"); - let mut router = mock_app(); + let owner = router.api().addr_make("owner"); + let buyer_one = router.api().addr_make("buyer_one"); + let buyer_two = router.api().addr_make("buyer_two"); + + router + .send_tokens( + Addr::unchecked("owner"), + buyer_one.clone(), + &[coin(1000, "uandr")], + ) + .unwrap(); + router + .send_tokens( + Addr::unchecked("owner"), + buyer_two.clone(), + &[coin(1000, "uandr")], + ) + .unwrap(); + let andr = mock_andromeda(&mut router, owner.clone()); // Store contract codes @@ -91,8 +94,15 @@ fn test_auction_app() { to_json_binary(&cw721_init_msg).unwrap(), ); - let auction_init_msg = - mock_auction_instantiate_msg(None, andr.kernel_address.to_string(), None, None); + let auction_init_msg = mock_auction_instantiate_msg( + None, + andr.kernel_address.to_string(), + None, + Some(vec![AndrAddr::from_string(format!( + "./{}", + cw721_component.name + ))]), + ); let auction_component = AppComponent::new( "auction".to_string(), "auction".to_string(), @@ -100,7 +110,7 @@ fn test_auction_app() { ); // Create App - let app_components = vec![cw721_component.clone(), auction_component.clone()]; + let app_components = vec![auction_component.clone(), cw721_component.clone()]; let app_init_msg = mock_app_instantiate_msg( "AuctionApp".to_string(), app_components.clone(), @@ -126,14 +136,14 @@ fn test_auction_app() { assert_eq!(components, app_components); - router - .execute_contract( - owner.clone(), - Addr::unchecked(app_addr.clone()), - &mock_claim_ownership_msg(None), - &[], - ) - .unwrap(); + // router + // .execute_contract( + // owner.clone(), + // Addr::unchecked(app_addr.clone()), + // &mock_claim_ownership_msg(None), + // &[], + // ) + // .unwrap(); // Mint Tokens let cw721_addr: String = router @@ -144,7 +154,7 @@ fn test_auction_app() { ) .unwrap(); let mint_msg = mock_quick_mint_msg(1, owner.to_string()); - andr.accept_ownership(&mut router, cw721_addr.clone(), owner.clone()); + // andr.accept_ownership(&mut router, cw721_addr.clone(), owner.clone()); router .execute_contract( owner.clone(), @@ -159,7 +169,7 @@ fn test_auction_app() { .wrap() .query_wasm_smart(app_addr, &mock_get_address_msg(auction_component.name)) .unwrap(); - andr.accept_ownership(&mut router, auction_addr.clone(), owner.clone()); + // andr.accept_ownership(&mut router, auction_addr.clone(), owner.clone()); router .execute_contract( owner.clone(), @@ -170,7 +180,13 @@ fn test_auction_app() { .unwrap(); let start_time = router.block_info().time.nanos() / MILLISECONDS_TO_NANOSECONDS_RATIO + 100; - let receive_msg = mock_start_auction(start_time, 1000, "uandr".to_string(), None, None); + let receive_msg = mock_start_auction( + Some(Milliseconds(start_time)), + Milliseconds(1000), + "uandr".to_string(), + None, + None, + ); let send_msg = mock_send_nft( auction_addr.clone(), "0".to_string(), diff --git a/tests-integration/tests/crowdfund_app.rs b/tests-integration/tests/crowdfund_app.rs index 0a1f24ed2..61d0b9f5b 100644 --- a/tests-integration/tests/crowdfund_app.rs +++ b/tests-integration/tests/crowdfund_app.rs @@ -1,7 +1,6 @@ use andromeda_app::app::{AppComponent, ComponentType}; use andromeda_app_contract::mock::{ - mock_andromeda_app, mock_app_instantiate_msg, mock_claim_ownership_msg, mock_get_address_msg, - mock_get_components_msg, + mock_andromeda_app, mock_app_instantiate_msg, mock_get_address_msg, mock_get_components_msg, }; use andromeda_crowdfund::mock::{ mock_andromeda_crowdfund, mock_crowdfund_instantiate_msg, mock_crowdfund_quick_mint_msg, @@ -13,7 +12,7 @@ use andromeda_cw721::mock::{ use andromeda_finance::splitter::AddressPercent; use andromeda_std::{ amp::{AndrAddr, Recipient}, - common::Milliseconds, + common::{expiration::MILLISECONDS_TO_NANOSECONDS_RATIO, Milliseconds}, }; use andromeda_modules::rates::{Rate, RateInfo}; @@ -22,65 +21,38 @@ use andromeda_splitter::mock::{ mock_andromeda_splitter, mock_splitter_instantiate_msg, mock_splitter_send_msg, }; use andromeda_std::ado_base::modules::Module; +use cw20::Expiration; use std::str::FromStr; -use andromeda_testing::mock::MockAndromeda; -use cosmwasm_std::{coin, to_json_binary, Addr, BlockInfo, Decimal, Uint128}; +use andromeda_testing::mock::{init_balances, mock_app, MockAndromeda, MockApp}; +use cosmwasm_std::{coin, to_json_binary, Addr, BlockInfo, Decimal, Timestamp, Uint128}; use cw721::OwnerOfResponse; -use cw_multi_test::{App, Executor}; +use cw_multi_test::Executor; -fn mock_app() -> App { - App::new(|router, _api, storage| { - router - .bank - .init_balance( - storage, - &Addr::unchecked("owner"), - [coin(999999, "uandr")].to_vec(), - ) - .unwrap(); - router - .bank - .init_balance( - storage, - &Addr::unchecked("buyer_one"), - [coin(100, "uandr")].to_vec(), - ) - .unwrap(); - router - .bank - .init_balance( - storage, - &Addr::unchecked("buyer_two"), - [coin(100, "uandr")].to_vec(), - ) - .unwrap(); - router - .bank - .init_balance( - storage, - &Addr::unchecked("buyer_three"), - [coin(100, "uandr")].to_vec(), - ) - .unwrap(); - }) -} - -fn mock_andromeda(app: &mut App, admin_address: Addr) -> MockAndromeda { +fn mock_andromeda(app: &mut MockApp, admin_address: Addr) -> MockAndromeda { MockAndromeda::new(app, &admin_address) } // TODO: Fix to check wallet balance post sale #[test] fn test_crowdfund_app() { - let owner = Addr::unchecked("owner"); - let vault_one_recipient_addr = Addr::unchecked("vault_one_recipient"); - let vault_two_recipient_addr = Addr::unchecked("vault_two_recipient"); - let buyer_one = Addr::unchecked("buyer_one"); - let buyer_two = Addr::unchecked("buyer_two"); - let buyer_three = Addr::unchecked("buyer_three"); - let mut router = mock_app(); + + let owner = router.api().addr_make("owner"); + let vault_one_recipient_addr = router.api().addr_make("vault_one_recipient"); + let vault_two_recipient_addr = router.api().addr_make("vault_two_recipient"); + let buyer_one = router.api().addr_make("buyer_one"); + let buyer_two = router.api().addr_make("buyer_two"); + let buyer_three = router.api().addr_make("buyer_three"); + init_balances( + &mut router, + vec![ + (buyer_one.clone(), &[coin(100, "uandr")]), + (buyer_two.clone(), &[coin(100, "uandr")]), + (buyer_three.clone(), &[coin(100, "uandr")]), + ], + ); + let andr = mock_andromeda(&mut router, owner.clone()); // Store contract codes @@ -98,7 +70,7 @@ fn test_crowdfund_app() { // Generate App Components // App component names must be less than 3 characters or longer than 54 characters to force them to be 'invalid' as the MockApi struct used within the CosmWasm App struct only contains those two validation checks - let rates_recipient = "rates_recipient"; + let rates_recipient = router.api().addr_make("rates_recipient"); // Generate rates contract let rates: Vec = [RateInfo { rate: Rate::Flat(coin(1, "uandr")), @@ -201,14 +173,14 @@ fn test_crowdfund_app() { assert_eq!(components, app_components); - router - .execute_contract( - owner.clone(), - app_addr.clone(), - &mock_claim_ownership_msg(None), - &[], - ) - .unwrap(); + // router + // .execute_contract( + // owner.clone(), + // app_addr.clone(), + // &mock_claim_ownership_msg(None), + // &[], + // ) + // .unwrap(); let crowdfund_addr: String = router .wrap() @@ -220,11 +192,11 @@ fn test_crowdfund_app() { // Mint Tokens let mint_msg = mock_crowdfund_quick_mint_msg(5, owner.to_string()); - andr.accept_ownership(&mut router, crowdfund_addr.clone(), owner.clone()); + // andr.accept_ownership(&mut router, crowdfund_addr.clone(), owner.clone()); router .execute_contract( owner.clone(), - Addr::unchecked(crowdfund_addr.clone()), + Addr::unchecked(crowdfund_addr.as_str()), &mint_msg, &[], ) @@ -233,10 +205,14 @@ fn test_crowdfund_app() { // Start Sale let token_price = coin(100, "uandr"); - let sale_recipient = Recipient::from_string(format!("~am/app/{}", splitter_app_component.name)) - .with_msg(mock_splitter_send_msg()); + let sale_recipient = + Recipient::from_string(format!("/home/{owner}/app/{}", splitter_app_component.name)) + .with_msg(mock_splitter_send_msg()); + let current_time = router.block_info().time.nanos() / MILLISECONDS_TO_NANOSECONDS_RATIO; + let start_msg = mock_start_crowdfund_msg( - Milliseconds::from_seconds(router.block_info().time.seconds() + 5), + None, + Expiration::AtTime(Timestamp::from_nanos((current_time + 2) * 1_000_000)), token_price.clone(), Uint128::from(3u128), Some(1), @@ -245,7 +221,7 @@ fn test_crowdfund_app() { router .execute_contract( owner.clone(), - Addr::unchecked(crowdfund_addr.clone()), + Addr::unchecked(crowdfund_addr.as_str()), &start_msg, &[], ) @@ -258,7 +234,7 @@ fn test_crowdfund_app() { router .execute_contract( buyer, - Addr::unchecked(crowdfund_addr.clone()), + Addr::unchecked(crowdfund_addr.as_str()), &purchase_msg, &[token_price.clone()], ) diff --git a/tests-integration/tests/cw20_staking.rs b/tests-integration/tests/cw20_staking.rs index c6dc65fe6..5a23c9d2c 100644 --- a/tests-integration/tests/cw20_staking.rs +++ b/tests-integration/tests/cw20_staking.rs @@ -1,7 +1,6 @@ use andromeda_app::app::AppComponent; use andromeda_app_contract::mock::{ - mock_andromeda_app, mock_app_instantiate_msg, mock_claim_ownership_msg, mock_get_address_msg, - mock_get_components_msg, + mock_andromeda_app, mock_app_instantiate_msg, mock_get_components_msg, }; use andromeda_cw20::mock::{ mock_andromeda_cw20, mock_cw20_instantiate_msg, mock_cw20_send, mock_cw20_transfer, @@ -17,46 +16,17 @@ use andromeda_fungible_tokens::cw20_staking::{AllocationConfig, StakerResponse}; use andromeda_std::common::Milliseconds; use andromeda_std::ado_base::version::VersionResponse; -use andromeda_testing::mock::MockAndromeda; +use andromeda_testing::mock::{mock_app, MockAndromeda, MockApp}; use cosmwasm_std::{coin, to_json_binary, Addr, BlockInfo, Timestamp, Uint128}; use cw20::{BalanceResponse, Cw20Coin}; use cw_asset::AssetInfoUnchecked; -use cw_multi_test::{App, Executor}; - -fn mock_app() -> App { - App::new(|router, _api, storage| { - router - .bank - .init_balance( - storage, - &Addr::unchecked("owner"), - [coin(999999, "uandr"), coin(99999, "uusd")].to_vec(), - ) - .unwrap(); - router - .bank - .init_balance( - storage, - &Addr::unchecked("staker_one"), - [coin(100, "uandr")].to_vec(), - ) - .unwrap(); - router - .bank - .init_balance( - storage, - &Addr::unchecked("staker_two"), - [coin(100, "uandr")].to_vec(), - ) - .unwrap(); - }) -} +use cw_multi_test::Executor; -fn mock_andromeda(app: &mut App, admin_address: Addr) -> MockAndromeda { +fn mock_andromeda(app: &mut MockApp, admin_address: Addr) -> MockAndromeda { MockAndromeda::new(app, &admin_address) } -fn setup_andr(router: &mut App, owner: &Addr) -> MockAndromeda { +fn setup_andr(router: &mut MockApp, owner: &Addr) -> MockAndromeda { let andr = mock_andromeda(router, owner.clone()); // Store contract codes @@ -70,10 +40,10 @@ fn setup_andr(router: &mut App, owner: &Addr) -> MockAndromeda { andr } -fn setup_app(andr: &MockAndromeda, router: &mut App) -> Addr { - let owner = Addr::unchecked("owner"); - let staker_one = Addr::unchecked("staker_one"); - let staker_two = Addr::unchecked("staker_two"); +fn setup_app(andr: &MockAndromeda, router: &mut MockApp) -> Addr { + let owner = router.api().addr_make("owner"); + let staker_one = router.api().addr_make("staker_one"); + let staker_two = router.api().addr_make("staker_two"); // Create App Components let initial_balances = vec![ @@ -97,7 +67,7 @@ fn setup_app(andr: &MockAndromeda, router: &mut App) -> Addr { 6, initial_balances, Some(mock_minter( - "owner".to_string(), + owner.to_string(), Some(Uint128::from(1000000u128)), )), None, @@ -141,20 +111,6 @@ fn setup_app(andr: &MockAndromeda, router: &mut App) -> Addr { Some(owner.to_string()), ) .unwrap(); - let claim_ownership = mock_claim_ownership_msg(None); - router - .execute_contract( - owner.clone(), - Addr::unchecked(app_addr.clone()), - &claim_ownership, - &[], - ) - .unwrap(); - let cw20_staking_addr: String = router - .wrap() - .query_wasm_smart(app_addr.to_string(), &mock_get_address_msg("cw20staking")) - .unwrap(); - andr.accept_ownership(router, cw20_staking_addr, owner); let components: Vec = router .wrap() @@ -168,23 +124,18 @@ fn setup_app(andr: &MockAndromeda, router: &mut App) -> Addr { #[test] fn test_cw20_staking_app() { - let owner = Addr::unchecked("owner"); - let staker_one = Addr::unchecked("staker_one"); - let staker_two = Addr::unchecked("staker_two"); - let mut router = mock_app(); + let owner = router.api().addr_make("owner"); + let staker_one = router.api().addr_make("staker_one"); + let staker_two = router.api().addr_make("staker_two"); + let andr = setup_andr(&mut router, &owner); let app_addr = setup_app(&andr, &mut router); // Component Addresses - let cw20_addr: String = router - .wrap() - .query_wasm_smart(app_addr.to_string(), &mock_get_address_msg("cw20")) - .unwrap(); - let cw20_staking_addr: String = router - .wrap() - .query_wasm_smart(app_addr.to_string(), &mock_get_address_msg("cw20staking")) - .unwrap(); + let cw20_addr = andr.vfs_resolve_path(&mut router, format!("/home/{app_addr}/cw20")); + let cw20_staking_addr = + andr.vfs_resolve_path(&mut router, format!("/home/{app_addr}/cw20staking")); // Check Balances let balance_one: BalanceResponse = router @@ -213,37 +164,27 @@ fn test_cw20_staking_app() { // Stake Tokens let staking_msg_one = mock_cw20_send( - cw20_staking_addr.clone(), + cw20_staking_addr.to_string(), Uint128::from(1000u128), to_json_binary(&mock_cw20_stake()).unwrap(), ); router - .execute_contract( - staker_one.clone(), - Addr::unchecked(cw20_addr.clone()), - &staking_msg_one, - &[], - ) + .execute_contract(staker_one.clone(), cw20_addr.clone(), &staking_msg_one, &[]) .unwrap(); let staking_msg_two = mock_cw20_send( - cw20_staking_addr.clone(), + cw20_staking_addr.to_string(), Uint128::from(2000u128), to_json_binary(&mock_cw20_stake()).unwrap(), ); router - .execute_contract( - staker_two.clone(), - Addr::unchecked(cw20_addr.clone()), - &staking_msg_two, - &[], - ) + .execute_contract(staker_two.clone(), cw20_addr.clone(), &staking_msg_two, &[]) .unwrap(); // Transfer Tokens for Reward - let transfer_msg = mock_cw20_transfer(cw20_staking_addr.clone(), Uint128::from(3000u128)); + let transfer_msg = mock_cw20_transfer(cw20_staking_addr.to_string(), Uint128::from(3000u128)); router - .execute_contract(owner, Addr::unchecked(cw20_addr), &transfer_msg, &[]) + .execute_contract(owner, cw20_addr, &transfer_msg, &[]) .unwrap(); // Check staking status @@ -270,23 +211,25 @@ fn test_cw20_staking_app() { #[test] fn test_cw20_staking_app_delayed() { - let owner = Addr::unchecked("owner"); - let staker_one = Addr::unchecked("staker_one"); - let staker_two = Addr::unchecked("staker_two"); - let mut router = mock_app(); + let owner = router.api().addr_make("owner"); + let staker_one = router.api().addr_make("staker_one"); + let staker_two = router.api().addr_make("staker_two"); + router + .send_tokens( + Addr::unchecked("owner"), + owner.clone(), + &[coin(1000u128, "uandr"), coin(1000u128, "uusd")], + ) + .unwrap(); + let andr = setup_andr(&mut router, &owner); let app_addr = setup_app(&andr, &mut router); // Component Addresses - let cw20_addr: String = router - .wrap() - .query_wasm_smart(app_addr.to_string(), &mock_get_address_msg("cw20")) - .unwrap(); - let cw20_staking_addr: String = router - .wrap() - .query_wasm_smart(app_addr.to_string(), &mock_get_address_msg("cw20staking")) - .unwrap(); + let cw20_addr = andr.vfs_resolve_path(&mut router, format!("/home/{app_addr}/cw20")); + let cw20_staking_addr = + andr.vfs_resolve_path(&mut router, format!("/home/{app_addr}/cw20staking")); let reward_token = AssetInfoUnchecked::native("uandr"); let add_reward_msg = mock_cw20_staking_add_reward_tokens( @@ -297,7 +240,7 @@ fn test_cw20_staking_app_delayed() { router .execute_contract( owner.clone(), - Addr::unchecked(cw20_staking_addr.clone()), + cw20_staking_addr.clone(), &add_reward_msg, &[], ) @@ -317,7 +260,7 @@ fn test_cw20_staking_app_delayed() { router .execute_contract( owner.clone(), - Addr::unchecked(cw20_staking_addr.clone()), + cw20_staking_addr.clone(), &add_reward_msg, &[], ) @@ -326,14 +269,14 @@ fn test_cw20_staking_app_delayed() { router .send_tokens( owner.clone(), - Addr::unchecked(cw20_staking_addr.clone()), + cw20_staking_addr.clone(), &[coin(60u128, "uandr")], ) .unwrap(); router .send_tokens( owner.clone(), - Addr::unchecked(cw20_staking_addr.clone()), + cw20_staking_addr.clone(), &[coin(300u128, "uusd")], ) .unwrap(); @@ -357,42 +300,27 @@ fn test_cw20_staking_app_delayed() { // Stake Tokens let staking_msg_one = mock_cw20_send( - cw20_staking_addr.clone(), + cw20_staking_addr.to_string(), Uint128::from(1000u128), to_json_binary(&mock_cw20_stake()).unwrap(), ); router - .execute_contract( - staker_one.clone(), - Addr::unchecked(cw20_addr.clone()), - &staking_msg_one, - &[], - ) + .execute_contract(staker_one.clone(), cw20_addr.clone(), &staking_msg_one, &[]) .unwrap(); let staking_msg_two = mock_cw20_send( - cw20_staking_addr.clone(), + cw20_staking_addr.to_string(), Uint128::from(2000u128), to_json_binary(&mock_cw20_stake()).unwrap(), ); router - .execute_contract( - staker_two.clone(), - Addr::unchecked(cw20_addr.clone()), - &staking_msg_two, - &[], - ) + .execute_contract(staker_two.clone(), cw20_addr.clone(), &staking_msg_two, &[]) .unwrap(); // Transfer Tokens for Reward - let transfer_msg = mock_cw20_transfer(cw20_staking_addr.clone(), Uint128::from(3000u128)); + let transfer_msg = mock_cw20_transfer(cw20_staking_addr.to_string(), Uint128::from(3000u128)); router - .execute_contract( - owner.clone(), - Addr::unchecked(cw20_addr), - &transfer_msg, - &[], - ) + .execute_contract(owner.clone(), cw20_addr, &transfer_msg, &[]) .unwrap(); // Check staking status @@ -436,7 +364,7 @@ fn test_cw20_staking_app_delayed() { router .execute_contract( owner, - Addr::unchecked(cw20_staking_addr.clone()), + cw20_staking_addr.clone(), &update_global_indexes, &[], ) diff --git a/tests-integration/tests/kernel.rs b/tests-integration/tests/kernel.rs index 6355b92ba..98d0ee7c5 100644 --- a/tests-integration/tests/kernel.rs +++ b/tests-integration/tests/kernel.rs @@ -8,51 +8,61 @@ use andromeda_std::{ amp::{messages::AMPMsg, AndrAddr, Recipient}, os::kernel::ExecuteMsg as KernelExecuteMsg, }; -use andromeda_testing::{mock::MockAndromeda, mock_contract::MockContract}; +use andromeda_testing::{ + mock::{mock_app, MockAndromeda, MockApp}, + mock_contract::MockContract, +}; use cosmwasm_std::{coin, to_json_binary, Addr, Decimal}; -use cw_multi_test::{App, Executor}; - -fn mock_app() -> App { - App::new(|router, _api, storage| { - router - .bank - .init_balance( - storage, - &Addr::unchecked("owner"), - [coin(999999, "uandr")].to_vec(), - ) - .unwrap(); - router - .bank - .init_balance( - storage, - &Addr::unchecked("buyer"), - [coin(1000, "uandr")].to_vec(), - ) - .unwrap(); - router - .bank - .init_balance( - storage, - &Addr::unchecked("user1"), - [coin(1, "uandr")].to_vec(), - ) - .unwrap(); - }) -} - -fn mock_andromeda(app: &mut App, admin_address: Addr) -> MockAndromeda { +use cw_multi_test::Executor; + +// fn mock_app() -> App { +// App::new(|router, _api, storage| { +// router +// .bank +// .init_balance( +// storage, +// &Addr::unchecked("owner"), +// [coin(999999, "uandr")].to_vec(), +// ) +// .unwrap(); +// router +// .bank +// .init_balance( +// storage, +// &Addr::unchecked("buyer"), +// [coin(1000, "uandr")].to_vec(), +// ) +// .unwrap(); +// router +// .bank +// .init_balance( +// storage, +// &Addr::unchecked("user1"), +// [coin(1, "uandr")].to_vec(), +// ) +// .unwrap(); +// }) +// } + +fn mock_andromeda(app: &mut MockApp, admin_address: Addr) -> MockAndromeda { MockAndromeda::new(app, &admin_address) } #[test] fn kernel() { - let owner = Addr::unchecked("owner"); - let user1 = "user1"; - let mut router = mock_app(); + let owner = router.api().addr_make("owner"); + let user1 = router.api().addr_make("user1"); + + router + .send_tokens( + Addr::unchecked("owner"), + owner.clone(), + &[coin(1000, "uandr")], + ) + .unwrap(); let andr = mock_andromeda(&mut router, owner.clone()); let splitter_code_id = router.store_code(mock_andromeda_splitter()); @@ -68,7 +78,7 @@ fn kernel() { let splitter_addr = router .instantiate_contract( splitter_code_id, - Addr::unchecked(user1), + user1.clone(), &splitter_msg, &[], "Splitter", @@ -116,7 +126,9 @@ fn kernel() { KernelExecuteMsg::Create { ado_type: "splitter".to_string(), msg: to_json_binary(&splitter_msg).unwrap(), - owner: Some(AndrAddr::from_string("~am".to_string())), + // owner: Some(AndrAddr::from_string("~am".to_string())), + // TODO: replace the below line with the above commented line once Register User in VFS is re-enabled. + owner: Some(AndrAddr::from_string(owner.to_string())), chain: None, }, owner.clone(), @@ -167,7 +179,7 @@ fn kernel() { .unwrap(); // user1 had one coin before the splitter execute msg which is expected to increase his balance by 100uandr - assert_eq!(user1_balance, coin(101, "uandr")); + assert_eq!(user1_balance, coin(100, "uandr")); let owner_balance = router .wrap() @@ -175,7 +187,7 @@ fn kernel() { .unwrap(); // The owner's balance should be his starting balance subtracted by the 100 he sent with the splitter execute msg - assert_eq!(owner_balance, coin(999999 - 100, "uandr")); + assert_eq!(owner_balance, coin(900, "uandr")); assert!(res.data.is_none()); diff --git a/tests-integration/tests/lockdrop.rs b/tests-integration/tests/lockdrop.rs index 69c84180c..e81ab8202 100644 --- a/tests-integration/tests/lockdrop.rs +++ b/tests-integration/tests/lockdrop.rs @@ -4,33 +4,12 @@ use andromeda_lockdrop::mock::{ mock_deposit_native, mock_enable_claims, mock_lockdrop_instantiate_msg, mock_withdraw_native, }; use andromeda_std::common::Milliseconds; -use andromeda_testing::mock::MockAndromeda; +use andromeda_testing::mock::{mock_app, MockAndromeda, MockApp}; use cosmwasm_std::{coin, to_json_binary, Addr, BlockInfo, Uint128}; use cw20::Cw20Coin; -use cw_multi_test::{App, Executor}; - -fn mock_app() -> App { - App::new(|router, _api, storage| { - router - .bank - .init_balance( - storage, - &Addr::unchecked("user1"), - [coin(500, "uusd")].to_vec(), - ) - .unwrap(); - router - .bank - .init_balance( - storage, - &Addr::unchecked("user2"), - [coin(500, "uusd")].to_vec(), - ) - .unwrap(); - }) -} +use cw_multi_test::Executor; -fn mock_andromeda(app: &mut App, admin_address: Addr) -> MockAndromeda { +fn mock_andromeda(app: &mut MockApp, admin_address: Addr) -> MockAndromeda { MockAndromeda::new(app, &admin_address) } @@ -38,9 +17,24 @@ fn mock_andromeda(app: &mut App, admin_address: Addr) -> MockAndromeda { #[test] fn test_lockdrop() { let mut app = mock_app(); - let andr = mock_andromeda(&mut app, Addr::unchecked("owner")); + let owner = app.api().addr_make("owner"); + let user1 = app.api().addr_make("user1"); + let user2 = app.api().addr_make("user2"); + let andr = mock_andromeda(&mut app, owner.clone()); let code = mock_andromeda_cw20(); let cw_20_code_id = app.store_code(code); + app.send_tokens( + Addr::unchecked("owner"), + user1.clone(), + &[coin(500u128, "uusd")], + ) + .unwrap(); + app.send_tokens( + Addr::unchecked("owner"), + user2.clone(), + &[coin(500u128, "uusd")], + ) + .unwrap(); let cw20_init_msg = mock_cw20_instantiate_msg( None, @@ -49,7 +43,7 @@ fn test_lockdrop() { 18u8, vec![Cw20Coin { amount: 100u128.into(), - address: "owner".to_string(), + address: owner.to_string(), }], None, None, @@ -59,7 +53,7 @@ fn test_lockdrop() { let cw20_incentives_address = app .instantiate_contract( cw_20_code_id, - Addr::unchecked("owner"), + owner.clone(), &cw20_init_msg, &[], "Token", @@ -85,7 +79,7 @@ fn test_lockdrop() { let lockdrop_addr = app .instantiate_contract( lockdrop_code_id, - Addr::unchecked("owner"), + owner.clone(), &init_msg, &[], "staking", @@ -100,7 +94,7 @@ fn test_lockdrop() { let msg = mock_deposit_native(); app.execute_contract( - Addr::unchecked("user1"), + user1.clone(), lockdrop_addr.clone(), &msg, &[coin(500, "uusd")], @@ -109,7 +103,7 @@ fn test_lockdrop() { let msg = mock_deposit_native(); app.execute_contract( - Addr::unchecked("user2"), + user2.clone(), lockdrop_addr.clone(), &msg, &[coin(500, "uusd")], @@ -122,7 +116,7 @@ fn test_lockdrop() { to_json_binary(&mock_cw20_hook_increase_incentives()).unwrap(), ); - app.execute_contract(Addr::unchecked("owner"), cw20_incentives_address, &msg, &[]) + app.execute_contract(owner.clone(), cw20_incentives_address, &msg, &[]) .unwrap(); app.set_block(BlockInfo { @@ -132,34 +126,34 @@ fn test_lockdrop() { //enable claims let msg = mock_enable_claims(); - app.execute_contract(Addr::unchecked("owner"), lockdrop_addr.clone(), &msg, &[]) + app.execute_contract(owner, lockdrop_addr.clone(), &msg, &[]) .unwrap(); //claim let msg = mock_claim_rewards(); - app.execute_contract(Addr::unchecked("user1"), lockdrop_addr.clone(), &msg, &[]) + app.execute_contract(user1.clone(), lockdrop_addr.clone(), &msg, &[]) .unwrap(); let msg = mock_claim_rewards(); - app.execute_contract(Addr::unchecked("user2"), lockdrop_addr.clone(), &msg, &[]) + app.execute_contract(user2, lockdrop_addr.clone(), &msg, &[]) .unwrap(); let balance = app .wrap() - .query_balance("user1", "uusd".to_string()) + .query_balance(user1.clone(), "uusd".to_string()) .unwrap(); assert_eq!(balance.amount, Uint128::zero()); let msg = mock_withdraw_native(None); - app.execute_contract(Addr::unchecked("user1"), lockdrop_addr, &msg, &[]) + app.execute_contract(user1.clone(), lockdrop_addr, &msg, &[]) .unwrap(); let balance = app .wrap() - .query_balance("user1", "uusd".to_string()) + .query_balance(user1.to_string(), "uusd".to_string()) .unwrap(); assert_eq!(balance.amount, Uint128::from(500u128)); diff --git a/tests-integration/tests/marketplace_app.rs b/tests-integration/tests/marketplace_app.rs index fd21b80fc..60996c841 100644 --- a/tests-integration/tests/marketplace_app.rs +++ b/tests-integration/tests/marketplace_app.rs @@ -5,8 +5,7 @@ use andromeda_address_list::mock::{ }; use andromeda_app::app::AppComponent; use andromeda_app_contract::mock::{ - mock_andromeda_app, mock_app_instantiate_msg, mock_claim_ownership_msg, mock_get_address_msg, - mock_get_components_msg, + mock_andromeda_app, mock_app_instantiate_msg, mock_get_address_msg, mock_get_components_msg, }; use andromeda_cw721::mock::{ mock_andromeda_cw721, mock_cw721_instantiate_msg, mock_cw721_owner_of, mock_quick_mint_msg, @@ -22,43 +21,29 @@ use andromeda_rates::mock::{mock_andromeda_rates, mock_rates_instantiate_msg}; use andromeda_std::ado_base::modules::Module; use andromeda_std::amp::messages::{AMPMsg, AMPPkt}; use andromeda_std::amp::Recipient; -use andromeda_testing::mock::MockAndromeda; -use cosmwasm_std::{coin, to_json_binary, Addr, Uint128}; +use andromeda_testing::mock::{mock_app, MockAndromeda, MockApp}; +use cosmwasm_std::{coin, to_json_binary, Addr, BlockInfo, Uint128}; use cw721::OwnerOfResponse; -use cw_multi_test::{App, Executor}; +use cw_multi_test::Executor; -fn mock_app() -> App { - App::new(|router, _api, storage| { - router - .bank - .init_balance( - storage, - &Addr::unchecked("owner"), - [coin(999999, "uandr")].to_vec(), - ) - .unwrap(); - router - .bank - .init_balance( - storage, - &Addr::unchecked("buyer"), - [coin(200, "uandr")].to_vec(), - ) - .unwrap(); - }) -} - -fn mock_andromeda(app: &mut App, admin_address: Addr) -> MockAndromeda { +fn mock_andromeda(app: &mut MockApp, admin_address: Addr) -> MockAndromeda { MockAndromeda::new(app, &admin_address) } #[test] fn test_marketplace_app() { - let owner = Addr::unchecked("owner"); - let buyer = Addr::unchecked("buyer"); - let rates_receiver = Addr::unchecked("receiver"); - let mut router = mock_app(); + let owner = router.api().addr_make("owner"); + let buyer = router.api().addr_make("buyer"); + let rates_receiver = router.api().addr_make("receiver"); + router + .send_tokens( + Addr::unchecked("owner"), + buyer.clone(), + &[coin(200, "uandr")], + ) + .unwrap(); + let andr = mock_andromeda(&mut router, owner.clone()); // Store contract codes @@ -155,16 +140,6 @@ fn test_marketplace_app() { assert_eq!(components, app_components); - // Claim Ownership - router - .execute_contract( - owner.clone(), - app_addr.clone(), - &mock_claim_ownership_msg(None), - &[], - ) - .unwrap(); - let cw721_addr: String = router .wrap() .query_wasm_smart( @@ -197,7 +172,6 @@ fn test_marketplace_app() { let token_id = "0"; - andr.accept_ownership(&mut router, address_list_addr.clone(), owner.clone()); // Whitelist router .execute_contract( @@ -245,6 +219,14 @@ fn test_marketplace_app() { vec![amp_msg], ); let receive_packet_msg = mock_receive_packet(packet); + + let block_info = router.block_info(); + router.set_block(BlockInfo { + height: block_info.height, + time: block_info.time.plus_minutes(1), + chain_id: block_info.chain_id, + }); + router .execute_contract( buyer.clone(), diff --git a/tests-integration/tests/primtive.rs b/tests-integration/tests/primtive.rs index d37e19cc6..71697db9e 100644 --- a/tests-integration/tests/primtive.rs +++ b/tests-integration/tests/primtive.rs @@ -6,41 +6,20 @@ use andromeda_primitive::mock::{ mock_andromeda_primitive, mock_primitive_get_value, mock_primitive_instantiate_msg, mock_store_value_msg, }; -use andromeda_testing::mock::MockAndromeda; +use andromeda_testing::mock::{mock_app, MockAndromeda, MockApp}; use cosmwasm_schema::schemars::Map; -use cosmwasm_std::{coin, Addr}; -use cw_multi_test::{App, Executor}; +use cosmwasm_std::Addr; +use cw_multi_test::Executor; -fn mock_app() -> App { - App::new(|router, _api, storage| { - router - .bank - .init_balance( - storage, - &Addr::unchecked("owner"), - [coin(999999, "uandr")].to_vec(), - ) - .unwrap(); - router - .bank - .init_balance( - storage, - &Addr::unchecked("buyer"), - [coin(200, "uandr")].to_vec(), - ) - .unwrap(); - }) -} - -fn mock_andromeda(app: &mut App, admin_address: Addr) -> MockAndromeda { +fn mock_andromeda(app: &mut MockApp, admin_address: Addr) -> MockAndromeda { MockAndromeda::new(app, &admin_address) } #[test] fn test_primtive() { - let sender = Addr::unchecked("owner"); - let mut router = mock_app(); + let sender = router.api().addr_make("owner"); + let andr = mock_andromeda(&mut router, sender.clone()); // Store contract codes From b602d476c9ed6493d30a3900ea4eb30d6b29a07d Mon Sep 17 00:00:00 2001 From: cowboy0015 Date: Mon, 1 Apr 2024 12:27:36 -0400 Subject: [PATCH 7/9] updated permission system pagination --- .../std/src/ado_contract/permissioning.rs | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/packages/std/src/ado_contract/permissioning.rs b/packages/std/src/ado_contract/permissioning.rs index 539eeb366..33f5a50a9 100644 --- a/packages/std/src/ado_contract/permissioning.rs +++ b/packages/std/src/ado_contract/permissioning.rs @@ -357,9 +357,13 @@ impl<'a> ADOContract<'a> { order_by: Option, ) -> Result, ContractError> { let action_string: String = action.into(); + let order_by = match order_by { + Some(OrderBy::Desc) => Order::Descending, + _ => Order::Ascending, + }; let mut actors = permissions() - .keys(deps.storage, None, None, Order::Ascending) + .keys(deps.storage, None, None, order_by) .filter(|item| item.as_ref().unwrap().starts_with(&action_string)) .map(|item| { let actor: String = item.unwrap_or_default()[action_string.len()..].to_string(); @@ -370,23 +374,11 @@ impl<'a> ADOContract<'a> { let start = start_after.unwrap_or(0) as usize; let limit = limit.unwrap_or(DEFAULT_QUERY_LIMIT).min(MAX_QUERY_LIMIT) as usize; - let (start, end) = match order_by { - Some(OrderBy::Desc) => ( - actors - .len() - .saturating_sub(cmp::min(actors.len(), start + limit)), - actors.len().saturating_sub(cmp::min(start, actors.len())), - ), - // Default ordering is Ascending. - _ => ( - cmp::min(actors.len(), start), - cmp::min(start + limit, actors.len()), - ), - }; + let (start, end) = ( + cmp::min(start, actors.len()), + cmp::min(start + limit, actors.len()), + ); let slice = &mut actors[start..end]; - if order_by == Some(OrderBy::Desc) { - slice.reverse(); - } Ok(slice.to_vec()) } } From c7fd085e88d60ce44f058a6bd1fa6b16b6076585 Mon Sep 17 00:00:00 2001 From: Connor Barr Date: Tue, 2 Apr 2024 11:40:14 +0100 Subject: [PATCH 8/9] Fixed query permissioned actors --- .../std/src/ado_contract/permissioning.rs | 50 +++++++++++-------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/packages/std/src/ado_contract/permissioning.rs b/packages/std/src/ado_contract/permissioning.rs index 33f5a50a9..c4d3247be 100644 --- a/packages/std/src/ado_contract/permissioning.rs +++ b/packages/std/src/ado_contract/permissioning.rs @@ -1,5 +1,3 @@ -use std::cmp; - use crate::{ ado_base::permissioning::{Permission, PermissionInfo, PermissioningMessage}, amp::{messages::AMPPkt, AndrAddr}, @@ -18,12 +16,13 @@ pub struct PermissionsIndices<'a> { /// PK: action + actor /// /// Secondary key: actor - pub permissions: MultiIndex<'a, String, PermissionInfo, String>, + pub actor: MultiIndex<'a, String, PermissionInfo, String>, + pub action: MultiIndex<'a, String, PermissionInfo, String>, } impl<'a> IndexList for PermissionsIndices<'a> { fn get_indexes(&'_ self) -> Box> + '_> { - let v: Vec<&dyn Index> = vec![&self.permissions]; + let v: Vec<&dyn Index> = vec![&self.action, &self.actor]; Box::new(v.into_iter()) } } @@ -33,7 +32,12 @@ impl<'a> IndexList for PermissionsIndices<'a> { /// Permissions are stored in a multi-indexed map with the primary key being the action and actor pub fn permissions<'a>() -> IndexedMap<'a, &'a str, PermissionInfo, PermissionsIndices<'a>> { let indexes = PermissionsIndices { - permissions: MultiIndex::new(|_pk: &[u8], r| r.actor.clone(), "andr_permissions", "actor"), + actor: MultiIndex::new(|_pk: &[u8], r| r.actor.clone(), "andr_permissions", "actor"), + action: MultiIndex::new( + |_pk: &[u8], r| r.action.clone(), + "andr_permissions", + "action", + ), }; IndexedMap::new("andr_permissions", indexes) } @@ -330,7 +334,7 @@ impl<'a> ADOContract<'a> { let limit = limit.unwrap_or(DEFAULT_QUERY_LIMIT).min(MAX_QUERY_LIMIT) as usize; let permissions = permissions() .idx - .permissions + .actor .prefix(actor) .range(deps.storage, min, None, Order::Ascending) .take(limit) @@ -352,7 +356,7 @@ impl<'a> ADOContract<'a> { &self, deps: Deps, action: impl Into, - start_after: Option, + start_after: Option, limit: Option, order_by: Option, ) -> Result, ContractError> { @@ -362,24 +366,26 @@ impl<'a> ADOContract<'a> { _ => Order::Ascending, }; - let mut actors = permissions() - .keys(deps.storage, None, None, order_by) - .filter(|item| item.as_ref().unwrap().starts_with(&action_string)) - .map(|item| { - let actor: String = item.unwrap_or_default()[action_string.len()..].to_string(); - actor + let actors = permissions() + .idx + .action + .prefix(action_string.clone()) + .keys( + deps.storage, + start_after.map(Bound::inclusive), + None, + order_by, + ) + .take((limit).unwrap_or(DEFAULT_QUERY_LIMIT).min(MAX_QUERY_LIMIT) as usize) + .map(|p| { + p.unwrap() + .strip_prefix(action_string.as_str()) + .unwrap() + .to_string() }) .collect::>(); - let start = start_after.unwrap_or(0) as usize; - let limit = limit.unwrap_or(DEFAULT_QUERY_LIMIT).min(MAX_QUERY_LIMIT) as usize; - - let (start, end) = ( - cmp::min(start, actors.len()), - cmp::min(start + limit, actors.len()), - ); - let slice = &mut actors[start..end]; - Ok(slice.to_vec()) + Ok(actors) } } From def71780830ceba7f282903e576808491e235dd7 Mon Sep 17 00:00:00 2001 From: Connor Barr Date: Tue, 2 Apr 2024 12:42:33 +0100 Subject: [PATCH 9/9] Linting --- contracts/non-fungible-tokens/andromeda-auction/src/contract.rs | 2 +- packages/andromeda-non-fungible-tokens/src/auction.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/non-fungible-tokens/andromeda-auction/src/contract.rs b/contracts/non-fungible-tokens/andromeda-auction/src/contract.rs index 7bcbcc453..827bf1aac 100644 --- a/contracts/non-fungible-tokens/andromeda-auction/src/contract.rs +++ b/contracts/non-fungible-tokens/andromeda-auction/src/contract.rs @@ -869,7 +869,7 @@ fn query_owner_of( fn query_authorized_addresses( deps: Deps, - start_after: Option, + start_after: Option, limit: Option, order_by: Option, ) -> Result { diff --git a/packages/andromeda-non-fungible-tokens/src/auction.rs b/packages/andromeda-non-fungible-tokens/src/auction.rs index 3bc8ea1aa..edc10f61c 100644 --- a/packages/andromeda-non-fungible-tokens/src/auction.rs +++ b/packages/andromeda-non-fungible-tokens/src/auction.rs @@ -96,7 +96,7 @@ pub enum QueryMsg { /// Gets all of the authorized addresses for the auction #[returns(AuthorizedAddressesResponse)] AuthorizedAddresses { - start_after: Option, + start_after: Option, limit: Option, order_by: Option, },