UNPKG

@coinbase/cdp-sdk

Version:

SDK for interacting with the Coinbase Developer Platform Wallet API

14,216 lines • 583 kB
/**
 * Generated by orval v7.21.0 🍺
 * Do not edit manually.
 * Coinbase Developer Platform APIs
 * The Coinbase Developer Platform APIs - leading the world's transition onchain.
 * OpenAPI spec version: 2.0.0
 */
/**
 * The type of the Account.

- `prime`: a linked Coinbase Prime account.
- `business`: a linked Coinbase Business account.
- `cdp`: a CDP-native account created via this API. Used for accounts created on
  behalf of an Entity and for Customer-owned accounts.
 */
export type AccountType = (typeof AccountType)[keyof typeof AccountType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AccountType = {
  prime: "prime",
  business: "business",
  cdp: "cdp",
} as const;

/**
 * The ID of the Account, which is a UUID prefixed by the string `account_`.
 * @pattern ^account_[a-f0-9\-]{36}$
 */
export type AccountId = string;

/**
 * The Owner ID of the Account.

Owner IDs are UUIDs prefixed with the Owner Type as follows:

* **Entity**: `entity_` - If the Owner is your Entity, e.g. `entity_af2937b0-9846-4fe7-bfe9-ccc22d935114`.

* **Customer**: `customer_` - If the Owner is one of your Customers,
  e.g. `customer_af2937b0-9846-4fe7-bfe9-ccc22d935114`. Customer ownership requires the
  Customer to have the `custodyCrypto`, `custodyFiat`, and `custodyStablecoin`
  capabilities enabled.
 * @pattern ^(entity|customer)_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
 */
export type Owner = string;

/**
 * An optional name for the account. Must be 1-64 characters and can only contain alphanumeric characters, hyphens, and spaces.
 * @maxLength 64
 * @pattern ^[a-zA-Z0-9 -]{1,64}$
 */
export type AccountName = string;

export interface Account {
  accountId: AccountId;
  type: AccountType;
  owner: Owner;
  name?: AccountName;
  /** The timestamp when the account was created. */
  createdAt: string;
  /** The timestamp when the account was last updated. */
  updatedAt: string;
}

export interface ListResponse {
  /** The token for the next page of items, if any. */
  nextPageToken?: string;
}

/**
 * The code that indicates the type of error that occurred. These error codes can be used to determine how to handle the error.
 */
export type ErrorType = (typeof ErrorType)[keyof typeof ErrorType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const ErrorType = {
  already_exists: "already_exists",
  authorization_expired: "authorization_expired",
  bad_gateway: "bad_gateway",
  capture_expired: "capture_expired",
  client_closed_request: "client_closed_request",
  customer_not_authorized: "customer_not_authorized",
  endpoint_unavailable: "endpoint_unavailable",
  faucet_limit_exceeded: "faucet_limit_exceeded",
  forbidden: "forbidden",
  idempotency_error: "idempotency_error",
  incompatible_event_types: "incompatible_event_types",
  internal_server_error: "internal_server_error",
  invalid_request: "invalid_request",
  invalid_webhook_headers: "invalid_webhook_headers",
  invalid_webhook_url: "invalid_webhook_url",
  invalid_sql_query: "invalid_sql_query",
  invalid_signature: "invalid_signature",
  malformed_transaction: "malformed_transaction",
  not_found: "not_found",
  operation_in_progress: "operation_in_progress",
  payment_method_required: "payment_method_required",
  payment_required: "payment_required",
  settlement_failed: "settlement_failed",
  rate_limit_exceeded: "rate_limit_exceeded",
  request_canceled: "request_canceled",
  service_unavailable: "service_unavailable",
  subscription_limit_exceeded: "subscription_limit_exceeded",
  timed_out: "timed_out",
  unauthorized: "unauthorized",
  unsupported_tos_language: "unsupported_tos_language",
  policy_violation: "policy_violation",
  policy_in_use: "policy_in_use",
  account_limit_exceeded: "account_limit_exceeded",
  network_not_tradable: "network_not_tradable",
  guest_permission_denied: "guest_permission_denied",
  guest_region_forbidden: "guest_region_forbidden",
  guest_transaction_limit: "guest_transaction_limit",
  guest_transaction_count: "guest_transaction_count",
  phone_number_verification_expired: "phone_number_verification_expired",
  otp_verification_code_invalid: "otp_verification_code_invalid",
  otp_verification_destination_mismatch: "otp_verification_destination_mismatch",
  otp_verification_expired: "otp_verification_expired",
  otp_verification_invalid: "otp_verification_invalid",
  otp_verification_not_found: "otp_verification_not_found",
  otp_verification_required: "otp_verification_required",
  document_verification_failed: "document_verification_failed",
  recipient_allowlist_violation: "recipient_allowlist_violation",
  recipient_allowlist_pending: "recipient_allowlist_pending",
  refund_expired: "refund_expired",
  travel_rules_recipient_violation: "travel_rules_recipient_violation",
  source_account_invalid: "source_account_invalid",
  target_account_invalid: "target_account_invalid",
  source_account_not_found: "source_account_not_found",
  target_account_not_found: "target_account_not_found",
  source_asset_not_supported: "source_asset_not_supported",
  target_asset_not_supported: "target_asset_not_supported",
  target_email_invalid: "target_email_invalid",
  target_onchain_address_invalid: "target_onchain_address_invalid",
  transfer_amount_invalid: "transfer_amount_invalid",
  transfer_asset_not_supported: "transfer_asset_not_supported",
  transfer_quote_expired: "transfer_quote_expired",
  insufficient_balance: "insufficient_balance",
  metadata_too_many_entries: "metadata_too_many_entries",
  metadata_key_too_long: "metadata_key_too_long",
  metadata_value_too_long: "metadata_value_too_long",
  travel_rules_field_missing: "travel_rules_field_missing",
  asset_mismatch: "asset_mismatch",
  mfa_already_enrolled: "mfa_already_enrolled",
  mfa_invalid_code: "mfa_invalid_code",
  mfa_challenge_not_found: "mfa_challenge_not_found",
  mfa_flow_expired: "mfa_flow_expired",
  mfa_required: "mfa_required",
  mfa_not_enrolled: "mfa_not_enrolled",
  order_quote_expired: "order_quote_expired",
  order_already_filled: "order_already_filled",
  order_already_canceled: "order_already_canceled",
  account_not_ready: "account_not_ready",
  insufficient_liquidity: "insufficient_liquidity",
  insufficient_allowance: "insufficient_allowance",
  transaction_simulation_failed: "transaction_simulation_failed",
  delegation_not_found: "delegation_not_found",
  delegation_expired: "delegation_expired",
  delegation_revoked: "delegation_revoked",
  delegation_not_authorized: "delegation_not_authorized",
  delegation_not_enabled: "delegation_not_enabled",
  network_mismatch: "network_mismatch",
  already_enabled: "already_enabled",
  payment_session_already_canceled: "payment_session_already_canceled",
  payment_session_already_authorized: "payment_session_already_authorized",
  payment_session_action_pending: "payment_session_action_pending",
  no_capturable_balance: "no_capturable_balance",
  no_voidable_balance: "no_voidable_balance",
  no_refundable_balance: "no_refundable_balance",
  entity_not_configured_for_payment_acceptance: "entity_not_configured_for_payment_acceptance",
  daily_transaction_limit_exceeded: "daily_transaction_limit_exceeded",
  daily_amount_limit_exceeded: "daily_amount_limit_exceeded",
  stale_attestation: "stale_attestation",
  moderation_rejected: "moderation_rejected",
  mandate_action_pending: "mandate_action_pending",
  mandate_policy_violation: "mandate_policy_violation",
  mandate_expired: "mandate_expired",
  mandate_canceled: "mandate_canceled",
  mandate_revoked: "mandate_revoked",
  mandate_invalid_status: "mandate_invalid_status",
} as const;

/**
 * A valid HTTP or HTTPS URL.
 * @minLength 11
 * @maxLength 2048
 * @pattern ^https?://.*$
 */
export type Url = string;

/**
 * The name of a capability. Capabilities represent granular functional permissions
that determine what actions a customer can perform. Each capability must be
explicitly requested before use.

 */
export type CapabilityName = (typeof CapabilityName)[keyof typeof CapabilityName];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const CapabilityName = {
  CustodyCrypto: "custodyCrypto",
  CustodyFiat: "custodyFiat",
  CustodyStablecoin: "custodyStablecoin",
  TradeCrypto: "tradeCrypto",
  TradeStablecoin: "tradeStablecoin",
  TransferCrypto: "transferCrypto",
  TransferFiat: "transferFiat",
  TransferStablecoin: "transferStablecoin",
} as const;

/**
 * An error response including the code for the type of error and a human-readable message describing the error.
 */
export interface Error {
  errorType: ErrorType;
  /** The error message. */
  errorMessage: string;
  /** A unique identifier for the request that generated the error. This can be used to help debug issues with the API. */
  correlationId?: string;
  /** A link to the corresponding error documentation. */
  errorLink?: Url;
  /** The capability code(s) that were not authorized for the customer on
this request. Present only when `errorType` is
`customer_not_authorized`; absent for every other error type.

Use this list to render onboarding UX for the listed capabilities, or
fetch `GET /v2/customers/{customerId}` and inspect each entry's
`status` / `requirements` to discover what (if anything) can be
submitted to resolve the block.
 */
  unauthorizedCapabilities?: CapabilityName[];
}

/**
 * Compliance context for a request. Carries per-request compliance signals,
such as the IP address of the individual (i.e., end-customer) that
initiated the request.

This object is request-only — it is never echoed back in responses.
Inner fields are write-only.

 */
export interface Compliance {
  /** IPv4 or IPv6 address of the individual (i.e., end-customer) that
initiated this request. NOT the IP of the partner server making the
API call.
 */
  requesterIpAddress?: string;
}

export interface CreateAccountRequest {
  /** The Owner of the Account to create.
* If omitted, the account will be owned by the Entity making the request.
* If the account is for a customer, the value will be a Customer ID,
  e.g. `customer_af2937b0-9846-4fe7-bfe9-ccc22d935114`.

* Further, the corresponding Customer must have all of the following capabilities enabled:
  - `custodyCrypto`
  - `custodyFiat`
  - `custodyStablecoin`. */
  owner?: Owner;
  name?: AccountName;
  /** Required when `owner` is a Customer ID; omit for Entity-owned accounts. */
  compliance?: Compliance;
}

/**
 * The symbol of the asset (e.g., eth, usd, usdc, usdt).
 * @minLength 1
 * @maxLength 42
 */
export type Asset = string;

/**
 * The type of the asset.
 */
export type AssetType = (typeof AssetType)[keyof typeof AssetType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AssetType = {
  fiat: "fiat",
  crypto: "crypto",
} as const;

/**
 * An asset, e.g. fiat or crypto.
 */
export interface BalancesAsset {
  symbol: Asset;
  type: AssetType;
  /** The name of the asset. */
  name: string;
  /** The number of decimals (i.e. significant digits to the right of the decimal point) supported for the asset. */
  decimals: number;
}

/**
 * Available and total amounts for a specific currency.
 */
export interface AmountDetail {
  /** The amount that is currently available to be used. */
  available: string;
  /** The total amount, including the amount that is currently on hold. */
  total: string;
}

/**
 * Amount details denominated in different assets. 
- The keys represent the asset symbols (e.g., "btc", "usd"), - Each value contains available and total amounts. - There will always be an entry for the asset specified in the `asset` field.
 */
export type BalanceAmount = { [key: string]: AmountDetail };

/**
 * A balance of an asset.
 */
export interface Balance {
  asset: BalancesAsset;
  /** Amount details denominated in different assets. 
- The keys represent the asset symbols (e.g., "btc", "usd"), - Each value contains available and total amounts. - There will always be an entry for the asset specified in the `asset` field. */
  amount: BalanceAmount;
}

/**
 * A list of balances for an account.
 */
export interface Balances {
  /** The list of balances. */
  balances: Balance[];
}

/**
 * The ID of the Customer, which is a UUID prefixed by `customer_`.
 * @pattern ^customer_[a-f0-9\-]{36}$
 */
export type CustomerId = string;

/**
 * The type of the customer. Required on create; accepted but ignored on update.

 */
export type CustomerType = (typeof CustomerType)[keyof typeof CustomerType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const CustomerType = {
  CustomerTypeIndividual: "individual",
} as const;

/**
 * The status of a capability. Based on recoverability:
- `unrequested`: Capability has not been requested by the customer
- `pending`: Customer can take action to resolve (requirements `due` or `rejected`)
- `active`: Capability is enabled and can be used
- `inactive`: Permanently blocked - no customer action possible

 */
export type CapabilityStatus = (typeof CapabilityStatus)[keyof typeof CapabilityStatus];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const CapabilityStatus = {
  unrequested: "unrequested",
  pending: "pending",
  active: "active",
  inactive: "inactive",
} as const;

/**
 * The current state of a capability for a customer. The `status` field is always
present. When `requested` is `false`, the status will be `unrequested`.

 */
export interface Capability {
  /** Whether the customer has explicitly requested this capability. */
  requested: boolean;
  /** Current status of the capability. When `requested` is `false`, status is `unrequested`.
When `requested` is `true`, status is one of `pending`, `active`, or `inactive`.
 */
  status: CapabilityStatus;
}

/**
 * The current state of each capability for a Customer. Each capability shows
whether it has been requested and its current status.

 */
export interface CapabilitiesMap {
  /** Hold cryptocurrency in a Coinbase custodial account. */
  custodyCrypto?: Capability;
  /** Hold fiat currency in a Coinbase custodial account. */
  custodyFiat?: Capability;
  /** Hold stablecoin in a Coinbase custodial account. */
  custodyStablecoin?: Capability;
  /** Trade cryptocurrency. */
  tradeCrypto?: Capability;
  /** Trade stablecoin. */
  tradeStablecoin?: Capability;
  /** Transfer cryptocurrency to another party. */
  transferCrypto?: Capability;
  /** Transfer fiat currency to another party. */
  transferFiat?: Capability;
  /** Transfer stablecoin to another party. */
  transferStablecoin?: Capability;
}

/**
 * The current status of a requirement:
- `due`: Must be submitted and no set deadline has passed
- `past_due`: Must be submitted and a set deadline has passed
- `pending`: Submitted, awaiting verification
- `rejected`: Verification failed - customer must resubmit

For a Terms of Service requirement, `past_due` applies if any unaccepted
version has a deadline set in the past. Otherwise the status is `due`,
including when a version has no deadline and requires immediate acceptance,
or when every set deadline is in the future and acceptance is in grace.

When verification passes, the requirement disappears from the response entirely.

 */
export type RequirementStatus = (typeof RequirementStatus)[keyof typeof RequirementStatus];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const RequirementStatus = {
  due: "due",
  past_due: "past_due",
  pending: "pending",
  rejected: "rejected",
} as const;

/**
 * Stable, opaque identifier for a specific Terms of Service version
(for example, `us_individual_2026-05-29`). The same identifier is
surfaced on `Customer.requirements.tos.tosVersions[].versionId` (the
versions a Customer still needs to accept) and on
`Customer.tosAcceptances[].versionId` (the versions the Customer has
accepted). Treat the value as opaque and submit it verbatim; the
identifier format is stable across API versions, but the set of
valid values grows over time as new Terms of Service versions are
published.

 * @minLength 1
 * @maxLength 64
 */
export type TosVersionId = string;

/**
 * Metadata for one Terms of Service document a Customer may need to
accept. Each entry represents one logical document (identified by
`versionId`) that may be published in multiple languages —
`languages` lists the BCP 47 language tags the document is available
to view and accept in. An optional `deadline` records the end of a grace
period: a future deadline is non-blocking `due`, an elapsed deadline is
`past_due`, and no deadline means acceptance is required immediately with
status `due`. `url` is the canonical, language-agnostic document URL;
partners append `?lang=<tag>` (where `<tag>` is one of `languages`) to
retrieve a specific translation, and omit the parameter to let the
documentation site choose a default. This API does not serve Terms of
Service body content; this schema describes metadata only.

 */
export interface TermsOfService {
  /** Stable identifier for this Terms of Service document. Submit this
value as `versionId` on a `TosAcceptance` to record acceptance.
 */
  versionId: TosVersionId;
  /** Optional deadline by which the Customer must accept this Terms of
Service version, in ISO 8601 / RFC 3339 format. A future deadline is
non-blocking grace with requirement status `due`; an elapsed deadline
produces `past_due`. When omitted, acceptance is required immediately
and the requirement status remains `due`.
 */
  deadline?: string;
  /**
   * BCP 47 language tags this Terms of Service document can be viewed
and accepted in. The list is non-empty (every published document
carries at least one language). Append the chosen tag to `url` as
`?lang=<tag>` to fetch the localized document, and submit the same
tag as `language` on the corresponding `TosAcceptance` to record
which translation the Customer reviewed.

   * @minItems 1
   */
  languages: string[];
  /** Canonical, language-agnostic URL where the Terms of Service
document is hosted (for example,
`https://www.coinbase.com/legal/user-agreements-third-party-provider`).
Append `?lang=<tag>` (where `<tag>` is one of `languages`) to
retrieve a specific translation; without the parameter, the
documentation site renders a default translation.
 */
  url: Url;
}

/**
 * Identifier for a tax attestation form a Customer may need to
complete. The same identifier is surfaced on
`Customer.requirements.taxAttestation.taxForms[]` (the forms a
Customer still needs to attest to) and submitted back as `form` on
`Customer.taxAttestations[]` to record the attestation.

 */
export type TaxForm = (typeof TaxForm)[keyof typeof TaxForm];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const TaxForm = {
  us_w9: "us_w9",
} as const;

/**
 * A single requirement that a customer must submit to enable capabilities.
Requirements are only shown for requested capabilities.

 */
export interface Requirement {
  status: RequirementStatus;
  /** Optional aggregate deadline by which this requirement must be satisfied.

For the `tos` requirement, this is the earliest set deadline among the
unaccepted required Terms of Service versions listed in `tosVersions`.
It is omitted only when none of the unaccepted versions has a deadline.
Do not infer `past_due` or whether the requirement blocks from this
aggregate field alone; inspect each version's deadline.
 */
  deadline?: string;
  /** List of capabilities affected by this requirement, sorted alphabetically.
Only present for `due`, `past_due`, `pending`, or `rejected` statuses.
 */
  impact?: CapabilityName[];
  /** Required Terms of Service versions the Customer has not yet
accepted, with the metadata needed to render an acceptance UI
(each entry carries a stable `versionId`, the BCP 47
`languages` the version is published in, an optional per-version
`deadline`, and a language-agnostic `url`). A missing deadline means
acceptance is required immediately while the requirement status remains
`due`; only a set deadline in the past produces `past_due`. This field
appears only under the requirement key `tos`; do not infer meaning from
`tosVersions` on other requirement keys. Only populated for the `tos`
requirement; omitted on every other requirement key. Submit each
`versionId` back via `tosAcceptances[].versionId` on `Update Customer`
(or `Create Customer`) together with `language` and `acceptedAt` to
clear the requirement.
 */
  tosVersions?: TermsOfService[];
  /** Required tax attestation forms the Customer has not yet completed.
This field appears only under the requirement key `taxAttestation`.
Submit each `form` back via `taxAttestations[].form` on
`Update Customer` (or `Create Customer`) together with the other
fields required for that form to clear the requirement.
 */
  taxForms?: TaxForm[];
}

/**
 * Map of requirements to be submitted. Each key is the field name
(e.g., "ssnLast4"), with values to describe its state. Requirements
are only shown for requested capabilities. When a requirement is
verified, it disappears from this map.

For the `tos` key, each entry in `tosVersions[]` has its own optional
deadline. The requirement-level `deadline` is an aggregate of those rows:
the earliest set deadline among unaccepted versions, not a separate clock.
A version with no deadline requires immediate acceptance but keeps the
aggregate status `due`. A future deadline is also `due` and represents
non-blocking grace. The aggregate status is `past_due` only when at least
one unaccepted version has a deadline set in the past. Do not infer status
or blocking behavior from omission of the aggregate deadline.

 */
export interface RequirementsMap {
  [key: string]: Requirement;
}

/**
 * An email address. Maximum length 254 characters per [RFC 5321](https://www.rfc-editor.org/rfc/rfc5321).
 * @maxLength 254
 * @pattern ^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}/-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$
 */
export type Email = string;

/**
 * Individual customer data returned on read — the `individual` object on
Get / Create / Update Customer responses. Only contact-identity fields are
echoed back; every other field accepted on the `IndividualInput` object
(`address`, `ssnLast4`, `dateOfBirth`, `fullSsn`, `citizenship`,
`phoneNumber`, and the CDD fields) is ingestion-only and never returned.

 */
export interface Individual {
  /** First name (given name). */
  firstName?: string;
  /** Last name (family name/surname). */
  lastName?: string;
  /** Email address for the customer. */
  email?: Email;
}

/**
 * The ID of the Project, a UUID v4.
 * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
 */
export type ProjectId = string;

/**
 * A single Terms of Service acceptance recorded for a Customer. Submit
one entry per required document listed in
`Customer.requirements.tos.tosVersions[]` (returned on `Get Customer`,
`Create Customer`, and `Update Customer`). `language` records the
single translation the Customer actually reviewed.

When new required Terms of Service versions are published, only the
new `versionId`s appear in `Customer.requirements.tos.tosVersions[]`;
submit acceptances for only those new version(s).

 */
export interface TosAcceptance {
  /** The `versionId` of the Terms of Service document being accepted,
as listed in `Customer.requirements.tos.tosVersions[]`.
 */
  versionId: TosVersionId;
  /** BCP 47 language tag of the Terms of Service translation the
Customer reviewed. At write time the server rejects values that
are not listed under `languages` on the matching required
document for this Customer (same `versionId` as listed in
`Customer.requirements.tos.tosVersions[]`).
 */
  language: string;
  /** Timestamp at which the Customer accepted the Terms of Service,
in ISO 8601 / RFC 3339 format. The server may validate or reject
obviously non-credible timestamps; when enforcement tightens,
the authoritative acceptance time may be recorded server-side
instead of trusting client-supplied values alone.
 */
  acceptedAt: string;
}

/**
 * A customer record returned on read (Get / Create / Update Customer).
 */
export interface Customer {
  customerId: CustomerId;
  type: CustomerType;
  /** Current state of each capability for this customer. Each capability
shows whether it has been requested and its current status.
 */
  readonly capabilities: CapabilitiesMap;
  /** Map of requirements to be submitted. Each key is the field name, with
values to describe its state. Requirements are only shown for requested
capabilities. When a requirement is fulfilled, it disappears from this map.
 */
  readonly requirements: RequirementsMap;
  /** Timestamp when the customer was created. */
  readonly createdAt?: string;
  /** Timestamp when the customer was last updated. */
  readonly updatedAt?: string;
  individual?: Individual;
  /** The project IDs that this customer is associated with. */
  projectIds?: ProjectId[];
  /** Terms of Service acceptances recorded for the customer.
   */
  tosAcceptances?: TosAcceptance[];
}

/**
 * Request to enable or disable a capability.
 */
export interface CapabilityInput {
  /** Whether to request this capability. */
  requested: boolean;
}

/**
 * The capabilities to request for a Customer. Each capability can be
individually requested. The requirements to enable each capability
will be returned in the response.

 */
export interface CapabilitiesMapInput {
  /** Hold cryptocurrency in a Coinbase custodial account. */
  custodyCrypto?: CapabilityInput;
  /** Hold fiat currency in a Coinbase custodial account. */
  custodyFiat?: CapabilityInput;
  /** Hold stablecoin in a Coinbase custodial account. */
  custodyStablecoin?: CapabilityInput;
  /** Trade cryptocurrency. */
  tradeCrypto?: CapabilityInput;
  /** Trade stablecoin. */
  tradeStablecoin?: CapabilityInput;
  /** Transfer cryptocurrency to another party. */
  transferCrypto?: CapabilityInput;
  /** Transfer fiat currency to another party. */
  transferFiat?: CapabilityInput;
  /** Transfer stablecoin to another party. */
  transferStablecoin?: CapabilityInput;
}

/**
 * A physical address with standard address components including street, city, state/province, postal code, and country.
 */
export interface PhysicalAddress {
  /** Primary street address. */
  line1?: string;
  /** Secondary address information. */
  line2?: string;
  /** City or locality. */
  city?: string;
  /** State, province, or region. */
  state?: string;
  /** Postal or ZIP code. */
  postCode?: string;
  /**
   * ISO 3166-1 alpha-2 country code (2 characters). See https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes.
   * @minLength 2
   * @maxLength 2
   */
  countryCode?: string;
}

/**
 * Date of birth with lenient formatting. Accepts both zero-padded ("04", "07")
and single-digit ("4", "7") values for day and month.

 */
export interface DateOfBirthLenient {
  /**
   * Day of birth (1-31). Both single-digit ("7") and zero-padded ("07") formats are accepted.
   * @minLength 1
   * @maxLength 2
   * @pattern ^(?:0?[1-9]|[12][0-9]|3[01])$
   */
  day?: string;
  /**
   * Month of birth (1-12). Both single-digit ("4") and zero-padded ("04") formats are accepted.
   * @minLength 1
   * @maxLength 2
   * @pattern ^(?:0?[1-9]|1[0-2])$
   */
  month?: string;
  /**
   * Year of birth (four digits).
   * @minLength 4
   * @maxLength 4
   * @pattern ^[0-9]{4}$
   */
  year?: string;
}

/**
 * An ISO 3166-1 alpha-2 country code.
 * @minLength 2
 * @maxLength 2
 * @pattern ^[A-Z]{2}$
 */
export type CountryCode = string;

/**
 * A phone number in [E.164](https://en.wikipedia.org/wiki/E.164) format.
 * @pattern ^\+[1-9]\d{1,14}$
 */
export type PhoneNumber = string;

/**
 * ISO 3166-1 alpha-2 country code. Only US addresses
are currently supported.

 */
export type IndividualInputAddressAllOfCountryCode =
  (typeof IndividualInputAddressAllOfCountryCode)[keyof typeof IndividualInputAddressAllOfCountryCode];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const IndividualInputAddressAllOfCountryCode = {
  US: "US",
} as const;

export type IndividualInputAddressAllOf = {
  /** ISO 3166-1 alpha-2 country code. Only US addresses
are currently supported.
 */
  countryCode?: IndividualInputAddressAllOfCountryCode;
};

/**
 * Primary residential address. Only US addresses are currently
supported. Non-US `countryCode` values are rejected with a 400.

 */
export type IndividualInputAddress = PhysicalAddress & IndividualInputAddressAllOf;

/**
 * Primary purpose for using Coinbase services.

 */
export type IndividualInputPurposeOfAccount =
  (typeof IndividualInputPurposeOfAccount)[keyof typeof IndividualInputPurposeOfAccount];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const IndividualInputPurposeOfAccount = {
  investing: "investing",
  long_term_investment: "long_term_investment",
  short_term_investment: "short_term_investment",
  trading: "trading",
  trading_on_coinbase: "trading_on_coinbase",
  trading_on_other_exchanges: "trading_on_other_exchanges",
  day_trading: "day_trading",
  arbitrage_trading: "arbitrage_trading",
  online_purchases: "online_purchases",
  online_payments: "online_payments",
  payments_or_gifts: "payments_or_gifts",
  payments_to_friends: "payments_to_friends",
  transfer_crypto: "transfer_crypto",
  investing_on_other_exchanges: "investing_on_other_exchanges",
  business: "business",
  other: "other",
} as const;

/**
 * Primary source of funds for the account.

 */
export type IndividualInputSourceOfFunds =
  (typeof IndividualInputSourceOfFunds)[keyof typeof IndividualInputSourceOfFunds];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const IndividualInputSourceOfFunds = {
  salary: "salary",
  employment_business_income: "employment_business_income",
  investments: "investments",
  savings: "savings",
  pension: "pension",
  business_earnings: "business_earnings",
  crypto_assets: "crypto_assets",
  inheritance: "inheritance",
  sale_of_assets: "sale_of_assets",
  sale_of_company_shares_or_dividends: "sale_of_company_shares_or_dividends",
  sale_of_property: "sale_of_property",
  sale_of_other_assets: "sale_of_other_assets",
  credit_or_loan: "credit_or_loan",
  government_benefits_or_credits: "government_benefits_or_credits",
  legal_settlement: "legal_settlement",
  family_or_third_party: "family_or_third_party",
  lottery_or_gambling: "lottery_or_gambling",
  crypto_mining: "crypto_mining",
  other: "other",
} as const;

/**
 * Current employment status.

 */
export type IndividualInputEmploymentStatus =
  (typeof IndividualInputEmploymentStatus)[keyof typeof IndividualInputEmploymentStatus];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const IndividualInputEmploymentStatus = {
  employed_fulltime: "employed_fulltime",
  employed_parttime: "employed_parttime",
  self_employed: "self_employed",
  employed_government_official: "employed_government_official",
  employed_company_officer_or_board_member: "employed_company_officer_or_board_member",
  employed_crypto_related_business: "employed_crypto_related_business",
  personal_trader_or_angel_investor: "personal_trader_or_angel_investor",
  crypto_miner: "crypto_miner",
  student: "student",
  retired: "retired",
  homemaker: "homemaker",
  unemployed: "unemployed",
  dependent: "dependent",
} as const;

/**
 * Industry or occupation.

 */
export type IndividualInputOccupation =
  (typeof IndividualInputOccupation)[keyof typeof IndividualInputOccupation];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const IndividualInputOccupation = {
  agriculture: "agriculture",
  arts_and_media: "arts_and_media",
  casinos_and_gaming: "casinos_and_gaming",
  construction: "construction",
  cryptocurrency: "cryptocurrency",
  defense: "defense",
  education: "education",
  energy_oil_and_gas: "energy_oil_and_gas",
  energy_other: "energy_other",
  entertainment: "entertainment",
  finance: "finance",
  financial_services_non_crypto: "financial_services_non_crypto",
  fintech_non_crypto_software_development: "fintech_non_crypto_software_development",
  fintech_non_crypto_internet_only_financial_institution:
    "fintech_non_crypto_internet_only_financial_institution",
  fintech_non_crypto_other: "fintech_non_crypto_other",
  food_and_hospitality: "food_and_hospitality",
  government: "government",
  health_and_fitness: "health_and_fitness",
  healthcare: "healthcare",
  healthcare_other: "healthcare_other",
  healthcare_pharmaceuticals: "healthcare_pharmaceuticals",
  mining: "mining",
  mining_crypto: "mining_crypto",
  non_profit_and_charity: "non_profit_and_charity",
  pharma_industry: "pharma_industry",
  politics: "politics",
  professional_services: "professional_services",
  property_and_construction_building_work: "property_and_construction_building_work",
  property_and_construction_commercial_and_management:
    "property_and_construction_commercial_and_management",
  property_and_construction_design: "property_and_construction_design",
  real_estate: "real_estate",
  retail_fashion: "retail_fashion",
  retail_food_and_beverage: "retail_food_and_beverage",
  retail_jewelry_and_antiques: "retail_jewelry_and_antiques",
  retail_other: "retail_other",
  retail_pharmacy: "retail_pharmacy",
  technology: "technology",
  technology_and_it: "technology_and_it",
  transportation: "transportation",
  all_other_industries_and_services: "all_other_industries_and_services",
  dependent_student_unemployed: "dependent_student_unemployed",
  other: "other",
} as const;

/**
 * Expected annual volume of activity on the account, expressed as a
dollar range. Use the dollar-honest ids below:

- `under_1k`: $0 – $1,000
- `1k_to_10k`: $1,000 – $10,000
- `10k_to_100k`: $10,000 – $100,000
- `100k_to_250k`: $100,000 – $250,000
- `250k_to_750k`: $250,000 – $750,000
- `750k_to_1_5m`: $750,000 – $1.5M
- `1_5m_plus`: $1.5M+

 */
export type IndividualInputExpectedVolume =
  (typeof IndividualInputExpectedVolume)[keyof typeof IndividualInputExpectedVolume];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const IndividualInputExpectedVolume = {
  under_1k: "under_1k",
  "1k_to_10k": "1k_to_10k",
  "10k_to_100k": "10k_to_100k",
  "100k_to_250k": "100k_to_250k",
  "250k_to_750k": "250k_to_750k",
  "750k_to_1_5m": "750k_to_1_5m",
  "1_5m_plus": "1_5m_plus",
} as const;

/**
 * Individual customer data submitted on create / update requests. Fields are
organized by the capabilities they unlock; not all are required for all
customers (the requirements depend on which capabilities are requested).
Read responses return the narrower `Individual` object (only `firstName`,
`lastName`, and `email`), not this full request shape.

 */
export interface IndividualInput {
  /** First name (given name). */
  firstName?: string;
  /** Last name (family name/surname). */
  lastName?: string;
  /** Primary residential address. Only US addresses are currently
supported. Non-US `countryCode` values are rejected with a 400.
 */
  address?: IndividualInputAddress;
  /**
   * Last 4 digits of the Social Security Number (US only).
Used for identity verification.

   * @minLength 4
   * @maxLength 4
   * @pattern ^[0-9]{4}$
   */
  ssnLast4?: string;
  /** Date of birth. */
  dateOfBirth?: DateOfBirthLenient;
  /**
   * Full Social Security Number (US only).

   * @pattern ^([0-9]{3}-[0-9]{2}-[0-9]{4}|\*\*\*-\*\*-[0-9]{4})$
   */
  fullSsn?: string;
  /** ISO 3166-1 alpha-2 country code representing the customer's citizenship.
   */
  citizenship?: CountryCode;
  /** Email address for the customer. */
  email?: Email;
  /** Phone number in [E.164](https://en.wikipedia.org/wiki/E.164) format. */
  phoneNumber?: PhoneNumber;
  /** Primary purpose for using Coinbase services.
   */
  purposeOfAccount?: IndividualInputPurposeOfAccount;
  /** Primary source of funds for the account.
   */
  sourceOfFunds?: IndividualInputSourceOfFunds;
  /** Current employment status.
   */
  employmentStatus?: IndividualInputEmploymentStatus;
  /** Industry or occupation.
   */
  occupation?: IndividualInputOccupation;
  /** Expected annual volume of activity on the account, expressed as a
dollar range. Use the dollar-honest ids below:

- `under_1k`: $0 – $1,000
- `1k_to_10k`: $1,000 – $10,000
- `10k_to_100k`: $10,000 – $100,000
- `100k_to_250k`: $100,000 – $250,000
- `250k_to_750k`: $250,000 – $750,000
- `750k_to_1_5m`: $750,000 – $1.5M
- `1_5m_plus`: $1.5M+
 */
  expectedVolume?: IndividualInputExpectedVolume;
}

export type UsW9AttestationForm = (typeof UsW9AttestationForm)[keyof typeof UsW9AttestationForm];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const UsW9AttestationForm = {
  us_w9: "us_w9",
} as const;

/**
 * Tax attestation for IRS Form W-9, used for US persons. Carries the
W-9-specific backup withholding certification alongside the fields common
to every form (`edeliveryConsent`, `acceptedAt`).

 */
export interface UsW9Attestation {
  form: UsW9AttestationForm;
  /** Whether the Customer consents to electronic delivery (e-delivery) of
tax documents. Both `true` and `false` are recorded as submitted.
 */
  edeliveryConsent: boolean;
  /** Timestamp at which the Customer completed the tax attestation, in
ISO 8601 / RFC 3339 format. The server may reject obviously
non-credible timestamps.
 */
  acceptedAt: string;
  /** Whether the Customer is exempt from backup withholding, as certified
on IRS Form W-9.
 */
  isExemptBackupWithholding: boolean;
}

/**
 * A single tax attestation recorded for a Customer. Submit one entry per
required form listed in `Customer.requirements.taxAttestation.taxForms[]`
(returned on `Get Customer`, `Create Customer`, and `Update Customer`
whenever a `taxAttestation` requirement is unsatisfied). The `form` field
selects the variant and determines which additional fields are required.

 */
export type TaxAttestation = UsW9Attestation;

/**
 * Fields accepted on customer create and update requests. Shared by
`CreateCustomerRequest` and `UpdateCustomerRequest`; excludes the
server-managed response-only fields that appear on `Customer`.

 */
export interface CustomerWriteBase {
  /** The type of the customer. Required on create; accepted but ignored on
update.
 */
  type?: CustomerType;
  /** Capabilities to request for the customer. */
  capabilities?: CapabilitiesMapInput;
  /** Information about an Individual customer. Not all fields are required
for all customers; the requirements depend on which capabilities are
requested. Submit only fields that are required by the capabilities
that have been requested.
 */
  individual?: IndividualInput;
  /** The project IDs that this customer is associated with. */
  projectIds?: ProjectId[];
  /** Terms of Service acceptances to record on the customer. Submit one
entry per required version surfaced inline on
`requirements.tos.tosVersions[]` (returned by `Get Customer`,
`Create Customer`, and `Update Customer` whenever a `tos` requirement
is unsatisfied). The server rejects each acceptance whose `language`
is not listed under `languages` on the matching required version with
`errorType: "unsupported_tos_language"`.

When new required Terms of Service versions are published, only the
new `versionId`s appear in `requirements.tos.tosVersions[]`; submit
acceptances for only those new version(s).

Omit `tosAcceptances` on a partial update to leave previously recorded
acceptances unchanged. Sending `tosAcceptances: []` is invalid
(`errorType: "invalid_request"`) because it would clear all acceptances
without replacing them; omit the field entirely when you are not
updating Terms of Service acceptances.
 */
  tosAcceptances?: TosAcceptance[];
  /** Tax attestations to record on the customer. Submit one entry per
required form surfaced inline on
`requirements.taxAttestation.taxForms[]` (returned by `Get Customer`,
`Create Customer`, and `Update Customer` whenever a `taxAttestation`
requirement is unsatisfied). The required fields per entry depend on
`form`; see `TaxAttestation`. This field is ingestion-only and is
never returned on read.

Omit `taxAttestations` on a partial update to leave previously
recorded attestations unchanged. Sending `taxAttestations: []` is
invalid (`errorType: "invalid_request"`) because it would clear all
attestations without replacing them; omit the field entirely when you
are not updating tax attestations.
 */
  taxAttestations?: TaxAttestation[];
  compliance?: Compliance;
}

export type CreateCustomerRequestAllOf = { [key: string]: unknown };

export type CreateCustomerRequest = CustomerWriteBase &
  CreateCustomerRequestAllOf &
  Required<Pick<CustomerWriteBase & CreateCustomerRequestAllOf, "type">>;

export type UpdateCustomerRequest = CustomerWriteBase;

/**
 * The type of deposit destination.
 */
export type DepositDestinationType = string;

/**
 * The status of the deposit destination.
 */
export type DepositDestinationStatus =
  (typeof DepositDestinationStatus)[keyof typeof DepositDestinationStatus];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const DepositDestinationStatus = {
  active: "active",
  inactive: "inactive",
  pending: "pending",
} as const;

/**
 * The ID of the Deposit Destination, which is a UUID prefixed by the string `depositDestination_`.
 * @pattern ^depositDestination_[a-f0-9\-]{36}$
 */
export type DepositDestinationId = string;

/**
 * The blockchain network for crypto payments, transfers, and deposit destinations.
 */
export type PaymentNetwork = (typeof PaymentNetwork)[keyof typeof PaymentNetwork];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const PaymentNetwork = {
  base: "base",
  ethereum: "ethereum",
  solana: "solana",
  arbitrum: "arbitrum",
  optimism: "optimism",
  monad: "monad",
  sui: "sui",
  avacchain: "avacchain",
  tempo: "tempo",
} as const;

/**
 * A blockchain address. Format varies by network (e.g., 0x-prefixed for EVM, base58 for Solana).
 * @minLength 1
 * @maxLength 128
 */
export type BlockchainAddress = string;

/**
 * Crypto-specific deposit destination details. In responses, this object is always present. Contains the network and address for the deposit destination.
 */
export interface DepositDestinationCrypto {
  network: PaymentNetwork;
  address: BlockchainAddress;
}

/**
 * The account and asset where incoming deposits should be credited.
 */
export interface DepositDestinationTargetAccount {
  /** The ID of the CDP Account to which deposited funds should be transferred. */
  accountId?: AccountId;
  /** The symbol of the asset that should land in the target account. */
  asset: Asset;
}

/**
 * The target of the payment is an onchain address.
 */
export interface OnchainAddress {
  /** The onchain crypto address of the recipient.

Examples:
- EVM address: 0xabc1234567890abcdef1234567890abcdef123456
- Solana address: HpabPRRCFbBKSuJr5PdkVvQc85FyxyTWkFM2obBRSvHT
- XRP address: rhccc5p23aKiCGFcEqqnjEfLRZ6xEvfy3s
 */
  address: BlockchainAddress;
  network: PaymentNetwork;
  /** The destination tag of the onchain address. Destination tags are used by certain networks
(primarily XRP/Ripple) to identify specific recipients when multiple users share a single address.
The tag ensures funds are credited to the correct account within the shared address.

Examples by network:
- XRP/Ripple: Numeric values like "1234567890" or "123456"
- Stellar (XLM): Memos which can be text, ID, or hash format

Note: Most networks (Ethereum, Bitcoin, Solana) do not use destination tags.
 */
  destinationTag?: string;
  /** Asset symbol of the payment received by the recipient. Supported values are `usdc` and `eurc`. */
  asset: Asset;
}

/**
 * Routes deposited funds to an external onchain address.
 */
export type DepositDestinationTargetOnchainAddress = OnchainAddress;

/**
 * The intended target for deposited funds.
 */
export type DepositDestinationTarget =
  | DepositDestinationTargetAccount
  | DepositDestinationTargetOnchainAddress;

/**
 * Optional metadata as key-value pairs. Use this to store additional structured information on a resource, such as customer IDs, order references, or any application-specific data. Up to 10 key/value pairs may be provided. Keys and values are both strings. Keys must be ≤ 40 characters; values must be ≤ 500 characters.
 */
export interface Metadata {
  [key: string]: string;
}

export type CryptoDepositDestinationType =
  (typeof CryptoDepositDestinationType)[keyof typeof CryptoDepositDestinationType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const CryptoDepositDestinationType = {
  crypto: "crypto",
} as const;

/**
 * A cryptocurrency deposit destination.
 */
export interface CryptoDepositDestination {
  depositDestinationId: DepositDestinationId;
  accountId: AccountId;
  type: CryptoDepositDestinationType;
  /** Crypto-specific details for this deposit destination. Always populated in responses. Contains the network and address. */
  crypto: DepositDestinationCrypto;
  target?: DepositDestinationTarget;
  status: DepositDestinationStatus;
  metadata?: Metadata;
  /** The timestamp when the deposit destination was created. */
  createdAt: string;
  /** The timestamp when the deposit destination was last updated. */
  updatedAt: string;
}

/**
 * The bank account number.
 * @pattern ^[0-9]{4,17}$
 */
export type FiatAccountNumber = string;

/**
 * A payment rail supported by a fiat deposit destination.
 */
export type DepositDestinationPaymentRail =
  (typeof DepositDestinationPaymentRail)[keyof typeof DepositDestinationPaymentRail];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const DepositDestinationPaymentRail = {
  ach: "ach",
  fedwire: "fedwire",
} as const;

export type BankAccountUSAccountType =
  (typeof BankAccountUSAccountType)[keyof typeof BankAccountUSAccountType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const BankAccountUSAccountType = {
  us_bank: "us_bank",
} as const;

/**
 * The fiat currency for the deposit destination.
 */
export type BankAccountUSCurrency =
  (typeof BankAccountUSCurrency)[keyof typeof BankAccountUSCurrency];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const BankAccountUSCurrency = {
  usd: "usd",
} as const;

/**
 * A US bank account identified by ABA routing number and account number.
 */
export interface BankAccountUS {
  accountType: BankAccountUSAccountType;
  /** The fiat currency for the deposit destination. */
  currency: BankAccountUSCurrency;
  /** The name of the bank holding the account. */
  bankName: string;
  /** The name of the account beneficiary. */
  beneficiaryName: string;
  /**
   * The ABA routing number of the bank.
   * @pattern ^[0-9]{9}$
   */
  routingNumber: string;
  accountNumber: FiatAccountNumber;
  /** The address of the bank. Present when required by the receiving institution. */
  bankAddress?: string;
  /** A reference code that must be included in the payment memo or reference field so the receiving institution can route the deposit to the correct account. Only present when required by the receiving institution. */
  referenceCode?: string;
  /** The payment rails this account can receive deposits on. */
  supportedRails: DepositDestinationPaymentRail[];
}

/**
 * Fiat bank account details for a deposit destination. The `accountType` field indicates the account identification scheme and determines which fields are present.
 */
export type DepositDestinationFiat = BankAccountUS;

export type FiatDepositDestinationType =
  (typeof FiatDepositDestinationType)[keyof typeof FiatDepositDestinationType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const FiatDepositDestinationType = {
  fiat: "fiat",
} as const;

/**
 * A fiat deposit destination. Represents a single bank account provisioned at a single banking partner. Each deposit destination has one status and one lifecycle. The `fiat` object contains the bank account details, keyed by account type.
 */
export interface FiatDepositDestination {
  depositDestinationId: DepositDestinationId;
  accountId: AccountId;
  type: FiatDepositDestinationType;
  fiat: DepositDestinationFiat;
  target?: DepositDestinationTarget;
  status: DepositDestinationStatus;
  metadata?: Metadata;
  /** The timestamp when the deposit destination was created. */
  createdAt: string;
  /** The timestamp when the deposit destination was last updated. */
  updatedAt: string;
}

/**
 * A deposit destination for receiving funds to an account.
 */
export type DepositDestination = CryptoDepositDestination | FiatDepositDestination;

/**
 * Common fields for creating a deposit destination.
 */
export interface CreateDepositDestinationRequestBase {
  /** The ID of the Account, which is a UUID prefixed by the string `account_`, that owns the deposit destination. */
  accountId: AccountId;
  type: DepositDestinationType;
  target?: DepositDestinationTarget;
  metadata?: Metadata;
  compliance?: Compliance;
}

/**
 * Crypto-specific details for creating a deposit destination.
 */
export interface CreateDepositDestinationCrypto {
  network: PaymentNetwork;
}

export type CreateCryptoDepositDestinationRequestAllOfType =
  (typeof CreateCryptoDepositDestinationRequestAllOfType)[keyof typeof CreateCryptoDepositDestinationRequestAllOfType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const CreateCryptoDepositDestinationRequestAllOfType = {
  crypto: "crypto",
} as const;

export type CreateCryptoDepositDestinationRequestAllOf = {
  type?: CreateCryptoDepositDestinationRequestAllOfType;
  /** Crypto-specific details. Required when `type` is `crypto`. */
  crypto: CreateDepositDestinationCrypto;
};

export type CreateCryptoDepositDestinationRequestType =
  (typeof CreateCryptoDepositDestinationRequestType)[keyof typeof CreateCryptoDepositDestinationRequestType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const CreateCryptoDepositDestinationRequestType = {
  crypto: "crypto",
} as const;

/**
 * Request to create a new crypto deposit destination. Provide the crypto-specific details.
 */
export type CreateCryptoDepositDestinationRequest = CreateDepositDestinationRequestBase &
  CreateCryptoDepositDestinationRequestAllOf & {
    type: CreateCryptoDepositDestinationRequestType;
  };

/**
 * The fiat currency for the deposit destination.
 */
export type CreateDepositDestinationFiatCurrency =
  (typeof CreateDepositDestinationFiatCurrency)[keyof typeof CreateDepositDestinationFiatCurrency];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const CreateDepositDestinationFiatCurrency = {
  usd: "usd",
} as const;

/**
 * Fiat-specific request fields for creating a deposit destination. The server determines the account type and provisioning method based on the account's eligibility. Optionally specify a `paymentRail` to target a specific payment rail, which may influence banking partner selection.
 */
export interface CreateDepositDestinationFiat {
  /** The fiat currency for the deposit destination. */
  currency: CreateDepositDestinationFiatCurrency;
  /** Optional. The desired payment rail. When omitted, the server provisions the default banking partner and returns all rails the account supports. When specified, the server selects a banking partner that supports the requested rail. */
  paymentRail?: DepositDestinationPaymentRail;
}

export type CreateFiatDepositDestinationRequestAllOfType =
  (typeof CreateFiatDepositDestinationRequestAllOfType)[keyof typeof CreateFiatDepositDestinationRequestAllOfType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const CreateFiatDepositDestinationRequestAllOfType = {
  fiat: "fiat",
} as const;

export type CreateFiatDepositDestinationRequestAllOf = {
  type?: CreateFiatDepositDestinationRequestAllOfType;
  /** Fiat-specific details. Required when `type` is `fiat`. */
  fiat: CreateDepositDestinationFiat;
};

export type CreateFiatDepositDestinationRequestType =
  (typeof CreateFiatDepositDestinationRequestType)[keyof typeof CreateFiatDepositDestinationRequestType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const CreateFiatDepositDestinationRequestType = {
  fiat: "fiat",
} as const;

export type CreateFiatDepositDestinationRequest = CreateDepositDestinationRequestBase &
  CreateFiatDepositDestinationRequestAllOf & {
    type: CreateFiatDepositDestinationRequestType;
  };

/**
 * Request to create a new deposit destination. Provide the type-specific details matching the chosen `type`.
 */
export type CreateDepositDestinationRequest =
  | CreateCryptoDepositDestinationRequest
  | CreateFiatDepositDestinationRequest;

/**
 * The current status of the transfer, indicating what action you need to take next. Required when validateOnly is false.
 */
export type TransferStatus = (typeof TransferStatus)[keyof typeof TransferStatus];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const TransferStatus = {
  /** Transfer was created with `execute: true`, but is momentarily being quoted before executing _or_ the transfer was created with `execute: false`. It can be executed by calling `\/v2\/transfers\/{transferId}\/execute` with `execute: true`. */
  quoted: "quoted",
  /** Transfer is executing after being quoted. No action needed - monitor progress via the transfers webhook. */
  processing: "processing",
  /** Transfer completed successfully. */
  completed: "completed",
  /** Transfer failed. See `failureReason` for details. */
  failed: "failed",
} as const;

/**
 * The Account specific details for the transfer.
 */
export interface TransfersAccount {
  /** The ID of the Account. */
  accountId: AccountId;
  /** The asset symbol. Supported values are `usdc`, `eurc`, `usd`, and `eur`. */
  asset: Asset;
}

/**
 * The ID of the Payment Method, which is a UUID prefixed by the string `paymentMethod_`.
 * @pattern ^paymentMethod_[a-f0-9\-]{36}$
 */
export type PaymentMethodId = string;

/**
 * The Payment Method specific details for the transfer.
 */
export interface PaymentMethod {
  /** The ID of the Payment Method. */
  paymentMethodId: PaymentMethodId;
  /** The asset symbol. Supported values are `usd` and `eur`. */
  asset: Asset;
}

/**
 * The originating ACH deposit details for the transfer source. Present when funds were deposited via ACH into a deposit destination.
 */
export interface AchDepositSource {
  /** The fiat currency of the ACH deposit (e.g., `usd`). */
  currency: Asset;
  /**
   * The company name from the ACH batch header record. Masked on webhook payloads.
   * @maxLength 16
   */
  companyName: string;
  /**
   * The company entry description from the ACH batch header record.
   * @maxLength 10
   */
  companyEntryDescription: string;
  /**
   * The individual identification number from the ACH entry detail record. For Person-to-Person WEB credit Entries, this field is required and contains the name of the consumer Originator. Masked on webhook payloads.
   * @maxLength 15
   */
  individualIdentificationNumber?: string;
}

/**
 * The originating Fedwire deposit details for the transfer source. Present when funds were deposited via Fedwire into a deposit destination.
 */
export interface FedwireDepositSource {
  /** The fiat currency of the Fedwire deposit (e.g., `usd`). */
  currency: Asset;
  /**
   * The Output Message Accountability Data (OMAD), a unique identifier assigned by the Fedwire network to the wire transfer message.
   * @maxLength 22
   */
  omad: string;
  /**
   * The originator's bank account number. Masked on webhook payloads.
   * @pattern ^[0-9]{4,17}$
   */
  accountNumber: string;
  /**
   * The name of the originator. Masked on webhook payloads.
   * @maxLength 35
   */
  originatorName: string;
  /**
   * The Originator to Beneficiary Information (OBI) lines from the Fedwire message. Up to 4 lines, each up to 35 characters. Free-form and may contain identifying information about the originator. Masked on webhook payloads.
   * @maxItems 4
   */
  originatorToBeneficiary?: string[];
}

/**
 * The source of the transfer.
 */
export type TransferSource =
  | TransfersAccount
  | PaymentMethod
  | OnchainAddress
  | AchDepositSource
  | FedwireDepositSource;

/**
 * The target of the payment is an email address.
 */
export interface EmailAddress {
  /** The email address of the recipient. The recipient will need to have an account with Coinbase or onboard to Coinbase to receive the payment. */
  email: Email;
}

export type EmailInstrumentAllOf = {
  /** Asset symbol of the payment received by the recipient. */
  asset: Asset;
};

/**
 * The target of the payment is an email address.
 */
export type EmailInstrument = EmailAddress & EmailInstrumentAllOf;

/**
 * The target of the transfer.
 */
export type TransferTarget = TransfersAccount | PaymentMethod | OnchainAddress | EmailInstrument;

/**
 * Exchange rate information for currency conversion. The rate indicates how much of the target asset is equivalent to one unit of the source asset.
 */
export interface TransferExchangeRate {
  /** The asset being converted from. */
  sourceAsset: Asset;
  /** The asset being converted to. */
  targetAsset: Asset;
  /** The exchange rate value as a decimal string. Indicates how many units of the target asset equal one unit of the source asset. */
  rate: string;
}

/**
 * The type of the fee, indicating its purpose.
 */
export type TransferFeeType = (typeof TransferFeeType)[keyof typeof TransferFeeType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const TransferFeeType = {
  BankFee: "bank",
  ConversionFee: "conversion",
  NetworkFee: "network",
  OtherFee: "other",
} as const;

/**
 * A single fee for a transfer.
 */
export interface TransferFee {
  /** The type of the fee, indicating its purpose. */
  type: TransferFeeType;
  /** The amount of the fee in units of the asset specified by `asset`. */
  amount: string;
  /** The asset symbol. */
  asset: Asset;
}

/**
 * The fees associated with this transfer. Different transfer types have different fee structures.

**NOTE:** These examples are not exhaustive.

Common examples:
* **Crypto transfers**: Network fees (gas) paid in the native token
* **Fiat conversions**: Processing fees + exchange fees in USD
* **Wire transfers**: Wire fees ($15) + processing fees ($5) in USD
* **Crypto conversions**: Spread fees paid in the source asset.
 */
export type TransferFees = TransferFee[];

/**
 * Captures estimated values for transfers where amounts can't be guaranteed (e.g., USDC -> EURC).

The values in `estimate` are not modified after a transfer is executed. They are preserved as an immutable record of the original pre-execution snapshot.

The actual executed values are populated in the `transfer` resource post-execution.
 */
export interface TransferEstimate {
  /** The estimated exchange rate at the time this estimate was captured. */
  exchangeRate?: TransferExchangeRate;
  /** Estimated amount of the target asset that will be received, as a decimal string in standard unit denomination. */
  targetAmount?: string;
  /** The asset symbol of the estimated target amount. */
  targetAsset?: Asset;
  /** The estimated fees at the time this estimate was captured. */
  fees?: TransferFees;
  /** The date and time when this estimate was captured. */
  estimatedAt: string;
}

/**
 * A reference to the deposit destination associated with the transfer.
 */
export interface DepositDestinationReference {
  id: DepositDestinationId;
}

/**
 * The status of a travel rule submission.
 */
export type TravelRuleStatus = (typeof TravelRuleStatus)[keyof typeof TravelRuleStatus];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const TravelRuleStatus = {
  /** Additional fields are required before the transfer can proceed. */
  TravelRuleStatusIncomplete: "incomplete",
  /** All requirements are satisfied and the transfer will proceed. */
  TravelRuleStatusCompleted: "completed",
} as const;

/**
 * An onchain transaction associated with the transfer.
 */
export type TransferDetailsOnchainTransactionsItem = {
  /** The transaction hash. */
  transactionHash: string;
  network: PaymentNetwork;
};

/**
 * Travel rule compliance status for deposit transfers. Present when the transfer requires travel rule information.
 */
export type TransferDetailsTravelRule = {
  status?: TravelRuleStatus;
  /** Additional details about the current travel rule status. For example, when status is `incomplete`, this may indicate the specific missing information required to proceed. */
  statusMessage?: string;
};

/**
 * Additional details about the transfer. For example, if the transfer was sent to a deposit destination, the information about that destination will be included in this field.
 */
export interface TransferDetails {
  depositDestination?: DepositDestinationReference;
  /** The onchain transactions associated with the transfer. */
  onchainTransactions?: TransferDetailsOnchainTransactionsItem[];
  /** Travel rule compliance status for deposit transfers. Present when the transfer requires travel rule information. */
  travelRule?: TransferDetailsTravelRule;
}

/**
 * A Transfer represents all the information needed to execute a transfer and tracks the lifecycle of a transfer from initiation through completion or failure.
 */
export interface Transfer {
  /** The ID of the transfer. Required when validateOnly is false. */
  transferId?: string;
  status?: TransferStatus;
  source: TransferSource;
  target: TransferTarget;
  /** The amount of the source asset that will be transferred out, as a decimal string in standard unit denomination. */
  sourceAmount?: string;
  /** The asset symbol of the source amount. */
  sourceAsset?: Asset;
  /** The amount of the target asset received, as a decimal string in standard unit denomination. May be omitted in the `quoted` state if the value cannot be guaranteed; see `estimate.targetAmount` for the expected value. Populated with the actual executed amount once the transfer completes. */
  targetAmount?: string;
  /** The asset symbol of the target amount. */
  targetAsset?: Asset;
  /** Exchange rate information for currency conversion. The rate indicates how much of the target asset is equivalent to one unit of the source asset. May be omitted in the `quoted` state if the rate cannot be guaranteed; see `estimate.exchangeRate` for the expected rate. Populated with the actual executed rate once the transfer completes. */
  exchangeRate?: TransferExchangeRate;
  /** The fees associated with this transfer. Different transfer types have different fee structures. May be omitted in the `quoted` state if the fees cannot be guaranteed; see `estimate.fees` for the expected fees. Populated with the actual fees once the transfer completes. */
  fees?: TransferFees;
  estimate?: TransferEstimate;
  /** The date and time the transfer was completed. */
  completedAt?: string;
  /** The reason for failure, if the transfer failed. Only present when status is `failed`. */
  failureReason?: string;
  /** The date and time when this transfer will expire if not executed. Only present for `quoted` status. A new transfer must be created to obtain an updated quote after expiration. Required when validateOnly is false. */
  expiresAt?: string;
  /** The date and time the transfer was executed and moved to processing. Only present when status has progressed beyond `quoted`. */
  executedAt?: string;
  /** The date and time the transfer was created. Required when validateOnly is false. */
  createdAt?: string;
  /** The date and time the transfer was last updated. Required when validateOnly is false. */
  updatedAt?: string;
  metadata?: Metadata;
  details?: TransferDetails;
}

/**
 * The source of the transfer.
 */
export type CreateTransferSource = TransfersAccount;

/**
 * A positive decimal string without scientific notation or whitespace.
 * @pattern ^\+?(?:(?:0*[1-9]\d*)(?:\.\d*)?|0*\.\d*[1-9]\d*)$
 */
export type PositiveDecimal = string;

/**
 * Indicates whether **Coinbase is acting as the intermediary Virtual Asset Service Provider (VASP)**, and your organization is acting as an originating VASP on behalf of your own end customer.

**Background:**

The Travel Rule (FATF Recommendation 16) requires VASPs to collect and share certain information about virtual asset transfers. If your organization is a VASP, and you are acting on behalf of your end customer, you must provide additional Travel Rule data to satisfy compliance requirements.

**Set to `true` when** your organization is itself a VASP acting on behalf of your own end customer (the true originator).

**Set to `false` (or omit) when** your organization is not itself a VASP acting on behalf of an end customer — for example, if the virtual assets involved are your organization's own funds.

**Impact on required fields:**

When `isIntermediary` is `true`, you must provide the `originator` object with the following details:
- The originator's (i.e. your end customer's) name
- The originator's address
- Your organization's VASP information (`virtualAssetServiceProvider` object with `identifier`, `name`, and `address`)

In certain jurisdictions, `personalId` and `dateOfBirth` must also reflect the **original sender's** identity — not your organization's. These fields will not be auto-populated from any internal KYC data when `isIntermediary` is `true`.

 */
export type IsIntermediary = boolean;

/**
 * Information about a party (originator or beneficiary) for travel rule compliance.
 */
export interface TravelRuleParty {
  /** Full name of the party. */
  name?: string;
  address?: PhysicalAddress;
  /** Name of the financial institution. */
  financialInstitution?: string;
}

/**
 * Date of birth.
 */
export interface DateOfBirth {
  /**
   * Day of birth (01-31).
   * @minLength 2
   * @maxLength 2
   * @pattern ^[0-9]{2}$
   */
  day?: string;
  /**
   * Month of birth (01-12).
   * @minLength 2
   * @maxLength 2
   * @pattern ^[0-9]{2}$
   */
  month?: string;
  /**
   * Year of birth (four digits).
   * @minLength 4
   * @maxLength 4
   * @pattern ^[0-9]{4}$
   */
  year?: string;
}

/**
 * Information about the originating Virtual Asset Service Provider (VASP) that handles cryptocurrency or other virtual assets on behalf of customers.
 */
export type TravelRuleOriginatorAllOfVirtualAssetServiceProvider = {
  /** The Legal Entity Identifier of the originating Virtual Asset Service Provider (VASP). */
  identifier?: string;
  /** The name of the originating Virtual Asset Service Provider (VASP). */
  name?: string;
  /** The address of the originating Virtual Asset Service Provider (VASP). */
  address?: PhysicalAddress;
};

export type TravelRuleOriginatorAllOf = {
  /** Information about the originating Virtual Asset Service Provider (VASP) that handles cryptocurrency or other virtual assets on behalf of customers. */
  virtualAssetServiceProvider?: TravelRuleOriginatorAllOfVirtualAssetServiceProvider;
  /** Personal identifier for travel rule compliance. For individuals: passport number, national ID, or driver's license. For institutions: LEI (Legal Entity Identifier). */
  personalId?: string;
  /** Date of birth of the originator. Required by certain jurisdictions (such as Coinbase Luxembourg) to satisfy Travel Rule reporting obligations. */
  dateOfBirth?: DateOfBirth;
};

/**
 * Originator (sender) party.
 */
export type TravelRuleOriginator = TravelRuleParty & TravelRuleOriginatorAllOf;

/**
 * The type of the beneficiary's wallet.
 */
export type TravelRuleBeneficiaryAllOfWalletType =
  (typeof TravelRuleBeneficiaryAllOfWalletType)[keyof typeof TravelRuleBeneficiaryAllOfWalletType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const TravelRuleBeneficiaryAllOfWalletType = {
  custodial: "custodial",
  self_custody: "self_custody",
} as const;

export type TravelRuleBeneficiaryAllOf = {
  /** The type of the beneficiary's wallet. */
  walletType?: TravelRuleBeneficiaryAllOfWalletType;
};

/**
 * Beneficiary (receiver) party.
 */
export type TravelRuleBeneficiary = TravelRuleParty & TravelRuleBeneficiaryAllOf;

/**
 * Required Travel Rule fields differ by region. These requirements are determined based on which Coinbase entity the customer has signed the service agreement for.
 */
export interface TravelRule {
  /** Indicates whether the user attests that the receiving wallet belongs to them. */
  isSelf?: boolean;
  isIntermediary?: IsIntermediary;
  /** When `true`, you attest that the beneficiary's wallet ownership has been verified out-of-band. Instructs Coinbase to skip the wallet verification check for this transfer.

**Only valid when `isIntermediary` is `true`.** You can only attest to the beneficiary's wallet ownership when your organization is acting as the originating VASP on behalf of your end customer, and Coinbase is acting as the intermediary VASP. Returns a `400` error if set to `true` when `isIntermediary` is `false` or omitted. */
  attestVerifiedWalletOwnership?: boolean;
  originator?: TravelRuleOriginator;
  beneficiary?: TravelRuleBeneficiary;
}

/**
 * Specifies whether the given amount is to be received by the target or taken from the source.

- `target`: The transfer `target` receives the exact value specified in `amount`. Fees are added to the amount taken from the transfer `source`.
- `source`: The transfer `target` receives the value specified in `amount`, minus any fees.

 */
export type TransferRequestAmountType =
  (typeof TransferRequestAmountType)[keyof typeof TransferRequestAmountType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const TransferRequestAmountType = {
  target: "target",
  source: "source",
} as const;

/**
 * A request to create a transfer.
 */
export interface TransferRequest {
  source: CreateTransferSource;
  target: TransferTarget;
  /** The amount of the transfer, as a decimal string in standard unit denomination of the asset specified by `asset` (e.g., "100.00" for 100 USD, "0.05" for 0.05 ETH). */
  amount: PositiveDecimal;
  /** The symbol of the asset for the amount. This must be one of the assets of the source or target. */
  asset: Asset;
  /** Specifies whether the given amount is to be received by the target or taken from the source.

- `target`: The transfer `target` receives the exact value specified in `amount`. Fees are added to the amount taken from the transfer `source`.
- `source`: The transfer `target` receives the value specified in `amount`, minus any fees.
 */
  amountType?: TransferRequestAmountType;
  /** If true, validates the transfer without initiating it.  If the request is valid, a 2xx will be returned. If the request is invalid, a 4xx error will be returned. The response will include an errorType, for e.g. invalid_target if the specified target cannot receive funds. */
  validateOnly?: boolean;
  /** Whether to immediately execute the transfer. If false, the transfer will be created in quoted status and must be executed manually via the /execute endpoint. */
  execute: boolean;
  metadata?: Metadata;
  /** Travel Rule compliance information for this transfer. Required for transfers to external wallets above regulatory thresholds. Fields required differ by region and Coinbase contracting entity. */
  travelRule?: TravelRule;
}

/**
 * Information about the Virtual Asset Service Provider (VASP) for a deposit travel rule submission.
 */
export interface DepositTravelRuleVasp {
  /** The Legal Entity Identifier (LEI) of the Virtual Asset Service Provider (VASP). */
  identifier?: string;
  /** The name of the Virtual Asset Service Provider (VASP). */
  name?: string;
}

/**
 * The type of the originator's wallet.
 */
export type DepositTravelRuleOriginatorWalletType =
  (typeof DepositTravelRuleOriginatorWalletType)[keyof typeof DepositTravelRuleOriginatorWalletType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const DepositTravelRuleOriginatorWalletType = {
  /** The originator\'s wallet is held by a custodial service. */
  custodial: "custodial",
  /** The originator\'s wallet is self-custodied. */
  self_custody: "self_custody",
} as const;

/**
 * Originator information for a deposit travel rule submission.
 */
export interface DepositTravelRuleOriginator {
  /** Full name of the originator. */
  name?: string;
  address?: PhysicalAddress;
  /** Name of the financial institution. */
  financialInstitution?: string;
  virtualAssetServiceProvider?: DepositTravelRuleVasp;
  /** Personal identifier for travel rule compliance. For individuals: passport number, national ID, or driver's license. For institutions: LEI (Legal Entity Identifier). */
  personalId?: string;
  /** Date of birth of the originator. */
  dateOfBirth?: DateOfBirth;
  /** The type of the originator's wallet. */
  walletType?: DepositTravelRuleOriginatorWalletType;
}

/**
 * Beneficiary information for a deposit travel rule submission.
 */
export interface DepositTravelRuleBeneficiary {
  /** Full name of the beneficiary. */
  name?: string;
}

/**
 * Request body for submitting travel rule information for a deposit transfer. Required fields vary by jurisdiction.
 */
export interface DepositTravelRuleRequest {
  /** Indicates whether the user attests that the originating wallet belongs to them. */
  isSelf?: boolean;
  isIntermediary?: IsIntermediary;
  /** When `true`, you attest that the originating wallet's ownership has been verified out-of-band. Instructs Coinbase to skip the wallet verification check for this travel-rule submission.

**Only valid when `isIntermediary` is `true`.** You can only attest to the originating wallet's ownership when your organization is acting as the originating VASP on behalf of your end customer, and Coinbase is acting as the intermediary VASP. Returns a `400` error if set to `true` when `isIntermediary` is `false` or omitted. */
  attestVerifiedWalletOwnership?: boolean;
  /** Originator information for the travel rule submission. */
  originator?: DepositTravelRuleOriginator;
  /** Beneficiary information for the travel rule submission. */
  beneficiary?: DepositTravelRuleBeneficiary;
}

/**
 * Response from submitting travel rule information for a deposit transfer.
 */
export interface DepositTravelRuleResponse {
  status: TravelRuleStatus;
  /** List of field paths that are still required to complete travel rule compliance. Each entry is a dot-separated path (e.g., "originator.name", "originator.address.countryCode"). Empty when status is "completed". */
  missingFields?: string[];
  /** Additional context about the current status. Present when status is `incomplete` to explain what needs to be fixed before the transfer can proceed. */
  reason?: string;
}

/**
 * The ID of the payment session, a UUID prefixed by `paymentSession_`.
 * @pattern ^paymentSession_[a-f0-9\-]{36}$
 */
export type PaymentSessionId = string;

/**
 * The blockchain network supported for payment session targets. Testnet networks are only available in sandbox environments.
 */
export type PaymentTargetNetwork = (typeof PaymentTargetNetwork)[keyof typeof PaymentTargetNetwork];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const PaymentTargetNetwork = {
  base: "base",
  "base-sepolia": "base-sepolia",
} as const;

/**
 * A blockchain wallet address used as a payment target (merchant recipient).
 */
export interface PaymentTargetWallet {
  /** The blockchain address of the recipient. */
  address: BlockchainAddress;
  /** The blockchain network for the payment. */
  network?: PaymentTargetNetwork;
}

/**
 * The target of the payment.
 */
export type PaymentSessionTarget = PaymentTargetWallet | TransfersAccount;

/**
 * Deadlines for each stage of the payment session lifecycle. All fields are optional; when omitted from a create request, the following defaults apply: `authorizationExpiresAt` = now + 1 day, `captureExpiresAt` = now + 7 days, `refundExpiresAt` = now + 30 days.

Expiries must satisfy `authorizationExpiresAt` ≤ `captureExpiresAt` ≤ `refundExpiresAt`. The API returns a 400 error if this constraint is violated.

Each deadline acts as a guard — after it passes, the corresponding action is rejected, but the session remains in its current status. No automatic state transitions occur; the merchant must take explicit action (e.g., cancel or void) to move the session to a terminal state.
 */
export interface PaymentExpiries {
  /** The UTC ISO 8601 timestamp after which authorization attempts are rejected. Defaults to now + 1 day if omitted. The session remains in its current pre-authorization status; the merchant must explicitly cancel the session. */
  authorizationExpiresAt?: string;
  /** The UTC ISO 8601 timestamp after which capture attempts are rejected. Defaults to now + 7 days if omitted. The session remains in its current status; the merchant must explicitly void to release uncaptured funds. */
  captureExpiresAt?: string;
  /** The UTC ISO 8601 timestamp after which refund attempts are rejected. Defaults to now + 30 days if omitted. The session remains in its current status; the refund window is simply closed. */
  refundExpiresAt?: string;
}

/**
 * The blockchain network supported for payment session sources. Testnet networks are only available in sandbox environments.
 */
export type PaymentSourceNetwork = (typeof PaymentSourceNetwork)[keyof typeof PaymentSourceNetwork];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const PaymentSourceNetwork = {
  arbitrum: "arbitrum",
  "arbitrum-sepolia": "arbitrum-sepolia",
  avalanche: "avalanche",
  base: "base",
  "base-sepolia": "base-sepolia",
  ethereum: "ethereum",
  "ethereum-sepolia": "ethereum-sepolia",
  optimism: "optimism",
  "optimism-sepolia": "optimism-sepolia",
  polygon: "polygon",
  "polygon-amoy": "polygon-amoy",
  solana: "solana",
  "solana-devnet": "solana-devnet",
} as const;

/**
 * A blockchain wallet address used as a payment source.
 */
export interface PaymentSourceWallet {
  /** The blockchain address of the payer. */
  address: BlockchainAddress;
  /** The blockchain network for the payment. */
  network?: PaymentSourceNetwork;
  /** The asset used for the payment. */
  asset?: Asset;
}

/**
 * A Coinbase account authenticated via OAuth, used as a payment source.
 */
export interface PaymentSourceCoinbase {
  /** The unique identifier of the payer within Coinbase. */
  coinbaseUserId: string;
}

/**
 * The source of the payment. Can be either an onchain wallet address or a Coinbase account authenticated via OAuth.
 */
export type PaymentSessionSource = PaymentSourceWallet | PaymentSourceCoinbase;

/**
 * The most recent meaningful event on the payment session.
For session-level milestones the value is one of `created` or `canceled`. For action outcomes the value follows the pattern `{action}_{result}` — e.g. `authorization_succeeded`, `capture_pending`, `refund_failed`.
 */
export type PaymentSessionStatus = (typeof PaymentSessionStatus)[keyof typeof PaymentSessionStatus];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const PaymentSessionStatus = {
  PaymentSessionStatusCreated: "created",
  PaymentSessionStatusCanceled: "canceled",
  PaymentSessionStatusAuthorizationPending: "authorization_pending",
  PaymentSessionStatusAuthorizationSucceeded: "authorization_succeeded",
  PaymentSessionStatusAuthorizationFailed: "authorization_failed",
  PaymentSessionStatusCapturePending: "capture_pending",
  PaymentSessionStatusCaptureSucceeded: "capture_succeeded",
  PaymentSessionStatusCaptureFailed: "capture_failed",
  PaymentSessionStatusVoidPending: "void_pending",
  PaymentSessionStatusVoidSucceeded: "void_succeeded",
  PaymentSessionStatusVoidFailed: "void_failed",
  PaymentSessionStatusRefundPending: "refund_pending",
  PaymentSessionStatusRefundSucceeded: "refund_succeeded",
  PaymentSessionStatusRefundFailed: "refund_failed",
} as const;

/**
 * Running totals tracking how funds move through the session. All amounts are decimal representations denominated in the session's `asset`.
 */
export interface PaymentSessionBalances {
  /** Authorized funds not yet captured or voided. Decreases with each capture or void. */
  capturable?: string;
  /** Total funds captured across all captures. */
  captured?: string;
  /** Captured funds not yet refunded. Equals `captured` minus `refunded`. */
  refundable?: string;
  /** Total funds refunded across all refunds. */
  refunded?: string;
}

/**
 * The ID of the authorization, a UUID prefixed by `authorization_`.
 * @pattern ^authorization_[a-f0-9\-]{36}$
 */
export type AuthorizationId = string;

/**
 * The current status of a payment action (authorization, capture, void, or refund).
 */
export type PaymentActionStatus = (typeof PaymentActionStatus)[keyof typeof PaymentActionStatus];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const PaymentActionStatus = {
  pending: "pending",
  succeeded: "succeeded",
  failed: "failed",
} as const;

/**
 * An error that occurred during a payment operation.
 */
export interface PaymentError {
  /** A machine-readable error code. */
  code?: string;
  /** A human-readable description of the error. */
  message?: string;
  /** The UTC ISO 8601 timestamp at which the error occurred. */
  occurredAt?: string;
}

/**
 * A merchant-provided internal identifier for a resource from the merchant's own system—not visible to the payer. It must not contain personally identifiable information (PII) or payment credentials.
 * @maxLength 256
 */
export type ExternalReferenceId = string;

/**
 * A short customer-facing reference for an operation, visible to the payer. It must not contain personally identifiable information (PII) or payment credentials.
 * @maxLength 128
 */
export type CustomerReferenceCode = string;

/**
 * Customer-facing display data for a payment operation, shown to the payer.
 */
export interface OperationCustomerDisplay {
  /** A short reference code for this payment operation, visible to the payer. */
  referenceCode?: CustomerReferenceCode;
}

/**
 * An onchain transaction associated with a payment action.
 */
export interface OnchainTransaction {
  /** The blockchain transaction hash. */
  transactionHash: string;
  /** The blockchain network the transaction occurred on. */
  network: PaymentSourceNetwork;
}

/**
 * A hold placed on the payer's funds. Once authorized, the merchant can capture (collect) the funds. Only one authorization is allowed per session.
 */
export interface Authorization {
  /** The unique identifier of the authorization. */
  authorizationId?: AuthorizationId;
  /** The ID of the payment session this authorization belongs to. */
  paymentSessionId?: PaymentSessionId;
  /** The current status of the authorization. */
  status?: PaymentActionStatus;
  /** A decimal representation of the authorized amount, denominated in the session's `asset`. */
  amount?: string;
  error?: PaymentError;
  /** A human-readable message describing the outcome or status for display. Returned for x402 authorizations; omitted for other authorization flows unless documented otherwise. */
  message?: string;
  metadata?: Metadata;
  /** A merchant-provided internal identifier for this authorization, from the merchant's own system—not visible to the payer. Present only when supplied on the authorization request. */
  externalReferenceId?: ExternalReferenceId;
  /** Customer-facing display data for this authorization, shown to the payer. Present when supplied on the authorization request or when the session's `orderCode` fallback applies; otherwise omitted. */
  customerDisplay?: OperationCustomerDisplay;
  /** The payer for this authorization. For wallet authorizations, this is the blockchain address that signed the payloads. For Coinbase authorizations, this is the authenticated Coinbase account. This value is also reflected on the parent payment session's `source` field after a successful authorization. */
  source?: PaymentSessionSource;
  /** The onchain transactions associated with this authorization. */
  onchainTransactions?: OnchainTransaction[];
  /** The UTC ISO 8601 timestamp at which the authorization was created. */
  createdAt?: string;
  /** The UTC ISO 8601 timestamp at which the authorization was last updated. */
  updatedAt?: string;
}

/**
 * The ID of the capture, a UUID prefixed by `capture_`.
 * @pattern ^capture_[a-f0-9\-]{36}$
 */
export type CaptureId = string;

/**
 * A collection of authorized funds. Multiple partial captures are allowed up to the authorized amount. Each capture settles funds to the merchant's target.
 */
export interface Capture {
  /** The unique identifier of the capture. */
  captureId?: CaptureId;
  /** The ID of the payment session this capture belongs to. */
  paymentSessionId?: PaymentSessionId;
  /** The current status of the capture. */
  status?: PaymentActionStatus;
  /** A decimal representation of the captured amount, denominated in the session's `asset`. */
  amount?: string;
  /** When `true`, this capture is treated as the final one for the authorization. Any remaining capturable balance is released back to the payer immediately after the capture settles. When `false`, the remaining capturable balance stays held and is available for subsequent partial captures (subject to `captureExpiresAt`). Has no effect if `amount` equals the full capturable balance, since no remaining balance exists to release. */
  finalCapture: boolean;
  error?: PaymentError;
  metadata?: Metadata;
  /** A merchant-provided internal identifier for this capture, from the merchant's own system—not visible to the payer. A manual capture uses the caller-provided value; an auto-capture reuses the authorization's value and omits it when the authorization omitted it. It never falls back to `PaymentSession.externalReferenceId`. */
  externalReferenceId?: ExternalReferenceId;
  /** Customer-facing display data for this capture, shown to the payer. A manual capture falls back to the session's `orderCode` when `referenceCode` is omitted; an auto-capture reuses the authorization's `referenceCode`. */
  customerDisplay?: OperationCustomerDisplay;
  /** The onchain transactions associated with this capture. */
  onchainTransactions?: OnchainTransaction[];
  /** The UTC ISO 8601 timestamp at which the capture was created. */
  createdAt?: string;
  /** The UTC ISO 8601 timestamp at which the capture was last updated. */
  updatedAt?: string;
}

/**
 * The ID of the void, a UUID prefixed by `void_`.
 * @pattern ^void_[a-f0-9\-]{36}$
 */
export type VoidId = string;

/**
 * A release of uncaptured authorized funds back to the payer. Voids release all remaining capturable funds in a single operation, including after partial refunds as long as a capturableAmount remains.
 */
export interface Void {
  /** The unique identifier of the void. */
  voidId?: VoidId;
  /** The ID of the payment session this void belongs to. */
  paymentSessionId?: PaymentSessionId;
  /** The current status of the void. */
  status?: PaymentActionStatus;
  /** A decimal representation of the voided amount, denominated in the session's `asset`. */
  amount?: string;
  error?: PaymentError;
  metadata?: Metadata;
  /** A merchant-provided internal identifier for this void, from the merchant's own system—not visible to the payer. Present only when supplied on the create void request. */
  externalReferenceId?: ExternalReferenceId;
  /** Customer-facing display data for this void, shown to the payer. Present when supplied on the create void request or when the session's `orderCode` fallback applies; otherwise omitted. */
  customerDisplay?: OperationCustomerDisplay;
  /** The onchain transactions associated with this void. */
  onchainTransactions?: OnchainTransaction[];
  /** The UTC ISO 8601 timestamp at which the void was created. */
  createdAt?: string;
  /** The UTC ISO 8601 timestamp at which the void was last updated. */
  updatedAt?: string;
}

/**
 * The ID of the refund, a UUID prefixed by `refund_`.
 * @pattern ^refund_[a-f0-9\-]{36}$
 */
export type RefundId = string;

/**
 * An onchain address from which funds are pulled to fund the refund. Network and asset are inferred from the payment session.
 */
export interface RefundWallet {
  /** The onchain crypto address from which to fund the refund. */
  address: BlockchainAddress;
}

/**
 * The source from which a refund is funded.
 */
export type RefundSource = TransfersAccount | RefundWallet;

/**
 * A return of previously captured funds to the payer. Multiple partial refunds are allowed up to the total captured amount.
 */
export interface Refund {
  /** The unique identifier of the refund. */
  refundId?: RefundId;
  /** The ID of the payment session this refund belongs to. */
  paymentSessionId?: PaymentSessionId;
  /** The source from which the refund is funded. Can be a CDP account or an onchain address. */
  source?: RefundSource;
  /** The current status of the refund. */
  status?: PaymentActionStatus;
  /** A decimal representation of the refunded amount, denominated in the session's `asset`. */
  amount?: string;
  /** The reason for the refund. */
  reason?: string;
  error?: PaymentError;
  metadata?: Metadata;
  /** A merchant-provided internal identifier for this refund, from the merchant's own system—not visible to the payer. Present only when supplied on the create refund request. */
  externalReferenceId?: ExternalReferenceId;
  /** Customer-facing display data for this refund, shown to the payer. Present when supplied on the create refund request or when the session's `orderCode` fallback applies; otherwise omitted. */
  customerDisplay?: OperationCustomerDisplay;
  /** The onchain transactions associated with this refund. */
  onchainTransactions?: OnchainTransaction[];
  /** The UTC ISO 8601 timestamp at which the refund was created. */
  createdAt?: string;
  /** The UTC ISO 8601 timestamp at which the refund was last updated. */
  updatedAt?: string;
}

/**
 * Redirect URLs used to direct the payer after a web-based payment flow completes or fails.
 */
export interface PaymentRedirect {
  /** The URL to redirect the payer to on payment failure. */
  failureUrl?: Url;
  /** The URL to redirect the payer to on payment success. */
  successUrl?: Url;
}

/**
 * The amount to present to the payer, which may differ from the authoritative settlement amount and asset. Commonly used when the payer's local currency differs from the settlement currency (e.g., charging in USD but displaying the equivalent in CAD). Stored and returned as-is — no cross-validation is performed against the authoritative `amount` and `asset`. Both `amount` and `currency` must be provided together.
 */
export type CustomerDisplayDisplayAmount = {
  /** The display amount as a decimal string (e.g., `"1.37"`). */
  amount: string;
  /** An ISO 4217 currency code in lowercase for the display amount (e.g., `cad`, `usd`). */
  currency: string;
};

/**
 * Merchant-provided display data shown to the payer during checkout. All fields are informational only — stored and returned as-is, with no effect on payment processing, settlement, or validation.
 */
export interface CustomerDisplay {
  /**
   * The merchant name to display on the payment UI. When provided, this overrides the default name derived from the entity's profile. Useful when a merchant operates multiple storefronts or brands under a single entity.
   * @maxLength 128
   */
  merchantName?: string;
  /** The amount to present to the payer, which may differ from the authoritative settlement amount and asset. Commonly used when the payer's local currency differs from the settlement currency (e.g., charging in USD but displaying the equivalent in CAD). Stored and returned as-is — no cross-validation is performed against the authoritative `amount` and `asset`. Both `amount` and `currency` must be provided together. */
  displayAmount?: CustomerDisplayDisplayAmount;
  /**
   * A customer-visible code for the overall order. When omitted, CDP generates one and returns it. It must not contain personally identifiable information (PII) or payment credentials.
   * @maxLength 128
   */
  orderCode?: string;
}

/**
 * Tracks the full lifecycle of a payment from creation through settlement. Typical flow: **Create** → **Authorize** (via payment method) → **Capture**. Optional: **Void** to release uncaptured funds, or **Refund** to return captured funds.
 */
export interface PaymentSession {
  /** The unique identifier of the payment session. */
  paymentSessionId?: PaymentSessionId;
  /** The ID of the entity that owns the payment session. */
  entityId?: string;
  /** A decimal representation of the payment amount, denominated in `asset`. */
  amount?: string;
  /** The symbol of the asset for the payment amount. */
  asset?: Asset;
  /** The target of the payment session. */
  target?: PaymentSessionTarget;
  /** When true, a capture is automatically created after a successful authorization. When false or omitted, the merchant must create captures manually via the captures endpoint. */
  autoCapture?: boolean;
  expiries?: PaymentExpiries;
  /** The source of the payment session. Set after a successful authorization. Not present before authorization. */
  source?: PaymentSessionSource;
  /** The most recent meaningful event on the payment session. */
  status?: PaymentSessionStatus;
  balances?: PaymentSessionBalances;
  /** The authorizations for this payment session. */
  authorizations?: Authorization[];
  /** The captures for this payment session. */
  captures?: Capture[];
  /** The voids for this payment session. */
  voids?: Void[];
  /** The refunds for this payment session. */
  refunds?: Refund[];
  /** A URL to the hosted payment page where the payer can complete this payment session. */
  readonly url?: Url;
  /** URL for the hosted x402 payment flow. This endpoint expects an HTTP **POST** request (for example, submitting the x402 payment via request headers); do not treat it as a page opened with GET alone. Only present when the payment target supports a wallet source. */
  readonly x402Url?: Url;
  redirect?: PaymentRedirect;
  customerDisplay?: CustomerDisplay;
  metadata?: Metadata;
  /**
   * A merchant-provided internal identifier for this payment session, from the merchant's own system—not visible to the payer. It must not contain personally identifiable information (PII) or payment credentials.
   * @maxLength 256
   */
  externalReferenceId?: string;
  /** The reason the payment session was canceled. Only present when the session has been canceled. */
  cancellationReason?: string;
  /** The UTC ISO 8601 timestamp at which the payment session was created. */
  createdAt?: string;
  /** The UTC ISO 8601 timestamp at which the payment session was last updated. */
  updatedAt?: string;
}

/**
 * A natural person, identified by name and physical address.
 */
export interface Person {
  /** Full legal name of the person. */
  name?: string;
  /** Physical address of the person. */
  address?: PhysicalAddress;
}

export type PaymentSessionComplianceAllOf = {
  /** Information about the person paying. Required by some entity configurations to meet regulatory requirements for fund transfers. When required, omitting this field or leaving required sub-fields empty returns a 400 listing the specific fields needed. */
  buyer?: Person;
};

/**
 * Compliance context for a payment session request. Extends the base Compliance schema with buyer information required for travel rule obligations.
This object is request-only — it is never echoed back in responses.
 */
export type PaymentSessionCompliance = Compliance & PaymentSessionComplianceAllOf;

/**
 * A request to create a new payment session.
 */
export interface CreatePaymentSessionRequest {
  /** A decimal representation of the payment amount, denominated in `asset`. */
  amount: string;
  /** The symbol of the asset for the payment amount. */
  asset: Asset;
  /** The target of the payment session. */
  target: PaymentSessionTarget;
  expiries?: PaymentExpiries;
  redirect?: PaymentRedirect;
  /** When true, a capture is automatically created after a successful authorization. When false or omitted, the merchant must create captures manually via the captures endpoint. */
  autoCapture?: boolean;
  /**
   * A merchant-provided internal identifier for this payment session, from the merchant's own system—not visible to the payer. It must not contain personally identifiable information (PII) or payment credentials.
   * @maxLength 256
   */
  externalReferenceId?: string;
  customerDisplay?: CustomerDisplay;
  metadata?: Metadata;
  /** Compliance context for this payment session. Carries buyer information required by some entity configurations to meet regulatory requirements. */
  compliance?: PaymentSessionCompliance;
}

/**
 * A request to cancel a payment session.
 */
export interface CancelPaymentSessionRequest {
  /** The reason for cancelling the payment session. */
  cancellationReason?: string;
}

/**
 * The domain of the EIP-712 typed data.
 */
export interface EIP712Domain {
  /** The name of the DApp or protocol. */
  name?: string;
  /** The version of the DApp or protocol. */
  version?: string;
  /** The chain ID of the EVM network. */
  chainId?: number;
  /**
   * The 0x-prefixed EVM address of the verifying smart contract.
   * @pattern ^0x[a-fA-F0-9]{40}$
   */
  verifyingContract?: string;
  /**
   * The optional 32-byte 0x-prefixed hex salt for domain separation.
   * @pattern ^0x[a-fA-F0-9]{64}$
   */
  salt?: string;
}

/**
 * A mapping of struct names to an array of type objects (name + type).
Each key corresponds to a type name (e.g., "`EIP712Domain`", "`PermitTransferFrom`").

 */
export interface EIP712Types {
  [key: string]: unknown;
}

/**
 * The message to sign. The structure of this message must match the `primaryType` struct in the `types` object.
 */
export type EIP712MessageMessage = { [key: string]: unknown };

/**
 * The message to sign using EIP-712.
 */
export interface EIP712Message {
  domain: EIP712Domain;
  types: EIP712Types;
  /** The primary type of the message. This is the name of the struct in the `types` object that is the root of the message. */
  primaryType: string;
  /** The message to sign. The structure of this message must match the `primaryType` struct in the `types` object. */
  message: EIP712MessageMessage;
}

/**
 * The payload type.
 */
export type EIP3009PayloadType = (typeof EIP3009PayloadType)[keyof typeof EIP3009PayloadType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const EIP3009PayloadType = {
  eip3009: "eip3009",
} as const;

/**
 * An EIP-3009 TransferWithAuthorization typed-data payload. The payer must pass `data` to `eth_signTypedData_v4` and return the resulting signature.
 */
export interface EIP3009Payload {
  /** The unique identifier of the payload. */
  payloadId: string;
  /** The payload type. */
  type: EIP3009PayloadType;
  /** EIP-712 typed data for a TransferWithAuthorization. Pass to `eth_signTypedData_v4`. */
  data: EIP712Message;
}

/**
 * The payload type.
 */
export type Permit2PayloadType = (typeof Permit2PayloadType)[keyof typeof Permit2PayloadType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const Permit2PayloadType = {
  permit2: "permit2",
} as const;

/**
 * A Permit2 PermitTransferFrom typed-data payload. The payer must pass `data` to `eth_signTypedData_v4` and return the resulting signature.
 */
export interface Permit2Payload {
  /** The unique identifier of the payload. */
  payloadId: string;
  /** The payload type. */
  type: Permit2PayloadType;
  /** EIP-712 typed data for a Permit2 PermitTransferFrom. Pass to `eth_signTypedData_v4`. */
  data: EIP712Message;
}

export type Erc20ApprovalPayloadType =
  (typeof Erc20ApprovalPayloadType)[keyof typeof Erc20ApprovalPayloadType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const Erc20ApprovalPayloadType = {
  erc20_approval: "erc20_approval",
} as const;

/**
 * An EVM transaction object. Send via `eth_sendTransaction`.
 */
export type Erc20ApprovalPayloadData = {
  /** The EVM chain ID for the transaction. */
  chainId: number;
  /**
   * The 0x-prefixed address of the ERC-20 token contract to approve.
   * @pattern ^0x[a-fA-F0-9]{40}$
   */
  to: string;
  /** The ABI-encoded `approve()` calldata. */
  data: string;
  /** The native token value to send (always `"0"` for approvals). */
  value: string;
  /** The estimated gas limit for the transaction. */
  gas?: string;
  /** The maximum fee per gas unit (EIP-1559). */
  maxFeePerGas?: string;
  /** The maximum priority fee per gas unit (EIP-1559). */
  maxPriorityFeePerGas?: string;
};

/**
 * An ERC-20 approval transaction payload. The payer must send `data` as an EVM transaction via `eth_sendTransaction` and return the resulting transaction hash.
 */
export interface Erc20ApprovalPayload {
  /** The unique identifier of the payload. */
  payloadId: string;
  type: Erc20ApprovalPayloadType;
  /** An EVM transaction object. Send via `eth_sendTransaction`. */
  data: Erc20ApprovalPayloadData;
}

/**
 * The payload type.
 */
export type SpendPermissionPayloadType =
  (typeof SpendPermissionPayloadType)[keyof typeof SpendPermissionPayloadType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SpendPermissionPayloadType = {
  spend_permission: "spend_permission",
} as const;

/**
 * A spend permission EIP-712 typed-data payload. The payer must pass `data` to `eth_signTypedData_v4` and return the resulting signature. This grants a spender the ability to transfer tokens from the payer's smart account under the specified constraints (allowance, period, expiry).
 */
export interface SpendPermissionPayload {
  /** The unique identifier of the payload. */
  payloadId: string;
  /** The payload type. */
  type: SpendPermissionPayloadType;
  /** EIP-712 typed data for a SpendPermission approval. Pass to `eth_signTypedData_v4`. */
  data: EIP712Message;
}

/**
 * A single onchain payload the payer must process to complete an onchain payment option. Inspect `type` to determine how to handle the `data` field:
- `eip3009` — pass `data` to `eth_signTypedData_v4`, return the signature.
- `permit2` — pass `data` to `eth_signTypedData_v4`, return the signature.
- `erc20_approval` — send `data` via `eth_sendTransaction`, return the transaction hash.
- `spend_permission` — pass `data` to `eth_signTypedData_v4`, return the signature.
 */
export type OnchainSignaturePayload =
  | EIP3009Payload
  | Permit2Payload
  | Erc20ApprovalPayload
  | SpendPermissionPayload;

/**
 * An authorization option for completing payment via a wallet. Specifies the currency, amount, and network the payer would pay on, and the payloads the payer must sign or submit.
 */
export interface WalletAuthorizationOption {
  /** The unique identifier of the authorization option. */
  optionId: string;
  /** The source address this authorization option applies to. */
  source: PaymentSourceWallet;
  /** A decimal representation of the amount the payer would pay if they choose this option, denominated in `asset`. May differ from the session amount when paying in a different asset. */
  amount: string;
  /** The symbol of the asset the payer would pay in for this option. */
  asset: Asset;
  /** The blockchain network the transaction will occur on for this option. */
  network: PaymentSourceNetwork;
  /** The payloads the payer must sign or submit to authorize the payment via this option. */
  payloads: OnchainSignaturePayload[];
}

/**
 * Describes, for one enabled (network, asset) combination, what the payer would need to fund a source address with so that it becomes eligible to authorize the payment. Appears in the `fundsRequired` list of an ineligible address whose `code` is `insufficient_funds`. All amounts are human-readable decimal strings, formatted the same way as `WalletAuthorizationOption.amount`.
 */
export interface WalletAuthorizationFundsRequirement {
  /** The symbol of the asset the payer would fund on this network. */
  asset: Asset;
  /** The blockchain network this funding requirement applies to. */
  network: PaymentSourceNetwork;
  /** A decimal representation of the address's current balance of `asset` on this `network`. */
  currentBalance: string;
  /** A decimal representation of the balance of `asset` the payer must hold on this `network` to become eligible to authorize the payment. */
  requiredBalance: string;
}

/**
 * A machine-readable code indicating why this address has no eligible authorization option. The enum is closed — any value the server returns must be listed below. Adding a new code is a deliberate, coordinated API change; clients receiving an undocumented value should treat it as a server violating the spec.
 */
export type IneligibleWalletAuthorizationAddressCode =
  (typeof IneligibleWalletAuthorizationAddressCode)[keyof typeof IneligibleWalletAuthorizationAddressCode];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const IneligibleWalletAuthorizationAddressCode = {
  /** The address does not hold enough of the session asset on a supported source network to cover the session amount. */
  insufficient_funds: "insufficient_funds",
  /** The address was superseded because a preferred funding option was selected instead. */
  superseded_by_preferred_option: "superseded_by_preferred_option",
} as const;

/**
 * A requested payer wallet address that has no eligible authorization option for this payment session, along with a machine- and human-readable reason.
 */
export interface IneligibleWalletAuthorizationAddress {
  /** The requested payer wallet address that has no eligible authorization option. */
  address: BlockchainAddress;
  /** A machine-readable code indicating why this address has no eligible authorization option. The enum is closed — any value the server returns must be listed below. Adding a new code is a deliberate, coordinated API change; clients receiving an undocumented value should treat it as a server violating the spec. */
  code: IneligibleWalletAuthorizationAddressCode;
  /** A human-readable, English-language description of why this address has no eligible authorization option. Suitable for surfacing in product UIs — does not contain personally identifiable information or internal infrastructure details. Clients that need localized strings should dispatch on `code` and provide their own translations. */
  message: string;
  /** The funding options for this address, one entry per (network, asset) combination the payer could fund to become eligible. Only present when `code` is `insufficient_funds`, and honors the request's `network` and `asset` filters. May be an empty array. */
  fundsRequired?: WalletAuthorizationFundsRequirement[];
}

/**
 * The available wallet authorization options for a payment session. Each option describes one way the payer can authorize the payment from their wallet. Present the options to the payer and let them choose one. Requested addresses with no eligible option appear in `ineligibleAddresses` with a `code` explaining why.
 */
export interface WalletAuthorizationOptionsResponse {
  /** The available wallet authorization options. */
  options: WalletAuthorizationOption[];
  /** Requested payer addresses that have no eligible authorization option, each with a `code` explaining why. Empty when every requested address can authorize the payment. */
  ineligibleAddresses: IneligibleWalletAuthorizationAddress[];
}

/**
 * A processed onchain payload containing the payload ID and the payer's signature or transaction hash. The `signature` value depends on the original payload `type`:
- `eip3009` / `permit2` / `spend_permission` — a hex-encoded signature from `eth_signTypedData_v4`.
- `erc20_approval` — a hex-encoded transaction hash from `eth_sendTransaction`.
- `solana_subscription` — the 64-byte ed25519 signature for the payer that
  signed, extracted from the signed Solana transaction and base58-encoded.
  Not the signed transaction bytes, and not `0x`-prefixed hex.
 */
export interface OnchainSignedPayload {
  /** The unique identifier of the signed payload. */
  payloadId?: string;
  /** The output from processing the payload. For `eip3009`, `permit2`, and `spend_permission` types, this is the cryptographic signature returned by `eth_signTypedData_v4`. For `erc20_approval` types, this is the transaction hash returned by `eth_sendTransaction`. For `solana_subscription`, this is the payer's 64-byte ed25519 signature extracted from the signed Solana transaction and base58-encoded, not the signed transaction bytes or `0x`-prefixed hex. */
  signature?: string;
}

/**
 * A request to authorize a payment session using a wallet. The payer selects one of the options returned by the wallet authorization options endpoint and submits the signed payloads.
 */
export interface WalletAuthorizationRequest {
  /** The identifier of the chosen authorization option. Must match an `optionId` from the wallet authorization options response. */
  optionId: string;
  /** The processed payloads from the payer, corresponding to the payloads in the selected authorization option. */
  signedPayloads: OnchainSignedPayload[];
  metadata?: Metadata;
  /** Optional customer-facing display data for this authorization, shown to the payer. Falls back to the session's `orderCode` when `referenceCode` is omitted. */
  customerDisplay?: OperationCustomerDisplay;
  /** An optional merchant-provided internal identifier for this wallet authorization, from the merchant's own system—not visible to the payer. */
  externalReferenceId?: ExternalReferenceId;
}

/**
 * A request to authorize a payment session using the payer's Coinbase account authenticated via OAuth.
 */
export interface CoinbaseAuthorizationRequest {
  metadata?: Metadata;
  /** Optional customer-facing display data for this authorization, shown to the payer. Falls back to the session's `orderCode` when `referenceCode` is omitted. */
  customerDisplay?: OperationCustomerDisplay;
  /** An optional merchant-provided internal identifier for this Coinbase authorization, from the merchant's own system—not visible to the payer. */
  externalReferenceId?: ExternalReferenceId;
}

/**
 * The ID of the mandate, a UUID prefixed by `mandate_`.
 * @pattern ^mandate_[a-f0-9\-]{36}$
 */
export type MandateId = string;

/**
 * A request to authorize a payment session against a mandate in `approval_succeeded` status, using the mandate's existing approval. No fresh signature is required. The charge must fall within the mandate's `policy`.
 */
export interface MandateAuthorizationRequest {
  /** The ID of the mandate to authorize against. Must be in `approval_succeeded` status. */
  mandateId: MandateId;
  metadata?: Metadata;
  /** Optional customer-facing display data for this authorization, shown to the payer. Falls back to the session's `orderCode` when `referenceCode` is omitted. */
  customerDisplay?: OperationCustomerDisplay;
  /** An optional merchant-provided internal identifier for this mandate authorization, from the merchant's own system—not visible to the payer. */
  externalReferenceId?: ExternalReferenceId;
}

/**
 * A request to create a capture for a payment session.
 */
export interface CreateCaptureRequest {
  /** A decimal representation of the amount to capture, denominated in the session's `asset`. If omitted, the full remaining capturable amount is captured. */
  amount?: string;
  /** When `true`, this capture is treated as the final one for the authorization. Any remaining capturable balance is released back to the payer immediately after the capture settles. When `false`, the remaining capturable balance stays held and is available for subsequent partial captures (subject to `captureExpiresAt`). Has no effect if `amount` equals the full capturable balance, since no remaining balance exists to release. */
  finalCapture: boolean;
  metadata?: Metadata;
  /** An optional merchant-provided internal identifier for this manual capture, from the merchant's own system—not visible to the payer. */
  externalReferenceId?: ExternalReferenceId;
  /** Optional customer-facing display data for this manual capture, shown to the payer. Falls back to the session's `orderCode` when `referenceCode` is omitted. */
  customerDisplay?: OperationCustomerDisplay;
}

/**
 * A request to create a void for a payment session. A void releases all remaining capturable funds back to the payer, including after partial refunds as long as a capturableAmount remains.
 */
export interface CreateVoidRequest {
  metadata?: Metadata;
  /** An optional merchant-provided internal identifier for this void, from the merchant's own system—not visible to the payer. */
  externalReferenceId?: ExternalReferenceId;
  /** Optional customer-facing display data for this void, shown to the payer. Falls back to the session's `orderCode` when `referenceCode` is omitted. */
  customerDisplay?: OperationCustomerDisplay;
}

/**
 * A request to create a refund for a payment session.
 */
export interface CreateRefundRequest {
  /** The source from which to fund the refund. Can be a CDP account or an onchain address. */
  source: RefundSource;
  /** A decimal representation of the amount to refund, denominated in the session's `asset`. If omitted, the full remaining refundable amount is refunded. */
  amount?: string;
  /** The reason for the refund. */
  reason?: string;
  metadata?: Metadata;
  /** An optional merchant-provided internal identifier for this refund, from the merchant's own system—not visible to the payer. */
  externalReferenceId?: ExternalReferenceId;
  /** Optional customer-facing display data for this refund, shown to the payer. Falls back to the session's `orderCode` when `referenceCode` is omitted. */
  customerDisplay?: OperationCustomerDisplay;
}

/**
 * The most recent action on the mandate. `status` is an informational indicator of the latest transition; it is not the source of truth for what has durably happened. Read the timestamps for that: `approvedAt`, `canceledAt`, and `revokedAt` each record a durable milestone independently of `status`.

- `created`: the mandate exists but no approval has been attempted. No
  source attached. Not usable.


- `approval_pending`: an approval is in flight. Not usable. Emits
  `acceptance.mandate.approval_initiated`.


- `approval_succeeded`: the mandate has a source and is usable.

- `approval_failed`: the last approval attempt failed. Not usable. Submit
  a new approval to retry.


- `revocation_pending`: a wallet revocation is being confirmed on the
  network. Emits `acceptance.mandate.revocation_initiated`. Resolves to
  `revocation_succeeded` on success or `revocation_failed` on failure.


- `revocation_succeeded`: a wallet revocation removed the spending allowance
  on-chain (`revokedAt` is set). Terminal.


- `revocation_failed`: the last wallet revocation attempt did not complete.
  The spending allowance was not removed, so the mandate remains usable if it
  was usable before. Submit a new revocation to retry.


- `canceled`: the merchant ended the mandate off-chain (`canceledAt` is set).
  The on-chain spending allowance may still be live; a later wallet
  revocation can still move `status` through the `revocation_*` values and
  set `revokedAt`.


**Usable when** `approvedAt` is set, `canceledAt` is null, `revokedAt` is null, and `expiresAt` is null or in the future. Usability is derived from these timestamps, not from `status`: a failed revocation, for example, leaves `status` at `revocation_failed` but the mandate stays usable because the allowance was never removed. Authorization checks the durable conditions in order, and the first match wins: an in-flight approval or revocation returns `409` (`mandate_action_pending`); `revokedAt` set returns `422` (`mandate_revoked`); `canceledAt` set returns `422` (`mandate_canceled`); a past `expiresAt` returns `400` (`mandate_expired`); any other status returns `422` (`mandate_invalid_status`). Approve a mandate and get wallet approval options use that same order for the in-flight, revoked, canceled, and expired checks. Any other status except `created` or `approval_failed` returns `422` (`mandate_invalid_status`). Those rejections do not change the timestamps. Debit limits are enforced at authorization time.
 */
export type MandateStatus = (typeof MandateStatus)[keyof typeof MandateStatus];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const MandateStatus = {
  created: "created",
  approval_pending: "approval_pending",
  approval_succeeded: "approval_succeeded",
  approval_failed: "approval_failed",
  revocation_pending: "revocation_pending",
  revocation_succeeded: "revocation_succeeded",
  revocation_failed: "revocation_failed",
  canceled: "canceled",
} as const;

/**
 * A blockchain wallet the mandate draws funds from. Extends the shared payment source wallet, requiring `network` and `asset` alongside `address` (the `asset` is what debits against the mandate are drawn in).
 */
export type MandateSourceWallet = PaymentSourceWallet & unknown;

/**
 * The funding source the mandate draws against. A wallet is the only supported source type today.
 */
export type MandateSource = MandateSourceWallet;

/**
 * The rolling window that `maxPerPeriod.amount` applies over. It is a fixed duration measured back from now, not a calendar window. For example, `month` means the trailing 30 days, not the current calendar month.
 */
export type MandatePolicyPeriod = (typeof MandatePolicyPeriod)[keyof typeof MandatePolicyPeriod];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const MandatePolicyPeriod = {
  day: "day",
  week: "week",
  month: "month",
  year: "year",
} as const;

/**
 * One rolling cap over `period` (a trailing window, not a calendar period). Send both `amount` and `period`, or omit the object. The stored amount is capped at the Coinbase ceiling for that period. Enforced atomically at authorization so concurrent charges cannot exceed the cap.
 */
export interface MandatePolicyPeriodCap {
  /** Max total authorizable in the rolling `period`. Capped at the Coinbase ceiling for `period`. */
  amount: string;
  period: MandatePolicyPeriod;
}

/**
 * Debit caps in the mandate's `asset`. Omit `policy` or send `{}` to default to a Coinbase-configured monthly max. Supplied amounts are capped at Coinbase ceilings. If you set `maxPerPeriod`, include both `amount` and `period`.
 */
export interface MandatePolicy {
  /** Max amount for one authorization. Omit to use the Coinbase default. Capped at the Coinbase ceiling. */
  maxPerAuthorization?: string;
  /** One rolling cap. Omit to use a Coinbase-configured monthly max. If set, both `amount` and `period` are required. Amount is capped at that period's ceiling. */
  maxPerPeriod?: MandatePolicyPeriodCap;
  /** Optional minimum available balance the payer must have to set up the mandate, denominated in the mandate's `asset`. When set, the mandate can only be approved if the payer's available balance is at least this amount; an approval attempted while the balance is below it is rejected with a `422` (`mandate_policy_violation`). This does not dictate the amount debited: the payment session amount remains the source of truth for what is debited. Omit to use the Coinbase-configured default. */
  minSetupBalance?: string;
}

/**
 * Merchant-provided display data shown to the customer on the hosted mandate pages. All fields are informational only. They are stored and returned as-is and do not affect mandate approval, authorization, or policy enforcement.
 */
export interface MandateCustomerDisplay {
  /**
   * The merchant name to display on the hosted mandate pages. When provided, this overrides the default name derived from the entity's profile. Useful when a merchant operates multiple storefronts or brands under a single entity.
   * @maxLength 128
   */
  merchantName?: string;
}

/**
 * A durable, revocable standing authorization to debit a funding `source` without the customer present each time, within its `policy` caps. Payment sessions draw against it by referencing its `mandateId`.

`source` is set once an approval succeeds. `status` reflects the most recent action; the `approvedAt`, `canceledAt`, and `revokedAt` timestamps are the durable record of what has happened. Ending one mandate does not affect other mandates on the same `source`.
 */
export interface Mandate {
  /** The unique identifier of the mandate. */
  mandateId: MandateId;
  /** The unit of account the mandate's `policy` caps are denominated in (e.g., `500` means 500 of this asset). Fixed at creation. This is only the denomination for the limits; the funding `source` may hold a different asset (for example, limits in `usdc` against a `usdt` source). Each authorization's amount is converted into this asset at authorization time to evaluate the caps, so the caps are always enforced in a single denomination. */
  asset: Asset;
  /** The funding source the mandate draws against. Set when an approval succeeds. Not present before the mandate is `approval_succeeded`. */
  source?: MandateSource;
  /** Debit caps. Always present. If you omitted `policy` at create, this is a Coinbase-configured monthly max. */
  policy: MandatePolicy;
  /** The current status of the mandate. */
  status: MandateStatus;
  /** The UTC ISO 8601 timestamp after which the mandate can no longer be authorized against. Authorization attempts after this time return `422`; `status` does not change. Omit for no expiry. */
  expiresAt?: string;
  /** Hosted page where the customer approves this mandate. Present only before the mandate reaches `approval_succeeded`; complemented by `revocationUrl` afterward. */
  readonly url?: Url;
  /** Hosted page where the customer can remove their spending allowance for this mandate. Present once the mandate has a `source` (from `approval_succeeded` onward); absent before approval, when there is nothing to revoke. */
  readonly revocationUrl?: Url;
  /** Optional merchant URLs used by the hosted mandate approval flow. The approval page redirects to `successUrl` when approval succeeds, or `failureUrl` when it fails. When omitted, the approval page keeps the customer on the Coinbase-hosted experience. */
  approvalRedirect?: PaymentRedirect;
  /** Optional merchant URLs used by the hosted mandate revocation flow. The revocation page redirects to `successUrl` when revocation succeeds, or `failureUrl` when it fails. When omitted, the revocation page keeps the customer on the Coinbase-hosted experience. */
  revocationRedirect?: PaymentRedirect;
  customerDisplay?: MandateCustomerDisplay;
  /** The UTC ISO 8601 timestamp at which an approval succeeded and the mandate became usable. Present only once the mandate has been approved; set once, on the successful approval, and unchanged by later transitions. Its presence is the durable signal that the mandate was approved, independent of `status`. */
  approvedAt?: string;
  /** The UTC ISO 8601 timestamp at which the merchant canceled the mandate off-chain. Present only once the mandate has been canceled. Canceling does not touch the on-chain spending allowance; check `revokedAt` for that. */
  canceledAt?: string;
  /** The UTC ISO 8601 timestamp at which the spending allowance was removed on-chain by a wallet revocation. Present only once that has happened. Its presence is the single signal that the allowance is gone, independent of `status` (for example, it can be set on a `canceled` mandate whose allowance was later cleaned up). */
  revokedAt?: string;
  metadata?: Metadata;
  /** The UTC ISO 8601 timestamp at which the mandate was created. */
  createdAt: string;
  /** The UTC ISO 8601 timestamp at which the mandate was last updated. */
  updatedAt: string;
}

/**
 * A request to create a new mandate. The merchant is inferred from the API key. The mandate is returned in `created` status with no source. Attach a source next by approving the mandate, using **Get wallet approval options** then **Approve a mandate with a wallet**, which returns a `pending` approval; the mandate becomes `approval_succeeded` once that approval succeeds. The mandate is denominated in `asset`, fixed at creation. `policy` is optional. Omit it or send `{}` to default to a Coinbase-configured monthly max. The response includes the resolved `policy`. If you set `maxPerPeriod`, include both `amount` and `period`.
 */
export interface CreateMandateRequest {
  /** The unit of account the mandate's `policy` caps are denominated in (e.g., `500` means 500 of this asset). Fixed at creation. This is only the denomination for the limits; the funding `source` may hold a different asset (for example, limits in `usdc` against a `usdt` source). Each authorization's amount is converted into this asset at authorization time to evaluate the caps, so the caps are always enforced in a single denomination. */
  asset: Asset;
  /** Optional. Omit or send `{}` to default to a Coinbase-configured monthly max. If you set `maxPerPeriod`, include both `amount` and `period`. */
  policy?: MandatePolicy;
  /** The UTC ISO 8601 timestamp after which this mandate can no longer be authorized against. Omit for a mandate with no expiry. */
  expiresAt?: string;
  /** Optional merchant URLs used by the hosted mandate approval flow. The approval page redirects to `successUrl` when approval succeeds, or `failureUrl` when it fails. Omit to keep the customer on the Coinbase-hosted experience. */
  approvalRedirect?: PaymentRedirect;
  /** Optional merchant URLs used by the hosted mandate revocation flow. The revocation page redirects to `successUrl` when revocation succeeds, or `failureUrl` when it fails. Omit to keep the customer on the Coinbase-hosted experience. */
  revocationRedirect?: PaymentRedirect;
  customerDisplay?: MandateCustomerDisplay;
  metadata?: Metadata;
}

/**
 * A request to cancel a mandate. The merchant is inferred from the API key.
 */
export interface CancelMandateRequest {
  /** An optional human-readable reason for canceling the mandate. */
  reason?: string;
}

/**
 * The ID of a revocation, a UUID prefixed by `revocation_`.
 * @pattern ^revocation_[a-f0-9\-]{36}$
 */
export type RevocationId = string;

/**
 * The status of a wallet revocation attempt:

- `pending`: awaiting network confirmation.

- `succeeded`: the spending allowance has been removed on-chain.

- `failed`: the revocation did not complete (see `error`).
 */
export type RevocationStatus = (typeof RevocationStatus)[keyof typeof RevocationStatus];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const RevocationStatus = {
  pending: "pending",
  succeeded: "succeeded",
  failed: "failed",
} as const;

/**
 * A record of a wallet revocation: the customer removing the mandate's spending allowance on-chain (see `onchainTransactions`). While it is confirming, the mandate's `status` is `revocation_pending`; on success it becomes `revocation_succeeded` and the mandate's `revokedAt` is set, and on failure it becomes `revocation_failed`. This applies regardless of whether the mandate was previously canceled: a revocation on an already-canceled mandate still moves `status` through the `revocation_*` values and sets `revokedAt`.

To check whether the spending allowance is still active, read the mandate: `revokedAt` is set once the allowance has been removed.
 */
export interface Revocation {
  /** The unique identifier of the revocation. */
  revocationId: RevocationId;
  /** The unique identifier of the mandate this revocation applies to. */
  mandateId: MandateId;
  /** The current status of the revocation attempt. */
  status: RevocationStatus;
  /** Network transactions that remove the spending allowance on-chain. Empty until the revocation has been submitted to the network. */
  onchainTransactions?: OnchainTransaction[];
  /** Details of why the revocation failed. Only present when `status` is `failed`. */
  error?: PaymentError;
  metadata?: Metadata;
  /** The UTC ISO 8601 timestamp at which the revocation was created. */
  createdAt: string;
  /** The UTC ISO 8601 timestamp at which the revocation was last updated. */
  updatedAt: string;
}

/**
 * A request to remove a mandate's spending allowance on-chain. Submit the `optionId` the customer chose from **Get wallet revocation options** along with their signed payloads. Returns a `pending` revocation that resolves once the network transaction confirms.
 */
export interface WalletRevocationRequest {
  /** The identifier of the chosen option. Must match an `optionId` from the **Get wallet revocation options** response. */
  optionId: string;
  /** The processed payloads from the customer, corresponding to the payloads in the selected option. */
  signedPayloads: OnchainSignedPayload[];
  /** An optional human-readable reason for revoking the spending allowance. */
  reason?: string;
  metadata?: Metadata;
}

export type EIP2612PayloadType = (typeof EIP2612PayloadType)[keyof typeof EIP2612PayloadType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const EIP2612PayloadType = {
  eip2612: "eip2612",
} as const;

/**
 * An EIP-2612 Permit typed-data payload. The payer must pass `data` to `eth_signTypedData_v4` and return the resulting signature. Used to set up a mandate's reusable credential; the permit stands in for a live per-authorization signature on later authorizations.
 */
export interface EIP2612Payload {
  /** The unique identifier of the payload. */
  payloadId: string;
  type: EIP2612PayloadType;
  /** EIP-712 typed data for an EIP-2612 Permit. Pass to `eth_signTypedData_v4`. */
  data: EIP712Message;
}

export type Permit2AllowancePayloadType =
  (typeof Permit2AllowancePayloadType)[keyof typeof Permit2AllowancePayloadType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const Permit2AllowancePayloadType = {
  permit2: "permit2",
} as const;

/**
 * A Permit2 `PermitSingle` (AllowanceTransfer) typed-data payload. It grants the spender a reusable allowance through the canonical Permit2 contract, so it can back repeated charges rather than a single transfer. The payer must pass `data` to `eth_signTypedData_v4` and return the resulting signature. A one-time ERC-20 approval of the Permit2 contract (an `erc20_approval` payload) is required first if the wallet has not yet approved Permit2 for this asset.
 */
export interface Permit2AllowancePayload {
  /** The unique identifier of the payload. */
  payloadId: string;
  type: Permit2AllowancePayloadType;
  /** EIP-712 typed data for a Permit2 `PermitSingle`. Pass to `eth_signTypedData_v4`. */
  data: EIP712Message;
}

/**
 * The unsigned Solana transaction the payer signs to approve or revoke a mandate on a Solana wallet source. Decode `transaction` and pass it to the Solana Wallet Standard `signTransaction` method. Submit only the extracted per-signer signature, not the signed transaction.
 */
export interface SolanaSubscriptionPayloadData {
  /** The unsigned Solana transaction, serialized to bytes and encoded as base64. Pass the decoded bytes to the Solana Wallet Standard `signTransaction` method. Do not POST this field (or the signed transaction bytes) as `OnchainSignedPayload.signature`. */
  transaction: string;
}

export type SolanaSubscriptionPayloadType =
  (typeof SolanaSubscriptionPayloadType)[keyof typeof SolanaSubscriptionPayloadType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SolanaSubscriptionPayloadType = {
  solana_subscription: "solana_subscription",
} as const;

/**
 * An unsigned Solana transaction the payer must sign to approve or revoke a mandate on a Solana wallet source. Decode `data.transaction` from base64 and pass the bytes to the Solana Wallet Standard `signTransaction` method (never `signAndSendTransaction`). Do not submit the signed transaction bytes. From the signed transaction, take the 64-byte ed25519 signature for the payer that signed, base58-encode those 64 bytes, and return that string as `OnchainSignedPayload.signature`.
 */
export interface SolanaSubscriptionPayload {
  /** The unique identifier of the payload. */
  payloadId: string;
  type: SolanaSubscriptionPayloadType;
  data: SolanaSubscriptionPayloadData;
}

/**
 * A single payload the customer signs to remove the mandate's spending allowance on-chain. Each payload sets the allowance to zero using the same credential type that granted it. Inspect `type` to determine how to handle `data`:

- `eip2612`: an EIP-2612 `Permit` with `value` of `0`; pass `data` to
  `eth_signTypedData_v4`, return the signature.


- `permit2`: a Permit2 `PermitSingle` with `amount` of `0`; pass `data` to
  `eth_signTypedData_v4`, return the signature.


- `erc20_approval`: an ERC-20 `approve` of `0`; send `data` via
  `eth_sendTransaction`, return the transaction hash.

- `solana_subscription`: decode `data.transaction` from base64 and pass the
  bytes to the Solana Wallet Standard `signTransaction` method (never
  `signAndSendTransaction`). The transaction is `revokeDelegation`.
  From the signed transaction, extract the 64-byte ed25519 signature for
  the payer that signed, base58-encode it, and return that string as
  `OnchainSignedPayload.signature`.
 */
export type RevocationPayload =
  | EIP2612Payload
  | Permit2AllowancePayload
  | Erc20ApprovalPayload
  | SolanaSubscriptionPayload;

/**
 * One way the customer can remove the mandate's spending allowance on-chain: a source and the payloads to sign for it.
 */
export interface WalletMandateRevocationOption {
  /** The unique identifier of the wallet mandate revocation option. */
  optionId: string;
  /** The funding source whose spending allowance this option removes. */
  source: MandateSourceWallet;
  /** The payloads the customer must sign to remove the spending allowance. */
  payloads: RevocationPayload[];
}

/**
 * The ways the customer can remove this mandate's spending allowance on-chain.
 */
export interface WalletMandateRevocationOptionsResponse {
  /** The available revocation options. At least one is present; when there is no active spending allowance to remove, the request fails with a `422` instead. */
  options: WalletMandateRevocationOption[];
}

/**
 * The ID of an approval, a UUID prefixed by `approval_`.
 * @pattern ^approval_[a-f0-9\-]{36}$
 */
export type ApprovalId = string;

/**
 * The status of an approval attempt:

- `pending`: the submitted source is being bound and verified.

- `succeeded`: the mandate's `source` is attached and its status becomes
  `approval_succeeded`.


- `failed`: the attempt could not be completed (see `error`). The mandate's
  status becomes `approval_failed`; submit a new approval to retry (which
  moves it back to `approval_pending`).
 */
export type ApprovalStatus = (typeof ApprovalStatus)[keyof typeof ApprovalStatus];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const ApprovalStatus = {
  pending: "pending",
  succeeded: "succeeded",
  failed: "failed",
} as const;

/**
 * An attempt to attach a funding source to a mandate and make it usable. A successful approval sets the mandate's `source` and moves the mandate to `approval_succeeded`; a failed one moves the mandate to `approval_failed` and can be retried by submitting a new approval. A mandate holds at most one active source, so at most one approval ever succeeds. The network transactions that grant the spending allowance are on `onchainTransactions`.
 */
export interface Approval {
  /** The unique identifier of the approval. */
  approvalId: ApprovalId;
  /** The current status of the approval attempt. */
  status: ApprovalStatus;
  /** The funding source this approval binds to the mandate. Present once the source has been determined from the customer's submission. */
  source?: MandateSource;
  /** Network transactions that grant the spending allowance on-chain. Empty until the approval has been submitted to the network. */
  onchainTransactions?: OnchainTransaction[];
  /** Details of why the approval failed. Only present when `status` is `failed`. */
  error?: PaymentError;
  metadata?: Metadata;
  /** The UTC ISO 8601 timestamp at which the approval was created. */
  createdAt: string;
  /** The UTC ISO 8601 timestamp at which the approval was last updated. */
  updatedAt: string;
}

/**
 * A request to approve a mandate on a wallet source. Submit the `optionId` the customer chose from **Get wallet approval options** along with the signed payloads. This creates a `pending` approval; the mandate becomes `approval_succeeded` once the approval succeeds.
 */
export interface WalletApprovalRequest {
  /** The identifier of the chosen option. Must match an `optionId` from the **Get wallet approval options** response. */
  optionId: string;
  /** The processed payloads from the customer, corresponding to the payloads in the selected option. */
  signedPayloads: OnchainSignedPayload[];
  metadata?: Metadata;
}

/**
 * A single payload the customer signs to approve a mandate on a wallet source. Mandates support allowance-style credentials only, since a mandate must be reusable for later debits when the customer is not present. Inspect `type` to determine how to handle `data`:

- `eip2612`: pass `data` to `eth_signTypedData_v4`, return the signature.

- `permit2`: a Permit2 `PermitSingle` (AllowanceTransfer) granting a
  reusable allowance; pass `data` to `eth_signTypedData_v4`, return the
  signature. Preceded by a one-time `erc20_approval` of the Permit2 contract
  when the wallet has not yet approved Permit2 for this asset.


- `erc20_approval`: send `data` via `eth_sendTransaction`, return the transaction hash.
- `solana_subscription`: decode `data.transaction` from base64 and pass the
  bytes to the Solana Wallet Standard `signTransaction` method (never
  `signAndSendTransaction`). From the signed transaction, extract the
  64-byte ed25519 signature for the payer that signed, base58-encode it,
  and return that string as `OnchainSignedPayload.signature`. Do not
  submit the signed transaction bytes.
 */
export type ApprovalPayload =
  | EIP2612Payload
  | Permit2AllowancePayload
  | Erc20ApprovalPayload
  | SolanaSubscriptionPayload;

/**
 * An option for approving a mandate on a wallet source. Specifies the source (address, network, asset) and the payloads the customer must sign to approve the mandate on that source.
 */
export interface WalletMandateApprovalOption {
  /** The unique identifier of the wallet mandate approval option. */
  optionId: string;
  /** The source this option would attach to the mandate. */
  source: MandateSourceWallet;
  /** The payloads the customer must sign to approve this source. */
  payloads: ApprovalPayload[];
}

/**
 * Describes, for one enabled (network, asset) combination, what the customer would need to fund a source address with so that it becomes eligible to approve the mandate. Appears in the `fundsRequired` list of an ineligible address whose `code` is `insufficient_funds`. All amounts are human-readable decimal strings.
 */
export interface WalletMandateApprovalFundsRequirement {
  /** The symbol of the asset the customer would fund on this network. */
  asset: Asset;
  /** The blockchain network this funding requirement applies to. */
  network: PaymentSourceNetwork;
  /** A decimal representation of the address's current balance of `asset` on this `network`. */
  currentBalance: string;
  /** A decimal representation of the balance of `asset` the customer must hold on this `network` to become eligible to approve the mandate. */
  requiredBalance: string;
}

/**
 * A machine-readable code indicating why this address has no eligible mandate approval option. The enum is closed; any value the server returns must be listed below. Adding a new code is a deliberate, coordinated API change; clients receiving an undocumented value should treat it as a server violating the spec.
 */
export type IneligibleWalletMandateApprovalAddressesCode =
  (typeof IneligibleWalletMandateApprovalAddressesCode)[keyof typeof IneligibleWalletMandateApprovalAddressesCode];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const IneligibleWalletMandateApprovalAddressesCode = {
  /** The address does not hold enough of a supported asset on a supported source network to approve the mandate. */
  insufficient_funds: "insufficient_funds",
  /** The address was superseded because a preferred funding option was selected instead. */
  superseded_by_preferred_option: "superseded_by_preferred_option",
} as const;

/**
 * A requested customer wallet address that has no eligible mandate approval option, along with a machine- and human-readable reason.
 */
export interface IneligibleWalletMandateApprovalAddresses {
  /** The requested customer wallet address that has no eligible mandate approval option. */
  address: BlockchainAddress;
  /** A machine-readable code indicating why this address has no eligible mandate approval option. The enum is closed; any value the server returns must be listed below. Adding a new code is a deliberate, coordinated API change; clients receiving an undocumented value should treat it as a server violating the spec. */
  code: IneligibleWalletMandateApprovalAddressesCode;
  /** A human-readable, English-language description of why this address has no eligible mandate approval option. Suitable for surfacing in product UIs; does not contain personally identifiable information or internal infrastructure details. Clients that need localized strings should dispatch on `code` and provide their own translations. */
  message: string;
  /** The funding options for this address, one entry per (network, asset) combination the customer could fund to become eligible. Only present when `code` is `insufficient_funds`, and honors the request's `network` and `asset` filters. May be an empty array. */
  fundsRequired?: WalletMandateApprovalFundsRequirement[];
}

/**
 * The available options for approving this mandate on a wallet source, one per eligible asset the address can back. Present them to the customer, have them sign the chosen option's payloads, then call **Approve a mandate with a wallet**. Requested addresses with no eligible option appear in `ineligibleAddresses` with a `code` explaining why. This is a stateless read operation and does not modify the mandate.
 */
export interface WalletMandateApprovalOptionsResponse {
  /** The available wallet mandate approval options. */
  options: WalletMandateApprovalOption[];
  /** Requested customer addresses that have no eligible mandate approval option, each with a `code` explaining why. Empty when every requested address can approve the mandate. */
  ineligibleAddresses: IneligibleWalletMandateApprovalAddresses[];
}

/**
 * The ID of the disbursement, a UUID prefixed by `disbursement_`.
 * @pattern ^disbursement_[a-f0-9\-]{36}$
 */
export type DisbursementId = string;

/**
 * The source from which the disbursement is funded. Currently restricted to a CDP account owned by the merchant. Modeled as a `oneOf` so additional source types (e.g. a merchant-controlled onchain wallet) can be added without a breaking change.
 */
export type DisbursementSource = TransfersAccount;

/**
 * A Coinbase-user target for the disbursement.
 */
export interface DisbursementCoinbaseTarget {
  /** The unique identifier of the recipient within Coinbase. */
  coinbaseUserId: string;
}

/**
 * The blockchain network for the payment. Supported networks depend on the account type.
 */
export type Network = (typeof Network)[keyof typeof Network];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const Network = {
  base: "base",
  ethereum: "ethereum",
  solana: "solana",
  aptos: "aptos",
  arbitrum: "arbitrum",
  "arbitrum-sepolia": "arbitrum-sepolia",
  optimism: "optimism",
  polygon: "polygon",
  world: "world",
  "world-sepolia": "world-sepolia",
} as const;

/**
 * An onchain address target for the disbursement.
 */
export interface DisbursementWalletTarget {
  /** The onchain crypto address of the recipient. */
  address: BlockchainAddress;
  /** The blockchain network on which the target receives funds. */
  network: Network;
}

/**
 * The target of the disbursement. Can be either a Coinbase user account or an onchain blockchain address.
 */
export type DisbursementTarget = DisbursementCoinbaseTarget | DisbursementWalletTarget;

/**
 * A Disbursement represents a merchant-initiated payment of funds from a CDP account they own to a Coinbase account or onchain address. Used for standalone refunds, goodwill disbursements, rebates, and other merchant-driven payouts that are not tied to a specific payment session.

Disbursements are asynchronous: the resource is returned in `pending` status and transitions to `succeeded` (with associated `onchainTransactions`) or `failed` (with `error`).
 */
export interface Disbursement {
  /** The unique identifier of the disbursement. */
  disbursementId: DisbursementId;
  /** The source from which the disbursement is funded. */
  source: DisbursementSource;
  /** The target receiving the disbursement. */
  target: DisbursementTarget;
  /** A decimal representation of the disbursed amount, denominated in `asset`. */
  amount: string;
  /** The symbol of the asset for the disbursement amount. */
  asset: Asset;
  /** The current status of the disbursement. */
  status: PaymentActionStatus;
  /** Human-readable reason for the disbursement. */
  reason?: string;
  /**
   * A merchant-provided internal identifier for this disbursement, from the merchant's own system—not visible to the payer. It must not contain personally identifiable information (PII) or payment credentials.
   * @maxLength 256
   */
  externalReferenceId?: string;
  /** Customer-facing display data for this disbursement, shown to the payer. Always present: if the create request omits `referenceCode`, one is auto-generated, since disbursements have no payment session to fall back to. */
  customerDisplay?: OperationCustomerDisplay;
  metadata?: Metadata;
  /** Error details, present only when the disbursement failed. */
  error?: PaymentError;
  /** The onchain transactions associated with this disbursement. */
  onchainTransactions?: OnchainTransaction[];
  /** The UTC ISO 8601 timestamp at which the disbursement was created. */
  createdAt: string;
  /** The UTC ISO 8601 timestamp at which the disbursement was last updated. */
  updatedAt: string;
}

export type DisbursementComplianceAllOf = {
  /** Information about the person receiving this disbursement. Required by some entity configurations to meet regulatory requirements for fund transfers. When required, omitting this field or leaving required sub-fields empty returns a 400 listing the specific fields needed. */
  recipient?: Person;
};

/**
 * Compliance context for a disbursement request. Extends the base Compliance schema with recipient information required for travel rule obligations.
This object is request-only — it is never echoed back in responses.
 */
export type DisbursementCompliance = Compliance & DisbursementComplianceAllOf;

/**
 * A request to create a disbursement.
 */
export interface CreateDisbursementRequest {
  /** The source from which to fund the disbursement. */
  source: DisbursementSource;
  /** The target receiving the disbursement. */
  target: DisbursementTarget;
  /** A decimal representation of the amount to disburse, denominated in `asset`. */
  amount: string;
  /** The symbol of the asset for the disbursement amount. */
  asset: Asset;
  /** Human-readable reason for the disbursement. */
  reason?: string;
  /**
   * A merchant-provided internal identifier for this disbursement, from the merchant's own system—not visible to the payer. It must not contain personally identifiable information (PII) or payment credentials.
   * @maxLength 256
   */
  externalReferenceId?: string;
  /** Optional customer-facing display data for this disbursement, shown to the payer. If `referenceCode` is omitted, one is auto-generated — disbursements have no payment session to fall back to, unlike every other action type. */
  customerDisplay?: OperationCustomerDisplay;
  metadata?: Metadata;
  /** Compliance context for this disbursement. Carries recipient information required by some entity configurations to meet regulatory requirements. */
  compliance?: DisbursementCompliance;
}

/**
 * The type of authentication information.
 */
export type EmailAuthenticationType =
  (typeof EmailAuthenticationType)[keyof typeof EmailAuthenticationType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const EmailAuthenticationType = {
  email: "email",
} as const;

/**
 * Information about an end user who authenticates using a one-time password sent to their email address.
 */
export interface EmailAuthentication {
  /** The type of authentication information. */
  type: EmailAuthenticationType;
  /** The email address of the end user. */
  email: Email;
}

/**
 * The type of authentication information.
 */
export type SmsAuthenticationType =
  (typeof SmsAuthenticationType)[keyof typeof SmsAuthenticationType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SmsAuthenticationType = {
  sms: "sms",
} as const;

/**
 * Information about an end user who authenticates using a one-time password sent to their phone number via SMS.
 */
export interface SmsAuthentication {
  /** The type of authentication information. */
  type: SmsAuthenticationType;
  /** Phone number in [E.164](https://en.wikipedia.org/wiki/E.164) format. */
  phoneNumber: PhoneNumber;
}

/**
 * The type of authentication information.
 */
export type DeveloperJWTAuthenticationType =
  (typeof DeveloperJWTAuthenticationType)[keyof typeof DeveloperJWTAuthenticationType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const DeveloperJWTAuthenticationType = {
  jwt: "jwt",
} as const;

/**
 * Information about an end user who authenticates using a JWT issued by the developer.
 */
export interface DeveloperJWTAuthentication {
  /** The type of authentication information. */
  type: DeveloperJWTAuthenticationType;
  /** The key ID of the JWK used to sign the JWT. */
  kid: string;
  /** The unique identifier for the end user that is captured in the `sub` claim of the JWT. */
  sub: string;
}

/**
 * The type of OAuth2 provider.
 */
export type OAuth2ProviderType = (typeof OAuth2ProviderType)[keyof typeof OAuth2ProviderType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const OAuth2ProviderType = {
  google: "google",
  apple: "apple",
  x: "x",
  telegram: "telegram",
  github: "github",
} as const;

/**
 * Information about an end user who authenticates using a third-party provider.
 */
export interface OAuth2Authentication {
  type: OAuth2ProviderType;
  /** The unique identifier for the end user that is captured in the `sub` claim of the JWT. */
  sub: string;
  /** The email address of the end user contained within the user's ID token, if available from third-party OAuth2 provider's token exchange. */
  email?: string;
  /** The full name of the end user if available from third-party OAuth2 provider's token exchange. */
  name?: string;
  /** The username of the end user if available from third-party OAuth2 provider's token exchange. */
  username?: string;
}

/**
 * Information about an end user who authenticates using Telegram.
 */
export interface TelegramAuthentication {
  type: OAuth2ProviderType;
  /** The Telegram ID for the end user. */
  id: number;
  /** The Telegram user's first name. */
  firstName?: string;
  /** The Telegram user's last name. */
  lastName?: string;
  /** The Telegram user's profile picture. */
  photoUrl?: string;
  /** The Telegram user's last login as a Unix timestamp. */
  authDate: number;
  /** The Telegram user's username. */
  username?: string;
}

/**
 * The type of authentication information.
 */
export type SiweAuthenticationType =
  (typeof SiweAuthenticationType)[keyof typeof SiweAuthenticationType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SiweAuthenticationType = {
  siwe: "siwe",
} as const;

/**
 * Information about an end user who authenticates using Sign In With Ethereum (EIP-4361).
 */
export interface SiweAuthentication {
  /** The type of authentication information. */
  type: SiweAuthenticationType;
  /** The ERC-55 checksummed Ethereum address of the end user. */
  address: BlockchainAddress;
}

/**
 * Information about how the end user is authenticated.
 */
export type AuthenticationMethod =
  | EmailAuthentication
  | SmsAuthentication
  | DeveloperJWTAuthentication
  | OAuth2Authentication
  | TelegramAuthentication
  | SiweAuthentication;

/**
 * The list of valid authentication methods linked to the end user.
 */
export type AuthenticationMethods = AuthenticationMethod[];

/**
 * An object containing information about the end user's TOTP enrollment.
 */
export type MFAMethodsTotp = {
  /** The date and time when the method was enrolled, in ISO 8601 format. */
  enrolledAt: string;
};

/**
 * An object containing information about the end user's SMS MFA enrollment.
 */
export type MFAMethodsSms = {
  /** The date and time when the method was enrolled, in ISO 8601 format. */
  enrolledAt: string;
};

/**
 * Information about the end user's MFA enrollments.

 */
export interface MFAMethods {
  /** The date and time when the end user was prompted for MFA enrollment, in ISO 8601 format. If the this field exists, and the user has no other enrolled MFA methods, then the user skipped MFA enrollment. */
  enrollmentPromptedAt?: string;
  /** An object containing information about the end user's TOTP enrollment. */
  totp?: MFAMethodsTotp;
  /** An object containing information about the end user's SMS MFA enrollment. */
  sms?: MFAMethodsSms;
}

/**
 * Information about an EVM account associated with an end user.
 */
export interface EndUserEvmAccount {
  /**
   * The address of the EVM account.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  address: string;
  /** The date and time when the account was created, in ISO 8601 format. */
  createdAt: string;
  /**
   * The date and time when the account's private key was first exported, in ISO 8601 format. This is set on the first export and preserved on subsequent exports; it is not updated on re-export.
   * @nullable
   */
  exportedAt?: string | null;
  /**
   * The date and time when the account's key was ejected (marked for deletion), in ISO 8601 format. Populated when the account has been ejected. The account record remains queryable after this timestamp is set; it reflects when ejection was requested, not when the key material is purged.
   * @nullable
   */
  ejectedAt?: string | null;
}

/**
 * Information about an EVM smart account associated with an end user.
 */
export interface EndUserEvmSmartAccount {
  /**
   * The address of the EVM smart account.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  address: string;
  /** The addresses of the EVM EOA accounts that own this smart account. Smart accounts can have multiple owners, such as when spend permissions are enabled. */
  ownerAddresses: string[];
  /** The date and time when the account was created, in ISO 8601 format. */
  createdAt: string;
}

/**
 * Information about a Solana account associated with an end user.
 */
export interface EndUserSolanaAccount {
  /**
   * The base58 encoded address of the Solana account.
   * @pattern ^[1-9A-HJ-NP-Za-km-z]{32,44}$
   */
  address: string;
  /** The date and time when the account was created, in ISO 8601 format. */
  createdAt: string;
  /**
   * The date and time when the account's private key was first exported, in ISO 8601 format. This is set on the first export and preserved on subsequent exports; it is not updated on re-export.
   * @nullable
   */
  exportedAt?: string | null;
  /**
   * The date and time when the account's key was ejected (marked for deletion), in ISO 8601 format. Populated when the account has been ejected. The account record remains queryable after this timestamp is set; it reflects when ejection was requested, not when the key material is purged.
   * @nullable
   */
  ejectedAt?: string | null;
}

/**
 * Information about the end user.
 */
export interface EndUser {
  /**
   * A stable, unique identifier for the end user. The `userId` must be unique across all end users in the developer's CDP Project. It must be between 1 and 100 characters long and can only contain alphanumeric characters and hyphens.
   * @pattern ^[a-zA-Z0-9-]{1,100}$
   */
  userId: string;
  authenticationMethods: AuthenticationMethods;
  mfaMethods?: MFAMethods;
  /**
   * **DEPRECATED**: Use `evmAccountObjects` instead for richer account information. The list of EVM account addresses associated with the end user. End users can have up to 10 EVM accounts.
   * @deprecated
   */
  evmAccounts: string[];
  /** The list of EVM accounts associated with the end user. End users can have up to 10 EVM accounts. */
  evmAccountObjects: EndUserEvmAccount[];
  /**
   * **DEPRECATED**: Use `evmSmartAccountObjects` instead for richer account information including owner relationships. The list of EVM smart account addresses associated with the end user. Each EVM EOA can own one smart account.
   * @deprecated
   */
  evmSmartAccounts: string[];
  /** The list of EVM smart accounts associated with the end user. Each EVM EOA can own one smart account. */
  evmSmartAccountObjects: EndUserEvmSmartAccount[];
  /**
   * **DEPRECATED**: Use `solanaAccountObjects` instead for richer account information. The list of Solana account addresses associated with the end user. End users can have up to 10 Solana accounts.
   * @deprecated
   */
  solanaAccounts: string[];
  /** The list of Solana accounts associated with the end user. End users can have up to 10 Solana accounts. */
  solanaAccountObjects: EndUserSolanaAccount[];
  /** The date and time when the end user was created, in ISO 8601 format. */
  createdAt: string;
}

/**
 * The name of the EVM network that a borrow product is deployed on.
 */
export type BorrowProductNetwork = (typeof BorrowProductNetwork)[keyof typeof BorrowProductNetwork];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const BorrowProductNetwork = {
  base: "base",
} as const;

/**
 * The lending protocol that operates the borrow product.
 */
export type BorrowProductProtocol =
  (typeof BorrowProductProtocol)[keyof typeof BorrowProductProtocol];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const BorrowProductProtocol = {
  morpho_blue: "morpho_blue",
} as const;

/**
 * The globally unique ID of the borrow product, which is a UUID prefixed with the string `bp_`.
 * @pattern ^bp_[a-f0-9-]{36}$
 */
export type BorrowProductId = string;

/**
 * The onchain venue that hosts a borrow product. The venue comprises the protocol and  network the product is deployed on. An example of a venue would be Morpho Blue on  Base Mainnet.
 */
export interface BorrowProductVenue {
  /**
   * A stable identifier for the venue, which is a UUID prefixed with the string `bp_venue_`.
   * @pattern ^bp_venue_[a-f0-9-]{36}$
   */
  venueId: string;
  /**
   * The contract address of the venue's entrypoint.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  entrypointAddress: string;
  /** A human-readable name for the venue. */
  name: string;
}

/**
 * A token on an EVM borrow product network.
 */
export interface BorrowProductToken {
  /**
   * The contract address of the token.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  address: string;
  /** The symbol of the token (e.g. USDC, WETH). */
  symbol: string;
  /** The number of decimal places used by the token. */
  decimals: number;
}

/**
 * The role the asset plays within the product. `collateral` indicates the asset can be posted as collateral, and `debt` indicates the asset can be borrowed.
 */
export type BorrowProductAssetCapabilityType =
  (typeof BorrowProductAssetCapabilityType)[keyof typeof BorrowProductAssetCapabilityType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const BorrowProductAssetCapabilityType = {
  collateral: "collateral",
  debt: "debt",
} as const;

/**
 * A capability an asset provides within a borrow product, describing the role the asset plays, either as collateral or debt, and whether that capability is currently active.
 */
export interface BorrowProductAssetCapability {
  /** The role the asset plays within the product. `collateral` indicates the asset can be posted as collateral, and `debt` indicates the asset can be borrowed. */
  type: BorrowProductAssetCapabilityType;
  /** Whether this capability is currently active. For example, an asset with a `collateral` capability and `enabled: false` cannot currently be borrowed against.
Some venues may temporarily disable an asset's capability, which will be  reflected in the `enabled` field. This would not affect any user's existing  borrow positions. */
  enabled: boolean;
}

/**
 * The assets available to be borrowed or borrowed against in this market, together with the capabilities (collateral and/or debt) they provide.
 */
export interface BorrowProductAsset {
  /**
   * A stable identifier for the asset within the product, which is a UUID prefixed with the string `bp_asset_`.
   * @pattern ^bp_asset_[a-f0-9-]{36}$
   */
  assetId: string;
  /** The onchain token that can be used as collateral or debt. */
  token: BorrowProductToken;
  /**
   * The capabilities this asset provides within the borrow product. An asset may be used as collateral and/or debt.
   * @minItems 1
   */
  capabilities: BorrowProductAssetCapability[];
}

/**
 * The point-in-time at which onchain state, such as a borrow product or borrow position, was captured. This is when the data was last read from the chain.
 */
export interface BorrowProductSnapshot {
  /** The block number at which the state was observed. */
  blockNumber: number;
  /**
   * The hash of the block at which the state was observed.
   * @pattern ^0x[0-9a-fA-F]{64}$
   */
  blockHash: string;
  /** The onchain block timestamp at which the state was observed in Unix seconds. */
  blockTimestamp: number;
  /** The timestamp at which the state was observed. */
  observedAt: string;
}

/**
 * Morpho Blue's immutable onchain market parameters that uniquely define a borrow product.
 */
export interface MorphoBlueMarketParams {
  /**
   * The Morpho Blue native bytes32 market ID that uniquely identifies  the underlying market onchain.
   * @pattern ^0x[0-9a-fA-F]{64}$
   */
  onchainMarketId: string;
  /** The token that is borrowed in the product. */
  loanToken: BorrowProductToken;
  /** The token posted as collateral in the product. */
  collateralToken: BorrowProductToken;
  /**
   * The contract address of the oracle used to price the collateral token against the loan token.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  oracleAddress: string;
  /**
   * The contract address of the interest rate model that governs the product's borrow rate.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  interestRateModelAddress: string;
  /**
   * The liquidation loan-to-value of the product, expressed in basis points. For example, `9150` represents an LLTV of 91.5%.
   * @minimum 0
   * @maximum 10000
   */
  lltvBps: number;
}

export type MorphoBlueProtocolDetailsType =
  (typeof MorphoBlueProtocolDetailsType)[keyof typeof MorphoBlueProtocolDetailsType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const MorphoBlueProtocolDetailsType = {
  morpho_blue: "morpho_blue",
} as const;

/**
 * Morpho Blue-specific immutable onchain protocol details that uniquely define a borrow product.
 */
export interface MorphoBlueProtocolDetails {
  type: MorphoBlueProtocolDetailsType;
  /** The Morpho Blue market parameters that uniquely define the product onchain. */
  marketParams: MorphoBlueMarketParams;
}

/**
 * Protocol-specific immutable onchain details that uniquely define a borrow product. The `type` field indicates which protocol-specific schema describes the product's details.
 */
export type BorrowProductProtocolDetails = MorphoBlueProtocolDetails;

/**
 * A borrow product on an EVM network, operated by a lending protocol such as Morpho Blue. 
A borrow product is a protocol-native representation of a borrowable market,  describing the venue that hosts it, the assets that are borrowed or borrowed against  in it, a point-in-time snapshot of its onchain state, and the protocol-specific  immutable parameters that uniquely define it.
 */
export interface BorrowProduct {
  borrowProductId: BorrowProductId;
  network: BorrowProductNetwork;
  /** A human-readable name for the product, typically derived from its loan and collateral tokens. */
  name: string;
  venue: BorrowProductVenue;
  /** The assets available to be borrowed or borrowed against in this market. */
  assets: BorrowProductAsset[];
  snapshot: BorrowProductSnapshot;
  protocolDetails: BorrowProductProtocolDetails;
}

/**
 * The ERC-7677 `context` object forwarded to the paymaster service as part of the `paymasterService` capability. The fields in this object are defined by the paymaster service provider; CDP forwards them to the paymaster unchanged. This field is only valid when a paymaster is configured for the request. Providing `paymasterContext` without a paymaster configured results in an `invalid_request` error.
 */
export interface PaymasterContext {
  [key: string]: unknown;
}

/**
 * The request body for revoking a user-scoped or account-scoped delegation.
 */
export interface RevokeDelegationRequest {
  /**
   * When revoking with a wallet authentication scheme, the ID of the Temporary Wallet Secret that was used to sign the X-Wallet-Auth Header.
   * @pattern ^[a-zA-Z0-9-]{1,100}$
   */
  walletSecretId?: string;
}

/**
 * The network for the EIP-7702 delegation.
 */
export type EvmEip7702DelegationNetwork =
  (typeof EvmEip7702DelegationNetwork)[keyof typeof EvmEip7702DelegationNetwork];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const EvmEip7702DelegationNetwork = {
  "base-sepolia": "base-sepolia",
  base: "base",
  arbitrum: "arbitrum",
  optimism: "optimism",
  polygon: "polygon",
  ethereum: "ethereum",
  "ethereum-sepolia": "ethereum-sepolia",
} as const;

/**
 * The network the user operation is for.
 */
export type EvmUserOperationNetwork =
  (typeof EvmUserOperationNetwork)[keyof typeof EvmUserOperationNetwork];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const EvmUserOperationNetwork = {
  "base-sepolia": "base-sepolia",
  base: "base",
  arbitrum: "arbitrum",
  optimism: "optimism",
  zora: "zora",
  polygon: "polygon",
  bnb: "bnb",
  avalanche: "avalanche",
  ethereum: "ethereum",
  "ethereum-sepolia": "ethereum-sepolia",
} as const;

export interface EvmCall {
  /**
   * The address the call is directed to.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  to: string;
  /** The amount of ETH to send with the call, in wei. */
  value: string;
  /**
   * The call data to send. This is the hex-encoded data of the function call consisting of the method selector and the function arguments.
   * @pattern ^0x[0-9a-fA-F]*$
   */
  data: string;
  /** The override gas limit to use for the call instead of the bundler's estimated gas limit. */
  overrideGasLimit?: string;
}

/**
 * The revert data if the user operation has reverted.
 */
export interface UserOperationReceiptRevert {
  /**
   * The 0x-prefixed raw hex string.
   * @pattern ^0x[0-9a-fA-F]*$
   */
  data: string;
  /** Human-readable revert reason if able to decode. */
  message: string;
}

/**
 * The receipt that contains information about the execution of user operation.
 */
export interface UserOperationReceipt {
  revert?: UserOperationReceiptRevert;
  /**
   * The hash of this transaction as 0x-prefixed string.
   * @pattern ^0x[a-fA-F0-9]{64}$
   */
  transactionHash?: string;
  /**
   * The block hash of the block including the transaction as 0x-prefixed string.
   * @pattern ^0x[0-9a-fA-F]{64}$|^$
   */
  blockHash?: string;
  /** The block height (number) of the block including the transaction. */
  blockNumber?: number;
  /** The gas used for landing this user operation. */
  gasUsed?: string;
}

/**
 * The status of the user operation.
 */
export type EvmUserOperationStatus =
  (typeof EvmUserOperationStatus)[keyof typeof EvmUserOperationStatus];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const EvmUserOperationStatus = {
  pending: "pending",
  signed: "signed",
  broadcast: "broadcast",
  complete: "complete",
  dropped: "dropped",
  failed: "failed",
} as const;

/**
 * A smart account operation response.
 */
export interface EvmUserOperation {
  network: EvmUserOperationNetwork;
  /**
   * The hash of the user operation. This is not the transaction hash, as a transaction consists of multiple user operations. The user operation hash is the hash of this particular user operation which gets signed by the owner of the Smart Account.
   * @pattern ^0x[0-9a-fA-F]{64}$
   */
  userOpHash: string;
  /** The list of calls in the user operation. */
  calls: EvmCall[];
  /** The status of the user operation. */
  status: EvmUserOperationStatus;
  /**
   * The hash of the transaction that included this particular user operation. This gets set after the user operation is broadcasted and the transaction is included in a block.
   * @pattern ^0x[0-9a-fA-F]{64}$|^$
   */
  transactionHash?: string;
  /** The list of receipts associated with the user operation. */
  receipts?: UserOperationReceipt[];
  /** The timestamp at which the prepared user operation expires. */
  expiresAt?: string;
}

/**
 * The balance of either the collateral or debt token for a borrow position, as a decimal string in the token's standard unit denomination.
 */
export interface BorrowPositionAssetAmount {
  /**
   * The stable identifier for the asset within the borrow product, which is a UUID prefixed with the string `bp_asset_`. This matches the `assetId` of the corresponding asset on the borrow product.
   * @pattern ^bp_asset_[a-f0-9-]{36}$
   */
  assetId: string;
  /** The onchain token this balance is denominated in. */
  token: BorrowProductToken;
  /** The token balance as a decimal string in the token's standard unit denomination (i.e. "5000" for 5000 mGLO). */
  amount: PositiveDecimal;
}

export type BorrowPositionDebtAllOf = {
  /**
   * The current annualized borrow rate for the debt, expressed in basis points. For example, `525` represents a borrow APY of 5.25%. Omitted when the rate is unavailable.
   * @minimum 0
   */
  borrowApyBps?: number;
};

/**
 * The debt balance for a borrow position, including accrued interest, plus its current borrow rate.
 */
export type BorrowPositionDebt = BorrowPositionAssetAmount & BorrowPositionDebtAllOf;

/**
 * The aggregate health of a borrow position.

- `no_debt`: the position has no outstanding debt.
- `healthy`: the position has debt and is above its liquidation threshold.
- `undercollateralized`: the position is at or below its liquidation threshold and may be eligible for liquidation.
 */
export type BorrowPositionHealthStatus =
  (typeof BorrowPositionHealthStatus)[keyof typeof BorrowPositionHealthStatus];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const BorrowPositionHealthStatus = {
  no_debt: "no_debt",
  healthy: "healthy",
  undercollateralized: "undercollateralized",
} as const;

export type MorphoBlueOnchainStateType =
  (typeof MorphoBlueOnchainStateType)[keyof typeof MorphoBlueOnchainStateType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const MorphoBlueOnchainStateType = {
  morpho_blue: "morpho_blue",
} as const;

/**
 * The live onchain state of a Morpho Blue borrow position, read at the block described by the position's snapshot.
 */
export interface MorphoBlueOnchainState {
  type: MorphoBlueOnchainStateType;
  /** The non-zero collateral balances securing the position. */
  collateral: BorrowPositionAssetAmount[];
  /** The non-zero debt balances owed by the position. */
  debt: BorrowPositionDebt[];
  /** The position's liquidation headroom as a decimal string, where `1.0` is the liquidation boundary and higher is safer. For example, `1.79` means the position's weighted collateral is 1.79x its debt. Omitted when the position has no debt. */
  healthFactor?: string;
  /**
   * The position's current loan-to-value, expressed in basis points. For example, `5000` represents a current LTV of 50%. Omitted when the position has no debt.
   * @minimum 0
   */
  currentLtvBps?: number;
  /**
   * The loan-to-value at which the position becomes eligible for liquidation, expressed in basis points. For example, `8250` represents 82.5%. Omitted when the position has no debt.
   * @minimum 0
   * @maximum 10000
   */
  liquidationThresholdBps?: number;
  healthStatus: BorrowPositionHealthStatus;
}

/**
 * The live onchain state of a borrow position. The `type` field indicates which protocol-specific schema describes the state.
 */
export type BorrowPositionOnchainState = MorphoBlueOnchainState;

/**
 * A borrow position held by a smart account in a borrow product, together with its live onchain state read at a point-in-time snapshot.
 */
export interface BorrowPosition {
  borrowProductId: BorrowProductId;
  /**
   * The smart account address that owns the borrow position.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  address: string;
  network: BorrowProductNetwork;
  snapshot: BorrowProductSnapshot;
  onchainState: BorrowPositionOnchainState;
}

/**
 * A request to create a borrow position for an end user's smart account for the specified borrow product. 
The smart account posts collateral and borrows against it, broadcasting a user operation  to open the position onchain.
 */
export interface CreateBorrowPositionRequest {
  borrowProductId: BorrowProductId;
  /** The amount of collateral to post, as a decimal string in standard unit denomination of the collateral token (i.e. "1" for 1 cbBTC). */
  collateralAmount: PositiveDecimal;
  /** The amount of the loan token to borrow, as a decimal string in standard unit denomination of the loan token (i.e. "100" for 100 USDC). */
  loanAmount: PositiveDecimal;
  /**
   * The ID of the Temporary Wallet Secret that was used to sign the X-Wallet-Auth header.
   * @pattern ^[a-zA-Z0-9-]{1,100}$
   */
  walletSecretId: string;
  /** Whether to use the CDP Paymaster for the user operation. When `true`, `paymasterUrl` must not be set. */
  useCdpPaymaster: boolean;
  /** Paymaster URL to use for the user operation. Must not be set when `useCdpPaymaster` is `true`.
If `useCdpPaymaster` is `false` and no `paymasterUrl` is set, the smart account must have sufficient funds to cover network fees. */
  paymasterUrl?: Url;
  /** Optional paymaster metadata forwarded to the configured paymaster service. Valid only when a paymaster is configured via `useCdpPaymaster: true` or a `paymasterUrl`. */
  paymasterContext?: PaymasterContext;
}

/**
 * A request to adjust an existing borrow position for an end user's smart account on the specified borrow product.
The request can supply collateral, withdraw collateral, repay debt, and/or borrow more of the loan asset, broadcasting a user operation to apply the changes onchain.
A single request must not combine `addCollateralAmount` with `removeCollateralAmount` or `repayLoanAmount`, and must not combine `borrowLoanAmount` with `repayLoanAmount` or `removeCollateralAmount`. Otherwise any subset of the four amount fields may be supplied; at least one is required.
 */
export interface AdjustBorrowPositionRequest {
  borrowProductId: BorrowProductId;
  /** The amount of collateral to add to the position, as a decimal string in standard unit denomination of the collateral token (i.e. "1" for 1 cbBTC). Must not be combined with `removeCollateralAmount` or `repayLoanAmount`. */
  addCollateralAmount?: PositiveDecimal;
  /** The amount of collateral to withdraw from the position, as a decimal string in standard unit denomination of the collateral token (i.e. "1" for 1 cbBTC).  Must not be combined with `addCollateralAmount` or `borrowLoanAmount`. */
  removeCollateralAmount?: PositiveDecimal;
  /** The amount of the loan token to repay, as a decimal string in standard unit denomination of the loan token (i.e. "100" for 100 USDC).  Must not be combined with `borrowLoanAmount` or `addCollateralAmount`. */
  repayLoanAmount?: PositiveDecimal;
  /** The amount of the loan token to borrow, as a decimal string in standard unit denomination of the loan token (i.e. "100" for 100 USDC).  Must not be combined with `repayLoanAmount` or `removeCollateralAmount`. */
  borrowLoanAmount?: PositiveDecimal;
  /**
   * The ID of the Temporary Wallet Secret that was used to sign the X-Wallet-Auth header.
   * @pattern ^[a-zA-Z0-9-]{1,100}$
   */
  walletSecretId: string;
  /** Whether to use the CDP Paymaster for the user operation. When `true`, `paymasterUrl` must not be set. */
  useCdpPaymaster: boolean;
  /** Paymaster URL to use for the user operation. Must not be set when `useCdpPaymaster` is `true`.
If `useCdpPaymaster` is `false` and no `paymasterUrl` is set, the smart account must have sufficient funds to cover network fees. */
  paymasterUrl?: Url;
  /** Optional paymaster metadata forwarded to the configured paymaster service. Valid only when a paymaster is configured via `useCdpPaymaster: true` or a `paymasterUrl`. */
  paymasterContext?: PaymasterContext;
}

/**
 * A request to close an end user smart account's borrow position for the specified borrow product.
Closing fully repays the position's outstanding loan and withdraws all remaining collateral back to the smart account, broadcasting a single user operation to settle the position onchain. There is no partial close; use `adjustBorrowPositionWithEndUserAccount` to adjust a position without closing it.
 */
export interface CloseBorrowPositionRequest {
  borrowProductId: BorrowProductId;
  /**
   * The ID of the Temporary Wallet Secret that was used to sign the X-Wallet-Auth header.
   * @pattern ^[a-zA-Z0-9-]{1,100}$
   */
  walletSecretId: string;
  /** Whether to use the CDP Paymaster for the user operation. When `true`, `paymasterUrl` must not be set. */
  useCdpPaymaster: boolean;
  /** Paymaster URL to use for the user operation. Must not be set when `useCdpPaymaster` is `true`.
If `useCdpPaymaster` is `false` and no `paymasterUrl` is set, the smart account must have sufficient funds to cover network fees. */
  paymasterUrl?: Url;
  /** Optional paymaster metadata forwarded to the configured paymaster service. Valid only when a paymaster is configured via `useCdpPaymaster: true` or a `paymasterUrl`. */
  paymasterContext?: PaymasterContext;
}

/**
 * The version of the x402 protocol.
 */
export type X402Version = (typeof X402Version)[keyof typeof X402Version];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const X402Version = {
  NUMBER_1: 1,
  NUMBER_2: 2,
} as const;

/**
 * The x402 v2 network identifier in CAIP-2 format. x402 v2 identifies networks by their CAIP-2 chain ID (e.g. `eip155:<chainId>` for EVM networks, `solana:<genesisHash>` for Solana). Supported networks: Base, Polygon, Arbitrum One, World Chain (EVM), and Solana.
 */
export type X402V2Network = (typeof X402V2Network)[keyof typeof X402V2Network];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const X402V2Network = {
  "eip155:8453": "eip155:8453",
  "eip155:84532": "eip155:84532",
  "eip155:137": "eip155:137",
  "eip155:42161": "eip155:42161",
  "eip155:480": "eip155:480",
  "eip155:4801": "eip155:4801",
  "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
  "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1": "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
} as const;

/**
 * The scheme of the payment protocol to use. Supported schemes are `exact`, `upto`, and `batch-settlement`.
 */
export type X402V2PaymentRequirementsScheme =
  (typeof X402V2PaymentRequirementsScheme)[keyof typeof X402V2PaymentRequirementsScheme];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const X402V2PaymentRequirementsScheme = {
  exact: "exact",
  upto: "upto",
  "batch-settlement": "batch-settlement",
} as const;

/**
 * The optional additional scheme-specific payment info.
 */
export type X402V2PaymentRequirementsExtra = { [key: string]: unknown };

/**
 * The x402 v2 payment requirements. Uses CAIP-2 network identifiers and supports `exact`, `upto`, and `batch-settlement` schemes. Carries only the payment fields (no resource metadata — that is in the enclosing `x402V2PaymentPayload.resource`).
 */
export interface X402V2PaymentRequirements {
  /** The scheme of the payment protocol to use. Supported schemes are `exact`, `upto`, and `batch-settlement`. */
  scheme: X402V2PaymentRequirementsScheme;
  /** The network of the blockchain to send payment on in CAIP-2 format. */
  network: X402V2Network;
  /** The asset to pay with.

For EVM networks, the asset will be a 0x-prefixed, checksum EVM address.

For Solana-based networks, the asset will be a base58-encoded Solana address. */
  asset: BlockchainAddress;
  /** The amount to pay for the resource in atomic units of the payment asset. */
  amount: string;
  /** The destination to pay value to.

For EVM networks, payTo will be a 0x-prefixed, checksum EVM address.

For Solana-based networks, payTo will be a base58-encoded Solana address. */
  payTo: BlockchainAddress;
  /** The maximum time in seconds for the resource server to respond. */
  maxTimeoutSeconds: number;
  /** The optional additional scheme-specific payment info. */
  extra?: X402V2PaymentRequirementsExtra;
}

/**
 * The x402 v1 network identifier. x402 v1 uses human-readable network names. Supported networks: Base mainnet and testnet, Solana mainnet and devnet.
 */
export type X402V1Network = (typeof X402V1Network)[keyof typeof X402V1Network];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const X402V1Network = {
  base: "base",
  "base-sepolia": "base-sepolia",
  solana: "solana",
  "solana-devnet": "solana-devnet",
} as const;

/**
 * A human-readable description.
 * @minLength 0
 * @maxLength 500
 */
export type Description = string;

/**
 * The scheme of the payment protocol to use. Currently, the only supported scheme is `exact`.
 */
export type X402V1PaymentRequirementsScheme =
  (typeof X402V1PaymentRequirementsScheme)[keyof typeof X402V1PaymentRequirementsScheme];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const X402V1PaymentRequirementsScheme = {
  exact: "exact",
} as const;

/**
 * The optional JSON schema describing the resource output.
 */
export type X402V1PaymentRequirementsOutputSchema = { [key: string]: unknown };

/**
 * The optional additional scheme-specific payment info.
 */
export type X402V1PaymentRequirementsExtra = { [key: string]: unknown };

/**
 * The x402 v1 payment requirements. Uses human-readable network names, and carries resource metadata (`resource`, `description`, `mimeType`) alongside the payment fields. The only supported scheme is `exact`.
 */
export interface X402V1PaymentRequirements {
  /** The scheme of the payment protocol to use. Currently, the only supported scheme is `exact`. */
  scheme: X402V1PaymentRequirementsScheme;
  /** The network of the blockchain to send payment on. */
  network: X402V1Network;
  /** The maximum amount required to pay for the resource in atomic units of the payment asset. */
  maxAmountRequired: string;
  /** The URL of the resource to pay for. */
  resource: string;
  /** A human-readable description of the resource. */
  description: Description;
  /** The MIME type of the resource response. */
  mimeType: string;
  /** The optional JSON schema describing the resource output. */
  outputSchema?: X402V1PaymentRequirementsOutputSchema;
  /** The destination to pay value to.

For EVM networks, payTo will be a 0x-prefixed, checksum EVM address.

For Solana-based networks, payTo will be a base58-encoded Solana address. */
  payTo: BlockchainAddress;
  /** The maximum time in seconds for the resource server to respond. */
  maxTimeoutSeconds: number;
  /** The asset to pay with.

For EVM networks, the asset will be a 0x-prefixed, checksum EVM address.

For Solana-based networks, the asset will be a base58-encoded Solana address. */
  asset: BlockchainAddress;
  /** The optional additional scheme-specific payment info. */
  extra?: X402V1PaymentRequirementsExtra;
}

/**
 * The x402 protocol payment requirements that the resource server expects the client's payment payload to meet.
 */
export type X402PaymentRequirements = X402V2PaymentRequirements | X402V1PaymentRequirements;

/**
 * Describes the resource being accessed in x402 protocol.
 */
export interface X402ResourceInfo {
  /** The URL of the resource. */
  url?: string;
  /** A human-readable description of the resource. */
  description?: Description;
  /** The MIME type of the resource response. */
  mimeType?: string;
}

/**
 * Optional protocol extensions. Unknown keys are forwarded as-is into the signed payment payload.
 */
export type X402PaymentRequiredExtensions = { [key: string]: unknown };

/**
 * The x402 protocol payment required response body, returned by a resource server when a request lacks valid payment. Contains the accepted payment options, optional resource metadata, and an optional error message from the resource server.
 */
export interface X402PaymentRequired {
  /** The x402 protocol version. */
  x402Version: X402Version;
  /**
   * The list of payment options the resource server accepts. At least one option must be present.
   * @minItems 1
   * @maxItems 16
   */
  accepts: X402PaymentRequirements[];
  /** Optional metadata about the resource being paid for. */
  resource?: X402ResourceInfo;
  /** An optional error message from the resource server describing why payment is required. */
  error?: string;
  /** Optional protocol extensions. Unknown keys are forwarded as-is into the signed payment payload. */
  extensions?: X402PaymentRequiredExtensions;
}

/**
 * The authorization data for the ERC-3009 authorization message.
 */
export type X402ExactEvmPayloadAuthorization = {
  /**
   * The 0x-prefixed, checksum EVM address of the sender of the payment.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  from: string;
  /**
   * The 0x-prefixed, checksum EVM address of the recipient of the payment.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  to: string;
  /** The value of the payment, in atomic units of the payment asset. */
  value: string;
  /** The unix timestamp after which the payment is valid. */
  validAfter: string;
  /** The unix timestamp before which the payment is valid. */
  validBefore: string;
  /**
   * The hex-encoded nonce of the payment (bytes32).
   * @pattern ^0x[0-9a-fA-F]{64}$
   */
  nonce: string;
};

/**
 * The x402 protocol exact scheme payload for EVM networks. The scheme is implemented using ERC-3009. For more details, please see [EVM Exact Scheme Details](https://github.com/coinbase/x402/blob/main/specs/schemes/exact/scheme_exact_evm.md).
 */
export interface X402ExactEvmPayload {
  /**
   * The EIP-712 hex-encoded signature of the ERC-3009 authorization message. Smart account signatures may be longer than 65 bytes.
   * @pattern ^0x[0-9a-fA-F]{130,}$
   */
  signature: string;
  /** The authorization data for the ERC-3009 authorization message. */
  authorization: X402ExactEvmPayloadAuthorization;
}

/**
 * The token permissions for the transfer.
 */
export type X402ExactEvmPermit2PayloadPermit2AuthorizationPermitted = {
  /**
   * The 0x-prefixed, checksum EVM address of the token to transfer.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  token: string;
  /** The amount to transfer in atomic units. */
  amount: string;
};

/**
 * The witness data containing payment details.
 */
export type X402ExactEvmPermit2PayloadPermit2AuthorizationWitness = {
  /**
   * The 0x-prefixed, checksum EVM address of the recipient.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  to: string;
  /** The unix timestamp after which the payment is valid. */
  validAfter: string;
  /**
   * Optional hex-encoded extra data.
   * @pattern ^0x[0-9a-fA-F]*$
   */
  extra?: string;
};

/**
 * The authorization data for the Permit2 PermitWitnessTransferFrom message.
 */
export type X402ExactEvmPermit2PayloadPermit2Authorization = {
  /**
   * The 0x-prefixed, checksum EVM address of the sender of the payment.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  from: string;
  /** The token permissions for the transfer. */
  permitted: X402ExactEvmPermit2PayloadPermit2AuthorizationPermitted;
  /**
   * The 0x-prefixed, checksum EVM address of the spender (x402 Permit2 proxy contract).
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  spender: string;
  /**
   * The Permit2 nonce as a decimal string (uint256).
   * @pattern ^[0-9]+$
   */
  nonce: string;
  /** The unix timestamp before which the permit is valid. */
  deadline: string;
  /** The witness data containing payment details. */
  witness: X402ExactEvmPermit2PayloadPermit2AuthorizationWitness;
};

/**
 * The x402 protocol exact scheme payload for EVM networks using Permit2. Permit2 is a universal token approval mechanism that works with any ERC-20 token, unlike ERC-3009 which requires token-level support.
 */
export interface X402ExactEvmPermit2Payload {
  /**
   * The EIP-712 hex-encoded signature of the Permit2 PermitWitnessTransferFrom message. Smart account signatures may be longer than 65 bytes.
   * @pattern ^0x[0-9a-fA-F]{130,}$
   */
  signature: string;
  /** The authorization data for the Permit2 PermitWitnessTransferFrom message. */
  permit2Authorization: X402ExactEvmPermit2PayloadPermit2Authorization;
}

/**
 * The x402 protocol exact scheme payload for Solana networks. For more details, please see [Solana Exact Scheme Details](https://github.com/coinbase/x402/blob/main/specs/schemes/exact/scheme_exact_svm.md).
 */
export interface X402ExactSolanaPayload {
  /** The base64-encoded Solana transaction. */
  transaction: string;
}

/**
 * The token permissions for the transfer.
 */
export type X402UptoEvmPermit2PayloadPermit2AuthorizationPermitted = {
  /**
   * The 0x-prefixed, checksum EVM address of the token to transfer.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  token: string;
  /** The maximum amount the client authorizes to transfer in atomic units. */
  amount: string;
};

/**
 * The witness data containing payment details. Includes a `facilitator` field to bind the authorization to a specific facilitator address.
 */
export type X402UptoEvmPermit2PayloadPermit2AuthorizationWitness = {
  /**
   * The 0x-prefixed, checksum EVM address of the recipient.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  to: string;
  /**
   * The 0x-prefixed, checksum EVM address of the facilitator authorized to settle this payment. MUST match the `facilitatorAddress` advertised in the payment requirements `extra` field.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  facilitator: string;
  /** The unix timestamp after which the payment is valid. */
  validAfter: string;
};

/**
 * The authorization data for the Permit2 PermitWitnessTransferFrom message. The `permitted.amount` is the maximum the client authorizes; the actual settled amount is decided by the resource server at settle time and MUST be less than or equal to it.
 */
export type X402UptoEvmPermit2PayloadPermit2Authorization = {
  /**
   * The 0x-prefixed, checksum EVM address of the sender of the payment.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  from: string;
  /** The token permissions for the transfer. */
  permitted: X402UptoEvmPermit2PayloadPermit2AuthorizationPermitted;
  /**
   * The 0x-prefixed, checksum EVM address of the spender (the x402 Upto Permit2 proxy contract).
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  spender: string;
  /**
   * The Permit2 nonce as a decimal string (uint256).
   * @pattern ^[0-9]+$
   */
  nonce: string;
  /** The unix timestamp before which the permit is valid. */
  deadline: string;
  /** The witness data containing payment details. Includes a `facilitator` field to bind the authorization to a specific facilitator address. */
  witness: X402UptoEvmPermit2PayloadPermit2AuthorizationWitness;
};

/**
 * The x402 protocol upto scheme payload for EVM networks using Permit2. The `upto` scheme authorizes a maximum amount and lets the facilitator settle for the actual amount used. Structurally identical to `x402ExactEvmPermit2Payload` except `permit2Authorization.witness` carries an additional `facilitator` address that binds the authorization to a specific facilitator (the one announced via `extra.facilitatorAddress` in the payment requirements). For more details, see [EVM Upto Scheme Details](https://github.com/x402-foundation/x402/blob/main/specs/schemes/upto/scheme_upto_evm.md).
 */
export interface X402UptoEvmPermit2Payload {
  /**
   * The EIP-712 hex-encoded signature of the Permit2 PermitWitnessTransferFrom message. Smart account signatures may be longer than 65 bytes.
   * @pattern ^0x[0-9a-fA-F]{130,}$
   */
  signature: string;
  /** The authorization data for the Permit2 PermitWitnessTransferFrom message. The `permitted.amount` is the maximum the client authorizes; the actual settled amount is decided by the resource server at settle time and MUST be less than or equal to it. */
  permit2Authorization: X402UptoEvmPermit2PayloadPermit2Authorization;
}

/**
 * Immutable configuration for an x402 batch-settlement payment channel. The EIP-712 hash of this struct produces the `channelId` used by all batch-settlement payloads.
 */
export interface X402BatchSettlementChannelConfig {
  /**
   * The 0x-prefixed, checksum EVM address of the payer (channel funder).
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  payer: string;
  /**
   * The 0x-prefixed, checksum EVM address authorized to sign vouchers on behalf of the payer.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  payerAuthorizer: string;
  /**
   * The 0x-prefixed, checksum EVM address of the receiver (resource server / merchant).
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  receiver: string;
  /**
   * The 0x-prefixed, checksum EVM address authorized to sign claim batches on behalf of the receiver (typically the facilitator).
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  receiverAuthorizer: string;
  /**
   * The 0x-prefixed, checksum EVM address of the ERC-20 payment token.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  token: string;
  /**
   * The non-cooperative withdraw delay in seconds. Must be between 900 (15 minutes) and 2,592,000 (30 days).
   * @minimum 900
   * @maximum 2592000
   */
  withdrawDelay: number;
  /**
   * A 32-byte salt used to differentiate channels between the same payer/receiver pair.
   * @pattern ^0x[0-9a-fA-F]{64}$
   */
  salt: string;
}

/**
 * A signed cumulative-ceiling voucher for an x402 batch-settlement channel. `maxClaimableAmount` is monotonically increasing across requests in the same channel; the receiver may claim any amount up to this ceiling.
 */
export interface X402BatchSettlementVoucher {
  /**
   * The 32-byte EIP-712 hash of the `channelConfig` for this voucher's channel.
   * @pattern ^0x[0-9a-fA-F]{64}$
   */
  channelId: string;
  /**
   * The cumulative maximum amount (uint128 as decimal string) the receiver is authorized to claim from this channel as of this voucher.
   * @pattern ^[0-9]+$
   */
  maxClaimableAmount: string;
  /**
   * The EIP-712 hex-encoded signature of the voucher by `payerAuthorizer`.
   * @pattern ^0x[0-9a-fA-F]+$
   */
  signature: string;
}

export type X402BatchSettlementDepositPayloadType =
  (typeof X402BatchSettlementDepositPayloadType)[keyof typeof X402BatchSettlementDepositPayloadType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const X402BatchSettlementDepositPayloadType = {
  deposit: "deposit",
} as const;

/**
 * An ERC-3009 receiveWithAuthorization message authorizing the channel-funding transfer.
 */
export type X402BatchSettlementDepositPayloadDepositAuthorizationErc3009Authorization = {
  /** The unix timestamp after which the authorization is valid. */
  validAfter: string;
  /** The unix timestamp before which the authorization is valid. */
  validBefore: string;
  /**
   * The 32-byte ERC-3009 nonce/salt for replay protection.
   * @pattern ^0x[0-9a-fA-F]{64}$
   */
  salt: string;
  /**
   * The EIP-712 hex-encoded signature of the ERC-3009 authorization.
   * @pattern ^0x[0-9a-fA-F]+$
   */
  signature: string;
};

/**
 * The asset-transfer authorization for the deposit. Currently only ERC-3009 is supported.
 */
export type X402BatchSettlementDepositPayloadDepositAuthorization = {
  /** An ERC-3009 receiveWithAuthorization message authorizing the channel-funding transfer. */
  erc3009Authorization?: X402BatchSettlementDepositPayloadDepositAuthorizationErc3009Authorization;
};

/**
 * The deposit amount and asset-transfer authorization that funds the channel.
 */
export type X402BatchSettlementDepositPayloadDeposit = {
  /**
   * The deposit amount in atomic units of `channelConfig.token`.
   * @pattern ^[0-9]+$
   */
  amount: string;
  /** The asset-transfer authorization for the deposit. Currently only ERC-3009 is supported. */
  authorization: X402BatchSettlementDepositPayloadDepositAuthorization;
};

/**
 * Sent on the first request to fund a channel via an ERC-3009 receiveWithAuthorization deposit.
 */
export interface X402BatchSettlementDepositPayload {
  type: X402BatchSettlementDepositPayloadType;
  channelConfig: X402BatchSettlementChannelConfig;
  voucher: X402BatchSettlementVoucher;
  /** The deposit amount and asset-transfer authorization that funds the channel. */
  deposit: X402BatchSettlementDepositPayloadDeposit;
}

export type X402BatchSettlementVoucherPayloadType =
  (typeof X402BatchSettlementVoucherPayloadType)[keyof typeof X402BatchSettlementVoucherPayloadType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const X402BatchSettlementVoucherPayloadType = {
  voucher: "voucher",
} as const;

/**
 * Sent on subsequent requests against an already-funded channel; carries only the latest cumulative voucher.
 */
export interface X402BatchSettlementVoucherPayload {
  type: X402BatchSettlementVoucherPayloadType;
  channelConfig: X402BatchSettlementChannelConfig;
  voucher: X402BatchSettlementVoucher;
}

/**
 * The voucher to claim, identified by the channel config it was signed against and its cumulative ceiling. Field shape mirrors the on-chain claim struct.
 */
export type X402BatchSettlementClaimVoucher = {
  channel: X402BatchSettlementChannelConfig;
  /**
   * The cumulative maximum claimable amount (uint128 as decimal string) signed by the payer authorizer.
   * @pattern ^[0-9]+$
   */
  maxClaimableAmount: string;
};

/**
 * A single voucher claim within a batched on-chain claim transaction. Used by `x402BatchSettlementClaimPayload.claims` and by the server-enriched shape of `x402BatchSettlementRefundPayload.claims`.
NOTE: the nested `voucher` here has a **different shape** from the top-level `x402BatchSettlementVoucher` schema. The top-level voucher is the signed cumulative-ceiling message sent by a client (`{channelId, maxClaimableAmount, signature}`). This nested `voucher` mirrors the on-chain claim struct (`{channel: ChannelConfig, maxClaimableAmount}`) that participates in the EIP-712 hash, with `signature` and `totalClaimed` as siblings rather than nested fields. The field names match the upstream x402 protocol and the on-chain Solidity struct; they cannot be renamed without breaking wire and EIP-712 compatibility.
 */
export interface X402BatchSettlementClaim {
  /** The voucher to claim, identified by the channel config it was signed against and its cumulative ceiling. Field shape mirrors the on-chain claim struct. */
  voucher: X402BatchSettlementClaimVoucher;
  /**
   * The voucher signature from `payerAuthorizer`.
   * @pattern ^0x[0-9a-fA-F]+$
   */
  signature: string;
  /**
   * The cumulative amount already claimed from this channel as of this claim.
   * @pattern ^[0-9]+$
   */
  totalClaimed: string;
}

export type X402BatchSettlementRefundPayloadType =
  (typeof X402BatchSettlementRefundPayloadType)[keyof typeof X402BatchSettlementRefundPayloadType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const X402BatchSettlementRefundPayloadType = {
  refund: "refund",
} as const;

/**
 * A cooperative refund request. The client emits the minimal shape (just `channelConfig` and `voucher`, with an optional `amount`). A mediating server enriches the payload with `amount`, `refundNonce`, and `claims` before forwarding to the facilitator. Authorizer signatures are optional — the facilitator auto-signs when absent. Field presence determines which shape was sent; the facilitator dispatches accordingly.
 */
export interface X402BatchSettlementRefundPayload {
  type: X402BatchSettlementRefundPayloadType;
  channelConfig: X402BatchSettlementChannelConfig;
  voucher: X402BatchSettlementVoucher;
  /**
   * The refund amount in atomic units of `channelConfig.token`. Optional in the client-emitted shape (defaults to the full remaining channel balance). Required when the payload is enriched by a mediating server.
   * @pattern ^[0-9]+$
   */
  amount?: string;
  /**
   * The on-chain refund nonce for replay protection (uint256 as decimal string). Only present on the server-enriched shape.
   * @pattern ^[0-9]+$
   */
  refundNonce?: string;
  /** Voucher claims to include atomically with the refund. Only present on the server-enriched shape. */
  claims?: X402BatchSettlementClaim[];
  /**
   * Optional EIP-712 signature from the receiver authorizer over the refund. When omitted, the facilitator auto-signs.
   * @pattern ^0x[0-9a-fA-F]+$
   */
  refundAuthorizerSignature?: string;
  /**
   * Optional EIP-712 signature from the receiver authorizer over the included claims. When omitted, the facilitator auto-signs.
   * @pattern ^0x[0-9a-fA-F]+$
   */
  claimAuthorizerSignature?: string;
}

export type X402BatchSettlementClaimPayloadType =
  (typeof X402BatchSettlementClaimPayloadType)[keyof typeof X402BatchSettlementClaimPayloadType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const X402BatchSettlementClaimPayloadType = {
  claim: "claim",
} as const;

/**
 * Server-to-facilitator request to batch on-chain claims of accumulated vouchers. `claimAuthorizerSignature` is optional; when absent the facilitator auto-signs with its receiver-authorizer key.
 */
export interface X402BatchSettlementClaimPayload {
  type: X402BatchSettlementClaimPayloadType;
  /** The list of voucher claims to batch in a single on-chain `claim` call. */
  claims: X402BatchSettlementClaim[];
  /**
   * Optional EIP-712 signature from the receiver authorizer over the claim batch. When omitted, the facilitator auto-signs.
   * @pattern ^0x[0-9a-fA-F]+$
   */
  claimAuthorizerSignature?: string;
}

export type X402BatchSettlementSettlePayloadType =
  (typeof X402BatchSettlementSettlePayloadType)[keyof typeof X402BatchSettlementSettlePayloadType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const X402BatchSettlementSettlePayloadType = {
  settle: "settle",
} as const;

/**
 * Server-to-facilitator request to transfer claimed funds for a `(receiver, token)` pair to the receiver wallet.
 */
export interface X402BatchSettlementSettlePayload {
  type: X402BatchSettlementSettlePayloadType;
  /**
   * The 0x-prefixed, checksum EVM address of the receiver to settle to.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  receiver: string;
  /**
   * The 0x-prefixed, checksum EVM address of the token to settle.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  token: string;
}

/**
 * The x402 protocol batch-settlement scheme payload for EVM networks. The `batch-settlement` scheme uses pre-funded payment channels with off-chain cumulative-ceiling vouchers, allowing servers to batch-claim accumulated value in a single on-chain transaction. The payload is a discriminated union on the `type` field with five variants:

  - `deposit`: client-initiated channel funding via ERC-3009.
  - `voucher`: client-side cumulative voucher against an already-funded channel.
  - `refund`: cooperative refund request. The client emits a minimal shape (just channelConfig + voucher, with an optional `amount`); a mediating server enriches it with `amount`, `refundNonce`, and `claims` before forwarding to the facilitator. Authorizer signatures are optional — the facilitator auto-signs when absent.
  - `claim`: server-to-facilitator request to batch on-chain voucher claims.
  - `settle`: server-to-facilitator request to transfer claimed funds to the receiver.

For more details, see [batch-settlement specs](https://github.com/x402-foundation/x402/tree/main/specs/schemes/batch-settlement).
 */
export type X402BatchSettlementEvmPayload =
  | X402BatchSettlementDepositPayload
  | X402BatchSettlementVoucherPayload
  | X402BatchSettlementRefundPayload
  | X402BatchSettlementClaimPayload
  | X402BatchSettlementSettlePayload;

/**
 * The payload of the payment depending on the x402Version, scheme, and network. Discriminated by scheme-specific fields: exact-EVM/upto-EVM payloads carry a `signature`; exact-Solana carries a `transaction`; batch-settlement carries a `type` discriminator. See `x402BatchSettlementEvmPayload` for the documented batch-settlement variants.
 */
export type X402V2PaymentPayloadPayload =
  | X402ExactEvmPayload
  | X402ExactEvmPermit2Payload
  | X402ExactSolanaPayload
  | X402UptoEvmPermit2Payload
  | X402BatchSettlementEvmPayload;

/**
 * Optional protocol extensions.
 */
export type X402V2PaymentPayloadExtensions = { [key: string]: unknown };

/**
 * The x402 v2 protocol payment payload. Uses CAIP-2 network identifiers. The `accepted` field carries the full payment requirements; `scheme` and `network` are not top-level fields (they are on the nested `accepted` object).
 */
export interface X402V2PaymentPayload {
  /** The x402 protocol version. Must be `2` for this payload shape. */
  x402Version: X402Version;
  /** The payload of the payment depending on the x402Version, scheme, and network. Discriminated by scheme-specific fields: exact-EVM/upto-EVM payloads carry a `signature`; exact-Solana carries a `transaction`; batch-settlement carries a `type` discriminator. See `x402BatchSettlementEvmPayload` for the documented batch-settlement variants. */
  payload: X402V2PaymentPayloadPayload;
  accepted: X402V2PaymentRequirements;
  resource?: X402ResourceInfo;
  /** Optional protocol extensions. */
  extensions?: X402V2PaymentPayloadExtensions;
}

/**
 * The scheme of the payment protocol to use. Currently, the only supported scheme is `exact`.
 */
export type X402V1PaymentPayloadScheme =
  (typeof X402V1PaymentPayloadScheme)[keyof typeof X402V1PaymentPayloadScheme];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const X402V1PaymentPayloadScheme = {
  exact: "exact",
} as const;

/**
 * The payload of the payment depending on the x402Version, scheme, and network.
 */
export type X402V1PaymentPayloadPayload =
  | X402ExactEvmPayload
  | X402ExactEvmPermit2Payload
  | X402ExactSolanaPayload;

/**
 * The x402 v1 protocol payment payload. Uses human-readable network names and requires `scheme` and `network` alongside the inner `payload` object.
 */
export interface X402V1PaymentPayload {
  /** The x402 protocol version. Must be `1` for this payload shape. */
  x402Version: X402Version;
  /** The scheme of the payment protocol to use. Currently, the only supported scheme is `exact`. */
  scheme: X402V1PaymentPayloadScheme;
  /** The network of the blockchain to send payment on. */
  network: X402V1Network;
  /** The payload of the payment depending on the x402Version, scheme, and network. */
  payload: X402V1PaymentPayloadPayload;
}

/**
 * The x402 protocol payment payload that the client attaches to x402-paid API requests to the resource server in the PAYMENT-SIGNATURE header.
For EVM networks, smart account signatures can be longer than 65 bytes.
 */
export type X402PaymentPayload = X402V2PaymentPayload | X402V1PaymentPayload;

export interface EvmAccount {
  /**
   * The 0x-prefixed, checksum EVM address.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  address: string;
  /**
   * An optional name for the account.
Account names can consist of alphanumeric characters and hyphens, and be between 2 and 36 characters long.
Account names are guaranteed to be unique across all EVM accounts in the developer's CDP Project.
   * @pattern ^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$
   */
  name?: string;
  /** The list of policy IDs that apply to the account. This will include both the project-level policy and the account-level policy, if one exists. */
  policies?: string[];
  /** The UTC ISO 8601 timestamp at which the account was created. */
  createdAt?: string;
  /** The UTC ISO 8601 timestamp at which the account was last updated. */
  updatedAt?: string;
}

/**
 * The current status of the delegation operation.
UNSPECIFIED means the status has not been set. PENDING means the operation has been created but not yet submitted. SUBMITTED means the operation has been submitted to the network. COMPLETED means the operation has completed successfully. FAILED means the operation has failed.
 */
export type EvmEip7702DelegationOperationStatus =
  (typeof EvmEip7702DelegationOperationStatus)[keyof typeof EvmEip7702DelegationOperationStatus];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const EvmEip7702DelegationOperationStatus = {
  UNSPECIFIED: "UNSPECIFIED",
  PENDING: "PENDING",
  SUBMITTED: "SUBMITTED",
  COMPLETED: "COMPLETED",
  FAILED: "FAILED",
} as const;

/**
 * The status of an EIP-7702 delegation operation.
 */
export interface EvmEip7702DelegationOperation {
  /** The unique identifier for the delegation operation. */
  delegationOperationId: string;
  /** The current status of the delegation operation.
UNSPECIFIED means the status has not been set. PENDING means the operation has been created but not yet submitted. SUBMITTED means the operation has been submitted to the network. COMPLETED means the operation has completed successfully. FAILED means the operation has failed. */
  status: EvmEip7702DelegationOperationStatus;
  /**
   * The hash of the delegation transaction, if available. Present once the transaction has been submitted to the network.
   * @pattern ^0x[0-9a-fA-F]{64}$
   */
  transactionHash?: string;
  network: EvmEip7702DelegationNetwork;
  /**
   * The address the account has delegated to, if any. Only present when the account has an active delegation.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  delegateAddress?: string;
}

export interface EvmSmartAccount {
  /**
   * The 0x-prefixed, checksum address of the Smart Account.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  address: string;
  /** Today, only a single owner can be set for a Smart Account, but this is an array to allow having multiple owners in the future. The address is a 0x-prefixed, checksum address. */
  owners: string[];
  /**
   * An optional name for the account.
Account names can consist of alphanumeric characters and hyphens, and be between 2 and 36 characters long.
Account names are guaranteed to be unique across all Smart Accounts in the developer's CDP Project.
   * @pattern ^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$
   */
  name?: string;
  /** The list of policy IDs that apply to the smart account. This will include both the project-level policy and the account-level policy, if one exists. */
  policies?: string[];
  /** The UTC ISO 8601 timestamp at which the account was created. */
  createdAt?: string;
  /** The UTC ISO 8601 timestamp at which the account was last updated. */
  updatedAt?: string;
}

/**
 * The network the spend permission is on.
 */
export type SpendPermissionNetwork =
  (typeof SpendPermissionNetwork)[keyof typeof SpendPermissionNetwork];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SpendPermissionNetwork = {
  base: "base",
  "base-sepolia": "base-sepolia",
  ethereum: "ethereum",
  "ethereum-sepolia": "ethereum-sepolia",
  optimism: "optimism",
  arbitrum: "arbitrum",
  avalanche: "avalanche",
  polygon: "polygon",
} as const;

/**
 * Request parameters for creating a Spend Permission.
 */
export interface CreateSpendPermissionRequest {
  network: SpendPermissionNetwork;
  /**
   * Entity that can spend account's tokens. Can be either a Smart Account or an EOA.
   * @pattern ^0x[a-fA-F0-9]{40}$
   */
  spender: string;
  /**
   * ERC-7528 native token address (e.g. "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" for native ETH), or an  ERC-20 contract address.
   * @pattern ^0x[a-fA-F0-9]{40}$
   */
  token: string;
  /** Maximum allowed value to spend, in atomic units for the specified token, within each period. */
  allowance: string;
  /** Time duration for resetting used allowance on a recurring basis (seconds). */
  period: string;
  /** The start time for this spend permission, in Unix seconds. */
  start: string;
  /** The expiration time for this spend permission, in Unix seconds. */
  end: string;
  /** An arbitrary salt to differentiate unique spend permissions with otherwise identical data. */
  salt?: string;
  /** Arbitrary data to include in the permission. */
  extraData?: string;
  /** The paymaster URL of the spend permission. */
  paymasterUrl?: Url;
}

/**
 * The core spend permission.
 */
export interface SpendPermission {
  /**
   * Smart account this spend permission is valid for.
   * @pattern ^0x[a-fA-F0-9]{40}$
   */
  account: string;
  /**
   * Entity that can spend account's tokens.
   * @pattern ^0x[a-fA-F0-9]{40}$
   */
  spender: string;
  /**
   * Token address (ERC-7528 native token address or ERC-20 contract).
   * @pattern ^0x[a-fA-F0-9]{40}$
   */
  token: string;
  /** Maximum allowed value to spend, in atomic units for the specified token, within each period. */
  allowance: string;
  /** Time duration for resetting used allowance on a recurring basis (seconds). */
  period: string;
  /** The start time for this spend permission, in Unix seconds. */
  start: string;
  /** The expiration time for this spend permission, in Unix seconds. */
  end: string;
  /** An arbitrary salt to differentiate unique spend permissions with otherwise identical data. */
  salt: string;
  /** Arbitrary data to include in the permission. */
  extraData: string;
}

export interface SpendPermissionResponseObject {
  permission: SpendPermission;
  /** Unique hash identifier for this permission. */
  permissionHash: string;
  /** Whether this permission has been revoked. */
  revoked: boolean;
  /** The UTC ISO 8601 timestamp when the permission was revoked (if applicable). */
  revokedAt?: string;
  /** The UTC ISO 8601 timestamp when the permission was created. */
  createdAt: string;
  network: SpendPermissionNetwork;
}

/**
 * Request parameters for revoking a Spend Permission.
 */
export interface RevokeSpendPermissionRequest {
  network: SpendPermissionNetwork;
  /** The hash of the spend permission to revoke. */
  permissionHash: string;
  /** The paymaster URL of the spend permission. */
  paymasterUrl?: Url;
}

/**
 * The network on which to perform the swap.
 */
export type EvmSwapsNetwork = (typeof EvmSwapsNetwork)[keyof typeof EvmSwapsNetwork];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const EvmSwapsNetwork = {
  base: "base",
  ethereum: "ethereum",
  arbitrum: "arbitrum",
  optimism: "optimism",
  polygon: "polygon",
} as const;

/**
 * The 0x-prefixed contract address of the token to receive.
 * @pattern ^0x[a-fA-F0-9]{40}$
 */
export type ToToken = string;

/**
 * The 0x-prefixed contract address of the token to send.
 * @pattern ^0x[a-fA-F0-9]{40}$
 */
export type FromToken = string;

/**
 * The amount of the `fromToken` to send in atomic units of the token. For example, `1000000000000000000` when sending ETH equates to 1 ETH, `1000000` when sending USDC equates to 1 USDC, etc.
 * @pattern ^\d+$
 */
export type FromAmount = string;

/**
 * The 0x-prefixed address that holds the `fromToken` balance and has the `Permit2` allowance set for the swap.
 * @pattern ^0x[a-fA-F0-9]{40}$
 */
export type Taker = string;

/**
 * The 0x-prefixed Externally Owned Account (EOA) address that will sign the `Permit2` EIP-712 permit message. This is only needed if `taker` is a smart contract.
 * @pattern ^0x[a-fA-F0-9]{40}$
 */
export type SignerAddress = string;

/**
 * The target gas price for the swap transaction, in Wei. For EIP-1559 transactions, this value should be seen as the `maxFeePerGas` value. If not provided, the API will use an estimate based on the current network conditions.
 * @pattern ^\d+$
 */
export type GasPrice = string;

/**
 * The maximum acceptable slippage of the `toToken` in basis points. If this parameter is set to 0, no slippage will be tolerated. If not provided, the default slippage tolerance is 100 bps (i.e., 1%).
 * @minimum 0
 * @maximum 10000
 */
export type SlippageBps = number;

export interface TokenFee {
  /**
   * The estimated amount of the fee in atomic units of the `token`. For example, `1000000000000000` if the fee is in ETH equates to 0.001 ETH, `10000` if the fee is in USDC equates to 0.01 USDC, etc.
   * @pattern ^\d+$
   */
  amount: string;
  /**
   * The contract address of the token that the fee is paid in. The address `0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE` is used for the native token of the network (e.g. ETH).
   * @pattern ^0x[a-fA-F0-9]{40}$
   */
  token: string;
}

export interface CommonSwapResponseIssuesAllowance {
  /**
   * The current allowance of the `fromToken` by the `taker`.
   * @pattern ^\d+$
   */
  currentAllowance: string;
  /**
   * The 0x-prefixed address of to set the allowance on.
   * @pattern ^0x[a-fA-F0-9]{40}$
   */
  spender: string;
}

export interface CommonSwapResponseIssuesBalance {
  /**
   * The 0x-prefixed contract address of the token.
   * @pattern ^0x[a-fA-F0-9]{40}$
   */
  token: string;
  /**
   * The current balance of the `fromToken` by the `taker`.
   * @pattern ^\d+$
   */
  currentBalance: string;
  /**
   * The amount of the token that the `taker` must hold.
   * @pattern ^\d+$
   */
  requiredBalance: string;
}

/**
 * The estimated gas fee for the swap.
 */
export type CommonSwapResponseFeesGasFee = TokenFee | null;

/**
 * The estimated protocol fee for the swap.
 */
export type CommonSwapResponseFeesProtocolFee = TokenFee | null;

/**
 * The estimated fees for the swap.
 */
export type CommonSwapResponseFees = {
  /** The estimated gas fee for the swap. */
  gasFee: CommonSwapResponseFeesGasFee;
  /** The estimated protocol fee for the swap. */
  protocolFee: CommonSwapResponseFeesProtocolFee;
};

/**
 * Details of the allowances that the taker must set in order to execute the swap successfully. Null if no allowance is required.
 */
export type CommonSwapResponseIssuesAllowanceProperty = CommonSwapResponseIssuesAllowance | null;

/**
 * Details of the balance of the `fromToken` that the `taker` must hold. Null if the `taker` has a sufficient balance.
 */
export type CommonSwapResponseIssuesBalanceProperty = CommonSwapResponseIssuesBalance | null;

/**
 * An object containing potential issues discovered during validation that could prevent the swap from being executed successfully.
 */
export type CommonSwapResponseIssues = {
  /** Details of the allowances that the taker must set in order to execute the swap successfully. Null if no allowance is required. */
  allowance: CommonSwapResponseIssuesAllowanceProperty;
  /** Details of the balance of the `fromToken` that the `taker` must hold. Null if the `taker` has a sufficient balance. */
  balance: CommonSwapResponseIssuesBalanceProperty;
  /** This is set to true when the transaction cannot be validated. This can happen when the taker has an insufficient balance of the `fromToken`. Note that this does not necessarily mean that the trade will revert. */
  simulationIncomplete: boolean;
};

export interface CommonSwapResponse {
  /**
   * The block number at which the liquidity conditions were examined.
   * @pattern ^[1-9]\d*$
   */
  blockNumber: string;
  /**
   * The amount of the `toToken` that will be received in atomic units of the `toToken`. For example, `1000000000000000000` when receiving ETH equates to 1 ETH, `1000000` when receiving USDC equates to 1 USDC, etc.
   * @pattern ^(0|[1-9]\d*)$
   */
  toAmount: string;
  /**
   * The 0x-prefixed contract address of the token that will be received.
   * @pattern ^0x[a-fA-F0-9]{40}$
   */
  toToken: string;
  /** The estimated fees for the swap. */
  fees: CommonSwapResponseFees;
  /** An object containing potential issues discovered during validation that could prevent the swap from being executed successfully. */
  issues: CommonSwapResponseIssues;
  /** Whether sufficient liquidity is available to settle the swap. All other fields in the response will be empty if this is false. */
  liquidityAvailable: boolean;
  /**
   * The minimum amount of the `toToken` that must be received for the swap to succeed, in atomic units of the `toToken`.  For example, `1000000000000000000` when receiving ETH equates to 1 ETH, `1000000` when receiving USDC equates to 1 USDC, etc. This value is influenced by the `slippageBps` parameter.
   * @pattern ^(0|[1-9]\d*)$
   */
  minToAmount: string;
  /**
   * The amount of the `fromToken` that will be sent in this swap, in atomic units of the `fromToken`. For example, `1000000000000000000` when sending ETH equates to 1 ETH, `1000000` when sending USDC equates to 1 USDC, etc.
   * @pattern ^(0|[1-9]\d*)$
   */
  fromAmount: string;
  /**
   * The 0x-prefixed contract address of the token that will be sent.
   * @pattern ^0x[a-fA-F0-9]{40}$
   */
  fromToken: string;
}

/**
 * The estimated gas limit that should be used to send the transaction to guarantee settlement.
 */
export type GetSwapPriceResponseAllOfGas = string | null;

export type GetSwapPriceResponseAllOf = {
  /** The estimated gas limit that should be used to send the transaction to guarantee settlement. */
  gas: GetSwapPriceResponseAllOfGas;
  /**
   * The gas price, in Wei, that should be used to send the transaction. For EIP-1559 transactions, this value should be seen as the `maxFeePerGas` value. The transaction should be sent with this gas price to guarantee settlement.
   * @pattern ^\d+$
   */
  gasPrice: string;
};

export type GetSwapPriceResponse = CommonSwapResponse & GetSwapPriceResponseAllOf;

export interface SwapUnavailableResponse {
  /** Whether sufficient liquidity is available to settle the swap. All other fields in the response will be empty if this is false. */
  liquidityAvailable: boolean;
}

/**
 * A wrapper for the response of a swap price operation.
 */
export type GetSwapPriceResponseWrapper = GetSwapPriceResponse | SwapUnavailableResponse;

export interface SwapPermit2Approval {
  /**
   * The hash for the approval according to [EIP-712](https://eips.ethereum.org/EIPS/eip-712). Computing the hash of the `eip712` field should match the value of this field.
   * @pattern ^0x[a-fA-F0-9]{64}$
   */
  hash: string;
  eip712: EIP712Message;
}

/**
 * The approval object which contains the necessary fields to submit an approval for this transaction. Null if the `fromToken` is the native token or the transaction is a native token wrap / unwrap.
 */
export type CreateSwapQuoteResponseAllOfPermit2 = SwapPermit2Approval | null;

/**
 * The details of the transaction to be signed and submitted to execute the swap.
 */
export type CreateSwapQuoteResponseAllOfTransaction = {
  /**
   * The 0x-prefixed address of the contract to call.
   * @pattern ^0x[a-fA-F0-9]{40}$
   */
  to: string;
  /** The hex-encoded call data to send to the contract. */
  data: string;
  /**
   * The estimated gas limit that should be used to send the transaction to guarantee settlement.
   * @pattern ^\d+$
   */
  gas: string;
  /**
   * The gas price, in Wei, that should be used to send the transaction. For EIP-1559 transactions, this value should be seen as the `maxFeePerGas` value. The transaction should be sent with this gas price to guarantee settlement.
   * @pattern ^\d+$
   */
  gasPrice: string;
  /**
   * The value of the transaction in Wei.
   * @pattern ^\d+$
   */
  value: string;
};

export type CreateSwapQuoteResponseAllOf = {
  /** The approval object which contains the necessary fields to submit an approval for this transaction. Null if the `fromToken` is the native token or the transaction is a native token wrap / unwrap. */
  permit2: CreateSwapQuoteResponseAllOfPermit2;
  /** The details of the transaction to be signed and submitted to execute the swap. */
  transaction: CreateSwapQuoteResponseAllOfTransaction;
};

export type CreateSwapQuoteResponse = CreateSwapQuoteResponseAllOf & CommonSwapResponse;

/**
 * A wrapper for the response of a swap quote operation.
 */
export type CreateSwapQuoteResponseWrapper = CreateSwapQuoteResponse | SwapUnavailableResponse;

/**
 * The name of the supported EVM networks in human-readable format.
 */
export type ListEvmTokenBalancesNetwork =
  (typeof ListEvmTokenBalancesNetwork)[keyof typeof ListEvmTokenBalancesNetwork];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const ListEvmTokenBalancesNetwork = {
  base: "base",
  "base-sepolia": "base-sepolia",
  ethereum: "ethereum",
} as const;

/**
 * Amount of a given token.
 */
export interface TokenAmount {
  /**
   * The amount is denominated in the smallest indivisible unit of the token. For ETH, the smallest indivisible unit is Wei (10^-18 ETH). For ERC-20s, the smallest unit is the unit returned from `function totalSupply() public view returns (uint256)`.
   * @pattern ^[0-9]+$
   */
  amount: string;
  /** 'decimals' is the exponential value N that satisfies the equation `amount * 10^-N = standard_denomination`. The standard denomination is the most commonly used denomination for the token.
- In the case of the native gas token, `decimals` is defined via convention. As an example, for ETH of Ethereum mainnet, the standard denomination is 10^-18 the smallest denomination (Wei). As such, for ETH on Ethereum mainnet, `decimals` is 18. - In the case of ERC-20 tokens, `decimals` is defined via configuration. `decimals` will be the number returned by `function decimals() public view returns (uint8)` on the underlying token contract.
Not all tokens have a `decimals` field, as this function is [optional in the ERC-20 specification](https://eips.ethereum.org/EIPS/eip-20#decimals). This field will be left empty if the underlying token contract doesn't implement `decimals`.
Further, this endpoint will only populate this value for a small subset of whitelisted ERC-20 tokens at this time. We intend to improve coverage in the future. */
  decimals: number;
}

/**
 * General information about a token. Includes the type, the network, and other identifying information.
 */
export interface Token {
  network: ListEvmTokenBalancesNetwork;
  /** The symbol of this token (ex: SOL, ETH, USDC).
The token symbol is not unique. It is possible for two different tokens to have the same symbol.
For native gas tokens, this symbol is defined via convention. As an example, for ETH on Ethereum mainnet, the symbol is "ETH". For ERC-20 tokens, this symbol is defined via configuration. `symbol` will be the string returned by `function symbol() public view returns (string)` on the underlying token contract.
Not all tokens have a symbol, as this function is [optional in the ERC-20 specification](https://eips.ethereum.org/EIPS/eip-20#symbol). This field will only be populated when the token's underlying ERC-20 contract has a `symbol()` function.
Further, this endpoint will only populate this value for a small subset of whitelisted ERC-20 tokens at this time. We intend to improve coverage in the future. */
  symbol?: string;
  /** The name of this token (ex: "Solana", "Ether", "USD Coin").
The token name is not unique. It is possible for two different tokens to have the same name.
For native gas tokens, this name is defined via convention. As an example, for ETH on Ethereum mainnet, the name is "Ether". For ERC-20 tokens, this name is defined via configuration. `name` will be the string returned by `function name() public view returns (string)` on the underlying token contract.
Not all tokens have a name, as this function is [optional in the ERC-20 specification](https://eips.ethereum.org/EIPS/eip-20#name). This field will only be populated when the token's underlying ERC-20 contract has a `name()` function.
Further, this endpoint will only populate this value for a small subset of whitelisted ERC-20 tokens at this time. We intend to improve coverage in the future. */
  name?: string;
  /**
   * The contract address of the token.
For Ether, the contract address is `0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE` per [EIP-7528](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7528.md). For ERC-20 tokens, this is the contract address where the token is deployed.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  contractAddress: string;
}

export interface TokenBalance {
  amount: TokenAmount;
  token: Token;
}

/**
 * The type of criterion to use. This should be `ethValue`.
 */
export type EthValueCriterionType =
  (typeof EthValueCriterionType)[keyof typeof EthValueCriterionType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const EthValueCriterionType = {
  ethValue: "ethValue",
} as const;

/**
 * The operator to use for the comparison. The transaction's `value` field will be on the left-hand side of the operator, and the `ethValue` field will be on the right-hand side.
 */
export type EthValueCriterionOperator =
  (typeof EthValueCriterionOperator)[keyof typeof EthValueCriterionOperator];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const EthValueCriterionOperator = {
  ">": ">",
  ">=": ">=",
  "<": "<",
  "<=": "<=",
  "==": "==",
} as const;

/**
 * A schema for specifying a criterion for the `value` field of an EVM transaction.
 */
export interface EthValueCriterion {
  /** The type of criterion to use. This should be `ethValue`. */
  type: EthValueCriterionType;
  /**
   * The amount of ETH, in wei, that the transaction's `value` field should be compared to.
   * @maxLength 78
   * @pattern ^[0-9]+$
   */
  ethValue: string;
  /** The operator to use for the comparison. The transaction's `value` field will be on the left-hand side of the operator, and the `ethValue` field will be on the right-hand side. */
  operator: EthValueCriterionOperator;
}

/**
 * The type of criterion to use. This should be `evmAddress`.
 */
export type EvmAddressCriterionType =
  (typeof EvmAddressCriterionType)[keyof typeof EvmAddressCriterionType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const EvmAddressCriterionType = {
  evmAddress: "evmAddress",
} as const;

/**
 * The operator to use for the comparison. The transaction's `to` field will be on the left-hand side of the operator, and the `addresses` field will be on the right-hand side.
 */
export type EvmAddressCriterionOperator =
  (typeof EvmAddressCriterionOperator)[keyof typeof EvmAddressCriterionOperator];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const EvmAddressCriterionOperator = {
  in: "in",
  not_in: "not in",
} as const;

/**
 * A schema for specifying a criterion for the `to` field of an EVM transaction.
 */
export interface EvmAddressCriterion {
  /** The type of criterion to use. This should be `evmAddress`. */
  type: EvmAddressCriterionType;
  /** A list of 0x-prefixed EVM addresses that the transaction's `to` field should be compared to. There is a limit of 300 addresses per criterion. */
  addresses: string[];
  /** The operator to use for the comparison. The transaction's `to` field will be on the left-hand side of the operator, and the `addresses` field will be on the right-hand side. */
  operator: EvmAddressCriterionOperator;
}

/**
 * A reference to an established EIP standard. When referencing a `KnownAbiType` within a policy rule configuring an `EvmDataCriterion`, criteria will only decode function data officially documented in the standard. For more information on supported token standards, see the links below.
  - [erc20 - Token Standard](https://eips.ethereum.org/EIPS/eip-20).
  - [erc721 - Non-Fungible Token Standard](https://eips.ethereum.org/EIPS/eip-721).
  - [erc1155 - Multi Token Standard](https://eips.ethereum.org/EIPS/eip-1155).
 */
export type KnownAbiType = (typeof KnownAbiType)[keyof typeof KnownAbiType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const KnownAbiType = {
  erc20: "erc20",
  erc721: "erc721",
  erc1155: "erc1155",
} as const;

/**
 * Parameter definition for ABI functions, errors, and constructors.
 */
export interface AbiParameter {
  /** The name of the parameter. */
  name?: string;
  /** The canonical type of the parameter. */
  type: string;
  /** The internal Solidity type used by the compiler. */
  internalType?: string;
  /** Used for tuple types. */
  components?: AbiParameter[];
}

/**
 * State mutability of a function in Solidity.
 */
export type AbiStateMutability = (typeof AbiStateMutability)[keyof typeof AbiStateMutability];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AbiStateMutability = {
  pure: "pure",
  view: "view",
  nonpayable: "nonpayable",
  payable: "payable",
} as const;

/**
 * The type of the ABI item, must be `function`.
 */
export type AbiFunctionType = (typeof AbiFunctionType)[keyof typeof AbiFunctionType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AbiFunctionType = {
  function: "function",
} as const;

/**
 * ABI function type for contract functions.
 */
export interface AbiFunction {
  /** The type of the ABI item, must be `function`. */
  type: AbiFunctionType;
  /** The name of the ABI function. */
  name: string;
  /** The list of ABI parameters used for this function. */
  inputs: AbiParameter[];
  /** The values returned by this function. */
  outputs: AbiParameter[];
  /** Deprecated. Use pure or view from stateMutability instead. */
  constant?: boolean;
  /** Deprecated. Use payable or nonpayable from `stateMutability` instead. */
  payable?: boolean;
  stateMutability: AbiStateMutability;
  /** Deprecated. Vyper used to provide gas estimates. */
  gas?: number;
}

/**
 * The type of the ABI item.
 */
export type AbiInputType = (typeof AbiInputType)[keyof typeof AbiInputType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AbiInputType = {
  constructor: "constructor",
  error: "error",
  event: "event",
  fallback: "fallback",
  receive: "receive",
} as const;

/**
 * Generic ABI item type encapsulating all other types besides `function`.
 */
export interface AbiInput {
  /** The type of the ABI item. */
  type: AbiInputType;
  /** For additional information on the ABI JSON specification, see [the Solidity documentation](https://docs.soliditylang.org/en/latest/abi-spec.html#json). */
  additionalProperties?: unknown;
}

export type AbiItem = AbiFunction | AbiInput;

/**
 * Contract ABI Specification following Solidity's external JSON interface format.
 */
export type Abi = AbiItem[];

/**
 * The operator to use for the comparison. The value resolved at the `name` will be on the left-hand side of the operator, and the `value` field will be on the right-hand side.
 */
export type EvmDataParameterConditionOperator =
  (typeof EvmDataParameterConditionOperator)[keyof typeof EvmDataParameterConditionOperator];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const EvmDataParameterConditionOperator = {
  ">": ">",
  ">=": ">=",
  "<": "<",
  "<=": "<=",
  "==": "==",
} as const;

export interface EvmDataParameterCondition {
  /** The name of the parameter to check against a transaction's calldata. If name is unknown, or is not named, you may supply an array index, e.g., `0` for first parameter. */
  name: string;
  /** The operator to use for the comparison. The value resolved at the `name` will be on the left-hand side of the operator, and the `value` field will be on the right-hand side. */
  operator: EvmDataParameterConditionOperator;
  /** A single value to compare the value resolved at `name` to. All values are encoded as strings. Refer to the table in the documentation for how values should be encoded, and which operators are supported for each type. */
  value: string;
}

/**
 * The operator to use for the comparison. The value resolved at the `name` will be on the left-hand side of the operator, and the `values` field will be on the right-hand side.
 */
export type EvmDataParameterConditionListOperator =
  (typeof EvmDataParameterConditionListOperator)[keyof typeof EvmDataParameterConditionListOperator];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const EvmDataParameterConditionListOperator = {
  in: "in",
  not_in: "not in",
} as const;

export interface EvmDataParameterConditionList {
  /** The name of the parameter to check against a transaction's calldata. If name is unknown, or is not named, you may supply an array index, e.g., `0` for first parameter. */
  name: string;
  /** The operator to use for the comparison. The value resolved at the `name` will be on the left-hand side of the operator, and the `values` field will be on the right-hand side. */
  operator: EvmDataParameterConditionListOperator;
  /** Values to compare against the resolved `name` value. All values are encoded as strings. Refer to the table in the documentation for how values should be encoded, and which operators are supported for each type. */
  values: string[];
}

/**
 * A list of parameter conditions to apply against encoded arguments in the transaction's `data` field.
 */
export type EvmDataConditionParamsItem = EvmDataParameterCondition | EvmDataParameterConditionList;

/**
 * A single condition to apply against the function and encoded arguments in the transaction's `data` field. Each `parameter` configuration must be successfully evaluated against the corresponding function argument in order for a policy to be accepted.
 */
export interface EvmDataCondition {
  /** The name of a smart contract function being called. */
  function: string;
  /** An optional list of parameter conditions to apply against encoded arguments in the transaction's `data` field. */
  params?: EvmDataConditionParamsItem[];
}

/**
 * The type of criterion to use. This should be `evmData`.
 */
export type EvmDataCriterionType = (typeof EvmDataCriterionType)[keyof typeof EvmDataCriterionType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const EvmDataCriterionType = {
  evmData: "evmData",
} as const;

/**
 * The ABI of the smart contract being called. This can be a partial structure with only specific functions.
 */
export type EvmDataCriterionAbi = KnownAbiType | Abi;

/**
 * A schema for specifying a criterion for the `data` field of an EVM transaction.
 */
export interface EvmDataCriterion {
  /** The type of criterion to use. This should be `evmData`. */
  type: EvmDataCriterionType;
  /** The ABI of the smart contract being called. This can be a partial structure with only specific functions. */
  abi: EvmDataCriterionAbi;
  /** A list of conditions to apply against the function and encoded arguments in the transaction's `data` field. Each condition must be met in order for this policy to be accepted or rejected. */
  conditions: EvmDataCondition[];
}

/**
 * The type of criterion to use. This should be `netUSDChange`.
 */
export type NetUSDChangeCriterionType =
  (typeof NetUSDChangeCriterionType)[keyof typeof NetUSDChangeCriterionType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const NetUSDChangeCriterionType = {
  netUSDChange: "netUSDChange",
} as const;

/**
 * The operator to use for the comparison. The total value of a transaction's asset transfer will be on the left-hand side of the operator, and the `changeCents` field will be on the right-hand side.
 */
export type NetUSDChangeCriterionOperator =
  (typeof NetUSDChangeCriterionOperator)[keyof typeof NetUSDChangeCriterionOperator];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const NetUSDChangeCriterionOperator = {
  ">": ">",
  ">=": ">=",
  "<": "<",
  "<=": "<=",
  "==": "==",
} as const;

/**
 * A schema for specifying a criterion for the USD denominated asset transfer or exposure for a transaction. This includes native transfers, as well as token transfers.
 */
export interface NetUSDChangeCriterion {
  /** The type of criterion to use. This should be `netUSDChange`. */
  type: NetUSDChangeCriterionType;
  /** The amount of USD, in cents, that the total value of a transaction's asset transfer should be compared to. */
  changeCents: number;
  /** The operator to use for the comparison. The total value of a transaction's asset transfer will be on the left-hand side of the operator, and the `changeCents` field will be on the right-hand side. */
  operator: NetUSDChangeCriterionOperator;
}

export type SignEvmTransactionCriteriaItem =
  | EthValueCriterion
  | EvmAddressCriterion
  | EvmDataCriterion
  | NetUSDChangeCriterion;

/**
 * A schema for specifying criteria for the SignEvmTransaction operation.
 */
export type SignEvmTransactionCriteria = SignEvmTransactionCriteriaItem[];

/**
 * Whether matching the rule will cause the request to be rejected or accepted.
 */
export type SignEvmTransactionRuleAction =
  (typeof SignEvmTransactionRuleAction)[keyof typeof SignEvmTransactionRuleAction];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignEvmTransactionRuleAction = {
  reject: "reject",
  accept: "accept",
} as const;

/**
 * The operation to which the rule applies. Every element of the `criteria` array must match the specified operation.
 */
export type SignEvmTransactionRuleOperation =
  (typeof SignEvmTransactionRuleOperation)[keyof typeof SignEvmTransactionRuleOperation];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignEvmTransactionRuleOperation = {
  signEvmTransaction: "signEvmTransaction",
} as const;

export interface SignEvmTransactionRule {
  /** Whether matching the rule will cause the request to be rejected or accepted. */
  action: SignEvmTransactionRuleAction;
  /** The operation to which the rule applies. Every element of the `criteria` array must match the specified operation. */
  operation: SignEvmTransactionRuleOperation;
  criteria: SignEvmTransactionCriteria;
}

/**
 * The type of criterion to use. This should be `evmNetwork`.
 */
export type EvmNetworkCriterionType =
  (typeof EvmNetworkCriterionType)[keyof typeof EvmNetworkCriterionType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const EvmNetworkCriterionType = {
  evmNetwork: "evmNetwork",
} as const;

/**
 * The network the transaction is for.
 */
export type EvmNetworkCriterionNetworksItem =
  (typeof EvmNetworkCriterionNetworksItem)[keyof typeof EvmNetworkCriterionNetworksItem];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const EvmNetworkCriterionNetworksItem = {
  "base-sepolia": "base-sepolia",
  base: "base",
  ethereum: "ethereum",
  "ethereum-sepolia": "ethereum-sepolia",
  avalanche: "avalanche",
  polygon: "polygon",
  optimism: "optimism",
  arbitrum: "arbitrum",
  "arbitrum-sepolia": "arbitrum-sepolia",
  zora: "zora",
  bnb: "bnb",
  world: "world",
  "world-sepolia": "world-sepolia",
} as const;

/**
 * The operator to use for the comparison. The transaction's intended `network` will be on the left-hand side of the operator, and the `networks` field will be on the right-hand side.
 */
export type EvmNetworkCriterionOperator =
  (typeof EvmNetworkCriterionOperator)[keyof typeof EvmNetworkCriterionOperator];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const EvmNetworkCriterionOperator = {
  in: "in",
  not_in: "not in",
} as const;

/**
 * A schema for specifying a criterion for the intended `network` of an EVM transaction.
 */
export interface EvmNetworkCriterion {
  /** The type of criterion to use. This should be `evmNetwork`. */
  type: EvmNetworkCriterionType;
  /** A list of EVM network identifiers that the transaction's intended `network` should be compared to. */
  networks: EvmNetworkCriterionNetworksItem[];
  /** The operator to use for the comparison. The transaction's intended `network` will be on the left-hand side of the operator, and the `networks` field will be on the right-hand side. */
  operator: EvmNetworkCriterionOperator;
}

export type SendEvmTransactionCriteriaItem =
  | EthValueCriterion
  | EvmAddressCriterion
  | EvmNetworkCriterion
  | EvmDataCriterion
  | NetUSDChangeCriterion;

/**
 * A schema for specifying criteria for the SignEvmTransaction operation.
 */
export type SendEvmTransactionCriteria = SendEvmTransactionCriteriaItem[];

/**
 * Whether matching the rule will cause the request to be rejected or accepted.
 */
export type SendEvmTransactionRuleAction =
  (typeof SendEvmTransactionRuleAction)[keyof typeof SendEvmTransactionRuleAction];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SendEvmTransactionRuleAction = {
  reject: "reject",
  accept: "accept",
} as const;

/**
 * The operation to which the rule applies. Every element of the `criteria` array must match the specified operation.
 */
export type SendEvmTransactionRuleOperation =
  (typeof SendEvmTransactionRuleOperation)[keyof typeof SendEvmTransactionRuleOperation];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SendEvmTransactionRuleOperation = {
  sendEvmTransaction: "sendEvmTransaction",
} as const;

export interface SendEvmTransactionRule {
  /** Whether matching the rule will cause the request to be rejected or accepted. */
  action: SendEvmTransactionRuleAction;
  /** The operation to which the rule applies. Every element of the `criteria` array must match the specified operation. */
  operation: SendEvmTransactionRuleOperation;
  criteria: SendEvmTransactionCriteria;
}

/**
 * The type of criterion to use. This should be `evmMessage`.
 */
export type EvmMessageCriterionType =
  (typeof EvmMessageCriterionType)[keyof typeof EvmMessageCriterionType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const EvmMessageCriterionType = {
  evmMessage: "evmMessage",
} as const;

/**
 * A schema for specifying a criterion for the message being signed.
 */
export interface EvmMessageCriterion {
  /** The type of criterion to use. This should be `evmMessage`. */
  type: EvmMessageCriterionType;
  /** A regular expression the message is matched against. Accepts valid regular expression syntax described by [RE2](https://github.com/google/re2/wiki/Syntax). */
  match: string;
}

/**
 * A schema for specifying the rejection criteria for the SignEvmMessage operation.
 */
export type SignEvmMessageCriteria = EvmMessageCriterion[];

/**
 * Whether matching the rule will cause the request to be rejected or accepted.
 */
export type SignEvmMessageRuleAction =
  (typeof SignEvmMessageRuleAction)[keyof typeof SignEvmMessageRuleAction];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignEvmMessageRuleAction = {
  reject: "reject",
  accept: "accept",
} as const;

/**
 * The operation to which the rule applies. Every element of the `criteria` array must match the specified operation.
 */
export type SignEvmMessageRuleOperation =
  (typeof SignEvmMessageRuleOperation)[keyof typeof SignEvmMessageRuleOperation];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignEvmMessageRuleOperation = {
  signEvmMessage: "signEvmMessage",
} as const;

export interface SignEvmMessageRule {
  /** Whether matching the rule will cause the request to be rejected or accepted. */
  action: SignEvmMessageRuleAction;
  /** The operation to which the rule applies. Every element of the `criteria` array must match the specified operation. */
  operation: SignEvmMessageRuleOperation;
  criteria: SignEvmMessageCriteria;
}

/**
 * The operator to use for the comparison. The value located at the message's path will be on the left-hand side of the operator, and the `addresses` field will be on the right-hand side.
 */
export type EvmTypedAddressConditionOperator =
  (typeof EvmTypedAddressConditionOperator)[keyof typeof EvmTypedAddressConditionOperator];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const EvmTypedAddressConditionOperator = {
  in: "in",
  not_in: "not in",
} as const;

/**
 * A schema for specifying criterion for an address field of an EVM typed message. The address can be deeply nested within the typed data's message.
 */
export interface EvmTypedAddressCondition {
  /** A list of 0x-prefixed EVM addresses that the value located at the message's path should be compared to. There is a limit of 300 addresses per criterion. */
  addresses: string[];
  /** The operator to use for the comparison. The value located at the message's path will be on the left-hand side of the operator, and the `addresses` field will be on the right-hand side. */
  operator: EvmTypedAddressConditionOperator;
  /** The path to the field to compare against this criterion. To reference deeply nested fields within the message, separate object keys by `.`, and access array values using `[index]`. If the field does not exist or is not an address, the operation will be rejected. */
  path: string;
}

/**
 * The operator to use for the comparison. The value located at the message's path will be on the left-hand side of the operator, and the `value` field will be on the right-hand side.
 */
export type EvmTypedNumericalConditionOperator =
  (typeof EvmTypedNumericalConditionOperator)[keyof typeof EvmTypedNumericalConditionOperator];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const EvmTypedNumericalConditionOperator = {
  ">": ">",
  ">=": ">=",
  "<": "<",
  "<=": "<=",
  "==": "==",
} as const;

/**
 * A schema for specifying criterion for a numerical field of an EVM typed message. The value can be deeply nested within the typed data's message.
 */
export interface EvmTypedNumericalCondition {
  /**
   * The amount that the value located at the message's path should be compared to.
   * @pattern ^[0-9]+$
   */
  value: string;
  /** The operator to use for the comparison. The value located at the message's path will be on the left-hand side of the operator, and the `value` field will be on the right-hand side. */
  operator: EvmTypedNumericalConditionOperator;
  /** The path to the field to compare against this criterion. To reference deeply nested fields within the message, separate object keys by `.`, and access array values using `[index]`. If the field does not exist or is not an address, the operation will be rejected. */
  path: string;
}

/**
 * A schema for specifying criterion for a string field of an EVM typed message. The value can be deeply nested within the typed data's message.
 */
export interface EvmTypedStringCondition {
  /** A regular expression the field is matched against. */
  match: string;
  /** The path to the field to compare against this criterion. To reference deeply nested fields within the message, separate object keys by `.`, and access array values using `[index]`. If the field does not exist or is not an address, the operation will be rejected. */
  path: string;
}

/**
 * The type of criterion to use. This should be `evmTypedDataField`.
 */
export type SignEvmTypedDataFieldCriterionType =
  (typeof SignEvmTypedDataFieldCriterionType)[keyof typeof SignEvmTypedDataFieldCriterionType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignEvmTypedDataFieldCriterionType = {
  evmTypedDataField: "evmTypedDataField",
} as const;

export type SignEvmTypedDataFieldCriterionTypesTypesItem = {
  /** The name of a key within an EIP-712 data structure. */
  name?: string;
  /** The Solidity type of a value within an EIP-712 data structure. */
  type?: string;
};

/**
 * EIP-712 compliant map of model names to model definitions.
 */
export type SignEvmTypedDataFieldCriterionTypesTypes = {
  [key: string]: SignEvmTypedDataFieldCriterionTypesTypesItem[];
};

/**
 * An object containing EIP-712 type definitions, as well as a primary type for the root message object.
 */
export type SignEvmTypedDataFieldCriterionTypes = {
  /** EIP-712 compliant map of model names to model definitions. */
  types: SignEvmTypedDataFieldCriterionTypesTypes;
  /** The name of the root EIP-712 type. This value must be included in the `types` object. */
  primaryType: string;
};

export type SignEvmTypedDataFieldCriterionConditionsItem =
  | EvmTypedAddressCondition
  | EvmTypedNumericalCondition
  | EvmTypedStringCondition;

export interface SignEvmTypedDataFieldCriterion {
  /** The type of criterion to use. This should be `evmTypedDataField`. */
  type: SignEvmTypedDataFieldCriterionType;
  /** An object containing EIP-712 type definitions, as well as a primary type for the root message object. */
  types: SignEvmTypedDataFieldCriterionTypes;
  /** A list of conditions to check against the data being signed. Each condition must be met for the rule to take effect. */
  conditions: SignEvmTypedDataFieldCriterionConditionsItem[];
}

/**
 * The type of criterion to use. This should be `evmTypedDataVerifyingContract`.
 */
export type SignEvmTypedDataVerifyingContractCriterionType =
  (typeof SignEvmTypedDataVerifyingContractCriterionType)[keyof typeof SignEvmTypedDataVerifyingContractCriterionType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignEvmTypedDataVerifyingContractCriterionType = {
  evmTypedDataVerifyingContract: "evmTypedDataVerifyingContract",
} as const;

/**
 * The operator to use for the comparison. The domain's verifying contract will be on the left-hand side of the operator, and the `addresses` field will be on the right-hand side.
 */
export type SignEvmTypedDataVerifyingContractCriterionOperator =
  (typeof SignEvmTypedDataVerifyingContractCriterionOperator)[keyof typeof SignEvmTypedDataVerifyingContractCriterionOperator];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignEvmTypedDataVerifyingContractCriterionOperator = {
  in: "in",
  not_in: "not in",
} as const;

/**
 * A schema for specifying criterion for a domain's verifying contract.
 */
export interface SignEvmTypedDataVerifyingContractCriterion {
  /** The type of criterion to use. This should be `evmTypedDataVerifyingContract`. */
  type: SignEvmTypedDataVerifyingContractCriterionType;
  /** A list of 0x-prefixed EVM addresses that the domain's verifying contract should be compared to. There is a limit of 300 addresses per criterion. */
  addresses: string[];
  /** The operator to use for the comparison. The domain's verifying contract will be on the left-hand side of the operator, and the `addresses` field will be on the right-hand side. */
  operator: SignEvmTypedDataVerifyingContractCriterionOperator;
}

export type SignEvmTypedDataCriteriaItem =
  | SignEvmTypedDataFieldCriterion
  | SignEvmTypedDataVerifyingContractCriterion;

/**
 * A schema for specifying criteria for the SignEvmTypedData operation.
 */
export type SignEvmTypedDataCriteria = SignEvmTypedDataCriteriaItem[];

/**
 * Whether matching the rule will cause the request to be rejected or accepted.
 */
export type SignEvmTypedDataRuleAction =
  (typeof SignEvmTypedDataRuleAction)[keyof typeof SignEvmTypedDataRuleAction];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignEvmTypedDataRuleAction = {
  reject: "reject",
  accept: "accept",
} as const;

/**
 * The operation to which the rule applies. Every element of the `criteria` array must match the specified operation.
 */
export type SignEvmTypedDataRuleOperation =
  (typeof SignEvmTypedDataRuleOperation)[keyof typeof SignEvmTypedDataRuleOperation];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignEvmTypedDataRuleOperation = {
  signEvmTypedData: "signEvmTypedData",
} as const;

export interface SignEvmTypedDataRule {
  /** Whether matching the rule will cause the request to be rejected or accepted. */
  action: SignEvmTypedDataRuleAction;
  /** The operation to which the rule applies. Every element of the `criteria` array must match the specified operation. */
  operation: SignEvmTypedDataRuleOperation;
  criteria: SignEvmTypedDataCriteria;
}

/**
 * The type of criterion to use. This should be `solAddress`.
 */
export type SolAddressCriterionType =
  (typeof SolAddressCriterionType)[keyof typeof SolAddressCriterionType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SolAddressCriterionType = {
  solAddress: "solAddress",
} as const;

/**
 * The operator to use for the comparison. Each of the native transfer recipient addresses in the transaction's `accountKeys` (for legacy transactions) or `staticAccountKeys` (for V0 transactions) array will be on the left-hand side of the operator, and the `addresses` field will be on the right-hand side.
 */
export type SolAddressCriterionOperator =
  (typeof SolAddressCriterionOperator)[keyof typeof SolAddressCriterionOperator];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SolAddressCriterionOperator = {
  in: "in",
  not_in: "not in",
} as const;

/**
 * The criterion for the recipient addresses of a Solana transaction's native transfer instruction.
 */
export interface SolAddressCriterion {
  /** The type of criterion to use. This should be `solAddress`. */
  type: SolAddressCriterionType;
  /** The Solana addresses that are compared to the list of native transfer recipient addresses in the transaction's `accountKeys` (for legacy transactions) or `staticAccountKeys` (for V0 transactions) array. */
  addresses: string[];
  /** The operator to use for the comparison. Each of the native transfer recipient addresses in the transaction's `accountKeys` (for legacy transactions) or `staticAccountKeys` (for V0 transactions) array will be on the left-hand side of the operator, and the `addresses` field will be on the right-hand side. */
  operator: SolAddressCriterionOperator;
}

/**
 * The type of criterion to use. This should be `solValue`.
 */
export type SolValueCriterionType =
  (typeof SolValueCriterionType)[keyof typeof SolValueCriterionType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SolValueCriterionType = {
  solValue: "solValue",
} as const;

/**
 * The operator to use for the comparison. The transaction instruction's `value` field will be on the left-hand side of the operator, and the `solValue` field will be on the right-hand side.
 */
export type SolValueCriterionOperator =
  (typeof SolValueCriterionOperator)[keyof typeof SolValueCriterionOperator];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SolValueCriterionOperator = {
  ">": ">",
  ">=": ">=",
  "<": "<",
  "<=": "<=",
  "==": "==",
} as const;

/**
 * The criterion for the SOL value in lamports of a native transfer instruction in a Solana transaction.
 */
export interface SolValueCriterion {
  /** The type of criterion to use. This should be `solValue`. */
  type: SolValueCriterionType;
  /** The amount of SOL in lamports that the transaction instruction's `value` field should be compared to. */
  solValue: string;
  /** The operator to use for the comparison. The transaction instruction's `value` field will be on the left-hand side of the operator, and the `solValue` field will be on the right-hand side. */
  operator: SolValueCriterionOperator;
}

/**
 * The type of criterion to use. This should be `splAddress`.
 */
export type SplAddressCriterionType =
  (typeof SplAddressCriterionType)[keyof typeof SplAddressCriterionType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SplAddressCriterionType = {
  splAddress: "splAddress",
} as const;

/**
 * The operator to use for the comparison. Each of the SPL token transfer recipient addresses in the transaction's `accountKeys` (for legacy transactions) or `staticAccountKeys` (for V0 transactions) array will be on the left-hand side of the operator, and the `addresses` field will be on the right-hand side.
 */
export type SplAddressCriterionOperator =
  (typeof SplAddressCriterionOperator)[keyof typeof SplAddressCriterionOperator];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SplAddressCriterionOperator = {
  in: "in",
  not_in: "not in",
} as const;

/**
 * The criterion for the recipient addresses of a Solana transaction's SPL token transfer instructions.
 */
export interface SplAddressCriterion {
  /** The type of criterion to use. This should be `splAddress`. */
  type: SplAddressCriterionType;
  /** The Solana addresses that are compared to the list of SPL token transfer recipient addresses in the transaction's `accountKeys` (for legacy transactions) or `staticAccountKeys` (for V0 transactions) array. */
  addresses: string[];
  /** The operator to use for the comparison. Each of the SPL token transfer recipient addresses in the transaction's `accountKeys` (for legacy transactions) or `staticAccountKeys` (for V0 transactions) array will be on the left-hand side of the operator, and the `addresses` field will be on the right-hand side. */
  operator: SplAddressCriterionOperator;
}

/**
 * The type of criterion to use. This should be `splValue`.
 */
export type SplValueCriterionType =
  (typeof SplValueCriterionType)[keyof typeof SplValueCriterionType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SplValueCriterionType = {
  splValue: "splValue",
} as const;

/**
 * The operator to use for the comparison. The transaction instruction's `value` field will be on the left-hand side of the operator, and the `splValue` field will be on the right-hand side.
 */
export type SplValueCriterionOperator =
  (typeof SplValueCriterionOperator)[keyof typeof SplValueCriterionOperator];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SplValueCriterionOperator = {
  ">": ">",
  ">=": ">=",
  "<": "<",
  "<=": "<=",
  "==": "==",
} as const;

/**
 * The criterion for the SPL token value of a SPL token transfer instruction in a Solana transaction.
 */
export interface SplValueCriterion {
  /** The type of criterion to use. This should be `splValue`. */
  type: SplValueCriterionType;
  /** The amount of the SPL token that the transaction instruction's `value` field should be compared to. */
  splValue: string;
  /** The operator to use for the comparison. The transaction instruction's `value` field will be on the left-hand side of the operator, and the `splValue` field will be on the right-hand side. */
  operator: SplValueCriterionOperator;
}

/**
 * The type of criterion to use. This should be `mintAddress`.
 */
export type MintAddressCriterionType =
  (typeof MintAddressCriterionType)[keyof typeof MintAddressCriterionType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const MintAddressCriterionType = {
  mintAddress: "mintAddress",
} as const;

/**
 * The operator to use for the comparison. Each of the token mint addresses in the transaction's `accountKeys` (for legacy transactions) or `staticAccountKeys` (for V0 transactions) array will be on the left-hand side of the operator, and the `addresses` field will be on the right-hand side.
 */
export type MintAddressCriterionOperator =
  (typeof MintAddressCriterionOperator)[keyof typeof MintAddressCriterionOperator];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const MintAddressCriterionOperator = {
  in: "in",
  not_in: "not in",
} as const;

/**
 * The criterion for the token mint addresses of a Solana transaction's SPL token transfer instructions.
 */
export interface MintAddressCriterion {
  /** The type of criterion to use. This should be `mintAddress`. */
  type: MintAddressCriterionType;
  /** The Solana addresses that are compared to the list of token mint addresses in the transaction's `accountKeys` (for legacy transactions) or `staticAccountKeys` (for V0 transactions) array. */
  addresses: string[];
  /** The operator to use for the comparison. Each of the token mint addresses in the transaction's `accountKeys` (for legacy transactions) or `staticAccountKeys` (for V0 transactions) array will be on the left-hand side of the operator, and the `addresses` field will be on the right-hand side. */
  operator: MintAddressCriterionOperator;
}

/**
 * A reference to an established Solana program. When referencing a `KnownIdlType` within a policy rule configuring an `SolDataCriterion`, criteria will decode instruction data as documented in the programs. For more information on supported programs, see the links below.
  - [SystemProgram](https://docs.rs/solana-program/latest/solana_program/system_instruction/enum.SystemInstruction.html).
  - [TokenProgram](https://docs.rs/spl-token/latest/spl_token/instruction/enum.TokenInstruction.html).
  - [AssociatedTokenProgram](https://docs.rs/spl-associated-token-account/latest/spl_associated_token_account/instruction/index.html).
 */
export type KnownIdlType = (typeof KnownIdlType)[keyof typeof KnownIdlType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const KnownIdlType = {
  SystemProgram: "SystemProgram",
  TokenProgram: "TokenProgram",
  AssociatedTokenProgram: "AssociatedTokenProgram",
} as const;

export type IdlInstructionsItemArgsItem = {
  /** The argument name. */
  name: string;
  /** The argument type. */
  type: string;
};

export type IdlInstructionsItemAccountsItem = {
  /** The account name. */
  name: string;
  /** Whether the account is writable. */
  writable?: boolean;
  /** Whether the account must be a signer. */
  signer?: boolean;
};

export type IdlInstructionsItem = {
  /** The instruction name. */
  name: string;
  /**
   * Array of 8 numbers representing the instruction discriminator.
   * @minItems 8
   * @maxItems 8
   */
  discriminator: number[];
  /** List of instruction arguments. */
  args: IdlInstructionsItemArgsItem[];
  /** Optional list of accounts required by the instruction. */
  accounts?: IdlInstructionsItemAccountsItem[];
};

/**
 * Optional metadata about the IDL.
 */
export type IdlMetadata = {
  /** The program name. */
  name?: string;
  /** The program version. */
  version?: string;
  /** The IDL specification version. */
  spec?: string;
};

export type IdlTypesItem = { [key: string]: unknown };

/**
 * IDL Specification following Anchor's IDL format v0.30+.
 */
export interface Idl {
  /** The program address. */
  address: string;
  /** List of program instructions. */
  instructions: IdlInstructionsItem[];
  /** Optional metadata about the IDL. */
  metadata?: IdlMetadata;
  /** Optional type definitions for custom data structures used in the program. */
  types?: IdlTypesItem[];
}

/**
 * The operator to use for the comparison. The value resolved at the `name` will be on the left-hand side of the operator, and the `value` field will be on the right-hand side.
 */
export type SolDataParameterConditionOperator =
  (typeof SolDataParameterConditionOperator)[keyof typeof SolDataParameterConditionOperator];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SolDataParameterConditionOperator = {
  ">": ">",
  ">=": ">=",
  "<": "<",
  "<=": "<=",
  "==": "==",
} as const;

/**
 * A single parameter condition to apply against a specific instruction's parameters.
 */
export interface SolDataParameterCondition {
  /** The parameter name. */
  name: string;
  /** The operator to use for the comparison. The value resolved at the `name` will be on the left-hand side of the operator, and the `value` field will be on the right-hand side. */
  operator: SolDataParameterConditionOperator;
  /** The value to compare against. */
  value: string;
}

/**
 * The operator to use for the comparison. The value resolved at the `name` will be on the left-hand side of the operator, and the `value` field will be on the right-hand side.
 */
export type SolDataParameterConditionListOperator =
  (typeof SolDataParameterConditionListOperator)[keyof typeof SolDataParameterConditionListOperator];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SolDataParameterConditionListOperator = {
  in: "in",
  not_in: "not in",
} as const;

/**
 * A single parameter condition to apply against a specific instruction's parameters.
 */
export interface SolDataParameterConditionList {
  /** The parameter name. */
  name: string;
  /** The operator to use for the comparison. The value resolved at the `name` will be on the left-hand side of the operator, and the `value` field will be on the right-hand side. */
  operator: SolDataParameterConditionListOperator;
  /** The values to compare against. */
  values: string[];
}

/**
 * A list of parameter conditions to apply against a specific instruction's data.
 */
export type SolDataConditionParamsItem = SolDataParameterCondition | SolDataParameterConditionList;

/**
 * A single condition to apply against a specific instruction type and its parameters.
 */
export interface SolDataCondition {
  /** The instruction name. */
  instruction: string;
  /** Parameter conditions for the instruction. */
  params?: SolDataConditionParamsItem[];
}

/**
 * The type of criterion to use. This should be `solData`.
 */
export type SolDataCriterionType = (typeof SolDataCriterionType)[keyof typeof SolDataCriterionType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SolDataCriterionType = {
  solData: "solData",
} as const;

export type SolDataCriterionIdlsItem = KnownIdlType | Idl;

/**
 * A schema for specifying criterion for instruction data in a Solana transaction.
 */
export interface SolDataCriterion {
  /** The type of criterion to use. This should be `solData`. */
  type: SolDataCriterionType;
  /** List of IDL specifications. Can contain known program names (strings) or custom IDL objects. */
  idls: SolDataCriterionIdlsItem[];
  /** A list of conditions to apply against the transaction instruction. Only one condition must evaluate to true for this criterion to be met. */
  conditions: SolDataCondition[];
}

/**
 * The type of criterion to use. This should be `programId`.
 */
export type ProgramIdCriterionType =
  (typeof ProgramIdCriterionType)[keyof typeof ProgramIdCriterionType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const ProgramIdCriterionType = {
  programId: "programId",
} as const;

/**
 * The operator to use for the comparison. Each of the program IDs in the transaction's instructions will be on the left-hand side of the operator, and the `programIds` field will be on the right-hand side.
 */
export type ProgramIdCriterionOperator =
  (typeof ProgramIdCriterionOperator)[keyof typeof ProgramIdCriterionOperator];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const ProgramIdCriterionOperator = {
  in: "in",
  not_in: "not in",
} as const;

/**
 * The criterion for the program IDs of a Solana transaction's instructions.
 */
export interface ProgramIdCriterion {
  /** The type of criterion to use. This should be `programId`. */
  type: ProgramIdCriterionType;
  /** The Solana program IDs that are compared to the list of program IDs in the transaction's instructions. */
  programIds: string[];
  /** The operator to use for the comparison. Each of the program IDs in the transaction's instructions will be on the left-hand side of the operator, and the `programIds` field will be on the right-hand side. */
  operator: ProgramIdCriterionOperator;
}

export type SignSolTransactionCriteriaItem =
  | SolAddressCriterion
  | SolValueCriterion
  | SplAddressCriterion
  | SplValueCriterion
  | MintAddressCriterion
  | SolDataCriterion
  | ProgramIdCriterion;

/**
 * A schema for specifying criteria for the SignSolTransaction operation.
 */
export type SignSolTransactionCriteria = SignSolTransactionCriteriaItem[];

/**
 * Whether matching the rule will cause the request to be rejected or accepted.
 */
export type SignSolTransactionRuleAction =
  (typeof SignSolTransactionRuleAction)[keyof typeof SignSolTransactionRuleAction];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignSolTransactionRuleAction = {
  reject: "reject",
  accept: "accept",
} as const;

/**
 * The operation to which the rule applies. Every element of the `criteria` array must match the specified operation.
 */
export type SignSolTransactionRuleOperation =
  (typeof SignSolTransactionRuleOperation)[keyof typeof SignSolTransactionRuleOperation];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignSolTransactionRuleOperation = {
  signSolTransaction: "signSolTransaction",
} as const;

export interface SignSolTransactionRule {
  /** Whether matching the rule will cause the request to be rejected or accepted. */
  action: SignSolTransactionRuleAction;
  /** The operation to which the rule applies. Every element of the `criteria` array must match the specified operation. */
  operation: SignSolTransactionRuleOperation;
  criteria: SignSolTransactionCriteria;
}

/**
 * The type of criterion to use. This should be `solNetwork`.
 */
export type SolNetworkCriterionType =
  (typeof SolNetworkCriterionType)[keyof typeof SolNetworkCriterionType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SolNetworkCriterionType = {
  solNetwork: "solNetwork",
} as const;

/**
 * The Solana network the transaction is for.
 */
export type SolNetworkCriterionNetworksItem =
  (typeof SolNetworkCriterionNetworksItem)[keyof typeof SolNetworkCriterionNetworksItem];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SolNetworkCriterionNetworksItem = {
  "solana-devnet": "solana-devnet",
  solana: "solana",
} as const;

/**
 * The operator to use for the comparison. The transaction's intended network will be on the left-hand side of the operator, and the `networks` field will be on the right-hand side.
 */
export type SolNetworkCriterionOperator =
  (typeof SolNetworkCriterionOperator)[keyof typeof SolNetworkCriterionOperator];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SolNetworkCriterionOperator = {
  in: "in",
  not_in: "not in",
} as const;

/**
 * The criterion for the Solana network of a transaction.
 */
export interface SolNetworkCriterion {
  /** The type of criterion to use. This should be `solNetwork`. */
  type: SolNetworkCriterionType;
  /** The Solana networks that the transaction's intended network should be compared to. */
  networks: SolNetworkCriterionNetworksItem[];
  /** The operator to use for the comparison. The transaction's intended network will be on the left-hand side of the operator, and the `networks` field will be on the right-hand side. */
  operator: SolNetworkCriterionOperator;
}

export type SendSolTransactionCriteriaItem =
  | SolAddressCriterion
  | SolValueCriterion
  | SplAddressCriterion
  | SplValueCriterion
  | MintAddressCriterion
  | SolDataCriterion
  | ProgramIdCriterion
  | SolNetworkCriterion;

/**
 * A schema for specifying criteria for the SendSolTransaction operation.
 */
export type SendSolTransactionCriteria = SendSolTransactionCriteriaItem[];

/**
 * Whether matching the rule will cause the request to be rejected or accepted.
 */
export type SendSolTransactionRuleAction =
  (typeof SendSolTransactionRuleAction)[keyof typeof SendSolTransactionRuleAction];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SendSolTransactionRuleAction = {
  reject: "reject",
  accept: "accept",
} as const;

/**
 * The operation to which the rule applies. Every element of the `criteria` array must match the specified operation.
 */
export type SendSolTransactionRuleOperation =
  (typeof SendSolTransactionRuleOperation)[keyof typeof SendSolTransactionRuleOperation];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SendSolTransactionRuleOperation = {
  sendSolTransaction: "sendSolTransaction",
} as const;

export interface SendSolTransactionRule {
  /** Whether matching the rule will cause the request to be rejected or accepted. */
  action: SendSolTransactionRuleAction;
  /** The operation to which the rule applies. Every element of the `criteria` array must match the specified operation. */
  operation: SendSolTransactionRuleOperation;
  criteria: SendSolTransactionCriteria;
}

/**
 * The type of criterion to use. This should be `solMessage`.
 */
export type SolMessageCriterionType =
  (typeof SolMessageCriterionType)[keyof typeof SolMessageCriterionType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SolMessageCriterionType = {
  solMessage: "solMessage",
} as const;

/**
 * The criterion for the message of a Solana transaction.
 */
export interface SolMessageCriterion {
  /** The type of criterion to use. This should be `solMessage`. */
  type: SolMessageCriterionType;
  /** A regular expression the field is matched against. */
  match: string;
}

/**
 * A schema for specifying criteria for the SignSolMessage operation.
 */
export type SignSolMessageCriteria = SolMessageCriterion[];

/**
 * Whether matching the rule will cause the request to be rejected or accepted.
 */
export type SignSolMessageRuleAction =
  (typeof SignSolMessageRuleAction)[keyof typeof SignSolMessageRuleAction];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignSolMessageRuleAction = {
  reject: "reject",
  accept: "accept",
} as const;

/**
 * The operation to which the rule applies. Every element of the `criteria` array must match the specified operation.
 */
export type SignSolMessageRuleOperation =
  (typeof SignSolMessageRuleOperation)[keyof typeof SignSolMessageRuleOperation];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignSolMessageRuleOperation = {
  signSolMessage: "signSolMessage",
} as const;

export interface SignSolMessageRule {
  /** Whether matching the rule will cause the request to be rejected or accepted. */
  action: SignSolMessageRuleAction;
  /** The operation to which the rule applies. Every element of the `criteria` array must match the specified operation. */
  operation: SignSolMessageRuleOperation;
  criteria: SignSolMessageCriteria;
}

/**
 * Whether any attempts to sign a hash will be accepted or rejected. This rule does not accept any criteria.
 */
export type SignEvmHashRuleAction =
  (typeof SignEvmHashRuleAction)[keyof typeof SignEvmHashRuleAction];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignEvmHashRuleAction = {
  reject: "reject",
  accept: "accept",
} as const;

/**
 * The operation to which the rule applies.
 */
export type SignEvmHashRuleOperation =
  (typeof SignEvmHashRuleOperation)[keyof typeof SignEvmHashRuleOperation];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignEvmHashRuleOperation = {
  signEvmHash: "signEvmHash",
} as const;

export interface SignEvmHashRule {
  /** Whether any attempts to sign a hash will be accepted or rejected. This rule does not accept any criteria. */
  action: SignEvmHashRuleAction;
  /** The operation to which the rule applies. */
  operation: SignEvmHashRuleOperation;
}

export type PrepareUserOperationCriteriaItem =
  | EthValueCriterion
  | EvmAddressCriterion
  | EvmNetworkCriterion
  | EvmDataCriterion
  | NetUSDChangeCriterion;

/**
 * A schema for specifying criteria for the PrepareUserOperation operation.
 */
export type PrepareUserOperationCriteria = PrepareUserOperationCriteriaItem[];

/**
 * Whether matching the rule will cause the request to be rejected or accepted.
 */
export type PrepareUserOperationRuleAction =
  (typeof PrepareUserOperationRuleAction)[keyof typeof PrepareUserOperationRuleAction];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const PrepareUserOperationRuleAction = {
  reject: "reject",
  accept: "accept",
} as const;

/**
 * The operation to which the rule applies. Every element of the `criteria` array must match the specified operation.
 */
export type PrepareUserOperationRuleOperation =
  (typeof PrepareUserOperationRuleOperation)[keyof typeof PrepareUserOperationRuleOperation];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const PrepareUserOperationRuleOperation = {
  prepareUserOperation: "prepareUserOperation",
} as const;

export interface PrepareUserOperationRule {
  /** Whether matching the rule will cause the request to be rejected or accepted. */
  action: PrepareUserOperationRuleAction;
  /** The operation to which the rule applies. Every element of the `criteria` array must match the specified operation. */
  operation: PrepareUserOperationRuleOperation;
  criteria: PrepareUserOperationCriteria;
}

export type SendUserOperationCriteriaItem =
  | EthValueCriterion
  | EvmAddressCriterion
  | EvmNetworkCriterion
  | EvmDataCriterion
  | NetUSDChangeCriterion;

/**
 * A schema for specifying criteria for the SendUserOperation operation.
 */
export type SendUserOperationCriteria = SendUserOperationCriteriaItem[];

/**
 * Whether matching the rule will cause the request to be rejected or accepted.
 */
export type SendUserOperationRuleAction =
  (typeof SendUserOperationRuleAction)[keyof typeof SendUserOperationRuleAction];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SendUserOperationRuleAction = {
  reject: "reject",
  accept: "accept",
} as const;

/**
 * The operation to which the rule applies. Every element of the `criteria` array must match the specified operation.
 */
export type SendUserOperationRuleOperation =
  (typeof SendUserOperationRuleOperation)[keyof typeof SendUserOperationRuleOperation];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SendUserOperationRuleOperation = {
  sendUserOperation: "sendUserOperation",
} as const;

export interface SendUserOperationRule {
  /** Whether matching the rule will cause the request to be rejected or accepted. */
  action: SendUserOperationRuleAction;
  /** The operation to which the rule applies. Every element of the `criteria` array must match the specified operation. */
  operation: SendUserOperationRuleOperation;
  criteria: SendUserOperationCriteria;
}

export type SignEndUserEvmTransactionCriteriaItem =
  | EthValueCriterion
  | EvmAddressCriterion
  | EvmDataCriterion
  | NetUSDChangeCriterion;

/**
 * A schema for specifying criteria for the signEndUserEvmTransaction operation.
 */
export type SignEndUserEvmTransactionCriteria = SignEndUserEvmTransactionCriteriaItem[];

/**
 * Whether matching the rule will cause the request to be rejected or accepted.
 */
export type SignEndUserEvmTransactionRuleAction =
  (typeof SignEndUserEvmTransactionRuleAction)[keyof typeof SignEndUserEvmTransactionRuleAction];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignEndUserEvmTransactionRuleAction = {
  reject: "reject",
  accept: "accept",
} as const;

/**
 * The operation to which the rule applies. Every element of the `criteria` array must match the specified operation.
 */
export type SignEndUserEvmTransactionRuleOperation =
  (typeof SignEndUserEvmTransactionRuleOperation)[keyof typeof SignEndUserEvmTransactionRuleOperation];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignEndUserEvmTransactionRuleOperation = {
  signEndUserEvmTransaction: "signEndUserEvmTransaction",
} as const;

export interface SignEndUserEvmTransactionRule {
  /** Whether matching the rule will cause the request to be rejected or accepted. */
  action: SignEndUserEvmTransactionRuleAction;
  /** The operation to which the rule applies. Every element of the `criteria` array must match the specified operation. */
  operation: SignEndUserEvmTransactionRuleOperation;
  criteria: SignEndUserEvmTransactionCriteria;
}

export type SendEndUserEvmTransactionCriteriaItem =
  | EthValueCriterion
  | EvmAddressCriterion
  | EvmNetworkCriterion
  | EvmDataCriterion
  | NetUSDChangeCriterion;

/**
 * A schema for specifying criteria for the sendEndUserEvmTransaction operation.
 */
export type SendEndUserEvmTransactionCriteria = SendEndUserEvmTransactionCriteriaItem[];

/**
 * Whether matching the rule will cause the request to be rejected or accepted.
 */
export type SendEndUserEvmTransactionRuleAction =
  (typeof SendEndUserEvmTransactionRuleAction)[keyof typeof SendEndUserEvmTransactionRuleAction];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SendEndUserEvmTransactionRuleAction = {
  reject: "reject",
  accept: "accept",
} as const;

/**
 * The operation to which the rule applies. Every element of the `criteria` array must match the specified operation.
 */
export type SendEndUserEvmTransactionRuleOperation =
  (typeof SendEndUserEvmTransactionRuleOperation)[keyof typeof SendEndUserEvmTransactionRuleOperation];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SendEndUserEvmTransactionRuleOperation = {
  sendEndUserEvmTransaction: "sendEndUserEvmTransaction",
} as const;

export interface SendEndUserEvmTransactionRule {
  /** Whether matching the rule will cause the request to be rejected or accepted. */
  action: SendEndUserEvmTransactionRuleAction;
  /** The operation to which the rule applies. Every element of the `criteria` array must match the specified operation. */
  operation: SendEndUserEvmTransactionRuleOperation;
  criteria: SendEndUserEvmTransactionCriteria;
}

/**
 * A schema for specifying criteria for the signEndUserEvmMessage operation.
 */
export type SignEndUserEvmMessageCriteria = EvmMessageCriterion[];

/**
 * Whether matching the rule will cause the request to be rejected or accepted.
 */
export type SignEndUserEvmMessageRuleAction =
  (typeof SignEndUserEvmMessageRuleAction)[keyof typeof SignEndUserEvmMessageRuleAction];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignEndUserEvmMessageRuleAction = {
  reject: "reject",
  accept: "accept",
} as const;

/**
 * The operation to which the rule applies. Every element of the `criteria` array must match the specified operation.
 */
export type SignEndUserEvmMessageRuleOperation =
  (typeof SignEndUserEvmMessageRuleOperation)[keyof typeof SignEndUserEvmMessageRuleOperation];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignEndUserEvmMessageRuleOperation = {
  signEndUserEvmMessage: "signEndUserEvmMessage",
} as const;

export interface SignEndUserEvmMessageRule {
  /** Whether matching the rule will cause the request to be rejected or accepted. */
  action: SignEndUserEvmMessageRuleAction;
  /** The operation to which the rule applies. Every element of the `criteria` array must match the specified operation. */
  operation: SignEndUserEvmMessageRuleOperation;
  criteria: SignEndUserEvmMessageCriteria;
}

export type SignEndUserEvmTypedDataCriteriaItem =
  | SignEvmTypedDataFieldCriterion
  | SignEvmTypedDataVerifyingContractCriterion;

/**
 * A schema for specifying criteria for the signEndUserEvmTypedData operation.
 */
export type SignEndUserEvmTypedDataCriteria = SignEndUserEvmTypedDataCriteriaItem[];

/**
 * Whether matching the rule will cause the request to be rejected or accepted.
 */
export type SignEndUserEvmTypedDataRuleAction =
  (typeof SignEndUserEvmTypedDataRuleAction)[keyof typeof SignEndUserEvmTypedDataRuleAction];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignEndUserEvmTypedDataRuleAction = {
  reject: "reject",
  accept: "accept",
} as const;

/**
 * The operation to which the rule applies. Every element of the `criteria` array must match the specified operation.
 */
export type SignEndUserEvmTypedDataRuleOperation =
  (typeof SignEndUserEvmTypedDataRuleOperation)[keyof typeof SignEndUserEvmTypedDataRuleOperation];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignEndUserEvmTypedDataRuleOperation = {
  signEndUserEvmTypedData: "signEndUserEvmTypedData",
} as const;

export interface SignEndUserEvmTypedDataRule {
  /** Whether matching the rule will cause the request to be rejected or accepted. */
  action: SignEndUserEvmTypedDataRuleAction;
  /** The operation to which the rule applies. Every element of the `criteria` array must match the specified operation. */
  operation: SignEndUserEvmTypedDataRuleOperation;
  criteria: SignEndUserEvmTypedDataCriteria;
}

/**
 * Whether any attempts to sign a hash will be accepted or rejected. This rule does not accept any criteria.
 */
export type SignEndUserEvmHashRuleAction =
  (typeof SignEndUserEvmHashRuleAction)[keyof typeof SignEndUserEvmHashRuleAction];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignEndUserEvmHashRuleAction = {
  reject: "reject",
  accept: "accept",
} as const;

/**
 * The operation to which the rule applies.
 */
export type SignEndUserEvmHashRuleOperation =
  (typeof SignEndUserEvmHashRuleOperation)[keyof typeof SignEndUserEvmHashRuleOperation];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignEndUserEvmHashRuleOperation = {
  signEndUserEvmHash: "signEndUserEvmHash",
} as const;

export interface SignEndUserEvmHashRule {
  /** Whether any attempts to sign a hash will be accepted or rejected. This rule does not accept any criteria. */
  action: SignEndUserEvmHashRuleAction;
  /** The operation to which the rule applies. */
  operation: SignEndUserEvmHashRuleOperation;
}

export type SignEndUserSolTransactionCriteriaItem =
  | SolAddressCriterion
  | SolValueCriterion
  | SplAddressCriterion
  | SplValueCriterion
  | MintAddressCriterion
  | SolDataCriterion
  | ProgramIdCriterion;

/**
 * A schema for specifying criteria for the signEndUserSolTransaction operation.
 */
export type SignEndUserSolTransactionCriteria = SignEndUserSolTransactionCriteriaItem[];

/**
 * Whether matching the rule will cause the request to be rejected or accepted.
 */
export type SignEndUserSolTransactionRuleAction =
  (typeof SignEndUserSolTransactionRuleAction)[keyof typeof SignEndUserSolTransactionRuleAction];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignEndUserSolTransactionRuleAction = {
  reject: "reject",
  accept: "accept",
} as const;

/**
 * The operation to which the rule applies. Every element of the `criteria` array must match the specified operation.
 */
export type SignEndUserSolTransactionRuleOperation =
  (typeof SignEndUserSolTransactionRuleOperation)[keyof typeof SignEndUserSolTransactionRuleOperation];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignEndUserSolTransactionRuleOperation = {
  signEndUserSolTransaction: "signEndUserSolTransaction",
} as const;

export interface SignEndUserSolTransactionRule {
  /** Whether matching the rule will cause the request to be rejected or accepted. */
  action: SignEndUserSolTransactionRuleAction;
  /** The operation to which the rule applies. Every element of the `criteria` array must match the specified operation. */
  operation: SignEndUserSolTransactionRuleOperation;
  criteria: SignEndUserSolTransactionCriteria;
}

export type SendEndUserSolTransactionCriteriaItem =
  | SolAddressCriterion
  | SolValueCriterion
  | SplAddressCriterion
  | SplValueCriterion
  | MintAddressCriterion
  | SolDataCriterion
  | ProgramIdCriterion
  | SolNetworkCriterion;

/**
 * A schema for specifying criteria for the sendEndUserSolTransaction operation.
 */
export type SendEndUserSolTransactionCriteria = SendEndUserSolTransactionCriteriaItem[];

/**
 * Whether matching the rule will cause the request to be rejected or accepted.
 */
export type SendEndUserSolTransactionRuleAction =
  (typeof SendEndUserSolTransactionRuleAction)[keyof typeof SendEndUserSolTransactionRuleAction];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SendEndUserSolTransactionRuleAction = {
  reject: "reject",
  accept: "accept",
} as const;

/**
 * The operation to which the rule applies. Every element of the `criteria` array must match the specified operation.
 */
export type SendEndUserSolTransactionRuleOperation =
  (typeof SendEndUserSolTransactionRuleOperation)[keyof typeof SendEndUserSolTransactionRuleOperation];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SendEndUserSolTransactionRuleOperation = {
  sendEndUserSolTransaction: "sendEndUserSolTransaction",
} as const;

export interface SendEndUserSolTransactionRule {
  /** Whether matching the rule will cause the request to be rejected or accepted. */
  action: SendEndUserSolTransactionRuleAction;
  /** The operation to which the rule applies. Every element of the `criteria` array must match the specified operation. */
  operation: SendEndUserSolTransactionRuleOperation;
  criteria: SendEndUserSolTransactionCriteria;
}

/**
 * A schema for specifying criteria for the signEndUserSolMessage operation.
 */
export type SignEndUserSolMessageCriteria = SolMessageCriterion[];

/**
 * Whether matching the rule will cause the request to be rejected or accepted.
 */
export type SignEndUserSolMessageRuleAction =
  (typeof SignEndUserSolMessageRuleAction)[keyof typeof SignEndUserSolMessageRuleAction];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignEndUserSolMessageRuleAction = {
  reject: "reject",
  accept: "accept",
} as const;

/**
 * The operation to which the rule applies. Every element of the `criteria` array must match the specified operation.
 */
export type SignEndUserSolMessageRuleOperation =
  (typeof SignEndUserSolMessageRuleOperation)[keyof typeof SignEndUserSolMessageRuleOperation];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignEndUserSolMessageRuleOperation = {
  signEndUserSolMessage: "signEndUserSolMessage",
} as const;

export interface SignEndUserSolMessageRule {
  /** Whether matching the rule will cause the request to be rejected or accepted. */
  action: SignEndUserSolMessageRuleAction;
  /** The operation to which the rule applies. Every element of the `criteria` array must match the specified operation. */
  operation: SignEndUserSolMessageRuleOperation;
  criteria: SignEndUserSolMessageCriteria;
}

export type SendEndUserEvmAssetCriteriaItem =
  | EvmNetworkCriterion
  | EvmDataCriterion
  | NetUSDChangeCriterion;

/**
 * A schema for specifying criteria for the sendEndUserEvmAsset operation.
 */
export type SendEndUserEvmAssetCriteria = SendEndUserEvmAssetCriteriaItem[];

/**
 * Whether matching the rule will cause the request to be rejected or accepted.
 */
export type SendEndUserEvmAssetRuleAction =
  (typeof SendEndUserEvmAssetRuleAction)[keyof typeof SendEndUserEvmAssetRuleAction];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SendEndUserEvmAssetRuleAction = {
  reject: "reject",
  accept: "accept",
} as const;

/**
 * The operation to which the rule applies. Every element of the `criteria` array must match the specified operation.
 */
export type SendEndUserEvmAssetRuleOperation =
  (typeof SendEndUserEvmAssetRuleOperation)[keyof typeof SendEndUserEvmAssetRuleOperation];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SendEndUserEvmAssetRuleOperation = {
  sendEndUserEvmAsset: "sendEndUserEvmAsset",
} as const;

export interface SendEndUserEvmAssetRule {
  /** Whether matching the rule will cause the request to be rejected or accepted. */
  action: SendEndUserEvmAssetRuleAction;
  /** The operation to which the rule applies. Every element of the `criteria` array must match the specified operation. */
  operation: SendEndUserEvmAssetRuleOperation;
  criteria: SendEndUserEvmAssetCriteria;
}

export type SendEndUserSolAssetCriteriaItem =
  | SplAddressCriterion
  | SplValueCriterion
  | SolDataCriterion
  | SolNetworkCriterion;

/**
 * A schema for specifying criteria for the sendEndUserSolAsset operation.
 */
export type SendEndUserSolAssetCriteria = SendEndUserSolAssetCriteriaItem[];

/**
 * Whether matching the rule will cause the request to be rejected or accepted.
 */
export type SendEndUserSolAssetRuleAction =
  (typeof SendEndUserSolAssetRuleAction)[keyof typeof SendEndUserSolAssetRuleAction];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SendEndUserSolAssetRuleAction = {
  reject: "reject",
  accept: "accept",
} as const;

/**
 * The operation to which the rule applies. Every element of the `criteria` array must match the specified operation.
 */
export type SendEndUserSolAssetRuleOperation =
  (typeof SendEndUserSolAssetRuleOperation)[keyof typeof SendEndUserSolAssetRuleOperation];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SendEndUserSolAssetRuleOperation = {
  sendEndUserSolAsset: "sendEndUserSolAsset",
} as const;

export interface SendEndUserSolAssetRule {
  /** Whether matching the rule will cause the request to be rejected or accepted. */
  action: SendEndUserSolAssetRuleAction;
  /** The operation to which the rule applies. Every element of the `criteria` array must match the specified operation. */
  operation: SendEndUserSolAssetRuleOperation;
  criteria: SendEndUserSolAssetCriteria;
}

export type SendEndUserOperationCriteriaItem =
  | EthValueCriterion
  | EvmAddressCriterion
  | EvmNetworkCriterion
  | EvmDataCriterion
  | NetUSDChangeCriterion;

/**
 * A schema for specifying criteria for the sendEndUserOperation operation.
 */
export type SendEndUserOperationCriteria = SendEndUserOperationCriteriaItem[];

/**
 * Whether matching the rule will cause the request to be rejected or accepted.
 */
export type SendEndUserOperationRuleAction =
  (typeof SendEndUserOperationRuleAction)[keyof typeof SendEndUserOperationRuleAction];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SendEndUserOperationRuleAction = {
  reject: "reject",
  accept: "accept",
} as const;

/**
 * The operation to which the rule applies. Every element of the `criteria` array must match the specified operation.
 */
export type SendEndUserOperationRuleOperation =
  (typeof SendEndUserOperationRuleOperation)[keyof typeof SendEndUserOperationRuleOperation];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SendEndUserOperationRuleOperation = {
  sendEndUserOperation: "sendEndUserOperation",
} as const;

export interface SendEndUserOperationRule {
  /** Whether matching the rule will cause the request to be rejected or accepted. */
  action: SendEndUserOperationRuleAction;
  /** The operation to which the rule applies. Every element of the `criteria` array must match the specified operation. */
  operation: SendEndUserOperationRuleOperation;
  criteria: SendEndUserOperationCriteria;
}

export type CreateEndUserEvmSwapCriteriaItem =
  | EvmNetworkCriterion
  | EvmDataCriterion
  | NetUSDChangeCriterion;

/**
 * A schema for specifying criteria for the createEndUserEvmSwap operation.
 */
export type CreateEndUserEvmSwapCriteria = CreateEndUserEvmSwapCriteriaItem[];

/**
 * Whether matching the rule will cause the request to be rejected or accepted.
 */
export type CreateEndUserEvmSwapRuleAction =
  (typeof CreateEndUserEvmSwapRuleAction)[keyof typeof CreateEndUserEvmSwapRuleAction];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const CreateEndUserEvmSwapRuleAction = {
  reject: "reject",
  accept: "accept",
} as const;

/**
 * The operation to which the rule applies. Every element of the `criteria` array must match the specified operation.
 */
export type CreateEndUserEvmSwapRuleOperation =
  (typeof CreateEndUserEvmSwapRuleOperation)[keyof typeof CreateEndUserEvmSwapRuleOperation];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const CreateEndUserEvmSwapRuleOperation = {
  createEndUserEvmSwap: "createEndUserEvmSwap",
} as const;

export interface CreateEndUserEvmSwapRule {
  /** Whether matching the rule will cause the request to be rejected or accepted. */
  action: CreateEndUserEvmSwapRuleAction;
  /** The operation to which the rule applies. Every element of the `criteria` array must match the specified operation. */
  operation: CreateEndUserEvmSwapRuleOperation;
  criteria: CreateEndUserEvmSwapCriteria;
}

/**
 * A rule that limits the behavior of an account.
 */
export type Rule =
  | SignEvmTransactionRule
  | SendEvmTransactionRule
  | SignEvmMessageRule
  | SignEvmTypedDataRule
  | SignSolTransactionRule
  | SendSolTransactionRule
  | SignSolMessageRule
  | SignEvmHashRule
  | PrepareUserOperationRule
  | SendUserOperationRule
  | SignEndUserEvmTransactionRule
  | SendEndUserEvmTransactionRule
  | SignEndUserEvmMessageRule
  | SignEndUserEvmTypedDataRule
  | SignEndUserEvmHashRule
  | SignEndUserSolTransactionRule
  | SendEndUserSolTransactionRule
  | SignEndUserSolMessageRule
  | SendEndUserEvmAssetRule
  | SendEndUserSolAssetRule
  | SendEndUserOperationRule
  | CreateEndUserEvmSwapRule;

/**
 * A list of rules that comprise the policy. Each policy is limited to 100 rules and a total serialized size of 8 MiB.
 */
export type PolicyRules = Rule[];

/**
 * The scope of the policy. Only one project-level policy can exist at any time.
 */
export type PolicyScope = (typeof PolicyScope)[keyof typeof PolicyScope];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const PolicyScope = {
  project: "project",
  account: "account",
} as const;

export interface Policy {
  /**
   * The unique identifier for the policy.
   * @pattern ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$
   */
  id: string;
  /**
   * An optional human-readable description of the policy.
Policy descriptions can consist of alphanumeric characters, spaces, commas, and periods, and be 50 characters or less.
   * @pattern ^[A-Za-z0-9 ,.]{1,50}$
   */
  description?: string;
  /** The scope of the policy. Only one project-level policy can exist at any time. */
  scope: PolicyScope;
  rules: PolicyRules;
  /** The ISO 8601 timestamp at which the Policy was created. */
  createdAt: string;
  /** The ISO 8601 timestamp at which the Policy was last updated. */
  updatedAt: string;
}

export interface SolanaAccount {
  /**
   * The base58 encoded Solana address.
   * @pattern ^[1-9A-HJ-NP-Za-km-z]{32,44}$
   */
  address: string;
  /**
   * An optional name for the account.
Account names can consist of alphanumeric characters and hyphens, and be between 2 and 36 characters long.
Account names are guaranteed to be unique across all Solana accounts in the developer's CDP Project.
   * @pattern ^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$
   */
  name?: string;
  /** The list of policy IDs that apply to the account. This will include both the project-level policy and the account-level policy, if one exists. */
  policies?: string[];
  /** The ISO 8601 UTC timestamp at which the account was created. */
  createdAt?: string;
  /** The ISO 8601 UTC timestamp at which the account was last updated. */
  updatedAt?: string;
}

/**
 * The name of the supported Solana networks in human-readable format.
 */
export type ListSolanaTokenBalancesNetwork =
  (typeof ListSolanaTokenBalancesNetwork)[keyof typeof ListSolanaTokenBalancesNetwork];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const ListSolanaTokenBalancesNetwork = {
  solana: "solana",
  "solana-devnet": "solana-devnet",
} as const;

/**
 * Amount of a given Solana token.
 */
export interface SolanaTokenAmount {
  /**
   * The amount is denominated in the smallest indivisible unit of the token. For SOL, the smallest indivisible unit is lamports (10^-9 SOL). For SPL tokens, the smallest unit is defined by the token's decimals configuration.
   * @pattern ^[0-9]+$
   */
  amount: string;
  /** 'decimals' is the exponential value N that satisfies the equation `amount * 10^-N = standard_denomination`. The standard denomination is the most commonly used denomination for the token.
- For native SOL, `decimals` is 9 (1 SOL = 10^9 lamports). - For SPL tokens, `decimals` is defined in the token's mint configuration. */
  decimals: number;
}

/**
 * General information about a Solana token. Includes the mint address, and other identifying information.
 */
export interface SolanaToken {
  /** The symbol of this token (ex: SOL, USDC, RAY).
The token symbol is not unique. It is possible for two different tokens to have the same symbol.
For the native SOL token, this symbol is "SOL". For SPL tokens, this symbol is defined in the token's metadata.
Not all tokens have a symbol. This field will only be populated when the token has metadata available. */
  symbol?: string;
  /** The name of this token (ex: "Solana", "USD Coin", "Raydium").
The token name is not unique. It is possible for two different tokens to have the same name.
For the native SOL token, this name is "Solana". For SPL tokens, this name is defined in the token's metadata.
Not all tokens have a name. This field will only be populated when the token has metadata available. */
  name?: string;
  /**
   * The mint address of the token.
For native SOL, the mint address is `So11111111111111111111111111111111111111111`. For SPL tokens, this is the mint address where the token is defined.
   * @pattern ^[1-9A-HJ-NP-Za-km-z]{32,44}$
   */
  mintAddress: string;
}

export interface SolanaTokenBalance {
  amount: SolanaTokenAmount;
  token: SolanaToken;
}

/**
 * Enables control over how often queries need to be fully re-executed on the backing store.
This can be useful in scenarios where API calls might be made frequently, API latency is critical, and some freshness lag (ex: 750ms, 2s, 5s) is tolerable.
By default, each query result is returned from cache so long as the result is from an identical query and less than 500ms old. This freshness tolerance can be modified upwards, to a maximum of 900000ms (i.e. 900s, 15m).

 */
export type OnchainDataQueryCache = {
  /**
   * The maximum tolerable staleness of the query result cache in milliseconds. If a previous execution result of an identical query is older than this age, the query will be re-executed. If the data is less than this age, the result will be returned from cache.
   * @minimum 500
   * @maximum 900000
   */
  maxAgeMs?: number;
};

/**
 * Request to execute a SQL query against indexed blockchain data.
 */
export interface OnchainDataQuery {
  /**
   * SQL query to execute against the indexed blockchain data.
   * @minLength 1
   * @maxLength 100000
   */
  sql: string;
  /** Enables control over how often queries need to be fully re-executed on the backing store.
This can be useful in scenarios where API calls might be made frequently, API latency is critical, and some freshness lag (ex: 750ms, 2s, 5s) is tolerable.
By default, each query result is returned from cache so long as the result is from an identical query and less than 500ms old. This freshness tolerance can be modified upwards, to a maximum of 900000ms (i.e. 900s, 15m).
 */
  cache?: OnchainDataQueryCache;
}

/**
 * Row data with column names as keys.
 */
export type OnchainDataResultResultItem = { [key: string]: unknown };

/**
 * Column data type (ClickHouse types).
 */
export type OnchainDataResultSchemaColumnsItemType =
  (typeof OnchainDataResultSchemaColumnsItemType)[keyof typeof OnchainDataResultSchemaColumnsItemType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const OnchainDataResultSchemaColumnsItemType = {
  String: "String",
  UInt8: "UInt8",
  UInt16: "UInt16",
  UInt32: "UInt32",
  UInt64: "UInt64",
  UInt128: "UInt128",
  UInt256: "UInt256",
  Int8: "Int8",
  Int16: "Int16",
  Int32: "Int32",
  Int64: "Int64",
  Int128: "Int128",
  Int256: "Int256",
  Float32: "Float32",
  Float64: "Float64",
  Bool: "Bool",
  Date: "Date",
  DateTime: "DateTime",
  DateTime64: "DateTime64",
  UUID: "UUID",
} as const;

export type OnchainDataResultSchemaColumnsItem = {
  /** Column name. */
  name?: string;
  /** Column data type (ClickHouse types). */
  type?: OnchainDataResultSchemaColumnsItemType;
};

/**
 * Schema information for the query result. This is a derived schema from the query result, so types may not match the underlying table.

 */
export type OnchainDataResultSchema = {
  /** Column definitions. */
  columns?: OnchainDataResultSchemaColumnsItem[];
};

/**
 * Metadata about query execution.
 */
export type OnchainDataResultMetadata = {
  /** Whether the result was served from the query result cache. */
  cached?: boolean;
  /** When the query result was executed against the backing store in RFC 3339 format. */
  executionTimestamp?: string;
  /** Query execution time in milliseconds. */
  executionTimeMs?: number;
  /** Number of rows returned. */
  rowCount?: number;
};

/**
 * Result of executing a SQL query.
 */
export interface OnchainDataResult {
  /** Query result as an array of objects representing rows. */
  result?: OnchainDataResultResultItem[];
  /** Schema information for the query result. This is a derived schema from the query result, so types may not match the underlying table.
   */
  schema?: OnchainDataResultSchema;
  /** Metadata about query execution. */
  metadata?: OnchainDataResultMetadata;
}

/**
 * Schema definition for a table column.
 */
export interface OnchainDataColumnSchema {
  /** Column name. */
  name?: string;
  /** Column data type. */
  type?: string;
  /** Whether this column can contain NULL values. */
  nullable?: boolean;
  /** Human-readable description of the column. */
  description?: Description;
  /** The order of the column in the index. A lower number means the column is more important for the index and should be first in the query. */
  indexOrder?: number;
}

/**
 * Schema definition for a data table.
 */
export interface OnchainDataTableSchema {
  /** The blockchain network database this table belongs to. */
  database?: string;
  /** Table name. */
  table?: string;
  /** Column definitions for this table. */
  columns?: OnchainDataColumnSchema[];
}

/**
 * Schema information for available blockchain data tables.
 */
export interface OnchainDataSchemaResponse {
  /** List of available tables. */
  tables?: OnchainDataTableSchema[];
}

/**
 * Response containing token addresses that an account has received.
 */
export interface AccountTokenAddressesResponse {
  /** The account address that was queried. */
  accountAddress?: string;
  /** List of token contract addresses that the account has received. */
  tokenAddresses?: string[];
  /**
   * Total number of unique token addresses discovered.
   * @minimum 0
   */
  totalCount?: number;
}

/**
 * Blockchain network being monitored.
 */
export type OnchainActivityWebhookResponseLabelsNetwork =
  (typeof OnchainActivityWebhookResponseLabelsNetwork)[keyof typeof OnchainActivityWebhookResponseLabelsNetwork];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const OnchainActivityWebhookResponseLabelsNetwork = {
  "base-mainnet": "base-mainnet",
  "base-sepolia": "base-sepolia",
} as const;

/**
 * Effective labels returned for `onchain.activity.detected` subscriptions.
 */
export interface OnchainActivityWebhookResponseLabels {
  /** Blockchain network being monitored. */
  network: OnchainActivityWebhookResponseLabelsNetwork;
  /** Smart contract address being monitored. */
  contract_address: string;
  /** Decoded contract event name being matched. */
  event_name?: string;
  /** Canonical event signature being matched. */
  event_signature?: string;
  /** Transaction sender address being matched. */
  transaction_from?: string;
  /** Transaction recipient address being matched. */
  transaction_to?: string;
}

/**
 * Blockchain network being monitored.
 */
export type WalletActivityDetectedWebhookResponseLabelsNetwork =
  (typeof WalletActivityDetectedWebhookResponseLabelsNetwork)[keyof typeof WalletActivityDetectedWebhookResponseLabelsNetwork];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const WalletActivityDetectedWebhookResponseLabelsNetwork = {
  "base-mainnet": "base-mainnet",
  "base-sepolia": "base-sepolia",
} as const;

/**
 * Effective labels returned for `wallet.activity.detected` subscriptions.
 */
export type WalletActivityDetectedWebhookResponseLabels =
  | (unknown & {
      /** Blockchain network being monitored. */
      network: WalletActivityDetectedWebhookResponseLabelsNetwork;
      /** Transaction recipient address being matched. */
      "params.to"?: string;
      /** Transaction sender address being matched. */
      "params.from"?: string;
    })
  | (unknown & {
      /** Blockchain network being monitored. */
      network: WalletActivityDetectedWebhookResponseLabelsNetwork;
      /** Transaction recipient address being matched. */
      "params.to"?: string;
      /** Transaction sender address being matched. */
      "params.from"?: string;
    });

/**
 * Blockchain network being monitored.
 */
export type WalletActivityMultiWebhookResponseLabelsNetwork =
  (typeof WalletActivityMultiWebhookResponseLabelsNetwork)[keyof typeof WalletActivityMultiWebhookResponseLabelsNetwork];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const WalletActivityMultiWebhookResponseLabelsNetwork = {
  "base-mainnet": "base-mainnet",
  "base-sepolia": "base-sepolia",
} as const;

/**
 * Effective labels returned for `wallet.activity.multi` subscriptions.
 */
export interface WalletActivityMultiWebhookResponseLabels {
  /** Blockchain network being monitored. */
  network: WalletActivityMultiWebhookResponseLabelsNetwork;
  /** Comma-separated EVM wallet addresses being monitored. */
  wallet_addresses: string;
}

/**
 * A CDP service whose health and maintenance status are tracked here.
 */
export type HealthService = (typeof HealthService)[keyof typeof HealthService];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const HealthService = {
  /** Payment Acceptance — accepting and processing payments on behalf of merchants. */
  payments_acceptance: "payments_acceptance",
  /** CDP\'s webhook delivery infrastructure. */
  webhooks: "webhooks",
} as const;

/**
 * Effective labels returned for `health.*` subscriptions.
 */
export interface HealthWebhookResponseLabels {
  /** Service whose health events are delivered. */
  service: HealthService;
}

/**
 * Server-injected labels returned for entity-scoped subscriptions.
 */
export interface EntityWebhookResponseLabels {
  /** Authenticated entity that owns the subscription. */
  entity: string;
}

/**
 * Stringified boolean indicating whether the subscription receives sandbox user events.
 */
export type UserWebhookResponseLabelsSandbox =
  (typeof UserWebhookResponseLabelsSandbox)[keyof typeof UserWebhookResponseLabelsSandbox];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const UserWebhookResponseLabelsSandbox = {
  true: "true",
  false: "false",
} as const;

/**
 * Server-injected labels returned for user-scoped subscriptions.
 */
export interface UserWebhookResponseLabels {
  /** Authenticated user whose events are delivered. */
  user_uuid: string;
  /** Stringified boolean indicating whether the subscription receives sandbox user events. */
  sandbox: UserWebhookResponseLabelsSandbox;
}

/**
 * Server-injected labels returned for project-scoped subscriptions.
 */
export interface ProjectWebhookResponseLabels {
  /** Authenticated project that owns the subscription. */
  project: string;
}

/**
 * A human-readable description of the webhook subscription.
Must be at most 100 characters.

 * @minLength 0
 * @maxLength 100
 */
export type WebhookDescription = string;

/**
 * A webhook event type identifier following dot-separated format:
`<domain>.<entity>.<verb>` (e.g., "onchain.activity.detected").

 */
export type EventType = (typeof EventType)[keyof typeof EventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const EventType = {
  onchainactivitydetected: "onchain.activity.detected",
  walletactivitydetected: "wallet.activity.detected",
  walletactivitymulti: "wallet.activity.multi",
  wallettransactioncreated: "wallet.transaction.created",
  wallettransactionsigned: "wallet.transaction.signed",
  wallettransactionbroadcast: "wallet.transaction.broadcast",
  wallettransactionreplaced: "wallet.transaction.replaced",
  wallettransactionpending: "wallet.transaction.pending",
  wallettransactionconfirmed: "wallet.transaction.confirmed",
  wallettransactionfailed: "wallet.transaction.failed",
  walletdelegationcreated: "wallet.delegation.created",
  walletdelegationrevoked: "wallet.delegation.revoked",
  wallettyped_datasigned: "wallet.typed_data.signed",
  walletmessagesigned: "wallet.message.signed",
  wallethashsigned: "wallet.hash.signed",
  paymentstransfersquoted: "payments.transfers.quoted",
  paymentstransfersprocessing: "payments.transfers.processing",
  paymentstransferscompleted: "payments.transfers.completed",
  paymentstransfersfailed: "payments.transfers.failed",
  paymentstransfersexpired: "payments.transfers.expired",
  paymentstransferstravel_rule_incomplete: "payments.transfers.travel_rule_incomplete",
  paymentstransferstravel_rule_completed: "payments.transfers.travel_rule_completed",
  onramptransactioncreated: "onramp.transaction.created",
  onramptransactionupdated: "onramp.transaction.updated",
  onramptransactionsuccess: "onramp.transaction.success",
  onramptransactionfailed: "onramp.transaction.failed",
  offramptransactioncreated: "offramp.transaction.created",
  offramptransactionupdated: "offramp.transaction.updated",
  offramptransactionsuccess: "offramp.transaction.success",
  offramptransactionfailed: "offramp.transaction.failed",
  acceptancepayment_sessioncreated: "acceptance.payment_session.created",
  acceptancepayment_sessioncanceled: "acceptance.payment_session.canceled",
  acceptancepayment_sessionauthorization_pending:
    "acceptance.payment_session.authorization_pending",
  acceptancepayment_sessionauthorization_succeeded:
    "acceptance.payment_session.authorization_succeeded",
  acceptancepayment_sessionauthorization_failed: "acceptance.payment_session.authorization_failed",
  acceptancepayment_sessioncapture_pending: "acceptance.payment_session.capture_pending",
  acceptancepayment_sessioncapture_succeeded: "acceptance.payment_session.capture_succeeded",
  acceptancepayment_sessioncapture_failed: "acceptance.payment_session.capture_failed",
  acceptancepayment_sessionrefund_pending: "acceptance.payment_session.refund_pending",
  acceptancepayment_sessionrefund_succeeded: "acceptance.payment_session.refund_succeeded",
  acceptancepayment_sessionrefund_failed: "acceptance.payment_session.refund_failed",
  acceptancepayment_sessionvoid_pending: "acceptance.payment_session.void_pending",
  acceptancepayment_sessionvoid_succeeded: "acceptance.payment_session.void_succeeded",
  acceptancepayment_sessionvoid_failed: "acceptance.payment_session.void_failed",
  acceptancemandatecreated: "acceptance.mandate.created",
  acceptancemandatecanceled: "acceptance.mandate.canceled",
  acceptancemandateapproval_initiated: "acceptance.mandate.approval_initiated",
  acceptancemandateapproval_succeeded: "acceptance.mandate.approval_succeeded",
  acceptancemandateapproval_failed: "acceptance.mandate.approval_failed",
  acceptancemandaterevocation_initiated: "acceptance.mandate.revocation_initiated",
  acceptancemandaterevocation_succeeded: "acceptance.mandate.revocation_succeeded",
  acceptancemandaterevocation_failed: "acceptance.mandate.revocation_failed",
  acceptancedisbursementpending: "acceptance.disbursement.pending",
  acceptancedisbursementsucceeded: "acceptance.disbursement.succeeded",
  acceptancedisbursementfailed: "acceptance.disbursement.failed",
  healthstatusupdated: "health.status.updated",
  healthmaintenancescheduled: "health.maintenance.scheduled",
  healthmaintenancestarted: "health.maintenance.started",
  healthmaintenancecompleted: "health.maintenance.completed",
  healthmaintenancecanceled: "health.maintenance.canceled",
  customerscapabilitychanged: "customers.capability.changed",
  customerscustomerdeleted: "customers.customer.deleted",
} as const;

/**
 * Additional headers to include in webhook requests.
 */
export type WebhookTargetHeaders = { [key: string]: string };

/**
 * Target configuration for webhook delivery.
Specifies the destination URL and any custom headers to include in webhook requests.

 */
export interface WebhookTarget {
  /** The webhook URL to deliver events to.

Must be a publicly accessible HTTPS URL that responds to HEAD requests with a 200 status code.

If the URL is not publicly accessible or doesn't respond to HEAD requests with a 200 status code, the URL will be rejected with a 400.
 */
  url: Url;
  /** Additional headers to include in webhook requests. */
  headers?: WebhookTargetHeaders;
}

/**
 * Effective filters stored on the webhook subscription. The response includes
client-supplied labels plus labels defaulted or injected by the server.

* `onchain.activity.detected`, `wallet.activity.detected`, and `wallet.activity.multi`
  include `network`. It defaults to `base-mainnet` when omitted from the request.
* `wallet.activity.multi` includes the requested comma-separated `wallet_addresses`.
* `health.*` includes the requested `service`.
* Project-scoped events include the authenticated `project`.
* Entity-scoped events include the authenticated `entity`.
* User-scoped events include the authenticated `user_uuid` and a `sandbox` value.

 */
export interface WebhookResponseLabels {
  [key: string]: string;
}

export type WebhookSubscriptionResponseMetadataAllOf = {
  /**
   * Use the root-level `secret` field instead. Maintained for backward compatibility only.
   * @deprecated
   */
  secret?: string;
};

/**
 * Additional metadata for the subscription.
 */
export type WebhookSubscriptionResponseMetadata = Metadata &
  WebhookSubscriptionResponseMetadataAllOf;

/**
 * Response containing webhook subscription details.
 */
export interface WebhookSubscriptionResponse {
  /** When the subscription was created. */
  createdAt: string;
  /** When the subscription was last updated. */
  updatedAt?: string;
  description?: WebhookDescription;
  /** Types of events to subscribe to. Event types follow a dot-separated format:
service.resource.verb (e.g., "onchain.activity.detected", "wallet.activity.detected", "onramp.transaction.created",
"acceptance.payment_session.authorization_succeeded").
 */
  eventTypes: EventType[];
  /** Whether the subscription is enabled. */
  isEnabled: boolean;
  /** Additional metadata for the subscription. */
  metadata?: WebhookSubscriptionResponseMetadata;
  /** Secret for webhook signature validation. */
  secret: string;
  /** Unique identifier for the subscription. */
  subscriptionId: string;
  target: WebhookTarget;
  labels?: WebhookResponseLabels;
}

/**
 * Response containing a list of webhook subscriptions.
 */
export type WebhookSubscriptionListResponseAllOf = {
  /** The list of webhook subscriptions. */
  subscriptions: WebhookSubscriptionResponse[];
};

export type WebhookSubscriptionListResponse = WebhookSubscriptionListResponseAllOf & ListResponse;

/**
 * Blockchain network to monitor.
 */
export type OnchainActivityWebhookLabelsNetwork =
  (typeof OnchainActivityWebhookLabelsNetwork)[keyof typeof OnchainActivityWebhookLabelsNetwork];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const OnchainActivityWebhookLabelsNetwork = {
  "base-mainnet": "base-mainnet",
  "base-sepolia": "base-sepolia",
} as const;

/**
 * Labels accepted for `onchain.activity.detected` subscriptions.
 */
export interface OnchainActivityWebhookLabels {
  /** Blockchain network to monitor. */
  network?: OnchainActivityWebhookLabelsNetwork;
  /** Smart contract address to monitor. */
  contract_address: string;
  /** Decoded contract event name to match. */
  event_name?: string;
  /** Canonical event signature to match. */
  event_signature?: string;
  /** Transaction sender address to match. */
  transaction_from?: string;
  /** Transaction recipient address to match. */
  transaction_to?: string;
}

/**
 * Blockchain network to monitor.
 */
export type WalletActivityDetectedWebhookLabelsNetwork =
  (typeof WalletActivityDetectedWebhookLabelsNetwork)[keyof typeof WalletActivityDetectedWebhookLabelsNetwork];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const WalletActivityDetectedWebhookLabelsNetwork = {
  "base-mainnet": "base-mainnet",
  "base-sepolia": "base-sepolia",
} as const;

/**
 * Labels accepted for `wallet.activity.detected` subscriptions.
 */
export type WalletActivityDetectedWebhookLabels =
  | (unknown & {
      /** Blockchain network to monitor. */
      network?: WalletActivityDetectedWebhookLabelsNetwork;
      /** Transaction recipient address to match. */
      "params.to"?: string;
      /** Transaction sender address to match. */
      "params.from"?: string;
    })
  | (unknown & {
      /** Blockchain network to monitor. */
      network?: WalletActivityDetectedWebhookLabelsNetwork;
      /** Transaction recipient address to match. */
      "params.to"?: string;
      /** Transaction sender address to match. */
      "params.from"?: string;
    });

/**
 * Blockchain network to monitor.
 */
export type WalletActivityMultiWebhookLabelsNetwork =
  (typeof WalletActivityMultiWebhookLabelsNetwork)[keyof typeof WalletActivityMultiWebhookLabelsNetwork];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const WalletActivityMultiWebhookLabelsNetwork = {
  "base-mainnet": "base-mainnet",
  "base-sepolia": "base-sepolia",
} as const;

/**
 * Labels accepted for `wallet.activity.multi` subscriptions.
 */
export interface WalletActivityMultiWebhookLabels {
  /** Blockchain network to monitor. */
  network?: WalletActivityMultiWebhookLabelsNetwork;
  /**
   * Comma-separated EVM wallet addresses to monitor. Each address must be `0x`-prefixed and contain 40 hexadecimal characters. Maximum 100 addresses.
   * @minLength 42
   * @maxLength 4299
   * @pattern ^0x[0-9a-fA-F]{40}(,0x[0-9a-fA-F]{40})*$
   */
  wallet_addresses: string;
}

/**
 * Labels accepted for `health.*` subscriptions.
 */
export interface HealthWebhookLabels {
  /** Service whose health events should be delivered. */
  service: HealthService;
}

/**
 * Optional subscription metadata. Up to 10 key/value pairs may be provided. Keys and values must each contain between 1 and 50 characters.
 */
export interface WebhookMetadata {
  [key: string]: string;
}

/**
 * String-valued filters supplied when creating or updating a webhook subscription.
The subscription's `eventTypes` determine whether labels are required and which
label keys are accepted. A subscription accepts at most 20 client-supplied labels.

#### Label Behavior

An event must match ALL labels to fire to your subscription `targetURL`. When multiple labels are supplied, the event must match ALL labels to fire to your subscription `targetURL`.

 */
export interface WebhookRequestLabels {
  [key: string]: string;
}

/**
 * Request to create a new webhook subscription with support for multi-label filtering.

 */
export interface WebhookSubscriptionRequest {
  description?: WebhookDescription;
  /** Types of events to subscribe to. Event types follow a dot-separated format:
service.resource.verb (e.g., "onchain.activity.detected", "wallet.activity.detected", "onramp.transaction.created",
"acceptance.payment_session.authorization_succeeded").
The subscription will only receive events matching these types AND the label filter(s).
 */
  eventTypes: EventType[];
  /** Whether the subscription is enabled. */
  isEnabled: boolean;
  target: WebhookTarget;
  metadata?: WebhookMetadata;
  labels?: WebhookRequestLabels;
}

/**
 * Request to update an existing webhook subscription.

 */
export interface WebhookSubscriptionUpdateRequest {
  description?: WebhookDescription;
  /** Types of events to subscribe to. Event types follow a three-part dot-separated format:
service.resource.verb (e.g., "onchain.activity.detected", "wallet.activity.detected", "onramp.transaction.created").
 */
  eventTypes: EventType[];
  /** Whether the subscription is enabled. */
  isEnabled: boolean;
  target: WebhookTarget;
  metadata?: WebhookMetadata;
  labels?: WebhookRequestLabels;
}

/**
 * Details of the HTTP response received from the webhook target.
 */
export interface WebhookEventResponseDetail {
  /** HTTP status code returned by the webhook target. */
  httpCode?: number;
  /** Round-trip time of the webhook delivery in milliseconds. */
  elapsedTimeMs?: number;
  /** Response body returned by the webhook target. */
  body?: string;
  /** Error name if the delivery failed (e.g., timeout, connection_refused). */
  errorName?: string;
}

/**
 * Current delivery status of the event.
 */
export type WebhookEventResponseStatus =
  (typeof WebhookEventResponseStatus)[keyof typeof WebhookEventResponseStatus];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const WebhookEventResponseStatus = {
  pending: "pending",
  processing: "processing",
  succeeded: "succeeded",
  failed: "failed",
  retrying: "retrying",
} as const;

/**
 * Details of a webhook event delivery attempt for a subscription.
 */
export interface WebhookEventResponse {
  /** Unique identifier for the webhook event. */
  eventId: string;
  /** The type of event that was delivered (e.g., "onchain.activity.detected"). */
  eventTypeName: string;
  /** Current delivery status of the event. */
  status: WebhookEventResponseStatus;
  /** Timestamp when the event delivery attempt was created. */
  createdAt: string;
  /** Timestamp when the event was successfully delivered. Only present if status is "succeeded". */
  succeededAt?: string;
  /** Number of delivery retry attempts so far. */
  retryCount: number;
  response?: WebhookEventResponseDetail;
}

/**
 * Response containing a list of webhook event delivery attempts.
 */
export interface WebhookEventListResponse {
  /** The list of webhook event delivery attempts. */
  events: WebhookEventResponse[];
}

/**
 * The reason the payment is invalid on the x402 protocol.
 */
export type X402VerifyInvalidReason =
  (typeof X402VerifyInvalidReason)[keyof typeof X402VerifyInvalidReason];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const X402VerifyInvalidReason = {
  insufficient_funds: "insufficient_funds",
  invalid_scheme: "invalid_scheme",
  invalid_network: "invalid_network",
  invalid_x402_version: "invalid_x402_version",
  invalid_payment_requirements: "invalid_payment_requirements",
  invalid_payload: "invalid_payload",
  invalid_exact_evm_payload_authorization_value: "invalid_exact_evm_payload_authorization_value",
  invalid_exact_evm_payload_authorization_value_too_low:
    "invalid_exact_evm_payload_authorization_value_too_low",
  invalid_exact_evm_payload_authorization_valid_after:
    "invalid_exact_evm_payload_authorization_valid_after",
  invalid_exact_evm_payload_authorization_valid_before:
    "invalid_exact_evm_payload_authorization_valid_before",
  invalid_exact_evm_payload_authorization_typed_data_message:
    "invalid_exact_evm_payload_authorization_typed_data_message",
  invalid_exact_evm_payload_authorization_from_address_kyt:
    "invalid_exact_evm_payload_authorization_from_address_kyt",
  invalid_exact_evm_payload_authorization_to_address_kyt:
    "invalid_exact_evm_payload_authorization_to_address_kyt",
  invalid_exact_evm_payload_signature: "invalid_exact_evm_payload_signature",
  invalid_exact_evm_payload_signature_address: "invalid_exact_evm_payload_signature_address",
  invalid_exact_evm_permit2_payload_allowance_required:
    "invalid_exact_evm_permit2_payload_allowance_required",
  invalid_exact_evm_permit2_payload_signature: "invalid_exact_evm_permit2_payload_signature",
  invalid_exact_evm_permit2_payload_deadline: "invalid_exact_evm_permit2_payload_deadline",
  invalid_exact_evm_permit2_payload_valid_after: "invalid_exact_evm_permit2_payload_valid_after",
  invalid_exact_evm_permit2_payload_spender: "invalid_exact_evm_permit2_payload_spender",
  invalid_exact_evm_permit2_payload_recipient: "invalid_exact_evm_permit2_payload_recipient",
  invalid_exact_evm_permit2_payload_amount: "invalid_exact_evm_permit2_payload_amount",
  invalid_exact_svm_payload_transaction: "invalid_exact_svm_payload_transaction",
  invalid_exact_svm_payload_transaction_amount_mismatch:
    "invalid_exact_svm_payload_transaction_amount_mismatch",
  invalid_exact_svm_payload_transaction_create_ata_instruction:
    "invalid_exact_svm_payload_transaction_create_ata_instruction",
  invalid_exact_svm_payload_transaction_create_ata_instruction_incorrect_payee:
    "invalid_exact_svm_payload_transaction_create_ata_instruction_incorrect_payee",
  invalid_exact_svm_payload_transaction_create_ata_instruction_incorrect_asset:
    "invalid_exact_svm_payload_transaction_create_ata_instruction_incorrect_asset",
  invalid_exact_svm_payload_transaction_instructions:
    "invalid_exact_svm_payload_transaction_instructions",
  invalid_exact_svm_payload_transaction_instructions_length:
    "invalid_exact_svm_payload_transaction_instructions_length",
  invalid_exact_svm_payload_transaction_instructions_compute_limit_instruction:
    "invalid_exact_svm_payload_transaction_instructions_compute_limit_instruction",
  invalid_exact_svm_payload_transaction_instructions_compute_price_instruction:
    "invalid_exact_svm_payload_transaction_instructions_compute_price_instruction",
  invalid_exact_svm_payload_transaction_instructions_compute_price_instruction_too_high:
    "invalid_exact_svm_payload_transaction_instructions_compute_price_instruction_too_high",
  invalid_exact_svm_payload_transaction_instruction_not_spl_token_transfer_checked:
    "invalid_exact_svm_payload_transaction_instruction_not_spl_token_transfer_checked",
  invalid_exact_svm_payload_transaction_instruction_not_token_2022_transfer_checked:
    "invalid_exact_svm_payload_transaction_instruction_not_token_2022_transfer_checked",
  invalid_exact_svm_payload_transaction_not_a_transfer_instruction:
    "invalid_exact_svm_payload_transaction_not_a_transfer_instruction",
  invalid_exact_svm_payload_transaction_cannot_derive_receiver_ata:
    "invalid_exact_svm_payload_transaction_cannot_derive_receiver_ata",
  invalid_exact_svm_payload_transaction_receiver_ata_not_found:
    "invalid_exact_svm_payload_transaction_receiver_ata_not_found",
  invalid_exact_svm_payload_transaction_sender_ata_not_found:
    "invalid_exact_svm_payload_transaction_sender_ata_not_found",
  invalid_exact_svm_payload_transaction_simulation_failed:
    "invalid_exact_svm_payload_transaction_simulation_failed",
  invalid_exact_svm_payload_transaction_transfer_to_incorrect_ata:
    "invalid_exact_svm_payload_transaction_transfer_to_incorrect_ata",
  invalid_exact_svm_payload_transaction_fee_payer_included_in_instruction_accounts:
    "invalid_exact_svm_payload_transaction_fee_payer_included_in_instruction_accounts",
  invalid_exact_svm_payload_transaction_fee_payer_transferring_funds:
    "invalid_exact_svm_payload_transaction_fee_payer_transferring_funds",
  invalid_batch_settlement_evm_scheme: "invalid_batch_settlement_evm_scheme",
  invalid_batch_settlement_evm_network_mismatch: "invalid_batch_settlement_evm_network_mismatch",
  invalid_batch_settlement_evm_payload_type: "invalid_batch_settlement_evm_payload_type",
  invalid_batch_settlement_evm_channel_not_found: "invalid_batch_settlement_evm_channel_not_found",
  invalid_batch_settlement_evm_deposit_simulation_failed:
    "invalid_batch_settlement_evm_deposit_simulation_failed",
  invalid_batch_settlement_evm_channel_id_mismatch:
    "invalid_batch_settlement_evm_channel_id_mismatch",
  invalid_batch_settlement_evm_channel_state_read_failed:
    "invalid_batch_settlement_evm_channel_state_read_failed",
  invalid_batch_settlement_evm_cumulative_below_claimed:
    "invalid_batch_settlement_evm_cumulative_below_claimed",
  invalid_batch_settlement_evm_cumulative_exceeds_balance:
    "invalid_batch_settlement_evm_cumulative_exceeds_balance",
  invalid_batch_settlement_evm_eip2612_amount_mismatch:
    "invalid_batch_settlement_evm_eip2612_amount_mismatch",
  invalid_batch_settlement_evm_eip2612_asset_mismatch:
    "invalid_batch_settlement_evm_eip2612_asset_mismatch",
  invalid_batch_settlement_evm_eip2612_deadline_expired:
    "invalid_batch_settlement_evm_eip2612_deadline_expired",
  invalid_batch_settlement_evm_eip2612_invalid_format:
    "invalid_batch_settlement_evm_eip2612_invalid_format",
  invalid_batch_settlement_evm_eip2612_invalid_signature:
    "invalid_batch_settlement_evm_eip2612_invalid_signature",
  invalid_batch_settlement_evm_eip2612_owner_mismatch:
    "invalid_batch_settlement_evm_eip2612_owner_mismatch",
  invalid_batch_settlement_evm_eip2612_spender_mismatch:
    "invalid_batch_settlement_evm_eip2612_spender_mismatch",
  invalid_batch_settlement_evm_erc20_approval_asset_mismatch:
    "invalid_batch_settlement_evm_erc20_approval_asset_mismatch",
  invalid_batch_settlement_evm_erc20_approval_from_mismatch:
    "invalid_batch_settlement_evm_erc20_approval_from_mismatch",
  invalid_batch_settlement_evm_erc20_approval_invalid_format:
    "invalid_batch_settlement_evm_erc20_approval_invalid_format",
  invalid_batch_settlement_evm_erc20_approval_unavailable:
    "invalid_batch_settlement_evm_erc20_approval_unavailable",
  invalid_batch_settlement_evm_erc20_approval_wrong_spender:
    "invalid_batch_settlement_evm_erc20_approval_wrong_spender",
  invalid_batch_settlement_evm_erc3009_authorization_required:
    "invalid_batch_settlement_evm_erc3009_authorization_required",
  invalid_batch_settlement_evm_insufficient_balance:
    "invalid_batch_settlement_evm_insufficient_balance",
  invalid_batch_settlement_evm_deposit_payload: "invalid_batch_settlement_evm_deposit_payload",
  invalid_batch_settlement_evm_receive_authorization_signature:
    "invalid_batch_settlement_evm_receive_authorization_signature",
  invalid_batch_settlement_evm_refund_payload: "invalid_batch_settlement_evm_refund_payload",
  invalid_batch_settlement_evm_voucher_payload: "invalid_batch_settlement_evm_voucher_payload",
  invalid_batch_settlement_evm_voucher_signature: "invalid_batch_settlement_evm_voucher_signature",
  invalid_batch_settlement_evm_missing_eip712_domain:
    "invalid_batch_settlement_evm_missing_eip712_domain",
  invalid_batch_settlement_evm_payload_authorization_valid_after:
    "invalid_batch_settlement_evm_payload_authorization_valid_after",
  invalid_batch_settlement_evm_payload_authorization_valid_before:
    "invalid_batch_settlement_evm_payload_authorization_valid_before",
  invalid_batch_settlement_evm_permit2_allowance_required:
    "invalid_batch_settlement_evm_permit2_allowance_required",
  invalid_batch_settlement_evm_permit2_amount_mismatch:
    "invalid_batch_settlement_evm_permit2_amount_mismatch",
  invalid_batch_settlement_evm_permit2_authorization_required:
    "invalid_batch_settlement_evm_permit2_authorization_required",
  invalid_batch_settlement_evm_permit2_deadline_expired:
    "invalid_batch_settlement_evm_permit2_deadline_expired",
  invalid_batch_settlement_evm_permit2_invalid_signature:
    "invalid_batch_settlement_evm_permit2_invalid_signature",
  invalid_batch_settlement_evm_permit2_invalid_spender:
    "invalid_batch_settlement_evm_permit2_invalid_spender",
  invalid_batch_settlement_evm_receiver_authorizer_mismatch:
    "invalid_batch_settlement_evm_receiver_authorizer_mismatch",
  invalid_batch_settlement_evm_receiver_mismatch: "invalid_batch_settlement_evm_receiver_mismatch",
  invalid_batch_settlement_evm_rpc_read_failed: "invalid_batch_settlement_evm_rpc_read_failed",
  invalid_batch_settlement_evm_token_mismatch: "invalid_batch_settlement_evm_token_mismatch",
  invalid_batch_settlement_evm_withdraw_delay_mismatch:
    "invalid_batch_settlement_evm_withdraw_delay_mismatch",
  invalid_batch_settlement_evm_withdraw_delay_out_of_range:
    "invalid_batch_settlement_evm_withdraw_delay_out_of_range",
  invalid_exact_evm_scheme: "invalid_exact_evm_scheme",
  invalid_exact_evm_network_mismatch: "invalid_exact_evm_network_mismatch",
  invalid_exact_evm_payload: "invalid_exact_evm_payload",
  invalid_exact_evm_payload_missing_signature: "invalid_exact_evm_payload_missing_signature",
  invalid_exact_evm_failed_to_get_network_config: "invalid_exact_evm_failed_to_get_network_config",
  invalid_exact_evm_missing_eip712_domain: "invalid_exact_evm_missing_eip712_domain",
  invalid_exact_evm_recipient_mismatch: "invalid_exact_evm_recipient_mismatch",
  invalid_exact_evm_authorization_value: "invalid_exact_evm_authorization_value",
  invalid_exact_evm_required_amount: "invalid_exact_evm_required_amount",
  invalid_exact_evm_payload_authorization_value_mismatch:
    "invalid_exact_evm_payload_authorization_value_mismatch",
  invalid_exact_evm_failed_to_check_nonce: "invalid_exact_evm_failed_to_check_nonce",
  invalid_exact_evm_nonce_already_used: "invalid_exact_evm_nonce_already_used",
  invalid_exact_evm_failed_to_get_balance: "invalid_exact_evm_failed_to_get_balance",
  invalid_exact_evm_insufficient_balance: "invalid_exact_evm_insufficient_balance",
  invalid_exact_evm_signature_format: "invalid_exact_evm_signature_format",
  invalid_exact_evm_failed_to_verify_signature: "invalid_exact_evm_failed_to_verify_signature",
  invalid_exact_evm_signature: "invalid_exact_evm_signature",
  invalid_exact_evm_token_name_mismatch: "invalid_exact_evm_token_name_mismatch",
  invalid_exact_evm_token_version_mismatch: "invalid_exact_evm_token_version_mismatch",
  invalid_exact_evm_eip3009_not_supported: "invalid_exact_evm_eip3009_not_supported",
  invalid_exact_evm_transaction_simulation_failed:
    "invalid_exact_evm_transaction_simulation_failed",
  invalid_exact_evm_verification_failed: "invalid_exact_evm_verification_failed",
  invalid_exact_evm_failed_to_parse_signature: "invalid_exact_evm_failed_to_parse_signature",
  invalid_exact_evm_failed_to_check_deployment: "invalid_exact_evm_failed_to_check_deployment",
  invalid_exact_evm_failed_to_execute_transfer: "invalid_exact_evm_failed_to_execute_transfer",
  invalid_exact_evm_failed_to_get_receipt: "invalid_exact_evm_failed_to_get_receipt",
  invalid_exact_evm_transaction_failed: "invalid_exact_evm_transaction_failed",
  invalid_exact_evm_payload_undeployed_smart_wallet:
    "invalid_exact_evm_payload_undeployed_smart_wallet",
  smart_wallet_deployment_failed: "smart_wallet_deployment_failed",
  unsupported_payload_type: "unsupported_payload_type",
  invalid_erc20_approval_extension_format: "invalid_erc20_approval_extension_format",
  erc20_approval_tx_failed: "erc20_approval_tx_failed",
  erc20_approval_from_mismatch: "erc20_approval_from_mismatch",
  erc20_approval_asset_mismatch: "erc20_approval_asset_mismatch",
  erc20_approval_spender_not_permit2: "erc20_approval_spender_not_permit2",
  erc20_approval_tx_parse_failed: "erc20_approval_tx_parse_failed",
  erc20_approval_tx_wrong_target: "erc20_approval_tx_wrong_target",
  erc20_approval_tx_wrong_selector: "erc20_approval_tx_wrong_selector",
  erc20_approval_tx_wrong_spender: "erc20_approval_tx_wrong_spender",
  erc20_approval_tx_signer_mismatch: "erc20_approval_tx_signer_mismatch",
  erc20_approval_tx_invalid_signature: "erc20_approval_tx_invalid_signature",
  invalid_exact_evm_unsupported_scheme: "invalid_exact_evm_unsupported_scheme",
  invalid_exact_evm_extra_field: "invalid_exact_evm_extra_field",
  invalid_exact_evm_payload_recipient_mismatch: "invalid_exact_evm_payload_recipient_mismatch",
  invalid_exact_evm_insufficient_funds: "invalid_exact_evm_insufficient_funds",
  invalid_exact_evm_transaction_state: "invalid_exact_evm_transaction_state",
  invalid_permit2_spender: "invalid_permit2_spender",
  invalid_permit2_recipient_mismatch: "invalid_permit2_recipient_mismatch",
  permit2_deadline_expired: "permit2_deadline_expired",
  permit2_not_yet_valid: "permit2_not_yet_valid",
  permit2_amount_mismatch: "permit2_amount_mismatch",
  permit2_token_mismatch: "permit2_token_mismatch",
  invalid_permit2_signature: "invalid_permit2_signature",
  permit2_allowance_required: "permit2_allowance_required",
  permit2_invalid_amount: "permit2_invalid_amount",
  permit2_invalid_destination: "permit2_invalid_destination",
  permit2_invalid_owner: "permit2_invalid_owner",
  permit2_payment_too_early: "permit2_payment_too_early",
  permit2_invalid_nonce: "permit2_invalid_nonce",
  permit2_2612_amount_mismatch: "permit2_2612_amount_mismatch",
  permit2_simulation_failed: "permit2_simulation_failed",
  permit2_insufficient_balance: "permit2_insufficient_balance",
  permit2_proxy_not_deployed: "permit2_proxy_not_deployed",
  erc20_approval_insufficient_eth_for_gas: "erc20_approval_insufficient_eth_for_gas",
  erc20_approval_broadcast_failed: "erc20_approval_broadcast_failed",
  invalid_exact_solana_unsupported_scheme: "invalid_exact_solana_unsupported_scheme",
  invalid_exact_solana_network_mismatch: "invalid_exact_solana_network_mismatch",
  invalid_exact_solana_payload_missing_fee_payer: "invalid_exact_solana_payload_missing_fee_payer",
  invalid_exact_solana_fee_payer_not_managed_by_facilitator:
    "invalid_exact_solana_fee_payer_not_managed_by_facilitator",
  invalid_exact_solana_payload_transaction: "invalid_exact_solana_payload_transaction",
  invalid_exact_solana_payload_transaction_could_not_be_decoded:
    "invalid_exact_solana_payload_transaction_could_not_be_decoded",
  invalid_exact_solana_payload_transaction_instructions_length:
    "invalid_exact_solana_payload_transaction_instructions_length",
  invalid_exact_solana_payload_unknown_fourth_instruction:
    "invalid_exact_solana_payload_unknown_fourth_instruction",
  invalid_exact_solana_payload_unknown_fifth_instruction:
    "invalid_exact_solana_payload_unknown_fifth_instruction",
  invalid_exact_solana_payload_unknown_sixth_instruction:
    "invalid_exact_solana_payload_unknown_sixth_instruction",
  invalid_exact_solana_payload_transaction_instructions_compute_limit_instruction:
    "invalid_exact_solana_payload_transaction_instructions_compute_limit_instruction",
  invalid_exact_solana_payload_transaction_instructions_compute_price_instruction:
    "invalid_exact_solana_payload_transaction_instructions_compute_price_instruction",
  invalid_exact_solana_payload_transaction_instructions_compute_price_instruction_too_high:
    "invalid_exact_solana_payload_transaction_instructions_compute_price_instruction_too_high",
  invalid_exact_solana_payload_no_transfer_instruction:
    "invalid_exact_solana_payload_no_transfer_instruction",
  invalid_exact_solana_payload_transaction_fee_payer_transferring_funds:
    "invalid_exact_solana_payload_transaction_fee_payer_transferring_funds",
  invalid_exact_solana_payload_mint_mismatch: "invalid_exact_solana_payload_mint_mismatch",
  invalid_exact_solana_payload_recipient_mismatch:
    "invalid_exact_solana_payload_recipient_mismatch",
  invalid_exact_solana_payload_amount_insufficient:
    "invalid_exact_solana_payload_amount_insufficient",
  invalid_exact_solana_invalid_fee_payer: "invalid_exact_solana_invalid_fee_payer",
  invalid_exact_solana_transaction_signing_failed:
    "invalid_exact_solana_transaction_signing_failed",
  invalid_exact_solana_transaction_simulation_failed:
    "invalid_exact_solana_transaction_simulation_failed",
  invalid_exact_solana_payload_memo_mismatch: "invalid_exact_solana_payload_memo_mismatch",
  invalid_exact_solana_payload_memo_count: "invalid_exact_solana_payload_memo_count",
  invalid_exact_solana_verification_failed: "invalid_exact_solana_verification_failed",
  invalid_exact_solana_fee_payer_mismatch: "invalid_exact_solana_fee_payer_mismatch",
  invalid_exact_solana_transaction_failed: "invalid_exact_solana_transaction_failed",
  invalid_exact_solana_transaction_confirmation_failed:
    "invalid_exact_solana_transaction_confirmation_failed",
  duplicate_settlement: "duplicate_settlement",
  invalid_exact_solana_extra_field: "invalid_exact_solana_extra_field",
  batch_settlement_cumulative_amount_mismatch: "batch_settlement_cumulative_amount_mismatch",
  batch_settlement_channel_busy: "batch_settlement_channel_busy",
  missing_batch_settlement_channel: "missing_batch_settlement_channel",
  batch_settlement_charge_exceeds_signed_cumulative:
    "batch_settlement_charge_exceeds_signed_cumulative",
  batch_settlement_refund_no_balance: "batch_settlement_refund_no_balance",
  batch_settlement_refund_amount_invalid: "batch_settlement_refund_amount_invalid",
  batch_settlement_refund_amount_exceeds_balance: "batch_settlement_refund_amount_exceeds_balance",
  amount_too_low: "amount_too_low",
  invalid_amount: "invalid_amount",
  kyt_risk_detected: "kyt_risk_detected",
  permit2_disabled: "permit2_disabled",
  preflight_validation_failed: "preflight_validation_failed",
  request_blocked_by_location: "request_blocked_by_location",
  self_send_not_allowed: "self_send_not_allowed",
  invalid_bazaar_extension: "invalid_bazaar_extension",
  node_failure: "node_failure",
  unknown_error: "unknown_error",
} as const;

/**
 * The result when x402 payment verification fails.
 */
export interface X402VerifyPaymentRejection {
  /** Indicates whether the payment is valid. */
  isValid: boolean;
  invalidReason: X402VerifyInvalidReason;
  /** The message describing the invalid reason. */
  invalidMessage?: string;
  /** The onchain address of the client that is paying for the resource.

For EVM networks, the payer will be a 0x-prefixed, checksum EVM address.

For Solana-based networks, the payer will be a base58-encoded Solana address. */
  payer?: BlockchainAddress;
}

/**
 * The reason the payment settlement errored on the x402 protocol.
 */
export type X402SettleErrorReason =
  (typeof X402SettleErrorReason)[keyof typeof X402SettleErrorReason];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const X402SettleErrorReason = {
  insufficient_funds: "insufficient_funds",
  invalid_scheme: "invalid_scheme",
  invalid_network: "invalid_network",
  invalid_x402_version: "invalid_x402_version",
  invalid_payment_requirements: "invalid_payment_requirements",
  invalid_payload: "invalid_payload",
  invalid_exact_evm_payload_authorization_value: "invalid_exact_evm_payload_authorization_value",
  invalid_exact_evm_payload_authorization_value_too_low:
    "invalid_exact_evm_payload_authorization_value_too_low",
  invalid_exact_evm_payload_authorization_valid_after:
    "invalid_exact_evm_payload_authorization_valid_after",
  invalid_exact_evm_payload_authorization_valid_before:
    "invalid_exact_evm_payload_authorization_valid_before",
  invalid_exact_evm_payload_authorization_typed_data_message:
    "invalid_exact_evm_payload_authorization_typed_data_message",
  invalid_exact_evm_payload_authorization_from_address_kyt:
    "invalid_exact_evm_payload_authorization_from_address_kyt",
  invalid_exact_evm_payload_authorization_to_address_kyt:
    "invalid_exact_evm_payload_authorization_to_address_kyt",
  invalid_exact_evm_payload_signature: "invalid_exact_evm_payload_signature",
  invalid_exact_evm_payload_signature_address: "invalid_exact_evm_payload_signature_address",
  invalid_exact_evm_permit2_payload_allowance_required:
    "invalid_exact_evm_permit2_payload_allowance_required",
  invalid_exact_evm_permit2_payload_signature: "invalid_exact_evm_permit2_payload_signature",
  invalid_exact_evm_permit2_payload_deadline: "invalid_exact_evm_permit2_payload_deadline",
  invalid_exact_evm_permit2_payload_valid_after: "invalid_exact_evm_permit2_payload_valid_after",
  invalid_exact_evm_permit2_payload_spender: "invalid_exact_evm_permit2_payload_spender",
  invalid_exact_evm_permit2_payload_recipient: "invalid_exact_evm_permit2_payload_recipient",
  invalid_exact_evm_permit2_payload_amount: "invalid_exact_evm_permit2_payload_amount",
  invalid_exact_svm_payload_transaction: "invalid_exact_svm_payload_transaction",
  invalid_exact_svm_payload_transaction_amount_mismatch:
    "invalid_exact_svm_payload_transaction_amount_mismatch",
  invalid_exact_svm_payload_transaction_create_ata_instruction:
    "invalid_exact_svm_payload_transaction_create_ata_instruction",
  invalid_exact_svm_payload_transaction_create_ata_instruction_incorrect_payee:
    "invalid_exact_svm_payload_transaction_create_ata_instruction_incorrect_payee",
  invalid_exact_svm_payload_transaction_create_ata_instruction_incorrect_asset:
    "invalid_exact_svm_payload_transaction_create_ata_instruction_incorrect_asset",
  invalid_exact_svm_payload_transaction_instructions:
    "invalid_exact_svm_payload_transaction_instructions",
  invalid_exact_svm_payload_transaction_instructions_length:
    "invalid_exact_svm_payload_transaction_instructions_length",
  invalid_exact_svm_payload_transaction_instructions_compute_limit_instruction:
    "invalid_exact_svm_payload_transaction_instructions_compute_limit_instruction",
  invalid_exact_svm_payload_transaction_instructions_compute_price_instruction:
    "invalid_exact_svm_payload_transaction_instructions_compute_price_instruction",
  invalid_exact_svm_payload_transaction_instructions_compute_price_instruction_too_high:
    "invalid_exact_svm_payload_transaction_instructions_compute_price_instruction_too_high",
  invalid_exact_svm_payload_transaction_instruction_not_spl_token_transfer_checked:
    "invalid_exact_svm_payload_transaction_instruction_not_spl_token_transfer_checked",
  invalid_exact_svm_payload_transaction_instruction_not_token_2022_transfer_checked:
    "invalid_exact_svm_payload_transaction_instruction_not_token_2022_transfer_checked",
  invalid_exact_svm_payload_transaction_not_a_transfer_instruction:
    "invalid_exact_svm_payload_transaction_not_a_transfer_instruction",
  invalid_exact_svm_payload_transaction_cannot_derive_receiver_ata:
    "invalid_exact_svm_payload_transaction_cannot_derive_receiver_ata",
  invalid_exact_svm_payload_transaction_receiver_ata_not_found:
    "invalid_exact_svm_payload_transaction_receiver_ata_not_found",
  invalid_exact_svm_payload_transaction_sender_ata_not_found:
    "invalid_exact_svm_payload_transaction_sender_ata_not_found",
  invalid_exact_svm_payload_transaction_simulation_failed:
    "invalid_exact_svm_payload_transaction_simulation_failed",
  invalid_exact_svm_payload_transaction_transfer_to_incorrect_ata:
    "invalid_exact_svm_payload_transaction_transfer_to_incorrect_ata",
  invalid_exact_svm_payload_transaction_fee_payer_included_in_instruction_accounts:
    "invalid_exact_svm_payload_transaction_fee_payer_included_in_instruction_accounts",
  invalid_exact_svm_payload_transaction_fee_payer_transferring_funds:
    "invalid_exact_svm_payload_transaction_fee_payer_transferring_funds",
  settle_exact_evm_transaction_confirmation_timed_out:
    "settle_exact_evm_transaction_confirmation_timed_out",
  settle_exact_node_failure: "settle_exact_node_failure",
  settle_exact_failed_onchain: "settle_exact_failed_onchain",
  settle_exact_svm_block_height_exceeded: "settle_exact_svm_block_height_exceeded",
  settle_exact_svm_transaction_confirmation_timed_out:
    "settle_exact_svm_transaction_confirmation_timed_out",
  settlement_pending: "settlement_pending",
  invalid_batch_settlement_evm_unknown_settle_action:
    "invalid_batch_settlement_evm_unknown_settle_action",
  invalid_batch_settlement_evm_claim_payload: "invalid_batch_settlement_evm_claim_payload",
  invalid_batch_settlement_evm_settle_payload: "invalid_batch_settlement_evm_settle_payload",
  invalid_batch_settlement_evm_authorizer_address_mismatch:
    "invalid_batch_settlement_evm_authorizer_address_mismatch",
  invalid_batch_settlement_evm_claim_simulation_failed:
    "invalid_batch_settlement_evm_claim_simulation_failed",
  invalid_batch_settlement_evm_claim_transaction_failed:
    "invalid_batch_settlement_evm_claim_transaction_failed",
  invalid_batch_settlement_evm_deposit_transaction_failed:
    "invalid_batch_settlement_evm_deposit_transaction_failed",
  invalid_batch_settlement_evm_refund_simulation_failed:
    "invalid_batch_settlement_evm_refund_simulation_failed",
  invalid_batch_settlement_evm_refund_transaction_failed:
    "invalid_batch_settlement_evm_refund_transaction_failed",
  invalid_batch_settlement_evm_settle_simulation_failed:
    "invalid_batch_settlement_evm_settle_simulation_failed",
  invalid_batch_settlement_evm_settle_transaction_failed:
    "invalid_batch_settlement_evm_settle_transaction_failed",
  invalid_batch_settlement_evm_transaction_reverted:
    "invalid_batch_settlement_evm_transaction_reverted",
  invalid_batch_settlement_evm_wait_for_receipt_failed:
    "invalid_batch_settlement_evm_wait_for_receipt_failed",
  invalid_batch_settlement_evm_erc20_approval_broadcast_failed:
    "invalid_batch_settlement_evm_erc20_approval_broadcast_failed",
  invalid_batch_settlement_evm_channel_id_mismatch:
    "invalid_batch_settlement_evm_channel_id_mismatch",
  invalid_batch_settlement_evm_channel_state_read_failed:
    "invalid_batch_settlement_evm_channel_state_read_failed",
  invalid_batch_settlement_evm_cumulative_below_claimed:
    "invalid_batch_settlement_evm_cumulative_below_claimed",
  invalid_batch_settlement_evm_cumulative_exceeds_balance:
    "invalid_batch_settlement_evm_cumulative_exceeds_balance",
  invalid_batch_settlement_evm_eip2612_amount_mismatch:
    "invalid_batch_settlement_evm_eip2612_amount_mismatch",
  invalid_batch_settlement_evm_eip2612_asset_mismatch:
    "invalid_batch_settlement_evm_eip2612_asset_mismatch",
  invalid_batch_settlement_evm_eip2612_deadline_expired:
    "invalid_batch_settlement_evm_eip2612_deadline_expired",
  invalid_batch_settlement_evm_eip2612_invalid_format:
    "invalid_batch_settlement_evm_eip2612_invalid_format",
  invalid_batch_settlement_evm_eip2612_invalid_signature:
    "invalid_batch_settlement_evm_eip2612_invalid_signature",
  invalid_batch_settlement_evm_eip2612_owner_mismatch:
    "invalid_batch_settlement_evm_eip2612_owner_mismatch",
  invalid_batch_settlement_evm_eip2612_spender_mismatch:
    "invalid_batch_settlement_evm_eip2612_spender_mismatch",
  invalid_batch_settlement_evm_erc20_approval_asset_mismatch:
    "invalid_batch_settlement_evm_erc20_approval_asset_mismatch",
  invalid_batch_settlement_evm_erc20_approval_from_mismatch:
    "invalid_batch_settlement_evm_erc20_approval_from_mismatch",
  invalid_batch_settlement_evm_erc20_approval_invalid_format:
    "invalid_batch_settlement_evm_erc20_approval_invalid_format",
  invalid_batch_settlement_evm_erc20_approval_unavailable:
    "invalid_batch_settlement_evm_erc20_approval_unavailable",
  invalid_batch_settlement_evm_erc20_approval_wrong_spender:
    "invalid_batch_settlement_evm_erc20_approval_wrong_spender",
  invalid_batch_settlement_evm_erc3009_authorization_required:
    "invalid_batch_settlement_evm_erc3009_authorization_required",
  invalid_batch_settlement_evm_insufficient_balance:
    "invalid_batch_settlement_evm_insufficient_balance",
  invalid_batch_settlement_evm_deposit_payload: "invalid_batch_settlement_evm_deposit_payload",
  invalid_batch_settlement_evm_receive_authorization_signature:
    "invalid_batch_settlement_evm_receive_authorization_signature",
  invalid_batch_settlement_evm_refund_payload: "invalid_batch_settlement_evm_refund_payload",
  invalid_batch_settlement_evm_voucher_payload: "invalid_batch_settlement_evm_voucher_payload",
  invalid_batch_settlement_evm_voucher_signature: "invalid_batch_settlement_evm_voucher_signature",
  invalid_batch_settlement_evm_missing_eip712_domain:
    "invalid_batch_settlement_evm_missing_eip712_domain",
  invalid_batch_settlement_evm_payload_authorization_valid_after:
    "invalid_batch_settlement_evm_payload_authorization_valid_after",
  invalid_batch_settlement_evm_payload_authorization_valid_before:
    "invalid_batch_settlement_evm_payload_authorization_valid_before",
  invalid_batch_settlement_evm_permit2_allowance_required:
    "invalid_batch_settlement_evm_permit2_allowance_required",
  invalid_batch_settlement_evm_permit2_amount_mismatch:
    "invalid_batch_settlement_evm_permit2_amount_mismatch",
  invalid_batch_settlement_evm_permit2_authorization_required:
    "invalid_batch_settlement_evm_permit2_authorization_required",
  invalid_batch_settlement_evm_permit2_deadline_expired:
    "invalid_batch_settlement_evm_permit2_deadline_expired",
  invalid_batch_settlement_evm_permit2_invalid_signature:
    "invalid_batch_settlement_evm_permit2_invalid_signature",
  invalid_batch_settlement_evm_permit2_invalid_spender:
    "invalid_batch_settlement_evm_permit2_invalid_spender",
  invalid_batch_settlement_evm_receiver_authorizer_mismatch:
    "invalid_batch_settlement_evm_receiver_authorizer_mismatch",
  invalid_batch_settlement_evm_receiver_mismatch: "invalid_batch_settlement_evm_receiver_mismatch",
  invalid_batch_settlement_evm_rpc_read_failed: "invalid_batch_settlement_evm_rpc_read_failed",
  invalid_batch_settlement_evm_token_mismatch: "invalid_batch_settlement_evm_token_mismatch",
  invalid_batch_settlement_evm_withdraw_delay_mismatch:
    "invalid_batch_settlement_evm_withdraw_delay_mismatch",
  invalid_batch_settlement_evm_withdraw_delay_out_of_range:
    "invalid_batch_settlement_evm_withdraw_delay_out_of_range",
  invalid_batch_settlement_evm_scheme: "invalid_batch_settlement_evm_scheme",
  invalid_batch_settlement_evm_network_mismatch: "invalid_batch_settlement_evm_network_mismatch",
  invalid_batch_settlement_evm_payload_type: "invalid_batch_settlement_evm_payload_type",
  invalid_batch_settlement_evm_channel_not_found: "invalid_batch_settlement_evm_channel_not_found",
  invalid_batch_settlement_evm_deposit_simulation_failed:
    "invalid_batch_settlement_evm_deposit_simulation_failed",
  invalid_exact_evm_scheme: "invalid_exact_evm_scheme",
  invalid_exact_evm_network_mismatch: "invalid_exact_evm_network_mismatch",
  invalid_exact_evm_payload: "invalid_exact_evm_payload",
  invalid_exact_evm_payload_missing_signature: "invalid_exact_evm_payload_missing_signature",
  invalid_exact_evm_failed_to_get_network_config: "invalid_exact_evm_failed_to_get_network_config",
  invalid_exact_evm_missing_eip712_domain: "invalid_exact_evm_missing_eip712_domain",
  invalid_exact_evm_recipient_mismatch: "invalid_exact_evm_recipient_mismatch",
  invalid_exact_evm_authorization_value: "invalid_exact_evm_authorization_value",
  invalid_exact_evm_required_amount: "invalid_exact_evm_required_amount",
  invalid_exact_evm_payload_authorization_value_mismatch:
    "invalid_exact_evm_payload_authorization_value_mismatch",
  invalid_exact_evm_failed_to_check_nonce: "invalid_exact_evm_failed_to_check_nonce",
  invalid_exact_evm_nonce_already_used: "invalid_exact_evm_nonce_already_used",
  invalid_exact_evm_failed_to_get_balance: "invalid_exact_evm_failed_to_get_balance",
  invalid_exact_evm_insufficient_balance: "invalid_exact_evm_insufficient_balance",
  invalid_exact_evm_signature_format: "invalid_exact_evm_signature_format",
  invalid_exact_evm_failed_to_verify_signature: "invalid_exact_evm_failed_to_verify_signature",
  invalid_exact_evm_signature: "invalid_exact_evm_signature",
  invalid_exact_evm_token_name_mismatch: "invalid_exact_evm_token_name_mismatch",
  invalid_exact_evm_token_version_mismatch: "invalid_exact_evm_token_version_mismatch",
  invalid_exact_evm_eip3009_not_supported: "invalid_exact_evm_eip3009_not_supported",
  invalid_exact_evm_transaction_simulation_failed:
    "invalid_exact_evm_transaction_simulation_failed",
  invalid_exact_evm_verification_failed: "invalid_exact_evm_verification_failed",
  invalid_exact_evm_failed_to_parse_signature: "invalid_exact_evm_failed_to_parse_signature",
  invalid_exact_evm_failed_to_check_deployment: "invalid_exact_evm_failed_to_check_deployment",
  invalid_exact_evm_failed_to_execute_transfer: "invalid_exact_evm_failed_to_execute_transfer",
  invalid_exact_evm_failed_to_get_receipt: "invalid_exact_evm_failed_to_get_receipt",
  invalid_exact_evm_transaction_failed: "invalid_exact_evm_transaction_failed",
  invalid_exact_evm_payload_undeployed_smart_wallet:
    "invalid_exact_evm_payload_undeployed_smart_wallet",
  smart_wallet_deployment_failed: "smart_wallet_deployment_failed",
  unsupported_payload_type: "unsupported_payload_type",
  invalid_erc20_approval_extension_format: "invalid_erc20_approval_extension_format",
  erc20_approval_tx_failed: "erc20_approval_tx_failed",
  erc20_approval_from_mismatch: "erc20_approval_from_mismatch",
  erc20_approval_asset_mismatch: "erc20_approval_asset_mismatch",
  erc20_approval_spender_not_permit2: "erc20_approval_spender_not_permit2",
  erc20_approval_tx_parse_failed: "erc20_approval_tx_parse_failed",
  erc20_approval_tx_wrong_target: "erc20_approval_tx_wrong_target",
  erc20_approval_tx_wrong_selector: "erc20_approval_tx_wrong_selector",
  erc20_approval_tx_wrong_spender: "erc20_approval_tx_wrong_spender",
  erc20_approval_tx_signer_mismatch: "erc20_approval_tx_signer_mismatch",
  erc20_approval_tx_invalid_signature: "erc20_approval_tx_invalid_signature",
  invalid_exact_evm_unsupported_scheme: "invalid_exact_evm_unsupported_scheme",
  invalid_exact_evm_extra_field: "invalid_exact_evm_extra_field",
  invalid_exact_evm_payload_recipient_mismatch: "invalid_exact_evm_payload_recipient_mismatch",
  invalid_exact_evm_insufficient_funds: "invalid_exact_evm_insufficient_funds",
  invalid_exact_evm_transaction_state: "invalid_exact_evm_transaction_state",
  invalid_permit2_spender: "invalid_permit2_spender",
  invalid_permit2_recipient_mismatch: "invalid_permit2_recipient_mismatch",
  permit2_deadline_expired: "permit2_deadline_expired",
  permit2_not_yet_valid: "permit2_not_yet_valid",
  permit2_amount_mismatch: "permit2_amount_mismatch",
  permit2_token_mismatch: "permit2_token_mismatch",
  invalid_permit2_signature: "invalid_permit2_signature",
  permit2_allowance_required: "permit2_allowance_required",
  permit2_invalid_amount: "permit2_invalid_amount",
  permit2_invalid_destination: "permit2_invalid_destination",
  permit2_invalid_owner: "permit2_invalid_owner",
  permit2_payment_too_early: "permit2_payment_too_early",
  permit2_invalid_nonce: "permit2_invalid_nonce",
  permit2_2612_amount_mismatch: "permit2_2612_amount_mismatch",
  permit2_simulation_failed: "permit2_simulation_failed",
  permit2_insufficient_balance: "permit2_insufficient_balance",
  permit2_proxy_not_deployed: "permit2_proxy_not_deployed",
  erc20_approval_insufficient_eth_for_gas: "erc20_approval_insufficient_eth_for_gas",
  erc20_approval_broadcast_failed: "erc20_approval_broadcast_failed",
  invalid_exact_solana_unsupported_scheme: "invalid_exact_solana_unsupported_scheme",
  invalid_exact_solana_network_mismatch: "invalid_exact_solana_network_mismatch",
  invalid_exact_solana_payload_missing_fee_payer: "invalid_exact_solana_payload_missing_fee_payer",
  invalid_exact_solana_fee_payer_not_managed_by_facilitator:
    "invalid_exact_solana_fee_payer_not_managed_by_facilitator",
  invalid_exact_solana_payload_transaction: "invalid_exact_solana_payload_transaction",
  invalid_exact_solana_payload_transaction_could_not_be_decoded:
    "invalid_exact_solana_payload_transaction_could_not_be_decoded",
  invalid_exact_solana_payload_transaction_instructions_length:
    "invalid_exact_solana_payload_transaction_instructions_length",
  invalid_exact_solana_payload_unknown_fourth_instruction:
    "invalid_exact_solana_payload_unknown_fourth_instruction",
  invalid_exact_solana_payload_unknown_fifth_instruction:
    "invalid_exact_solana_payload_unknown_fifth_instruction",
  invalid_exact_solana_payload_unknown_sixth_instruction:
    "invalid_exact_solana_payload_unknown_sixth_instruction",
  invalid_exact_solana_payload_transaction_instructions_compute_limit_instruction:
    "invalid_exact_solana_payload_transaction_instructions_compute_limit_instruction",
  invalid_exact_solana_payload_transaction_instructions_compute_price_instruction:
    "invalid_exact_solana_payload_transaction_instructions_compute_price_instruction",
  invalid_exact_solana_payload_transaction_instructions_compute_price_instruction_too_high:
    "invalid_exact_solana_payload_transaction_instructions_compute_price_instruction_too_high",
  invalid_exact_solana_payload_no_transfer_instruction:
    "invalid_exact_solana_payload_no_transfer_instruction",
  invalid_exact_solana_payload_transaction_fee_payer_transferring_funds:
    "invalid_exact_solana_payload_transaction_fee_payer_transferring_funds",
  invalid_exact_solana_payload_mint_mismatch: "invalid_exact_solana_payload_mint_mismatch",
  invalid_exact_solana_payload_recipient_mismatch:
    "invalid_exact_solana_payload_recipient_mismatch",
  invalid_exact_solana_payload_amount_insufficient:
    "invalid_exact_solana_payload_amount_insufficient",
  invalid_exact_solana_invalid_fee_payer: "invalid_exact_solana_invalid_fee_payer",
  invalid_exact_solana_transaction_signing_failed:
    "invalid_exact_solana_transaction_signing_failed",
  invalid_exact_solana_transaction_simulation_failed:
    "invalid_exact_solana_transaction_simulation_failed",
  invalid_exact_solana_payload_memo_mismatch: "invalid_exact_solana_payload_memo_mismatch",
  invalid_exact_solana_payload_memo_count: "invalid_exact_solana_payload_memo_count",
  invalid_exact_solana_verification_failed: "invalid_exact_solana_verification_failed",
  invalid_exact_solana_fee_payer_mismatch: "invalid_exact_solana_fee_payer_mismatch",
  invalid_exact_solana_transaction_failed: "invalid_exact_solana_transaction_failed",
  invalid_exact_solana_transaction_confirmation_failed:
    "invalid_exact_solana_transaction_confirmation_failed",
  duplicate_settlement: "duplicate_settlement",
  invalid_exact_solana_extra_field: "invalid_exact_solana_extra_field",
  batch_settlement_cumulative_amount_mismatch: "batch_settlement_cumulative_amount_mismatch",
  batch_settlement_channel_busy: "batch_settlement_channel_busy",
  missing_batch_settlement_channel: "missing_batch_settlement_channel",
  batch_settlement_charge_exceeds_signed_cumulative:
    "batch_settlement_charge_exceeds_signed_cumulative",
  batch_settlement_refund_no_balance: "batch_settlement_refund_no_balance",
  batch_settlement_refund_amount_invalid: "batch_settlement_refund_amount_invalid",
  batch_settlement_refund_amount_exceeds_balance: "batch_settlement_refund_amount_exceeds_balance",
  amount_too_low: "amount_too_low",
  invalid_amount: "invalid_amount",
  kyt_risk_detected: "kyt_risk_detected",
  permit2_disabled: "permit2_disabled",
  preflight_validation_failed: "preflight_validation_failed",
  request_blocked_by_location: "request_blocked_by_location",
  self_send_not_allowed: "self_send_not_allowed",
  invalid_bazaar_extension: "invalid_bazaar_extension",
  unknown_error: "unknown_error",
} as const;

/**
 * The result when x402 payment settlement fails.
 */
export interface X402SettlePaymentRejection {
  /** Indicates whether the payment settlement is successful. */
  success: boolean;
  errorReason: X402SettleErrorReason;
  /** The message describing the error reason. */
  errorMessage?: string;
  /** The onchain address of the client that is paying for the resource.

For EVM networks, the payer will be a 0x-prefixed, checksum EVM address.

For Solana-based networks, the payer will be a base58-encoded Solana address. */
  payer?: BlockchainAddress;
  /**
   * The transaction of the settlement.
For EVM networks, the transaction will be a 0x-prefixed, EVM transaction hash.
For Solana-based networks, the transaction will be a base58-encoded Solana signature.
Populated even though `success` is `false` when `errorReason` is `settlement_pending`: the transaction broadcast successfully but its receipt could not be retrieved, so the hash is returned for the caller to reconcile before retrying.
   * @pattern ^(0x[a-fA-F0-9]{64}|[1-9A-HJ-NP-Za-km-z]{87,88})$
   */
  transaction?: string;
  /** The network where the settlement occurred. */
  network?: string;
}

/**
 * The scheme of the payment protocol.
 */
export type X402SupportedPaymentKindScheme =
  (typeof X402SupportedPaymentKindScheme)[keyof typeof X402SupportedPaymentKindScheme];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const X402SupportedPaymentKindScheme = {
  exact: "exact",
  upto: "upto",
  "batch-settlement": "batch-settlement",
} as const;

/**
 * The network of the blockchain. The format corresponds to the `x402Version` of the enclosing `x402SupportedPaymentKind`: v1 uses human-readable names (see `X402V1Network`); v2 uses CAIP-2 chain IDs (see `X402V2Network`).
 */
export type X402SupportedPaymentKindNetwork =
  (typeof X402SupportedPaymentKindNetwork)[keyof typeof X402SupportedPaymentKindNetwork];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const X402SupportedPaymentKindNetwork = {
  "base-sepolia": "base-sepolia",
  base: "base",
  "solana-devnet": "solana-devnet",
  solana: "solana",
  "eip155:8453": "eip155:8453",
  "eip155:84532": "eip155:84532",
  "eip155:137": "eip155:137",
  "eip155:42161": "eip155:42161",
  "eip155:480": "eip155:480",
  "eip155:4801": "eip155:4801",
  "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
  "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1": "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
} as const;

/**
 * The optional additional scheme-specific payment info.
Common scheme-specific fields:
  - `exact` on Solana: `feePayer` — the base58-encoded Solana address that pays transaction fees.
  - `upto` on EVM: `name`, `version`, and `facilitatorAddress` — the EVM address of the facilitator that the client must bind into the Permit2 witness when constructing the payment payload.
  - `batch-settlement` on EVM: `name`, `version`, `receiverAuthorizer` (the EVM address authorized to sign claim batches), `withdrawDelay` (channel non-cooperative withdraw delay in seconds, 900–2,592,000), and optionally `assetTransferMethod` (e.g., `"eip3009"`).
 */
export type X402SupportedPaymentKindExtra = { [key: string]: unknown };

/**
 * The supported payment kind for the x402 protocol. A kind is comprised of a scheme and a network, which together uniquely identify a way to move money on the x402 protocol. For more details, please see [x402 Schemes](https://github.com/coinbase/x402?tab=readme-ov-file#schemes).
 */
export interface X402SupportedPaymentKind {
  x402Version: X402Version;
  /** The scheme of the payment protocol. */
  scheme: X402SupportedPaymentKindScheme;
  /** The network of the blockchain. The format corresponds to the `x402Version` of the enclosing `x402SupportedPaymentKind`: v1 uses human-readable names (see `X402V1Network`); v2 uses CAIP-2 chain IDs (see `X402V2Network`). */
  network: X402SupportedPaymentKindNetwork;
  /** The optional additional scheme-specific payment info.
Common scheme-specific fields:
  - `exact` on Solana: `feePayer` — the base58-encoded Solana address that pays transaction fees.
  - `upto` on EVM: `name`, `version`, and `facilitatorAddress` — the EVM address of the facilitator that the client must bind into the Permit2 witness when constructing the payment payload.
  - `batch-settlement` on EVM: `name`, `version`, `receiverAuthorizer` (the EVM address authorized to sign claim batches), `withdrawDelay` (channel non-cooperative withdraw delay in seconds, 900–2,592,000), and optionally `assetTransferMethod` (e.g., `"eip3009"`). */
  extra?: X402SupportedPaymentKindExtra;
}

/**
 * Quality metrics for a discovered x402 resource.
 */
export interface X402ResourceQuality {
  /** Total number of paid calls to a resource in the last 30 days. */
  l30DaysTotalCalls?: number;
  /** Number of unique payers to a resource in the last 30 days. */
  l30DaysUniquePayers?: number;
  /** Timestamp of the most recent paid call to a resource. */
  lastCalledAt?: string;
}

/**
 * Communication protocol (e.g., "http", "mcp").
 */
export type X402DiscoveryResourceType =
  (typeof X402DiscoveryResourceType)[keyof typeof X402DiscoveryResourceType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const X402DiscoveryResourceType = {
  http: "http",
  mcp: "mcp",
} as const;

/**
 * Map of x402 protocol extensions supported by the resource, keyed by extension name.
 */
export type X402DiscoveryResourceExtensions = { [key: string]: unknown };

/**
 * A single discovered x402 resource. Its fields come from three sources:

- **x402 protocol** — negotiated from the resource's payment-required response: `resource`,
  `type`, `x402Version`, `accepts`, `extensions`.
- **Provider-supplied** — metadata published by the resource owner: `description`,
  `serviceName`, `tags`.
- **Coinbase-derived** — added during ingestion and curation: `iconUrl`, `quality`,
  `lastUpdated`, and (for Coinbase-curated endpoints only) `curated`, `skillUrl` (a
  Coinbase-authored SKILL.md), and `bundleSlugs`.

 */
export interface X402DiscoveryResource {
  /** The URL of the resource. */
  resource: string;
  /** A human-readable description of the resource. */
  description?: string;
  /** Communication protocol (e.g., "http", "mcp"). */
  type: X402DiscoveryResourceType;
  x402Version: X402Version;
  /** Timestamp of the last update. */
  lastUpdated?: string;
  /** Payment requirements accepted by the resource. */
  accepts?: X402PaymentRequirements[];
  /** Map of x402 protocol extensions supported by the resource, keyed by extension name. */
  extensions?: X402DiscoveryResourceExtensions;
  quality?: X402ResourceQuality;
  /** Display name of the service this resource belongs to. This is a free-form
label for grouping and presentation only — it is not a stable identifier, and two resources
sharing the same `serviceName` are not guaranteed to belong to the same logical service.
 */
  serviceName?: string;
  /** Low-cardinality string labels associated with the resource for client-side
filtering and display. Values are free-form (no controlled vocabulary) and case-sensitive.
Order is not significant and duplicates are not expected.
 */
  tags?: string[];
  /**
   * Slugs of the curated x402 bundles this resource belongs to. A bundle is an ordered, named grouping of curated resources covering a common agent workflow. Present only for Coinbase-curated resources (`curated: true`); omitted when the resource is not curated or is not a member of any bundle.
   * @maxItems 50
   */
  bundleSlugs?: string[];
  /** URL of a square icon representing the service this resource belongs to. Distinct from a
brand logo: this is intended for compact, list-view rendering (favicon-style) and is
normalized to a square aspect ratio at ingestion. The image is moderated and re-hosted by
Coinbase, so the URL is stable and safe to render directly in clients. Omitted when the
provider did not supply an icon, when the supplied icon failed moderation, or when image
processing was unavailable at ingestion time.
 */
  iconUrl?: Url;
  /** Whether this resource is a Coinbase-curated endpoint. Curated endpoints have passed the
partner-admission and verification bar and surface higher in search and listing results.
Omitted (treated as `false`) when the resource is not curated.
 */
  curated?: boolean;
  /** URL of the SKILL.md document describing how to use this resource. Omitted when the resource
has no associated skill document.
 */
  skillUrl?: Url;
}

/**
 * Pagination information for the response.
 */
export type X402DiscoveryResourcesResponsePagination = {
  /** The number of discovered x402 resources to return per page. */
  limit?: number;
  /** The offset of the first discovered x402 resource to return. */
  offset?: number;
  /** The total number of discovered x402 resources. */
  total?: number;
};

/**
 * Response containing discovered x402 resources.
 */
export interface X402DiscoveryResourcesResponse {
  x402Version: X402Version;
  /** List of discovered x402 resources. */
  items: X402DiscoveryResource[];
  /** Pagination information for the response. */
  pagination: X402DiscoveryResourcesResponsePagination;
}

/**
 * Pagination information for the response.
 */
export type X402DiscoveryMerchantResponsePagination = {
  /** The number of resources returned per page. */
  limit?: number;
  /** The offset of the first resource returned. */
  offset?: number;
  /** The total number of resources associated with the merchant's payTo address. */
  total?: number;
};

/**
 * Response containing x402 resources associated with a merchant payment address. The resources list is empty when no active resources are found.
 */
export interface X402DiscoveryMerchantResponse {
  x402Version: X402Version;
  payTo: BlockchainAddress;
  /** List of discovered x402 resources associated with the merchant's payTo address. This list is empty when no active resources are found. */
  resources: X402DiscoveryResource[];
  /** Pagination information for the response. */
  pagination: X402DiscoveryMerchantResponsePagination;
}

/**
 * The search method used to retrieve the results (e.g., "text", "vector", "hybrid").
 */
export type X402SearchResourcesResponseSearchMethod =
  (typeof X402SearchResourcesResponseSearchMethod)[keyof typeof X402SearchResourcesResponseSearchMethod];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const X402SearchResourcesResponseSearchMethod = {
  text: "text",
  vector: "vector",
  hybrid: "hybrid",
} as const;

/**
 * Response from a search for x402 resources.
 */
export interface X402SearchResourcesResponse {
  /** List of x402 resources matching the search query and filters. */
  resources: X402DiscoveryResource[];
  /** Indicates whether the result set was truncated because there were more results than the requested limit. */
  partialResults: boolean;
  /** The search method used to retrieve the results (e.g., "text", "vector", "hybrid"). */
  searchMethod?: X402SearchResourcesResponseSearchMethod;
  x402Version: X402Version;
}

/**
 * JSON-RPC version, must be "2.0".
 */
export type X402McpRequestJsonrpc =
  (typeof X402McpRequestJsonrpc)[keyof typeof X402McpRequestJsonrpc];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const X402McpRequestJsonrpc = {
  "20": "2.0",
} as const;

/**
 * Request identifier.
 */
export type X402McpRequestId = string | number;

/**
 * Optional parameters for the method.
 */
export type X402McpRequestParams = { [key: string]: unknown };

/**
 * A JSON-RPC 2.0 request for the Model Context Protocol.
 */
export interface X402McpRequest {
  /** JSON-RPC version, must be "2.0". */
  jsonrpc: X402McpRequestJsonrpc;
  /** Request identifier. */
  id?: X402McpRequestId;
  /** The MCP method to invoke. */
  method: string;
  /** Optional parameters for the method. */
  params?: X402McpRequestParams;
}

/**
 * Additional error data.
 */
export type X402McpErrorData = { [key: string]: unknown };

/**
 * JSON-RPC 2.0 error object.
 */
export interface X402McpError {
  /** Error code. */
  code: number;
  /** Error message. */
  message: string;
  /** Additional error data. */
  data?: X402McpErrorData;
}

/**
 * JSON-RPC version.
 */
export type X402McpResponseJsonrpc =
  (typeof X402McpResponseJsonrpc)[keyof typeof X402McpResponseJsonrpc];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const X402McpResponseJsonrpc = {
  "20": "2.0",
} as const;

/**
 * Request identifier (matches the request ID, null for notifications).
 * @nullable
 */
export type X402McpResponseId = string | number | null;

/**
 * The result of the method call (present on success).
 */
export type X402McpResponseResult = { [key: string]: unknown };

/**
 * A JSON-RPC 2.0 response for the Model Context Protocol.
 */
export interface X402McpResponse {
  /** JSON-RPC version. */
  jsonrpc: X402McpResponseJsonrpc;
  /**
   * Request identifier (matches the request ID, null for notifications).
   * @nullable
   */
  id?: X402McpResponseId;
  /** The result of the method call (present on success). */
  result?: X402McpResponseResult;
  error?: X402McpError;
}

/**
 * A curated workflow bundle: an ordered, named grouping of curated x402 resources that together cover a common agent workflow. This metadata shape is returned by the bundle list endpoint; the per-bundle detail endpoint additionally returns the joined member resources.
 */
export interface X402Bundle {
  /**
   * The stable, unique, URL-safe identifier for the bundle. Used as the path segment in `GET /v2/x402/discovery/bundles/{bundleSlug}`.
   * @maxLength 64
   * @pattern ^[a-z0-9]+(?:-[a-z0-9]+)*$
   */
  slug: string;
  /** The human-readable display name of the bundle. */
  name: string;
  /** A human-readable description of the workflow the bundle covers. */
  description?: string;
}

/**
 * Response containing the available curated x402 bundles. Unlike x402 protocol discovery and search responses, bundle responses omit `x402Version` because bundles are CDP-curated metadata, not protocol negotiation payloads.
 */
export interface X402BundlesResponse {
  /**
   * The list of available curated bundles. This list is empty when no bundles are defined.
   * @maxItems 50
   */
  bundles: X402Bundle[];
}

export type X402BundleResponseAllOf = {
  /**
   * The bundle's member resources in bundle-defined order. Each entry is the full discovery metadata for a curated endpoint belonging to this bundle. Bundle membership is capped at 50 resources.
   * @maxItems 50
   */
  resources: X402DiscoveryResource[];
};

/**
 * Response containing a single curated bundle's metadata and its ordered member resources. Members are the bundle's curated endpoints joined to their full discovery metadata, in bundle-defined order. Unlike x402 protocol discovery and search responses, bundle responses omit `x402Version` because bundles are CDP-curated metadata, not protocol negotiation payloads.
 */
export type X402BundleResponse = X402Bundle & X402BundleResponseAllOf;

/**
 * A valid HTTPS URL.
 * @minLength 12
 * @maxLength 2048
 * @pattern ^https://.*$
 */
export type HttpsUrl = string;

/**
 * The HTTP method used to probe the endpoint. Only GET and POST are supported; other verbs are intentionally rejected because x402 resources are expected to respond to these methods.
 */
export type X402ValidateRequestMethod =
  (typeof X402ValidateRequestMethod)[keyof typeof X402ValidateRequestMethod];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const X402ValidateRequestMethod = {
  GET: "GET",
  POST: "POST",
} as const;

/**
 * Request to validate an x402 endpoint's bazaar-discovery configuration.
 */
export interface X402ValidateRequest {
  /** HTTPS URL of the x402 endpoint to validate. Must use the `https://` scheme. */
  resource: HttpsUrl;
  /** The HTTP method used to probe the endpoint. Only GET and POST are supported; other verbs are intentionally rejected because x402 resources are expected to respond to these methods. */
  method?: X402ValidateRequestMethod;
}

/**
 * The name of the preflight check. New values may be added in future versions; clients should handle unknown values gracefully.
 */
export type X402ValidateCheckCheck =
  (typeof X402ValidateCheckCheck)[keyof typeof X402ValidateCheckCheck];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const X402ValidateCheckCheck = {
  reachable: "reachable",
  returns_402: "returns_402",
  has_bazaar_extension: "has_bazaar_extension",
  parse: "parse",
} as const;

/**
 * Whether this check is a hard indexing requirement or a quality recommendation. A `required` check affects validity when it fails. An `advisory` check (for example, a missing output schema) is a suggestion to improve discoverability and does not make the endpoint invalid.
 */
export type X402ValidateCheckSeverity =
  (typeof X402ValidateCheckSeverity)[keyof typeof X402ValidateCheckSeverity];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const X402ValidateCheckSeverity = {
  required: "required",
  advisory: "advisory",
} as const;

/**
 * The result of a single preflight check performed against the x402 endpoint.
 */
export interface X402ValidateCheck {
  /** The name of the preflight check. New values may be added in future versions; clients should handle unknown values gracefully. */
  check: X402ValidateCheckCheck;
  /** Whether the check passed. */
  passed: boolean;
  /** A human-readable explanation of the check result. */
  detail: string;
  /** The value the check expected, when applicable. */
  expected?: string;
  /** The value the check observed, when applicable. */
  actual?: string;
  /** Whether this check is a hard indexing requirement or a quality recommendation. A `required` check affects validity when it fails. An `advisory` check (for example, a missing output schema) is a suggestion to improve discoverability and does not make the endpoint invalid. */
  severity: X402ValidateCheckSeverity;
}

/**
 * The simulated facilitator outcome: `accepted` if the facilitator would index the resource, or `rejected` if it would reject it.
 */
export type X402ValidateSimulationOutcome =
  (typeof X402ValidateSimulationOutcome)[keyof typeof X402ValidateSimulationOutcome];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const X402ValidateSimulationOutcome = {
  accepted: "accepted",
  rejected: "rejected",
} as const;

/**
 * The simulated facilitator decision for the x402 endpoint.
 */
export interface X402ValidateSimulation {
  /** The simulated facilitator outcome: `accepted` if the facilitator would index the resource, or `rejected` if it would reject it. */
  outcome: X402ValidateSimulationOutcome;
  /** The reason the resource would be rejected, present only when `outcome` is `rejected`. */
  rejectionReason?: string;
}

/**
 * Bazaar index status for a validated x402 endpoint.
 */
export interface X402ValidateIndex {
  /** Whether the indexed resource is active and served in discovery results. */
  active: boolean;
  /**
   * When the endpoint was last crawled, or `null` if it has been indexed but not yet crawled.
   * @nullable
   */
  lastCrawledAt: string | null;
  /** Quality metrics for the indexed resource, present only when the endpoint has call history. */
  quality?: X402ResourceQuality;
}

/**
 * The raw decoded payment requirements returned by the endpoint, or `null` if the endpoint was not reachable or did not return a parseable 402 payload. Lets sellers inspect exactly what their endpoint is advertising.
 * @nullable
 */
export type X402ValidateResponsePaymentRequirements = X402PaymentRequirements | null;

/**
 * The `extensions.bazaar` block from the endpoint's discovery metadata, or `null` if the bazaar extension was absent or the endpoint was not reachable. Lets sellers verify the discovery configuration their endpoint is advertising.
 * @nullable
 */
export type X402ValidateResponseBazaarExtension = { [key: string]: unknown } | null;

/**
 * Bazaar index status for the endpoint, or `null` if the endpoint is not yet indexed. Present on every response regardless of simulation outcome.
 * @nullable
 */
export type X402ValidateResponseIndex = X402ValidateIndex | null;

/**
 * Response from validating an x402 endpoint's bazaar-discovery configuration.
 */
export interface X402ValidateResponse {
  /** Whether the endpoint is valid: all preflight checks passed and the facilitator would index the resource. */
  valid: boolean;
  /**
   * The HTTP status code returned by the endpoint, or `null` if the endpoint was not reachable.
   * @nullable
   */
  statusCode: number | null;
  /**
   * The x402 protocol version advertised by the endpoint, or `null` if it could not be determined. Intentionally a bare integer rather than the `X402Version` enum so the validator can surface unsupported or malformed version values returned by non-conforming endpoints.
   * @nullable
   */
  x402Version: number | null;
  /** All check results in run order. Well-known check names are `reachable`, `returns_402`, `has_bazaar_extension`, and `parse`. Additional checks may be added in future versions. */
  preflight: X402ValidateCheck[];
  /**
   * The raw decoded payment requirements returned by the endpoint, or `null` if the endpoint was not reachable or did not return a parseable 402 payload. Lets sellers inspect exactly what their endpoint is advertising.
   * @nullable
   */
  paymentRequirements: X402ValidateResponsePaymentRequirements;
  /**
   * The `extensions.bazaar` block from the endpoint's discovery metadata, or `null` if the bazaar extension was absent or the endpoint was not reachable. Lets sellers verify the discovery configuration their endpoint is advertising.
   * @nullable
   */
  bazaarExtension: X402ValidateResponseBazaarExtension;
  simulation: X402ValidateSimulation;
  /**
   * Bazaar index status for the endpoint, or `null` if the endpoint is not yet indexed. Present on every response regardless of simulation outcome.
   * @nullable
   */
  index: X402ValidateResponseIndex;
}

/**
 * The OTP delivery channel.
 */
export type InitiateOnrampVerificationRequestChannel =
  (typeof InitiateOnrampVerificationRequestChannel)[keyof typeof InitiateOnrampVerificationRequestChannel];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const InitiateOnrampVerificationRequestChannel = {
  sms: "sms",
  email: "email",
} as const;

/**
 * The phone number or email address to send the OTP to.
 */
export type InitiateOnrampVerificationRequestDestination = PhoneNumber | Email;

/**
 * Request body for initiating an onramp OTP verification.
 */
export interface InitiateOnrampVerificationRequest {
  /** The OTP delivery channel. */
  channel: InitiateOnrampVerificationRequestChannel;
  /** The phone number or email address to send the OTP to. */
  destination: InitiateOnrampVerificationRequestDestination;
}

/**
 * A unique identifier for an onramp verification record, in the format `onramp_verification_<uuid>`.
 * @pattern ^onramp_verification_[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$
 */
export type OnrampVerificationId = string;

/**
 * The result of initiating an onramp OTP verification.
 */
export interface OnrampVerificationInitiation {
  /** Identifier returned by this endpoint. Pass to the Submit Onramp Verification endpoint along with the OTP code within 10 minutes. */
  verificationId: OnrampVerificationId;
  /** The deadline for submitting the OTP code (10 minutes from now). */
  otpExpiresAt: string;
}

/**
 * Request body for submitting an OTP code to complete an onramp verification.
 */
export interface SubmitOnrampVerificationRequest {
  /**
   * The 6-digit OTP code the user received.
   * @pattern ^\d{6}$
   */
  otpCode: string;
}

/**
 * The result of successfully submitting an onramp OTP verification.
 */
export interface OnrampVerificationConfirmation {
  /** The same verification ID. Store on the user's device and pass to the Create Onramp Order endpoint. Valid for 60 days. */
  verificationId: OnrampVerificationId;
  /** The date and time when this verification expires for order placement. */
  verificationExpiresAt: string;
}

/**
 * The type of payment method to be used to complete an onramp order.
 */
export type OnrampOrderPaymentMethodTypeId =
  (typeof OnrampOrderPaymentMethodTypeId)[keyof typeof OnrampOrderPaymentMethodTypeId];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const OnrampOrderPaymentMethodTypeId = {
  GUEST_CHECKOUT_APPLE_PAY: "GUEST_CHECKOUT_APPLE_PAY",
  GUEST_CHECKOUT_GOOGLE_PAY: "GUEST_CHECKOUT_GOOGLE_PAY",
} as const;

/**
 * A reusable, PII-free token issued after a user completes verification in the embedded onramp flow. It encodes only the underlying verification IDs, no personal information. Pass it on subsequent orders to take a returning user straight to the pay button, skipping OTP when checking out to the same wallet.

In the embedded flow, `phoneNumber`, `email`, `phoneNumberVerifiedAt`, and `agreementAcceptedAt` are handled by Coinbase in the hosted popup and may be omitted from the request even though they are required for the standard partner-verified flow. Reuse is best-effort: an invalid, expired, or different-wallet token still requires the user to verify. Valid for 60 days.
 */
export type OnrampUserAuthToken = string;

/**
 * The type of fee.
 */
export type OnrampOrderFeeType = (typeof OnrampOrderFeeType)[keyof typeof OnrampOrderFeeType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const OnrampOrderFeeType = {
  FEE_TYPE_NETWORK: "FEE_TYPE_NETWORK",
  FEE_TYPE_EXCHANGE: "FEE_TYPE_EXCHANGE",
} as const;

/**
 * A fee associated with an order.
 */
export interface OnrampOrderFee {
  /** The type of fee. */
  type: OnrampOrderFeeType;
  /** The amount of the fee. */
  amount: string;
  /** The currency of the fee. */
  currency: string;
}

/**
 * The status of an onramp order.
 */
export type OnrampOrderStatus = (typeof OnrampOrderStatus)[keyof typeof OnrampOrderStatus];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const OnrampOrderStatus = {
  ONRAMP_ORDER_STATUS_PENDING_AUTH: "ONRAMP_ORDER_STATUS_PENDING_AUTH",
  ONRAMP_ORDER_STATUS_PENDING_VERIFICATION: "ONRAMP_ORDER_STATUS_PENDING_VERIFICATION",
  ONRAMP_ORDER_STATUS_PENDING_PAYMENT: "ONRAMP_ORDER_STATUS_PENDING_PAYMENT",
  ONRAMP_ORDER_STATUS_PROCESSING: "ONRAMP_ORDER_STATUS_PROCESSING",
  ONRAMP_ORDER_STATUS_COMPLETED: "ONRAMP_ORDER_STATUS_COMPLETED",
  ONRAMP_ORDER_STATUS_FAILED: "ONRAMP_ORDER_STATUS_FAILED",
} as const;

/**
 * An Onramp order.
 */
export interface OnrampOrder {
  /** The ID of the onramp order. */
  orderId: string;
  /** The total amount of fiat to be paid, inclusive of any fees. */
  paymentTotal: string;
  /** The amount of fiat to be converted to crypto. */
  paymentSubtotal: string;
  /** The fiat currency to be converted to crypto. */
  paymentCurrency: string;
  paymentMethod: OnrampOrderPaymentMethodTypeId;
  /** The amount of crypto to be purchased. */
  purchaseAmount: string;
  /** The crypto currency to be purchased. */
  purchaseCurrency: string;
  /** The fees associated with the order. */
  fees: OnrampOrderFee[];
  /** The exchange rate used to convert fiat to crypto i.e. the crypto value of one fiat. */
  exchangeRate: string;
  /** The destination address to send the crypto to. */
  destinationAddress: BlockchainAddress;
  /** The network to send the crypto on. */
  destinationNetwork: string;
  status: OnrampOrderStatus;
  /** The transaction hash of the order (only available once crypto has been sent). */
  txHash?: string;
  /** The date and time the order was created. */
  createdAt: string;
  /** The date and time the order was last updated. */
  updatedAt: string;
  /** The partner user reference ID. */
  partnerUserRef?: string;
}

/**
 * The type of payment link.
 */
export type OnrampPaymentLinkType =
  (typeof OnrampPaymentLinkType)[keyof typeof OnrampPaymentLinkType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const OnrampPaymentLinkType = {
  PAYMENT_LINK_TYPE_APPLE_PAY_BUTTON: "PAYMENT_LINK_TYPE_APPLE_PAY_BUTTON",
  PAYMENT_LINK_TYPE_GOOGLE_PAY_BUTTON: "PAYMENT_LINK_TYPE_GOOGLE_PAY_BUTTON",
  PAYMENT_LINK_TYPE_EMBEDDED_ORDER: "PAYMENT_LINK_TYPE_EMBEDDED_ORDER",
} as const;

/**
 * A payment link to pay for an order.

Please refer to the [Onramp docs](https://docs.cdp.coinbase.com/onramp-&-offramp/onramp-apis/onramp-overview) for details on how to integrate with the different payment link types.
 */
export interface OnrampPaymentLink {
  /** The URL to the hosted widget the user should be redirected to. For certain payment link types you can append your own redirect_url query parameter to this URL to ensure the user is redirected back to your app after the widget completes. */
  url: Url;
  paymentLinkType: OnrampPaymentLinkType;
}

/**
 * The type of payment method used to generate the onramp quote.
 */
export type OnrampQuotePaymentMethodTypeId =
  (typeof OnrampQuotePaymentMethodTypeId)[keyof typeof OnrampQuotePaymentMethodTypeId];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const OnrampQuotePaymentMethodTypeId = {
  CARD: "CARD",
  ACH: "ACH",
  APPLE_PAY: "APPLE_PAY",
  PAYPAL: "PAYPAL",
  FIAT_WALLET: "FIAT_WALLET",
  CRYPTO_WALLET: "CRYPTO_WALLET",
} as const;

/**
 * A valid URI.
 * @minLength 5
 * @maxLength 2048
 * @pattern ^.*://.*$
 */
export type Uri = string;

/**
 * Common request parameters shared by [Create Onramp Session](#operation/createOnrampSession) and [Create Onramp Mobile Challenge](#operation/createOnrampMobileChallenge).
 */
export interface OnrampSessionRequest {
  /** The ticker (e.g. `BTC`, `USDC`, `SOL`) or the Coinbase UUID (e.g. `d85dce9b-5b73-5c3c-8978-522ce1d1c1b4`) of the crypto asset to be purchased.

Use the [Onramp Buy Options API](https://docs.cdp.coinbase.com/api-reference/rest-api/onramp-offramp/get-buy-options) to discover the supported purchase currencies for your user's location. */
  purchaseCurrency: string;
  /** The name of the crypto network the purchased currency will be sent on.

Use the [Onramp Buy Options API](https://docs.cdp.coinbase.com/api-reference/rest-api/onramp-offramp/get-buy-options) to discover the supported networks for your user's location. */
  destinationNetwork: string;
  /** The address the purchased crypto will be sent to. */
  destinationAddress: BlockchainAddress;
  /** A string representing the amount of fiat the user wishes to pay in exchange for crypto. When using this parameter, the returned quote will be inclusive of fees i.e. the user will pay this exact amount of the payment currency. */
  paymentAmount?: string;
  /** A string representing the amount of crypto the user wishes to purchase. When using this parameter, the returned quote will be exclusive of fees i.e. the user will receive this exact amount of the purchase currency. */
  purchaseAmount?: string;
  /** The fiat currency to be converted to crypto. */
  paymentCurrency?: string;
  paymentMethod?: OnrampQuotePaymentMethodTypeId;
  /** The ISO 3166-1 two letter country code (e.g. US). */
  country?: string;
  /** The ISO 3166-2 two letter state code (e.g. NY). Only required for US. */
  subdivision?: string;
  /** URI to redirect the user to after they complete or dismiss the transaction. Embedded in the returned onramp URL as a query parameter. */
  redirectUrl?: Uri;
  /** The IP address of the end user requesting the onramp transaction. */
  clientIp?: string;
  /** A unique string that represents the user in your app. This can be used to link individual transactions together so you can retrieve the transaction history for your users. Prefix this string with "sandbox-" (e.g. "sandbox-user-1234") to perform a sandbox transaction which will allow you to test your integration without any real transfer of funds.

This value can be used with the [Onramp User Transactions API](https://docs.cdp.coinbase.com/api-reference/rest-api/onramp-offramp/get-onramp-transactions-by-id) to retrieve all transactions created by the user. */
  partnerUserRef?: string;
}

/**
 * An onramp session containing a ready-to-use onramp URL.
 */
export interface OnrampSession {
  /** Ready-to-use onramp URL. */
  onrampUrl: Url;
}

/**
 * Quote information with pricing details for the crypto purchase.
 */
export interface OnrampQuote {
  /** The total amount of fiat to be paid, inclusive of any fees. */
  paymentTotal: string;
  /** The amount of fiat to be converted to crypto. */
  paymentSubtotal: string;
  /** The fiat currency to be converted to crypto. */
  paymentCurrency: string;
  /** The amount of crypto to be purchased. */
  purchaseAmount: string;
  /** The crypto currency to be purchased. */
  purchaseCurrency: string;
  /** The network to send the crypto on. */
  destinationNetwork: string;
  /** The fees associated with the quote. */
  fees: OnrampOrderFee[];
  /** The exchange rate used to convert fiat to crypto i.e. the crypto value of one fiat. */
  exchangeRate: string;
}

/**
 * The type of user identifier:
- `phone_number`: A phone number in E.164 format associated with an onramp user.

 */
export type OnrampUserIdType = (typeof OnrampUserIdType)[keyof typeof OnrampUserIdType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const OnrampUserIdType = {
  phone_number: "phone_number",
} as const;

/**
 * The type of limit:
- `weekly_spending`: Rolling 7-day spending limit. The limit applies to the sum of all completed transactions 
  within a sliding 168-hour (7-day) window. As time passes, older transactions naturally expire from the window. 
  $500 is the default limit.
- `lifetime_transactions`: All-time transaction count limit. Tracks the total number of completed transactions 
  across the user's entire history with no time-based expiration. Once the limit is reached, no further 
  transactions are allowed. 15 is the default limit.

 */
export type OnrampLimitType = (typeof OnrampLimitType)[keyof typeof OnrampLimitType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const OnrampLimitType = {
  weekly_spending: "weekly_spending",
  lifetime_transactions: "lifetime_transactions",
} as const;

/**
 * A single limit with remaining capacity.
 */
export interface OnrampUserLimit {
  limitType: OnrampLimitType;
  /** The currency of the limit amounts. Only present for spending limits, not for count-based limits. */
  currency?: string;
  /** The maximum limit value. */
  limit: string;
  /** The remaining amount or count available. */
  remaining: string;
}

/**
 * The status of verification:
- `unrequested`: The limit upgrade has not been submitted.
- `resubmit`: One or more identity fields must be resubmitted.
- `pending`: The submitted identity fields are pending review.
- `active`: The limit upgrade is active.
- `inactive`: The limit upgrade was rejected and cannot be resubmitted.

 */
export type OnrampLimitUpgradeStatus =
  (typeof OnrampLimitUpgradeStatus)[keyof typeof OnrampLimitUpgradeStatus];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const OnrampLimitUpgradeStatus = {
  unrequested: "unrequested",
  resubmit: "resubmit",
  pending: "pending",
  active: "active",
  inactive: "inactive",
} as const;

/**
 * The identity field key for limit upgrades. These keys correspond to the fields
in the limits upgrade request:
- `ssnLast4`: Last 4 digits of the Social Security Number
- `dateOfBirth`: Date of birth

 */
export type OnrampLimitUpgradeIdentityFieldKey =
  (typeof OnrampLimitUpgradeIdentityFieldKey)[keyof typeof OnrampLimitUpgradeIdentityFieldKey];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const OnrampLimitUpgradeIdentityFieldKey = {
  ssnLast4: "ssnLast4",
  dateOfBirth: "dateOfBirth",
} as const;

/**
 * Describes a limit value associated with an upgrade.
 */
export interface OnrampLimitUpgrade {
  limitType: OnrampLimitType;
  /** The maximum limit value possible after completing the upgrade. Risk factors may impact the actual limit value that takes effect. For `lifetime_transactions`, `2147483647` represents an unlimited number of transactions. */
  maxUpgrade: string;
}

/**
 * Describes the current status and potential limit changes for a limit upgrade.
 */
export interface OnrampLimitUpgradeOption {
  status: OnrampLimitUpgradeStatus;
  /** The identity fields associated with the current status. Contains fields to submit for `unrequested` and `resubmit`, fields pending review for `pending`, and is empty for `active` and `inactive`. */
  fields: OnrampLimitUpgradeIdentityFieldKey[];
  /** The limit values associated with this upgrade. */
  limitUpgrades: OnrampLimitUpgrade[];
}

/**
 * The interaction mode for the limit upgrade request:
- `api`: Submit identity fields directly in the API request.
- `embedded`: Return a Coinbase-hosted URL where the user enters identity fields.

 */
export type OnrampLimitUpgradeInteractionMode =
  (typeof OnrampLimitUpgradeInteractionMode)[keyof typeof OnrampLimitUpgradeInteractionMode];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const OnrampLimitUpgradeInteractionMode = {
  OnrampLimitUpgradeInteractionModeAPI: "api",
  OnrampLimitUpgradeInteractionModeEmbedded: "embedded",
} as const;

/**
 * Populate the properties that correspond to the `fields` array from the user's `OnrampLimitUpgradeOption`.
 */
export interface OnrampLimitUpgradeIdentityFields {
  /** Last 4 digits of the Social Security Number (no dashes or spaces). */
  ssnLast4?: string;
  /** Date of birth. */
  dateOfBirth?: DateOfBirth;
}

/**
 * Request to request a limits upgrade for a user.
 */
export interface OnrampLimitUpgradeRequest {
  /** The user identifier value. For `phone_number` type, this must be in E.164 format. */
  userId: string;
  userIdType: OnrampUserIdType;
  /** The interaction mode for the limit upgrade request. Defaults to `api`. */
  interactionMode?: OnrampLimitUpgradeInteractionMode;
  /** Populate the properties that correspond to the `fields` array from the user's `OnrampLimitUpgradeOption`. Required in `api` mode. Omit in `embedded` mode — the user enters their identity information on the Coinbase-hosted upgrade page (see `interactionMode`), so any value sent here is rejected. */
  fields?: OnrampLimitUpgradeIdentityFields;
}

/**
 * A Coinbase-hosted URL for collecting limit upgrade identity fields.
 */
export interface OnrampLimitUpgradeEmbeddedResponse {
  /** The Coinbase-hosted URL where the user enters identity information for the limit upgrade. Treat the session token in this URL as opaque. */
  upgradeUrl: Url;
  /** The time at which the hosted limit upgrade URL expires. Request a new upgrade URL after this time. */
  expiresAt: string;
}

/**
 * Common properties shared by all payment method types.
 */
export interface PaymentMethodBase {
  paymentMethodId: PaymentMethodId;
  /** Whether the payment method is active and can be used in transfers. A payment method may be inactive due to verification requirements or entity-level restrictions. */
  active: boolean;
  /** The timestamp when the payment method was created. */
  createdAt: string;
  /** The timestamp when the payment method was last updated. */
  updatedAt: string;
}

/**
 * Details specific to Fedwire (domestic USD wire) payment methods.
 */
export interface FedwireDetails {
  /** The asset for this payment method. Always `usd` for Fedwire. */
  asset: string;
  /** The name of the bank. */
  bankName: string;
  /**
   * The last 4 digits of the bank account number.
   * @pattern ^[0-9]{4}$
   */
  accountLast4: string;
  /**
   * The ABA routing number of the bank.
   * @pattern ^[0-9]{9}$
   */
  routingNumber: string;
}

/**
 * The payment rail for this payment method.
 */
export type FedwirePaymentMethodAllOfPaymentRail =
  (typeof FedwirePaymentMethodAllOfPaymentRail)[keyof typeof FedwirePaymentMethodAllOfPaymentRail];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const FedwirePaymentMethodAllOfPaymentRail = {
  fedwire: "fedwire",
} as const;

export type FedwirePaymentMethodAllOf = {
  /** The payment rail for this payment method. */
  paymentRail: FedwirePaymentMethodAllOfPaymentRail;
  /** Fedwire (domestic USD wire) details. */
  fedwire: FedwireDetails;
};

export type FedwirePaymentMethodPaymentRail =
  (typeof FedwirePaymentMethodPaymentRail)[keyof typeof FedwirePaymentMethodPaymentRail];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const FedwirePaymentMethodPaymentRail = {
  fedwire: "fedwire",
} as const;

/**
 * A Fedwire (domestic USD wire) payment method linked to your entity.
 */
export type FedwirePaymentMethod = PaymentMethodBase &
  FedwirePaymentMethodAllOf & {
    paymentRail: FedwirePaymentMethodPaymentRail;
  };

/**
 * Details specific to SWIFT (international wire) payment methods.
 */
export interface SwiftDetails {
  /** The asset for this payment method (e.g., `eur`, `gbp`). */
  asset: string;
  /** The name of the bank. */
  bankName: string;
  /**
   * The last 4 characters of the account identifier. For IBAN-based accounts (e.g., EU), this is the last 4 characters of the IBAN. For account number-based accounts (e.g., US), this is the last 4 digits of the account number.
   * @pattern ^[A-Z0-9]{4}$
   */
  accountLast4: string;
  /**
   * Deprecated: use `accountLast4` instead. The last 4 characters of the account identifier.
   * @deprecated
   * @pattern ^[A-Z0-9]{4}$
   */
  ibanLast4?: string;
  /**
   * The Bank Identifier Code (BIC) / SWIFT code.
   * @pattern ^[A-Z]{6}[A-Z0-9]{2}([A-Z0-9]{3})?$
   */
  bic: string;
}

/**
 * The payment rail for this payment method.
 */
export type SwiftPaymentMethodAllOfPaymentRail =
  (typeof SwiftPaymentMethodAllOfPaymentRail)[keyof typeof SwiftPaymentMethodAllOfPaymentRail];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SwiftPaymentMethodAllOfPaymentRail = {
  swift: "swift",
} as const;

export type SwiftPaymentMethodAllOf = {
  /** The payment rail for this payment method. */
  paymentRail: SwiftPaymentMethodAllOfPaymentRail;
  /** SWIFT (international wire) details. */
  swift: SwiftDetails;
};

export type SwiftPaymentMethodPaymentRail =
  (typeof SwiftPaymentMethodPaymentRail)[keyof typeof SwiftPaymentMethodPaymentRail];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SwiftPaymentMethodPaymentRail = {
  swift: "swift",
} as const;

/**
 * A SWIFT (international wire) payment method linked to your entity.
 */
export type SwiftPaymentMethod = PaymentMethodBase &
  SwiftPaymentMethodAllOf & {
    paymentRail: SwiftPaymentMethodPaymentRail;
  };

/**
 * Details specific to SEPA (Single Euro Payments Area) payment methods.
 */
export interface SepaDetails {
  /** The asset for this payment method. Always `eur` for SEPA. */
  asset: string;
  /** The name of the bank. */
  bankName: string;
  /**
   * The last 4 characters of the IBAN.
   * @pattern ^[A-Z0-9]{4}$
   */
  ibanLast4: string;
  /**
   * The Bank Identifier Code (BIC) / SWIFT code.
   * @pattern ^[A-Z]{6}[A-Z0-9]{2}([A-Z0-9]{3})?$
   */
  bic: string;
}

/**
 * The payment rail for this payment method.
 */
export type SepaPaymentMethodAllOfPaymentRail =
  (typeof SepaPaymentMethodAllOfPaymentRail)[keyof typeof SepaPaymentMethodAllOfPaymentRail];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SepaPaymentMethodAllOfPaymentRail = {
  sepa: "sepa",
} as const;

export type SepaPaymentMethodAllOf = {
  /** The payment rail for this payment method. */
  paymentRail: SepaPaymentMethodAllOfPaymentRail;
  /** SEPA (Single Euro Payments Area) details. */
  sepa: SepaDetails;
};

export type SepaPaymentMethodPaymentRail =
  (typeof SepaPaymentMethodPaymentRail)[keyof typeof SepaPaymentMethodPaymentRail];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SepaPaymentMethodPaymentRail = {
  sepa: "sepa",
} as const;

/**
 * A SEPA (Single Euro Payments Area) payment method linked to your entity.
 */
export type SepaPaymentMethod = PaymentMethodBase &
  SepaPaymentMethodAllOf & {
    paymentRail: SepaPaymentMethodPaymentRail;
  };

/**
 * A payment method linked to your entity. Payment methods represent external financial instruments that can be used as a target for transfers.

The `paymentRail` field indicates which type-specific details object is present. Type-specific fields are nested under a key matching the rail name (e.g., `fedwire`, `swift`).
 */
export type PaymentMethodsPaymentMethod =
  | FedwirePaymentMethod
  | SwiftPaymentMethod
  | SepaPaymentMethod;

/**
 * Decoded event parameters from the contract event. Keys correspond to the named arguments in the event signature (e.g., `from`, `to`, `value` for an ERC-20 `Transfer`). Values are returned as strings to preserve precision for large integers and to avoid loss for address types. The exact set of keys depends on the contract event.
 */
export interface OnchainActivityEventParameters {
  [key: string]: string;
}

/**
 * The payload delivered when onchain activity matching your subscription filters is detected. Each event corresponds to a single decoded contract log emitted onchain. The set of keys in `parameters` varies by the contract event being decoded (e.g., `Transfer(address,address,uint256)`).
 */
export interface OnchainActivityDetectedEvent {
  /** The block number containing the transaction that emitted the event. */
  block_number: number;
  /** The contract address that emitted the event. */
  contract_address: string;
  /** The name of the decoded contract event. */
  event_name: string;
  /** The canonical event signature used to decode the log, including parameter types (e.g., `Transfer(address,address,uint256)`). */
  event_signature: string;
  /** The zero-based index of the log within the transaction. */
  log_index: number;
  /** The blockchain network where the activity was detected. */
  network: string;
  parameters: OnchainActivityEventParameters;
  /** The block timestamp of the transaction (ISO 8601 format). */
  timestamp: string;
  /** The address that initiated the transaction (the transaction sender). */
  transaction_from: string;
  /** The hash of the transaction that emitted the event. */
  transaction_hash: string;
  /** The address the transaction was sent to (typically a contract address). */
  transaction_to: string;
}

/**
 * Decoded blockchain event data for the wallet activity webhook. The exact fields depend on the type of onchain activity detected. Common fields include network, block info, and transaction hash. Additional fields are event-specific (e.g., `from`, `to`, `value` for transfers).
 */
export interface OnchainActivityEventData {
  /** The blockchain network where the activity was detected. */
  network: string;
  /** The block number containing the transaction. */
  blockNumber?: string;
  /** The timestamp of the block. */
  blockTimestamp?: string;
  /** The transaction hash of the detected activity. */
  transactionHash: string;
  /** The log index within the transaction. */
  logIndex?: string;
  /** The contract address that emitted the event. */
  contractAddress?: string;
  /** The name of the decoded contract event. */
  eventName?: string;
  [key: string]: unknown;
}

/**
 * Common fields included in every wallet activity webhook event payload.
 */
export interface WalletActivityEventBase {
  /** Unique identifier for this webhook event. Use this for idempotency. */
  eventId: string;
  /** When this event occurred (ISO 8601 format). */
  timestamp: string;
  data: OnchainActivityEventData;
}

/**
 * The type of webhook event.
 */
export type WalletActivityDetectedEventAllOfEventType =
  (typeof WalletActivityDetectedEventAllOfEventType)[keyof typeof WalletActivityDetectedEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const WalletActivityDetectedEventAllOfEventType = {
  walletactivitydetected: "wallet.activity.detected",
} as const;

export type WalletActivityDetectedEventAllOf = {
  /** The type of webhook event. */
  eventType: WalletActivityDetectedEventAllOfEventType;
};

export type WalletActivityDetectedEvent = WalletActivityEventBase &
  WalletActivityDetectedEventAllOf;

/**
 * The type of webhook event.
 */
export type WalletActivityMultiEventAllOfEventType =
  (typeof WalletActivityMultiEventAllOfEventType)[keyof typeof WalletActivityMultiEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const WalletActivityMultiEventAllOfEventType = {
  walletactivitymulti: "wallet.activity.multi",
} as const;

export type WalletActivityMultiEventAllOf = {
  /** The type of webhook event. */
  eventType: WalletActivityMultiEventAllOfEventType;
};

export type WalletActivityMultiEvent = WalletActivityEventBase & WalletActivityMultiEventAllOf;

/**
 * Payload for `wallet.transaction.created` on EVM networks. Includes the originating `address`.
 */
export interface WalletEvmTransactionCreatedPayload {
  /**
   * The EVM wallet address that created the transaction.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  address: BlockchainAddress;
  /** The blockchain network identifier. */
  network: Network;
  /** When the transaction was created (ISO 8601 format). */
  created_at: string;
}

/**
 * Payload for API Key Wallet events. These events carry no end-user payload fields, so neither `user_id` nor `delegation_id` is present.
 */
export interface WalletApiKeyEventPayload {
  [key: string]: unknown;
}

/**
 * Payload for `wallet.transaction.created` on Solana. Solana transaction events do not include an `address`.
 */
export interface WalletSolanaTransactionCreatedPayload {
  /** The blockchain network identifier. */
  network: Network;
  /** When the transaction was created (ISO 8601 format). */
  created_at: string;
}

/**
 * Payload for User Wallet events. The wallet is owned by an end user, identified by `user_id`. User Wallet actions do not include `delegation_id`.
 */
export interface WalletUserEventPayload {
  /** The user ID that owns the User Wallet. */
  user_id: string;
}

/**
 * Payload for delegated User Wallet events, where a User Wallet action was authorized via a delegation grant. Includes `user_id` and the `delegation_id` of the active grant.
 */
export interface WalletDelegatedEventPayload {
  /** The user ID that owns the User Wallet. */
  user_id: string;
  /** The delegation grant ID used to authorize the action. */
  delegation_id: string;
}

export type WalletTransactionCreatedEventOneOf = WalletEvmTransactionCreatedPayload &
  WalletApiKeyEventPayload;

export type WalletTransactionCreatedEventOneOfTwo = WalletSolanaTransactionCreatedPayload &
  WalletApiKeyEventPayload;

export type WalletTransactionCreatedEventOneOfThree = WalletEvmTransactionCreatedPayload &
  WalletUserEventPayload;

export type WalletTransactionCreatedEventOneOfFour = WalletSolanaTransactionCreatedPayload &
  WalletUserEventPayload;

export type WalletTransactionCreatedEventOneOfFive = WalletEvmTransactionCreatedPayload &
  WalletDelegatedEventPayload;

export type WalletTransactionCreatedEventOneOfSix = WalletSolanaTransactionCreatedPayload &
  WalletDelegatedEventPayload;

/**
 * Delivered when a transaction is created. The payload is one of six variants: API Key Wallet, User Wallet, or User Wallet (Delegated Signing), each delivered as an EVM or Solana variant.
 */
export type WalletTransactionCreatedEvent =
  | WalletTransactionCreatedEventOneOf
  | WalletTransactionCreatedEventOneOfTwo
  | WalletTransactionCreatedEventOneOfThree
  | WalletTransactionCreatedEventOneOfFour
  | WalletTransactionCreatedEventOneOfFive
  | WalletTransactionCreatedEventOneOfSix;

/**
 * Payload for EVM wallet signing events. Carries the EVM signing `address` and timestamp; no network or transaction identifier.
 */
export interface WalletEvmSigningPayload {
  /**
   * The EVM wallet address that performed the signing.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  address: BlockchainAddress;
  /** When the signing occurred (ISO 8601 format). */
  signed_at: string;
}

/**
 * Payload for Solana wallet signing events. Carries the Solana signing `address` and timestamp; no network or transaction identifier.
 */
export interface WalletSolanaSigningPayload {
  /**
   * The Solana wallet address that performed the signing.
   * @pattern ^[1-9A-HJ-NP-Za-km-z]{32,44}$
   */
  address: BlockchainAddress;
  /** When the signing occurred (ISO 8601 format). */
  signed_at: string;
}

export type WalletTransactionSignedEventOneOf = WalletEvmSigningPayload & WalletApiKeyEventPayload;

export type WalletTransactionSignedEventOneOfTwo = WalletSolanaSigningPayload &
  WalletApiKeyEventPayload;

export type WalletTransactionSignedEventOneOfThree = WalletEvmSigningPayload &
  WalletUserEventPayload;

export type WalletTransactionSignedEventOneOfFour = WalletSolanaSigningPayload &
  WalletUserEventPayload;

export type WalletTransactionSignedEventOneOfFive = WalletEvmSigningPayload &
  WalletDelegatedEventPayload;

export type WalletTransactionSignedEventOneOfSix = WalletSolanaSigningPayload &
  WalletDelegatedEventPayload;

/**
 * Delivered when a transaction is signed. Emitted for both EVM and Solana wallets. The payload is one of six variants: API Key Wallet, User Wallet, or User Wallet (Delegated Signing), each delivered as an EVM or Solana variant.
 */
export type WalletTransactionSignedEvent =
  | WalletTransactionSignedEventOneOf
  | WalletTransactionSignedEventOneOfTwo
  | WalletTransactionSignedEventOneOfThree
  | WalletTransactionSignedEventOneOfFour
  | WalletTransactionSignedEventOneOfFive
  | WalletTransactionSignedEventOneOfSix;

/**
 * Payload for `wallet.transaction.broadcast` on EVM networks. Includes `transaction_hash` and `address`.
 */
export interface WalletEvmTransactionBroadcastPayload {
  /** The onchain transaction hash. */
  transaction_hash: string;
  /**
   * The EVM wallet address that broadcast the transaction.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  address: BlockchainAddress;
  /** The blockchain network identifier. */
  network: Network;
  /** When the transaction was broadcast (ISO 8601 format). */
  broadcast_at: string;
}

/**
 * Payload for `wallet.transaction.broadcast` on Solana. Includes `transaction_signature` and omits `address`.
 */
export interface WalletSolanaTransactionBroadcastPayload {
  /** The Solana transaction signature. */
  transaction_signature: string;
  /** The blockchain network identifier. */
  network: Network;
  /** When the transaction was broadcast (ISO 8601 format). */
  broadcast_at: string;
}

export type WalletTransactionBroadcastEventOneOf = WalletEvmTransactionBroadcastPayload &
  WalletApiKeyEventPayload;

export type WalletTransactionBroadcastEventOneOfTwo = WalletSolanaTransactionBroadcastPayload &
  WalletApiKeyEventPayload;

export type WalletTransactionBroadcastEventOneOfThree = WalletEvmTransactionBroadcastPayload &
  WalletUserEventPayload;

export type WalletTransactionBroadcastEventOneOfFour = WalletSolanaTransactionBroadcastPayload &
  WalletUserEventPayload;

export type WalletTransactionBroadcastEventOneOfFive = WalletEvmTransactionBroadcastPayload &
  WalletDelegatedEventPayload;

export type WalletTransactionBroadcastEventOneOfSix = WalletSolanaTransactionBroadcastPayload &
  WalletDelegatedEventPayload;

/**
 * Delivered when a transaction is broadcast to the network. The payload is one of six variants: API Key Wallet, User Wallet, or User Wallet (Delegated Signing), each delivered as an EVM or Solana variant.
 */
export type WalletTransactionBroadcastEvent =
  | WalletTransactionBroadcastEventOneOf
  | WalletTransactionBroadcastEventOneOfTwo
  | WalletTransactionBroadcastEventOneOfThree
  | WalletTransactionBroadcastEventOneOfFour
  | WalletTransactionBroadcastEventOneOfFive
  | WalletTransactionBroadcastEventOneOfSix;

/**
 * Payload for `wallet.transaction.replaced`. EVM-only; Solana transactions are not replaceable.
 */
export interface WalletTransactionReplacedPayload {
  /** The onchain transaction hash of the replaced transaction. */
  transaction_hash: string;
  /**
   * The EVM wallet address whose transaction was replaced.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  address: BlockchainAddress;
  /** The blockchain network identifier. */
  network: Network;
  /** When the transaction was replaced (ISO 8601 format). */
  replaced_at: string;
}

export type WalletTransactionReplacedEventOneOf = WalletTransactionReplacedPayload &
  WalletApiKeyEventPayload;

export type WalletTransactionReplacedEventOneOfTwo = WalletTransactionReplacedPayload &
  WalletUserEventPayload;

export type WalletTransactionReplacedEventOneOfThree = WalletTransactionReplacedPayload &
  WalletDelegatedEventPayload;

/**
 * Delivered when a pending transaction is replaced (e.g. a fee bump). EVM-only. The payload is one of three EVM wallet-type variants: API Key Wallet, User Wallet, or User Wallet (Delegated Signing).
 */
export type WalletTransactionReplacedEvent =
  | WalletTransactionReplacedEventOneOf
  | WalletTransactionReplacedEventOneOfTwo
  | WalletTransactionReplacedEventOneOfThree;

/**
 * Payload for `wallet.transaction.pending`. EVM-only. EIP-1559 fee fields are included.
 */
export interface WalletTransactionPendingPayload {
  /** The onchain transaction hash. */
  transaction_hash: string;
  /**
   * The EVM wallet address whose transaction is pending.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  address: BlockchainAddress;
  /** The blockchain network identifier. */
  network: Network;
  /** When the transaction entered the pending state (ISO 8601 format). */
  pending_since: string;
  /** EIP-1559 max fee per gas in wei. */
  max_fee_per_gas: string;
  /** EIP-1559 max priority fee per gas in wei. */
  max_priority_fee_per_gas: string;
}

export type WalletTransactionPendingEventOneOf = WalletTransactionPendingPayload &
  WalletApiKeyEventPayload;

export type WalletTransactionPendingEventOneOfTwo = WalletTransactionPendingPayload &
  WalletUserEventPayload;

export type WalletTransactionPendingEventOneOfThree = WalletTransactionPendingPayload &
  WalletDelegatedEventPayload;

/**
 * Delivered when a transaction enters the pending state. EVM-only. The payload is one of three EVM wallet-type variants: API Key Wallet, User Wallet, or User Wallet (Delegated Signing).
 */
export type WalletTransactionPendingEvent =
  | WalletTransactionPendingEventOneOf
  | WalletTransactionPendingEventOneOfTwo
  | WalletTransactionPendingEventOneOfThree;

/**
 * Payload for `wallet.transaction.confirmed` on EVM networks. Includes `transaction_hash` and `address`.
 */
export interface WalletEvmTransactionConfirmedPayload {
  /** The onchain transaction hash. */
  transaction_hash: string;
  /**
   * The EVM wallet address that submitted the transaction.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  address: BlockchainAddress;
  /** The blockchain network identifier. */
  network: Network;
  /** When the transaction was confirmed (ISO 8601 format). */
  confirmed_at: string;
}

/**
 * Payload for `wallet.transaction.confirmed` on Solana. Includes `transaction_signature` and omits `address`.
 */
export interface WalletSolanaTransactionConfirmedPayload {
  /** The Solana transaction signature. */
  transaction_signature: string;
  /** The blockchain network identifier. */
  network: Network;
  /** When the transaction was confirmed (ISO 8601 format). */
  confirmed_at: string;
}

export type WalletTransactionConfirmedEventOneOf = WalletEvmTransactionConfirmedPayload &
  WalletApiKeyEventPayload;

export type WalletTransactionConfirmedEventOneOfTwo = WalletSolanaTransactionConfirmedPayload &
  WalletApiKeyEventPayload;

export type WalletTransactionConfirmedEventOneOfThree = WalletEvmTransactionConfirmedPayload &
  WalletUserEventPayload;

export type WalletTransactionConfirmedEventOneOfFour = WalletSolanaTransactionConfirmedPayload &
  WalletUserEventPayload;

export type WalletTransactionConfirmedEventOneOfFive = WalletEvmTransactionConfirmedPayload &
  WalletDelegatedEventPayload;

export type WalletTransactionConfirmedEventOneOfSix = WalletSolanaTransactionConfirmedPayload &
  WalletDelegatedEventPayload;

/**
 * Delivered when a transaction is confirmed onchain. The payload is one of six variants: API Key Wallet, User Wallet, or User Wallet (Delegated Signing), each delivered as an EVM or Solana variant.
 */
export type WalletTransactionConfirmedEvent =
  | WalletTransactionConfirmedEventOneOf
  | WalletTransactionConfirmedEventOneOfTwo
  | WalletTransactionConfirmedEventOneOfThree
  | WalletTransactionConfirmedEventOneOfFour
  | WalletTransactionConfirmedEventOneOfFive
  | WalletTransactionConfirmedEventOneOfSix;

/**
 * Payload for `wallet.transaction.failed` on EVM networks. Includes `transaction_hash` and `address`.
 */
export interface WalletEvmTransactionFailedPayload {
  /** The onchain transaction hash. */
  transaction_hash: string;
  /**
   * The EVM wallet address that submitted the transaction.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  address: BlockchainAddress;
  /** The blockchain network identifier. */
  network: Network;
  /** When the transaction failed (ISO 8601 format). */
  failed_at: string;
}

/**
 * Payload for `wallet.transaction.failed` on Solana. Includes `transaction_signature` and omits `address`.
 */
export interface WalletSolanaTransactionFailedPayload {
  /** The Solana transaction signature. */
  transaction_signature: string;
  /** The blockchain network identifier. */
  network: Network;
  /** When the transaction failed (ISO 8601 format). */
  failed_at: string;
}

export type WalletTransactionFailedEventOneOf = WalletEvmTransactionFailedPayload &
  WalletApiKeyEventPayload;

export type WalletTransactionFailedEventOneOfTwo = WalletSolanaTransactionFailedPayload &
  WalletApiKeyEventPayload;

export type WalletTransactionFailedEventOneOfThree = WalletEvmTransactionFailedPayload &
  WalletUserEventPayload;

export type WalletTransactionFailedEventOneOfFour = WalletSolanaTransactionFailedPayload &
  WalletUserEventPayload;

export type WalletTransactionFailedEventOneOfFive = WalletEvmTransactionFailedPayload &
  WalletDelegatedEventPayload;

export type WalletTransactionFailedEventOneOfSix = WalletSolanaTransactionFailedPayload &
  WalletDelegatedEventPayload;

/**
 * Delivered when a transaction fails. The payload is one of six variants: API Key Wallet, User Wallet, or User Wallet (Delegated Signing), each delivered as an EVM or Solana variant.
 */
export type WalletTransactionFailedEvent =
  | WalletTransactionFailedEventOneOf
  | WalletTransactionFailedEventOneOfTwo
  | WalletTransactionFailedEventOneOfThree
  | WalletTransactionFailedEventOneOfFour
  | WalletTransactionFailedEventOneOfFive
  | WalletTransactionFailedEventOneOfSix;

/**
 * Delivered when a delegation grant is created for a User Wallet.
 */
export interface WalletDelegationCreatedEvent {
  /** The unique identifier for the delegation grant. */
  delegation_id: string;
  /** The user ID that owns the delegation. */
  user_id: string;
  /** When the delegation expires (ISO 8601 format). */
  expires_at: string;
  /** When the delegation was created (ISO 8601 format). */
  created_at: string;
}

/**
 * Delivered when a delegation grant is revoked.
 */
export interface WalletDelegationRevokedEvent {
  /** The unique identifier for the delegation grant. */
  delegation_id: string;
  /** The user ID that owns the delegation. */
  user_id: string;
  /** When the delegation was revoked (ISO 8601 format). */
  revoked_at: string;
}

export type WalletTypedDataSignedEventOneOf = WalletEvmSigningPayload & WalletApiKeyEventPayload;

export type WalletTypedDataSignedEventOneOfTwo = WalletEvmSigningPayload & WalletUserEventPayload;

export type WalletTypedDataSignedEventOneOfThree = WalletEvmSigningPayload &
  WalletDelegatedEventPayload;

/**
 * Delivered when EIP-712 typed data is signed. EVM-only. Uses the EVM signing payload. The payload is one of three EVM wallet-type variants: API Key Wallet, User Wallet, or User Wallet (Delegated Signing).
 */
export type WalletTypedDataSignedEvent =
  | WalletTypedDataSignedEventOneOf
  | WalletTypedDataSignedEventOneOfTwo
  | WalletTypedDataSignedEventOneOfThree;

export type WalletMessageSignedEventOneOf = WalletEvmSigningPayload & WalletApiKeyEventPayload;

export type WalletMessageSignedEventOneOfTwo = WalletSolanaSigningPayload &
  WalletApiKeyEventPayload;

export type WalletMessageSignedEventOneOfThree = WalletEvmSigningPayload & WalletUserEventPayload;

export type WalletMessageSignedEventOneOfFour = WalletSolanaSigningPayload & WalletUserEventPayload;

export type WalletMessageSignedEventOneOfFive = WalletEvmSigningPayload &
  WalletDelegatedEventPayload;

export type WalletMessageSignedEventOneOfSix = WalletSolanaSigningPayload &
  WalletDelegatedEventPayload;

/**
 * Delivered when a message is signed. Emitted for both EVM and Solana wallets. The payload is one of six variants: API Key Wallet, User Wallet, or User Wallet (Delegated Signing), each delivered as an EVM or Solana variant.
 */
export type WalletMessageSignedEvent =
  | WalletMessageSignedEventOneOf
  | WalletMessageSignedEventOneOfTwo
  | WalletMessageSignedEventOneOfThree
  | WalletMessageSignedEventOneOfFour
  | WalletMessageSignedEventOneOfFive
  | WalletMessageSignedEventOneOfSix;

export type WalletHashSignedEventOneOf = WalletEvmSigningPayload & WalletApiKeyEventPayload;

export type WalletHashSignedEventOneOfTwo = WalletSolanaSigningPayload & WalletApiKeyEventPayload;

export type WalletHashSignedEventOneOfThree = WalletEvmSigningPayload & WalletUserEventPayload;

export type WalletHashSignedEventOneOfFour = WalletSolanaSigningPayload & WalletUserEventPayload;

export type WalletHashSignedEventOneOfFive = WalletEvmSigningPayload & WalletDelegatedEventPayload;

export type WalletHashSignedEventOneOfSix = WalletSolanaSigningPayload &
  WalletDelegatedEventPayload;

/**
 * Delivered when a raw hash is signed. Emitted for both EVM and Solana wallets. The payload is one of six variants: API Key Wallet, User Wallet, or User Wallet (Delegated Signing), each delivered as an EVM or Solana variant.
 */
export type WalletHashSignedEvent =
  | WalletHashSignedEventOneOf
  | WalletHashSignedEventOneOfTwo
  | WalletHashSignedEventOneOfThree
  | WalletHashSignedEventOneOfFour
  | WalletHashSignedEventOneOfFive
  | WalletHashSignedEventOneOfSix;

/**
 * Common envelope fields included in every payments transfers webhook event payload.
 */
export interface PaymentsTransfersEventBase {
  /** Unique identifier for this webhook event. Use this for idempotency. */
  eventID: string;
  /** The type of webhook event. */
  eventType: string;
  /** The UTC ISO 8601 timestamp at which the underlying state change occurred, not the time at which this webhook was delivered. */
  timestamp: string;
  data: Transfer;
}

/**
 * The type of webhook event.
 */
export type PaymentsTransfersQuotedEventAllOfEventType =
  (typeof PaymentsTransfersQuotedEventAllOfEventType)[keyof typeof PaymentsTransfersQuotedEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const PaymentsTransfersQuotedEventAllOfEventType = {
  paymentstransfersquoted: "payments.transfers.quoted",
} as const;

export type PaymentsTransfersQuotedEventAllOf = {
  /** The type of webhook event. */
  eventType: PaymentsTransfersQuotedEventAllOfEventType;
};

export type PaymentsTransfersQuotedEvent = PaymentsTransfersEventBase &
  PaymentsTransfersQuotedEventAllOf;

/**
 * The type of webhook event.
 */
export type PaymentsTransfersProcessingEventAllOfEventType =
  (typeof PaymentsTransfersProcessingEventAllOfEventType)[keyof typeof PaymentsTransfersProcessingEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const PaymentsTransfersProcessingEventAllOfEventType = {
  paymentstransfersprocessing: "payments.transfers.processing",
} as const;

export type PaymentsTransfersProcessingEventAllOf = {
  /** The type of webhook event. */
  eventType: PaymentsTransfersProcessingEventAllOfEventType;
};

export type PaymentsTransfersProcessingEvent = PaymentsTransfersEventBase &
  PaymentsTransfersProcessingEventAllOf;

/**
 * The type of webhook event.
 */
export type PaymentsTransfersCompletedEventAllOfEventType =
  (typeof PaymentsTransfersCompletedEventAllOfEventType)[keyof typeof PaymentsTransfersCompletedEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const PaymentsTransfersCompletedEventAllOfEventType = {
  paymentstransferscompleted: "payments.transfers.completed",
} as const;

export type PaymentsTransfersCompletedEventAllOf = {
  /** The type of webhook event. */
  eventType: PaymentsTransfersCompletedEventAllOfEventType;
};

export type PaymentsTransfersCompletedEvent = PaymentsTransfersEventBase &
  PaymentsTransfersCompletedEventAllOf;

/**
 * The type of webhook event.
 */
export type PaymentsTransfersFailedEventAllOfEventType =
  (typeof PaymentsTransfersFailedEventAllOfEventType)[keyof typeof PaymentsTransfersFailedEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const PaymentsTransfersFailedEventAllOfEventType = {
  paymentstransfersfailed: "payments.transfers.failed",
} as const;

export type PaymentsTransfersFailedEventAllOf = {
  /** The type of webhook event. */
  eventType: PaymentsTransfersFailedEventAllOfEventType;
};

export type PaymentsTransfersFailedEvent = PaymentsTransfersEventBase &
  PaymentsTransfersFailedEventAllOf;

/**
 * The type of webhook event.
 */
export type PaymentsTransfersExpiredEventAllOfEventType =
  (typeof PaymentsTransfersExpiredEventAllOfEventType)[keyof typeof PaymentsTransfersExpiredEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const PaymentsTransfersExpiredEventAllOfEventType = {
  paymentstransfersexpired: "payments.transfers.expired",
} as const;

export type PaymentsTransfersExpiredEventAllOf = {
  /** The type of webhook event. */
  eventType: PaymentsTransfersExpiredEventAllOfEventType;
};

export type PaymentsTransfersExpiredEvent = PaymentsTransfersEventBase &
  PaymentsTransfersExpiredEventAllOf;

/**
 * The type of webhook event.
 */
export type PaymentsTransfersTravelRuleIncompleteEventAllOfEventType =
  (typeof PaymentsTransfersTravelRuleIncompleteEventAllOfEventType)[keyof typeof PaymentsTransfersTravelRuleIncompleteEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const PaymentsTransfersTravelRuleIncompleteEventAllOfEventType = {
  paymentstransferstravel_rule_incomplete: "payments.transfers.travel_rule_incomplete",
} as const;

export type PaymentsTransfersTravelRuleIncompleteEventAllOf = {
  /** The type of webhook event. */
  eventType: PaymentsTransfersTravelRuleIncompleteEventAllOfEventType;
};

export type PaymentsTransfersTravelRuleIncompleteEvent = PaymentsTransfersEventBase &
  PaymentsTransfersTravelRuleIncompleteEventAllOf;

/**
 * The type of webhook event.
 */
export type PaymentsTransfersTravelRuleCompletedEventAllOfEventType =
  (typeof PaymentsTransfersTravelRuleCompletedEventAllOfEventType)[keyof typeof PaymentsTransfersTravelRuleCompletedEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const PaymentsTransfersTravelRuleCompletedEventAllOfEventType = {
  paymentstransferstravel_rule_completed: "payments.transfers.travel_rule_completed",
} as const;

export type PaymentsTransfersTravelRuleCompletedEventAllOf = {
  /** The type of webhook event. */
  eventType: PaymentsTransfersTravelRuleCompletedEventAllOfEventType;
};

export type PaymentsTransfersTravelRuleCompletedEvent = PaymentsTransfersEventBase &
  PaymentsTransfersTravelRuleCompletedEventAllOf;

/**
 * A monetary amount with currency.
 */
export interface MoneyAmount {
  /** Currency code (e.g., "USD", "USDC", "ETH"). */
  currency: string;
  /** The amount as a string. */
  value: string;
}

/**
 * Current status of the transaction.
 */
export type OnrampTransactionPayloadStatus =
  (typeof OnrampTransactionPayloadStatus)[keyof typeof OnrampTransactionPayloadStatus];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const OnrampTransactionPayloadStatus = {
  ONRAMP_TRANSACTION_STATUS_UNSPECIFIED: "ONRAMP_TRANSACTION_STATUS_UNSPECIFIED",
  ONRAMP_TRANSACTION_STATUS_CREATED: "ONRAMP_TRANSACTION_STATUS_CREATED",
  ONRAMP_TRANSACTION_STATUS_IN_PROGRESS: "ONRAMP_TRANSACTION_STATUS_IN_PROGRESS",
  ONRAMP_TRANSACTION_STATUS_SUCCESS: "ONRAMP_TRANSACTION_STATUS_SUCCESS",
  ONRAMP_TRANSACTION_STATUS_FAILED: "ONRAMP_TRANSACTION_STATUS_FAILED",
  ONRAMP_TRANSACTION_STATUS_AWAITING_AUTH: "ONRAMP_TRANSACTION_STATUS_AWAITING_AUTH",
  ONRAMP_TRANSACTION_STATUS_AWAITING_PAYMENT: "ONRAMP_TRANSACTION_STATUS_AWAITING_PAYMENT",
} as const;

/**
 * The payment method used.
 */
export type OnrampTransactionPayloadPaymentMethod =
  (typeof OnrampTransactionPayloadPaymentMethod)[keyof typeof OnrampTransactionPayloadPaymentMethod];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const OnrampTransactionPayloadPaymentMethod = {
  UNSPECIFIED: "UNSPECIFIED",
  CARD: "CARD",
  ACH_BANK_ACCOUNT: "ACH_BANK_ACCOUNT",
  APPLE_PAY: "APPLE_PAY",
  FIAT_WALLET: "FIAT_WALLET",
  CRYPTO_ACCOUNT: "CRYPTO_ACCOUNT",
  GUEST_CHECKOUT_CARD: "GUEST_CHECKOUT_CARD",
  PAYPAL: "PAYPAL",
  RTP: "RTP",
  GUEST_CHECKOUT_APPLE_PAY: "GUEST_CHECKOUT_APPLE_PAY",
  GUEST_CHECKOUT_GOOGLE_PAY: "GUEST_CHECKOUT_GOOGLE_PAY",
} as const;

/**
 * The type of onramp transaction.
 */
export type OnrampTransactionPayloadType =
  (typeof OnrampTransactionPayloadType)[keyof typeof OnrampTransactionPayloadType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const OnrampTransactionPayloadType = {
  ONRAMP_TRANSACTION_TYPE_UNSPECIFIED: "ONRAMP_TRANSACTION_TYPE_UNSPECIFIED",
  ONRAMP_TRANSACTION_TYPE_BUY_AND_SEND: "ONRAMP_TRANSACTION_TYPE_BUY_AND_SEND",
  ONRAMP_TRANSACTION_TYPE_SEND: "ONRAMP_TRANSACTION_TYPE_SEND",
} as const;

/**
 * Whether the user is authed or guest.
 */
export type OnrampTransactionPayloadUserType =
  (typeof OnrampTransactionPayloadUserType)[keyof typeof OnrampTransactionPayloadUserType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const OnrampTransactionPayloadUserType = {
  USER_TYPE_UNSPECIFIED: "USER_TYPE_UNSPECIFIED",
  USER_TYPE_AUTHED: "USER_TYPE_AUTHED",
  USER_TYPE_GUEST: "USER_TYPE_GUEST",
} as const;

/**
 * The reason for failure (if applicable).
 */
export type OnrampTransactionPayloadFailureReason =
  (typeof OnrampTransactionPayloadFailureReason)[keyof typeof OnrampTransactionPayloadFailureReason];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const OnrampTransactionPayloadFailureReason = {
  FAILURE_REASON_UNSPECIFIED: "FAILURE_REASON_UNSPECIFIED",
  FAILURE_REASON_BUY_FAILED: "FAILURE_REASON_BUY_FAILED",
  FAILURE_REASON_SEND_FAILED: "FAILURE_REASON_SEND_FAILED",
} as const;

/**
 * Webhook payload for standard onramp transactions (guest checkout and authed flow). Serialized from the OnrampTransaction proto via protojson with eventType appended.
 */
export interface OnrampTransactionPayload {
  /** The webhook event type. */
  eventType: string;
  /** Unique transaction identifier. */
  transactionId: string;
  /** Current status of the transaction. */
  status: OnrampTransactionPayloadStatus;
  /** The crypto currency purchased (e.g., "USDC", "ETH"). */
  purchaseCurrency?: string;
  /** The blockchain network for the purchase (e.g., "ethereum", "base"). */
  purchaseNetwork?: string;
  purchaseAmount?: MoneyAmount;
  paymentTotal?: MoneyAmount;
  paymentTotalUsd?: MoneyAmount;
  paymentSubtotal?: MoneyAmount;
  coinbaseFee?: MoneyAmount;
  networkFee?: MoneyAmount;
  exchangeRate?: MoneyAmount;
  /** The onchain transaction hash of the send (0x-prefixed for EVM). */
  txHash?: string;
  /** When the transaction was created. */
  createdAt?: string;
  /** When the transaction completed (uses send_started_at for early success). */
  completedAt?: string;
  /** The user's country code. */
  country?: string;
  /** Hashed user identifier (entity hash for guest, user ID for authed). */
  userId?: string;
  /** The payment method used. */
  paymentMethod?: OnrampTransactionPayloadPaymentMethod;
  /** The destination wallet address. */
  walletAddress?: string;
  /** The type of onramp transaction. */
  type?: OnrampTransactionPayloadType;
  /** Whether the user is authed or guest. */
  userType?: OnrampTransactionPayloadUserType;
  /** The partnerUserId provided when initializing the onramp session. */
  partnerUserRef?: string;
  /** The token contract address (populated when asset metadata is available). */
  contractAddress?: string;
  /** The reason for failure (if applicable). */
  failureReason?: OnrampTransactionPayloadFailureReason;
  /** The name of the developer app. */
  endPartnerName?: string;
  /** Error code for the transaction failure (if applicable). */
  errorCode?: string;
}

/**
 * The type of fee.
 */
export type OrderFeeFeeType = (typeof OrderFeeFeeType)[keyof typeof OrderFeeFeeType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const OrderFeeFeeType = {
  FEE_TYPE_UNSPECIFIED: "FEE_TYPE_UNSPECIFIED",
  FEE_TYPE_NETWORK: "FEE_TYPE_NETWORK",
  FEE_TYPE_EXCHANGE: "FEE_TYPE_EXCHANGE",
} as const;

/**
 * A fee associated with a Headless Onramp API order.
 */
export interface OrderFee {
  /** The type of fee. */
  feeType?: OrderFeeFeeType;
  /** The amount of the fee. */
  feeAmount?: string;
  /** The currency of the fee. */
  feeCurrency?: string;
}

/**
 * The payment method used.
 */
export type OnrampOrderPayloadPaymentMethod =
  (typeof OnrampOrderPayloadPaymentMethod)[keyof typeof OnrampOrderPayloadPaymentMethod];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const OnrampOrderPayloadPaymentMethod = {
  UNSPECIFIED: "UNSPECIFIED",
  CARD: "CARD",
  ACH_BANK_ACCOUNT: "ACH_BANK_ACCOUNT",
  APPLE_PAY: "APPLE_PAY",
  FIAT_WALLET: "FIAT_WALLET",
  CRYPTO_ACCOUNT: "CRYPTO_ACCOUNT",
  GUEST_CHECKOUT_CARD: "GUEST_CHECKOUT_CARD",
  PAYPAL: "PAYPAL",
  RTP: "RTP",
  GUEST_CHECKOUT_APPLE_PAY: "GUEST_CHECKOUT_APPLE_PAY",
  GUEST_CHECKOUT_GOOGLE_PAY: "GUEST_CHECKOUT_GOOGLE_PAY",
} as const;

/**
 * The status of the order.
 */
export type OnrampOrderPayloadStatus =
  (typeof OnrampOrderPayloadStatus)[keyof typeof OnrampOrderPayloadStatus];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const OnrampOrderPayloadStatus = {
  ONRAMP_ORDER_STATUS_UNSPECIFIED: "ONRAMP_ORDER_STATUS_UNSPECIFIED",
  ONRAMP_ORDER_STATUS_PENDING_AUTH: "ONRAMP_ORDER_STATUS_PENDING_AUTH",
  ONRAMP_ORDER_STATUS_PENDING_VERIFICATION: "ONRAMP_ORDER_STATUS_PENDING_VERIFICATION",
  ONRAMP_ORDER_STATUS_PENDING_PAYMENT: "ONRAMP_ORDER_STATUS_PENDING_PAYMENT",
  ONRAMP_ORDER_STATUS_PROCESSING: "ONRAMP_ORDER_STATUS_PROCESSING",
  ONRAMP_ORDER_STATUS_COMPLETED: "ONRAMP_ORDER_STATUS_COMPLETED",
  ONRAMP_ORDER_STATUS_FAILED: "ONRAMP_ORDER_STATUS_FAILED",
} as const;

/**
 * Webhook payload for Headless Onramp API orders (Apple Pay / Google Pay). Serialized from the OnrampOrder proto via protojson with eventType appended.
 */
export interface OnrampOrderPayload {
  /** The webhook event type. */
  eventType: string;
  /** Unique order identifier. */
  orderId: string;
  /** The total fiat amount paid. */
  paymentTotal?: string;
  /** The fiat amount converted to crypto (excluding fees). */
  paymentSubtotal?: string;
  /** The fiat currency used for payment. */
  paymentCurrency?: string;
  /** The payment method used. */
  paymentMethod?: OnrampOrderPayloadPaymentMethod;
  /** The amount of crypto purchased. */
  purchaseAmount?: string;
  /** The crypto currency purchased. */
  purchaseCurrency?: string;
  /** Breakdown of fees for the order. */
  fees?: OrderFee[];
  /** The exchange rate used for conversion. */
  exchangeRate?: string;
  /** The destination wallet address. */
  destinationAddress?: string;
  /** The blockchain network for delivery. */
  destinationNetwork?: string;
  /** The status of the order. */
  status: OnrampOrderPayloadStatus;
  /** The onchain transaction hash (available once crypto is sent). */
  txHash?: string;
  /** When the order was created. */
  createdAt?: string;
  /** When the order was last updated. */
  updatedAt?: string;
  /** The partner user reference ID. */
  partnerUserRef?: string;
}

/**
 * Webhook payload for all onramp transaction events (created, updated, success, failed). Shape depends on transaction type — standard flow (guest checkout / authorized) uses OnrampTransactionPayload, Headless API (Apple Pay / Google Pay) uses OnrampOrderPayload. Distinguish by presence of `orderId` (Headless) vs `transactionId` (standard).
 */
export type OnrampTransactionEvent = OnrampTransactionPayload | OnrampOrderPayload;

export type OnrampTransactionCreatedEvent = OnrampTransactionEvent;

export type OnrampTransactionUpdatedEvent = OnrampTransactionEvent;

export type OnrampTransactionSuccessEvent = OnrampTransactionEvent;

export type OnrampTransactionFailedEvent = OnrampTransactionEvent;

/**
 * Current status of the offramp transaction.
 */
export type OfframpTransactionPayloadStatus =
  (typeof OfframpTransactionPayloadStatus)[keyof typeof OfframpTransactionPayloadStatus];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const OfframpTransactionPayloadStatus = {
  TRANSACTION_STATUS_UNSPECIFIED: "TRANSACTION_STATUS_UNSPECIFIED",
  TRANSACTION_STATUS_CREATED: "TRANSACTION_STATUS_CREATED",
  TRANSACTION_STATUS_EXPIRED: "TRANSACTION_STATUS_EXPIRED",
  TRANSACTION_STATUS_STARTED: "TRANSACTION_STATUS_STARTED",
  TRANSACTION_STATUS_SUCCESS: "TRANSACTION_STATUS_SUCCESS",
  TRANSACTION_STATUS_FAILED: "TRANSACTION_STATUS_FAILED",
} as const;

/**
 * The payment method type used for cashout.
 */
export type OfframpTransactionPayloadPaymentMethod =
  (typeof OfframpTransactionPayloadPaymentMethod)[keyof typeof OfframpTransactionPayloadPaymentMethod];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const OfframpTransactionPayloadPaymentMethod = {
  UNSPECIFIED: "UNSPECIFIED",
  CARD: "CARD",
  ACH_BANK_ACCOUNT: "ACH_BANK_ACCOUNT",
  APPLE_PAY: "APPLE_PAY",
  FIAT_WALLET: "FIAT_WALLET",
  CRYPTO_ACCOUNT: "CRYPTO_ACCOUNT",
  GUEST_CHECKOUT_CARD: "GUEST_CHECKOUT_CARD",
  PAYPAL: "PAYPAL",
  RTP: "RTP",
  GUEST_CHECKOUT_APPLE_PAY: "GUEST_CHECKOUT_APPLE_PAY",
  GUEST_CHECKOUT_GOOGLE_PAY: "GUEST_CHECKOUT_GOOGLE_PAY",
} as const;

/**
 * Webhook payload for offramp transactions. Serialized from the OfframpTransaction proto via protojson with eventType appended.
 */
export interface OfframpTransactionPayload {
  /** The webhook event type. */
  eventType: string;
  /** Unique transaction identifier. */
  transactionId: string;
  /** Current status of the offramp transaction. */
  status: OfframpTransactionPayloadStatus;
  /** The crypto currency being sold (e.g., "ETH", "USDC"). */
  asset?: string;
  /** The blockchain network (e.g., "ethereum", "base"). */
  network?: string;
  sellAmount?: MoneyAmount;
  total?: MoneyAmount;
  minimumTotal?: MoneyAmount;
  subtotal?: MoneyAmount;
  coinbaseFee?: MoneyAmount;
  exchangeRate?: MoneyAmount;
  unitPrice?: MoneyAmount;
  /** The address crypto was received from. */
  fromAddress?: string;
  /** The address crypto was sent to (Coinbase deposit address). */
  toAddress?: string;
  /** When the transaction was created. */
  createdAt?: string;
  /** When the transaction was last updated. */
  updatedAt?: string;
  /** The onchain transaction hash of the crypto send. */
  txHash?: string;
  /** The URL the user was redirected to after confirming the offramp. */
  redirectUrl?: string;
  /** The payment method type used for cashout. */
  paymentMethod?: OfframpTransactionPayloadPaymentMethod;
  /** The partnerUserId provided when initializing the offramp session. */
  partnerUserRef?: string;
}

export type OfframpTransactionCreatedEvent = OfframpTransactionPayload;

export type OfframpTransactionUpdatedEvent = OfframpTransactionPayload;

export type OfframpTransactionSuccessEvent = OfframpTransactionPayload;

export type OfframpTransactionFailedEvent = OfframpTransactionPayload;

/**
 * A summary of the payment session included in webhook payloads. Contains the session identity, amount, asset, payer and recipient information, execution behavior, expiry deadlines, current status, running balance totals, and any metadata originally provided when the session was created.
 */
export interface PaymentSessionSummary {
  /** The unique identifier of the payment session. */
  paymentSessionId: PaymentSessionId;
  /** The ID of the entity that owns the payment session. */
  entityId: string;
  /** A decimal representation of the payment amount, denominated in `asset`. */
  amount: string;
  /** The symbol of the asset for the payment amount. */
  asset: Asset;
  /** The payer's address and network. Set after a successful authorization. Not present before authorization. */
  source?: PaymentSessionSource;
  /** The recipient of the payment. */
  target: PaymentSessionTarget;
  /** When true, a capture is automatically created after a successful authorization. */
  autoCapture: boolean;
  /** Deadline timestamps for authorization, capture, and refund windows. */
  expiries: PaymentExpiries;
  /** The current status of the payment session at the time the event was emitted. */
  status: PaymentSessionStatus;
  /** Running balance totals for the payment session at the time the event was emitted. */
  balances: PaymentSessionBalances;
  /**
   * A merchant-provided internal identifier for this payment session, from the merchant's own system—not visible to the payer. It must not contain personally identifiable information (PII) or payment credentials.
   * @maxLength 256
   */
  externalReferenceId?: string;
  customerDisplay?: CustomerDisplay;
  metadata?: Metadata;
  /** The UTC ISO 8601 timestamp at which the payment session was created. */
  createdAt: string;
  /** The UTC ISO 8601 timestamp at which the payment session was last updated. */
  updatedAt: string;
}

/**
 * Present when the event was triggered by an authorization status transition (`pending`, `succeeded`, or `failed`).
 */
export type PaymentSessionEventDataAuthorization = {
  /** The unique identifier of the authorization. */
  authorizationId: AuthorizationId;
  /** The current status of the authorization. */
  status: PaymentActionStatus;
  /** A decimal representation of the authorized amount, denominated in the session's `asset`. */
  amount: string;
  /** An optional merchant-provided internal identifier for this authorization, from the merchant's own system—not visible to the payer. Present only when supplied on the authorization request. */
  externalReferenceId?: ExternalReferenceId;
  /** Customer-facing display data for this authorization, shown to the payer. Present when supplied on the authorization request or when the session's `orderCode` fallback applies; otherwise omitted. */
  customerDisplay?: OperationCustomerDisplay;
  /** Error details, present only when the authorization failed. */
  error?: PaymentError;
  /** The onchain transactions associated with this authorization. */
  onchainTransactions?: OnchainTransaction[];
  metadata?: Metadata;
  /** The payer for this authorization. For wallet authorizations, this is the blockchain address that signed the payloads. For Coinbase authorizations, this is the authenticated Coinbase account. */
  source?: PaymentSessionSource;
  /** The UTC ISO 8601 timestamp at which the authorization was created. */
  createdAt: string;
  /** The UTC ISO 8601 timestamp at which the authorization was last updated. */
  updatedAt: string;
};

/**
 * Present when the event was triggered by a capture status transition (`pending`, `succeeded`, or `failed`).
 */
export type PaymentSessionEventDataCapture = {
  /** The unique identifier of the capture. */
  captureId: CaptureId;
  /** The current status of the capture. */
  status: PaymentActionStatus;
  /** A decimal representation of the captured amount, denominated in the session's `asset`. */
  amount: string;
  /** An optional merchant-provided internal identifier for this capture, from the merchant's own system—not visible to the payer. For an auto-capture, it is copied from the authorization. */
  externalReferenceId?: ExternalReferenceId;
  /** Customer-facing display data for this capture, shown to the payer. An auto-capture reuses the authorization's `referenceCode`. */
  customerDisplay?: OperationCustomerDisplay;
  /** When `true`, this capture is treated as the final one for the authorization. Any remaining capturable balance is released back to the payer immediately after the capture settles. When `false`, the remaining capturable balance stays held and is available for subsequent partial captures (subject to `captureExpiresAt`). Has no effect if `amount` equals the full capturable balance, since no remaining balance exists to release. */
  finalCapture: boolean;
  /** Error details, present only when the capture failed. */
  error?: PaymentError;
  /** The onchain transactions associated with this capture. */
  onchainTransactions?: OnchainTransaction[];
  metadata?: Metadata;
  /** The UTC ISO 8601 timestamp at which the capture was created. */
  createdAt: string;
  /** The UTC ISO 8601 timestamp at which the capture was last updated. */
  updatedAt: string;
};

/**
 * Present when the event was triggered by a void status transition (`pending`, `succeeded`, or `failed`).
 */
export type PaymentSessionEventDataVoid = {
  /** The unique identifier of the void. */
  voidId: VoidId;
  /** The current status of the void. */
  status: PaymentActionStatus;
  /** A decimal representation of the voided amount, denominated in the session's `asset`. */
  amount: string;
  /** An optional merchant-provided internal identifier for this void, from the merchant's own system—not visible to the payer. Present only when supplied on the create void request. */
  externalReferenceId?: ExternalReferenceId;
  /** Customer-facing display data for this void, shown to the payer. Present when supplied on the create void request or when the session's `orderCode` fallback applies; otherwise omitted. */
  customerDisplay?: OperationCustomerDisplay;
  /** Error details, present only when the void failed. */
  error?: PaymentError;
  /** The onchain transactions associated with this void. */
  onchainTransactions?: OnchainTransaction[];
  metadata?: Metadata;
  /** The UTC ISO 8601 timestamp at which the void was created. */
  createdAt: string;
  /** The UTC ISO 8601 timestamp at which the void was last updated. */
  updatedAt: string;
};

/**
 * Present when the event was triggered by a refund status transition (`pending`, `succeeded`, or `failed`).
 */
export type PaymentSessionEventDataRefund = {
  /** The unique identifier of the refund. */
  refundId: RefundId;
  /** The current status of the refund. */
  status: PaymentActionStatus;
  /** A decimal representation of the refunded amount, denominated in the session's `asset`. */
  amount: string;
  /** An optional merchant-provided internal identifier for this refund, from the merchant's own system—not visible to the payer. Present only when supplied on the create refund request. */
  externalReferenceId?: ExternalReferenceId;
  /** Customer-facing display data for this refund, shown to the payer. Present when supplied on the create refund request or when the session's `orderCode` fallback applies; otherwise omitted. */
  customerDisplay?: OperationCustomerDisplay;
  /** The reason for the refund, if provided when the refund was created. */
  reason?: string;
  /** Error details, present only when the refund failed. */
  error?: PaymentError;
  /** The onchain transactions associated with this refund. */
  onchainTransactions?: OnchainTransaction[];
  metadata?: Metadata;
  /** The UTC ISO 8601 timestamp at which the refund was created. */
  createdAt: string;
  /** The UTC ISO 8601 timestamp at which the refund was last updated. */
  updatedAt: string;
};

/**
 * The data payload for a payment session webhook event. Always contains the `paymentSession` summary reflecting the session's current state. When the event was triggered by an action (authorization, capture, void, or refund), the corresponding optional field is present with the action details. For session-level events (created, canceled) no action field is included — the `paymentSession.status` value is sufficient.
 */
export interface PaymentSessionEventData {
  paymentSession: PaymentSessionSummary;
  /** Present when the event was triggered by an authorization status transition (`pending`, `succeeded`, or `failed`). */
  authorization?: PaymentSessionEventDataAuthorization;
  /** Present when the event was triggered by a capture status transition (`pending`, `succeeded`, or `failed`). */
  capture?: PaymentSessionEventDataCapture;
  /** Present when the event was triggered by a void status transition (`pending`, `succeeded`, or `failed`). */
  void?: PaymentSessionEventDataVoid;
  /** Present when the event was triggered by a refund status transition (`pending`, `succeeded`, or `failed`). */
  refund?: PaymentSessionEventDataRefund;
}

/**
 * Common fields included in every PaymentSessionEvent payload.
 */
export interface PaymentSessionEventBase {
  /** Unique identifier for this webhook event. Use this for idempotency. */
  eventId: string;
  /** When this event occurred (ISO 8601 format). */
  timestamp: string;
  data: PaymentSessionEventData;
}

/**
 * The type of webhook event.
 */
export type AcceptancePaymentSessionCreatedEventAllOfEventType =
  (typeof AcceptancePaymentSessionCreatedEventAllOfEventType)[keyof typeof AcceptancePaymentSessionCreatedEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AcceptancePaymentSessionCreatedEventAllOfEventType = {
  acceptancepayment_sessioncreated: "acceptance.payment_session.created",
} as const;

export type AcceptancePaymentSessionCreatedEventAllOf = {
  /** The type of webhook event. */
  eventType: AcceptancePaymentSessionCreatedEventAllOfEventType;
};

export type AcceptancePaymentSessionCreatedEvent = PaymentSessionEventBase &
  AcceptancePaymentSessionCreatedEventAllOf;

/**
 * The type of webhook event.
 */
export type AcceptancePaymentSessionCanceledEventAllOfEventType =
  (typeof AcceptancePaymentSessionCanceledEventAllOfEventType)[keyof typeof AcceptancePaymentSessionCanceledEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AcceptancePaymentSessionCanceledEventAllOfEventType = {
  acceptancepayment_sessioncanceled: "acceptance.payment_session.canceled",
} as const;

export type AcceptancePaymentSessionCanceledEventAllOf = {
  /** The type of webhook event. */
  eventType: AcceptancePaymentSessionCanceledEventAllOfEventType;
};

export type AcceptancePaymentSessionCanceledEvent = PaymentSessionEventBase &
  AcceptancePaymentSessionCanceledEventAllOf;

/**
 * The type of webhook event.
 */
export type AcceptancePaymentSessionAuthorizationPendingEventAllOfEventType =
  (typeof AcceptancePaymentSessionAuthorizationPendingEventAllOfEventType)[keyof typeof AcceptancePaymentSessionAuthorizationPendingEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AcceptancePaymentSessionAuthorizationPendingEventAllOfEventType = {
  acceptancepayment_sessionauthorization_pending:
    "acceptance.payment_session.authorization_pending",
} as const;

export type AcceptancePaymentSessionAuthorizationPendingEventAllOf = {
  /** The type of webhook event. */
  eventType: AcceptancePaymentSessionAuthorizationPendingEventAllOfEventType;
};

export type AcceptancePaymentSessionAuthorizationPendingEvent = PaymentSessionEventBase &
  AcceptancePaymentSessionAuthorizationPendingEventAllOf;

/**
 * The type of webhook event.
 */
export type AcceptancePaymentSessionAuthorizationSucceededEventAllOfEventType =
  (typeof AcceptancePaymentSessionAuthorizationSucceededEventAllOfEventType)[keyof typeof AcceptancePaymentSessionAuthorizationSucceededEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AcceptancePaymentSessionAuthorizationSucceededEventAllOfEventType = {
  acceptancepayment_sessionauthorization_succeeded:
    "acceptance.payment_session.authorization_succeeded",
} as const;

export type AcceptancePaymentSessionAuthorizationSucceededEventAllOf = {
  /** The type of webhook event. */
  eventType: AcceptancePaymentSessionAuthorizationSucceededEventAllOfEventType;
};

export type AcceptancePaymentSessionAuthorizationSucceededEvent = PaymentSessionEventBase &
  AcceptancePaymentSessionAuthorizationSucceededEventAllOf;

/**
 * The type of webhook event.
 */
export type AcceptancePaymentSessionAuthorizationFailedEventAllOfEventType =
  (typeof AcceptancePaymentSessionAuthorizationFailedEventAllOfEventType)[keyof typeof AcceptancePaymentSessionAuthorizationFailedEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AcceptancePaymentSessionAuthorizationFailedEventAllOfEventType = {
  acceptancepayment_sessionauthorization_failed: "acceptance.payment_session.authorization_failed",
} as const;

export type AcceptancePaymentSessionAuthorizationFailedEventAllOf = {
  /** The type of webhook event. */
  eventType: AcceptancePaymentSessionAuthorizationFailedEventAllOfEventType;
};

export type AcceptancePaymentSessionAuthorizationFailedEvent = PaymentSessionEventBase &
  AcceptancePaymentSessionAuthorizationFailedEventAllOf;

/**
 * The type of webhook event.
 */
export type AcceptancePaymentSessionCapturePendingEventAllOfEventType =
  (typeof AcceptancePaymentSessionCapturePendingEventAllOfEventType)[keyof typeof AcceptancePaymentSessionCapturePendingEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AcceptancePaymentSessionCapturePendingEventAllOfEventType = {
  acceptancepayment_sessioncapture_pending: "acceptance.payment_session.capture_pending",
} as const;

export type AcceptancePaymentSessionCapturePendingEventAllOf = {
  /** The type of webhook event. */
  eventType: AcceptancePaymentSessionCapturePendingEventAllOfEventType;
};

export type AcceptancePaymentSessionCapturePendingEvent = PaymentSessionEventBase &
  AcceptancePaymentSessionCapturePendingEventAllOf;

/**
 * The type of webhook event.
 */
export type AcceptancePaymentSessionCaptureSucceededEventAllOfEventType =
  (typeof AcceptancePaymentSessionCaptureSucceededEventAllOfEventType)[keyof typeof AcceptancePaymentSessionCaptureSucceededEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AcceptancePaymentSessionCaptureSucceededEventAllOfEventType = {
  acceptancepayment_sessioncapture_succeeded: "acceptance.payment_session.capture_succeeded",
} as const;

export type AcceptancePaymentSessionCaptureSucceededEventAllOf = {
  /** The type of webhook event. */
  eventType: AcceptancePaymentSessionCaptureSucceededEventAllOfEventType;
};

export type AcceptancePaymentSessionCaptureSucceededEvent = PaymentSessionEventBase &
  AcceptancePaymentSessionCaptureSucceededEventAllOf;

/**
 * The type of webhook event.
 */
export type AcceptancePaymentSessionCaptureFailedEventAllOfEventType =
  (typeof AcceptancePaymentSessionCaptureFailedEventAllOfEventType)[keyof typeof AcceptancePaymentSessionCaptureFailedEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AcceptancePaymentSessionCaptureFailedEventAllOfEventType = {
  acceptancepayment_sessioncapture_failed: "acceptance.payment_session.capture_failed",
} as const;

export type AcceptancePaymentSessionCaptureFailedEventAllOf = {
  /** The type of webhook event. */
  eventType: AcceptancePaymentSessionCaptureFailedEventAllOfEventType;
};

export type AcceptancePaymentSessionCaptureFailedEvent = PaymentSessionEventBase &
  AcceptancePaymentSessionCaptureFailedEventAllOf;

/**
 * The type of webhook event.
 */
export type AcceptancePaymentSessionRefundPendingEventAllOfEventType =
  (typeof AcceptancePaymentSessionRefundPendingEventAllOfEventType)[keyof typeof AcceptancePaymentSessionRefundPendingEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AcceptancePaymentSessionRefundPendingEventAllOfEventType = {
  acceptancepayment_sessionrefund_pending: "acceptance.payment_session.refund_pending",
} as const;

export type AcceptancePaymentSessionRefundPendingEventAllOf = {
  /** The type of webhook event. */
  eventType: AcceptancePaymentSessionRefundPendingEventAllOfEventType;
};

export type AcceptancePaymentSessionRefundPendingEvent = PaymentSessionEventBase &
  AcceptancePaymentSessionRefundPendingEventAllOf;

/**
 * The type of webhook event.
 */
export type AcceptancePaymentSessionRefundSucceededEventAllOfEventType =
  (typeof AcceptancePaymentSessionRefundSucceededEventAllOfEventType)[keyof typeof AcceptancePaymentSessionRefundSucceededEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AcceptancePaymentSessionRefundSucceededEventAllOfEventType = {
  acceptancepayment_sessionrefund_succeeded: "acceptance.payment_session.refund_succeeded",
} as const;

export type AcceptancePaymentSessionRefundSucceededEventAllOf = {
  /** The type of webhook event. */
  eventType: AcceptancePaymentSessionRefundSucceededEventAllOfEventType;
};

export type AcceptancePaymentSessionRefundSucceededEvent = PaymentSessionEventBase &
  AcceptancePaymentSessionRefundSucceededEventAllOf;

/**
 * The type of webhook event.
 */
export type AcceptancePaymentSessionRefundFailedEventAllOfEventType =
  (typeof AcceptancePaymentSessionRefundFailedEventAllOfEventType)[keyof typeof AcceptancePaymentSessionRefundFailedEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AcceptancePaymentSessionRefundFailedEventAllOfEventType = {
  acceptancepayment_sessionrefund_failed: "acceptance.payment_session.refund_failed",
} as const;

export type AcceptancePaymentSessionRefundFailedEventAllOf = {
  /** The type of webhook event. */
  eventType: AcceptancePaymentSessionRefundFailedEventAllOfEventType;
};

export type AcceptancePaymentSessionRefundFailedEvent = PaymentSessionEventBase &
  AcceptancePaymentSessionRefundFailedEventAllOf;

/**
 * The type of webhook event.
 */
export type AcceptancePaymentSessionVoidPendingEventAllOfEventType =
  (typeof AcceptancePaymentSessionVoidPendingEventAllOfEventType)[keyof typeof AcceptancePaymentSessionVoidPendingEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AcceptancePaymentSessionVoidPendingEventAllOfEventType = {
  acceptancepayment_sessionvoid_pending: "acceptance.payment_session.void_pending",
} as const;

export type AcceptancePaymentSessionVoidPendingEventAllOf = {
  /** The type of webhook event. */
  eventType: AcceptancePaymentSessionVoidPendingEventAllOfEventType;
};

export type AcceptancePaymentSessionVoidPendingEvent = PaymentSessionEventBase &
  AcceptancePaymentSessionVoidPendingEventAllOf;

/**
 * The type of webhook event.
 */
export type AcceptancePaymentSessionVoidSucceededEventAllOfEventType =
  (typeof AcceptancePaymentSessionVoidSucceededEventAllOfEventType)[keyof typeof AcceptancePaymentSessionVoidSucceededEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AcceptancePaymentSessionVoidSucceededEventAllOfEventType = {
  acceptancepayment_sessionvoid_succeeded: "acceptance.payment_session.void_succeeded",
} as const;

export type AcceptancePaymentSessionVoidSucceededEventAllOf = {
  /** The type of webhook event. */
  eventType: AcceptancePaymentSessionVoidSucceededEventAllOfEventType;
};

export type AcceptancePaymentSessionVoidSucceededEvent = PaymentSessionEventBase &
  AcceptancePaymentSessionVoidSucceededEventAllOf;

/**
 * The type of webhook event.
 */
export type AcceptancePaymentSessionVoidFailedEventAllOfEventType =
  (typeof AcceptancePaymentSessionVoidFailedEventAllOfEventType)[keyof typeof AcceptancePaymentSessionVoidFailedEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AcceptancePaymentSessionVoidFailedEventAllOfEventType = {
  acceptancepayment_sessionvoid_failed: "acceptance.payment_session.void_failed",
} as const;

export type AcceptancePaymentSessionVoidFailedEventAllOf = {
  /** The type of webhook event. */
  eventType: AcceptancePaymentSessionVoidFailedEventAllOfEventType;
};

export type AcceptancePaymentSessionVoidFailedEvent = PaymentSessionEventBase &
  AcceptancePaymentSessionVoidFailedEventAllOf;

/**
 * The `data` payload for every mandate webhook event. Always contains the full `mandate`. Action events also carry the relevant sub-resource: `approval` on the three `approval_*` events, `revocation` on the three `revocation_*` events. The `created` and `canceled` events carry only the `mandate`.

`mandate.status` reflects only the latest action. Read `mandate.canceledAt` and `mandate.revokedAt` to know what has durably happened: the on-chain spending allowance is gone precisely when `revokedAt` is set, and canceling alone does not remove it.
 */
export interface MandateEventData {
  mandate: Mandate;
  /** The approval attempt this event concerns. Present only on the approval events (`acceptance.mandate.approval_initiated`, `acceptance.mandate.approval_succeeded`, and `acceptance.mandate.approval_failed`); absent on all other events. A `failed` approval carries an `error`. */
  approval?: Approval;
  /** The wallet revocation this event concerns. Present only on revocation events (`revocation_initiated`, `revocation_succeeded`, `revocation_failed`); absent on all others. A `failed` revocation carries an `error`. */
  revocation?: Revocation;
}

/**
 * Common fields included in every mandate webhook event payload.
 */
export interface MandateEventBase {
  /** Unique identifier for this webhook event. Use this for idempotency. */
  eventId: string;
  /** When this event occurred (ISO 8601 format). */
  timestamp: string;
  data: MandateEventData;
}

/**
 * The type of webhook event.
 */
export type AcceptanceMandateCreatedEventAllOfEventType =
  (typeof AcceptanceMandateCreatedEventAllOfEventType)[keyof typeof AcceptanceMandateCreatedEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AcceptanceMandateCreatedEventAllOfEventType = {
  acceptancemandatecreated: "acceptance.mandate.created",
} as const;

export type AcceptanceMandateCreatedEventAllOf = {
  /** The type of webhook event. */
  eventType: AcceptanceMandateCreatedEventAllOfEventType;
};

/**
 * The `acceptance.mandate.created` event. `data` carries the full `mandate`.
 */
export type AcceptanceMandateCreatedEvent = MandateEventBase & AcceptanceMandateCreatedEventAllOf;

/**
 * The type of webhook event.
 */
export type AcceptanceMandateCanceledEventAllOfEventType =
  (typeof AcceptanceMandateCanceledEventAllOfEventType)[keyof typeof AcceptanceMandateCanceledEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AcceptanceMandateCanceledEventAllOfEventType = {
  acceptancemandatecanceled: "acceptance.mandate.canceled",
} as const;

export type AcceptanceMandateCanceledEventAllOf = {
  /** The type of webhook event. */
  eventType: AcceptanceMandateCanceledEventAllOfEventType;
};

/**
 * The `acceptance.mandate.canceled` event. `data` carries the full `mandate`, now in `canceled` status with `canceledAt` set. The on-chain spending allowance is unaffected; it is gone only if `mandate.revokedAt` is set.
 */
export type AcceptanceMandateCanceledEvent = MandateEventBase & AcceptanceMandateCanceledEventAllOf;

/**
 * The type of webhook event.
 */
export type AcceptanceMandateApprovalInitiatedEventAllOfEventType =
  (typeof AcceptanceMandateApprovalInitiatedEventAllOfEventType)[keyof typeof AcceptanceMandateApprovalInitiatedEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AcceptanceMandateApprovalInitiatedEventAllOfEventType = {
  acceptancemandateapproval_initiated: "acceptance.mandate.approval_initiated",
} as const;

export type AcceptanceMandateApprovalInitiatedEventAllOf = {
  /** The type of webhook event. */
  eventType: AcceptanceMandateApprovalInitiatedEventAllOfEventType;
};

/**
 * The `acceptance.mandate.approval_initiated` event. `data` carries the full `mandate` and the `approval`.
 */
export type AcceptanceMandateApprovalInitiatedEvent = MandateEventBase &
  AcceptanceMandateApprovalInitiatedEventAllOf;

/**
 * The type of webhook event.
 */
export type AcceptanceMandateApprovalSucceededEventAllOfEventType =
  (typeof AcceptanceMandateApprovalSucceededEventAllOfEventType)[keyof typeof AcceptanceMandateApprovalSucceededEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AcceptanceMandateApprovalSucceededEventAllOfEventType = {
  acceptancemandateapproval_succeeded: "acceptance.mandate.approval_succeeded",
} as const;

export type AcceptanceMandateApprovalSucceededEventAllOf = {
  /** The type of webhook event. */
  eventType: AcceptanceMandateApprovalSucceededEventAllOfEventType;
};

/**
 * The `acceptance.mandate.approval_succeeded` event. `data` carries the full `mandate` and the `approval`.
 */
export type AcceptanceMandateApprovalSucceededEvent = MandateEventBase &
  AcceptanceMandateApprovalSucceededEventAllOf;

/**
 * The type of webhook event.
 */
export type AcceptanceMandateApprovalFailedEventAllOfEventType =
  (typeof AcceptanceMandateApprovalFailedEventAllOfEventType)[keyof typeof AcceptanceMandateApprovalFailedEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AcceptanceMandateApprovalFailedEventAllOfEventType = {
  acceptancemandateapproval_failed: "acceptance.mandate.approval_failed",
} as const;

export type AcceptanceMandateApprovalFailedEventAllOf = {
  /** The type of webhook event. */
  eventType: AcceptanceMandateApprovalFailedEventAllOfEventType;
};

/**
 * The `acceptance.mandate.approval_failed` event. `data` carries the full `mandate` and the failed `approval`.
 */
export type AcceptanceMandateApprovalFailedEvent = MandateEventBase &
  AcceptanceMandateApprovalFailedEventAllOf;

/**
 * The type of webhook event.
 */
export type AcceptanceMandateRevocationInitiatedEventAllOfEventType =
  (typeof AcceptanceMandateRevocationInitiatedEventAllOfEventType)[keyof typeof AcceptanceMandateRevocationInitiatedEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AcceptanceMandateRevocationInitiatedEventAllOfEventType = {
  acceptancemandaterevocation_initiated: "acceptance.mandate.revocation_initiated",
} as const;

export type AcceptanceMandateRevocationInitiatedEventAllOf = {
  /** The type of webhook event. */
  eventType: AcceptanceMandateRevocationInitiatedEventAllOfEventType;
};

/**
 * The `acceptance.mandate.revocation_initiated` event. `data` carries the full `mandate` and the `revocation`. Emitted when a wallet revocation is submitted to the network.
 */
export type AcceptanceMandateRevocationInitiatedEvent = MandateEventBase &
  AcceptanceMandateRevocationInitiatedEventAllOf;

/**
 * The type of webhook event.
 */
export type AcceptanceMandateRevocationSucceededEventAllOfEventType =
  (typeof AcceptanceMandateRevocationSucceededEventAllOfEventType)[keyof typeof AcceptanceMandateRevocationSucceededEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AcceptanceMandateRevocationSucceededEventAllOfEventType = {
  acceptancemandaterevocation_succeeded: "acceptance.mandate.revocation_succeeded",
} as const;

export type AcceptanceMandateRevocationSucceededEventAllOf = {
  /** The type of webhook event. */
  eventType: AcceptanceMandateRevocationSucceededEventAllOfEventType;
};

/**
 * The `acceptance.mandate.revocation_succeeded` event. `data` carries the full `mandate` and the `revocation`. The spending allowance has been removed on-chain, `mandate.revokedAt` is set, and `mandate.status` becomes `revocation_succeeded`. This is terminal. It applies regardless of whether the mandate was previously canceled (`canceledAt` remains set).
 */
export type AcceptanceMandateRevocationSucceededEvent = MandateEventBase &
  AcceptanceMandateRevocationSucceededEventAllOf;

/**
 * The type of webhook event.
 */
export type AcceptanceMandateRevocationFailedEventAllOfEventType =
  (typeof AcceptanceMandateRevocationFailedEventAllOfEventType)[keyof typeof AcceptanceMandateRevocationFailedEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AcceptanceMandateRevocationFailedEventAllOfEventType = {
  acceptancemandaterevocation_failed: "acceptance.mandate.revocation_failed",
} as const;

export type AcceptanceMandateRevocationFailedEventAllOf = {
  /** The type of webhook event. */
  eventType: AcceptanceMandateRevocationFailedEventAllOfEventType;
};

/**
 * The `acceptance.mandate.revocation_failed` event. `data` carries the full `mandate` and the failed `revocation`, including its `error`. `mandate.status` becomes `revocation_failed`; the allowance was not removed (`revokedAt` stays unset), so the mandate stays usable if it was usable before. Retry with a new wallet revocation.
 */
export type AcceptanceMandateRevocationFailedEvent = MandateEventBase &
  AcceptanceMandateRevocationFailedEventAllOf;

/**
 * Common fields included in every DisbursementEvent payload.
 */
export interface DisbursementEventBase {
  /** Unique identifier for this webhook event. Use this for idempotency. */
  eventId: string;
  /** When this event occurred (ISO 8601 format). */
  timestamp: string;
  data: Disbursement;
}

/**
 * The type of webhook event.
 */
export type AcceptanceDisbursementPendingEventAllOfEventType =
  (typeof AcceptanceDisbursementPendingEventAllOfEventType)[keyof typeof AcceptanceDisbursementPendingEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AcceptanceDisbursementPendingEventAllOfEventType = {
  acceptancedisbursementpending: "acceptance.disbursement.pending",
} as const;

export type AcceptanceDisbursementPendingEventAllOf = {
  /** The type of webhook event. */
  eventType: AcceptanceDisbursementPendingEventAllOfEventType;
};

export type AcceptanceDisbursementPendingEvent = DisbursementEventBase &
  AcceptanceDisbursementPendingEventAllOf;

/**
 * The type of webhook event.
 */
export type AcceptanceDisbursementSucceededEventAllOfEventType =
  (typeof AcceptanceDisbursementSucceededEventAllOfEventType)[keyof typeof AcceptanceDisbursementSucceededEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AcceptanceDisbursementSucceededEventAllOfEventType = {
  acceptancedisbursementsucceeded: "acceptance.disbursement.succeeded",
} as const;

export type AcceptanceDisbursementSucceededEventAllOf = {
  /** The type of webhook event. */
  eventType: AcceptanceDisbursementSucceededEventAllOfEventType;
};

export type AcceptanceDisbursementSucceededEvent = DisbursementEventBase &
  AcceptanceDisbursementSucceededEventAllOf;

/**
 * The type of webhook event.
 */
export type AcceptanceDisbursementFailedEventAllOfEventType =
  (typeof AcceptanceDisbursementFailedEventAllOfEventType)[keyof typeof AcceptanceDisbursementFailedEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AcceptanceDisbursementFailedEventAllOfEventType = {
  acceptancedisbursementfailed: "acceptance.disbursement.failed",
} as const;

export type AcceptanceDisbursementFailedEventAllOf = {
  /** The type of webhook event. */
  eventType: AcceptanceDisbursementFailedEventAllOfEventType;
};

export type AcceptanceDisbursementFailedEvent = DisbursementEventBase &
  AcceptanceDisbursementFailedEventAllOf;

/**
 * A finer-grained operation within a service. Optional — omitted when a health status or maintenance window applies to the service as a whole.
 */
export type HealthOperation = (typeof HealthOperation)[keyof typeof HealthOperation];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const HealthOperation = {
  /** Authorizing a payment session funded by the customer\'s onchain wallet. */
  payment_session_authorize_wallet: "payment_session_authorize_wallet",
  /** Authorizing a payment session funded by the customer\'s Coinbase account. */
  payment_session_authorize_coinbase: "payment_session_authorize_coinbase",
  /** Authorizing a payment session funded via the x402 payment protocol. */
  payment_session_authorize_x402: "payment_session_authorize_x402",
  /** Capturing funds for a previously authorized payment session. */
  payment_session_capture: "payment_session_capture",
  /** Voiding a previously authorized payment session. */
  payment_session_void: "payment_session_void",
  /** Refunding a previously captured payment session. */
  payment_session_refund: "payment_session_refund",
  /** Disbursing funds to a payee. */
  disbursement: "disbursement",
  /** Linking a customer\'s external account to Payment Acceptance. */
  account_linking: "account_linking",
} as const;

/**
 * The operational status of a service or operation. `operational`, `degraded_performance`, `partial_outage`, and `major_outage` form a severity ladder that can move up or down between adjacent levels as an organic issue develops or recovers.
 */
export type HealthStatusValue = (typeof HealthStatusValue)[keyof typeof HealthStatusValue];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const HealthStatusValue = {
  /** Working normally. */
  operational: "operational",
  /** Elevated latency or reduced capacity, with no significant failure rate. */
  degraded_performance: "degraded_performance",
  /** A subset of requests or users are failing; still functional for most. */
  partial_outage: "partial_outage",
  /** A significant portion of requests are failing; most users are impacted. */
  major_outage: "major_outage",
  /** A planned maintenance window is active — not a failure. Computed, not caller-settable: returned when there is an active maintenance window and no organic outage is currently declared. */
  under_maintenance: "under_maintenance",
} as const;

/**
 * The health status of a service or operation. See `HealthStatusValue` for the severity ladder this moves along, and `under_maintenance`'s special computed-status behavior.
 */
export interface HealthStatus {
  /** The service this status applies to. */
  service: HealthService;
  /** The operation this status applies to. Omitted when the status applies to the service as a whole. */
  operation?: HealthOperation;
  /** The current health status. */
  status: HealthStatusValue;
  /** The time this status took effect. */
  startedAt: string;
  /** A human-readable description of the status. */
  message?: string;
}

/**
 * The type of webhook event.
 */
export type HealthStatusUpdatedEventEventType =
  (typeof HealthStatusUpdatedEventEventType)[keyof typeof HealthStatusUpdatedEventEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const HealthStatusUpdatedEventEventType = {
  healthstatusupdated: "health.status.updated",
} as const;

export interface HealthStatusUpdatedEvent {
  /** Unique identifier for this logical webhook event. Webhooks are delivered at least once, so your endpoint may receive duplicate deliveries for the same event. Use this `eventId` as the idempotency/deduplication key. */
  eventId: string;
  /** The UTC ISO 8601 timestamp at which this event's transition occurred, not the time at which this webhook was delivered. */
  timestamp: string;
  /** The type of webhook event. */
  eventType: HealthStatusUpdatedEventEventType;
  data: HealthStatus;
}

/**
 * Common fields included in every maintenance event payload.
 */
export interface MaintenanceEventBase {
  /** Unique identifier for this logical webhook event. Webhooks are delivered at least once, so your endpoint may receive duplicate deliveries for the same event. Use this `eventId` as the idempotency/deduplication key. */
  eventId: string;
  /** The UTC ISO 8601 timestamp at which this event's transition occurred, not the time at which this webhook was delivered. */
  timestamp: string;
}

/**
 * The lifecycle status of a maintenance window: `scheduled` → `started` → `completed`, or `scheduled` → `canceled`. `completed` and `canceled` are terminal.
 */
export type MaintenanceStatus = (typeof MaintenanceStatus)[keyof typeof MaintenanceStatus];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const MaintenanceStatus = {
  /** The maintenance window has been scheduled but has not started yet. */
  scheduled: "scheduled",
  /** The maintenance window is currently in progress. */
  started: "started",
  /** The maintenance window has finished. */
  completed: "completed",
  /** The maintenance window was canceled before starting. */
  canceled: "canceled",
} as const;

/**
 * A maintenance window for a service or operation, moving through `scheduled` → `started` → `completed`, or `scheduled` → `canceled`. While `started`, it moves the affected service or operation's effective `HealthStatus` to `under_maintenance`.
 */
export interface MaintenanceWindow {
  /** The service this maintenance window applies to. */
  service: HealthService;
  /** The operation this maintenance window applies to. Omitted when the maintenance window applies to the service as a whole. */
  operation?: HealthOperation;
  /** The start time of the maintenance window: in the future for a `scheduled` window, in the past for one that has already `started`. */
  startsAt: string;
  /**
   * The expected duration of the maintenance window, in seconds.
   * @minimum 0
   */
  expectedDurationSeconds?: number;
  /** The current status of the maintenance window. */
  status: MaintenanceStatus;
  /** A human-readable description of the maintenance window. */
  message?: string;
}

/**
 * The type of webhook event.
 */
export type HealthMaintenanceScheduledEventAllOfEventType =
  (typeof HealthMaintenanceScheduledEventAllOfEventType)[keyof typeof HealthMaintenanceScheduledEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const HealthMaintenanceScheduledEventAllOfEventType = {
  healthmaintenancescheduled: "health.maintenance.scheduled",
} as const;

export type HealthMaintenanceScheduledEventAllOfDataAllOfStatus =
  (typeof HealthMaintenanceScheduledEventAllOfDataAllOfStatus)[keyof typeof HealthMaintenanceScheduledEventAllOfDataAllOfStatus];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const HealthMaintenanceScheduledEventAllOfDataAllOfStatus = {
  scheduled: "scheduled",
} as const;

export type HealthMaintenanceScheduledEventAllOfDataAllOf = {
  status?: HealthMaintenanceScheduledEventAllOfDataAllOfStatus;
};

/**
 * Announces a future maintenance window. Does not change the affected service's or operation's current recorded status.
 */
export type HealthMaintenanceScheduledEventAllOfData = MaintenanceWindow &
  HealthMaintenanceScheduledEventAllOfDataAllOf &
  Required<
    Pick<
      MaintenanceWindow & HealthMaintenanceScheduledEventAllOfDataAllOf,
      "expectedDurationSeconds"
    >
  >;

export type HealthMaintenanceScheduledEventAllOf = {
  /** The type of webhook event. */
  eventType: HealthMaintenanceScheduledEventAllOfEventType;
  /** Announces a future maintenance window. Does not change the affected service's or operation's current recorded status. */
  data: HealthMaintenanceScheduledEventAllOfData;
};

export type HealthMaintenanceScheduledEvent = MaintenanceEventBase &
  HealthMaintenanceScheduledEventAllOf;

/**
 * The type of webhook event.
 */
export type HealthMaintenanceStartedEventAllOfEventType =
  (typeof HealthMaintenanceStartedEventAllOfEventType)[keyof typeof HealthMaintenanceStartedEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const HealthMaintenanceStartedEventAllOfEventType = {
  healthmaintenancestarted: "health.maintenance.started",
} as const;

export type HealthMaintenanceStartedEventAllOfDataAllOfStatus =
  (typeof HealthMaintenanceStartedEventAllOfDataAllOfStatus)[keyof typeof HealthMaintenanceStartedEventAllOfDataAllOfStatus];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const HealthMaintenanceStartedEventAllOfDataAllOfStatus = {
  started: "started",
} as const;

export type HealthMaintenanceStartedEventAllOfDataAllOf = {
  status?: HealthMaintenanceStartedEventAllOfDataAllOfStatus;
};

/**
 * Fired when a previously scheduled maintenance window begins. The affected service's or operation's effective health status is recomputed and reports `under_maintenance`, unless an organic outage is already in progress, which continues to take priority.
 */
export type HealthMaintenanceStartedEventAllOfData = MaintenanceWindow &
  HealthMaintenanceStartedEventAllOfDataAllOf &
  Required<
    Pick<MaintenanceWindow & HealthMaintenanceStartedEventAllOfDataAllOf, "expectedDurationSeconds">
  >;

export type HealthMaintenanceStartedEventAllOf = {
  /** The type of webhook event. */
  eventType: HealthMaintenanceStartedEventAllOfEventType;
  /** Fired when a previously scheduled maintenance window begins. The affected service's or operation's effective health status is recomputed and reports `under_maintenance`, unless an organic outage is already in progress, which continues to take priority. */
  data: HealthMaintenanceStartedEventAllOfData;
};

export type HealthMaintenanceStartedEvent = MaintenanceEventBase &
  HealthMaintenanceStartedEventAllOf;

/**
 * The type of webhook event.
 */
export type HealthMaintenanceCompletedEventAllOfEventType =
  (typeof HealthMaintenanceCompletedEventAllOfEventType)[keyof typeof HealthMaintenanceCompletedEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const HealthMaintenanceCompletedEventAllOfEventType = {
  healthmaintenancecompleted: "health.maintenance.completed",
} as const;

export type HealthMaintenanceCompletedEventAllOfDataAllOfStatus =
  (typeof HealthMaintenanceCompletedEventAllOfDataAllOfStatus)[keyof typeof HealthMaintenanceCompletedEventAllOfDataAllOfStatus];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const HealthMaintenanceCompletedEventAllOfDataAllOfStatus = {
  completed: "completed",
} as const;

export type HealthMaintenanceCompletedEventAllOfDataAllOf = {
  status?: HealthMaintenanceCompletedEventAllOfDataAllOfStatus;
};

/**
 * Fired when a maintenance window ends normally. The affected service's or operation's effective health status is recomputed and returns to `operational`, unless an organic outage remains in progress, which continues to take priority.
 */
export type HealthMaintenanceCompletedEventAllOfData = MaintenanceWindow &
  HealthMaintenanceCompletedEventAllOfDataAllOf;

export type HealthMaintenanceCompletedEventAllOf = {
  /** The type of webhook event. */
  eventType: HealthMaintenanceCompletedEventAllOfEventType;
  /** Fired when a maintenance window ends normally. The affected service's or operation's effective health status is recomputed and returns to `operational`, unless an organic outage remains in progress, which continues to take priority. */
  data: HealthMaintenanceCompletedEventAllOfData;
};

export type HealthMaintenanceCompletedEvent = MaintenanceEventBase &
  HealthMaintenanceCompletedEventAllOf;

/**
 * The type of webhook event.
 */
export type HealthMaintenanceCanceledEventAllOfEventType =
  (typeof HealthMaintenanceCanceledEventAllOfEventType)[keyof typeof HealthMaintenanceCanceledEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const HealthMaintenanceCanceledEventAllOfEventType = {
  healthmaintenancecanceled: "health.maintenance.canceled",
} as const;

export type HealthMaintenanceCanceledEventAllOfDataAllOfStatus =
  (typeof HealthMaintenanceCanceledEventAllOfDataAllOfStatus)[keyof typeof HealthMaintenanceCanceledEventAllOfDataAllOfStatus];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const HealthMaintenanceCanceledEventAllOfDataAllOfStatus = {
  canceled: "canceled",
} as const;

export type HealthMaintenanceCanceledEventAllOfDataAllOf = {
  status?: HealthMaintenanceCanceledEventAllOfDataAllOfStatus;
};

/**
 * Fired when a previously scheduled maintenance window is canceled before it starts.
 */
export type HealthMaintenanceCanceledEventAllOfData = MaintenanceWindow &
  HealthMaintenanceCanceledEventAllOfDataAllOf;

export type HealthMaintenanceCanceledEventAllOf = {
  /** The type of webhook event. */
  eventType: HealthMaintenanceCanceledEventAllOfEventType;
  /** Fired when a previously scheduled maintenance window is canceled before it starts. */
  data: HealthMaintenanceCanceledEventAllOfData;
};

export type HealthMaintenanceCanceledEvent = MaintenanceEventBase &
  HealthMaintenanceCanceledEventAllOf;

/**
 * Common envelope fields included in every Customers webhook event payload.
 */
export interface CustomersEventBase {
  /** Unique identifier for this logical webhook event. Webhooks are delivered at least once, so your endpoint may receive duplicate deliveries for the same event. Use this `eventId` as the idempotency/deduplication key. */
  eventId: string;
  /** The type of webhook event. */
  eventType: string;
  /** The UTC ISO 8601 timestamp at which the underlying state change occurred, not the time at which this webhook was delivered. */
  timestamp: string;
}

/**
 * The type of webhook event.
 */
export type CustomersCapabilityChangedEventAllOfEventType =
  (typeof CustomersCapabilityChangedEventAllOfEventType)[keyof typeof CustomersCapabilityChangedEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const CustomersCapabilityChangedEventAllOfEventType = {
  customerscapabilitychanged: "customers.capability.changed",
} as const;

/**
 * A single capability whose status changed. Carries only `{code, status}`.
 */
export type CustomersCapabilityChangedEventAllOfDataCapabilitiesItem = {
  /** The capability whose status changed. */
  code: CapabilityName;
  /** The new status of the capability after the change. */
  status: CapabilityStatus;
};

/**
 * Payload body for the `customers.capability.changed` event. Emitted when the status of a capability changes. Several capabilities may change in a single event, with each change represented by a distinct entry in the `capabilities` array.
 */
export type CustomersCapabilityChangedEventAllOfData = {
  /** The CDP Customer ID the event applies to. */
  customerId: CustomerId;
  /**
   * The set of capabilities whose status changed in this event.
   * @minItems 1
   */
  capabilities: CustomersCapabilityChangedEventAllOfDataCapabilitiesItem[];
};

export type CustomersCapabilityChangedEventAllOf = {
  /** The type of webhook event. */
  eventType: CustomersCapabilityChangedEventAllOfEventType;
  /** Payload body for the `customers.capability.changed` event. Emitted when the status of a capability changes. Several capabilities may change in a single event, with each change represented by a distinct entry in the `capabilities` array. */
  data: CustomersCapabilityChangedEventAllOfData;
};

export type CustomersCapabilityChangedEvent = CustomersEventBase &
  CustomersCapabilityChangedEventAllOf;

/**
 * The type of webhook event.
 */
export type CustomersCustomerDeletedEventAllOfEventType =
  (typeof CustomersCustomerDeletedEventAllOfEventType)[keyof typeof CustomersCustomerDeletedEventAllOfEventType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const CustomersCustomerDeletedEventAllOfEventType = {
  customerscustomerdeleted: "customers.customer.deleted",
} as const;

/**
 * Payload body for the `customers.customer.deleted` event. Emitted when the Customer record is deleted; this transition is terminal.
 */
export type CustomersCustomerDeletedEventAllOfData = {
  /** The ID of the deleted Customer. */
  customerId: CustomerId;
};

export type CustomersCustomerDeletedEventAllOf = {
  /** The type of webhook event. */
  eventType: CustomersCustomerDeletedEventAllOfEventType;
  /** Payload body for the `customers.customer.deleted` event. Emitted when the Customer record is deleted; this transition is terminal. */
  data: CustomersCustomerDeletedEventAllOfData;
};

export type CustomersCustomerDeletedEvent = CustomersEventBase & CustomersCustomerDeletedEventAllOf;

/**
 * Idempotency key conflict.
 */
export type IdempotencyErrorResponse = Error;

/**
 * The endpoint cannot serve the request right now, either because the API is in an unintended outage (`service_unavailable` — dependency failure, deploy issue) or because an operator has intentionally disabled this specific endpoint via a kill switch (`endpoint_unavailable`). Clients should dispatch on `errorType`: `service_unavailable` is typically transient and safe to retry, while `endpoint_unavailable` may persist until an operator re-enables the endpoint.
 */
export type EndpointUnavailableErrorResponse = Error;

/**
 * Unauthorized.
 */
export type UnauthorizedErrorResponse = Error;

/**
 * Internal server error.
 */
export type InternalServerErrorResponse = Error;

/**
 * Bad gateway.
 */
export type BadGatewayErrorResponse = Error;

/**
 * Service unavailable.
 */
export type ServiceUnavailableErrorResponse = Error;

/**
 * Rate limit exceeded.
 */
export type RateLimitExceededResponse = Error;

/**
 * Payment is required to complete this operation.
 */
export type PaymentRequiredResponse = Error;

/**
 * A payment method is required to complete this operation.
 */
export type PaymentMethodRequiredErrorResponse = Error;

/**
 * The request was rejected due to a delegation issue. The errorType field indicates the specific reason.
 */
export type DelegationForbiddenErrorResponse = Error;

/**
 * The resource already exists.
 */
export type AlreadyExistsErrorResponse = Error;

/**
 * The underlying SQL string is invalid.
 */
export type InvalidSQLQueryErrorResponse = Error;

/**
 * The client closed the connection before the server could send a response.
 */
export type ClientClosedRequestErrorResponse = Error;

/**
 * The request timed out.
 */
export type TimedOutErrorResponse = Error;

/**
 * Optional scheme-specific verify metadata returned by the facilitator.
 */
export type X402VerifyResponseResponseExtra = { [key: string]: unknown };

export type X402VerifyResponseResponse = {
  /** Indicates whether the payment is valid. */
  isValid: boolean;
  invalidReason?: X402VerifyInvalidReason;
  /** The message describing the invalid reason. */
  invalidMessage?: string;
  /** The onchain address of the client that is paying for the resource.

For EVM networks, the payer will be a 0x-prefixed, checksum EVM address.

For Solana-based networks, the payer will be a base58-encoded Solana address. */
  payer: BlockchainAddress;
  /** Optional scheme-specific verify metadata returned by the facilitator. */
  extra?: X402VerifyResponseResponseExtra;
};

/**
 * Invalid payment verification on the x402 protocol.
 */
export type X402VerifyInvalidErrorResponse = X402VerifyPaymentRejection;

/**
 * Optional scheme-specific success metadata returned by the facilitator.
 */
export type X402SettleResponseResponseExtra = { [key: string]: unknown };

export type X402SettleResponseResponse = {
  /** Indicates whether the payment settlement is successful. */
  success: boolean;
  errorReason?: X402SettleErrorReason;
  /** The message describing the error reason. */
  errorMessage?: string;
  /** The onchain address of the client that is paying for the resource.

For EVM networks, the payer will be a 0x-prefixed, checksum EVM address.

For Solana-based networks, the payer will be a base58-encoded Solana address. */
  payer: BlockchainAddress;
  /**
   * The transaction of the settlement.
For EVM networks, the transaction will be a 0x-prefixed, EVM transaction hash.
For Solana-based networks, the transaction will be a base58-encoded Solana signature.
   * @pattern ^(0x[a-fA-F0-9]{64}|[1-9A-HJ-NP-Za-km-z]{87,88})$
   */
  transaction: string;
  /** The network where the settlement occurred. */
  network: string;
  /** The amount that was settled, in atomic units. */
  amount?: string;
  /** Optional scheme-specific success metadata returned by the facilitator. */
  extra?: X402SettleResponseResponseExtra;
};

/**
 * Unsuccessful payment settlement on the x402 protocol.
 */
export type X402SettleErrorResponse = X402SettlePaymentRejection;

/**
 * A map of CAIP-2 network or protocol family patterns to their supported signer addresses.
 */
export type X402SupportedPaymentKindsResponseResponseSigners = { [key: string]: string[] };

export type X402SupportedPaymentKindsResponseResponse = {
  /** The list of supported payment kinds. */
  kinds: X402SupportedPaymentKind[];
  /** The list of supported x402 extensions. */
  extensions: string[];
  /** A map of CAIP-2 network or protocol family patterns to their supported signer addresses. */
  signers: X402SupportedPaymentKindsResponseResponseSigners;
};

/**
 * User forbidden from performing the action.
 */
export type ForbiddenErrorResponse = Error;

/**
 * The number of resources to return per page.
 */
export type PageSizeParameter = number;

/**
 * The token for the next page of resources, if any.
 */
export type PageTokenParameter = string;

/**
 * An optional string request header for making requests safely retryable.
When included, duplicate requests with the same key will return identical responses.
Refer to our [Idempotency docs](https://docs.cdp.coinbase.com/api-reference/v2/idempotency) for more information on using idempotency keys.

 */
export type IdempotencyKeyParameter = string;

/**
 * A JWT signed using your Wallet Secret, encoded in base64. Refer to the
[Generate Wallet Token](https://docs.cdp.coinbase.com/api-reference/v2/authentication#2-generate-wallet-token)
section of our Authentication docs for more details on how to generate your Wallet Token.

 */
export type XWalletAuthParameter = string;

/**
 * The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
 */
export type ProjectIDOptionalParameter = string;

/**
 * A JWT signed using your Wallet Secret, encoded in base64. Refer to the
[Generate Wallet Token](https://docs.cdp.coinbase.com/api-reference/v2/authentication#2-generate-wallet-token)
section of our Authentication docs for more details on how to generate your Wallet Token.

 */
export type XWalletAuthOptionalParameter = string;

/**
 * A JWT signed using your Wallet Secret, encoded in base64. Refer to the
[Generate Wallet Token](https://docs.cdp.coinbase.com/api-reference/v2/authentication#2-generate-wallet-token)
section of our Authentication docs for more details on how to generate your Wallet Token.

 */
export type XDeveloperAuthParameter = string;

/**
 * The Onramp-issued identifier of a disclosed end partner, scoped to an aggregator's developer app. Aggregators integrating Onramp on behalf of multiple end partners set this header to attribute a request to one of their registered partners; omit it for standard, non-aggregator integrations. Only honored for developer apps registered as an aggregator — requires Onramp aggregator onboarding, including registration of each end partner. Contact the Onramp team for access.
 */
export type OnrampPartnerIdParameter = string;

export type ListCustomersParams = {
  /**
   * The number of resources to return per page.
   */
  pageSize?: PageSizeParameter;
  /**
   * The token for the next page of resources, if any.
   */
  pageToken?: PageTokenParameter;
};

export type ListCustomers200AllOf = {
  /** The list of customers. */
  customers: Customer[];
};

export type ListCustomers200 = ListCustomers200AllOf & ListResponse;

export type GetCustomerRequirementsParams = {
  /**
   * The type of the hypothetical customer.
   */
  customerType: CustomerType;
  /**
 * The capabilities the hypothetical customer would request.
Repeat the parameter to specify multiple capabilities, for
example `capabilities=custodyCrypto&capabilities=transferCrypto`.

 * @minItems 1
 */
  capabilities: CapabilityName[];
  /**
 * The hypothetical customer's country of residence. At least one
of `countryCode` or `citizenship` is required. When both are
present, `countryCode` takes precedence.

 */
  countryCode?: CountryCode;
  /**
 * The hypothetical customer's citizenship. At least one of
`countryCode` or `citizenship` is required.

 */
  citizenship?: CountryCode;
};

export type ListPaymentSessionsParams = {
  /**
   * The number of resources to return per page.
   */
  pageSize?: PageSizeParameter;
  /**
   * The token for the next page of resources, if any.
   */
  pageToken?: PageTokenParameter;
};

export type ListPaymentSessions200AllOf = {
  /** The list of payment sessions. */
  paymentSessions: PaymentSession[];
};

export type ListPaymentSessions200 = ListPaymentSessions200AllOf & ListResponse;

export type GetWalletAuthorizationOptionsParams = {
  /**
   * The payer wallet addresses to generate authorization options for. Provide between 1 and 5 unique addresses, comma-separated (e.g. `?addresses=0xA,0xB`). Each returned option's `source.address` identifies which requested address it applies to. If a requested address has no eligible authorization options, it appears in `ineligibleAddresses` with a `code` explaining why.
   * @minItems 1
   * @maxItems 5
   */
  addresses: BlockchainAddress[];
  /**
   * Optional filter to restrict options to a specific blockchain network.
   */
  network?: PaymentSourceNetwork;
  /**
   * Filter options by asset. Currently, only `usdc` and `usdt` return results.
   */
  asset?: Asset;
};

export type ListPaymentSessionAuthorizationsParams = {
  /**
   * The number of resources to return per page.
   */
  pageSize?: PageSizeParameter;
  /**
   * The token for the next page of resources, if any.
   */
  pageToken?: PageTokenParameter;
};

export type ListPaymentSessionAuthorizations200AllOf = {
  /** The list of authorizations. */
  authorizations: Authorization[];
};

export type ListPaymentSessionAuthorizations200 = ListPaymentSessionAuthorizations200AllOf &
  ListResponse;

export type ListPaymentSessionCapturesParams = {
  /**
   * The number of resources to return per page.
   */
  pageSize?: PageSizeParameter;
  /**
   * The token for the next page of resources, if any.
   */
  pageToken?: PageTokenParameter;
};

export type ListPaymentSessionCaptures200AllOf = {
  /** The list of captures. */
  captures: Capture[];
};

export type ListPaymentSessionCaptures200 = ListPaymentSessionCaptures200AllOf & ListResponse;

export type ListPaymentSessionVoidsParams = {
  /**
   * The number of resources to return per page.
   */
  pageSize?: PageSizeParameter;
  /**
   * The token for the next page of resources, if any.
   */
  pageToken?: PageTokenParameter;
};

export type ListPaymentSessionVoids200AllOf = {
  /** The list of voids. */
  voids: Void[];
};

export type ListPaymentSessionVoids200 = ListPaymentSessionVoids200AllOf & ListResponse;

export type ListPaymentSessionRefundsParams = {
  /**
   * The number of resources to return per page.
   */
  pageSize?: PageSizeParameter;
  /**
   * The token for the next page of resources, if any.
   */
  pageToken?: PageTokenParameter;
};

export type ListPaymentSessionRefunds200AllOf = {
  /** The list of refunds. */
  refunds: Refund[];
};

export type ListPaymentSessionRefunds200 = ListPaymentSessionRefunds200AllOf & ListResponse;

export type ListMandatesParams = {
  /**
   * Filter mandates by the customer's wallet address.
   */
  address?: BlockchainAddress;
  /**
   * Filter mandates by the customer's wallet network. Only applies when `address` is also provided.
   */
  network?: PaymentSourceNetwork;
  /**
   * Filter mandates by their latest action, e.g. `approval_succeeded` for mandates whose most recent transition was a successful approval. Note that `status` tracks the latest action, not usability; usability is derived from the `approvedAt`, `canceledAt`, and `revokedAt` timestamps.
   */
  status?: MandateStatus;
  /**
   * The number of resources to return per page.
   */
  pageSize?: PageSizeParameter;
  /**
   * The token for the next page of resources, if any.
   */
  pageToken?: PageTokenParameter;
};

export type ListMandates200AllOf = {
  /** The list of mandates. */
  mandates: Mandate[];
};

export type ListMandates200 = ListMandates200AllOf & ListResponse;

export type ListMandateRevocationsParams = {
  /**
   * The number of resources to return per page.
   */
  pageSize?: PageSizeParameter;
  /**
   * The token for the next page of resources, if any.
   */
  pageToken?: PageTokenParameter;
};

export type ListMandateRevocations200AllOf = {
  /** The list of revocations for the mandate, most recent first. */
  revocations: Revocation[];
};

export type ListMandateRevocations200 = ListMandateRevocations200AllOf & ListResponse;

export type ListMandateApprovalsParams = {
  /**
   * The number of resources to return per page.
   */
  pageSize?: PageSizeParameter;
  /**
   * The token for the next page of resources, if any.
   */
  pageToken?: PageTokenParameter;
};

export type ListMandateApprovals200AllOf = {
  /** The list of approvals for the mandate, most recent first. */
  approvals: Approval[];
};

export type ListMandateApprovals200 = ListMandateApprovals200AllOf & ListResponse;

export type GetWalletApprovalOptionsParams = {
  /**
   * The customer's wallet addresses to generate approval options for. Provide between 1 and 5 unique addresses, comma-separated (e.g. `?addresses=0xA,0xB`). Each returned option's `source.address` identifies which requested address it applies to. If a requested address has no eligible approval options, it appears in `ineligibleAddresses` with a `code` explaining why.
   * @minItems 1
   * @maxItems 5
   */
  addresses: BlockchainAddress[];
  /**
   * Optional filter to restrict options to a specific blockchain network.
   */
  network?: PaymentSourceNetwork;
  /**
   * Filter options by asset. Currently, only `usdc` and `usdt` return results.
   */
  asset?: Asset;
};

export type ListDisbursementsParams = {
  /**
   * The number of resources to return per page.
   */
  pageSize?: PageSizeParameter;
  /**
   * The token for the next page of resources, if any.
   */
  pageToken?: PageTokenParameter;
  /**
   * Filter disbursements by status.
   */
  status?: PaymentActionStatus;
  /**
   * Filter disbursements by the source CDP account ID.
   */
  sourceAccountId?: string;
  /**
   * Filter disbursements by the client-supplied external reference ID.
   */
  externalReferenceId?: string;
};

export type ListDisbursements200AllOf = {
  /** The list of disbursements. */
  disbursements: Disbursement[];
};

export type ListDisbursements200 = ListDisbursements200AllOf & ListResponse;

/**
 * Configuration for creating an EVM account for the end user.
 */
export type CreateEndUserBodyEvmAccount = {
  /** If true, creates an EVM smart account and a default EVM EOA account as the owner. If false, only a EVM EOA account is created. */
  createSmartAccount?: boolean;
  /** If true, enables spend permissions for the EVM smart account. */
  enableSpendPermissions?: boolean;
};

/**
 * Configuration for creating a Solana account for the end user.
 */
export type CreateEndUserBodySolanaAccount = {
  /** Only false is a valid option since currently smart accounts on Solana are not supported. */
  createSmartAccount?: boolean;
};

export type CreateEndUserBody = {
  /**
   * A stable, unique identifier for the end user. The `userId` must be unique across all end users in the developer's CDP Project. It must be between 1 and 100 characters long and can only contain alphanumeric characters and hyphens.

If `userId` is not provided in the request, the server will generate a random UUID.
   * @pattern ^[a-zA-Z0-9-]{1,100}$
   */
  userId?: string;
  authenticationMethods: AuthenticationMethods;
  /** Configuration for creating an EVM account for the end user. */
  evmAccount?: CreateEndUserBodyEvmAccount;
  /** Configuration for creating a Solana account for the end user. */
  solanaAccount?: CreateEndUserBodySolanaAccount;
};

export type ListEndUsersParams = {
  /**
   * The number of end users to return per page.
   * @minimum 1
   * @maximum 100
   */
  pageSize?: number;
  /**
   * The token for the desired page of end users. Will be empty if there are no more end users to fetch.
   */
  pageToken?: string;
  /**
   * Sort end users. Defaults to ascending order (oldest first).
   */
  sort?: ListEndUsersSortItem[];
};

export type ListEndUsersSortItem = (typeof ListEndUsersSortItem)[keyof typeof ListEndUsersSortItem];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const ListEndUsersSortItem = {
  "createdAt=asc": "createdAt=asc",
  "createdAt=desc": "createdAt=desc",
} as const;

export type ListEndUsers200AllOf = {
  /** The list of end users. */
  endUsers: EndUser[];
};

export type ListEndUsers200 = ListEndUsers200AllOf & ListResponse;

/**
 * The request body for a developer to verify an end user's access token.
 */
export type ValidateEndUserAccessTokenBody = {
  /** The access token in JWT format to verify. */
  accessToken: string;
};

export type LookupEndUserParams = {
  /**
   * The email address to search for across all email-based authentication methods.
   */
  email?: Email;
  /**
   * The OAuth provider to search by. Must be provided together with oauthSubject.
   */
  oauthProvider?: OAuth2ProviderType;
  /**
   * The OAuth subject (the `sub` claim from the provider's ID token). Must be provided together with oauthProvider.
   */
  oauthSubject?: string;
  /**
   * The E.164-formatted phone number to search for. Must be URL-encoded when passed as a query parameter (e.g. `+14155552671` → `%2B14155552671`).
   */
  phoneNumber?: PhoneNumber;
  /**
   * The ERC-55 checksummed Ethereum address to search for. Looks up a user by the address they authenticated with via Sign In With Ethereum (EIP-4361).
   */
  siweAddress?: BlockchainAddress;
};

export type LookupEndUser200 = {
  /** The list of end users matching the lookup. */
  endUsers: EndUser[];
};

export type AddEndUserEvmAccountBody = { [key: string]: unknown };

export type AddEndUserEvmAccount201 = {
  evmAccount: EndUserEvmAccount;
};

export type AddEndUserEvmSmartAccountBody = {
  /** If true, enables spend permissions for the EVM smart account. */
  enableSpendPermissions?: boolean;
};

export type AddEndUserEvmSmartAccount201 = {
  evmSmartAccount: EndUserEvmSmartAccount;
};

export type AddEndUserSolanaAccountBody = { [key: string]: unknown };

export type AddEndUserSolanaAccount201 = {
  solanaAccount: EndUserSolanaAccount;
};

/**
 * The type of key being imported. Determines what type of account will be associated for the end user.
 */
export type ImportEndUserBodyKeyType =
  (typeof ImportEndUserBodyKeyType)[keyof typeof ImportEndUserBodyKeyType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const ImportEndUserBodyKeyType = {
  evm: "evm",
  solana: "solana",
} as const;

export type ImportEndUserBody = {
  /**
   * A stable, unique identifier for the end user. The `userId` must be unique across all end users in the developer's CDP Project. It must be between 1 and 100 characters long and can only contain alphanumeric characters and hyphens.
   * @pattern ^[a-zA-Z0-9-]{1,100}$
   */
  userId: string;
  authenticationMethods: AuthenticationMethods;
  /** The base64-encoded, encrypted private key to import. The private key must be encrypted using the CDP SDK's encryption scheme. This is a 32-byte raw private key. */
  encryptedPrivateKey: string;
  /** The type of key being imported. Determines what type of account will be associated for the end user. */
  keyType: ImportEndUserBodyKeyType;
};

export type ListEvmBorrowProductsParams = {
  /**
   * The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
   * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
   */
  projectID?: ProjectIDOptionalParameter;
  /**
   * The EVM network name to list borrow products for.
   */
  network?: BorrowProductNetwork;
  /**
   * The lending protocol whose borrow products to list.
   */
  protocol?: BorrowProductProtocol;
  /**
   * The number of resources to return per page.
   */
  pageSize?: PageSizeParameter;
  /**
   * The token for the next page of resources, if any.
   */
  pageToken?: PageTokenParameter;
};

/**
 * Response containing a list of borrow products.
 */
export type ListEvmBorrowProducts200AllOf = {
  /** The list of borrow products, optionally filtered by the supplied network and/or protocol. */
  borrowProducts: BorrowProduct[];
};

export type ListEvmBorrowProducts200 = ListEvmBorrowProducts200AllOf & ListResponse;

export type GetEvmBorrowProductParams = {
  /**
   * The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
   * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
   */
  projectID?: ProjectIDOptionalParameter;
};

export type SignEvmTransactionWithEndUserAccountParams = {
  /**
   * The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
   * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
   */
  projectID?: ProjectIDOptionalParameter;
};

export type SignEvmTransactionWithEndUserAccountBody = {
  /**
   * The 0x-prefixed address of the EVM account belonging to the end user.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  address: string;
  /** The RLP-encoded transaction to sign, as a 0x-prefixed hex string. */
  transaction: string;
  /**
   * Required when not using delegated signing. The ID of the Temporary Wallet Secret that was used to sign the X-Wallet-Auth Header.
   * @pattern ^[a-zA-Z0-9-]{1,100}$
   */
  walletSecretId?: string;
};

export type SignEvmTransactionWithEndUserAccount200 = {
  /** The RLP-encoded signed transaction, as a 0x-prefixed hex string. */
  signedTransaction: string;
};

export type SendEvmTransactionWithEndUserAccountParams = {
  /**
   * The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
   * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
   */
  projectID?: ProjectIDOptionalParameter;
};

/**
 * The network to send the transaction to.
 */
export type SendEvmTransactionWithEndUserAccountBodyNetwork =
  (typeof SendEvmTransactionWithEndUserAccountBodyNetwork)[keyof typeof SendEvmTransactionWithEndUserAccountBodyNetwork];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SendEvmTransactionWithEndUserAccountBodyNetwork = {
  base: "base",
  "base-sepolia": "base-sepolia",
  ethereum: "ethereum",
  "ethereum-sepolia": "ethereum-sepolia",
  avalanche: "avalanche",
  polygon: "polygon",
  optimism: "optimism",
  arbitrum: "arbitrum",
  "arbitrum-sepolia": "arbitrum-sepolia",
  world: "world",
  "world-sepolia": "world-sepolia",
} as const;

export type SendEvmTransactionWithEndUserAccountBody = {
  /**
   * The 0x-prefixed address of the EVM account belonging to the end user.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  address: string;
  /** The network to send the transaction to. */
  network: SendEvmTransactionWithEndUserAccountBodyNetwork;
  /**
   * Required when not using delegated signing. The ID of the Temporary Wallet Secret that was used to sign the X-Wallet-Auth Header.
   * @pattern ^[a-zA-Z0-9-]{1,100}$
   */
  walletSecretId?: string;
  /** The RLP-encoded transaction to sign and send, as a 0x-prefixed hex string. */
  transaction: string;
};

export type SendEvmTransactionWithEndUserAccount200 = {
  /** The hash of the transaction, as a 0x-prefixed hex string. */
  transactionHash: string;
};

export type SendEvmAssetWithEndUserAccountParams = {
  /**
   * The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
   * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
   */
  projectID?: ProjectIDOptionalParameter;
};

/**
 * The EVM network to send USDC on.
 */
export type SendEvmAssetWithEndUserAccountBodyNetwork =
  (typeof SendEvmAssetWithEndUserAccountBodyNetwork)[keyof typeof SendEvmAssetWithEndUserAccountBodyNetwork];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SendEvmAssetWithEndUserAccountBodyNetwork = {
  base: "base",
  "base-sepolia": "base-sepolia",
  ethereum: "ethereum",
  "ethereum-sepolia": "ethereum-sepolia",
  avalanche: "avalanche",
  polygon: "polygon",
  optimism: "optimism",
  arbitrum: "arbitrum",
  "arbitrum-sepolia": "arbitrum-sepolia",
  world: "world",
  "world-sepolia": "world-sepolia",
} as const;

export type SendEvmAssetWithEndUserAccountBody = {
  /**
   * The 0x-prefixed address of the recipient.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  to: BlockchainAddress;
  /**
   * The amount of USDC to send as a decimal string (e.g., "1.5" or "25.50").
   * @minLength 1
   * @maxLength 32
   */
  amount: string;
  /** The EVM network to send USDC on. */
  network: SendEvmAssetWithEndUserAccountBodyNetwork;
  /** Whether to use CDP Paymaster to sponsor gas fees. Only applicable for EVM Smart Accounts. When true, the transaction gas will be paid by the Paymaster, allowing users to send USDC without holding native gas tokens. Ignored for EOA accounts. Cannot be used together with `paymasterUrl`. */
  useCdpPaymaster?: boolean;
  /** Optional custom Paymaster URL to use for gas sponsorship. Only applicable for EVM Smart Accounts. This allows you to use your own Paymaster service instead of CDP's Paymaster. Cannot be used together with `useCdpPaymaster`. */
  paymasterUrl?: Url;
  paymasterContext?: PaymasterContext;
  /**
   * Required when not using delegated signing. The ID of the Temporary Wallet Secret that was used to sign the X-Wallet-Auth Header.
   * @pattern ^[a-zA-Z0-9-]{1,100}$
   */
  walletSecretId?: string;
};

export type SendEvmAssetWithEndUserAccount200 = {
  /**
   * The hash of the transaction, as a 0x-prefixed hex string. Populated for EOA accounts. Null for Smart Accounts (use userOpHash instead).
   * @nullable
   */
  transactionHash?: string | null;
  /**
   * The hash of the user operation, as a 0x-prefixed hex string. Populated for Smart Accounts. Null for EOA accounts (use transactionHash instead).
   * @nullable
   */
  userOpHash?: string | null;
};

export type SignEvmMessageWithEndUserAccountParams = {
  /**
   * The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
   * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
   */
  projectID?: ProjectIDOptionalParameter;
};

export type SignEvmMessageWithEndUserAccountBody = {
  /**
   * The 0x-prefixed address of the EVM account belonging to the end user.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  address: string;
  /** The message to sign. */
  message: string;
  /**
   * Required when not using delegated signing. The ID of the Temporary Wallet Secret that was used to sign the X-Wallet-Auth Header.
   * @pattern ^[a-zA-Z0-9-]{1,100}$
   */
  walletSecretId?: string;
};

export type SignEvmMessageWithEndUserAccount200 = {
  /** The signature of the message, as a 0x-prefixed hex string. */
  signature: string;
};

export type SignEvmTypedDataWithEndUserAccountParams = {
  /**
   * The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
   * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
   */
  projectID?: ProjectIDOptionalParameter;
};

export type SignEvmTypedDataWithEndUserAccountBody = {
  /**
   * The 0x-prefixed address of the EVM account belonging to the end user.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  address: string;
  typedData: EIP712Message;
  /**
   * Required when not using delegated signing. The ID of the Temporary Wallet Secret that was used to sign the X-Wallet-Auth Header.
   * @pattern ^[a-zA-Z0-9-]{1,100}$
   */
  walletSecretId?: string;
};

export type SignEvmTypedDataWithEndUserAccount200 = {
  /** The signature of the typed data, as a 0x-prefixed hex string. */
  signature: string;
};

export type GetDelegationForEndUserParams = {
  /**
   * The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
   * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
   */
  projectID?: ProjectIDOptionalParameter;
};

export type GetDelegationForEndUser200 = {
  /** The date until which the delegation is valid. */
  expiresAt: string;
};

export type RevokeDelegationForEndUserDeprecatedParams = {
  /**
   * The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
   * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
   */
  projectID?: ProjectIDOptionalParameter;
};

export type RevokeDelegationForEndUserParams = {
  /**
   * The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
   * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
   */
  projectID?: ProjectIDOptionalParameter;
};

export type CreateDelegationForEndUserAccountParams = {
  /**
   * The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
   * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
   */
  projectID?: ProjectIDOptionalParameter;
};

export type CreateDelegationForEndUserAccountBody = {
  /** The date until which the delegation is valid. */
  expiresAt: string;
  /**
   * The ID of the Temporary Wallet Secret that was used to sign the X-Wallet-Auth Header.
   * @pattern ^[a-zA-Z0-9-]{1,100}$
   */
  walletSecretId: string;
};

export type CreateDelegationForEndUserAccount201 = {
  /** The date until which the delegation is valid. */
  expiresAt: string;
};

export type GetDelegationForEndUserAccountParams = {
  /**
   * The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
   * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
   */
  projectID?: ProjectIDOptionalParameter;
};

export type GetDelegationForEndUserAccount200 = {
  /** The date until which the delegation is valid. */
  expiresAt: string;
};

export type RevokeDelegationForEndUserAccountDeprecatedParams = {
  /**
   * The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
   * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
   */
  projectID?: ProjectIDOptionalParameter;
};

export type RevokeDelegationForEndUserAccountParams = {
  /**
   * The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
   * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
   */
  projectID?: ProjectIDOptionalParameter;
};

export type CreateEvmEip7702DelegationWithEndUserAccountParams = {
  /**
   * The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
   * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
   */
  projectID?: ProjectIDOptionalParameter;
};

export type CreateEvmEip7702DelegationWithEndUserAccountBody = {
  /**
   * The 0x-prefixed address of the EVM account to delegate.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  address: string;
  network: EvmEip7702DelegationNetwork;
  /** Whether to configure spend permissions for the upgraded, delegated account. When enabled, the account can grant permissions for third parties to spend on its behalf. */
  enableSpendPermissions?: boolean;
  /**
   * Required when not using delegated signing. The ID of the Temporary Wallet Secret that was used to sign the X-Wallet-Auth Header.
   * @pattern ^[a-zA-Z0-9-]{1,100}$
   */
  walletSecretId?: string;
};

export type CreateEvmEip7702DelegationWithEndUserAccount201 = {
  /** The unique identifier for the delegation operation. Use this to poll the operation status. */
  delegationOperationId: string;
};

export type GetUserOperationWithEndUserAccountParams = {
  /**
   * The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
   * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
   */
  projectID?: ProjectIDOptionalParameter;
};

export type SendUserOperationWithEndUserAccountParams = {
  /**
   * The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
   * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
   */
  projectID?: ProjectIDOptionalParameter;
};

export type SendUserOperationWithEndUserAccountBody = {
  network: EvmUserOperationNetwork;
  /** The list of calls to make from the Smart Account. */
  calls: EvmCall[];
  /** Whether to use the CDP Paymaster for the user operation. */
  useCdpPaymaster: boolean;
  /** The URL of the paymaster to use for the user operation. If using the CDP Paymaster, use the `useCdpPaymaster` option. */
  paymasterUrl?: Url;
  paymasterContext?: PaymasterContext;
  /**
   * Required when not using delegated signing. The ID of the Temporary Wallet Secret that was used to sign the X-Wallet-Auth Header.
   * @pattern ^[a-zA-Z0-9-]{1,100}$
   */
  walletSecretId?: string;
  /**
   * The EIP-8021 data suffix (hex-encoded) that enables transaction attribution for the user operation.
   * @pattern ^0x[0-9a-fA-F]+$
   */
  dataSuffix?: string;
};

export type ListBorrowPositionsWithEndUserAccountParams = {
  /**
   * The number of resources to return per page.
   */
  pageSize?: PageSizeParameter;
  /**
   * The token for the next page of resources, if any.
   */
  pageToken?: PageTokenParameter;
  /**
   * The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
   * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
   */
  projectID?: ProjectIDOptionalParameter;
};

/**
 * Response containing a list of borrow positions.
 */
export type ListBorrowPositionsWithEndUserAccount200AllOf = {
  /** The borrow positions held by the smart account. */
  borrowPositions: BorrowPosition[];
};

export type ListBorrowPositionsWithEndUserAccount200 =
  ListBorrowPositionsWithEndUserAccount200AllOf & ListResponse;

export type CreateBorrowPositionWithEndUserAccountParams = {
  /**
   * The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
   * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
   */
  projectID?: ProjectIDOptionalParameter;
};

export type AdjustBorrowPositionWithEndUserAccountParams = {
  /**
   * The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
   * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
   */
  projectID?: ProjectIDOptionalParameter;
};

export type CloseBorrowPositionWithEndUserAccountParams = {
  /**
   * The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
   * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
   */
  projectID?: ProjectIDOptionalParameter;
};

export type SignSolanaMessageWithEndUserAccountParams = {
  /**
   * The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
   * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
   */
  projectID?: ProjectIDOptionalParameter;
};

export type SignSolanaMessageWithEndUserAccountBody = {
  /**
   * The base58 encoded address of the Solana account belonging to the end user.
   * @pattern ^[1-9A-HJ-NP-Za-km-z]{32,44}$
   */
  address: string;
  /** The base64 encoded arbitrary message to sign. */
  message: string;
  /**
   * Required when not using delegated signing. The ID of the Temporary Wallet Secret that was used to sign the X-Wallet-Auth Header.
   * @pattern ^[a-zA-Z0-9-]{1,100}$
   */
  walletSecretId?: string;
};

export type SignSolanaMessageWithEndUserAccount200 = {
  /** The signature of the message, as a base58 encoded string. */
  signature: string;
};

export type SignSolanaTransactionWithEndUserAccountParams = {
  /**
   * The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
   * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
   */
  projectID?: ProjectIDOptionalParameter;
};

/**
 * The Solana network the transaction targets. Required when using versioned transactions that reference address lookup tables, since resolving those tables requires querying a specific network. Optional otherwise.
 */
export type SignSolanaTransactionWithEndUserAccountBodyNetwork =
  (typeof SignSolanaTransactionWithEndUserAccountBodyNetwork)[keyof typeof SignSolanaTransactionWithEndUserAccountBodyNetwork];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignSolanaTransactionWithEndUserAccountBodyNetwork = {
  solana: "solana",
  "solana-devnet": "solana-devnet",
} as const;

export type SignSolanaTransactionWithEndUserAccountBody = {
  /**
   * The base58 encoded address of the Solana account belonging to the end user.
   * @pattern ^[1-9A-HJ-NP-Za-km-z]{32,44}$
   */
  address: string;
  /** The Solana network the transaction targets. Required when using versioned transactions that reference address lookup tables, since resolving those tables requires querying a specific network. Optional otherwise. */
  network?: SignSolanaTransactionWithEndUserAccountBodyNetwork;
  /** The base64 encoded transaction to sign. */
  transaction: string;
  /**
   * Required when not using delegated signing. The ID of the Temporary Wallet Secret that was used to sign the X-Wallet-Auth Header.
   * @pattern ^[a-zA-Z0-9-]{1,100}$
   */
  walletSecretId?: string;
};

export type SignSolanaTransactionWithEndUserAccount200 = {
  /** The base64 encoded signed transaction. */
  signedTransaction: string;
};

export type SignSolanaX402PaymentWithEndUserAccountParams = {
  /**
   * The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
   * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
   */
  projectID?: ProjectIDOptionalParameter;
};

export type SignSolanaX402PaymentWithEndUserAccountBody = {
  /** The complete x402 payment required response body from the resource server. Top-level fields (x402Version, resource, error, extensions) are preserved in the signed payment payload; acceptsIndex selects which entry from accepts is signed as paymentPayload.accepted. */
  paymentRequired: X402PaymentRequired;
  /**
   * Zero-based index into paymentRequired.accepts selecting which payment option to sign. Must be less than the length of accepts. The entry at this index must be a Solana network payment option for this endpoint.
   * @minimum 0
   */
  acceptsIndex: number;
  /**
   * The base58 encoded address of the end user's Solana account to sign with.
   * @pattern ^[1-9A-HJ-NP-Za-km-z]{32,44}$
   */
  address: string;
  /**
   * Required when not using delegated signing. The ID of the Temporary Wallet Secret that was used to sign the X-Wallet-Auth Header.
   * @pattern ^[a-zA-Z0-9-]{1,100}$
   */
  walletSecretId?: string;
};

export type SignSolanaX402PaymentWithEndUserAccount200 = {
  /** The signed x402 payment payload. Base64-encode this and send it in the PAYMENT-SIGNATURE header of the resource request. */
  paymentPayload: X402PaymentPayload;
};

export type SendSolanaTransactionWithEndUserAccountParams = {
  /**
   * The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
   * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
   */
  projectID?: ProjectIDOptionalParameter;
};

/**
 * The Solana network to send the transaction to.
 */
export type SendSolanaTransactionWithEndUserAccountBodyNetwork =
  (typeof SendSolanaTransactionWithEndUserAccountBodyNetwork)[keyof typeof SendSolanaTransactionWithEndUserAccountBodyNetwork];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SendSolanaTransactionWithEndUserAccountBodyNetwork = {
  solana: "solana",
  "solana-devnet": "solana-devnet",
} as const;

export type SendSolanaTransactionWithEndUserAccountBody = {
  /**
   * The base58 encoded address of the Solana account belonging to the end user.
   * @pattern ^[1-9A-HJ-NP-Za-km-z]{32,44}$
   */
  address: string;
  /** The Solana network to send the transaction to. */
  network: SendSolanaTransactionWithEndUserAccountBodyNetwork;
  /**
   * Required when not using delegated signing. The ID of the Temporary Wallet Secret that was used to sign the X-Wallet-Auth Header.
   * @pattern ^[a-zA-Z0-9-]{1,100}$
   */
  walletSecretId?: string;
  /** The base64 encoded transaction to sign and send. This transaction can contain multiple instructions for native Solana batching. */
  transaction: string;
  /** Whether transaction fees should be sponsored by CDP. When true, CDP sponsors the transaction fees on behalf of the end user. When false, the end user is responsible for paying the transaction fees. */
  useCdpSponsor?: boolean;
};

export type SendSolanaTransactionWithEndUserAccount200 = {
  /** The base58 encoded transaction signature. */
  transactionSignature: string;
};

export type SendSolanaAssetWithEndUserAccountParams = {
  /**
   * The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
   * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
   */
  projectID?: ProjectIDOptionalParameter;
};

/**
 * The Solana network to send USDC on.
 */
export type SendSolanaAssetWithEndUserAccountBodyNetwork =
  (typeof SendSolanaAssetWithEndUserAccountBodyNetwork)[keyof typeof SendSolanaAssetWithEndUserAccountBodyNetwork];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SendSolanaAssetWithEndUserAccountBodyNetwork = {
  solana: "solana",
  "solana-devnet": "solana-devnet",
} as const;

export type SendSolanaAssetWithEndUserAccountBody = {
  /**
   * The base58 encoded address of the recipient.
   * @pattern ^[1-9A-HJ-NP-Za-km-z]{32,44}$
   */
  to: BlockchainAddress;
  /**
   * The amount of USDC to send as a decimal string (e.g., "1.5" or "25.50").
   * @minLength 1
   * @maxLength 32
   */
  amount: string;
  /** The Solana network to send USDC on. */
  network: SendSolanaAssetWithEndUserAccountBodyNetwork;
  /** Whether to automatically create an Associated Token Account (ATA) for the recipient if it doesn't exist. When true, the sender pays the rent-exempt minimum to create the recipient's USDC ATA. When false, the transaction will fail if the recipient doesn't have a USDC ATA. */
  createRecipientAta?: boolean;
  /**
   * Required when not using delegated signing. The ID of the Temporary Wallet Secret that was used to sign the X-Wallet-Auth Header.
   * @pattern ^[a-zA-Z0-9-]{1,100}$
   */
  walletSecretId?: string;
  /** Whether transaction fees should be sponsored by CDP. When true, CDP sponsors the transaction fees on behalf of the end user. When false, the end user is responsible for paying the transaction fees. */
  useCdpSponsor?: boolean;
};

export type SendSolanaAssetWithEndUserAccount200 = {
  /** The base58 encoded transaction signature. */
  transactionSignature: string;
};

export type ListEvmAccountsParams = {
  /**
   * The number of resources to return per page.
   */
  pageSize?: PageSizeParameter;
  /**
   * The token for the next page of resources, if any.
   */
  pageToken?: PageTokenParameter;
};

export type ListEvmAccounts200AllOf = {
  /** The list of EVM accounts. */
  accounts: EvmAccount[];
};

export type ListEvmAccounts200 = ListEvmAccounts200AllOf & ListResponse;

export type CreateEvmAccountBody = {
  /**
   * An optional name for the account.
Account names can consist of alphanumeric characters and hyphens, and be between 2 and 36 characters long.
Account names must be unique across all EVM accounts in the developer's CDP Project.
   * @pattern ^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$
   */
  name?: string;
  /**
   * The ID of the account-level policy to apply to the account.
   * @pattern ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$
   */
  accountPolicy?: string;
};

export type UpdateEvmAccountBody = {
  /**
   * An optional name for the account.
Account names can consist of alphanumeric characters and hyphens, and be between 2 and 36 characters long.
Account names must be unique across all EVM accounts in the developer's CDP Project.
   * @pattern ^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$
   */
  name?: string;
  /**
   * The ID of the account-level policy to apply to the account, or an empty string to unset attached policy.
   * @pattern (^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)|(^$)
   */
  accountPolicy?: string;
};

/**
 * The network to send the transaction to.
 */
export type SendEvmTransactionBodyNetwork =
  (typeof SendEvmTransactionBodyNetwork)[keyof typeof SendEvmTransactionBodyNetwork];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SendEvmTransactionBodyNetwork = {
  base: "base",
  "base-sepolia": "base-sepolia",
  ethereum: "ethereum",
  "ethereum-sepolia": "ethereum-sepolia",
  avalanche: "avalanche",
  polygon: "polygon",
  optimism: "optimism",
  arbitrum: "arbitrum",
  "arbitrum-sepolia": "arbitrum-sepolia",
  world: "world",
  "world-sepolia": "world-sepolia",
} as const;

export type SendEvmTransactionBody = {
  /** The network to send the transaction to. */
  network: SendEvmTransactionBodyNetwork;
  /** The RLP-encoded transaction to sign and send, as a 0x-prefixed hex string. */
  transaction: string;
};

export type SendEvmTransaction200 = {
  /** The hash of the transaction, as a 0x-prefixed hex string. */
  transactionHash: string;
};

export type SignEvmTransactionBody = {
  /** The RLP-encoded transaction to sign, as a 0x-prefixed hex string. */
  transaction: string;
};

export type SignEvmTransaction200 = {
  /** The RLP-encoded signed transaction, as a 0x-prefixed hex string. */
  signedTransaction: string;
};

export type SignEvmHashBody = {
  /** The arbitrary 32 byte hash to sign. */
  hash: string;
};

export type SignEvmHash200 = {
  /** The signature of the hash, as a 0x-prefixed hex string. */
  signature: string;
};

export type SignEvmMessageBody = {
  /** The message to sign. */
  message: string;
};

export type SignEvmMessage200 = {
  /** The signature of the message, as a 0x-prefixed hex string. */
  signature: string;
};

export type SignEvmTypedData200 = {
  /** The signature of the typed data, as a 0x-prefixed hex string. */
  signature: string;
};

export type CreateEvmEip7702DelegationBody = {
  network: EvmEip7702DelegationNetwork;
  /** Whether to configure spend permissions for the upgraded, delegated account. When enabled, the account can grant permissions for third parties to spend on its behalf. */
  enableSpendPermissions?: boolean;
};

export type CreateEvmEip7702Delegation201 = {
  /** The unique identifier for the delegation operation. Use this to poll the operation status. */
  delegationOperationId: string;
};

export type ListEvmSmartAccountsParams = {
  /**
   * The number of resources to return per page.
   */
  pageSize?: PageSizeParameter;
  /**
   * The token for the next page of resources, if any.
   */
  pageToken?: PageTokenParameter;
};

export type ListEvmSmartAccounts200AllOf = {
  /** The list of Smart Accounts. */
  accounts: EvmSmartAccount[];
};

export type ListEvmSmartAccounts200 = ListEvmSmartAccounts200AllOf & ListResponse;

export type CreateEvmSmartAccountBody = {
  /** Today, only a single owner can be set for a Smart Account, but this is an array to allow setting multiple owners in the future. */
  owners: string[];
  /**
   * An optional name for the account.
Account names can consist of alphanumeric characters and hyphens, and be between 2 and 36 characters long.
Account names must be unique across all EVM accounts in the developer's CDP Project.
   * @pattern ^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$
   */
  name?: string;
};

export type ImportEvmAccountBody = {
  /** The base64-encoded, encrypted private key of the EVM account. The private key must be encrypted using the CDP SDK's encryption scheme. */
  encryptedPrivateKey: string;
  /**
   * An optional name for the account.
Account names can consist of alphanumeric characters and hyphens, and be between 2 and 36 characters long.
Account names must be unique across all EVM accounts in the developer's CDP Project.
   * @pattern ^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$
   */
  name?: string;
  /**
   * The ID of the account-level policy to apply to the account.
   * @pattern ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$
   */
  accountPolicy?: string;
};

export type ExportEvmAccountBody = {
  /** The base64-encoded, public part of the RSA key in DER format used to encrypt the account private key. */
  exportEncryptionKey: string;
};

export type ExportEvmAccount200 = {
  /** The base64-encoded, encrypted private key of the EVM account which is a 32 byte raw private key. The private key is encrypted in transport using the exportEncryptionKey in the request. */
  encryptedPrivateKey: string;
};

export type ExportEvmAccountByNameBody = {
  /** The base64-encoded, public part of the RSA key in DER format used to encrypt the account private key. */
  exportEncryptionKey: string;
};

export type ExportEvmAccountByName200 = {
  /** The base64-encoded, encrypted private key of the EVM account which is a 32 byte raw private key. The private key is encrypted in transport using the exportEncryptionKey in the request. */
  encryptedPrivateKey: string;
};

export type UpdateEvmSmartAccountBody = {
  /**
   * An optional name for the smart account.
Account names can consist of alphanumeric characters and hyphens, and be between 2 and 36 characters long.
Account names must be unique across all EVM smart accounts in the developer's CDP Project.
   * @pattern ^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$
   */
  name?: string;
};

export type PrepareUserOperationBody = {
  network: EvmUserOperationNetwork;
  /** The list of calls to make from the Smart Account. */
  calls: EvmCall[];
  /** The URL of the paymaster to use for the user operation. */
  paymasterUrl?: Url;
  paymasterContext?: PaymasterContext;
  /**
   * The EIP-8021 data suffix (hex-encoded) that enables transaction attribution for the user operation.
   * @pattern ^0x[0-9a-fA-F]+$
   */
  dataSuffix?: string;
};

export type PrepareAndSendUserOperationBody = {
  network: EvmUserOperationNetwork;
  /** The list of calls to make from the Smart Account. */
  calls: EvmCall[];
  /** The URL of the paymaster to use for the user operation. */
  paymasterUrl?: Url;
  paymasterContext?: PaymasterContext;
};

export type SendUserOperationBody = {
  /** The hex-encoded signature of the user operation. This should be a 65-byte signature consisting of the `r`, `s`, and `v` values of the ECDSA signature. Note that the `v` value should conform to the `personal_sign` standard, which means it should be 27 or 28. */
  signature: string;
};

export type ListSpendPermissionsParams = {
  /**
   * The number of spend permissions to return per page.
   */
  pageSize?: number;
  /**
   * The token for the next page of spend permissions. Will be empty if there are no more spend permissions to fetch.
   */
  pageToken?: string;
};

export type ListSpendPermissions200AllOf = {
  /** The spend permissions for the smart account. */
  spendPermissions: SpendPermissionResponseObject[];
};

export type ListSpendPermissions200 = ListSpendPermissions200AllOf & ListResponse;

export type GetEvmSwapPriceParams = {
  network: EvmSwapsNetwork;
  toToken: ToToken;
  fromToken: FromToken;
  fromAmount: FromAmount;
  taker: Taker;
  signerAddress?: SignerAddress;
  gasPrice?: GasPrice;
  slippageBps?: SlippageBps;
};

export type CreateEvmSwapQuoteBody = {
  network: EvmSwapsNetwork;
  /**
   * The 0x-prefixed contract address of the token to receive.
   * @pattern ^0x[a-fA-F0-9]{40}$
   */
  toToken: string;
  /**
   * The 0x-prefixed contract address of the token to send.
   * @pattern ^0x[a-fA-F0-9]{40}$
   */
  fromToken: string;
  /**
   * The amount of the `fromToken` to send in atomic units of the token. For example, `1000000000000000000` when sending ETH equates to 1 ETH, `1000000` when sending USDC equates to 1 USDC, etc.
   * @pattern ^\d+$
   */
  fromAmount: string;
  /**
   * The 0x-prefixed address that holds the `fromToken` balance and has the `Permit2` allowance set for the swap.
   * @pattern ^0x[a-fA-F0-9]{40}$
   */
  taker: string;
  /**
   * The 0x-prefixed Externally Owned Account (EOA) address that will sign the `Permit2` EIP-712 permit message. This is only needed if `taker` is a smart contract.
   * @pattern ^0x[a-fA-F0-9]{40}$
   */
  signerAddress?: string;
  /**
   * The target gas price for the swap transaction, in Wei. For EIP-1559 transactions, this value should be seen as the `maxFeePerGas` value. If not provided, the API will use an estimate based on the current network conditions.
   * @pattern ^\d+$
   */
  gasPrice?: string;
  /**
   * The maximum acceptable slippage of the `toToken` in basis points. If this parameter is set to 0, no slippage will be tolerated. If not provided, the default slippage tolerance is 100 bps (i.e., 1%).
   * @minimum 0
   * @maximum 10000
   */
  slippageBps?: number;
};

export type ListEvmTokenBalancesParams = {
  /**
   * The number of resources to return per page.
   */
  pageSize?: PageSizeParameter;
  /**
   * The token for the next page of resources, if any.
   */
  pageToken?: PageTokenParameter;
};

export type ListEvmTokenBalances200AllOf = {
  /** The list of EVM token balances. */
  balances: TokenBalance[];
};

export type ListEvmTokenBalances200 = ListEvmTokenBalances200AllOf & ListResponse;

/**
 * The network to request funds from.
 */
export type RequestEvmFaucetBodyNetwork =
  (typeof RequestEvmFaucetBodyNetwork)[keyof typeof RequestEvmFaucetBodyNetwork];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const RequestEvmFaucetBodyNetwork = {
  "base-sepolia": "base-sepolia",
  "ethereum-sepolia": "ethereum-sepolia",
  "ethereum-hoodi": "ethereum-hoodi",
} as const;

/**
 * The token to request funds for.
 */
export type RequestEvmFaucetBodyToken =
  (typeof RequestEvmFaucetBodyToken)[keyof typeof RequestEvmFaucetBodyToken];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const RequestEvmFaucetBodyToken = {
  eth: "eth",
  usdc: "usdc",
  eurc: "eurc",
  cbbtc: "cbbtc",
} as const;

export type RequestEvmFaucetBody = {
  /** The network to request funds from. */
  network: RequestEvmFaucetBodyNetwork;
  /**
   * The address to request funds to, which is a 0x-prefixed hexadecimal string.
   * @pattern ^0x[0-9a-fA-F]{40}$
   */
  address: string;
  /** The token to request funds for. */
  token: RequestEvmFaucetBodyToken;
};

export type RequestEvmFaucet200 = {
  /** The hash of the transaction that requested the funds.
   **Note:** In rare cases, when gas conditions are unusually high, the transaction may not confirm, and the system may issue a replacement transaction to complete the faucet request. In these rare cases, the `transactionHash` will be out of sync with the actual faucet transaction that was confirmed onchain. */
  transactionHash: string;
};

export type ListPoliciesParams = {
  /**
   * The number of resources to return per page.
   */
  pageSize?: PageSizeParameter;
  /**
   * The token for the next page of resources, if any.
   */
  pageToken?: PageTokenParameter;
  /**
   * The scope of the policies to return. If `project`, the response will include exactly one policy, which is the project-level policy. If `account`, the response will include all account-level policies for the developer's CDP Project.
   */
  scope?: ListPoliciesScope;
};

export type ListPoliciesScope = (typeof ListPoliciesScope)[keyof typeof ListPoliciesScope];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const ListPoliciesScope = {
  project: "project",
  account: "account",
} as const;

export type ListPolicies200AllOf = {
  /** The list of policies. */
  policies: Policy[];
};

export type ListPolicies200 = ListPolicies200AllOf & ListResponse;

/**
 * The scope of the policy.
 */
export type CreatePolicyBodyScope =
  (typeof CreatePolicyBodyScope)[keyof typeof CreatePolicyBodyScope];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const CreatePolicyBodyScope = {
  project: "project",
  account: "account",
} as const;

export type CreatePolicyBody = {
  /** The scope of the policy. */
  scope: CreatePolicyBodyScope;
  /**
   * An optional human-readable description for the policy.
Policy descriptions can consist of alphanumeric characters, spaces, commas, and periods, and be 50 characters or less.
   * @pattern ^[A-Za-z0-9 ,.]{1,50}$
   */
  description?: string;
  rules: PolicyRules;
};

export type UpdatePolicyBody = {
  /**
   * An optional human-readable description for the policy.
Policy descriptions can consist of alphanumeric characters, spaces, commas, and periods, and be 50 characters or less.
   * @pattern ^[A-Za-z0-9 ,.]{1,50}$
   */
  description?: string;
  rules: PolicyRules;
};

export type ListSolanaAccountsParams = {
  /**
   * The number of resources to return per page.
   */
  pageSize?: PageSizeParameter;
  /**
   * The token for the next page of resources, if any.
   */
  pageToken?: PageTokenParameter;
};

export type ListSolanaAccounts200AllOf = {
  /** The list of Solana accounts. */
  accounts: SolanaAccount[];
};

export type ListSolanaAccounts200 = ListSolanaAccounts200AllOf & ListResponse;

export type CreateSolanaAccountBody = {
  /**
   * An optional name for the account.
Account names can consist of alphanumeric characters and hyphens, and be between 2 and 36 characters long.
Account names must be unique across all Solana accounts in the developer's CDP Project.
   * @pattern ^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$
   */
  name?: string;
  /**
   * The ID of the account-level policy to apply to the account.
   * @pattern ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$
   */
  accountPolicy?: string;
};

export type UpdateSolanaAccountBody = {
  /**
   * An optional name for the account. Account names can consist of alphanumeric characters and hyphens, and be between 2 and 36 characters long.
Account names must be unique across all Solana accounts in the developer's CDP Project.
   * @pattern ^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$
   */
  name?: string;
  /**
   * The ID of the account-level policy to apply to the account, or an empty string to unset attached policy.
   * @pattern (^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)|(^$)
   */
  accountPolicy?: string;
};

export type ImportSolanaAccountBody = {
  /** The base64-encoded, encrypted 32-byte private key of the Solana account. The private key must be encrypted using the CDP SDK's encryption scheme. */
  encryptedPrivateKey: string;
  /**
   * An optional name for the account.
Account names can consist of alphanumeric characters and hyphens, and be between 2 and 36 characters long.
Account names must be unique across all EVM accounts in the developer's CDP Project.
   * @pattern ^[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$
   */
  name?: string;
};

export type ExportSolanaAccountBody = {
  /** The base64-encoded, public part of the RSA key in DER format used to encrypt the account private key. */
  exportEncryptionKey: string;
};

export type ExportSolanaAccount200 = {
  /** The base64-encoded, encrypted private key of the Solana account which is a 32 byte raw private key. The private key is encrypted in transport using the exportEncryptionKey in the request. */
  encryptedPrivateKey: string;
};

export type ExportSolanaAccountByNameBody = {
  /** The base64-encoded, public part of the RSA key in DER format used to encrypt the account private key. */
  exportEncryptionKey: string;
};

export type ExportSolanaAccountByName200 = {
  /** The base64-encoded, encrypted private key of the Solana account which is a 32 byte raw private key. The private key is encrypted in transport using the exportEncryptionKey in the request. */
  encryptedPrivateKey: string;
};

/**
 * The Solana network the transaction targets. Required when using versioned transactions that reference address lookup tables, since resolving those tables requires querying a specific network. Optional otherwise.
 */
export type SignSolanaTransactionBodyNetwork =
  (typeof SignSolanaTransactionBodyNetwork)[keyof typeof SignSolanaTransactionBodyNetwork];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignSolanaTransactionBodyNetwork = {
  solana: "solana",
  "solana-devnet": "solana-devnet",
} as const;

export type SignSolanaTransactionBody = {
  /** The Solana network the transaction targets. Required when using versioned transactions that reference address lookup tables, since resolving those tables requires querying a specific network. Optional otherwise. */
  network?: SignSolanaTransactionBodyNetwork;
  /** The base64 encoded transaction to sign. */
  transaction: string;
};

export type SignSolanaTransaction200 = {
  /** The base64 encoded signed transaction. */
  signedTransaction: string;
};

/**
 * The encoding of the message. Use `utf8` to sign the literal UTF-8 bytes of the message, or `base64` to decode an RFC 4648 standard Base64 string before signing. Base64 input must use the standard `+` and `/` alphabet with `=` padding where required. If omitted, the message is interpreted as UTF-8.
 */
export type SignSolanaMessageBodyEncoding =
  (typeof SignSolanaMessageBodyEncoding)[keyof typeof SignSolanaMessageBodyEncoding];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SignSolanaMessageBodyEncoding = {
  utf8: "utf8",
  base64: "base64",
} as const;

export type SignSolanaMessageBody = {
  /** The arbitrary message to sign. */
  message: string;
  /** The encoding of the message. Use `utf8` to sign the literal UTF-8 bytes of the message, or `base64` to decode an RFC 4648 standard Base64 string before signing. Base64 input must use the standard `+` and `/` alphabet with `=` padding where required. If omitted, the message is interpreted as UTF-8. */
  encoding?: SignSolanaMessageBodyEncoding;
};

export type SignSolanaMessage200 = {
  /** The signature of the message, as a base58 encoded string. */
  signature: string;
};

/**
 * The Solana network to send the transaction to.
 */
export type SendSolanaTransactionBodyNetwork =
  (typeof SendSolanaTransactionBodyNetwork)[keyof typeof SendSolanaTransactionBodyNetwork];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SendSolanaTransactionBodyNetwork = {
  solana: "solana",
  "solana-devnet": "solana-devnet",
} as const;

export type SendSolanaTransactionBody = {
  /** The Solana network to send the transaction to. */
  network: SendSolanaTransactionBodyNetwork;
  /** The base64 encoded transaction to sign and send. This transaction can contain multiple instructions for native Solana batching. */
  transaction: string;
  /** Whether transaction fees should be sponsored by CDP. When true, CDP sponsors the transaction fees on behalf of the server wallet. When false, the server wallet is responsible for paying the transaction fees. */
  useCdpSponsor?: boolean;
};

export type SendSolanaTransaction200 = {
  /** The base58 encoded transaction signature. */
  transactionSignature: string;
};

/**
 * The token to request funds for.
 */
export type RequestSolanaFaucetBodyToken =
  (typeof RequestSolanaFaucetBodyToken)[keyof typeof RequestSolanaFaucetBodyToken];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const RequestSolanaFaucetBodyToken = {
  sol: "sol",
  usdc: "usdc",
  cbtusd: "cbtusd",
} as const;

export type RequestSolanaFaucetBody = {
  /**
   * The address to request funds to, which is a base58-encoded string.
   * @pattern ^[1-9A-HJ-NP-Za-km-z]{32,44}$
   */
  address: string;
  /** The token to request funds for. */
  token: RequestSolanaFaucetBodyToken;
};

export type RequestSolanaFaucet200 = {
  /** The signature identifying the transaction that requested the funds. */
  transactionSignature: string;
};

export type ListSolanaTokenBalancesParams = {
  /**
   * The number of balances to return per page.
   */
  pageSize?: number;
  /**
   * The token for the next page of balances. Will be empty if there are no more balances to fetch.
   */
  pageToken?: string;
};

export type ListSolanaTokenBalances200AllOf = {
  /** The list of Solana token balances. */
  balances: SolanaTokenBalance[];
};

export type ListSolanaTokenBalances200 = ListSolanaTokenBalances200AllOf & ListResponse;

export type GetSQLSchemaParams = {
  /**
   * The name of the database to query. Defaults to "base" when not specified.
   */
  database?: GetSQLSchemaDatabase;
  /**
   * Get the schema for a specific table.
   */
  table?: string;
};

export type GetSQLSchemaDatabase = (typeof GetSQLSchemaDatabase)[keyof typeof GetSQLSchemaDatabase];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const GetSQLSchemaDatabase = {
  base: "base",
  base_sepolia: "base_sepolia",
  solana: "solana",
  hyperevm: "hyperevm",
} as const;

export type ListDataTokenBalancesParams = {
  /**
   * The number of resources to return per page.
   */
  pageSize?: PageSizeParameter;
  /**
   * The token for the next page of resources, if any.
   */
  pageToken?: PageTokenParameter;
};

export type ListDataTokenBalances200AllOf = {
  /** The list of EVM token balances. */
  balances: TokenBalance[];
};

export type ListDataTokenBalances200 = ListDataTokenBalances200AllOf & ListResponse;

export type ListWebhookSubscriptionsParams = {
  /**
   * The number of subscriptions to return per page.
   * @minimum 1
   * @maximum 100
   */
  pageSize?: number;
  /**
   * The token for the next page of subscriptions, if any.
   */
  pageToken?: string;
};

export type ListWebhookSubscriptionEventsParams = {
  /**
   * Filter by a specific event ID.
   */
  eventId?: string;
  /**
   * Filter events created at or after this timestamp (RFC 3339 format).
   */
  minCreatedAt?: string;
  /**
   * Filter events created at or before this timestamp (RFC 3339 format).
   */
  maxCreatedAt?: string;
  /**
   * Filter by event type names (comma-separated).
   */
  eventTypeNames?: string;
};

export type VerifyX402PaymentBody = {
  x402Version: X402Version;
  paymentPayload: X402PaymentPayload;
  paymentRequirements: X402PaymentRequirements;
};

export type SettleX402PaymentBody = {
  x402Version: X402Version;
  paymentPayload: X402PaymentPayload;
  paymentRequirements: X402PaymentRequirements;
};

export type ListX402DiscoveryResourcesParams = {
  /**
 * Filter by protocol type (e.g., "http", "mcp").
Currently, the only supported protocol type is "http".
 */
  type?: string;
  /**
   * The number of discovered x402 resources to return per page.
   */
  limit?: number;
  /**
   * The offset of the first discovered x402 resource to return.
   */
  offset?: number;
};

export type ListX402DiscoveryMerchantParams = {
  /**
 * The merchant's payment address to look up.
This is the onchain address that payment requirements route funds to.
 */
  payTo: BlockchainAddress;
  /**
   * The number of resources to return per page.
   */
  limit?: number;
  /**
   * The offset of the first resource to return.
   */
  offset?: number;
};

export type SearchX402ResourcesParams = {
  /**
   * Full-text or semantic search query to find matching resources.
   * @maxLength 400
   */
  query?: string;
  /**
 * Filter results by network in CAIP-2 format (e.g., `eip155:8453`) or legacy name (e.g., `base`, `base-sepolia`, `solana`).
Legacy names are normalized to their CAIP-2 equivalents before filtering.
 */
  network?: string;
  /**
 * Filter results by asset address.
For EVM networks, provide a 0x-prefixed EVM address. For Solana networks, provide a base58-encoded address.
Matching is case-insensitive.
 */
  asset?: string;
  /**
   * Filter results by payment scheme (e.g., `exact`).
   */
  scheme?: string;
  /**
 * Filter results by the merchant's payment address.
For EVM networks, provide a 0x-prefixed EVM address. For Solana networks, provide a base58-encoded address.
 */
  payTo?: BlockchainAddress;
  /**
 * Filter results to resources whose URL contains this value (case-insensitive substring match against the resource URL).
Useful for narrowing results to a specific domain, subdomain, or path segment. Combine with `query` to perform semantic search restricted to a URL subset.
Tip: include enough of the URL to disambiguate (e.g. `api.example.com` rather than `example`) — a short substring may also match resources whose path contains the same string.
 * @minLength 3
 * @maxLength 2048
 */
  urlSubstring?: string;
  /**
   * Filter results to resources with a USD price at or below this value.
   */
  maxUsdPrice?: string;
  /**
   * Filter results to resources that support the specified protocol extensions. Can be specified multiple times to filter by multiple extensions.
   */
  extensions?: string[];
  /**
   * Filter results to resources published with any of the specified provider tags (case-sensitive exact match). Can be specified multiple times to filter by multiple tags; a resource matches if it carries at least one of the supplied tags (OR).
   * @maxItems 5
   */
  tags?: string[];
  /**
   * Filter results to resources that belong to any of the specified curated bundles (by bundle slug). Can be specified multiple times to filter by multiple bundles; a resource matches if it belongs to at least one of the supplied bundles (OR).
   * @maxItems 5
   */
  bundleSlugs?: string[];
  /**
   * When `true`, restrict results to Coinbase-curated resources (those with `curated: true`). When `false` or omitted, both curated and non-curated resources are returned.
   */
  curatedOnly?: boolean;
  /**
 * Maximum number of resources to return. Must be a positive integer no greater than 20.
Defaults to 20.
 * @minimum 1
 * @maximum 20
 */
  limit?: number;
};

export type CreateOnrampOrderBody = {
  /** The timestamp of when the user acknowledged that by using Coinbase Onramp they are accepting the Coinbase Terms (https://www.coinbase.com/legal/guest-checkout/us), User Agreement (https://www.coinbase.com/legal/user_agreement),  and Privacy Policy (https://www.coinbase.com/legal/privacy). */
  agreementAcceptedAt?: string;
  /** The address the purchased crypto will be sent to. */
  destinationAddress: BlockchainAddress;
  /** The name of the crypto network the purchased currency will be sent on.

Use the [Onramp Buy Options API](https://docs.cdp.coinbase.com/api-reference/rest-api/onramp-offramp/get-buy-options) to discover the supported networks for your user's location. */
  destinationNetwork: string;
  /** The verified email address of the user requesting the onramp transaction. This email must be verified by your app (via OTP) before being used with the Onramp API. */
  email?: string;
  /** If true, this API will return a quote without creating any transaction. */
  isQuote?: boolean;
  /** Optional partner order reference ID. */
  partnerOrderRef?: string;
  /** A unique string that represents the user in your app. This can be used to link individual transactions together so you can retrieve the transaction history for your users. Prefix this string with "sandbox-" (e.g. "sandbox-user-1234") to perform a sandbox transaction which will allow you to test your integration without any real transfer of funds.

This value can be used with the [Onramp User Transactions API](https://docs.cdp.coinbase.com/api-reference/rest-api/onramp-offramp/get-onramp-transactions-by-id) to retrieve all transactions created by the user. */
  partnerUserRef: string;
  /** A string representing the amount of fiat the user wishes to pay in exchange for crypto. When using  this parameter, the returned quote will be inclusive of fees i.e. the user will pay this exact amount  of the payment currency. */
  paymentAmount?: string;
  /** The fiat currency to be converted to crypto. */
  paymentCurrency: string;
  paymentMethod: OnrampOrderPaymentMethodTypeId;
  /** The phone number of the user requesting the onramp transaction in E.164 format. This phone number must  be verified by your app (via OTP) before being used with the Onramp API.
Please refer to the [Onramp docs](https://docs.cdp.coinbase.com/onramp/headless-onramp/overview) for more details on phone number verification requirements and best practices. */
  phoneNumber?: string;
  /** Timestamp of when the user's phone number was verified via OTP. User phone number must be verified every 60 days. If this timestamp is older than 60 days, an error will be returned. */
  phoneNumberVerifiedAt?: string;
  /** The SMS verification ID returned by the Submit Onramp Verification endpoint after verifying the user's phone number. When provided, Onramp validates the server-side verification record instead of trusting `phoneNumberVerifiedAt`. */
  smsVerificationId?: OnrampVerificationId;
  /** The email verification ID returned by the Submit Onramp Verification endpoint after verifying the user's email address. */
  emailVerificationId?: OnrampVerificationId;
  /** A string representing the amount of crypto the user wishes to purchase. When using this parameter the  returned quote will be exclusive of fees i.e. the user will receive this exact amount of the purchase  currency. */
  purchaseAmount?: string;
  /** The ticker (e.g. `BTC`, `USDC`, `SOL`) or the Coinbase UUID (e.g. `d85dce9b-5b73-5c3c-8978-522ce1d1c1b4`)  of the crypto asset to be purchased.

Use the [Onramp Buy Options API](https://docs.cdp.coinbase.com/api-reference/rest-api/onramp-offramp/get-buy-options) to discover the supported purchase currencies for your user's location. */
  purchaseCurrency: string;
  /** The IP address of the end user requesting the onramp transaction. */
  clientIp?: string;
  /** The domain that the Apple Pay or Google Pay button will be rendered on. Required when using the `GUEST_CHECKOUT_APPLE_PAY` or `GUEST_CHECKOUT_GOOGLE_PAY` payment method and embedding the payment link in an iframe. Omit this field entirely for mobile iOS Apple Pay via WebView integration. */
  domain?: string;
  /**
   * Optional [BCP-47](https://www.rfc-editor.org/info/bcp47) locale tag (e.g. `es-ES`, `pt-BR`, `en`) used to localize the hosted payment page. When provided, it is appended to the returned `paymentLink` URL and mapped to the closest locale supported by the Apple Pay and Google Pay buttons; unsupported locales fall back to the user's browser language. Any well-formed BCP-47 tag is accepted.
   * @pattern ^[a-zA-Z]{2,3}(-[a-zA-Z0-9]{2,8})*$
   */
  locale?: string;
  /** Optional. A reusable token returned by a previous verified order. When provided, a returning user checking out to the same wallet is taken straight to the pay button, skipping OTP (best-effort — an invalid, expired, or different-wallet token still requires verification). */
  userAuthToken?: OnrampUserAuthToken;
};

export type CreateOnrampOrder201 = {
  order: OnrampOrder;
  paymentLink?: OnrampPaymentLink;
  /** Present for embedded orders once the user has verified. Store this and pass it on future orders for the same user to skip OTP verification. Valid for 60 days. */
  userAuthToken?: OnrampUserAuthToken;
};

export type GetOnrampOrderById200 = {
  order: OnrampOrder;
};

export type CreateOnrampSession201 = {
  session: OnrampSession;
  quote?: OnrampQuote;
};

export type GetOnrampUserLimitsBody = {
  paymentMethodType: OnrampOrderPaymentMethodTypeId;
  /** The user identifier value. For `phone_number` type, this must be in E.164 format. */
  userId: string;
  userIdType: OnrampUserIdType;
};

export type GetOnrampUserLimits200 = {
  /** The list of limits applicable to the user. */
  limits: OnrampUserLimit[];
  /** The user's limit upgrade status and associated upgrade details. Omitted when limit upgrades are not available for the calling app or user. Use the [Request Limit Upgrade](https://docs.cdp.coinbase.com/api-reference/v2/rest-api/onramp/request-limits-upgrade) endpoint to request a limit upgrade. */
  limitUpgradeOptions?: OnrampLimitUpgradeOption[];
};