controller.ts


Overview

The [controller.ts](/projects/291/68853) file defines the `Proxy` controller class, which is a part of the Proxy API Service. This service acts as an intermediary layer that provides RESTful API endpoints, notably exposing an **address validation** endpoint. The controller leverages the `Elliptic` class to perform address validation by interacting with the Elliptic AML API.

This file's primary responsibility is to expose the [/api/v1/validate/{address}](/projects/291/69210) GET endpoint, which clients can call to verify the validity and risk status of a blockchain address. It handles request routing, response typing, validation annotations, and error handling using common API error classes.


Detailed Breakdown

Imports


Class: Proxy

The `Proxy` class extends [Controller](/projects/291/69211) from tsoa and exposes the address validation endpoint.

Decorators:


Method: validateAddress

async validateAddress(@Path() address: string): Promise<ValidationResult>
const proxy = new Proxy();

proxy.validateAddress('0x1234abcd...').then(result => {
  console.log(result.valid ? 'Address is valid' : 'Address is invalid');
}).catch(err => {
  console.error('Validation failed:', err);
});

Important Implementation Details


Interaction with Other Modules


Mermaid Class Diagram

The following class diagram shows the structure of the `Proxy` controller class, its method, and its relationship with the `Elliptic` instance.

classDiagram
    class Proxy {
        +validateAddress(address: string): Promise<ValidationResult>
    }
    class Elliptic {
        +validateAddress(address: string): Promise<ValidationResult>
    }
    Proxy --> Elliptic : uses

Summary

This file acts as the entry point for clients seeking address validation services, providing a clean, well-documented REST interface that abstracts the complexities of AML checks and caching handled elsewhere in the system.