Skip to content

Commit

Permalink
add federation examples, prepare release
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-rogobete committed Jul 14, 2020
1 parent e431d5e commit 3711f66
Show file tree
Hide file tree
Showing 11 changed files with 121 additions and 11 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [1.0.2] - 14.Jul.2020.
- SEP-0002 implementation - Federation
- update documentation
- add tests and examples

## [1.0.1] - 12.Jul.2020.
- SEP-0001 implementation
- loading and parsing stellar.toml data
Expand Down
28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The Soneso open source Stellar SDK for Flutter is build with Dart and provides A
1. Add the dependency to your pubspec.yaml file:
```
dependencies:
stellar_flutter_sdk: ^1.0.1
stellar_flutter_sdk: ^1.0.2
```
2. Install it (command line or IDE):
```
Expand Down Expand Up @@ -228,6 +228,24 @@ if (response.success) {
}
```

### 5. Resolving a stellar address by using Federation

```dart
FederationResponse response = await Federation.resolveStellarAddress("bob*soneso.com");
print(response.stellarAddress);
// bob*soneso.com
print(response.accountId);
// GBVPKXWMAB3FIUJB6T7LF66DABKKA2ZHRHDOQZ25GBAEFZVHTBPJNOJI
print(response.memoType);
// text
print(response.memo);
// hello memo text
```

## Documentation and Examples

