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