Skip to content

Commit

Permalink
suppprt for muxed accounts by default see #39
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-rogobete committed Jan 25, 2022
1 parent ae6e2d8 commit 15be58d
Show file tree
Hide file tree
Showing 34 changed files with 156 additions and 129 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [1.2.9] - 25.Jan.2022.
- Muxed accounts are now supported by default
- fix sep-0012 headers
- improve documentation

## [1.2.8] - 11.Jan.2022.
- fix sep-10 transaction post
- fix revoke sponsorship operation
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,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.2.8
stellar_flutter_sdk: ^1.2.9
```
2. Install it (command line or IDE):
```
Expand Down Expand Up @@ -311,8 +311,10 @@ You can find additional documentation including the API documentation in the [do
- [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)
- [SEP-0005 (Key derivation)](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0005.md)
- [SEP-0006: Deposit and Withdrawal API](documentation/sdk_examples/sep-0006-transfer.md)
- [SEP-0010 (Stellar Web Authentication)](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0010.md)
- [SEP-0011 (Txrep)](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0011.md)
- [SEP-0012: KYC API](documentation/sdk_examples/sep-0012-kyc.md)

## How to contribute

Expand Down
12 changes: 12 additions & 0 deletions documentation/sdk_examples/muxed_account_payment.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,15 @@ response = await sdk.submitTransaction(transaction);
// https://laboratory.stellar.org/#explorer?resource=transactions&endpoint=single&network=test
print(response.hash);
```

Since version 1.2.9 also use muxed "M..." addresses are supported by default as source account ids and destination account ids.

For example:
```dart
String sourceAccountId = "MD6HSPJQPCQBMMSPP33SMERH32U5ZWIJN7DAD2V3UPWZBO347GN3EAAAAAAAAAPGE4NB4";
String destinationAccountId = "MBUZNQV4SSPFZPLIK55ZQ4SZWROKZLJQ62YF5Q3IKJAD5ICYCC3JSAAAAAAAABHOUBCZ4";
PaymentOperation paymentOperation = new PaymentOperationBuilder(destinationAccountId, Asset.NATIVE, "100")
.setSourceAccount(sourceAccountId)
.build();
```
10 changes: 8 additions & 2 deletions lib/src/account.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,18 @@ class Account implements TransactionBuilderAccount {
MuxedAccount? _muxedAccount;

Account(String? ed25519AccountId, int sequenceNumber, {int? muxedAccountMed25519Id}) {
_accountId = checkNotNull(ed25519AccountId, "keypair cannot be null");
_accountId = checkNotNull(ed25519AccountId, "ed25519AccountId cannot be null");
_mSequenceNumber = checkNotNull(sequenceNumber, "sequenceNumber cannot be null");

_muxedAccount = MuxedAccount(ed25519AccountId, muxedAccountMed25519Id);
}

static Account fromAccountId(String accountId, int sequenceNumber) {
checkNotNull(accountId, "accountId cannot be null");
checkNotNull(sequenceNumber, "sequenceNumber cannot be null");
MuxedAccount mux = MuxedAccount.fromAccountId(accountId)!;
return new Account(mux.ed25519AccountId, sequenceNumber, muxedAccountMed25519Id: mux.id);
}

@override
String? get accountId => _accountId;

Expand Down
13 changes: 7 additions & 6 deletions lib/src/account_merge_operation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class AccountMergeOperationBuilder {
MuxedAccount? _mSourceAccount;

/// Creates a new AccountMerge builder.
AccountMergeOperationBuilder(String? destination) {
AccountMergeOperationBuilder(String destination) {
checkNotNull(destination, "destination cannot be null");
this._destination = MuxedAccount(destination, null);
this._destination = MuxedAccount.fromAccountId(destination);
}

/// Creates a new AccountMerge builder for a muxed destination account.
Expand All @@ -52,13 +52,14 @@ class AccountMergeOperationBuilder {
}

/// Set source account of this operation
AccountMergeOperationBuilder setSourceAccount(String sourceAccount) {
_mSourceAccount = MuxedAccount(sourceAccount, null);
AccountMergeOperationBuilder setSourceAccount(String sourceAccountId) {
checkNotNull(sourceAccountId, "sourceAccountId cannot be null");
_mSourceAccount = MuxedAccount.fromAccountId(sourceAccountId);
return this;
}

AccountMergeOperationBuilder setMuxedSourceAccount(MuxedAccount? sourceAccount) {
_mSourceAccount = sourceAccount;
AccountMergeOperationBuilder setMuxedSourceAccount(MuxedAccount sourceAccount) {
_mSourceAccount = checkNotNull(sourceAccount, "sourceAccount cannot be null");
return this;
}

Expand Down
9 changes: 5 additions & 4 deletions lib/src/allow_trust_operation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,14 @@ class AllowTrustOperationBuilder {
}

///Set source account of this operation
AllowTrustOperationBuilder setSourceAccount(String sourceAccount) {
_mSourceAccount = MuxedAccount(sourceAccount, null);
AllowTrustOperationBuilder setSourceAccount(String sourceAccountId) {
checkNotNull(sourceAccountId, "sourceAccountId cannot be null");
_mSourceAccount = MuxedAccount.fromAccountId(sourceAccountId);
return this;
}

AllowTrustOperationBuilder setMuxedSourceAccount(MuxedAccount? sourceAccount) {
_mSourceAccount = sourceAccount;
AllowTrustOperationBuilder setMuxedSourceAccount(MuxedAccount sourceAccount) {
_mSourceAccount = checkNotNull(sourceAccount, "sourceAccount cannot be null");
return this;
}

Expand Down
10 changes: 5 additions & 5 deletions lib/src/begin_sponsoring_future_reserves_operation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ class BeginSponsoringFutureReservesOperationBuilder {

BeginSponsoringFutureReservesOperationBuilder(this._sponsoredId);

/// Sets the source account for this operation represented by [sourceAccount].
BeginSponsoringFutureReservesOperationBuilder setSourceAccount(String sourceAccount) {
checkNotNull(sourceAccount, "sourceAccount cannot be null");
_mSourceAccount = MuxedAccount(sourceAccount, null);
/// Sets the source account for this operation represented by [sourceAccountId].
BeginSponsoringFutureReservesOperationBuilder setSourceAccount(String sourceAccountId) {
checkNotNull(sourceAccountId, "sourceAccountId cannot be null");
_mSourceAccount = MuxedAccount.fromAccountId(sourceAccountId);
return this;
}

/// Sets the muxed source account for this operation represented by [sourceAccountId].
/// Sets the muxed source account for this operation represented by [sourceAccount].
BeginSponsoringFutureReservesOperationBuilder setMuxedSourceAccount(MuxedAccount sourceAccount) {
_mSourceAccount = checkNotNull(sourceAccount, "sourceAccount cannot be null");
return this;
Expand Down
6 changes: 3 additions & 3 deletions lib/src/bump_sequence_operation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ class BumpSequenceOperationBuilder {
}

/// Sets the source account for this operation.
BumpSequenceOperationBuilder setSourceAccount(String sourceAccount) {
checkNotNull(sourceAccount, "sourceAccount cannot be null");
_mSourceAccount = MuxedAccount(sourceAccount, null);
BumpSequenceOperationBuilder setSourceAccount(String sourceAccountId) {
checkNotNull(sourceAccountId, "sourceAccountId cannot be null");
_mSourceAccount = MuxedAccount.fromAccountId(sourceAccountId);
return this;
}

Expand Down
8 changes: 4 additions & 4 deletions lib/src/change_trust_operation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ class ChangeTrustOperationBuilder {
}

/// Set source account of this operation.
ChangeTrustOperationBuilder setSourceAccount(String? sourceAccount) {
checkNotNull(sourceAccount, "sourceAccount cannot be null");
_mSourceAccount = MuxedAccount(sourceAccount, null);
ChangeTrustOperationBuilder setSourceAccount(String sourceAccountId) {
checkNotNull(sourceAccountId, "sourceAccountId cannot be null");
_mSourceAccount = MuxedAccount.fromAccountId(sourceAccountId);
return this;
}

/// Set muxed source account of this operation.
ChangeTrustOperationBuilder setMuxedSourceAccount(MuxedAccount? sourceAccount) {
ChangeTrustOperationBuilder setMuxedSourceAccount(MuxedAccount sourceAccount) {
_mSourceAccount = checkNotNull(sourceAccount, "sourceAccount cannot be null");
return this;
}
Expand Down
10 changes: 5 additions & 5 deletions lib/src/claim_claimable_balance_operation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ class ClaimClaimableBalanceOperationBuilder {

ClaimClaimableBalanceOperationBuilder(this._balanceId);

/// Sets the source account for this operation represented by [sourceAccount].
ClaimClaimableBalanceOperationBuilder setSourceAccount(String sourceAccount) {
checkNotNull(sourceAccount, "sourceAccount cannot be null");
_mSourceAccount = MuxedAccount(sourceAccount, null);
/// Sets the source account for this operation represented by [sourceAccountId].
ClaimClaimableBalanceOperationBuilder setSourceAccount(String sourceAccountId) {
checkNotNull(sourceAccountId, "sourceAccountId cannot be null");
_mSourceAccount = MuxedAccount.fromAccountId(sourceAccountId);
return this;
}

/// Sets the muxed source account for this operation represented by [sourceAccountId].
/// Sets the muxed source account for this operation represented by [sourceAccount].
ClaimClaimableBalanceOperationBuilder setMuxedSourceAccount(MuxedAccount sourceAccount) {
_mSourceAccount = checkNotNull(sourceAccount, "sourceAccount cannot be null");
return this;
Expand Down
10 changes: 5 additions & 5 deletions lib/src/clawback_claimable_balance_operation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ class ClawbackClaimableBalanceOperationBuilder {

ClawbackClaimableBalanceOperationBuilder(this._balanceId);

/// Sets the source account for this operation represented by [sourceAccount].
ClawbackClaimableBalanceOperationBuilder setSourceAccount(String sourceAccount) {
checkNotNull(sourceAccount, "sourceAccount cannot be null");
_mSourceAccount = MuxedAccount(sourceAccount, null);
/// Sets the source account for this operation represented by [sourceAccountId].
ClawbackClaimableBalanceOperationBuilder setSourceAccount(String sourceAccountId) {
checkNotNull(sourceAccountId, "sourceAccountId cannot be null");
_mSourceAccount = MuxedAccount.fromAccountId(sourceAccountId);
return this;
}

/// Sets the muxed source account for this operation represented by [sourceAccountId].
/// Sets the muxed source account for this operation represented by [sourceAccount].
ClawbackClaimableBalanceOperationBuilder setMuxedSourceAccount(MuxedAccount sourceAccount) {
_mSourceAccount = checkNotNull(sourceAccount, "sourceAccount cannot be null");
return this;
Expand Down
8 changes: 5 additions & 3 deletions lib/src/clawback_operation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class ClawbackOperationBuilder {
/// [amount] Amount to be clawed back.
ClawbackOperationBuilder(Asset asset, String fromAccountId, String amount) {
this._asset = asset;
this._from = MuxedAccount(fromAccountId, null);
this._from = MuxedAccount.fromAccountId(fromAccountId);
this._amount = amount;
}

Expand All @@ -82,12 +82,14 @@ class ClawbackOperationBuilder {

/// Sets the source account for this operation.
ClawbackOperationBuilder setSourceAccount(String sourceAccountId) {
_mSourceAccount = MuxedAccount(sourceAccountId, null);
checkNotNull(sourceAccountId, "sourceAccountId cannot be null");
_mSourceAccount = MuxedAccount.fromAccountId(sourceAccountId);
return this;
}

/// Sets the muxed source account for this operation.
ClawbackOperationBuilder setMuxedSourceAccount(MuxedAccount sourceAccount) {
_mSourceAccount = sourceAccount;
_mSourceAccount = checkNotNull(sourceAccount, "sourceAccount cannot be null");
return this;
}

Expand Down
10 changes: 5 additions & 5 deletions lib/src/create_account_operation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ class CreateAccountOperationBuilder {
/// Creates a CreateAccount builder.
CreateAccountOperationBuilder(this._destination, this._startingBalance);

/// Sets the source account for this operation represented by [sourceAccount].
CreateAccountOperationBuilder setSourceAccount(String? sourceAccount) {
checkNotNull(sourceAccount, "sourceAccount cannot be null");
_mSourceAccount = MuxedAccount(sourceAccount, null);
/// Sets the source account for this operation represented by [sourceAccountId].
CreateAccountOperationBuilder setSourceAccount(String sourceAccountId) {
checkNotNull(sourceAccountId, "sourceAccountId cannot be null");
_mSourceAccount = MuxedAccount.fromAccountId(sourceAccountId);
return this;
}

/// Sets the muxed source account for this operation represented by [sourceAccountId].
/// Sets the muxed source account for this operation represented by [sourceAccount].
CreateAccountOperationBuilder setMuxedSourceAccount(MuxedAccount? sourceAccount) {
_mSourceAccount = checkNotNull(sourceAccount, "sourceAccount cannot be null");
return this;
Expand Down
10 changes: 5 additions & 5 deletions lib/src/create_claimable_balance_operation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ class CreateClaimableBalanceOperationBuilder {

CreateClaimableBalanceOperationBuilder(this._claimants, this._asset, this._amount);

/// Sets the source account for this operation represented by [sourceAccount].
CreateClaimableBalanceOperationBuilder setSourceAccount(String sourceAccount) {
checkNotNull(sourceAccount, "sourceAccount cannot be null");
_mSourceAccount = MuxedAccount(sourceAccount, null);
/// Sets the source account for this operation represented by [sourceAccountId].
CreateClaimableBalanceOperationBuilder setSourceAccount(String sourceAccountId) {
checkNotNull(sourceAccountId, "sourceAccountId cannot be null");
_mSourceAccount = MuxedAccount.fromAccountId(sourceAccountId);
return this;
}

/// Sets the muxed source account for this operation represented by [sourceAccountId].
/// Sets the muxed source account for this operation represented by [sourceAccount].
CreateClaimableBalanceOperationBuilder setMuxedSourceAccount(MuxedAccount sourceAccount) {
_mSourceAccount = checkNotNull(sourceAccount, "sourceAccount cannot be null");
return this;
Expand Down
8 changes: 4 additions & 4 deletions lib/src/create_passive_sell_offer_operation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ class CreatePassiveSellOfferOperationBuilder {
}

/// Sets the source account for this operation.
CreatePassiveSellOfferOperationBuilder setSourceAccount(String sourceAccount) {
checkNotNull(sourceAccount, "sourceAccount cannot be null");
_mSourceAccount = MuxedAccount(sourceAccount, null);
CreatePassiveSellOfferOperationBuilder setSourceAccount(String sourceAccountId) {
checkNotNull(sourceAccountId, "sourceAccountId cannot be null");
_mSourceAccount = MuxedAccount.fromAccountId(sourceAccountId);
return this;
}

/// Sets the muxed source account for this operation.
CreatePassiveSellOfferOperationBuilder setMuxedSourceAccount(MuxedAccount? sourceAccount) {
CreatePassiveSellOfferOperationBuilder setMuxedSourceAccount(MuxedAccount sourceAccount) {
_mSourceAccount = checkNotNull(sourceAccount, "sourceAccount cannot be null");
return this;
}
Expand Down
10 changes: 5 additions & 5 deletions lib/src/end_sponsoring_future_reserves_operation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ class EndSponsoringFutureReservesOperationBuilder {

EndSponsoringFutureReservesOperationBuilder();

/// Sets the source account for this operation represented by [sourceAccount].
EndSponsoringFutureReservesOperationBuilder setSourceAccount(String sourceAccount) {
checkNotNull(sourceAccount, "sourceAccount cannot be null");
_mSourceAccount = MuxedAccount(sourceAccount, null);
/// Sets the source account for this operation represented by [sourceAccountId].
EndSponsoringFutureReservesOperationBuilder setSourceAccount(String sourceAccountId) {
checkNotNull(sourceAccountId, "sourceAccountId cannot be null");
_mSourceAccount = MuxedAccount.fromAccountId(sourceAccountId);
return this;
}

/// Sets the muxed source account for this operation represented by [sourceAccountId].
/// Sets the muxed source account for this operation represented by [sourceAccount].
EndSponsoringFutureReservesOperationBuilder setMuxedSourceAccount(MuxedAccount sourceAccount) {
_mSourceAccount = checkNotNull(sourceAccount, "sourceAccount cannot be null");
return this;
Expand Down
10 changes: 5 additions & 5 deletions lib/src/liquidity_pool_deposit_operation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ class LiquidityPoolDepositOperationBuilder {
required this.minPrice,
required this.maxPrice});

/// Sets the source account for this operation represented by [sourceAccount].
LiquidityPoolDepositOperationBuilder setSourceAccount(String sourceAccount) {
checkNotNull(sourceAccount, "sourceAccount cannot be null");
_mSourceAccount = MuxedAccount(sourceAccount, null);
/// Sets the source account for this operation represented by [sourceAccountId].
LiquidityPoolDepositOperationBuilder setSourceAccount(String sourceAccountId) {
checkNotNull(sourceAccountId, "sourceAccountId cannot be null");
_mSourceAccount = MuxedAccount.fromAccountId(sourceAccountId);
return this;
}

/// Sets the muxed source account for this operation represented by [sourceAccountId].
/// Sets the muxed source account for this operation represented by [sourceAccount].
LiquidityPoolDepositOperationBuilder setMuxedSourceAccount(
MuxedAccount sourceAccount) {
_mSourceAccount =
Expand Down
8 changes: 4 additions & 4 deletions lib/src/liquidity_pool_withdraw_operation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ class LiquidityPoolWithdrawOperationBuilder {
required this.minAmountA,
required this.minAmountB});

/// Sets the source account for this operation represented by [sourceAccount].
LiquidityPoolWithdrawOperationBuilder setSourceAccount(String sourceAccount) {
checkNotNull(sourceAccount, "sourceAccount cannot be null");
_mSourceAccount = MuxedAccount(sourceAccount, null);
/// Sets the source account for this operation represented by [sourceAccountId].
LiquidityPoolWithdrawOperationBuilder setSourceAccount(String sourceAccountId) {
checkNotNull(sourceAccountId, "sourceAccountId cannot be null");
_mSourceAccount = MuxedAccount.fromAccountId(sourceAccountId);
return this;
}

Expand Down
8 changes: 4 additions & 4 deletions lib/src/manage_buy_offer_operation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ class ManageBuyOfferOperationBuilder {
}

/// Sets the source account for this operation.
ManageBuyOfferOperationBuilder setSourceAccount(String sourceAccount) {
checkNotNull(sourceAccount, "sourceAccount cannot be null");
_mSourceAccount = MuxedAccount(sourceAccount, null);
ManageBuyOfferOperationBuilder setSourceAccount(String sourceAccountId) {
checkNotNull(sourceAccountId, "sourceAccountId cannot be null");
_mSourceAccount = MuxedAccount.fromAccountId(sourceAccountId);
return this;
}

/// Sets the muxed source account for this operation.
ManageBuyOfferOperationBuilder setMuxedSourceAccount(MuxedAccount? sourceAccount) {
ManageBuyOfferOperationBuilder setMuxedSourceAccount(MuxedAccount sourceAccount) {
_mSourceAccount = checkNotNull(sourceAccount, "sourceAccount cannot be null");
return this;
}
Expand Down
8 changes: 4 additions & 4 deletions lib/src/manage_data_operation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ class ManageDataOperationBuilder {
}

/// Sets the source account for this operation.
ManageDataOperationBuilder setSourceAccount(String sourceAccount) {
checkNotNull(sourceAccount, "sourceAccount cannot be null");
_mSourceAccount = MuxedAccount(sourceAccount, null);
ManageDataOperationBuilder setSourceAccount(String sourceAccountId) {
checkNotNull(sourceAccountId, "sourceAccountId cannot be null");
_mSourceAccount = MuxedAccount.fromAccountId(sourceAccountId);
return this;
}

/// Sets the muxed source account for this operation.
ManageDataOperationBuilder setMuxedSourceAccount(MuxedAccount? sourceAccount) {
ManageDataOperationBuilder setMuxedSourceAccount(MuxedAccount sourceAccount) {
_mSourceAccount = checkNotNull(sourceAccount, "sourceAccount cannot be null");
return this;
}
Expand Down
Loading

0 comments on commit 15be58d

Please sign in to comment.