currencyFromUrl method
- String toml
Alternately to specifying a currency in its content, stellar.toml can link out to a separate TOML file for the currency by specifying toml="https://DOMAIN/.well-known/CURRENCY.toml" as the currency's only field. In this case you can use this method to load the currency data from the received link (Currency.toml).
Implementation
static Future<Currency> currencyFromUrl(String toml) async {
Uri uri = Uri.parse(toml);
return await http.Client()
.get(uri, headers: RequestBuilder.headers)
.then((response) {
if (response.statusCode != 200) {
throw Exception(
"Currency toml not found, response status code ${response.statusCode}");
}
var parser = new TomlParser();
var document = parser.parse(response.body).value;
return _currencyFromItem(document);
});
}