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

feat: add ibc executions #74

Merged
merged 24 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,13 @@ tsconfig.tsbuildinfo
.env.production.local
.envrc
.turbo/

packages/core/account/
packages/core/api/
packages/core/apps/
packages/core/chain-registry/
packages/core/cw-plus/
packages/core/modules/
packages/core/native/
packages/cosmwasm
packages/react/internal
adairrr marked this conversation as resolved.
Show resolved Hide resolved
35 changes: 22 additions & 13 deletions examples/wagemos-cosmoskit-nextjs/src/app/remote/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import {
} from '../../components/ui/select'
import { WalletButton } from '../_components/wallet-button'

const CHAIN_NAME = 'juno'
const CHAIN_NAME = 'neutron'
export default function RemotePage() {
const { data: remoteHosts, isLoading } = useRemoteHosts(CHAIN_NAME)
const [chainInput, setChainInput] = useState(CHAIN_NAME)
const { data: remoteHosts, isLoading, refetch } = useRemoteHosts(CHAIN_NAME)
const [chainInput, setChainInput] = useState(remoteHosts?.[0]?.[0])

const { address } = useChain(CHAIN_NAME)

Expand All @@ -45,10 +45,11 @@ export default function RemotePage() {
[accounts],
)

const { mutate: createRemoteAccount } = useCreateRemoteAccount({
accountId: firstAccount,
})
const { mutate: execRemote } = useExecuteOnRemote({
const { mutate: createRemoteAccount, isLoading: isCreating } =
useCreateRemoteAccount({
accountId: firstAccount,
})
const { mutate: execRemote, isLoading: isExecuting } = useExecuteOnRemote({
accountId: firstAccount,
})

Expand All @@ -63,20 +64,23 @@ export default function RemotePage() {
return undefined
}

console.log('creating remote account')

createRemoteAccount({
fee: 'auto',
args: {
hostChainName: chainInput,
base_asset: 'juno>juno',
},
})
}, [createRemoteAccount])
}, [createRemoteAccount, chainInput])

const onExecClick = useCallback(() => {
if (!chainInput) {
console.log('no chain input')
return undefined
}
console.log('executing remote account')
execRemote({
fee: 'auto',
args: {
Expand All @@ -88,7 +92,7 @@ export default function RemotePage() {
},
},
})
}, [execRemote])
}, [execRemote, chainInput])

return (
<>
Expand All @@ -109,14 +113,19 @@ export default function RemotePage() {
</Select>
{isLoading && <div>Loading...</div>}
{/*<Input placeholder="chain" value={chainInput} onChange={(e) => setChainInput(e.target.value)} />*/}
<Button onClick={onCreateClick} disabled={!chainInput}>
Create Remote Account
<Button onClick={onCreateClick} disabled={!chainInput || isCreating}>
Creat{isCreating ? 'ing' : 'e'} Remote Account {isCreating && '...'}
</Button>
<Button onClick={onExecClick} disabled={!chainInput}>
Update Remote Account
<Button onClick={onExecClick} disabled={!chainInput || isExecuting}>
Updat{isExecuting ? 'ing' : 'e'} Remote Account {isExecuting && '...'}
</Button>

<WalletButton />
<h3>Remote Accounts</h3>
<div>
<pre>{JSON.stringify(remoteAccountIds, null, 2)}</pre>
</div>
<Button onClick={() => refetch()}>Refresh</Button>
</>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ export async function getIbcClientQueryClientFromManager({
}

return getIbcClientQueryClient({
args: { cosmWasmClient, ibcClientAddress: ansHostAddress },
args: { cosmWasmClient, ibcClientAddress },
})
}
Loading