@coinbase/cdp-sdk
Version:
SDK for interacting with the Coinbase Developer Platform Wallet API
71 lines • 3.04 kB
TypeScript
import type { EvmAccount } from "../accounts/evm/types.js";
import type { SignTypedDataOptions } from "../client/evm/evm.types.js";
import type { TransactionSigner } from "@solana/kit";
import type { ClientEvmSigner } from "@x402/evm";
import type { Address, Hex } from "viem";
/**
* The subset of a CDP EVM server account (EOA) required to sign x402 payments.
* Derived from the SDK's {@link EvmAccount} type so the adapter stays in sync
* with the real account surface.
*/
export type CdpEvmAccount = Pick<EvmAccount, "address" | "signTypedData">;
/**
* Converts a CDP EVM server account (EOA) into an x402-compatible signer.
*
* @param account - A CDP EVM account from `cdpClient.evm.getOrCreateAccount()`
* @returns A `ClientEvmSigner` compatible with `@x402/evm`'s `registerExactEvmScheme`
*/
export declare function fromCdpEvmAccount(account: CdpEvmAccount): ClientEvmSigner;
/**
* The subset of a CDP Smart Account (EvmSmartAccount) required to sign x402
* payments. Its `signTypedData` mirrors the SDK smart-account signature, which
* requires a `network` derived from the EIP-712 domain's `chainId`.
*/
export interface CdpSmartAccount {
address: Address;
signTypedData(options: Omit<SignTypedDataOptions, "address"> & {
network: string;
}): Promise<Hex>;
}
/**
* Resolves a CDP SDK network name from an EIP-712 domain chain ID.
*
* @param chainId - The EIP-712 domain chain ID to resolve.
* @throws {Error} If the chain ID is undefined or not supported.
* @returns The CDP SDK network name (e.g. `"base-sepolia"`).
*/
export declare function resolveNetworkFromChainId(chainId: number | undefined): string;
/**
* Converts a CDP Smart Account (EvmSmartAccount) into an x402-compatible signer.
*
* CDP Smart Accounts differ from EOAs in that their `signTypedData` requires a
* `network` parameter. This adapter derives the network automatically from the
* EIP-712 domain's `chainId`.
*
* @param account - A CDP Smart Account from `cdpClient.evm.getOrCreateSmartAccount()`
* @returns A `ClientEvmSigner` compatible with `@x402/evm`'s `registerExactEvmScheme`
*/
export declare function fromCdpSmartWallet(account: CdpSmartAccount): ClientEvmSigner;
/**
* Minimal interface for a CDP Solana account.
* Matches the relevant methods from CdpClient's SolanaAccount.
*/
export interface CdpSolanaAccount {
address: string;
signTransaction(options: {
transaction: string;
}): Promise<{
signedTransaction: string;
}>;
}
/**
* Converts a CDP Solana account into an x402-compatible `TransactionSigner`.
*
* Handles the translation between CDP's base64-encoded transaction strings and
* `@solana/kit`'s compiled transaction objects.
*
* @param account - A CDP Solana account from `cdpClient.solana.getOrCreateAccount()`
* @returns A `TransactionSigner` compatible with `@x402/svm`'s `registerExactSvmScheme`
*/
export declare function cdpSolanaAccountToSvmSigner(account: CdpSolanaAccount): TransactionSigner;
//# sourceMappingURL=account-signers.d.ts.map