Skip to content

Commit

Permalink
lots of tweaks and more content
Browse files Browse the repository at this point in the history
  • Loading branch information
merklejerk committed Jun 6, 2024
1 parent 96d4c8f commit 5c41730
Show file tree
Hide file tree
Showing 11 changed files with 1,379 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/lib/components/lede.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
> :global(h1) {
@extend .initialed;
margin: 0;
margin: 0 !important;
color: rgb(176, 138, 40);
text-indent: 0 !important;
}
Expand Down
15 changes: 11 additions & 4 deletions src/lib/contest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,18 @@ export async function fetchSeasons(
szn.privateKey = args.privateKey;
szn.state = SeasonState.Revealed;
} else if (log.eventName === 'WinnerDeclared') {
szn.winner = args.winner;
szn.prize = args.prize;
szn.unclaimedPrize = args.prize;
if (args.season in seasonsByIdx) {
const winSeason = seasonsByIdx[args.season];
winSeason.winner = args.winner;
winSeason.prize = args.prize;
winSeason.unclaimedPrize = args.prize;
}
} else {
szn.unclaimedPrize = 0n;
if (args.season in seasonsByIdx) {
const winSeason = seasonsByIdx[args.season];
winSeason.prize = args.prize;
winSeason.unclaimedPrize = 0n;
}
}
}
if (seasonsByIdx[currentSeasonIdx]) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/styles/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ input:not([type]), input[type='text'], textarea {
.alert {
border-image: url('/attention-border.png') 50% 12% / 0.75em 2ex round;
padding: 0.2em 2ex;
margin: 0 auto;
margin: 1em auto;
text-align: center;
width: fit-content
}
6 changes: 3 additions & 3 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@
fn: 'winner', args: [idx],
})),
});
for (const idx of seasonsWithUnclaimedPrizes) {
currentSeasons[idx].winner = seasonWins[idx][0];
currentSeasons[idx].unclaimedPrize = seasonWins[idx][1];
for (const [i, idx] of seasonsWithUnclaimedPrizes.entries()) {
currentSeasons[idx].winner = seasonWins[i][0];
currentSeasons[idx].unclaimedPrize = seasonWins[i][1];
}
}
setSeasons(currentSeasons);
Expand Down
21 changes: 17 additions & 4 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@
}
}
section {
> ul {
> li {
margin-bottom: 0.5em;
}
}
}
</style>

