-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83497f9
commit 49ca15e
Showing
25 changed files
with
318 additions
and
287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"semi": true, | ||
"trailingComma": "none", | ||
"singleQuote": true, | ||
"printWidth": 80 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export const RootLocation = '/'; | ||
export const GameLocation = '/game'; | ||
export const GameLocation = '/game'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,37 @@ | ||
import gql from 'fake-tag'; | ||
|
||
export const BattleshipGameDetails = gql` | ||
fragment BattleshipGameDetails on BattleshipGame { | ||
id | ||
status | ||
totalShots | ||
winner | ||
} | ||
` | ||
fragment BattleshipGameDetails on BattleshipGame { | ||
id | ||
status | ||
totalShots | ||
winner | ||
} | ||
`; | ||
|
||
export const ENSDetails = gql` | ||
fragment ENSDetails on Account { | ||
domains(first: 1) { | ||
labelhash | ||
labelName | ||
name | ||
resolver { | ||
texts | ||
} | ||
owner { | ||
id | ||
} | ||
} | ||
fragment ENSDetails on Account { | ||
domains(first: 1) { | ||
labelhash | ||
labelName | ||
name | ||
resolver { | ||
texts | ||
} | ||
owner { | ||
id | ||
} | ||
} | ||
` | ||
} | ||
`; | ||
|
||
export const ShotDetails = gql` | ||
fragment ShotDetails on Shot { | ||
id | ||
game { | ||
id | ||
} | ||
hit | ||
turn | ||
fragment ShotDetails on Shot { | ||
id | ||
game { | ||
id | ||
} | ||
` | ||
hit | ||
turn | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,36 @@ | ||
import gql from 'fake-tag'; | ||
import { ENSDetails } from './fragments'; | ||
import { CLIENTS } from './client'; | ||
import { GetEnsDomainsQuery, GetEnsDomainsQueryVariables } from './autogen/types'; | ||
import { | ||
GetEnsDomainsQuery, | ||
GetEnsDomainsQueryVariables | ||
} from './autogen/types'; | ||
|
||
const ensDomainQuery = gql` | ||
query GetENSDomains( | ||
$limit: Int! | ||
$addresses: [ID!] | ||
) { | ||
accounts ( | ||
first: $limit | ||
where: {id_in: $addresses} | ||
) { | ||
...ENSDetails | ||
} | ||
query GetENSDomains($limit: Int!, $addresses: [ID!]) { | ||
accounts(first: $limit, where: { id_in: $addresses }) { | ||
...ENSDetails | ||
} | ||
${ENSDetails} | ||
` | ||
} | ||
${ENSDetails} | ||
`; | ||
|
||
export const getENSDomains = async (limit: number, addresses: string[]): Promise<GetEnsDomainsQuery | null> => { | ||
const { data, error } = await CLIENTS[1].query<GetEnsDomainsQuery, GetEnsDomainsQueryVariables>(ensDomainQuery, { limit, addresses }).toPromise() | ||
if (!data) { | ||
if (error) { | ||
throw error; | ||
} | ||
|
||
return null; | ||
export const getENSDomains = async ( | ||
limit: number, | ||
addresses: string[] | ||
): Promise<GetEnsDomainsQuery | null> => { | ||
const { data, error } = await CLIENTS[1] | ||
.query<GetEnsDomainsQuery, GetEnsDomainsQueryVariables>(ensDomainQuery, { | ||
limit, | ||
addresses | ||
}) | ||
.toPromise(); | ||
if (!data) { | ||
if (error) { | ||
throw error; | ||
} | ||
return data; | ||
} | ||
|
||
return null; | ||
} | ||
return data; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,38 @@ | ||
import gql from 'fake-tag'; | ||
import { BattleshipGameDetails } from './fragments'; | ||
import { CLIENTS } from './client'; | ||
import { GameStatus, GetBattlesipGamesQuery, GetBattlesipGamesQueryVariables } from './autogen/types'; | ||
import { | ||
GameStatus, | ||
GetBattleshipGamesQuery, | ||
GetBattleshipGamesQueryVariables | ||
} from './autogen/types'; | ||
|
||
const battleshipGameQuery = gql` | ||
query GetBattlesipGames( | ||
$limit: Int! | ||
$status: GameStatus! | ||
) { | ||
battleshipGames ( | ||
first: $limit | ||
where: {status: $status} | ||
) { | ||
...BattleshipGameDetails | ||
} | ||
query GetBattleshipGames($limit: Int!, $status: GameStatus!) { | ||
battleshipGames(first: $limit, where: { status: $status }) { | ||
...BattleshipGameDetails | ||
} | ||
${BattleshipGameDetails} | ||
` | ||
} | ||
${BattleshipGameDetails} | ||
`; | ||
|
||
export const getGames = async (chainId: number, limit: number, status: GameStatus): Promise<GetBattlesipGamesQuery | null> => { | ||
const { data, error } = await CLIENTS[chainId].query<GetBattlesipGamesQuery, GetBattlesipGamesQueryVariables>(battleshipGameQuery, { limit, status }).toPromise() | ||
if (!data) { | ||
if (error) { | ||
throw error; | ||
} | ||
|
||
return null; | ||
export const getGames = async ( | ||
chainId: number, | ||
limit: number, | ||
status: GameStatus | ||
): Promise<GetBattleshipGamesQuery | null> => { | ||
const { data, error } = await CLIENTS[chainId] | ||
.query<GetBattleshipGamesQuery, GetBattleshipGamesQueryVariables>( | ||
battleshipGameQuery, | ||
{ limit, status } | ||
) | ||
.toPromise(); | ||
if (!data) { | ||
if (error) { | ||
throw error; | ||
} | ||
return data; | ||
} | ||
|
||
return null; | ||
} | ||
return data; | ||
}; |
Oops, something went wrong.