@circle-fin/provider-cctp-v2 1.6.2 → 1.6.3

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/CHANGELOG.md +6 -0
  2. package/index.cjs +1593 -925
  3. package/index.d.ts +470 -4
  4. package/index.mjs +1593 -925
  5. package/package.json +2 -1
package/index.d.ts CHANGED
@@ -166,6 +166,43 @@ interface BaseChainDefinition {
166
166
  * ```
167
167
  */
168
168
  kitContracts?: KitContracts;
169
+ /**
170
+ * Optional Gateway contract configuration for Gateway protocol support.
171
+ *
172
+ * @description When provided, the chain supports the Gateway protocol for
173
+ * cross-chain transfers. Gateway provides an alternative bridging mechanism
174
+ * with its own set of smart contracts (GatewayWallet and GatewayMinter).
175
+ *
176
+ * Use the {@link isGatewayV1Supported} type guard to check if a chain
177
+ * supports Gateway v1 before accessing these properties.
178
+ *
179
+ * @example
180
+ * ```typescript
181
+ * // Chain with Gateway v1 support
182
+ * const chainWithGateway: ChainDefinition = {
183
+ * // ... other properties
184
+ * gateway: {
185
+ * domain: 6,
186
+ * forwarderSupported: { source: true, destination: true },
187
+ * contracts: {
188
+ * v1: {
189
+ * wallet: '0x1234567890abcdef1234567890abcdef12345678',
190
+ * minter: '0xabcdef1234567890abcdef1234567890abcdef12'
191
+ * }
192
+ * }
193
+ * }
194
+ * }
195
+ *
196
+ * // Check Gateway support
197
+ * if (isGatewayV1Supported(chainWithGateway)) {
198
+ * console.log('Gateway wallet:', chainWithGateway.gateway.contracts.v1.wallet)
199
+ * }
200
+ * ```
201
+ *
202
+ * @see {@link GatewayConfig} for the structure of Gateway configuration.
203
+ * @see {@link isGatewayV1Supported} for checking Gateway v1 support.
204
+ */
205
+ gateway?: GatewayConfig;
169
206
  }
170
207
  /**
171
208
  * Represents chain definitions for Ethereum Virtual Machine (EVM) compatible blockchains.
@@ -447,6 +484,128 @@ interface CCTPConfig {
447
484
  * ```
448
485
  */
449
486
  type KitContractType = 'bridge' | 'adapter';
487
+ /**
488
+ * Configuration for Gateway v1 contracts.
489
+ *
490
+ * @description Contains the addresses for the GatewayWallet and GatewayMinter
491
+ * smart contracts that enable Gateway functionality on a chain.
492
+ *
493
+ * @example
494
+ * ```typescript
495
+ * import type { GatewayV1Contracts } from '@core/chains'
496
+ *
497
+ * const v1Contracts: GatewayV1Contracts = {
498
+ * wallet: '0x1234567890abcdef1234567890abcdef12345678',
499
+ * minter: '0xabcdef1234567890abcdef1234567890abcdef12'
500
+ * }
501
+ * ```
502
+ */
503
+ interface GatewayV1Contracts {
504
+ /**
505
+ * The address of the GatewayWallet smart contract.
506
+ *
507
+ * @description The GatewayWallet contract manages wallet operations
508
+ * for Gateway transactions.
509
+ *
510
+ * Address format varies by blockchain:
511
+ * - EVM chains: 40-character hexadecimal with 0x prefix (e.g., "0x1234...")
512
+ * - Solana: Base58-encoded 32-byte address (e.g., "9WzDX...")
513
+ *
514
+ * @example "0x1234567890abcdef1234567890abcdef12345678"
515
+ */
516
+ wallet: string;
517
+ /**
518
+ * The address of the GatewayMinter smart contract.
519
+ *
520
+ * @description The GatewayMinter contract handles minting operations
521
+ * for Gateway transactions.
522
+ *
523
+ * Address format varies by blockchain:
524
+ * - EVM chains: 40-character hexadecimal with 0x prefix (e.g., "0x1234...")
525
+ * - Solana: Base58-encoded 32-byte address (e.g., "9WzDX...")
526
+ *
527
+ * @example "0xabcdef1234567890abcdef1234567890abcdef12"
528
+ */
529
+ minter: string;
530
+ }
531
+ /**
532
+ * Versioned map of Gateway contract configurations.
533
+ *
534
+ * @description Maps protocol versions to their contract addresses, following
535
+ * the same pattern as {@link CCTPContracts}. Each version is optional so that
536
+ * chains can support any combination of Gateway protocol versions.
537
+ *
538
+ * @example
539
+ * ```typescript
540
+ * import type { GatewayContracts } from '@core/chains'
541
+ *
542
+ * const contracts: GatewayContracts = {
543
+ * v1: {
544
+ * wallet: '0x1234567890abcdef1234567890abcdef12345678',
545
+ * minter: '0xabcdef1234567890abcdef1234567890abcdef12'
546
+ * }
547
+ * }
548
+ * ```
549
+ */
550
+ type GatewayContracts = Partial<{
551
+ v1: GatewayV1Contracts;
552
+ }>;
553
+ /**
554
+ * Configuration for the Gateway protocol on a blockchain.
555
+ *
556
+ * @description Contains the Gateway domain identifier and version-specific
557
+ * contract configurations. Follows the same structure as {@link CCTPConfig}:
558
+ * a domain number plus a versioned contracts map.
559
+ *
560
+ * @example
561
+ * ```typescript
562
+ * import type { GatewayConfig } from '@core/chains'
563
+ *
564
+ * const gatewayConfig: GatewayConfig = {
565
+ * domain: 0,
566
+ * forwarderSupported: { source: true, destination: true },
567
+ * contracts: {
568
+ * v1: {
569
+ * wallet: '0x1234567890abcdef1234567890abcdef12345678',
570
+ * minter: '0xabcdef1234567890abcdef1234567890abcdef12'
571
+ * }
572
+ * }
573
+ * }
574
+ * ```
575
+ */
576
+ interface GatewayConfig {
577
+ /**
578
+ * The Gateway domain identifier for this chain.
579
+ *
580
+ * @description Similar to CCTP domains, this number uniquely identifies
581
+ * the chain within the Gateway protocol.
582
+ *
583
+ * @example 0 for Ethereum, 6 for Base
584
+ */
585
+ domain: number;
586
+ /**
587
+ * Version-specific Gateway contract addresses.
588
+ *
589
+ * @description Contains the addresses for each supported Gateway protocol
590
+ * version, following the same pattern as {@link CCTPContracts}.
591
+ */
592
+ contracts: GatewayContracts;
593
+ /**
594
+ * Indicate whether the chain supports the Forwarding Service as a source
595
+ * and/or destination within the Gateway protocol.
596
+ *
597
+ * @example
598
+ * ```typescript
599
+ * forwarderSupported: { source: true, destination: true }
600
+ * ```
601
+ */
602
+ forwarderSupported: {
603
+ /** Whether this chain can be used as a source in forwarded transfers. */
604
+ source: boolean;
605
+ /** Whether this chain can be used as a destination in forwarded transfers. */
606
+ destination: boolean;
607
+ };
608
+ }
450
609
  /**
451
610
  * Kit-specific contract addresses for enhanced chain functionality.
452
611
  *
@@ -761,10 +920,39 @@ type EvmPreparedChainRequestParams = {
761
920
  functionName: string;
762
921
  /** The arguments to pass to the function. */
763
922
  args: unknown[];
923
+ /**
924
+ * Specific block number to read contract state at (read-only calls only).
925
+ * Used for historical reads, e.g. checking delegate status at Gateway's
926
+ * processed height rather than the latest block. Ignored for write
927
+ * operations (transactions).
928
+ */
929
+ blockNumber?: bigint;
764
930
  } & Partial<EvmEstimateOverrides>;
