diff --git a/app/src/api/clientApi.ts b/app/src/api/clientApi.ts index add8b33..68042e9 100644 --- a/app/src/api/clientApi.ts +++ b/app/src/api/clientApi.ts @@ -20,8 +20,7 @@ export interface GetProposalMessagesResponse { export interface SendProposalMessageRequest { // proposalId: String; proposal_id: String; - author: String; - text: String; + message: Message; } export interface SendProposalMessageResponse { @@ -46,7 +45,7 @@ export interface ApproveProposalResponse { export enum ClientMethod { GET_PROPOSAL_MESSAGES = 'get_proposal_messages', - SEND_PROPOSAL_MESSAGE = 'send_proposal_message', + SEND_PROPOSAL_MESSAGE = 'send_proposal_messages', CREATE_PROPOSAL_MESSAGES = 'create_new_proposal', APPROVE_PROPOSAL_MESSAGE = 'approve_proposal', } diff --git a/app/src/api/dataSource/LogicApiDataSource.ts b/app/src/api/dataSource/LogicApiDataSource.ts index 49c54b9..4f20459 100644 --- a/app/src/api/dataSource/LogicApiDataSource.ts +++ b/app/src/api/dataSource/LogicApiDataSource.ts @@ -181,7 +181,7 @@ export class LogicApiDataSource implements ClientApi { return { error }; } - const response = await getJsonRpcClient().mutate< + const response = await getJsonRpcClient().execute< SendProposalMessageRequest, SendProposalMessageResponse >( diff --git a/app/src/pages/home/index.tsx b/app/src/pages/home/index.tsx index b381b3d..bd783a2 100644 --- a/app/src/pages/home/index.tsx +++ b/app/src/pages/home/index.tsx @@ -21,6 +21,7 @@ import { import { getStorageApplicationId } from '../../utils/node'; import { clearApplicationId, + getJWTObject, getStorageExecutorPublicKey, } from '../../utils/storage'; import { useNavigate } from 'react-router-dom'; @@ -186,11 +187,16 @@ export default function HomePage() { async function sendProposalMessage(request: SendProposalMessageRequest) { const params: SendProposalMessageRequest = { proposal_id: request.proposal_id, - author: request.author, - text: request.text, + message: { + id: request.message.id, + proposal_id: request.proposal_id, + author: request.message.author, + text: request.message.text, + created_at: new Date().toISOString(), + }, }; - const result: ResponseData = - await new LogicApiDataSource().getProposalMessages(params); + const result: ResponseData = + await new LogicApiDataSource().sendProposalMessage(params); if (result?.error) { console.error('Error:', result.error); window.alert(`${result.error.message}`); @@ -401,8 +407,13 @@ export default function HomePage() { onClick={() => { sendProposalMessage({ proposal_id: selectedProposal.id, - author: getStorageExecutorPublicKey(), - text: 'test' + Math.random(), + message: { + id: 'test' + Math.random(), + proposal_id: selectedProposal.id, + author: getJWTObject()?.executor_public_key, + text: 'test' + Math.random(), + created_at: new Date().toISOString(), + }, } as SendProposalMessageRequest); }} >