0.1.6 • Published 12 months ago

@unionlabs/client v0.1.6

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

JSR NPM Version

Union Labs TypeScript SDK providing utilities for cross-chain transfers and more.

npm install @unionlabs/client

Development

Fetch latest schema

nix run .#ts-sdk-fetch-schema -L

Publishing

Publish to npm registry:

npm run build # important!
npm publish --access='public' --no-git-tags

Publish to JSR:

bun ./scripts/publish.ts

Usage

Initiate a client

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(`0x${process.env.PRIVATE_KEY}`),
})

Examples

Transfer strd from Stride Testnet on Cosmos (stride-internal-1) chain to Sepolia on EVM (1111551111) chain.

import { DirectSecp256k1Wallet } from "@cosmjs/proto-signing"
import { createUnionClient, hexToBytes, http } from "@unionlabs/client"

const PRIVATE_KEY = process.env["PRIVATE_KEY"]
if (!PRIVATE_KEY) throw new Error("Private key not found")

const cosmosAccount = await DirectSecp256k1Wallet.fromKey(
  Uint8Array.from(hexToBytes(PRIVATE_KEY)),
  "stride"
)

const client = createUnionClient({
  account: cosmosAccount,
  chainId: "stride-internal-1",
  transport: http("stride.testnet-1.stridenet.co")
})

const transfer = await client.transferAsset({
  amount: 1n,
  autoApprove: true,
  denomAddress: "strd",
  destinationChainId: "11155111",
  receiver: "0x8478B37E983F520dBCB5d7D3aAD8276B82631aBd"
})

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

console.info(transfer.value)

How to patch dependencies

npm install
npm install --package-lock-only
# edit node_modules/foo
./node_modules/patch-package/index.js foo
# a patch will be generated for foo in the patches/ dir
0.1.6

12 months ago

0.1.4

12 months ago

0.1.5

12 months ago

0.1.0

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.3

1 year ago

0.0.60

1 year ago

0.0.61

1 year ago

0.0.59

1 year ago

0.0.51

1 year ago

0.0.52

1 year ago

0.0.53

1 year ago

0.0.54

1 year ago

0.0.55

1 year ago

0.0.56

1 year ago

0.0.57

1 year ago

0.0.58

1 year ago

0.0.50

1 year ago

0.0.49

1 year ago

0.0.48

1 year ago

0.0.44

1 year ago

0.0.45

1 year ago

0.0.40

1 year ago

0.0.41

1 year ago

0.0.42

1 year ago

0.0.43

1 year ago

0.0.38

1 year ago

0.0.39

1 year ago

0.0.37

1 year ago

0.0.36

1 year ago

0.0.32

1 year ago

0.0.33

1 year ago

0.0.34

1 year ago

0.0.35

1 year ago

0.0.30

1 year ago

0.0.31

1 year ago

0.0.28

1 year ago

0.0.29

1 year ago

0.0.27

1 year ago

0.0.26

1 year ago

0.0.25

1 year ago

0.0.24

1 year ago

0.0.23

1 year ago

0.0.22

1 year ago

0.0.21

1 year ago

0.0.20

1 year ago

0.0.19

1 year ago

0.0.18

1 year ago

0.0.17

1 year ago

0.0.16

1 year ago

0.0.0

2 years ago