import { Message } from "@keplr-wallet/router" ; import { ROUTE } from "./constants" ; export class EnableAccessMsg extends Message < void > { public static type ( ) { return "enable-access" ; } constructor ( public readonly chainIds ) { super ( ) ; } validateBasic ( ) { if ( ! this . chainIds || this . chainIds . length === 0 ) { throw new Error ( "chain id not set" ) ; } } route ( ) { return ROUTE ; } approveExternal ( ) { return true ; } type ( ) { return EnableAccessMsg . type ( ) ; } } export class GetPermissionOriginsMsg extends Message < string [ ] > { public static type ( ) { return "get-permission-origins" ; } constructor ( public readonly chainId , public readonly permissionType ) { super ( ) ; } validateBasic ( ) { if ( ! this . chainId ) { throw new Error ( "chain id not set" ) ; } if ( ! this . permissionType ) { throw new Error ( "empty permission type" ) ; } } route ( ) { return ROUTE ; } type ( ) { return GetPermissionOriginsMsg . type ( ) ; } } export class GetOriginPermittedChainsMsg extends Message < string [ ] > { public static type ( ) { return "get-origin-permitted-chains" ; } constructor ( public readonly permissionOrigin , public readonly permissionType ) { super ( ) ; } validateBasic ( ) { if ( ! this . permissionOrigin ) { throw new Error ( "origin not set" ) ; } if ( ! this . permissionType ) { throw new Error ( "empty permission type" ) ; } } route ( ) { return ROUTE ; } type ( ) { return GetOriginPermittedChainsMsg . type ( ) ; } } export class AddPermissionOrigin extends Message < void > { public static type ( ) { return "add-permission-origin" ; } constructor ( public readonly chainId , public readonly permissionType , public readonly permissionOrigin ) { super ( ) ; } validateBasic ( ) { if ( ! this . chainId ) { throw new Error ( "chain id not set" ) ; } if ( ! this . permissionType ) { throw new Error ( "empty permission type" ) ; } if ( ! this . permissionOrigin ) { throw new Error ( "empty permission origin" ) ; } } route ( ) { return ROUTE ; } type ( ) { return AddPermissionOrigin . type ( ) ; } } export class RemovePermissionOrigin extends Message < void > { public static type ( ) { return "remove-permission-origin" ; } constructor ( public readonly chainId , public readonly permissionType , public readonly permissionOrigin ) { super ( ) ; } validateBasic ( ) { if ( ! this . chainId ) { throw new Error ( "chain id not set" ) ; } if ( ! this . permissionType ) { throw new Error ( "empty permission type" ) ; } if ( ! this . permissionOrigin ) { throw new Error ( "empty permission origin" ) ; } } route ( ) { return ROUTE ; } type ( ) { return RemovePermissionOrigin . type ( ) ; } }