stakwork / sphinx-js

Web extension and PWA for Sphinx.chat and 2nd Brain
2 stars 2 forks source link

Add content to secondbrain #8

Open ecurrencyhodler opened 9 months ago

ecurrencyhodler commented 9 months ago

Once a user has clicked into a secondbrain and deposited sats, they are now ready to submit content to Second Brain.

User Story

As a user, I paste a link I want to submit to the Second Brain then click "Add". I then see a success screen and the balance reduced. Or I see a failed screen and the balance is preserved.

Technical Considerations

1. Specify 2B API Call You can specify which 2B endpoint to hit by using this logic.

Endpoint = /node/content

Request:

{
   "source": "{URL}"
}

2. Submit content through API call When submitting the content, you must include the link in the body of the call as well as the L402 in the header. This is how the secondbrain knows which L402 to decrement 10 sats from.

Here is the getLsat function to identify the specific L402 that is being used.

Here is an example getLsat call.

3. Success/Fail The API call should also tell us whether or not it was successful.

If successful, another call is made to check balance of the L402 using /balance. If the balance is different from before, amount should be updated with the correct amount. We should expect decrements of 10 sats each time.

If failed, then the user balance should be preserved in the Chrome Extension.

Designs

Inside 2B 29 Paste URL 34 Success Screen Please note that the amount has decreased by 10 sats. This is visible for 3 seconds and can be exited before that by clicking anywhere inside the "added susccessfully" screen. They then returned to the Inside 2b screen again to be prompted to add another url. 36 Fail Screen Add content - Error

Account balance 0 If the account balance hits 0, they will be taken to the home screen and prompted to fund. 35

You can find the figma file here. Use dev mode for exact requirements.

Acceptance Criteria