Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "GI7+exBM57/V+zc9afQYloOJkf31QC4QQ4J/FCjTkp0=",
"shasum": "h2/tYCy6l8S2zP9EdqxHKc0WSftxxnkP60i8d58vbno=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/browserify/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "kVPM+Ft1gxNWF59oCgW0MRN1DuA7kVyXwIdMbGec3aI=",
"shasum": "5mzSECxLy9lFHEwzmvRpjs0xL2TG0kTR2QXIjjavRTo=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-controllers/src/snaps/SnapController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3689,7 +3689,7 @@ export class SnapController extends BaseController<
const { assets: requestedAssets } = requestedParams;

const filteredAssets = Object.keys(assets).reduce<
Record<CaipAssetType, FungibleAssetMetadata>
Record<CaipAssetType, FungibleAssetMetadata | null>
>((accumulator, assetType) => {
const castAssetType = assetType as CaipAssetType;
const isValid =
Expand Down
7 changes: 4 additions & 3 deletions packages/snaps-sdk/src/types/handlers/assets-conversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
string,
optional,
record,
nullable,
} from '@metamask/superstruct';
import { CaipAssetTypeStruct, type CaipAssetType } from '@metamask/utils';

Expand All @@ -17,7 +18,7 @@ export const AssetConversionStruct = object({
export const OnAssetsConversionResponseStruct = object({
conversionRates: record(
CaipAssetTypeStruct,
record(CaipAssetTypeStruct, AssetConversionStruct),
record(CaipAssetTypeStruct, nullable(AssetConversionStruct)),
),
});

Expand All @@ -40,11 +41,11 @@ export type OnAssetsConversionHandler = (
/**
* The response from the conversion query, containing rates about each requested asset pair.
*
* @property conversionRates - A nested object with two CAIP-19 keys that contains a conversion rate between the two keys.
* @property conversionRates - A nested object with two CAIP-19 keys that contains a conversion rate or null between the two keys.
*/
export type OnAssetsConversionResponse = {
conversionRates: Record<
CaipAssetType,
Record<CaipAssetType, AssetConversion>
Record<CaipAssetType, AssetConversion | null>
>;
};
7 changes: 4 additions & 3 deletions packages/snaps-sdk/src/types/handlers/assets-lookup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
refine,
string,
record,
nullable,
} from '@metamask/superstruct';
import {
assert,
Expand Down Expand Up @@ -46,7 +47,7 @@ export const FungibleAssetMetadataStruct = object({
});

export const OnAssetsLookupResponseStruct = object({
assets: record(CaipAssetTypeStruct, FungibleAssetMetadataStruct),
assets: record(CaipAssetTypeStruct, nullable(FungibleAssetMetadataStruct)),
});

export type FungibleAssetMetadata = Infer<typeof FungibleAssetMetadataStruct>;
Expand All @@ -68,8 +69,8 @@ export type OnAssetsLookupHandler = (
/**
* The response from the query, containing metadata about each requested asset.
*
* @property assets - An object containing a mapping between the CAIP-19 key and a metadata object.
* @property assets - An object containing a mapping between the CAIP-19 key and a metadata object or null.
*/
export type OnAssetsLookupResponse = {
assets: Record<CaipAssetType, FungibleAssetMetadata>;
assets: Record<CaipAssetType, FungibleAssetMetadata | null>;
};
Loading