-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- refactor reading in files - update golang version to latest - fix address decoding - update auth and bank queries - update table display - fixed csv display - updated distribution queries - fixed double entry bug - fixed staking details bug - cleaned up api response processing - fixed some initialization runtime errors - fixed issue with chains that don't have prefix query - cleaned up table display column names - cleaned up chain registry queries - fix injective denom query - log account not found errors, without skipping any other accounts - put in an exception for medibloc prefix query returning the wrong value - update github workflow - tidy up data structures - move api response structs into the api folder - standardize method usage for http query responses - remove zabbix related code
- Loading branch information
Showing
33 changed files
with
1,293 additions
and
5,306 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package api | ||
|
||
import ( | ||
"encoding/json" | ||
"net/http" | ||
) | ||
|
||
type Bech32PrefixResponse struct { | ||
Bech32Prefix string `json:"bech32_prefix"` | ||
} | ||
|
||
type AcctResponse struct { | ||
Account struct { | ||
Type string `json:"@type"` | ||
BaseVestingAccount struct { | ||
BaseAccount struct { | ||
Address string `json:"address,omitempty"` | ||
PubKey string `json:"public_key,omitempty"` | ||
AccountNumber string `json:"account_number,omitempty"` | ||
Sequence string `json:"sequence,omitempty"` | ||
} | ||
OriginalVesting []struct { | ||
Denom string `json:"denom"` | ||
Amount string `json:"amount"` | ||
} `json:"original_vesting"` | ||
DelegatedFree []struct { | ||
Denom string `json:"denom"` | ||
Amount string `json:"amount"` | ||
} `json:"delegated_free"` | ||
DelegatedVesting []struct { | ||
Denom string `json:"denom"` | ||
Amount string `json:"amount"` | ||
} `json:"delegated_vesting"` | ||
EndTime string `json:"end_time"` | ||
} `json:"base_vesting_account"` | ||
StartTime string `json:"start_time"` | ||
VestingPeriods []struct { | ||
Length string `json:"length"` | ||
Amount []struct { | ||
Denom string `json:"denom"` | ||
Amount string `json:"amount"` | ||
} `json:"amount"` | ||
} `json:"vesting_periods"` | ||
} `json:"account"` | ||
} | ||
|
||
func (a *AcctResponse) GetBalances() map[int]map[string]string { | ||
balances := make(map[int]map[string]string) | ||
balances[OriginalVesting] = make(map[string]string) | ||
balances[DelegatedVesting] = make(map[string]string) | ||
|
||
for _, balance := range a.Account.BaseVestingAccount.OriginalVesting { | ||
balances[OriginalVesting][balance.Denom] = balance.Amount | ||
} | ||
|
||
for _, balance := range a.Account.BaseVestingAccount.DelegatedVesting { | ||
balances[DelegatedVesting][balance.Denom] = balance.Amount | ||
} | ||
return balances | ||
} | ||
|
||
func (p *Bech32PrefixResponse) GetPrefix(endpointURL string, client *http.Client) error { | ||
var body []byte | ||
|
||
url := endpointURL + "/cosmos/auth/v1beta1/bech32" | ||
body, err := HttpGet(url, client) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = json.Unmarshal(body, p) | ||
if err != nil { | ||
return err | ||
} | ||
return err | ||
} | ||
|
||
func (a *AcctResponse) QueryAuth(address string, endpoint string, client *http.Client) error { | ||
var body []byte | ||
|
||
url := endpoint + "/cosmos/auth/v1beta1/accounts/" + address | ||
body, err := HttpGet(url, client) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = json.Unmarshal(body, a) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package api | ||
|
||
import ( | ||
"encoding/json" | ||
"net/http" | ||
"strings" | ||
) | ||
|
||
type AssetList struct { | ||
Assets []struct { | ||
Description string `json:"description"` | ||
DenomUnits []struct { | ||
Denom string `json:"denom"` | ||
Exponent int `json:"exponent"` | ||
} `json:"denom_units"` | ||
Base string `json:"base"` | ||
Name string `json:"name"` | ||
Display string `json:"display"` | ||
Symbol string `json:"symbol"` | ||
} `json:"assets"` | ||
} | ||
|
||
type ChainData struct { | ||
Bech32Prefix string `json:"bech32_prefix"` | ||
} | ||
|
||
// SearchForAsset search for the symbol for a particular denom in the assets list | ||
func (a *AssetList) SearchForAsset(denom string) (string, int) { | ||
for i := range a.Assets { | ||
if a.Assets[i].Base == denom { | ||
for j := range a.Assets[i].DenomUnits { | ||
if strings.ToUpper(a.Assets[i].DenomUnits[j].Denom) == strings.ToUpper(a.Assets[i].Display) { | ||
// Some chains (*cough* Injective *cough*) have decided to differentiate between denom units | ||
// using letter casing... | ||
if a.Assets[i].DenomUnits[j].Exponent != 0 { | ||
return a.Assets[i].Symbol, a.Assets[i].DenomUnits[j].Exponent | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return denom, 0 | ||
} | ||
|
||
func (a *AssetList) QueryAssetList(chain string, client *http.Client) error { | ||
var body []byte | ||
|
||
url := "https://chains.cosmos.directory/" + chain + "/assetlist" | ||
body, err := HttpGet(url, client) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = json.Unmarshal(body, a) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func (c *ChainData) QueryChainData(chain string, client *http.Client) error { | ||
var body []byte | ||
|
||
url := "https://chains.cosmos.directory/" + chain + "/chain" | ||
body, err := HttpGet(url, client) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = json.Unmarshal(body, c) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.