@circle-fin/provider-cctp-v2 1.0.0 → 1.0.2
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/CHANGELOG.md +100 -0
- package/README.md +4 -2
- package/{index.cjs.js → index.cjs} +432 -203
- package/index.cjs.map +1 -0
- package/index.d.ts +167 -30
- package/index.mjs +430 -202
- package/package.json +7 -3
- package/index.cjs.js.map +0 -1
package/index.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/index.d.ts
CHANGED
|
@@ -408,6 +408,7 @@ declare enum Blockchain {
|
|
|
408
408
|
Algorand_Testnet = "Algorand_Testnet",
|
|
409
409
|
Aptos = "Aptos",
|
|
410
410
|
Aptos_Testnet = "Aptos_Testnet",
|
|
411
|
+
Arc_Testnet = "Arc_Testnet",
|
|
411
412
|
Arbitrum = "Arbitrum",
|
|
412
413
|
Arbitrum_Sepolia = "Arbitrum_Sepolia",
|
|
413
414
|
Avalanche = "Avalanche",
|
|
@@ -593,10 +594,11 @@ interface EvmPreparedChainRequest {
|
|
|
593
594
|
* Estimate the gas cost for the contract execution.
|
|
594
595
|
*
|
|
595
596
|
* @param overrides - Optional parameters to override the default estimation behavior
|
|
597
|
+
* @param fallback - Optional fallback gas information to use if the estimation fails
|
|
596
598
|
* @returns A promise that resolves to the estimated gas information
|
|
597
599
|
* @throws If the estimation fails
|
|
598
600
|
*/
|
|
599
|
-
estimate(overrides?: EvmEstimateOverrides): Promise<EstimatedGas>;
|
|
601
|
+
estimate(overrides?: EvmEstimateOverrides, fallback?: EstimatedGas): Promise<EstimatedGas>;
|
|
600
602
|
/**
|
|
601
603
|
* Execute the prepared contract call.
|
|
602
604
|
*
|
|
@@ -674,7 +676,7 @@ interface SolanaPreparedChainRequest {
|
|
|
674
676
|
/** The type of the chain request. */
|
|
675
677
|
type: 'solana';
|
|
676
678
|
/** Estimate the compute units and fee for the transaction. */
|
|
677
|
-
estimate(overrides?: SolanaEstimateOverrides): Promise<EstimatedGas>;
|
|
679
|
+
estimate(overrides?: SolanaEstimateOverrides, fallback?: EstimatedGas): Promise<EstimatedGas>;
|
|
678
680
|
/** Execute the prepared transaction. */
|
|
679
681
|
execute(overrides?: SolanaExecuteOverrides): Promise<string>;
|
|
680
682
|
}
|
|
@@ -706,7 +708,7 @@ interface NoopPreparedChainRequest {
|
|
|
706
708
|
* Placeholder for the estimate method.
|
|
707
709
|
* @returns The estimated gas cost.
|
|
708
710
|
*/
|
|
709
|
-
estimate: () => Promise<EstimatedGas>;
|
|
711
|
+
estimate: (overrides?: EvmEstimateOverrides | SolanaEstimateOverrides, fallback?: EstimatedGas) => Promise<EstimatedGas>;
|
|
710
712
|
/**
|
|
711
713
|
* Placeholder for the execute method.
|
|
712
714
|
* @returns The transaction hash.
|
|
@@ -1964,10 +1966,23 @@ interface AdapterCapabilities {
|
|
|
1964
1966
|
*/
|
|
1965
1967
|
declare abstract class Adapter<TAdapterCapabilities extends AdapterCapabilities = AdapterCapabilities> {
|
|
1966
1968
|
/**
|
|
1967
|
-
* The type of the chain.
|
|
1968
|
-
*
|
|
1969
|
+
* The type of the chain for this adapter.
|
|
1970
|
+
*
|
|
1971
|
+
* - For concrete adapters, this should be a real chain type (e.g., `'evm'`, `'solana'`, etc.) from the ChainType union.
|
|
1972
|
+
* - For hybrid adapters (adapters that route to concrete adapters supporting multiple ecosystems),
|
|
1973
|
+
* set this property to the string literal `'hybrid'`.
|
|
1974
|
+
*
|
|
1975
|
+
* Note: `'hybrid'` is not a legal ChainType and should only be used as a marker for multi-ecosystem adapters.
|
|
1976
|
+
* Hybrid adapters do not interact directly with any chain, but instead route requests to a concrete underlying adapter.
|
|
1977
|
+
*
|
|
1978
|
+
* @example
|
|
1979
|
+
* // For an EVM-only adapter:
|
|
1980
|
+
* chainType = 'evm'
|
|
1981
|
+
*
|
|
1982
|
+
* // For a hybrid adapter:
|
|
1983
|
+
* chainType = 'hybrid'
|
|
1969
1984
|
*/
|
|
1970
|
-
abstract chainType: ChainType;
|
|
1985
|
+
abstract chainType: ChainType | 'hybrid';
|
|
1971
1986
|
/**
|
|
1972
1987
|
* Capabilities of this adapter, defining address control model and supported chains.
|
|
1973
1988
|
*
|
|
@@ -2049,7 +2064,7 @@ declare abstract class Adapter<TAdapterCapabilities extends AdapterCapabilities
|
|
|
2049
2064
|
* })
|
|
2050
2065
|
* ```
|
|
2051
2066
|
*/
|
|
2052
|
-
prepareAction<TActionKey extends ActionKeys>(action: TActionKey, params: ActionPayload<TActionKey>, ctx
|
|
2067
|
+
prepareAction<TActionKey extends ActionKeys>(action: TActionKey, params: ActionPayload<TActionKey>, ctx: OperationContext<TAdapterCapabilities>): Promise<PreparedChainRequest>;
|
|
2053
2068
|
/**
|
|
2054
2069
|
* Prepares a transaction for future gas estimation and execution.
|
|
2055
2070
|
*
|
|
@@ -2434,6 +2449,49 @@ TChainDefinition extends ChainDefinition = ChainDefinition> {
|
|
|
2434
2449
|
*/
|
|
2435
2450
|
chain: TChainDefinition;
|
|
2436
2451
|
}
|
|
2452
|
+
/**
|
|
2453
|
+
* Wallet context for bridge destinations with optional custom recipient.
|
|
2454
|
+
*
|
|
2455
|
+
* Extends WalletContext to support scenarios where the recipient address
|
|
2456
|
+
* differs from the signer address (e.g., bridging to a third-party wallet).
|
|
2457
|
+
* The signer address is used for transaction authorization, while the
|
|
2458
|
+
* recipient address specifies where the minted funds should be sent.
|
|
2459
|
+
*
|
|
2460
|
+
* @typeParam TAdapterCapabilities - The adapter capabilities type to use for the wallet context.
|
|
2461
|
+
* @typeParam TChainDefinition - The chain definition type to use for the wallet context.
|
|
2462
|
+
*
|
|
2463
|
+
* @example
|
|
2464
|
+
* ```typescript
|
|
2465
|
+
* import type { DestinationWalletContext } from '@core/provider'
|
|
2466
|
+
* import { adapter, blockchain } from './setup'
|
|
2467
|
+
*
|
|
2468
|
+
* // Bridge to a custom recipient address
|
|
2469
|
+
* const destination: DestinationWalletContext = {
|
|
2470
|
+
* adapter,
|
|
2471
|
+
* address: '0x1234...abcd', // Signer address
|
|
2472
|
+
* chain: blockchain,
|
|
2473
|
+
* recipientAddress: '0x9876...fedc' // Custom recipient
|
|
2474
|
+
* }
|
|
2475
|
+
* ```
|
|
2476
|
+
*/
|
|
2477
|
+
interface DestinationWalletContext<TAdapterCapabilities extends AdapterCapabilities = AdapterCapabilities,
|
|
2478
|
+
/**
|
|
2479
|
+
* The chain definition type to use for the wallet context.
|
|
2480
|
+
*
|
|
2481
|
+
* @defaultValue ChainDefinition
|
|
2482
|
+
*/
|
|
2483
|
+
TChainDefinition extends ChainDefinition = ChainDefinition> extends WalletContext<TAdapterCapabilities, TChainDefinition> {
|
|
2484
|
+
/**
|
|
2485
|
+
* Optional custom recipient address for minted funds.
|
|
2486
|
+
*
|
|
2487
|
+
* When provided, minted tokens will be sent to this address instead of
|
|
2488
|
+
* the address specified in the wallet context. The wallet context address
|
|
2489
|
+
* is still used for transaction signing and authorization.
|
|
2490
|
+
*
|
|
2491
|
+
* Must be a valid address format for the specified blockchain.
|
|
2492
|
+
*/
|
|
2493
|
+
recipientAddress?: string;
|
|
2494
|
+
}
|
|
2437
2495
|
/**
|
|
2438
2496
|
* Parameters for executing a cross-chain bridge operation.
|
|
2439
2497
|
*/
|
|
@@ -2447,7 +2505,7 @@ TChainDefinition extends ChainDefinition = ChainDefinition> {
|
|
|
2447
2505
|
/** The source adapter containing wallet and chain information */
|
|
2448
2506
|
source: WalletContext<TFromCapabilities, TChainDefinition>;
|
|
2449
2507
|
/** The destination adapter containing wallet and chain information */
|
|
2450
|
-
destination:
|
|
2508
|
+
destination: DestinationWalletContext<TToCapabilities, TChainDefinition>;
|
|
2451
2509
|
/** The amount to transfer (as a string to avoid precision issues) */
|
|
2452
2510
|
amount: string;
|
|
2453
2511
|
/** The token to transfer (currently only USDC is supported) */
|
|
@@ -2591,7 +2649,26 @@ interface BridgeConfig {
|
|
|
2591
2649
|
/**
|
|
2592
2650
|
* The maximum fee to pay for the burn operation.
|
|
2593
2651
|
*
|
|
2594
|
-
*
|
|
2652
|
+
* Provide the amount as a base-10 numeric string representing the
|
|
2653
|
+
* token amount in human-readable format. For example: to set a maximum
|
|
2654
|
+
* fee of 1 USDC, pass `"1"`. Decimal values are supported (e.g., `"0.5"`
|
|
2655
|
+
* for half a USDC).
|
|
2656
|
+
*
|
|
2657
|
+
* @defaultValue `"0"`
|
|
2658
|
+
*
|
|
2659
|
+
* @example
|
|
2660
|
+
* ```typescript
|
|
2661
|
+
* import type { BridgeConfig, TransferSpeed } from '@core/provider'
|
|
2662
|
+
*
|
|
2663
|
+
* const config: BridgeConfig = {
|
|
2664
|
+
* transferSpeed: TransferSpeed.FAST,
|
|
2665
|
+
* maxFee: "1", // 1 USDC maximum fee
|
|
2666
|
+
* customFee: {
|
|
2667
|
+
* value: "0.5", // 0.5 USDC developer fee
|
|
2668
|
+
* recipientAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb0"
|
|
2669
|
+
* }
|
|
2670
|
+
* }
|
|
2671
|
+
* ```
|
|
2595
2672
|
*/
|
|
2596
2673
|
maxFee?: string;
|
|
2597
2674
|
/**
|
|
@@ -2602,8 +2679,8 @@ interface BridgeConfig {
|
|
|
2602
2679
|
/**
|
|
2603
2680
|
* Custom fee configuration charged by the integrator.
|
|
2604
2681
|
*
|
|
2605
|
-
* Use to charge an absolute fee on the source chain
|
|
2606
|
-
*
|
|
2682
|
+
* Use to charge an absolute fee on the source chain in human-readable
|
|
2683
|
+
* token amounts.
|
|
2607
2684
|
*
|
|
2608
2685
|
* @remarks
|
|
2609
2686
|
* This is an absolute amount, not a percentage. The `recipientAddress` must be
|
|
@@ -2614,7 +2691,7 @@ interface BridgeConfig {
|
|
|
2614
2691
|
* import type { CustomFee } from '@core/provider'
|
|
2615
2692
|
*
|
|
2616
2693
|
* const config: CustomFee = {
|
|
2617
|
-
* value: '
|
|
2694
|
+
* value: '1', // 1 USDC
|
|
2618
2695
|
* recipientAddress: '0x1234567890123456789012345678901234567890',
|
|
2619
2696
|
* }
|
|
2620
2697
|
* ```
|
|
@@ -2622,20 +2699,25 @@ interface BridgeConfig {
|
|
|
2622
2699
|
interface CustomFee {
|
|
2623
2700
|
/**
|
|
2624
2701
|
* The absolute fee to charge for the transfer.
|
|
2625
|
-
*
|
|
2626
|
-
*
|
|
2702
|
+
*
|
|
2703
|
+
* Provide the amount as a base-10 numeric string representing the token
|
|
2704
|
+
* amount in human-readable format. For example: to charge 1 USDC, pass
|
|
2705
|
+
* `"1"`. Decimal values are supported (e.g., `"0.5"` for half a USDC).
|
|
2627
2706
|
* This is not a percentage.
|
|
2628
2707
|
*
|
|
2629
|
-
* Note: passing `
|
|
2708
|
+
* Note: passing `"0"` results in no fee being charged.
|
|
2630
2709
|
*/
|
|
2631
2710
|
value?: string | undefined;
|
|
2632
2711
|
/**
|
|
2633
2712
|
* The fee recipient for the bridge transfer.
|
|
2634
|
-
*
|
|
2635
|
-
*
|
|
2713
|
+
*
|
|
2714
|
+
* This is the address that will receive the fee on the source chain of the
|
|
2715
|
+
* bridge transfer. The fee recipient address **must be a valid address for
|
|
2716
|
+
* the source chain** of the bridge transfer.
|
|
2636
2717
|
*
|
|
2637
2718
|
* For example: if bridging from Ethereum to Solana, pass an EVM address like
|
|
2638
|
-
* `
|
|
2719
|
+
* `"0x1234567890123456789012345678901234567890"` because the source chain
|
|
2720
|
+
* is Ethereum.
|
|
2639
2721
|
*/
|
|
2640
2722
|
recipientAddress?: string | undefined;
|
|
2641
2723
|
}
|
|
@@ -3125,7 +3207,7 @@ type CCTPV2BridgeParams<TFromAdapterCapabilities extends AdapterCapabilities = A
|
|
|
3125
3207
|
/**
|
|
3126
3208
|
* The destination wallet context containing the chain definition and wallet address.
|
|
3127
3209
|
*/
|
|
3128
|
-
destination:
|
|
3210
|
+
destination: DestinationWalletContext<TToAdapterCapabilities, ChainDefinitionWithCCTPv2>;
|
|
3129
3211
|
/**
|
|
3130
3212
|
* The bridge configuration for the CCTPv2 transfer.
|
|
3131
3213
|
*/
|
|
@@ -3134,17 +3216,28 @@ type CCTPV2BridgeParams<TFromAdapterCapabilities extends AdapterCapabilities = A
|
|
|
3134
3216
|
/**
|
|
3135
3217
|
* Action types supported by the CCTP v2 provider.
|
|
3136
3218
|
*
|
|
3219
|
+
* @remarks
|
|
3137
3220
|
* This interface defines the structure of actions that can be dispatched during
|
|
3138
|
-
* CCTP v2 transfer operations. Each action includes protocol metadata and
|
|
3139
|
-
* values
|
|
3221
|
+
* CCTP v2 transfer operations. Each action includes protocol metadata and a
|
|
3222
|
+
* `values` field containing the full bridge step with transaction details.
|
|
3223
|
+
*
|
|
3224
|
+
* All transaction-based steps (approve, burn, mint) include `txHash` and
|
|
3225
|
+
* `explorerUrl` fields for direct links to block explorers.
|
|
3140
3226
|
*
|
|
3141
3227
|
* @example
|
|
3142
3228
|
* ```typescript
|
|
3143
|
-
*
|
|
3229
|
+
* // Action structure received by event listeners
|
|
3230
|
+
* const burnAction: CCTPV2Actions['burn'] = {
|
|
3144
3231
|
* protocol: 'cctp',
|
|
3145
3232
|
* version: 'v2',
|
|
3146
|
-
* method: '
|
|
3147
|
-
* values: {
|
|
3233
|
+
* method: 'burn',
|
|
3234
|
+
* values: {
|
|
3235
|
+
* name: 'burn',
|
|
3236
|
+
* state: 'success',
|
|
3237
|
+
* txHash: '0x2ed454c5cfab41f0a58ad0c55bf6c326eb97067d2b02fa046dc5698bfc5530f1',
|
|
3238
|
+
* explorerUrl: 'https://sepolia.etherscan.io/tx/0x2ed454...',
|
|
3239
|
+
* data: { ... }
|
|
3240
|
+
* }
|
|
3148
3241
|
* }
|
|
3149
3242
|
* ```
|
|
3150
3243
|
*/
|
|
@@ -3220,7 +3313,7 @@ interface ICCTPV2BridgingProvider extends BridgingProvider<CCTPV2Actions> {
|
|
|
3220
3313
|
* @param txHash - The transaction hash of the deposit for burn transaction.
|
|
3221
3314
|
* @returns A promise that resolves to the attestation message.
|
|
3222
3315
|
*/
|
|
3223
|
-
fetchAttestation<TFromAdapterCapabilities extends AdapterCapabilities, TToAdapterCapabilities extends AdapterCapabilities>(source: BridgeParams<TFromAdapterCapabilities, TToAdapterCapabilities>['source'], txHash: string): Promise<AttestationMessage>;
|
|
3316
|
+
fetchAttestation<TFromAdapterCapabilities extends AdapterCapabilities, TToAdapterCapabilities extends AdapterCapabilities>(source: BridgeParams<TFromAdapterCapabilities, TToAdapterCapabilities>['source'], txHash: string, config?: Partial<ApiPollingConfig>): Promise<AttestationMessage>;
|
|
3224
3317
|
/**
|
|
3225
3318
|
* Mints the amount of tokens for the destination wallet.
|
|
3226
3319
|
*
|
|
@@ -3487,7 +3580,7 @@ declare class CCTPV2BridgingProvider extends BridgingProvider<CCTPV2Actions> imp
|
|
|
3487
3580
|
* console.log('Mint transaction:', txHash)
|
|
3488
3581
|
* ```
|
|
3489
3582
|
*/
|
|
3490
|
-
mint<TFromAdapterCapabilities extends AdapterCapabilities, TToAdapterCapabilities extends AdapterCapabilities>(source: WalletContext<TFromAdapterCapabilities, ChainDefinitionWithCCTPv2>, destination:
|
|
3583
|
+
mint<TFromAdapterCapabilities extends AdapterCapabilities, TToAdapterCapabilities extends AdapterCapabilities>(source: WalletContext<TFromAdapterCapabilities, ChainDefinitionWithCCTPv2>, destination: BridgeParams<TFromAdapterCapabilities, TToAdapterCapabilities>['destination'], attestation: AttestationMessage): Promise<PreparedChainRequest>;
|
|
3491
3584
|
/**
|
|
3492
3585
|
* Fetches attestation data for a burn transaction from the IRIS API.
|
|
3493
3586
|
*
|
|
@@ -3568,7 +3661,9 @@ declare class CCTPV2BridgingProvider extends BridgingProvider<CCTPV2Actions> imp
|
|
|
3568
3661
|
* - `source`: The source wallet context with chain definition and adapter
|
|
3569
3662
|
* - `destination`: The destination wallet context with chain definition and adapter
|
|
3570
3663
|
* - `amount`: The bridge amount in minor units (e.g., "1000000" for 1 USDC)
|
|
3571
|
-
* - `config`: Optional bridge configuration including transferSpeed and maxFee settings
|
|
3664
|
+
* - `config`: Optional bridge configuration including transferSpeed and maxFee settings.
|
|
3665
|
+
* When used via BridgeKit, fee values are automatically converted from human-readable
|
|
3666
|
+
* format (e.g., "1") to smallest units (e.g., "1000000").
|
|
3572
3667
|
* @returns The maximum fee to be used for the bridge operation in minor units
|
|
3573
3668
|
*
|
|
3574
3669
|
* @example
|
|
@@ -3576,9 +3671,12 @@ declare class CCTPV2BridgingProvider extends BridgingProvider<CCTPV2Actions> imp
|
|
|
3576
3671
|
* const maxFee = await provider.getMaxFee({
|
|
3577
3672
|
* source: { adapter: sourceAdapter, chain: Chains.Ethereum, address: '0x...' },
|
|
3578
3673
|
* destination: { adapter: destAdapter, chain: Chains.Base, address: '0x...' },
|
|
3579
|
-
* amount: '1000000', // 1 USDC
|
|
3674
|
+
* amount: '1000000', // 1 USDC in minor units
|
|
3580
3675
|
* token: 'USDC',
|
|
3581
|
-
* config: {
|
|
3676
|
+
* config: {
|
|
3677
|
+
* transferSpeed: TransferSpeed.FAST,
|
|
3678
|
+
* maxFee: '1000000' // Provider receives values in smallest units
|
|
3679
|
+
* }
|
|
3582
3680
|
* })
|
|
3583
3681
|
* console.log('Max fee:', maxFee)
|
|
3584
3682
|
* ```
|
|
@@ -3633,5 +3731,44 @@ declare class CCTPV2BridgingProvider extends BridgingProvider<CCTPV2Actions> imp
|
|
|
3633
3731
|
waitForTransaction(adapter: Adapter, txHash: string, chain: ChainDefinition, config?: WaitForTransactionConfig): Promise<WaitForTransactionResponse>;
|
|
3634
3732
|
}
|
|
3635
3733
|
|
|
3636
|
-
|
|
3734
|
+
/**
|
|
3735
|
+
* Get the token account address where USDC will be minted for the recipient.
|
|
3736
|
+
*
|
|
3737
|
+
* For EVM chains, the recipient address directly holds ERC20 tokens, so the raw
|
|
3738
|
+
* address is returned as-is. For Solana, USDC is held in Associated Token Accounts
|
|
3739
|
+
* (ATAs), so this function derives the ATA address for the given owner and USDC mint.
|
|
3740
|
+
*
|
|
3741
|
+
* @param chainType - The type of blockchain ('evm' or 'solana').
|
|
3742
|
+
* @param rawAddress - The recipient's wallet address on the destination chain.
|
|
3743
|
+
* @param mint - The USDC mint address (only used for Solana chains).
|
|
3744
|
+
* @returns The address where USDC tokens will be minted (raw address for EVM, ATA for Solana).
|
|
3745
|
+
*
|
|
3746
|
+
* @example
|
|
3747
|
+
* ```typescript
|
|
3748
|
+
* import { getMintRecipientAccount } from './getMintRecipientAccount'
|
|
3749
|
+
*
|
|
3750
|
+
* // EVM: returns the same address
|
|
3751
|
+
* const evmAccount = await getMintRecipientAccount(
|
|
3752
|
+
* 'evm',
|
|
3753
|
+
* '0x742d35Cc6634C0532925a3b8D89C7DA5C3cfa',
|
|
3754
|
+
* 'N/A'
|
|
3755
|
+
* )
|
|
3756
|
+
*
|
|
3757
|
+
* // Solana: derives the Associated Token Account
|
|
3758
|
+
* const solanaAccount = await getMintRecipientAccount(
|
|
3759
|
+
* 'solana',
|
|
3760
|
+
* '9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM',
|
|
3761
|
+
* 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
|
|
3762
|
+
* )
|
|
3763
|
+
* ```
|
|
3764
|
+
*/
|
|
3765
|
+
declare const getMintRecipientAccount: (
|
|
3766
|
+
/** The blockchain type - determines how token accounts are handled */
|
|
3767
|
+
chainType: ChainType,
|
|
3768
|
+
/** The recipient's wallet address (hex format for EVM, base58 for Solana) */
|
|
3769
|
+
rawAddress: string,
|
|
3770
|
+
/** The USDC mint address (ignored for EVM chains, required base58 address for Solana) */
|
|
3771
|
+
mintAddress: string) => Promise<string>;
|
|
3772
|
+
|
|
3773
|
+
export { CCTPV2BridgingProvider, getMintRecipientAccount };
|
|
3637
3774
|
export type { CCTPV2Config };
|