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

Refactor assets slice #3553

Closed
wants to merge 5 commits into from
Closed

Refactor assets slice #3553

wants to merge 5 commits into from

Conversation

hyphenized
Copy link
Contributor

@hyphenized hyphenized commented Jul 18, 2023

Refactored assets slice to an object indexed by asset ids. State updates emitted from the indexing service are diffed and handled faster with this approach.

Builds on top of #3530 and #3526

To Test

Switch from main to this branch

  • Check Balances
  • Check Overview
  • Check Swaps
  • Check Send page
  • Check Activities

Latest build: extension-builds-3553 (as of Tue, 18 Jul 2023 18:59:27 GMT).

This should help reduce redundancy after trust checks
Removed symbols from network base asset ids generation, added chain id
to ids for all asset types. This allows us to use these for indexing
assets across networks in e.g. redux.
Refactored assets slice to an object indexed by asset ids. State updates
emitted from the indexing service are diffed and handled faster with this
approach.
@hyphenized hyphenized requested a review from a team July 18, 2023 16:55
Properly pass a custom asset to the metadata update test
to account for updated reducer logic
Copy link
Contributor

@kkosiorowska kkosiorowska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not tested yet, some minor comments.

Comment on lines +57 to +58
// Update verified status, token lists or discovery txs for custom assets
if (!isBaselineTrustedAsset(existing)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isBaselineTrustedAsset checks if asset is a base asset or asset from token list. This means that only custom assets should be updated. Why then do we allow updates to property tokenLists. Shouldn't custom assets have this property empty? 🤔

const pricesState: PricesState = {
[getFullAssetID(assetWithPricePoint)]: {
[getFullAssetID(asset)]: {
USD: pricePoint,
},
}

describe("Reducers", () => {
describe("assetsLoaded", () => {
test("updates cached asset metadata", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking

I wonder if it wouldn't be good if the description was more specific about what tests do.

Comment on lines +985 to +986
.map(({ value }) => value)
.flat()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to use flatMap here?

Comment on lines +6 to +24
export const assets: Record<string, SmartContractFungibleAsset> =
Object.fromEntries(
[
{
name: "Wrapped Ether",
symbol: "WETH",
decimals: 18,
homeNetwork: ETHEREUM,
contractAddress: "0x0",
},
{
name: "Uniswap",
symbol: "UNI",
decimals: 18,
homeNetwork: ETHEREUM,
contractAddress: "0x0",
},
].map((asset) => [getFullAssetID(asset), asset])
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking

I wonder why we don't just use createSmartContractAsset here.

@hyphenized
Copy link
Contributor Author

Closed until reprioritization

@hyphenized hyphenized closed this Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants