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: improve typescript sdk docs #2946

Merged
merged 1 commit into from
Sep 12, 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
16 changes: 10 additions & 6 deletions docs/src/content/docs/integrations/typescript/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import { Tabs, TabItem } from '@astrojs/starlight/components'
<PackageManagers
type="add"
frame="none"
pkg="@unionlabs/client"
pkg="@unionlabs/client@latest"
pkgManagers={['npm', 'pnpm', 'bun', 'yarn']}
/>

The Union client is TypeScript-first and framework agnostic.
The Union Client is TypeScript-first and framework agnostic.
At [app.union.build](https://app.union.build) we use [Svelte](https://svelte.dev) but you can use any framework or no frameworks at all.
If you're a [React](https://reactjs.org) user, [checkout this demo on Stackblitz](https://stackblitz.com/edit/github-nav3yr-xbanxq?file=src%2Fapp.tsx).
If you're a [React](https://reactjs.org) developer, [checkout this demo on Stackblitz](https://stackblitz.com/edit/github-nav3yr-xbanxq?file=src%2Fapp.tsx).

:::note

Expand Down Expand Up @@ -140,10 +140,14 @@ console.info(`Transfer hash: ${transfer.value}`)
import { privateKeyToAccount } from "viem/accounts"
import { createUnionClient, http } from "@unionlabs/client"

let PRIVATE_KEY = process.env["PRIVATE_KEY"]
if (!PRIVATE_KEY) throw new Error("PRIVATE_KEY is not set")
PRIVATE_KEY = PRIVATE_KEY.startsWith("0x") ? PRIVATE_KEY : `0x${PRIVATE_KEY}`

export const unionClient = createUnionClient({
chainId: "80084",
transport: http("https://bartio.rpc.berachain.com"),
account: privateKeyToAccount(`0x${process.env.PRIVATE_KEY}`),
account: privateKeyToAccount(PRIVATE_KEY),
transport: http("https://bartio.rpc.berachain.com")
})
```
</TabItem>
Expand All @@ -152,5 +156,5 @@ export const unionClient = createUnionClient({
Run the above example

```bash frame="none"
PRIVATE_KEY= npm_config_yes=true npx tsx main.ts
PRIVATE_KEY="" npm_config_yes=true npx tsx main.ts
```
Binary file modified typescript-sdk/bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion typescript-sdk/jsr.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://jsr.io/schema/config-file.v1.json",
"name": "@union/client",
"version": "0.0.18",
"version": "0.0.19",
"license": "MIT",
"exports": {
".": "./src/mod.ts"
Expand Down
10 changes: 5 additions & 5 deletions typescript-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@unionlabs/client",
"version": "0.0.18",
"version": "0.0.19",
"homepage": "https://jsr.io/@union/client",
"description": "Union Labs cross-chain transfers client",
"type": "module",
Expand Down Expand Up @@ -36,7 +36,7 @@
"@scure/base": "1.1.8",
"neverthrow": "^8.0.0",
"ofetch": "^1.3.4",
"viem": "^2.21.4"
"viem": "^2.21.6"
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.16.2",
Expand All @@ -48,13 +48,13 @@
"@types/node": "^22.5.4",
"consola": "^3.2.3",
"cosmjs-types": "^0.9.0",
"jsr": "^0.13.1",
"jsr": "^0.13.2",
"patch-package": "^8.0.0",
"tsup": "^8.2.4",
"tsx": "^4.19.0",
"tsx": "^4.19.1",
"typescript": "^5.6.2",
"vite-tsconfig-paths": "^5.0.1",
"vitest": "^2.0.5"
"vitest": "^2.1.0"
},
"repository": {
"type": "git",
Expand Down