@metamask/snaps-sdk 1.4.0 → 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.
- package/CHANGELOG.md +12 -1
- package/dist/cjs/types/handlers/index.js +1 -0
- package/dist/cjs/types/handlers/index.js.map +1 -1
- package/dist/cjs/types/handlers/transaction.js.map +1 -1
- package/dist/cjs/types/handlers/user-input.js +51 -0
- package/dist/cjs/types/handlers/user-input.js.map +1 -0
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/cjs/types/interface.js +26 -0
- package/dist/cjs/types/interface.js.map +1 -0
- package/dist/cjs/types/methods/create-interface.js +6 -0
- package/dist/cjs/types/methods/create-interface.js.map +1 -0
- package/dist/cjs/types/methods/dialog.js.map +1 -1
- package/dist/cjs/types/methods/get-interface-state.js +6 -0
- package/dist/cjs/types/methods/get-interface-state.js.map +1 -0
- package/dist/cjs/types/methods/index.js +3 -0
- package/dist/cjs/types/methods/index.js.map +1 -1
- package/dist/cjs/types/methods/update-interface.js +6 -0
- package/dist/cjs/types/methods/update-interface.js.map +1 -0
- package/dist/cjs/ui/components/button.js +59 -0
- package/dist/cjs/ui/components/button.js.map +1 -0
- package/dist/cjs/ui/components/form.js +41 -0
- package/dist/cjs/ui/components/form.js.map +1 -0
- package/dist/cjs/ui/components/index.js +3 -0
- package/dist/cjs/ui/components/index.js.map +1 -1
- package/dist/cjs/ui/components/input.js +52 -0
- package/dist/cjs/ui/components/input.js.map +1 -0
- package/dist/cjs/ui/components/panel.js +7 -1
- package/dist/cjs/ui/components/panel.js.map +1 -1
- package/dist/cjs/ui/nodes.js +3 -0
- package/dist/cjs/ui/nodes.js.map +1 -1
- package/dist/esm/types/handlers/home-page.js.map +1 -1
- package/dist/esm/types/handlers/index.js +1 -0
- package/dist/esm/types/handlers/index.js.map +1 -1
- package/dist/esm/types/handlers/name-lookup.js.map +1 -1
- package/dist/esm/types/handlers/signature.js.map +1 -1
- package/dist/esm/types/handlers/transaction.js.map +1 -1
- package/dist/esm/types/handlers/user-input.js +24 -0
- package/dist/esm/types/handlers/user-input.js.map +1 -0
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/types/interface.js +12 -0
- package/dist/esm/types/interface.js.map +1 -0
- package/dist/esm/types/methods/create-interface.js +3 -0
- package/dist/esm/types/methods/create-interface.js.map +1 -0
- package/dist/esm/types/methods/dialog.js.map +1 -1
- package/dist/esm/types/methods/get-interface-state.js +3 -0
- package/dist/esm/types/methods/get-interface-state.js.map +1 -0
- package/dist/esm/types/methods/index.js +3 -0
- package/dist/esm/types/methods/index.js.map +1 -1
- package/dist/esm/types/methods/methods.js.map +1 -1
- package/dist/esm/types/methods/update-interface.js +3 -0
- package/dist/esm/types/methods/update-interface.js.map +1 -0
- package/dist/esm/types/permissions.js.map +1 -1
- package/dist/esm/ui/components/button.js +50 -0
- package/dist/esm/ui/components/button.js.map +1 -0
- package/dist/esm/ui/components/form.js +39 -0
- package/dist/esm/ui/components/form.js.map +1 -0
- package/dist/esm/ui/components/index.js +3 -0
- package/dist/esm/ui/components/index.js.map +1 -1
- package/dist/esm/ui/components/input.js +47 -0
- package/dist/esm/ui/components/input.js.map +1 -0
- package/dist/esm/ui/components/panel.js +7 -1
- package/dist/esm/ui/components/panel.js.map +1 -1
- package/dist/esm/ui/nodes.js +3 -0
- package/dist/esm/ui/nodes.js.map +1 -1
- package/dist/types/types/handlers/home-page.d.ts +3 -0
- package/dist/types/types/handlers/index.d.ts +1 -0
- package/dist/types/types/handlers/name-lookup.d.ts +31 -10
- package/dist/types/types/handlers/signature.d.ts +4 -0
- package/dist/types/types/handlers/transaction.d.ts +4 -0
- package/dist/types/types/handlers/user-input.d.ts +64 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/interface.d.ts +10 -0
- package/dist/types/types/methods/create-interface.d.ts +13 -0
- package/dist/types/types/methods/dialog.d.ts +14 -0
- package/dist/types/types/methods/get-interface-state.d.ts +13 -0
- package/dist/types/types/methods/index.d.ts +3 -0
- package/dist/types/types/methods/methods.d.ts +6 -0
- package/dist/types/types/methods/update-interface.d.ts +15 -0
- package/dist/types/types/permissions.d.ts +39 -20
- package/dist/types/ui/components/button.d.ts +62 -0
- package/dist/types/ui/components/form.d.ts +144 -0
- package/dist/types/ui/components/index.d.ts +3 -0
- package/dist/types/ui/components/input.d.ts +69 -0
- package/dist/types/ui/components/panel.d.ts +150 -0
- package/dist/types/ui/nodes.d.ts +4 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [2.0.0]
|
|
10
|
+
### Changed
|
|
11
|
+
- **BREAKING:** Update name lookup API types ([#2113](https://github.com/MetaMask/snaps/pull/2113))
|
|
12
|
+
- The return value and the permission format has changed, see [SIP-12](https://metamask.github.io/SIPs/SIPS/sip-12) for more details.
|
|
13
|
+
- Add support for dynamic user interfaces ([#1465](https://github.com/MetaMask/snaps/pull/1465), [#2126](https://github.com/MetaMask/snaps/pull/2126), [#2143](https://github.com/MetaMask/snaps/pull/2143))
|
|
14
|
+
- Add support for snap defined execution timeouts ([#2098](https://github.com/MetaMask/snaps/pull/2098))
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
- Fix initial permissions types ([#2111](https://github.com/MetaMask/snaps/pull/2111))
|
|
18
|
+
|
|
9
19
|
## [1.4.0]
|
|
10
20
|
### Added
|
|
11
21
|
- Add support for signature insights ([#2074](https://github.com/MetaMask/snaps/pull/2074), [#2079](https://github.com/MetaMask/snaps/pull/2079))
|
|
@@ -45,7 +55,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
45
55
|
### Added
|
|
46
56
|
- Initial release of this package.
|
|
47
57
|
|
|
48
|
-
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@
|
|
58
|
+
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@2.0.0...HEAD
|
|
59
|
+
[2.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@1.4.0...@metamask/snaps-sdk@2.0.0
|
|
49
60
|
[1.4.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@1.3.2...@metamask/snaps-sdk@1.4.0
|
|
50
61
|
[1.3.2]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@1.3.1...@metamask/snaps-sdk@1.3.2
|
|
51
62
|
[1.3.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@1.3.0...@metamask/snaps-sdk@1.3.1
|
|
@@ -10,6 +10,7 @@ _export_star(require("./name-lookup"), exports);
|
|
|
10
10
|
_export_star(require("./rpc-request"), exports);
|
|
11
11
|
_export_star(require("./transaction"), exports);
|
|
12
12
|
_export_star(require("./signature"), exports);
|
|
13
|
+
_export_star(require("./user-input"), exports);
|
|
13
14
|
function _export_star(from, to) {
|
|
14
15
|
Object.keys(from).forEach(function(k) {
|
|
15
16
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/types/handlers/index.ts"],"sourcesContent":["export * from './cronjob';\nexport * from './home-page';\nexport * from './keyring';\nexport * from './lifecycle';\nexport * from './name-lookup';\nexport * from './rpc-request';\nexport * from './transaction';\nexport * from './signature';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/handlers/index.ts"],"sourcesContent":["export * from './cronjob';\nexport * from './home-page';\nexport * from './keyring';\nexport * from './lifecycle';\nexport * from './name-lookup';\nexport * from './rpc-request';\nexport * from './transaction';\nexport * from './signature';\nexport * from './user-input';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
|
|
@@ -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
|
|
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":";;;;;;;;;;IAWO;UAAKA,aAAa;IAAbA,cACVC,cAAW;GADDD,kBAAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
UserInputEventType: function() {
|
|
13
|
+
return UserInputEventType;
|
|
14
|
+
},
|
|
15
|
+
GenericEventStruct: function() {
|
|
16
|
+
return GenericEventStruct;
|
|
17
|
+
},
|
|
18
|
+
ButtonClickEventStruct: function() {
|
|
19
|
+
return ButtonClickEventStruct;
|
|
20
|
+
},
|
|
21
|
+
FormSubmitEventStruct: function() {
|
|
22
|
+
return FormSubmitEventStruct;
|
|
23
|
+
},
|
|
24
|
+
UserInputEventStruct: function() {
|
|
25
|
+
return UserInputEventStruct;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const _superstruct = require("superstruct");
|
|
29
|
+
var UserInputEventType;
|
|
30
|
+
(function(UserInputEventType) {
|
|
31
|
+
UserInputEventType["ButtonClickEvent"] = "ButtonClickEvent";
|
|
32
|
+
UserInputEventType["FormSubmitEvent"] = "FormSubmitEvent";
|
|
33
|
+
})(UserInputEventType || (UserInputEventType = {}));
|
|
34
|
+
const GenericEventStruct = (0, _superstruct.object)({
|
|
35
|
+
type: (0, _superstruct.string)(),
|
|
36
|
+
name: (0, _superstruct.optional)((0, _superstruct.string)())
|
|
37
|
+
});
|
|
38
|
+
const ButtonClickEventStruct = (0, _superstruct.assign)(GenericEventStruct, (0, _superstruct.object)({
|
|
39
|
+
type: (0, _superstruct.literal)(UserInputEventType.ButtonClickEvent)
|
|
40
|
+
}));
|
|
41
|
+
const FormSubmitEventStruct = (0, _superstruct.assign)(GenericEventStruct, (0, _superstruct.object)({
|
|
42
|
+
type: (0, _superstruct.literal)(UserInputEventType.FormSubmitEvent),
|
|
43
|
+
value: (0, _superstruct.record)((0, _superstruct.string)(), (0, _superstruct.string)()),
|
|
44
|
+
name: (0, _superstruct.string)()
|
|
45
|
+
}));
|
|
46
|
+
const UserInputEventStruct = (0, _superstruct.union)([
|
|
47
|
+
ButtonClickEventStruct,
|
|
48
|
+
FormSubmitEventStruct
|
|
49
|
+
]);
|
|
50
|
+
|
|
51
|
+
//# 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":["GenericEventStruct","ButtonClickEventStruct","FormSubmitEventStruct","UserInputEventStruct","UserInputEventType","ButtonClickEvent","FormSubmitEvent","object","type","string","name","optional","assign","literal","value","record","union"],"mappings":";;;;;;;;;;;;;;IAuBaA,kBAAkB;eAAlBA;;IAKAC,sBAAsB;eAAtBA;;IAOAC,qBAAqB;eAArBA;;IASAC,oBAAoB;eAApBA;;;6BAnCN;IASA;UAAKC,kBAAkB;IAAlBA,mBACVC,sBAAAA;IADUD,mBAEVE,qBAAAA;GAFUF,uBAAAA;AAKL,MAAMJ,qBAAqBO,IAAAA,mBAAM,EAAC;IACvCC,MAAMC,IAAAA,mBAAM;IACZC,MAAMC,IAAAA,qBAAQ,EAACF,IAAAA,mBAAM;AACvB;AAEO,MAAMR,yBAAyBW,IAAAA,mBAAM,EAC1CZ,oBACAO,IAAAA,mBAAM,EAAC;IACLC,MAAMK,IAAAA,oBAAO,EAACT,mBAAmBC,gBAAgB;AACnD;AAGK,MAAMH,wBAAwBU,IAAAA,mBAAM,EACzCZ,oBACAO,IAAAA,mBAAM,EAAC;IACLC,MAAMK,IAAAA,oBAAO,EAACT,mBAAmBE,eAAe;IAChDQ,OAAOC,IAAAA,mBAAM,EAACN,IAAAA,mBAAM,KAAIA,IAAAA,mBAAM;IAC9BC,MAAMD,IAAAA,mBAAM;AACd;AAGK,MAAMN,uBAAuBa,IAAAA,kBAAK,EAAC;IACxCf;IACAC;CACD"}
|
package/dist/cjs/types/index.js
CHANGED
|
@@ -11,6 +11,7 @@ _export_star(require("./methods"), exports);
|
|
|
11
11
|
_export_star(require("./permissions"), exports);
|
|
12
12
|
_export_star(require("./provider"), exports);
|
|
13
13
|
_export_star(require("./snap"), exports);
|
|
14
|
+
_export_star(require("./interface"), exports);
|
|
14
15
|
function _export_star(from, to) {
|
|
15
16
|
Object.keys(from).forEach(function(k) {
|
|
16
17
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -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;;;;;QAChD;qBAEO;qBACA;qBACA;qBACA;qBACA;qBACA"}
|
|
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;;;;;QAChD;qBAEO;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
FormStateStruct: function() {
|
|
13
|
+
return FormStateStruct;
|
|
14
|
+
},
|
|
15
|
+
InterfaceStateStruct: function() {
|
|
16
|
+
return InterfaceStateStruct;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _superstruct = require("superstruct");
|
|
20
|
+
const FormStateStruct = (0, _superstruct.record)((0, _superstruct.string)(), (0, _superstruct.nullable)((0, _superstruct.string)()));
|
|
21
|
+
const InterfaceStateStruct = (0, _superstruct.record)((0, _superstruct.string)(), (0, _superstruct.union)([
|
|
22
|
+
FormStateStruct,
|
|
23
|
+
(0, _superstruct.nullable)((0, _superstruct.string)())
|
|
24
|
+
]));
|
|
25
|
+
|
|
26
|
+
//# 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":["FormStateStruct","InterfaceStateStruct","record","string","nullable","union"],"mappings":";;;;;;;;;;;IASaA,eAAe;eAAfA;;IAEAC,oBAAoB;eAApBA;;;6BAVmC;AAQzC,MAAMD,kBAAkBE,IAAAA,mBAAM,EAACC,IAAAA,mBAAM,KAAIC,IAAAA,qBAAQ,EAACD,IAAAA,mBAAM;AAExD,MAAMF,uBAAuBC,IAAAA,mBAAM,EACxCC,IAAAA,mBAAM,KACNE,IAAAA,kBAAK,EAAC;IAACL;IAAiBI,IAAAA,qBAAQ,EAACD,IAAAA,mBAAM;CAAI"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/methods/create-interface.ts"],"names":[],"mappings":""}
|
|
@@ -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
|
|
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":";;;;;;;;;;IAWO;UAAKA,UAAU;IAAVA,WACVC,WAAQ;IADED,WAEVE,kBAAe;IAFLF,WAGVG,YAAS;GAHCH,eAAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/methods/get-interface-state.ts"],"names":[],"mappings":""}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
+
_export_star(require("./create-interface"), exports);
|
|
5
6
|
_export_star(require("./dialog"), exports);
|
|
6
7
|
_export_star(require("./get-bip32-entropy"), exports);
|
|
7
8
|
_export_star(require("./get-bip32-public-key"), exports);
|
|
@@ -9,6 +10,7 @@ _export_star(require("./get-bip44-entropy"), exports);
|
|
|
9
10
|
_export_star(require("./get-client-status"), exports);
|
|
10
11
|
_export_star(require("./get-entropy"), exports);
|
|
11
12
|
_export_star(require("./get-file"), exports);
|
|
13
|
+
_export_star(require("./get-interface-state"), exports);
|
|
12
14
|
_export_star(require("./get-locale"), exports);
|
|
13
15
|
_export_star(require("./get-snaps"), exports);
|
|
14
16
|
_export_star(require("./invoke-keyring"), exports);
|
|
@@ -18,6 +20,7 @@ _export_star(require("./manage-state"), exports);
|
|
|
18
20
|
_export_star(require("./methods"), exports);
|
|
19
21
|
_export_star(require("./notify"), exports);
|
|
20
22
|
_export_star(require("./request-snaps"), exports);
|
|
23
|
+
_export_star(require("./update-interface"), exports);
|
|
21
24
|
function _export_star(from, to) {
|
|
22
25
|
Object.keys(from).forEach(function(k) {
|
|
23
26
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -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-client-status';\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":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
|
|
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":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/methods/update-interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
ButtonVariant: function() {
|
|
13
|
+
return ButtonVariant;
|
|
14
|
+
},
|
|
15
|
+
ButtonType: function() {
|
|
16
|
+
return ButtonType;
|
|
17
|
+
},
|
|
18
|
+
ButtonStruct: function() {
|
|
19
|
+
return ButtonStruct;
|
|
20
|
+
},
|
|
21
|
+
button: function() {
|
|
22
|
+
return button;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const _superstruct = require("superstruct");
|
|
26
|
+
const _internals = require("../../internals");
|
|
27
|
+
const _builder = require("../builder");
|
|
28
|
+
const _nodes = require("../nodes");
|
|
29
|
+
var ButtonVariant;
|
|
30
|
+
(function(ButtonVariant) {
|
|
31
|
+
ButtonVariant["Primary"] = 'primary';
|
|
32
|
+
ButtonVariant["Secondary"] = 'secondary';
|
|
33
|
+
})(ButtonVariant || (ButtonVariant = {}));
|
|
34
|
+
var ButtonType;
|
|
35
|
+
(function(ButtonType) {
|
|
36
|
+
ButtonType["Button"] = 'button';
|
|
37
|
+
ButtonType["Submit"] = 'submit';
|
|
38
|
+
})(ButtonType || (ButtonType = {}));
|
|
39
|
+
const ButtonStruct = (0, _superstruct.assign)(_nodes.LiteralStruct, (0, _superstruct.object)({
|
|
40
|
+
type: (0, _superstruct.literal)(_nodes.NodeType.Button),
|
|
41
|
+
value: (0, _superstruct.string)(),
|
|
42
|
+
variant: (0, _superstruct.optional)((0, _superstruct.union)([
|
|
43
|
+
(0, _internals.enumValue)(ButtonVariant.Primary),
|
|
44
|
+
(0, _internals.enumValue)(ButtonVariant.Secondary)
|
|
45
|
+
])),
|
|
46
|
+
buttonType: (0, _superstruct.optional)((0, _superstruct.union)([
|
|
47
|
+
(0, _internals.enumValue)(ButtonType.Button),
|
|
48
|
+
(0, _internals.enumValue)(ButtonType.Submit)
|
|
49
|
+
])),
|
|
50
|
+
name: (0, _superstruct.optional)((0, _superstruct.string)())
|
|
51
|
+
}));
|
|
52
|
+
const button = (0, _builder.createBuilder)(_nodes.NodeType.Button, ButtonStruct, [
|
|
53
|
+
'value',
|
|
54
|
+
'buttonType',
|
|
55
|
+
'name',
|
|
56
|
+
'variant'
|
|
57
|
+
]);
|
|
58
|
+
|
|
59
|
+
//# 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":["ButtonStruct","button","ButtonVariant","Primary","Secondary","ButtonType","Button","Submit","assign","LiteralStruct","object","type","literal","NodeType","value","string","variant","optional","union","enumValue","buttonType","name","createBuilder"],"mappings":";;;;;;;;;;;;;;;;;IAiBaA,YAAY;eAAZA;;IA6CAC,MAAM;eAANA;;;6BA7DoD;2BAEvC;yBACI;uBACU;IAEjC;UAAKC,aAAa;IAAbA,cACVC,aAAU;IADAD,cAEVE,eAAY;GAFFF,kBAAAA;IAKL;UAAKG,UAAU;IAAVA,WACVC,YAAS;IADCD,WAEVE,YAAS;GAFCF,eAAAA;AAKL,MAAML,eAAeQ,IAAAA,mBAAM,EAChCC,oBAAa,EACbC,IAAAA,mBAAM,EAAC;IACLC,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACP,MAAM;IAC7BQ,OAAOC,IAAAA,mBAAM;IACbC,SAASC,IAAAA,qBAAQ,EACfC,IAAAA,kBAAK,EAAC;QACJC,IAAAA,oBAAS,EAACjB,cAAcC,OAAO;QAC/BgB,IAAAA,oBAAS,EAACjB,cAAcE,SAAS;KAClC;IAEHgB,YAAYH,IAAAA,qBAAQ,EAClBC,IAAAA,kBAAK,EAAC;QAACC,IAAAA,oBAAS,EAACd,WAAWC,MAAM;QAAGa,IAAAA,oBAAS,EAACd,WAAWE,MAAM;KAAE;IAEpEc,MAAMJ,IAAAA,qBAAQ,EAACF,IAAAA,mBAAM;AACvB;AA8BK,MAAMd,SAASqB,IAAAA,sBAAa,EAACT,eAAQ,CAACP,MAAM,EAAEN,cAAc;IACjE;IACA;IACA;IACA;CACD"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
FormComponentStruct: function() {
|
|
13
|
+
return FormComponentStruct;
|
|
14
|
+
},
|
|
15
|
+
FormStruct: function() {
|
|
16
|
+
return FormStruct;
|
|
17
|
+
},
|
|
18
|
+
form: function() {
|
|
19
|
+
return form;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const _superstruct = require("superstruct");
|
|
23
|
+
const _builder = require("../builder");
|
|
24
|
+
const _nodes = require("../nodes");
|
|
25
|
+
const _button = require("./button");
|
|
26
|
+
const _input = require("./input");
|
|
27
|
+
const FormComponentStruct = (0, _superstruct.union)([
|
|
28
|
+
_input.InputStruct,
|
|
29
|
+
_button.ButtonStruct
|
|
30
|
+
]);
|
|
31
|
+
const FormStruct = (0, _superstruct.assign)(_nodes.NodeStruct, (0, _superstruct.object)({
|
|
32
|
+
type: (0, _superstruct.literal)(_nodes.NodeType.Form),
|
|
33
|
+
children: (0, _superstruct.array)(FormComponentStruct),
|
|
34
|
+
name: (0, _superstruct.string)()
|
|
35
|
+
}));
|
|
36
|
+
const form = (0, _builder.createBuilder)(_nodes.NodeType.Form, FormStruct, [
|
|
37
|
+
'name',
|
|
38
|
+
'children'
|
|
39
|
+
]);
|
|
40
|
+
|
|
41
|
+
//# 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":["FormComponentStruct","FormStruct","form","union","InputStruct","ButtonStruct","assign","NodeStruct","object","type","literal","NodeType","Form","children","array","name","string","createBuilder"],"mappings":";;;;;;;;;;;IAQaA,mBAAmB;eAAnBA;;IAOAC,UAAU;eAAVA;;IAsCAC,IAAI;eAAJA;;;6BApDiD;yBAEhC;uBACO;wBACR;uBACD;AAErB,MAAMF,sBAAsBG,IAAAA,kBAAK,EAAC;IAACC,kBAAW;IAAEC,oBAAY;CAAC;AAO7D,MAAMJ,aAAaK,IAAAA,mBAAM,EAC9BC,iBAAU,EACVC,IAAAA,mBAAM,EAAC;IACLC,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACC,IAAI;IAC3BC,UAAUC,IAAAA,kBAAK,EAACd;IAChBe,MAAMC,IAAAA,mBAAM;AACd;AAgCK,MAAMd,OAAOe,IAAAA,sBAAa,EAACN,eAAQ,CAACC,IAAI,EAAEX,YAAY;IAC3D;IACA;CACD"}
|
|
@@ -34,6 +34,9 @@ const _panel = require("./panel");
|
|
|
34
34
|
_export_star(require("./spinner"), exports);
|
|
35
35
|
_export_star(require("./text"), exports);
|
|
36
36
|
_export_star(require("./row"), exports);
|
|
37
|
+
_export_star(require("./button"), exports);
|
|
38
|
+
_export_star(require("./input"), exports);
|
|
39
|
+
_export_star(require("./form"), exports);
|
|
37
40
|
function _export_star(from, to) {
|
|
38
41
|
Object.keys(from).forEach(function(k) {
|
|
39
42
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -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":";;;;;;;;;;;IAKSA,KAAK;eAALA,YAAK;;IAAEC,WAAW;eAAXA,kBAAW;;IAElBC,eAAe;eAAfA,sBAAe;;IAAEC,KAAK;eAALA,YAAK;;IAAEC,WAAW;eAAXA,kBAAW;;;qBAP9B;qBACA;qBACA;qBACA;uBAEqB;uBAEiB;qBACtC;qBACA;qBACA"}
|
|
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":";;;;;;;;;;;IAKSA,KAAK;eAALA,YAAK;;IAAEC,WAAW;eAAXA,kBAAW;;IAElBC,eAAe;eAAfA,sBAAe;;IAAEC,KAAK;eAALA,YAAK;;IAAEC,WAAW;eAAXA,kBAAW;;;qBAP9B;qBACA;qBACA;qBACA;uBAEqB;uBAEiB;qBACtC;qBACA;qBACA;qBACA;qBACA;qBACA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
InputType: function() {
|
|
13
|
+
return InputType;
|
|
14
|
+
},
|
|
15
|
+
InputStruct: function() {
|
|
16
|
+
return InputStruct;
|
|
17
|
+
},
|
|
18
|
+
input: function() {
|
|
19
|
+
return input;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const _superstruct = require("superstruct");
|
|
23
|
+
const _internals = require("../../internals");
|
|
24
|
+
const _builder = require("../builder");
|
|
25
|
+
const _nodes = require("../nodes");
|
|
26
|
+
var InputType;
|
|
27
|
+
(function(InputType) {
|
|
28
|
+
InputType[/* eslint-disable @typescript-eslint/no-shadow */ "Text"] = 'text';
|
|
29
|
+
InputType["Number"] = 'number';
|
|
30
|
+
InputType[/* eslint-enable @typescript-eslint/no-shadow */ "Password"] = 'password';
|
|
31
|
+
})(InputType || (InputType = {}));
|
|
32
|
+
const InputStruct = (0, _superstruct.assign)(_nodes.LiteralStruct, (0, _superstruct.object)({
|
|
33
|
+
type: (0, _superstruct.literal)(_nodes.NodeType.Input),
|
|
34
|
+
value: (0, _superstruct.optional)((0, _superstruct.string)()),
|
|
35
|
+
name: (0, _superstruct.string)(),
|
|
36
|
+
inputType: (0, _superstruct.optional)((0, _superstruct.union)([
|
|
37
|
+
(0, _internals.enumValue)(InputType.Text),
|
|
38
|
+
(0, _internals.enumValue)(InputType.Password),
|
|
39
|
+
(0, _internals.enumValue)(InputType.Number)
|
|
40
|
+
])),
|
|
41
|
+
placeholder: (0, _superstruct.optional)((0, _superstruct.string)()),
|
|
42
|
+
label: (0, _superstruct.optional)((0, _superstruct.string)())
|
|
43
|
+
}));
|
|
44
|
+
const input = (0, _builder.createBuilder)(_nodes.NodeType.Input, InputStruct, [
|
|
45
|
+
'name',
|
|
46
|
+
'inputType',
|
|
47
|
+
'placeholder',
|
|
48
|
+
'value',
|
|
49
|
+
'label'
|
|
50
|
+
]);
|
|
51
|
+
|
|
52
|
+
//# 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":["InputStruct","input","InputType","Text","Number","Password","assign","LiteralStruct","object","type","literal","NodeType","Input","value","optional","string","name","inputType","union","enumValue","placeholder","label","createBuilder"],"mappings":";;;;;;;;;;;;;;IAmBaA,WAAW;eAAXA;;IA+CAC,KAAK;eAALA;;;6BAjEoD;2BAEvC;yBACI;uBACU;IAMjC;UAAKC,SAAS;IAATA,UACV,+CAA+C,GAC/CC,UAAO;IAFGD,UAGVE,YAAS;IAHCF,UAIV,8CAA8C,GAC9CG,cAAW;GALDH,cAAAA;AAQL,MAAMF,cAAcM,IAAAA,mBAAM,EAC/BC,oBAAa,EACbC,IAAAA,mBAAM,EAAC;IACLC,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACC,KAAK;IAC5BC,OAAOC,IAAAA,qBAAQ,EAACC,IAAAA,mBAAM;IACtBC,MAAMD,IAAAA,mBAAM;IACZE,WAAWH,IAAAA,qBAAQ,EACjBI,IAAAA,kBAAK,EAAC;QACJC,IAAAA,oBAAS,EAACjB,UAAUC,IAAI;QACxBgB,IAAAA,oBAAS,EAACjB,UAAUG,QAAQ;QAC5Bc,IAAAA,oBAAS,EAACjB,UAAUE,MAAM;KAC3B;IAEHgB,aAAaN,IAAAA,qBAAQ,EAACC,IAAAA,mBAAM;IAC5BM,OAAOP,IAAAA,qBAAQ,EAACC,IAAAA,mBAAM;AACxB;AAgCK,MAAMd,QAAQqB,IAAAA,sBAAa,EAACX,eAAQ,CAACC,KAAK,EAAEZ,aAAa;IAC9D;IACA;IACA;IACA;IACA;CACD"}
|
|
@@ -26,10 +26,13 @@ const _superstruct = require("superstruct");
|
|
|
26
26
|
const _builder = require("../builder");
|
|
27
27
|
const _nodes = require("../nodes");
|
|
28
28
|
const _address = require("./address");
|
|
29
|
+
const _button = require("./button");
|
|
29
30
|
const _copyable = require("./copyable");
|
|
30
31
|
const _divider = require("./divider");
|
|
32
|
+
const _form = require("./form");
|
|
31
33
|
const _heading = require("./heading");
|
|
32
34
|
const _image = require("./image");
|
|
35
|
+
const _input = require("./input");
|
|
33
36
|
const _row = require("./row");
|
|
34
37
|
const _spinner = require("./spinner");
|
|
35
38
|
const _text = require("./text");
|
|
@@ -53,7 +56,10 @@ const ComponentStruct = (0, _superstruct.union)([
|
|
|
53
56
|
_spinner.SpinnerStruct,
|
|
54
57
|
_text.TextStruct,
|
|
55
58
|
_row.RowStruct,
|
|
56
|
-
_address.AddressStruct
|
|
59
|
+
_address.AddressStruct,
|
|
60
|
+
_input.InputStruct,
|
|
61
|
+
_form.FormStruct,
|
|
62
|
+
_button.ButtonStruct
|
|
57
63
|
]);
|
|
58
64
|
|
|
59
65
|
//# 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":["ParentStruct","PanelStruct","panel","ComponentStruct","assign","NodeStruct","object","children","array","lazy","type","literal","NodeType","Panel","createBuilder","union","CopyableStruct","DividerStruct","HeadingStruct","ImageStruct","SpinnerStruct","TextStruct","RowStruct","AddressStruct"],"mappings":";;;;;;;;;;;
|
|
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":["ParentStruct","PanelStruct","panel","ComponentStruct","assign","NodeStruct","object","children","array","lazy","type","literal","NodeType","Panel","createBuilder","union","CopyableStruct","DividerStruct","HeadingStruct","ImageStruct","SpinnerStruct","TextStruct","RowStruct","AddressStruct","InputStruct","FormStruct","ButtonStruct"],"mappings":";;;;;;;;;;;IAoBaA,YAAY;eAAZA;;IAsBAC,WAAW;eAAXA;;IAyCAC,KAAK;eAALA;;IAGAC,eAAe;eAAfA;;;6BArF+C;yBAE9B;uBACO;yBACP;wBACD;0BACE;yBACD;sBACH;yBACG;uBACF;uBACA;qBACF;yBACI;sBACH;AAKpB,MAAMH,eAAeI,IAAAA,mBAAM,EAChCC,iBAAU,EACVC,IAAAA,mBAAM,EAAC;IACL,sEAAsE;IACtE,mEAAmE;IACnEC,UAAUC,IAAAA,kBAAK,EAACC,IAAAA,iBAAI,EAAC,IAAMN;AAC7B;AAgBK,MAAMF,cAA6BG,IAAAA,mBAAM,EAC9CJ,cACAM,IAAAA,mBAAM,EAAC;IACLI,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACC,KAAK;AAC9B;AAqCK,MAAMX,QAAQY,IAAAA,sBAAa,EAACF,eAAQ,CAACC,KAAK,EAAEZ,aAAa;IAAC;CAAW;AAGrE,MAAME,kBAAkBY,IAAAA,kBAAK,EAAC;IACnCC,wBAAc;IACdC,sBAAa;IACbC,sBAAa;IACbC,kBAAW;IACXlB;IACAmB,sBAAa;IACbC,gBAAU;IACVC,cAAS;IACTC,sBAAa;IACbC,kBAAW;IACXC,gBAAU;IACVC,oBAAY;CACb"}
|
package/dist/cjs/ui/nodes.js
CHANGED
|
@@ -32,6 +32,9 @@ var NodeType;
|
|
|
32
32
|
NodeType["Image"] = 'image';
|
|
33
33
|
NodeType["Row"] = 'row';
|
|
34
34
|
NodeType["Address"] = 'address';
|
|
35
|
+
NodeType["Button"] = 'button';
|
|
36
|
+
NodeType["Input"] = 'input';
|
|
37
|
+
NodeType["Form"] = 'form';
|
|
35
38
|
})(NodeType || (NodeType = {}));
|
|
36
39
|
const NodeStruct = (0, _superstruct.object)({
|
|
37
40
|
type: (0, _superstruct.string)()
|
package/dist/cjs/ui/nodes.js.map
CHANGED
|
@@ -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":["NodeStruct","LiteralStruct","NodeType","Copyable","Divider","Heading","Panel","Spinner","Text","Image","Row","Address","object","type","string","assign","value","unknown"],"mappings":";;;;;;;;;;;;;;
|
|
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":["NodeStruct","LiteralStruct","NodeType","Copyable","Divider","Heading","Panel","Spinner","Text","Image","Row","Address","Button","Input","Form","object","type","string","assign","value","unknown"],"mappings":";;;;;;;;;;;;;;IA2BaA,UAAU;eAAVA;;IAgBAC,aAAa;eAAbA;;;6BA1CmC;IAOzC;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;AAmBL,MAAMF,aAAae,IAAAA,mBAAM,EAAC;IAC/BC,MAAMC,IAAAA,mBAAM;AACd;AAcO,MAAMhB,gBAAgBiB,IAAAA,mBAAM,EACjClB,YACAe,IAAAA,mBAAM,EAAC;IACLI,OAAOC,IAAAA,oBAAO;AAChB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/types/handlers/home-page.ts"],"sourcesContent":["import type { Component } from '../../ui';\n\n/**\n * The `onHomePage` handler. This is called when the user navigates to the\n * Snap's home page in the MetaMask UI.\n *\n * This function does not receive any arguments.\n *\n * @returns The content to display on the home page. See\n * {@link OnHomePageResponse}.\n */\nexport type OnHomePageHandler = () => Promise<OnHomePageResponse>;\n\n/**\n * The content to display on the home page.\n *\n * @property content - A custom UI component, that will be shown in MetaMask.\n */\nexport type OnHomePageResponse
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/handlers/home-page.ts"],"sourcesContent":["import type { Component } from '../../ui';\n\n/**\n * The `onHomePage` handler. This is called when the user navigates to the\n * Snap's home page in the MetaMask UI.\n *\n * This function does not receive any arguments.\n *\n * @returns The content to display on the home page. See\n * {@link OnHomePageResponse}.\n */\nexport type OnHomePageHandler = () => Promise<OnHomePageResponse>;\n\n/**\n * The content to display on the home page.\n *\n * @property content - A custom UI component, that will be shown in MetaMask.\n * @property id - A custom UI interface ID, that will be shown in MetaMask.\n */\nexport type OnHomePageResponse =\n | {\n content: Component;\n }\n | { id: string };\n"],"names":[],"mappings":"AAAA,WAuBmB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/types/handlers/index.ts"],"sourcesContent":["export * from './cronjob';\nexport * from './home-page';\nexport * from './keyring';\nexport * from './lifecycle';\nexport * from './name-lookup';\nexport * from './rpc-request';\nexport * from './transaction';\nexport * from './signature';\n"],"names":[],"mappings":"AAAA,cAAc,YAAY;AAC1B,cAAc,cAAc;AAC5B,cAAc,YAAY;AAC1B,cAAc,cAAc;AAC5B,cAAc,gBAAgB;AAC9B,cAAc,gBAAgB;AAC9B,cAAc,gBAAgB;AAC9B,cAAc,cAAc"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/handlers/index.ts"],"sourcesContent":["export * from './cronjob';\nexport * from './home-page';\nexport * from './keyring';\nexport * from './lifecycle';\nexport * from './name-lookup';\nexport * from './rpc-request';\nexport * from './transaction';\nexport * from './signature';\nexport * from './user-input';\n"],"names":[],"mappings":"AAAA,cAAc,YAAY;AAC1B,cAAc,cAAc;AAC5B,cAAc,YAAY;AAC1B,cAAc,cAAc;AAC5B,cAAc,gBAAgB;AAC9B,cAAc,gBAAgB;AAC9B,cAAc,gBAAgB;AAC9B,cAAc,cAAc;AAC5B,cAAc,eAAe"}
|
|
@@ -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
|
|
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"}
|
|
@@ -1 +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 severity - The severity level of the content. Currently only one\n * level is supported: `critical`.\n */\nexport type OnSignatureResponse
|
|
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"}
|