@circle-fin/adapter-ethers-v6 0.0.2-alpha.7 → 1.0.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 +39 -13
- package/index.cjs.js +154 -246
- package/index.d.ts +29 -96
- package/index.mjs +96 -188
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ _Seamlessly interact with 16+ EVM networks using a single, strongly-typed interf
|
|
|
45
45
|
|
|
46
46
|
## Overview
|
|
47
47
|
|
|
48
|
-
The Ethers v6 Adapter is a strongly-typed implementation of the `Adapter` interface for **EVM-compatible blockchains**. Built on top of the popular [Ethers v6](https://docs.ethers.org/v6/) library, it provides type-safe blockchain interactions through a unified interface that's designed to work seamlessly with the [
|
|
48
|
+
The Ethers v6 Adapter is a strongly-typed implementation of the `Adapter` interface for **EVM-compatible blockchains**. Built on top of the popular [Ethers v6](https://docs.ethers.org/v6/) library, it provides type-safe blockchain interactions through a unified interface that's designed to work seamlessly with the [Bridge Kit](https://www.npmjs.com/package/@circle-fin/bridge-kit) for cross-chain USDC transfers between Solana and EVM networks, as well as any future kits for additional stablecoin operations. It can be used by any Kit built using the Stablecoin Kits architecture and/or any providers plugged into those kits.
|
|
49
49
|
|
|
50
50
|
### Why Ethers v6 Adapter?
|
|
51
51
|
|
|
@@ -60,12 +60,22 @@ The Ethers v6 Adapter is a strongly-typed implementation of the `Adapter` interf
|
|
|
60
60
|
|
|
61
61
|
#### For Kit Users
|
|
62
62
|
|
|
63
|
-
If you're using the
|
|
63
|
+
If you're using the Bridge Kit or other Stablecoin Kits for cross-chain operations, you only need to instantiate one adapter and pass it to the kit. The same adapter works across all supported chains.
|
|
64
64
|
|
|
65
65
|
```typescript
|
|
66
66
|
// Single adapter instance for multi-chain operations
|
|
67
|
+
// Note: Private keys can be provided with or without '0x' prefix
|
|
67
68
|
const adapter = createAdapterFromPrivateKey({
|
|
68
|
-
privateKey: process.env.PRIVATE_KEY as `0x${string}`,
|
|
69
|
+
privateKey: process.env.PRIVATE_KEY as `0x${string}`, // Both '0x...' and '...' work
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
// Both formats are automatically normalized:
|
|
73
|
+
const adapter1 = createAdapterFromPrivateKey({
|
|
74
|
+
privateKey: '0x1234...', // With prefix ✅
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
const adapter2 = createAdapterFromPrivateKey({
|
|
78
|
+
privateKey: '1234...', // Without prefix ✅ (automatically normalized)
|
|
69
79
|
})
|
|
70
80
|
```
|
|
71
81
|
|
|
@@ -81,6 +91,27 @@ npm install @circle-fin/adapter-ethers-v6 ethers
|
|
|
81
91
|
yarn add @circle-fin/adapter-ethers-v6 ethers
|
|
82
92
|
```
|
|
83
93
|
|
|
94
|
+
## Peer Dependencies
|
|
95
|
+
|
|
96
|
+
This adapter requires `ethers` (v6) as a peer dependency. Install it alongside the adapter:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
npm install @circle-fin/adapter-ethers-v6 ethers
|
|
100
|
+
# or
|
|
101
|
+
yarn add @circle-fin/adapter-ethers-v6 ethers
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Supported Versions:** `^6.11.0` (6.11.x through 6.x.x, excluding 7.x.x)
|
|
105
|
+
|
|
106
|
+
### Troubleshooting Version Conflicts
|
|
107
|
+
|
|
108
|
+
If you encounter peer dependency warnings:
|
|
109
|
+
|
|
110
|
+
- Check your `ethers` version: `npm ls ethers`
|
|
111
|
+
- Ensure ethers v6 is between 6.11.0 and 7.0.0 (exclusive)
|
|
112
|
+
- Use `npm install ethers@^6.11.0` to install a compatible version
|
|
113
|
+
- Note: This adapter is **not** compatible with ethers v5 or v7
|
|
114
|
+
|
|
84
115
|
## Quick Start
|
|
85
116
|
|
|
86
117
|
### Zero-Config Setup (Recommended)
|
|
@@ -91,8 +122,9 @@ The simplest way to get started with lazy initialization. Default configuration
|
|
|
91
122
|
import { createAdapterFromPrivateKey } from '@circle-fin/adapter-ethers-v6'
|
|
92
123
|
|
|
93
124
|
// Minimal configuration with lazy initialization
|
|
125
|
+
// Note: Private keys work with or without '0x' prefix
|
|
94
126
|
const adapter = createAdapterFromPrivateKey({
|
|
95
|
-
privateKey: process.env.PRIVATE_KEY as `0x${string}`,
|
|
127
|
+
privateKey: process.env.PRIVATE_KEY as `0x${string}`, // Both '0x...' and '...' work
|
|
96
128
|
// Defaults applied:
|
|
97
129
|
// - addressContext: 'user-controlled'
|
|
98
130
|
// - supportedChains: all EVM chains (~34 networks)
|
|
@@ -419,18 +451,18 @@ console.log('Permit signature:', signature)
|
|
|
419
451
|
|
|
420
452
|
### Cross-Chain Bridging
|
|
421
453
|
|
|
422
|
-
**Bridge USDC** using the
|
|
454
|
+
**Bridge USDC** using the Bridge Kit with OperationContext:
|
|
423
455
|
|
|
424
456
|
```typescript
|
|
425
457
|
import { createAdapterFromPrivateKey } from '@circle-fin/adapter-ethers-v6'
|
|
426
|
-
import {
|
|
458
|
+
import { BridgeKit } from '@circle-fin/bridge-kit'
|
|
427
459
|
|
|
428
460
|
// Create adapter for multi-chain operations
|
|
429
461
|
const adapter = createAdapterFromPrivateKey({
|
|
430
462
|
privateKey: process.env.PRIVATE_KEY as `0x${string}`,
|
|
431
463
|
})
|
|
432
464
|
|
|
433
|
-
const kit = new
|
|
465
|
+
const kit = new BridgeKit()
|
|
434
466
|
|
|
435
467
|
// Bridge from Ethereum to Base using the same adapter
|
|
436
468
|
const result = await kit.bridge({
|
|
@@ -548,12 +580,6 @@ Gets the connected wallet address. Chain parameter is provided automatically by
|
|
|
548
580
|
|
|
549
581
|
**Returns:** `Promise<string>` - Wallet address
|
|
550
582
|
|
|
551
|
-
#### `getChain()`
|
|
552
|
-
|
|
553
|
-
**Deprecated** - Use OperationContext pattern instead. Gets the current chain definition.
|
|
554
|
-
|
|
555
|
-
**Returns:** `Promise<ChainDefinition>`
|
|
556
|
-
|
|
557
583
|
### Token Operations
|
|
558
584
|
|
|
559
585
|
Built-in token operations using the action system:
|