@metamask/snaps-sdk 1.3.2 → 2.0.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.
Files changed (96) hide show
  1. package/CHANGELOG.md +21 -1
  2. package/dist/cjs/types/handlers/index.js +2 -0
  3. package/dist/cjs/types/handlers/index.js.map +1 -1
  4. package/dist/cjs/types/handlers/signature.js +6 -0
  5. package/dist/cjs/types/handlers/signature.js.map +1 -0
  6. package/dist/cjs/types/handlers/transaction.js.map +1 -1
  7. package/dist/cjs/types/handlers/user-input.js +51 -0
  8. package/dist/cjs/types/handlers/user-input.js.map +1 -0
  9. package/dist/cjs/types/index.js +1 -0
  10. package/dist/cjs/types/index.js.map +1 -1
  11. package/dist/cjs/types/interface.js +26 -0
  12. package/dist/cjs/types/interface.js.map +1 -0
  13. package/dist/cjs/types/methods/create-interface.js +6 -0
  14. package/dist/cjs/types/methods/create-interface.js.map +1 -0
  15. package/dist/cjs/types/methods/dialog.js.map +1 -1
  16. package/dist/cjs/types/methods/get-client-status.js +10 -0
  17. package/dist/cjs/types/methods/get-client-status.js.map +1 -0
  18. package/dist/cjs/types/methods/get-interface-state.js +6 -0
  19. package/dist/cjs/types/methods/get-interface-state.js.map +1 -0
  20. package/dist/cjs/types/methods/index.js +4 -0
  21. package/dist/cjs/types/methods/index.js.map +1 -1
  22. package/dist/cjs/types/methods/update-interface.js +6 -0
  23. package/dist/cjs/types/methods/update-interface.js.map +1 -0
  24. package/dist/cjs/ui/components/button.js +59 -0
  25. package/dist/cjs/ui/components/button.js.map +1 -0
  26. package/dist/cjs/ui/components/form.js +41 -0
  27. package/dist/cjs/ui/components/form.js.map +1 -0
  28. package/dist/cjs/ui/components/index.js +3 -0
  29. package/dist/cjs/ui/components/index.js.map +1 -1
  30. package/dist/cjs/ui/components/input.js +52 -0
  31. package/dist/cjs/ui/components/input.js.map +1 -0
  32. package/dist/cjs/ui/components/panel.js +7 -1
  33. package/dist/cjs/ui/components/panel.js.map +1 -1
  34. package/dist/cjs/ui/nodes.js +3 -0
  35. package/dist/cjs/ui/nodes.js.map +1 -1
  36. package/dist/esm/types/handlers/home-page.js.map +1 -1
  37. package/dist/esm/types/handlers/index.js +2 -0
  38. package/dist/esm/types/handlers/index.js.map +1 -1
  39. package/dist/esm/types/handlers/name-lookup.js.map +1 -1
  40. package/dist/esm/types/handlers/signature.js +3 -0
  41. package/dist/esm/types/handlers/signature.js.map +1 -0
  42. package/dist/esm/types/handlers/transaction.js.map +1 -1
  43. package/dist/esm/types/handlers/user-input.js +24 -0
  44. package/dist/esm/types/handlers/user-input.js.map +1 -0
  45. package/dist/esm/types/index.js +1 -0
  46. package/dist/esm/types/index.js.map +1 -1
  47. package/dist/esm/types/interface.js +12 -0
  48. package/dist/esm/types/interface.js.map +1 -0
  49. package/dist/esm/types/methods/create-interface.js +3 -0
  50. package/dist/esm/types/methods/create-interface.js.map +1 -0
  51. package/dist/esm/types/methods/dialog.js.map +1 -1
  52. package/dist/esm/types/methods/get-client-status.js +7 -0
  53. package/dist/esm/types/methods/get-client-status.js.map +1 -0
  54. package/dist/esm/types/methods/get-interface-state.js +3 -0
  55. package/dist/esm/types/methods/get-interface-state.js.map +1 -0
  56. package/dist/esm/types/methods/index.js +4 -0
  57. package/dist/esm/types/methods/index.js.map +1 -1
  58. package/dist/esm/types/methods/methods.js.map +1 -1
  59. package/dist/esm/types/methods/update-interface.js +3 -0
  60. package/dist/esm/types/methods/update-interface.js.map +1 -0
  61. package/dist/esm/types/permissions.js.map +1 -1
  62. package/dist/esm/ui/components/button.js +50 -0
  63. package/dist/esm/ui/components/button.js.map +1 -0
  64. package/dist/esm/ui/components/form.js +39 -0
  65. package/dist/esm/ui/components/form.js.map +1 -0
  66. package/dist/esm/ui/components/index.js +3 -0
  67. package/dist/esm/ui/components/index.js.map +1 -1
  68. package/dist/esm/ui/components/input.js +47 -0
  69. package/dist/esm/ui/components/input.js.map +1 -0
  70. package/dist/esm/ui/components/panel.js +7 -1
  71. package/dist/esm/ui/components/panel.js.map +1 -1
  72. package/dist/esm/ui/nodes.js +3 -0
  73. package/dist/esm/ui/nodes.js.map +1 -1
  74. package/dist/types/types/handlers/home-page.d.ts +3 -0
  75. package/dist/types/types/handlers/index.d.ts +2 -0
  76. package/dist/types/types/handlers/name-lookup.d.ts +31 -10
  77. package/dist/types/types/handlers/signature.d.ts +111 -0
  78. package/dist/types/types/handlers/transaction.d.ts +4 -0
  79. package/dist/types/types/handlers/user-input.d.ts +64 -0
  80. package/dist/types/types/index.d.ts +1 -0
  81. package/dist/types/types/interface.d.ts +10 -0
  82. package/dist/types/types/methods/create-interface.d.ts +13 -0
  83. package/dist/types/types/methods/dialog.d.ts +14 -0
  84. package/dist/types/types/methods/get-client-status.d.ts +14 -0
  85. package/dist/types/types/methods/get-interface-state.d.ts +13 -0
  86. package/dist/types/types/methods/index.d.ts +4 -0
  87. package/dist/types/types/methods/methods.d.ts +8 -0
  88. package/dist/types/types/methods/update-interface.d.ts +15 -0
  89. package/dist/types/types/permissions.d.ts +41 -19
  90. package/dist/types/ui/components/button.d.ts +62 -0
  91. package/dist/types/ui/components/form.d.ts +144 -0
  92. package/dist/types/ui/components/index.d.ts +3 -0
  93. package/dist/types/ui/components/input.d.ts +69 -0
  94. package/dist/types/ui/components/panel.d.ts +150 -0
  95. package/dist/types/ui/nodes.d.ts +4 -1
  96. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/types/handlers/name-lookup.ts"],"sourcesContent":["import type { ChainId } from '../caip';\n\ntype BaseOnNameLookupArgs = {\n chainId: ChainId;\n};\n\n/**\n * The arguments for a domain lookup.\n *\n * @property domain - The human-readable domain name that is to be resolved.\n */\nexport type DomainLookupArgs = BaseOnNameLookupArgs & {\n domain: string;\n address?: never;\n};\n\n/**\n * The result of a domain lookup.\n *\n * @property resolvedAddress - The resolved address.\n */\nexport type DomainLookupResult = {\n resolvedAddress: string;\n resolvedDomain?: never;\n};\n\n/**\n * The arguments for an address lookup.\n *\n * @property address - The address that is to be resolved.\n */\nexport type AddressLookupArgs = BaseOnNameLookupArgs & {\n address: string;\n domain?: never;\n};\n\n/**\n * The result of an address lookup.\n *\n * @property resolvedDomain - The resolved domain name.\n */\nexport type AddressLookupResult = {\n resolvedDomain: string;\n resolvedAddress?: never;\n};\n\n/**\n * The `onNameLookup` handler, which is called when MetaMask needs to resolve an\n * address or domain.\n *\n * Note that using this handler requires the `endowment:name-lookup` permission.\n *\n * @param args - The request arguments.\n * @param args.chainId - The CAIP-2 {@link ChainId} of the network the\n * transaction is being submitted to.\n * @param args.domain - The human-readable address that is to be resolved. This\n * is mutually exclusive with `args.address`.\n * @param args.address - The address that is to be resolved. This is mutually\n * exclusive with `args.domain`.\n * @returns The resolved domain or address from the lookup. Must be either\n * {@link AddressLookupResult}, {@link DomainLookupResult}, or `null` if the\n * address or domain could not be resolved.\n */\nexport type OnNameLookupHandler = (\n args: AddressLookupArgs | DomainLookupArgs,\n) => Promise<AddressLookupResult | DomainLookupResult | null>;\n"],"names":[],"mappings":"AAAA,WAiE8D"}
