@metamask/snaps-sdk
Version:
A library containing the core functionality for building MetaMask Snaps
1 lines • 3.2 kB
Source Map (JSON)
{"version":3,"file":"interface.mjs","sourceRoot":"","sources":["../../src/types/interface.ts"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,MAAM,EACN,KAAK,EACN,8BAA8B;AAC/B,OAAO,EACL,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,QAAQ,EACT,wBAAwB;AAEzB,OAAO,EACL,wBAAwB,EACxB,UAAU,EACV,0BAA0B,EAC3B,6BAAmB;AACpB,OAAO,EAAE,cAAc,EAAE,+BAAqB;AAE9C,OAAO,EAAE,oBAAoB,EAAE,yBAAe;AAE9C,OAAO,EAAE,eAAe,EAAE,wBAAc;AAExC;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC;IAC/B,0BAA0B;IAC1B,wBAAwB;IACxB,UAAU;IACV,MAAM,EAAE;IACR,OAAO,EAAE;IACT,mBAAmB;CACpB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;AAEvE,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CACxC,MAAM,EAAE,EACR,KAAK,CAAC,CAAC,eAAe,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAChD,CAAC;AAOF,MAAM,CAAC,MAAM,wBAAwB,GAAG,cAAc,CAAC,CAAC,KAAK,EAAE,EAAE;IAC/D,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC;QACpD,OAAO,eAAe,CAAC;IACzB,CAAC;IACD,OAAO,oBAAoB,CAAC;AAC9B,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,MAAM,EAAE,EAAE,UAAU,CAAC,CAAC;AAGnE,MAAM,CAAN,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,kCAAmB,CAAA;IACnB,gCAAiB,CAAA;IACjB,4CAA6B,CAAA;IAC7B,oCAAqB,CAAA;AACvB,CAAC,EALW,WAAW,KAAX,WAAW,QAKtB","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport {\n boolean,\n nullable,\n record,\n string,\n union,\n} from '@metamask/superstruct';\nimport {\n CaipAccountIdStruct,\n JsonStruct,\n hasProperty,\n isObject,\n} from '@metamask/utils';\n\nimport {\n AssetSelectorStateStruct,\n FileStruct,\n AccountSelectorStateStruct,\n} from './handlers';\nimport { selectiveUnion } from '../internals';\nimport type { JSXElement } from '../jsx';\nimport { RootJSXElementStruct } from '../jsx';\nimport type { Component } from '../ui';\nimport { ComponentStruct } from '../ui';\n\n/**\n * To avoid typing problems with the interface state when manipulating it we\n * have to differentiate the state of a form (that will be contained inside the\n * root state) and the root state since a key in the root stat can contain\n * either the value of an input or a sub-state of a form.\n */\n\nexport const StateStruct = union([\n AccountSelectorStateStruct,\n AssetSelectorStateStruct,\n FileStruct,\n string(),\n boolean(),\n CaipAccountIdStruct,\n]);\n\nexport const FormStateStruct = record(string(), nullable(StateStruct));\n\nexport const InterfaceStateStruct = record(\n string(),\n union([FormStateStruct, nullable(StateStruct)]),\n);\n\nexport type State = Infer<typeof StateStruct>;\nexport type FormState = Infer<typeof FormStateStruct>;\nexport type InterfaceState = Infer<typeof InterfaceStateStruct>;\n\nexport type ComponentOrElement = Component | JSXElement;\nexport const ComponentOrElementStruct = selectiveUnion((value) => {\n if (isObject(value) && !hasProperty(value, 'props')) {\n return ComponentStruct;\n }\n return RootJSXElementStruct;\n});\n\nexport const InterfaceContextStruct = record(string(), JsonStruct);\nexport type InterfaceContext = Infer<typeof InterfaceContextStruct>;\n\nexport enum ContentType {\n Insight = 'Insight',\n Dialog = 'Dialog',\n Notification = 'Notification',\n HomePage = 'HomePage',\n}\n"]}