@circle-fin/provider-cctp-v2 1.1.0 → 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.
package/index.d.ts CHANGED
@@ -17,7 +17,7 @@
17
17
  */
18
18
 
19
19
  import { Abi } from 'abitype';
20
- import { TransactionInstruction, Signer } from '@solana/web3.js';
20
+ import { TransactionInstruction, Signer, AddressLookupTableAccount } from '@solana/web3.js';
21
21
 
22
22
  /**
23
23
  * @packageDocumentation
@@ -435,6 +435,8 @@ declare enum Blockchain {
435
435
  Ink_Testnet = "Ink_Testnet",
436
436
  Linea = "Linea",
437
437
  Linea_Sepolia = "Linea_Sepolia",
438
+ Monad = "Monad",
439
+ Monad_Testnet = "Monad_Testnet",
438
440
  NEAR = "NEAR",
439
441
  NEAR_Testnet = "NEAR_Testnet",
440
442
  Noble = "Noble",
@@ -644,14 +646,26 @@ interface SolanaPreparedChainRequestParams {
644
646
  */
645
647
  instructions: TransactionInstruction[];
646
648
  /**
647
- * Additional signers besides the Adapters wallet (e.g. program-derived authorities).
649
+ * Additional signers besides the Adapter's wallet (e.g. program-derived authorities).
648
650
  */
649
651
  signers?: Signer[];
650
652
  /**
651
653
  * Optional override for how many compute units this transaction may consume.
652
- * If omitted, the networks default compute budget applies.
654
+ * If omitted, the network's default compute budget applies.
653
655
  */
654
656
  computeUnitLimit?: number;
657
+ /**
658
+ * Optional Address Lookup Table accounts for transaction compression.
659
+ * Used to reduce transaction size by compressing frequently-used addresses.
660
+ * This is used by @solana/web3.js adapters that have already fetched the ALT data.
661
+ */
662
+ addressLookupTableAccounts?: AddressLookupTableAccount[];
663
+ /**
664
+ * Optional Address Lookup Table addresses for transaction compression.
665
+ * Used by adapters that need to fetch ALT data themselves (e.g., @solana/kit adapters).
666
+ * These are base58-encoded addresses of ALT accounts to use for compression.
667
+ */
668
+ addressLookupTableAddresses?: string[];
655
669
  }
656
670
  /**
657
671
  * Solana-specific configuration for transaction estimation.
@@ -1333,6 +1347,34 @@ interface CCTPActionMap {
1333
1347
  readonly v2: CCTPv2ActionMap;
1334
1348
  }
1335
1349
 
1350
+ /**
1351
+ * Action map for native token operations (ETH, SOL, MATIC, etc.).
1352
+ *
1353
+ * Native tokens are the primary currency of each blockchain network,
1354
+ * used for paying transaction fees and as a store of value.
1355
+ * These actions operate on the native token without requiring
1356
+ * a separate token contract address.
1357
+ *
1358
+ * @remarks
1359
+ * Native token operations differ from ERC-20/SPL token operations
1360
+ * in that they don't require contract interactions for basic transfers
1361
+ * and balance checks.
1362
+ *
1363
+ * @see {@link ActionMap} for the complete action structure
1364
+ */
1365
+ interface NativeActionMap {
1366
+ /**
1367
+ * Get the native token balance (SOL, ETH, etc.) for a wallet address.
1368
+ */
1369
+ balanceOf: ActionParameters & {
1370
+ /**
1371
+ * The address to check the native balance for. If not provided, it will be
1372
+ * automatically derived from the adapter context.
1373
+ */
1374
+ walletAddress?: string | undefined;
1375
+ };
1376
+ }
1377
+
1336
1378
  interface TokenActionMap {
1337
1379
  /**
1338
1380
  * Set an allowance for a delegate to spend tokens on behalf of the wallet.
@@ -1564,6 +1606,8 @@ interface USDCActionMap {
1564
1606
  interface ActionMap {
1565
1607
  /** CCTP-specific operations with automatic address resolution. */
1566
1608
  readonly cctp: CCTPActionMap;
1609
+ /** Native token operations (ETH, SOL, MATIC, etc.). */
1610
+ readonly native: NativeActionMap;
1567
1611
  /** General token operations requiring explicit token addresses. */
1568
1612
  readonly token: TokenActionMap;
1569
1613
  /** USDC-specific operations with automatic address resolution. */
@@ -3365,6 +3409,16 @@ interface CCTPV2Actions {
3365
3409
  method: 'mint';
3366
3410
  values: BridgeStep;
3367
3411
  };
3412
+ /**
3413
+ * Re-attestation action for CCTP v2 transfers.
3414
+ * Used to request a fresh attestation when the original has expired.
3415
+ */
3416
+ reAttest: {
3417
+ protocol: 'cctp';
3418
+ version: 'v2';
3419
+ method: 'reAttest';
3420
+ values: BridgeFetchAttestationStep;
3421
+ };
3368
3422
  }
3369
3423
  /**
3370
3424
  * CCTPv2 bridging provider interface.
@@ -3917,5 +3971,102 @@ rawAddress: string,
3917
3971
  /** The USDC mint address (ignored for EVM chains, required base58 address for Solana) */
3918
3972
  mintAddress: string) => Promise<string>;
