Including TypeScript Library

To include the library in your TypeScript program, you can follow these steps:

  1. Create a TypeScript file (e.g., myProgram.ts) where you intend to use the Circular library.

  2. In the same directory as your TypeScript file, create a TypeScript declaration file (e.g., Circular.d.ts) to define the types for the Circular library. This file should include the TypeScript interface for the Circular object. Below is an example of the content for Circular.d.ts:

declare module 'Circular' {
        interface Circular {
            GetWallet(Blockchain: string, Address: string): Promise;
            SetNAGKey(NAGKey: string): void;
            SetNAGURL(NURL: string): void;
            stringToHex(str: string): string;
            RegisterWallet(Blockchain: string, PrivateKey: string): Promise;
            GetAsset(Blockchain: string, Name: string): Promise;
            GetAssetSupply(Blockchain: string, Name: string): Promise;
            SignMessage(message: string, privateKey: string): string;
            getPublicKey(privateKey: string): string;
            getFormattedTimestamp(): string;
            verifySignature(publicKey: string, message: string, signature: string): boolean;
            GetBlock(Blockchain: string, Num: number): Promise;
            SendTransaction(ID: string, From: string, To: string, Timestamp: string, Type: string,
                         Payload: string, Nonce: string, PublicKey: string, Signature: string, Blockchain: string ): Promise;
          }

        const Circular: Circular;
        export default Circular;
}
  1. In your TypeScript program (myProgram.ts), you can now import and use the Circular library like this:

   import Circular from 'Circular';

    // Create the Circular object
    const circular: Circular = (() => {
    // ... (The rest of your code goes here)
    })();

Ensure that the TypeScript declaration file (Circular.d.ts) and the library files (JavaScript files) are located in the same directory or have the correct relative path specified in the import statement.

  1. You can now use the Circular library functions and objects with TypeScript type checking in your myProgram.ts file.

Don't forget to install any required dependencies, such as 'elliptic' and 'sha256,' using npm or yarn to guarantee the correct functioning of the library.

Last updated