Skip to content

Commit 906dd43

Browse files
authored
Merge pull request #261 from skycoin/develop
Merge to master
2 parents 0887a62 + 7f26932 commit 906dd43

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

explorer.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,23 @@ func buildSkycoinURL(path string, query url.Values) string {
124124
return u.String()
125125
}
126126

127+
type CoinSupply struct {
128+
// Coins distributed beyond the project:
129+
CurrentSupply string `json:"current_supply"`
130+
// TotalSupply is CurrentSupply plus coins held by the distribution addresses that are spendable
131+
TotalSupply string `json:"total_supply"`
132+
// MaxSupply is the maximum number of coins to be distributed ever
133+
MaxSupply string `json:"max_supply"`
134+
// CurrentCoinHourSupply is coins hours in non distribution addresses
135+
CurrentCoinHourSupply string `json:"current_coinhour_supply"`
136+
// TotalCoinHourSupply is coin hours in all addresses including unlocked distribution addresses
137+
TotalCoinHourSupply string `json:"total_coinhour_supply"`
138+
// Distribution addresses which count towards total supply
139+
UnlockedAddresses []string `json:"unlocked_distribution_addresses"`
140+
// Distribution addresses which are locked and do not count towards total supply
141+
LockedAddresses []string `json:"locked_distribution_addresses"`
142+
}
143+
127144
type APIEndpoint struct {
128145
ExplorerPath string `json:"explorer_path"`
129146
SkycoinPath string `json:"skycoin_path"`
@@ -163,6 +180,21 @@ func (s APIEndpoint) ServeHTTP(w http.ResponseWriter, r *http.Request) {
163180
defer resp.Body.Close()
164181

165182
w.WriteHeader(resp.StatusCode)
183+
184+
if s.ExplorerPath == "/api/coinmarketcap" {
185+
w.Header().Set("Content-Type", "text/plain")
186+
var cs CoinSupply
187+
if err := json.NewDecoder(resp.Body).Decode(&cs); err != nil {
188+
msg := "Decode CoinSupply result failed"
189+
log.Println("ERROR:", msg, skycoinURL, err)
190+
http.Error(w, msg, http.StatusInternalServerError)
191+
return
192+
}
193+
194+
fmt.Fprintf(w, "%s", cs.CurrentSupply)
195+
return
196+
}
197+
166198
w.Header().Set("Content-Type", "application/json")
167199

168200
if n, err := io.Copy(w, resp.Body); err != nil {
@@ -205,6 +237,13 @@ var apiEndpoints = []APIEndpoint{
205237
]
206238
}`,
207239
},
240+
{
241+
ExplorerPath: "/api/coinmarketcap",
242+
SkycoinPath: "/coinSupply",
243+
Description: "Returns circulating supply coin number.",
244+
ExampleRequest: "/api/coinmarketcap",
245+
ExampleResponse: "7187500.000000",
246+
},
208247
{
209248
ExplorerPath: "/api/address",
210249
SkycoinPath: "/explorer/address",

src/app/components/layout/footer/footer.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<a href="https://www.skycoin.net/team">Team</a>
1212
<a href="https://www.skycoin.net/blog">Blog</a>
1313
<a href="/" class="active">Explorer</a>
14+
<a href="https://explorer.skycoin.net/api.html">API docs</a>
1415
</div>
1516
</div>
1617
<div class="footer-second-row">

src/app/components/layout/header/header.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<a href="https://www.skycoin.net/team" class="nav-link">Team</a>
1919
<a href="https://www.skycoin.net/blog" class="nav-link">Blog</a>
2020
<a href="/" class="nav-link active">Explorer</a>
21+
<a href="https://explorer.skycoin.net/api.html" class="nav-link">API docs</a>
2122
</div>
2223
<div class="nav-group mobile">
2324
<a href="https://t.me/Skycoin" target="_blank" class="nav-link">

0 commit comments

Comments
 (0)