Skip to content

Commit

Permalink
update and un-ibc app template
Browse files Browse the repository at this point in the history
  • Loading branch information
Buckram123 committed Oct 30, 2024
1 parent e2051c7 commit 601c538
Show file tree
Hide file tree
Showing 16 changed files with 45 additions and 207 deletions.
7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ abstract-standalone = { version = "0.24.1" }
abstract-interface = { version = "0.24.1" }
abstract-client = { version = "0.24.1" }
cw-orch = { version = "0.27.0" }
{% if with_ibc %}
{% if include_ibc_app %}
cw-orch-interchain = { version = "0.8.0" }
{% endif %}

Expand All @@ -48,3 +48,8 @@ clap = { version = "4.5.19" }
{% if include_standalone %}
{{standalone_name | kebab_case}} = { path = "contracts/{{standalone_name}}" }
{% endif %}

[patch.crates-io]
abstract-client = { git = "https://github.com/AbstractSDK/abstract.git", branch = "buckram/fix-abstract-client-fetch_or_build_account" }
abstract-std = { git = "https://github.com/AbstractSDK/abstract.git", branch = "buckram/fix-abstract-client-fetch_or_build_account" }
abstract-interface = { git = "https://github.com/AbstractSDK/abstract.git", branch = "buckram/fix-abstract-client-fetch_or_build_account" }
14 changes: 6 additions & 8 deletions cargo-generate.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ post = ["post-script.rhai"]
include_app = { prompt = "Include App Module", default = true, type = "bool" }
include_adapter = { prompt = "Include Adapter Module", default = true, type = "bool" }
include_standalone = { prompt = "Include Standalone Module", default = true, type = "bool" }
include_ibc_app = { prompt = "Include IBC App Module", default = true, type = "bool" }

[conditional.'include_app'.placeholders]
# App can have IBC
with_ibc = { prompt = "Would you like to include IBC template in the app?", default = false, type = "bool" }
app_name = { prompt = "Enter App Name", default = "my_app", type = "string" }

