Skip to content

Commit

Permalink
Dependency updates (stellar#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
quietbits authored Oct 7, 2021
1 parent 9fb18e0 commit 7b18ac3
Show file tree
Hide file tree
Showing 7 changed files with 460 additions and 310 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
extends: ["@stellar/eslint-config"],
extends: ["@stellar/eslint-config", "plugin:import/typescript"],
rules: {
"no-console": "off",
"import/no-unresolved": "off",
Expand Down
40 changes: 20 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,33 @@
]
},
"dependencies": {
"@reduxjs/toolkit": "^1.6.1",
"@stellar/design-system": "^0.4.0",
"@stellar/frontend-helpers": "^2.0.1",
"@reduxjs/toolkit": "^1.6.2",
"@stellar/design-system": "^0.4.1",
"@stellar/frontend-helpers": "^2.1.3",
"@stellar/prettier-config": "^1.0.1",
"@stellar/wallet-sdk": "^0.5.0-rc.0",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^12.1.0",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^13.2.1",
"bignumber.js": "^9.0.1",
"crypto": "^1.0.1",
"dompurify": "^2.3.3",
"html-react-parser": "^1.2.7",
"html-react-parser": "^1.4.0",
"lodash": "^4.17.21",
"marked": "^3.0.4",
"node-sass": "^6.0.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-json-view": "^1.21.3",
"react-redux": "^7.2.5",
"react-router-dom": "^5.2.0",
"react-router-dom": "^5.3.0",
"react-scripts": "4.0.3",
"redux": "^4.1.1",
"stellar-sdk": "^9.0.0-beta.1",
"styled-components": "^5.3.0",
"styled-components": "^5.3.1",
"toml": "^3.0.0",
"tslib": "^2.3.0",
"typescript": "~4.3.5",
"tslib": "^2.3.1",
"typescript": "~4.4.3",
"web-vitals": "^2.1.0"
},
"scripts": {
Expand Down Expand Up @@ -76,33 +76,33 @@
"@stellar/eslint-config": "^2.1.1",
"@stellar/tsconfig": "^1.0.2",
"@types/jest": "^27.0.2",
"@types/lodash": "^4.14.173",
"@types/lodash": "^4.14.175",
"@types/marked": "^3.0.1",
"@types/node": "^16.9.4",
"@types/react": "^17.0.22",
"@types/node": "^16.10.3",
"@types/react": "^17.0.27",
"@types/react-copy-to-clipboard": "^5.0.1",
"@types/react-dom": "^17.0.9",
"@types/react-redux": "^7.1.18",
"@types/react-router-dom": "^5.1.9",
"@types/redux": "^3.6.0",
"@types/styled-components": "^5.1.14",
"@typescript-eslint/eslint-plugin": "^4.31.2",
"@typescript-eslint/parser": "^4.31.2",
"concurrently": "^6.2.1",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"concurrently": "^6.3.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-config-react": "^1.1.7",
"eslint-config-react-app": "^6.0.0",
"eslint-plugin-flowtype": "^6.1.0",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jsdoc": "^36.0.6",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-jsdoc": "^36.1.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-react": "^7.26.1",
"eslint-plugin-react-hooks": "^4.2.0",
"husky": "^7.0.2",
"lint-staged": "^11.1.2",
"prettier": "^2.3.2",
"lint-staged": "^11.2.0",
"prettier": "^2.4.1",
"pretty-quick": "^3.1.1"
}
}
15 changes: 10 additions & 5 deletions src/ducks/account.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createAsyncThunk, createSlice } from "@reduxjs/toolkit";
import { DataProvider, Types } from "@stellar/wallet-sdk";
import { getCatchError } from "@stellar/frontend-helpers";
import { Keypair } from "stellar-sdk";

import { RootState } from "config/store";
Expand Down Expand Up @@ -35,6 +36,10 @@ interface FetchAccountActionResponse extends AccountActionBaseResponse {
secretKey: string;
}

