forked from JSKitty/scc-web3
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into chain_refactor
- Loading branch information
Showing
62 changed files
with
3,672 additions
and
1,614 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
export const ALERTS = new Proxy( | ||
{}, | ||
{ | ||
get(_target, prop) { | ||
// Return the proxy itself if trying to access ALERTS | ||
if (prop === 'ALERTS') return translation; | ||
// Return key in tests so they aren't affected by translation changes | ||
return prop; | ||
}, | ||
} | ||
); | ||
|
||
export const translation = ALERTS; | ||
|
||
export const tr = (message, vars) => { | ||
return ( | ||
message + | ||
' ' + | ||
vars | ||
.map((v) => { | ||
let varStr = ''; | ||
for (const key in v) { | ||
varStr += key + ' ' + v[key]; | ||
} | ||
return varStr; | ||
}) | ||
.join(' ') | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { ref, watch, toRaw } from 'vue'; | ||
import { defineStore } from 'pinia'; | ||
import { Database } from '../database.js'; | ||
import { getEventEmitter } from '../event_bus.js'; | ||
|
||
export const useMasternode = defineStore('masternode', () => { | ||
/** | ||
* @type{import('vue').Ref<import('../masternode.js').default?>} | ||
*/ | ||
const masternode = ref(null); | ||
const localProposals = ref([]); | ||
watch( | ||
localProposals, | ||
async () => { | ||
const database = await Database.getInstance(); | ||
const account = await database.getAccount(); | ||
if (account) { | ||
account.localProposals = toRaw(localProposals.value); | ||
await database.updateAccount(account); | ||
} | ||
}, | ||
{ | ||
// We need deep reactivity to detect proposal changes e.g. proposalHeight update when it gets confirmed | ||
deep: true, | ||
} | ||
); | ||
const fetchProposalsFromDatabase = async () => { | ||
const database = await Database.getInstance(); | ||
const account = await database.getAccount(); | ||
localProposals.value = account?.localProposals ?? []; | ||
}; | ||
|
||
const fetchMasternodeFromDatabase = async () => { | ||
const database = await Database.getInstance(); | ||
masternode.value = await database.getMasternode(); | ||
}; | ||
|
||
watch(masternode, async () => { | ||
const database = await Database.getInstance(); | ||
await database.addMasternode(toRaw(masternode.value)); | ||
}); | ||
|
||
fetchProposalsFromDatabase().then(() => {}); | ||
fetchMasternodeFromDatabase().then(() => {}); | ||
getEventEmitter().on('toggle-network', () => { | ||
fetchProposalsFromDatabase().then(() => {}); | ||
fetchMasternodeFromDatabase().then(() => {}); | ||
}); | ||
return { masternode, localProposals }; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.