Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberHoward committed May 28, 2024
1 parent cb8df96 commit ee5dc2f
Show file tree
Hide file tree
Showing 25 changed files with 200 additions and 150 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ lazy_static = "1.4.0"
cw-orch = { version = "0.22.2" }
const_format = "0.2.32"

my-app = { path = "contracts/my-app" }
intersync = { path = "contracts/intersync" }
my-adapter = { path = "contracts/my-adapter" }
speculoos = "0.11.0"
semver = "1.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "my-app"
name = "intersync"
version = "0.0.1"
authors = [
"CyberHoward <cyberhoward@protonmail.com>",
Expand Down Expand Up @@ -54,6 +54,9 @@ cw-asset = { workspace = true }
abstract-app = { workspace = true }
const_format = { workspace = true }
serde = "1"
cw-utils = "1.0.3"
dao-voting = "2.3.0"


# Dependencies for interface
cw-orch = { workspace = true }
Expand All @@ -66,6 +69,6 @@ dotenv = { workspace = true, optional = true }
env_logger = { workspace = true, optional = true }

[dev-dependencies]
my-app = { workspace = true }
intersync = { workspace = true }
abstract-client = { workspace = true }
abstract-app = { workspace = true, features = ["test-utils"] }
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
//!
//! # Run
//!
//! `RUST_LOG=info cargo run --bin --features="daemon-bin" local_daemon --package my-app`
use my_app::MY_APP_ID;
//! `RUST_LOG=info cargo run --bin --features="daemon-bin" local_daemon --package intersync`
use intersync::MY_APP_ID;

use abstract_app::objects::namespace::Namespace;
use abstract_client::{AbstractClient, Publisher};
use cw_orch::{anyhow, prelude::*, tokio::runtime::Runtime};
use my_app::{msg::MyAppInstantiateMsg, MyAppInterface};
use intersync::{msg::IntersyncInstantiateMsg, IntersyncInterface};

const LOCAL_MNEMONIC: &str = "clip hire initial neck maid actor venue client foam budget lock catalog sweet steak waste crater broccoli pipe steak sister coyote moment obvious choose";

Expand Down Expand Up @@ -46,16 +46,16 @@ fn main() -> anyhow::Result<()> {
}

// Publish the App to the Abstract Platform
publisher.publish_app::<MyAppInterface<Daemon>>()?;
publisher.publish_app::<IntersyncInterface<Daemon>>()?;

// Install the App on a new account

let account = abstract_client.account_builder().build()?;
// Installs the app on the Account
let app = account.install_app::<MyAppInterface<_>>(&MyAppInstantiateMsg { count: 0 }, &[])?;
let app = account.install_app::<IntersyncInterface<_>>(&IntersyncInstantiateMsg { count: 0 }, &[])?;

// Import app's endpoint function traits for easy interactions.
use my_app::msg::{MyAppExecuteMsgFns, MyAppQueryMsgFns};
use intersync::msg::{IntersyncExecuteMsgFns, IntersyncQueryMsgFns};
assert_eq!(app.count()?.count, 0);
// Execute the App
app.increment()?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
//! ```bash
//! $ just publish uni-6 osmo-test-5
//! ```
use my_app::MY_APP_ID;
use intersync::MY_APP_ID;

use abstract_app::objects::namespace::Namespace;
use abstract_client::{AbstractClient, Publisher};
use clap::Parser;
use cw_orch::{anyhow, daemon::networks::parse_network, prelude::*, tokio::runtime::Runtime};
use my_app::MyAppInterface;
use intersync::IntersyncInterface;

fn publish(networks: Vec<ChainInfo>) -> anyhow::Result<()> {
// run for each requested network
Expand All @@ -38,7 +38,7 @@ fn publish(networks: Vec<ChainInfo>) -> anyhow::Result<()> {
}

// Publish the App to the Abstract Platform
publisher.publish_app::<MyAppInterface<Daemon>>()?;
publisher.publish_app::<IntersyncInterface<Daemon>>()?;
}
Ok(())
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cosmwasm_schema::remove_schemas;
use my_app::contract::MyApp;
use intersync::contract::Intersync;
use std::env::current_dir;
use std::fs::create_dir_all;

Expand All @@ -10,5 +10,5 @@ fn main() {
remove_schemas(&out_dir).unwrap();

#[cfg(feature = "schema")]
MyApp::export_schema(&out_dir);
Intersync::export_schema(&out_dir);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
error::MyAppError,
error::IntersyncError,
handlers,
msg::{MyAppExecuteMsg, MyAppInstantiateMsg, MyAppMigrateMsg, MyAppQueryMsg},
msg::{IntersyncExecuteMsg, IntersyncInstantiateMsg, IntersyncMigrateMsg, IntersyncQueryMsg},
replies::{self, INSTANTIATE_REPLY_ID},
APP_VERSION, MY_APP_ID,
};
Expand All @@ -10,13 +10,13 @@ use abstract_app::AppContract;
use cosmwasm_std::Response;

/// The type of the result returned by your app's entry points.
pub type MyAppResult<T = Response> = Result<T, MyAppError>;
pub type IntersyncResult<T = Response> = Result<T, IntersyncError>;

/// The type of the app that is used to build your app and access the Abstract SDK features.
pub type MyApp =
AppContract<MyAppError, MyAppInstantiateMsg, MyAppExecuteMsg, MyAppQueryMsg, MyAppMigrateMsg>;
pub type Intersync =
AppContract<IntersyncError, IntersyncInstantiateMsg, IntersyncExecuteMsg, IntersyncQueryMsg, IntersyncMigrateMsg>;

const APP: MyApp = MyApp::new(MY_APP_ID, APP_VERSION, None)
const APP: Intersync = Intersync::new(MY_APP_ID, APP_VERSION, None)
.with_instantiate(handlers::instantiate_handler)
.with_execute(handlers::execute_handler)
.with_query(handlers::query_handler)
Expand All @@ -26,15 +26,15 @@ const APP: MyApp = MyApp::new(MY_APP_ID, APP_VERSION, None)

// Export handlers
#[cfg(feature = "export")]
abstract_app::export_endpoints!(APP, MyApp);
abstract_app::export_endpoints!(APP, Intersync);

abstract_app::cw_orch_interface!(APP, MyApp, MyAppInterface);
abstract_app::cw_orch_interface!(APP, Intersync, IntersyncInterface);

// TODO: add to docmuentation
// https://linear.app/abstract-sdk/issue/ABS-414/add-documentation-on-dependencycreation-trait
#[cfg(not(target_arch = "wasm32"))]
impl<Chain: cw_orch::environment::CwEnv> abstract_interface::DependencyCreation
for crate::MyAppInterface<Chain>
for crate::IntersyncInterface<Chain>
{
type DependenciesConfig = cosmwasm_std::Empty;
}
10 changes: 10 additions & 0 deletions contracts/intersync/src/data.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize)]
pub struct Data {
name: String,

age: i64,

sex: String,
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use cw_controllers::AdminError;
use thiserror::Error;

#[derive(Error, Debug, PartialEq)]
pub enum MyAppError {
pub enum IntersyncError {
#[error("{0}")]
Std(#[from] StdError),

Expand Down
44 changes: 44 additions & 0 deletions contracts/intersync/src/handlers/execute.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
use crate::{
contract::{Intersync, IntersyncResult},
msg::IntersyncExecuteMsg,
state::{CONFIG, COUNT},
};

use abstract_app::traits::AbstractResponse;
use cosmwasm_std::{DepsMut, Env, MessageInfo};

pub fn execute_handler(
deps: DepsMut,
_env: Env,
info: MessageInfo,
app: Intersync,
msg: IntersyncExecuteMsg,
) -> IntersyncResult {
match msg {
IntersyncExecuteMsg::UpdateConfig {} => update_config(deps, info, app),

Check failure on line 18 in contracts/intersync/src/handlers/execute.rs

View workflow job for this annotation

GitHub Actions / clippy

no variant named `UpdateConfig` found for enum `msg::IntersyncExecuteMsg`

error[E0599]: no variant named `UpdateConfig` found for enum `msg::IntersyncExecuteMsg` --> contracts/intersync/src/handlers/execute.rs:18:30 | 18 | IntersyncExecuteMsg::UpdateConfig {} => update_config(deps, info, app), | ^^^^^^^^^^^^ variant not found in `msg::IntersyncExecuteMsg` | ::: contracts/intersync/src/msg.rs:18:1 | 18 | pub enum IntersyncExecuteMsg { | ---------------------------- variant `UpdateConfig` not found here
IntersyncExecuteMsg::Increment {} => increment(deps, app),

Check failure on line 19 in contracts/intersync/src/handlers/execute.rs

View workflow job for this annotation

GitHub Actions / clippy

no variant named `Increment` found for enum `msg::IntersyncExecuteMsg`

error[E0599]: no variant named `Increment` found for enum `msg::IntersyncExecuteMsg` --> contracts/intersync/src/handlers/execute.rs:19:30 | 19 | IntersyncExecuteMsg::Increment {} => increment(deps, app), | ^^^^^^^^^ variant not found in `msg::IntersyncExecuteMsg` | ::: contracts/intersync/src/msg.rs:18:1 | 18 | pub enum IntersyncExecuteMsg { | ---------------------------- variant `Increment` not found here
IntersyncExecuteMsg::Reset { count } => reset(deps, info, count, app),

Check failure on line 20 in contracts/intersync/src/handlers/execute.rs

View workflow job for this annotation

GitHub Actions / clippy

no variant named `Reset` found for enum `msg::IntersyncExecuteMsg`

error[E0599]: no variant named `Reset` found for enum `msg::IntersyncExecuteMsg` --> contracts/intersync/src/handlers/execute.rs:20:30 | 20 | IntersyncExecuteMsg::Reset { count } => reset(deps, info, count, app), | ^^^^^ variant not found in `msg::IntersyncExecuteMsg` | ::: contracts/intersync/src/msg.rs:18:1 | 18 | pub enum IntersyncExecuteMsg { | ---------------------------- variant `Reset` not found here
}
}

/// Update the configuration of the app
fn update_config(deps: DepsMut, msg_info: MessageInfo, app: Intersync) -> IntersyncResult {
// Only the admin should be able to call this
app.admin.assert_admin(deps.as_ref(), &msg_info.sender)?;
let mut _config = CONFIG.load(deps.storage)?;

Ok(app.response("update_config"))
}

fn increment(deps: DepsMut, app: Intersync) -> IntersyncResult {
COUNT.update(deps.storage, |count| IntersyncResult::Ok(count + 1))?;

Ok(app.response("increment"))
}

fn reset(deps: DepsMut, info: MessageInfo, count: i32, app: Intersync) -> IntersyncResult {
app.admin.assert_admin(deps.as_ref(), &info.sender)?;
COUNT.save(deps.storage, &count)?;

Ok(app.response("reset"))
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
contract::{MyApp, MyAppResult},
msg::MyAppInstantiateMsg,
contract::{Intersync, IntersyncResult},
msg::IntersyncInstantiateMsg,
state::{Config, CONFIG, COUNT},
};

Expand All @@ -10,9 +10,9 @@ pub fn instantiate_handler(
deps: DepsMut,
_env: Env,
_info: MessageInfo,
_app: MyApp,
msg: MyAppInstantiateMsg,
) -> MyAppResult {
_app: Intersync,
msg: IntersyncInstantiateMsg,
) -> IntersyncResult {
let config: Config = Config {};

CONFIG.save(deps.storage, &config)?;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
contract::{MyApp, MyAppResult},
msg::MyAppMigrateMsg,
contract::{Intersync, IntersyncResult},
msg::IntersyncMigrateMsg,
};

use abstract_app::traits::AbstractResponse;
Expand All @@ -11,8 +11,8 @@ use cosmwasm_std::{DepsMut, Env};
pub fn migrate_handler(
_deps: DepsMut,
_env: Env,
app: MyApp,
_msg: MyAppMigrateMsg,
) -> MyAppResult {
app: Intersync,
_msg: IntersyncMigrateMsg,
) -> IntersyncResult {
Ok(app.response("migrate"))
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
contract::{MyApp, MyAppResult},
msg::{ConfigResponse, CountResponse, MyAppQueryMsg},
contract::{Intersync, IntersyncResult},
msg::{ConfigResponse, CountResponse, IntersyncQueryMsg},
state::{CONFIG, COUNT},
};

Expand All @@ -9,12 +9,12 @@ use cosmwasm_std::{to_json_binary, Binary, Deps, Env, StdResult};
pub fn query_handler(
deps: Deps,
_env: Env,
_app: &MyApp,
msg: MyAppQueryMsg,
) -> MyAppResult<Binary> {
_app: &Intersync,
msg: IntersyncQueryMsg,
) -> IntersyncResult<Binary> {
match msg {
MyAppQueryMsg::Config {} => to_json_binary(&query_config(deps)?),
MyAppQueryMsg::Count {} => to_json_binary(&query_count(deps)?),
IntersyncQueryMsg::Config {} => to_json_binary(&query_config(deps)?),
IntersyncQueryMsg::Count {} => to_json_binary(&query_count(deps)?),
}
.map_err(Into::into)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ mod replies;
pub mod state;
mod data;

pub use error::MyAppError;
pub use error::IntersyncError;

/// The version of your app
pub const APP_VERSION: &str = env!("CARGO_PKG_VERSION");

pub use contract::interface::MyAppInterface;
pub use contract::interface::IntersyncInterface;

pub const MY_NAMESPACE: &str = "yournamespace";
pub const MY_APP_NAME: &str = "my-app";
pub const MY_APP_NAME: &str = "intersync";
pub const MY_APP_ID: &str = const_format::formatcp!("{MY_NAMESPACE}:{MY_APP_NAME}");
30 changes: 17 additions & 13 deletions contracts/my-app/src/msg.rs → contracts/intersync/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,39 +1,43 @@
use crate::contract::MyApp;
use crate::contract::Intersync;

use cosmwasm_schema::QueryResponses;

// This is used for type safety and re-exporting the contract endpoint structs.
abstract_app::app_msg_types!(MyApp, MyAppExecuteMsg, MyAppQueryMsg);
abstract_app::app_msg_types!(Intersync, IntersyncExecuteMsg, IntersyncQueryMsg);

/// App instantiate message
#[cosmwasm_schema::cw_serde]
pub struct MyAppInstantiateMsg {
pub struct IntersyncInstantiateMsg {
pub count: i32,
}

/// App execute messages
#[cosmwasm_schema::cw_serde]
#[derive(cw_orch::ExecuteFns)]
#[impl_into(ExecuteMsg)]
pub enum MyAppExecuteMsg {
UpdateConfig {},
/// Increment count by 1
Increment {},
/// Admin method - reset count
Reset {
/// Count value after reset
count: i32,
pub enum IntersyncExecuteMsg {
/// Called by gov when a chain wants to create a proposal
CreateProposal {

},
/// Can be called by any chain to trigger tallying
TallyProposal {

},
///Called by gov to vote on a proposal
VoteProposal {

}
}

#[cosmwasm_schema::cw_serde]
pub struct MyAppMigrateMsg {}
pub struct IntersyncMigrateMsg {}

/// App query messages
#[cosmwasm_schema::cw_serde]
#[derive(QueryResponses, cw_orch::QueryFns)]
#[impl_into(QueryMsg)]
pub enum MyAppQueryMsg {
pub enum IntersyncQueryMsg {
#[returns(ConfigResponse)]
Config {},
#[returns(CountResponse)]
Expand Down
8 changes: 8 additions & 0 deletions contracts/intersync/src/replies/instantiate.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use crate::contract::{Intersync, IntersyncResult};

use abstract_app::traits::AbstractResponse;
use cosmwasm_std::{DepsMut, Env, Reply};

pub fn instantiate_reply(_deps: DepsMut, _env: Env, app: Intersync, _reply: Reply) -> IntersyncResult {
Ok(app.response("instantiate_reply"))
}
File renamed without changes.
Loading

0 comments on commit ee5dc2f

Please sign in to comment.