3919
3973
 
3920
- export { CCTPV2BridgingProvider, getMintRecipientAccount };
3974
+ /** A block number value that can be provided as bigint, number, or string. */
3975
+ type BlockNumberInput = bigint | number | string | undefined;
3976
+ /**
3977
+ * Determines whether an attestation has expired based on the current block number.
3978
+ *
3979
+ * An attestation expires when the destination chain's current block number is greater
3980
+ * than or equal to the expiration block specified in the attestation message.
3981
+ * Slow transfers and re-attested messages have `expirationBlock: '0'` and never expire.
3982
+ *
3983
+ * @param attestation - The attestation message containing expiration block information
3984
+ * @param currentBlockNumber - The current block number on the destination chain (bigint, number, or string)
3985
+ * @returns `true` if the attestation has expired, `false` if still valid or never expires
3986
+ * @throws KitError If currentBlockNumber or expirationBlock is invalid
3987
+ *
3988
+ * @example
3989
+ * ```typescript
3990
+ * import { isAttestationExpired } from '@circle-fin/cctp-v2-provider'
3991
+ *
3992
+ * // Check if attestation is expired on EVM chain
3993
+ * const publicClient = await adapter.getPublicClient(destinationChain)
3994
+ * const currentBlock = await publicClient.getBlockNumber()
3995
+ * const expired = isAttestationExpired(attestation, currentBlock)
3996
+ *
3997
+ * if (expired) {
3998
+ * const freshAttestation = await provider.reAttest(source, burnTxHash)
3999
+ * }
4000
+ * ```
4001
+ *
4002
+ * @example
4003
+ * ```typescript
4004
+ * // Check on Solana
4005
+ * const slot = await adapter.getConnection(destinationChain).getSlot()
4006
+ * const expired = isAttestationExpired(attestation, slot)
4007
+ * ```
4008
+ */
4009
+ declare const isAttestationExpired: (attestation: AttestationMessage, currentBlockNumber: BlockNumberInput) => boolean;
4010
+ /**
4011
+ * Calculates the number of blocks remaining until an attestation expires.
4012
+ *
4013
+ * Returns the difference between the expiration block and the current block number.
4014
+ * Returns `null` if the attestation has `expirationBlock: '0'` (never expires).
4015
+ * Returns `0n` or a negative bigint if the attestation has already expired.
4016
+ *
4017
+ * @param attestation - The attestation message containing expiration block information
4018
+ * @param currentBlockNumber - The current block number on the destination chain (bigint, number, or string)
4019
+ * @returns The number of blocks until expiry as a bigint, or `null` if the attestation never expires
4020
+ * @throws KitError If currentBlockNumber or expirationBlock is invalid
4021
+ *
4022
+ * @example
4023
+ * ```typescript
4024
+ * import { getBlocksUntilExpiry } from '@circle-fin/cctp-v2-provider'
4025
+ *
4026
+ * const publicClient = await adapter.getPublicClient(destinationChain)
4027
+ * const currentBlock = await publicClient.getBlockNumber()
4028
+ * const blocksRemaining = getBlocksUntilExpiry(attestation, currentBlock)
4029
+ *
4030
+ * if (blocksRemaining === null) {
4031
+ * console.log('Attestation never expires')
4032
+ * } else if (blocksRemaining <= 0n) {
4033
+ * console.log('Attestation has expired')
4034
+ * } else {
4035
+ * console.log(`${blocksRemaining} blocks until expiry`)
4036
+ * }
4037
+ * ```
4038
+ */
4039
+ declare const getBlocksUntilExpiry: (attestation: AttestationMessage, currentBlockNumber: BlockNumberInput) => bigint | null;
4040
+ /**
4041
+ * Determines whether a mint failure was caused by an expired attestation.
4042
+ *
4043
+ * This function inspects the error thrown during a mint operation to detect
4044
+ * if the failure is due to the attestation's expiration block being exceeded.
4045
+ * When this returns `true`, the caller should use `reAttest()` to obtain a
4046
+ * fresh attestation before retrying the mint.
4047
+ *
4048
+ * @param error - The error thrown during the mint operation
4049
+ * @returns `true` if the error indicates the attestation has expired, `false` otherwise
4050
+ *
4051
+ * @example
4052
+ * ```typescript
4053
+ * import { isMintFailureRelatedToAttestation } from '@circle-fin/cctp-v2-provider'
4054
+ *
4055
+ * try {
4056
+ * await mintRequest.execute()
4057
+ * } catch (error) {
4058
+ * if (isMintFailureRelatedToAttestation(error)) {
4059
+ * // Attestation expired - get a fresh one
4060
+ * const freshAttestation = await provider.reAttest(source, burnTxHash)
4061
+ * const newMintRequest = await provider.mint(source, destination, freshAttestation)
4062
+ * await newMintRequest.execute()
4063
+ * } else {
4064
+ * throw error
4065
+ * }
4066
+ * }
4067
+ * ```
4068
+ */
4069
+ declare const isMintFailureRelatedToAttestation: (error: unknown) => boolean;
4070
+
4071
+ export { CCTPV2BridgingProvider, getBlocksUntilExpiry, getMintRecipientAccount, isAttestationExpired, isMintFailureRelatedToAttestation };
3921
4072
  export type { CCTPV2Config };