/**
 * Store the config related to UI.
 */ import { action , makeObservable , observable , runInAction , toJS } from "mobx" ; import { KVStore } from "@keplr-wallet/common" ; export interface UIConfigOptions { showAdvancedIBCTransfer : boolean ; } export class UIConfigStore { @ observable . deep protected options : UIConfigOptions = { showAdvancedIBCTransfer : false , } ; constructor ( protected readonly kvStore ) { makeObservable ( this ) ; this . init ( ) ; } protected async init ( ) { const data = await this . kvStore . get < Partial < UIConfigOptions > > ( "options" ) ; runInAction ( ( ) => { this . options = { ... this . options , ... data , } ; } ) ; } /**
     * Currently, keplr only supports the IBC UI which the users should set the counterparty channel manually.
     * However, it makes the normal users take a mistake.
     * So, to reduce this problem, show the IBC UI to users who only turns on the `showAdvancedIBCTransfer` explicitly.
     */ get showAdvancedIBCTransfer ( ) : boolean { return this . options . showAdvancedIBCTransfer ; } @ action setShowAdvancedIBCTransfer ( value ) { this . options . showAdvancedIBCTransfer = value ; this . save ( ) ; } async save ( ) { const data = toJS ( this . options ) ; await this . kvStore . set ( "options" , data ) ; } }