Add saved payout destination UX and service contracts (#54)

This commit is contained in:
Stephan D committed 2026-10-16 12:01:33 +02:00
1 parent a5689876ff
commit 24af794112
49 files changed
+4687 -62

No files matched your search

@@ -1,3 +1,4 @@
import '../destinations/transport.dart';
import '../models/wallet.dart';
class AccountDTO {
@@ -23,11 +24,13 @@ class RequestDTO {
this.source,
this.destination,
this.amount,
this.recipient,
);
this.recipient, {
this.payoutInput,
});
final String kind, source, recipient;
final String? destination;
final int amount;
final DestinationInputDTO? payoutInput;
}
class QuoteDTO {
@@ -39,12 +42,16 @@ class QuoteDTO {
this.credit,
this.expires,
this.numerator,
this.denominator,
);
this.denominator, {
this.payoutSnapshot,
this.payoutTerms,
});
final String id;
final RequestDTO request;
final int fee, debit, credit, numerator, denominator;
final DateTime expires;
final DestinationDTO? payoutSnapshot;
final PayoutTermsDTO? payoutTerms;
}
class OperationDTO {
@@ -78,14 +85,28 @@ abstract final class WalletMapper {
payoutLabel: d.payoutLabel,
canFund: d.canFund,
);
static RequestDTO request(TransferRequest r) =>
RequestDTO(r.kind.name, r.source, r.destination, r.amount, r.recipient);
static RequestDTO request(
TransferRequest r, {
bool includePayoutInput = true,
}) => RequestDTO(
r.kind.name,
r.source,
r.destination,
r.amount,
r.recipient,
payoutInput: !includePayoutInput || r.payoutDestination == null
? null
: DestinationInputMapper.toDTO(r.payoutDestination!),
);
static TransferRequest fromRequest(RequestDTO d) => TransferRequest(
kind: TransferKind.values.byName(d.kind),
source: d.source,
destination: d.destination,
amount: d.amount,
recipient: d.recipient,
payoutDestination: d.payoutInput == null
? null
: DestinationInputMapper.fromDTO(d.payoutInput!),
);
static Quote quote(QuoteDTO d) => Quote(
id: d.id,
@@ -96,6 +117,17 @@ abstract final class WalletMapper {
expiresAt: d.expires,
rateNumerator: d.numerator,
rateDenominator: d.denominator,
payoutTerms: d.payoutTerms == null
? null
: PayoutTerms(
d.payoutTerms!.amount,
d.payoutTerms!.precision,
d.payoutTerms!.assetLabel,
d.payoutTerms!.expectedSeconds,
),
payoutSnapshot: d.payoutSnapshot == null
? null
: DestinationMapper.fromDTO(d.payoutSnapshot!),
);
static WalletOperation operation(OperationDTO d) => WalletOperation(
id: d.id,
@@ -105,3 +137,14 @@ abstract final class WalletMapper {
);
static AccountProfile profile(ProfileDTO dto) => AccountProfile(dto.locale);
}
class PayoutTermsDTO {
const PayoutTermsDTO(
this.amount,
this.precision,
this.assetLabel,
this.expectedSeconds,
);
final int amount, precision, expectedSeconds;
final String assetLabel;
}