@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.
- package/README.md +22 -35
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@tuwaio/orbit-evm)
|
|
4
4
|
[](./LICENSE)
|
|
5
5
|
|
|
6
|
-
`@tuwaio/orbit-evm` provides concrete implementations
|
|
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
|
-
- **
|
|
13
|
-
- **ENS Metadata Engine:**
|
|
14
|
-
- **
|
|
15
|
-
- **
|
|
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
|
-
## 🚀
|
|
30
|
+
## 🚀 Technical Integration
|
|
31
31
|
|
|
32
|
-
###
|
|
32
|
+
### Cached Client Generation & Routing
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
Create a public client wrapper to route queries to EVM nodes:
|
|
35
35
|
|
|
36
36
|
```typescript
|
|
37
|
-
import {
|
|
37
|
+
import { createViemClient } from '@tuwaio/orbit-evm';
|
|
38
38
|
import { mainnet } from 'viem/chains';
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
###
|
|
44
|
+
### Deterministic Chain Switcher
|
|
53
45
|
|
|
54
|
-
|
|
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
|
|
52
|
+
declare const config: Config;
|
|
61
53
|
|
|
62
|
-
async function
|
|
54
|
+
async function switchNetwork(targetChainId: number) {
|
|
63
55
|
try {
|
|
64
|
-
|
|
65
|
-
|
|
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('
|
|
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`
|
|
68
|
+
`@tuwaio/orbit-evm` exposes the following modules:
|
|
78
69
|
|
|
79
|
-
- **Chain
|
|
80
|
-
- **
|
|
81
|
-
- **ENS
|
|
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.
|
|
3
|
+
"version": "0.2.18",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Oleksandr Tkach",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
|
-
"description": "
|
|
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.
|
|
43
|
+
"@wagmi/core": "^3.6.3",
|
|
44
44
|
"tsup": "^8.5.1",
|
|
45
45
|
"typescript": "^6.0.3",
|
|
46
|
-
"viem": "^2.
|
|
46
|
+
"viem": "^2.55.2"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"start": "tsup src/index.ts --watch",
|