@tezos-x/octez.connect-dapp 5.0.2 → 5.0.4

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.
@@ -89,11 +89,15 @@ export interface DAppClientOptions {
89
89
  /**
90
90
  * Configuration that is passed to the WalletConnect transport.
91
91
  *
92
- * This is required to enable WalletConnect connections.
92
+ * OPTIONAL: WalletConnect is enabled by default using a shared ecosystem
93
+ * projectId, so dApps don't need to register with WalletConnect Cloud.
94
+ * Provide this to use your own projectId and/or relay server instead. To
95
+ * turn WalletConnect off entirely, set `disableWalletConnect`.
93
96
  */
94
97
  walletConnectOptions?: RequireAtLeastOne<{
95
98
  /**
96
- * The projectId of the application. Has to be obtained from https://cloud.walletconnect.com/
99
+ * Your own projectId, obtained from https://cloud.walletconnect.com/ —
100
+ * omit it to use the shared ecosystem default.
97
101
  */
98
102
  projectId?: string;
99
103
  /**
@@ -104,13 +108,11 @@ export interface DAppClientOptions {
104
108
  /**
105
109
  * Explicitly disable the WalletConnect transport.
106
110
  *
107
- * WalletConnect is opt-in (it is only built when `walletConnectOptions` is
108
- * provided). This additive flag lets a DApp that does provide
109
- * `walletConnectOptions` still turn the transport off without removing that
110
- * configuration. When `true`, no WalletConnect transport is constructed or
111
- * listened to. Absence preserves current behavior. Use it for environments
112
- * where the WalletConnect provider cannot run (e.g. a Firefox MV3
113
- * content-script compartment).
111
+ * WalletConnect is ON by default (with the shared ecosystem projectId, or
112
+ * the one from `walletConnectOptions`). When `true`, no WalletConnect
113
+ * transport is constructed or listened to, regardless of
114
+ * `walletConnectOptions`. Use it for environments where the WalletConnect
115
+ * provider cannot run (e.g. a Firefox MV3 content-script compartment).
114
116
  */
115
117
  disableWalletConnect?: boolean;
116
118
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"DAppClientOptions.js","sourceRoot":"","sources":["../../../src/dapp-client/DAppClientOptions.ts"],"names":[],"mappings":"","sourcesContent":["import { BeaconEvent, BeaconEventType, BeaconEventHandlerFunction } from '../events'\nimport { BlockExplorer } from '../utils/block-explorer'\nimport {\n Storage,\n NetworkType,\n ColorMode,\n NodeDistributions,\n AnalyticsInterface,\n Network\n} from '@tezos-x/octez.connect-types'\n\ntype RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> &\n {\n [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>\n }[Keys]\n\n/**\n * @category DApp\n */\nexport interface DAppClientOptions {\n /**\n * Name of the application\n */\n name: string\n\n /**\n * Description of the application\n */\n description?: string\n\n /**\n * A URL to the icon of the application\n */\n iconUrl?: string\n\n /**\n * A URL to the website of the application\n */\n appUrl?: string\n\n /**\n * The storage that will be used by the SDK\n */\n storage?: Storage\n\n /**\n * An object that will be used to overwrite default event handler behaviour.\n *\n * If you plan to overwrite all default events, use \"disableDefaultEvents\" instead.\n *\n * This will overwrite the default event handler, so this can lead to unexpected behavior in some cases.\n * We recommend that you overwrite all handlers if you want to use your own UI.\n *\n * If you simply want to be notified of events happening, but do not want to overwrite the default behavior,\n * please use `subscribeToEvent()` on the DAppClient instead.\n */\n eventHandlers?: {\n [key in BeaconEvent]?: {\n handler: BeaconEventHandlerFunction<BeaconEventType[key]>\n }\n }\n\n /**\n * Disable all default Events and UI elements. If passed together with \"eventHandlers\",\n * the default eventHandlers will be removed, and the ones passed by the user will be added.\n */\n disableDefaultEvents?: boolean\n\n /**\n * A list of matrix nodes to connect to. If a non-empty array is passed, the default options will be overwritten.\n * One node will be randomly selected based on the local keypair and the other nodes will be used as a fallback in case the primary node goes down.\n *\n * Only provide the hostname, no https:// prefix. Eg. { [Regions.EU1]: ['matrix.example.com'] }\n */\n matrixNodes?: NodeDistributions\n\n /**\n * The block explorer used by the SDK\n */\n blockExplorer?: BlockExplorer\n\n /**\n * Indicates on which network the DApp is running on.\n */\n network?: Network\n\n /**\n * @deprecated Please use \"network\" instead.\n * Indicates on which network the DApp is planning to run. This is currently used to adjust the URLs of web-wallets in the pairing alert if they use different URLs for testnets.\n * You will still have to define the network you intend to use during the permission request.\n */\n preferredNetwork?: NetworkType\n\n /**\n * Set the color mode for the UI elements (alerts and toasts)\n */\n colorMode?: ColorMode\n\n /**\n * A URL to the Terms & Conditions page that will be displayed in the pairing modal\n */\n termsAndConditionsUrl?: string\n\n /**\n * A URL to the Privacy Policy page that will be displayed in the pairing modal\n */\n privacyPolicyUrl?: string\n\n /**\n * A list of contracts that the DApp is using. Allows to attach human readable error messages for to error codes\n */\n errorMessages?: Record<string, Record<string | number, string>>\n\n /**\n * Configuration that is passed to the WalletConnect transport.\n *\n * This is required to enable WalletConnect connections.\n */\n walletConnectOptions?: RequireAtLeastOne<{\n /**\n * The projectId of the application. Has to be obtained from https://cloud.walletconnect.com/\n */\n projectId?: string\n\n /**\n * The relay server to connect to\n */\n relayUrl?: string\n }>\n\n /**\n * Explicitly disable the WalletConnect transport.\n *\n * WalletConnect is opt-in (it is only built when `walletConnectOptions` is\n * provided). This additive flag lets a DApp that does provide\n * `walletConnectOptions` still turn the transport off without removing that\n * configuration. When `true`, no WalletConnect transport is constructed or\n * listened to. Absence preserves current behavior. Use it for environments\n * where the WalletConnect provider cannot run (e.g. a Firefox MV3\n * content-script compartment).\n */\n disableWalletConnect?: boolean\n\n /**\n * The analytics instance that will be used by the SDK\n */\n analytics?: AnalyticsInterface\n\n /**\n * The wallets that will be featured in the UI.\n */\n featuredWallets?: string[]\n\n /**\n * Automatically switch between apps on Mobile Devices (Enabled by Default)\n */\n enableAppSwitching?: boolean\n\n /**\n * Enable metrics tracking (Disabled by Default)\n */\n enableMetrics?: boolean\n\n /**\n * Minimum wallet version the dApp will accept. The gate is opt-in: it\n * defaults to the lowest supported protocol version, so every wallet the\n * SDK can talk to is accepted and upgrading the SDK never rejects existing\n * v2/v3 wallets. Set `'4'` to require the v4 multi-network protocol. Must\n * be a decimal-integer string in `[1, BEACON_VERSION]`; otherwise\n * `InvalidRequiredMinimumVersionError` is thrown at construction. A wallet\n * below this minimum is rejected with `VersionUnsupportedBeaconError` when\n * a request is sent.\n *\n * The version compared against this minimum is the wallet's EFFECTIVE\n * version, not the raw `peer.version`: legacy wallets echo the dApp's own\n * version at pairing, so a declared version is only trusted when the\n * pairing response carried the v5 `protocolVersion` capability marker —\n * marker-less wallets that declared a version count as `'2'` (and are\n * therefore rejected by a minimum of `'3'` or `'4'`, even though their\n * echoed `peer.version` may read higher). A wallet that reports no version\n * at all (WalletConnect pairings) is still treated as unknown and allowed,\n * so those pairings keep working.\n */\n requiredMinimumVersion?: string\n}\n"]}
1
+ {"version":3,"file":"DAppClientOptions.js","sourceRoot":"","sources":["../../../src/dapp-client/DAppClientOptions.ts"],"names":[],"mappings":"","sourcesContent":["import { BeaconEvent, BeaconEventType, BeaconEventHandlerFunction } from '../events'\nimport { BlockExplorer } from '../utils/block-explorer'\nimport {\n Storage,\n NetworkType,\n ColorMode,\n NodeDistributions,\n AnalyticsInterface,\n Network\n} from '@tezos-x/octez.connect-types'\n\ntype RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> &\n {\n [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>\n }[Keys]\n\n/**\n * @category DApp\n */\nexport interface DAppClientOptions {\n /**\n * Name of the application\n */\n name: string\n\n /**\n * Description of the application\n */\n description?: string\n\n /**\n * A URL to the icon of the application\n */\n iconUrl?: string\n\n /**\n * A URL to the website of the application\n */\n appUrl?: string\n\n /**\n * The storage that will be used by the SDK\n */\n storage?: Storage\n\n /**\n * An object that will be used to overwrite default event handler behaviour.\n *\n * If you plan to overwrite all default events, use \"disableDefaultEvents\" instead.\n *\n * This will overwrite the default event handler, so this can lead to unexpected behavior in some cases.\n * We recommend that you overwrite all handlers if you want to use your own UI.\n *\n * If you simply want to be notified of events happening, but do not want to overwrite the default behavior,\n * please use `subscribeToEvent()` on the DAppClient instead.\n */\n eventHandlers?: {\n [key in BeaconEvent]?: {\n handler: BeaconEventHandlerFunction<BeaconEventType[key]>\n }\n }\n\n /**\n * Disable all default Events and UI elements. If passed together with \"eventHandlers\",\n * the default eventHandlers will be removed, and the ones passed by the user will be added.\n */\n disableDefaultEvents?: boolean\n\n /**\n * A list of matrix nodes to connect to. If a non-empty array is passed, the default options will be overwritten.\n * One node will be randomly selected based on the local keypair and the other nodes will be used as a fallback in case the primary node goes down.\n *\n * Only provide the hostname, no https:// prefix. Eg. { [Regions.EU1]: ['matrix.example.com'] }\n */\n matrixNodes?: NodeDistributions\n\n /**\n * The block explorer used by the SDK\n */\n blockExplorer?: BlockExplorer\n\n /**\n * Indicates on which network the DApp is running on.\n */\n network?: Network\n\n /**\n * @deprecated Please use \"network\" instead.\n * Indicates on which network the DApp is planning to run. This is currently used to adjust the URLs of web-wallets in the pairing alert if they use different URLs for testnets.\n * You will still have to define the network you intend to use during the permission request.\n */\n preferredNetwork?: NetworkType\n\n /**\n * Set the color mode for the UI elements (alerts and toasts)\n */\n colorMode?: ColorMode\n\n /**\n * A URL to the Terms & Conditions page that will be displayed in the pairing modal\n */\n termsAndConditionsUrl?: string\n\n /**\n * A URL to the Privacy Policy page that will be displayed in the pairing modal\n */\n privacyPolicyUrl?: string\n\n /**\n * A list of contracts that the DApp is using. Allows to attach human readable error messages for to error codes\n */\n errorMessages?: Record<string, Record<string | number, string>>\n\n /**\n * Configuration that is passed to the WalletConnect transport.\n *\n * OPTIONAL: WalletConnect is enabled by default using a shared ecosystem\n * projectId, so dApps don't need to register with WalletConnect Cloud.\n * Provide this to use your own projectId and/or relay server instead. To\n * turn WalletConnect off entirely, set `disableWalletConnect`.\n */\n walletConnectOptions?: RequireAtLeastOne<{\n /**\n * Your own projectId, obtained from https://cloud.walletconnect.com/ —\n * omit it to use the shared ecosystem default.\n */\n projectId?: string\n\n /**\n * The relay server to connect to\n */\n relayUrl?: string\n }>\n\n /**\n * Explicitly disable the WalletConnect transport.\n *\n * WalletConnect is ON by default (with the shared ecosystem projectId, or\n * the one from `walletConnectOptions`). When `true`, no WalletConnect\n * transport is constructed or listened to, regardless of\n * `walletConnectOptions`. Use it for environments where the WalletConnect\n * provider cannot run (e.g. a Firefox MV3 content-script compartment).\n */\n disableWalletConnect?: boolean\n\n /**\n * The analytics instance that will be used by the SDK\n */\n analytics?: AnalyticsInterface\n\n /**\n * The wallets that will be featured in the UI.\n */\n featuredWallets?: string[]\n\n /**\n * Automatically switch between apps on Mobile Devices (Enabled by Default)\n */\n enableAppSwitching?: boolean\n\n /**\n * Enable metrics tracking (Disabled by Default)\n */\n enableMetrics?: boolean\n\n /**\n * Minimum wallet version the dApp will accept. The gate is opt-in: it\n * defaults to the lowest supported protocol version, so every wallet the\n * SDK can talk to is accepted and upgrading the SDK never rejects existing\n * v2/v3 wallets. Set `'4'` to require the v4 multi-network protocol. Must\n * be a decimal-integer string in `[1, BEACON_VERSION]`; otherwise\n * `InvalidRequiredMinimumVersionError` is thrown at construction. A wallet\n * below this minimum is rejected with `VersionUnsupportedBeaconError` when\n * a request is sent.\n *\n * The version compared against this minimum is the wallet's EFFECTIVE\n * version, not the raw `peer.version`: legacy wallets echo the dApp's own\n * version at pairing, so a declared version is only trusted when the\n * pairing response carried the v5 `protocolVersion` capability marker —\n * marker-less wallets that declared a version count as `'2'` (and are\n * therefore rejected by a minimum of `'3'` or `'4'`, even though their\n * echoed `peer.version` may read higher). A wallet that reports no version\n * at all (WalletConnect pairings) is still treated as unknown and allowed,\n * so those pairings keep working.\n */\n requiredMinimumVersion?: string\n}\n"]}
@@ -269,7 +269,7 @@ const showRateLimitReached = async () => {
269
269
  });
