Skip to content

Commit

Permalink
prepare for release 0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-rogobete committed Jun 25, 2020
1 parent 2ddd6df commit 3116354
Show file tree
Hide file tree
Showing 7 changed files with 208 additions and 86 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [0.8.0] - 26.Jun.2020.
- Extend documentation and tests, extend orders result.

## [0.7.9] - 25.Jun.2020.
- Added examples, documentation, tests and bugfixes.

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# [Stellar SDK for Flutter](https://github.com/Soneso/stellar_flutter_sdk)

![Beta Version](https://img.shields.io/badge/Beta-v0.7.9-yellow.svg)
![Beta Version](https://img.shields.io/badge/Beta-v0.8.0-yellow.svg)
![Dart](https://img.shields.io/badge/Dart-green.svg)
![Flutter](https://img.shields.io/badge/Flutter-blue.svg)
![Supports Stellar Horizon v1.4.0](https://img.shields.io/badge/Horizon-v1.4.0-blue.svg)
![Supports Stellar Core v13](https://img.shields.io/badge/Core-v13-blue.svg)

The Soneso open source Stellar SDK for Flutter is build with Dart and provides APIs to build and sign transactions, connect and query [Horizon](https://github.com/stellar/horizon).

The SDK is currently in beta stage - v. 0.7.9.
The SDK is currently in beta stage - v. 0.8.0.

## Installation

### From pub.dev
1. Add the dependency to your pubspec.yaml file:
```
dependencies:
stellar_flutter_sdk: ^0.7.9
stellar_flutter_sdk: ^0.8.0
```
2. Install it (command line or IDE):
```
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 = "0.7.9";
static const versionNumber = "0.8.0";

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: 0.7.9
version: 0.8.0
homepage: https://github.com/Soneso/stellar_flutter_sdk

environment:
Expand Down
Binary file modified sdk_api_doc.zip
Binary file not shown.
159 changes: 113 additions & 46 deletions test/trading_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,23 @@ void main() {
await FriendBot.fundTestAccount(buyerAccountId);

AccountResponse buyerAccount = await sdk.accounts.account(buyerAccountId);
CreateAccountOperationBuilder caob = CreateAccountOperationBuilder(issuerAccountId, "10");
Transaction transaction = TransactionBuilder(buyerAccount, Network.TESTNET).addOperation(caob.build()).build();
CreateAccountOperationBuilder caob =
CreateAccountOperationBuilder(issuerAccountId, "10");
Transaction transaction = TransactionBuilder(buyerAccount, Network.TESTNET)
.addOperation(caob.build())
.build();
transaction.sign(buyerKeipair);
SubmitTransactionResponse response = await sdk.submitTransaction(transaction);
SubmitTransactionResponse response =
await sdk.submitTransaction(transaction);
assert(response.success);

Asset astroDollar = AssetTypeCreditAlphaNum12("ASTRO", issuerAccountId);

ChangeTrustOperationBuilder ctob = ChangeTrustOperationBuilder(astroDollar,"10000");
transaction = TransactionBuilder(buyerAccount, Network.TESTNET).addOperation(ctob.build()).build();
ChangeTrustOperationBuilder ctob =
ChangeTrustOperationBuilder(astroDollar, "10000");
transaction = TransactionBuilder(buyerAccount, Network.TESTNET)
.addOperation(ctob.build())
.build();
transaction.sign(buyerKeipair);

response = await sdk.submitTransaction(transaction);
Expand All @@ -34,13 +41,18 @@ void main() {
String amountBuying = "100";
String price = "0.5";

ManageBuyOfferOperation ms = ManageBuyOfferOperationBuilder(Asset.NATIVE, astroDollar, amountBuying, price).build();
transaction = TransactionBuilder(buyerAccount, Network.TESTNET).addOperation(ms).build();
ManageBuyOfferOperation ms = ManageBuyOfferOperationBuilder(
Asset.NATIVE, astroDollar, amountBuying, price)
.build();
transaction = TransactionBuilder(buyerAccount, Network.TESTNET)
.addOperation(ms)
.build();
transaction.sign(buyerKeipair);
response = await sdk.submitTransaction(transaction);
assert(response.success);

List<OfferResponse> offers = (await sdk.offers.forAccount(buyerAccountId).execute()).records;
List<OfferResponse> offers =
(await sdk.offers.forAccount(buyerAccountId).execute()).records;
assert(offers.length == 1);
OfferResponse offer = offers.first;
assert(offer.buying == astroDollar);
Expand All @@ -59,8 +71,13 @@ void main() {
// update offer
amountBuying = "150";
price = "0.3";
ms = ManageBuyOfferOperationBuilder(Asset.NATIVE, astroDollar, amountBuying, price).setOfferId(offerId).build();
transaction = TransactionBuilder(buyerAccount, Network.TESTNET).addOperation(ms).build();
ms = ManageBuyOfferOperationBuilder(
Asset.NATIVE, astroDollar, amountBuying, price)
.setOfferId(offerId)
.build();
transaction = TransactionBuilder(buyerAccount, Network.TESTNET)
.addOperation(ms)
.build();
transaction.sign(buyerKeipair);
response = await sdk.submitTransaction(transaction);
assert(response.success);
Expand All @@ -81,19 +98,22 @@ void main() {

// delete offer
amountBuying = "0";
ms = ManageBuyOfferOperationBuilder(Asset.NATIVE, astroDollar, amountBuying, price).setOfferId(offerId).build();
transaction = TransactionBuilder(buyerAccount, Network.TESTNET).addOperation(ms).build();
ms = ManageBuyOfferOperationBuilder(
Asset.NATIVE, astroDollar, amountBuying, price)
.setOfferId(offerId)
.build();
transaction = TransactionBuilder(buyerAccount, Network.TESTNET)
.addOperation(ms)
.build();
transaction.sign(buyerKeipair);
response = await sdk.submitTransaction(transaction);
assert(response.success);

offers = (await sdk.offers.forAccount(buyerAccountId).execute()).records;
assert(offers.length == 0);

});

test('manage sell offer', () async {

KeyPair issuerKeipair = KeyPair.random();
KeyPair sellerKeipair = KeyPair.random();

Expand All @@ -103,25 +123,35 @@ void main() {
await FriendBot.fundTestAccount(sellerAccountId);

AccountResponse sellerAccount = await sdk.accounts.account(sellerAccountId);
CreateAccountOperation co = CreateAccountOperationBuilder(issuerAccountId, "10").build();
Transaction transaction = TransactionBuilder(sellerAccount, Network.TESTNET).addOperation(co).build();
CreateAccountOperation co =
CreateAccountOperationBuilder(issuerAccountId, "10").build();
Transaction transaction = TransactionBuilder(sellerAccount, Network.TESTNET)
.addOperation(co)
.build();
transaction.sign(sellerKeipair);
SubmitTransactionResponse response = await sdk.submitTransaction(transaction);
SubmitTransactionResponse response =
await sdk.submitTransaction(transaction);
assert(response.success);

AccountResponse issuerAccount = await sdk.accounts.account(issuerAccountId);

Asset moonDollar = AssetTypeCreditAlphaNum4("MOON", issuerAccountId);

ChangeTrustOperationBuilder ctob = ChangeTrustOperationBuilder(moonDollar,"10000");
transaction = TransactionBuilder(sellerAccount, Network.TESTNET).addOperation(ctob.build()).build();
ChangeTrustOperationBuilder ctob =
ChangeTrustOperationBuilder(moonDollar, "10000");
transaction = TransactionBuilder(sellerAccount, Network.TESTNET)
.addOperation(ctob.build())
.build();
transaction.sign(sellerKeipair);

response = await sdk.submitTransaction(transaction);
assert(response.success);

PaymentOperation po = PaymentOperationBuilder(sellerAccountId, moonDollar, "2000").build();
transaction = TransactionBuilder(issuerAccount, Network.TESTNET).addOperation(po).build();
PaymentOperation po =
PaymentOperationBuilder(sellerAccountId, moonDollar, "2000").build();
transaction = TransactionBuilder(issuerAccount, Network.TESTNET)
.addOperation(po)
.build();
transaction.sign(issuerKeipair);

response = await sdk.submitTransaction(transaction);
Expand All @@ -130,13 +160,18 @@ void main() {
String amountSelling = "100";
String price = "0.5";

ManageSellOfferOperation ms = ManageSellOfferOperationBuilder(moonDollar, Asset.NATIVE, amountSelling, price).build();
transaction = TransactionBuilder(sellerAccount, Network.TESTNET).addOperation(ms).build();
ManageSellOfferOperation ms = ManageSellOfferOperationBuilder(
moonDollar, Asset.NATIVE, amountSelling, price)
.build();
transaction = TransactionBuilder(sellerAccount, Network.TESTNET)
.addOperation(ms)
.build();
transaction.sign(sellerKeipair);
response = await sdk.submitTransaction(transaction);
assert(response.success);

List<OfferResponse> offers = (await sdk.offers.forAccount(sellerAccountId).execute()).records;
List<OfferResponse> offers =
(await sdk.offers.forAccount(sellerAccountId).execute()).records;
assert(offers.length == 1);
OfferResponse offer = offers.first;
assert(offer.buying == Asset.NATIVE);
Expand All @@ -157,8 +192,13 @@ void main() {
// update offer
amountSelling = "150";
price = "0.3";
ms = ManageSellOfferOperationBuilder(moonDollar, Asset.NATIVE, amountSelling, price).setOfferId(offerId).build();
transaction = TransactionBuilder(sellerAccount, Network.TESTNET).addOperation(ms).build();
ms = ManageSellOfferOperationBuilder(
moonDollar, Asset.NATIVE, amountSelling, price)
.setOfferId(offerId)
.build();
transaction = TransactionBuilder(sellerAccount, Network.TESTNET)
.addOperation(ms)
.build();
transaction.sign(sellerKeipair);
response = await sdk.submitTransaction(transaction);
assert(response.success);
Expand All @@ -182,19 +222,22 @@ void main() {

// delete offer
amountSelling = "0";
ms = ManageSellOfferOperationBuilder(moonDollar, Asset.NATIVE, amountSelling, price).setOfferId(offerId).build();
transaction = TransactionBuilder(sellerAccount, Network.TESTNET).addOperation(ms).build();
ms = ManageSellOfferOperationBuilder(
moonDollar, Asset.NATIVE, amountSelling, price)
.setOfferId(offerId)
.build();
transaction = TransactionBuilder(sellerAccount, Network.TESTNET)
.addOperation(ms)
.build();
transaction.sign(sellerKeipair);
response = await sdk.submitTransaction(transaction);
assert(response.success);

offers = (await sdk.offers.forAccount(sellerAccountId).execute()).records;
assert(offers.length == 0);

});

test('create passive sell offer', () async {

KeyPair issuerKeipair = KeyPair.random();
KeyPair sellerKeipair = KeyPair.random();

Expand All @@ -204,25 +247,35 @@ void main() {
await FriendBot.fundTestAccount(sellerAccountId);

AccountResponse sellerAccount = await sdk.accounts.account(sellerAccountId);
CreateAccountOperation co = CreateAccountOperationBuilder(issuerAccountId, "10").build();
Transaction transaction = TransactionBuilder(sellerAccount, Network.TESTNET).addOperation(co).build();
CreateAccountOperation co =
CreateAccountOperationBuilder(issuerAccountId, "10").build();
Transaction transaction = TransactionBuilder(sellerAccount, Network.TESTNET)
.addOperation(co)
.build();
transaction.sign(sellerKeipair);
SubmitTransactionResponse response = await sdk.submitTransaction(transaction);
SubmitTransactionResponse response =
await sdk.submitTransaction(transaction);
assert(response.success);

AccountResponse issuerAccount = await sdk.accounts.account(issuerAccountId);

Asset marsDollar = AssetTypeCreditAlphaNum4("MARS", issuerAccountId);

ChangeTrustOperationBuilder ctob = ChangeTrustOperationBuilder(marsDollar,"10000");
transaction = TransactionBuilder(sellerAccount, Network.TESTNET).addOperation(ctob.build()).build();
ChangeTrustOperationBuilder ctob =
ChangeTrustOperationBuilder(marsDollar, "10000");
transaction = TransactionBuilder(sellerAccount, Network.TESTNET)
.addOperation(ctob.build())
.build();
transaction.sign(sellerKeipair);

response = await sdk.submitTransaction(transaction);
assert(response.success);

PaymentOperation po = PaymentOperationBuilder(sellerAccountId, marsDollar, "2000").build();
transaction = TransactionBuilder(issuerAccount, Network.TESTNET).addOperation(po).build();
PaymentOperation po =
PaymentOperationBuilder(sellerAccountId, marsDollar, "2000").build();
transaction = TransactionBuilder(issuerAccount, Network.TESTNET)
.addOperation(po)
.build();
transaction.sign(issuerKeipair);

response = await sdk.submitTransaction(transaction);
Expand All @@ -231,13 +284,19 @@ void main() {
String amountSelling = "100";
String price = "0.5";

CreatePassiveSellOfferOperation cpso = CreatePassiveSellOfferOperationBuilder(marsDollar, Asset.NATIVE, amountSelling, price).build();
transaction = TransactionBuilder(sellerAccount, Network.TESTNET).addOperation(cpso).build();
CreatePassiveSellOfferOperation cpso =
CreatePassiveSellOfferOperationBuilder(
marsDollar, Asset.NATIVE, amountSelling, price)
.build();
transaction = TransactionBuilder(sellerAccount, Network.TESTNET)
.addOperation(cpso)
.build();
transaction.sign(sellerKeipair);
response = await sdk.submitTransaction(transaction);
assert(response.success);

List<OfferResponse> offers = (await sdk.offers.forAccount(sellerAccountId).execute()).records;
List<OfferResponse> offers =
(await sdk.offers.forAccount(sellerAccountId).execute()).records;
assert(offers.length == 1);
OfferResponse offer = offers.first;
assert(offer.buying == Asset.NATIVE);
Expand All @@ -258,8 +317,13 @@ void main() {
// update offer
amountSelling = "150";
price = "0.3";
ManageSellOfferOperation ms = ManageSellOfferOperationBuilder(marsDollar, Asset.NATIVE, amountSelling, price).setOfferId(offerId).build();
transaction = TransactionBuilder(sellerAccount, Network.TESTNET).addOperation(ms).build();
ManageSellOfferOperation ms = ManageSellOfferOperationBuilder(
marsDollar, Asset.NATIVE, amountSelling, price)
.setOfferId(offerId)
.build();
transaction = TransactionBuilder(sellerAccount, Network.TESTNET)
.addOperation(ms)
.build();
transaction.sign(sellerKeipair);
response = await sdk.submitTransaction(transaction);
assert(response.success);
Expand All @@ -283,15 +347,18 @@ void main() {

// delete offer
amountSelling = "0";
ms = ManageSellOfferOperationBuilder(marsDollar, Asset.NATIVE, amountSelling, price).setOfferId(offerId).build();
transaction = TransactionBuilder(sellerAccount, Network.TESTNET).addOperation(ms).build();
ms = ManageSellOfferOperationBuilder(
marsDollar, Asset.NATIVE, amountSelling, price)
.setOfferId(offerId)
.build();
transaction = TransactionBuilder(sellerAccount, Network.TESTNET)
.addOperation(ms)
.build();
transaction.sign(sellerKeipair);
response = await sdk.submitTransaction(transaction);
assert(response.success);

offers = (await sdk.offers.forAccount(sellerAccountId).execute()).records;
assert(offers.length == 0);

});

}
Loading

0 comments on commit 3116354

Please sign in to comment.