Skip to content
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

update wallet docs for flutter #262

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/building-apps/wallet/component/dart/install.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { CodeExample } from "@site/src/components/CodeExample";

<CodeExample>

```dart
// pubspec.yaml
stellar_wallet_flutter_sdk: ^0.0.2
stellar_flutter_sdk: ^1.6.9
```

</CodeExample>

You can get the latest available version on the [project GitHub page](https://github.com/Soneso/stellar_wallet_flutter_sdk)
23 changes: 20 additions & 3 deletions docs/building-apps/wallet/intro.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { WalletCodeExample as CodeExample } from "@site/src/components/WalletCod
import Header from "./component/header.mdx";
import KtInstall from "./component/kt/install.mdx";
import TsInstall from "./component/ts/install.mdx";
import DartInstall from "./component/dart/install.mdx";
import KtHttpConfig from "./component/kt/httpConfig.mdx";
import KtConfigClient from "./component/kt/configClient.mdx";
import TsConfigClient from "./component/ts/configClient.mdx";
Expand All @@ -18,7 +19,11 @@ import TsConfigClient from "./component/ts/configClient.mdx";

First, you need to add the SDK dependency to your project.

<LanguageSpecific kt={<KtInstall />} ts={<TsInstall />} />
<LanguageSpecific
kt={<KtInstall />}
ts={<TsInstall />}
dart={<DartInstall />}
/>

## Working with the SDK

Expand All @@ -34,8 +39,8 @@ val wallet = Wallet(StellarConfiguration.Testnet)
let wallet = walletSdk.Wallet.TestNet();
```

```flutter
final StellarSDK sdk = StellarSDK.TESTNET;
```dart
var wallet = Wallet(StellarConfiguration.testNet);
```

</CodeExample>
Expand All @@ -54,6 +59,10 @@ let wallet = new Wallet({
});
```

```dart
var wallet = Wallet(StellarConfiguration.publicNet);
```

</CodeExample>

<LanguageSpecific kt={<KtHttpConfig />} />
Expand Down Expand Up @@ -102,6 +111,10 @@ val anchor = wallet.anchor("https://testanchor.stellar.org")
let anchor = wallet.anchor({ homeDomain: "testanchor.stellar.org" });
```

```dart
var anchor = wallet.anchor("testanchor.stellar.org")
```

</CodeExample>

And the most basic interaction of fetching a [SEP-1]: Stellar Info File:
Expand All @@ -118,6 +131,10 @@ suspend fun anchorToml(): TomlInfo {
let resp = await anchor.sep1();
```

```dart
var resp = await anchor.sep1();
```

</CodeExample>

The anchor class also supports [SEP-10]: Stellar Authentication and [SEP-24]: Hosted Deposit and Withdrawal features.
Expand Down
41 changes: 19 additions & 22 deletions docs/building-apps/wallet/sep10.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ let anchor = wallet.anchor({ homeDomain: "https://testanchor.stellar.org" });
```

```dart
final webAuth = WebAuth.fromDomain("https://testanchor.stellar.org", Network.TESTNET);
final anchor = wallet.anchor("testanchor.stellar.org");
```

</CodeExample>
Expand All @@ -69,9 +69,10 @@ const authToken = await sep10.authenticate({ accountKp: authKey });
```

```dart
KeyPair authKey = KeyPair.fromSecretSeed("my secret key");
String accountId = authKey.accountId;
String jwtToken = await webAuth.jwtToken(accountId, [authKey]);
final authKey = SigningKeyPair.fromSecret("my secret key");
final sep10 = await anchor.sep10();

final authToken = await sep10.authenticate(authKey);
```

</CodeExample>
Expand Down Expand Up @@ -140,25 +141,11 @@ const getAuthToken = async () => {
```

```dart
// delegate client signing
String jwtToken = await webAuth.jwtToken(
userAccountId,
[userKeyPair],
clientDomain: "demo-wallet-server.stellar.org",
clientDomainSigningDelegate: (transaction) async {
// delegate client signing e.g.:
return myWalletSigner.signTransaction(transaction, clientKeyPair);
}
);

// alternatively let the SDK also sign with the clientKeyPair
String jwtToken = await webAuth.jwtToken(
userAccountId,
[userKeyPair],
clientDomain: "demo-wallet-server.stellar.org",
clientDomainAccountKeyPair: clientKeyPair
);
final signer = DomainSigner("https://demo-wallet-server.stellar.org/sign");
final sep10 = await anchor.sep10();

final authToken = await sep10.authenticate(userKeyPair,
clientDomainSigner: signer, clientDomain: "demo-wallet-server.stellar.org");
```

</CodeExample>
Expand Down Expand Up @@ -202,6 +189,16 @@ const demoWalletSigner: WalletSigner = {
};
```

```dart
Map<String, String> requestHeaders = {
"Authorization": "Bearer $token",
"Content-Type": "application/json"
};

var signer = DomainSigner("https://demo-wallet-server.stellar.org/sign",
requestHeaders: requestHeaders);
```

</CodeExample>

[//]: # "TODO: update after WAL-882 is completed"
Expand Down
Loading