1
+ {"version":3,"sources":["../../../../src/types/handlers/name-lookup.ts"],"sourcesContent":["import type { NonEmptyArray } from '@metamask/utils';\n\nimport type { ChainId } from '../caip';\n\ntype BaseOnNameLookupArgs = {\n chainId: ChainId;\n};\n\n/**\n * The arguments for a domain lookup.\n *\n * @property domain - The human-readable domain name that is to be resolved.\n */\nexport type DomainLookupArgs = BaseOnNameLookupArgs & {\n domain: string;\n address?: never;\n};\n\n/**\n * The arguments for an address lookup.\n *\n * @property address - The address that is to be resolved.\n */\nexport type AddressLookupArgs = BaseOnNameLookupArgs & {\n address: string;\n domain?: never;\n};\n\n/**\n * The address resolution object.\n *\n * @property protocol - The protocol that resolved the domain.\n * @property resolvedAddress - The resolved address.\n */\nexport type AddressResolution = {\n protocol: string;\n resolvedAddress: string;\n};\n\n/**\n * The domain resolution object.\n *\n * @property protocol - The protocol that resolved the address.\n * @property resolvedDomain - The resolved domain.\n */\nexport type DomainResolution = {\n protocol: string;\n resolvedDomain: string;\n};\n\n/**\n * The result of a domain lookup.\n *\n * @property resolvedAddress - The resolved address.\n */\nexport type DomainLookupResult = {\n resolvedAddresses: NonEmptyArray<AddressResolution>;\n resolvedDomains?: never;\n};\n\n/**\n * The result of an address lookup.\n *\n * @property resolvedDomain - The resolved domain name.\n */\nexport type AddressLookupResult = {\n resolvedDomains: NonEmptyArray<DomainResolution>;\n resolvedAddresses?: never;\n};\n\n/**\n * The `onNameLookup` handler, which is called when MetaMask needs to resolve an\n * address or domain.\n *\n * Note that using this handler requires the `endowment:name-lookup` permission.\n *\n * @param args - The request arguments.\n * @param args.chainId - The CAIP-2 {@link ChainId} of the network the\n * transaction is being submitted to.\n * @param args.domain - The human-readable address that is to be resolved. This\n * is mutually exclusive with `args.address`.\n * @param args.address - The address that is to be resolved. This is mutually\n * exclusive with `args.domain`.\n * @returns The resolved domain or address from the lookup. Must be either\n * {@link AddressLookupResult}, {@link DomainLookupResult}, or `null` if the\n * address or domain could not be resolved.\n */\nexport type OnNameLookupHandler = (\n args: AddressLookupArgs | DomainLookupArgs,\n) => Promise<AddressLookupResult | DomainLookupResult | null>;\n"],"names":[],"mappings":"AAAA,WAyF8D"}
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=signature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/types/handlers/signature.ts"],"sourcesContent":["import type { EnumToUnion } from '../../internals';\nimport type { Component } from '../../ui';\nimport type { SeverityLevel } from './transaction';\n\n/**\n * An eth_sign signature object.\n *\n * @property from - The address the signature is being sent from.\n * @property data - The data (hex string) that is being signed.\n * @property signatureMethod - The signature method, which in this case is eth_sign\n */\nexport type EthSignature = {\n from: string;\n data: string;\n signatureMethod: 'eth_sign';\n};\n\n/**\n * A personal_sign signature object.\n *\n * @property from - The address the signature is being sent from.\n * @property data - The data (hex string) that is being signed.\n * @property signatureMethod - The signature method, which in this case is personal_sign\n */\nexport type PersonalSignature = {\n from: string;\n data: string;\n signatureMethod: 'personal_sign';\n};\n\n/**\n * An eth_signTypedData signature object.\n *\n * @property from - The address the signature is being sent from.\n * @property data - The data that is being signed.\n * @property signatureMethod - The signature method, which in this case is eth_signTypedData\n */\nexport type SignTypedDataSignature = {\n from: string;\n data: Record<string, any>[];\n signatureMethod: 'eth_signTypedData';\n};\n\n/**\n * An eth_signTypedData_v3 signature object.\n *\n * @property from - The address the signature is being sent from.\n * @property data - The data that is being signed.\n * @property signatureMethod - The signature method, which in this case is eth_signTypedData_v3\n */\nexport type SignTypedDataV3Signature = {\n from: string;\n data: Record<string, any>;\n signatureMethod: 'eth_signTypedData_v3';\n};\n\n/**\n * An eth_signTypedData_v4 signature object.\n *\n * @property from - The address the signature is being sent from.\n * @property data - The data that is being signed.\n * @property signatureMethod - The signature method, which in this case is eth_signTypedData_v4\n */\nexport type SignTypedDataV4Signature = {\n from: string;\n data: Record<string, any>;\n signatureMethod: 'eth_signTypedData_v4';\n};\n\n/**\n * A signature object. This can be one of the below signature methods.\n *\n * @see EthSignature\n * @see PersonalSignature\n * @see SignTypedDataSignature\n * @see SignTypedDataV3Signature\n * @see SignTypedDataV4Signature\n */\nexport type Signature =\n | EthSignature\n | PersonalSignature\n | SignTypedDataSignature\n | SignTypedDataV3Signature\n | SignTypedDataV4Signature;\n\n/**\n * The `onSignature` handler. This is called whenever a signature is\n * submitted to the snap. It can return insights about the signature, which\n * will be displayed to the user.\n *\n * Note that using this handler requires the `endowment:signature-insight`\n * permission.\n *\n * @param args - The request arguments.\n * @param args.signature - The signature object that contains the from address,\n * data and signature method.\n * @param args.signatureOrigin - The origin of the signature. This is the\n * URL of the website that submitted the signature. This is only available if\n * the Snap has enabled the `allowSignatureOrigin` option in the\n * `endowment:signature-insight` permission.\n * @returns An object containing insights about the signature. See\n * {@link OnSignatureResponse}. Can also return `null` if no insights are\n * available.\n */\nexport type OnSignatureHandler = (args: {\n signature: Signature;\n signatureOrigin?: string;\n}) => Promise<OnSignatureResponse | null>;\n\n/**\n * The response from a Snap's `onSignature` handler.\n *\n * @property component - A custom UI component, that will be shown in MetaMask.\n * @property id - A Snap interface ID.\n * @property severity - The severity level of the content. Currently only one\n * level is supported: `critical`.\n */\nexport type OnSignatureResponse =\n | {\n content: Component;\n severity?: EnumToUnion<SeverityLevel>;\n }\n | {\n id: string;\n severity?: EnumToUnion<SeverityLevel>;\n };\n"],"names":[],"mappings":"AAAA,WA6HM"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/types/handlers/transaction.ts"],"sourcesContent":["import type { EnumToUnion } from '../../internals';\nimport type { Component } from '../../ui';\nimport type { ChainId } from '../caip';\n\n/**\n * The severity level of content being returned from a transaction insight.\n * Currently only one level is supported:\n *\n * - `critical` - The transaction is critical and should not be submitted by the\n * user.\n */\nexport enum SeverityLevel {\n Critical = 'critical',\n}\n\n/**\n * An EIP-1559 (type 2) transaction object.\n *\n * @property from - The address the transaction is being sent from.\n * @property to - The address the transaction is being sent to.\n * @property nonce - The nonce of the transaction.\n * @property value - The value of the transaction.\n * @property data - The data of the transaction.\n * @property gas - The gas limit of the transaction.\n * @property maxFeePerGas - The maximum fee per gas of the transaction.\n * @property maxPriorityFeePerGas - The maximum priority fee per gas of the\n * transaction.\n * @property estimateSuggested - The suggested gas price for the transaction.\n * @property estimateUsed - The gas price used for the transaction.\n * @see https://eips.ethereum.org/EIPS/eip-1559\n */\nexport type EIP1559Transaction = {\n from: string;\n to: string;\n nonce: string;\n value: string;\n data: string;\n gas: string;\n maxFeePerGas: string;\n maxPriorityFeePerGas: string;\n estimateSuggested: string;\n estimateUsed: string;\n};\n\n/**\n * A legacy (type \"0\") transaction object.\n *\n * @property from - The address the transaction is being sent from.\n * @property to - The address the transaction is being sent to.\n * @property nonce - The nonce of the transaction.\n * @property value - The value of the transaction.\n * @property data - The data of the transaction.\n * @property gas - The gas limit of the transaction.\n * @property gasPrice - The gas price of the transaction.\n * @property estimateSuggested - The suggested gas price for the transaction.\n * @property estimateUsed - The gas price used for the transaction.\n */\nexport type LegacyTransaction = {\n from: string;\n to: string;\n nonce: string;\n value: string;\n data: string;\n gas: string;\n gasPrice: string;\n estimateSuggested: string;\n estimateUsed: string;\n};\n\n/**\n * A transaction object. This can be either an EIP-1559 transaction or a legacy\n * transaction.\n *\n * @see EIP1559Transaction\n * @see LegacyTransaction\n */\nexport type Transaction = EIP1559Transaction | LegacyTransaction;\n\n/**\n * The `onTransaction` handler. This is called whenever a transaction is\n * submitted to the snap. It can return insights about the transaction, which\n * will be displayed to the user.\n *\n * Note that using this handler requires the `endowment:transaction-insights`\n * permission.\n *\n * @param args - The request arguments.\n * @param args.transaction - The transaction object, containing the address,\n * value, data, and other properties of the transaction.\n * @param args.chainId - The CAIP-2 {@link ChainId} of the network the\n * transaction is being submitted to.\n * @param args.transactionOrigin - The origin of the transaction. This is the\n * URL of the website that submitted the transaction. This is only available if\n * the Snap has enabled the `allowTransactionOrigin` option in the\n * `endowment:transaction-insight` permission.\n * @returns An object containing insights about the transaction. See\n * {@link OnTransactionResponse}. Can also return `null` if no insights are\n * available.\n */\nexport type OnTransactionHandler = (args: {\n transaction: Transaction;\n chainId: ChainId;\n transactionOrigin?: string;\n}) => Promise<OnTransactionResponse | null>;\n\n/**\n * The response from a Snap's `onTransaction` handler.\n *\n * @property component - A custom UI component, that will be shown in MetaMask.\n * @property severity - The severity level of the content. Currently only one\n * level is supported: `critical`.\n */\nexport type OnTransactionResponse = {\n content: Component;\n severity?: EnumToUnion<SeverityLevel>;\n};\n"],"names":["SeverityLevel","Critical"],"mappings":"WAWO;UAAKA,aAAa;IAAbA,cACVC,cAAW;GADDD,kBAAAA"}
1
+ {"version":3,"sources":["../../../../src/types/handlers/transaction.ts"],"sourcesContent":["import type { EnumToUnion } from '../../internals';\nimport type { Component } from '../../ui';\nimport type { ChainId } from '../caip';\n\n/**\n * The severity level of content being returned from a transaction insight.\n * Currently only one level is supported:\n *\n * - `critical` - The transaction is critical and should not be submitted by the\n * user.\n */\nexport enum SeverityLevel {\n Critical = 'critical',\n}\n\n/**\n * An EIP-1559 (type 2) transaction object.\n *\n * @property from - The address the transaction is being sent from.\n * @property to - The address the transaction is being sent to.\n * @property nonce - The nonce of the transaction.\n * @property value - The value of the transaction.\n * @property data - The data of the transaction.\n * @property gas - The gas limit of the transaction.\n * @property maxFeePerGas - The maximum fee per gas of the transaction.\n * @property maxPriorityFeePerGas - The maximum priority fee per gas of the\n * transaction.\n * @property estimateSuggested - The suggested gas price for the transaction.\n * @property estimateUsed - The gas price used for the transaction.\n * @see https://eips.ethereum.org/EIPS/eip-1559\n */\nexport type EIP1559Transaction = {\n from: string;\n to: string;\n nonce: string;\n value: string;\n data: string;\n gas: string;\n maxFeePerGas: string;\n maxPriorityFeePerGas: string;\n estimateSuggested: string;\n estimateUsed: string;\n};\n\n/**\n * A legacy (type \"0\") transaction object.\n *\n * @property from - The address the transaction is being sent from.\n * @property to - The address the transaction is being sent to.\n * @property nonce - The nonce of the transaction.\n * @property value - The value of the transaction.\n * @property data - The data of the transaction.\n * @property gas - The gas limit of the transaction.\n * @property gasPrice - The gas price of the transaction.\n * @property estimateSuggested - The suggested gas price for the transaction.\n * @property estimateUsed - The gas price used for the transaction.\n */\nexport type LegacyTransaction = {\n from: string;\n to: string;\n nonce: string;\n value: string;\n data: string;\n gas: string;\n gasPrice: string;\n estimateSuggested: string;\n estimateUsed: string;\n};\n\n/**\n * A transaction object. This can be either an EIP-1559 transaction or a legacy\n * transaction.\n *\n * @see EIP1559Transaction\n * @see LegacyTransaction\n */\nexport type Transaction = EIP1559Transaction | LegacyTransaction;\n\n/**\n * The `onTransaction` handler. This is called whenever a transaction is\n * submitted to the snap. It can return insights about the transaction, which\n * will be displayed to the user.\n *\n * Note that using this handler requires the `endowment:transaction-insights`\n * permission.\n *\n * @param args - The request arguments.\n * @param args.transaction - The transaction object, containing the address,\n * value, data, and other properties of the transaction.\n * @param args.chainId - The CAIP-2 {@link ChainId} of the network the\n * transaction is being submitted to.\n * @param args.transactionOrigin - The origin of the transaction. This is the\n * URL of the website that submitted the transaction. This is only available if\n * the Snap has enabled the `allowTransactionOrigin` option in the\n * `endowment:transaction-insight` permission.\n * @returns An object containing insights about the transaction. See\n * {@link OnTransactionResponse}. Can also return `null` if no insights are\n * available.\n */\nexport type OnTransactionHandler = (args: {\n transaction: Transaction;\n chainId: ChainId;\n transactionOrigin?: string;\n}) => Promise<OnTransactionResponse | null>;\n\n/**\n * The response from a Snap's `onTransaction` handler.\n *\n * @property component - A custom UI component, that will be shown in MetaMask.\n * @property id - A Snap interface ID.\n * @property severity - The severity level of the content. Currently only one\n * level is supported: `critical`.\n */\nexport type OnTransactionResponse =\n | {\n content: Component;\n severity?: EnumToUnion<SeverityLevel>;\n }\n | {\n id: string;\n severity?: EnumToUnion<SeverityLevel>;\n };\n"],"names":["SeverityLevel","Critical"],"mappings":"WAWO;UAAKA,aAAa;IAAbA,cACVC,cAAW;GADDD,kBAAAA"}
@@ -0,0 +1,24 @@
1
+ import { assign, literal, object, optional, record, string, union } from 'superstruct';
2
+ export var UserInputEventType;
3
+ (function(UserInputEventType) {
4
+ UserInputEventType["ButtonClickEvent"] = "ButtonClickEvent";
5
+ UserInputEventType["FormSubmitEvent"] = "FormSubmitEvent";
6
+ })(UserInputEventType || (UserInputEventType = {}));
7
+ export const GenericEventStruct = object({
8
+ type: string(),
9
+ name: optional(string())
10
+ });
11
+ export const ButtonClickEventStruct = assign(GenericEventStruct, object({
12
+ type: literal(UserInputEventType.ButtonClickEvent)
13
+ }));
14
+ export const FormSubmitEventStruct = assign(GenericEventStruct, object({
15
+ type: literal(UserInputEventType.FormSubmitEvent),
16
+ value: record(string(), string()),
17
+ name: string()
18
+ }));
19
+ export const UserInputEventStruct = union([
20
+ ButtonClickEventStruct,
21
+ FormSubmitEventStruct
22
+ ]);
23
+
24
+ //# sourceMappingURL=user-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/types/handlers/user-input.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport {\n assign,\n literal,\n object,\n optional,\n record,\n string,\n union,\n} from 'superstruct';\n\n/**\n * The type of user input event fired.\n * Currently only two events are supported:\n *\n * - `ButtonClickEvent` - A button has been clicked in the UI.\n * - `FormSubmitEvent` - A Form has been submitted in the UI.\n */\nexport enum UserInputEventType {\n ButtonClickEvent = 'ButtonClickEvent',\n FormSubmitEvent = 'FormSubmitEvent',\n}\n\nexport const GenericEventStruct = object({\n type: string(),\n name: optional(string()),\n});\n\nexport const ButtonClickEventStruct = assign(\n GenericEventStruct,\n object({\n type: literal(UserInputEventType.ButtonClickEvent),\n }),\n);\n\nexport const FormSubmitEventStruct = assign(\n GenericEventStruct,\n object({\n type: literal(UserInputEventType.FormSubmitEvent),\n value: record(string(), string()),\n name: string(),\n }),\n);\n\nexport const UserInputEventStruct = union([\n ButtonClickEventStruct,\n FormSubmitEventStruct,\n]);\n\n/**\n * A user input event fired in the UI. This is passed to the params of the `onUserInput` handler.\n *\n * @property type - The type of event fired. See {@link UserInputEventType} for the different types.\n * @property name - The component name that fired the event. It is optional for an {@link UserInputEventType.ButtonClickEvent}.\n * @property value - The value associated with the event. Only available when an {@link UserInputEventType.FormSubmitEvent} is fired.\n * It contains the form values submitted.\n */\ntype UserInputEvent = Infer<typeof UserInputEventStruct>;\n\n/**\n * The `onUserInput` handler. This is called when an user input event is fired in the UI.\n *\n * @param args - The user input event.\n * @param args.id - The user interface id.\n * @param args.event - The {@link UserInputEvent} object, containing the data about the fired event.\n */\nexport type OnUserInputHandler = (args: {\n id: string;\n event: UserInputEvent;\n}) => Promise<void>;\n"],"names":["assign","literal","object","optional","record","string","union","UserInputEventType","ButtonClickEvent","FormSubmitEvent","GenericEventStruct","type","name","ButtonClickEventStruct","FormSubmitEventStruct","value","UserInputEventStruct"],"mappings":"AACA,SACEA,MAAM,EACNC,OAAO,EACPC,MAAM,EACNC,QAAQ,EACRC,MAAM,EACNC,MAAM,EACNC,KAAK,QACA,cAAc;WASd;UAAKC,kBAAkB;IAAlBA,mBACVC,sBAAAA;IADUD,mBAEVE,qBAAAA;GAFUF,uBAAAA;AAKZ,OAAO,MAAMG,qBAAqBR,OAAO;IACvCS,MAAMN;IACNO,MAAMT,SAASE;AACjB,GAAG;AAEH,OAAO,MAAMQ,yBAAyBb,OACpCU,oBACAR,OAAO;IACLS,MAAMV,QAAQM,mBAAmBC,gBAAgB;AACnD,IACA;AAEF,OAAO,MAAMM,wBAAwBd,OACnCU,oBACAR,OAAO;IACLS,MAAMV,QAAQM,mBAAmBE,eAAe;IAChDM,OAAOX,OAAOC,UAAUA;IACxBO,MAAMP;AACR,IACA;AAEF,OAAO,MAAMW,uBAAuBV,MAAM;IACxCO;IACAC;CACD,EAAE"}
@@ -7,5 +7,6 @@ export * from './methods';
7
7
  export * from './permissions';
