@lydianpay/lydianconnect 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,9 +1,7 @@
1
1
  # @lydianpay/lydianconnect
2
2
 
3
- Wallet-connection library for Lydian frontends. It connects to a user's wallet
4
- through the wallet's **native SDK** when one exists (MetaMask, Coinbase) and
5
- falls back to **WalletConnect** for everything else — behind a single uniform
6
- API, so your app never branches on which path was used.
3
+ One API for every wallet. LydianConnect abstracts the messy differences between
4
+ wallet connection methods into a single, uniform interface.
7
5
 
8
6
  ## Install
9
7
 
@@ -14,70 +12,39 @@ npm install @lydianpay/lydianconnect
14
12
  ## Usage
15
13
 
16
14
  ```ts
17
- import {
18
- LydianConnect,
19
- WalletConnectConnector,
20
- MetaMaskConnector,
21
- CoinbaseConnector,
22
- } from '@lydianpay/lydianconnect';
15
+ import { LydianConnect } from '@lydianpay/lydianconnect';
23
16
 
24
17
  const lc = new LydianConnect({
25
- connectors: [
26
- new MetaMaskConnector({ dappMetadata: { name: 'My App', url: location.origin } }),
27
- new CoinbaseConnector({ appName: 'My App' }),
28
- ],
29
- fallback: new WalletConnectConnector({
30
- projectId: 'your-walletconnect-project-id',
31
- metadata: {
32
- name: 'My App',
33
- description: 'My App',
34
- url: location.origin,
35
- icons: ['https://my.app/icon.png'],
36
- },
37
- }),
38
- });
39
-
40
- // One call — the result is identical whether it routes to a native SDK or
41
- // to WalletConnect. Your app never branches on the source.
42
- const conn = await lc.connect({
43
- walletId: 'metamask',
44
- namespace: {
45
- name: 'eip155',
46
- value: { chains: ['eip155:1'], methods: ['eth_sendTransaction'], events: [] },
47
- },
18
+ appName: 'My App',
19
+ walletConnectProjectId: 'your-wc-project-id',
20
+ icon: 'https://my.app/icon.png', // optional
21
+ description: 'My App checkout', // optional
48
22
  });
49
23
 
24
+ const conn = await lc.connect({ walletId: 'metamask', chainId: 137 });
50
25
  const txHash = await conn.request({ method: 'eth_sendTransaction', params: [tx] });
51
26
 
52
27
  lc.on((event) => {
53
- // 'connect' | 'disconnect' | 'chainChanged' | 'accountsChanged'
54
- // | 'display_uri' | 'wallet_open_failed'
28
+ // 'connect' | 'disconnect' | 'chainChanged' | 'accountsChanged' | 'display_uri' | 'wallet_open_failed'
55
29
  });
56
30
  ```
57
31
 
58
- `conn` is the uniform handle: `{ walletId, account, chainId, request, disconnect }`.
59
- Encoding/signing (ethers, viem, …) stays in your app — this library only moves
60
- opaque RPC requests.
61
-
62
- ## Supported wallets
63
-
64
- - **Native SDK:** MetaMask, Coinbase
65
- - **WalletConnect fallback:** every other WalletConnect-compatible wallet, with
66
- per-wallet deep-linking generated from the WalletConnect explorer registry
32
+ ## Config
67
33
 
68
- ## Development
34
+ | Field | Required | Notes |
35
+ |-------|----------|-------|
36
+ | `appName` | yes | Display name shown in the wallet's connect prompt. |
37
+ | `walletConnectProjectId` | yes | WalletConnect Cloud project id. |
38
+ | `icon` | no | Icon shown in the connect prompt. |
39
+ | `description` | no | Defaults to `appName`. |
69
40
 
70
- See [CLAUDE.md](./CLAUDE.md) for architecture, conventions, and the wallet-link
71
- registry generator (`scripts/build-wallet-links.mjs`).
41
+ `connect({ walletId, chainId })` `chainId` is the chain the user is paying on (a number like `137`, or a CAIP-2 id like `'eip155:137'`).
72
42
 
73
- ```bash
74
- npm install
75
- npm run build # ESM + CJS + d.ts
76
- npm run lint
77
- npm run typecheck
78
- npm test
79
- ```
43
+ ## Supported wallets
80
44
 
81
- ## License
45
+ **Native SDK:** MetaMask, Coinbase Wallet.
82
46
 
83
- MIT
47
+ **WalletConnect:** Rainbow, Trust Wallet, OKX Wallet, Crypto.com, Phantom, Zerion,
48
+ Argent, Ledger, 1inch, SafePal, imToken, TokenPocket, Blockchain.com, Exodus,
49
+ Ronin Wallet, Coin98, Bitget Wallet, Infinity Wallet, Atomic Wallet, AlphaWallet,
50
+ MathWallet, BitPay — each with native deep-linking.