interface ResponseError extends Error {
isUnfunded?: boolean;
}

export const fetchAccountAction = createAsyncThunk<
FetchAccountActionResponse,
AccountKeyPair,
Expand Down Expand Up @@ -66,7 +71,9 @@ export const fetchAccountAction = createAsyncThunk<
balances: stellarAccount.balances,
networkUrl: networkConfig.url,
});
} catch (error) {
} catch (e) {
const error: ResponseError = getCatchError(e);

if (error.isUnfunded) {
log.instruction({ title: `Account is not funded` });

Expand Down Expand Up @@ -233,7 +240,5 @@ const accountSlice = createSlice({
export const accountSelector = (state: RootState) => state.account;

export const { reducer } = accountSlice;
export const {
resetAccountAction,
resetAccountStatusAction,
} = accountSlice.actions;
export const { resetAccountAction, resetAccountStatusAction } =
accountSlice.actions;
13 changes: 7 additions & 6 deletions src/ducks/untrustedAssets.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createAsyncThunk, createSlice } from "@reduxjs/toolkit";
import { getCatchError } from "@stellar/frontend-helpers";
import { RootState } from "config/store";
import { accountSelector } from "ducks/account";
import { settingsSelector } from "ducks/settings";
Expand Down Expand Up @@ -64,7 +65,8 @@ export const addUntrustedAssetAction = createAsyncThunk<
accountAssets: accountData?.balances,
networkUrl: getNetworkConfig(pubnet).url,
});
} catch (error) {
} catch (e) {
const error = getCatchError(e);
throw new Error(error.message);
}

Expand All @@ -74,7 +76,8 @@ export const addUntrustedAssetAction = createAsyncThunk<
}

return response;
} catch (error) {
} catch (e) {
const error = getCatchError(e);
log.error({ title: error.toString() });
return rejectWithValue({
errorString: getErrorMessage(error),
Expand Down Expand Up @@ -140,7 +143,5 @@ export const untrustedAssetsSelector = (state: RootState) =>
state.untrustedAssets;

export const { reducer } = untrustedAssetsSlice;
export const {
resetUntrustedAssetStatusAction,
resetUntrustedAssetsAction,
} = untrustedAssetsSlice.actions;
export const { resetUntrustedAssetStatusAction, resetUntrustedAssetsAction } =
untrustedAssetsSlice.actions;
8 changes: 6 additions & 2 deletions src/helpers/getErrorMessage.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
export const getErrorMessage = (error: Error) =>
error.message || error.toString();
import { getCatchError } from "@stellar/frontend-helpers";

export const getErrorMessage = (error: Error | unknown) => {
const e = getCatchError(error);
return e.message || e.toString();
};
25 changes: 21 additions & 4 deletions src/methods/sep31Send/sendPayment.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getCatchError } from "@stellar/frontend-helpers";
import {
Account,
Asset,
Expand All @@ -23,6 +24,21 @@ interface SendPaymentProps {
receiverAddress: string;
}

interface SendPaymentError extends Error {
result?: {
data: {
status: string;
extras: {
// eslint-disable-next-line camelcase
result_codes: {
transaction: string;
operations: string[];
};
};
};
};
}

export const sendPayment = async ({
secretKey,
assetCode,
Expand Down Expand Up @@ -110,10 +126,11 @@ const submitTransaction = async ({ tx, server }: { tx: any; server: any }) => {
try {
result = await server.submitTransaction(tx);
} catch (e) {
const data = e.result.data;
const status = data.status;
const txStatus = data.extras.result_codes.transaction;
const codes = data.extras.result_codes.operations;
const error: SendPaymentError = getCatchError(e);
const data = error?.result?.data;
const status = data?.status;
const txStatus = data?.extras.result_codes.transaction;
const codes = data?.extras.result_codes.operations;
const codesList = codes ? codes.join(", ") : "";

throw new Error(
Expand Down
Loading

0 comments on commit 7b18ac3

Please sign in to comment.