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

chore: erc3770 chain specific addresses #3848

Merged
merged 13 commits into from
Feb 14, 2025
Merged

chore: erc3770 chain specific addresses #3848

merged 13 commits into from
Feb 14, 2025

Conversation

lukaisailovic
Copy link
Collaborator

@lukaisailovic lukaisailovic commented Feb 12, 2025

Description

Adding support for displaying chain-specific addresses following the ERC-3770. When a user connects with an EIP-155 compatible wallet, the address will be displayed in both CAIP and ERC-3770 formats.

We're also exporting a utility from experimental package to convert CAIP-10 to ERC-3770

import { convertCaip10ToErc3770 } from '@reown/appkit-experimental/erc3770'

const erc3770address = convertCaip10ToErc3770(caipAddress)

and another one to construct ERC3770 address on its own

import { createErc3770Address } from '@reown/appkit-experimental/erc3770'

const erc3770address = createErc3770Address(address, chainId)

Type of change

  • Chore (non-breaking change that addresses non-functional tasks, maintenance, or code quality improvements)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Associated Issues

For Linear issues: Closes APKT-xxx
For GH issues: closes #...

Showcase (Optional)

Screenshot 2025-02-12 at 12 20 43

Checklist

  • Code in this PR is covered by automated tests (Unit tests, E2E tests)
  • My changes generate no new warnings
  • I have reviewed my own code
  • I have filled out all required sections
  • I have tested my changes on the preview link
  • Approver of this PR confirms that the changes are tested on the preview link

Copy link

changeset-bot bot commented Feb 12, 2025

⚠️ No Changeset found

Latest commit: fbf1f03

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Feb 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
appkit-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 14, 2025 8:45am
appkit-ethers5-bera ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 14, 2025 8:45am
appkit-laboratory ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 14, 2025 8:45am
next-wagmi-solana-bitcoin-example ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 14, 2025 8:45am
9 Skipped Deployments
Name Status Preview Comments Updated (UTC)
appkit-basic-ep ⬜️ Ignored (Inspect) Feb 14, 2025 8:45am
appkit-basic-ep-example ⬜️ Ignored (Inspect) Feb 14, 2025 8:45am
appkit-basic-example ⬜️ Ignored (Inspect) Feb 14, 2025 8:45am
appkit-basic-sign-client-example ⬜️ Ignored (Inspect) Feb 14, 2025 8:45am
appkit-basic-up-example ⬜️ Ignored (Inspect) Feb 14, 2025 8:45am
appkit-vue-solana ⬜️ Ignored (Inspect) Feb 14, 2025 8:45am
appkit-wagmi-cdn-example ⬜️ Ignored (Inspect) Feb 14, 2025 8:45am
ethereum-provider-wagmi-example ⬜️ Ignored (Inspect) Visit Preview Feb 14, 2025 8:45am
vue-wagmi-example ⬜️ Ignored (Inspect) Feb 14, 2025 8:45am

Copy link
Contributor

github-actions bot commented Feb 12, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 71.21% 22446 / 31517
🔵 Statements 71.21% 22446 / 31517
🔵 Functions 61.01% 1789 / 2932
🔵 Branches 80.76% 3771 / 4669
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/experimental/src/erc3770/utils/ConstantsUtil.ts 100% 100% 100% 100%
packages/experimental/src/erc3770/utils/ConverterUtil.ts 100% 100% 100% 100%
Generated in workflow #9569 for commit fbf1f03 by the Vitest Coverage Report Action

Copy link
Contributor

github-actions bot commented Feb 12, 2025

Warnings
⚠️ File packages/experimental/package.json contains a KEY or SECRET

Generated by 🚫 dangerJS against fbf1f03

@lukaisailovic
Copy link
Collaborator Author

@tomiir I added viem for address validation. I don't think the bundle size is a concern for experimental package. Wdyt

Comment on lines +5 to +8
describe('ConverterUtil', () => {
describe('convertCaip10ToErc3770', () => {
it('should convert Ethereum mainnet CAIP address to ERC-3770 format with checksum', () => {
const caipAddress = 'eip155:1:0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359'
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is what I call a test file

Comment on lines +12 to +14
namespace === undefined ||
chainId === undefined ||
address === undefined
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: do we need explicit check agains undefined?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Typescript will complain down below when using the chainId and namespace so I just added validation for everything in one go

}

const createErc3770Address = (address: string, chainId: string): string => {
const shortName = ConstantsUtil.CHAIN_NAMES[chainId]
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this something we need to mantain or is there a public registry we can use? should this maybe be some api endpoint?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There is a public registry https://github.com/ethereum-lists/chains
I would consider moving it to an API or just modifying the json with the chains we support if we wanted to go in prod with it

Copy link
Collaborator Author

@lukaisailovic lukaisailovic Feb 12, 2025

Choose a reason for hiding this comment

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

We can just query them from here (not directly ofc) https://chainid.network/chains_mini.json, but its an additional unnecessary request atm

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.

3 participants