Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
Support language codes (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
Morley Zhi authored Mar 11, 2020
1 parent ba51675 commit bb0e4f3
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
transfer-related fetches.
- [Transfers] Make the transactions fetcher more resilient to invalid responses
from /transactions.
- [Transfers] `DepositProvider` and `WithdrawProvider` instantiation now takes a
third, optional parameter for
[ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) language codes. The
default value is "en".

## [v0.0.9-rc.1](https://github.com/stellar/js-stellar-wallets/compare/v0.0.8-rc.1...v0.0.9-rc.1)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stellar/wallet-sdk",
"version": "0.0.9-rc.4",
"version": "0.0.9-rc.5",
"description": "Libraries to help you write Stellar-enabled wallets in Javascript",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
10 changes: 8 additions & 2 deletions src/transfers/DepositProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,12 @@ export class DepositProvider extends TransferProvider {
public response?: TransferResponse;
public request?: DepositRequest;

constructor(transferServer: string, account: string) {
super(transferServer, account, "deposit");
constructor(
transferServer: string,
account: string,
language: string = "en",
) {
super(transferServer, account, language, "deposit");
}

/**
Expand Down Expand Up @@ -120,6 +124,8 @@ export class DepositProvider extends TransferProvider {
body.append(key, request[key]);
});

body.append("lang", this.language);

response = await fetch(
`${this.transferServer}/transactions/deposit/interactive`,
{
Expand Down
7 changes: 6 additions & 1 deletion src/transfers/TransferProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export abstract class TransferProvider {
public transferServer: string;
public operation: "deposit" | "withdraw";
public account: string;
public language: string;
public info?: Info;
public authToken?: string;

Expand All @@ -85,6 +86,7 @@ export abstract class TransferProvider {
constructor(
transferServer: string,
account: string,
language: string,
operation: "deposit" | "withdraw",
) {
if (!transferServer) {
Expand All @@ -103,6 +105,7 @@ export abstract class TransferProvider {
this.transferServer = transferServer.replace(/\/$/, "");
this.operation = operation;
this.account = account;
this.language = language;

this._watchOneTransactionRegistry = {};
this._watchAllTransactionsRegistry = {};
Expand All @@ -112,7 +115,9 @@ export abstract class TransferProvider {
}

protected async fetchInfo(): Promise<Info> {
const response = await fetch(`${this.transferServer}/info`);
const response = await fetch(
`${this.transferServer}/info?lang=${this.language}`,
);

if (!response.ok) {
try {
Expand Down
10 changes: 8 additions & 2 deletions src/transfers/WithdrawProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,12 @@ export class WithdrawProvider extends TransferProvider {
public response?: TransferResponse;
public request?: WithdrawRequest;

constructor(transferServer: string, account: string) {
super(transferServer, account, "withdraw");
constructor(
transferServer: string,
account: string,
language: string = "en",
) {
super(transferServer, account, language, "withdraw");
}

/**
Expand Down Expand Up @@ -113,6 +117,8 @@ export class WithdrawProvider extends TransferProvider {
body.append(key, request[key]);
});

body.append("lang", this.language);

response = await fetch(
`${this.transferServer}/transactions/withdraw/interactive`,
{
Expand Down

0 comments on commit bb0e4f3

Please sign in to comment.