GithubHelp home page GithubHelp logo

social-tw-website's People

Contributors

andy78644 avatar badukwei avatar cc03668 avatar chen-yanlong avatar chentihe avatar dylanyang0523 avatar foodchain1028 avatar iverjisty avatar jason-ntu avatar lisooo790926 avatar nooma-42 avatar ryanycw avatar uranuslin avatar vivianjeng avatar wangj509 avatar xiawpohr avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

social-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

epkHelper.verifyAndCheck(publicSignals, proof);
EpochKeyVerifierHelper.EpochKeySignals memory signals = epkHelper
.decodeEpochKeySignals(publicSignals);
uint256 postId = epochKeyPostIndex[signals.epochKey];
epochKeyPostIndex[signals.epochKey] = postId + 1;

Relay
This check would prevent submitting tx would be reverted and faster respond to clients.

const epochKeyProof = new EpochKeyProof(
publicSignals,
proof,
synchronizer.prover
)
const valid = await epochKeyProof.verify()
if (!valid) {
res.status(400).json({ error: 'Invalid proof' })
return
}

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.

[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

Screenshots
image

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
relates to #25 #47

Deployment function can be reused in test

Current Behavior
The contract test copies the deployment code, but there is a function in ../scripts/utils

const helper = await deployVerifierHelper(deployer, Circuit.epochKey)
const verifierF = await ethers.getContractFactory('DataProofVerifier')
const verifier = await verifierF.deploy()
await verifier.deployed()
const App = await ethers.getContractFactory('UnirepApp')
app = await App.deploy(
unirep.address,
helper.address,
verifier.address,
epochLength
)
await app.deployed()

Suggestion

Use the deployApp function in the contract package

export async function deployApp(deployer: ethers.Signer, epochLength: number) {

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長這樣
image
導致我發了一篇新的文章後,那篇文章的Post interface裡id為null,因此點擊Post不會前往/posts/${id}

To Reproduce

  1. 註冊
  2. 發文
  3. 點擊剛剛發佈的那篇文章
  4. 會看到只能夠前往/posts/ 而非/posts/:id

Expected behavior

  1. 註冊
  2. 發文
  3. 點擊剛剛發佈的那篇文章
  4. 前往該文章的PostDetail頁面 /posts/${_id}

Screenshots
image

Desktop (please complete the following information):

  • OS: MacOS
  • Browser: Chrome

Additional context
順便請問一下,上圖可見回傳的post結構裡還有一個postId,並且也是list of component的key,但由於皆為從0開始的整數,與範例post產生衝突。因此想請問一下

  1. 未來會用這個postId來辨識post嗎?如果是的話是否要與範例post先做出區隔以免造成bug。
  2. 若其實是要用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:

  1. checkout to branch feature/signup-status-ui
  2. start the server
  3. navigate to http://localhost:3000
  4. finish the sign up flow (clean the local storage if you don't see the twitter login page)
  5. open the console, refresh the page once you see has signed up message

Expected behavior
no error message shows up on the console

Screenshots
image
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

  1. Login the account
  2. Enter text to crate post
  3. Create a post
  4. See error

Expected behavior

It shouldn't return status 500 when calling api/post

Screenshots

image

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:

  1. Raise PR
  2. Run CI steps
  3. check the result

Expected behavior
CI should success

Screenshots

[relay] check proof before submitting tx

Similar to #95
In signup router

const signupProof = new SignupProof(
publicSignals,
proof,
synchronizer.prover
)
const valid = await signupProof.verify()
if (!valid) {
throw new Error('Invalid proof')
}

There are things we can check before submitting to contract and prevent revert

  1. check attester ID matches current contract address (signupProof.attesterId)
  2. 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

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:

  1. Add a PR to release/integrate_0713
  2. Click on 'Actions'
  3. Check the newest action.
  4. 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
image

How to push the container

  1. Pull the Dockerfile in here, or you can just copy the content to some local directory.
  2. Navigate to the directory containing the above Dockerfile.
  3. Run docker build -t ubnutu-22.04:circom . this step might take minutes to complete.
  4. You can check if the image is build by the command: docker images. image
  5. 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!!!
  6. export CR_PAT=<the personal access token>
  7. echo $CR_PAT | docker login ghcr.io -u social-tw --password-stdin
  8. 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

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

  1. login callback with OauthToken (need to discuss how to signUp with wallet)
  2. 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

Screenshots
image

test contracts

Describe the bug
A clear and concise description of what the bug is. contracts

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. 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:

  1. check to feature/combine-init-and-signup-behavior
  2. push commit to remote

Expected behavior
Lint ci job should success

Screenshots
image

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.

Screenshots
image

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

  1. 用手機版註冊/登入
  2. 點擊個人頁面

Expected behavior

  1. 用手機版註冊/登入
  2. 點擊個人頁面
  3. 導向 /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)

Additional context
related to #25 #47

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

type User = {
hashUserId: string
status: number
signMsg: string | undefined
token: string | undefined
}

UserRegisterStatus

export const enum UserRegisterStatus {
NOT_REGISTER,
INIT,
REGISTERER,
REGISTERER_SERVER,
}

ActionType

export enum ActionType {
Post = 'Post',
}

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

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 🙏🏻

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

  1. checkout to main branch
  2. start all servers
  3. navigate to http://localhost:3000/api/login
  4. login with twitter
  5. signup with either wallet or server

Expected behavior
console log should display has signed up

Screenshots
messageImage_1693532463091

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

  1. send an sample issue or PR
  2. look at github job

Expected behavior
issue triage run for issue, or otherwise

Screenshots
截圖 2023-08-22 上午8 14 44
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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.