@circle-fin/adapter-ethers-v6 1.1.1 → 1.3.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.
Files changed (6) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +25 -25
  3. package/index.cjs +3673 -3050
  4. package/index.d.ts +379 -62
  5. package/index.mjs +3672 -3051
  6. package/package.json +16 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # @circle-fin/adapter-ethers-v6
2
2
 
3
+ ## 1.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Add `native.balanceOf` action to query native token balances (ETH, SOL, etc.)
8
+ - Added `NativeActionMap` with `balanceOf` action to check native token balance for any wallet address
9
+ - Added abstract `readNativeBalance(address, chain)` method to base adapters
10
+ - Implemented `readNativeBalance` in all concrete adapters (Viem, Ethers, Solana, SolanaKit)
11
+ - Registered `native.balanceOf` action handlers for EVM and Solana chains
12
+ - Balance reads are gas-free operations returning balance as string (wei for EVM, lamports for Solana)
13
+
14
+ ### Patch Changes
15
+
16
+ - **Faster balance and allowance checks**: Read-only operations like checking token balances or allowances no longer require wallet network switching. This means no wallet popups asking for permission to switch networks, resulting in quicker responses and a smoother user experience.
17
+
18
+ ## 1.2.0
19
+
20
+ ### Minor Changes
21
+
22
+ - Clearer ethers factory names eliminate aliasing when using multiple adapters. Prefer `createEthersAdapterFromProvider` and `createEthersAdapterFromPrivateKey` over the deprecated generic `createAdapterFromProvider` and `createAdapterFromPrivateKey`. Existing code works unchanged.
23
+
24
+ ### Patch Changes
25
+
26
+ - Validation errors now use standardized error codes for consistent error handling. All validation failures return the same `KitError` structure as other SDK errors.
27
+
28
+ **Migration:** If you're catching validation errors, update your error handling:
29
+ - Check `error.code === 1098` instead of `instanceof ValidationError`
30
+ - Access details via `error.cause?.trace?.validationErrors` instead of `error.errors`
31
+
32
+ The legacy `ValidationError` class remains available for backward compatibility.
33
+
34
+ - Fixed an issue where custom RPC URLs were not fully respected in Ethers adapter, ensuring users can now properly configure alternative RPC endpoints.
35
+ - Fixed unnecessary chain switching in EthersAdapter that was causing redundant provider reconnections and wallet prompts. The adapter now checks the current chain ID before attempting to switch, skipping the operation when already on the target chain. This improves performance for dev-controlled wallets and reduces unnecessary wallet prompts for browser users (MetaMask, WalletConnect, etc.) when performing multiple operations on the same chain.
36
+
3
37
  ## 1.1.1
4
38
 
5
39
  ### Patch Changes
