Skip to content

Commit

Permalink
Merge pull request #40 from gridcoin-community/dev
Browse files Browse the repository at this point in the history
release
  • Loading branch information
gridcat authored Oct 21, 2022
2 parents c79b042 + 10b9323 commit 0daa870
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
# Gridcoin Stamp Service

Monorepo for the https://stamp.gridcoin.club service.

Tor address: http://u4embjw2uzwpdubgm72ywbmixte4kqgwurc4r4rp6elhlokutdfsy4id.onion

1 change: 1 addition & 0 deletions packages/grc-stamp-frontend/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
NEXT_PUBLIC_API_URL=/api
NEXT_PUBLIC_API_URL_SERVER=https://stamp.gridcoin.club/api
NEXT_PUBLIC_EXPLORER_BLOCK_URL=https://gridcoinstats.eu/block/[data]
NEXT_PUBLIC_EXPLORER_TX_URL=https://gridcoinstats.eu/tx/[data]
NEXT_PUBLIC_TRACK=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ export function StampsList({ stamps }: Props) {
<span>
Hash:
{' '}
{stamp.hash}
<Link href={`/proof/${stamp.hash}`}>
{stamp.hash}
</Link>
</span>
<br />
<span>
Expand Down
2 changes: 1 addition & 1 deletion packages/grc-stamp-frontend/src/pages/proof/[hash].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type ServerSideProps = { props: Partial<Props> } | { notFound: boolean };
export async function getServerSideProps(context: Context): Promise<ServerSideProps> {
const { hash } = context.params;
const repository = new StampRepository();
const stamp = await repository.findStampByHash(hash);
const stamp = await repository.findStampByHash(hash, true);

if (!stamp || !stamp.isFinished()) {
return {
Expand Down
13 changes: 9 additions & 4 deletions packages/grc-stamp-frontend/src/repositories/StampsRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,16 @@ export class StampRepository {
* Even if somebody will craf the transaction manually,
* server must return the very first record and ignore the rest
*/
public async findStampByHash(hash: string): Promise<StampEntity | null> {
public async findStampByHash(hash: string, isServer = false): Promise<StampEntity | null> {
const store = new Store();
const { data: result } = await this.httpClient.get<ApiResponse & { data: StampRawData[] }>(
`${process.env.NEXT_PUBLIC_API_URL}/stamps?filter[hash]=${hash}`,
);
let url = `stamps?filter[hash]=${hash}`;
if (isServer) {
url = `${process.env.NEXT_PUBLIC_API_URL_SERVER}/${url}`;
} else {
url = `${process.env.NEXT_PUBLIC_API_URL}/${url}`;
}
const { data: result } = await this.httpClient.get<ApiResponse & { data: StampRawData[] }>(url);

if (!result?.meta?.count) {
return null;
}
Expand Down

0 comments on commit 0daa870

Please sign in to comment.