Skip to content

Commit

Permalink
Release/5.17.0 (#1127)
Browse files Browse the repository at this point in the history
* fix error in string translation (#1125)

* adds invoker auth warning in signing flow

* Added translations

* update variant and copy for invoker auth warning

* enabling mainnet access to Soroban (#1123)

* splits logic for auth entry invocations to account for contract creation (#1126)

* fixes display for scvBytes in preview helper

* Feature/token allowlist copy update (#1132)

* legal copy updates for allowlist warnings

* Added translations

* match style of destination acct not found error

* update account creation warning copy

* Feature/token allowlist copy update (#1133)

* legal copy updates for allowlist warnings

* Added translations

* match style of destination acct not found error

* update account creation warning copy

* add space

* change link styling to bold instead of underline (#1134)

---------

Co-authored-by: Aristides Staffieri <aristides.staffieri@stellar.org>
  • Loading branch information
piyalbasu and aristidesstaffieri authored Feb 22, 2024
1 parent 40dcb32 commit bf18d61
Show file tree
Hide file tree
Showing 20 changed files with 357 additions and 86 deletions.
3 changes: 2 additions & 1 deletion @shared/api/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
MigratableAccount,
MigratedAccount,
Settings,
IndexerSettings,
} from "./types";
import {
MAINNET_NETWORK_DETAILS,
Expand Down Expand Up @@ -922,7 +923,7 @@ export const editCustomNetwork = async ({
return response;
};

export const loadSettings = (): Promise<Settings> =>
export const loadSettings = (): Promise<Settings & IndexerSettings> =>
sendMessageToBackground({
type: SERVICE_TYPES.LOAD_SETTINGS,
});
Expand Down
5 changes: 5 additions & 0 deletions @shared/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export interface Response {
isSafetyValidationEnabled: boolean;
isValidatingSafeAssetsEnabled: boolean;
isExperimentalModeEnabled: boolean;
isSorobanPublicEnabled: boolean;
networkDetails: NetworkDetails;
sorobanRpcUrl: string;
networksList: NetworkDetails[];
Expand Down Expand Up @@ -139,6 +140,10 @@ export interface Preferences {
isExperimentalModeEnabled: boolean;
}

export interface IndexerSettings {
isSorobanPublicEnabled: boolean;
}

export type Settings = {
allowList: string[];
networkDetails: NetworkDetails;
Expand Down
3 changes: 3 additions & 0 deletions @shared/constants/stellar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export enum FRIENDBOT_URLS {
}

export const SOROBAN_RPC_URLS: { [key in NETWORKS]?: string } = {
[NETWORKS.PUBLIC]:
"http://soroban-rpc-pubnet-prd.soroban-rpc-pubnet-prd.svc.cluster.local:8000",
[NETWORKS.TESTNET]: "https://soroban-testnet.stellar.org/",
[NETWORKS.FUTURENET]: "https://rpc-futurenet.stellar.org/",
};
Expand All @@ -42,6 +44,7 @@ export const MAINNET_NETWORK_DETAILS: NetworkDetails = {
networkName: NETWORK_NAMES.PUBNET,
networkUrl: NETWORK_URLS.PUBLIC,
networkPassphrase: Networks.PUBLIC,
sorobanRpcUrl: SOROBAN_RPC_URLS.PUBLIC,
};

export const TESTNET_NETWORK_DETAILS: NetworkDetails = {
Expand Down
5 changes: 0 additions & 5 deletions extension/src/background/helpers/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,6 @@ export const getNetworksList = async () => {
return networksList;
};

export const getIsSorobanSupported = async () => {
const networkDetails = await getNetworkDetails();
return !!networkDetails.sorobanRpcUrl;
};

export const subscribeAccount = async (publicKey: string) => {
// if pub key already has a subscription setup, skip this
const keyId = await localStore.getItem(KEY_ID);
Expand Down
32 changes: 32 additions & 0 deletions extension/src/background/helpers/dataStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
DEFAULT_NETWORKS,
NetworkDetails,
NETWORKS,
MAINNET_NETWORK_DETAILS,
TESTNET_NETWORK_DETAILS,
FUTURENET_NETWORK_DETAILS,
SOROBAN_RPC_URLS,
Expand Down Expand Up @@ -193,12 +194,43 @@ export const migrateToAccountSubscriptions = async () => {
}
};

const migrateMainnetSorobanRpcUrlNetworkDetails = async () => {
const localStore = dataStorageAccess(browserLocalStorage);
const storageVersion = (await localStore.getItem(STORAGE_VERSION)) as string;

if (!storageVersion || semver.lt(storageVersion, "4.0.0")) {
const networksList: NetworkDetails[] =
(await localStore.getItem(NETWORKS_LIST_ID)) || DEFAULT_NETWORKS;

const migratedNetworkList = networksList.map((network) => {
if (network.network === NETWORKS.PUBLIC) {
return {
...MAINNET_NETWORK_DETAILS,
sorobanRpcUrl: SOROBAN_RPC_URLS[NETWORKS.PUBLIC],
};
}

return network;
});

const currentNetwork = await localStore.getItem(NETWORK_ID);

if (currentNetwork && currentNetwork.network === NETWORKS.PUBLIC) {
await localStore.setItem(NETWORK_ID, MAINNET_NETWORK_DETAILS);
}

await localStore.setItem(NETWORKS_LIST_ID, migratedNetworkList);
await migrateDataStorageVersion("4.0.0");
}
};

export const versionedMigration = async () => {
// sequentially call migrations in order to enforce smooth schema upgrades

await migrateTokenIdList();
await migrateTestnetSorobanRpcUrlNetworkDetails();
await migrateToAccountSubscriptions();
await migrateMainnetSorobanRpcUrlNetworkDetails();
};

// Updates storage version
Expand Down
11 changes: 11 additions & 0 deletions extension/src/background/messageListener/popupMessageListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import browser from "webextension-polyfill";
import { fromMnemonic, generateMnemonic } from "stellar-hd-wallet";
import { BigNumber } from "bignumber.js";

import { INDEXER_URL } from "@shared/constants/mercury";
import { SERVICE_TYPES } from "@shared/constants/services";
import { APPLICATION_STATE } from "@shared/constants/applicationState";
import { WalletType } from "@shared/constants/hardwareWallet";
Expand Down Expand Up @@ -1213,6 +1214,15 @@ export const popupMessageListener = (request: Request, sessionStore: Store) => {
const isDataSharingAllowed =
(await localStore.getItem(DATA_SHARING_ID)) ?? true;

let resJson = { useSorobanPublic: false };

try {
const res = await fetch(`${INDEXER_URL}/feature-flags`);
resJson = await res.json();
} catch (e) {
console.error(e);
}

return {
allowList: await getAllowList(),
isDataSharingAllowed,
Expand All @@ -1222,6 +1232,7 @@ export const popupMessageListener = (request: Request, sessionStore: Store) => {
isExperimentalModeEnabled: await getIsExperimentalModeEnabled(),
networkDetails: await getNetworkDetails(),
networksList: await getNetworksList(),
isSorobanPublicEnabled: resJson.useSorobanPublic,
};
};

Expand Down
56 changes: 49 additions & 7 deletions extension/src/popup/components/WarningMessages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import React, { useState, useRef, useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import { createPortal } from "react-dom";
import { Button, Icon, Loader, Notification } from "@stellar/design-system";
import {
Button,
Icon,
Loader,
Link,
Notification,
} from "@stellar/design-system";
import { useTranslation } from "react-i18next";
import { POPUP_HEIGHT } from "constants/dimensions";
import {
Expand Down Expand Up @@ -757,7 +763,7 @@ export const UnverifiedTokenWarning = ({
"Before you add this asset, please double-check its information and characteristics. This can help you identify fraudulent assets.",
)}
variant="warning"
></Notification>
/>
<div className="UnverifiedTokenWarning__flags">
<div className="UnverifiedTokenWarning__flags__info">
{t("Asset Info")}
Expand All @@ -768,13 +774,30 @@ export const UnverifiedTokenWarning = ({
</div>
<div className="UnverifiedTokenWarning__flag__content">
<div className="UnverifiedTokenWarning__flag__header UnverifiedTokenWarning__flags__icon--unverified">
{t("Asset not in the asset list")}
</div>
<div className="UnverifiedTokenWarning__flag__description">
{t(
`This asset is not part of the asset list by stellar.expert (${networkDetails.network})`,
"The asset is not part of Stellar Expert's top 50 assets list",
)}
</div>
<div className="UnverifiedTokenWarning__flag__description">
{t("This asset is not part of")}{" "}
<Link
isUnderline
variant="secondary"
href="https://api.stellar.expert/explorer/testnet/asset-list/top50"
target="_blank"
rel="noreferrer"
>
Stellar Expert's top 50 assets list
</Link>
<br />
<Link
isUnderline
variant="secondary"
href="https://www.freighter.app/faq"
>
{t("Learn more")}
</Link>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -828,7 +851,7 @@ export const TransferWarning = ({

return (
<WarningMessage
header="Authorizes Token Transfer"
header="Authorizes a token transfer. Proceed with caution."
variant={WarningMessageVariant.warning}
>
<div className="TokenTransferWarning">
Expand All @@ -849,6 +872,25 @@ export const TransferWarning = ({
);
};

export const InvokerAuthWarning = () => {
const { t } = useTranslation();

return (
<WarningMessage
header="Your account is signing this authorization. Proceed with caution."
variant={WarningMessageVariant.default}
>
<div className="InvokerAuthWarning">
<p>
{t(
"This authorization uses the source account's credentials, so you are implicitly authorizing this when you sign the transaction.",
)}
</p>
</div>
</WarningMessage>
);
};

export const UnverifiedTokenTransferWarning = ({
details,
}: {
Expand Down
9 changes: 7 additions & 2 deletions extension/src/popup/components/WarningMessages/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@

&__icon {
color: #6432f1;
width: 0.875rem;
width: 24px;
}

&__default-icon {
color: var(--color-purple-50);
width: 24px;
}

&__link-wrapper {
Expand Down Expand Up @@ -342,7 +343,7 @@
margin-bottom: 1.5rem;
column-gap: 0.5rem;
&__header {
color: var(--color-purple-50);
color: var(--color-white);
font-size: 0.875rem;
margin-bottom: 0.25rem;
}
Expand Down Expand Up @@ -386,3 +387,7 @@
}
}
}

.InvokerAuthWarning {
overflow-wrap: break-word;
}
30 changes: 27 additions & 3 deletions extension/src/popup/components/manageAssets/AddToken/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useEffect, useCallback, useRef, useState } from "react";
import { useSelector } from "react-redux";
import { Redirect } from "react-router-dom";
import { Formik, Form, Field, FieldProps } from "formik";
import { Icon, Input, Loader } from "@stellar/design-system";
import { Icon, Input, Link, Loader } from "@stellar/design-system";
import debounce from "lodash/debounce";
import { useTranslation } from "react-i18next";
import { INDEXER_URL } from "@shared/constants/mercury";
Expand Down Expand Up @@ -40,14 +40,38 @@ const VerificationBadge = ({ isVerified }: { isVerified: boolean }) => {
<>
<Icon.Verified />
<span className="AddToken__heading__text">
{t("Part of the asset list")}
{t("This asset is part of")}{" "}
<Link
variant="secondary"
href="https://api.stellar.expert/explorer/testnet/asset-list/top50"
target="_blank"
rel="noreferrer"
>
Stellar Expert's top 50 assets list
</Link>
.{" "}
<Link variant="secondary" href="https://www.freighter.app/faq">
{t("Learn more")}
</Link>
</span>
</>
) : (
<>
<img src={IconUnverified} alt="unverified icon" />
<span className="AddToken__heading__text">
{t("Not part of the asset list")}
{t("This asset is not part of")}{" "}
<Link
variant="secondary"
href="https://api.stellar.expert/explorer/testnet/asset-list/top50"
target="_blank"
rel="noreferrer"
>
Stellar Expert's top 50 assets list
</Link>
.{" "}
<Link variant="secondary" href="https://www.freighter.app/faq">
{t("Learn more")}
</Link>
</span>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
color: var(--color-gray-70);
font-size: 0.875rem;
margin-left: 0.15625rem;

a {
font-weight: var(--font-weight-semi-bold);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useEffect, useState } from "react";
import { useSelector, useDispatch } from "react-redux";
import { Icon, Notification } from "@stellar/design-system";
import { Icon, Link, Notification } from "@stellar/design-system";
import { useTranslation } from "react-i18next";

import { ROUTES } from "popup/constants/routes";
import { navigateTo } from "popup/helpers/navigate";
Expand Down Expand Up @@ -28,6 +29,7 @@ export function AssetSelect({
assetCode: string;
issuerKey: string;
}) {
const { t } = useTranslation();
const dispatch = useDispatch();
const { assetIcons } = useSelector(transactionSubmissionSelector);
const networkDetails = useSelector(settingsNetworkDetailsSelector);
Expand Down Expand Up @@ -68,9 +70,23 @@ export function AssetSelect({
{isUnverifiedToken ? (
<div className="AssetSelect__unverified">
<Notification
title="This asset is not on the asset list"
title="The asset is not part of Stellar Expert's top 50 assets list"
variant="primary"
/>
>
{t("This asset is not part of")}{" "}
<Link
variant="secondary"
href="https://api.stellar.expert/explorer/testnet/asset-list/top50"
target="_blank"
rel="noreferrer"
>
Stellar Expert's top 50 assets list
</Link>
.{" "}
<Link variant="secondary" href="https://www.freighter.app/faq">
{t("Learn more")}
</Link>
</Notification>
</div>
) : null}
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,7 @@ export const SubmitFail = () => {
title={t("The destination account doesn’t exist")}
>
<div>
{t(
"The destination account doesn’t exist. Make sure it is a funded Stellar account and try again.",
)}
{t("Make sure it is a funded Stellar account and try again.")},
<Link
isUnderline
variant="secondary"
Expand Down
4 changes: 1 addition & 3 deletions extension/src/popup/components/sendPayment/SendTo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ export const AccountDoesntExistWarning = () => {
title={t("The destination account doesn’t exist")}
>
<div>
{t(
"The destination account doesn’t exist. Send at least 1 XLM to create account.",
)}{" "}
{t("Send at least 1 XLM to create account.")}{" "}
<Link
variant="secondary"
href="https://developers.stellar.org/docs/tutorials/create-account/#create-account"
Expand Down
Loading

0 comments on commit bf18d61

Please sign in to comment.