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

Commit

Permalink
v0.0.3-rc1 (#65)
Browse files Browse the repository at this point in the history
- Add changelog
- Upgrade stellar-sdk to a working 2.0.0 beta
- Bump version number
  • Loading branch information
Morley Zhi authored Jun 14, 2019
1 parent d6675c7 commit a70332d
Show file tree
Hide file tree
Showing 12 changed files with 106 additions and 62 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Changelog

**Breaking changes** will be clearly marked.

## v0.0.3

Initial (official) release! 🎉

This early prototype includes the following functionality:

- Fetching data from the Stellar network
- Encrypting and storing secret keys
- Helpers for stepping through anchor deposits and withdraws

Future versions will refine the library's API and add functionality.
6 changes: 3 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ module.exports = {

coveragePathIgnorePatterns: [
"node_modules",
"example",
"documentation",
"playground",
"build",
"dist",
],

modulePathIgnorePatterns: ["example", "documentation", "build", "dist"],
modulePathIgnorePatterns: ["documentation", "playground", "build", "dist"],

testPathIgnorePatterns: [
"node_modules",
"example",
"documentation",
"playground",
"build",
"dist",
],
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stellar/wallet-sdk",
"version": "0.0.2-rc1",
"version": "0.0.3-rc1",
"description": "Libraries to help you write Stellar-enabled wallets in Javascript",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand All @@ -9,7 +9,7 @@
"license": "Apache-2.0",
"prettier": "@stellar/prettier-config",
"peerDependencies": {
"stellar-sdk": "^1.x.x"
"stellar-sdk": "^2.x.x"
},
"scripts": {
"build": "tsc -p tsconfig.json",
Expand Down Expand Up @@ -67,7 +67,7 @@
"lodash": "^4.17.11",
"query-string": "^6.4.2",
"scrypt-async": "^2.0.1",
"stellar-sdk": "^1.0.2",
"stellar-sdk": "^2.0.0-beta.6",
"tweetnacl": "^1.0.1",
"tweetnacl-util": "^0.15.0",
"url": "^0.11.0"
Expand Down
9 changes: 0 additions & 9 deletions playground/src/App.test.js

This file was deleted.

23 changes: 14 additions & 9 deletions src/data/DataProvider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-ignore
import debounce from "lodash/debounce";
import { Server, StrKey } from "stellar-sdk";
import { Server, ServerApi, StrKey } from "stellar-sdk";

import {
Account,
Expand Down Expand Up @@ -166,10 +166,12 @@ export class DataProvider {
}

private async _processOpenOffers(
offers: Server.CollectionPage<Server.OfferRecord>,
offers: ServerApi.CollectionPage<ServerApi.OfferRecord>,
): Promise<Collection<Offer>> {
// find all offerids and check for trades of each
const tradeRequests = offers.records.map(({ id }) =>
const tradeRequests: Array<
Promise<ServerApi.CollectionPage<ServerApi.TradeRecord>>
> = offers.records.map(({ id }: { id: string }) =>
this.server
.trades()
.forOffer(id)
Expand All @@ -184,14 +186,17 @@ export class DataProvider {
{ publicKey: this.accountKey },
{
offers: offers.records,
tradeResponses: tradeResponses.map((res) => res.records),
tradeResponses: tradeResponses.map(
(res: ServerApi.CollectionPage<ServerApi.TradeRecord>) =>
res.records,
),
},
),
};
}

private async _processTrades(
trades: Server.CollectionPage<Server.TradeRecord>,
trades: ServerApi.CollectionPage<ServerApi.TradeRecord>,
): Promise<Collection<Trade>> {
return {
next: () => trades.next().then(this._processTrades),
Expand All @@ -204,10 +209,10 @@ export class DataProvider {
}

private async _processTransfers(
transfers: Server.CollectionPage<
| Server.PaymentOperationRecord
| Server.CreateAccountOperationRecord
| Server.PathPaymentOperationRecord
transfers: ServerApi.CollectionPage<
| ServerApi.PaymentOperationRecord
| ServerApi.CreateAccountOperationRecord
| ServerApi.PathPaymentOperationRecord
>,
): Promise<Collection<Transfer>> {
return {
Expand Down
4 changes: 2 additions & 2 deletions src/data/makeDisplayableBalances.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import BigNumber from "bignumber.js";
import { Horizon, Server } from "stellar-sdk";
import { Horizon, ServerApi } from "stellar-sdk";

import { BalanceMap } from "../types";

Expand All @@ -8,7 +8,7 @@ import { BASE_RESERVE, BASE_RESERVE_MIN_COUNT } from "../constants/stellar";
import { getBalanceIdentifier } from "./";

export function makeDisplayableBalances(
accountDetails: Server.AccountRecord,
accountDetails: ServerApi.AccountRecord,
): BalanceMap {
const { balances, subentry_count } = accountDetails;

Expand Down
8 changes: 4 additions & 4 deletions src/data/makeDisplayableOffers.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import BigNumber from "bignumber.js";
import flatten from "lodash/flatten";
import { AssetType } from "stellar-base";
import { Server } from "stellar-sdk";
import { ServerApi } from "stellar-sdk";

import { makeDisplayableTrades } from "./makeDisplayableTrades";

import { Account, Offer, Token, Trade } from "../types";

export type TradeCollection = Server.TradeRecord[];
export type TradeCollection = ServerApi.TradeRecord[];

export interface DisplayableOffersParams {
offers: Server.OfferRecord[];
offers: ServerApi.OfferRecord[];
tradeResponses: TradeCollection[];
}

Expand Down Expand Up @@ -42,7 +42,7 @@ export function makeDisplayableOffers(
}, {});

return offers.map(
(offer: Server.OfferRecord): Offer => {
(offer: ServerApi.OfferRecord): Offer => {
const {
id,
selling,
Expand Down
6 changes: 3 additions & 3 deletions src/data/makeDisplayableTrades.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import BigNumber from "bignumber.js";
import { AssetType } from "stellar-base";
import { Server } from "stellar-sdk";
import { ServerApi } from "stellar-sdk";

import { Account, Token, Trade } from "../types";

Expand Down Expand Up @@ -46,11 +46,11 @@ import { Account, Token, Trade } from "../types";

export function makeDisplayableTrades(
subjectAccount: Account,
trades: Server.TradeRecord[],
trades: ServerApi.TradeRecord[],
): Trade[] {
// make a map of trades to their original offerids
return trades.map(
(trade: Server.TradeRecord): Trade => {
(trade: ServerApi.TradeRecord): Trade => {
const base = {
publicKey: trade.base_account,
};
Expand Down
20 changes: 11 additions & 9 deletions src/data/makeDisplayableTransfers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import BigNumber from "bignumber.js";
import { AssetType } from "stellar-base";
import { Server } from "stellar-sdk";
import { ServerApi } from "stellar-sdk";

import { Account, Token, Transfer } from "../types";

Expand Down Expand Up @@ -45,28 +45,30 @@ import { Account, Token, Transfer } from "../types";
},
*/

function isCreateAccount(obj: any): obj is Server.CreateAccountOperationRecord {
function isCreateAccount(
obj: any,
): obj is ServerApi.CreateAccountOperationRecord {
return obj.type === "create_account";
}

function isPathPayment(obj: any): obj is Server.PathPaymentOperationRecord {
function isPathPayment(obj: any): obj is ServerApi.PathPaymentOperationRecord {
return obj.type === "path_payment";
}

export function makeDisplayableTransfers(
subjectAccount: Account,
payments: Array<
| Server.CreateAccountOperationRecord
| Server.PaymentOperationRecord
| Server.PathPaymentOperationRecord
| ServerApi.CreateAccountOperationRecord
| ServerApi.PaymentOperationRecord
| ServerApi.PathPaymentOperationRecord
>,
): Transfer[] {
return payments.map(
(
payment:
| Server.CreateAccountOperationRecord
| Server.PaymentOperationRecord
| Server.PathPaymentOperationRecord,
| ServerApi.CreateAccountOperationRecord
| ServerApi.PaymentOperationRecord
| ServerApi.PathPaymentOperationRecord,
): Transfer => {
const isRecipient = payment.source_account !== subjectAccount.publicKey;

Expand Down
4 changes: 2 additions & 2 deletions src/types/data.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import BigNumber from "bignumber.js";
import { AssetType } from "stellar-base";
import { Horizon, Server } from "stellar-sdk";
import { Horizon, ServerApi } from "stellar-sdk";
import { EffectType } from "../constants/data";

export type TradeId = string;
Expand Down Expand Up @@ -142,7 +142,7 @@ export interface AccountDetails {
inflationDestination?: string;
lastModifiedLedger: number;
thresholds: Horizon.AccountThresholds;
signers: Horizon.AccountSigner[];
signers: ServerApi.AccountRecordSigners[];
flags: Horizon.Flags;
balances: BalanceMap;
}
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
"lib": ["es2015", "dom"],
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"outDir": "dist",
"target": "es5"
},
"include": ["src"],
"exclude": [
"node_modules",
"dist",
"examples/src/js-stellar-wallets",
"playground/src/@stellar",
"documentation/src/docs.json",
"src/fixtures"
],
Expand Down
Loading

0 comments on commit a70332d

Please sign in to comment.