8
8
  export * from './provider';
9
9
  export * from './snap';
10
+ export * from './interface';
10
11
 
11
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/types/index.ts"],"sourcesContent":["// This is intentionally imported, rather than re-exported.\n// eslint-disable-next-line import/no-unassigned-import\nimport './global';\n\nexport * from './caip';\nexport * from './handlers';\nexport * from './methods';\nexport * from './permissions';\nexport * from './provider';\nexport * from './snap';\n"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,uDAAuD;AACvD,OAAO,WAAW;AAElB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,gBAAgB;AAC9B,cAAc,aAAa;AAC3B,cAAc,SAAS"}
1
+ {"version":3,"sources":["../../../src/types/index.ts"],"sourcesContent":["// This is intentionally imported, rather than re-exported.\n// eslint-disable-next-line import/no-unassigned-import\nimport './global';\n\nexport * from './caip';\nexport * from './handlers';\nexport * from './methods';\nexport * from './permissions';\nexport * from './provider';\nexport * from './snap';\nexport * from './interface';\n"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,uDAAuD;AACvD,OAAO,WAAW;AAElB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,gBAAgB;AAC9B,cAAc,aAAa;AAC3B,cAAc,SAAS;AACvB,cAAc,cAAc"}
@@ -0,0 +1,12 @@
1
+ import { nullable, record, string, union } from 'superstruct';
2
+ /**
3
+ * To avoid typing problems with the interface state when manipulating it we have to differentiate the state of
4
+ * a form (that will be contained inside the root state) and the root state since a key in the root stat can contain
5
+ * either the value of an input or a sub-state of a form.
6
+ */ export const FormStateStruct = record(string(), nullable(string()));
7
+ export const InterfaceStateStruct = record(string(), union([
8
+ FormStateStruct,
9
+ nullable(string())
10
+ ]));
11
+
12
+ //# sourceMappingURL=interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/types/interface.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { nullable, record, string, union } from 'superstruct';\n\n/**\n * To avoid typing problems with the interface state when manipulating it we have to differentiate the state of\n * a form (that will be contained inside the 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 FormStateStruct = record(string(), nullable(string()));\n\nexport const InterfaceStateStruct = record(\n string(),\n union([FormStateStruct, nullable(string())]),\n);\n\nexport type FormState = Infer<typeof FormStateStruct>;\nexport type InterfaceState = Infer<typeof InterfaceStateStruct>;\n"],"names":["nullable","record","string","union","FormStateStruct","InterfaceStateStruct"],"mappings":"AACA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,MAAM,EAAEC,KAAK,QAAQ,cAAc;AAE9D;;;;CAIC,GAED,OAAO,MAAMC,kBAAkBH,OAAOC,UAAUF,SAASE,WAAW;AAEpE,OAAO,MAAMG,uBAAuBJ,OAClCC,UACAC,MAAM;IAACC;IAAiBJ,SAASE;CAAU,GAC3C"}
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=create-interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/types/methods/create-interface.ts"],"sourcesContent":["import type { Component } from '../../ui';\n\n/**\n * The request parameters for the `snap_createInterface` method.\n *\n * @property ui - The components to display in the interface.\n */\nexport type CreateInterfaceParams = {\n ui: Component;\n};\n\n/**\n * The result returned by the `snap_createInterface` method, which is the id of the created interface.\n */\nexport type CreateInterfaceResult = string;\n"],"names":[],"mappings":"AAAA,WAc2C"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/types/methods/dialog.ts"],"sourcesContent":["import type { EnumToUnion } from '../../internals';\nimport type { Component } from '../../ui';\n\n/**\n * The type of dialog to display.\n *\n * - `alert` - A dialog with a single button.\n * - `confirmation` - A dialog with two buttons, one to confirm and one to\n * cancel.\n * - `prompt` - A dialog with two buttons and a text input.\n */\nexport enum DialogType {\n Alert = 'alert',\n Confirmation = 'confirmation',\n Prompt = 'prompt',\n}\n\n/**\n * An alert dialog.\n *\n * @property type - The type of dialog. Must be `alert`.\n * @property content - The content to display in the dialog.\n */\nexport type AlertDialog = {\n type: EnumToUnion<DialogType.Alert>;\n content: Component;\n};\n\n/**\n * A confirmation dialog.\n *\n * @property type - The type of dialog. Must be `confirmation`.\n * @property content - The content to display in the dialog.\n */\nexport type ConfirmationDialog = {\n type: EnumToUnion<DialogType.Confirmation>;\n content: Component;\n};\n\n/**\n * A prompt dialog.\n *\n * @property type - The type of dialog. Must be `prompt`.\n * @property content - The content to display in the dialog.\n * @property placeholder - An optional placeholder text to display in the text\n * input.\n */\nexport type PromptDialog = {\n type: EnumToUnion<DialogType.Prompt>;\n content: Component;\n placeholder?: string;\n};\n\n/**\n * The request parameters for the `snap_dialog` method.\n *\n * @property type - The type of dialog to display.\n * @property content - The content to display in the dialog.\n * @property placeholder - The placeholder text to display in the dialog. Only\n * applicable for the `prompt` dialog.\n */\nexport type DialogParams = AlertDialog | ConfirmationDialog | PromptDialog;\n\n/**\n * The result returned by the `snap_dialog` method.\n *\n * - If the dialog is an `alert`, the result is `null`.\n * - If the dialog is a `confirmation`, the result is a boolean indicating\n * whether the user confirmed the dialog.\n * - If the dialog is a `prompt`, the result is the value entered by\n * the user.\n */\nexport type DialogResult = null | boolean | string;\n"],"names":["DialogType","Alert","Confirmation","Prompt"],"mappings":"WAWO;UAAKA,UAAU;IAAVA,WACVC,WAAQ;IADED,WAEVE,kBAAe;IAFLF,WAGVG,YAAS;GAHCH,eAAAA"}
1
+ {"version":3,"sources":["../../../../src/types/methods/dialog.ts"],"sourcesContent":["import type { EnumToUnion } from '../../internals';\nimport type { Component } from '../../ui';\n\n/**\n * The type of dialog to display.\n *\n * - `alert` - A dialog with a single button.\n * - `confirmation` - A dialog with two buttons, one to confirm and one to\n * cancel.\n * - `prompt` - A dialog with two buttons and a text input.\n */\nexport enum DialogType {\n Alert = 'alert',\n Confirmation = 'confirmation',\n Prompt = 'prompt',\n}\n\n/**\n * An alert dialog.\n *\n * @property type - The type of dialog. Must be `alert`.\n * @property content - The content to display in the dialog.\n * @property id - The Snap interface ID.\n */\nexport type AlertDialog =\n | {\n type: EnumToUnion<DialogType.Alert>;\n content: Component;\n }\n | {\n type: EnumToUnion<DialogType.Alert>;\n id: string;\n };\n\n/**\n * A confirmation dialog.\n *\n * @property type - The type of dialog. Must be `confirmation`.\n * @property content - The content to display in the dialog.\n * @property id - The Snap interface ID.\n */\nexport type ConfirmationDialog =\n | {\n type: EnumToUnion<DialogType.Confirmation>;\n content: Component;\n }\n | {\n type: EnumToUnion<DialogType.Confirmation>;\n id: string;\n };\n\n/**\n * A prompt dialog.\n *\n * @property type - The type of dialog. Must be `prompt`.\n * @property content - The content to display in the dialog.\n * @property id - The Snap interface ID.\n * @property placeholder - An optional placeholder text to display in the text\n * input.\n */\nexport type PromptDialog =\n | {\n type: EnumToUnion<DialogType.Prompt>;\n content: Component;\n placeholder?: string;\n }\n | {\n type: EnumToUnion<DialogType.Prompt>;\n id: string;\n placeholder?: string;\n };\n\n/**\n * The request parameters for the `snap_dialog` method.\n *\n * @property type - The type of dialog to display.\n * @property content - The content to display in the dialog.\n * @property id - The Snap interface ID.\n * @property placeholder - The placeholder text to display in the dialog. Only\n * applicable for the `prompt` dialog.\n */\nexport type DialogParams = AlertDialog | ConfirmationDialog | PromptDialog;\n\n/**\n * The result returned by the `snap_dialog` method.\n *\n * - If the dialog is an `alert`, the result is `null`.\n * - If the dialog is a `confirmation`, the result is a boolean indicating\n * whether the user confirmed the dialog.\n * - If the dialog is a `prompt`, the result is the value entered by\n * the user.\n */\nexport type DialogResult = null | boolean | string;\n"],"names":["DialogType","Alert","Confirmation","Prompt"],"mappings":"WAWO;UAAKA,UAAU;IAAVA,WACVC,WAAQ;IADED,WAEVE,kBAAe;IAFLF,WAGVG,YAAS;GAHCH,eAAAA"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The request parameters for the `snap_getClientStatus` method.
3
+ *
4
+ * This method does not accept any parameters.
5
+ */ export { };
6
+
7
+ //# sourceMappingURL=get-client-status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/types/methods/get-client-status.ts"],"sourcesContent":["/**\n * The request parameters for the `snap_getClientStatus` method.\n *\n * This method does not accept any parameters.\n */\nexport type GetClientStatusParams = never;\n\n/**\n * The result returned by the `snap_getClientStatus` method.\n *\n * It returns an object containing useful information about the client.\n */\nexport type GetClientStatusResult = { locked: boolean };\n"],"names":[],"mappings":"AAAA;;;;CAIC,GACD,WAOwD"}
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=get-interface-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/types/methods/get-interface-state.ts"],"sourcesContent":["import type { InterfaceState } from '../interface';\n\n/**\n * The request parameters for the `snap_getInterfaceState` method.\n *\n * @property id - The interface id.\n */\nexport type GetInterfaceStateParams = {\n id: string;\n};\n\n/**\n * The result returned by the `snap_getInterfaceState` method, which is the state of the interface.\n */\nexport type GetInterfaceStateResult = InterfaceState;\n"],"names":[],"mappings":"AAAA,WAcqD"}
@@ -1,9 +1,12 @@
1
+ export * from './create-interface';
1
2
  export * from './dialog';
2
3
  export * from './get-bip32-entropy';
3
4
  export * from './get-bip32-public-key';
4
5
  export * from './get-bip44-entropy';
6
+ export * from './get-client-status';
5
7
  export * from './get-entropy';
6
8
  export * from './get-file';
9
+ export * from './get-interface-state';
7
10
  export * from './get-locale';
8
11
  export * from './get-snaps';
9
12
  export * from './invoke-keyring';
@@ -13,5 +16,6 @@ export * from './manage-state';
13
16
  export * from './methods';
14
17
  export * from './notify';
15
18
  export * from './request-snaps';
19
+ export * from './update-interface';
16
20
 
17
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/types/methods/index.ts"],"sourcesContent":["export * from './dialog';\nexport * from './get-bip32-entropy';\nexport * from './get-bip32-public-key';\nexport * from './get-bip44-entropy';\nexport * from './get-entropy';\nexport * from './get-file';\nexport * from './get-locale';\nexport * from './get-snaps';\nexport * from './invoke-keyring';\nexport * from './invoke-snap';\nexport * from './manage-accounts';\nexport * from './manage-state';\nexport * from './methods';\nexport * from './notify';\nexport * from './request-snaps';\n"],"names":[],"mappings":"AAAA,cAAc,WAAW;AACzB,cAAc,sBAAsB;AACpC,cAAc,yBAAyB;AACvC,cAAc,sBAAsB;AACpC,cAAc,gBAAgB;AAC9B,cAAc,aAAa;AAC3B,cAAc,eAAe;AAC7B,cAAc,cAAc;AAC5B,cAAc,mBAAmB;AACjC,cAAc,gBAAgB;AAC9B,cAAc,oBAAoB;AAClC,cAAc,iBAAiB;AAC/B,cAAc,YAAY;AAC1B,cAAc,WAAW;AACzB,cAAc,kBAAkB"}
1
+ {"version":3,"sources":["../../../../src/types/methods/index.ts"],"sourcesContent":["export * from './create-interface';\nexport * from './dialog';\nexport * from './get-bip32-entropy';\nexport * from './get-bip32-public-key';\nexport * from './get-bip44-entropy';\nexport * from './get-client-status';\nexport * from './get-entropy';\nexport * from './get-file';\nexport * from './get-interface-state';\nexport * from './get-locale';\nexport * from './get-snaps';\nexport * from './invoke-keyring';\nexport * from './invoke-snap';\nexport * from './manage-accounts';\nexport * from './manage-state';\nexport * from './methods';\nexport * from './notify';\nexport * from './request-snaps';\nexport * from './update-interface';\n"],"names":[],"mappings":"AAAA,cAAc,qBAAqB;AACnC,cAAc,WAAW;AACzB,cAAc,sBAAsB;AACpC,cAAc,yBAAyB;AACvC,cAAc,sBAAsB;AACpC,cAAc,sBAAsB;AACpC,cAAc,gBAAgB;AAC9B,cAAc,aAAa;AAC3B,cAAc,wBAAwB;AACtC,cAAc,eAAe;AAC7B,cAAc,cAAc;AAC5B,cAAc,mBAAmB;AACjC,cAAc,gBAAgB;AAC9B,cAAc,oBAAoB;AAClC,cAAc,iBAAiB;AAC/B,cAAc,YAAY;AAC1B,cAAc,WAAW;AACzB,cAAc,kBAAkB;AAChC,cAAc,qBAAqB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/types/methods/methods.ts"],"sourcesContent":["import type { Method } from '../../internals';\nimport type { DialogParams, DialogResult } from './dialog';\nimport type {\n GetBip32EntropyParams,\n GetBip32EntropyResult,\n} from './get-bip32-entropy';\nimport type {\n GetBip32PublicKeyParams,\n GetBip32PublicKeyResult,\n} from './get-bip32-public-key';\nimport type {\n GetBip44EntropyParams,\n GetBip44EntropyResult,\n} from './get-bip44-entropy';\nimport type { GetEntropyParams, GetEntropyResult } from './get-entropy';\nimport type { GetFileParams, GetFileResult } from './get-file';\nimport type { GetLocaleParams, GetLocaleResult } from './get-locale';\nimport type { GetSnapsParams, GetSnapsResult } from './get-snaps';\nimport type {\n InvokeKeyringParams,\n InvokeKeyringResult,\n} from './invoke-keyring';\nimport type { InvokeSnapParams, InvokeSnapResult } from './invoke-snap';\nimport type {\n ManageAccountsParams,\n ManageAccountsResult,\n} from './manage-accounts';\nimport type { ManageStateParams, ManageStateResult } from './manage-state';\nimport type { NotifyParams, NotifyResult } from './notify';\nimport type { RequestSnapsParams, RequestSnapsResult } from './request-snaps';\n\n/**\n * The methods that are available to the Snap. Each method is a tuple of the\n * request parameters and the result returned by the method.\n */\nexport type SnapMethods = {\n /* eslint-disable @typescript-eslint/naming-convention */\n snap_dialog: [DialogParams, DialogResult];\n snap_getBip32Entropy: [GetBip32EntropyParams, GetBip32EntropyResult];\n snap_getBip32PublicKey: [GetBip32PublicKeyParams, GetBip32PublicKeyResult];\n snap_getBip44Entropy: [GetBip44EntropyParams, GetBip44EntropyResult];\n snap_getEntropy: [GetEntropyParams, GetEntropyResult];\n snap_getFile: [GetFileParams, GetFileResult];\n snap_getLocale: [GetLocaleParams, GetLocaleResult];\n snap_manageAccounts: [ManageAccountsParams, ManageAccountsResult];\n snap_manageState: [ManageStateParams, ManageStateResult];\n snap_notify: [NotifyParams, NotifyResult];\n wallet_getSnaps: [GetSnapsParams, GetSnapsResult];\n wallet_invokeKeyring: [InvokeKeyringParams, InvokeKeyringResult];\n wallet_invokeSnap: [InvokeSnapParams, InvokeSnapResult];\n wallet_snap: [InvokeSnapParams, InvokeSnapResult];\n wallet_requestSnaps: [RequestSnapsParams, RequestSnapsResult];\n /* eslint-enable @typescript-eslint/naming-convention */\n};\n\n/**\n * The request function that is available to the Snap. It takes a request\n * object and returns a promise that resolves to the result of the request.\n *\n * @param request - The request object.\n * @param request.method - The method to call.\n * @param request.params - The parameters to pass to the method. This is\n * inferred from the method, based on the {@link SnapMethods} type, and may be\n * optional.\n * @returns A promise that resolves to the result of the request. This is\n * inferred from the request method, based on the {@link SnapMethods} type.\n * @example\n * // Get the user's locale\n * const result = await request({\n * method: 'snap_getLocale',\n * });\n * @example\n * // Get a file\n * const result = await request({\n * method: 'snap_getFile',\n * params: {\n * path: 'foo/bar.txt',\n * },\n * });\n */\nexport type RequestFunction = <MethodName extends keyof SnapMethods>(\n request: Method<MethodName, SnapMethods[MethodName][0]>,\n) => Promise<SnapMethods[MethodName][1]>;\n"],"names":[],"mappings":"AAAA,WAkFyC"}
1
+ {"version":3,"sources":["../../../../src/types/methods/methods.ts"],"sourcesContent":["import type { Method } from '../../internals';\nimport type {\n CreateInterfaceParams,\n CreateInterfaceResult,\n} from './create-interface';\nimport type { DialogParams, DialogResult } from './dialog';\nimport type {\n GetBip32EntropyParams,\n GetBip32EntropyResult,\n} from './get-bip32-entropy';\nimport type {\n GetBip32PublicKeyParams,\n GetBip32PublicKeyResult,\n} from './get-bip32-public-key';\nimport type {\n GetBip44EntropyParams,\n GetBip44EntropyResult,\n} from './get-bip44-entropy';\nimport type {\n GetClientStatusParams,\n GetClientStatusResult,\n} from './get-client-status';\nimport type { GetEntropyParams, GetEntropyResult } from './get-entropy';\nimport type { GetFileParams, GetFileResult } from './get-file';\nimport type {\n GetInterfaceStateParams,\n GetInterfaceStateResult,\n} from './get-interface-state';\nimport type { GetLocaleParams, GetLocaleResult } from './get-locale';\nimport type { GetSnapsParams, GetSnapsResult } from './get-snaps';\nimport type {\n InvokeKeyringParams,\n InvokeKeyringResult,\n} from './invoke-keyring';\nimport type { InvokeSnapParams, InvokeSnapResult } from './invoke-snap';\nimport type {\n ManageAccountsParams,\n ManageAccountsResult,\n} from './manage-accounts';\nimport type { ManageStateParams, ManageStateResult } from './manage-state';\nimport type { NotifyParams, NotifyResult } from './notify';\nimport type { RequestSnapsParams, RequestSnapsResult } from './request-snaps';\nimport type {\n UpdateInterfaceParams,\n UpdateInterfaceResult,\n} from './update-interface';\n\n/**\n * The methods that are available to the Snap. Each method is a tuple of the\n * request parameters and the result returned by the method.\n */\nexport type SnapMethods = {\n /* eslint-disable @typescript-eslint/naming-convention */\n snap_dialog: [DialogParams, DialogResult];\n snap_getBip32Entropy: [GetBip32EntropyParams, GetBip32EntropyResult];\n snap_getBip32PublicKey: [GetBip32PublicKeyParams, GetBip32PublicKeyResult];\n snap_getBip44Entropy: [GetBip44EntropyParams, GetBip44EntropyResult];\n snap_getClientStatus: [GetClientStatusParams, GetClientStatusResult];\n snap_getEntropy: [GetEntropyParams, GetEntropyResult];\n snap_getFile: [GetFileParams, GetFileResult];\n snap_getLocale: [GetLocaleParams, GetLocaleResult];\n snap_manageAccounts: [ManageAccountsParams, ManageAccountsResult];\n snap_manageState: [ManageStateParams, ManageStateResult];\n snap_notify: [NotifyParams, NotifyResult];\n snap_createInterface: [CreateInterfaceParams, CreateInterfaceResult];\n snap_updateInterface: [UpdateInterfaceParams, UpdateInterfaceResult];\n snap_getInterfaceState: [GetInterfaceStateParams, GetInterfaceStateResult];\n wallet_getSnaps: [GetSnapsParams, GetSnapsResult];\n wallet_invokeKeyring: [InvokeKeyringParams, InvokeKeyringResult];\n wallet_invokeSnap: [InvokeSnapParams, InvokeSnapResult];\n wallet_snap: [InvokeSnapParams, InvokeSnapResult];\n wallet_requestSnaps: [RequestSnapsParams, RequestSnapsResult];\n /* eslint-enable @typescript-eslint/naming-convention */\n};\n\n/**\n * The request function that is available to the Snap. It takes a request\n * object and returns a promise that resolves to the result of the request.\n *\n * @param request - The request object.\n * @param request.method - The method to call.\n * @param request.params - The parameters to pass to the method. This is\n * inferred from the method, based on the {@link SnapMethods} type, and may be\n * optional.\n * @returns A promise that resolves to the result of the request. This is\n * inferred from the request method, based on the {@link SnapMethods} type.\n * @example\n * // Get the user's locale\n * const result = await request({\n * method: 'snap_getLocale',\n * });\n * @example\n * // Get a file\n * const result = await request({\n * method: 'snap_getFile',\n * params: {\n * path: 'foo/bar.txt',\n * },\n * });\n */\nexport type RequestFunction = <MethodName extends keyof SnapMethods>(\n request: Method<MethodName, SnapMethods[MethodName][0]>,\n) => Promise<SnapMethods[MethodName][1]>;\n"],"names":[],"mappings":"AAAA,WAsGyC"}
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=update-interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/types/methods/update-interface.ts"],"sourcesContent":["import type { Component } from '../../ui';\n\n/**\n * The request parameters for the `snap_createInterface` method.\n *\n * @property id - The interface id.\n * @property ui - The components to display in the interface.\n */\nexport type UpdateInterfaceParams = {\n id: string;\n ui: Component;\n};\n\n/**\n * The result returned by the `snap_updateInterface` method.\n */\nexport type UpdateInterfaceResult = null;\n"],"names":[],"mappings":"AAAA,WAgByC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/types/permissions.ts"],"sourcesContent":["import type { JsonRpcRequest } from '@metamask/utils';\n\nimport type { ChainId } from './caip';\n\nexport type EmptyObject = Record<string, never>;\n\nexport type Cronjob = {\n expression: string;\n request: Omit<JsonRpcRequest, 'jsonrpc' | 'id'>;\n};\n\nexport type Bip32Entropy = {\n curve: 'secp256k1' | 'ed25519';\n path: string[];\n};\n\nexport type Bip44Entropy = {\n coinType: number;\n};\n\nexport type RequestedSnap = {\n version?: string;\n};\n\nexport type InitialPermissions = {\n 'endowment:cronjob'?: {\n jobs: Cronjob[];\n };\n 'endowment:keyring'?: {\n allowedOrigins?: string[];\n };\n 'endowment:name-lookup'?: ChainId[];\n 'endowment:network-access'?: EmptyObject;\n 'endowment:rpc'?: {\n dapps?: boolean;\n snaps?: boolean;\n allowedOrigins?: string[];\n };\n 'endowment:transaction-insight'?: {\n allowTransactionOrigin?: boolean;\n };\n 'endowment:webassembly'?: EmptyObject;\n\n /* eslint-disable @typescript-eslint/naming-convention */\n snap_confirm?: EmptyObject;\n snap_dialog?: EmptyObject;\n snap_getBip32Entropy?: Bip32Entropy[];\n snap_getBip32PublicKey?: Bip32Entropy[];\n snap_getBip44Entropy?: Bip44Entropy[];\n snap_getEntropy?: EmptyObject;\n snap_manageAccounts?: EmptyObject;\n snap_manageState?: EmptyObject;\n snap_notify?: EmptyObject;\n wallet_snap?: Record<string, RequestedSnap>;\n /* eslint-enable @typescript-eslint/naming-convention */\n};\n"],"names":[],"mappings":"AAAA,WAuDE"}
1
+ {"version":3,"sources":["../../../src/types/permissions.ts"],"sourcesContent":["import type { JsonRpcRequest } from '@metamask/utils';\n\nimport type { ChainId } from './caip';\n\nexport type EmptyObject = Record<string, never>;\n\nexport type Cronjob = {\n expression: string;\n request: Omit<JsonRpcRequest, 'jsonrpc' | 'id'>;\n};\n\nexport type Bip32Entropy = {\n curve: 'secp256k1' | 'ed25519';\n path: string[];\n};\n\nexport type Bip44Entropy = {\n coinType: number;\n};\n\nexport type RequestedSnap = {\n version?: string;\n};\n\nexport type InitialPermissions = Partial<{\n 'endowment:cronjob': {\n jobs: Cronjob[];\n maxRequestTime?: number;\n };\n 'endowment:ethereum-provider': EmptyObject;\n 'endowment:keyring': {\n allowedOrigins?: string[];\n maxRequestTime?: number;\n };\n 'endowment:lifecycle-hooks'?: {\n maxRequestTime?: number;\n };\n 'endowment:name-lookup': {\n chains?: ChainId[];\n matchers?: { tlds?: string[]; schemes?: string[] };\n maxRequestTime?: number;\n };\n 'endowment:network-access': EmptyObject;\n 'endowment:page-home'?: {\n maxRequestTime?: number;\n };\n 'endowment:rpc': {\n dapps?: boolean;\n snaps?: boolean;\n allowedOrigins?: string[];\n maxRequestTime?: number;\n };\n 'endowment:signature-insight': {\n allowSignatureOrigin?: boolean;\n maxRequestTime?: number;\n };\n 'endowment:transaction-insight': {\n allowTransactionOrigin?: boolean;\n maxRequestTime?: number;\n };\n 'endowment:webassembly': EmptyObject;\n\n /* eslint-disable @typescript-eslint/naming-convention */\n snap_dialog: EmptyObject;\n snap_getBip32Entropy: Bip32Entropy[];\n snap_getBip32PublicKey: Bip32Entropy[];\n snap_getBip44Entropy: Bip44Entropy[];\n snap_getEntropy: EmptyObject;\n snap_getLocale: EmptyObject;\n snap_manageAccounts: EmptyObject;\n snap_manageState: EmptyObject;\n snap_notify: EmptyObject;\n wallet_snap: Record<string, RequestedSnap>;\n /* eslint-enable @typescript-eslint/naming-convention */\n}>;\n"],"names":[],"mappings":"AAAA,WA0EG"}
@@ -0,0 +1,50 @@
1
+ import { assign, literal, object, optional, string, union } from 'superstruct';
2
+ import { enumValue } from '../../internals';
3
+ import { createBuilder } from '../builder';
4
+ import { LiteralStruct, NodeType } from '../nodes';
5
+ export var ButtonVariant;
6
+ (function(ButtonVariant) {
7
+ ButtonVariant["Primary"] = 'primary';
8
+ ButtonVariant["Secondary"] = 'secondary';
9
+ })(ButtonVariant || (ButtonVariant = {}));
10
+ export var ButtonType;
11
+ (function(ButtonType) {
12
+ ButtonType["Button"] = 'button';
13
+ ButtonType["Submit"] = 'submit';
14
+ })(ButtonType || (ButtonType = {}));
15
+ export const ButtonStruct = assign(LiteralStruct, object({
16
+ type: literal(NodeType.Button),
17
+ value: string(),
18
+ variant: optional(union([
19
+ enumValue(ButtonVariant.Primary),
20
+ enumValue(ButtonVariant.Secondary)
21
+ ])),
22
+ buttonType: optional(union([
23
+ enumValue(ButtonType.Button),
24
+ enumValue(ButtonType.Submit)
25
+ ])),
26
+ name: optional(string())
27
+ }));
28
+ /**
29
+ * Create a {@link Button} node.
30
+ *
31
+ * @param args - The node arguments. This can be either a string, or an object
32
+ * with a `value` property. A set of optional properties can be passed.
33
+ * @param args.variant - The optional variant of the button.
34
+ * @param args.value - The text content of the node.
35
+ * @param args.name - The optional name of the button.
36
+ * @returns The text node as object.
37
+ * @example
38
+ * ```typescript
39
+ * const node = button({ variant: 'primary', text: 'Hello, world!', name: 'myButton' });
40
+ * const node = button('Hello, world!', 'button', 'myButton', 'primary');
41
+ * const node = button('Hello, world!');
42
+ * ```
43
+ */ export const button = createBuilder(NodeType.Button, ButtonStruct, [
44
+ 'value',
45
+ 'buttonType',
46
+ 'name',
47
+ 'variant'
48
+ ]);
49
+
50
+ //# sourceMappingURL=button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/ui/components/button.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { assign, literal, object, optional, string, union } from 'superstruct';\n\nimport { enumValue } from '../../internals';\nimport { createBuilder } from '../builder';\nimport { LiteralStruct, NodeType } from '../nodes';\n\nexport enum ButtonVariant {\n Primary = 'primary',\n Secondary = 'secondary',\n}\n\nexport enum ButtonType {\n Button = 'button',\n Submit = 'submit',\n}\n\nexport const ButtonStruct = assign(\n LiteralStruct,\n object({\n type: literal(NodeType.Button),\n value: string(),\n variant: optional(\n union([\n enumValue(ButtonVariant.Primary),\n enumValue(ButtonVariant.Secondary),\n ]),\n ),\n buttonType: optional(\n union([enumValue(ButtonType.Button), enumValue(ButtonType.Submit)]),\n ),\n name: optional(string()),\n }),\n);\n\n/**\n * A button node, that renders either a primary or a secondary button.\n *\n * @property type - The type of the node, must be the string 'button'.\n * @property variant - The style variant of the node, must be either 'primary' or 'secondary'.\n * @property value - The text content of the node as plain text.\n * @property buttonType - The type of the button, must be either 'button' or 'submit'.\n * @property name - An optional name to identify the button.\n */\nexport type Button = Infer<typeof ButtonStruct>;\n\n/**\n * Create a {@link Button} node.\n *\n * @param args - The node arguments. This can be either a string, or an object\n * with a `value` property. A set of optional properties can be passed.\n * @param args.variant - The optional variant of the button.\n * @param args.value - The text content of the node.\n * @param args.name - The optional name of the button.\n * @returns The text node as object.\n * @example\n * ```typescript\n * const node = button({ variant: 'primary', text: 'Hello, world!', name: 'myButton' });\n * const node = button('Hello, world!', 'button', 'myButton', 'primary');\n * const node = button('Hello, world!');\n * ```\n */\nexport const button = createBuilder(NodeType.Button, ButtonStruct, [\n 'value',\n 'buttonType',\n 'name',\n 'variant',\n]);\n"],"names":["assign","literal","object","optional","string","union","enumValue","createBuilder","LiteralStruct","NodeType","ButtonVariant","Primary","Secondary","ButtonType","Button","Submit","ButtonStruct","type","value","variant","buttonType","name","button"],"mappings":"AACA,SAASA,MAAM,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,KAAK,QAAQ,cAAc;AAE/E,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAASC,aAAa,EAAEC,QAAQ,QAAQ,WAAW;WAE5C;UAAKC,aAAa;IAAbA,cACVC,aAAU;IADAD,cAEVE,eAAY;GAFFF,kBAAAA;WAKL;UAAKG,UAAU;IAAVA,WACVC,YAAS;IADCD,WAEVE,YAAS;GAFCF,eAAAA;AAKZ,OAAO,MAAMG,eAAehB,OAC1BQ,eACAN,OAAO;IACLe,MAAMhB,QAAQQ,SAASK,MAAM;IAC7BI,OAAOd;IACPe,SAAShB,SACPE,MAAM;QACJC,UAAUI,cAAcC,OAAO;QAC/BL,UAAUI,cAAcE,SAAS;KAClC;IAEHQ,YAAYjB,SACVE,MAAM;QAACC,UAAUO,WAAWC,MAAM;QAAGR,UAAUO,WAAWE,MAAM;KAAE;IAEpEM,MAAMlB,SAASC;AACjB,IACA;AAaF;;;;;;;;;;;;;;;CAeC,GACD,OAAO,MAAMkB,SAASf,cAAcE,SAASK,MAAM,EAAEE,cAAc;IACjE;IACA;IACA;IACA;CACD,EAAE"}
@@ -0,0 +1,39 @@
1
+ import { array, assign, literal, object, string, union } from 'superstruct';
2
+ import { createBuilder } from '../builder';
3
+ import { NodeStruct, NodeType } from '../nodes';
4
+ import { ButtonStruct } from './button';
5
+ import { InputStruct } from './input';
6
+ export const FormComponentStruct = union([
7
+ InputStruct,
8
+ ButtonStruct
9
+ ]);
10
+ export const FormStruct = assign(NodeStruct, object({
11
+ type: literal(NodeType.Form),
12
+ children: array(FormComponentStruct),
13
+ name: string()
14
+ }));
15
+ /**
16
+ * Create a {@link Form} node.
17
+ *
18
+ * @param args - The node arguments. This can be either an array of children and a string, or
19
+ * an object with a `name` and `children` property.
20
+ * @param args.name - The form name used to identify it.
21
+ * @param args.children - The child nodes of the form. This can be any valid
22
+ * {@link FormComponent}.
23
+ * @returns The form node as object.
24
+ * @example
25
+ * const node = form({
26
+ * name: 'myForm',
27
+ * children: [
28
+ * input({ name: 'myInput' }),
29
+ * button({ value: 'Hello, world!' }),
30
+ * ],
31
+ * });
32
+ *
33
+ * const node = form('myForm', [input('myInput'), button('Hello, world!')]);
34
+ */ export const form = createBuilder(NodeType.Form, FormStruct, [
35
+ 'name',
36
+ 'children'
37
+ ]);
38
+
39
+ //# sourceMappingURL=form.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/ui/components/form.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { array, assign, literal, object, string, union } from 'superstruct';\n\nimport { createBuilder } from '../builder';\nimport { NodeStruct, NodeType } from '../nodes';\nimport { ButtonStruct } from './button';\nimport { InputStruct } from './input';\n\nexport const FormComponentStruct = union([InputStruct, ButtonStruct]);\n\n/**\n * The subset of nodes allowed as children in the {@link Form} node.\n */\nexport type FormComponent = Infer<typeof FormComponentStruct>;\n\nexport const FormStruct = assign(\n NodeStruct,\n object({\n type: literal(NodeType.Form),\n children: array(FormComponentStruct),\n name: string(),\n }),\n);\n\n/**\n * A form node that takes children {@link FormComponent} nodes and renders a form.\n *\n * @property type - The type of the node. Must be the string `form`.\n * @property children - The children of the node. Only {@link FormComponent} nodes are allowed.\n * @property name - The form name used to identify it.\n */\nexport type Form = Infer<typeof FormStruct>;\n\n/**\n * Create a {@link Form} node.\n *\n * @param args - The node arguments. This can be either an array of children and a string, or\n * an object with a `name` and `children` property.\n * @param args.name - The form name used to identify it.\n * @param args.children - The child nodes of the form. This can be any valid\n * {@link FormComponent}.\n * @returns The form node as object.\n * @example\n * const node = form({\n * name: 'myForm',\n * children: [\n * input({ name: 'myInput' }),\n * button({ value: 'Hello, world!' }),\n * ],\n * });\n *\n * const node = form('myForm', [input('myInput'), button('Hello, world!')]);\n */\nexport const form = createBuilder(NodeType.Form, FormStruct, [\n 'name',\n 'children',\n]);\n"],"names":["array","assign","literal","object","string","union","createBuilder","NodeStruct","NodeType","ButtonStruct","InputStruct","FormComponentStruct","FormStruct","type","Form","children","name","form"],"mappings":"AACA,SAASA,KAAK,EAAEC,MAAM,EAAEC,OAAO,EAAEC,MAAM,EAAEC,MAAM,EAAEC,KAAK,QAAQ,cAAc;AAE5E,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAASC,UAAU,EAAEC,QAAQ,QAAQ,WAAW;AAChD,SAASC,YAAY,QAAQ,WAAW;AACxC,SAASC,WAAW,QAAQ,UAAU;AAEtC,OAAO,MAAMC,sBAAsBN,MAAM;IAACK;IAAaD;CAAa,EAAE;AAOtE,OAAO,MAAMG,aAAaX,OACxBM,YACAJ,OAAO;IACLU,MAAMX,QAAQM,SAASM,IAAI;IAC3BC,UAAUf,MAAMW;IAChBK,MAAMZ;AACR,IACA;AAWF;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,MAAMa,OAAOX,cAAcE,SAASM,IAAI,EAAEF,YAAY;IAC3D;IACA;CACD,EAAE"}
@@ -7,5 +7,8 @@ export { ComponentStruct, panel, PanelStruct } from './panel';
7
7
  export * from './spinner';
8
8
  export * from './text';
9
9
  export * from './row';
10
+ export * from './button';
11
+ export * from './input';
12
+ export * from './form';
10
13
 
11
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/ui/components/index.ts"],"sourcesContent":["export * from './address';\nexport * from './copyable';\nexport * from './divider';\nexport * from './heading';\nexport type { Image } from './image';\nexport { image, ImageStruct } from './image';\nexport type { Component, Panel } from './panel';\nexport { ComponentStruct, panel, PanelStruct } from './panel';\nexport * from './spinner';\nexport * from './text';\nexport * from './row';\n"],"names":["image","ImageStruct","ComponentStruct","panel","PanelStruct"],"mappings":"AAAA,cAAc,YAAY;AAC1B,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,YAAY;AAE1B,SAASA,KAAK,EAAEC,WAAW,QAAQ,UAAU;AAE7C,SAASC,eAAe,EAAEC,KAAK,EAAEC,WAAW,QAAQ,UAAU;AAC9D,cAAc,YAAY;AAC1B,cAAc,SAAS;AACvB,cAAc,QAAQ"}
1
+ {"version":3,"sources":["../../../../src/ui/components/index.ts"],"sourcesContent":["export * from './address';\nexport * from './copyable';\nexport * from './divider';\nexport * from './heading';\nexport type { Image } from './image';\nexport { image, ImageStruct } from './image';\nexport type { Component, Panel } from './panel';\nexport { ComponentStruct, panel, PanelStruct } from './panel';\nexport * from './spinner';\nexport * from './text';\nexport * from './row';\nexport * from './button';\nexport * from './input';\nexport * from './form';\n"],"names":["image","ImageStruct","ComponentStruct","panel","PanelStruct"],"mappings":"AAAA,cAAc,YAAY;AAC1B,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,YAAY;AAE1B,SAASA,KAAK,EAAEC,WAAW,QAAQ,UAAU;AAE7C,SAASC,eAAe,EAAEC,KAAK,EAAEC,WAAW,QAAQ,UAAU;AAC9D,cAAc,YAAY;AAC1B,cAAc,SAAS;AACvB,cAAc,QAAQ;AACtB,cAAc,WAAW;AACzB,cAAc,UAAU;AACxB,cAAc,SAAS"}
@@ -0,0 +1,47 @@
1
+ import { assign, literal, object, optional, string, union } from 'superstruct';
2
+ import { enumValue } from '../../internals';
3
+ import { createBuilder } from '../builder';
4
+ import { LiteralStruct, NodeType } from '../nodes';
5
+ export var InputType;
6
+ (function(InputType) {
7
+ InputType[/* eslint-disable @typescript-eslint/no-shadow */ "Text"] = 'text';
8
+ InputType["Number"] = 'number';
9
+ InputType[/* eslint-enable @typescript-eslint/no-shadow */ "Password"] = 'password';
10
+ })(InputType || (InputType = {}));
11
+ export const InputStruct = assign(LiteralStruct, object({
12
+ type: literal(NodeType.Input),
13
+ value: optional(string()),
14
+ name: string(),
15
+ inputType: optional(union([
16
+ enumValue(InputType.Text),
17
+ enumValue(InputType.Password),
18
+ enumValue(InputType.Number)
19
+ ])),
20
+ placeholder: optional(string()),
21
+ label: optional(string())
22
+ }));
23
+ /**
24
+ * Create a {@link Input} node.
25
+ *
26
+ * @param args - The node arguments. This can either be a name and an optional variant, value and placeholder or an object
27
+ * with the properties: `inputType`, `value`, `variant`, `placeholder` and `name`.
28
+ * @param args.name - The name for the input.
29
+ * @param args.value - The value of the input.
30
+ * @param args.inputType - An optional type, either `text`, `password` or `number`.
31
+ * @param args.placeholder - An optional input placeholder.
32
+ * @param args.label - An optional input label.
33
+ * @returns The input node as an object.
34
+ * @example
35
+ * const node = input('myInput');
36
+ * const node = input('myInput', InputType.Text, 'my placeholder', 'myValue', 'myLabel');
37
+ * const node = input({ name: 'myInput' });
38
+ * const node = input({name: 'myInput', value: 'myValue', inputType: InputType.Password, placeholder: 'placeholder'})
39
+ */ export const input = createBuilder(NodeType.Input, InputStruct, [
40
+ 'name',
41
+ 'inputType',
42
+ 'placeholder',
43
+ 'value',
44
+ 'label'
45
+ ]);
46
+
47
+ //# sourceMappingURL=input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/ui/components/input.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { assign, literal, object, optional, string, union } from 'superstruct';\n\nimport { enumValue } from '../../internals';\nimport { createBuilder } from '../builder';\nimport { LiteralStruct, NodeType } from '../nodes';\n\n/**\n * This replicates the available input types from the metamask extension.\n * https://github.com/MetaMask/metamask-extension/develop/ui/components/component-library/input/input.constants.js\n */\nexport enum InputType {\n /* eslint-disable @typescript-eslint/no-shadow */\n Text = 'text',\n Number = 'number',\n /* eslint-enable @typescript-eslint/no-shadow */\n Password = 'password',\n}\n\nexport const InputStruct = assign(\n LiteralStruct,\n object({\n type: literal(NodeType.Input),\n value: optional(string()),\n name: string(),\n inputType: optional(\n union([\n enumValue(InputType.Text),\n enumValue(InputType.Password),\n enumValue(InputType.Number),\n ]),\n ),\n placeholder: optional(string()),\n label: optional(string()),\n }),\n);\n\n/**\n * An input node, that renders an input.\n *\n * @property type - The type of the node, must be the string 'input'.\n * @property name - The name for the input.\n * @property value - The value of the input.\n * @property inputType - An optional type, either `text`, `password` or `number`.\n * @property placeholder - An optional input placeholder.\n * @property label - An optional input label.\n */\nexport type Input = Infer<typeof InputStruct>;\n\n/**\n * Create a {@link Input} node.\n *\n * @param args - The node arguments. This can either be a name and an optional variant, value and placeholder or an object\n * with the properties: `inputType`, `value`, `variant`, `placeholder` and `name`.\n * @param args.name - The name for the input.\n * @param args.value - The value of the input.\n * @param args.inputType - An optional type, either `text`, `password` or `number`.\n * @param args.placeholder - An optional input placeholder.\n * @param args.label - An optional input label.\n * @returns The input node as an object.\n * @example\n * const node = input('myInput');\n * const node = input('myInput', InputType.Text, 'my placeholder', 'myValue', 'myLabel');\n * const node = input({ name: 'myInput' });\n * const node = input({name: 'myInput', value: 'myValue', inputType: InputType.Password, placeholder: 'placeholder'})\n */\nexport const input = createBuilder(NodeType.Input, InputStruct, [\n 'name',\n 'inputType',\n 'placeholder',\n 'value',\n 'label',\n]);\n"],"names":["assign","literal","object","optional","string","union","enumValue","createBuilder","LiteralStruct","NodeType","InputType","Text","Number","Password","InputStruct","type","Input","value","name","inputType","placeholder","label","input"],"mappings":"AACA,SAASA,MAAM,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,KAAK,QAAQ,cAAc;AAE/E,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAASC,aAAa,EAAEC,QAAQ,QAAQ,WAAW;WAM5C;UAAKC,SAAS;IAATA,UACV,+CAA+C,GAC/CC,UAAO;IAFGD,UAGVE,YAAS;IAHCF,UAIV,8CAA8C,GAC9CG,cAAW;GALDH,cAAAA;AAQZ,OAAO,MAAMI,cAAcd,OACzBQ,eACAN,OAAO;IACLa,MAAMd,QAAQQ,SAASO,KAAK;IAC5BC,OAAOd,SAASC;IAChBc,MAAMd;IACNe,WAAWhB,SACTE,MAAM;QACJC,UAAUI,UAAUC,IAAI;QACxBL,UAAUI,UAAUG,QAAQ;QAC5BP,UAAUI,UAAUE,MAAM;KAC3B;IAEHQ,aAAajB,SAASC;IACtBiB,OAAOlB,SAASC;AAClB,IACA;AAcF;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,MAAMkB,QAAQf,cAAcE,SAASO,KAAK,EAAEF,aAAa;IAC9D;IACA;IACA;IACA;IACA;CACD,EAAE"}
@@ -2,10 +2,13 @@ import { array, assign, lazy, literal, object, union } from 'superstruct';
2
2
  import { createBuilder } from '../builder';
