@circle-fin/provider-cctp-v2 1.0.0 → 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.
Files changed (5) hide show
  1. package/README.md +4 -2
  2. package/index.cjs.js +273 -109
  3. package/index.d.ts +100 -20
  4. package/index.mjs +273 -110
  5. package/package.json +3 -1
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",
@@ -2591,7 +2592,26 @@ interface BridgeConfig {
2591
2592
  /**
2592
2593
  * The maximum fee to pay for the burn operation.
2593
2594
  *
2594
- * @defaultValue 0
2595
+ * Provide the amount as a base-10 numeric string representing the
2596
+ * token amount in human-readable format. For example: to set a maximum
2597
+ * fee of 1 USDC, pass `"1"`. Decimal values are supported (e.g., `"0.5"`
2598
+ * for half a USDC).
2599
+ *
2600
+ * @defaultValue `"0"`
2601
+ *
2602
+ * @example
2603
+ * ```typescript
2604
+ * import type { BridgeConfig, TransferSpeed } from '@core/provider'
2605
+ *
2606
+ * const config: BridgeConfig = {
2607
+ * transferSpeed: TransferSpeed.FAST,
2608
+ * maxFee: "1", // 1 USDC maximum fee
2609
+ * customFee: {
2610
+ * value: "0.5", // 0.5 USDC developer fee
2611
+ * recipientAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb0"
2612
+ * }
2613
+ * }
2614
+ * ```
2595
2615
  */
2596
2616
  maxFee?: string;
2597
2617
  /**
@@ -2602,8 +2622,8 @@ interface BridgeConfig {
2602
2622
  /**
2603
2623
  * Custom fee configuration charged by the integrator.
2604
2624
  *
2605
- * Use to charge an absolute fee on the source chain, in the token's
2606
- * smallest unit.
2625
+ * Use to charge an absolute fee on the source chain in human-readable
2626
+ * token amounts.
2607
2627
  *
2608
2628
  * @remarks
2609
2629
  * This is an absolute amount, not a percentage. The `recipientAddress` must be
@@ -2614,7 +2634,7 @@ interface BridgeConfig {
2614
2634
  * import type { CustomFee } from '@core/provider'
2615
2635
  *
2616
2636
  * const config: CustomFee = {
2617
- * value: '1000000', // 1 USDC in base units (6 decimals)
2637
+ * value: '1', // 1 USDC
2618
2638
  * recipientAddress: '0x1234567890123456789012345678901234567890',
2619
2639
  * }
2620
2640
  * ```
@@ -2622,20 +2642,25 @@ interface BridgeConfig {
2622
2642
  interface CustomFee {
2623
2643
  /**
2624
2644
  * The absolute fee to charge for the transfer.
2625
- * Provide the amount as a base-10 numeric string representing the integer amount of the token (not in smallest units).
2626
- * For example: to charge 1 USDC or 1 USDC, pass `'1'`.
2645
+ *
2646
+ * Provide the amount as a base-10 numeric string representing the token
2647
+ * amount in human-readable format. For example: to charge 1 USDC, pass
2648
+ * `"1"`. Decimal values are supported (e.g., `"0.5"` for half a USDC).
2627
2649
  * This is not a percentage.
2628
2650
  *
2629
- * Note: passing `'0'` results in no fee being charged.
2651
+ * Note: passing `"0"` results in no fee being charged.
2630
2652
  */
2631
2653
  value?: string | undefined;
2632
2654
  /**
2633
2655
  * The fee recipient for the bridge transfer.
2634
- * This is the address that will receive the fee on the source chain of the bridge transfer.
2635
- * The fee recipient address **must be a valid address for the source chain** of the bridge transfer.
2656
+ *
2657
+ * This is the address that will receive the fee on the source chain of the
2658
+ * bridge transfer. The fee recipient address **must be a valid address for
2659
+ * the source chain** of the bridge transfer.
2636
2660
  *
2637
2661
  * For example: if bridging from Ethereum to Solana, pass an EVM address like
2638
- * `'0x1234567890123456789012345678901234567890'` because the source chain is Ethereum.
2662
+ * `"0x1234567890123456789012345678901234567890"` because the source chain
2663
+ * is Ethereum.
2639
2664
  */
2640
2665
  recipientAddress?: string | undefined;
2641
2666
  }
@@ -3134,17 +3159,28 @@ type CCTPV2BridgeParams<TFromAdapterCapabilities extends AdapterCapabilities = A
3134
3159
  /**
3135
3160
  * Action types supported by the CCTP v2 provider.
3136
3161
  *
3162
+ * @remarks
3137
3163
  * This interface defines the structure of actions that can be dispatched during
3138
- * CCTP v2 transfer operations. Each action includes protocol metadata and specific
3139
- * values required for the operation.
3164
+ * CCTP v2 transfer operations. Each action includes protocol metadata and a
3165
+ * `values` field containing the full bridge step with transaction details.
3166
+ *
3167
+ * All transaction-based steps (approve, burn, mint) include `txHash` and
3168
+ * `explorerUrl` fields for direct links to block explorers.
3140
3169
  *
3141
3170
  * @example
3142
3171
  * ```typescript
3143
- * const approveAction: CCTPV2Actions['approve'] = {
3172
+ * // Action structure received by event listeners
3173
+ * const burnAction: CCTPV2Actions['burn'] = {
3144
3174
  * protocol: 'cctp',
3145
3175
  * version: 'v2',
3146
- * method: 'approve',
3147
- * values: { amount: '100.50', fee: '0.1' }
3176
+ * method: 'burn',
3177
+ * values: {
3178
+ * name: 'burn',
3179
+ * state: 'success',
3180
+ * txHash: '0x2ed454c5cfab41f0a58ad0c55bf6c326eb97067d2b02fa046dc5698bfc5530f1',
3181
+ * explorerUrl: 'https://sepolia.etherscan.io/tx/0x2ed454...',
3182
+ * data: { ... }
3183
+ * }
3148
3184
  * }
3149
3185
  * ```
3150
3186
  */
