mirror of
https://github.com/tornadocash/trusted-setup-server.git
synced 2024-11-21 17:36:54 +01:00
index page contributions
This commit is contained in:
parent
af76b7cdb1
commit
955983f6a9
@ -256,10 +256,7 @@
|
||||
.table {
|
||||
a {
|
||||
color: $primary;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.social-link {
|
||||
|
116
pages/index.vue
116
pages/index.vue
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="ceremony">
|
||||
<h1 class="title is-size-1 is-spaced">Lorem <span>Ipsum Dolor</span></h1>
|
||||
<h1 class="title is-size-1 is-spaced">Tornado.cash <span>Trusted setup ceremony</span></h1>
|
||||
<p class="p is-size-5">
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
|
||||
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
|
||||
@ -11,7 +11,9 @@
|
||||
Make the contribution
|
||||
</b-button>
|
||||
</div>
|
||||
<div class="currently">Currently there are <span>8999</span> contributions</div>
|
||||
<div class="currently">
|
||||
Currently there are <span>{{ contributions.length }}</span> contributions
|
||||
</div>
|
||||
|
||||
<b-table
|
||||
:data="filteredContributions"
|
||||
@ -28,16 +30,17 @@
|
||||
|
||||
<b-table-column label="Account">
|
||||
<a
|
||||
v-if="props.row.account"
|
||||
:href="`#${props.row.account}`"
|
||||
v-if="props.row.handle"
|
||||
:href="`https://${props.row.socialType}.com/${props.row.handle}`"
|
||||
class="social-link"
|
||||
target="_blank"
|
||||
>
|
||||
<span :class="`icon-${props.row.socialType}`" class="icon"></span>
|
||||
{{ props.row.account }}
|
||||
@{{ props.row.handle }}
|
||||
</a>
|
||||
<div v-else class="social-link">
|
||||
<span :class="`icon-${props.row.socialType}`" class="icon"></span>
|
||||
Anonymous
|
||||
</div>
|
||||
</b-table-column>
|
||||
|
||||
@ -49,8 +52,8 @@
|
||||
{{ props.row.company }}
|
||||
</b-table-column>
|
||||
|
||||
<b-table-column label="Attestation">
|
||||
<a :href="props.row.attestation" target="_blank">{{ props.row.account }}</a>
|
||||
<b-table-column :centered="true" label="Attestation">
|
||||
<a :href="props.row.attestation" target="_blank">{{ getAttestation(props.row) }}</a>
|
||||
</b-table-column>
|
||||
|
||||
<b-table-column :centered="true" label="Contribution">
|
||||
@ -114,71 +117,18 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
contributions: [
|
||||
{
|
||||
id: 1,
|
||||
socialType: 'twitter',
|
||||
account: '@VitalikButerin',
|
||||
name: 'Vitalik Buterin',
|
||||
company: 'Ethereum',
|
||||
attestation: 'https://twitter.com/VitalikButerin/status/1220158987456237568',
|
||||
contribution: '#'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
socialType: 'twitter',
|
||||
account: '@Chims1974',
|
||||
name: 'Rickey Kline',
|
||||
company: 'Big Wheel',
|
||||
attestation: '#',
|
||||
contribution: '#'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
socialType: 'github',
|
||||
account: '@Diguest',
|
||||
name: 'Ryan Obrien',
|
||||
company: 'Brilliant Home',
|
||||
attestation: '#',
|
||||
contribution: '#'
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
socialType: 'anonymous',
|
||||
account: '',
|
||||
name: 'Anonymous',
|
||||
company: '',
|
||||
attestation: '',
|
||||
contribution: '#'
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
socialType: 'github',
|
||||
account: '@Mathervenrat',
|
||||
name: 'William Hartwig',
|
||||
company: 'New World',
|
||||
attestation: '#',
|
||||
contribution: '#'
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
socialType: 'twitter',
|
||||
account: '@Hichercy',
|
||||
name: 'Wayne Biggins',
|
||||
company: 'Balanced Fortune',
|
||||
attestation: '#',
|
||||
contribution: '#'
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
socialType: 'anonymous',
|
||||
account: '',
|
||||
name: 'Anonymous',
|
||||
company: '',
|
||||
attestation: '',
|
||||
contribution: '#'
|
||||
}
|
||||
],
|
||||
contributions: [],
|
||||
// contributions: [
|
||||
// {
|
||||
// id: 1,
|
||||
// socialType: 'twitter',
|
||||
// account: '@VitalikButerin',
|
||||
// name: 'Vitalik Buterin',
|
||||
// company: 'Ethereum',
|
||||
// attestation: 'https://twitter.com/VitalikButerin/status/1220158987456237568',
|
||||
// contribution: '#'
|
||||
// }
|
||||
// ],
|
||||
rowsPerPage: 10,
|
||||
contributionSearch: ''
|
||||
}
|
||||
@ -186,9 +136,29 @@ export default {
|
||||
computed: {
|
||||
filteredContributions() {
|
||||
return this.contributions.filter((contribution) => {
|
||||
return contribution.name.toLowerCase().includes(this.contributionSearch.toLowerCase())
|
||||
const name = contribution.name || 'anonymous'
|
||||
return name.toLowerCase().includes(this.contributionSearch.toLowerCase())
|
||||
})
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
try {
|
||||
const response = await fetch('/api/contributions')
|
||||
const data = await response.json()
|
||||
this.contributions = data
|
||||
} catch (e) {
|
||||
console.error('e', e)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getAttestation(row) {
|
||||
const type = {
|
||||
twitter: 'Tweet',
|
||||
github: 'Gist',
|
||||
anonymous: ''
|
||||
}
|
||||
return type[row.socialType]
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -99,7 +99,7 @@ export default {
|
||||
return !!this.user.name && this.user.name !== 'Anonymous'
|
||||
},
|
||||
isContributeBtnDisabled() {
|
||||
return !this.contributionType
|
||||
return !this.contributionType || (!this.isLoggedIn && this.contributionType !== 'anonymous')
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
@ -173,10 +173,10 @@ export default {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
})
|
||||
const responseData = await resp.json()
|
||||
if (resp.ok) {
|
||||
this.status.msg = 'Your contribution is verified and recorded. THX BYE.'
|
||||
this.status.type = 'is-success'
|
||||
const responseData = await resp.json()
|
||||
this.contributionIndex = responseData.contributionIndex
|
||||
} else if (resp.status === 422) {
|
||||
if (retry < 3) {
|
||||
|
2
seed.sql
2
seed.sql
@ -4,6 +4,8 @@ create table contributions
|
||||
token varchar(64) not null,
|
||||
name varchar(255) null,
|
||||
company varchar(255) null,
|
||||
handle varchar(255) null,
|
||||
socialType varchar(255) not null,
|
||||
hash varchar(130) null,
|
||||
|
||||
constraint contributions_pk
|
||||
|
@ -73,10 +73,18 @@ router.post('/response', upload.single('response'), async (req, res) => {
|
||||
|
||||
console.log('Committing changes')
|
||||
await fs.rename(`/tmp/tornado/${req.file.filename}`, './server/snark_files/current.params')
|
||||
await Contribution.insertContributionInfo(
|
||||
req.body ? req.body.name || null : null,
|
||||
req.body ? req.body.company || null : null
|
||||
)
|
||||
|
||||
const socialType = req.session.socialType || 'anonymous'
|
||||
let name = null
|
||||
let company = null
|
||||
let handle = null
|
||||
if (socialType !== 'anonymous' && req.body) {
|
||||
name = req.body.name || null
|
||||
company = req.body.company || null
|
||||
handle = req.session.handle || null
|
||||
}
|
||||
|
||||
await Contribution.insertContributionInfo({ name, company, handle, socialType })
|
||||
console.log('Finished')
|
||||
res.json({ contributionIndex: currentContributionIndex })
|
||||
} catch (e) {
|
||||
|
@ -25,7 +25,8 @@ router.get('/user_data', (req, res) => {
|
||||
} else {
|
||||
userData = JSON.parse(data)
|
||||
userData.handle = userData.screen_name
|
||||
// req.session.twitterScreenName = userData.screen_name
|
||||
req.session.handle = userData.screen_name
|
||||
req.session.socialType = 'twitter'
|
||||
}
|
||||
res.json(userData)
|
||||
}
|
||||
|
@ -10,16 +10,15 @@ Contributions.currentContributionIndex = async function() {
|
||||
return (rows[0].max || 0) + 1
|
||||
}
|
||||
|
||||
Contributions.insertContributionInfo = async function(name, company) {
|
||||
Contributions.insertContributionInfo = async function({ name, company, handle, socialType }) {
|
||||
const token = crypto.randomBytes(32).toString('hex')
|
||||
await sql.execute('insert into contributions(token, name, company) values(?, ?, ?)', [
|
||||
token,
|
||||
name,
|
||||
company
|
||||
])
|
||||
await sql.execute(
|
||||
'insert into contributions(token, name, company, handle, socialType) values(?, ?, ?, ?, ?)',
|
||||
[token, name, company, handle, socialType]
|
||||
)
|
||||
}
|
||||
|
||||
Contributions.updateContributionInfo = async function(token, name, company) {
|
||||
Contributions.updateContributionInfo = async function({ token, name, company }) {
|
||||
await sql.execute('insert into contributions(token, name, company) values(?, ?, ?)', [
|
||||
token,
|
||||
name,
|
||||
@ -28,7 +27,9 @@ Contributions.updateContributionInfo = async function(token, name, company) {
|
||||
}
|
||||
|
||||
Contributions.getContributions = async function() {
|
||||
const [rows] = await db.execute('select id, name, company from contributions')
|
||||
const [rows] = await sql.execute(
|
||||
'select id, name, company, handle, socialType from contributions'
|
||||
)
|
||||
return rows
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user