Skip to content

Commit

Permalink
format store
Browse files Browse the repository at this point in the history
  • Loading branch information
johnson86tw committed May 2, 2024
1 parent 1346a4b commit f052da8
Show file tree
Hide file tree
Showing 6 changed files with 688 additions and 685 deletions.
25 changes: 12 additions & 13 deletions src/store/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { createStore } from 'vuex';
import network from "./modules/network";
import user from "./modules/user";
import punk from "./modules/punk";
import tld from "./modules/tld";

import { createStore } from 'vuex'
import network from './modules/network'
import user from './modules/user'
import punk from './modules/punk'
import tld from './modules/tld'

const store = createStore({
modules: {
network,
user,
punk,
tld
}
modules: {
network,
user,
punk,
tld,
},
})

export default store;
export default store
151 changes: 74 additions & 77 deletions src/store/modules/network.ts
Original file line number Diff line number Diff line change
@@ -1,80 +1,77 @@
import { useEthers } from 'vue-dapp';
import tokens from "../../abi/tokens.json";
import { useEthers } from 'vue-dapp'
import tokens from '../../abi/tokens.json'

const { chainId } = useEthers();
const { chainId } = useEthers()

export default {
namespaced: true,

state: () => ({
networkCurrency: "ETH",
networkName: "Unsupported Network",
supportedNetworks: {
34443: "Mode"
}
}),

getters: {
getBlockExplorerBaseUrl() {
// TODO
return "https://explorer.mode.network/";
},

getChainId() {
return chainId.value;
},

getNetworkCurrency(state) {
return state.networkCurrency;
},

getNetworkName(state) {
const supportedIds = Object.keys(state.supportedNetworks);

if (supportedIds && supportedIds.includes(String(chainId.value))) {
return state.networkName;
}

return "Unsupported Network";
},

getSupportedNetworks(state) {
return state.supportedNetworks;
},

getSupportedNetworkIds(state) {
return Object.keys(state.supportedNetworks);
},

getSupportedNetworkNames(state) {
return Object.values(state.supportedNetworks);
},

getTokens(state) {
return tokens[String(chainId.value)]
},

isNetworkSupported(state) {
const supportedIds = Object.keys(state.supportedNetworks);

if (supportedIds && supportedIds.includes(String(chainId.value))) {
return true;
}

return false;
}
},

mutations: {
setNetworkData(state) {
// TODO
state.networkName = "Mode";
state.networkCurrency = "ETH";
}
},

actions: {

}

};
namespaced: true,

state: () => ({
networkCurrency: 'ETH',
networkName: 'Unsupported Network',
supportedNetworks: {
34443: 'Mode',
},
}),

getters: {
getBlockExplorerBaseUrl() {
// TODO
return 'https://explorer.mode.network/'
},

getChainId() {
return chainId.value
},

getNetworkCurrency(state) {
return state.networkCurrency
},

getNetworkName(state) {
const supportedIds = Object.keys(state.supportedNetworks)

if (supportedIds && supportedIds.includes(String(chainId.value))) {
return state.networkName
}

return 'Unsupported Network'
},

getSupportedNetworks(state) {
return state.supportedNetworks
},

getSupportedNetworkIds(state) {
return Object.keys(state.supportedNetworks)
},

getSupportedNetworkNames(state) {
return Object.values(state.supportedNetworks)
},

getTokens(state) {
return tokens[String(chainId.value)]
},

isNetworkSupported(state) {
const supportedIds = Object.keys(state.supportedNetworks)

if (supportedIds && supportedIds.includes(String(chainId.value))) {
return true
}

return false
},
},

mutations: {
setNetworkData(state) {
// TODO
state.networkName = 'Mode'
state.networkCurrency = 'ETH'
},
},

actions: {},
}
16 changes: 8 additions & 8 deletions src/store/modules/punk.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import tldAbi from "../../abi/PunkTLD.json";
import tldAbi from '../../abi/PunkTLD.json'

export default {
namespaced: true,
namespaced: true,

getters: {
getTldAbi() {
return tldAbi;
}
}
};
getters: {
getTldAbi() {
return tldAbi
},
},
}
22 changes: 7 additions & 15 deletions src/store/modules/template.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
export default {
namespaced: true,

state: () => ({

}),
namespaced: true,

getters: {

},
state: () => ({}),

mutations: {

},
getters: {},

actions: {
}
};
mutations: {},

actions: {},
}
Loading

0 comments on commit f052da8

Please sign in to comment.