diff --git a/fc-community-backend/apps/api/src/app.controller.ts b/fc-community-backend/apps/api/src/app.controller.ts index adf665ee..5c07ef06 100644 --- a/fc-community-backend/apps/api/src/app.controller.ts +++ b/fc-community-backend/apps/api/src/app.controller.ts @@ -12,6 +12,11 @@ import { Headers, } from "@nestjs/common"; import { getNetworkConfig } from "./factchain-core/networks/config"; + +function validateInputAddress(address: string): boolean { + return (/^(0x){1}[0-9a-fA-F]{40}$/i.test(address)); +} + @Controller() export class AppController { constructor(private readonly appService: AppService) {} @@ -38,6 +43,14 @@ export class AppController { @Headers() headers: Record, ): Promise { const network = getNetworkConfig(headers["network"]); + + if (creatorAddress && !validateInputAddress(creatorAddress)) { + throw new Error("Invalid creatorAddress"); + } + if (awaitingRatingBy && !validateInputAddress(awaitingRatingBy)) { + throw new Error("Invalid awaitingRatingBy"); + } + let notes = []; // Double Query Params @@ -90,7 +103,7 @@ export class AppController { @Query("noteUrl") noteUrl: string, @Headers() headers: Record, ): Promise { - const network = getNetworkConfig(headers["Network"]); + const network = getNetworkConfig(headers["network"]); console.log(`Get factchain ID for X note URL ${noteUrl}`); const res = await this.appService.getXNoteID(network, noteUrl); return res; @@ -104,7 +117,7 @@ export class AppController { @Body("content") content: string, @Headers() headers: Record, ): Promise { - const network = getNetworkConfig(headers["Network"]); + const network = getNetworkConfig(headers["network"]); const res = await this.appService.createXNoteMetadata( network, noteUrl, diff --git a/fc-community-extension/src/pages/popup.js b/fc-community-extension/src/pages/popup.js index 191d3692..f6b9433b 100644 --- a/fc-community-extension/src/pages/popup.js +++ b/fc-community-extension/src/pages/popup.js @@ -105,9 +105,13 @@ function FCProfile(props) { } function FCNotes(props) { - const [notes] = createResource(() => - getNotesForAllSocials(props.queryparams) - ); + const [notes] = createResource(props.loggedIn, (loggedIn) => { + if (loggedIn) { + return getNotesForAllSocials(props.queryparams); + } else { + return null; + } + }); return ( @@ -120,7 +124,7 @@ function FCNotes(props) {
to view Factchain notes
- + 0}>
diff --git a/fc-community-extension/src/utils/backend.js b/fc-community-extension/src/utils/backend.js index 475477e8..c61f61a9 100644 --- a/fc-community-extension/src/utils/backend.js +++ b/fc-community-extension/src/utils/backend.js @@ -72,6 +72,7 @@ export const getXNoteId = async (noteUrl) => { method: 'GET', headers: { 'Content-Type': 'application/json', + network: 'ETHEREUM_SEPOLIA', }, }); if (response.status === 404) { @@ -98,6 +99,7 @@ export const createXNoteId = async (noteUrl, content) => { method: 'POST', headers: { 'Content-Type': 'application/json', + network: 'ETHEREUM_SEPOLIA', }, body: JSON.stringify({ noteUrl, content }), });