-
Notifications
You must be signed in to change notification settings - Fork 0
add stellar client #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
76 commits
Select commit
Hold shift + click to select a range
9e7e24b
add stellar client
AlaaElattar f4906ee
use switch on network type instead of if condition
AlaaElattar e042b14
Merge branch 'main' of https://github.com/codescalers/tfgrid-sdk-dart…
AlaaElattar 34f4610
fix workflow
AlaaElattar 9efdb8a
fix coverage workflow
AlaaElattar aeedf47
fix sdk version
AlaaElattar 0265a5b
specify dart version in workflow
AlaaElattar 557570a
return version to stable
AlaaElattar 2df5c8b
change version to 3.4.4
AlaaElattar 775dbc7
change version to 3.4.4.
AlaaElattar e1c664d
undo changes of coverage workflow
AlaaElattar 65cf67d
update client && support listing transactions && loading from secretSeed
AlaaElattar 100c485
update listing transaction && apply dart format
AlaaElattar f75f46d
update sendTransaction function
AlaaElattar 87a4655
specify dart version to fix workflow
AlaaElattar 0a192ec
comment setup dart sdk part
AlaaElattar aa4808e
Merge branch 'main' of https://github.com/codescalers/tfgrid-sdk-dart…
AlaaElattar ff97ddd
undo coverage changes
AlaaElattar 4a34f3d
add readme && fix workflow
AlaaElattar 4444c57
clear cache
AlaaElattar bd790cc
verify dart version
AlaaElattar 3263fe5
debug what's wrong with versions
AlaaElattar 826999d
debug what's wrong with versions
AlaaElattar 3ddae2f
update sdk version of stellar
AlaaElattar 48c663e
run melos with specific sdk
AlaaElattar d7a0f73
debug version of melos
AlaaElattar 77c20cd
separate dependencies of dart from flutter ones
AlaaElattar f83fb7a
exclude stellar client from melos unit tests7
AlaaElattar aa68935
exclude stellar client from melos unit tests
AlaaElattar 8eecd65
fix excluding stellar client
AlaaElattar 757f285
remove test dir from stellar
AlaaElattar 99a00d8
add flutter setup in coverage
AlaaElattar fa7b4c6
add flutter setup in coverage
AlaaElattar b78f06c
setting flutter after dart version
AlaaElattar 359a3d6
remove verify melos
AlaaElattar e96e39a
export dart path
AlaaElattar cca5bc3
update flutter version
AlaaElattar 511768c
Delete .vscode/settings.json
AlaaElattar c87f951
Delete melos_tfgrid_sdk_dart_monorepo.iml
AlaaElattar 37cbb21
Delete packages/tfchain_client/pubspec_overrides.yaml
AlaaElattar eec522b
Delete packages/signer/coverage/lcov.info
AlaaElattar c61be1f
Delete packages/tfchain_client/coverage/filtered.lcov.info
AlaaElattar 51709ba
Delete packages/tfchain_client/coverage/result.txt
AlaaElattar 701bdda
Delete packages/tfchain_client/coverage/lcov.info
AlaaElattar 94fc0d7
remove models && rename the file && prepare main file with example
AlaaElattar 4495b2c
Delete packages/tfchain_client/.dart_tool/package_config.json
AlaaElattar f9a52d4
Delete packages/zos/.dart_tool/package_config.json
AlaaElattar 758be0f
Delete packages/zos/pubspec.lock
AlaaElattar 204485f
Delete packages/rmb_client/.dart_tool/package_config.json
AlaaElattar 4debc34
Delete packages/rmb_client/pubspec.lock
AlaaElattar 4a4ca4f
remove bin files
AlaaElattar a550724
return .dart_tool in gitignore
AlaaElattar d5403f3
Delete .dart_tool/package_config.json
AlaaElattar ea50510
remove tfchain files
AlaaElattar e1a8fdc
return .dart_tool in gitignore
AlaaElattar 62da5c0
fix dart version
AlaaElattar 7a738fc
fix dart version
AlaaElattar aaf5e67
change dart version to 3.2.0
AlaaElattar 8d401b1
update dart version in tfchian
AlaaElattar c6cdf86
add listing files in coverage workflow
AlaaElattar 4c7627c
run flutter pub get in stellar directory
AlaaElattar df32829
change flutter version to 3.16
AlaaElattar e3a0274
change flutter, dart versions && update client constructors && fix wo…
AlaaElattar c9932eb
update analyze command
AlaaElattar 43aec2a
fix renaming of activation functions
AlaaElattar bd3b287
remove network coditions and add it as param
AlaaElattar 36446a4
change createAccountFromSecret to be activation only
AlaaElattar d20acde
check workflow
AlaaElattar eac5ee7
add setup flutter in analyze workflow
AlaaElattar 53bd1b1
remove unnecessary null assertion
AlaaElattar ed83a3c
remove spaces
AlaaElattar 90e955e
fix bug
AlaaElattar b3637b0
apply comments
AlaaElattar 282b488
update readme file and bin file
AlaaElattar fd4129f
modify 2 sentences in readme
AlaaElattar 2c3f378
modify example
AlaaElattar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## 1.0.0 | ||
|
||
- Initial version. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Stellar Client | ||
|
||
This Dart client allows you to communicate with the Stellar network, enabling the creation or loading of existing Stellar accounts. It supports interactions with both the testnet and public network, and the assets currently supported are TFT (Threefold Token) and XLM (Stellar Lumens). | ||
|
||
## Installation | ||
|
||
To install the necessary dependencies, run: | ||
|
||
```bash | ||
dart pub get | ||
``` | ||
|
||
## Usage | ||
|
||
This client enables you to create new Stellar accounts or load existing ones on the testnet or public network. Once an account is created or loaded, you can manage assets such as TFT and XLM. | ||
|
||
### TESTNET | ||
|
||
Create new testnet account: | ||
|
||
- Use `Client.create(NetworkType.TESTNET)` to create a new client. | ||
- Use `Client.createFromMnemonic(NetworkType.TESTNET, "mnemonic")` to create a client from an existing mnemonic. | ||
- Account can be activated through friendbot (only for testnet). | ||
- After activation, trustlines can be added to the account. | ||
|
||
```dart | ||
import 'package:stellar_client/stellar_client.dart'; | ||
final stellarClient = Client.create(NetworkType.TESTNET); | ||
// final stellarClient = await Client.createFromMnemonic(NetworkType.TESTNET, "mnemonic"); | ||
await stellarClient.activateThroughFriendBot(accountId: stellarClient.accountId); | ||
await stellarClient.addTrustLine(); | ||
final balance = await stellarClient.getBalance(); | ||
print(balance); | ||
``` | ||
|
||
Load previously created account: | ||
|
||
- Accounts can be loaded from secret seed. | ||
|
||
```dart | ||
import 'package:stellar_client/stellar_client.dart'; | ||
final stellarClient = Client(NetworkType.TESTNET, secretSeed); | ||
final transactions = await stellarClient.getTransactions(); | ||
print(transactions); | ||
``` | ||
|
||
### PUBLIC | ||
|
||
- Activation through Threefold service will add assets automatically. | ||
|
||
```dart | ||
import 'package:stellar_client/stellar_client.dart'; | ||
final stellarClient = Client.create(NetworkType.PUBLIC); | ||
await stellarClient.activateThroughThreefoldService(); | ||
await stellarClient.transfer( | ||
destinationAddress: "destination-public-key", | ||
amount: "20", | ||
currency: "TFT", | ||
memoText: "Memo Text"); | ||
await stellarClient.getTransactions(); | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import 'package:stellar_client/stellar_client.dart'; | ||
|
||
void main() async { | ||
final stellarClient = Client.create(NetworkType.PUBLIC); | ||
await stellarClient.activateThroughThreefoldService(); | ||
|
||
await stellarClient.transfer( | ||
destinationAddress: "destination-public-key", | ||
amount: "20", | ||
currency: "TFT", | ||
memoText: "Memo Text"); | ||
|
||
await stellarClient.getTransactions(); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
abstract class BalanceInfo { | ||
String get assetCode; | ||
String get balance; | ||
} | ||
|
||
class BalanceData implements BalanceInfo { | ||
@override | ||
final String assetCode; | ||
@override | ||
final String balance; | ||
|
||
BalanceData({required this.assetCode, required this.balance}); | ||
|
||
@override | ||
String toString() { | ||
return 'BalanceData(assetCode: $assetCode, balance: $balance)'; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
class Currency { | ||
final String assetCode; | ||
final String issuer; | ||
|
||
Currency({required this.assetCode, required this.issuer}); | ||
|
||
Map<String, dynamic> toJson() { | ||
return { | ||
'asset_code': assetCode, | ||
'issuer': issuer, | ||
}; | ||
} | ||
} | ||
|
||
class Currencies { | ||
late final Map<String, Currency> currencies; | ||
|
||
Currencies(this.currencies); | ||
|
||
Map<String, dynamic> toJson() { | ||
Map<String, dynamic> jsonMap = {}; | ||
currencies.forEach((key, value) { | ||
jsonMap[key] = value.toJson(); | ||
}); | ||
return jsonMap; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class TransactionData { | ||
final String asset; | ||
final String feeAccountId; | ||
final String feeFixed; | ||
|
||
TransactionData({ | ||
required this.asset, | ||
required this.feeAccountId, | ||
required this.feeFixed, | ||
}); | ||
|
||
factory TransactionData.fromJson(Map<String, dynamic> json) { | ||
return TransactionData( | ||
asset: json['asset'], | ||
feeAccountId: json['fee_account_id'], | ||
feeFixed: json['fee_fixed'], | ||
); | ||
} | ||
|
||
@override | ||
String toString() { | ||
return 'TransactionData{asset: $asset, feeAccountId: $feeAccountId, feeFixed: $feeFixed}'; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
class PaymentOperationDetails { | ||
final String from; | ||
final String to; | ||
final double amount; | ||
final String assetCode; | ||
final bool isSuccessful; | ||
|
||
PaymentOperationDetails({ | ||
required this.from, | ||
required this.to, | ||
required this.amount, | ||
required this.assetCode, | ||
required this.isSuccessful, | ||
}); | ||
|
||
@override | ||
String toString() { | ||
return 'PaymentOperationDetails(from: $from, to: $to, amount: $amount, assetCode: $assetCode, isSuccessful: $isSuccessful)'; | ||
} | ||
} | ||
|
||
class CreateAccountOperationDetails { | ||
final String account; | ||
final double startingBalance; | ||
|
||
CreateAccountOperationDetails({ | ||
required this.account, | ||
required this.startingBalance, | ||
}); | ||
|
||
@override | ||
String toString() { | ||
return 'CreateAccountOperationDetails(account: $account, startingBalance: $startingBalance)'; | ||
} | ||
} | ||
|
||
class PathPaymentStrictReceiveOperationDetails { | ||
final String from; | ||
final String to; | ||
final double sourceAmount; | ||
final String sourceAssetCode; | ||
final double destinationAmount; | ||
final String destinationAssetCode; | ||
|
||
PathPaymentStrictReceiveOperationDetails({ | ||
required this.from, | ||
required this.to, | ||
required this.sourceAmount, | ||
required this.sourceAssetCode, | ||
required this.destinationAmount, | ||
required this.destinationAssetCode, | ||
}); | ||
|
||
@override | ||
String toString() { | ||
return 'PathPaymentStrictReceiveOperationDetails(from: $from, to: $to, sourceAmount: $sourceAmount, sourceAssetCode: $sourceAssetCode, destinationAmount: $destinationAmount, destinationAssetCode: $destinationAssetCode)'; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.