Git Product home page Git Product logo

api's People

Contributors

ashleyvega avatar bufdev avatar cdm avatar connorchristie avatar dependabot[bot] avatar edd avatar emilbayes avatar fkondej avatar gordsport avatar jeremyletang avatar mattrussell36 avatar renovate-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

api's Issues

JS/TS: Implement walletclient

At the moment, we have;

  • in the Console: src/contexts/wallet/ ts and tsx files
  • in this repo:
    • python walletclient: https://github.com/vegaprotocol/api/blob/develop/grpc/clients/python/vegaapiclient/walletclient.py
    • (in tests) javascript clunky wallet_server_login function
      function wallet_server_login(walletServerURL, walletName, walletPassphrase) {
      var request = new xhr.XMLHttpRequest();
      var token;
      request.onload = function () {
      if (request.status !== 200) {
      throw "Failed to log in to wallet server: HTTP " + request.status + " " + request.responseText;
      }
      var j = JSON.parse(request.responseText);
      if (j === undefined) {
      throw "Failed to get parse response JSON: " + request.responseText;
      }
      token = j.token;
      if (token === undefined) {
      throw "Failed to get token from response body: " + request.responseText;
      }
      }
      request.open("POST", walletServerURL + "/api/v1/auth/token", true);
      request.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
      request.send(JSON.stringify({wallet: walletName, passphrase: walletPassphrase}, null, 2));
      return token;
      }

Task

Implement walletclient in Javascript/Typescript so it can be used by tests in this repo, as well as by other users of the api package (perhaps possibly the Console).

Add oracles

Oracle proto files have been added to Core. Copy them into this repo and update auto-generated files.

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Add new github action to verify all PRs have linked issues

In order to visualise all the work we have in progress on the project board and ensure that all work in PRs has an associated issue that can be seen, read and understood, we will add an action to validate that all PRs are linked to an issue.

This will help to ensure that we are focusing on the right work for the time and that each work item can be tested as required against acceptance criteria captured in the issue.

Known limitations of this action:

  • There must be a space after the issue number (ie "#num " not "#num".) This is due to the way the RegEx is structured and will be resolved in a future release.
  • The Issue reference by # needs to be in the body, we don't currently look in the title. That is a future enhancement.

JS: Packaging help

Our current packaging up of the JS is poor in a number of ways. First and foremost: the main script.

api/js/package.json

Lines 5 to 10 in d9e0eda

