Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Monetization flow] #77

Closed
7 tasks done
raducristianpopa opened this issue Jan 16, 2024 · 1 comment
Closed
7 tasks done

[Monetization flow] #77

raducristianpopa opened this issue Jan 16, 2024 · 1 comment
Labels
area: background Improvements or additions to extension background script story

Comments

@raducristianpopa
Copy link
Member

raducristianpopa commented Jan 16, 2024

Content Script

  1. Setup MutationObserver to detect link tags
  2. For each found tag check if the href has a valid JSON response (based on OP Spec)
  3. For each valid tag save details (Wallet Address response - authServer, resourceServer etc ... + a unique identifier - uuidv4, w/e)
    in a map/array/something and send START_MONETIZATION (payload wallet JSON - opt requestId TBD) event to background script
  4. Receicer for MONETIZATION_EVENT that will dispatch a MonetizationEvent to the link tag
  5. Watch for document visibility change
    • on hidden, stop monetization
      • send "STOP_MONETIZATION" event with payload requestId
    • on visible, resume monetization
      • send "RESUME_MONETIZATION" event with payload requestId

Background
4. In background - call monetizationServer.start()
4.1 request incoming payment grant
4.2 create incoming payment - NO AMOUNT
4.3 try to send payment - if received status code is 403, rotate token
4.4 revoke grant after creating incoming payment
4.5 add incoming payment details to a map - (key: tabId, value: {"uuidv4" : { ...incomingPaymentDetails, active: true }, ...})
5. Create quote with receiveAmount = RATE_OF_PAY / 3600 to incoming payment (active: true)
6. Create outgoing payment with quote identifier (active: true)
7. Send "MONETIZATION_EVENT" to content script with MonetizationEvent payload + request id
8. Watch for document visibility change

  • on hidden, stop monetization
    • receive "STOP_MONETIZATION" event with payload requestId and mark active false for that requestId
  • on visible, resume monetization
    • receive "RESUME_MONETIZATION" event with payload requestId and mark active true for that requestId
    • repeat steps 5-6 - if IP expired, go back to 4.1 and update payment details instead of adding a new record
  1. Add tab listener to watch for closed tabs and remove payment details from map (step 4.5) for that specific tab

TODO:

@raducristianpopa raducristianpopa added the area: background Improvements or additions to extension background script label Jan 16, 2024
@tselit
Copy link

tselit commented Feb 15, 2024

Please expand on the context & description @raducristianpopa (this update is also low priority)

@dianafulga dianafulga changed the title Add monetization service [Monetization flow] Mar 11, 2024
@tselit tselit added the story label Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: background Improvements or additions to extension background script story
Projects
Status: Done
Development

No branches or pull requests

2 participants