Code Monkey home page Code Monkey logo

dappbot-types's Introduction

dappbot-types

Typescript bindings describing the core data types and API interactions with DappBot. Extracted into their own repository in order to :

  • Guarantee consistency across multiple client and server projects
  • Make the overall DappBot codebase DRYer
  • Share these types with our API customers

There is full generated documentation from the source code hosted at eximchain.github.io/dappbot-types. Briefly, the types are grouped into nested namespaces in order to minimize both collisions and stuttering. They are nested like:

  • DappBotTypes: Overall namespace, package's default export
    • Dapp: Interfaces, type guards, and factories related to the DappItem data type
    • User: Interfaces, type guards, and factories related to the User & auth data types
    • Responses: Interfaces and helper functions for our API responses
    • Methods: Each sub-module within here (Auth, Payment, Private, Public) contains all types related to that resource's available methods. Each method contains keys Args, Result, Response, HTTP, & Path. The Result corresponds to the res.data in a successful call, Response just wraps that shape in data/err.

As a consumer, you can import either import the full namespace from the top or instead use the import string to grab one of the more nested ones. All of the individual namespaces & types are declared within the spec folder, which you can directly refer to in your import. By example, below are two ways of getting at the same type:

// Grab the overall types object and drill down through
// the namespaces to get the interface we want
import Types from 'dappbot-types';
const argsFromType:Types.Methods.Auth.Login.Args = {
  username : 'wuddup',
  password : 'we here',
  yis : 'this prop is not legal and gets an error'
}

// Now we're going through the file structure to more
// directly grab the namespace with the types we're
// concerned about in this hypothetical file.
import { Login } from 'dappbot-types/spec/methods/auth';
const argsFromAuth:Login.Args = {
  username : "this object will have err because it's missing a property"
}

dappbot-types's People

Contributors

eximchain137 avatar john-osullivan avatar lsquared13 avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

lsquared13

dappbot-types's Issues

[Dappbot Free Tier] - Update Stripe plans to reflect new signup on free tier - Types

The stripe plans are inferred from dappbot types package where the change should happen:

export interface StripePlans {

The arguments are also used in the following places, once the change is made test and make sure nothing is broken.

The DappBotAPI Repo uses stripe plans to create trials in two places:
https://github.com/Eximchain/payment-gateway-stripe-lambda/blob/b78278fa89a5c8428f08b1b27de5b67a84187b4a/src/api.ts#L38

https://github.com/Eximchain/payment-gateway-stripe-lambda/blob/master/src/services/stripe.ts#L26

Add types describing our supported blockchains

The blockchain constants are a key set of values which need to exist in the dapphub-spa, the management-spa, and the cli. The important shared property is the Web3URL, but we also need to have that info connected to stuff like the chainId and the hash of the chain's genesis block. You need that info when you create a dapp, then you need it again when it's loaded up. Classic set of data points to put in here.

Upgrade Chains.Details to support multiple Web3URLs per network

Right now the Web3URL is the only way the Dapp knows which chain it's on -- we have a mapping here in the types package. Eventually we will want to be able to add new URLs for the Eximchain network, so this issue is here to remind us of that. Note that because the Web3URL is the "key" telling us the correct network, removing one of the existing URLs would require a manual DB migration.

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.