Skip to content

Instantly share code, notes, and snippets.

@duartefdias
Created March 14, 2022 07:02
Show Gist options
  • Save duartefdias/a548a185ce811772fe22bcd9a7531fb8 to your computer and use it in GitHub Desktop.
Save duartefdias/a548a185ce811772fe22bcd9a7531fb8 to your computer and use it in GitHub Desktop.
export const state = () => ({
metamaskConnected: false,
ethereum: null,
accounts: []
})
export const mutations = {
setMetamaskConnected(state, value) {
state.metamaskConnected = value
},
setEthereum(state, value) {
state.ethereum = value
},
setAccounts(state, value) {
state.accounts = value
}
}
export const getters = {
metamaskConnected: state => state.metamaskConnected,
ethereum: state => { if(process.client) { return window.ethereum } },
getFirstAccount: state => { return state.accounts[0] }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment