GithubHelp home page GithubHelp logo

challenge-cryptocoins's Introduction

Challenge Cryptocoins

Elixir CI

To start the server:

  • Install dependencies with mix deps.get
  • Create and migrate your database with mix ecto.setup
  • Start Phoenix endpoint with mix phx.server

GraphQL API on: localhost:4000/api

Assumptions

  • Only loged users can make operations (get, list, invest, refund) on Funds (only on in their name)
  • Only admin users can create and update the Funds
  • A Fund is created with a amount of tokens, these tokens will have a owner and can be registred on a historic of transactions to see the user profit later
  • Funds cannot have the same name
  • If the exchanger dont have owned tokens on a Fund, then the user cannot invest in this Fund, dont subtracting nothing from the user (the default is that all tokens when created is owned by the exchanger)
  • If the user dont have owned tokens on a Fund, then the user cannot refund in this Fund, dont adding nothing to the user
  • A new admin cannot be created from the API (use the login(email: "[email protected]", password: "admin") from the seeds)

Notes

  • Dont load the seeds.exs on the test ENV, this will broke the tests
  • A web doc can be generated with mix docs
  • Code using rules from mix credo and mix dialyzer

Examples

Login

Login as admin:

mutation {
  login(email: "[email protected]", password: "admin") {
    token
  } 
}

Login as normal client

mutation {
  login(email: "[email protected]", password: "test") {
    token
  } 
}

Insert the token on the HTTP Header Authorization Ex: Authorization Bearer SFMyNTY.g2gDdAAAAAFkAAJpZG0AAAAkZTA4YzQzY2UtOWEzZC00NWUzLWE3NDEtYjNhNGIyNzQxYmJibgYA-qa7oHIBYgABUYA.lDLsr-jWc2BftBNGnB-BTazsR15tqqwGOvEi_Fex40g

Fund

List:

{
  me {
    listFunds {
      description
      name
      value
    }
  } 
}

Get:

{
  me {
    getFund(name: "fund 1") {
      description
      name
      value
    }
  } 
}

Create (only as admin):

mutation {
  me {
    createFund(name: "fund 4", value: 20, tokenAmount: 5) {
      description
      name
      value
    }
  }
}

Update (only as admin):

mutation {
  me {
    updateFund(fundName: "fund 1", value: 30) {
      description
      name
      value
    } 
  }
}

Invest:

mutation {
  me {
    invest(fundName: "fund 1", tokenAmount: 1) 
  }
}

Refund:

mutation {
  me {
    refund(fundName: "fund 1", tokenAmount: 1) 
  }
}

Get profit:

{
  me {
    getUserProfit
  }
}

challenge-cryptocoins's People

Contributors

shiryel avatar

Watchers

 avatar  avatar

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.