-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
9 changed files
with
924 additions
and
0 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,12 @@ | ||
# EditorConfig is awesome: https://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
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,12 @@ | ||
env: | ||
browser: true | ||
es2021: true | ||
extends: | ||
- react-app | ||
- plugin:prettier/recommended | ||
parserOptions: | ||
ecmaVersion: latest | ||
sourceType: module | ||
plugins: | ||
- testing-library | ||
rules: {} |
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,24 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
Large diffs are not rendered by default.
Oops, something went wrong.
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,108 @@ | ||
<p align="center" width="100%"> | ||
<img src="https://developer.vocdoni.io/img/vocdoni_logotype_full_white.svg" /> | ||
</p> | ||
|
||
<p align="center" width="100%"> | ||
<a href="https://github.com/vocdoni/ui-components/commits/main/"><img src="https://img.shields.io/github/commit-activity/m/vocdoni/ui-components" /></a> | ||
<a href="https://github.com/vocdoni/ui-components/issues"><img src="https://img.shields.io/github/issues/vocdoni/ui-components" /></a> | ||
<a href="https://github.com/vocdoni/ui-components/actions/workflows/test.yml/"><img src="https://github.com/vocdoni/ui-components/actions/workflows/test.yml/badge.svg" /></a> | ||
<a href="https://discord.gg/xFTh8Np2ga"><img src="https://img.shields.io/badge/discord-join%20chat-blue.svg" /></a> | ||
<a href="https://twitter.com/vocdoni"><img src="https://img.shields.io/twitter/follow/vocdoni.svg?style=social&label=Follow" /></a> | ||
</p> | ||
|
||
|
||
<div align="center"> | ||
Vocdoni is the first universally verifiable, censorship-resistant, anonymous, and self-sovereign governance protocol. <br /> | ||
Our main aim is a trustless voting system where anyone can speak their voice and where everything is auditable. <br /> | ||
We are engineering building blocks for a permissionless, private and censorship resistant democracy. | ||
<br /> | ||
<a href="https://developer.vocdoni.io/"><strong>Explore the developer portal »</strong></a> | ||
<br /> | ||
<h3>More About Us</h3> | ||
<a href="https://vocdoni.io">Vocdoni Website</a> | ||
| | ||
<a href="https://vocdoni.app">Web Application</a> | ||
| | ||
<a href="https://explorer.vote/">Blockchain Explorer</a> | ||
| | ||
<a href="https://law.mit.edu/pub/remotevotingintheageofcryptography/release/1">MIT Law Publication</a> | ||
| | ||
<a href="https://chat.vocdoni.io">Contact Us</a> | ||
<br /> | ||
<h3>Key Repositories</h3> | ||
<a href="https://github.com/vocdoni/vocdoni-node">Vocdoni Node</a> | ||
| | ||
<a href="https://github.com/vocdoni/vocdoni-sdk/">Vocdoni SDK</a> | ||
| | ||
<a href="https://github.com/vocdoni/ui-components">UI Components</a> | ||
| | ||
<a href="https://github.com/vocdoni/ui-scaffold">Application UI</a> | ||
| | ||
<a href="https://github.com/vocdoni/census3">Census3</a> | ||
</div> | ||
|
||
# @vocdoni/extended-sdk | ||
|
||
This package is an extension of the Vocdoni SDK client that implements some functions that are not included on the | ||
original SDK. These functions are related to Vochain statistics, blocks, transactions etc... Which are not intended to be | ||
used for common users. | ||
|
||
To use it add the custom client on the provider like this: | ||
|
||
```tsx | ||
import { ExtendedSDKClient } from '@vocdoni/extended-sdk'; | ||
import { ClientProvider } from '@vocdoni/chakra-components'; | ||
|
||
const VocdoniSdkProvider = ({ children }: { children: ReactNode }) => { | ||
const environment = VOCDONI_ENVIRONMENT as EnvOptions; | ||
|
||
const sdkClient = new ExtendedSDKClient({ | ||
env: environment, | ||
}); | ||
|
||
return ( | ||
<ClientProvider client={sdkClient}> | ||
{children} | ||
</ClientProvider> | ||
); | ||
}; | ||
``` | ||
|
||
And then, at places you want to use it, specify the client type like: | ||
|
||
```tsx | ||
const { client } = useClient<ExtendedSDKClient>(); | ||
``` | ||
|
||
## Disclaimer | ||
|
||
This project is a WIP and is subject to continuous changes during its | ||
development. We encourage you to review this repository and the developer portal for any changes. | ||
|
||
## Contributing | ||
|
||
While we welcome contributions from the community, we do not track all of our issues on Github and we may not have the resources to onboard developers and review complex pull requests. That being said, there are multiple ways you can get involved with the project. | ||
|
||
Please review our [development guidelines](https://developer.vocdoni.io/development-guidelines). | ||
|
||
## License | ||
|
||
This repository is licensed under the [GNU Affero General Public License v3.0.](./LICENSE) | ||
|
||
Vocdoni UI React Components | ||
Copyright (C) 2024 Vocdoni Association | ||
|
||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
|
||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
[](https://www.gnu.org/licenses/agpl-3.0) |
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,31 @@ | ||
{ | ||
"name": "@vocdoni/extended-sdk", | ||
"version": "0.0.1", | ||
"license": "GPL-3.0-or-later", | ||
"homepage": "https://github.com/vocdoni/ui-components/tree/main/packages/extended-sdk#readme", | ||
"bugs": "https://github.com/vocdoni/ui-components/issues", | ||
"repository": "github.com:vocdoni/ui-components", | ||
"description": "Vocdoni's extended SDK", | ||
"keywords": [ | ||
"SDK", | ||
"context", | ||
"blockchain", | ||
"voting" | ||
], | ||
"type": "module", | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"lint": "tsc", | ||
"build": "tsup src --dts", | ||
"prepack": "clean-package", | ||
"clean": "rm -rf dist .turbo node_modules", | ||
"postpack": "mv -fv package.json.backup package.json" | ||
}, | ||
"main": "src/index.ts", | ||
"peerDependencies": { | ||
"@vocdoni/sdk": "~0.8.0" | ||
}, | ||
"clean-package": "../../clean-package.config.json" | ||
} |
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,53 @@ | ||
import { | ||
AccountAPI, | ||
ChainAPI, | ||
ClientOptions, | ||
ElectionAPI, | ||
IChainBlockInfoResponse, | ||
VocdoniSDKClient, | ||
VoteAPI, | ||
} from '@vocdoni/sdk' | ||
|
||
export default class ExtendedSDKClient extends VocdoniSDKClient { | ||
constructor(opts: ClientOptions) { | ||
super(opts) | ||
} | ||
|
||
txInfo = (txHash: string) => ChainAPI.txInfo(this.url, txHash) | ||
txInfoByBlock = (blockHeight: number, txIndex: number) => ChainAPI.txInfoByBlock(this.url, blockHeight, txIndex) | ||
txList = (page?: number) => ChainAPI.txList(this.url, page) | ||
organizationList = (page?: number, organizationId?: string) => | ||
ChainAPI.organizationList(this.url, page, organizationId) | ||
organizationCount = () => ChainAPI.organizationCount(this.url) | ||
organizationElectionsList = (organizationId: string, page?: number) => | ||
AccountAPI.electionsList(this.url, organizationId, page) | ||
validatorsList = () => ChainAPI.validatorsList(this.url) | ||
chainInfo = () => ChainAPI.info(this.url) | ||
blockByHash = (hash: string) => ChainAPI.blockByHash(this.url, hash) | ||
voteInfo = (voteId: string) => VoteAPI.info(this.url, voteId) | ||
electionVotesList = (electionId: string, page?: number) => ElectionAPI.votesList(this.url, electionId, page) | ||
electionVotesCount = (electionId: string) => ElectionAPI.votesCount(this.url, electionId) | ||
electionKeys = (electionId: string) => ElectionAPI.keys(this.url, electionId) | ||
electionList = (page: number, electionId?: string, organizationId?: string, status?: any, withResults?: boolean) => | ||
ElectionAPI.electionsList(this.url, page, { | ||
electionId, | ||
organizationId, | ||
status, | ||
withResults, | ||
}) | ||
blockTransactions = (height: number, page?: number) => ChainAPI.blockTransactions(this.url, height, page) | ||
blockByHeight = (height: number) => ChainAPI.blockByHeight(this.url, height) | ||
// todo: this method will be fixed backend side, see https://github.com/vocdoni/interoperability/issues/33 | ||
blockList = (from: number, listSize: number = 10): Promise<IChainBlockInfoResponse[]> => { | ||
const promises: Promise<IChainBlockInfoResponse>[] = [] | ||
// If is not a number bigger than 0 | ||
if (isNaN(from)) return Promise.all(promises) | ||
for (let i = 0; i < listSize; i++) { | ||
if (from + i > 0) promises.push(this.blockByHeight(from + i)) | ||
} | ||
return Promise.all(promises).then((blockInfo) => { | ||
// flatten the array[][] into array[] | ||
return blockInfo.reduce((prev, cur) => prev.concat(cur), []).reverse() | ||
}) | ||
} | ||
} |
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 @@ | ||
export * from './client' | ||
export * from './election' | ||
export * from './i18n' | ||
export * from './organization' | ||
export type { ErrorPayload, RecursivePartial } from './types' | ||
export * from './utils' |
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,4 @@ | ||
{ | ||
"extends": "tsconfig/react-library.json", | ||
"include": ["src"] | ||
} |