931
+ /**
932
+ * Parameters for preparing an EIP-712 typed data signing request (EVM).
933
+ * When executed, returns the signature hex string.
934
+ */
935
+ interface EvmSignTypedDataPreparedChainRequestParams {
936
+ type: 'evm-sign-typed-data';
937
+ typedData: {
938
+ types: Record<string, unknown[]>;
939
+ domain: Record<string, unknown>;
940
+ primaryType: string;
941
+ message: Record<string, unknown>;
942
+ };
943
+ }
765
944
  /**
766
945
  * Solana-specific parameters for preparing a transaction.
767
- * @interface SolanaPreparedChainRequestParams
946
+ *
947
+ * @example
948
+ * ```typescript
949
+ * import type { SolanaPreparedChainRequestParams } from '@core/adapter'
950
+ *
951
+ * const params: SolanaPreparedChainRequestParams = {
952
+ * instructions: [transferInstruction],
953
+ * addressLookupTables: [],
954
+ * }
955
+ * ```
768
956
  */
769
957
  interface SolanaPreparedChainRequestParams {
770
958
  /**
@@ -805,6 +993,24 @@ interface SolanaPreparedChainRequestParams {
805
993
  */
806
994
  addressLookupTableAddresses?: string[];
807
995
  }
996
+ /**
997
+ * Parameters for preparing a message signing request (Solana).
998
+ * When executed, returns the signature.
999
+ *
1000
+ * @example
1001
+ * ```typescript
1002
+ * import type { SolanaSignMessagePreparedChainRequestParams } from '@core/adapter'
1003
+ *
1004
+ * const params: SolanaSignMessagePreparedChainRequestParams = {
1005
+ * type: 'solana-sign-message',
1006
+ * message: new TextEncoder().encode('Sign this message'),
1007
+ * }
1008
+ * ```
1009
+ */
1010
+ interface SolanaSignMessagePreparedChainRequestParams {
1011
+ type: 'solana-sign-message';
1012
+ message: Uint8Array;
1013
+ }
808
1014
  /**
809
1015
  * Solana-specific configuration for transaction estimation.
810
1016
  * @interface SolanaEstimateOverrides
@@ -877,7 +1083,7 @@ interface NoopPreparedChainRequest {
877
1083
  * Union type for all supported contract execution parameters.
878
1084
  * Currently only supports EVM chains, but can be extended for other chains.
879
1085
  */
