Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update frontend dependencies and example endpoints #82

Merged
merged 3 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ schema/
!/frontend/**

build/

.next
# frontend/.next
9 changes: 5 additions & 4 deletions contracts/{{adapter_name}}/src/bin/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +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: Publisher<_> = abstract_client
.publisher_builder(adapter_namespace)
.build()?;
// 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()))?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to just clone namespace, but "builder fn" doesn't capture environment, as it's function instead of closure, fixed in AbstractSDK/abstract#519


// 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
7 changes: 5 additions & 2 deletions contracts/{{app_name}}/src/bin/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +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: Publisher<_> = abstract_client.publisher_builder(app_namespace).build()?;
// 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`]
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
9 changes: 5 additions & 4 deletions contracts/{{standalone_name}}/src/bin/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +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: Publisher<_> = abstract_client
.publisher_builder(standalone_namespace)
.build()?;
// 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`]
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
2 changes: 1 addition & 1 deletion frontend/.env.example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ABSTRACT_API_URL=https://api.abstract.money/graphql
ABSTRACT_API_URL=https://api-hackmos-2024.up.railway.app/
22 changes: 13 additions & 9 deletions frontend/app/_components/codegen-contract.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import { Card, CardContent, CardHeader, CardTitle } from "../../components/card"
import { Alert, AlertDescription, AlertTitle } from "../../components/alert"
import { AlertCircle } from "lucide-react"

const EXAMPLE_NEUTRONTESTNET_CW20 = "neutron1sj7exsjqgy460zky8t0u0cvjutu09fswqfq3trssq9z935dryl3snjeekf"


export const CodegenContract: React.FC = () => {
const contractAddress = "juno1ju8k8sqwsqu5k6umrypmtyqu2wqcpnrkf4w4mntvl0javt4nma7s8lzgss"
const chainId = appChain.chainId

const { data: cosmosAccount } = useAccount({ chainId })
Expand All @@ -24,10 +26,12 @@ export const CodegenContract: React.FC = () => {
},
})
const { data: accountsMetadata } = useAccountsMetadataGraphQLQuery({ accountIds: accounts })
const { data: balance, isLoading } = cw20Base.queries.useBalance({
contractAddress,
args: { address: accountsMetadata?.[0]?.proxy ?? "" },
options: { enabled: !!accountsMetadata?.[0]?.proxy && !!contractAddress },

const { data: exampleCw20Balance, isLoading } = cw20Base.queries.useBalance({
contractAddress: EXAMPLE_NEUTRONTESTNET_CW20,
chainName: appChain.chainName,
args: { address: accountsMetadata?.[0]?.address ?? "" },
options: { enabled: !!accountsMetadata?.[0]?.address && !!EXAMPLE_NEUTRONTESTNET_CW20 },
})

return (
Expand All @@ -38,11 +42,11 @@ export const CodegenContract: React.FC = () => {
<CardContent>
{isLoading ? (
<p>Loading balance...</p>
) : balance ? (
) : exampleCw20Balance ? (
<div className="bg-gray-100 p-3 rounded-md">
<h3 className="font-semibold mb-2">Balance for address: {accountsMetadata?.[0]?.proxy ?? ""}</h3>
<h3 className="font-semibold mb-2">Balance for address: {accountsMetadata?.[0]?.address ?? ""}</h3>
<p>
<strong>Balance:</strong> {balance.balance}
<strong>Balance:</strong> {exampleCw20Balance.balance}
</p>
</div>
) : (
Expand All @@ -57,4 +61,4 @@ export const CodegenContract: React.FC = () => {
</CardContent>
</Card>
)
}
}
Loading