Update Dart documentation

This commit is contained in:
Erdem Yerebasmaz
2023-10-04 21:34:29 +03:00
parent df7e639c5d
commit 031bab5a0a
6 changed files with 48 additions and 15 deletions

View File

@@ -68,7 +68,8 @@ try {
```dart ```dart
try { try {
BuyBitcoinResponse buyBitcoinResponse = buyBitcoin( BuyBitcoinResponse buyBitcoinResponse = buyBitcoin(
reqData: BuyBitcoinRequest(provider: BuyBitcoinProvider.Moonpay, reqData: BuyBitcoinRequest(
provider: BuyBitcoinProvider.Moonpay,
), ),
); );
} catch { } catch {

View File

@@ -109,7 +109,7 @@ try {
```dart ```dart
try { try {
Map<String, Rate> fiatRatesMap = fetchFiatRates(); Map<String, Rate> fiatRatesMap = await fetchFiatRates();
// print your desired rate // print your desired rate
print(fiatRatesMap["USD"]?.value); print(fiatRatesMap["USD"]?.value);
} catch(e) { } catch(e) {
@@ -201,7 +201,31 @@ fun fiatCurrenciesAndRate(): Map<FiatCurrency, Rate> = try {
<section> <section>
```dart ```dart
// TODO Future<Map<FiatCurrency, Rate>> fiatCurrenciesAndRate() async {
try {
List<FiatCurrency> fiatCurrencies = await _breezLib.listFiatCurrencies();
Map<String, Rate> fiatRates = await _breezLib.fetchFiatRates();
var sorted = fiatCurrencies.toList();
sorted.sort((f1, f2) {
return f1.id.compareTo(f2.id);
});
Map<FiatCurrency, Rate> result = {};
for (var currency in sorted) {
var rate = fiatRates[currency.id];
if (rate != null) {
result[currency] = rate;
}
}
return result;
} catch (e) {
// Handle error
return {};
}
}
``` ```
</section> </section>

View File

@@ -75,7 +75,7 @@ try {
```dart ```dart
try { try {
ReceivePaymentResponse invoice = await receivePayment( ReceivePaymentResponse invoice = await receivePayment(
reqData: ReceivePaymentRequestData( reqData: ReceivePaymentRequest(
amountSats: 3000, amountSats: 3000,
description: "Invoice for 3000 sats", description: "Invoice for 3000 sats",
), ),

View File

@@ -68,7 +68,9 @@ try {
```dart ```dart
try { try {
SwapInfo swapInfo = await receiveOnchain(ReceiveOnchainRequest()); SwapInfo swapInfo = await receiveOnchain(
reqData: ReceiveOnchainRequest(),
);
// Send your funds to the below bitcoin address // Send your funds to the below bitcoin address
String address = swapInfo.bitcoinAddress; String address = swapInfo.bitcoinAddress;
@@ -175,7 +177,7 @@ try {
```dart ```dart
try { try {
SwapInfo? swapInfo = await inProgressSwap() SwapInfo? swapInfo = await inProgressSwap();
} catch (error) { } catch (error) {
// handle error // handle error
} }
@@ -507,7 +509,8 @@ try {
```dart ```dart
int amountMsats = <amount msats> int amountMsats = <amount msats>
try { try {
int channelFees = openChannelFee(OpenChannelFeeRequest( int channelFees = openChannelFee(
req: OpenChannelFeeRequest(
amountMsats: amountMsats, amountMsats: amountMsats,
), ),
); );

View File

@@ -275,6 +275,7 @@ try {
String destinationAddress = "bc1.."; String destinationAddress = "bc1..";
int amountSat = <amount>; int amountSat = <amount>;
int satPerVbyte = <fee rate> int satPerVbyte = <fee rate>
ReverseSwapPairInfo currentFees = <current reverse swap fees>
try { try {
ReverseSwapInfo reverseSwapInfo = await sendOnchain( ReverseSwapInfo reverseSwapInfo = await sendOnchain(
amountSat: amountSat, amountSat: amountSat,

View File

@@ -63,7 +63,11 @@ try {
```dart ```dart
try { try {
StaticBackupResponse backupData = await staticBackup(request: StaticBackupRequest(workingDir: "<working directory>")); StaticBackupResponse backupData = await staticBackup(
request: StaticBackupRequest
workingDir: "<working directory>",
),
);
} catch (error) { } catch (error) {
// handle error // handle error
} }