@tuwaio/orbit-evm 0.2.16 → 0.2.18

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.
Files changed (2) hide show
  1. package/README.md +22 -35
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -3,16 +3,16 @@
3
3
  [![NPM Version](https://img.shields.io/npm/v/@tuwaio/orbit-evm.svg)](https://www.npmjs.com/package/@tuwaio/orbit-evm)
4
4
  [![License](https://img.shields.io/npm/l/@tuwaio/orbit-evm.svg)](./LICENSE)
5
5
 
6
- `@tuwaio/orbit-evm` provides concrete implementations and utilities tailored specifically for EVM-compatible blockchains. Built entirely in **TypeScript** and powered by **`@wagmi/core`** and **`viem`**, it acts as the EVM adapter for the Orbit Utils ecosystem, simplifying client connections, chain switching, and identity lookups in web3 UIs.
6
+ `@tuwaio/orbit-evm` provides concrete implementations of low-level EVM-specific communication primitives for Layer 2 (L2) of the TUWA Orbit stack. Engineered strictly on top of **`@wagmi/core`** and **`viem`**, this package provides deterministic chain switching, custom Viem client generation, and cached ENS metadata resolution, while enforcing a complete exclusion of legacy libraries like `ethers.js` or `web3.js`.
7
7
 
8
8
  ---
9
9
 
10
10
  ## 🏛️ Core Capabilities
11
11
 
12
- - **Public Client Caching:** Dynamically instantiates and caches `viem` public clients (`createViemClient`) to optimize RPC request efficiency.
13
- - **ENS Metadata Engine:** Built-in ENS lookups targeting Ethereum Mainnet with internal caching for resolving ENS names to addresses, reverse resolving addresses, and fetching avatars.
14
- - **Intelligent Chain Switcher:** Safe utility (`checkAndSwitchChain`) to prompt users' wallets to align with the required target network.
15
- - **Type-Safe APIs:** Seamlessly aligned with typescript standards v5.9+ and Wagmi/Viem typings.
12
+ - **Viem Client Optimization:** Creates and caches high-performance `viem` public clients (`createViemClient`) to minimize request latency and avoid duplicate RPC instantiation.
13
+ - **ENS Metadata Engine:** Direct lookup utilities (`getName`, `getAvatar`, `getAddress`) on the Ethereum Mainnet context with local caching.
14
+ - **Deterministic Chain Switching:** Low-level utility (`checkAndSwitchChain`) to enforce network alignment with the target blockchain, requesting wallet configurations dynamically.
15
+ - **Strict Compile-Time Types:** Fully integrated with TypeScript standards v5.9+ and native Viem/Wagmi typings.
16
16
 
17
17
  ---
18
18
 
@@ -27,45 +27,36 @@ pnpm add @tuwaio/orbit-evm @wagmi/core viem
27
27
 
28
28
  ---
29
29
 
30
- ## 🚀 Quick Start
30
+ ## 🚀 Technical Integration
31
31
 
32
- ### ENS Metadata Resolution
32
+ ### Cached Client Generation & Routing
33
33
 
34
- Retrieve profile metadata associated with an Ethereum address dynamically:
34
+ Create a public client wrapper to route queries to EVM nodes:
35
35
 
36
36
  ```typescript
37
- import { getName, getAvatar } from '@tuwaio/orbit-evm';
37
+ import { createViemClient } from '@tuwaio/orbit-evm';
38
38
  import { mainnet } from 'viem/chains';
39
39
 
40
- async function fetchUserProfile(address: `0x${string}`) {
41
- // Resolve primary ENS name
42
- const name = await getName(address, [mainnet]);
43
-
44
- if (name) {
45
- // Resolve avatar image URL
46
- const avatarUrl = await getAvatar(name, [mainnet]);
47
- console.log(`ENS: ${name}, Avatar: ${avatarUrl}`);
48
- }
49
- }
40
+ // Retrieve cached or new Viem Public Client
41
+ const client = createViemClient(mainnet);
50
42
  ```
51
43
 
52
- ### Wallet Chain Alignment
44
+ ### Deterministic Chain Switcher
53
45
 
54
- Prompt the user's wallet to switch to the desired network context:
46
+ Enforce that the wallet's connection context matches the requested chain:
55
47
 
56
48
  ```typescript
57
49
  import { checkAndSwitchChain } from '@tuwaio/orbit-evm';
58
50
  import { type Config } from '@wagmi/core';
59
51
 
60
- declare const wagmiConfig: Config; // Your wagmi configuration instance
52
+ declare const config: Config;
61
53
 
62
- async function alignNetwork() {
54
+ async function switchNetwork(targetChainId: number) {
63
55
  try {
64
- const mainnetChainId = 1;
65
- await checkAndSwitchChain(mainnetChainId, wagmiConfig);
66
- console.log('Wallet aligned to Ethereum Mainnet');
56
+ await checkAndSwitchChain(targetChainId, config);
57
+ console.log(`Execution context successfully switched to: ${targetChainId}`);
67
58
  } catch (error) {
68
- console.error('Failed to align network:', error);
59
+ console.error('Chain switch rejected:', error);
69
60
  }
70
61
  }
71
62
  ```
@@ -74,18 +65,14 @@ async function alignNetwork() {
74
65
 
75
66
  ## 🔧 API & Module Architecture
76
67
 
77
- `@tuwaio/orbit-evm` exports the following modules:
68
+ `@tuwaio/orbit-evm` exposes the following modules:
78
69
 
79
- - **Chain Switcher:** `checkAndSwitchChain`.
80
- - **Public Client Factory:** `createViemClient` (cache-backed).
81
- - **ENS Responders:** `getAddress`, `getAvatar`, `getName`, `isEnsName`.
70
+ - **Chain Alignment:** `checkAndSwitchChain`.
71
+ - **Client Factory:** `createViemClient`.
72
+ - **ENS Resolvers:** `getAddress`, `getAvatar`, `getName`, `isEnsName`.
82
73
 
83
74
  ---
84
75
 
85
- ## 🤝 Contributing
86
-
87
- Please read our main **[Contribution Guidelines](https://github.com/TuwaIO/workflows/blob/main/CONTRIBUTING.md)** before submitting pull requests.
88
-
89
76
  ## 📄 License
90
77
 
91
78
  Licensed under the **Apache-2.0 License**. See the [LICENSE](./LICENSE) file for details.
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@tuwaio/orbit-evm",
3
- "version": "0.2.16",
3
+ "version": "0.2.18",
4
4
  "private": false,
5
5
  "author": "Oleksandr Tkach",
6
6
  "license": "Apache-2.0",
7
- "description": "The core, with web3 EVM utilities and helpers for TUWA projects.",
7
+ "description": "Layer 2 (L2) of the TUWA Ecosystem. Low-level EVM-specific communication primitives powered strictly by viem and wagmi.",
8
8
  "main": "./dist/index.js",
9
9
  "module": "./dist/index.mjs",
10
10
  "types": "./dist/index.d.ts",
@@ -40,10 +40,10 @@
40
40
  "viem": "2.x.x"
41
41
  },
42
42
  "devDependencies": {
43
- "@wagmi/core": "^3.5.1",
43
+ "@wagmi/core": "^3.6.3",
44
44
  "tsup": "^8.5.1",
45
45
  "typescript": "^6.0.3",
46
- "viem": "^2.52.2"
46
+ "viem": "^2.55.2"
47
47
  },
48
48
  "scripts": {
49
49
  "start": "tsup src/index.ts --watch",