diff --git a/backend/.sqlx/query-c8d24ca519a169649988c11cd219c72e368b507d97cf30946aa188deff70b9c3.json b/backend/.sqlx/query-c8d24ca519a169649988c11cd219c72e368b507d97cf30946aa188deff70b9c3.json
new file mode 100644
index 0000000..66d5b5d
--- /dev/null
+++ b/backend/.sqlx/query-c8d24ca519a169649988c11cd219c72e368b507d97cf30946aa188deff70b9c3.json
@@ -0,0 +1,42 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT \n id,\n CAST(utxo_subject_amount(era, cbor, decode($2::varchar, 'hex')) AS INTEGER) AS fuel,\n CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 2 ->> 'bytes' AS TEXT) AS ship_token_name,\n CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 3 ->> 'bytes' AS TEXT) AS pilot_token_name\n FROM \n utxos\n WHERE \n utxo_address(era, cbor) = from_bech32($3::varchar)\n AND utxo_has_policy_id(era, cbor, decode($1::varchar, 'hex'))\n AND ABS(CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 0 ->> 'int' AS INTEGER)) + ABS(CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 1 ->> 'int' AS INTEGER)) = 0\n order by slot ASC\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "id",
+ "type_info": "Varchar"
+ },
+ {
+ "ordinal": 1,
+ "name": "fuel",
+ "type_info": "Int4"
+ },
+ {
+ "ordinal": 2,
+ "name": "ship_token_name",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 3,
+ "name": "pilot_token_name",
+ "type_info": "Text"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Varchar",
+ "Varchar",
+ "Varchar"
+ ]
+ },
+ "nullable": [
+ false,
+ null,
+ null,
+ null
+ ]
+ },
+ "hash": "c8d24ca519a169649988c11cd219c72e368b507d97cf30946aa188deff70b9c3"
+}
diff --git a/backend/src/main.rs b/backend/src/main.rs
index db016c4..769c45b 100644
--- a/backend/src/main.rs
+++ b/backend/src/main.rs
@@ -458,12 +458,12 @@ impl QueryRoot {
Ok(map_objects)
}
- async fn leaderboard(
+ async fn leaderboard_players(
&self,
ctx: &Context<'_>,
spacetime_policy_id: String,
- fuel_policy_id: String,
- ship_address: String,
+ pellet_policy_id: String,
+ spacetime_address: String,
) -> Result
- Shipyard Policy | { challenge.shipyardPolicyId } + Spacetime Policy | { challenge.spacetimePolicyId }
{ challenge.label }
diff --git a/frontend/src/pages/leaderboard/index.tsx b/frontend/src/pages/leaderboard/index.tsx
index 9b85400..533d6b2 100644
--- a/frontend/src/pages/leaderboard/index.tsx
+++ b/frontend/src/pages/leaderboard/index.tsx
@@ -4,9 +4,9 @@ import { useChallengeStore, Challenge } from '@/stores/challenge';
const PAGE_SIZE = 10;
-const GET_LEADERBOARD_RECORDS = gql`
- query Leaderboard($shipyardPolicyId: String, $fuelPolicyId: String, $shipAddress: String) {
- leaderboard(shipyardPolicyId: $shipyardPolicyId, fuelPolicyId: $fuelPolicyId, shipAddress: $shipAddress) {
+const GET_LEADERBOARD_PLAYERS_RECORDS = gql`
+ query LeaderboardPlayers($spacetimePolicyId: String, $pelletPolicyId: String, $spacetimeAddress: String) {
+ leaderboardPlayers(spacetimePolicyId: $spacetimePolicyId, pelletPolicyId: $pelletPolicyId, spacetimeAddress: $spacetimeAddress) {
ranking,
address,
shipName,
@@ -17,8 +17,21 @@ const GET_LEADERBOARD_RECORDS = gql`
}
`;
+const GET_LEADERBOARD_WINNERS_RECORDS = gql`
+ query LeaderboardWinners($spacetimePolicyId: String, $pelletPolicyId: String, $spacetimeAddress: String) {
+ leaderboardWinners(spacetimePolicyId: $spacetimePolicyId, pelletPolicyId: $pelletPolicyId, spacetimeAddress: $spacetimeAddress) {
+ ranking,
+ address,
+ shipName,
+ pilotName,
+ fuel
+ }
+ }
+`;
+
interface LeaderboardQueryResult {
- leaderboard: LeaderboardRecord[];
+ leaderboardPlayers: LeaderboardRecord[];
+ leaderboardWinners: LeaderboardRecord[];
}
interface LeaderboardRecord {
@@ -31,6 +44,7 @@ interface LeaderboardRecord {
}
interface RecordProps {
+ leaderboard: boolean;
challenge: Challenge;
record: LeaderboardRecord;
}
@@ -89,27 +103,35 @@ const LeaderboardRow: React.FunctionComponent
- {`Displaying ${offset+1}-${offset+PAGE_SIZE} of ${data && data.leaderboard ? data.leaderboard.length-3 : 0}`}
+ {getPagination()}
{props.record.fuel}
-
-
- {`${props.record.distance}km`}
-
-
+ {props.leaderboard && (
+
+
+ {props.record.distance}
+
+
+ )}
);
export default function Leaderboard() {
+ const [ offset, setOffset ] = useState
- DISTANCE TO ASTERIA
+ setLeaderboard(!leaderboard) }>
+ {`ASTERIA ${ leaderboard ? 'PLAYERS' : 'WINNERS' } >`}
+
- {['Ranking', 'Address', 'Ship name', 'Pilot name', 'Fuel', 'Distance'].map(header =>
+ {getColumns().map(header =>
{getPageData().map(record =>
- {header}
)}