@metamask/snaps-sdk 9.0.0 → 9.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -1
- package/dist/error-wrappers.d.cts +192 -192
- package/dist/error-wrappers.d.mts +192 -192
- package/dist/internals/error-wrappers.d.cts +12 -12
- package/dist/internals/error-wrappers.d.mts +12 -12
- package/dist/jsx/components/Row.cjs.map +1 -1
- package/dist/jsx/components/Row.d.cts +3 -9
- package/dist/jsx/components/Row.d.cts.map +1 -1
- package/dist/jsx/components/Row.d.mts +3 -9
- package/dist/jsx/components/Row.d.mts.map +1 -1
- package/dist/jsx/components/Row.mjs.map +1 -1
- package/dist/jsx/validation.cjs +3 -8
- package/dist/jsx/validation.cjs.map +1 -1
- package/dist/jsx/validation.d.cts.map +1 -1
- package/dist/jsx/validation.d.mts.map +1 -1
- package/dist/jsx/validation.mjs +3 -8
- package/dist/jsx/validation.mjs.map +1 -1
- package/dist/types/handlers/assets-lookup.cjs +74 -2
- package/dist/types/handlers/assets-lookup.cjs.map +1 -1
- package/dist/types/handlers/assets-lookup.d.cts +227 -5
- package/dist/types/handlers/assets-lookup.d.cts.map +1 -1
- package/dist/types/handlers/assets-lookup.d.mts +227 -5
- package/dist/types/handlers/assets-lookup.d.mts.map +1 -1
- package/dist/types/handlers/assets-lookup.mjs +75 -3
- package/dist/types/handlers/assets-lookup.mjs.map +1 -1
- package/dist/types/handlers/assets-market-data.cjs.map +1 -1
- package/dist/types/handlers/assets-market-data.d.cts +47 -5
- package/dist/types/handlers/assets-market-data.d.cts.map +1 -1
- package/dist/types/handlers/assets-market-data.d.mts +47 -5
- package/dist/types/handlers/assets-market-data.d.mts.map +1 -1
- package/dist/types/handlers/assets-market-data.mjs.map +1 -1
- package/dist/types/methods/end-trace.cjs +3 -0
- package/dist/types/methods/end-trace.cjs.map +1 -0
- package/dist/types/methods/end-trace.d.cts +31 -0
- package/dist/types/methods/end-trace.d.cts.map +1 -0
- package/dist/types/methods/end-trace.d.mts +31 -0
- package/dist/types/methods/end-trace.d.mts.map +1 -0
- package/dist/types/methods/end-trace.mjs +2 -0
- package/dist/types/methods/end-trace.mjs.map +1 -0
- package/dist/types/methods/index.cjs.map +1 -1
- package/dist/types/methods/index.d.cts +2 -0
- package/dist/types/methods/index.d.cts.map +1 -1
- package/dist/types/methods/index.d.mts +2 -0
- package/dist/types/methods/index.d.mts.map +1 -1
- package/dist/types/methods/index.mjs.map +1 -1
- package/dist/types/methods/methods.cjs.map +1 -1
- package/dist/types/methods/methods.d.cts +4 -0
- package/dist/types/methods/methods.d.cts.map +1 -1
- package/dist/types/methods/methods.d.mts +4 -0
- package/dist/types/methods/methods.d.mts.map +1 -1
- package/dist/types/methods/methods.mjs.map +1 -1
- package/dist/types/methods/start-trace.cjs +3 -0
- package/dist/types/methods/start-trace.cjs.map +1 -0
- package/dist/types/methods/start-trace.d.cts +58 -0
- package/dist/types/methods/start-trace.d.cts.map +1 -0
- package/dist/types/methods/start-trace.d.mts +58 -0
- package/dist/types/methods/start-trace.d.mts.map +1 -0
- package/dist/types/methods/start-trace.mjs +2 -0
- package/dist/types/methods/start-trace.mjs.map +1 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.mjs","sourceRoot":"","sources":["../../src/jsx/validation.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,EAAE,EACF,OAAO,EACP,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,KAAK,EACL,MAAM,EACN,MAAM,EACN,KAAK,EACN,8BAA8B;AAC/B,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACX,wBAAwB,EACxB,aAAa,EACb,UAAU,EACX,wBAAwB;AAqDzB,OAAO,EAAE,QAAQ,EAAE,+BAAqB;AAExC,OAAO,EACL,OAAO,EACP,SAAS,EACT,cAAc,EACd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,cAAc;IACd,aAAa;IACb,aAAa;IACb,WAAW;IACX,UAAU;IACV,SAAS;IACT,aAAa;IACb,UAAU;IACV,cAAc;IACd,YAAY;IACZ,gBAAgB;IAChB,WAAW;IACX,WAAW;IACX,aAAa;IACb,cAAc;IACd,YAAY;IACZ,eAAe;IACf,UAAU;IACV,UAAU;IACV,cAAc;IACd,oBAAoB;IACpB,aAAa;IACb,YAAY;IACZ,YAAY;IACZ,cAAc;CACf,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,EAAE,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,OAAO,CACL,aAAa,CAAC,KAAK,CAAC;QACpB,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC;QAC1B,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC;QAC3B,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,CAC1B,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,4EAA4E;IAC5E,0EAA0E;IAC1E,2DAA2D;IAC3D,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CACb,wCAAwC,IAAI,CAAC,SAAS,CACpD,KAAK,CACN,qFAAqF,CACvF,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import type {\n AnyStruct,\n Infer,\n InferStructTuple,\n ObjectSchema,\n Struct,\n} from '@metamask/superstruct';\nimport {\n is,\n boolean,\n optional,\n array,\n lazy,\n nullable,\n number,\n object,\n record,\n string,\n tuple,\n refine,\n assign,\n union,\n} from '@metamask/superstruct';\nimport {\n CaipAccountIdStruct,\n CaipChainIdStruct,\n hasProperty,\n HexChecksumAddressStruct,\n isPlainObject,\n JsonStruct,\n} from '@metamask/utils';\n\nimport type {\n GenericSnapChildren,\n GenericSnapElement,\n JsonObject,\n Key,\n Nestable,\n SnapElement,\n SnapsChildren,\n StringElement,\n} from './component';\nimport type {\n AssetSelectorElement,\n AvatarElement,\n AccountSelectorElement,\n SkeletonElement,\n AddressElement,\n AddressInputElement,\n BoldElement,\n BoxElement,\n ButtonElement,\n CheckboxElement,\n CardElement,\n CopyableElement,\n DividerElement,\n DropdownElement,\n OptionElement,\n RadioElement,\n RadioGroupElement,\n FieldElement,\n FormElement,\n HeadingElement,\n ImageElement,\n InputElement,\n ItalicElement,\n JSXElement,\n LinkElement,\n RowElement,\n SpinnerElement,\n StandardFormattingElement,\n TextElement,\n TooltipElement,\n ValueElement,\n FileInputElement,\n ContainerElement,\n FooterElement,\n IconElement,\n SectionElement,\n SelectorElement,\n SelectorOptionElement,\n BannerElement,\n} from './components';\nimport { IconName } from './components';\nimport type { Describe } from '../internals';\nimport {\n literal,\n nullUnion,\n selectiveUnion,\n svg,\n typedUnion,\n} from '../internals';\nimport {\n NonEip155AssetTypeStruct,\n NonEip155ChainIdStruct,\n NonEip155CaipAccountIdsMatchedByAddressAndNamespaceStruct,\n type EmptyObject,\n} from '../types';\n\n/**\n * A struct for the {@link Key} type.\n */\nexport const KeyStruct: Describe<Key> = nullUnion([string(), number()]);\n\n/**\n * A struct for the {@link StringElement} type.\n */\nexport const StringElementStruct: Describe<StringElement> = children([\n string(),\n]);\n\n/**\n * A struct for the {@link GenericSnapElement} type.\n */\nexport const ElementStruct: Describe<GenericSnapElement> = object({\n type: string(),\n props: record(string(), JsonStruct),\n key: nullable(KeyStruct),\n});\n\n/**\n * A helper function for creating a struct for a {@link Nestable} type.\n *\n * @param struct - The struct for the type to test.\n * @returns The struct for the nestable type.\n */\nfunction nestable<Type, Schema>(\n struct: Struct<Type, Schema>,\n): Struct<Nestable<Type>, any> {\n const nestableStruct: Struct<Nestable<Type>> = selectiveUnion((value) => {\n if (Array.isArray(value)) {\n return array(lazy(() => nestableStruct));\n }\n return struct;\n });\n\n return nestableStruct;\n}\n\n/**\n * A helper function for creating a struct which allows children of a specific\n * type, as well as `null` and `boolean`.\n *\n * @param structs - The structs to allow as children.\n * @returns The struct for the children.\n */\nfunction children<Head extends AnyStruct, Tail extends AnyStruct[]>(\n structs: [head: Head, ...tail: Tail],\n): Struct<\n Nestable<Infer<Head> | InferStructTuple<Tail>[number] | boolean | null>,\n null\n> {\n const potentialUnion = structs.length === 1 ? structs[0] : nullUnion(structs);\n return nestable(\n nullable(\n selectiveUnion((value) => {\n if (typeof value === 'boolean') {\n return boolean();\n }\n return potentialUnion;\n }),\n ),\n ) as unknown as Struct<\n Nestable<Infer<Head> | InferStructTuple<Tail>[number] | boolean | null>,\n null\n >;\n}\n\n/**\n * A helper function for creating a struct which allows a single child of a specific\n * type, as well as `null` and `boolean`.\n *\n * @param struct - The struct to allow as a single child.\n * @returns The struct for the children.\n */\nfunction singleChild<Type extends AnyStruct>(\n struct: Type,\n): Struct<Infer<Type> | boolean | null, null> {\n return nullable(\n selectiveUnion((value) => {\n if (typeof value === 'boolean') {\n return boolean();\n }\n\n return struct;\n }),\n ) as unknown as Struct<Infer<Type> | boolean | null, null>;\n}\n\n/**\n * A helper function for creating a struct for a JSX element.\n *\n * @param name - The name of the element.\n * @param props - The props of the element.\n * @returns The struct for the element.\n */\nfunction element<Name extends string, Props extends ObjectSchema = EmptyObject>(\n name: Name,\n props: Props = {} as Props,\n) {\n return object({\n type: literal(name) as unknown as Struct<Name, Name>,\n props: object(props),\n key: nullable(KeyStruct),\n });\n}\n\n/**\n * A helper function for creating a struct for a JSX element with selective props.\n *\n * @param name - The name of the element.\n * @param selector - The selector function choosing the struct to validate with.\n * @returns The struct for the element.\n */\nfunction elementWithSelectiveProps<\n Name extends string,\n Selector extends (value: any) => AnyStruct,\n>(name: Name, selector: Selector) {\n return object({\n type: literal(name) as unknown as Struct<Name, Name>,\n props: selectiveUnion(selector),\n key: nullable(KeyStruct),\n });\n}\n\n/**\n * Shared struct used to validate border radius values used by various Snaps components.\n */\nexport const BorderRadiusStruct = nullUnion([\n literal('none'),\n literal('medium'),\n literal('full'),\n]);\n\n/**\n * A struct for the {@link ImageElement} type.\n */\nexport const ImageStruct: Describe<ImageElement> = element('Image', {\n src: svg(),\n alt: optional(string()),\n borderRadius: optional(BorderRadiusStruct),\n});\n\nconst IconNameStruct: Struct<`${IconName}`, null> = nullUnion(\n Object.values(IconName).map((name) => literal(name)) as any,\n);\n\n/**\n * A struct for the {@link IconElement} type.\n */\nexport const IconStruct: Describe<IconElement> = element('Icon', {\n name: IconNameStruct,\n color: optional(\n nullUnion([literal('default'), literal('primary'), literal('muted')]),\n ),\n size: optional(nullUnion([literal('md'), literal('inherit')])),\n});\n\n/**\n * A struct for the {@link ButtonElement} type.\n */\nexport const ButtonStruct: Describe<ButtonElement> = element('Button', {\n children: children([StringElementStruct, ImageStruct, IconStruct]),\n name: optional(string()),\n type: optional(nullUnion([literal('button'), literal('submit')])),\n variant: optional(nullUnion([literal('primary'), literal('destructive')])),\n size: optional(nullUnion([literal('sm'), literal('md')])),\n disabled: optional(boolean()),\n loading: optional(boolean()),\n form: optional(string()),\n});\n\n/**\n * A struct for the {@link CheckboxElement} type.\n */\nexport const CheckboxStruct: Describe<CheckboxElement> = element('Checkbox', {\n name: string(),\n checked: optional(boolean()),\n label: optional(string()),\n variant: optional(nullUnion([literal('default'), literal('toggle')])),\n disabled: optional(boolean()),\n});\n\n/**\n * A struct for the generic input element props.\n */\nexport const GenericInputPropsStruct = object({\n name: string(),\n value: optional(string()),\n placeholder: optional(string()),\n disabled: optional(boolean()),\n});\n\n/**\n * A struct for the text type input props.\n */\nexport const TextInputPropsStruct = assign(\n GenericInputPropsStruct,\n object({\n type: literal('text'),\n }),\n);\n\n/**\n * A struct for the password type input props.\n */\nexport const PasswordInputPropsStruct = assign(\n GenericInputPropsStruct,\n object({\n type: literal('password'),\n }),\n);\n\n/**\n * A struct for the number type input props.\n */\nexport const NumberInputPropsStruct = assign(\n GenericInputPropsStruct,\n object({\n type: literal('number'),\n min: optional(number()),\n max: optional(number()),\n step: optional(number()),\n }),\n);\n\n/**\n * A struct for the {@link InputElement} type.\n */\nexport const InputStruct: Describe<InputElement> = elementWithSelectiveProps(\n 'Input',\n (value) => {\n if (isPlainObject(value) && hasProperty(value, 'type')) {\n switch (value.type) {\n case 'text':\n return TextInputPropsStruct;\n case 'password':\n return PasswordInputPropsStruct;\n case 'number':\n return NumberInputPropsStruct;\n default:\n return GenericInputPropsStruct;\n }\n }\n return GenericInputPropsStruct;\n },\n);\n\n/**\n * A struct for the {@link AddressInputElement} type.\n */\nexport const AddressInputStruct: Describe<AddressInputElement> = element(\n 'AddressInput',\n {\n name: string(),\n chainId: CaipChainIdStruct,\n value: optional(string()),\n placeholder: optional(string()),\n disabled: optional(boolean()),\n displayAvatar: optional(boolean()),\n },\n);\n\n/**\n * A struct for the {@link OptionElement} type.\n */\nexport const OptionStruct: Describe<OptionElement> = element('Option', {\n value: string(),\n children: string(),\n disabled: optional(boolean()),\n});\n\n/**\n * A struct for the {@link DropdownElement} type.\n */\nexport const DropdownStruct: Describe<DropdownElement> = element('Dropdown', {\n name: string(),\n value: optional(string()),\n children: children([OptionStruct]),\n disabled: optional(boolean()),\n});\n\n/**\n * A struct for the {@link AddressElement} type.\n */\nexport const AddressStruct: Describe<AddressElement> = element('Address', {\n address: selectiveUnion((value) => {\n if (typeof value === 'string' && value.startsWith('0x')) {\n return HexChecksumAddressStruct;\n }\n return CaipAccountIdStruct;\n }),\n truncate: optional(boolean()),\n displayName: optional(boolean()),\n avatar: optional(boolean()),\n});\n\n/**\n * A struct for the {@link AccountSelectorElement} type.\n */\nexport const AccountSelectorStruct: Describe<AccountSelectorElement> = element(\n 'AccountSelector',\n {\n name: string(),\n hideExternalAccounts: optional(boolean()),\n chainIds: optional(array(CaipChainIdStruct)) as unknown as Struct<\n Infer<typeof CaipChainIdStruct>[] | undefined,\n null\n >,\n switchGlobalAccount: optional(boolean()),\n value: optional(CaipAccountIdStruct),\n disabled: optional(boolean()),\n },\n);\n\n/**\n * A struct for the {@link CardElement} type.\n */\nexport const CardStruct: Describe<CardElement> = element('Card', {\n image: optional(string()),\n title: selectiveUnion((value) => {\n if (typeof value === 'object') {\n return AddressStruct;\n }\n return string();\n }),\n description: optional(string()),\n value: string(),\n extra: optional(string()),\n});\n\n/**\n * A struct for the {@link SelectorOptionElement} type.\n */\nexport const SelectorOptionStruct: Describe<SelectorOptionElement> = element(\n 'SelectorOption',\n {\n value: string(),\n children: CardStruct,\n disabled: optional(boolean()),\n },\n);\n\n/**\n * A struct for the {@link SelectorElement} type.\n */\nexport const SelectorStruct: Describe<SelectorElement> = element('Selector', {\n name: string(),\n title: string(),\n value: optional(string()),\n children: children([SelectorOptionStruct]),\n disabled: optional(boolean()),\n});\n\n/**\n * A struct for the {@link AssetSelectorElement} type.\n */\nexport const AssetSelectorStruct: Describe<AssetSelectorElement> = element(\n 'AssetSelector',\n {\n name: string(),\n addresses: NonEip155CaipAccountIdsMatchedByAddressAndNamespaceStruct,\n chainIds: optional(array(NonEip155ChainIdStruct)) as unknown as Struct<\n Infer<typeof NonEip155ChainIdStruct>[] | undefined,\n null\n >,\n value: optional(NonEip155AssetTypeStruct),\n disabled: optional(boolean()),\n },\n);\n\n/**\n * A struct for the {@link RadioElement} type.\n */\nexport const RadioStruct: Describe<RadioElement> = element('Radio', {\n value: string(),\n children: string(),\n disabled: optional(boolean()),\n});\n\n/**\n * A struct for the {@link RadioGroupElement} type.\n */\nexport const RadioGroupStruct: Describe<RadioGroupElement> = element(\n 'RadioGroup',\n {\n name: string(),\n value: optional(string()),\n children: children([RadioStruct]),\n disabled: optional(boolean()),\n },\n);\n\n/**\n * A struct for the {@link FileInputElement} type.\n */\nexport const FileInputStruct: Describe<FileInputElement> = element(\n 'FileInput',\n {\n name: string(),\n accept: nullUnion([optional(array(string()))]),\n compact: optional(boolean()),\n disabled: optional(boolean()),\n },\n);\n\n/**\n * A subset of JSX elements that represent the tuple Box + Input of the Field children.\n */\nconst BOX_INPUT_LEFT = [\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n singleChild(lazy(() => BoxChildStruct)),\n InputStruct,\n] as [typeof BoxChildStruct, typeof InputStruct];\n\n/**\n * A subset of JSX elements that represent the tuple Input + Box of the Field children.\n */\nconst BOX_INPUT_RIGHT = [\n InputStruct,\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n singleChild(lazy(() => BoxChildStruct)),\n] as [typeof InputStruct, typeof BoxChildStruct];\n\n/**\n * A subset of JSX elements that represent the tuple Box + Input + Box of the Field children.\n */\nconst BOX_INPUT_BOTH = [\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n singleChild(lazy(() => BoxChildStruct)),\n InputStruct,\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n singleChild(lazy(() => BoxChildStruct)),\n] as [typeof BoxChildStruct, typeof InputStruct, typeof BoxChildStruct];\n\n/**\n * A subset of JSX elements that are allowed as single children of the Field component.\n */\nconst FIELD_CHILDREN_ARRAY = [\n AssetSelectorStruct,\n AddressInputStruct,\n AccountSelectorStruct,\n InputStruct,\n DropdownStruct,\n RadioGroupStruct,\n FileInputStruct,\n CheckboxStruct,\n SelectorStruct,\n] as [\n typeof AssetSelectorStruct,\n typeof AddressInputStruct,\n typeof AccountSelectorStruct,\n typeof InputStruct,\n typeof DropdownStruct,\n typeof RadioGroupStruct,\n typeof FileInputStruct,\n typeof CheckboxStruct,\n typeof SelectorStruct,\n];\n\n/**\n * A union of the allowed children of the Field component.\n * This is mainly used in the simulator for validation purposes.\n */\nexport const FieldChildUnionStruct = nullUnion([\n ...FIELD_CHILDREN_ARRAY,\n ...BOX_INPUT_LEFT,\n ...BOX_INPUT_RIGHT,\n ...BOX_INPUT_BOTH,\n]);\n\n/**\n * A subset of JSX elements that are allowed as children of the Field component.\n */\nconst FieldChildStruct = selectiveUnion((value) => {\n const isArray = Array.isArray(value);\n if (isArray && value.length === 3) {\n return tuple(BOX_INPUT_BOTH);\n }\n\n if (isArray && value.length === 2) {\n return value[0]?.type === 'Box'\n ? tuple(BOX_INPUT_LEFT)\n : tuple(BOX_INPUT_RIGHT);\n }\n\n return typedUnion(FIELD_CHILDREN_ARRAY);\n}) as unknown as Struct<\n | [InputElement, GenericSnapChildren]\n | [GenericSnapChildren, InputElement]\n | [GenericSnapChildren, InputElement, GenericSnapChildren]\n | DropdownElement\n | RadioGroupElement\n | FileInputElement\n | InputElement\n | CheckboxElement\n | SelectorElement\n | AssetSelectorElement\n | AddressInputElement\n | AccountSelectorElement,\n null\n>;\n\n/**\n * A struct for the {@link FieldElement} type.\n */\nexport const FieldStruct: Describe<FieldElement> = element('Field', {\n label: optional(string()),\n error: optional(string()),\n children: FieldChildStruct,\n});\n\n/**\n * A struct for the {@link BoldElement} type.\n */\nexport const BoldStruct: Describe<BoldElement> = element('Bold', {\n children: children([\n string(),\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n lazy(() => ItalicStruct) as unknown as Struct<\n SnapElement<JsonObject, 'Italic'>\n >,\n ]),\n});\n\n/**\n * A struct for the {@link ItalicElement} type.\n */\nexport const ItalicStruct: Describe<ItalicElement> = element('Italic', {\n children: children([\n string(),\n lazy(() => BoldStruct) as unknown as Struct<\n SnapElement<JsonObject, 'Bold'>\n >,\n ]),\n});\n\nexport const FormattingStruct: Describe<StandardFormattingElement> = typedUnion(\n [BoldStruct, ItalicStruct],\n);\n\n/**\n * A struct for the {@link AvatarElement} type.\n */\nexport const AvatarStruct = element('Avatar', {\n address: CaipAccountIdStruct,\n size: optional(nullUnion([literal('sm'), literal('md'), literal('lg')])),\n}) as unknown as Struct<AvatarElement, null>;\n\nexport const BoxChildrenStruct = children(\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n [lazy(() => BoxChildStruct)],\n) as unknown as Struct<SnapsChildren<GenericSnapElement>, null>;\n\n/**\n * A struct for the {@link BoxElement} type.\n */\nexport const BoxStruct: Describe<BoxElement> = element('Box', {\n children: BoxChildrenStruct,\n direction: optional(nullUnion([literal('horizontal'), literal('vertical')])),\n alignment: optional(\n nullUnion([\n literal('start'),\n literal('center'),\n literal('end'),\n literal('space-between'),\n literal('space-around'),\n ]),\n ),\n crossAlignment: optional(\n nullUnion([literal('start'), literal('center'), literal('end')]),\n ),\n center: optional(boolean()),\n});\n\n/**\n * A subset of JSX elements that are allowed as children of the Form component.\n */\nexport const FormChildStruct = BoxChildrenStruct;\n\n/**\n * A struct for the {@link FormElement} type.\n */\nexport const FormStruct: Describe<FormElement> = element('Form', {\n children: FormChildStruct,\n name: string(),\n});\n\nconst FooterButtonStruct = refine(ButtonStruct, 'FooterButton', (value) => {\n if (\n typeof value.props.children === 'string' ||\n typeof value.props.children === 'boolean' ||\n value.props.children === null\n ) {\n return true;\n }\n\n if (Array.isArray(value.props.children)) {\n const hasNonTextElements = value.props.children.some(\n (child) =>\n typeof child !== 'string' &&\n typeof child !== 'boolean' &&\n child !== null,\n );\n\n if (!hasNonTextElements) {\n return true;\n }\n }\n\n return 'Footer buttons may only contain text.';\n});\n\n/**\n * A struct for the {@link SectionElement} type.\n */\nexport const SectionStruct: Describe<SectionElement> = element('Section', {\n children: BoxChildrenStruct,\n direction: optional(nullUnion([literal('horizontal'), literal('vertical')])),\n alignment: optional(\n nullUnion([\n literal('start'),\n literal('center'),\n literal('end'),\n literal('space-between'),\n literal('space-around'),\n ]),\n ),\n});\n\n/**\n * A subset of JSX elements that are allowed as children of the Footer component.\n * This set should include a single button or a tuple of two buttons.\n */\n\nexport const FooterChildStruct = selectiveUnion((value) => {\n if (Array.isArray(value)) {\n return tuple([FooterButtonStruct, FooterButtonStruct]);\n }\n return FooterButtonStruct;\n});\n\n/**\n * A struct for the {@link FooterElement} type.\n */\nexport const FooterStruct: Describe<FooterElement> = element('Footer', {\n children: FooterChildStruct,\n});\n\n/**\n * A struct for the {@link CopyableElement} type.\n */\nexport const CopyableStruct: Describe<CopyableElement> = element('Copyable', {\n value: string(),\n sensitive: optional(boolean()),\n});\n\n/**\n * A struct for the {@link DividerElement} type.\n */\nexport const DividerStruct: Describe<DividerElement> = element('Divider');\n\n/**\n * A struct for the {@link HeadingElement} type.\n */\nexport const HeadingStruct: Describe<HeadingElement> = element('Heading', {\n children: StringElementStruct,\n size: optional(nullUnion([literal('sm'), literal('md'), literal('lg')])),\n});\n\n/**\n * A struct for the {@link LinkElement} type.\n */\nexport const LinkStruct: Describe<LinkElement> = element('Link', {\n href: string(),\n children: children([\n FormattingStruct,\n string(),\n IconStruct,\n ImageStruct,\n AddressStruct,\n ]),\n});\n\n/**\n * A struct for the {@link SkeletonElement} type.\n */\nexport const SkeletonStruct: Describe<SkeletonElement> = element('Skeleton', {\n width: optional(union([number(), string()])),\n height: optional(union([number(), string()])),\n borderRadius: optional(BorderRadiusStruct),\n});\n\n/**\n * A struct for the {@link TextElement} type.\n */\nexport const TextStruct: Describe<TextElement> = element('Text', {\n children: children([\n selectiveUnion((value) => {\n if (typeof value === 'string') {\n return string();\n }\n return typedUnion([\n BoldStruct,\n ItalicStruct,\n LinkStruct,\n IconStruct,\n SkeletonStruct,\n ]);\n }),\n ]),\n alignment: optional(\n nullUnion([literal('start'), literal('center'), literal('end')]),\n ),\n color: optional(\n nullUnion([\n literal('default'),\n literal('alternative'),\n literal('muted'),\n literal('error'),\n literal('success'),\n literal('warning'),\n ]),\n ),\n size: optional(nullUnion([literal('sm'), literal('md')])),\n fontWeight: optional(\n nullUnion([literal('regular'), literal('medium'), literal('bold')]),\n ),\n});\n\n/**\n * A struct for the {@link ValueElement} type.\n */\nexport const ValueStruct: Describe<ValueElement> = element('Value', {\n value: selectiveUnion((value) => {\n if (typeof value === 'string') {\n return string();\n }\n\n return TextStruct;\n }),\n extra: selectiveUnion((value) => {\n if (typeof value === 'string') {\n return string();\n }\n\n return TextStruct;\n }),\n});\n\n/**\n * A subset of JSX elements that are allowed as children of the Tooltip component.\n * This set should include all text components and the Image.\n */\nexport const TooltipChildStruct = selectiveUnion((value) => {\n if (typeof value === 'boolean') {\n return boolean();\n }\n return typedUnion([\n TextStruct,\n BoldStruct,\n ItalicStruct,\n LinkStruct,\n ImageStruct,\n IconStruct,\n ]);\n});\n\n/**\n * A subset of JSX elements that are allowed as content of the Tooltip component.\n * This set should include all text components.\n */\nexport const TooltipContentStruct = selectiveUnion((value) => {\n if (typeof value === 'string') {\n return string();\n }\n return typedUnion([\n TextStruct,\n BoldStruct,\n ItalicStruct,\n LinkStruct,\n IconStruct,\n ]);\n});\n\n/**\n * A struct for the {@link TooltipElement} type.\n */\nexport const TooltipStruct: Describe<TooltipElement> = element('Tooltip', {\n children: nullable(TooltipChildStruct),\n content: TooltipContentStruct,\n});\n\n/**\n * A struct for the {@link BannerElement} type.\n */\nexport const BannerStruct: Describe<BannerElement> = element('Banner', {\n children: children([\n TextStruct,\n LinkStruct,\n IconStruct,\n ButtonStruct,\n BoldStruct,\n ItalicStruct,\n SkeletonStruct,\n ]),\n title: string(),\n severity: union([\n literal('danger'),\n literal('info'),\n literal('success'),\n literal('warning'),\n ]),\n});\n\n/**\n * A struct for the {@link RowElement} type.\n */\nexport const RowStruct: Describe<RowElement> = element('Row', {\n label: string(),\n children: typedUnion([\n AddressStruct,\n ImageStruct,\n TextStruct,\n ValueStruct,\n LinkStruct,\n SkeletonStruct,\n ]),\n variant: optional(\n nullUnion([literal('default'), literal('warning'), literal('critical')]),\n ),\n tooltip: optional(string()),\n});\n\n/**\n * A struct for the {@link SpinnerElement} type.\n */\nexport const SpinnerStruct: Describe<SpinnerElement> = element('Spinner');\n\n/**\n * A subset of JSX elements that are allowed as children of the Box component.\n * This set includes all components, except components that need to be nested in\n * another component (e.g., Field must be contained in a Form).\n */\nexport const BoxChildStruct = typedUnion([\n AccountSelectorStruct,\n AddressStruct,\n AssetSelectorStruct,\n AddressInputStruct,\n BoldStruct,\n BoxStruct,\n ButtonStruct,\n CopyableStruct,\n DividerStruct,\n DropdownStruct,\n RadioGroupStruct,\n FieldStruct,\n FileInputStruct,\n FormStruct,\n HeadingStruct,\n InputStruct,\n ImageStruct,\n ItalicStruct,\n LinkStruct,\n RowStruct,\n SpinnerStruct,\n TextStruct,\n TooltipStruct,\n CheckboxStruct,\n CardStruct,\n IconStruct,\n SelectorStruct,\n SectionStruct,\n AvatarStruct,\n BannerStruct,\n SkeletonStruct,\n]);\n\n/**\n * A struct for the {@link ContainerElement} type.\n */\nexport const ContainerStruct: Describe<ContainerElement> = element(\n 'Container',\n {\n children: selectiveUnion((value) => {\n if (Array.isArray(value)) {\n return tuple([BoxChildStruct, FooterStruct]);\n }\n return BoxChildStruct;\n }) as unknown as Struct<\n [GenericSnapElement, FooterElement] | GenericSnapElement,\n null\n >,\n backgroundColor: optional(\n nullUnion([literal('default'), literal('alternative')]),\n ),\n },\n);\n\n/**\n * For now, the allowed JSX elements at the root are the same as the allowed\n * children of the Box component.\n */\nexport const RootJSXElementStruct = typedUnion([\n BoxChildStruct,\n ContainerStruct,\n]);\n\n/**\n * A struct for the {@link JSXElement} type.\n */\nexport const JSXElementStruct: Describe<JSXElement> = typedUnion([\n AssetSelectorStruct,\n AddressInputStruct,\n AccountSelectorStruct,\n ButtonStruct,\n InputStruct,\n FileInputStruct,\n FieldStruct,\n FormStruct,\n BoldStruct,\n ItalicStruct,\n AddressStruct,\n BoxStruct,\n CopyableStruct,\n DividerStruct,\n HeadingStruct,\n ImageStruct,\n LinkStruct,\n RowStruct,\n SpinnerStruct,\n TextStruct,\n DropdownStruct,\n OptionStruct,\n RadioGroupStruct,\n RadioStruct,\n ValueStruct,\n TooltipStruct,\n CheckboxStruct,\n FooterStruct,\n ContainerStruct,\n CardStruct,\n IconStruct,\n SelectorStruct,\n SelectorOptionStruct,\n SectionStruct,\n AvatarStruct,\n BannerStruct,\n SkeletonStruct,\n]);\n\n/**\n * Check if a value is a JSX element.\n *\n * @param value - The value to check.\n * @returns True if the value is a JSX element, false otherwise.\n */\nexport function isJSXElement(value: unknown): value is JSXElement {\n return is(value, JSXElementStruct);\n}\n\n/**\n * Check if a value is a JSX element, without validating all of its contents.\n * This is useful when you want to validate the structure of a value, but not\n * all the children.\n *\n * This should only be used when you are sure that the value is safe to use,\n * i.e., after using {@link isJSXElement}.\n *\n * @param value - The value to check.\n * @returns True if the value is a JSX element, false otherwise.\n */\nexport function isJSXElementUnsafe(value: unknown): value is JSXElement {\n return (\n isPlainObject(value) &&\n hasProperty(value, 'type') &&\n hasProperty(value, 'props') &&\n hasProperty(value, 'key')\n );\n}\n\n/**\n * Assert that a value is a JSX element.\n *\n * @param value - The value to check.\n * @throws If the value is not a JSX element.\n */\nexport function assertJSXElement(value: unknown): asserts value is JSXElement {\n // TODO: We should use the error parsing utils from `snaps-utils` to improve\n // the error messages. It currently includes colours and potentially other\n // formatting that we might not want to include in the SDK.\n if (!isJSXElement(value)) {\n throw new Error(\n `Expected a JSX element, but received ${JSON.stringify(\n value,\n )}. Please refer to the documentation for the supported JSX elements and their props.`,\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"validation.mjs","sourceRoot":"","sources":["../../src/jsx/validation.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,EAAE,EACF,OAAO,EACP,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,KAAK,EACL,MAAM,EACN,MAAM,EACN,KAAK,EACN,8BAA8B;AAC/B,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACX,wBAAwB,EACxB,aAAa,EACb,UAAU,EACX,wBAAwB;AAqDzB,OAAO,EAAE,QAAQ,EAAE,+BAAqB;AAExC,OAAO,EACL,OAAO,EACP,SAAS,EACT,cAAc,EACd,GAAG,EACH,UAAU,EACX,+BAAqB;AACtB,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,yDAAyD,EAE1D,2BAAiB;AAElB;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAkB,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,C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,UAAU;IACV,cAAc;IACd,oBAAoB;IACpB,aAAa;IACb,YAAY;IACZ,YAAY;IACZ,cAAc;CACf,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,EAAE,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,OAAO,CACL,aAAa,CAAC,KAAK,CAAC;QACpB,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC;QAC1B,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC;QAC3B,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,CAC1B,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,4EAA4E;IAC5E,0EAA0E;IAC1E,2DAA2D;IAC3D,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CACb,wCAAwC,IAAI,CAAC,SAAS,CACpD,KAAK,CACN,qFAAqF,CACvF,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import type {\n AnyStruct,\n Infer,\n InferStructTuple,\n ObjectSchema,\n Struct,\n} from '@metamask/superstruct';\nimport {\n is,\n boolean,\n optional,\n array,\n lazy,\n nullable,\n number,\n object,\n record,\n string,\n tuple,\n refine,\n assign,\n union,\n} from '@metamask/superstruct';\nimport {\n CaipAccountIdStruct,\n CaipChainIdStruct,\n hasProperty,\n HexChecksumAddressStruct,\n isPlainObject,\n JsonStruct,\n} from '@metamask/utils';\n\nimport type {\n GenericSnapChildren,\n GenericSnapElement,\n JsonObject,\n Key,\n Nestable,\n SnapElement,\n SnapsChildren,\n StringElement,\n} from './component';\nimport type {\n AssetSelectorElement,\n AvatarElement,\n AccountSelectorElement,\n SkeletonElement,\n AddressElement,\n AddressInputElement,\n BoldElement,\n BoxElement,\n ButtonElement,\n CheckboxElement,\n CardElement,\n CopyableElement,\n DividerElement,\n DropdownElement,\n OptionElement,\n RadioElement,\n RadioGroupElement,\n FieldElement,\n FormElement,\n HeadingElement,\n ImageElement,\n InputElement,\n ItalicElement,\n JSXElement,\n LinkElement,\n RowElement,\n SpinnerElement,\n StandardFormattingElement,\n TextElement,\n TooltipElement,\n ValueElement,\n FileInputElement,\n ContainerElement,\n FooterElement,\n IconElement,\n SectionElement,\n SelectorElement,\n SelectorOptionElement,\n BannerElement,\n} from './components';\nimport { IconName } from './components';\nimport type { Describe } from '../internals';\nimport {\n literal,\n nullUnion,\n selectiveUnion,\n svg,\n typedUnion,\n} from '../internals';\nimport {\n NonEip155AssetTypeStruct,\n NonEip155ChainIdStruct,\n NonEip155CaipAccountIdsMatchedByAddressAndNamespaceStruct,\n type EmptyObject,\n} from '../types';\n\n/**\n * A struct for the {@link Key} type.\n */\nexport const KeyStruct: Describe<Key> = nullUnion([string(), number()]);\n\n/**\n * A struct for the {@link StringElement} type.\n */\nexport const StringElementStruct: Describe<StringElement> = children([\n string(),\n]);\n\n/**\n * A struct for the {@link GenericSnapElement} type.\n */\nexport const ElementStruct: Describe<GenericSnapElement> = object({\n type: string(),\n props: record(string(), JsonStruct),\n key: nullable(KeyStruct),\n});\n\n/**\n * A helper function for creating a struct for a {@link Nestable} type.\n *\n * @param struct - The struct for the type to test.\n * @returns The struct for the nestable type.\n */\nfunction nestable<Type, Schema>(\n struct: Struct<Type, Schema>,\n): Struct<Nestable<Type>, any> {\n const nestableStruct: Struct<Nestable<Type>> = selectiveUnion((value) => {\n if (Array.isArray(value)) {\n return array(lazy(() => nestableStruct));\n }\n return struct;\n });\n\n return nestableStruct;\n}\n\n/**\n * A helper function for creating a struct which allows children of a specific\n * type, as well as `null` and `boolean`.\n *\n * @param structs - The structs to allow as children.\n * @returns The struct for the children.\n */\nfunction children<Head extends AnyStruct, Tail extends AnyStruct[]>(\n structs: [head: Head, ...tail: Tail],\n): Struct<\n Nestable<Infer<Head> | InferStructTuple<Tail>[number] | boolean | null>,\n null\n> {\n const potentialUnion = structs.length === 1 ? structs[0] : nullUnion(structs);\n return nestable(\n nullable(\n selectiveUnion((value) => {\n if (typeof value === 'boolean') {\n return boolean();\n }\n return potentialUnion;\n }),\n ),\n ) as unknown as Struct<\n Nestable<Infer<Head> | InferStructTuple<Tail>[number] | boolean | null>,\n null\n >;\n}\n\n/**\n * A helper function for creating a struct which allows a single child of a specific\n * type, as well as `null` and `boolean`.\n *\n * @param struct - The struct to allow as a single child.\n * @returns The struct for the children.\n */\nfunction singleChild<Type extends AnyStruct>(\n struct: Type,\n): Struct<Infer<Type> | boolean | null, null> {\n return nullable(\n selectiveUnion((value) => {\n if (typeof value === 'boolean') {\n return boolean();\n }\n\n return struct;\n }),\n ) as unknown as Struct<Infer<Type> | boolean | null, null>;\n}\n\n/**\n * A helper function for creating a struct for a JSX element.\n *\n * @param name - The name of the element.\n * @param props - The props of the element.\n * @returns The struct for the element.\n */\nfunction element<Name extends string, Props extends ObjectSchema = EmptyObject>(\n name: Name,\n props: Props = {} as Props,\n) {\n return object({\n type: literal(name) as unknown as Struct<Name, Name>,\n props: object(props),\n key: nullable(KeyStruct),\n });\n}\n\n/**\n * A helper function for creating a struct for a JSX element with selective props.\n *\n * @param name - The name of the element.\n * @param selector - The selector function choosing the struct to validate with.\n * @returns The struct for the element.\n */\nfunction elementWithSelectiveProps<\n Name extends string,\n Selector extends (value: any) => AnyStruct,\n>(name: Name, selector: Selector) {\n return object({\n type: literal(name) as unknown as Struct<Name, Name>,\n props: selectiveUnion(selector),\n key: nullable(KeyStruct),\n });\n}\n\n/**\n * Shared struct used to validate border radius values used by various Snaps components.\n */\nexport const BorderRadiusStruct = nullUnion([\n literal('none'),\n literal('medium'),\n literal('full'),\n]);\n\n/**\n * A struct for the {@link ImageElement} type.\n */\nexport const ImageStruct: Describe<ImageElement> = element('Image', {\n src: svg(),\n alt: optional(string()),\n borderRadius: optional(BorderRadiusStruct),\n});\n\nconst IconNameStruct: Struct<`${IconName}`, null> = nullUnion(\n Object.values(IconName).map((name) => literal(name)) as any,\n);\n\n/**\n * A struct for the {@link IconElement} type.\n */\nexport const IconStruct: Describe<IconElement> = element('Icon', {\n name: IconNameStruct,\n color: optional(\n nullUnion([literal('default'), literal('primary'), literal('muted')]),\n ),\n size: optional(nullUnion([literal('md'), literal('inherit')])),\n});\n\n/**\n * A struct for the {@link ButtonElement} type.\n */\nexport const ButtonStruct: Describe<ButtonElement> = element('Button', {\n children: children([StringElementStruct, ImageStruct, IconStruct]),\n name: optional(string()),\n type: optional(nullUnion([literal('button'), literal('submit')])),\n variant: optional(nullUnion([literal('primary'), literal('destructive')])),\n size: optional(nullUnion([literal('sm'), literal('md')])),\n disabled: optional(boolean()),\n loading: optional(boolean()),\n form: optional(string()),\n});\n\n/**\n * A struct for the {@link CheckboxElement} type.\n */\nexport const CheckboxStruct: Describe<CheckboxElement> = element('Checkbox', {\n name: string(),\n checked: optional(boolean()),\n label: optional(string()),\n variant: optional(nullUnion([literal('default'), literal('toggle')])),\n disabled: optional(boolean()),\n});\n\n/**\n * A struct for the generic input element props.\n */\nexport const GenericInputPropsStruct = object({\n name: string(),\n value: optional(string()),\n placeholder: optional(string()),\n disabled: optional(boolean()),\n});\n\n/**\n * A struct for the text type input props.\n */\nexport const TextInputPropsStruct = assign(\n GenericInputPropsStruct,\n object({\n type: literal('text'),\n }),\n);\n\n/**\n * A struct for the password type input props.\n */\nexport const PasswordInputPropsStruct = assign(\n GenericInputPropsStruct,\n object({\n type: literal('password'),\n }),\n);\n\n/**\n * A struct for the number type input props.\n */\nexport const NumberInputPropsStruct = assign(\n GenericInputPropsStruct,\n object({\n type: literal('number'),\n min: optional(number()),\n max: optional(number()),\n step: optional(number()),\n }),\n);\n\n/**\n * A struct for the {@link InputElement} type.\n */\nexport const InputStruct: Describe<InputElement> = elementWithSelectiveProps(\n 'Input',\n (value) => {\n if (isPlainObject(value) && hasProperty(value, 'type')) {\n switch (value.type) {\n case 'text':\n return TextInputPropsStruct;\n case 'password':\n return PasswordInputPropsStruct;\n case 'number':\n return NumberInputPropsStruct;\n default:\n return GenericInputPropsStruct;\n }\n }\n return GenericInputPropsStruct;\n },\n);\n\n/**\n * A struct for the {@link AddressInputElement} type.\n */\nexport const AddressInputStruct: Describe<AddressInputElement> = element(\n 'AddressInput',\n {\n name: string(),\n chainId: CaipChainIdStruct,\n value: optional(string()),\n placeholder: optional(string()),\n disabled: optional(boolean()),\n displayAvatar: optional(boolean()),\n },\n);\n\n/**\n * A struct for the {@link OptionElement} type.\n */\nexport const OptionStruct: Describe<OptionElement> = element('Option', {\n value: string(),\n children: string(),\n disabled: optional(boolean()),\n});\n\n/**\n * A struct for the {@link DropdownElement} type.\n */\nexport const DropdownStruct: Describe<DropdownElement> = element('Dropdown', {\n name: string(),\n value: optional(string()),\n children: children([OptionStruct]),\n disabled: optional(boolean()),\n});\n\n/**\n * A struct for the {@link AddressElement} type.\n */\nexport const AddressStruct: Describe<AddressElement> = element('Address', {\n address: selectiveUnion((value) => {\n if (typeof value === 'string' && value.startsWith('0x')) {\n return HexChecksumAddressStruct;\n }\n return CaipAccountIdStruct;\n }),\n truncate: optional(boolean()),\n displayName: optional(boolean()),\n avatar: optional(boolean()),\n});\n\n/**\n * A struct for the {@link AccountSelectorElement} type.\n */\nexport const AccountSelectorStruct: Describe<AccountSelectorElement> = element(\n 'AccountSelector',\n {\n name: string(),\n hideExternalAccounts: optional(boolean()),\n chainIds: optional(array(CaipChainIdStruct)) as unknown as Struct<\n Infer<typeof CaipChainIdStruct>[] | undefined,\n null\n >,\n switchGlobalAccount: optional(boolean()),\n value: optional(CaipAccountIdStruct),\n disabled: optional(boolean()),\n },\n);\n\n/**\n * A struct for the {@link CardElement} type.\n */\nexport const CardStruct: Describe<CardElement> = element('Card', {\n image: optional(string()),\n title: selectiveUnion((value) => {\n if (typeof value === 'object') {\n return AddressStruct;\n }\n return string();\n }),\n description: optional(string()),\n value: string(),\n extra: optional(string()),\n});\n\n/**\n * A struct for the {@link SelectorOptionElement} type.\n */\nexport const SelectorOptionStruct: Describe<SelectorOptionElement> = element(\n 'SelectorOption',\n {\n value: string(),\n children: CardStruct,\n disabled: optional(boolean()),\n },\n);\n\n/**\n * A struct for the {@link SelectorElement} type.\n */\nexport const SelectorStruct: Describe<SelectorElement> = element('Selector', {\n name: string(),\n title: string(),\n value: optional(string()),\n children: children([SelectorOptionStruct]),\n disabled: optional(boolean()),\n});\n\n/**\n * A struct for the {@link AssetSelectorElement} type.\n */\nexport const AssetSelectorStruct: Describe<AssetSelectorElement> = element(\n 'AssetSelector',\n {\n name: string(),\n addresses: NonEip155CaipAccountIdsMatchedByAddressAndNamespaceStruct,\n chainIds: optional(array(NonEip155ChainIdStruct)) as unknown as Struct<\n Infer<typeof NonEip155ChainIdStruct>[] | undefined,\n null\n >,\n value: optional(NonEip155AssetTypeStruct),\n disabled: optional(boolean()),\n },\n);\n\n/**\n * A struct for the {@link RadioElement} type.\n */\nexport const RadioStruct: Describe<RadioElement> = element('Radio', {\n value: string(),\n children: string(),\n disabled: optional(boolean()),\n});\n\n/**\n * A struct for the {@link RadioGroupElement} type.\n */\nexport const RadioGroupStruct: Describe<RadioGroupElement> = element(\n 'RadioGroup',\n {\n name: string(),\n value: optional(string()),\n children: children([RadioStruct]),\n disabled: optional(boolean()),\n },\n);\n\n/**\n * A struct for the {@link FileInputElement} type.\n */\nexport const FileInputStruct: Describe<FileInputElement> = element(\n 'FileInput',\n {\n name: string(),\n accept: nullUnion([optional(array(string()))]),\n compact: optional(boolean()),\n disabled: optional(boolean()),\n },\n);\n\n/**\n * A subset of JSX elements that represent the tuple Box + Input of the Field children.\n */\nconst BOX_INPUT_LEFT = [\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n singleChild(lazy(() => BoxChildStruct)),\n InputStruct,\n] as [typeof BoxChildStruct, typeof InputStruct];\n\n/**\n * A subset of JSX elements that represent the tuple Input + Box of the Field children.\n */\nconst BOX_INPUT_RIGHT = [\n InputStruct,\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n singleChild(lazy(() => BoxChildStruct)),\n] as [typeof InputStruct, typeof BoxChildStruct];\n\n/**\n * A subset of JSX elements that represent the tuple Box + Input + Box of the Field children.\n */\nconst BOX_INPUT_BOTH = [\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n singleChild(lazy(() => BoxChildStruct)),\n InputStruct,\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n singleChild(lazy(() => BoxChildStruct)),\n] as [typeof BoxChildStruct, typeof InputStruct, typeof BoxChildStruct];\n\n/**\n * A subset of JSX elements that are allowed as single children of the Field component.\n */\nconst FIELD_CHILDREN_ARRAY = [\n AssetSelectorStruct,\n AddressInputStruct,\n AccountSelectorStruct,\n InputStruct,\n DropdownStruct,\n RadioGroupStruct,\n FileInputStruct,\n CheckboxStruct,\n SelectorStruct,\n] as [\n typeof AssetSelectorStruct,\n typeof AddressInputStruct,\n typeof AccountSelectorStruct,\n typeof InputStruct,\n typeof DropdownStruct,\n typeof RadioGroupStruct,\n typeof FileInputStruct,\n typeof CheckboxStruct,\n typeof SelectorStruct,\n];\n\n/**\n * A union of the allowed children of the Field component.\n * This is mainly used in the simulator for validation purposes.\n */\nexport const FieldChildUnionStruct = nullUnion([\n ...FIELD_CHILDREN_ARRAY,\n ...BOX_INPUT_LEFT,\n ...BOX_INPUT_RIGHT,\n ...BOX_INPUT_BOTH,\n]);\n\n/**\n * A subset of JSX elements that are allowed as children of the Field component.\n */\nconst FieldChildStruct = selectiveUnion((value) => {\n const isArray = Array.isArray(value);\n if (isArray && value.length === 3) {\n return tuple(BOX_INPUT_BOTH);\n }\n\n if (isArray && value.length === 2) {\n return value[0]?.type === 'Box'\n ? tuple(BOX_INPUT_LEFT)\n : tuple(BOX_INPUT_RIGHT);\n }\n\n return typedUnion(FIELD_CHILDREN_ARRAY);\n}) as unknown as Struct<\n | [InputElement, GenericSnapChildren]\n | [GenericSnapChildren, InputElement]\n | [GenericSnapChildren, InputElement, GenericSnapChildren]\n | DropdownElement\n | RadioGroupElement\n | FileInputElement\n | InputElement\n | CheckboxElement\n | SelectorElement\n | AssetSelectorElement\n | AddressInputElement\n | AccountSelectorElement,\n null\n>;\n\n/**\n * A struct for the {@link FieldElement} type.\n */\nexport const FieldStruct: Describe<FieldElement> = element('Field', {\n label: optional(string()),\n error: optional(string()),\n children: FieldChildStruct,\n});\n\n/**\n * A struct for the {@link BoldElement} type.\n */\nexport const BoldStruct: Describe<BoldElement> = element('Bold', {\n children: children([\n string(),\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n lazy(() => ItalicStruct) as unknown as Struct<\n SnapElement<JsonObject, 'Italic'>\n >,\n ]),\n});\n\n/**\n * A struct for the {@link ItalicElement} type.\n */\nexport const ItalicStruct: Describe<ItalicElement> = element('Italic', {\n children: children([\n string(),\n lazy(() => BoldStruct) as unknown as Struct<\n SnapElement<JsonObject, 'Bold'>\n >,\n ]),\n});\n\nexport const FormattingStruct: Describe<StandardFormattingElement> = typedUnion(\n [BoldStruct, ItalicStruct],\n);\n\n/**\n * A struct for the {@link AvatarElement} type.\n */\nexport const AvatarStruct = element('Avatar', {\n address: CaipAccountIdStruct,\n size: optional(nullUnion([literal('sm'), literal('md'), literal('lg')])),\n}) as unknown as Struct<AvatarElement, null>;\n\nexport const BoxChildrenStruct = children(\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n [lazy(() => BoxChildStruct)],\n) as unknown as Struct<SnapsChildren<GenericSnapElement>, null>;\n\n/**\n * A struct for the {@link BoxElement} type.\n */\nexport const BoxStruct: Describe<BoxElement> = element('Box', {\n children: BoxChildrenStruct,\n direction: optional(nullUnion([literal('horizontal'), literal('vertical')])),\n alignment: optional(\n nullUnion([\n literal('start'),\n literal('center'),\n literal('end'),\n literal('space-between'),\n literal('space-around'),\n ]),\n ),\n crossAlignment: optional(\n nullUnion([literal('start'), literal('center'), literal('end')]),\n ),\n center: optional(boolean()),\n});\n\n/**\n * A subset of JSX elements that are allowed as children of the Form component.\n */\nexport const FormChildStruct = BoxChildrenStruct;\n\n/**\n * A struct for the {@link FormElement} type.\n */\nexport const FormStruct: Describe<FormElement> = element('Form', {\n children: FormChildStruct,\n name: string(),\n});\n\nconst FooterButtonStruct = refine(ButtonStruct, 'FooterButton', (value) => {\n if (\n typeof value.props.children === 'string' ||\n typeof value.props.children === 'boolean' ||\n value.props.children === null\n ) {\n return true;\n }\n\n if (Array.isArray(value.props.children)) {\n const hasNonTextElements = value.props.children.some(\n (child) =>\n typeof child !== 'string' &&\n typeof child !== 'boolean' &&\n child !== null,\n );\n\n if (!hasNonTextElements) {\n return true;\n }\n }\n\n return 'Footer buttons may only contain text.';\n});\n\n/**\n * A struct for the {@link SectionElement} type.\n */\nexport const SectionStruct: Describe<SectionElement> = element('Section', {\n children: BoxChildrenStruct,\n direction: optional(nullUnion([literal('horizontal'), literal('vertical')])),\n alignment: optional(\n nullUnion([\n literal('start'),\n literal('center'),\n literal('end'),\n literal('space-between'),\n literal('space-around'),\n ]),\n ),\n});\n\n/**\n * A subset of JSX elements that are allowed as children of the Footer component.\n * This set should include a single button or a tuple of two buttons.\n */\n\nexport const FooterChildStruct = selectiveUnion((value) => {\n if (Array.isArray(value)) {\n return tuple([FooterButtonStruct, FooterButtonStruct]);\n }\n return FooterButtonStruct;\n});\n\n/**\n * A struct for the {@link FooterElement} type.\n */\nexport const FooterStruct: Describe<FooterElement> = element('Footer', {\n children: FooterChildStruct,\n});\n\n/**\n * A struct for the {@link CopyableElement} type.\n */\nexport const CopyableStruct: Describe<CopyableElement> = element('Copyable', {\n value: string(),\n sensitive: optional(boolean()),\n});\n\n/**\n * A struct for the {@link DividerElement} type.\n */\nexport const DividerStruct: Describe<DividerElement> = element('Divider');\n\n/**\n * A struct for the {@link HeadingElement} type.\n */\nexport const HeadingStruct: Describe<HeadingElement> = element('Heading', {\n children: StringElementStruct,\n size: optional(nullUnion([literal('sm'), literal('md'), literal('lg')])),\n});\n\n/**\n * A struct for the {@link LinkElement} type.\n */\nexport const LinkStruct: Describe<LinkElement> = element('Link', {\n href: string(),\n children: children([\n FormattingStruct,\n string(),\n IconStruct,\n ImageStruct,\n AddressStruct,\n ]),\n});\n\n/**\n * A struct for the {@link SkeletonElement} type.\n */\nexport const SkeletonStruct: Describe<SkeletonElement> = element('Skeleton', {\n width: optional(union([number(), string()])),\n height: optional(union([number(), string()])),\n borderRadius: optional(BorderRadiusStruct),\n});\n\n/**\n * A struct for the {@link TextElement} type.\n */\nexport const TextStruct: Describe<TextElement> = element('Text', {\n children: children([\n selectiveUnion((value) => {\n if (typeof value === 'string') {\n return string();\n }\n return typedUnion([\n BoldStruct,\n ItalicStruct,\n LinkStruct,\n IconStruct,\n SkeletonStruct,\n ]);\n }),\n ]),\n alignment: optional(\n nullUnion([literal('start'), literal('center'), literal('end')]),\n ),\n color: optional(\n nullUnion([\n literal('default'),\n literal('alternative'),\n literal('muted'),\n literal('error'),\n literal('success'),\n literal('warning'),\n ]),\n ),\n size: optional(nullUnion([literal('sm'), literal('md')])),\n fontWeight: optional(\n nullUnion([literal('regular'), literal('medium'), literal('bold')]),\n ),\n});\n\n/**\n * A struct for the {@link ValueElement} type.\n */\nexport const ValueStruct: Describe<ValueElement> = element('Value', {\n value: selectiveUnion((value) => {\n if (typeof value === 'string') {\n return string();\n }\n\n return TextStruct;\n }),\n extra: selectiveUnion((value) => {\n if (typeof value === 'string') {\n return string();\n }\n\n return TextStruct;\n }),\n});\n\n/**\n * A subset of JSX elements that are allowed as children of the Tooltip component.\n * This set should include all text components and the Image.\n */\nexport const TooltipChildStruct = selectiveUnion((value) => {\n if (typeof value === 'boolean') {\n return boolean();\n }\n return typedUnion([\n TextStruct,\n BoldStruct,\n ItalicStruct,\n LinkStruct,\n ImageStruct,\n IconStruct,\n ]);\n});\n\n/**\n * A subset of JSX elements that are allowed as content of the Tooltip component.\n * This set should include all text components.\n */\nexport const TooltipContentStruct = selectiveUnion((value) => {\n if (typeof value === 'string') {\n return string();\n }\n return typedUnion([\n TextStruct,\n BoldStruct,\n ItalicStruct,\n LinkStruct,\n IconStruct,\n ]);\n});\n\n/**\n * A struct for the {@link TooltipElement} type.\n */\nexport const TooltipStruct: Describe<TooltipElement> = element('Tooltip', {\n children: nullable(TooltipChildStruct),\n content: TooltipContentStruct,\n});\n\n/**\n * A struct for the {@link BannerElement} type.\n */\nexport const BannerStruct: Describe<BannerElement> = element('Banner', {\n children: children([\n TextStruct,\n LinkStruct,\n IconStruct,\n ButtonStruct,\n BoldStruct,\n ItalicStruct,\n SkeletonStruct,\n ]),\n title: string(),\n severity: union([\n literal('danger'),\n literal('info'),\n literal('success'),\n literal('warning'),\n ]),\n});\n\n/**\n * A struct for the {@link RowElement} type.\n */\nexport const RowStruct: Describe<RowElement> = element('Row', {\n label: string(),\n children: lazy(() =>\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n typedUnion([ValueStruct, BoxChildStruct]),\n ) as unknown as Describe<GenericSnapElement>,\n variant: optional(\n nullUnion([literal('default'), literal('warning'), literal('critical')]),\n ),\n tooltip: optional(string()),\n});\n\n/**\n * A struct for the {@link SpinnerElement} type.\n */\nexport const SpinnerStruct: Describe<SpinnerElement> = element('Spinner');\n\n/**\n * A subset of JSX elements that are allowed as children of the Box component.\n * This set includes all components, except components that need to be nested in\n * another component (e.g., Field must be contained in a Form).\n */\nexport const BoxChildStruct = typedUnion([\n AccountSelectorStruct,\n AddressStruct,\n AssetSelectorStruct,\n AddressInputStruct,\n BoldStruct,\n BoxStruct,\n ButtonStruct,\n CopyableStruct,\n DividerStruct,\n DropdownStruct,\n RadioGroupStruct,\n FieldStruct,\n FileInputStruct,\n FormStruct,\n HeadingStruct,\n InputStruct,\n ImageStruct,\n ItalicStruct,\n LinkStruct,\n RowStruct,\n SpinnerStruct,\n TextStruct,\n TooltipStruct,\n CheckboxStruct,\n CardStruct,\n IconStruct,\n SelectorStruct,\n SectionStruct,\n AvatarStruct,\n BannerStruct,\n SkeletonStruct,\n]);\n\n/**\n * A struct for the {@link ContainerElement} type.\n */\nexport const ContainerStruct: Describe<ContainerElement> = element(\n 'Container',\n {\n children: selectiveUnion((value) => {\n if (Array.isArray(value)) {\n return tuple([BoxChildStruct, FooterStruct]);\n }\n return BoxChildStruct;\n }) as unknown as Struct<\n [GenericSnapElement, FooterElement] | GenericSnapElement,\n null\n >,\n backgroundColor: optional(\n nullUnion([literal('default'), literal('alternative')]),\n ),\n },\n);\n\n/**\n * For now, the allowed JSX elements at the root are the same as the allowed\n * children of the Box component.\n */\nexport const RootJSXElementStruct = typedUnion([\n BoxChildStruct,\n ContainerStruct,\n]);\n\n/**\n * A struct for the {@link JSXElement} type.\n */\nexport const JSXElementStruct: Describe<JSXElement> = typedUnion([\n AssetSelectorStruct,\n AddressInputStruct,\n AccountSelectorStruct,\n ButtonStruct,\n InputStruct,\n FileInputStruct,\n FieldStruct,\n FormStruct,\n BoldStruct,\n ItalicStruct,\n AddressStruct,\n BoxStruct,\n CopyableStruct,\n DividerStruct,\n HeadingStruct,\n ImageStruct,\n LinkStruct,\n RowStruct,\n SpinnerStruct,\n TextStruct,\n DropdownStruct,\n OptionStruct,\n RadioGroupStruct,\n RadioStruct,\n ValueStruct,\n TooltipStruct,\n CheckboxStruct,\n FooterStruct,\n ContainerStruct,\n CardStruct,\n IconStruct,\n SelectorStruct,\n SelectorOptionStruct,\n SectionStruct,\n AvatarStruct,\n BannerStruct,\n SkeletonStruct,\n]);\n\n/**\n * Check if a value is a JSX element.\n *\n * @param value - The value to check.\n * @returns True if the value is a JSX element, false otherwise.\n */\nexport function isJSXElement(value: unknown): value is JSXElement {\n return is(value, JSXElementStruct);\n}\n\n/**\n * Check if a value is a JSX element, without validating all of its contents.\n * This is useful when you want to validate the structure of a value, but not\n * all the children.\n *\n * This should only be used when you are sure that the value is safe to use,\n * i.e., after using {@link isJSXElement}.\n *\n * @param value - The value to check.\n * @returns True if the value is a JSX element, false otherwise.\n */\nexport function isJSXElementUnsafe(value: unknown): value is JSXElement {\n return (\n isPlainObject(value) &&\n hasProperty(value, 'type') &&\n hasProperty(value, 'props') &&\n hasProperty(value, 'key')\n );\n}\n\n/**\n * Assert that a value is a JSX element.\n *\n * @param value - The value to check.\n * @throws If the value is not a JSX element.\n */\nexport function assertJSXElement(value: unknown): asserts value is JSXElement {\n // TODO: We should use the error parsing utils from `snaps-utils` to improve\n // the error messages. It currently includes colours and potentially other\n // formatting that we might not want to include in the SDK.\n if (!isJSXElement(value)) {\n throw new Error(\n `Expected a JSX element, but received ${JSON.stringify(\n value,\n )}. Please refer to the documentation for the supported JSX elements and their props.`,\n );\n }\n}\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OnAssetsLookupResponseStruct = exports.FungibleAssetMetadataStruct = exports.AssetIconUrlStruct = exports.FungibleAssetUnitStruct = void 0;
|
|
3
|
+
exports.OnAssetsLookupResponseStruct = exports.AssetMetadataStruct = exports.NonFungibleAssetMetadataStruct = exports.NonFungibleAssetCollectionStruct = exports.FungibleAssetMetadataStruct = exports.AssetIconUrlStruct = exports.FungibleAssetUnitStruct = void 0;
|
|
4
4
|
const superstruct_1 = require("@metamask/superstruct");
|
|
5
5
|
const utils_1 = require("@metamask/utils");
|
|
6
|
+
const internals_1 = require("../../internals/index.cjs");
|
|
6
7
|
exports.FungibleAssetUnitStruct = (0, superstruct_1.object)({
|
|
7
8
|
name: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
8
9
|
symbol: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
@@ -20,6 +21,16 @@ exports.AssetIconUrlStruct = (0, superstruct_1.refine)((0, superstruct_1.string)
|
|
|
20
21
|
return 'Invalid URL';
|
|
21
22
|
}
|
|
22
23
|
});
|
|
24
|
+
/**
|
|
25
|
+
* A struct representing the metadata for a fungible asset.
|
|
26
|
+
*
|
|
27
|
+
* @property name - The name of the asset, if available.
|
|
28
|
+
* @property symbol - The symbol of the asset, if available.
|
|
29
|
+
* @property fungible - Indicates that this is a fungible asset. This is always `
|
|
30
|
+
* true` for fungible assets.
|
|
31
|
+
* @property iconUrl - The URL of the asset's icon, which can be a base64 SVG or a remote HTTPS URL.
|
|
32
|
+
* @property units - An array of units for the asset, each represented by {@link FungibleAssetUnitStruct}.
|
|
33
|
+
*/
|
|
23
34
|
exports.FungibleAssetMetadataStruct = (0, superstruct_1.object)({
|
|
24
35
|
name: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
25
36
|
symbol: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
@@ -27,7 +38,68 @@ exports.FungibleAssetMetadataStruct = (0, superstruct_1.object)({
|
|
|
27
38
|
iconUrl: exports.AssetIconUrlStruct,
|
|
28
39
|
units: (0, superstruct_1.size)((0, superstruct_1.array)(exports.FungibleAssetUnitStruct), 1, Infinity),
|
|
29
40
|
});
|
|
41
|
+
/**
|
|
42
|
+
* A collection of non-fungible assets, which can be used to group
|
|
43
|
+
* assets that share a common theme or creator.
|
|
44
|
+
*
|
|
45
|
+
* @property name - The name of the collection.
|
|
46
|
+
* @property address - The CAIP-10 account ID of the collection's creator.
|
|
47
|
+
* @property symbol - The symbol of the collection.
|
|
48
|
+
* @property tokenCount - The number of tokens in the collection, if available.
|
|
49
|
+
* @property creator - The CAIP-10 account ID of the collection's creator, if
|
|
50
|
+
* available.
|
|
51
|
+
* @property imageUrl - The URL of the collection's image.
|
|
52
|
+
*/
|
|
53
|
+
exports.NonFungibleAssetCollectionStruct = (0, superstruct_1.object)({
|
|
54
|
+
name: (0, superstruct_1.string)(),
|
|
55
|
+
address: utils_1.CaipAccountIdStruct,
|
|
56
|
+
symbol: (0, superstruct_1.string)(),
|
|
57
|
+
tokenCount: (0, superstruct_1.optional)((0, superstruct_1.number)()),
|
|
58
|
+
creator: (0, superstruct_1.optional)(utils_1.CaipAccountIdStruct),
|
|
59
|
+
imageUrl: (0, superstruct_1.optional)(exports.AssetIconUrlStruct),
|
|
60
|
+
});
|
|
61
|
+
/**
|
|
62
|
+
* A struct representing the metadata for a non-fungible asset.
|
|
63
|
+
*
|
|
64
|
+
* @property fungible - Indicates that this is a non-fungible asset.
|
|
65
|
+
* This is always `false` for non-fungible assets.
|
|
66
|
+
* @property name - The name of the asset, if available.
|
|
67
|
+
* @property symbol - The symbol of the asset, if available.
|
|
68
|
+
* @property imageUrl - The URL of the asset's image, which can be a base64 SVG or a remote HTTPS URL.
|
|
69
|
+
* @property description - A description of the asset, if available.
|
|
70
|
+
* @property acquiredAt - The timestamp when the asset was acquired, if available.
|
|
71
|
+
* @property isPossibleSpam - Indicates if the asset is possibly spam, if available.
|
|
72
|
+
* @property attributes - Additional attributes of the asset, represented as a record of string keys and
|
|
73
|
+
* string or number values.
|
|
74
|
+
* @property collection - The collection the asset belongs to, if available. See {@link NonFungibleAssetCollectionStruct}.
|
|
75
|
+
*/
|
|
76
|
+
exports.NonFungibleAssetMetadataStruct = (0, superstruct_1.object)({
|
|
77
|
+
fungible: (0, superstruct_1.literal)(false),
|
|
78
|
+
name: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
79
|
+
symbol: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
80
|
+
imageUrl: (0, superstruct_1.optional)(exports.AssetIconUrlStruct),
|
|
81
|
+
description: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
82
|
+
acquiredAt: (0, superstruct_1.optional)((0, superstruct_1.number)()),
|
|
83
|
+
isPossibleSpam: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
|
|
84
|
+
attributes: (0, superstruct_1.optional)((0, superstruct_1.record)((0, superstruct_1.string)(), (0, superstruct_1.union)([(0, superstruct_1.string)(), (0, superstruct_1.number)()]))),
|
|
85
|
+
collection: (0, superstruct_1.optional)(exports.NonFungibleAssetCollectionStruct),
|
|
86
|
+
});
|
|
87
|
+
/**
|
|
88
|
+
* A struct representing the metadata for an asset, which can be either
|
|
89
|
+
* {@link FungibleAssetMetadataStruct} or {@link NonFungibleAssetMetadataStruct}.
|
|
90
|
+
*/
|
|
91
|
+
exports.AssetMetadataStruct = (0, internals_1.selectiveUnion)((metadata) => {
|
|
92
|
+
if ((0, utils_1.isObject)(metadata) && metadata.fungible) {
|
|
93
|
+
return exports.FungibleAssetMetadataStruct;
|
|
94
|
+
}
|
|
95
|
+
return exports.NonFungibleAssetMetadataStruct;
|
|
96
|
+
});
|
|
97
|
+
/**
|
|
98
|
+
* A struct representing the response of the `onAssetsLookup` method.
|
|
99
|
+
*
|
|
100
|
+
* @property assets - An object containing a mapping between the CAIP-19 key and a metadata object or null.
|
|
101
|
+
*/
|
|
30
102
|
exports.OnAssetsLookupResponseStruct = (0, superstruct_1.object)({
|
|
31
|
-
assets: (0, superstruct_1.record)(utils_1.
|
|
103
|
+
assets: (0, superstruct_1.record)(utils_1.CaipAssetTypeOrIdStruct, (0, superstruct_1.nullable)(exports.AssetMetadataStruct)),
|
|
32
104
|
});
|
|
33
105
|
//# sourceMappingURL=assets-lookup.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assets-lookup.cjs","sourceRoot":"","sources":["../../../src/types/handlers/assets-lookup.ts"],"names":[],"mappings":";;;AACA,uDAW+B;AAC/B,2CAIyB;AAEZ,QAAA,uBAAuB,GAAG,IAAA,oBAAM,EAAC;IAC5C,IAAI,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IACxB,MAAM,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IAC1B,QAAQ,EAAE,IAAA,oBAAM,GAAE;CACnB,CAAC,CAAC;AAIU,QAAA,kBAAkB,GAAG,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;IACxE,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;QAC3B,+EAA+E;QAC/E,IAAA,cAAM,EACJ,GAAG,CAAC,QAAQ,KAAK,QAAQ;YACvB,KAAK,CAAC,UAAU,CAAC,4BAA4B,CAAC,CACjD,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,aAAa,CAAC;IACvB,CAAC;AACH,CAAC,CAAC,CAAC;AAEU,QAAA,2BAA2B,GAAG,IAAA,oBAAM,EAAC;IAChD,IAAI,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IACxB,MAAM,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IAC1B,QAAQ,EAAE,IAAA,qBAAO,EAAC,IAAI,CAAC;IACvB,OAAO,EAAE,0BAAkB;IAC3B,KAAK,EAAE,IAAA,kBAAI,EAAC,IAAA,mBAAK,EAAC,+BAAuB,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC;CACzD,CAAC,CAAC;AAEU,QAAA,4BAA4B,GAAG,IAAA,oBAAM,EAAC;IACjD,MAAM,EAAE,IAAA,oBAAM,EAAC,2BAAmB,EAAE,IAAA,sBAAQ,EAAC,mCAA2B,CAAC,CAAC;CAC3E,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport {\n array,\n size,\n literal,\n number,\n object,\n refine,\n string,\n record,\n nullable,\n optional,\n} from '@metamask/superstruct';\nimport {\n assert,\n CaipAssetTypeStruct,\n type CaipAssetType,\n} from '@metamask/utils';\n\nexport const FungibleAssetUnitStruct = object({\n name: optional(string()),\n symbol: optional(string()),\n decimals: number(),\n});\n\nexport type FungibleAssetUnit = Infer<typeof FungibleAssetUnitStruct>;\n\nexport const AssetIconUrlStruct = refine(string(), 'Asset URL', (value) => {\n try {\n const url = new URL(value);\n // For now, we require asset URLs to either be base64 SVGs or remote HTTPS URLs\n assert(\n url.protocol === 'https:' ||\n value.startsWith('data:image/svg+xml;base64,'),\n );\n return true;\n } catch {\n return 'Invalid URL';\n }\n});\n\nexport const FungibleAssetMetadataStruct = object({\n name: optional(string()),\n symbol: optional(string()),\n fungible: literal(true),\n iconUrl: AssetIconUrlStruct,\n units: size(array(FungibleAssetUnitStruct), 1, Infinity),\n});\n\nexport const OnAssetsLookupResponseStruct = object({\n assets: record(CaipAssetTypeStruct, nullable(FungibleAssetMetadataStruct)),\n});\n\nexport type FungibleAssetMetadata = Infer<typeof FungibleAssetMetadataStruct>;\n\nexport type OnAssetsLookupArguments = {\n assets: CaipAssetType[];\n};\n\n/**\n * The `onAssetsLookup` handler. This is called by MetaMask when querying about specific assets on specific chains.\n *\n * @returns The metadata about each asset. See\n * {@link OnAssetsLookupResponse}.\n */\nexport type OnAssetsLookupHandler = (\n args: OnAssetsLookupArguments,\n) => Promise<OnAssetsLookupResponse>;\n\n/**\n * The response from the query, containing metadata about each requested asset.\n *\n * @property assets - An object containing a mapping between the CAIP-19 key and a metadata object or null.\n */\nexport type OnAssetsLookupResponse = {\n assets: Record<CaipAssetType, FungibleAssetMetadata | null>;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"assets-lookup.cjs","sourceRoot":"","sources":["../../../src/types/handlers/assets-lookup.ts"],"names":[],"mappings":";;;AACA,uDAa+B;AAC/B,2CAKyB;AAGzB,yDAAiD;AAEpC,QAAA,uBAAuB,GAAG,IAAA,oBAAM,EAAC;IAC5C,IAAI,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IACxB,MAAM,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IAC1B,QAAQ,EAAE,IAAA,oBAAM,GAAE;CACnB,CAAC,CAAC;AAYU,QAAA,kBAAkB,GAAG,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;IACxE,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;QAC3B,+EAA+E;QAC/E,IAAA,c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,IAAA,sBAAQ,EAAC,0BAAkB,CAAC;IACtC,WAAW,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IAC/B,UAAU,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IAC9B,cAAc,EAAE,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC;IACnC,UAAU,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,IAAA,mBAAK,EAAC,CAAC,IAAA,oBAAM,GAAE,EAAE,IAAA,oBAAM,GAAE,CAAC,CAAC,CAAC,CAAC;IACnE,UAAU,EAAE,IAAA,sBAAQ,EAAC,wCAAgC,CAAC;CACvD,CAAC,CAAC;AAEH;;;GAGG;AACU,QAAA,mBAAmB,GAAG,IAAA,0BAAc,EAAC,CAAC,QAAQ,EAAE,EAAE;IAC7D,IAAI,IAAA,gBAAQ,EAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;QAC5C,OAAO,mCAA2B,CAAC;IACrC,CAAC;IAED,OAAO,sCAA8B,CAAC;AACxC,CAAC,CAAC,CAAC;AAEH;;;;GAIG;AACU,QAAA,4BAA4B,GAAG,IAAA,oBAAM,EAAC;IACjD,MAAM,EAAE,IAAA,oBAAM,EAAC,+BAAuB,EAAE,IAAA,sBAAQ,EAAC,2BAAmB,CAAC,CAAC;CACvE,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport {\n array,\n size,\n literal,\n number,\n object,\n refine,\n string,\n record,\n nullable,\n optional,\n boolean,\n union,\n} from '@metamask/superstruct';\nimport {\n CaipAccountIdStruct,\n CaipAssetTypeOrIdStruct,\n assert,\n isObject,\n} from '@metamask/utils';\nimport type { CaipAssetTypeOrId } from '@metamask/utils';\n\nimport { selectiveUnion } from '../../internals';\n\nexport const FungibleAssetUnitStruct = object({\n name: optional(string()),\n symbol: optional(string()),\n decimals: number(),\n});\n\n/**\n * A unit of a fungible asset, which can be used to represent\n * different denominations of the asset.\n *\n * @property name - The name of the unit, if available.\n * @property symbol - The symbol of the unit, if available.\n * @property decimals - The number of decimal places for the unit.\n */\nexport type FungibleAssetUnit = Infer<typeof FungibleAssetUnitStruct>;\n\nexport const AssetIconUrlStruct = refine(string(), 'Asset URL', (value) => {\n try {\n const url = new URL(value);\n // For now, we require asset URLs to either be base64 SVGs or remote HTTPS URLs\n assert(\n url.protocol === 'https:' ||\n value.startsWith('data:image/svg+xml;base64,'),\n );\n return true;\n } catch {\n return 'Invalid URL';\n }\n});\n\n/**\n * A struct representing the metadata for a fungible asset.\n *\n * @property name - The name of the asset, if available.\n * @property symbol - The symbol of the asset, if available.\n * @property fungible - Indicates that this is a fungible asset. This is always `\n * true` for fungible assets.\n * @property iconUrl - The URL of the asset's icon, which can be a base64 SVG or a remote HTTPS URL.\n * @property units - An array of units for the asset, each represented by {@link FungibleAssetUnitStruct}.\n */\nexport const FungibleAssetMetadataStruct = object({\n name: optional(string()),\n symbol: optional(string()),\n fungible: literal(true),\n iconUrl: AssetIconUrlStruct,\n units: size(array(FungibleAssetUnitStruct), 1, Infinity),\n});\n\n/**\n * A collection of non-fungible assets, which can be used to group\n * assets that share a common theme or creator.\n *\n * @property name - The name of the collection.\n * @property address - The CAIP-10 account ID of the collection's creator.\n * @property symbol - The symbol of the collection.\n * @property tokenCount - The number of tokens in the collection, if available.\n * @property creator - The CAIP-10 account ID of the collection's creator, if\n * available.\n * @property imageUrl - The URL of the collection's image.\n */\nexport const NonFungibleAssetCollectionStruct = object({\n name: string(),\n address: CaipAccountIdStruct,\n symbol: string(),\n tokenCount: optional(number()),\n creator: optional(CaipAccountIdStruct),\n imageUrl: optional(AssetIconUrlStruct),\n});\n\n/**\n * A collection of non-fungible assets, which can be used to group\n * assets that share a common theme or creator.\n *\n * @property name - The name of the collection.\n * @property address - The CAIP-10 account ID of the collection's creator.\n * @property symbol - The symbol of the collection.\n * @property tokenCount - The number of tokens in the collection, if available.\n * @property creator - The CAIP-10 account ID of the collection's creator, if\n * available.\n * @property imageUrl - The URL of the collection's image.\n */\nexport type NonFungibleAssetCollection = Infer<\n typeof NonFungibleAssetCollectionStruct\n>;\n\n/**\n * A struct representing the metadata for a non-fungible asset.\n *\n * @property fungible - Indicates that this is a non-fungible asset.\n * This is always `false` for non-fungible assets.\n * @property name - The name of the asset, if available.\n * @property symbol - The symbol of the asset, if available.\n * @property imageUrl - The URL of the asset's image, which can be a base64 SVG or a remote HTTPS URL.\n * @property description - A description of the asset, if available.\n * @property acquiredAt - The timestamp when the asset was acquired, if available.\n * @property isPossibleSpam - Indicates if the asset is possibly spam, if available.\n * @property attributes - Additional attributes of the asset, represented as a record of string keys and\n * string or number values.\n * @property collection - The collection the asset belongs to, if available. See {@link NonFungibleAssetCollectionStruct}.\n */\nexport const NonFungibleAssetMetadataStruct = object({\n fungible: literal(false),\n name: optional(string()),\n symbol: optional(string()),\n imageUrl: optional(AssetIconUrlStruct),\n description: optional(string()),\n acquiredAt: optional(number()),\n isPossibleSpam: optional(boolean()),\n attributes: optional(record(string(), union([string(), number()]))),\n collection: optional(NonFungibleAssetCollectionStruct),\n});\n\n/**\n * A struct representing the metadata for an asset, which can be either\n * {@link FungibleAssetMetadataStruct} or {@link NonFungibleAssetMetadataStruct}.\n */\nexport const AssetMetadataStruct = selectiveUnion((metadata) => {\n if (isObject(metadata) && metadata.fungible) {\n return FungibleAssetMetadataStruct;\n }\n\n return NonFungibleAssetMetadataStruct;\n});\n\n/**\n * A struct representing the response of the `onAssetsLookup` method.\n *\n * @property assets - An object containing a mapping between the CAIP-19 key and a metadata object or null.\n */\nexport const OnAssetsLookupResponseStruct = object({\n assets: record(CaipAssetTypeOrIdStruct, nullable(AssetMetadataStruct)),\n});\n\n/**\n * The metadata for an asset, which can be either fungible or non-fungible.\n *\n */\nexport type AssetMetadata = Infer<typeof AssetMetadataStruct>;\n\n/**\n * The metadata for a fungible asset.\n *\n * @property fungible - Indicates that this is a fungible asset.\n * This is always `true` for fungible assets.\n * @property name - The name of the asset.\n * @property symbol - The symbol of the asset.\n * @property iconUrl - The URL of the asset's icon.\n * @property units - An array of units for the asset, each represented by {@link FungibleAssetUnit}.\n */\nexport type FungibleAssetMetadata = Infer<typeof FungibleAssetMetadataStruct>;\n\n/**\n * The metadata for a non-fungible asset.\n *\n * @property fungible - Indicates that this is a non-fungible asset.\n * This is always `false` for non-fungible assets.\n * @property name - The name of the asset.\n * @property symbol - The symbol of the asset.\n * @property imageUrl - The URL of the asset's image.\n * @property description - A description of the asset.\n * @property acquiredAt - The timestamp when the asset was acquired, if available.\n * @property isPossibleSpam - Indicates if the asset is possibly spam, if available.\n * @property attributes - Additional attributes of the asset, represented as a record of string keys and\n * string or number values.\n * @property collection - The collection the asset belongs to, if available. See {@link NonFungibleAssetCollection}.\n */\nexport type NonFungibleAssetMetadata = Infer<\n typeof NonFungibleAssetMetadataStruct\n>;\n\n/**\n * The arguments for the `onAssetsLookup` handler.\n *\n * @property assets - An array of CAIP-19 asset types to look up.\n */\nexport type OnAssetsLookupArguments = {\n assets: CaipAssetTypeOrId[];\n};\n\n/**\n * The `onAssetsLookup` handler. This is called by MetaMask when querying about specific assets on specific chains.\n *\n * @returns The metadata about each asset. See\n * {@link OnAssetsLookupResponse}.\n */\nexport type OnAssetsLookupHandler = (\n args: OnAssetsLookupArguments,\n) => Promise<OnAssetsLookupResponse>;\n\n/**\n * The response from the query, containing metadata about each requested asset.\n *\n * @property assets - An object containing a mapping between the CAIP-19 key and a metadata object or null.\n */\nexport type OnAssetsLookupResponse = {\n assets: Record<CaipAssetTypeOrId, AssetMetadata | null>;\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Infer } from "@metamask/superstruct";
|
|
2
|
-
import {
|
|
2
|
+
import type { CaipAssetTypeOrId } from "@metamask/utils";
|
|
3
3
|
export declare const FungibleAssetUnitStruct: import("@metamask/superstruct").Struct<{
|
|
4
4
|
decimals: number;
|
|
5
5
|
symbol?: string | undefined;
|
|
@@ -9,8 +9,26 @@ export declare const FungibleAssetUnitStruct: import("@metamask/superstruct").St
|
|
|
9
9
|
symbol: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
10
10
|
decimals: import("@metamask/superstruct").Struct<number, null>;
|
|
11
11
|
}>;
|
|
12
|
+
/**
|
|
13
|
+
* A unit of a fungible asset, which can be used to represent
|
|
14
|
+
* different denominations of the asset.
|
|
15
|
+
*
|
|
16
|
+
* @property name - The name of the unit, if available.
|
|
17
|
+
* @property symbol - The symbol of the unit, if available.
|
|
18
|
+
* @property decimals - The number of decimal places for the unit.
|
|
19
|
+
*/
|
|
12
20
|
export type FungibleAssetUnit = Infer<typeof FungibleAssetUnitStruct>;
|
|
13
21
|
export declare const AssetIconUrlStruct: import("@metamask/superstruct").Struct<string, null>;
|
|
22
|
+
/**
|
|
23
|
+
* A struct representing the metadata for a fungible asset.
|
|
24
|
+
*
|
|
25
|
+
* @property name - The name of the asset, if available.
|
|
26
|
+
* @property symbol - The symbol of the asset, if available.
|
|
27
|
+
* @property fungible - Indicates that this is a fungible asset. This is always `
|
|
28
|
+
* true` for fungible assets.
|
|
29
|
+
* @property iconUrl - The URL of the asset's icon, which can be a base64 SVG or a remote HTTPS URL.
|
|
30
|
+
* @property units - An array of units for the asset, each represented by {@link FungibleAssetUnitStruct}.
|
|
31
|
+
*/
|
|
14
32
|
export declare const FungibleAssetMetadataStruct: import("@metamask/superstruct").Struct<{
|
|
15
33
|
fungible: true;
|
|
16
34
|
iconUrl: string;
|
|
@@ -40,8 +58,142 @@ export declare const FungibleAssetMetadataStruct: import("@metamask/superstruct"
|
|
|
40
58
|
decimals: import("@metamask/superstruct").Struct<number, null>;
|
|
41
59
|
}>>;
|
|
42
60
|
}>;
|
|
61
|
+
/**
|
|
62
|
+
* A collection of non-fungible assets, which can be used to group
|
|
63
|
+
* assets that share a common theme or creator.
|
|
64
|
+
*
|
|
65
|
+
* @property name - The name of the collection.
|
|
66
|
+
* @property address - The CAIP-10 account ID of the collection's creator.
|
|
67
|
+
* @property symbol - The symbol of the collection.
|
|
68
|
+
* @property tokenCount - The number of tokens in the collection, if available.
|
|
69
|
+
* @property creator - The CAIP-10 account ID of the collection's creator, if
|
|
70
|
+
* available.
|
|
71
|
+
* @property imageUrl - The URL of the collection's image.
|
|
72
|
+
*/
|
|
73
|
+
export declare const NonFungibleAssetCollectionStruct: import("@metamask/superstruct").Struct<{
|
|
74
|
+
symbol: string;
|
|
75
|
+
name: string;
|
|
76
|
+
address: `${string}:${string}:${string}`;
|
|
77
|
+
tokenCount?: number | undefined;
|
|
78
|
+
creator?: `${string}:${string}:${string}` | undefined;
|
|
79
|
+
imageUrl?: string | undefined;
|
|
80
|
+
}, {
|
|
81
|
+
name: import("@metamask/superstruct").Struct<string, null>;
|
|
82
|
+
address: import("@metamask/superstruct").Struct<`${string}:${string}:${string}`, null>;
|
|
83
|
+
symbol: import("@metamask/superstruct").Struct<string, null>;
|
|
84
|
+
tokenCount: import("@metamask/superstruct").Struct<number | undefined, null>;
|
|
85
|
+
creator: import("@metamask/superstruct").Struct<`${string}:${string}:${string}` | undefined, null>;
|
|
86
|
+
imageUrl: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
87
|
+
}>;
|
|
88
|
+
/**
|
|
89
|
+
* A collection of non-fungible assets, which can be used to group
|
|
90
|
+
* assets that share a common theme or creator.
|
|
91
|
+
*
|
|
92
|
+
* @property name - The name of the collection.
|
|
93
|
+
* @property address - The CAIP-10 account ID of the collection's creator.
|
|
94
|
+
* @property symbol - The symbol of the collection.
|
|
95
|
+
* @property tokenCount - The number of tokens in the collection, if available.
|
|
96
|
+
* @property creator - The CAIP-10 account ID of the collection's creator, if
|
|
97
|
+
* available.
|
|
98
|
+
* @property imageUrl - The URL of the collection's image.
|
|
99
|
+
*/
|
|
100
|
+
export type NonFungibleAssetCollection = Infer<typeof NonFungibleAssetCollectionStruct>;
|
|
101
|
+
/**
|
|
102
|
+
* A struct representing the metadata for a non-fungible asset.
|
|
103
|
+
*
|
|
104
|
+
* @property fungible - Indicates that this is a non-fungible asset.
|
|
105
|
+
* This is always `false` for non-fungible assets.
|
|
106
|
+
* @property name - The name of the asset, if available.
|
|
107
|
+
* @property symbol - The symbol of the asset, if available.
|
|
108
|
+
* @property imageUrl - The URL of the asset's image, which can be a base64 SVG or a remote HTTPS URL.
|
|
109
|
+
* @property description - A description of the asset, if available.
|
|
110
|
+
* @property acquiredAt - The timestamp when the asset was acquired, if available.
|
|
111
|
+
* @property isPossibleSpam - Indicates if the asset is possibly spam, if available.
|
|
112
|
+
* @property attributes - Additional attributes of the asset, represented as a record of string keys and
|
|
113
|
+
* string or number values.
|
|
114
|
+
* @property collection - The collection the asset belongs to, if available. See {@link NonFungibleAssetCollectionStruct}.
|
|
115
|
+
*/
|
|
116
|
+
export declare const NonFungibleAssetMetadataStruct: import("@metamask/superstruct").Struct<{
|
|
117
|
+
fungible: false;
|
|
118
|
+
symbol?: string | undefined;
|
|
119
|
+
description?: string | undefined;
|
|
120
|
+
name?: string | undefined;
|
|
121
|
+
imageUrl?: string | undefined;
|
|
122
|
+
acquiredAt?: number | undefined;
|
|
123
|
+
isPossibleSpam?: boolean | undefined;
|
|
124
|
+
attributes?: Record<string, string | number> | undefined;
|
|
125
|
+
collection?: {
|
|
126
|
+
symbol: string;
|
|
127
|
+
name: string;
|
|
128
|
+
address: `${string}:${string}:${string}`;
|
|
129
|
+
tokenCount?: number | undefined;
|
|
130
|
+
creator?: `${string}:${string}:${string}` | undefined;
|
|
131
|
+
imageUrl?: string | undefined;
|
|
132
|
+
} | undefined;
|
|
133
|
+
}, {
|
|
134
|
+
fungible: import("@metamask/superstruct").Struct<false, false>;
|
|
135
|
+
name: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
136
|
+
symbol: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
137
|
+
imageUrl: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
138
|
+
description: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
139
|
+
acquiredAt: import("@metamask/superstruct").Struct<number | undefined, null>;
|
|
140
|
+
isPossibleSpam: import("@metamask/superstruct").Struct<boolean | undefined, null>;
|
|
141
|
+
attributes: import("@metamask/superstruct").Struct<Record<string, string | number> | undefined, null>;
|
|
142
|
+
collection: import("@metamask/superstruct").Struct<{
|
|
143
|
+
symbol: string;
|
|
144
|
+
name: string;
|
|
145
|
+
address: `${string}:${string}:${string}`;
|
|
146
|
+
tokenCount?: number | undefined;
|
|
147
|
+
creator?: `${string}:${string}:${string}` | undefined;
|
|
148
|
+
imageUrl?: string | undefined;
|
|
149
|
+
} | undefined, {
|
|
150
|
+
name: import("@metamask/superstruct").Struct<string, null>;
|
|
151
|
+
address: import("@metamask/superstruct").Struct<`${string}:${string}:${string}`, null>;
|
|
152
|
+
symbol: import("@metamask/superstruct").Struct<string, null>;
|
|
153
|
+
tokenCount: import("@metamask/superstruct").Struct<number | undefined, null>;
|
|
154
|
+
creator: import("@metamask/superstruct").Struct<`${string}:${string}:${string}` | undefined, null>;
|
|
155
|
+
imageUrl: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
156
|
+
}>;
|
|
157
|
+
}>;
|
|
158
|
+
/**
|
|
159
|
+
* A struct representing the metadata for an asset, which can be either
|
|
160
|
+
* {@link FungibleAssetMetadataStruct} or {@link NonFungibleAssetMetadataStruct}.
|
|
161
|
+
*/
|
|
162
|
+
export declare const AssetMetadataStruct: import("@metamask/superstruct").Struct<{
|
|
163
|
+
fungible: true;
|
|
164
|
+
iconUrl: string;
|
|
165
|
+
units: {
|
|
166
|
+
decimals: number;
|
|
167
|
+
symbol?: string | undefined;
|
|
168
|
+
name?: string | undefined;
|
|
169
|
+
}[];
|
|
170
|
+
symbol?: string | undefined;
|
|
171
|
+
name?: string | undefined;
|
|
172
|
+
} | {
|
|
173
|
+
fungible: false;
|
|
174
|
+
symbol?: string | undefined;
|
|
175
|
+
description?: string | undefined;
|
|
176
|
+
name?: string | undefined;
|
|
177
|
+
imageUrl?: string | undefined;
|
|
178
|
+
acquiredAt?: number | undefined;
|
|
179
|
+
isPossibleSpam?: boolean | undefined;
|
|
180
|
+
attributes?: Record<string, string | number> | undefined;
|
|
181
|
+
collection?: {
|
|
182
|
+
symbol: string;
|
|
183
|
+
name: string;
|
|
184
|
+
address: `${string}:${string}:${string}`;
|
|
185
|
+
tokenCount?: number | undefined;
|
|
186
|
+
creator?: `${string}:${string}:${string}` | undefined;
|
|
187
|
+
imageUrl?: string | undefined;
|
|
188
|
+
} | undefined;
|
|
189
|
+
}, null>;
|
|
190
|
+
/**
|
|
191
|
+
* A struct representing the response of the `onAssetsLookup` method.
|
|
192
|
+
*
|
|
193
|
+
* @property assets - An object containing a mapping between the CAIP-19 key and a metadata object or null.
|
|
194
|
+
*/
|
|
43
195
|
export declare const OnAssetsLookupResponseStruct: import("@metamask/superstruct").Struct<{
|
|
44
|
-
assets: Record<`${string}:${string}/${string}:${string}`, {
|
|
196
|
+
assets: Record<`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`, {
|
|
45
197
|
fungible: true;
|
|
46
198
|
iconUrl: string;
|
|
47
199
|
units: {
|
|
@@ -51,9 +203,26 @@ export declare const OnAssetsLookupResponseStruct: import("@metamask/superstruct
|
|
|
51
203
|
}[];
|
|
52
204
|
symbol?: string | undefined;
|
|
53
205
|
name?: string | undefined;
|
|
206
|
+
} | {
|
|
207
|
+
fungible: false;
|
|
208
|
+
symbol?: string | undefined;
|
|
209
|
+
description?: string | undefined;
|
|
210
|
+
name?: string | undefined;
|
|
211
|
+
imageUrl?: string | undefined;
|
|
212
|
+
acquiredAt?: number | undefined;
|
|
213
|
+
isPossibleSpam?: boolean | undefined;
|
|
214
|
+
attributes?: Record<string, string | number> | undefined;
|
|
215
|
+
collection?: {
|
|
216
|
+
symbol: string;
|
|
217
|
+
name: string;
|
|
218
|
+
address: `${string}:${string}:${string}`;
|
|
219
|
+
tokenCount?: number | undefined;
|
|
220
|
+
creator?: `${string}:${string}:${string}` | undefined;
|
|
221
|
+
imageUrl?: string | undefined;
|
|
222
|
+
} | undefined;
|
|
54
223
|
} | null>;
|
|
55
224
|
}, {
|
|
56
|
-
assets: import("@metamask/superstruct").Struct<Record<`${string}:${string}/${string}:${string}`, {
|
|
225
|
+
assets: import("@metamask/superstruct").Struct<Record<`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`, {
|
|
57
226
|
fungible: true;
|
|
58
227
|
iconUrl: string;
|
|
59
228
|
units: {
|
|
@@ -63,11 +232,64 @@ export declare const OnAssetsLookupResponseStruct: import("@metamask/superstruct
|
|
|
63
232
|
}[];
|
|
64
233
|
symbol?: string | undefined;
|
|
65
234
|
name?: string | undefined;
|
|
235
|
+
} | {
|
|
236
|
+
fungible: false;
|
|
237
|
+
symbol?: string | undefined;
|
|
238
|
+
description?: string | undefined;
|
|
239
|
+
name?: string | undefined;
|
|
240
|
+
imageUrl?: string | undefined;
|
|
241
|
+
acquiredAt?: number | undefined;
|
|
242
|
+
isPossibleSpam?: boolean | undefined;
|
|
243
|
+
attributes?: Record<string, string | number> | undefined;
|
|
244
|
+
collection?: {
|
|
245
|
+
symbol: string;
|
|
246
|
+
name: string;
|
|
247
|
+
address: `${string}:${string}:${string}`;
|
|
248
|
+
tokenCount?: number | undefined;
|
|
249
|
+
creator?: `${string}:${string}:${string}` | undefined;
|
|
250
|
+
imageUrl?: string | undefined;
|
|
251
|
+
} | undefined;
|
|
66
252
|
} | null>, null>;
|
|
67
253
|
}>;
|
|
254
|
+
/**
|
|
255
|
+
* The metadata for an asset, which can be either fungible or non-fungible.
|
|
256
|
+
*
|
|
257
|
+
*/
|
|
258
|
+
export type AssetMetadata = Infer<typeof AssetMetadataStruct>;
|
|
259
|
+
/**
|
|
260
|
+
* The metadata for a fungible asset.
|
|
261
|
+
*
|
|
262
|
+
* @property fungible - Indicates that this is a fungible asset.
|
|
263
|
+
* This is always `true` for fungible assets.
|
|
264
|
+
* @property name - The name of the asset.
|
|
265
|
+
* @property symbol - The symbol of the asset.
|
|
266
|
+
* @property iconUrl - The URL of the asset's icon.
|
|
267
|
+
* @property units - An array of units for the asset, each represented by {@link FungibleAssetUnit}.
|
|
268
|
+
*/
|
|
68
269
|
export type FungibleAssetMetadata = Infer<typeof FungibleAssetMetadataStruct>;
|
|
270
|
+
/**
|
|
271
|
+
* The metadata for a non-fungible asset.
|
|
272
|
+
*
|
|
273
|
+
* @property fungible - Indicates that this is a non-fungible asset.
|
|
274
|
+
* This is always `false` for non-fungible assets.
|
|
275
|
+
* @property name - The name of the asset.
|
|
276
|
+
* @property symbol - The symbol of the asset.
|
|
277
|
+
* @property imageUrl - The URL of the asset's image.
|
|
278
|
+
* @property description - A description of the asset.
|
|
279
|
+
* @property acquiredAt - The timestamp when the asset was acquired, if available.
|
|
280
|
+
* @property isPossibleSpam - Indicates if the asset is possibly spam, if available.
|
|
281
|
+
* @property attributes - Additional attributes of the asset, represented as a record of string keys and
|
|
282
|
+
* string or number values.
|
|
283
|
+
* @property collection - The collection the asset belongs to, if available. See {@link NonFungibleAssetCollection}.
|
|
284
|
+
*/
|
|
285
|
+
export type NonFungibleAssetMetadata = Infer<typeof NonFungibleAssetMetadataStruct>;
|
|
286
|
+
/**
|
|
287
|
+
* The arguments for the `onAssetsLookup` handler.
|
|
288
|
+
*
|
|
289
|
+
* @property assets - An array of CAIP-19 asset types to look up.
|
|
290
|
+
*/
|
|
69
291
|
export type OnAssetsLookupArguments = {
|
|
70
|
-
assets:
|
|
292
|
+
assets: CaipAssetTypeOrId[];
|
|
71
293
|
};
|
|
72
294
|
/**
|
|
73
295
|
* The `onAssetsLookup` handler. This is called by MetaMask when querying about specific assets on specific chains.
|
|
@@ -82,6 +304,6 @@ export type OnAssetsLookupHandler = (args: OnAssetsLookupArguments) => Promise<O
|
|
|
82
304
|
* @property assets - An object containing a mapping between the CAIP-19 key and a metadata object or null.
|
|
83
305
|
*/
|
|
84
306
|
export type OnAssetsLookupResponse = {
|
|
85
|
-
assets: Record<
|
|
307
|
+
assets: Record<CaipAssetTypeOrId, AssetMetadata | null>;
|
|
86
308
|
};
|
|
87
309
|
//# sourceMappingURL=assets-lookup.d.cts.map
|