Skip to content

Commit

Permalink
update sep-001 implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-rogobete committed Sep 20, 2022
1 parent 61f4861 commit 075d61d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
17 changes: 15 additions & 2 deletions lib/src/sep/0001/stellar_toml.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:toml/toml.dart';

/// Parses the stellar toml data from a given string or from a given domain.
/// See <a href="https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0001.md" target="_blank">Stellar Toml</a>
/// Supported Version: 2.5.0
class StellarToml {
GeneralInformation? generalInformation;
Documentation? documentation;
Expand Down Expand Up @@ -40,6 +41,8 @@ class StellarToml {
});
}
generalInformation!.uriRequestSigningKey = document['URI_REQUEST_SIGNING_KEY'];
generalInformation!.directPaymentServer = document['DIRECT_PAYMENT_SERVER'];
generalInformation!.anchorQuoteServer = document['ANCHOR_QUOTE_SERVER'];

if (document['DOCUMENTATION'] != null) {
documentation = Documentation();
Expand All @@ -58,6 +61,7 @@ class StellarToml {
documentation!.orgTwitter = document['DOCUMENTATION']['ORG_TWITTER'];
documentation!.orgGithub = document['DOCUMENTATION']['ORG_GITHUB'];
documentation!.orgOfficialEmail = document['DOCUMENTATION']['ORG_OFFICIAL_EMAIL'];
documentation!.orgSupportEmail = document['DOCUMENTATION']['ORG_SUPPORT_EMAIL'];
documentation!.orgLicensingAuthority = document['DOCUMENTATION']['ORG_LICENSING_AUTHORITY'];
documentation!.orgLicenseType = document['DOCUMENTATION']['ORG_LICENSE_TYPE'];
documentation!.orgLicenseNumber = document['DOCUMENTATION']['ORG_LICENSE_NUMBER'];
Expand Down Expand Up @@ -207,7 +211,7 @@ class GeneralInformation {
/// The endpoint used for SEP-10 Web Authentication.
String? webAuthEndpoint;

/// The signing key is used for SEP-3 Compliance Protocol and SEP-10 Authentication Protocol.
/// The signing key is used for SEP-3 Compliance Protocol (deprecated) and SEP-10 Authentication Protocol.
String? signingKey;

/// Location of public-facing Horizon instance (if one is offered).
Expand All @@ -218,6 +222,12 @@ class GeneralInformation {

/// The signing key is used for SEP-7 delegated signing.
String? uriRequestSigningKey;

/// The server used for receiving SEP-31 direct fiat-to-fiat payments. Requires SEP-12 and hence a KYC_SERVER TOML attribute.
String? directPaymentServer;

/// The server used for receiving SEP-38 requests.
String? anchorQuoteServer;
}

/// Organization Documentation. From the stellar.toml DOCUMENTATION table.
Expand Down Expand Up @@ -262,6 +272,9 @@ class Documentation {
/// An email where clients can contact the organization. Must be hosted at the orgUrl domain.
String? orgOfficialEmail;

/// An email that users can use to request support regarding the organizations Stellar assets or applications.
String? orgSupportEmail;

/// Name of the authority or agency that licensed the organization, if applicable.
String? orgLicensingAuthority;

Expand Down Expand Up @@ -342,7 +355,7 @@ class Currency {
/// true if token can be redeemed for underlying asset, otherwise false.
bool? isAssetAnchored;

/// Type of asset anchored. Can be fiat, crypto, stock, bond, commodity, realestate, or other.
/// Type of asset anchored. Can be fiat, crypto, nft, stock, bond, commodity, realestate, or other.
String? anchorAssetType;

/// If anchored token, code / symbol for asset that token is anchored to. E.g. USD, BTC, SBUX, Address of real-estate investment property.
Expand Down
10 changes: 8 additions & 2 deletions test/sep0001_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ void main() {
"GAENZLGHJGJRCMX5VCHOLHQXU3EMCU5XWDNU4BGGJFNLI2EL354IVBK7",
"GAOO3LWBC4XF6VWRP5ESJ6IBHAISVJMSBTALHOQM2EZG7Q477UWA6L7U"
]
DIRECT_PAYMENT_SERVER="https://test.direct-payment.com"
ANCHOR_QUOTE_SERVER="https://test.anchor-quote.com"
[DOCUMENTATION]
ORG_NAME="Organization Name"
Expand All @@ -34,7 +36,8 @@ void main() {
ORG_KEYBASE="accountname"
ORG_TWITTER="orgtweet"
ORG_GITHUB="orgcode"
ORG_OFFICIAL_EMAIL="[email protected]"
ORG_OFFICIAL_EMAIL="[email protected]"
ORG_SUPPORT_EMAIL="[email protected]"
[[PRINCIPALS]]
name="Jane Jedidiah Johnson"
Expand Down Expand Up @@ -130,6 +133,8 @@ void main() {
assert(generalInformation.accounts
.contains("GAOO3LWBC4XF6VWRP5ESJ6IBHAISVJMSBTALHOQM2EZG7Q477UWA6L7U"));
assert(generalInformation.uriRequestSigningKey == null);
assert(generalInformation.directPaymentServer == "https://test.direct-payment.com");
assert(generalInformation.anchorQuoteServer == "https://test.anchor-quote.com");

Documentation documentation = stellarToml.documentation!;
assert(documentation.orgName == "Organization Name");
Expand All @@ -147,7 +152,8 @@ void main() {
assert(documentation.orgKeybase == "accountname");
assert(documentation.orgTwitter == "orgtweet");
assert(documentation.orgGithub == "orgcode");
assert(documentation.orgOfficialEmail == "[email protected]");
assert(documentation.orgOfficialEmail == "[email protected]");
assert(documentation.orgSupportEmail == "[email protected]");
assert(documentation.orgLicensingAuthority == null);
assert(documentation.orgLicenseType == null);
assert(documentation.orgLicenseNumber == null);
Expand Down

0 comments on commit 075d61d

Please sign in to comment.