3
3
  import { NodeStruct, NodeType } from '../nodes';
4
4
  import { AddressStruct } from './address';
5
+ import { ButtonStruct } from './button';
5
6
  import { CopyableStruct } from './copyable';
6
7
  import { DividerStruct } from './divider';
8
+ import { FormStruct } from './form';
7
9
  import { HeadingStruct } from './heading';
8
10
  import { ImageStruct } from './image';
11
+ import { InputStruct } from './input';
9
12
  import { RowStruct } from './row';
10
13
  import { SpinnerStruct } from './spinner';
11
14
  import { TextStruct } from './text';
@@ -54,7 +57,10 @@ export const ComponentStruct = union([
54
57
  SpinnerStruct,
55
58
  TextStruct,
56
59
  RowStruct,
57
- AddressStruct
60
+ AddressStruct,
61
+ InputStruct,
62
+ FormStruct,
63
+ ButtonStruct
58
64
  ]);
59
65
 
60
66
  //# sourceMappingURL=panel.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/ui/components/panel.ts"],"sourcesContent":["import type { Infer, Struct } from 'superstruct';\nimport { array, assign, lazy, literal, object, union } from 'superstruct';\n\nimport { createBuilder } from '../builder';\nimport { NodeStruct, NodeType } from '../nodes';\nimport { AddressStruct } from './address';\nimport { CopyableStruct } from './copyable';\nimport { DividerStruct } from './divider';\nimport { HeadingStruct } from './heading';\nimport { ImageStruct } from './image';\nimport { RowStruct } from './row';\nimport { SpinnerStruct } from './spinner';\nimport { TextStruct } from './text';\n\n/**\n * @internal\n */\nexport const ParentStruct = assign(\n NodeStruct,\n object({\n // This node references itself indirectly, so we need to use `lazy()`.\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n children: array(lazy(() => ComponentStruct)),\n }),\n);\n\n/**\n * A node which supports child nodes. This is used for nodes that render their\n * children, such as {@link Panel}.\n *\n * @property type - The type of the node.\n * @property children - The children of the node\n * @internal\n */\nexport type Parent = Infer<typeof ParentStruct>;\n\n/**\n * @internal\n */\nexport const PanelStruct: Struct<Panel> = assign(\n ParentStruct,\n object({\n type: literal(NodeType.Panel),\n }),\n);\n\n/**\n * A panel node, which renders its children.\n *\n * @property type - The type of the node, must be the string 'text'.\n * @property value - The text content of the node, either as plain text, or as a\n * markdown string.\n */\n// This node references itself indirectly, so it cannot be inferred.\nexport type Panel = {\n type: NodeType.Panel;\n children: Component[];\n};\n\n/**\n * Create a {@link Panel} node.\n *\n * @param args - The node arguments. This can be either an array of children, or\n * an object with a `children` property.\n * @param args.children - The child nodes of the panel. This can be any valid\n * {@link Component}.\n * @returns The panel node as object.\n * @example\n * const node = panel({\n * children: [\n * heading({ text: 'Hello, world!' }),\n * text({ text: 'This is a panel.' }),\n * ],\n * });\n *\n * const node = panel([\n * heading('Hello, world!'),\n * text('This is a panel.'),\n * ]);\n */\nexport const panel = createBuilder(NodeType.Panel, PanelStruct, ['children']);\n\n// This is defined separately from `Component` to avoid circular dependencies.\nexport const ComponentStruct = union([\n CopyableStruct,\n DividerStruct,\n HeadingStruct,\n ImageStruct,\n PanelStruct,\n SpinnerStruct,\n TextStruct,\n RowStruct,\n AddressStruct,\n]);\n\n/**\n * All supported component types.\n */\nexport type Component = Infer<typeof ComponentStruct>;\n"],"names":["array","assign","lazy","literal","object","union","createBuilder","NodeStruct","NodeType","AddressStruct","CopyableStruct","DividerStruct","HeadingStruct","ImageStruct","RowStruct","SpinnerStruct","TextStruct","ParentStruct","children","ComponentStruct","PanelStruct","type","Panel","panel"],"mappings":"AACA,SAASA,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,MAAM,EAAEC,KAAK,QAAQ,cAAc;AAE1E,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAASC,UAAU,EAAEC,QAAQ,QAAQ,WAAW;AAChD,SAASC,aAAa,QAAQ,YAAY;AAC1C,SAASC,cAAc,QAAQ,aAAa;AAC5C,SAASC,aAAa,QAAQ,YAAY;AAC1C,SAASC,aAAa,QAAQ,YAAY;AAC1C,SAASC,WAAW,QAAQ,UAAU;AACtC,SAASC,SAAS,QAAQ,QAAQ;AAClC,SAASC,aAAa,QAAQ,YAAY;AAC1C,SAASC,UAAU,QAAQ,SAAS;AAEpC;;CAEC,GACD,OAAO,MAAMC,eAAehB,OAC1BM,YACAH,OAAO;IACL,sEAAsE;IACtE,mEAAmE;IACnEc,UAAUlB,MAAME,KAAK,IAAMiB;AAC7B,IACA;AAYF;;CAEC,GACD,OAAO,MAAMC,cAA6BnB,OACxCgB,cACAb,OAAO;IACLiB,MAAMlB,QAAQK,SAASc,KAAK;AAC9B,IACA;AAeF;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,MAAMC,QAAQjB,cAAcE,SAASc,KAAK,EAAEF,aAAa;IAAC;CAAW,EAAE;AAE9E,8EAA8E;AAC9E,OAAO,MAAMD,kBAAkBd,MAAM;IACnCK;IACAC;IACAC;IACAC;IACAO;IACAL;IACAC;IACAF;IACAL;CACD,EAAE"}
