Skip to content

Commit

Permalink
Release/5.17.4 (#1180)
Browse files Browse the repository at this point in the history
* handles not ok cases that dont fall through to catch block, resets account sub storage

* removes the rpc urls passed to the backend, no longer needed after standalone move back to client side

* upgrades webpack and babel-loader

* regen yarn lock file

* pins redux toolkit version

* upgrades typescript, eslint and plugins

* use correct eslint version

* restore awaits on redux dispatches

* upgrades react and rect-dom to >=18

* updates test to waitFor dom nodes, react 18 batching updates

* upgrades stellar-sdk to 11.2.2

* Bugfix/allowlist native contract (#1179)

* add native contract to verified assets list

* do not show verification for XLM

* fix linting errors

* fix linting issue

* [Soroban] getTokenInvocationArgs amount should be bigint or number (#1181)

* [FEATURE] Token transfer summary in auth entry review (#1182)

* adds loading state for token details in token summary

* adds soroban token icon in token summary

* adds sender to transfer summary

* restore async message listener (#1183)

* clean up UI for showing "destination acct doesn't exist" warning (#1184)

* clean up UI for showing "destination acct doesn't exist" warning

* cleanup import order

* formats token amounts in transfer summary, removes token transfer constraint in history items for soroban ops

* adds fallback to raw value with warning when unable to fetch token details

* flips title boolean in NetworkForm to show correct title

* adds layout styles to form container to avoid button overflow in footer

* namespace FormContainer under AddAsset

* handle horizon error result codes (#1188)

* tweaks loading state in Account in order to avoid flicker between account changes

* plumbs setLoading through to account header in order to retain loading state when switchin accounts

* remvoes debug logs

* trying to clean up Amplitude Sentry errors a bit more (#1189)

* adds missing loading state for asset detail and transaction detail, fixes redundant title in error message

* adds asset error check in loading state

* labels status on send error when status is available

* tweaks op_no_trust error notification to not repeat title in body

* Added translations

* adds send option for soroban token from asset detail (#1193)

* [WIP] Feature/auto horizon error (#1195)

* first pass at adding horizon and generic notifications

* Added translations

* fix translations

* fix sentry errors

* update error type

* fix error

* show horizon error msg

* Bugfix/user notification typo (#1196)

* fix typo

* Added translations

* fix auto-scrolling in add trustlines views (#1199)

---------

Co-authored-by: Aristides Staffieri <[email protected]>
Co-authored-by: Cássio Marcos Goulart <[email protected]>
  • Loading branch information
3 people authored Mar 18, 2024
1 parent 5fef3ee commit db0eda2
Show file tree
Hide file tree
Showing 103 changed files with 4,084 additions and 963 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ module.exports = {
"@typescript-eslint/no-unused-vars": ["error"],
"no-console": "off",
"react/jsx-filename-extension": ["error", { extensions: [".tsx", ".jsx"] }],
"jsdoc/newline-after-description": "off",
"max-len": "off",
},
settings: {
"import/resolver": {
Expand Down
17 changes: 15 additions & 2 deletions @shared/api/helpers/stellarSdkServer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
import { FeeBumpTransaction, Horizon, Transaction } from "stellar-sdk";

interface HorizonError {
response: {
status: number;
};
}
const isHorizonError = (val: unknown): val is HorizonError =>
typeof val === "object" &&
val !== null &&
"response" in val &&
typeof val.response == "object" &&
val.response !== null &&
"status" in val.response;

export const getIsAllowHttp = (networkUrl: string) =>
!networkUrl.includes("https");

Expand All @@ -19,8 +32,8 @@ export const submitTx = async ({

try {
submittedTx = await server.submitTransaction(tx);
} catch (e) {
if (e.response.status === 504) {
} catch (e: unknown) {
if (isHorizonError(e) && e.response.status === 504) {
// in case of 504, keep retrying this tx until submission succeeds or we get a different error
// https://developers.stellar.org/api/errors/http-status-codes/horizon-specific/timeout
// https://developers.stellar.org/docs/encyclopedia/error-handling
Expand Down
15 changes: 9 additions & 6 deletions @shared/api/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
AccountBalancesInterface,
BalanceToMigrate,
Balances,
HorizonOperation,
MigratableAccount,
MigratedAccount,
Settings,
Expand Down Expand Up @@ -442,8 +441,6 @@ export const getAccountIndexerBalances = async (
const contractIds = await getTokenIds(networkDetails.network as NETWORKS);
const url = new URL(`${INDEXER_URL}/account-balances/${publicKey}`);
url.searchParams.append("network", networkDetails.network);
url.searchParams.append("horizon_url", networkDetails.networkUrl);
url.searchParams.append("soroban_url", networkDetails.sorobanRpcUrl!);
for (const id of contractIds) {
url.searchParams.append("contract_ids", id);
}
Expand All @@ -455,6 +452,11 @@ export const getAccountIndexerBalances = async (
throw new Error(_err);
}

if ("error" in data && (data?.error?.horizon || data?.error?.soroban)) {
const _err = JSON.stringify(data.error);
captureException(`Failed to fetch account balances - ${_err}`);
}

const formattedBalances = {} as NonNullable<
AccountBalancesInterface["balances"]
>;
Expand Down Expand Up @@ -666,14 +668,14 @@ export const getIndexerAccountHistory = async ({
}: {
publicKey: string;
networkDetails: NetworkDetails;
}) => {
}): Promise<Horizon.ServerApi.OperationRecord[]> => {
try {
const url = new URL(
`${INDEXER_URL}/account-history/${publicKey}?network=${networkDetails.network}&soroban_url=${networkDetails.sorobanRpcUrl}&horizon_url=${networkDetails.networkUrl}`,
`${INDEXER_URL}/account-history/${publicKey}?network=${networkDetails.network}`,
);
const response = await fetch(url.href);

const data = (await response.json()) as HorizonOperation;
const data = await response.json();
if (!response.ok) {
throw new Error(data);
}
Expand Down Expand Up @@ -1043,6 +1045,7 @@ export const saveSettings = async ({
isValidatingSafeAssetsEnabled: true,
isExperimentalModeEnabled: false,
isRpcHealthy: false,
userNotification: { enabled: false, message: "" },
settingsState: SettingsState.IDLE,
isSorobanPublicEnabled: false,
error: "",
Expand Down
2 changes: 1 addition & 1 deletion @shared/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"@stellar/wallet-sdk": "v0.11.0-beta.1",
"bignumber.js": "^9.1.1",
"prettier": "^2.0.5",
"stellar-sdk": "^11.1.0",
"stellar-sdk": "^11.2.2",
"typescript": "~3.7.2",
"webextension-polyfill": "^0.10.0"
},
Expand Down
10 changes: 9 additions & 1 deletion @shared/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface Response {
isExperimentalModeEnabled: boolean;
isSorobanPublicEnabled: boolean;
isRpcHealthy: boolean;
userNotification: UserNotification;
settingsState: SettingsState;
networkDetails: NetworkDetails;
sorobanRpcUrl: string;
Expand Down Expand Up @@ -149,10 +150,16 @@ export enum SettingsState {
SUCCESS = "SUCCESS",
}

export interface UserNotification {
enabled: boolean;
message: string;
}

export interface IndexerSettings {
settingsState: SettingsState;
isSorobanPublicEnabled: boolean;
isRpcHealthy: boolean;
userNotification: UserNotification;
}

export type Settings = {
Expand Down Expand Up @@ -196,14 +203,15 @@ export type AssetType = Types.AssetBalance | Types.NativeBalance | TokenBalance;
export type TokenBalances = SorobanBalance[];

/* eslint-disable camelcase */
export type HorizonOperation = any;
export type HorizonOperation = Horizon.ServerApi.OperationRecord;
/* eslint-enable camelcase */

export interface AccountBalancesInterface {
balances: Balances;
tokensWithNoBalance: string[];
isFunded: boolean | null;
subentryCount: number;
error?: { horizon: any; soroban: any };
}

export interface AccountHistoryInterface {
Expand Down
2 changes: 1 addition & 1 deletion @shared/constants/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"prettier": "@stellar/prettier-config",
"version": "1.0.0",
"dependencies": {
"stellar-sdk": "^11.1.0",
"stellar-sdk": "^11.2.2",
"typescript": "~3.7.2"
},
"devDependencies": {
Expand Down
11 changes: 11 additions & 0 deletions @shared/constants/soroban/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ export enum SorobanTokenInterface {
mint = "mint",
}

export type ArgsForTokenInvocation = {
from: string;
to: string;
amount: bigint | number;
};

export type TokenInvocationArgs = ArgsForTokenInvocation & {
fnName: SorobanTokenInterface;
contractId: string;
};

// TODO: can we generate this at build time using the cli TS generator? Also should we?
export interface SorobanToken {
// only currently holds fields we care about
Expand Down
2 changes: 1 addition & 1 deletion @shared/helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "1.0.0",
"dependencies": {
"bignumber.js": "^9.1.1",
"stellar-sdk": "^11.1.0",
"stellar-sdk": "^11.2.2",
"typescript": "~3.7.2"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"@docusaurus/preset-classic": "2.4.1",
"@stellar/freighter-api": "^2.0.0",
"clsx": "^1.1.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-is": "^16.13.1",
"styled-components": "^5.0.1"
},
Expand Down
1 change: 1 addition & 0 deletions extension/e2e-tests/onboarding.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ test.beforeEach(async ({ page, extensionId }) => {
});

test("Welcome page loads", async ({ page }) => {
await page.locator(".Welcome__column").waitFor();
await expect(
page.getByText("Welcome! Is this your first time using Freighter?"),
).toBeVisible();
Expand Down
11 changes: 6 additions & 5 deletions extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"dependencies": {
"@ledgerhq/hw-app-str": "^6.27.1",
"@ledgerhq/hw-transport-webusb": "^6.27.1",
"@reduxjs/toolkit": "^1.5.0",
"@reduxjs/toolkit": "1.5.0",
"@sentry/browser": "^6.0.0",
"@sentry/tracing": "^6.0.0",
"@shared/api": "1.0.0",
Expand All @@ -26,7 +26,7 @@
"@stellar-asset-lists/sdk": "^1.0.0",
"@stellar/design-system": "^1.1.2",
"@stellar/wallet-sdk": "v0.11.0-beta.1",
"@testing-library/react": "^10.4.8",
"@testing-library/react": "^14.2.1",
"@testing-library/user-event": "^7.1.2",
"@types/chrome": "^0.0.104",
"@types/history": "^4.7.7",
Expand All @@ -35,6 +35,7 @@
"@types/node": "^12.0.0",
"@types/qrcode.react": "^1.0.1",
"@types/react-copy-to-clipboard": "^4.3.0",
"@types/react-dom": "^18.2.20",
"@types/react-redux": "^7.1.7",
"@types/react-router-dom": "^5.1.3",
"@types/redux": "^3.6.0",
Expand Down Expand Up @@ -66,9 +67,9 @@
"prop-types": "^15.7.2",
"punycode": "^2.1.1",
"qrcode.react": "^1.0.0",
"react": "^17.0.2",
"react": "^18.2.0",
"react-copy-to-clipboard": "^5.0.2",
"react-dom": "^17.0.2",
"react-dom": "^18.2.0",
"react-i18next": "^11.18.0",
"react-redux": "^7.2.6",
"react-router-dom": "^5.3.0",
Expand All @@ -79,7 +80,7 @@
"ses": "^0.18.5",
"stellar-hd-wallet": "^0.0.10",
"stellar-identicon-js": "^1.0.0",
"stellar-sdk": "^11.1.0",
"stellar-sdk": "^11.2.2",
"svg-url-loader": "^5.0.0",
"tsconfig-paths-webpack-plugin": "^3.2.0",
"tslib": "2.0.0",
Expand Down
10 changes: 6 additions & 4 deletions extension/src/background/ducks/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export const logIn = createAsyncThunk<
allAccounts,
};
} catch (e) {
return thunkApi.rejectWithValue({ errorMessage: e.message || e });
const message = e instanceof Error ? e.message : JSON.stringify(e);
return thunkApi.rejectWithValue({ errorMessage: message });
}
});

Expand All @@ -39,22 +40,23 @@ export const setActivePublicKey = createAsyncThunk<
privateKey: "",
};
} catch (e) {
return thunkApi.rejectWithValue({ errorMessage: e.message || e });
const message = e instanceof Error ? e.message : JSON.stringify(e);
return thunkApi.rejectWithValue({ errorMessage: message });
}
});

const initialState = {
publicKey: "",
privateKey: "",
mnemonicPhrase: "",
allAccounts: [] as Array<Account>,
allAccounts: [] as Account[],
migratedMnemonicPhrase: "",
};

interface UiData {
publicKey: string;
mnemonicPhrase?: string;
allAccounts?: Array<Account>;
allAccounts?: Account[];
migratedMnemonicPhrase?: string;
}

Expand Down
Loading

0 comments on commit db0eda2

Please sign in to comment.