## Foreign Assets PR Notes
Foreign Assets: [PR](https://github.com/paritytech/substrate-api-sidecar/pull/1314)
Notes after commit: [test: added test & mock data](https://github.com/paritytech/substrate-api-sidecar/pull/1314/commits/0683642fb43e4ba1206963d5495464a6c47d1131)
### New Files - Total : 9
- `PalletsForeignAssetsService.spec.ts`
- 🤔 the test for `Pallet Assets` and for `Pallets Foreign Assets` do not include `status` as one of the returned fields but in the response there is an actual field called `status`
- Shouldnt this be corrected in pjs in the type of `AssetDetails` ?
- the same but somewhat reverse is the `isFrozen: false` field in the AssetInfo/AssetDetails :
- it is not in the response (e.g. in the browser)
- but it is returned from the call
- it is in the AssetDetails interface and in our mocked data
- and we have it in the expected response of the test otherwise the test fails
- `...mock/assets/mockAssetHubKusamaData.ts`
- ❓Removed the `Promise` from `foreignAssetInfo`. Not sure if it is the correct to do this but it was not working without it.
- ❗I had an issue here :
- KSM units were being added in the `deposit` fields of the response right after I was calling the `toHuman` in the `Service` file.
- I removed the `toHuman` from the service. More info further down.
- `assetHubKusamaRegistry.ts`
- `assetHubKusamaMetadata`
- `mockAssetHubKusamaApi`
- The exported variables I changed them so it is the same format that Beto used except `mockAssetHubKusamaApi`
- but if it is an issue I can also change that to `mockAssetHubKusama` to be aligned.
- `mockBlock523510`
- `block523510.json`
- checked against asset hub kusama
- `foreignAssets`
- ❗I added a separate file here in case I want to add a 2nd foreign asset location. In that case I will have to add a 2nd foregin asset to test.
- `foreignAssetsEntries`
- ❗Here again I added a separate file to loop through all the locations (from the above file). Right now I only have one location so not very useful.
### Changed Files - Total : 3
- `PalletsForeignAssetsService.ts`
- ❓Removed the `toHuman` from assetInfo and assetMetadata calls because otherwise the test does not pass :
- as soon as i have toHuman it keeps giving me KSM and KSM units like mKSM
- the issue with removing the `toHuman` call is that now the response is not formatted in a user friendly way
- but its the same case in the assets endpoint. Maybe for the same reason ?
- if i really want to have to use `toHuman` and have everything formatted nicely in the response then I would have to create the mock data based on the Tinkernet registry no ?
- `typeFactory`
- ❓My objective of the changes in the `TypeFactory` class was to create the Multilocation Storage key (I call it in `foreignAssetsEntries` file). For this I found 2 ways (if any is correct) :
1. I add (current solution) the `storageKeyMultilocation` method in the `TypeFactory`class but it is exactly the same as `storageKey` and the only difference is the 1st arg which in Multilocation is JSON. I was trying to pass it as a string but somehow I could not make it work.
2. I do not add any new method and use `storageKey`and just add in the index 3 possible types instead of 2 so :
> `index: number | string | AnyJson,`
I am just not sure if we want to change that in that method.
3. I think the ideal solution would be to be able to pass the Multilocation as a string ?
- `src/services/test-helpers/mock/index.ts`
- `src/test-helpers/registries/index`
### General Notes - Pendings
- Haven't checked fully if the Storage Key that is created is correct
- Add a second foreign asset in the tests?