Skip to content

Commit

Permalink
update publisher fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
Buckram123 committed Nov 1, 2024
1 parent e221e39 commit 4a79e91
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 18 deletions.
8 changes: 4 additions & 4 deletions contracts/{{adapter_name}}/src/bin/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ fn publish(networks: Vec<ChainInfo>) -> anyhow::Result<()> {
// Create an [`AbstractClient`]
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_acc = abstract_client.fetch_account(adapter_namespace)?;
// Get the [`Account`] that owns the namespace, otherwise create a new one and claim the namespace
let publisher_acc = abstract_client.fetch_or_build_account(adapter_namespace, |builder| builder.namespace(Namespace::from_id({{adapter_name | shouty_snake_case}}_ID).unwrap()))?;

// Get the [`Publisher`] that owns the namespace, otherwise create a new one and claim the namespace
let publisher: Publisher<_> = Publisher::new(&publisher_acc)?;
// Get the [`Publisher`]
let publisher: Publisher<_> = publisher_acc.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
8 changes: 4 additions & 4 deletions contracts/{{app_name}}/src/bin/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ fn publish(networks: Vec<ChainInfo>) -> anyhow::Result<()> {
// Create an [`AbstractClient`]
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_acc = abstract_client.fetch_account(app_namespace)?;
// Get the [`Account`] that owns the namespace, otherwise create a new one and claim the namespace
let publisher_acc = abstract_client.fetch_or_build_account(app_namespace, |builder| builder.namespace(Namespace::from_id({{app_name | shouty_snake_case}}_ID).unwrap()))?;

// Get the [`Publisher`] that owns the namespace, otherwise create a new one and claim the namespace
let publisher: Publisher<_> = Publisher::new(&publisher_acc)?;
// Get the [`Publisher`]
let publisher: Publisher<_> = publisher_acc.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/{{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
8 changes: 4 additions & 4 deletions contracts/{{standalone_name}}/src/bin/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ fn publish(networks: Vec<ChainInfo>) -> anyhow::Result<()> {
// Create an [`AbstractClient`]
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_acc = abstract_client.fetch_account(standalone_namespace)?;
// Get the [`Account`] that owns the namespace, otherwise create a new one and claim the namespace
let publisher_acc = abstract_client.fetch_or_build_account(standalone_namespace, |builder| builder.namespace(Namespace::from_id({{standalone_name | shouty_snake_case}}_ID).unwrap()))?;

// Get the [`Publisher`] that owns the namespace, otherwise create a new one and claim the namespace
let publisher: Publisher<_> = Publisher::new(&publisher_acc)?;
// Get the [`Publisher`]
let publisher: Publisher<_> = publisher_acc.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 4a79e91

Please sign in to comment.