Joystream / status-endpoint-joystream

Status endpoint for the Joystream network
GNU General Public License v3.0
1 stars 4 forks source link

Circulating supply #35

Closed DzhideX closed 1 year ago

DzhideX commented 1 year ago

This PR implements the circulating supply to be used all over the ecosystem (CMC, Pioneer, etc.).

Done with the help of @bwhm.

bedeho commented 1 year ago

For review purposes, this is what CMC states

Connect API Endpoint

    In simple text format ONLY
    e.g:http://chainz.cryptoid.info/grs/api.dws?q=totalcoins
    No commas, no extraneous characters - Just the numerical value

Not sure what Coingecko expects.

mnaamani commented 1 year ago

I tested my suggested changes, and I'm getting this result:

Screenshot 2023-07-10 at 1 01 24 AM

Supply 425522429

mnaamani commented 1 year ago

Confirmed, it is plain text response from example provided

curl https://chainz.cryptoid.info/grs/api.dws?q=totalcoins --verbose
*   Trying 104.26.10.171:443...
* Connected to chainz.cryptoid.info (104.26.10.171) port 443 (#0)
* ALPN: offers h2,http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN: server accepted h2
* Server certificate:
*  subject: C=US; ST=California; L=San Francisco; O=Cloudflare, Inc.; CN=sni.cloudflaressl.com
*  start date: Apr 16 00:00:00 2023 GMT
*  expire date: Apr 15 23:59:59 2024 GMT
*  subjectAltName: host "chainz.cryptoid.info" matched cert's "*.cryptoid.info"
*  issuer: C=US; O=Cloudflare, Inc.; CN=Cloudflare Inc ECC CA-3
*  SSL certificate verify ok.
* using HTTP/2
* h2 [:method: GET]
* h2 [:scheme: https]
* h2 [:authority: chainz.cryptoid.info]
* h2 [:path: /grs/api.dws?q=totalcoins]
* h2 [user-agent: curl/8.1.2]
* h2 [accept: */*]
* Using Stream ID: 1 (easy handle 0x14f80dc00)
> GET /grs/api.dws?q=totalcoins HTTP/2
> Host: chainz.cryptoid.info
> User-Agent: curl/8.1.2
> Accept: */*
> 
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* old SSL session ID is stale, removing
< HTTP/2 200 
< date: Sun, 09 Jul 2023 22:06:49 GMT
< content-type: text/plain
< content-length: 17
< cache-control: public,s-maxage=5,max-age=5
< etag: W/"c77f0f4c5a73"
< access-control-allow-origin: *
< cf-cache-status: DYNAMIC
< report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=Uq1YuUu4Au4KCKWC5U1nfhCkSRYQVvpxIivcLP7KJj1dof%2FiaaBOEIm%2F3l3OFt3KNn53P%2B42n7%2B2Er9siCoXfxPv%2FsQ8cauadV2hrtQr0Qox8LUB9WsFkxn2LyputyI1zpdqmQat"}],"group":"cf-nel","max_age":604800}
< nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
< server: cloudflare
< cf-ray: 7e43e0583b5311ae-MRS
< 
* Connection #0 to host chainz.cryptoid.info left intact
82932258.88736623
mnaamani commented 1 year ago

For review purposes, this is what CMC states

Connect API Endpoint

    In simple text format ONLY
    e.g:http://chainz.cryptoid.info/grs/api.dws?q=totalcoins
    No commas, no extraneous characters - Just the numerical value

Not sure what Coingecko expects.

If we need different formats we can easily add a different endpoint for it.

Perhaps /circulating-supply/cmc and /circulating-supply/coingecko

DzhideX commented 1 year ago

Thank you for the review @mnaamani. I agree with all of your suggestions and have therefore aimed to implement them. Let me know if there are any other changes necessary!

mnaamani commented 1 year ago

Just an afterthought, perhaps sending back status 500 is too general, 503 might be a better fit with a Retry-After response header.