Skip to content

Commit

Permalink
add sep-0001 support
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-rogobete committed Jan 11, 2022
1 parent 24484cc commit 2408eb5
Show file tree
Hide file tree
Showing 14 changed files with 1,254 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ if ($response->isSuccessful()) {
| [Fee bump transaction](examples/fee_bump.md) | Fee bump transactions allow an arbitrary account to pay the fee for a transaction.| [Fee bump transactions](https://github.com/stellar/stellar-protocol/blob/master/core/cap-0015.md)|
| [Muxed accounts](examples/muxed_account_payment.md) | In this example we will see how to use a muxed account in a payment operation.| [First-class multiplexed accounts](https://github.com/stellar/stellar-protocol/blob/master/core/cap-0027.md)|
| [Stream payments](examples/stream_payments.md) | Listens for payments received by a given account.| [Streaming](https://developers.stellar.org/api/introduction/streaming/) |
| [SEP-0001: stellar.toml](examples/sep-0001-toml.md) | In this example you can find out how to obtain data about an organization’s Stellar integration.| [SEP-0001](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0001.md)|
| [SEP-0005: Key derivation](examples/sep-0005-key-derivation.md) | In this examples you can see how to generate 12 or 24 words mnemonics for different languages using the PHP SDK, how to generate key pairs from a mnemonic (with and without BIP 39 passphrase) and how to generate key pairs from a BIP 39 seed. | [SEP-0005](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0005.md)|

More examples can be found in the [tests](https://github.com/Soneso/stellar-php-sdk/tree/main/Soneso/StellarSDKTests).
39 changes: 39 additions & 0 deletions Soneso/StellarSDK/SEP/Toml/Currencies.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php declare(strict_types=1);

// Copyright 2021 The Stellar PHP SDK Authors. All rights reserved.
// Use of this source code is governed by a license that can be
// found in the LICENSE file.

namespace Soneso\StellarSDK\SEP\Toml;

class Currencies extends \IteratorIterator
{

public function __construct(Currency ...$currencies)
{
parent::__construct(new \ArrayIterator($currencies));
}

public function current(): Currency
{
return parent::current();
}

public function add(Currency $currency)
{
$this->getInnerIterator()->append($currency);
}

public function count(): int
{
return $this->getInnerIterator()->count();
}

public function toArray() : array {
$result = array();
foreach($this as $value) {
array_push($result, $value);
}
return $result;
}
}
83 changes: 83 additions & 0 deletions Soneso/StellarSDK/SEP/Toml/Currency.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php declare(strict_types=1);

// Copyright 2021 The Stellar PHP SDK Authors. All rights reserved.
// Use of this source code is governed by a license that can be
// found in the LICENSE file.

namespace Soneso\StellarSDK\SEP\Toml;

/// Currency Documentation. From the stellar.toml [[CURRENCIES]] list, one set of fields for each currency supported. Applicable fields should be completed and any that don't apply should be excluded.
/// See <a href="https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0001.md" target="_blank">Stellar Toml</a>
class Currency
{
/// Token code.
public ?string $code = null;

/// A pattern with ? as a single character wildcard. Allows a [[CURRENCIES]] entry to apply to multiple assets that share the same info. An example is futures, where the only difference between issues is the date of the contract. E.g. CORN???????? to match codes such as CORN20180604.
public ?string $codeTemplate = null;

/// Token issuer Stellar public key.
public ?string $issuer = null;

/// Status of token. One of live, dead, test, or private. Allows issuer to mark whether token is dead/for testing/for private use or is live and should be listed in live exchanges.
public ?string $status = null;

/// Preference for number of decimals to show when a client displays currency balance.
public ?int $displayDecimals = null;

/// A short name for the token.
public ?string $name = null;

/// Description of token and what it represents.
public ?string $desc = null;

/// Conditions on token.
public ?string $conditions = null;

/// URL to a PNG image on a transparent background representing token.
public ?string $image = null;

/// Fixed number of tokens, if the number of tokens issued will never change.
public ?int $fixedNumber = null;

/// Max number of tokens, if there will never be more than maxNumber tokens.
public ?int $maxNumber = null;

/// The number of tokens is dilutable at the issuer's discretion.
public ?bool $isUnlimited = null;

/// true if token can be redeemed for underlying asset, otherwise false.
public ?bool $isAssetAnchored = null;

/// Type of asset anchored. Can be fiat, crypto, stock, bond, commodity, realestate, or other.
public ?string $anchorAssetType = null;

/// If anchored token, code / symbol for asset that token is anchored to. E.g. USD, BTC, SBUX, Address of real-estate investment property.
public ?string $anchorAsset = null;

/// If anchored token, these are instructions to redeem the underlying asset from tokens.
public ?string $redemptionInstructions = null;

/// If this is an anchored crypto token, list of one or more public addresses that hold the assets for which you are issuing tokens.
public ?array $collateralAddresses = null; // [string]

/// Messages stating that funds in the collateralAddresses list are reserved to back the issued asset.
public ?array $collateralAddressMessages = null; // [string]

/// These prove you control the collateralAddresses. For each address you list, sign the entry in collateralAddressMessages with the address's private key and add the resulting string to this list as a base64-encoded raw signature.
public ?array $collateralAddressSignatures = null; // [string]

/// Indicates whether or not this is a sep0008 regulated asset. If missing, false is assumed.
public ?bool $regulated = null;

/// URL of a sep0008 compliant approval service that signs validated transactions.
public ?string $approvalServer = null;

/// A human readable string that explains the issuer's requirements for approving transactions.
public ?string $approvalCriteria = null;

/// Alternately, stellar.toml can link out to a separate TOML file for each currency by specifying toml="https://DOMAIN/.well-known/CURRENCY.toml" as the currency's only field.
/// In this case only this field is filled. To load the currency data, you can use StellarToml.currencyFromUrl(String toml).
public ?string $toml = null;

}
60 changes: 60 additions & 0 deletions Soneso/StellarSDK/SEP/Toml/Documentation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php declare(strict_types=1);

// Copyright 2021 The Stellar PHP SDK Authors. All rights reserved.
// Use of this source code is governed by a license that can be
// found in the LICENSE file.

namespace Soneso\StellarSDK\SEP\Toml;

/// Organization Documentation. From the stellar.toml DOCUMENTATION table.
/// See <a href="https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0001.md" target="_blank">Stellar Toml</a>
class Documentation
{
/// Legal name of the organization.
public ?string $orgName = null;

/// (may not apply) DBA of the organization.
public ?string $orgDBA = null;

/// The organization's official URL. The stellar.toml must be hosted on the same domain.
public ?string $orgUrl = null;

/// An Url to a PNG image of the organization's logo on a transparent background.
public ?string $orgLogo = null;

/// Short description of the organization.
public ?string $orgDescription = null;

/// Physical address for the organization.
public ?string $orgPhysicalAddress = null;

/// URL on the same domain as the orgUrl that contains an image or pdf official document attesting to the physical address. It must list the orgName or orgDBA as the party at the address. Only documents from an official third party are acceptable. E.g. a utility bill, mail from a financial institution, or business license.
public ?string $orgPhysicalAddressAttestation = null;

/// The organization's phone number in E.164 format, e.g. +14155552671.
public ?string $orgPhoneNumber = null;

/// URL on the same domain as the orgUrl that contains an image or pdf of a phone bill showing both the phone number and the organization's name.
public ?string $orgPhoneNumberAttestation = null;

/// A Keybase account name for the organization. Should contain proof of ownership of any public online accounts you list here, including the organization's domain.
public ?string $orgKeybase = null;

/// The organization's Twitter account.
public ?string $orgTwitter = null;

/// The organization's Github account
public ?string $orgGithub = null;

/// An email where clients can contact the organization. Must be hosted at the orgUrl domain.
public ?string $orgOfficialEmail = null;

/// Name of the authority or agency that licensed the organization, if applicable.
public ?string $orgLicensingAuthority = null;

/// Type of financial or other license the organization holds, if applicable
public ?string $orgLicenseType = null;

/// Official license number of the organization, if applicable.
public ?string $orgLicenseNumber = null;
}
48 changes: 48 additions & 0 deletions Soneso/StellarSDK/SEP/Toml/GeneralInformation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php declare(strict_types=1);

// Copyright 2021 The Stellar PHP SDK Authors. All rights reserved.
// Use of this source code is governed by a license that can be
// found in the LICENSE file.

namespace Soneso\StellarSDK\SEP\Toml;

/// General information from the stellar.toml file.
/// See <a href="https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0001.md" target="_blank">Stellar Toml</a>
class GeneralInformation
{
/// The version of SEP-1 your stellar.toml adheres to. This helps parsers know which fields to expect.
public ?string $version = null;

/// The passphrase for the specific Stellar network this infrastructure operates on.
public ?string $networkPassphrase = null;

/// The endpoint for clients to resolve stellar addresses for users on your domain via SEP-2 Federation Protocol.
public ?string $federationServer = null;

/// The endpoint used for SEP-3 Compliance Protocol.
public ?string $authServer = null;

/// The server used for SEP-6 Anchor/Client interoperability.
public ?string $transferServer = null;

/// The server used for SEP-24 Anchor/Client interoperability.
public ?string $transferServerSep24 = null;

/// The server used for SEP-12 Anchor/Client customer info transfer.
public ?string $kYCServer = null;

/// The endpoint used for SEP-10 Web Authentication.
public ?string $webAuthEndpoint = null;

/// The signing key is used for SEP-3 Compliance Protocol and SEP-10 Authentication Protocol.
public ?string $signingKey = null;

/// Location of public-facing Horizon instance (if one is offered).
public ?string $horizonUrl = null;

/// A list of Stellar accounts that are controlled by this domain
public array $accounts = array();

/// The signing key is used for SEP-7 delegated signing.
public ?string $uriRequestSigningKey = null;
}
37 changes: 37 additions & 0 deletions Soneso/StellarSDK/SEP/Toml/PointOfContact.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php declare(strict_types=1);

// Copyright 2021 The Stellar PHP SDK Authors. All rights reserved.
// Use of this source code is governed by a license that can be
// found in the LICENSE file.

namespace Soneso\StellarSDK\SEP\Toml;

/// Point of Contact Documentation. From the stellar.toml [[PRINCIPALS]] list. It contains identifying information for the primary point of contact or principal of the organization.
/// See <a href="https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0001.md" target="_blank">Stellar Toml</a>
class PointOfContact
{
/// Full legal name.
public ?string $name = null;

/// Business email address for the principal.
public ?string $email = null;

/// Personal Keybase account. Should include proof of ownership for other online accounts, as well as the organization's domain.
public ?string $keybase = null;

/// Personal Telegram account.
public ?string $telegram = null;

/// Personal Twitter account.
public ?string $twitter = null;

/// Personal Github account.
public ?string $github = null;

/// SHA-256 hash of a photo of the principal's government-issued photo ID.
public ?string $idPhotoHash = null;

/// SHA-256 hash of a verification photo of principal. Should be well-lit and contain: principal holding ID card and signed, dated, hand-written message stating I, $name, am a principal of $orgName, a Stellar token issuer with address $issuerAddress.
public ?string $verificationPhotoHash = null;

}
39 changes: 39 additions & 0 deletions Soneso/StellarSDK/SEP/Toml/Principals.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php declare(strict_types=1);

// Copyright 2021 The Stellar PHP SDK Authors. All rights reserved.
// Use of this source code is governed by a license that can be
// found in the LICENSE file.

namespace Soneso\StellarSDK\SEP\Toml;

class Principals extends \IteratorIterator
{

public function __construct(PointOfContact ...$pointsOfContact)
{
parent::__construct(new \ArrayIterator($pointsOfContact));
}

public function current(): PointOfContact
{
return parent::current();
}

public function add(PointOfContact $pointOfContact)
{
$this->getInnerIterator()->append($pointOfContact);
}

public function count(): int
{
return $this->getInnerIterator()->count();
}

public function toArray() : array {
$result = array();
foreach($this as $value) {
array_push($result, $value);
}
return $result;
}
}
Loading

0 comments on commit 2408eb5

Please sign in to comment.