### Examples
Expand All @@ -249,14 +267,20 @@ if (response.success) {
| [Stream payments](documentation/sdk_examples/stream_payments.md) | Listens for payments received by a given account.| [Streaming](https://developers.stellar.org/api/introduction/streaming/) |
| [Fee bump transaction](documentation/sdk_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](documentation/sdk_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)|
| [SEP-0001: stellar.toml](documentation/sdk_examples/sep-0001.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-0001: stellar.toml](documentation/sdk_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-0002: Federation](documentation/sdk_examples/sep-0002-federation.md) | This examples shows how to resolve a stellar address, a stellar account id, a transaction id and a forward by using the federation protocol. | [SEP-0002](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0002.md)|

Additional examples can be found in the [tests](https://github.com/Soneso/stellar_flutter_sdk/blob/master/test/).

### Documentation

You can fild additional documentation including the API documentation in the [documentation folder](documentation/).

### SEPs implemented

- [SEP-0001 (stellar.toml)](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0001.md)
- [SEP-0002 (Federation)](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0002.md)

## How to contribute

Please read our [Contribution Guide](https://github.com/Soneso/stellar_flutter_sdk/blob/master/CONTRIBUTING.md).
Expand Down
4 changes: 3 additions & 1 deletion documentation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ The Soneso open source Stellar SDK for Flutter is build with Dart and provides A
| [Stream payments](sdk_examples/stream_payments.md) | Listens for payments received by a given account.| [Streaming](https://developers.stellar.org/api/introduction/streaming/) |
| [Fee bump transaction](sdk_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](sdk_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)|
| [SEP-0001: stellar.toml](sdk_examples/sep-0001.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-0001: stellar.toml](sdk_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-0002: Federation](sdk_examples/sep-0002-federation.md) | This examples shows how to resolve a stellar address, a stellar account id, a transaction id and a forward by using the federation protocol. | [SEP-0002](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0002.md)|


More examples and use cases can be found in the [test classes](../test).

Expand Down
Binary file modified documentation/sdk_api_doc.zip
Binary file not shown.
3 changes: 2 additions & 1 deletion documentation/sdk_examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ The [Soneso open source Stellar SDK for Flutter](https://github.com/Soneso/stell
| [Stream payments](stream_payments.md) | Listens for payments received by a given account.| [Streaming](https://developers.stellar.org/api/introduction/streaming/) |
| [Fee bump transaction](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](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)|
| [SEP-0001: stellar.toml](sep-0001.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-0001: stellar.toml](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-0002: Federation](sep-0002-federation.md) | This examples shows how to resolve a stellar address, a stellar account id, a transaction id and a forward by using the federation protocol. | [SEP-0002](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0002.md)|

File renamed without changes.
68 changes: 68 additions & 0 deletions documentation/sdk_examples/sep-0002-federation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@

### SEP-0002 - Federation

This examples shows how to resolve a stellar address, a stellar account id, a transaction id and a forward by using the federation protocol. For more details see: [SEP-0002 Federation](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0002.md).

#### Resolving a stellar address

To resolve a stellar address like for example ```bob*soneso.com``` we can use the static method ```Federation.resolveStellarAddress ``` as shown below:

```dart
FederationResponse response = await Federation.resolveStellarAddress("bob*soneso.com");
print(response.stellarAddress);
// bob*soneso.com
print(response.accountId);
// GBVPKXWMAB3FIUJB6T7LF66DABKKA2ZHRHDOQZ25GBAEFZVHTBPJNOJI
print(response.memoType);
// text
print(response.memo);
// hello memo text
```

#### Resolving a stellar account id

To resolve a stellar account id like for example ```GBVPKXWMAB3FIUJB6T7LF66DABKKA2ZHRHDOQZ25GBAEFZVHTBPJNOJI``` we can use the static method ```Federation.resolveStellarAccountId ```. We need to provide the account id and the federation server url as parameters:

```dart
FederationResponse response = await Federation.resolveStellarAccountId("GBVPKXWMAB3FIUJB6T7LF66DABKKA2ZHRHDOQZ25GBAEFZVHTBPJNOJI", "https://stellarid.io/federation/");
print(response.stellarAddress);
// bob*soneso.com
print(response.accountId);
// GBVPKXWMAB3FIUJB6T7LF66DABKKA2ZHRHDOQZ25GBAEFZVHTBPJNOJI
print(response.memoType);
// text
print(response.memo);
// hello memo text
```

#### Resolving a stellar transaction id

To resolve a stellar transaction id like for example ```c1b368c00e9852351361e07cc58c54277e7a6366580044ab152b8db9cd8ec52a``` we can use the static method ```Federation.resolveStellarTransactionId ```. We need to provide the transaction id and the federation server url as parameters:

```dart
// Returns the federation record of the sender of the transaction if known by the server
FederationResponse response = await Federation.resolveStellarTransactionId("c1b368c00e9852351361e07cc58c54277e7a6366580044ab152b8db9cd8ec52a", "https://stellarid.io/federation/");
```

#### Resolving a forward

Used for forwarding the payment on to a different network or different financial institution. Here we can use the static method ```Federation.resolveForward``` . We need to provide the needed query parameters as ```Map<String, String>``` and the federation server url:

```dart
FederationResponse response = await Federation.resolveForward({
"forward_type": "bank_account",
"swift": "BOPBPHMM",
"acct": "2382376"
}, "https://stellarid.io/federation/");
// resulting request url:
// https://stellarid.io/federation/?type=forward&forward_type=bank_account&swift=BOPBPHMM&acct=2382376
```
11 changes: 6 additions & 5 deletions lib/src/sep/0002/federation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,14 @@ class Federation {
return response;
}

/// Resolves a stellar account transaction id such as c1b368c00e9852351361e07cc58c54277e7a6366580044ab152b8db9cd8ec52a
/// The url of the federation server has to be provided.
/// Resolves a stellar forward.
/// The url of the federation server and the forward query parameters have to be provided.
/// Returns a [FederationResponse] object.
static Future<FederationResponse> resolveForward(
Map<String, String> queryParameters, String federationServerUrl) async {
Map params =
checkNotNull(queryParameters, "queryParameters can not be null");
Map<String, String> forwardQueryParameters,
String federationServerUrl) async {
Map params = checkNotNull(
forwardQueryParameters, "forwardQueryParameters can not be null");
String server = checkNotNull(
federationServerUrl, "federationServerUrl can not be null");

Expand Down
2 changes: 1 addition & 1 deletion lib/src/stellar_sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import 'requests/trades_request_builder.dart';

/// Main class of the flutter stellar sdk.
class StellarSDK {
static const versionNumber = "1.0.1";
static const versionNumber = "1.0.2";

static final StellarSDK PUBLIC =
new StellarSDK("https://horizon.stellar.org");
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: stellar_flutter_sdk
description: A stellar blockchain sdk that query's horizon, build, signs and submits transactions to the stellar netweok.
version: 1.0.1
version: 1.0.2
homepage: https://github.com/Soneso/stellar_flutter_sdk

environment:
Expand Down
9 changes: 9 additions & 0 deletions test/examples_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1610,4 +1610,13 @@ void main() {
}
}
});

test('sep 0002 - federation - resolve address', () async {
FederationResponse response =
await Federation.resolveStellarAddress("bob*soneso.com");
print(response.stellarAddress);
print(response.accountId);
print(response.memoType);
print(response.memo);
});
}

0 comments on commit 3711f66

Please sign in to comment.