270
270
  };
271
271
  /**
272
- * Show a "connection successful" alert for 1.5 seconds
272
+ * Close the pairing alert once the extension connection is established
273
273
  */
274
274
  const showExtensionConnectedAlert = () => {
275
275
  closeAlert();
@@ -287,7 +287,8 @@ const showRelayerErrorAlert = async (errorContext) => {
287
287
  });
288
288
  };
289
289
  /**
290
- * Show a "channel closed" alert for 1.5 seconds
290
+ * No-op: the "channel closed" alert is intentionally disabled
291
+ * (body kept below for reference)
291
292
  */
292
293
  const showChannelClosedAlert = async () => {
293
294
  // openAlert({
@@ -1 +1 @@
1
- {"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,aAAa,EAGb,UAAU,EACV,SAAS,EAEV,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACL,eAAe,EAmBhB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EACL,kBAAkB,EAElB,MAAM,EACN,QAAQ;AACR,gCAAgC;AAChC,sBAAsB;EACvB,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAEhE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAEtD,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,qBAAqB,CAAC,CAAA;AAEhD,MAAM,aAAa,GAAW,CAAC,GAAG,IAAI,CAAA;AAYtC;;GAEG;AACH,MAAM,CAAN,IAAY,WAgDX;AAhDD,WAAY,WAAW;IACrB,kEAAmD,CAAA;IACnD,wEAAyD,CAAA;IACzD,oEAAqD,CAAA;IACrD,8FAA+E,CAAA;IAC/E,oGAAqF,CAAA;IACrF,gGAAiF,CAAA;IACjF,kHAAmG,CAAA;IACnG,wHAAyG,CAAA;IACzG,oHAAqG,CAAA;IACrG,gEAAiD,CAAA;IACjD,sEAAuD,CAAA;IACvD,kEAAmD,CAAA;IACnD,sDAAuC,CAAA;IACvC,4DAA6C,CAAA;IAC7C,wDAAyC,CAAA;IACzC,wEAAyD,CAAA;IACzD,mBAAmB;IACnB,iDAAiD;IACjD,uDAAuD;IACvD,mDAAmD;IACnD,gEAAiD,CAAA;IACjD,sEAAuD,CAAA;IACvD,kEAAmD,CAAA;IACnD,4DAA6C,CAAA;IAE7C,oEAAqD,CAAA;IAErD,gDAAiC,CAAA;IAEjC,wDAAyC,CAAA;IAE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AG,IAAI,CAAC,CAAA;gBACnC,CAAC,CAAC,CAAA;YACJ,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;CACF","sourcesContent":["import {\n closeAlert,\n openAlert,\n openBugReport,\n AlertButton,\n AlertConfig,\n closeToast,\n openToast,\n ToastAction\n} from '@tezos-x/octez.connect-ui'\nimport {\n BeaconErrorType,\n ExtendedPostMessagePairingResponse,\n ExtendedP2PPairingResponse,\n AccountInfo,\n ErrorResponse,\n PermissionResponseOutput,\n OperationResponseOutput,\n BroadcastResponseOutput,\n SignPayloadResponseOutput,\n Network,\n ConnectionContext,\n NetworkType,\n AcknowledgeResponse,\n WalletInfo,\n ExtendedWalletConnectPairingResponse,\n AnalyticsInterface,\n ProofOfEventChallengeResponseOutput,\n SimulatedProofOfEventChallengeResponseOutput,\n ErrorContext\n} from '@tezos-x/octez.connect-types'\nimport {\n UnknownBeaconError,\n Transport,\n Logger,\n getError\n // EncryptPayloadResponseOutput,\n // EncryptionOperation\n} from '@tezos-x/octez.connect-core'\nimport { isMobile, isMobileOS } from '@tezos-x/octez.connect-ui'\nimport { BlockExplorer } from './utils/block-explorer'\nimport { shortenString } from './utils/shorten-string'\n\nconst logger = new Logger('octez.connectEvents')\n\nconst SUCCESS_TIMER: number = 5 * 1000\n\ntype RPCError = {\n kind: string\n id: string\n contract_handle?: string\n location?: number\n with?: {\n string?: string\n int?: number\n }\n}\n/**\n * The different events that can be emitted by the octez.connect-sdk\n */\nexport enum BeaconEvent {\n PERMISSION_REQUEST_SENT = 'PERMISSION_REQUEST_SENT',\n PERMISSION_REQUEST_SUCCESS = 'PERMISSION_REQUEST_SUCCESS',\n PERMISSION_REQUEST_ERROR = 'PERMISSION_REQUEST_ERROR',\n PROOF_OF_EVENT_CHALLENGE_REQUEST_SENT = 'PROOF_OF_EVENT_CHALLENGE_REQUEST_SENT',\n PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS = 'PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS',\n PROOF_OF_EVENT_CHALLENGE_REQUEST_ERROR = 'PROOF_OF_EVENT_CHALLENGE_REQUEST_ERROR',\n SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SENT = 'SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SENT',\n SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS = 'SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS',\n SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_ERROR = 'SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_ERROR',\n OPERATION_REQUEST_SENT = 'OPERATION_REQUEST_SENT',\n OPERATION_REQUEST_SUCCESS = 'OPERATION_REQUEST_SUCCESS',\n OPERATION_REQUEST_ERROR = 'OPERATION_REQUEST_ERROR',\n SIGN_REQUEST_SENT = 'SIGN_REQUEST_SENT',\n SIGN_REQUEST_SUCCESS = 'SIGN_REQUEST_SUCCESS',\n SIGN_REQUEST_ERROR = 'SIGN_REQUEST_ERROR',\n BLOCKCHAIN_REQUEST_SUCCESS = 'BLOCKCHAIN_REQUEST_SUCCESS',\n // TODO: ENCRYPTION\n // ENCRYPT_REQUEST_SENT = 'ENCRYPT_REQUEST_SENT',\n // ENCRYPT_REQUEST_SUCCESS = 'ENCRYPT_REQUEST_SUCCESS',\n // ENCRYPT_REQUEST_ERROR = 'ENCRYPT_REQUEST_ERROR',\n BROADCAST_REQUEST_SENT = 'BROADCAST_REQUEST_SENT',\n BROADCAST_REQUEST_SUCCESS = 'BROADCAST_REQUEST_SUCCESS',\n BROADCAST_REQUEST_ERROR = 'BROADCAST_REQUEST_ERROR',\n ACKNOWLEDGE_RECEIVED = 'ACKNOWLEDGE_RECEIVED',\n\n LOCAL_RATE_LIMIT_REACHED = 'LOCAL_RATE_LIMIT_REACHED',\n\n NO_PERMISSIONS = 'NO_PERMISSIONS',\n\n ACTIVE_ACCOUNT_SET = 'ACTIVE_ACCOUNT_SET',\n\n ACTIVE_TRANSPORT_SET = 'ACTIVE_TRANSPORT_SET',\n\n SHOW_PREPARE = 'SHOW_PREPARE',\n HIDE_UI = 'HIDE_UI',\n INVALID_ACTIVE_ACCOUNT_STATE = 'INVALID_ACTIVE_ACCOUNT_STATE',\n INVALID_ACCOUNT_DEACTIVATED = 'INVALID_ACCOUNT_DEACTIVATED',\n PAIR_INIT = 'PAIR_INIT',\n PAIR_SUCCESS = 'PAIR_SUCCESS',\n PAIR_ABORTED = 'PAIR_ABORTED',\n CHANNEL_CLOSED = 'CHANNEL_CLOSED',\n GENERIC_ERROR = 'GENERIC_ERROR',\n OPEN_BUG_REPORT = 'OPEN_BUG_REPORT',\n RELAYER_ERROR = 'RELAYER_ERROR',\n\n INTERNAL_ERROR = 'INTERNAL_ERROR',\n UNKNOWN = 'UNKNOWN'\n}\n\nexport interface ExtraInfo {\n resetCallback?(): Promise<void>\n}\n\ninterface RequestSentInfo {\n extraInfo: ExtraInfo\n walletInfo: WalletInfo\n}\n\n/**\n * The type of the payload of the different BeaconEvents\n */\nexport interface BeaconEventType {\n [BeaconEvent.PERMISSION_REQUEST_SENT]: RequestSentInfo\n [BeaconEvent.PERMISSION_REQUEST_SUCCESS]: {\n account: AccountInfo\n output: PermissionResponseOutput\n blockExplorer: BlockExplorer\n connectionContext: ConnectionContext\n walletInfo: WalletInfo\n }\n [BeaconEvent.PERMISSION_REQUEST_ERROR]: {\n errorResponse: ErrorResponse\n walletInfo: WalletInfo\n errorContext?: ErrorContext\n }\n [BeaconEvent.PROOF_OF_EVENT_CHALLENGE_REQUEST_SENT]: RequestSentInfo\n [BeaconEvent.PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS]: {\n account: AccountInfo\n output: ProofOfEventChallengeResponseOutput\n blockExplorer: BlockExplorer\n connectionContext: ConnectionContext\n walletInfo: WalletInfo\n }\n [BeaconEvent.PROOF_OF_EVENT_CHALLENGE_REQUEST_ERROR]: {\n errorResponse: ErrorResponse\n walletInfo: WalletInfo\n }\n [BeaconEvent.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SENT]: RequestSentInfo\n [BeaconEvent.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS]: {\n account: AccountInfo\n output: SimulatedProofOfEventChallengeResponseOutput\n blockExplorer: BlockExplorer\n connectionContext: ConnectionContext\n walletInfo: WalletInfo\n }\n [BeaconEvent.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_ERROR]: {\n errorResponse: ErrorResponse\n walletInfo: WalletInfo\n }\n [BeaconEvent.OPERATION_REQUEST_SENT]: RequestSentInfo\n [BeaconEvent.OPERATION_REQUEST_SUCCESS]: {\n account: AccountInfo\n output: OperationResponseOutput\n blockExplorer: BlockExplorer\n connectionContext: ConnectionContext\n walletInfo: WalletInfo\n }\n [BeaconEvent.OPERATION_REQUEST_ERROR]: {\n errorResponse: ErrorResponse\n walletInfo: WalletInfo\n errorMessages: Record<string, Record<string | number, string>>\n }\n [BeaconEvent.SIGN_REQUEST_SENT]: RequestSentInfo\n [BeaconEvent.SIGN_REQUEST_SUCCESS]: {\n output: SignPayloadResponseOutput\n connectionContext: ConnectionContext\n walletInfo: WalletInfo\n }\n [BeaconEvent.SIGN_REQUEST_ERROR]: { errorResponse: ErrorResponse; walletInfo: WalletInfo }\n // TODO: ENCRYPTION\n // [BeaconEvent.ENCRYPT_REQUEST_SENT]: RequestSentInfo\n // [BeaconEvent.ENCRYPT_REQUEST_SUCCESS]: {\n // output: EncryptPayloadResponseOutput\n // connectionContext: ConnectionContext\n // walletInfo: WalletInfo\n // }\n // [BeaconEvent.ENCRYPT_REQUEST_ERROR]: { errorResponse: ErrorResponse; walletInfo: WalletInfo }\n [BeaconEvent.BLOCKCHAIN_REQUEST_SUCCESS]: RequestSentInfo\n [BeaconEvent.BROADCAST_REQUEST_SENT]: RequestSentInfo\n [BeaconEvent.BROADCAST_REQUEST_SUCCESS]: {\n network: Network\n output: BroadcastResponseOutput\n blockExplorer: BlockExplorer\n connectionContext: ConnectionContext\n walletInfo: WalletInfo\n }\n [BeaconEvent.BROADCAST_REQUEST_ERROR]: { errorResponse: ErrorResponse; walletInfo: WalletInfo }\n [BeaconEvent.ACKNOWLEDGE_RECEIVED]: {\n message: AcknowledgeResponse\n extraInfo: ExtraInfo\n walletInfo: WalletInfo\n }\n [BeaconEvent.LOCAL_RATE_LIMIT_REACHED]: undefined\n [BeaconEvent.NO_PERMISSIONS]: undefined\n [BeaconEvent.ACTIVE_ACCOUNT_SET]: AccountInfo\n [BeaconEvent.ACTIVE_TRANSPORT_SET]: Transport\n [BeaconEvent.INVALID_ACTIVE_ACCOUNT_STATE]: undefined\n [BeaconEvent.GENERIC_ERROR]: { message: string; errorContext?: ErrorContext }\n [BeaconEvent.INVALID_ACCOUNT_DEACTIVATED]: undefined\n [BeaconEvent.SHOW_PREPARE]: { walletInfo?: WalletInfo }\n [BeaconEvent.HIDE_UI]: ('alert' | 'toast')[] | undefined\n [BeaconEvent.PAIR_INIT]: {\n p2pPeerInfo: Promise<string>\n postmessagePeerInfo: Promise<string>\n walletConnectPeerInfo: Promise<string>\n networkType: NetworkType\n abortedHandler?(): void\n analytics: AnalyticsInterface\n featuredWallets?: string[]\n termsAndConditionsUrl?: string\n privacyPolicyUrl?: string\n substratePairing?: boolean\n }\n [BeaconEvent.PAIR_SUCCESS]:\n | ExtendedPostMessagePairingResponse\n | ExtendedP2PPairingResponse\n | ExtendedWalletConnectPairingResponse\n [BeaconEvent.PAIR_ABORTED]: undefined\n [BeaconEvent.CHANNEL_CLOSED]: string\n [BeaconEvent.INTERNAL_ERROR]: { text: string; buttons?: AlertButton[]; errorContext?: ErrorContext }\n [BeaconEvent.OPEN_BUG_REPORT]: undefined\n [BeaconEvent.RELAYER_ERROR]: ErrorContext\n [BeaconEvent.UNKNOWN]: undefined\n}\n\n/**\n * Show a \"Request sent\" toast\n */\nconst showSentToast = async (data: RequestSentInfo): Promise<void> => {\n let openWalletAction\n const actions: ToastAction[] = []\n if (data.walletInfo.deeplink) {\n if (\n data.walletInfo.type === 'web' ||\n (data.walletInfo.type === 'mobile' && isMobile(window)) ||\n (data.walletInfo.type === 'desktop' && !isMobile(window))\n ) {\n const link = data.walletInfo.deeplink\n openWalletAction = async (): Promise<void> => {\n const a = document.createElement('a')\n a.setAttribute('rel', 'noopener')\n a.setAttribute('href', link)\n a.setAttribute('target', '_blank')\n a.dispatchEvent(new MouseEvent('click', { view: window, bubbles: true, cancelable: true }))\n }\n }\n }\n actions.push({\n text: `No answer from your wallet received yet. Please make sure the wallet is open.`,\n isBold: true\n })\n actions.push({\n text: 'Wallet not receiving request?',\n actionText: 'Reset Connection',\n actionCallback: async (): Promise<void> => {\n closeToast()\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const resetCallback = data.extraInfo.resetCallback\n if (resetCallback) {\n logger.log('showSentToast', 'resetCallback invoked')\n await resetCallback()\n }\n }\n })\n actions.push({\n text: 'Do you wish to report a bug?',\n actionText: 'Open',\n actionCallback: async (): Promise<void> => {\n closeToast()\n openBugReport()\n }\n })\n\n openToast({\n body: `Request sent to\\u00A0 {{wallet}}`,\n walletInfo: data.walletInfo,\n state: 'loading',\n timer: isMobileOS(window) ? SUCCESS_TIMER : 0,\n actions,\n openWalletAction\n })\n}\n\nconst showAcknowledgedToast = async (data: {\n message: AcknowledgeResponse\n extraInfo: ExtraInfo\n walletInfo: WalletInfo\n}): Promise<void> => {\n openToast({\n body: 'Awaiting confirmation in\\u00A0 {{wallet}}',\n state: 'acknowledge',\n walletInfo: data.walletInfo\n })\n}\n\nconst showPrepare = async (data: { walletInfo?: WalletInfo }): Promise<void> => {\n const text = data.walletInfo\n ? `Preparing Request for\\u00A0 {{wallet}}...`\n : 'Preparing Request...'\n openToast({\n body: text,\n state: 'prepare',\n walletInfo: data.walletInfo\n })\n}\n\nconst hideUI = (elements?: ('alert' | 'toast')[]) => {\n if (elements?.includes('alert')) {\n closeAlert()\n }\n\n if (elements?.includes('toast') || !elements) {\n closeToast()\n }\n}\n\n/**\n * Show a \"No Permission\" alert\n */\nconst showNoPermissionAlert = async (): Promise<void> => {\n openAlert({\n title: 'No Permission',\n body: 'Please allow the wallet to handle this type of request.'\n })\n}\n\n/**\n * Show an \"Invalid state\" alert\n */\nconst showInvalidActiveAccountState = async (): Promise<void> => {\n openAlert({\n title: 'Invalid state',\n body: `An active account has been received, but no active subscription was found for BeaconEvent.ACTIVE_ACCOUNT_SET.\n For more information, visit: https://octez-connect.tezos.com/guides/migration-guide`\n })\n}\n\n/**\n * Show an \"account deactivated\" error alert\n */\nconst showInvalidAccountDeactivated = async (): Promise<void> => {\n await openAlert({\n title: 'Error',\n body: `Your session has expired. Please pair with your wallet again.`\n })\n}\n\n/**\n * Show an \"Invalid state\" alert\n */\nconst showGenericErrorAlert = async (data: { message: string; errorContext?: ErrorContext }): Promise<void> => {\n openAlert({\n title: `${data.message}`,\n body: 'Please try again. If this problem persists please send us a bug report.',\n errorContext: data.errorContext,\n buttons: [\n {\n label: 'Send Report',\n type: 'primary',\n onClick: () => openBugReport()\n }\n ] as any\n })\n}\n\n/**\n * Show an error toast\n *\n * @param beaconError The beacon error\n */\nconst showErrorToast = async (\n response: {\n errorResponse: ErrorResponse\n walletInfo: WalletInfo\n errorContext?: ErrorContext\n errorMessages?: Record<string, Record<string | number, string>>\n },\n buttons?: AlertButton[]\n): Promise<void> => {\n const error = response.errorResponse.errorType\n ? getError(response.errorResponse.errorType, response.errorResponse.errorData)\n : new UnknownBeaconError()\n\n const actions: ToastAction[] = [\n {\n text: error.title,\n isBold: true\n }\n ]\n\n if (\n response.errorResponse.errorType === BeaconErrorType.TRANSACTION_INVALID_ERROR &&\n response.errorResponse.errorData\n ) {\n const err: RPCError[] = response.errorResponse.errorData\n const errorMessages = response.errorMessages\n\n let hasHumandReadableError = false\n\n if (err[0]?.contract_handle && errorMessages && errorMessages?.[err[0].contract_handle]) {\n const errCode = err[1]?.with?.int ?? err[1]?.with?.string\n const contractErrors = errorMessages?.[err[0].contract_handle]\n if (errCode && contractErrors?.[errCode]) {\n actions.push({\n text: contractErrors?.[errCode],\n isBold: true\n })\n hasHumandReadableError = true\n }\n }\n\n if (!hasHumandReadableError) {\n actions.push({\n text: error.description\n })\n }\n\n actions.push({\n text: '',\n actionText: 'Show Details',\n actionCallback: async (): Promise<void> => {\n closeToast()\n openAlert({\n title: error.title,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n body: error.fullDescription.description,\n data: error.fullDescription.data,\n errorContext: response.errorContext,\n buttons\n })\n }\n })\n } else {\n // For non-transaction errors, add \"Show Details\" action\n actions.push({\n text: '',\n actionText: 'Show Details',\n actionCallback: async (): Promise<void> => {\n closeToast()\n openAlert({\n title: error.title,\n body: error.description,\n errorContext: response.errorContext,\n buttons\n })\n }\n })\n }\n\n openToast({\n body: `{{wallet}}\\u00A0 has returned an error`,\n timer:\n response.errorResponse.errorType === BeaconErrorType.ABORTED_ERROR\n ? SUCCESS_TIMER\n : undefined,\n state: 'finished',\n walletInfo: response.walletInfo,\n actions\n })\n}\n\n/**\n * Show a rate limit reached toast\n */\nconst showRateLimitReached = async (): Promise<void> => {\n openAlert({\n title: 'Error',\n body: 'Rate limit reached. Please slow down',\n buttons: [{ text: 'Done', style: 'outline' }],\n timer: 3000\n })\n}\n\n/**\n * Show a \"connection successful\" alert for 1.5 seconds\n */\nconst showExtensionConnectedAlert = () => {\n closeAlert()\n}\n\nconst showBugReportForm = async () => {\n await openBugReport()\n}\n\nconst showRelayerErrorAlert = async (errorContext: ErrorContext): Promise<void> => {\n openAlert({\n title: 'Error',\n body: `Failed to connect to the relayer. Please check that your system time is synchronized with the current time and reload the page.`,\n errorContext,\n buttons: [{ text: 'Done', style: 'outline' }],\n timer: 1500\n })\n}\n\n/**\n * Show a \"channel closed\" alert for 1.5 seconds\n */\nconst showChannelClosedAlert = async (): Promise<void> => {\n // openAlert({\n // title: 'Channel closed',\n // body: `Your peer has closed the connection.`,\n // buttons: [{ text: 'Done', style: 'outline' }],\n // timer: 1500\n // })\n}\n\nconst showInternalErrorAlert = async (\n data: BeaconEventType[BeaconEvent.INTERNAL_ERROR]\n): Promise<void> => {\n const buttons: AlertButton[] = [...(data.buttons ?? [])]\n\n buttons.push({ text: 'Done', style: 'outline' })\n\n const alertConfig: AlertConfig = {\n title: 'Internal Error',\n body: data.text,\n errorContext: data.errorContext,\n buttons\n }\n openAlert(alertConfig)\n}\n\n/**\n * Show a connect alert with QR code\n *\n * @param data The data that is emitted by the PAIR_INIT event\n */\nconst showPairAlert = async (data: BeaconEventType[BeaconEvent.PAIR_INIT]): Promise<void> => {\n logger.log('showPairAlert')\n const alertConfig: AlertConfig = {\n title: 'Choose your preferred wallet',\n body: `<p></p>`,\n pairingPayload: {\n p2pSyncCode: data.p2pPeerInfo,\n walletConnectSyncCode: data.walletConnectPeerInfo,\n postmessageSyncCode: data.postmessagePeerInfo,\n networkType: data.networkType\n },\n // eslint-disable-next-line @typescript-eslint/unbound-method\n closeButtonCallback: data.abortedHandler,\n analytics: data.analytics,\n featuredWallets: data.featuredWallets,\n termsAndConditionsUrl: data.termsAndConditionsUrl,\n privacyPolicyUrl: data.privacyPolicyUrl,\n substratePairing: data.substratePairing\n }\n openAlert(alertConfig)\n}\n\n/**\n * Show a \"Permission Granted\" alert\n *\n * @param data The data that is emitted by the PERMISSION_REQUEST_SUCCESS event\n */\nconst showPermissionSuccessAlert = async (\n data: BeaconEventType[BeaconEvent.PERMISSION_REQUEST_SUCCESS]\n): Promise<void> => {\n const { output } = data\n\n const actions: any[] = [\n {\n text: 'Address',\n actionText: shortenString(output.address),\n isBold: true\n }\n ]\n\n if ((output.network.type as any) !== 'substrate') {\n actions.push({\n text: 'Network',\n actionText: `${output.network.type}`\n })\n actions.push({\n text: 'Permissions',\n actionText: output.scopes.join(', ')\n })\n }\n\n openToast({\n body: `{{wallet}}\\u00A0 has granted permission`,\n timer: SUCCESS_TIMER,\n walletInfo: data.walletInfo,\n state: 'finished',\n actions\n })\n}\n\nconst showProofOfEventChallengeSuccessAlert = async (\n data: BeaconEventType[BeaconEvent.PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS]\n): Promise<void> => {\n const { output } = data\n\n openToast({\n body: `{{wallet}}\\u00A0 has ${output.isAccepted ? 'accepted' : 'refused'} the challenge`,\n timer: SUCCESS_TIMER,\n walletInfo: data.walletInfo,\n state: 'finished',\n actions: output.isAccepted\n ? [\n {\n text: `Payload hash: ${output.payloadHash}`,\n actionText: 'Copy to clipboard',\n actionCallback: async (): Promise<void> => {\n navigator.clipboard.writeText(output.payloadHash).then(\n () => {\n logger.log('showSignSuccessAlert', 'Copying to clipboard was successful!')\n },\n (err) => {\n logger.error('showSignSuccessAlert', 'Could not copy text to clipboard: ', err)\n }\n )\n closeToast()\n }\n }\n ]\n : []\n })\n}\n\nconst showSimulatedProofOfEventChallengeSuccessAlert = async (\n data: BeaconEventType[BeaconEvent.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS]\n): Promise<void> => {\n const { output } = data\n\n openToast({\n body: !output.errorMessage\n ? `{{wallet}}\\u00A0 has returned the list of operation`\n : `{{wallet}}\\u00A0 has returned an error`,\n timer: SUCCESS_TIMER,\n walletInfo: data.walletInfo,\n state: 'finished',\n actions: !output.errorMessage\n ? [\n {\n text: 'Operation list',\n actionText: 'Copy to clipboard',\n actionCallback: async (): Promise<void> => {\n navigator.clipboard.writeText(output.operationsList).then(\n () => {\n logger.log('showSignSuccessAlert', 'Copying to clipboard was successful!')\n },\n (err) => {\n logger.error('showSignSuccessAlert', 'Could not copy text to clipboard: ', err)\n }\n )\n closeToast()\n }\n }\n ]\n : [{ text: 'Error message', actionText: output.errorMessage }]\n })\n}\n\n/**\n * Show an \"Operation Broadcasted\" alert\n *\n * @param data The data that is emitted by the OPERATION_REQUEST_SUCCESS event\n */\nconst showOperationSuccessAlert = async (\n data: BeaconEventType[BeaconEvent.OPERATION_REQUEST_SUCCESS]\n): Promise<void> => {\n const { account, output, blockExplorer } = data\n\n openToast({\n body: `{{wallet}}\\u00A0 successfully submitted operation`,\n timer: SUCCESS_TIMER,\n state: 'finished',\n walletInfo: data.walletInfo,\n actions: [\n {\n text: shortenString(output.transactionHash),\n isBold: true,\n actionText: `Open Blockexplorer`,\n actionLogo: 'external',\n actionCallback: async (): Promise<void> => {\n const link: string = await blockExplorer.getTransactionLink(\n output.transactionHash,\n account.network\n )\n window.open(link, '_blank', 'noopener')\n closeToast()\n }\n }\n ]\n })\n}\n\n/**\n * Show a \"Transaction Signed\" alert\n *\n * @param data The data that is emitted by the SIGN_REQUEST_SUCCESS event\n */\nconst showSignSuccessAlert = async (\n data: BeaconEventType[BeaconEvent.SIGN_REQUEST_SUCCESS]\n): Promise<void> => {\n const output = data.output\n openToast({\n body: `{{wallet}}\\u00A0 successfully signed payload`,\n timer: SUCCESS_TIMER,\n state: 'finished',\n walletInfo: data.walletInfo,\n actions: [\n {\n text: `Signature: ${shortenString(output.signature)}`,\n actionText: 'Copy to clipboard',\n actionCallback: async (): Promise<void> => {\n navigator.clipboard.writeText(output.signature).then(\n () => {\n logger.log('showSignSuccessAlert', 'Copying to clipboard was successful!')\n },\n (err) => {\n logger.error('showSignSuccessAlert', 'Could not copy text to clipboard: ', err)\n }\n )\n closeToast()\n }\n }\n ]\n })\n}\n\n/**\n * Show a \"Transaction Signed\" alert\n *\n * @param data The data that is emitted by the ENCRYPT_REQUEST_SUCCESS event\n */\n// TODO: ENCRYPTION\n// const showEncryptSuccessAlert = async (\n// data: BeaconEventType[BeaconEvent.ENCRYPT_REQUEST_SUCCESS]\n// ): Promise<void> => {\n// const output = data.output\n// openToast({\n// body: `{{wallet}}\\u00A0 successfully ${\n// data.output.cryptoOperation === EncryptionOperation.ENCRYPT ? 'encrypted' : 'decrypted'\n// } payload`,\n// timer: SUCCESS_TIMER,\n// state: 'finished',\n// walletInfo: data.walletInfo,\n// actions: [\n// {\n// text: `Payload: <strong>${shortenString(output.payload)}</strong>`,\n// actionText: 'Copy to clipboard',\n// actionCallback: async (): Promise<void> => {\n// navigator.clipboard.writeText(output.payload).then(\n// () => {\n// logger.log('showSignSuccessAlert', 'Copying to clipboard was successful!')\n// },\n// (err) => {\n// logger.error('showSignSuccessAlert', 'Could not copy text to clipboard: ', err)\n// }\n// )\n// closeToast()\n// }\n// }\n// ]\n// })\n// }\n\nconst showBlockchainRequestSuccessToast = async (\n data: BeaconEventType[BeaconEvent.BLOCKCHAIN_REQUEST_SUCCESS]\n): Promise<void> => {\n openToast({\n body: `{{wallet}}\\u00A0 request successfully executed`,\n timer: SUCCESS_TIMER,\n state: 'finished',\n walletInfo: data.walletInfo\n })\n}\n\n/**\n * Show a \"Broadcasted\" alert\n *\n * @param data The data that is emitted by the BROADCAST_REQUEST_SUCCESS event\n */\nconst showBroadcastSuccessAlert = async (\n data: BeaconEventType[BeaconEvent.BROADCAST_REQUEST_SUCCESS]\n): Promise<void> => {\n const { network, output, blockExplorer } = data\n\n openToast({\n body: `{{wallet}}\\u00A0 successfully injected operation`,\n timer: SUCCESS_TIMER,\n state: 'finished',\n walletInfo: data.walletInfo,\n actions: [\n {\n text: shortenString(output.transactionHash),\n isBold: true,\n actionText: `Open Blockexplorer`,\n actionLogo: 'external',\n actionCallback: async (): Promise<void> => {\n const link: string = await blockExplorer.getTransactionLink(\n output.transactionHash,\n network\n )\n window.open(link, '_blank', 'noopener')\n closeToast()\n }\n }\n ]\n })\n}\n\nconst emptyHandler = (): BeaconEventHandlerFunction => async (): Promise<void> => {\n //\n}\n\nexport type BeaconEventHandlerFunction<T = unknown> = (\n data: T,\n eventCallback?: AlertButton[]\n) => void | Promise<void>\n\n/**\n * The default event handlers\n */\nexport const defaultEventCallbacks: {\n [key in BeaconEvent]: BeaconEventHandlerFunction<BeaconEventType[key]>\n} = {\n [BeaconEvent.PERMISSION_REQUEST_SENT]: showSentToast,\n [BeaconEvent.PERMISSION_REQUEST_SUCCESS]: showPermissionSuccessAlert,\n [BeaconEvent.PERMISSION_REQUEST_ERROR]: showErrorToast,\n [BeaconEvent.PROOF_OF_EVENT_CHALLENGE_REQUEST_SENT]: showSentToast,\n [BeaconEvent.PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS]: showProofOfEventChallengeSuccessAlert,\n [BeaconEvent.PROOF_OF_EVENT_CHALLENGE_REQUEST_ERROR]: showErrorToast,\n [BeaconEvent.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SENT]: showSentToast,\n [BeaconEvent.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS]:\n showSimulatedProofOfEventChallengeSuccessAlert,\n [BeaconEvent.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_ERROR]: showErrorToast,\n [BeaconEvent.OPERATION_REQUEST_SENT]: showSentToast,\n [BeaconEvent.OPERATION_REQUEST_SUCCESS]: showOperationSuccessAlert,\n [BeaconEvent.OPERATION_REQUEST_ERROR]: showErrorToast,\n [BeaconEvent.SIGN_REQUEST_SENT]: showSentToast,\n [BeaconEvent.SIGN_REQUEST_SUCCESS]: showSignSuccessAlert,\n [BeaconEvent.SIGN_REQUEST_ERROR]: showErrorToast,\n // TODO: ENCRYPTION\n // [BeaconEvent.ENCRYPT_REQUEST_SENT]: showSentToast,\n // [BeaconEvent.ENCRYPT_REQUEST_SUCCESS]: showEncryptSuccessAlert,\n // [BeaconEvent.ENCRYPT_REQUEST_ERROR]: showErrorToast,\n [BeaconEvent.BROADCAST_REQUEST_SENT]: showSentToast,\n [BeaconEvent.BROADCAST_REQUEST_SUCCESS]: showBroadcastSuccessAlert,\n [BeaconEvent.BROADCAST_REQUEST_ERROR]: showErrorToast,\n [BeaconEvent.ACKNOWLEDGE_RECEIVED]: showAcknowledgedToast,\n [BeaconEvent.LOCAL_RATE_LIMIT_REACHED]: showRateLimitReached,\n [BeaconEvent.NO_PERMISSIONS]: showNoPermissionAlert,\n [BeaconEvent.ACTIVE_ACCOUNT_SET]: emptyHandler(),\n [BeaconEvent.ACTIVE_TRANSPORT_SET]: emptyHandler(),\n [BeaconEvent.INVALID_ACTIVE_ACCOUNT_STATE]: showInvalidActiveAccountState,\n [BeaconEvent.GENERIC_ERROR]: showGenericErrorAlert,\n [BeaconEvent.INVALID_ACCOUNT_DEACTIVATED]: showInvalidAccountDeactivated,\n [BeaconEvent.SHOW_PREPARE]: showPrepare,\n [BeaconEvent.HIDE_UI]: hideUI,\n [BeaconEvent.PAIR_INIT]: showPairAlert,\n [BeaconEvent.PAIR_SUCCESS]: showExtensionConnectedAlert,\n [BeaconEvent.PAIR_ABORTED]: emptyHandler(),\n [BeaconEvent.OPEN_BUG_REPORT]: showBugReportForm,\n [BeaconEvent.RELAYER_ERROR]: showRelayerErrorAlert,\n [BeaconEvent.CHANNEL_CLOSED]: showChannelClosedAlert,\n [BeaconEvent.INTERNAL_ERROR]: showInternalErrorAlert,\n [BeaconEvent.BLOCKCHAIN_REQUEST_SUCCESS]: showBlockchainRequestSuccessToast,\n [BeaconEvent.UNKNOWN]: emptyHandler()\n}\n\n/**\n * @internalapi\n *\n * Handles beacon events\n */\nexport class BeaconEventHandler {\n private readonly callbackMap: {\n [key in BeaconEvent]: BeaconEventHandlerFunction<any>[] // TODO: Fix type\n } = {\n [BeaconEvent.PERMISSION_REQUEST_SENT]: [defaultEventCallbacks.PERMISSION_REQUEST_SENT],\n [BeaconEvent.PERMISSION_REQUEST_SUCCESS]: [defaultEventCallbacks.PERMISSION_REQUEST_SUCCESS],\n [BeaconEvent.PERMISSION_REQUEST_ERROR]: [defaultEventCallbacks.PERMISSION_REQUEST_ERROR],\n [BeaconEvent.PROOF_OF_EVENT_CHALLENGE_REQUEST_SENT]: [\n defaultEventCallbacks.PERMISSION_REQUEST_SENT\n ],\n [BeaconEvent.PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS]: [\n defaultEventCallbacks.PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS\n ],\n [BeaconEvent.PROOF_OF_EVENT_CHALLENGE_REQUEST_ERROR]: [\n defaultEventCallbacks.PROOF_OF_EVENT_CHALLENGE_REQUEST_ERROR\n ],\n [BeaconEvent.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SENT]: [\n defaultEventCallbacks.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SENT\n ],\n [BeaconEvent.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS]: [\n defaultEventCallbacks.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS\n ],\n [BeaconEvent.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_ERROR]: [\n defaultEventCallbacks.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_ERROR\n ],\n [BeaconEvent.OPERATION_REQUEST_SENT]: [defaultEventCallbacks.OPERATION_REQUEST_SENT],\n [BeaconEvent.OPERATION_REQUEST_SUCCESS]: [defaultEventCallbacks.OPERATION_REQUEST_SUCCESS],\n [BeaconEvent.OPERATION_REQUEST_ERROR]: [defaultEventCallbacks.OPERATION_REQUEST_ERROR],\n [BeaconEvent.SIGN_REQUEST_SENT]: [defaultEventCallbacks.SIGN_REQUEST_SENT],\n [BeaconEvent.SIGN_REQUEST_SUCCESS]: [defaultEventCallbacks.SIGN_REQUEST_SUCCESS],\n [BeaconEvent.SIGN_REQUEST_ERROR]: [defaultEventCallbacks.SIGN_REQUEST_ERROR],\n // TODO: ENCRYPTION\n // [BeaconEvent.ENCRYPT_REQUEST_SENT]: [defaultEventCallbacks.ENCRYPT_REQUEST_SENT],\n // [BeaconEvent.ENCRYPT_REQUEST_SUCCESS]: [defaultEventCallbacks.ENCRYPT_REQUEST_SUCCESS],\n // [BeaconEvent.ENCRYPT_REQUEST_ERROR]: [defaultEventCallbacks.ENCRYPT_REQUEST_ERROR],\n [BeaconEvent.BROADCAST_REQUEST_SENT]: [defaultEventCallbacks.BROADCAST_REQUEST_SENT],\n [BeaconEvent.BROADCAST_REQUEST_SUCCESS]: [defaultEventCallbacks.BROADCAST_REQUEST_SUCCESS],\n [BeaconEvent.BROADCAST_REQUEST_ERROR]: [defaultEventCallbacks.BROADCAST_REQUEST_ERROR],\n [BeaconEvent.BLOCKCHAIN_REQUEST_SUCCESS]: [defaultEventCallbacks.BLOCKCHAIN_REQUEST_SUCCESS],\n [BeaconEvent.ACKNOWLEDGE_RECEIVED]: [defaultEventCallbacks.ACKNOWLEDGE_RECEIVED],\n [BeaconEvent.LOCAL_RATE_LIMIT_REACHED]: [defaultEventCallbacks.LOCAL_RATE_LIMIT_REACHED],\n [BeaconEvent.NO_PERMISSIONS]: [defaultEventCallbacks.NO_PERMISSIONS],\n [BeaconEvent.ACTIVE_ACCOUNT_SET]: [defaultEventCallbacks.ACTIVE_ACCOUNT_SET],\n [BeaconEvent.ACTIVE_TRANSPORT_SET]: [defaultEventCallbacks.ACTIVE_TRANSPORT_SET],\n [BeaconEvent.INVALID_ACTIVE_ACCOUNT_STATE]: [\n defaultEventCallbacks.INVALID_ACTIVE_ACCOUNT_STATE\n ],\n [BeaconEvent.GENERIC_ERROR]: [showGenericErrorAlert],\n [BeaconEvent.INVALID_ACCOUNT_DEACTIVATED]: [defaultEventCallbacks.INVALID_ACCOUNT_DEACTIVATED],\n [BeaconEvent.SHOW_PREPARE]: [defaultEventCallbacks.SHOW_PREPARE],\n [BeaconEvent.HIDE_UI]: [defaultEventCallbacks.HIDE_UI],\n [BeaconEvent.PAIR_INIT]: [defaultEventCallbacks.PAIR_INIT],\n [BeaconEvent.PAIR_SUCCESS]: [defaultEventCallbacks.PAIR_SUCCESS],\n [BeaconEvent.PAIR_ABORTED]: [defaultEventCallbacks.PAIR_ABORTED],\n [BeaconEvent.OPEN_BUG_REPORT]: [showBugReportForm],\n [BeaconEvent.CHANNEL_CLOSED]: [defaultEventCallbacks.CHANNEL_CLOSED],\n [BeaconEvent.INTERNAL_ERROR]: [defaultEventCallbacks.INTERNAL_ERROR],\n [BeaconEvent.RELAYER_ERROR]: [defaultEventCallbacks.RELAYER_ERROR],\n [BeaconEvent.UNKNOWN]: [defaultEventCallbacks.UNKNOWN]\n }\n constructor(\n eventsToOverride: {\n [key in BeaconEvent]?: {\n handler: BeaconEventHandlerFunction<BeaconEventType[key]>\n }\n } = {},\n overrideAll?: boolean\n ) {\n if (overrideAll) {\n this.setAllHandlers()\n }\n this.overrideDefaults(eventsToOverride)\n }\n\n /**\n * A method to subscribe to a specific beacon event and register a callback\n *\n * @param event The event being emitted\n * @param eventCallback The callback that will be invoked\n */\n public async on<K extends BeaconEvent>(\n event: K,\n eventCallback: BeaconEventHandlerFunction<BeaconEventType[K]>\n ): Promise<void> {\n const listeners = this.callbackMap[event] || []\n listeners.push(eventCallback)\n this.callbackMap[event] = listeners\n }\n\n /**\n * Emit a beacon event\n *\n * @param event The event being emitted\n * @param data The data to be emit\n */\n public async emit<K extends BeaconEvent>(\n event: K,\n data?: BeaconEventType[K],\n eventCallback?: AlertButton[]\n ): Promise<void> {\n const listeners = this.callbackMap[event]\n if (listeners && listeners.length > 0) {\n listeners.forEach(async (listener: BeaconEventHandlerFunction) => {\n try {\n await listener(data, eventCallback)\n } catch (listenerError) {\n logger.error(`error handling event ${event}`, listenerError)\n }\n })\n }\n }\n\n /**\n * Override beacon event default callbacks. This can be used to disable default alert/toast behaviour\n *\n * @param eventsToOverride An object with the events to override\n */\n private overrideDefaults(eventsToOverride: {\n [key in BeaconEvent]?: {\n handler: BeaconEventHandlerFunction<BeaconEventType[key]>\n }\n }): void {\n Object.keys(eventsToOverride).forEach((untypedEvent: string) => {\n const eventType: BeaconEvent = untypedEvent as BeaconEvent\n const event = eventsToOverride[eventType]\n if (event) {\n this.callbackMap[eventType] = [event.handler]\n }\n })\n }\n\n /**\n * Set all event callbacks to a specific handler.\n */\n private setAllHandlers(handler?: BeaconEventHandlerFunction): void {\n Object.keys(this.callbackMap).forEach((untypedEvent: string) => {\n const eventType: BeaconEvent = untypedEvent as BeaconEvent\n this.callbackMap[eventType] = []\n if (handler) {\n this.callbackMap[eventType].push(handler)\n } else {\n this.callbackMap[eventType].push((...data) => {\n logger.log(untypedEvent, ...data)\n })\n }\n })\n }\n}\n"]}
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,aAAa,EAGb,UAAU,EACV,SAAS,EAEV,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACL,eAAe,EAmBhB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EACL,kBAAkB,EAElB,MAAM,EACN,QAAQ;AACR,gCAAgC;AAChC,sBAAsB;EACvB,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAEhE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAEtD,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,qBAAqB,CAAC,CAAA;AAEhD,MAAM,aAAa,GAAW,CAAC,GAAG,IAAI,CAAA;AAYtC;;GAEG;AACH,MAAM,CAAN,IAAY,WAgDX;AAhDD,WAAY,WAAW;IACrB,kEAAmD,CAAA;IACnD,wEAAyD,CAAA;IACzD,oEAAqD,CAAA;IACrD,8FAA+E,CAAA;IAC/E,oGAAqF,CAAA;IACrF,gGAAiF,CAAA;IACjF,kHAAmG,CAAA;IACnG,wHAAyG,CAAA;IACzG,oHAAqG,CAAA;IACrG,gEAAiD,CAAA;IACjD,sEAAuD,CAAA;IACvD,kEAAmD,CAAA;IACnD,sDAAuC,CAAA;IACvC,4DAA6C,CAAA;IAC7C,wDAAyC,CAAA;IACzC,wEAAyD,CAAA;IACzD,mBAAmB;IACnB,iDAAiD;IACjD,uDAAuD;IACvD,mDAAmD;IACnD,gEAAiD,CAAA;IACjD,sEAAuD,CAAA;IACvD,kEAAmD,CAAA;IACnD,4DAA6C,CAAA;IAE7C,oEAAqD,CAAA;IAErD,gDAAiC,CAAA;IAEjC,wDAAyC,CAAA;IAEzC,4DAA6C,CA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C,CAAA;gBACnC,CAAC,CAAC,CAAA;YACJ,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;CACF","sourcesContent":["import {\n closeAlert,\n openAlert,\n openBugReport,\n AlertButton,\n AlertConfig,\n closeToast,\n openToast,\n ToastAction\n} from '@tezos-x/octez.connect-ui'\nimport {\n BeaconErrorType,\n ExtendedPostMessagePairingResponse,\n ExtendedP2PPairingResponse,\n AccountInfo,\n ErrorResponse,\n PermissionResponseOutput,\n OperationResponseOutput,\n BroadcastResponseOutput,\n SignPayloadResponseOutput,\n Network,\n ConnectionContext,\n NetworkType,\n AcknowledgeResponse,\n WalletInfo,\n ExtendedWalletConnectPairingResponse,\n AnalyticsInterface,\n ProofOfEventChallengeResponseOutput,\n SimulatedProofOfEventChallengeResponseOutput,\n ErrorContext\n} from '@tezos-x/octez.connect-types'\nimport {\n UnknownBeaconError,\n Transport,\n Logger,\n getError\n // EncryptPayloadResponseOutput,\n // EncryptionOperation\n} from '@tezos-x/octez.connect-core'\nimport { isMobile, isMobileOS } from '@tezos-x/octez.connect-ui'\nimport { BlockExplorer } from './utils/block-explorer'\nimport { shortenString } from './utils/shorten-string'\n\nconst logger = new Logger('octez.connectEvents')\n\nconst SUCCESS_TIMER: number = 5 * 1000\n\ntype RPCError = {\n kind: string\n id: string\n contract_handle?: string\n location?: number\n with?: {\n string?: string\n int?: number\n }\n}\n/**\n * The different events that can be emitted by the octez.connect-sdk\n */\nexport enum BeaconEvent {\n PERMISSION_REQUEST_SENT = 'PERMISSION_REQUEST_SENT',\n PERMISSION_REQUEST_SUCCESS = 'PERMISSION_REQUEST_SUCCESS',\n PERMISSION_REQUEST_ERROR = 'PERMISSION_REQUEST_ERROR',\n PROOF_OF_EVENT_CHALLENGE_REQUEST_SENT = 'PROOF_OF_EVENT_CHALLENGE_REQUEST_SENT',\n PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS = 'PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS',\n PROOF_OF_EVENT_CHALLENGE_REQUEST_ERROR = 'PROOF_OF_EVENT_CHALLENGE_REQUEST_ERROR',\n SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SENT = 'SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SENT',\n SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS = 'SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS',\n SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_ERROR = 'SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_ERROR',\n OPERATION_REQUEST_SENT = 'OPERATION_REQUEST_SENT',\n OPERATION_REQUEST_SUCCESS = 'OPERATION_REQUEST_SUCCESS',\n OPERATION_REQUEST_ERROR = 'OPERATION_REQUEST_ERROR',\n SIGN_REQUEST_SENT = 'SIGN_REQUEST_SENT',\n SIGN_REQUEST_SUCCESS = 'SIGN_REQUEST_SUCCESS',\n SIGN_REQUEST_ERROR = 'SIGN_REQUEST_ERROR',\n BLOCKCHAIN_REQUEST_SUCCESS = 'BLOCKCHAIN_REQUEST_SUCCESS',\n // TODO: ENCRYPTION\n // ENCRYPT_REQUEST_SENT = 'ENCRYPT_REQUEST_SENT',\n // ENCRYPT_REQUEST_SUCCESS = 'ENCRYPT_REQUEST_SUCCESS',\n // ENCRYPT_REQUEST_ERROR = 'ENCRYPT_REQUEST_ERROR',\n BROADCAST_REQUEST_SENT = 'BROADCAST_REQUEST_SENT',\n BROADCAST_REQUEST_SUCCESS = 'BROADCAST_REQUEST_SUCCESS',\n BROADCAST_REQUEST_ERROR = 'BROADCAST_REQUEST_ERROR',\n ACKNOWLEDGE_RECEIVED = 'ACKNOWLEDGE_RECEIVED',\n\n LOCAL_RATE_LIMIT_REACHED = 'LOCAL_RATE_LIMIT_REACHED',\n\n NO_PERMISSIONS = 'NO_PERMISSIONS',\n\n ACTIVE_ACCOUNT_SET = 'ACTIVE_ACCOUNT_SET',\n\n ACTIVE_TRANSPORT_SET = 'ACTIVE_TRANSPORT_SET',\n\n SHOW_PREPARE = 'SHOW_PREPARE',\n HIDE_UI = 'HIDE_UI',\n INVALID_ACTIVE_ACCOUNT_STATE = 'INVALID_ACTIVE_ACCOUNT_STATE',\n INVALID_ACCOUNT_DEACTIVATED = 'INVALID_ACCOUNT_DEACTIVATED',\n PAIR_INIT = 'PAIR_INIT',\n PAIR_SUCCESS = 'PAIR_SUCCESS',\n PAIR_ABORTED = 'PAIR_ABORTED',\n CHANNEL_CLOSED = 'CHANNEL_CLOSED',\n GENERIC_ERROR = 'GENERIC_ERROR',\n OPEN_BUG_REPORT = 'OPEN_BUG_REPORT',\n RELAYER_ERROR = 'RELAYER_ERROR',\n\n INTERNAL_ERROR = 'INTERNAL_ERROR',\n UNKNOWN = 'UNKNOWN'\n}\n\nexport interface ExtraInfo {\n resetCallback?(): Promise<void>\n}\n\ninterface RequestSentInfo {\n extraInfo: ExtraInfo\n walletInfo: WalletInfo\n}\n\n/**\n * The type of the payload of the different BeaconEvents\n */\nexport interface BeaconEventType {\n [BeaconEvent.PERMISSION_REQUEST_SENT]: RequestSentInfo\n [BeaconEvent.PERMISSION_REQUEST_SUCCESS]: {\n account: AccountInfo\n output: PermissionResponseOutput\n blockExplorer: BlockExplorer\n connectionContext: ConnectionContext\n walletInfo: WalletInfo\n }\n [BeaconEvent.PERMISSION_REQUEST_ERROR]: {\n errorResponse: ErrorResponse\n walletInfo: WalletInfo\n errorContext?: ErrorContext\n }\n [BeaconEvent.PROOF_OF_EVENT_CHALLENGE_REQUEST_SENT]: RequestSentInfo\n [BeaconEvent.PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS]: {\n account: AccountInfo\n output: ProofOfEventChallengeResponseOutput\n blockExplorer: BlockExplorer\n connectionContext: ConnectionContext\n walletInfo: WalletInfo\n }\n [BeaconEvent.PROOF_OF_EVENT_CHALLENGE_REQUEST_ERROR]: {\n errorResponse: ErrorResponse\n walletInfo: WalletInfo\n }\n [BeaconEvent.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SENT]: RequestSentInfo\n [BeaconEvent.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS]: {\n account: AccountInfo\n output: SimulatedProofOfEventChallengeResponseOutput\n blockExplorer: BlockExplorer\n connectionContext: ConnectionContext\n walletInfo: WalletInfo\n }\n [BeaconEvent.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_ERROR]: {\n errorResponse: ErrorResponse\n walletInfo: WalletInfo\n }\n [BeaconEvent.OPERATION_REQUEST_SENT]: RequestSentInfo\n [BeaconEvent.OPERATION_REQUEST_SUCCESS]: {\n account: AccountInfo\n output: OperationResponseOutput\n blockExplorer: BlockExplorer\n connectionContext: ConnectionContext\n walletInfo: WalletInfo\n }\n [BeaconEvent.OPERATION_REQUEST_ERROR]: {\n errorResponse: ErrorResponse\n walletInfo: WalletInfo\n errorMessages: Record<string, Record<string | number, string>>\n }\n [BeaconEvent.SIGN_REQUEST_SENT]: RequestSentInfo\n [BeaconEvent.SIGN_REQUEST_SUCCESS]: {\n output: SignPayloadResponseOutput\n connectionContext: ConnectionContext\n walletInfo: WalletInfo\n }\n [BeaconEvent.SIGN_REQUEST_ERROR]: { errorResponse: ErrorResponse; walletInfo: WalletInfo }\n // TODO: ENCRYPTION\n // [BeaconEvent.ENCRYPT_REQUEST_SENT]: RequestSentInfo\n // [BeaconEvent.ENCRYPT_REQUEST_SUCCESS]: {\n // output: EncryptPayloadResponseOutput\n // connectionContext: ConnectionContext\n // walletInfo: WalletInfo\n // }\n // [BeaconEvent.ENCRYPT_REQUEST_ERROR]: { errorResponse: ErrorResponse; walletInfo: WalletInfo }\n [BeaconEvent.BLOCKCHAIN_REQUEST_SUCCESS]: RequestSentInfo\n [BeaconEvent.BROADCAST_REQUEST_SENT]: RequestSentInfo\n [BeaconEvent.BROADCAST_REQUEST_SUCCESS]: {\n network: Network\n output: BroadcastResponseOutput\n blockExplorer: BlockExplorer\n connectionContext: ConnectionContext\n walletInfo: WalletInfo\n }\n [BeaconEvent.BROADCAST_REQUEST_ERROR]: { errorResponse: ErrorResponse; walletInfo: WalletInfo }\n [BeaconEvent.ACKNOWLEDGE_RECEIVED]: {\n message: AcknowledgeResponse\n extraInfo: ExtraInfo\n walletInfo: WalletInfo\n }\n [BeaconEvent.LOCAL_RATE_LIMIT_REACHED]: undefined\n [BeaconEvent.NO_PERMISSIONS]: undefined\n [BeaconEvent.ACTIVE_ACCOUNT_SET]: AccountInfo\n [BeaconEvent.ACTIVE_TRANSPORT_SET]: Transport\n [BeaconEvent.INVALID_ACTIVE_ACCOUNT_STATE]: undefined\n [BeaconEvent.GENERIC_ERROR]: { message: string; errorContext?: ErrorContext }\n [BeaconEvent.INVALID_ACCOUNT_DEACTIVATED]: undefined\n [BeaconEvent.SHOW_PREPARE]: { walletInfo?: WalletInfo }\n [BeaconEvent.HIDE_UI]: ('alert' | 'toast')[] | undefined\n [BeaconEvent.PAIR_INIT]: {\n p2pPeerInfo: Promise<string>\n postmessagePeerInfo: Promise<string>\n walletConnectPeerInfo: Promise<string>\n networkType: NetworkType\n abortedHandler?(): void\n analytics: AnalyticsInterface\n featuredWallets?: string[]\n termsAndConditionsUrl?: string\n privacyPolicyUrl?: string\n substratePairing?: boolean\n }\n [BeaconEvent.PAIR_SUCCESS]:\n | ExtendedPostMessagePairingResponse\n | ExtendedP2PPairingResponse\n | ExtendedWalletConnectPairingResponse\n [BeaconEvent.PAIR_ABORTED]: undefined\n [BeaconEvent.CHANNEL_CLOSED]: string\n [BeaconEvent.INTERNAL_ERROR]: { text: string; buttons?: AlertButton[]; errorContext?: ErrorContext }\n [BeaconEvent.OPEN_BUG_REPORT]: undefined\n [BeaconEvent.RELAYER_ERROR]: ErrorContext\n [BeaconEvent.UNKNOWN]: undefined\n}\n\n/**\n * Show a \"Request sent\" toast\n */\nconst showSentToast = async (data: RequestSentInfo): Promise<void> => {\n let openWalletAction\n const actions: ToastAction[] = []\n if (data.walletInfo.deeplink) {\n if (\n data.walletInfo.type === 'web' ||\n (data.walletInfo.type === 'mobile' && isMobile(window)) ||\n (data.walletInfo.type === 'desktop' && !isMobile(window))\n ) {\n const link = data.walletInfo.deeplink\n openWalletAction = async (): Promise<void> => {\n const a = document.createElement('a')\n a.setAttribute('rel', 'noopener')\n a.setAttribute('href', link)\n a.setAttribute('target', '_blank')\n a.dispatchEvent(new MouseEvent('click', { view: window, bubbles: true, cancelable: true }))\n }\n }\n }\n actions.push({\n text: `No answer from your wallet received yet. Please make sure the wallet is open.`,\n isBold: true\n })\n actions.push({\n text: 'Wallet not receiving request?',\n actionText: 'Reset Connection',\n actionCallback: async (): Promise<void> => {\n closeToast()\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const resetCallback = data.extraInfo.resetCallback\n if (resetCallback) {\n logger.log('showSentToast', 'resetCallback invoked')\n await resetCallback()\n }\n }\n })\n actions.push({\n text: 'Do you wish to report a bug?',\n actionText: 'Open',\n actionCallback: async (): Promise<void> => {\n closeToast()\n openBugReport()\n }\n })\n\n openToast({\n body: `Request sent to\\u00A0 {{wallet}}`,\n walletInfo: data.walletInfo,\n state: 'loading',\n timer: isMobileOS(window) ? SUCCESS_TIMER : 0,\n actions,\n openWalletAction\n })\n}\n\nconst showAcknowledgedToast = async (data: {\n message: AcknowledgeResponse\n extraInfo: ExtraInfo\n walletInfo: WalletInfo\n}): Promise<void> => {\n openToast({\n body: 'Awaiting confirmation in\\u00A0 {{wallet}}',\n state: 'acknowledge',\n walletInfo: data.walletInfo\n })\n}\n\nconst showPrepare = async (data: { walletInfo?: WalletInfo }): Promise<void> => {\n const text = data.walletInfo\n ? `Preparing Request for\\u00A0 {{wallet}}...`\n : 'Preparing Request...'\n openToast({\n body: text,\n state: 'prepare',\n walletInfo: data.walletInfo\n })\n}\n\nconst hideUI = (elements?: ('alert' | 'toast')[]) => {\n if (elements?.includes('alert')) {\n closeAlert()\n }\n\n if (elements?.includes('toast') || !elements) {\n closeToast()\n }\n}\n\n/**\n * Show a \"No Permission\" alert\n */\nconst showNoPermissionAlert = async (): Promise<void> => {\n openAlert({\n title: 'No Permission',\n body: 'Please allow the wallet to handle this type of request.'\n })\n}\n\n/**\n * Show an \"Invalid state\" alert\n */\nconst showInvalidActiveAccountState = async (): Promise<void> => {\n openAlert({\n title: 'Invalid state',\n body: `An active account has been received, but no active subscription was found for BeaconEvent.ACTIVE_ACCOUNT_SET.\n For more information, visit: https://octez-connect.tezos.com/guides/migration-guide`\n })\n}\n\n/**\n * Show an \"account deactivated\" error alert\n */\nconst showInvalidAccountDeactivated = async (): Promise<void> => {\n await openAlert({\n title: 'Error',\n body: `Your session has expired. Please pair with your wallet again.`\n })\n}\n\n/**\n * Show an \"Invalid state\" alert\n */\nconst showGenericErrorAlert = async (data: { message: string; errorContext?: ErrorContext }): Promise<void> => {\n openAlert({\n title: `${data.message}`,\n body: 'Please try again. If this problem persists please send us a bug report.',\n errorContext: data.errorContext,\n buttons: [\n {\n label: 'Send Report',\n type: 'primary',\n onClick: () => openBugReport()\n }\n ] as any\n })\n}\n\n/**\n * Show an error toast\n *\n * @param beaconError The beacon error\n */\nconst showErrorToast = async (\n response: {\n errorResponse: ErrorResponse\n walletInfo: WalletInfo\n errorContext?: ErrorContext\n errorMessages?: Record<string, Record<string | number, string>>\n },\n buttons?: AlertButton[]\n): Promise<void> => {\n const error = response.errorResponse.errorType\n ? getError(response.errorResponse.errorType, response.errorResponse.errorData)\n : new UnknownBeaconError()\n\n const actions: ToastAction[] = [\n {\n text: error.title,\n isBold: true\n }\n ]\n\n if (\n response.errorResponse.errorType === BeaconErrorType.TRANSACTION_INVALID_ERROR &&\n response.errorResponse.errorData\n ) {\n const err: RPCError[] = response.errorResponse.errorData\n const errorMessages = response.errorMessages\n\n let hasHumandReadableError = false\n\n if (err[0]?.contract_handle && errorMessages && errorMessages?.[err[0].contract_handle]) {\n const errCode = err[1]?.with?.int ?? err[1]?.with?.string\n const contractErrors = errorMessages?.[err[0].contract_handle]\n if (errCode && contractErrors?.[errCode]) {\n actions.push({\n text: contractErrors?.[errCode],\n isBold: true\n })\n hasHumandReadableError = true\n }\n }\n\n if (!hasHumandReadableError) {\n actions.push({\n text: error.description\n })\n }\n\n actions.push({\n text: '',\n actionText: 'Show Details',\n actionCallback: async (): Promise<void> => {\n closeToast()\n openAlert({\n title: error.title,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n body: error.fullDescription.description,\n data: error.fullDescription.data,\n errorContext: response.errorContext,\n buttons\n })\n }\n })\n } else {\n // For non-transaction errors, add \"Show Details\" action\n actions.push({\n text: '',\n actionText: 'Show Details',\n actionCallback: async (): Promise<void> => {\n closeToast()\n openAlert({\n title: error.title,\n body: error.description,\n errorContext: response.errorContext,\n buttons\n })\n }\n })\n }\n\n openToast({\n body: `{{wallet}}\\u00A0 has returned an error`,\n timer:\n response.errorResponse.errorType === BeaconErrorType.ABORTED_ERROR\n ? SUCCESS_TIMER\n : undefined,\n state: 'finished',\n walletInfo: response.walletInfo,\n actions\n })\n}\n\n/**\n * Show a rate limit reached toast\n */\nconst showRateLimitReached = async (): Promise<void> => {\n openAlert({\n title: 'Error',\n body: 'Rate limit reached. Please slow down',\n buttons: [{ text: 'Done', style: 'outline' }],\n timer: 3000\n })\n}\n\n/**\n * Close the pairing alert once the extension connection is established\n */\nconst showExtensionConnectedAlert = () => {\n closeAlert()\n}\n\nconst showBugReportForm = async () => {\n await openBugReport()\n}\n\nconst showRelayerErrorAlert = async (errorContext: ErrorContext): Promise<void> => {\n openAlert({\n title: 'Error',\n body: `Failed to connect to the relayer. Please check that your system time is synchronized with the current time and reload the page.`,\n errorContext,\n buttons: [{ text: 'Done', style: 'outline' }],\n timer: 1500\n })\n}\n\n/**\n * No-op: the \"channel closed\" alert is intentionally disabled\n * (body kept below for reference)\n */\nconst showChannelClosedAlert = async (): Promise<void> => {\n // openAlert({\n // title: 'Channel closed',\n // body: `Your peer has closed the connection.`,\n // buttons: [{ text: 'Done', style: 'outline' }],\n // timer: 1500\n // })\n}\n\nconst showInternalErrorAlert = async (\n data: BeaconEventType[BeaconEvent.INTERNAL_ERROR]\n): Promise<void> => {\n const buttons: AlertButton[] = [...(data.buttons ?? [])]\n\n buttons.push({ text: 'Done', style: 'outline' })\n\n const alertConfig: AlertConfig = {\n title: 'Internal Error',\n body: data.text,\n errorContext: data.errorContext,\n buttons\n }\n openAlert(alertConfig)\n}\n\n/**\n * Show a connect alert with QR code\n *\n * @param data The data that is emitted by the PAIR_INIT event\n */\nconst showPairAlert = async (data: BeaconEventType[BeaconEvent.PAIR_INIT]): Promise<void> => {\n logger.log('showPairAlert')\n const alertConfig: AlertConfig = {\n title: 'Choose your preferred wallet',\n body: `<p></p>`,\n pairingPayload: {\n p2pSyncCode: data.p2pPeerInfo,\n walletConnectSyncCode: data.walletConnectPeerInfo,\n postmessageSyncCode: data.postmessagePeerInfo,\n networkType: data.networkType\n },\n // eslint-disable-next-line @typescript-eslint/unbound-method\n closeButtonCallback: data.abortedHandler,\n analytics: data.analytics,\n featuredWallets: data.featuredWallets,\n termsAndConditionsUrl: data.termsAndConditionsUrl,\n privacyPolicyUrl: data.privacyPolicyUrl,\n substratePairing: data.substratePairing\n }\n openAlert(alertConfig)\n}\n\n/**\n * Show a \"Permission Granted\" alert\n *\n * @param data The data that is emitted by the PERMISSION_REQUEST_SUCCESS event\n */\nconst showPermissionSuccessAlert = async (\n data: BeaconEventType[BeaconEvent.PERMISSION_REQUEST_SUCCESS]\n): Promise<void> => {\n const { output } = data\n\n const actions: any[] = [\n {\n text: 'Address',\n actionText: shortenString(output.address),\n isBold: true\n }\n ]\n\n if ((output.network.type as any) !== 'substrate') {\n actions.push({\n text: 'Network',\n actionText: `${output.network.type}`\n })\n actions.push({\n text: 'Permissions',\n actionText: output.scopes.join(', ')\n })\n }\n\n openToast({\n body: `{{wallet}}\\u00A0 has granted permission`,\n timer: SUCCESS_TIMER,\n walletInfo: data.walletInfo,\n state: 'finished',\n actions\n })\n}\n\nconst showProofOfEventChallengeSuccessAlert = async (\n data: BeaconEventType[BeaconEvent.PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS]\n): Promise<void> => {\n const { output } = data\n\n openToast({\n body: `{{wallet}}\\u00A0 has ${output.isAccepted ? 'accepted' : 'refused'} the challenge`,\n timer: SUCCESS_TIMER,\n walletInfo: data.walletInfo,\n state: 'finished',\n actions: output.isAccepted\n ? [\n {\n text: `Payload hash: ${output.payloadHash}`,\n actionText: 'Copy to clipboard',\n actionCallback: async (): Promise<void> => {\n navigator.clipboard.writeText(output.payloadHash).then(\n () => {\n logger.log('showSignSuccessAlert', 'Copying to clipboard was successful!')\n },\n (err) => {\n logger.error('showSignSuccessAlert', 'Could not copy text to clipboard: ', err)\n }\n )\n closeToast()\n }\n }\n ]\n : []\n })\n}\n\nconst showSimulatedProofOfEventChallengeSuccessAlert = async (\n data: BeaconEventType[BeaconEvent.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS]\n): Promise<void> => {\n const { output } = data\n\n openToast({\n body: !output.errorMessage\n ? `{{wallet}}\\u00A0 has returned the list of operation`\n : `{{wallet}}\\u00A0 has returned an error`,\n timer: SUCCESS_TIMER,\n walletInfo: data.walletInfo,\n state: 'finished',\n actions: !output.errorMessage\n ? [\n {\n text: 'Operation list',\n actionText: 'Copy to clipboard',\n actionCallback: async (): Promise<void> => {\n navigator.clipboard.writeText(output.operationsList).then(\n () => {\n logger.log('showSignSuccessAlert', 'Copying to clipboard was successful!')\n },\n (err) => {\n logger.error('showSignSuccessAlert', 'Could not copy text to clipboard: ', err)\n }\n )\n closeToast()\n }\n }\n ]\n : [{ text: 'Error message', actionText: output.errorMessage }]\n })\n}\n\n/**\n * Show an \"Operation Broadcasted\" alert\n *\n * @param data The data that is emitted by the OPERATION_REQUEST_SUCCESS event\n */\nconst showOperationSuccessAlert = async (\n data: BeaconEventType[BeaconEvent.OPERATION_REQUEST_SUCCESS]\n): Promise<void> => {\n const { account, output, blockExplorer } = data\n\n openToast({\n body: `{{wallet}}\\u00A0 successfully submitted operation`,\n timer: SUCCESS_TIMER,\n state: 'finished',\n walletInfo: data.walletInfo,\n actions: [\n {\n text: shortenString(output.transactionHash),\n isBold: true,\n actionText: `Open Blockexplorer`,\n actionLogo: 'external',\n actionCallback: async (): Promise<void> => {\n const link: string = await blockExplorer.getTransactionLink(\n output.transactionHash,\n account.network\n )\n window.open(link, '_blank', 'noopener')\n closeToast()\n }\n }\n ]\n })\n}\n\n/**\n * Show a \"Transaction Signed\" alert\n *\n * @param data The data that is emitted by the SIGN_REQUEST_SUCCESS event\n */\nconst showSignSuccessAlert = async (\n data: BeaconEventType[BeaconEvent.SIGN_REQUEST_SUCCESS]\n): Promise<void> => {\n const output = data.output\n openToast({\n body: `{{wallet}}\\u00A0 successfully signed payload`,\n timer: SUCCESS_TIMER,\n state: 'finished',\n walletInfo: data.walletInfo,\n actions: [\n {\n text: `Signature: ${shortenString(output.signature)}`,\n actionText: 'Copy to clipboard',\n actionCallback: async (): Promise<void> => {\n navigator.clipboard.writeText(output.signature).then(\n () => {\n logger.log('showSignSuccessAlert', 'Copying to clipboard was successful!')\n },\n (err) => {\n logger.error('showSignSuccessAlert', 'Could not copy text to clipboard: ', err)\n }\n )\n closeToast()\n }\n }\n ]\n })\n}\n\n/**\n * Show a \"Transaction Signed\" alert\n *\n * @param data The data that is emitted by the ENCRYPT_REQUEST_SUCCESS event\n */\n// TODO: ENCRYPTION\n// const showEncryptSuccessAlert = async (\n// data: BeaconEventType[BeaconEvent.ENCRYPT_REQUEST_SUCCESS]\n// ): Promise<void> => {\n// const output = data.output\n// openToast({\n// body: `{{wallet}}\\u00A0 successfully ${\n// data.output.cryptoOperation === EncryptionOperation.ENCRYPT ? 'encrypted' : 'decrypted'\n// } payload`,\n// timer: SUCCESS_TIMER,\n// state: 'finished',\n// walletInfo: data.walletInfo,\n// actions: [\n// {\n// text: `Payload: <strong>${shortenString(output.payload)}</strong>`,\n// actionText: 'Copy to clipboard',\n// actionCallback: async (): Promise<void> => {\n// navigator.clipboard.writeText(output.payload).then(\n// () => {\n// logger.log('showSignSuccessAlert', 'Copying to clipboard was successful!')\n// },\n// (err) => {\n// logger.error('showSignSuccessAlert', 'Could not copy text to clipboard: ', err)\n// }\n// )\n// closeToast()\n// }\n// }\n// ]\n// })\n// }\n\nconst showBlockchainRequestSuccessToast = async (\n data: BeaconEventType[BeaconEvent.BLOCKCHAIN_REQUEST_SUCCESS]\n): Promise<void> => {\n openToast({\n body: `{{wallet}}\\u00A0 request successfully executed`,\n timer: SUCCESS_TIMER,\n state: 'finished',\n walletInfo: data.walletInfo\n })\n}\n\n/**\n * Show a \"Broadcasted\" alert\n *\n * @param data The data that is emitted by the BROADCAST_REQUEST_SUCCESS event\n */\nconst showBroadcastSuccessAlert = async (\n data: BeaconEventType[BeaconEvent.BROADCAST_REQUEST_SUCCESS]\n): Promise<void> => {\n const { network, output, blockExplorer } = data\n\n openToast({\n body: `{{wallet}}\\u00A0 successfully injected operation`,\n timer: SUCCESS_TIMER,\n state: 'finished',\n walletInfo: data.walletInfo,\n actions: [\n {\n text: shortenString(output.transactionHash),\n isBold: true,\n actionText: `Open Blockexplorer`,\n actionLogo: 'external',\n actionCallback: async (): Promise<void> => {\n const link: string = await blockExplorer.getTransactionLink(\n output.transactionHash,\n network\n )\n window.open(link, '_blank', 'noopener')\n closeToast()\n }\n }\n ]\n })\n}\n\nconst emptyHandler = (): BeaconEventHandlerFunction => async (): Promise<void> => {\n //\n}\n\nexport type BeaconEventHandlerFunction<T = unknown> = (\n data: T,\n eventCallback?: AlertButton[]\n) => void | Promise<void>\n\n/**\n * The default event handlers\n */\nexport const defaultEventCallbacks: {\n [key in BeaconEvent]: BeaconEventHandlerFunction<BeaconEventType[key]>\n} = {\n [BeaconEvent.PERMISSION_REQUEST_SENT]: showSentToast,\n [BeaconEvent.PERMISSION_REQUEST_SUCCESS]: showPermissionSuccessAlert,\n [BeaconEvent.PERMISSION_REQUEST_ERROR]: showErrorToast,\n [BeaconEvent.PROOF_OF_EVENT_CHALLENGE_REQUEST_SENT]: showSentToast,\n [BeaconEvent.PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS]: showProofOfEventChallengeSuccessAlert,\n [BeaconEvent.PROOF_OF_EVENT_CHALLENGE_REQUEST_ERROR]: showErrorToast,\n [BeaconEvent.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SENT]: showSentToast,\n [BeaconEvent.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS]:\n showSimulatedProofOfEventChallengeSuccessAlert,\n [BeaconEvent.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_ERROR]: showErrorToast,\n [BeaconEvent.OPERATION_REQUEST_SENT]: showSentToast,\n [BeaconEvent.OPERATION_REQUEST_SUCCESS]: showOperationSuccessAlert,\n [BeaconEvent.OPERATION_REQUEST_ERROR]: showErrorToast,\n [BeaconEvent.SIGN_REQUEST_SENT]: showSentToast,\n [BeaconEvent.SIGN_REQUEST_SUCCESS]: showSignSuccessAlert,\n [BeaconEvent.SIGN_REQUEST_ERROR]: showErrorToast,\n // TODO: ENCRYPTION\n // [BeaconEvent.ENCRYPT_REQUEST_SENT]: showSentToast,\n // [BeaconEvent.ENCRYPT_REQUEST_SUCCESS]: showEncryptSuccessAlert,\n // [BeaconEvent.ENCRYPT_REQUEST_ERROR]: showErrorToast,\n [BeaconEvent.BROADCAST_REQUEST_SENT]: showSentToast,\n [BeaconEvent.BROADCAST_REQUEST_SUCCESS]: showBroadcastSuccessAlert,\n [BeaconEvent.BROADCAST_REQUEST_ERROR]: showErrorToast,\n [BeaconEvent.ACKNOWLEDGE_RECEIVED]: showAcknowledgedToast,\n [BeaconEvent.LOCAL_RATE_LIMIT_REACHED]: showRateLimitReached,\n [BeaconEvent.NO_PERMISSIONS]: showNoPermissionAlert,\n [BeaconEvent.ACTIVE_ACCOUNT_SET]: emptyHandler(),\n [BeaconEvent.ACTIVE_TRANSPORT_SET]: emptyHandler(),\n [BeaconEvent.INVALID_ACTIVE_ACCOUNT_STATE]: showInvalidActiveAccountState,\n [BeaconEvent.GENERIC_ERROR]: showGenericErrorAlert,\n [BeaconEvent.INVALID_ACCOUNT_DEACTIVATED]: showInvalidAccountDeactivated,\n [BeaconEvent.SHOW_PREPARE]: showPrepare,\n [BeaconEvent.HIDE_UI]: hideUI,\n [BeaconEvent.PAIR_INIT]: showPairAlert,\n [BeaconEvent.PAIR_SUCCESS]: showExtensionConnectedAlert,\n [BeaconEvent.PAIR_ABORTED]: emptyHandler(),\n [BeaconEvent.OPEN_BUG_REPORT]: showBugReportForm,\n [BeaconEvent.RELAYER_ERROR]: showRelayerErrorAlert,\n [BeaconEvent.CHANNEL_CLOSED]: showChannelClosedAlert,\n [BeaconEvent.INTERNAL_ERROR]: showInternalErrorAlert,\n [BeaconEvent.BLOCKCHAIN_REQUEST_SUCCESS]: showBlockchainRequestSuccessToast,\n [BeaconEvent.UNKNOWN]: emptyHandler()\n}\n\n/**\n * @internalapi\n *\n * Handles beacon events\n */\nexport class BeaconEventHandler {\n private readonly callbackMap: {\n [key in BeaconEvent]: BeaconEventHandlerFunction<any>[] // TODO: Fix type\n } = {\n [BeaconEvent.PERMISSION_REQUEST_SENT]: [defaultEventCallbacks.PERMISSION_REQUEST_SENT],\n [BeaconEvent.PERMISSION_REQUEST_SUCCESS]: [defaultEventCallbacks.PERMISSION_REQUEST_SUCCESS],\n [BeaconEvent.PERMISSION_REQUEST_ERROR]: [defaultEventCallbacks.PERMISSION_REQUEST_ERROR],\n [BeaconEvent.PROOF_OF_EVENT_CHALLENGE_REQUEST_SENT]: [\n defaultEventCallbacks.PERMISSION_REQUEST_SENT\n ],\n [BeaconEvent.PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS]: [\n defaultEventCallbacks.PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS\n ],\n [BeaconEvent.PROOF_OF_EVENT_CHALLENGE_REQUEST_ERROR]: [\n defaultEventCallbacks.PROOF_OF_EVENT_CHALLENGE_REQUEST_ERROR\n ],\n [BeaconEvent.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SENT]: [\n defaultEventCallbacks.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SENT\n ],\n [BeaconEvent.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS]: [\n defaultEventCallbacks.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS\n ],\n [BeaconEvent.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_ERROR]: [\n defaultEventCallbacks.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_ERROR\n ],\n [BeaconEvent.OPERATION_REQUEST_SENT]: [defaultEventCallbacks.OPERATION_REQUEST_SENT],\n [BeaconEvent.OPERATION_REQUEST_SUCCESS]: [defaultEventCallbacks.OPERATION_REQUEST_SUCCESS],\n [BeaconEvent.OPERATION_REQUEST_ERROR]: [defaultEventCallbacks.OPERATION_REQUEST_ERROR],\n [BeaconEvent.SIGN_REQUEST_SENT]: [defaultEventCallbacks.SIGN_REQUEST_SENT],\n [BeaconEvent.SIGN_REQUEST_SUCCESS]: [defaultEventCallbacks.SIGN_REQUEST_SUCCESS],\n [BeaconEvent.SIGN_REQUEST_ERROR]: [defaultEventCallbacks.SIGN_REQUEST_ERROR],\n // TODO: ENCRYPTION\n // [BeaconEvent.ENCRYPT_REQUEST_SENT]: [defaultEventCallbacks.ENCRYPT_REQUEST_SENT],\n // [BeaconEvent.ENCRYPT_REQUEST_SUCCESS]: [defaultEventCallbacks.ENCRYPT_REQUEST_SUCCESS],\n // [BeaconEvent.ENCRYPT_REQUEST_ERROR]: [defaultEventCallbacks.ENCRYPT_REQUEST_ERROR],\n [BeaconEvent.BROADCAST_REQUEST_SENT]: [defaultEventCallbacks.BROADCAST_REQUEST_SENT],\n [BeaconEvent.BROADCAST_REQUEST_SUCCESS]: [defaultEventCallbacks.BROADCAST_REQUEST_SUCCESS],\n [BeaconEvent.BROADCAST_REQUEST_ERROR]: [defaultEventCallbacks.BROADCAST_REQUEST_ERROR],\n [BeaconEvent.BLOCKCHAIN_REQUEST_SUCCESS]: [defaultEventCallbacks.BLOCKCHAIN_REQUEST_SUCCESS],\n [BeaconEvent.ACKNOWLEDGE_RECEIVED]: [defaultEventCallbacks.ACKNOWLEDGE_RECEIVED],\n [BeaconEvent.LOCAL_RATE_LIMIT_REACHED]: [defaultEventCallbacks.LOCAL_RATE_LIMIT_REACHED],\n [BeaconEvent.NO_PERMISSIONS]: [defaultEventCallbacks.NO_PERMISSIONS],\n [BeaconEvent.ACTIVE_ACCOUNT_SET]: [defaultEventCallbacks.ACTIVE_ACCOUNT_SET],\n [BeaconEvent.ACTIVE_TRANSPORT_SET]: [defaultEventCallbacks.ACTIVE_TRANSPORT_SET],\n [BeaconEvent.INVALID_ACTIVE_ACCOUNT_STATE]: [\n defaultEventCallbacks.INVALID_ACTIVE_ACCOUNT_STATE\n ],\n [BeaconEvent.GENERIC_ERROR]: [showGenericErrorAlert],\n [BeaconEvent.INVALID_ACCOUNT_DEACTIVATED]: [defaultEventCallbacks.INVALID_ACCOUNT_DEACTIVATED],\n [BeaconEvent.SHOW_PREPARE]: [defaultEventCallbacks.SHOW_PREPARE],\n [BeaconEvent.HIDE_UI]: [defaultEventCallbacks.HIDE_UI],\n [BeaconEvent.PAIR_INIT]: [defaultEventCallbacks.PAIR_INIT],\n [BeaconEvent.PAIR_SUCCESS]: [defaultEventCallbacks.PAIR_SUCCESS],\n [BeaconEvent.PAIR_ABORTED]: [defaultEventCallbacks.PAIR_ABORTED],\n [BeaconEvent.OPEN_BUG_REPORT]: [showBugReportForm],\n [BeaconEvent.CHANNEL_CLOSED]: [defaultEventCallbacks.CHANNEL_CLOSED],\n [BeaconEvent.INTERNAL_ERROR]: [defaultEventCallbacks.INTERNAL_ERROR],\n [BeaconEvent.RELAYER_ERROR]: [defaultEventCallbacks.RELAYER_ERROR],\n [BeaconEvent.UNKNOWN]: [defaultEventCallbacks.UNKNOWN]\n }\n constructor(\n eventsToOverride: {\n [key in BeaconEvent]?: {\n handler: BeaconEventHandlerFunction<BeaconEventType[key]>\n }\n } = {},\n overrideAll?: boolean\n ) {\n if (overrideAll) {\n this.setAllHandlers()\n }\n this.overrideDefaults(eventsToOverride)\n }\n\n /**\n * A method to subscribe to a specific beacon event and register a callback\n *\n * @param event The event being emitted\n * @param eventCallback The callback that will be invoked\n */\n public async on<K extends BeaconEvent>(\n event: K,\n eventCallback: BeaconEventHandlerFunction<BeaconEventType[K]>\n ): Promise<void> {\n const listeners = this.callbackMap[event] || []\n listeners.push(eventCallback)\n this.callbackMap[event] = listeners\n }\n\n /**\n * Emit a beacon event\n *\n * @param event The event being emitted\n * @param data The data to be emit\n */\n public async emit<K extends BeaconEvent>(\n event: K,\n data?: BeaconEventType[K],\n eventCallback?: AlertButton[]\n ): Promise<void> {\n const listeners = this.callbackMap[event]\n if (listeners && listeners.length > 0) {\n listeners.forEach(async (listener: BeaconEventHandlerFunction) => {\n try {\n await listener(data, eventCallback)\n } catch (listenerError) {\n logger.error(`error handling event ${event}`, listenerError)\n }\n })\n }\n }\n\n /**\n * Override beacon event default callbacks. This can be used to disable default alert/toast behaviour\n *\n * @param eventsToOverride An object with the events to override\n */\n private overrideDefaults(eventsToOverride: {\n [key in BeaconEvent]?: {\n handler: BeaconEventHandlerFunction<BeaconEventType[key]>\n }\n }): void {\n Object.keys(eventsToOverride).forEach((untypedEvent: string) => {\n const eventType: BeaconEvent = untypedEvent as BeaconEvent\n const event = eventsToOverride[eventType]\n if (event) {\n this.callbackMap[eventType] = [event.handler]\n }\n })\n }\n\n /**\n * Set all event callbacks to a specific handler.\n */\n private setAllHandlers(handler?: BeaconEventHandlerFunction): void {\n Object.keys(this.callbackMap).forEach((untypedEvent: string) => {\n const eventType: BeaconEvent = untypedEvent as BeaconEvent\n this.callbackMap[eventType] = []\n if (handler) {\n this.callbackMap[eventType].push(handler)\n } else {\n this.callbackMap[eventType].push((...data) => {\n logger.log(untypedEvent, ...data)\n })\n }\n })\n }\n}\n"]}