import { Message } from "@keplr-wallet/router" ; import { ROUTE } from "./constants" ; export class GetPubkeyMsg extends Message < Uint8Array > { public static type ( ) { return "get-pubkey-msg" ; } constructor ( public readonly chainId ) { super ( ) ; } validateBasic ( ) { if ( ! this . chainId ) { throw new Error ( "chain id not set" ) ; } } approveExternal ( ) { return true ; } route ( ) { return ROUTE ; } type ( ) { return GetPubkeyMsg . type ( ) ; } } export class ReqeustEncryptMsg extends Message < Uint8Array > { public static type ( ) { return "request-encrypt-msg" ; } constructor ( public readonly chainId , public readonly contractCodeHash , public readonly msg ) { super ( ) ; } validateBasic ( ) { if ( ! this . chainId ) { throw new Error ( "chain id not set" ) ; } if ( ! this . contractCodeHash ) { throw new Error ( "contract code hash not set" ) ; } if ( ! this . msg ) { throw new Error ( "msg not set" ) ; } } approveExternal ( ) { return true ; } route ( ) { return ROUTE ; } type ( ) { return ReqeustEncryptMsg . type ( ) ; } } export class RequestDecryptMsg extends Message < Uint8Array > { public static type ( ) { return "request-decrypt-msg" ; } constructor ( public readonly chainId , public readonly cipherText , public readonly nonce ) { super ( ) ; } validateBasic ( ) { if ( ! this . chainId ) { throw new Error ( "chain id not set" ) ; } if ( ! this . cipherText || this . cipherText . length === 0 ) { throw new Error ( "ciphertext not set" ) ; } if ( ! this . nonce || this . nonce . length === 0 ) { throw new Error ( "nonce not set" ) ; } } approveExternal ( ) { return true ; } route ( ) { return ROUTE ; } type ( ) { return RequestDecryptMsg . type ( ) ; } } export class GetTxEncryptionKeyMsg extends Message < Uint8Array > { public static type ( ) { return "get-tx-encryption-key-msg" ; } constructor ( public readonly chainId , public readonly nonce ) { super ( ) ; } validateBasic ( ) { if ( ! this . chainId ) { throw new Error ( "chain id not set" ) ; } if ( ! this . nonce ) { throw new Error ( "nonce is null" ) ; } } approveExternal ( ) { return true ; } route ( ) { return ROUTE ; } type ( ) { return GetTxEncryptionKeyMsg . type ( ) ; } }