@circle-fin/adapter-ethers-v6 0.0.2-alpha.7 → 1.0.1
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 +457 -252
- package/index.d.ts +276 -97
- package/index.mjs +396 -194
- package/package.json +6 -4
package/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import { Provider, Signer as Signer$1, Eip1193Provider } from 'ethers';
|
|
20
|
+
export { JsonRpcProvider } from 'ethers';
|
|
20
21
|
import { Abi } from 'abitype';
|
|
21
22
|
import { TransactionInstruction, Signer } from '@solana/web3.js';
|
|
22
23
|
|
|
@@ -409,6 +410,7 @@ declare enum Blockchain {
|
|
|
409
410
|
Algorand_Testnet = "Algorand_Testnet",
|
|
410
411
|
Aptos = "Aptos",
|
|
411
412
|
Aptos_Testnet = "Aptos_Testnet",
|
|
413
|
+
Arc_Testnet = "Arc_Testnet",
|
|
412
414
|
Arbitrum = "Arbitrum",
|
|
413
415
|
Arbitrum_Sepolia = "Arbitrum_Sepolia",
|
|
414
416
|
Avalanche = "Avalanche",
|
|
@@ -1168,6 +1170,14 @@ interface CCTPv2ActionMap {
|
|
|
1168
1170
|
* Destination chain definition where tokens will be minted.
|
|
1169
1171
|
*/
|
|
1170
1172
|
readonly toChain: ChainDefinitionWithCCTPv2;
|
|
1173
|
+
/**
|
|
1174
|
+
* Optional destination wallet address on the destination chain to receive minted USDC.
|
|
1175
|
+
*
|
|
1176
|
+
* When provided (e.g., for Solana), the mint instruction will derive the
|
|
1177
|
+
* recipient's Associated Token Account (ATA) from this address instead of
|
|
1178
|
+
* the adapter's default address.
|
|
1179
|
+
*/
|
|
1180
|
+
readonly destinationAddress?: string;
|
|
1171
1181
|
};
|
|
1172
1182
|
/**
|
|
1173
1183
|
* Initiate a cross-chain USDC transfer using a custom bridge contract with preapproval funnel.
|
|
@@ -1525,7 +1535,7 @@ interface USDCActionMap {
|
|
|
1525
1535
|
/**
|
|
1526
1536
|
* Central registry of all available action namespaces and their operations.
|
|
1527
1537
|
*
|
|
1528
|
-
* Define the complete action map structure used throughout the
|
|
1538
|
+
* Define the complete action map structure used throughout the bridge kit.
|
|
1529
1539
|
* Each top-level key represents a namespace (e.g., 'token', 'usdc') containing
|
|
1530
1540
|
* related operations. The structure supports arbitrary nesting depth through
|
|
1531
1541
|
* the recursive utility types provided in this module.
|
|
@@ -1618,7 +1628,7 @@ type NestedValue<T, K extends string> = K extends `${infer First}.${infer Rest}`
|
|
|
1618
1628
|
*
|
|
1619
1629
|
* @remarks
|
|
1620
1630
|
* This type serves as the canonical source for all valid action identifiers
|
|
1621
|
-
* in the
|
|
1631
|
+
* in the bridge kit. It ensures compile-time validation of action keys
|
|
1622
1632
|
* and enables type-safe action dispatching throughout the application.
|
|
1623
1633
|
*
|
|
1624
1634
|
* @see {@link ActionPayload} for extracting parameter types
|
|
@@ -1987,26 +1997,6 @@ declare abstract class Adapter<TAdapterCapabilities extends AdapterCapabilities
|
|
|
1987
1997
|
* ```
|
|
1988
1998
|
*/
|
|
1989
1999
|
capabilities?: TAdapterCapabilities;
|
|
1990
|
-
/**
|
|
1991
|
-
* Default chain for operations when none is explicitly provided.
|
|
1992
|
-
*
|
|
1993
|
-
* This allows adapters to have sensible defaults for chain operations,
|
|
1994
|
-
* reducing the need for explicit chain specification in every call.
|
|
1995
|
-
*
|
|
1996
|
-
* @remarks
|
|
1997
|
-
* This is optional for backward compatibility and because some adapter types
|
|
1998
|
-
* (like developer-controlled adapters) may not have meaningful defaults.
|
|
1999
|
-
*
|
|
2000
|
-
* @example
|
|
2001
|
-
* ```typescript
|
|
2002
|
-
* // User-controlled adapter with default chain
|
|
2003
|
-
* defaultChain = Ethereum
|
|
2004
|
-
*
|
|
2005
|
-
* // Developer-controlled adapter (no default)
|
|
2006
|
-
* defaultChain = undefined
|
|
2007
|
-
* ```
|
|
2008
|
-
*/
|
|
2009
|
-
defaultChain?: ChainDefinition;
|
|
2010
2000
|
/**
|
|
2011
2001
|
* Registry of available actions for this adapter.
|
|
2012
2002
|
*
|
|
@@ -2120,16 +2110,6 @@ declare abstract class Adapter<TAdapterCapabilities extends AdapterCapabilities
|
|
|
2120
2110
|
* @returns A promise that resolves to the blockchain address as a string.
|
|
2121
2111
|
*/
|
|
2122
2112
|
abstract getAddress(chain?: ChainDefinition): Promise<string>;
|
|
2123
|
-
/**
|
|
2124
|
-
* Retrieves the {@link ChainDefinition} object that describes the blockchain
|
|
2125
|
-
* this adapter is configured to interact with.
|
|
2126
|
-
*
|
|
2127
|
-
* This includes information such as the chain ID, name, native currency, etc.,
|
|
2128
|
-
* as defined by the `ChainDefinition` type.
|
|
2129
|
-
*
|
|
2130
|
-
* @returns A promise that resolves to the {@link ChainDefinition} for the current chain.
|
|
2131
|
-
*/
|
|
2132
|
-
abstract getChain(): Promise<ChainDefinition>;
|
|
2133
2113
|
/**
|
|
2134
2114
|
* Switches the adapter to operate on the specified chain.
|
|
2135
2115
|
*
|
|
@@ -2174,17 +2154,14 @@ declare abstract class Adapter<TAdapterCapabilities extends AdapterCapabilities
|
|
|
2174
2154
|
* - **Browser wallet adapters**: Request chain switch via EIP-1193 or equivalent
|
|
2175
2155
|
* - **Multi-entity adapters**: Validate chain support (operations are contextual)
|
|
2176
2156
|
*
|
|
2177
|
-
* @param chain - The target chain for operations.
|
|
2157
|
+
* @param chain - The target chain for operations.
|
|
2178
2158
|
* @returns A promise that resolves when the adapter is operating on the specified chain.
|
|
2179
2159
|
* @throws When the target chain is not supported or chain switching fails.
|
|
2180
2160
|
*
|
|
2181
2161
|
* @remarks
|
|
2182
|
-
* This method
|
|
2183
|
-
*
|
|
2184
|
-
*
|
|
2185
|
-
* **Backward Compatibility**: The default implementation provides basic validation but
|
|
2186
|
-
* doesn't perform actual chain switching. Concrete adapter implementations should override
|
|
2187
|
-
* this method to provide proper chain switching logic.
|
|
2162
|
+
* This method always calls `switchToChain()` to ensure consistency across all adapter types.
|
|
2163
|
+
* The underlying implementations handle idempotent switching efficiently (e.g., browser wallets
|
|
2164
|
+
* gracefully handle switching to the current chain, private key adapters recreate lightweight clients).
|
|
2188
2165
|
*
|
|
2189
2166
|
* @example
|
|
2190
2167
|
* ```typescript
|
|
@@ -2198,7 +2175,7 @@ declare abstract class Adapter<TAdapterCapabilities extends AdapterCapabilities
|
|
|
2198
2175
|
* await circleWalletsAdapter.ensureChain(Ethereum)
|
|
2199
2176
|
* ```
|
|
2200
2177
|
*/
|
|
2201
|
-
ensureChain(
|
|
2178
|
+
ensureChain(targetChain: ChainDefinition): Promise<void>;
|
|
2202
2179
|
/**
|
|
2203
2180
|
* Validate that the target chain is supported by this adapter.
|
|
2204
2181
|
*
|
|
@@ -2320,6 +2297,127 @@ interface TypedData<Types extends Record<string, TypedDataField[]>, Message exte
|
|
|
2320
2297
|
/** The message payload to be signed */
|
|
2321
2298
|
message: Message;
|
|
2322
2299
|
}
|
|
2300
|
+
/**
|
|
2301
|
+
* Standard ECDSA signature format (r, s, v components).
|
|
2302
|
+
*
|
|
2303
|
+
* Used for all EIP-712 and permit/authorization signatures.
|
|
2304
|
+
*
|
|
2305
|
+
* @example
|
|
2306
|
+
* ```typescript
|
|
2307
|
+
* const sig: Signature = { v: 28, r: "0x...", s: "0x..." }
|
|
2308
|
+
* ```
|
|
2309
|
+
*/
|
|
2310
|
+
interface Signature {
|
|
2311
|
+
/** Recovery identifier (27 or 28) */
|
|
2312
|
+
v: number;
|
|
2313
|
+
/** ECDSA signature r value (32-byte hex string) */
|
|
2314
|
+
r: `0x${string}`;
|
|
2315
|
+
/** ECDSA signature s value (32-byte hex string) */
|
|
2316
|
+
s: `0x${string}`;
|
|
2317
|
+
}
|
|
2318
|
+
declare const PERMIT_STANDARDS: readonly ["EIP-2612"];
|
|
2319
|
+
type KnownPermitStandard = (typeof PERMIT_STANDARDS)[number];
|
|
2320
|
+
/**
|
|
2321
|
+
* Supported permit/authorization standards for cross-chain USDC.
|
|
2322
|
+
*
|
|
2323
|
+
* Extend this union as new standards are supported.
|
|
2324
|
+
*/
|
|
2325
|
+
type PermitStandardName = KnownPermitStandard
|
|
2326
|
+
/**
|
|
2327
|
+
* Branded string type to keep this union from collapsing into plain `string`.
|
|
2328
|
+
* This lets TS/your IDE still offer autocomplete for the known literals
|
|
2329
|
+
* while allowing any other string without casting.
|
|
2330
|
+
*/
|
|
2331
|
+
| (string & {
|
|
2332
|
+
readonly __brand?: 'PermitStandardName';
|
|
2333
|
+
});
|
|
2334
|
+
/**
|
|
2335
|
+
* Metadata required to construct an EIP-712 domain.
|
|
2336
|
+
*
|
|
2337
|
+
* Used as input to typed data builders for various standards.
|
|
2338
|
+
*
|
|
2339
|
+
* @example
|
|
2340
|
+
* ```typescript
|
|
2341
|
+
* const meta: DomainMeta = {
|
|
2342
|
+
* name: "USD Coin",
|
|
2343
|
+
* version: "2",
|
|
2344
|
+
* chainId: 1,
|
|
2345
|
+
* verifyingContract: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
|
|
2346
|
+
* }
|
|
2347
|
+
* ```
|
|
2348
|
+
*/
|
|
2349
|
+
interface DomainMeta {
|
|
2350
|
+
/** Human-readable name of the signing domain */
|
|
2351
|
+
name: string;
|
|
2352
|
+
/** Current major version of the signing domain */
|
|
2353
|
+
version: string;
|
|
2354
|
+
/** EVM chain ID */
|
|
2355
|
+
chainId: number | bigint;
|
|
2356
|
+
/** Address of the verifying contract */
|
|
2357
|
+
verifyingContract: `0x${string}`;
|
|
2358
|
+
}
|
|
2359
|
+
|
|
2360
|
+
/**
|
|
2361
|
+
* Utility module for handling ECDSA signatures and EIP-712 typed data.
|
|
2362
|
+
*
|
|
2363
|
+
* This file provides:
|
|
2364
|
+
* 1. parseSignature: Take a raw hexadecimal signature and split it into its three
|
|
2365
|
+
* ECDSA components: r, s, and v (recovery identifier). Used when verifying
|
|
2366
|
+
* Ethereum transactions and signed messages.
|
|
2367
|
+
*
|
|
2368
|
+
* 2. buildTypedData: Assemble a data structure compliant with EIP-712, which standardizes
|
|
2369
|
+
* how structured data is formatted and hashed for secure off-chain signing.
|
|
2370
|
+
*
|
|
2371
|
+
* Key concepts:
|
|
2372
|
+
* - Cryptographic signatures (r, s, v) ensure that only the holder of a private key can
|
|
2373
|
+
* authorize actions or sign messages. The 'v' component enables recovering the public key
|
|
2374
|
+
* from the signature, confirming the signer’s identity.
|
|
2375
|
+
* - EIP-712 typed data enforces a clear schema for signing, preventing ambiguous or replayable
|
|
2376
|
+
* signatures and simplifying integration with common wallet libraries.
|
|
2377
|
+
*/
|
|
2378
|
+
|
|
2379
|
+
/**
|
|
2380
|
+
* parseSignature
|
|
2381
|
+
*
|
|
2382
|
+
* Parse a 65-byte ECDSA signature into its r, s, and v components, expressed in hex.
|
|
2383
|
+
*
|
|
2384
|
+
* Ethereum signatures are structured as:
|
|
2385
|
+
* signature = r (32 bytes) || s (32 bytes) || v (1 byte)
|
|
2386
|
+
*
|
|
2387
|
+
* - r, s: Big-endian hex values (32 bytes each)
|
|
2388
|
+
* - v: Recovery identifier, used by secp256k1 to reconstruct the signer’s public key
|
|
2389
|
+
*
|
|
2390
|
+
* @param signatureHex - Signature as a hex string, optionally prefixed with "0x".
|
|
2391
|
+
* @returns { r, s, v }
|
|
2392
|
+
* - r: Hex string of the R component.
|
|
2393
|
+
* - s: Hex string of the S component.
|
|
2394
|
+
* - v: Numeric recovery ID.
|
|
2395
|
+
*
|
|
2396
|
+
* @throws Error if:
|
|
2397
|
+
* - Input is not valid hex.
|
|
2398
|
+
* - Incorrect length (must be exactly 65 bytes / 130 hex chars).
|
|
2399
|
+
* - v is outside the supported range (Legacy or EIP-155 formula).
|
|
2400
|
+
*
|
|
2401
|
+
* Notes on EIP-155 overload:
|
|
2402
|
+
* EIP-155 repurposes the v field so that:
|
|
2403
|
+
* v = 35 + (2 * chainId) + recoveryId(0 or 1)
|
|
2404
|
+
* Any v value >= 35 indicates the chain-id is encoded, preventing cross-chain replay.
|
|
2405
|
+
* r and s values remain unchanged.
|
|
2406
|
+
*
|
|
2407
|
+
* Example:
|
|
2408
|
+
* ```typescript
|
|
2409
|
+
* const rawSig = '0x6c1b...f02b'
|
|
2410
|
+
* try {
|
|
2411
|
+
* const { r, s, v } = parseSignature(rawSig)
|
|
2412
|
+
* console.log('R:', r)
|
|
2413
|
+
* console.log('S:', s)
|
|
2414
|
+
* console.log('Recovery ID (v):', v)
|
|
2415
|
+
* } catch (err) {
|
|
2416
|
+
* console.error('Signature parse error:', err.message)
|
|
2417
|
+
* }
|
|
2418
|
+
* ```
|
|
2419
|
+
*/
|
|
2420
|
+
declare function parseSignature(signatureHex: string): Signature;
|
|
2323
2421
|
|
|
2324
2422
|
/**
|
|
2325
2423
|
* Core type definitions for EVM-compatible blockchain transaction execution
|
|
@@ -2386,19 +2484,6 @@ declare abstract class EvmAdapter<TAdapterCapabilities extends AdapterCapabiliti
|
|
|
2386
2484
|
* The type of chain this adapter is for.
|
|
2387
2485
|
*/
|
|
2388
2486
|
chainType: ChainType;
|
|
2389
|
-
/**
|
|
2390
|
-
* Cached EVM chain definition.
|
|
2391
|
-
*
|
|
2392
|
-
* This property holds the most recently synchronized EVM chain definition for the adapter.
|
|
2393
|
-
* It is automatically set by `getChain()` and updated via `syncChain()` when provider events
|
|
2394
|
-
* (such as wallet chain changes) are detected. Setting this property to `undefined` clears
|
|
2395
|
-
* the cached chain, which is useful when resetting adapter state or handling disconnects.
|
|
2396
|
-
*
|
|
2397
|
-
* @remarks
|
|
2398
|
-
* This property narrows the base Adapter's `cachedChain` to the EVM-specific type,
|
|
2399
|
-
* ensuring type safety for EVM operations and consumers.
|
|
2400
|
-
*/
|
|
2401
|
-
cachedChain?: EVMChainDefinition;
|
|
2402
2487
|
/**
|
|
2403
2488
|
* Cached gas price for the current network.
|
|
2404
2489
|
*/
|
|
@@ -2513,6 +2598,129 @@ declare abstract class EvmAdapter<TAdapterCapabilities extends AdapterCapabiliti
|
|
|
2513
2598
|
calculateTransactionFee(baseComputeUnits: bigint, bufferBasisPoints: bigint | undefined, chain: EVMChainDefinition): Promise<EstimatedGas>;
|
|
2514
2599
|
}
|
|
2515
2600
|
|
|
2601
|
+
/**
|
|
2602
|
+
* EIP-2612 permit type definition.
|
|
2603
|
+
* Defines the structure for permit signatures according to EIP-2612 specification.
|
|
2604
|
+
*
|
|
2605
|
+
* @see {@link https://eips.ethereum.org/EIPS/eip-2612 | EIP-2612 Specification}
|
|
2606
|
+
*/
|
|
2607
|
+
declare const EIP2612_TYPES: {
|
|
2608
|
+
readonly Permit: TypedDataField[];
|
|
2609
|
+
};
|
|
2610
|
+
/**
|
|
2611
|
+
* EIP-2612 permit message structure.
|
|
2612
|
+
* This is the exact data that gets signed according to EIP-2612.
|
|
2613
|
+
*/
|
|
2614
|
+
interface EIP2612Message extends Record<string, unknown> {
|
|
2615
|
+
/** Token owner address */
|
|
2616
|
+
owner: `0x${string}`;
|
|
2617
|
+
/** Address permitted to spend tokens */
|
|
2618
|
+
spender: `0x${string}`;
|
|
2619
|
+
/** Amount of tokens permitted */
|
|
2620
|
+
value: bigint;
|
|
2621
|
+
/** Current nonce for the owner */
|
|
2622
|
+
nonce: bigint;
|
|
2623
|
+
/** Deadline timestamp (Unix timestamp in seconds) */
|
|
2624
|
+
deadline: bigint;
|
|
2625
|
+
}
|
|
2626
|
+
/**
|
|
2627
|
+
* Input options for building an EIP-2612 permit.
|
|
2628
|
+
* Nonce and deadline can be omitted and will be fetched/computed automatically.
|
|
2629
|
+
*
|
|
2630
|
+
* **Address Formatting**: Addresses are automatically formatted with proper EIP-55
|
|
2631
|
+
* checksumming, so you can provide addresses in any case format.
|
|
2632
|
+
*/
|
|
2633
|
+
interface EIP2612Options extends Record<string, unknown> {
|
|
2634
|
+
/** Token owner address (automatically formatted with EIP-55 checksumming) */
|
|
2635
|
+
owner: `0x${string}`;
|
|
2636
|
+
/** Address that will be permitted to spend tokens (automatically formatted with EIP-55 checksumming) */
|
|
2637
|
+
spender: `0x${string}`;
|
|
2638
|
+
/** Amount of tokens to permit */
|
|
2639
|
+
value: bigint;
|
|
2640
|
+
/** Optional nonce - will be fetched from token contract if not provided */
|
|
2641
|
+
nonce?: bigint;
|
|
2642
|
+
/** Optional deadline - will default to 1 hour from now if not provided */
|
|
2643
|
+
deadline?: bigint;
|
|
2644
|
+
}
|
|
2645
|
+
/**
|
|
2646
|
+
* Function type for fetching nonces from EIP-2612 compatible tokens.
|
|
2647
|
+
*
|
|
2648
|
+
* @param owner - Token owner address
|
|
2649
|
+
* @param token - Token contract address
|
|
2650
|
+
* @returns Promise resolving to current nonce
|
|
2651
|
+
*/
|
|
2652
|
+
type EIP2612NonceFetcher = (token: `0x${string}`, owner: `0x${string}`) => Promise<bigint>;
|
|
2653
|
+
|
|
2654
|
+
interface EIP2612Adapter {
|
|
2655
|
+
fetchEIP2612Nonce(tokenAddress: `0x${string}`, ownerAddress: `0x${string}`, ctx: OperationContext): Promise<bigint>;
|
|
2656
|
+
}
|
|
2657
|
+
/**
|
|
2658
|
+
* Build EIP-2612 typed data for permit signing.
|
|
2659
|
+
*
|
|
2660
|
+
* This function creates the complete EIP-712 typed data structure required
|
|
2661
|
+
* for EIP-2612 permit signatures, including automatic nonce fetching using
|
|
2662
|
+
* the adapter's built-in nonce fetching capability.
|
|
2663
|
+
*
|
|
2664
|
+
* **Address Formatting**: All addresses are automatically formatted with proper
|
|
2665
|
+
* EIP-55 checksumming using the `convertAddress` utility, ensuring compatibility
|
|
2666
|
+
* with strict validation libraries like viem.
|
|
2667
|
+
*
|
|
2668
|
+
* **Nonce Handling**: The nonce can be provided explicitly or will be fetched
|
|
2669
|
+
* automatically using the adapter's `fetchEIP2612Nonce` method, which queries
|
|
2670
|
+
* the token contract's `nonces(owner)` function.
|
|
2671
|
+
*
|
|
2672
|
+
* **Deadline Calculation**: If no deadline is provided, it defaults to 24 hours
|
|
2673
|
+
* from the current time (computed using `computeDefaultDeadline`).
|
|
2674
|
+
*
|
|
2675
|
+
* @param meta - Domain metadata for the token contract
|
|
2676
|
+
* @param adapter - Adapter instance with nonce-fetching capability
|
|
2677
|
+
* @param opts - EIP-2612 permit options including owner, spender, value
|
|
2678
|
+
* @returns Complete EIP-712 typed data ready for signing
|
|
2679
|
+
*
|
|
2680
|
+
* @example
|
|
2681
|
+
* ```typescript
|
|
2682
|
+
* import { buildEIP2612TypedData } from '@core/adapter-evm'
|
|
2683
|
+
*
|
|
2684
|
+
* const typedData = await buildEIP2612TypedData(
|
|
2685
|
+
* {
|
|
2686
|
+
* name: 'USD Coin',
|
|
2687
|
+
* version: '2',
|
|
2688
|
+
* chainId: 1,
|
|
2689
|
+
* verifyingContract: '0xa0b86a33e6441e4d178bb0c14ce0e9ce9c83bdd8'
|
|
2690
|
+
* },
|
|
2691
|
+
* adapter,
|
|
2692
|
+
* {
|
|
2693
|
+
* owner: '0x742d35cc6639c0532fbe9002b3a2265ca4c878f8e',
|
|
2694
|
+
* spender: '0x1234567890123456789012345678901234567890',
|
|
2695
|
+
* value: 1000000n
|
|
2696
|
+
* }
|
|
2697
|
+
* )
|
|
2698
|
+
*
|
|
2699
|
+
* const signature = await adapter.signTypedData(typedData)
|
|
2700
|
+
* ```
|
|
2701
|
+
*/
|
|
2702
|
+
declare function buildEIP2612TypedData(meta: DomainMeta, adapter: EIP2612Adapter, opts: EIP2612Options, ctx: OperationContext): Promise<TypedData<typeof EIP2612_TYPES, EIP2612Message>>;
|
|
2703
|
+
|
|
2704
|
+
/**
|
|
2705
|
+
* Compute default deadline for permit signatures.
|
|
2706
|
+
*
|
|
2707
|
+
* Returns a timestamp 1 hour (3600 seconds) from the current time,
|
|
2708
|
+
* converted to Unix timestamp format as a bigint. This is commonly
|
|
2709
|
+
* used as the default expiration time for EIP-2612 permit signatures.
|
|
2710
|
+
*
|
|
2711
|
+
* @returns Unix timestamp (in seconds) 1 hour from now as a bigint
|
|
2712
|
+
*
|
|
2713
|
+
* @example
|
|
2714
|
+
* ```typescript
|
|
2715
|
+
* import { computeDefaultDeadline } from '@core/adapter-evm'
|
|
2716
|
+
*
|
|
2717
|
+
* const deadline = computeDefaultDeadline()
|
|
2718
|
+
* console.log(`Permit expires at: ${deadline}`)
|
|
2719
|
+
* // Output: Permit expires at: 1640998800
|
|
2720
|
+
* ```
|
|
2721
|
+
*/
|
|
2722
|
+
declare function computeDefaultDeadline(): bigint;
|
|
2723
|
+
|
|
2516
2724
|
/**
|
|
2517
2725
|
* @packageDocumentation
|
|
2518
2726
|
* @module EthersAdapter
|
|
@@ -2858,37 +3066,6 @@ declare class EthersAdapter<TAdapterCapabilities extends AdapterCapabilities = A
|
|
|
2858
3066
|
* ```
|
|
2859
3067
|
*/
|
|
2860
3068
|
getAddress(chain?: EVMChainDefinition): Promise<string>;
|
|
2861
|
-
/**
|
|
2862
|
-
* Gets the current chain definition.
|
|
2863
|
-
*
|
|
2864
|
-
* TEMP This method is temporary and will be removed once all adapters migrate to the OperationContext pattern.
|
|
2865
|
-
*
|
|
2866
|
-
* **Migration Guide:**
|
|
2867
|
-
*
|
|
2868
|
-
* With the OperationContext pattern, chain information is provided explicitly in each operation
|
|
2869
|
-
* rather than queried from the adapter. This eliminates ambiguity and enables seamless multi-chain
|
|
2870
|
-
* operations with a single adapter instance.
|
|
2871
|
-
*
|
|
2872
|
-
* **Before (Deprecated):**
|
|
2873
|
-
* ```typescript
|
|
2874
|
-
* const chain = await adapter.getChain()
|
|
2875
|
-
* const prepared = await adapter.prepare(params) // Uses cached chain
|
|
2876
|
-
* ```
|
|
2877
|
-
*
|
|
2878
|
-
* **After (OperationContext):**
|
|
2879
|
-
* ```typescript
|
|
2880
|
-
* // Chain specified explicitly per operation
|
|
2881
|
-
* const prepared = await adapter.prepare(params, { chain: 'Ethereum' })
|
|
2882
|
-
*
|
|
2883
|
-
* // Multi-chain operations with same adapter
|
|
2884
|
-
* const ethPrepared = await adapter.prepare(params, { chain: 'Ethereum' })
|
|
2885
|
-
* const basePrepared = await adapter.prepare(params, { chain: 'Base' })
|
|
2886
|
-
* ```
|
|
2887
|
-
*
|
|
2888
|
-
* @returns A promise that resolves to the first supported chain from capabilities
|
|
2889
|
-
* @throws Error when no supported chains are configured
|
|
2890
|
-
*/
|
|
2891
|
-
getChain(): Promise<ChainDefinition>;
|
|
2892
3069
|
/**
|
|
2893
3070
|
* Waits for a transaction to be mined and confirmed on the blockchain.
|
|
2894
3071
|
*
|
|
@@ -3040,9 +3217,10 @@ declare class EthersAdapter<TAdapterCapabilities extends AdapterCapabilities = A
|
|
|
3040
3217
|
interface CreateAdapterFromPrivateKeyParams<TCapabilities extends Partial<AdapterCapabilities> = AdapterCapabilities> {
|
|
3041
3218
|
/**
|
|
3042
3219
|
* The private key to use for wallet derivation.
|
|
3043
|
-
* Must be a valid 32-byte hex string
|
|
3220
|
+
* Must be a valid 32-byte hex string, with or without '0x' prefix.
|
|
3221
|
+
* If the prefix is omitted, it will be added automatically during validation.
|
|
3044
3222
|
*/
|
|
3045
|
-
privateKey:
|
|
3223
|
+
privateKey: string;
|
|
3046
3224
|
/**
|
|
3047
3225
|
* Optional function to create providers for different chains.
|
|
3048
3226
|
* If not provided, a default implementation using JsonRpcProvider will be used.
|
|
@@ -3115,16 +3293,17 @@ interface CreateAdapterFromPrivateKeyParams<TCapabilities extends Partial<Adapte
|
|
|
3115
3293
|
* ```typescript
|
|
3116
3294
|
* import { createAdapterFromPrivateKey } from '@circle-fin/adapter-ethers-v6'
|
|
3117
3295
|
*
|
|
3118
|
-
* //
|
|
3119
|
-
* const
|
|
3120
|
-
* privateKey: '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'
|
|
3121
|
-
*
|
|
3122
|
-
*
|
|
3123
|
-
*
|
|
3296
|
+
* // Both private key formats are supported (with or without '0x' prefix):
|
|
3297
|
+
* const adapter1 = createAdapterFromPrivateKey({
|
|
3298
|
+
* privateKey: '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef' // With prefix
|
|
3299
|
+
* })
|
|
3300
|
+
*
|
|
3301
|
+
* const adapter2 = createAdapterFromPrivateKey({
|
|
3302
|
+
* privateKey: '1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef' // Without prefix (automatically normalized)
|
|
3124
3303
|
* })
|
|
3125
3304
|
*
|
|
3126
3305
|
* // Chain specified per-operation via OperationContext
|
|
3127
|
-
* const prepared = await
|
|
3306
|
+
* const prepared = await adapter1.prepare({
|
|
3128
3307
|
* address: '0x...',
|
|
3129
3308
|
* abi: contractAbi,
|
|
3130
3309
|
* functionName: 'transfer',
|
|
@@ -3397,13 +3576,13 @@ interface CreateAdapterFromProviderParams {
|
|
|
3397
3576
|
* ```typescript
|
|
3398
3577
|
* // Cross-chain transfer using a single adapter
|
|
3399
3578
|
* import { createAdapterFromProvider } from '@circle-fin/adapter-ethers-v6'
|
|
3400
|
-
* import {
|
|
3579
|
+
* import { BridgeKit } from '@circle-fin/bridge-kit'
|
|
3401
3580
|
*
|
|
3402
3581
|
* const adapter = await createAdapterFromProvider({
|
|
3403
3582
|
* provider: window.ethereum
|
|
3404
3583
|
* })
|
|
3405
3584
|
*
|
|
3406
|
-
* const kit = new
|
|
3585
|
+
* const kit = new BridgeKit()
|
|
3407
3586
|
*
|
|
3408
3587
|
* // Use the same adapter for both source and destination
|
|
3409
3588
|
* const result = await kit.bridge({
|
|
@@ -3471,5 +3650,5 @@ declare const createAdapterFromProvider: (params: CreateAdapterFromProviderParam
|
|
|
3471
3650
|
*/
|
|
3472
3651
|
declare function validateAdapterCapabilities(capabilities: AdapterCapabilities): void;
|
|
3473
3652
|
|
|
3474
|
-
export { EthersAdapter, createAdapterFromPrivateKey, createAdapterFromProvider, validateAdapterCapabilities };
|
|
3475
|
-
export type { ChainIdentifier, CreateAdapterFromPrivateKeyParams, CreateAdapterFromProviderParams, EthersAdapterOptions };
|
|
3653
|
+
export { Blockchain, EthersAdapter, buildEIP2612TypedData, computeDefaultDeadline, createAdapterFromPrivateKey, createAdapterFromProvider, parseSignature, validateAdapterCapabilities };
|
|
3654
|
+
export type { ChainIdentifier, CreateAdapterFromPrivateKeyParams, CreateAdapterFromProviderParams, EIP2612Message, EIP2612NonceFetcher, EIP2612Options, EthersAdapterOptions, PermitStandardName, Signature, TypedData, TypedDataField };
|