880
- type PreparedChainRequestParams = EvmPreparedChainRequestParams | SolanaPreparedChainRequestParams;
1086
+ type PreparedChainRequestParams = EvmPreparedChainRequestParams | EvmSignTypedDataPreparedChainRequestParams | SolanaPreparedChainRequestParams | SolanaSignMessagePreparedChainRequestParams;
881
1087
  /**
882
1088
  * Response from waiting for a transaction to be mined and confirmed on the blockchain.
883
1089
  *
@@ -2228,6 +2434,18 @@ interface USDCActionMap {
2228
2434
  * This is a read-only operation.
2229
2435
  */
2230
2436
  balanceOf: Omit<BaseUSDCActions['balanceOf'], 'tokenAddress'>;
2437
+ /**
2438
+ * Get the EIP-712 domain name of the USDC contract on the current chain.
2439
+ *
2440
+ * Automatically uses the USDC contract address for the current chain.
2441
+ * This is a read-only operation with no parameters.
2442
+ */
2443
+ name: ActionParameters & {
2444
+ /**
2445
+ * Optional chain override; defaults to the operation context chain.
2446
+ */
2447
+ chain?: ChainDefinition;
2448
+ };
2231
2449
  }
2232
2450
 
2233
2451
  /**
@@ -2270,6 +2488,252 @@ interface USDTActionMap {
2270
2488
  transfer: BaseUSDTActions['transfer'];
2271
2489
  }
2272
2490
 
2491
+ /**
2492
+ * Versioned wrapper for Gateway action namespaces.
2493
+ *
2494
+ * Follows the same pattern as {@link CCTPActionMap}: each version is a
2495
+ * nested namespace so that action keys read `gateway.v1.deposit`, etc.
2496
+ *
2497
+ * @see {@link GatewayV1ActionMap} for v1 action definitions
2498
+ */
2499
+ interface GatewayActionMap {
2500
+ /** Gateway protocol v1 operations. */
2501
+ readonly v1: GatewayV1ActionMap;
2502
+ }
2503
+ /**
2504
+ * Action map for Circle Gateway Wallet v1 contract operations.
2505
+ *
2506
+ * Mirrors the GatewayWallet interface: deposit variants, delegate management,
2507
+ * and balance queries.
2508
+ *
2509
+ * @see https://developers.circle.com/gateway/references/contract-interfaces-and-events
2510
+ * @see https://developers.circle.com/gateway/references/solana-programs
2511
+ */
2512
+ interface GatewayV1ActionMap {
2513
+ /**
2514
+ * Deposit tokens after approving the Gateway contract. Balance is credited to the caller.
2515
+ *
2516
+ * Corresponds to `deposit(address token, uint256 value)`.
2517
+ */
2518
+ deposit: ActionParameters & {
2519
+ /** Token contract address (e.g. USDC). */
2520
+ token: string;
2521
+ /** Amount in token's smallest unit. */
2522
+ value: bigint;
2523
+ /** Chain with Gateway v1 (optional; defaults to operation context chain). */
2524
+ chain?: ChainDefinition;
2525
+ };
2526
+ /**
2527
+ * Deposit tokens on behalf of another address after approving. Balance is credited to `depositor`.
2528
+ *
2529
+ * Corresponds to `depositFor(address token, address depositor, uint256 value)`.
2530
+ */
2531
+ depositFor: ActionParameters & {
2532
+ /** Token contract address. */
2533
+ token: string;
2534
+ /** Address that will own the resulting balance. */
2535
+ depositor: string;
2536
+ /** Amount in token's smallest unit. */
2537
+ value: bigint;
2538
+ /** Chain with Gateway v1 (optional; defaults to operation context chain). */
2539
+ chain?: ChainDefinition;
2540
+ };
2541
+ /**
2542
+ * Deposit with EIP-2612 permit (gasless approval via signature).
2543
+ *
2544
+ * Corresponds to `depositWithPermit(token, owner, value, deadline, signature)` (bytes)
2545
+ * or the overload with (v, r, s). Use `signature` for EIP-7597 (SCA); use (v, r, s) for EOA.
2546
+ */
2547
+ depositWithPermit: ActionParameters & {
2548
+ /** Token contract address. */
2549
+ token: string;
2550
+ /** Depositor's address (owner in permit). */
2551
+ owner: string;
2552
+ /** Amount in token's smallest unit. */
2553
+ value: bigint;
2554
+ /** Permit deadline (Unix timestamp) or max uint256 for no expiration. */
2555
+ deadline: bigint;
2556
+ /** Signature as bytes (EIP-7597) or omit and use v, r, s. */
2557
+ signature?: `0x${string}`;
2558
+ /** ECDSA v (when not using signature bytes). */
2559
+ v?: number;
2560
+ /** ECDSA r (when not using signature bytes). */
2561
+ r?: `0x${string}`;
2562
+ /** ECDSA s (when not using signature bytes). */
2563
+ s?: `0x${string}`;
2564
+ /** Chain with Gateway v1 (optional; defaults to operation context chain). */
2565
+ chain?: ChainDefinition;
2566
+ };
2567
+ /**
2568
+ * Deposit with EIP-3009 transferWithAuthorization (receiveWithAuthorization).
2569
+ *
2570
+ * Corresponds to `depositWithAuthorization(token, from, value, validAfter, validBefore, nonce, signature)`
2571
+ * or the overload with (v, r, s).
2572
+ */
2573
+ depositWithAuthorization: ActionParameters & {
2574
+ /** Token contract address. */
2575
+ token: string;
2576
+ /** Depositor's address (from in authorization). */
2577
+ from: string;
2578
+ /** Amount in token's smallest unit. */
2579
+ value: bigint;
2580
+ /** Unix timestamp after which the authorization is valid. */
2581
+ validAfter: bigint;
2582
+ /** Unix timestamp before which the authorization is valid. */
2583
+ validBefore: bigint;
2584
+ /** Unique nonce (bytes32). */
2585
+ nonce: `0x${string}`;
2586
+ /** Signature as bytes (EIP-7598) or omit and use v, r, s. */
2587
+ signature?: `0x${string}`;
2588
+ /** ECDSA v (when not using signature bytes). */
2589
+ v?: number;
2590
+ /** ECDSA r (when not using signature bytes). */
2591
+ r?: `0x${string}`;
2592
+ /** ECDSA s (when not using signature bytes). */
2593
+ s?: `0x${string}`;
2594
+ /** Chain with Gateway v1 (optional; defaults to operation context chain). */
2595
+ chain?: ChainDefinition;
2596
+ };
2597
+ /**
2598
+ * Grant spending rights to a delegate on the caller's Gateway account.
2599
+ *
2600
+ * Corresponds to `addDelegate(address token, address delegate)`.
2601
+ */
2602
+ addDelegate: ActionParameters & {
2603
+ /** Token contract address (e.g. USDC). */
2604
+ token: string;
2605
+ /** Address to authorize as a delegate. */
2606
+ delegate: string;
2607
+ /** Chain with Gateway v1 (optional; defaults to operation context chain). */
2608
+ chain?: ChainDefinition;
2609
+ };
2610
+ /**
2611
+ * Revoke spending rights from a delegate on the caller's Gateway account.
2612
+ *
2613
+ * Corresponds to `removeDelegate(address token, address delegate)`.
2614
+ */
2615
+ removeDelegate: ActionParameters & {
2616
+ /** Token contract address (e.g. USDC). */
2617
+ token: string;
2618
+ /** Address to revoke as a delegate. */
2619
+ delegate: string;
2620
+ /** Chain with Gateway v1 (optional; defaults to operation context chain). */
2621
+ chain?: ChainDefinition;
2622
+ };
2623
+ /**
2624
+ * Check whether an address is authorized as a delegate for a depositor's balance.
2625
+ *
2626
+ * Corresponds to `isAuthorizedForBalance(address token, address depositor, address addr)`.
2627
+ */
2628
+ isDelegate: ActionParameters & {
2629
+ /** Token contract address (e.g. USDC). */
2630
+ token: string;
2631
+ /** The depositor (balance owner) address. */
2632
+ depositor: string;
2633
+ /** The address to check for delegate status. */
2634
+ delegate: string;
2635
+ /** Chain with Gateway v1 (optional; defaults to operation context chain). */
2636
+ chain?: ChainDefinition;
2637
+ /** EVM: specific block number to read state at (for finality-aware checks). */
2638
+ blockNumber?: bigint;
2639
+ /** Solana: commitment level for the account read. */
2640
+ commitment?: 'confirmed' | 'finalized';
2641
+ };
2642
+ /**
2643
+ * Start a delayed fund removal from a Gateway account.
2644
+ *
2645
+ * Corresponds to `initiateWithdrawal(address token, uint256 value)` (EVM)
2646
+ * or the `initiate_withdrawal` instruction (Solana).
2647
+ */
2648
+ initiateWithdrawal: ActionParameters & {
2649
+ /** Token contract address (e.g. USDC). */
2650
+ token: string;
2651
+ /** Amount in token's smallest unit. */
2652
+ value: bigint;
2653
+ /** Chain with Gateway v1 (optional; defaults to operation context chain). */
2654
+ chain?: ChainDefinition;
2655
+ };
2656
+ /**
2657
+ * Complete a fund removal after the withdrawal delay has elapsed.
2658
+ *
2659
+ * Corresponds to `withdraw(address token)` (EVM) or the `withdraw`
2660
+ * instruction (Solana). No amount parameter -- the contract returns the
2661
+ * full pending withdrawal balance.
2662
+ */
2663
+ withdraw: ActionParameters & {
2664
+ /** Token contract address (e.g. USDC). */
2665
+ token: string;
2666
+ /** Chain with Gateway v1 (optional; defaults to operation context chain). */
2667
+ chain?: ChainDefinition;
2668
+ };
2669
+ /**
2670
+ * Read the pending withdrawal balance for a depositor.
2671
+ *
2672
+ * Corresponds to `withdrawingBalance(address token, address depositor)` (EVM)
2673
+ * or reading `withdrawing_amount` from the `GatewayDeposit` PDA (Solana).
2674
+ */
2675
+ withdrawingBalance: ActionParameters & {
2676
+ /** Token contract address (e.g. USDC). */
2677
+ token: string;
2678
+ /** The depositor whose pending withdrawal to query. */
2679
+ depositor: string;
2680
+ /** Chain with Gateway v1 (optional; defaults to operation context chain). */
2681
+ chain?: ChainDefinition;
2682
+ };
2683
+ /**
2684
+ * Read the block number at which a pending withdrawal can be completed.
2685
+ *
2686
+ * Corresponds to `withdrawalBlock(address token, address depositor)` (EVM)
2687
+ * or reading `withdrawal_block` from the `GatewayDeposit` PDA (Solana).
2688
+ */
2689
+ withdrawalBlock: ActionParameters & {
2690
+ /** Token contract address (e.g. USDC). */
2691
+ token: string;
2692
+ /** The depositor whose withdrawal block to query. */
2693
+ depositor: string;
2694
+ /** Chain with Gateway v1 (optional; defaults to operation context chain). */
2695
+ chain?: ChainDefinition;
2696
+ };
2697
+ /**
2698
+ * Execute gatewayBurn on the Gateway Wallet contract.
2699
+ * Burns tokens from a source chain as part of a cross-chain spend.
2700
+ *
2701
+ * Corresponds to `gatewayBurn(bytes calldataBytes, bytes signature)`.
2702
+ */
2703
+ gatewayBurn: ActionParameters & {
2704
+ /** ABI-encoded burn intent calldata. */
2705
+ calldataBytes: `0x${string}`;
2706
+ /** Signature over the burn intent(s). */
2707
+ signature: `0x${string}`;
2708
+ /** Chain with Gateway v1 (optional; defaults to operation context chain). */
2709
+ chain?: ChainDefinition;
2710
+ };
2711
+ /**
2712
+ * Execute gatewayMint on the Gateway Minter contract.
2713
+ * Mints tokens on the destination chain to complete a cross-chain spend.
2714
+ *
2715
+ * Corresponds to `gatewayMint(bytes attestationPayload, bytes signature)`.
2716
+ */
2717
+ gatewayMint: ActionParameters & {
2718
+ /** Attestation payload from the Gateway API. */
2719
+ attestation: `0x${string}`;
2720
+ /** Signature over the attestation. */
2721
+ signature: `0x${string}`;
2722
+ /** Chain with Gateway v1 (optional; defaults to operation context chain). */
2723
+ chain?: ChainDefinition;
2724
+ };
2725
+ /**
2726
+ * Sign burn intents using EIP-712 typed data (EVM) or binary encoding (Solana).
2727
+ * Returns the signature needed for the Gateway API transfer call.
2728
+ */
2729
+ signBurnIntents: ActionParameters & {
2730
+ /** EIP-712 typed data for EVM, or binary-encoded data for Solana. */
2731
+ typedData: unknown;
2732
+ /** Chain with Gateway v1 (optional; defaults to operation context chain). */
2733
+ chain?: ChainDefinition;
2734
+ };
2735
+ }
2736
+
2273
2737
  /**
2274
2738
  * Native token-related action maps for the bridge kit.
2275
2739
  *
@@ -2324,14 +2788,16 @@ interface NativeActionMap {
2324
2788
  interface ActionMap {
2325
2789
  /** CCTP-specific operations with automatic address resolution. */
2326
2790
  readonly cctp: CCTPActionMap;
2791
+ /** Gateway Wallet operations, versioned (e.g. gateway.v1.deposit). */
2792
+ readonly gateway: GatewayActionMap;
2793
+ /** Native token operations (ETH, SOL, MATIC, etc.). */
2794
+ readonly native: NativeActionMap;
2327
2795
  /** General token operations requiring explicit token addresses. */
2328
2796
  readonly token: TokenActionMap;
2329
2797
  /** USDC-specific operations with automatic address resolution. */
2330
2798
  readonly usdc: USDCActionMap;
2331
2799
  /** USDT-specific operations with automatic address resolution. */
2332
2800
  readonly usdt: USDTActionMap;
2333
- /** Native token operations. */
2334
- readonly native: NativeActionMap;
2335
2801
  /** Swap operations for DEX aggregator integrations. */
2336
2802
  readonly swap: SwapActionMap;
2337
2803
  }