Skip to content

Commit

Permalink
Merge pull request #221 from xuhcc/rounds-all
Browse files Browse the repository at this point in the history
Allow to add extra rounds to round list
  • Loading branch information
xuhcc authored Dec 11, 2020
2 parents 33c4a79 + 62ca75c commit 9521a5f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions vue-app/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ VUE_APP_IPFS_GATEWAY_URL=https://ipfs.io
VUE_APP_CLRFUND_FACTORY_ADDRESS=0x3619DbE27d7c1e7E91aA738697Ae7Bc5FC3eACA5
VUE_APP_USER_REGISTRY_TYPE=simple
VUE_APP_RECIPIENT_REGISTRY_TYPE=simple
VUE_APP_EXTRA_ROUNDS=
6 changes: 6 additions & 0 deletions vue-app/src/api/recipient-registry-kleros.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ function decodeTcrItemData(columns: TcrColumn[], data: any[]): {
description: string;
imageUrl: string;
} {
// Disable console.error to ignore parser errors
/* eslint-disable no-console */
const consoleError = console.error
console.error = function () {} // eslint-disable-line @typescript-eslint/no-empty-function
const decodedMetadata = gtcrDecode({ columns, values: data })
console.error = consoleError
/* eslint-enable no-console */
return {
name: decodedMetadata[0] as string,
description: decodedMetadata[3] as string,
Expand Down
8 changes: 6 additions & 2 deletions vue-app/src/api/rounds.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { factory } from './core'
import { factory, ipfsGatewayUrl } from './core'

export interface Round {
index: number;
address: string;
url?: string;
}

export async function getRounds(): Promise<Round[]> {
const eventFilter = factory.filters.RoundStarted()
const events = await factory.queryFilter(eventFilter, 0)
const rounds: Round[] = []
const extraRounds = (process.env.VUE_APP_EXTRA_ROUNDS || '').split(',')
const rounds: Round[] = extraRounds.map((ipfsHash: string, index): Round => {
return { index, address: '', url: `${ipfsGatewayUrl}/ipfs/${ipfsHash}` }
})
for (const event of events) {
if (event.args) {
rounds.push({
Expand Down
6 changes: 5 additions & 1 deletion vue-app/src/views/RoundList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
<div
class="round"
v-for="round in rounds"
:key="round.address"
:key="round.index"
>
<router-link
v-if="round.address"
class="round-name"
:to="{ name: 'round', params: { address: round.address }}"
>
Round {{ round.index }}
</router-link>
<a v-else :href="round.url">
Round {{ round.index }}
</a>
</div>
</div>
</template>
Expand Down

0 comments on commit 9521a5f

Please sign in to comment.