[conditional.'include_adapter'.placeholders]
Expand All @@ -21,16 +20,15 @@ adapter_name = { prompt = "Enter Adapter Name", default = "my_adapter", type = "
[conditional.'include_standalone'.placeholders]
standalone_name = { prompt = "Enter Standalone Name", default = "my_standalone", type = "string" }

[conditional.'include_ibc_app'.placeholders]
ibc_app_name = { prompt = "Enter IBC App Name", default = "my_ibc_app", type = "string" }

# Ignore files if not included
[conditional.'!include_app']
ignore = ["contracts/{{app_name}}"]
[conditional.'!include_adapter']
ignore = ["contracts/{{adapter_name}}"]
[conditional.'!include_standalone']
ignore = ["contracts/{{standalone_name}}"]

[conditional.'!with_ibc']
ignore = [
"contracts/{{app_name}}/src/ibc",
"contracts/{{app_name}}/tests/interchain_integration.rs",
]
[conditional.'!include_ibc_app']
ignore = ["contracts/{{ibc_app_name}}"]
6 changes: 4 additions & 2 deletions contracts/{{adapter_name}}/src/bin/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ fn publish(networks: Vec<ChainInfo>) -> anyhow::Result<()> {

// Get the [`Publisher`] that owns the namespace, otherwise create a new one and claim the namespace
let publisher: Publisher<_> = abstract_client
.publisher_builder(adapter_namespace)
.build()?;
.account_builder()
.namespace(adapter_namespace)
.build()?
.publisher()?;

if publisher.account().owner()? != chain.sender_addr() {
panic!("The current sender can not publish to this namespace. Please use the wallet that owns the Account that owns the Namespace.")
Expand Down
12 changes: 8 additions & 4 deletions contracts/{{adapter_name}}/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ impl TestEnv<MockBech32> {
abs_client.set_balance(&sender, &coins(123, "ucosm"))?;

// Publish the adapter
let publisher = abs_client.publisher_builder(namespace).build()?;
let publisher = abs_client
.account_builder()
.namespace(namespace)
.build()?
.publisher()?;
publisher.publish_adapter::<{{adapter_name | upper_camel_case}}InstantiateMsg, {{adapter_name | upper_camel_case}}Interface<_>>(
{{adapter_name | upper_camel_case}}InstantiateMsg {},
)?;
Expand Down Expand Up @@ -67,8 +71,8 @@ fn update_config() -> anyhow::Result<()> {
// Note that it's not a requirement to have it installed in this case
let publisher_account = env
.abs
.publisher_builder(Namespace::new({{project-name | shouty_snake_case}}_NAMESPACE).unwrap())
.build()?;
.fetch_account(Namespace::new({{project-name | shouty_snake_case}}_NAMESPACE).unwrap())?
.publisher()?;

adapter.execute(
&AdapterRequestMsg {
Expand Down Expand Up @@ -109,7 +113,7 @@ fn set_status() -> anyhow::Result<()> {
let new_account = env
.abs
.account_builder()
.install_adapter::<{{adapter_name | upper_camel_case}}Interface<MockBech32>>()?
.install_adapter::<{{adapter_name | upper_camel_case}}Interface<MockBech32>>()
.build()?;

new_account.as_ref().execute_on_module(
Expand Down
5 changes: 1 addition & 4 deletions contracts/{{app_name}}/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ const_format = { workspace = true }
# Dependencies for interface
cw-orch = { workspace = true }
abstract-interface = { workspace = true }
{% if with_ibc %}
cw-orch-interchain = { workspace = true }
{% endif %}

# Dependencies for bins
clap = { workspace = true, optional = true, features = ["derive"] }
Expand All @@ -61,5 +58,5 @@ env_logger = { workspace = true, optional = true }

[dev-dependencies]
{{app_name | kebab_case}} = { workspace = true }
abstract-client = { workspace = true{%if with_ibc %}, features = ["interchain"]{% endif %} }
abstract-client = { workspace = true }
abstract-app = { workspace = true, features = ["test-utils"] }
6 changes: 5 additions & 1 deletion contracts/{{app_name}}/src/bin/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ fn publish(networks: Vec<ChainInfo>) -> anyhow::Result<()> {
let abstract_client: AbstractClient<Daemon> = AbstractClient::new(chain.clone())?;

// Get the [`Publisher`] that owns the namespace, otherwise create a new one and claim the namespace
let publisher: Publisher<_> = abstract_client.publisher_builder(app_namespace).build()?;
let publisher: Publisher<_> = abstract_client
.account_builder()
.namespace(app_namespace)
.build()?
.publisher()?;

if publisher.account().owner()? != chain.sender_addr() {
panic!("The current sender can not publish to this namespace. Please use the wallet that owns the Account that owns the Namespace.")
Expand Down
4 changes: 1 addition & 3 deletions contracts/{{app_name}}/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ const APP: {{app_name | upper_camel_case}} = {{app_name | upper_camel_case}}::ne
.with_execute(handlers::execute_handler)
.with_query(handlers::query_handler)
.with_migrate(handlers::migrate_handler)
.with_replies(&[(INSTANTIATE_REPLY_ID, replies::instantiate_reply)]){% if with_ibc %}
.with_ibc_callback(crate::ibc::ibc_callback)
.with_module_ibc(crate::ibc::receive_module_ibc){% endif %}
.with_replies(&[(INSTANTIATE_REPLY_ID, replies::instantiate_reply)])
.with_dependencies(&[]);

// Export handlers
Expand Down
19 changes: 0 additions & 19 deletions contracts/{{app_name}}/src/ibc/callback.rs

This file was deleted.

5 changes: 0 additions & 5 deletions contracts/{{app_name}}/src/ibc/mod.rs

This file was deleted.

21 changes: 0 additions & 21 deletions contracts/{{app_name}}/src/ibc/module.rs

This file was deleted.

2 changes: 0 additions & 2 deletions contracts/{{app_name}}/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ pub mod msg;
mod replies;
pub mod state;

{% if with_ibc %}pub mod ibc;{% endif %}

pub use error::{{app_name | upper_camel_case}}Error;

/// The version of your app
Expand Down
11 changes: 0 additions & 11 deletions contracts/{{app_name}}/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,3 @@ pub struct ConfigResponse {}
pub struct CountResponse {
pub count: i32,
}

{% if with_ibc %}
#[cosmwasm_schema::cw_serde]
pub enum IbcCallbackMsg {
Empty {},
}

#[cosmwasm_schema::cw_serde]
pub struct IbcMsg {
}
{% endif %}
6 changes: 5 additions & 1 deletion contracts/{{app_name}}/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ impl TestEnv<MockBech32> {
abs_client.set_balance(&sender, &coins(123, "ucosm"))?;

// Publish the app
let publisher = abs_client.publisher_builder(namespace).build()?;
let publisher = abs_client
.account_builder()
.namespace(namespace)
.build()?
.publisher()?;
publisher.publish_app::<{{app_name | upper_camel_case}}Interface<_>>()?;

let app = publisher
Expand Down
122 changes: 0 additions & 122 deletions contracts/{{app_name}}/tests/interchain_integration.rs

This file was deleted.

6 changes: 4 additions & 2 deletions contracts/{{standalone_name}}/src/bin/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ fn publish(networks: Vec<ChainInfo>) -> anyhow::Result<()> {

// Get the [`Publisher`] that owns the namespace, otherwise create a new one and claim the namespace
let publisher: Publisher<_> = abstract_client
.publisher_builder(standalone_namespace)
.build()?;
.account_builder()
.namespace(standalone_namespace)
.build()?
.publisher()?;

if publisher.account().owner()? != chain.sender_addr() {
panic!("The current sender can not publish to this namespace. Please use the wallet that owns the Account that owns the Namespace.")
Expand Down
6 changes: 5 additions & 1 deletion contracts/{{standalone_name}}/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ impl TestEnv<MockBech32> {
abs_client.set_balance(&sender, &coins(123, "ucosm"))?;

// Publish the standalone
let publisher = abs_client.publisher_builder(namespace).build()?;
let publisher = abs_client
.account_builder()
.namespace(namespace)
.build()?
.publisher()?;
publisher.publish_standalone::<{{standalone_name | upper_camel_case}}Interface<_>>()?;

let standalone = publisher
Expand Down

0 comments on commit 601c538

Please sign in to comment.