Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
piyalbasu committed Jul 12, 2023
1 parent 0e6c79a commit c3ca86a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
43 changes: 28 additions & 15 deletions docs/building-apps/wallet/intro.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,13 @@ val walletCustom = Wallet(
)
```

```typescript
const customClient: AxiosInstance = axios.create({
baseURL: "https://some-url.com/api",
timeout: 1000,
headers: { "X-Custom-Header": "foobar" },
});
let appConfig = new ApplicationConfiguration(DefaultSigner, customClient);
let wal = new Wallet({
stellarConfiguration: StellarConfiguration.TestNet(),
applicationConfiguration: appConfig,
});
```

</CodeExample>

### Configuring the Client

The wallet SDK uses the [ktor client](https://ktor.io/docs/getting-started-ktor-client.html) for all network requests (excluding Horizon, where the Stellar SDK's HTTP client is used). Currently, the okhttp engine is configured to be used with the client. You can read more about how to configure the ktor client [here](https://ktor.io/docs/create-client.html#configure-client).
The Kotlin wallet SDK uses the [ktor client](https://ktor.io/docs/getting-started-ktor-client.html) for all network requests (excluding Horizon, where the Stellar SDK's HTTP client is used). Currently, the okhttp engine is configured to be used with the client. You can read more about how to configure the ktor client [here](https://ktor.io/docs/create-client.html#configure-client).

The Typescript wallet SDK uses the [axios client](https://axios-http.com/docs/intro) for all network requests (excluding Horizon, where the Stellar SDK's HTTP client is used). You can read more about how to configure the axios client [here](https://axios-http.com/docs/instance).

For example, the client can be globally configured:

Expand All @@ -105,9 +94,22 @@ val walletCustomClient =
)
```

```typescript
const customClient: AxiosInstance = axios.create({
timeout: 1000,
});
let appConfig = new ApplicationConfiguration(DefaultSigner, customClient);
let wal = new Wallet({
stellarConfiguration: StellarConfiguration.TestNet(),
applicationConfiguration: appConfig,
});
```

</CodeExample>

This code will set the connect timeout to ten seconds via the [okhttp configuration](https://ktor.io/docs/http-client-engines.html#okhttp) and also installs the [retry plugin](https://ktor.io/docs/client-retry.html). You can also specify client configuration for specific wallet SDK classes.
This Kotlin code will set the connect timeout to ten seconds via the [okhttp configuration](https://ktor.io/docs/http-client-engines.html#okhttp) and also installs the [retry plugin](https://ktor.io/docs/client-retry.html). You can also specify client configuration for specific wallet SDK classes.

In Typescript, we can use axios to [configure](https://axios-http.com/docs/req_config) the timeout in milliseconds.

For example, to change connect timeout when connecting to some anchor server:

Expand All @@ -120,6 +122,17 @@ val anchorCustomClient =
}
```

```typescript
const customClient: AxiosInstance = axios.create({
timeout: 10000,
});
let appConfig = new ApplicationConfiguration(DefaultSigner, customClient);
let wal = new Wallet({
stellarConfiguration: StellarConfiguration.TestNet(),
applicationConfiguration: appConfig,
});
```

</CodeExample>

### Closing Resources
Expand Down
5 changes: 3 additions & 2 deletions docs/building-apps/wallet/sep24.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ val sep24 = anchor.sep24()
```

```typescript
let sep24 = await anchor.getInfo();
let sep24 = await anchor.interactive();
```

</CodeExample>
Expand Down Expand Up @@ -191,6 +191,7 @@ suspend fun depositDifferentAccount(): InteractiveFlowResponse {

```typescript
const recipientAccount = "G...";
// TODO: Add `memo` param when the SDK supports it
const depositDifferentAccount = async (): Promise<InteractiveFlowResponse> => {
return anchor.interactive().deposit({
accountAddress: accountKp.publicKey(),
Expand Down Expand Up @@ -325,7 +326,7 @@ val transactions = sep24.getTransactionsForAsset(asset, token)
```

```typescript
const transactions = await anchor.getHistory({
const transactions = await anchor.getTransactionsForAsset({
authToken,
assetCode,
});
Expand Down

0 comments on commit c3ca86a

Please sign in to comment.