Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/5.23.2 #1447

Open
wants to merge 68 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
4edcb81
adds fetchJson to handle non json fetch responses
aristidesstaffieri Aug 27, 2024
599e250
awaits json response
aristidesstaffieri Aug 27, 2024
b5496c9
encodes xdr for query param usage
aristidesstaffieri Aug 27, 2024
9b758db
[FEATURE] malicious tx warning, sign-tx (#1449)
aristidesstaffieri Aug 28, 2024
786cbb5
adds scan labels for all scan result types, tweaks styles
aristidesstaffieri Aug 28, 2024
6e2ccdf
Added translations
aristidesstaffieri Aug 28, 2024
bf43b10
adds unit tests for grant access views scan site labels
aristidesstaffieri Aug 29, 2024
1fe440b
adds sac contract check in transfer detail, formats transfers like re…
aristidesstaffieri Aug 28, 2024
f22832c
adds unit test for sac transfer history item
aristidesstaffieri Aug 29, 2024
3c58b8f
memoizes translation fn as dependency of history item effect
aristidesstaffieri Aug 29, 2024
8f2dd57
Feature/blockaid asset UI warning (#1452)
piyalbasu Aug 30, 2024
e660533
removes configurable fee constraint on token transfers
aristidesstaffieri Aug 30, 2024
df27b1d
take into account min resource fee for toke payments
aristidesstaffieri Sep 3, 2024
af176f8
split out simulation api to internal api, update tests to use correct…
aristidesstaffieri Sep 3, 2024
6aceb69
qa fixes for blockaid asset check (#1460)
piyalbasu Sep 3, 2024
7f107b1
add Blockaid tests for account, manage assets, send and swap flows (#…
piyalbasu Sep 3, 2024
97cce0e
adds tx scan during send payment flow tx details
aristidesstaffieri Sep 4, 2024
7ebf035
adds failed simulation state to tx scan label, updates tx scan respon…
aristidesstaffieri Sep 5, 2024
bc6c91f
removes unused cast functions
aristidesstaffieri Sep 5, 2024
2fa6312
add Blockaid announcement modal (#1465)
piyalbasu Sep 5, 2024
782f5ab
split tx scan for classic sends and swaps
aristidesstaffieri Sep 5, 2024
b376fe4
pulls tx construction out into helper
aristidesstaffieri Sep 5, 2024
d53346f
Bugfix/show non malicious blockaid info (#1469)
piyalbasu Sep 9, 2024
d38d80f
fixes transparent bg on asset warning
aristidesstaffieri Sep 9, 2024
046567f
handle complete blockaid data fro indexer (#1474)
piyalbasu Sep 9, 2024
616d03d
add better typing for standalone balances (#1475)
piyalbasu Sep 11, 2024
f3c4591
Merge branch 'master' into release/5.23.2
piyalbasu Sep 11, 2024
98b7097
add blockaid scan for custom mainnet and use blockaid lib for types (…
piyalbasu Sep 12, 2024
3235067
makes suspicious asset check stricter
aristidesstaffieri Sep 16, 2024
c14b687
use blockaid lib for blockaid scan tx result (#1480)
piyalbasu Sep 16, 2024
f3809c3
move terser to only production config (#1481)
piyalbasu Sep 16, 2024
89f7637
check for scam asset warning message in send flow (#1482)
piyalbasu Sep 16, 2024
ab4feef
Feature/rm stellar.expert safety checks (#1483)
piyalbasu Sep 17, 2024
15493bc
adds advanced settings guide
aristidesstaffieri Sep 13, 2024
4318b2d
adds add asset docs
aristidesstaffieri Sep 13, 2024
f63ba20
adds docs for account, network settings, make payment, add asset, and…
aristidesstaffieri Sep 16, 2024
38b47d9
fix grammar
aristidesstaffieri Sep 17, 2024
f854edc
fix typo
aristidesstaffieri Sep 17, 2024
1c88d19
fix grammar
aristidesstaffieri Sep 17, 2024
46e99a7
fix grammar
aristidesstaffieri Sep 17, 2024
9cb2303
fix grammar
aristidesstaffieri Sep 17, 2024
0bc9127
splits guide into 2 groups, updates copy importing new key instructions
aristidesstaffieri Sep 17, 2024
20498a8
split intro in sidebar, expand intro to include new docs
aristidesstaffieri Sep 17, 2024
6cadcea
clarify seed phrase import copy
aristidesstaffieri Sep 17, 2024
ba9227d
rename "blocked accounts" to "memo required accounts" (#1485)
piyalbasu Sep 19, 2024
1d98378
removes benign scan label for site scans
aristidesstaffieri Sep 19, 2024
8347a9b
skip benign label test for now
aristidesstaffieri Sep 19, 2024
f6daddf
updates tx scan copy and adds malicious tx scan state for buttons
aristidesstaffieri Sep 19, 2024
3bdea09
tweaks grant access width to stop button overflow, tweaks cancel text
aristidesstaffieri Sep 24, 2024
a87938d
better loading states while loading blockaid data (#1486)
piyalbasu Sep 24, 2024
3780072
adjust blockaid-related styling (#1493)
piyalbasu Sep 24, 2024
c7e50b7
scan search results in a loop to avoid long loading times (#1494)
piyalbasu Sep 25, 2024
8dead38
scan asset results in manual add (#1496)
piyalbasu Sep 26, 2024
4257248
add helper to determine if a tx is suspicious (#1497)
piyalbasu Sep 26, 2024
97268da
show error button in send flow warning (#1499)
piyalbasu Sep 26, 2024
6131cf6
restore dropped styles for modal subject
aristidesstaffieri Sep 27, 2024
d8560f5
redesign popup blockaid warnings (#1503)
piyalbasu Oct 2, 2024
2128740
adjust padding on buttons (#1504)
piyalbasu Oct 3, 2024
b3225d2
adds new test token address after testnet reset
aristidesstaffieri Oct 3, 2024
b4afa73
comments blockaid announcement, tweaks e2e details in tests
aristidesstaffieri Oct 3, 2024
adc1f85
fixes loading state for token transfer details after transfer, fixes …
aristidesstaffieri Oct 4, 2024
c06e75f
updates test for history item change
aristidesstaffieri Oct 4, 2024
4b9157c
fix stale state instead by manually dismissing loading when not scann…
aristidesstaffieri Oct 4, 2024
010b458
restore login and fund on first payment test
aristidesstaffieri Oct 4, 2024
41f3199
make e2e tests run in sequence
aristidesstaffieri Oct 4, 2024
4f78900
restore slow timeout settings for payment tests
aristidesstaffieri Oct 4, 2024
0df7282
avoids rescanning classic transactions after tx is sent in details
aristidesstaffieri Oct 4, 2024
ad93929
add explicit prop to scan tx in tx details
aristidesstaffieri Oct 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 75 additions & 25 deletions @shared/api/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,21 +518,26 @@ export const getSorobanTokenBalance = async (
export const getAccountBalancesStandalone = async ({
publicKey,
networkDetails,
isMainnet,
}: {
publicKey: string;
networkDetails: NetworkDetails;
}): Promise<AccountBalancesInterface> => {
isMainnet: boolean;
}) => {
const { network, networkUrl, networkPassphrase } = networkDetails;

let balances: any = null;
let balances = null;
let isFunded = null;
let subentryCount = 0;

try {
const server = stellarSdkServer(networkUrl, networkPassphrase);
const accountSummary = await server.accounts().accountId(publicKey).call();

const displayableBalances = makeDisplayableBalances(accountSummary);
const displayableBalances = await makeDisplayableBalances(
accountSummary,
isMainnet,
);
const sponsor = accountSummary.sponsor
? { sponsor: accountSummary.sponsor }
: {};
Expand All @@ -556,20 +561,19 @@ export const getAccountBalancesStandalone = async ({
// eslint-disable-next-line no-plusplus
for (let i = 0; i < Object.keys(resp.balances).length; i++) {
const k = Object.keys(resp.balances)[i];
const v: any = resp.balances[k];
if (v.liquidity_pool_id) {
const v = resp.balances[k];
if (v.liquidityPoolId) {
const server = stellarSdkServer(networkUrl, networkPassphrase);
// eslint-disable-next-line no-await-in-loop
const lp = await server
.liquidityPools()
.liquidityPoolId(v.liquidity_pool_id)
.liquidityPoolId(v.liquidityPoolId)
.call();
balances[k] = {
...balances[k],
liquidityPoolId: v.liquidity_pool_id,
liquidityPoolId: v.liquidityPoolId,
reserves: lp.reserves,
};
delete balances[k].liquidity_pool_id;
}
}
isFunded = true;
Expand Down Expand Up @@ -1172,14 +1176,10 @@ export const saveAllowList = async ({
export const saveSettings = async ({
isDataSharingAllowed,
isMemoValidationEnabled,
isSafetyValidationEnabled,
isValidatingSafeAssetsEnabled,
isNonSSLEnabled,
}: {
isDataSharingAllowed: boolean;
isMemoValidationEnabled: boolean;
isSafetyValidationEnabled: boolean;
isValidatingSafeAssetsEnabled: boolean;
isNonSSLEnabled: boolean;
}): Promise<Settings & IndexerSettings> => {
let response = {
Expand All @@ -1188,22 +1188,19 @@ export const saveSettings = async ({
networkDetails: MAINNET_NETWORK_DETAILS,
networksList: DEFAULT_NETWORKS,
isMemoValidationEnabled: true,
isSafetyValidationEnabled: true,
isValidatingSafeAssetsEnabled: true,
isRpcHealthy: false,
userNotification: { enabled: false, message: "" },
settingsState: SettingsState.IDLE,
isSorobanPublicEnabled: false,
isNonSSLEnabled: false,
isBlockaidAnnounced: false,
error: "",
};

try {
response = await sendMessageToBackground({
isDataSharingAllowed,
isMemoValidationEnabled,
isSafetyValidationEnabled,
isValidatingSafeAssetsEnabled,
isNonSSLEnabled,
type: SERVICE_TYPES.SAVE_SETTINGS,
});
Expand Down Expand Up @@ -1351,16 +1348,9 @@ export const loadSettings = (): Promise<
type: SERVICE_TYPES.LOAD_SETTINGS,
});

export const getBlockedDomains = async () => {
const resp = await sendMessageToBackground({
type: SERVICE_TYPES.GET_BLOCKED_DOMAINS,
});
return resp;
};

export const getBlockedAccounts = async () => {
export const getMemoRequiredAccounts = async () => {
const resp = await sendMessageToBackground({
type: SERVICE_TYPES.GET_BLOCKED_ACCOUNTS,
type: SERVICE_TYPES.GET_MEMO_REQUIRED_ACCOUNTS,
});
return resp;
};
Expand Down Expand Up @@ -1460,3 +1450,63 @@ export const modifyAssetsList = async ({

return { assetsLists: response.assetsLists, error: response.error };
};

export const simulateTokenTransfer = async (args: {
address: string;
publicKey: string;
memo: string;
params: {
publicKey: string;
destination: string;
amount: number;
};
networkDetails: NetworkDetails;
transactionFee: string;
}) => {
const { address, publicKey, memo, params, networkDetails } = args;
const options = {
method: "POST",
headers: {
// eslint-disable-next-line @typescript-eslint/naming-convention
"Content-Type": "application/json",
},
body: JSON.stringify({
address,
// eslint-disable-next-line @typescript-eslint/naming-convention
pub_key: publicKey,
memo,
params,
// eslint-disable-next-line @typescript-eslint/naming-convention
network_url: networkDetails.sorobanRpcUrl,
// eslint-disable-next-line @typescript-eslint/naming-convention
network_passphrase: networkDetails.networkPassphrase,
}),
};
const res = await fetch(`${INDEXER_URL}/simulate-token-transfer`, options);
const response = await res.json();
return {
ok: res.ok,
response,
};
};

export const saveIsBlockaidAnnounced = async ({
isBlockaidAnnounced,
}: {
isBlockaidAnnounced: boolean;
}) => {
let response = {
error: "",
isBlockaidAnnounced: false,
};

response = await sendMessageToBackground({
type: SERVICE_TYPES.SAVE_IS_BLOCKAID_ANNOUNCED,
isBlockaidAnnounced,
});

return {
isBlockaidAnnounced: response.isBlockaidAnnounced,
error: response.error,
};
};
1 change: 1 addition & 0 deletions @shared/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"version": "1.0.0",
"private": true,
"dependencies": {
"@blockaid/client": "^0.25.0",
"@stellar/js-xdr": "^3.1.1",
"bignumber.js": "^9.1.1",
"prettier": "^2.0.5",
Expand Down
36 changes: 26 additions & 10 deletions @shared/api/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import BigNumber from "bignumber.js";
import { AssetType as SdkAssetType, Horizon } from "stellar-sdk";
import Blockaid from "@blockaid/client";

import { SERVICE_TYPES, EXTERNAL_SERVICE_TYPES } from "../constants/services";
import { APPLICATION_STATE } from "../constants/applicationState";
Expand Down Expand Up @@ -75,8 +76,7 @@ export interface Response {
recentAddresses: string[];
hardwareWalletType: WalletType;
bipPath: string;
blockedDomains: BlockedDomains;
blockedAccounts: BlockedAccount[];
memoRequiredAccounts: MemoRequiredAccount[];
assetDomain: string;
contractId: string;
tokenId: string;
Expand All @@ -90,13 +90,10 @@ export interface Response {
isMergeSelected: boolean;
recommendedFee: string;
isNonSSLEnabled: boolean;
isBlockaidAnnounced: boolean;
}

export interface BlockedDomains {
[key: string]: boolean;
}

export interface BlockedAccount {
export interface MemoRequiredAccount {
address: string;
name: string;
domain: string | null;
Expand Down Expand Up @@ -144,10 +141,9 @@ export enum AccountType {
export interface Preferences {
isDataSharingAllowed: boolean;
isMemoValidationEnabled: boolean;
isSafetyValidationEnabled: boolean;
isValidatingSafeAssetsEnabled: boolean;
networksList: NetworkDetails[];
isNonSSLEnabled: boolean;
isBlockaidAnnounced: boolean;
error: string;
}

Expand Down Expand Up @@ -237,9 +233,27 @@ export interface Balance {
total: BigNumber;
buyingLiabilities: string;
sellingLiabilities: string;
liquidityPoolId?: string;
reserves?: Horizon.HorizonApi.Reserve[];
contractId?: string;
blockaidData: BlockAidScanAssetResult;
}

export type BlockAidScanAssetResult = Blockaid.TokenScanResponse;
export interface BlockAidScanAssetResultIndex {
[key: string]: Blockaid.TokenScanResponse.AttackTypes &
Blockaid.TokenScanResponse.Fees &
Blockaid.TokenScanResponse.BasicMetadataToken &
Blockaid.TokenScanResponse.FinancialStats &
Blockaid.TokenScanResponse.TradingLimits;
}

export type BlockAidScanSiteResult = Blockaid.SiteScanResponse;
export type BlockAidScanTxResult = Blockaid.StellarTransactionScanResponse;
export type BlockAidBulkScanAssetResult = Blockaid.TokenBulkScanResponse;

export interface AssetBalance extends Balance {
limit: BigNumber;
token: AssetToken;
sponsor?: string;
}
Expand All @@ -250,8 +264,10 @@ export interface NativeBalance extends Balance {
}

export interface TokenBalance extends AssetBalance {
decimals: number;
name: string;
symbol: string;
decimals: number;
total: BigNumber;
}

export interface BalanceMap {
Expand Down
4 changes: 2 additions & 2 deletions @shared/constants/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ export enum SERVICE_TYPES {
CACHE_ASSET_ICON = "CACHE_ASSET_ICON",
GET_CACHED_ASSET_DOMAIN = "GET_CACHED_ASSET_DOMAIN",
CACHE_ASSET_DOMAIN = "CACHE_ASSET_DOMAIN",
GET_BLOCKED_ACCOUNTS = "GET_BLOCKED_ACCOUNTS",
GET_BLOCKED_DOMAINS = "GET_BLOCKED_DOMAINS",
GET_MEMO_REQUIRED_ACCOUNTS = "GET_MEMO_REQUIRED_ACCOUNTS",
ADD_CUSTOM_NETWORK = "ADD_CUSTOM_NETWORK",
CHANGE_NETWORK = "CHANGE_NETWORK",
REMOVE_CUSTOM_NETWORK = "REMOVE_CUSTOM_NETWORK",
Expand All @@ -48,6 +47,7 @@ export enum SERVICE_TYPES {
MIGRATE_ACCOUNTS = "MIGRATE_ACCOUNTS",
ADD_ASSETS_LIST = "ADD_ASSETS_LIST",
MODIFY_ASSETS_LIST = "MODIFY_ASSETS_LIST",
SAVE_IS_BLOCKAID_ANNOUNCED = "SAVE_IS_BLOCKAID_ANNOUNCED",
}

export enum EXTERNAL_SERVICE_TYPES {
Expand Down
Loading