vegaprotocol / api Goto Github PK
View Code? Open in Web Editor NEWAuto-generated API clients
License: MIT License
Auto-generated API clients
License: MIT License
At the moment, we have;
src/contexts/wallet/
ts and tsx fileswalletclient
: https://github.com/vegaprotocol/api/blob/develop/grpc/clients/python/vegaapiclient/walletclient.pywallet_server_login
function api/grpc/clients/js/test/vega/order.test.js
Lines 10 to 30 in 18a356f
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).
Here the proto api refer to the rest of the proto:
https://github.com/vegaprotocol/api-clients/blob/develop/go/generated/code.vegaprotocol.io/vega/proto/api/trading.pb.go#L7
Although the generated path should most likely be something like this:
import "github.com/vegaprotocol/api-clients/go/generated/code.vegaprotocol.io/vega/proto"
The generated Golang code does not work.
See also mwitkow/go-proto-validators#51
Fix it with something like:
find proto -name '*.validator.pb.go' | sort | while read -r pbfile
do
sed -i -re 's/this\.Size_/this.Size/' "$pbfile"
done
Addressing a dependable alert
Oracle proto files have been added to Core. Copy them into this repo and update auto-generated files.
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.
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:
Our current packaging up of the JS is poor in a number of ways. First and foremost: the main
script.
Lines 5 to 10 in d9e0eda
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.
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?
main
declarationYes. 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
Also the weird mix of Typescript & JS is a little odd. We should fix that - but that's a separate issue.
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
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.
partyID
for instance)enactmentDatetime
is now enactmentTimestamp
)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.
@ashleyvega to populate - I'm putting this here for reference
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
}
]
}
}
}
}
Slack ref https://vegaprotocol.slack.com/archives/CE5L3T60J/p1609844934342500
The current set of tape tests is minimal. Add one or more tests that:
grpc-web
and/or grpc-node
)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.
/graphql/
/graphql/
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.
is it possible to get TypeScript type definitions generated for the JS client?
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:
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:
core-grpc-doc.json
and datanode-grpc-doc.json
see existing go in?
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)
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.
This issue provides visibility into Renovate updates and their statuses. Learn more
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
@graphql-codegen/typescript
, @graphql-codegen/typescript-apollo-client-helpers
, @graphql-codegen/typescript-react-apollo
, @typescript-eslint/eslint-plugin
, @typescript-eslint/parser
, typescript
)@typescript-eslint/eslint-plugin
, @typescript-eslint/parser
)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
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)
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)
Add the file schema.graphql
from the Core repo. Auto-generate docs from this file using graphqldoc (graphqldoc -s path/to/schema.graphql -o graphql_output_dir/
).
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_)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.