wallet-connect-web-examples/wallets/react-wallet-v2/src/store/ModalStore.ts
hamidra 1406ce3999
Add Polkadot RPCs to the Dapp examples and wallet (#44)
Co-authored-by: Ben Kremer <contact@bkrem.dev>
2022-08-11 11:43:12 +02:00

52 lines
947 B
TypeScript

import { SessionTypes, SignClientTypes } from '@walletconnect/types'
import { proxy } from 'valtio'
/**
* Types
*/
interface ModalData {
proposal?: SignClientTypes.EventArguments['session_proposal']
requestEvent?: SignClientTypes.EventArguments['session_request']
requestSession?: SessionTypes.Struct
}
interface State {
open: boolean
view?:
| 'SessionProposalModal'
| 'SessionSignModal'
| 'SessionSignTypedDataModal'
| 'SessionSendTransactionModal'
| 'SessionUnsuportedMethodModal'
| 'SessionSignCosmosModal'
| 'SessionSignSolanaModal'
| 'SessionSignPolkadotModal'
data?: ModalData
}
/**
* State
*/
const state = proxy<State>({
open: false
})
/**
* Store / Actions
*/
const ModalStore = {
state,
open(view: State['view'], data: State['data']) {
state.view = view
state.data = data
state.open = true
},
close() {
state.open = false
}
}
export default ModalStore