{"version":3,"file":"response.mjs","sourceRoot":"","sources":["../../src/api/response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,gCAAgC;AAEhE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,8BAA8B;AAC/D,OAAO,EAAE,UAAU,EAAE,wBAAwB;AAE7C,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC;IACzC,MAAM,CAAC;QACL;;;;;;WAMG;QACH,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC;QAEtB;;;;;;WAMG;QACH,QAAQ,EAAE,aAAa,CACrB,MAAM,CAAC;YACL,OAAO,EAAE,aAAa,CAAC,MAAM,EAAE,CAAC;YAChC,GAAG,EAAE,aAAa,CAAC,MAAM,EAAE,CAAC;SAC7B,CAAC,CACH;KACF,CAAC;IACF,MAAM,CAAC;QACL;;;;;;WAMG;QACH,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC;QAEvB;;WAEG;QACH,MAAM,EAAE,UAAU;KACnB,CAAC;CACH,CAAC,CAAC","sourcesContent":["import { exactOptional, object } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { literal, string, union } from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\nexport const KeyringResponseStruct = union([\n  object({\n    /**\n     * Pending flag.\n     *\n     * Setting the pending flag to true indicates that the request will be\n     * handled asynchronously. The keyring must be called with `approveRequest`\n     * or `rejectRequest` to resolve the request.\n     */\n    pending: literal(true),\n\n    /**\n     * Redirect URL.\n     *\n     * If present in the response, MetaMask will display a confirmation dialog\n     * with a link to the redirect URL. The user can choose to follow the link\n     * or cancel the request.\n     */\n    redirect: exactOptional(\n      object({\n        message: exactOptional(string()),\n        url: exactOptional(string()),\n      }),\n    ),\n  }),\n  object({\n    /**\n     * Pending flag.\n     *\n     * Setting the pending flag to false indicates that the request will be\n     * handled synchronously. The keyring must return the result of the\n     * request execution.\n     */\n    pending: literal(false),\n\n    /**\n     * Request result.\n     */\n    result: JsonStruct,\n  }),\n]);\n\n/**\n * Response to a call to `submitRequest`.\n *\n * Keyring implementations must return a response with `pending: true` if the\n * request will be handled asynchronously. Otherwise, the response must contain\n * the result of the request and `pending: false`.\n *\n * In the asynchronous case, the keyring can return a redirect URL and message\n * to be shown to the user. The user can choose to follow the link or cancel\n * the request. The main use case for this is to redirect the user to the snap\n * dapp to review the request.\n */\nexport type KeyringResponse = Infer<typeof KeyringResponseStruct>;\n"]}