1
+ {"version":3,"sources":["../../../../src/ui/components/panel.ts"],"sourcesContent":["import type { Infer, Struct } from 'superstruct';\nimport { array, assign, lazy, literal, object, union } from 'superstruct';\n\nimport { createBuilder } from '../builder';\nimport { NodeStruct, NodeType } from '../nodes';\nimport { AddressStruct } from './address';\nimport { ButtonStruct } from './button';\nimport { CopyableStruct } from './copyable';\nimport { DividerStruct } from './divider';\nimport { FormStruct } from './form';\nimport { HeadingStruct } from './heading';\nimport { ImageStruct } from './image';\nimport { InputStruct } from './input';\nimport { RowStruct } from './row';\nimport { SpinnerStruct } from './spinner';\nimport { TextStruct } from './text';\n\n/**\n * @internal\n */\nexport const ParentStruct = assign(\n NodeStruct,\n object({\n // This node references itself indirectly, so we need to use `lazy()`.\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n children: array(lazy(() => ComponentStruct)),\n }),\n);\n\n/**\n * A node which supports child nodes. This is used for nodes that render their\n * children, such as {@link Panel}.\n *\n * @property type - The type of the node.\n * @property children - The children of the node\n * @internal\n */\nexport type Parent = Infer<typeof ParentStruct>;\n\n/**\n * @internal\n */\nexport const PanelStruct: Struct<Panel> = assign(\n ParentStruct,\n object({\n type: literal(NodeType.Panel),\n }),\n);\n\n/**\n * A panel node, which renders its children.\n *\n * @property type - The type of the node, must be the string 'text'.\n * @property value - The text content of the node, either as plain text, or as a\n * markdown string.\n */\n// This node references itself indirectly, so it cannot be inferred.\nexport type Panel = {\n type: NodeType.Panel;\n children: Component[];\n};\n\n/**\n * Create a {@link Panel} node.\n *\n * @param args - The node arguments. This can be either an array of children, or\n * an object with a `children` property.\n * @param args.children - The child nodes of the panel. This can be any valid\n * {@link Component}.\n * @returns The panel node as object.\n * @example\n * const node = panel({\n * children: [\n * heading({ text: 'Hello, world!' }),\n * text({ text: 'This is a panel.' }),\n * ],\n * });\n *\n * const node = panel([\n * heading('Hello, world!'),\n * text('This is a panel.'),\n * ]);\n */\nexport const panel = createBuilder(NodeType.Panel, PanelStruct, ['children']);\n\n// This is defined separately from `Component` to avoid circular dependencies.\nexport const ComponentStruct = union([\n CopyableStruct,\n DividerStruct,\n HeadingStruct,\n ImageStruct,\n PanelStruct,\n SpinnerStruct,\n TextStruct,\n RowStruct,\n AddressStruct,\n InputStruct,\n FormStruct,\n ButtonStruct,\n]);\n\n/**\n * All supported component types.\n */\nexport type Component = Infer<typeof ComponentStruct>;\n"],"names":["array","assign","lazy","literal","object","union","createBuilder","NodeStruct","NodeType","AddressStruct","ButtonStruct","CopyableStruct","DividerStruct","FormStruct","HeadingStruct","ImageStruct","InputStruct","RowStruct","SpinnerStruct","TextStruct","ParentStruct","children","ComponentStruct","PanelStruct","type","Panel","panel"],"mappings":"AACA,SAASA,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,MAAM,EAAEC,KAAK,QAAQ,cAAc;AAE1E,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAASC,UAAU,EAAEC,QAAQ,QAAQ,WAAW;AAChD,SAASC,aAAa,QAAQ,YAAY;AAC1C,SAASC,YAAY,QAAQ,WAAW;AACxC,SAASC,cAAc,QAAQ,aAAa;AAC5C,SAASC,aAAa,QAAQ,YAAY;AAC1C,SAASC,UAAU,QAAQ,SAAS;AACpC,SAASC,aAAa,QAAQ,YAAY;AAC1C,SAASC,WAAW,QAAQ,UAAU;AACtC,SAASC,WAAW,QAAQ,UAAU;AACtC,SAASC,SAAS,QAAQ,QAAQ;AAClC,SAASC,aAAa,QAAQ,YAAY;AAC1C,SAASC,UAAU,QAAQ,SAAS;AAEpC;;CAEC,GACD,OAAO,MAAMC,eAAenB,OAC1BM,YACAH,OAAO;IACL,sEAAsE;IACtE,mEAAmE;IACnEiB,UAAUrB,MAAME,KAAK,IAAMoB;AAC7B,IACA;AAYF;;CAEC,GACD,OAAO,MAAMC,cAA6BtB,OACxCmB,cACAhB,OAAO;IACLoB,MAAMrB,QAAQK,SAASiB,KAAK;AAC9B,IACA;AAeF;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,MAAMC,QAAQpB,cAAcE,SAASiB,KAAK,EAAEF,aAAa;IAAC;CAAW,EAAE;AAE9E,8EAA8E;AAC9E,OAAO,MAAMD,kBAAkBjB,MAAM;IACnCM;IACAC;IACAE;IACAC;IACAQ;IACAL;IACAC;IACAF;IACAR;IACAO;IACAH;IACAH;CACD,EAAE"}
@@ -11,6 +11,9 @@ export var NodeType;
11
11
  NodeType["Image"] = 'image';
