Code Monkey home page Code Monkey logo

trophy

Hi there šŸ‘‹

I'm Johnny, ex Physics teacher, currently a passionate developer, future philantropist (hopefully).

šŸ”­ Iā€™m currently working on ...

  • rusty-bot: Simple discord server bot that holds "reputation" value for each member of a guild and gives those members api to change each other's reputation, query the messages and times. All in rust lang
  • airecruter: an LLM based Algorithm to ease out a job search
  • driver.app: Startup to conquer the ridesharing industry by storm.

šŸŒ± Iā€™m currently learning ...

  • Rust
  • Blockchain
  • Web3

šŸ’¬ Ask me about ...

  • Anything related to C or TypeScript, front end or backend.
  • Blockchain and decentralized applications
  • Any interesting idea to work on? [ I am an idea generator and can help with some creative brainstorms ]

šŸ“« How to reach me ...

āš” Fun fact ...

  • I love playing chess and play video games
  • I'm a big fan of Witcher universe
  • I can speak three languages: English, Russian, and Azerbaijani

šŸ“„ Some of my code snippets ...

// Resolution.ts

import { ResolutionError, ResolutionErrorCode } from './errors/resolutionError';
import { NamingServiceName, SourceDefinition, SourceParameters } from './types/publicTypes';
import { constructRecords, isNullAddress } from './utils';
import { EthereumNamingService } from './namingServices/ethereum';
import { Zns } from './namingServices/zns';
import { Ens } from './namingServices/ens';
import { Cns } from './namingServices/cns';
import { Udapi } from './namingServices/udapi';
import { UnclaimedDomainResponse } from './types';

/** @internal */
export type ResolutionServiceMap = {
  [key in NamingServiceName]: EthereumNamingService;
};

/** @internal */
export type ResolutionService = EthereumNamingService | Udapi;

/**
 * Blockchain domain Resolution library - Resolution.
 * Provides a way to resolve a domain name using various naming services
 * @example
 * ```
 * let resolution = new Resolution();
 * let result = await resolution.address('resolver.eth', 'ETH');
 * ```
 */
export default class Resolution {
  readonly blockchain: boolean;
  readonly serviceName: NamingServiceName;
  private readonly services: ResolutionServiceMap;

  /**
   * Creates a naming service instance
   * @param source - main configuration object
   * @param source.blockchain - blockchain configuration object
   * @param source.blockchain.ens - ens configuration object
   * @param source.blockchain.ens.url - blockchain api url
   * @param source.blockchain.ens.registryAddress - address of ens registry contract
   * @param source.blockchain.cns - cns configuration object
   * @param source.blockchain.cns.url - blockchain api url
   * @param source.blockchain.cns.registryAddress - address of cns registry contract
   * @param source.api - resolution api configuration object
   * @param source.api.url - resolution api url
   */
  constructor({
    blockchain = true,
    api = DefaultAPI,
    ...blockchainSource
  }: {
    blockchain?: boolean | SourceDefinition;
    api?: SourceDefinition;
  }) {
    this.blockchain = !!blockchain;
    this.serviceName = this.getServiceName();
    if (this.serviceName !== 'UDAPI') {
      const web3Provider = this.web3Provider(blockchainSource);
      this.services = {
        [NamingServiceName.CNS]: new Cns(web3Provider),
        [NamingServiceName.ENS]: new Ens(web3Provider),
        [NamingServiceName.ZNS]: new Zns(),
      };
    }
    if (!this.blockchain) {
      this.services = {
        [NamingServiceName.UDAPI]: new Udapi(api),
      };
    }
  }

  /**
   * Resolves domain name to a specific cryptoAddress
   * @async
   *
   * @param domain - domain name to be resolved
   * @param currencyTicker - currency ticker like BTC, ETH, ZIL, etc.
   * @returns A promise that resolves in a string
   */
  async address(domain: string, currencyTicker: string): Promise<string> {
    const data = await this.addressOrThrow(domain, currencyTicker);
    return data.address;
  }

  /**
   * Resolves domain name to a specific cryptoAddress or throws an error if not found or not supported by network.
   *
   * @async
   *
   * @param domain - domain name to be resolved
   * @param currencyTicker - currency ticker like BTC, ETH, ZIL, etc.
   */
  async addressOrThrow(domain: string, currencyTicker: string): Promise<{ address: string; coin: number }> {
    const method = this.isSupportedDomain(domain) ? 'addr' : 'address';
    const data = await this.resolver(domain)[method](domain, currencyTicker);
    if (!data)
      throw new ResolutionError(ResolutionErrorCode.UnspecifiedCurrency, {
        domain,
        currencyTicker,
      });
    return data;
  }
// Custom fetch Provider for UD resolution.ts

import { Provider } from './types';

export class FetchProvider implements Provider {
  private readonly url: string;

  constructor(url: string) {
    this.url = url;
  }

  public async request(request: RequestArguments): Promise<unknown> {
    const response = await fetch(this.url, {
      method: 'POST',
      headers: { 'content-type': 'application/json' },
      body: JSON.stringify(request),
    });

    if (!response.ok) {
      throw new Error(`FetchProvider: ${response.status} ${response.statusText}`);
    }

    return response.json();
  }
}

JohnnyJumper's Projects

cyborgbot icon cyborgbot

CyborgBoy for CyberSportsMen discord channel

ft_ls icon ft_ls

my implementation of ls command

jobmanager icon jobmanager

small visual tool for monitoring and analyzing job process

libft icon libft

My implementation of standard C library for school 42

moonlet icon moonlet

Moonlet is a blockchain agnostic cryptocurrency wallet.

recruter.ai icon recruter.ai

goofy project to utilize llm and apply for the jobs instead of my lazy bum

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.