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(ts-sdk): create transfers sdk #1017

Merged
merged 4 commits into from
Dec 20, 2023
Merged

feat(ts-sdk): create transfers sdk #1017

merged 4 commits into from
Dec 20, 2023

Conversation

o-az
Copy link
Member

@o-az o-az commented Dec 5, 2023

Summary by CodeRabbit

  • New Features
    • Added a search functionality to the app.
  • Refactor
    • Updated import statement for erc20abi variable in site/src/lib/constants.ts
  • Chores
    • Various file and directory patterns added to .gitignore
  • Documentation
    • Significant update to lib/typescript-sdk/README.md

@o-az o-az self-assigned this Dec 5, 2023
Copy link

coderabbitai bot commented Dec 5, 2023

Walkthrough

The recent changes encompass a broad expansion of the project, including the addition of new terms to the dictionary, updates to the TypeScript SDK, and the introduction of new scripts and configuration files. Notably, the TypeScript SDK has seen significant enhancements with the addition of various modules, functions, and type declarations, along with the expansion of allowed file extensions in flake.nix.

Changes

File/Directory Change Summary
.gitignore Removed bun.lockb, added new patterns for ignored files and directories
dictionary.txt Addition of new terms
flake.nix Expanded list of allowed extensions to include *.cjs, *.mjs, and *.d.ts
lib/typescript-sdk/.gitignore Added various directories and files to be ignored by Git
lib/typescript-sdk/README.md Significantly updated with new sections, notes, and code snippets
lib/typescript-sdk/environment.d.ts, reset.d.ts Introduces new interfaces and declarations
lib/typescript-sdk/scripts/demo.ts, faucet.ts Added new scripts for blockchain interactions and UNO retrieval
lib/typescript-sdk/src/abi/ibc.ts, index.ts, usc01relay.ts Substantial addition of public entities related to IBC handling and export statements
lib/typescript-sdk/src/actions.ts Addition of new types and an updated function unionActions
lib/typescript-sdk/src/balance.ts Introduction of new TypeScript code for balance retrieval on Union and Ethereum blockchains
lib/typescript-sdk/src/constants/chain.ts, index.ts Addition of new constants, environment-specific configuration values, and export statements
lib/typescript-sdk/src/index.ts Multiple import and export statements added
lib/typescript-sdk/src/patch.ts Changes related to type declarations introduced
lib/typescript-sdk/src/send.ts Significant changes including new functions and imports, and changes to function signatures
lib/typescript-sdk/src/utilities/faucet.ts, index.ts Addition of a new function and several utility functions
lib/typescript-sdk/tsup.config.ts, vitest.config.ts Addition of new TypeScript configuration files
site/src/lib/constants.ts Modified import statement for the erc20abi variable

Note

Pull Request Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://coderabbit.ai


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • You can reply to a review comment made by CodeRabbit.
  • You can tag CodeRabbit on specific lines of code or files in the PR by tagging @coderabbitai in a comment.
  • You can tag @coderabbitai in a PR comment and ask one-off questions about the PR and the codebase. Use quoted replies to pass the context for follow-up questions.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

@o-az o-az linked an issue Dec 5, 2023 that may be closed by this pull request
8 tasks
@o-az
Copy link
Member Author

o-az commented Dec 5, 2023

@coderabbitai review

@o-az o-az marked this pull request as ready for review December 11, 2023 22:33
@o-az
Copy link
Member Author

o-az commented Dec 11, 2023

@KaiserKarel & @cor not sure who will be reviewing but this is ready for review. Readme shows available actions: https://github.com/unionlabs/union/blob/ts-transfer-client/lib/typescript/README.md

and this script can run a little demo: https://github.com/unionlabs/union/blob/ts-transfer-client/lib/typescript/scripts/demo.ts

@o-az o-az requested review from cor and benluelo December 12, 2023 00:58
lib/typescript/bun.lockb Outdated Show resolved Hide resolved
lib/typescript/environment.d.ts Outdated Show resolved Hide resolved
lib/typescript/src/abi/ibc.ts Outdated Show resolved Hide resolved
lib/typescript/src/abi/usc01relay.ts Outdated Show resolved Hide resolved
lib/typescript/src/utilities/faucet.ts Outdated Show resolved Hide resolved
lib/typescript/src/utilities/index.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@KaiserKarel KaiserKarel left a comment

Choose a reason for hiding this comment

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

Ideally we have a client object like:

let client = Client.new();
client.send({chain_id, asset_id, amount});

This way, we treat all chains through a similar interface, and inside the client handle the overhead of detection. The client should autodetect wallets; and allow being instantiated with a configuration.

@o-az
Copy link
Member Author

o-az commented Dec 14, 2023

@KaiserKarel API interface updated to .approveAsset(..), .sendAsset(..), and .getBalance(..). I'm re-requesting your review for the ts stuff.

What's left is:
- moving biome to nix,
- making nix spellcheck recognize terms like these library names (currently failing because it doesn't recognize viem, tsup, treeshake)

Two questions:
- Is it ok to do the remaining items in a separate (subsequent?) pr?
- Does waiting until merge commit and doing squash then merge in the github ui work for our setup? And making sure the commit is formatted appropriately.

@o-az
Copy link
Member Author

o-az commented Dec 14, 2023

Ideally we have a client object like:

let client = Client.new();
client.send({chain_id, asset_id, amount});

This way, we treat all chains through a similar interface, and inside the client handle the overhead of detection. The client should autodetect wallets; and allow being instantiated with a configuration.

@KaiserKarel Incorporated this feedback: updated the interface to have client.sendAsset(..).

Re auto-detection: in browser environment, we use wagmi and supply multiple chains and the client will auto-detect which chain to use automatically. All we'd need to do is .extend(unionActions) the same way we're doing for viem and everything in this example becomes available in a browser environment.
Here's how multichain viem x wagmi setup looks like (this is framework agnostic so works with svelte): https://beta.wagmi.sh/core/guides/viem#multi-chain-viem-client

Aside: I favor keeping the client instantiation the same as viem to allow for maximum extensibility. As it stands right now, anyone using viem or wagmi can easily import our unionActions and extend their existing client in a single line.

For example,

if they're using a public client:

import { unionActions } from '@unionlabs/client'
import { createPublicClient, walletActions } from 'viem'

export const client = createPublicClient({
  // ...
})
  .extend(walletActions)
  .extend(unionActions)

if they're using a wallet client:

import { unionActions } from '@unionlabs/client'
import { createWalletClient, publicActions } from 'viem'

export const client = createWalletClient({
  // ...
})
  .extend(publicActions)
  .extend(unionActions)

Same thing for createTestClient.

@o-az o-az mentioned this pull request Dec 15, 2023
8 tasks
Copy link

Docs Preview URL

https://docs-r0ex1n4hv-unionbuild.vercel.app

@o-az o-az merged commit 1084829 into main Dec 20, 2023
129 checks passed
@o-az o-az deleted the ts-transfer-client branch December 20, 2023 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeScript SDK & Transfers
3 participants