Skip to content

Commit

Permalink
add quote to flutter wallet sdk (#296)
Browse files Browse the repository at this point in the history
* add recovery to flutter wallet sdk

* add stellar to flutter wallet sdk

* update flutter wallet sdk version nr

* add quote to flutter wallet sdk

* fix sep-38 code style issues
  • Loading branch information
christian-rogobete authored Feb 22, 2024
1 parent a6bdd92 commit 96ea773
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/building-apps/wallet/component/dart/install.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { CodeExample } from "@site/src/components/CodeExample";

```dart
// pubspec.yaml
stellar_wallet_flutter_sdk: ^0.1.0
stellar_flutter_sdk: ^1.7.1
stellar_wallet_flutter_sdk: ^0.2.0
stellar_flutter_sdk: ^1.7.4
```

</CodeExample>
Expand Down
46 changes: 45 additions & 1 deletion docs/building-apps/wallet/sep38.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { LanguageSpecific } from "@site/src/components/LanguageSpecific";
import { WalletCodeExample as CodeExample } from "@site/src/components/WalletCodeExample";
import Header from "./component/header.mdx";

<Header WIPLangs={["kotlin", "dart"]} />
<Header WIPLangs={["kotlin"]} />

The [SEP-38] standard defines a way for anchors to provide quotes for the exchange of an off-chain asset and a different on-chain asset, and vice versa. Quotes may be [indicative](https://www.investopedia.com/terms/i/indicativequote.asp) or [firm](https://www.investopedia.com/terms/f/firmquote.asp) ones. When either is used is explained in the sections below.

Expand All @@ -28,6 +28,14 @@ const authToken = await auth.authenticate({ accountKp });
const sep38 = anchor.sep38(authToken);
```

```dart
var accountKp = ... // our account keypair
var auth = await anchor.sep10();
var authToken = await auth.authenticate(accountKp);
var sep38 = anchor.sep38(authToken: authToken);
```

</CodeExample>

## Get Anchor Information
Expand All @@ -40,6 +48,10 @@ First, let's get information about the anchor's support for [SEP-38]. The respon
const resp = await sep38.info();
```

```dart
var resp = await sep38.info();
```

</CodeExample>

For example a response will look like this. The asset identifiers are described below in [Asset Identification Format](#asset-identification-format).
Expand Down Expand Up @@ -99,6 +111,13 @@ const resp = await sep38.prices({
});
```

```dart
var resp = await sep38.prices(
sellAsset: "iso4217:USD",
sellAmount: "5",
);
```

</CodeExample>

The response gives the asset prices for exchanging the requested sell asset. For example, a response look like this:
Expand Down Expand Up @@ -135,6 +154,16 @@ const resp = await sep38.price({
});
```

```dart
var resp = await sep38.price(
sellAsset: "iso4217:USD",
buyAsset:
"stellar:SRT:GCDNJUBQSX7AJWLJACMJ7I4BC3Z47BQUTMHEICZLE6MU4KQBRYG5JY6B",
sellAmount: "5",
context: "sep6",
);
```

</CodeExample>

The response gives information for exchanging these assets. For example, a response will look like this:
Expand All @@ -161,6 +190,16 @@ const requestResp = await sep38.requestQuote({
});
```

```dart
var requestResp = await sep38.requestQuote(
sellAsset: "iso4217:USD",
buyAsset:
"stellar:SRT:GCDNJUBQSX7AJWLJACMJ7I4BC3Z47BQUTMHEICZLE6MU4KQBRYG5JY6B",
sellAmount: "5",
context: "sep6",
);
```

</CodeExample>

However now the response gives an `id` that we can use to identify the quote. The `expires_at` field tells us how long the anchor will wait to receive funds for this quote.
Expand Down Expand Up @@ -190,6 +229,11 @@ const quoteId = requestResp.id;
const getResp = await sep38.getQuote(quoteId);
```

```dart
var quoteId = requestResp.id;
var getResp = await sep38.getQuote(quoteId);
```

</CodeExample>

The response should match the one given from `.requestQuote()` we made earlier.
Expand Down

0 comments on commit 96ea773

Please sign in to comment.