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

feat: save token and partner data in supabase on permit generation #285

Conversation

zugdev
Copy link
Contributor

@zugdev zugdev commented Feb 19, 2025

Resolves #284

Copy link
Contributor

Caution

No labels are set.

@zugdev
Copy link
Contributor Author

zugdev commented Feb 19, 2025

@0x4007

@zugdev
Copy link
Contributor Author

zugdev commented Feb 20, 2025

Not sure on how to QA this.

@0x4007
Copy link
Member

0x4007 commented Feb 20, 2025

[!CAUTION]
No labels are set.

@gentlementlegen caution should be reserved for application errors.

This should be a warning because its changeable based on the inputs (change the labels)

@0x4007 0x4007 requested a review from rndquu February 20, 2025 05:44
@rndquu
Copy link
Member

rndquu commented Feb 20, 2025

Not sure on how to QA this.

Pls:

  1. QA this PR, take the latest supabase backup from https://github.com/ubiquity/ubiquibot-db-backups and test the PR on your local DB instance
  2. Fix failing jest CI

@zugdev
Copy link
Contributor Author

zugdev commented Feb 21, 2025

Sorry, took some time but here is the QA! @rndquu @gentlementlegen

supabase-qa.mp4

@gentlementlegen
Copy link
Member

@zugdev I'll have a look at it tomorrow. Does it retroactively need to fix previous permits, since the previous ones did not save this info?

@zugdev
Copy link
Contributor Author

zugdev commented Feb 22, 2025

I will write a backfill script, apparently it makes more sense to have it here in the backend.

@zugdev
Copy link
Contributor Author

zugdev commented Feb 23, 2025

I made a backfill script that looks into the permit's origin URL (e.g #284) and then matches all https://pay.ubq.fi/?claim= URLs. It proceeds by decoding all encoded permits and matching the signature and user with what is in the DB. If it matches it then uses the owner and token info to update the permits table with that information.

image image

There are still some permits that don't match because they were deleted or voided. An example is permit 322, generated at ubiquity-os-marketplace/command-start-stop#2 which you have confirmed in a comment was invalidated.

To run you can simply do bun scripts/permits-backfill.ts with your .env setup: SUPABASE_KEY being the service_role secret key and not the anon key, which has no write privilege.

As of now, what allows us to fetch permits is this RLS rule.

image

However the table partners, for example, doesn't have that setup.

image

In my fork of the DB I will create the same rule, however someone with better context can decide if it's appropriate in production.

@zugdev
Copy link
Contributor Author

zugdev commented Feb 27, 2025

added better github handling (retrials, wait on rate limit, skip on 404...)

action QA: https://github.com/zugdev/conversation-rewards/actions/runs/13557258018/job/37893854455

@zugdev
Copy link
Contributor Author

zugdev commented Feb 27, 2025

this jest fail is from an rpc timeout. @gentlementlegen I'd be happy if you could prioritize wrapping this so I can follow up with ubiquity/pay.ubq.fi#383 (comment) :) dont worry if you cant

@gentlementlegen
Copy link
Member

@zugdev usually when RPC times out I just relaunch tests until it picks an RPC that is fast enough. Let me restart it.

@zugdev
Copy link
Contributor Author

zugdev commented Feb 27, 2025

@gentlementlegen done. I don't have permission to set secrets in this repo, so I'd appreciate if you could set SUPABASE_PRIVATE_KEY or give me the perms to set it.

Copy link
Member

@gentlementlegen gentlementlegen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just set the private key in the environment.

Copy link
Contributor

@zugdev, you have used 3 of 3 available deadline extensions. Please provide an update on your progress.

@zugdev
Copy link
Contributor Author

zugdev commented Mar 2, 2025

Nice, @gentlementlegen can we merge and run the action?

@gentlementlegen
Copy link
Member

@zugdev please resolve conflicts first

@gentlementlegen gentlementlegen merged commit 5811d06 into ubiquity-os-marketplace:development Mar 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Save permit owner (partner) and token information in Supabase on generation
4 participants