"main": "bundle/index.js",
"types": "./index.d.ts",
"scripts": {
"build": "npm run lint && npm run build:ts && npm run build:browser",
"build:ts": "tsc",
"build:browser": "browserify -p tinyify index.js > bundle/index.js",

main is set to bundle.index.js for a reason I'll go in to later. However trying to import the browserified bundle in vegaprotocol/console doesn't work. Because it's browserified, which isn't what we need over there.

Our current problem

We're trying to remove our usage of the prepareX endpoints. Previously we had no way of making protos for the wallet server to sign, but this api repo gives us that, so we're doing a spike to try it out

yarn add @vegaprotocol/vega-grpc

Works fine, and

import { vega } from '@vegaprotocol/vega-grpc'
// ...
const order = new vega.OrderSubmission()
order.setPartyId('1234')

In that example above, Intellij / VSCode / etc will correctly show the types and autocomplete. However when we get to actually running it in the browser, it won't bundle (will paste the error in a second)

Importing from '@vegaprotocol/vega-grpc/index' does work though?

Easy! Just remove that main declaration

Yes. This will fix it. The reason that Browserify bundle is there at all is when it comes to signing code using Tweetnacl to sign stuff, we turned out to need Buffer from node. Which leads to other issues (e.g. dchest/tweetnacl-js#59). However we're not using this functionality at the moment - so removing the main declaration is probably the way to go

Related

Also the weird mix of Typescript & JS is a little odd. We should fix that - but that's a separate issue.

Error with the proto validators import on the Python client v0.30.0

Upgraded to the latest grpc client lib and now getting:

Traceback (most recent call last):
  File "/Users/chrismoores/Projects/Vega/sample-api-scripts/submit-amend-pegged-order/submit-amend-pegged-order-with-Vega-API-client.py", line 55, in <module>
    import vegaapiclient as vac
  File "/Users/chrismoores/Projects/Vega/sample-api-scripts/venv/lib/python3.7/site-packages/vegaapiclient/__init__.py", line 3, in <module>
    from .vegatradingclient import VegaTradingClient
  File "/Users/chrismoores/Projects/Vega/sample-api-scripts/venv/lib/python3.7/site-packages/vegaapiclient/vegatradingclient.py", line 7, in <module>
    from .generated import vega_pb2 as vega
  File "/Users/chrismoores/Projects/Vega/sample-api-scripts/venv/lib/python3.7/site-packages/vegaapiclient/generated/vega_pb2.py", line 15, in <module>
    from .github.com.mwitkow.go_proto_validators import validator_pb2 as github_dot_com_dot_mwitkow_dot_go__proto__validators_dot_validator__pb2
ModuleNotFoundError: No module named 'vegaapiclient.generated.github'

Is this a common problem, or unique to my set up?
Last line says my package is missing generated.github

Add a valid proposal for use in the Console. Maybe?

With the arrival of txv2, and the removal of the prepare endpoints on the Core APIs / datanode APIs, https://github.com/vegaprotocol/api/blob/develop/graphql/examples/json/proposal-newmarket.json is no longer a useful resource to point people to if they are looking for a template proposal to use in the Propose window on Console. It's possible it's still useful for other purposes, but for at least that specific case, it's not. There is an alternative example committed in the (currently private) Console repo (https://github.com/vegaprotocol/console/blob/develop/src/routes/trading/windows/propose/test-json.json), which I'll paste here for the sake of people without access.

What's changed

  • Some fields have been removed (partyID for instance)
  • Some fields have changed name and format (enactmentDatetime is now enactmentTimestamp)
  • Some fields have moved (liquidityCommitment)

Currently the errors returned are not useful to anyone without time on their hands and a willingness to dig in the codebase. Issues are filed for the unclear errors that I hit, in their appropriate repositories.

Tasks

@ashleyvega to populate - I'm putting this here for reference

New valid-for-the-console-Proposal

Note that the dates used here are likely to be invalid when you come to use this.

{
  "terms": {
    "closingTimestamp": 1625586371,
    "enactmentTimestamp": 1625586430,
    "newMarket": {
      "changes": {
        "instrument": {
          "name": "fUSDC Test Market",
          "code": "test market code",
          "future": {
            "maturity": "2022-10-01T00:00:00.000Z",
            "quoteName": "test market quotename",
            "settlementAsset": "fUSDC",
            "oracleSpec": {
              "pubKeys": ["0x0"],
              "filters": [
                {
                  "key": {
                    "name": "price.ETH.value",
                    "type": "TYPE_INTEGER"
                  },
                  "conditions": [
                    {
                      "operator": "OPERATOR_EQUALS",
                      "value": "100"
                    }
                  ]
                }
              ]
            },
            "oracleSpecBinding": {
              "settlementPriceProperty": "price.ETH.value"
            }
          }
        },
        "decimalPlaces": 1,
        "logNormal": {
          "riskAversionParameter": 0.0001,
          "tau": 1.90129e-5,
          "params": {
            "mu": 0,
            "r": 0.016,
            "sigma": 1.5
          }
        },
        "metadata": ["tag-1"],
        "priceMonitoringParameters": {
          "triggers": [
            {
              "horizon": 43200,
              "probability": 0.9999999,
              "auctionExtension": 600
            }
          ]
        },
        "continuous": {
          "tickSize": "0.00001"
        }
      },
      "liquidityCommitment": {
        "commitmentAmount": 1,
        "fee": "0.01",
        "sells": [
          {
            "reference": "PEGGED_REFERENCE_MID",
            "proportion": 10,
            "offset": 2000
          },
          {
            "reference": "PEGGED_REFERENCE_MID",
            "proportion": 10,
            "offset": 1000
          }
        ],
        "buys": [
          {
            "reference": "PEGGED_REFERENCE_MID",
            "proportion": 10,
            "offset": -1000
          },
          {
            "reference": "PEGGED_REFERENCE_MID",
            "proportion": 10,
            "offset": -2000
          }
        ]
      }
    }
  }
}

Add GraphQL schema

The current API clients are all generated from the protos. We also have a GraphQL schema file in core that would be useful to have access to for developers interested in that API. Let's add it here.

Tasks

  • Add a new folder, /graphql/
  • Clone schema in to /graphql/
  • Auto-generate docs from the schema file using graphqldoc (graphqldoc -s path/to/schema.graphql -o graphql_output_dir/)

Nothing more needs to be done at the moment.

@cdm has pointed out that the GraphQL schema isn't really a client, which is true. Currently there is no plan to build GraphQL based clients in any language, but as Vega Console uses GraphQL it's possible that that functionality could be split out, in which case it would be added here. Feel free to leave a comment if that would be useful.

Update Core API auto-generated documentation

With the addition of the datanode we now require that the functionallity is added/enabled in order to create the auto-generated documentation for Core’s APIs:

  • rest
  • grpc

This is in order to be able to give us and the community a guide as to the API specification

Questions to cover might be:

  • Which repo should core-grpc-doc.json and datanode-grpc-doc.json see existing go in?
    • protos
    • some-sdk-doc-new-repo
    • other

For reference, swagger.json is in the protos repo and is copied in to the API repo.

Note: This question is relevant whether we are generating with Docusaurs (see vegaprotocol/documentation) or The Old System vegaprotocol/docs)

Remove the txn package

With the move to the transaction v2 format the package api/grpc/clients/go/txn have become obsolete.
We should remove it from the codebase from the next release or so.

Dependency Dashboard

This issue provides visibility into Renovate updates and their statuses. Learn more

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.


  • Check this box to trigger a request for Renovate to run again on this repository

Auto-generate documentation from proto files

Now that this repo is public, auto-generate documentation from proto files in HTML and Markdown formats.

Use a buf config such as:

---
version: v1beta1
plugins:
  - name: doc
    out: proto/doc
    opt: html,index.html
    strategy: all
  - name: doc
    out: proto/doc
    opt: markdown,index.md
    strategy: all

Try out `graphql-code-generator`

https://www.graphql-code-generator.com/ can generate client libraries from a Graphql schema. in https://github.com/vegaprotocol/console we use Apollo Codegen (https://www.npmjs.com/package/apollo#code-generation) but Graphql Code Generator looks like it gives us some more flexibility (specifically react hooks without a client library, or an urql client)

Spike

  • Create a branch using graphql-code-generator to create a react-apollo-hooks typescript library from the schema

If that looks reasonable, we can expand with other clients as required (urql would be a smart choice, but also react-query-hooks for the no-apollo-but-still-react crowd)

Go API do not build

When trying to import the go package into a go application, the build fail with the following error:

# github.com/vegaprotocol/api-clients/go/generated/code.vegaprotocol.io/vega/proto
../../../pkg/mod/github.com/vegaprotocol/[email protected]/go/generated/code.vegaprotocol.io/vega/proto/vega.validator.pb.go:219:11: this.Size_ undefined (type *OrderSubmission has no field or method Size_)
../../../pkg/mod/github.com/vegaprotocol/[email protected]/go/generated/code.vegaprotocol.io/vega/proto/vega.validator.pb.go:220:123: this.Size_ undefined (type *OrderSubmission has no field or method Size_)

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.