<Page>
Expand Down Expand Up @@ -91,7 +99,7 @@
<ContestProgress />
</div>
</section>
<section>
<section class="resources">
<h2>Resources</h2>
<ul>
<li>
Expand Down Expand Up @@ -119,8 +127,13 @@
</section>
<section>
<h2>Legal Disclosures</h2>
<div>
...
</div>
<ul>
<li>
<a href="/terms/rules.html">Contest Rules</a>
</li>
<li>
<a href="/terms/privacy.html">Privacy Agreement</a>
</li>
</ul>
</section>
</Page>
69 changes: 56 additions & 13 deletions src/routes/player/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@
playerAddress: Address;
playerName: string;
seasonResults: TournamentResult[][];
userId: string;
} | null = null;
let isWalletOperator = false;
let playerIsActive: boolean = false;
let playerPrize: bigint = 0n;
let currentSeason: SeasonInfo | null = null;
let profileUrl: string | null = null;
$: loadPlayerFromSearchParams($page.url.searchParams);
$: {
Expand All @@ -61,6 +63,21 @@
);
}
}
$: {
if (playerStats?.userId) {
resolvePlayerProfile(playerStats.userId);
}
}
async function resolvePlayerProfile(userId: string): Promise<void> {
profileUrl = null;
if (userId.startsWith('github:')) {
const resp = await fetch(`https://api.github.com/user/${userId.slice(7)}`);
const data = await resp.json();
profileUrl = `https://github.com/${data.login}`;
}
}
async function loadPlayerFromSearchParams(params: URLSearchParams): Promise<void> {
let searchAddress: Address | null = params.get('address') as Address ?? null;
Expand Down Expand Up @@ -116,6 +133,7 @@
address: Address;
name: string;
created: string;
userId: string;
performance: Array<{
rank: number;
totalPlayers: number;
Expand Down Expand Up @@ -147,6 +165,7 @@
playerAddress: r.address,
playerName: r.name,
seasonResults: tournamentsBySeason,
userId: r.userId,
};
}
Expand Down Expand Up @@ -269,6 +288,11 @@
grid: auto / repeat(5, 1fr);
flex-direction: row;
gap: 1ex;
&.header {
text-decoration: underline;
margin-bottom: 0.5em;
}
}
.submit-bytecode {
Expand All @@ -292,30 +316,40 @@
.name {
font-size: 1.25em;
color: #b52525;
color: rgb(37, 73, 181) !important;
}
.error {
color: red;
}
.address {
text-overflow: ellipsis;
overflow: hidden;
}
</style>

<Page title="Player Dashboard">
<Lede>
<h1>Merchant Details</h1>
{#if playerStats}
<div>
Name: <span class="name">{playerStats.playerName}</span>
Name:
{#if profileUrl}
<a class="name" target="_blank" href={profileUrl}>{playerStats.playerName}</a>
{:else}
<span class="name">{playerStats.playerName}</span>
{/if}
</div>
<div class="address">
Address: <a href={`${publicClient?.chain?.blockExplorers?.default.url}/address/${playerStats.playerAddress}`} target="_blank">{playerStats.playerAddress}</a>
Address: <a class="address" href={`${publicClient?.chain?.blockExplorers?.default.url}/address/${playerStats.playerAddress}`} target="_blank">{playerStats.playerAddress}</a>
</div>
<div class="is-active">
{#if playerIsActive}
Submission received.
Submission received ✓
{:else}
Awaiting submission.
Awaiting submission
{/if}
</div>
{/if}
Expand Down Expand Up @@ -352,6 +386,12 @@
{#if szn.length}
<div class="season">
<h3>Season {playerStats.seasonResults.length - i}</h3>
<div class="tournament-result header">
<div>Date</div>
<div>Type</div>
<div>Rank</div>
<div>Score</div>
</div>
{#each szn as tr (tr.tournamentId)}
<div class="tournament-result">
<div>
Expand All @@ -377,17 +417,19 @@
<h2>Submit code for season {(currentSeason.idx ?? 0) + 1}</h2>
{#if !playerIsActive}
<p>
You have not submitted any code for the current season, so you are not participating in any games.
You have not submitted player code for the current season, so you are not participating in any games.
</p>
{/if}
{:else}
<p>
You can either drop your player's compiled artifact file onto the text box below or you can manually paste the hex bytecode yourself.
You have already submitted your player code for the current season but you can replace your submission up until the season close.
</p>
{/if}
<p>
If you're using the provided foundry project, you can find can your player artifacts in the <tt>/out</tt> folder.
You can either drop your player's compiled (JSON) artifact file onto the text box below or you can manually paste the hex bytecode yourself.
If you're developing in the provided foundry project, you can find can your player artifacts in the <tt>/out</tt> folder under a folder of the same name as your contract file.
</p>
<p>
If you're providing your code manually, make sure you provide the <em>undeployed</em> bytecode and not the "deployed" one. These are typically named <tt>bytecode</tt> and <tt>deployedBytecode</tt>, respectively, in compiler artifacts.
If you're inputing your code manually, make sure you provide the <em>undeployed</em> bytecode and not the "deployed" one. These are typically named <tt>bytecode</tt> and <tt>deployedBytecode</tt>, respectively, in compiler artifacts.
</p>
<div>
<form on:submit|preventDefault={onSubmitCode} class="submit-bytecode">
Expand All @@ -401,16 +443,17 @@
aria-busy={submittingCodeState instanceof Promise}
disabled={submittingCodeState instanceof Promise}
>
{#if typeof(submittingCodeState) === 'string' && submittingCodeState !== '0x'}
Submitted!
{:else}
Submit
{/if}
</button>
{#if submittingCodeState instanceof Error}
<div class="error">
{getFriendlyErrorMsg(submittingCodeState)}
</div>
{:else if typeof(submittingCodeState) === 'string' && submittingCodeState !== '0x'}
<div class="success">
Submitted!
</div>
{/if}
</form>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/routes/players/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
ol {
max-width: min-content;
padding-inline-start: 0;
}
li {
display: flex;
Expand Down
2 changes: 1 addition & 1 deletion src/routes/register/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
<Page title="Register Merchant">
<Lede>
<h1>Registration</h1>
<p>Players must have a valid Github account to register. We may reach out to you about the contest (look for an "@dragonfly.xyz" email), so please make sure the email attached to the account is correct and reachable. We won't share this information with other parties.</p>
<p>Players must have a valid Github account to register. We may need to reach out to you about the contest (look for an "@dragonfly.xyz" email), so please make sure the email attached to the account is correct and reachable.</p>
</Lede>
{#if !authInfo}
<section>
Expand Down
2 changes: 1 addition & 1 deletion src/routes/tournament/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ import { page } from "$app/stores";
{#if data.type == 'scrimmage'}Market Day{:else}Grand Faire{/if} Summary
</h1>
<div>
Time: {data.time.toISOString()}
Time: {data.time.toLocaleDateString()} {data.time.toLocaleTimeString()}
</div>
<div>
Season: {data.season + 1}
Expand Down
Loading

0 comments on commit 5c41730

Please sign in to comment.