Skip to content

Commit

Permalink
chore: reorder sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
o-az committed Sep 12, 2024
1 parent 935788b commit 9dd6921
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 64 deletions.
17 changes: 6 additions & 11 deletions docs/astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,26 +117,21 @@ export default defineConfig({
}
]
},
{
label: "SDKs",
items: [
{
label: "TypeScript",
link: "/sdks/typescript",
badge: { variant: "note", text: "new" }
}
]
},
{
label: "Integrations",
items: [
{
label: "Getting Started",
link: "/integrations/getting-started"
},
{
label: "TypeScript SDK",
link: "/integrations/typescript",
badge: { variant: "note", text: "new" }
},
{
label: "API",
collapsed: false,
collapsed: true,
autogenerate: {
directory: "/integrations/api"
}
Expand Down
4 changes: 0 additions & 4 deletions docs/src/content/docs/SDKs/index.mdx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
---
title: "TypeScript SDK"
---
import Code from '#/components/Code.astro'
import { demoFiles } from './_data/demo-files.ts'
import Terminal from '#/components/Terminal.astro'
import { PackageManagers } from 'starlight-package-managers'
import { Tabs, TabItem } from '@astrojs/starlight/components'

Expand All @@ -26,51 +23,6 @@ If you need testnet tokens for testing, visit https://app.union.build/faucet and

:::

## Quick Example

End-to-end example to transfer assets between EVM and Cosmos SDK chains. You can run this example in the cli - more later.

We will transfer 1 `HONEY` from _**Berachain bArtio**_ (`80084`) to _**Stride Testnet**_ (`stride-internal-1`).

```ts
import { privateKeyToAccount } from "viem/accounts"
import { createUnionClient, http } from "@unionlabs/client"

const client = createUnionClient({
chainId: "80084",
transport: http("https://bartio.rpc.berachain.com"),
account: privateKeyToAccount(process.env["PRIVATE_KEY"]),
})

const HONEY_ADDRESS = "0x0E4aaF1351de4c0264C5c7056Ef3777b41BD8e03"

const transfer = await client.transferAsset({
amount: 1n,
autoApprove: true,
denomAddress: HONEY_ADDRESS,
destinationChainId: "stride-internal-1",
receiver: "stride17ttpfu2xsmfxu6shl756mmxyqu33l5ljegnwps"
})

if (transfer.isErr()) {
console.error(transfer.error)
process.exit(1)
}

console.info(transfer.value)
```

Run the above example

```bash frame="none"
PRIVATE_KEY= npm_config_yes=true npx tsx main.ts
```

## Breakdown

To transfer assets cross-chain, you start by initializing a client, then use the client to create a transfer.
You have the option to trigger the approval transaction manually by setting `autoApprove` to `false` then calling `.approveTransaction` before calling `.transferAsset`.

### Client Initialization

<Tabs>
Expand Down Expand Up @@ -142,9 +94,12 @@ const clients = createMultiUnionClient([
</TabItem>
</Tabs>


### Transferring Assets

We will transfer 1 [`HONEY`](https://bartio.beratrail.io/token/0x0E4aaF1351de4c0264C5c7056Ef3777b41BD8e03) from [**Berachain bArtio**](https://www.berachain.com) to [**Stride Testnet**](https://stride.zone).

You have the option to trigger the approval transaction manually by setting `autoApprove` to `false` then calling `.approveTransaction` before calling `.transferAsset`.

<Tabs>
<TabItem label='main.ts'>
```ts
Expand Down

0 comments on commit 9dd6921

Please sign in to comment.