All projects info of TRON Hackathon Season 3

I’m glad to introduce TsTron - TypeScript SDK for Tron developers. It’s a shame that currently there is official Javascript SDK available, which contains a number of serious bugs (including completely non-working code - the link points to undefined symbol that raises on run time), but there is no its upgraded version in TypeScript. Many developers have a strong preference to typed alternative, and it’s understandable: despite lots of ugly syntax and bad (technically incorrect) design decisions, TypeScript presents a smart enough compiler that can be helpful in many cases. I’m not with them, but I’m sure that everybody should use convenient instruments and not be restricted to the only existing option.

TsTron was developed as a fork of TronWeb Javascript Tron SDK, converted to add type information. I decided not to go *.d.ts -way, because the original library is not actively maintained, and there is enough to improve in implementation. As of writing this, the capabilities of TsTron are exactly the same as capabilities of TronWeb, and the overall interface remains very close to the old one. In short, it provides developers with a wrapper around all APIs, allowing to build, submit and retrieve a transaction for any goal, be it smart contract call, plain funds transfer or delegation adjustment, without having to dig into API structure and formats. It also exposes a set of handy utilities to convert/encode/decode data formats, manipulate addresses and manage accounts, etc. To ensure type correctness, all types for endpoints responses and other data structures are created based on protobuf definitions, which are actually used by API implementations.

I’d say that there was only one extremely difficult challenge: complete absence of HTTP API documentation. Protocol buffers, you say? Nope! I’m using them as templates for later manual editing, because some endpoints’ responses do not match protobuf files. Official documentation? Oh yeah, it says literally “returns: transaction”, go guess what it is supposed to mean (spoiler: no, not a Transaction from protobuf definition). So, this project may serve as (hopefully, almost correct) alternative to the non-existent Tron HTTP API documentation, allowing at least to find out what do the endpoints expect and return with the help of some IDE or by looking at interfaces manually.

You can read more on Devpost submission page and a forum post here. To get some feeling of how SDK may be used, you can check my github repo or do npm install @sterliakov/tstron and start building!

Please file an issue on github, if something goes wrong - the project is still alpha and may contain incorrect or not specific enough typing information. My brand-new documentation is under development, please refer to tronweb docs and Sun Network sidechain docs during this transition period.

My main obsession with this project was CI/CD implementation. I have set up github actions to test, build and publish the package, but there is enough to do more. I added some tests to the original suite, but the coverage remains low. Another target of the same priority is to add native gRPC support for those who write server-side code in TypeScript for Node.js - gRPC is more efficient compared to plain old JSON web-interfaces.

4 Likes