@@ -3220,7 +3256,7 @@ interface ICCTPV2BridgingProvider extends BridgingProvider<CCTPV2Actions> {
3220
3256
  * @param txHash - The transaction hash of the deposit for burn transaction.
3221
3257
  * @returns A promise that resolves to the attestation message.
3222
3258
  */
3223
- fetchAttestation<TFromAdapterCapabilities extends AdapterCapabilities, TToAdapterCapabilities extends AdapterCapabilities>(source: BridgeParams<TFromAdapterCapabilities, TToAdapterCapabilities>['source'], txHash: string): Promise<AttestationMessage>;
3259
+ fetchAttestation<TFromAdapterCapabilities extends AdapterCapabilities, TToAdapterCapabilities extends AdapterCapabilities>(source: BridgeParams<TFromAdapterCapabilities, TToAdapterCapabilities>['source'], txHash: string, config?: Partial<ApiPollingConfig>): Promise<AttestationMessage>;
3224
3260
  /**
3225
3261
  * Mints the amount of tokens for the destination wallet.
3226
3262
  *
@@ -3568,7 +3604,9 @@ declare class CCTPV2BridgingProvider extends BridgingProvider<CCTPV2Actions> imp
3568
3604
  * - `source`: The source wallet context with chain definition and adapter
3569
3605
  * - `destination`: The destination wallet context with chain definition and adapter
3570
3606
  * - `amount`: The bridge amount in minor units (e.g., "1000000" for 1 USDC)
3571
- * - `config`: Optional bridge configuration including transferSpeed and maxFee settings
3607
+ * - `config`: Optional bridge configuration including transferSpeed and maxFee settings.
3608
+ * When used via BridgeKit, fee values are automatically converted from human-readable
3609
+ * format (e.g., "1") to smallest units (e.g., "1000000").
3572
3610
  * @returns The maximum fee to be used for the bridge operation in minor units
3573
3611
  *
3574
3612
  * @example
@@ -3576,9 +3614,12 @@ declare class CCTPV2BridgingProvider extends BridgingProvider<CCTPV2Actions> imp
3576
3614
  * const maxFee = await provider.getMaxFee({
3577
3615
  * source: { adapter: sourceAdapter, chain: Chains.Ethereum, address: '0x...' },
3578
3616
  * destination: { adapter: destAdapter, chain: Chains.Base, address: '0x...' },
3579
- * amount: '1000000', // 1 USDC
3617
+ * amount: '1000000', // 1 USDC in minor units
3580
3618
  * token: 'USDC',
3581
- * config: { transferSpeed: TransferSpeed.FAST }
3619
+ * config: {
3620
+ * transferSpeed: TransferSpeed.FAST,
3621
+ * maxFee: '1000000' // Provider receives values in smallest units
3622
+ * }
3582
3623
  * })
3583
3624
  * console.log('Max fee:', maxFee)
3584
3625
  * ```
@@ -3633,5 +3674,44 @@ declare class CCTPV2BridgingProvider extends BridgingProvider<CCTPV2Actions> imp
3633
3674
  waitForTransaction(adapter: Adapter, txHash: string, chain: ChainDefinition, config?: WaitForTransactionConfig): Promise<WaitForTransactionResponse>;
3634
3675
  }
3635
3676
 
3636
- export { CCTPV2BridgingProvider };
3677
+ /**
3678
+ * Get the token account address where USDC will be minted for the recipient.
3679
+ *
3680
+ * For EVM chains, the recipient address directly holds ERC20 tokens, so the raw
3681
+ * address is returned as-is. For Solana, USDC is held in Associated Token Accounts
3682
+ * (ATAs), so this function derives the ATA address for the given owner and USDC mint.
3683
+ *
3684
+ * @param chainType - The type of blockchain ('evm' or 'solana').
3685
+ * @param rawAddress - The recipient's wallet address on the destination chain.
3686
+ * @param mint - The USDC mint address (only used for Solana chains).
3687
+ * @returns The address where USDC tokens will be minted (raw address for EVM, ATA for Solana).
3688
+ *
3689
+ * @example
3690
+ * ```typescript
3691
+ * import { getMintRecipientAccount } from './getMintRecipientAccount'
3692
+ *
3693
+ * // EVM: returns the same address
3694
+ * const evmAccount = await getMintRecipientAccount(
3695
+ * 'evm',
3696
+ * '0x742d35Cc6634C0532925a3b8D89C7DA5C3cfa',
3697
+ * 'N/A'
3698
+ * )
3699
+ *
3700
+ * // Solana: derives the Associated Token Account
3701
+ * const solanaAccount = await getMintRecipientAccount(
3702
+ * 'solana',
3703
+ * '9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM',
3704
+ * 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
3705
+ * )
3706
+ * ```
3707
+ */
3708
+ declare const getMintRecipientAccount: (
3709
+ /** The blockchain type - determines how token accounts are handled */
3710
+ chainType: ChainType,
3711
+ /** The recipient's wallet address (hex format for EVM, base58 for Solana) */
3712
+ rawAddress: string,
3713
+ /** The USDC mint address (ignored for EVM chains, required base58 address for Solana) */
3714
+ mintAddress: string) => Promise<string>;
3715
+
3716
+ export { CCTPV2BridgingProvider, getMintRecipientAccount };
3637
3717
  export type { CCTPV2Config };