aesirxio / web3-id-preregistration-backend

Backend for the pre-registration and share2earn of web3 id
GNU General Public License v3.0
0 stars 3 forks source link

Step 4: Enter to beta program and generate share2earn link #7

Open jatitoam opened 1 year ago

jatitoam commented 1 year ago

Add a new /preregistration/claimbeta/:account?signature=<signature> (PUT) endpoint to enter the beta program.

Validations should be returning using 4xx error and a json document:

{
   "error": "<specific error>"
}

Validations:

Important:

After signature verification (using concordium-sdk) the nonce needs to be cleared in the account document to invalidate it (if validation passes or fails).

Procedure:

If all validations pass, update the preregistration document belonging to the account and:

  1. Add a beta field with value true.
  2. Add a share2earn link generating a random 16-byte code (alphanumeric). Making sure that this value does not exist in another preregistration document.
  3. If the preregistration document has a non-empty refShare2Earn field (sent during #2), increase the referred field n the preregistration document of the owner of the refShare2Earn (using the share2earn field for searching) in 1. In other words: the account who referred this account getting to this point, will add 1 referred to its count (if the field does not exist in that account, create it with 1).

If any of these steps fail, send a 500 http code.

If everything succeeds, return a 201 http code:

{
   "result": "true"
}
CongThuong commented 1 year ago

I need to clear "Add a new dateShare2Earn when this is completed (with new Date())". new Date() for account who referred or current account or both? @jatitoam