Skip to content

Commit d5dac5d

Browse files
piyalbasuleofelix077aristidesstaffieriCassioMG
authored
release/5.36.0 (#2298)
* Feature/move history fetch to bg (#2273) * upgrade to yarn 2 and use resolutions to block vulnerable package versions (#2239) * upgrade to yarn 2 and use resolutions to block vulnerable package versions * rm deprecated .yarnrc * rm yarnpath * try committing yarn binary to repo * try corepack enable for gha * update run tests cmd * rm yarnpath * rm npm i yarn * update all pipelines * rm superfluous history types * ensure invoke host function tx shows contract parameters (#2243) * ensure invoke host function tx shows contract parameters * add test for fallback if contract spec retrieval fails * Bugfix/rm auth param names (#2244) * ensure invoke host function tx shows contract parameters * add test for fallback if contract spec retrieval fails * do not show contract parameters for authorizations * add tests for create contract v1 and invoke contract * add issuer for changeTrust op (#2246) * add issuer for changeTrust op * programmatically disable overflow:hidden when copying a value * Revert "add issuer for changeTrust op (#2246)" (#2247) This reverts commit 19c8a68. * Bugfix/add issuer for changetrust (#2249) * ensure invoke host function tx shows contract parameters * add test for fallback if contract spec retrieval fails * do not show contract parameters for authorizations * add tests for create contract v1 and invoke contract * add issuer for changeTrust op * programmatically disable overflow:hidden when copying a value * cache account balances and poll for updates * fix CI tests * rm `force:true` which was causing action to happen too fast * do a fresh balance fetch on account/network change * first pass at async history * pr comments * allow for history caching * add more sentry tracking for Account and Wallets views (#2268) * add more sentry tracking for Account and Wallets views * adding more sentry reporting * gracefully degrade on errors from Blockaid (#2269) * gracefully degrade on errors from Blockaid * should not be necessary to skip dapp scanning on custom network * rm extra dep * add a test for persisting configurations in the send flow (#2271) * add a test for persisting configurations in the send flow * rm logs and update muxed acct; lower xlm payment * rm slow loading simulation * handle missing scan-tx result; add disabled state for Confirm Anyway (#2272) * handle missing scan-tx result; add disabled state for Confirm Anyway * assertions to show correct confirm button on Blockaid error * add cache for balances to ensure we do a fresh lookup when needed (#2275) * add cache for balances to ensure we do a fresh lookup when needed * add try...catch to token-prices polling * rm log * only dispatch saveBalancesForAccount when fresh data has been fetched * adjust test to wait for UI change * replace yarn setup with just yarn * rm unnecessary return * clear token details on redux clear action * make history row construction async and check for redux state for updates * add tests for assetdetails * increase timeout for flakey test * pr comments * refresh account history every time account balances refresh * check for updated appdata before showing password modal (#2300) * check for updated appdata before showing password modal * update error msg * rm unused redirect logic * stringify errors rather than using `cause` (#2302) * Feature/move icons to own hook (#2308) * move get icons out of critical path; rely on background's cache * add tests and comments * add comment * add comment * only dispatch if we have cached icons * PR comments * skip blockaid scan on first fetch of account-balances (#2310) * skip blockaid scan on first fetch of account-balances * rm stub change * rm more stubs * rm log * add comments and update boolean naming * Dropdown menu option to copy wallet address (#2316) * add button to copy address from dropdown * Added translations * revert translation file changes * revert translation file changes * Added translations * revert changes to translation files * move copy address button to first dropdown position * scroll on long strings; pretty print json (#2320) * scroll on long strings; pretty print json * rm log * add correct snapshot for json message * rm log * finish comment * add error case for JSON * don't use carat for lib * update yarn.lock * move scrollbar to btm of container; reduce json font size * update snapshot * re-searching so should abort any in flight API requests (#2323) * re-searching so should abort any in flight API requests * add comment * fix test name * make test more reliable * add check for correct search results * fix jest locator * [FEATURE] new send/swap navigation flow (#2353) * adds SelectionTile and AddressTile, updates nav flows to match updates. Adds query parameter for default values in send flow * Added translations * adds address tile and uses it in swap flow, tweaks selection tile styles * adds unit tests for new tile components * Added translations * updates swap navigation flow to match updates, updates tests flows to match * updates back icon for send and swap steps, fixes bad test references * tweaks locator in address tile tests * adds store state to asset tile tests, removes asset icon mock * updates SelectionTile prop name, adds isSuspicious prop for AssetTile * adds placeholder value in TokenList for missing token USD value * uses real IdenticonImg in address tile unit tests * adds query param validation for send and swap flow * Update extension/src/popup/views/SendPayment/index.tsx Co-authored-by: Cássio Marcos Goulart <[email protected]> * adds missing import * adds class for tile icon --------- Co-authored-by: Cássio Marcos Goulart <[email protected]> * [FEATURE] adds send and swap buttons to asset detail view (#2351) * adds send and swap buttons to asset detail view * uses secondary button styles * removes run snapshots job (#2355) * release/5.35.4 (#2354) * upgrade to ledger-hq/hw-transport-webhid (#2350) * upgrade to ledger-hq/hw-transport-webhid * add tests * add ledger support for new trustline flow (#2352) * upgrade to ledger-hq/hw-transport-webhid * add ledger support for new trustline flow * only re-fetch balances if we were successful * test for fetching balances on success * add reset spys * adjust spacing at top of hw wallet modal * Now that `Done` button properly shows, click it in tests (#2356) * skip flakey test * skip flakey test * renames local vars to follow convention * adds tests for LP share and tweaks LP title * adds links with query params for asset detail CTAs --------- Co-authored-by: Piyal Basu <[email protected]> * only fetch asset list data if needed (#2369) * only fetch asset list data if needed * correctly show icon loading state * [BUG] SAC token management improvements (#2374) * adds SAC detection when changing trust in the add and remove token flows * updates arg signature for isAssetSac * Feature/cache token prices (#2373) * cache token prices and batch loading wallets * use similar methodology for token price and account balance caching * fix loading state trigger * fix tests * use helper for cache clearing * set isFetchingTokenPrices to false in catch handler * rollback error change * load backend settings async on Account view (#2381) * load backend settings async on Account view * rm console.logs * Feature/use ledger key for home domains (#2363) * use ledger-key/accounts endpoint for home domains * fix tests * create generic ledger key account helper; add tests * rm unneeded data-test prop * rm unused import * [CHORE] git process updates (#2361) * moves the add translations hook to the pre commit stage, removes standalone translations commit * adds script to update app version, removes version update from submit production action, adds update version step to test run action for release branches * removes version input, now uses package version * fetch asset domains in one calls * fix tests * cache home domains while iterating over account history rows * fitler non-G keys * rm .only * fix test param * PR comments --------- Co-authored-by: aristides <[email protected]> * update version numbers for release * rm unnecessary calls to make flows even faster (#2391) * makes send swap buttons stay in the container in full screen mode (#2392) * makes send swap buttons stay in the container in full screen mode * add a pause to make sure flakey e2e test has time to save changes * use redux selector for allAccounts to properly update rename (#2403) * use redux selector for allAccounts to properly update rename * add longer timeout for flakey btn * Add docs for 5.36.0 (#2408) --------- Co-authored-by: leofelix077 <[email protected]> Co-authored-by: aristides <[email protected]> Co-authored-by: Cássio Marcos Goulart <[email protected]>
1 parent 09ae75f commit d5dac5d

File tree

121 files changed

+7119
-1094
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+7119
-1094
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import { TESTNET_NETWORK_DETAILS } from "@shared/constants/stellar";
2+
import * as GetLedgerKeyAccounts from "../helpers/getLedgerKeyAccounts";
3+
import * as internalApi from "../internal";
4+
5+
describe("internalApi", () => {
6+
afterEach(() => {
7+
jest.clearAllMocks();
8+
});
9+
describe("getAssetDomains", () => {
10+
it("should return a list of domains from a list of issuers", async () => {
11+
jest
12+
.spyOn(GetLedgerKeyAccounts, "getLedgerKeyAccounts")
13+
.mockResolvedValue({
14+
G1: {
15+
account_id:
16+
"GDF32CQINROD3E2LMCGZUDVMWTXCJFR5SBYVRJ7WAAIAS3P7DCVWZEFY",
17+
home_domain: "stellar1.org",
18+
balance: "1000000000000000000",
19+
seq_num: 1,
20+
num_sub_entries: 1,
21+
inflation_dest: "G1",
22+
flags: 1,
23+
thresholds: "1000000000000000000",
24+
signers: [
25+
{
26+
key: "GDF32CQINROD3E2LMCGZUDVMWTXCJFR5SBYVRJ7WAAIAS3P7DCVWZEFY",
27+
weight: 1,
28+
},
29+
],
30+
sequence_number: 1,
31+
},
32+
G2: {
33+
account_id:
34+
"GBKWMR7TJ7BBICOOXRY2SWXKCWPTOHZPI6MP4LNNE5A73VP3WADGG3CH",
35+
home_domain: "stellar2.org",
36+
balance: "1000000000000000000",
37+
seq_num: 1,
38+
num_sub_entries: 1,
39+
inflation_dest:
40+
"GBKWMR7TJ7BBICOOXRY2SWXKCWPTOHZPI6MP4LNNE5A73VP3WADGG3CH",
41+
flags: 1,
42+
thresholds: "1000000000000000000",
43+
signers: [
44+
{
45+
key: "GBKWMR7TJ7BBICOOXRY2SWXKCWPTOHZPI6MP4LNNE5A73VP3WADGG3CH",
46+
weight: 1,
47+
},
48+
],
49+
sequence_number: 1,
50+
},
51+
});
52+
const assetDomains = await internalApi.getAssetDomains({
53+
assetIssuerDomainsToFetch: [
54+
"GDF32CQINROD3E2LMCGZUDVMWTXCJFR5SBYVRJ7WAAIAS3P7DCVWZEFY",
55+
"GBKWMR7TJ7BBICOOXRY2SWXKCWPTOHZPI6MP4LNNE5A73VP3WADGG3CH",
56+
],
57+
networkDetails: TESTNET_NETWORK_DETAILS,
58+
});
59+
60+
expect(assetDomains).toEqual({
61+
G1: "stellar1.org",
62+
G2: "stellar2.org",
63+
});
64+
});
65+
it("should return an empty object if the fetch fails", async () => {
66+
jest
67+
.spyOn(GetLedgerKeyAccounts, "getLedgerKeyAccounts")
68+
.mockRejectedValue(new Error("Fetch failed"));
69+
const assetDomains = await internalApi.getAssetDomains({
70+
assetIssuerDomainsToFetch: ["G1", "G2"],
71+
networkDetails: TESTNET_NETWORK_DETAILS,
72+
});
73+
expect(assetDomains).toEqual({});
74+
});
75+
it("should return an empty object if not valid public keys are provided", async () => {
76+
const getLedgerKeyAccountsSpy = jest.spyOn(
77+
GetLedgerKeyAccounts,
78+
"getLedgerKeyAccounts",
79+
);
80+
const assetDomains = await internalApi.getAssetDomains({
81+
assetIssuerDomainsToFetch: [
82+
"CAZXRTOKNUQ2JQQF3NCRU7GYMDJNZ2NMQN6IGN4FCT5DWPODMPVEXSND",
83+
],
84+
networkDetails: TESTNET_NETWORK_DETAILS,
85+
});
86+
expect(getLedgerKeyAccountsSpy).not.toHaveBeenCalled();
87+
expect(assetDomains).toEqual({});
88+
});
89+
});
90+
});
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import { TESTNET_NETWORK_DETAILS } from "@shared/constants/stellar";
2+
import { getIconUrlFromIssuer } from "../getIconUrlFromIssuer";
3+
import * as ExtensionMessaging from "@shared/api/helpers/extensionMessaging";
4+
import * as ApiInternal from "@shared/api/internal";
5+
6+
jest.mock("stellar-sdk", () => {
7+
const original = jest.requireActual("stellar-sdk");
8+
return {
9+
...original,
10+
StellarToml: {
11+
Resolver: {
12+
resolve: jest.fn().mockResolvedValue({
13+
CURRENCIES: [
14+
{
15+
code: "USDC",
16+
issuer:
17+
"GBKWMR7TJ7BBICOOXRY2SWXKCWPTOHZPI6MP4LNNE5A73VP3WADGG3CH",
18+
image: "http://tomldomain.com/baz.png",
19+
},
20+
],
21+
}),
22+
},
23+
},
24+
};
25+
});
26+
27+
describe("getIconUrlFromIssuer", () => {
28+
afterEach(() => {
29+
jest.clearAllMocks();
30+
});
31+
it("should return the icon url for a given issuer from the background cache", async () => {
32+
jest
33+
.spyOn(ExtensionMessaging, "sendMessageToBackground")
34+
.mockImplementationOnce(() =>
35+
Promise.resolve({
36+
iconUrl: "http://bgdomain.com/baz.png",
37+
} as any),
38+
);
39+
const iconUrl = await getIconUrlFromIssuer({
40+
key: "GBKWMR7TJ7BBICOOXRY2SWXKCWPTOHZPI6MP4LNNE5A73VP3WADGG3CH",
41+
code: "USDC",
42+
networkDetails: TESTNET_NETWORK_DETAILS,
43+
});
44+
expect(iconUrl).toBe("http://bgdomain.com/baz.png");
45+
});
46+
it("should return the icon url for a given issuer from a passed home domain", async () => {
47+
// mock both calls to the background
48+
jest
49+
.spyOn(ExtensionMessaging, "sendMessageToBackground")
50+
.mockImplementationOnce(() => Promise.resolve({} as any));
51+
jest
52+
.spyOn(ExtensionMessaging, "sendMessageToBackground")
53+
.mockImplementationOnce(() => Promise.resolve({} as any));
54+
const iconUrl = await getIconUrlFromIssuer({
55+
key: "GBKWMR7TJ7BBICOOXRY2SWXKCWPTOHZPI6MP4LNNE5A73VP3WADGG3CH",
56+
code: "USDC",
57+
networkDetails: TESTNET_NETWORK_DETAILS,
58+
homeDomain: "http://home.com/baz.png",
59+
});
60+
expect(iconUrl).toBe("http://tomldomain.com/baz.png");
61+
});
62+
it("should return the icon url for a given issuer from a passed home domain", async () => {
63+
// mock both calls to the background
64+
jest
65+
.spyOn(ExtensionMessaging, "sendMessageToBackground")
66+
.mockImplementationOnce(() => Promise.resolve({} as any));
67+
jest
68+
.spyOn(ExtensionMessaging, "sendMessageToBackground")
69+
.mockImplementationOnce(() => Promise.resolve({} as any));
70+
71+
const getAssetDomainsSpy = jest
72+
.spyOn(ApiInternal, "getAssetDomains")
73+
.mockImplementationOnce(() =>
74+
Promise.resolve({
75+
GBKWMR7TJ7BBICOOXRY2SWXKCWPTOHZPI6MP4LNNE5A73VP3WADGG3CH:
76+
"http://ledgerkeydomain.com/baz.png",
77+
}),
78+
);
79+
const iconUrl = await getIconUrlFromIssuer({
80+
key: "GBKWMR7TJ7BBICOOXRY2SWXKCWPTOHZPI6MP4LNNE5A73VP3WADGG3CH",
81+
code: "USDC",
82+
networkDetails: TESTNET_NETWORK_DETAILS,
83+
});
84+
85+
expect(getAssetDomainsSpy).toHaveBeenCalledWith({
86+
assetIssuerDomainsToFetch: [
87+
"GBKWMR7TJ7BBICOOXRY2SWXKCWPTOHZPI6MP4LNNE5A73VP3WADGG3CH",
88+
],
89+
networkDetails: TESTNET_NETWORK_DETAILS,
90+
});
91+
expect(iconUrl).toBe("http://tomldomain.com/baz.png");
92+
});
93+
});
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import { TESTNET_NETWORK_DETAILS } from "@shared/constants/stellar";
2+
import { getLedgerKeyAccounts } from "../getLedgerKeyAccounts";
3+
4+
describe("getDomainFromIssuer", () => {
5+
it("should return a list of domains from a list of issuers", async () => {
6+
const fetchSpy = jest.spyOn(global, "fetch").mockImplementation(() =>
7+
Promise.resolve({
8+
ok: true,
9+
json: () =>
10+
Promise.resolve({
11+
data: {
12+
ledger_key_accounts: {
13+
G1: { account_id: "G1", home_domain: "stellar1.org" },
14+
g2: { account_id: "g2", home_domain: "stellar2.org" },
15+
},
16+
},
17+
}),
18+
} as any),
19+
);
20+
const ledgerKeyAccounts = await getLedgerKeyAccounts({
21+
accountList: ["G1", "g2"],
22+
networkDetails: TESTNET_NETWORK_DETAILS,
23+
});
24+
25+
expect(fetchSpy).toHaveBeenCalledWith(
26+
new URL(
27+
"http://localhost:3003/api/v1/ledger-key/accounts?network=TESTNET",
28+
),
29+
{
30+
body: '{"public_keys":["G1","g2"]}',
31+
headers: { "Content-Type": "application/json" },
32+
method: "POST",
33+
},
34+
);
35+
36+
expect(ledgerKeyAccounts).toEqual({
37+
G1: { account_id: "G1", home_domain: "stellar1.org" },
38+
g2: { account_id: "g2", home_domain: "stellar2.org" },
39+
});
40+
});
41+
it("should return an empty object if the fetch fails", async () => {
42+
const fetchSpy = jest.spyOn(global, "fetch").mockImplementation(() =>
43+
Promise.resolve({
44+
ok: false,
45+
} as any),
46+
);
47+
const ledgerKeyAccounts = await getLedgerKeyAccounts({
48+
accountList: ["G1", "g2"],
49+
networkDetails: TESTNET_NETWORK_DETAILS,
50+
});
51+
52+
expect(fetchSpy).toHaveBeenCalledWith(
53+
new URL(
54+
"http://localhost:3003/api/v1/ledger-key/accounts?network=TESTNET",
55+
),
56+
{
57+
body: '{"public_keys":["G1","g2"]}',
58+
headers: { "Content-Type": "application/json" },
59+
method: "POST",
60+
},
61+
);
62+
63+
expect(ledgerKeyAccounts).toEqual({});
64+
});
65+
66+
it("should return an empty object if the fetch returns an error", async () => {
67+
const fetchSpy = jest.spyOn(global, "fetch").mockImplementation(() =>
68+
Promise.resolve({
69+
ok: true,
70+
json: () => Promise.resolve({ error: "test" }),
71+
} as any),
72+
);
73+
74+
const ledgerKeyAccounts = await getLedgerKeyAccounts({
75+
accountList: ["G1", "g2"],
76+
networkDetails: TESTNET_NETWORK_DETAILS,
77+
});
78+
79+
expect(fetchSpy).toHaveBeenCalledWith(
80+
new URL(
81+
"http://localhost:3003/api/v1/ledger-key/accounts?network=TESTNET",
82+
),
83+
{
84+
body: '{"public_keys":["G1","g2"]}',
85+
headers: { "Content-Type": "application/json" },
86+
method: "POST",
87+
},
88+
);
89+
90+
expect(ledgerKeyAccounts).toEqual({});
91+
});
92+
});

@shared/api/helpers/getDomainFromIssuer.ts

Lines changed: 0 additions & 58 deletions
This file was deleted.

@shared/api/helpers/getIconFromTokenList.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import {
55
import { NetworkDetails } from "@shared/constants/stellar";
66
import { getCanonicalFromAsset } from "@shared/helpers/stellar";
77

8+
import { sendMessageToBackground } from "./extensionMessaging";
9+
import { SERVICE_TYPES } from "../../constants/services";
10+
811
export const getIconFromTokenLists = async ({
912
issuerId,
1013
contractId,
@@ -36,6 +39,7 @@ export const getIconFromTokenLists = async ({
3639
issuerId &&
3740
record.issuer &&
3841
record.issuer === issuerId &&
42+
record.code === code &&
3943
record.icon
4044
) {
4145
verifiedToken = record;
@@ -46,6 +50,15 @@ export const getIconFromTokenLists = async ({
4650
}
4751
}
4852

53+
if (verifiedToken?.icon) {
54+
await sendMessageToBackground({
55+
activePublicKey: null,
56+
assetCanonical: `${code}:${contractId || issuerId}`,
57+
iconUrl: verifiedToken?.icon,
58+
type: SERVICE_TYPES.CACHE_ASSET_ICON,
59+
});
60+
}
61+
4962
return {
5063
icon: verifiedToken?.icon,
5164
canonicalAsset,

0 commit comments

Comments
 (0)