12
12
  NodeType["Row"] = 'row';
13
13
  NodeType["Address"] = 'address';
14
+ NodeType["Button"] = 'button';
15
+ NodeType["Input"] = 'input';
16
+ NodeType["Form"] = 'form';
14
17
  })(NodeType || (NodeType = {}));
15
18
  /**
16
19
  * @internal
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ui/nodes.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { assign, object, string, unknown } from 'superstruct';\n\n/**\n * The supported node types. This is based on SIP-7.\n *\n * @see https://metamask.github.io/SIPs/SIPS/sip-7\n */\nexport enum NodeType {\n Copyable = 'copyable',\n Divider = 'divider',\n Heading = 'heading',\n Panel = 'panel',\n Spinner = 'spinner',\n // eslint-disable-next-line @typescript-eslint/no-shadow\n Text = 'text',\n Image = 'image',\n Row = 'row',\n Address = 'address',\n}\n\n/**\n * @internal\n */\nexport const NodeStruct = object({\n type: string(),\n});\n\n/**\n * The base node type. All nodes extend this type.\n *\n * @property type - The type of the node. See {@link NodeType} for the supported\n * node types.\n * @internal\n */\nexport type Node = Infer<typeof NodeStruct>;\n\n/**\n * @internal\n */\nexport const LiteralStruct = assign(\n NodeStruct,\n object({\n value: unknown(),\n }),\n);\n\n/**\n * A node with a value. This is used for nodes that render a value, such as\n * {@link Text}.\n *\n * @property type - The type of the node.\n * @property value - The value of the node. The type of the value depends on the\n * node type.\n * @internal\n */\nexport type Literal = Infer<typeof LiteralStruct>;\n"],"names":["assign","object","string","unknown","NodeType","Copyable","Divider","Heading","Panel","Spinner","Text","Image","Row","Address","NodeStruct","type","LiteralStruct","value"],"mappings":"AACA,SAASA,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,OAAO,QAAQ,cAAc;WAOvD;UAAKC,QAAQ;IAARA,SACVC,cAAW;IADDD,SAEVE,aAAU;IAFAF,SAGVG,aAAU;IAHAH,SAIVI,WAAQ;IAJEJ,SAKVK,aAAU;IALAL,SAMV,wDAAwD;IACxDM,UAAO;IAPGN,SAQVO,WAAQ;IAREP,SASVQ,SAAM;IATIR,SAUVS,aAAU;GAVAT,aAAAA;AAaZ;;CAEC,GACD,OAAO,MAAMU,aAAab,OAAO;IAC/Bc,MAAMb;AACR,GAAG;AAWH;;CAEC,GACD,OAAO,MAAMc,gBAAgBhB,OAC3Bc,YACAb,OAAO;IACLgB,OAAOd;AACT,IACA"}
1
+ {"version":3,"sources":["../../../src/ui/nodes.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { assign, object, string, unknown } from 'superstruct';\n\n/**\n * The supported node types. This is based on SIP-7.\n *\n * @see https://metamask.github.io/SIPs/SIPS/sip-7\n */\nexport enum NodeType {\n Copyable = 'copyable',\n Divider = 'divider',\n Heading = 'heading',\n Panel = 'panel',\n Spinner = 'spinner',\n // eslint-disable-next-line @typescript-eslint/no-shadow\n Text = 'text',\n Image = 'image',\n Row = 'row',\n Address = 'address',\n Button = 'button',\n Input = 'input',\n Form = 'form',\n}\n\n/**\n * @internal\n */\nexport const NodeStruct = object({\n type: string(),\n});\n\n/**\n * The base node type. All nodes extend this type.\n *\n * @property type - The type of the node. See {@link NodeType} for the supported\n * node types.\n * @internal\n */\nexport type Node = Infer<typeof NodeStruct>;\n\n/**\n * @internal\n */\nexport const LiteralStruct = assign(\n NodeStruct,\n object({\n value: unknown(),\n }),\n);\n\n/**\n * A node with a value. This is used for nodes that render a value, such as\n * {@link Text}.\n *\n * @property type - The type of the node.\n * @property value - The value of the node. The type of the value depends on the\n * node type.\n * @internal\n */\nexport type Literal = Infer<typeof LiteralStruct>;\n"],"names":["assign","object","string","unknown","NodeType","Copyable","Divider","Heading","Panel","Spinner","Text","Image","Row","Address","Button","Input","Form","NodeStruct","type","LiteralStruct","value"],"mappings":"AACA,SAASA,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,OAAO,QAAQ,cAAc;WAOvD;UAAKC,QAAQ;IAARA,SACVC,cAAW;IADDD,SAEVE,aAAU;IAFAF,SAGVG,aAAU;IAHAH,SAIVI,WAAQ;IAJEJ,SAKVK,aAAU;IALAL,SAMV,wDAAwD;IACxDM,UAAO;IAPGN,SAQVO,WAAQ;IAREP,SASVQ,SAAM;IATIR,SAUVS,aAAU;IAVAT,SAWVU,YAAS;IAXCV,SAYVW,WAAQ;IAZEX,SAaVY,UAAO;GAbGZ,aAAAA;AAgBZ;;CAEC,GACD,OAAO,MAAMa,aAAahB,OAAO;IAC/BiB,MAAMhB;AACR,GAAG;AAWH;;CAEC,GACD,OAAO,MAAMiB,gBAAgBnB,OAC3BiB,YACAhB,OAAO;IACLmB,OAAOjB;AACT,IACA"}
@@ -13,7 +13,10 @@ export declare type OnHomePageHandler = () => Promise<OnHomePageResponse>;
13
13
  * The content to display on the home page.
14
14
  *
15
15
  * @property content - A custom UI component, that will be shown in MetaMask.
16
+ * @property id - A custom UI interface ID, that will be shown in MetaMask.
16
17
  */
17
18
  export declare type OnHomePageResponse = {
18
19
  content: Component;
20
+ } | {
21
+ id: string;
19
22
  };
@@ -5,3 +5,5 @@ export * from './lifecycle';
5
5
  export * from './name-lookup';
6
6
  export * from './rpc-request';
7
7
  export * from './transaction';
8
+ export * from './signature';
9
+ export * from './user-input';
@@ -1,3 +1,4 @@
1
+ import type { NonEmptyArray } from '@metamask/utils';
1
2
  import type { ChainId } from '../caip';
2
3
  declare type BaseOnNameLookupArgs = {
3
4
  chainId: ChainId;
@@ -12,22 +13,42 @@ export declare type DomainLookupArgs = BaseOnNameLookupArgs & {
12
13
  address?: never;
13
14
  };
14
15
  /**
15
- * The result of a domain lookup.
16
+ * The arguments for an address lookup.
16
17
  *
18
+ * @property address - The address that is to be resolved.
19
+ */
20
+ export declare type AddressLookupArgs = BaseOnNameLookupArgs & {
21
+ address: string;
22
+ domain?: never;
23
+ };
24
+ /**
25
+ * The address resolution object.
26
+ *
27
+ * @property protocol - The protocol that resolved the domain.
17
28
  * @property resolvedAddress - The resolved address.
18
29
  */
19
- export declare type DomainLookupResult = {
30
+ export declare type AddressResolution = {
31
+ protocol: string;
20
32
  resolvedAddress: string;
21
- resolvedDomain?: never;
22
33
  };
23
34
  /**
24
- * The arguments for an address lookup.
35
+ * The domain resolution object.
25
36
  *
26
- * @property address - The address that is to be resolved.
37
+ * @property protocol - The protocol that resolved the address.
38
+ * @property resolvedDomain - The resolved domain.
27
39
  */
28
- export declare type AddressLookupArgs = BaseOnNameLookupArgs & {
29
- address: string;
30
- domain?: never;
40
+ export declare type DomainResolution = {
41
+ protocol: string;
42
+ resolvedDomain: string;
43
+ };
44
+ /**
45
+ * The result of a domain lookup.
46
+ *
47
+ * @property resolvedAddress - The resolved address.
48
+ */
49
+ export declare type DomainLookupResult = {
50
+ resolvedAddresses: NonEmptyArray<AddressResolution>;
51
+ resolvedDomains?: never;
31
52
  };
32
53
  /**
33
54
  * The result of an address lookup.
@@ -35,8 +56,8 @@ export declare type AddressLookupArgs = BaseOnNameLookupArgs & {
35
56
  * @property resolvedDomain - The resolved domain name.
36
57
  */
37
58
  export declare type AddressLookupResult = {
38
- resolvedDomain: string;
39
- resolvedAddress?: never;
59
+ resolvedDomains: NonEmptyArray<DomainResolution>;
60
+ resolvedAddresses?: never;
40
61
  };
41
62
  /**
42
63
  * The `onNameLookup` handler, which is called when MetaMask needs to resolve an