-
Notifications
You must be signed in to change notification settings - Fork 393
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
Refactor assets slice #3553
Conversation
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.
Properly pass a custom asset to the metadata update test to account for updated reducer logic
caf756d
to
40cc6ab
Compare
There was a problem hiding this 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.
// Update verified status, token lists or discovery txs for custom assets | ||
if (!isBaselineTrustedAsset(existing)) { |
There was a problem hiding this comment.
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", () => { |
There was a problem hiding this comment.
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.
.map(({ value }) => value) | ||
.flat() |
There was a problem hiding this comment.
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?
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]) | ||
) |
There was a problem hiding this comment.
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.
Closed until reprioritization |
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
Latest build: extension-builds-3553 (as of Tue, 18 Jul 2023 18:59:27 GMT).