@metamask/snaps-sdk
Version:
A library containing the core functionality for building MetaMask Snaps
30 lines • 1.22 kB
JavaScript
import { assign, boolean, object, optional, string } from "@metamask/superstruct";
import { literal } from "../../internals/index.mjs";
import { createBuilder } from "../builder.mjs";
import { LiteralStruct, NodeType } from "../nodes.mjs";
export const CopyableStruct = assign(LiteralStruct, object({
type: literal(NodeType.Copyable),
value: string(),
sensitive: optional(boolean()),
}));
/**
* Create a {@link Copyable} component.
*
* @param args - The node arguments. This can either be a string, or an object
* with the `text` property.
* @param args.value - The text to be copied.
* @param args.sensitive - Whether the value is sensitive or not. Sensitive
* values are only displayed to the user after clicking on the component.
* Defaults to false.
* @returns A {@link Copyable} component.
* @deprecated Snaps component functions are deprecated, in favor of the new JSX
* components. This function will be removed in a future release.
* @example
* const node = copyable('Hello, world!');
* const node = copyable({ value: 'Hello, world!' });
*/
export const copyable = createBuilder(NodeType.Copyable, CopyableStruct, [
'value',
'sensitive',
]);
//# sourceMappingURL=copyable.mjs.map