social-tw-website's People
Forkers
uranuslin lisooo790926 ottbunn iverjisty chentihe badukwei nooma-42 foodchain1028 andy78644 jason-ntu chnejohnson 0xdononymoussocial-tw-website's Issues
Circom 2.1.0 Anonymous Components and Tuples
See: https://docs.circom.io/circom-language/anonymous-components-and-tuples/
Now we assigned every input into another templates with
template A(n){
signal input a, b;
signal output c;
c <== a*b;
}
template B(n){
signal input in[n];
signal out;
component temp_a = A(n);
temp_a.a <== in[0];
temp_a.b <== in[1];
out <== temp_a.c;
}
component main = B(2);
with anonymous components, we can assign each input with
template A(n){
signal input a, b;
signal output c;
c <== a*b;
}
template B(n){
signal input in[n];
signal out <== A(n)(in[0],in[1]);
}
component main = B(2);
which will improve the readability and reduce lines.
Update Readme
We need to update the current readme to help developers install/run the repo locally
- Introduction to the project (unirep social taiwan)
- How to install
- How to build
- How to run contracts/relay/frontend
- How to run test/lint
- How to contribute to this project
- How to contact us (discord, open issues, ....)
- (optional) a banner
- (optional) if CI/CD succeeds
- (optional) package version
Trigger CI when push to main (not only pull_request)
Is your feature request related to a problem? Please describe.
The CI only runs when pull_request, but we would like it to run when push to main branch.
Describe the solution you'd like
Update the github actions.
UnirepApp.test.ts Refactor
The functions in the test is still not modularized yet and @ryanycw suggested we could use a util.ts
file to put the functions which can be reused.
Moreover, I deem we should refactor the test file into different section/ files to make the assignments much easier in the future.
abstract code inside async load()
Is your feature request related to a problem? Please describe.
load()
is in context/User.ts
can be tricking during testing. Test case have to copy from load()
and replace some code manually
Describe the solution you'd like
Abstract the code in User.ts
from
const identity = new Identity(this.signature)
const {UNIREP_ADDRESS, APP_ADDRESS, ETH_PROVIDER_URL} = await fetch(
`${SERVER}/api/config`
).then((r) => r.json())
.......
Describe alternatives you've considered
N/A
Additional context
Do this after #38 merged
[contract][relay] verify state tree root, caller, epoch
In 2.0.0-beta-4, we move out the EpochKeyVerifier
from Unirep.sol
to minimize the core contract size.
But it doesn't check the state tree root (so users might be able to randomly generated a proof without the current Unirep merkle tree), and current epoch.
See VerifyAndCheckCaller
Suggestion
Contract
social-tw-website/packages/contracts/contracts/UnirepApp.sol
Lines 88 to 92 in 6e45b3b
- Use
verifyAndCheckCaller
to replaceverifyAndCheck
- Check epoch with
attesterCurrentEpoch
- Check state tree root with
attesterStateTreeRootExists
Relay
This check would prevent submitting tx would be reverted and faster respond to clients.
social-tw-website/packages/relay/src/routes/post.ts
Lines 72 to 82 in 6e45b3b
- Check epoch with
synchronizer.loadCurrentEpoch()
- Check state tree root with
synchronizer.stateTreeRootExists
Posting Frontend Tests
Implement the Frontend tests for posting. The following are the tests we discussed.
- Should have test scripts
- Should succeed to post
- Should let user input post contents
- Should let user choose epoch keys(or nonces)
- Should handle error message and return to correct status
Note: All tests should pass CICD
Create signing up loading ui
Is your feature request related to a problem? Please describe.
App should have a loading animation while sign up is progesssing. Let them know the status and block them from posting contents.
Describe the solution you'd like
Follow the design to create one.
Describe alternatives you've considered
Create an loading animation to block the creating component. Users should use see the animation until sign up finished. Then, they can create the contents.
Additional context
None by now.
Update login flow ui
Is your feature request related to a problem? Please describe.
Update the login flow ui
Describe the solution you'd like
Fix the forntend to match ui design
Describe alternatives you've considered
Fix the forntend to match ui design
Posting Smart Contract Tests
Implement the Smart Contracts tests for posting. The following are the tests we discussed.
- Happy Path: Post Success
- Check Event Emit
- Should fail with wrong proof
- Check revert with the right message
- Should fail with unsigned up user
Note: All tests should pass CICD
Wait for the transaction to finalize in relay test
Describe the bug
In #25 the hardhat test won't wait for post transaction to finish. Need to find a way to wait for the transaction to finish. And make sure the synchronizer have get the transaction and update the db.
To Reproduce
yarn relay test
Expected behavior
it('should create a post', async () => {
// FIXME: Look for fuzzer to test content
const testContent = 'test content'
const epochKeyProof = await userState.genEpochKeyProof({
nonce: 0,
})
const res = await fetch(`${HTTP_SERVER}/api/post`, {
method: 'POST',
headers: {
'content-type': 'application/json',
},
body: JSON.stringify(
stringifyBigInts({
content: testContent,
publicSignals: epochKeyProof.publicSignals,
proof: epochKeyProof.proof,
})
),
}).then((r) => r.json())
//expect(res.status).equal(200)
//expect(res.body).('postId')
// TODO: verify post
// [ ] verify transaction
// [ ] fetch post
})
Make sure this test passed with the right checks, finishing the TODO
Additional context
Add any other context about the problem here.
[relay] use abi from `@unirep/contracts/abi`
Suggestion
import ABI from '@unirep-app/contracts/abi/UnirepApp.json'
[Frontend] Loading Bar to prevent cancel edit while posting already
Is your feature request related to a problem? Please describe.
是,我希望【文章點擊送出後,可以蓋一個loading bar或是disable取消編輯的按鈕,避免造成誤會】
若沒有這樣做的話,可能會造成一些混亂的情況,例如發布後按了取消編輯的時候可能是已經送到後端前,那這篇文章將不會被發布;或是可能已經送到後端,那即便點擊取消也會照常發布。實測情況下如果一直發布/取消也會造成網路不穩的Error Message。
Describe the solution you'd like
文章點擊送出後,可以蓋一個loading bar或是disable取消編輯的按鈕。
- loading bar: 可以使用sign up的loading gadget
- disable button:pointerEvents=none 或是 onClick的時候判斷條件。
fresh build find no config
Describe the bug
this happens in post-relay branch and branch rebased on it.
yarn deploy
generates config.ts in root folder, but to build this branch current commit requires this config.ts which doesn't exist if you didn't run yarn deploy
To Reproduce
fresh clone test/post-relay branch and build
Expected behavior
For information, contracts package.json
"scripts": {
"build": "yarn buildVerifier && hardhat compile && yarn abi",
"buildVerifier": "ts-node ./scripts/genVerifier.ts ",
"abi": "ts-node scripts/abi",
"hardhat": "hardhat",
"deploy": "hardhat run scripts/deploy.ts",
yarn deploy
generates config.ts in root folder, but to build this branch current commit requires this config.ts which doesn't exist if you didn't run yarn deploy
Desktop (please complete the following information):
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
Smartphone (please complete the following information):
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
Deployment function can be reused in test
Current Behavior
The contract test copies the deployment code, but there is a function in ../scripts/utils
social-tw-website/packages/contracts/test/UnirepApp.test.ts
Lines 66 to 77 in 6e45b3b
Suggestion
Use the deployApp
function in the contract package
clean up console.log()
Describe the bug
After all tests is finalized, clean up the unused console.log()
Circom installation is wrong
the current readme
https://github.com/social-tw/social-tw-website/blob/main/README.md#1-installation
describes to use npm install -g circom
but circom
in js has been deprecated: https://www.npmjs.com/package/circom
we should use circom in rust to install the latest circom
see: https://docs.circom.io/getting-started/installation/
Login Smart Contract Tests
Implement the Smart Contract tests for login and sign-up. The following are the tests we discussed.
- Should have a test scripts for the signup() function
- it should pass
- should revert if double signup
- should revert if the proof is invalid.
[Frontend] Post ID
Describe the bug
interface Post {
id: string
epochKey: string
content: string
publishedAt: Date
commentCount: number
upCount: number
downCount: number
}
但是後端傳來的Post長這樣
導致我發了一篇新的文章後,那篇文章的Post interface裡id為null,因此點擊Post
不會前往/posts/${id}
。
To Reproduce
- 註冊
- 發文
- 點擊剛剛發佈的那篇文章
- 會看到只能夠前往
/posts/
而非/posts/:id
Expected behavior
- 註冊
- 發文
- 點擊剛剛發佈的那篇文章
- 前往該文章的PostDetail頁面
/posts/${_id}
Desktop (please complete the following information):
- OS: MacOS
- Browser: Chrome
Additional context
順便請問一下,上圖可見回傳的post結構裡還有一個postId
,並且也是list of component的key,但由於皆為從0開始的整數,與範例post產生衝突。因此想請問一下
- 未來會用這個
postId
來辨識post嗎?如果是的話是否要與範例post先做出區隔以免造成bug。 - 若其實是要用
post._id
來辨識post的話,這個postId
存在的意義是?
different commitments between proof and identity
Describe the bug
we use signature(wallet signs the hash user id) as constructor arg of semaphore identity.
when the user signs up, signature will be store at local storage on frontend to initiate the identity.
after signup event emitted, the db will store user signup data.
However, when we refresh the page, we cannot find out the UserSignUp data by the commitment which is derived by the signature. we found out that the commitment is different between the proof and the identity.
To Reproduce
Steps to reproduce the behavior:
- checkout to branch feature/signup-status-ui
- start the server
- navigate to
http://localhost:3000
- finish the sign up flow (clean the local storage if you don't see the twitter login page)
- open the console, refresh the page once you see
has signed up
message
Expected behavior
no error message shows up on the console
Screenshots
the commitment from identity: 21522971102930138771970627849125848578287951763320037973197264532156976505989n
the commitment from db:
2621895226801663766506515946213190338996256122790072923134401166554411614480
Desktop (please complete the following information):
- OS: maxOS
- Browser edge
- Version 116.0.1938.62
Add CI/CD
Either circleci or github actions
-
yarn && yarn build
-
yarn circuits test
-
yarn contracts test
-
yarn relay test
(TODO) -
yarn frontend test
(TODO) -
yarn lint --check
Add husky hooks for lint
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like
A clear and concise description of what you want to happen.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
IPFS local environment setting
Describe the bug
While calling api/post, the bug occurs. The error is about IFPS and some setting with connecting.
To Reproduce
- Login the account
- Enter text to crate post
- Create a post
- See error
Expected behavior
It shouldn't return status 500 when calling api/post
Screenshots
Desktop (please complete the following information):
- OS: [Windows (WSL)]
[CICD] Error when PR execute build and lint
Describe the bug
Raise error when PR CICD
To Reproduce
Steps to reproduce the behavior:
- Raise PR
- Run CI steps
- check the result
Expected behavior
CI should success
Screenshots
[relay] check proof before submitting tx
Similar to #95
In signup router
social-tw-website/packages/relay/src/services/UserService.ts
Lines 93 to 101 in 6e45b3b
There are things we can check before submitting to contract and prevent revert
- check attester ID matches current contract address (
signupProof.attesterId
) - check the identity commitment is not signed up before (
signupProof.identityCommitment
)
Reference: Unirep.sol
Modularize Login/SignUp Test Function
Modularize signUp functions and modify the test to protect the signUp logic
- Modularize signUp functions
- Call signUp function in test methods
- pass the test
[relay] LOAD_POST_COUNT
Suggestion
This can be written in e.g. config.ts
If there are more constant variables, it will be easier to manage
The package required by CICD is not there.
Describe the bug
The current CICD in the release/integrate_0713
branch doesn't work, since the required container registry (ie. image) is not uploaded yet. I need someone with proper permissions (maybe @ryanycw or @NOOMA-42 ?) to push the container registry for me.
To Reproduce
Steps to reproduce the failed CICD:
- Add a PR to
release/integrate_0713
- Click on 'Actions'
- Check the newest action.
- The following four jobs cannot find their container registry: Circuit, Contracts, Relay, Frontend
Expected behavior
The jobs should find the container registry in the path https://github.com/orgs/social-tw/packages
, but currently there is no container registry there. (otherwise one should be able to find it by clicking on the "Packages" tag in the main page)
Screenshots
This is the action that fails due to no container registry.
https://github.com/social-tw/social-tw-website/actions/runs/5950354199/job/16137962401
How to push the container
- Pull the Dockerfile in here, or you can just copy the content to some local directory.
- Navigate to the directory containing the above Dockerfile.
- Run
docker build -t ubnutu-22.04:circom .
this step might take minutes to complete. - You can check if the image is build by the command:
docker images
. - Create a Personal Access Token named as CR_PAT (as in step 1 and 2 in the reference at the bottom). Remember to keep the value of the token!!! Remember to keep the value of the token!!! Remember to keep the value of the token!!!
export CR_PAT=<the personal access token>
echo $CR_PAT | docker login ghcr.io -u social-tw --password-stdin
docker push ghcr.io/social-tw/ubuntu-22.04:circom
, done.
reference: How can I use private docker image in github actions
After pushing the container registry successfully, and if the secret.CR_PAT is correctly set, the contained should be found.
Improve and simplify relayer tests
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like
A clear and concise description of what you want to happen.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
User.ts refactor
Is your feature request related to a problem? Please describe.
Prevent side effect and make sure type safty
Describe the solution you'd like
Refactor the User.ts to functional component
Describe alternatives you've considered
Create a functional components context for user global states
Additional context
Need to solve bugs in merge for posting feature
`yarn-error.log` should be ignored
should add yarn-error.log
in .gitignore
Posting IPFS node refactor
Refactor the IPFS setup to launch the node inside the server. So it doesn't require setting up the node in another server and will be easier to maintain in an early stage.
Export deploy app script for relay test
Is your feature request related to a problem? Please describe.
In the current testing flow, we move the contract into relay/test for testing the relayer.
Describe the solution you'd like
Export the deploy app script in contract/ and import it inside the relay test.
Additional context
Learning from the style of Unirep Social. Thanks to @vivianjeng for suggesting this.
[Login][Enhancement] Combine Login(Init) and SignUp
Is your feature request related to a problem? Please describe.
Currently, we separate two behaviors including loginOrInit and signUp.
Could we simplify these behaviors to improve user experience and reduce the transaction?
Describe the solution you'd like
Combine these two behaviors to one for easily signUp
Describe alternatives you've considered
Need to discuss further
0907 discussions
- login callback with OauthToken (need to discuss how to signUp with wallet)
- Use DB (need to discuss how to extend relayer)
Login Backend Tests
Implement the Backend tests for login and sign-up. The following are the tests we discussed.
- The backend should have a /signup API.
- It should accept sign up proof and the router should verify it
- It should accepct Github Oauth information and record the used Github Account.
- It should return tx success or fail.
hardhat can't find ts-node
Describe the bug
In the release/integrate_0713 yarn && yarn build
works as expected. However in test/post-relay, it requires to use node18. And when running yarn && yarn build
from scratch, the following error occur.
To Reproduce
In test/post-relay, yarn && yarn build
.
And if cd packages/contracts/
and yarn add --dev ts-node
.
The yarn build
works
P.S. Use yarn contracts hardhat node
and yarn contracts deploy
to generate config.ts first
Expected behavior
https://app.warp.dev/block/TBQW9C3KUJf7pnjXrj0E4l
https://app.warp.dev/block/1diqb5rZmF17qG02cs68jI
test contracts
Describe the bug
A clear and concise description of what the bug is. contracts
To Reproduce
Steps to reproduce the behavior:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
Smartphone (please complete the following information):
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
Additional context
Add any other context about the problem here.
Ci failed of Lint job
Describe the bug
Something went wrong with Lint Ci Job, there's no modification on .github/PULL_REQUEST_TEMPLATE.md
CONTRIBUTING.md
, but these two files didn't pass the lint job
To Reproduce
Steps to reproduce the behavior:
- check to feature/combine-init-and-signup-behavior
- push commit to remote
Expected behavior
Lint ci job should success
Desktop (please complete the following information):
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
Contracts Test Broken
Describe the bug
The test of contracts fails.
To Reproduce
Steps to reproduce the behavior:
First, at the root dir of main branch, run
yarn install && yarn build
Which would build the files you needed for test.
After that, run
yarn contracts test
to run the tests of contracts.
The error should appear.
Expected behavior
All of the tests of contracts shall pass.
Additional context
Maybe this has something to do with #76.
[Frontend] Personal Page under Mobile mode
Describe the bug
個人檔案頁面在手機(小裝置)模式下無法前往。
AppLayout.tsx L154
:
if(isSmallDevice) {
...
<NavLink
className="flex items-center justify-center flex-1"
to={isLogin ? '#' : '/login'}
>
<PersonCircleIcon className="text-white w-14 h-14" />
</NavLink>
}
To Reproduce
- 用手機版註冊/登入
- 點擊個人頁面
Expected behavior
- 用手機版註冊/登入
- 點擊個人頁面
- 導向
/profile
Screenshots
https://github.com/social-tw/social-tw-website/assets/9023842/0556efed-3300-43aa-b422-d118d52a99fd
Desktop (please complete the following information):
- OS: MacOS
- Browser: chrome
Additional context
所以說把 to={isLogin ? '#' : '/login' }
改成 to={isLogin? '/profile' : '/login'}
即可
DataProofVerifier isn't moved into relay testing folder during build
Describe the bug
Artifact for contract "DataProofVerifier" not found. This might impact CICD in branch test/login-relay, test/post-relay
To Reproduce
clone fresh repo and build
Expected behavior
Screenshots
1) LOGIN /login
"before each" hook for "/api/user should catch redirection":
HardhatError: HH700: Artifact for contract "DataProofVerifier" not found.
at Artifacts._handleWrongArtifactForContractName (/Users/paulyu/opensource_project/social-tw-website/node_modules/hardhat/src/internal/artifacts.ts:702:11)
at Artifacts._getArtifactPathFromFiles (/Users/paulyu/opensource_project/social-tw-website/node_modules/hardhat/src/internal/artifacts.ts:827:19)
at Artifacts._getArtifactPath (/Users/paulyu/opensource_project/social-tw-website/node_modules/hardhat/src/internal/artifacts.ts:507:21)
at async Artifacts.readArtifact (/Users/paulyu/opensource_project/social-tw-website/node_modules/hardhat/src/internal/artifacts.ts:71:26)
at async getContractFactory (/Users/paulyu/opensource_project/social-tw-website/node_modules/@nomiclabs/hardhat-ethers/src/internal/helpers.ts:99:22)
at async deployContracts (/Users/paulyu/opensource_project/social-tw-website/packages/relay/test/environment.ts:32:23)
at async Context.<anonymous> (/Users/paulyu/opensource_project/social-tw-website/packages/relay/test/login.test.ts:19:28)
Posting Backend Tests
Implement the Backend tests for posting. The following are the tests we discussed.
- Should have test scripts
- Post successfully
- Should fail if a proof is invalid
- Should store data correctly
- Should submit transaction successfully and correctly
- Should return correct data (success/error messages)
Note: All tests should pass CICD
[relay] types definition
There are several types defined in different files, it might be hard to manage in the future
User
social-tw-website/packages/relay/src/data/User.ts
Lines 1 to 6 in 6e45b3b
UserRegisterStatus
ActionType
social-tw-website/packages/relay/src/synchornizer.ts
Lines 7 to 9 in 6e45b3b
Suggestions
There can be a directory src/types
and define these types, enums inside
Login Frontend Tests
Implement the front-end tests for login and sign-up. The following are the tests we discussed.
- Should have test scripts for the process.
- Should succeed to signup users
- Should succeed to log in users if signup successfully
- Should handle error messages and return to the correct status.
login ui update
Is your feature request related to a problem? Please describe.
Add user interface feature for user loggin but hasn't signed up
Describe the solution you'd like
Add user interface feature for user loggin but hasn't signed up
Describe alternatives you've considered
Match the design
[frontend] app name, favicon
Suggestion
- change the app name to Unirep Social TW or we will have different name
- we can use the current logo as favicon
Package.json can be updated
In the template we hardcode the
"author": "Unirep Team <[email protected]>",
"homepage": "https://github.com/Unirep/create-unirep-app#readme",
"bugs": {
"url": "https://github.com/Unirep/create-unirep-app/issues"
},
This could be updated in circuits/contracts/relay/frontend
sorry for the inconvenience 🙏🏻
[relay] tx manager with gasPrice and chainId
Different chains use different settings
We can use the gasPrice
and chainId
from provider
e.g. Unirep/create-unirep-app#53
social-tw-website/packages/relay/src/singletons/TransactionManager.ts
Lines 217 to 224 in 6e45b3b
Cannot signup properly
Describe the bug
When calling http://localhost:3000/login
to do the sign up flow, invalid hash error will occur after api/signup
.
To Reproduce
Steps to reproduce the behavior
- checkout to main branch
- start all servers
- navigate to
http://localhost:3000/api/login
- login with twitter
- signup with either wallet or server
Expected behavior
console log should display has signed up
Desktop (please complete the following information):
- OS: macOS
- Browser Edge
- Version 116.0.1938.62
labeler doesn't work properly
Describe the bug
both pr and issue triage will run for single item
To Reproduce
- send an sample issue or PR
- look at github job
Expected behavior
issue triage run for issue, or otherwise
Screenshots
As in this img shows, 2 triage were run in this pr
Additional context
Add any other context about the problem here.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.