package/README.md CHANGED
@@ -41,8 +41,8 @@ _Seamlessly interact with 16+ EVM networks using a single, strongly-typed interf
41
41
  - [Cross-Chain Bridging](#cross-chain-bridging)
42
42
  - [API Reference](#api-reference)
43
43
  - [Factory Functions](#factory-functions)
44
- - [`createAdapterFromPrivateKey(params)`](#createadapterfromprivatekeyparams)
45
- - [`createAdapterFromProvider(params)`](#createadapterfromproviderparams)
44
+ - [`createEthersAdapterFromPrivateKey(params)`](#createethersadapterfromprivatekeyparams)
45
+ - [`createEthersAdapterFromProvider(params)`](#createethersadapterfromproviderparams)
46
46
  - [Core Methods](#core-methods)
47
47
  - [`prepare(params, ctx)`](#prepareparams-ctx)
48
48
  - [`signTypedData(typedData, ctx)`](#signtypeddatatypeddata-ctx)
@@ -77,16 +77,16 @@ If you're using the Bridge Kit or other Stablecoin Kits for cross-chain operatio
77
77
  ```typescript
78
78
  // Single adapter instance for multi-chain operations
79
79
  // Note: Private keys can be provided with or without '0x' prefix
80
- const adapter = createAdapterFromPrivateKey({
80
+ const adapter = createEthersAdapterFromPrivateKey({
81
81
  privateKey: process.env.PRIVATE_KEY as `0x${string}`, // Both '0x...' and '...' work
82
82
  })
83
83
 
84
84
  // Both formats are automatically normalized:
85
- const adapter1 = createAdapterFromPrivateKey({
85
+ const adapter1 = createEthersAdapterFromPrivateKey({
86
86
  privateKey: '0x1234...', // With prefix ✅
87
87
  })
88
88
 
89
- const adapter2 = createAdapterFromPrivateKey({
89
+ const adapter2 = createEthersAdapterFromPrivateKey({
90
90
  privateKey: '1234...', // Without prefix ✅ (automatically normalized)
91
91
  })
92
92
  ```
@@ -131,11 +131,11 @@ If you encounter peer dependency warnings:
131
131
  The simplest way to get started with lazy initialization. Default configuration handles adapter setup automatically.
132
132
 
133
133
  ```typescript
134
- import { createAdapterFromPrivateKey } from '@circle-fin/adapter-ethers-v6'
134
+ import { createEthersAdapterFromPrivateKey } from '@circle-fin/adapter-ethers-v6'
135
135
 
136
136
  // Minimal configuration with lazy initialization
137
137
  // Note: Private keys work with or without '0x' prefix
138
- const adapter = createAdapterFromPrivateKey({
138
+ const adapter = createEthersAdapterFromPrivateKey({
139
139
  privateKey: process.env.PRIVATE_KEY as `0x${string}`, // Both '0x...' and '...' work
140
140
  // Defaults applied:
141
141
  // - addressContext: 'user-controlled'
@@ -162,12 +162,12 @@ const txHash = await prepared.execute()
162
162
  For production use, provide custom RPC endpoints for better reliability and performance:
163
163
 
164
164
  ```typescript
165
- import { createAdapterFromPrivateKey } from '@circle-fin/adapter-ethers-v6'
165
+ import { createEthersAdapterFromPrivateKey } from '@circle-fin/adapter-ethers-v6'
166
166
  import { JsonRpcProvider } from 'ethers'
167
167
  import { Ethereum, Base, Polygon } from '@core/chains'
168
168
 
169
169
  // Production-ready with custom RPC endpoints and lazy initialization
170
- const adapter = createAdapterFromPrivateKey({
170
+ const adapter = createEthersAdapterFromPrivateKey({
171
171
  privateKey: process.env.PRIVATE_KEY as `0x${string}`,
172
172
  // Custom RPC provider with explicit chain mapping
173
173
  getProvider: ({ chain }) => {
@@ -200,10 +200,10 @@ const adapter = createAdapterFromPrivateKey({
200
200
  For browser environments with MetaMask or WalletConnect:
201
201
 
202
202
  ```typescript
203
- import { createAdapterFromProvider } from '@circle-fin/adapter-ethers-v6'
203
+ import { createEthersAdapterFromProvider } from '@circle-fin/adapter-ethers-v6'
204
204
 
205
205
  // Minimal browser wallet configuration
206
- const adapter = await createAdapterFromProvider({
206
+ const adapter = await createEthersAdapterFromProvider({
207
207
  provider: window.ethereum,
208
208
  // Default capabilities applied automatically
209
209
  })
@@ -239,10 +239,10 @@ The OperationContext pattern is the modern approach for multi-chain operations.
239
239
  Every operation accepts an `OperationContext` parameter that specifies the chain:
240
240
 
241
241
  ```typescript
242
- import { createAdapterFromPrivateKey } from '@circle-fin/adapter-ethers-v6'
242
+ import { createEthersAdapterFromPrivateKey } from '@circle-fin/adapter-ethers-v6'
243
243
 
244
244
  // Create adapter without specifying a chain - true lazy initialization
245
- const adapter = createAdapterFromPrivateKey({
245
+ const adapter = createEthersAdapterFromPrivateKey({
246
246
  privateKey: process.env.PRIVATE_KEY as `0x${string}`,
247
247
  })
248
248
 
@@ -267,7 +267,7 @@ Use a single adapter instance for operations across multiple chains:
267
267
 
268
268
  ```typescript
269
269
  // Create adapter once for use across multiple chains
270
- const adapter = createAdapterFromPrivateKey({
270
+ const adapter = createEthersAdapterFromPrivateKey({
271
271
  privateKey: process.env.PRIVATE_KEY as `0x${string}`,
272
272
  })
273
273
 
@@ -317,7 +317,7 @@ The adapter supports two address control patterns. Choose the one that fits your
317
317
 
318
318
  ```typescript
319
319
  // User-controlled adapter (default for factory functions)
320
- const adapter = createAdapterFromPrivateKey({
320
+ const adapter = createEthersAdapterFromPrivateKey({
321
321
  privateKey: process.env.PRIVATE_KEY as `0x${string}`,
322
322
  // addressContext: 'user-controlled' is the default
323
323
  })
@@ -385,11 +385,11 @@ const prepared = await adapter.prepare(
385
385
  **Transfer USDC** across different chains with the same adapter:
386
386
 
387
387
  ```typescript
388
- import { createAdapterFromPrivateKey } from '@circle-fin/adapter-ethers-v6'
388
+ import { createEthersAdapterFromPrivateKey } from '@circle-fin/adapter-ethers-v6'
389
389
  import { parseAbi } from 'ethers'
390
390
 
391
391
  // Create adapter with lazy initialization
392
- const adapter = createAdapterFromPrivateKey({
392
+ const adapter = createEthersAdapterFromPrivateKey({
393
393
  privateKey: process.env.PRIVATE_KEY as `0x${string}`,
394
394
  })
395
395
 
@@ -421,9 +421,9 @@ console.log('Transaction hash:', txHash)
421
421
  **Sign permit approvals** for gasless token approvals:
422
422
 
423
423
  ```typescript
424
- import { createAdapterFromPrivateKey } from '@circle-fin/adapter-ethers-v6'
424
+ import { createEthersAdapterFromPrivateKey } from '@circle-fin/adapter-ethers-v6'
425
425
 
426
- const adapter = createAdapterFromPrivateKey({
426
+ const adapter = createEthersAdapterFromPrivateKey({
427
427
  privateKey: process.env.PRIVATE_KEY as `0x${string}`,
428
428
  })
429
429
 
@@ -466,11 +466,11 @@ console.log('Permit signature:', signature)
466
466
  **Bridge USDC** using the Bridge Kit with OperationContext:
467
467
 
468
468
  ```typescript
469
- import { createAdapterFromPrivateKey } from '@circle-fin/adapter-ethers-v6'
469
+ import { createEthersAdapterFromPrivateKey } from '@circle-fin/adapter-ethers-v6'
470
470
  import { BridgeKit } from '@circle-fin/bridge-kit'
471
471
 
472
472
  // Create adapter for multi-chain operations
473
- const adapter = createAdapterFromPrivateKey({
473
+ const adapter = createEthersAdapterFromPrivateKey({
474
474
  privateKey: process.env.PRIVATE_KEY as `0x${string}`,
475
475
  })
476
476
 
@@ -491,7 +491,7 @@ console.log('Bridge transaction:', result.transactionHash)
491
491
 
492
492
  ### Factory Functions
493
493
 
494
- #### `createAdapterFromPrivateKey(params)`
494
+ #### `createEthersAdapterFromPrivateKey(params)`
495
495
 
496
496
  Creates an adapter from a private key for server-side use.
497
497
 
@@ -506,12 +506,12 @@ Creates an adapter from a private key for server-side use.
506
506
  **Note:** No chain required at creation time. The adapter connects to chains lazily on first operation.
507
507
 
508
508
  ```typescript
509
- const adapter = createAdapterFromPrivateKey({
509
+ const adapter = createEthersAdapterFromPrivateKey({
510
510
  privateKey: '0x...',
511
511
  })
512
512
  ```
513
513
 
514
- #### `createAdapterFromProvider(params)`
514
+ #### `createEthersAdapterFromProvider(params)`
515
515
 
516
516
  Creates an adapter from a browser wallet provider (MetaMask, WalletConnect, etc.).
517
517
 
@@ -524,7 +524,7 @@ Creates an adapter from a browser wallet provider (MetaMask, WalletConnect, etc.
524
524
  **Returns:** `Promise<EthersAdapter>` instance
525
525
 
526
526
  ```typescript
527
- const adapter = await createAdapterFromProvider({
527
+ const adapter = await createEthersAdapterFromProvider({
528
528
  provider: window.ethereum,
529
529
  })
530
530
  ```