Skip to content

Commit

Permalink
Merge pull request #1 from calimero-network/feat--add-logic-fundamentals
Browse files Browse the repository at this point in the history
  • Loading branch information
frdomovic authored Nov 14, 2024
2 parents 115e106 + 0849be5 commit 43cb8e6
Show file tree
Hide file tree
Showing 14 changed files with 1,237 additions and 307 deletions.
5 changes: 3 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"version": "0.0.0",
"private": true,
"type": "module",
"homepage": "https://calimero-network.github.io/core-app-template/",
"homepage": "https://calimero-network.github.io/demo-blockchain-integrations/",
"dependencies": {
"@calimero-is-near/calimero-p2p-sdk": "0.0.41",
"@calimero-is-near/calimero-p2p-sdk": "0.1.2",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"axios": "^1.6.7",
Expand All @@ -28,6 +28,7 @@
"@typescript-eslint/eslint-plugin": "^7.13.0",
"@typescript-eslint/parser": "^7.13.0",
"@vitejs/plugin-react": "^4.2.1",
"bs58": "^6.0.0",
"concurrently": "^7.3.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
Expand Down
47 changes: 41 additions & 6 deletions app/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { getNodeUrl } from './utils/node';
export default function App() {
return (
<AccessTokenWrapper getNodeUrl={getNodeUrl}>
<BrowserRouter basename="/core-app-template/">
<BrowserRouter basename="/demo-blockchain-integrations/">
<Routes>
<Route path="/" element={<SetupPage />} />
<Route path="/auth" element={<Authenticate />} />
Expand Down
68 changes: 54 additions & 14 deletions app/src/api/clientApi.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,67 @@
import { ApiResponse } from '@calimero-is-near/calimero-p2p-sdk';

export interface GetCountResponse {
count: number;
export interface Message {
id: String;
proposal_id: String;
author: String;
text: String;
created_at: String;
}

export interface IncreaseCountRequest {
count: number;
export interface GetProposalMessagesRequest {
// proposalId: String;
proposal_id: String;
}

export interface IncreaseCountResponse {}
export interface GetProposalMessagesResponse {
messages: Message[];
}

export interface SendProposalMessageRequest {
// proposalId: String;
proposal_id: String;
message: Message;
}

export interface SendProposalMessageResponse {
result: boolean;
}

export interface CreateProposalRequest {
receiver: String;
}

export interface CreateProposalResponse {
proposal_id: String;
}

export interface ResetCounterResponse {}
export interface ApproveProposalRequest {
proposal_id: string;
}

export interface ApproveProposalResponse {
success: boolean;
}

export enum ClientMethod {
GET_COUNT = 'get_count',
INCREASE_COUNT = 'increase_count',
RESET = 'reset',
GET_PROPOSAL_MESSAGES = 'get_proposal_messages',
SEND_PROPOSAL_MESSAGE = 'send_proposal_messages',
CREATE_PROPOSAL_MESSAGES = 'create_new_proposal',
APPROVE_PROPOSAL_MESSAGE = 'approve_proposal',
}

export interface ClientApi {
getCount(): ApiResponse<GetCountResponse>;
increaseCount(
params: IncreaseCountRequest,
): ApiResponse<IncreaseCountResponse>;
reset(): ApiResponse<ResetCounterResponse>;
//Cali Storage
getProposalMessages(
proposalsRequest: GetProposalMessagesRequest,
): ApiResponse<GetProposalMessagesResponse>;
sendProposalMessage(
sendMessageRequest: SendProposalMessageRequest,
): ApiResponse<SendProposalMessageResponse>;
createProposal(
request: CreateProposalRequest,
): ApiResponse<CreateProposalResponse>;
approveProposal(
request: ApproveProposalRequest,
): ApiResponse<ApproveProposalResponse>;
}
78 changes: 78 additions & 0 deletions app/src/api/contractApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { ApiResponse } from '@calimero-is-near/calimero-p2p-sdk';
import { GetProposalsRequest } from './dataSource/ContractApiDataSource';

export interface ContextDetails {}

export interface Members {
publicKey: String;
}

export interface ProposalAction {
scope: string;
params: {
amount: number;
receiver_id: string;
};
}

export interface ContractProposal {
id: string;
author_id: string;
actions: ProposalAction[];
}

//
export interface CalimeroProposalMetadata {}

export interface ContextDetails {}

export interface Members {
publicKey: String;
}

export interface Message {
publicKey: String;
}

export interface ApprovalsCount {
proposal_id: string;
num_approvals: number;
}

export interface ContractApi {
//Contract
getContractProposals(
request: GetProposalsRequest,
): ApiResponse<ContractProposal[]>;
getNumOfProposals(): ApiResponse<number>;
getProposalApprovals(proposalId: String): ApiResponse<ApprovalsCount>;
getContextDetails(contextId: String): ApiResponse<ContextDetails>;
getContextMembers(): ApiResponse<Members[]>;
getContextMembersCount(): ApiResponse<number>;
}

// async removeProposal(proposalId: String): ApiResponse<boolean> {
// return await this.client.delete<boolean>(
// `${this.endpoint}/admin-api/contexts/${this.contextId}/proposals/${proposalId}`,
// );
// }

// async getProposalMessage(
// proposalId: String,
// messageId: String,
// ): ApiResponse<Message> {
// return await this.client.get<Message>(
// `${this.endpoint}/admin-api/contexts/${this.contextId}/proposals/${proposalId}/messages/${messageId}`,
// );
// }

// async getProposalMessages(proposalId: String): ApiResponse<Message[]> {
// return await this.client.get<Message[]>(
// `${this.endpoint}/admin-api/contexts/${this.contextId}/proposals/${proposalId}/messages`,
// );
// }
// async approveProposal(proposalId: String): ApiResponse<boolean> {
// return await this.client.post<boolean>(
// `${this.endpoint}/admin-api/contexts/${this.contextId}/proposals/${proposalId}/vote`,
// );
// }
Loading

0 comments on commit 43cb8e6

Please sign in to comment.