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!: store both recurring/one-time grants & spents; add state #379

Merged
merged 24 commits into from
Jul 2, 2024

Conversation

sidvishnoi
Copy link
Member

@sidvishnoi sidvishnoi commented Jun 28, 2024

Context

Closes #376

Changes proposed in this pull request

  1. Update storage as suggested in Update storage structure to support one-time + recurring grants; balance for each #376, but with following differences:
    • Instead of storing interval and approvedAmount as separate keys in grants, store them as amount: WalletAmount (but within the grant)
    • Instead of storing balances, we'll store spent amounts as API only returns spent amounts.
    • Add GrantDetails.type = "recurring" | "one-time" to make it easier for TypeScript to discriminate between two.
  2. Store a Storage.version to help with migrations, keep migrations indexed by this sequential version number.
  3. While we're doing a migration here:

Also includes some parts of #144 (setting the first available grant, but without switchGrant) and #272.

@github-actions github-actions bot added area: background Improvements or additions to extension background script area: popup Improvements or additions to extension popup labels Jun 28, 2024
@raducristianpopa
Copy link
Member

raducristianpopa commented Jun 28, 2024

Extension builds preview

Name Link
Latest commit b0be514
Latest job logs Run #9757704655
BadgeDownload
BadgeDownload

@sidvishnoi sidvishnoi changed the title feat!: store both recurring/one-time grants & balances; add state feat!: store both recurring/one-time grants & balances; add state, version Jun 28, 2024
@sidvishnoi sidvishnoi changed the title feat!: store both recurring/one-time grants & balances; add state, version feat!: store both recurring/one-time grants & balances; add state Jun 28, 2024
@sidvishnoi sidvishnoi marked this pull request as ready for review June 28, 2024 10:09
@sidvishnoi

This comment was marked as outdated.

src/shared/types.ts Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
src/background/services/background.ts Outdated Show resolved Hide resolved
src/background/services/events.ts Show resolved Hide resolved
src/background/services/background.ts Outdated Show resolved Hide resolved
src/background/services/background.ts Outdated Show resolved Hide resolved
src/background/services/background.ts Outdated Show resolved Hide resolved
src/background/services/openPayments.ts Outdated Show resolved Hide resolved
dianafulga
dianafulga previously approved these changes Jul 1, 2024
@sidvishnoi
Copy link
Member Author

@raducristianpopa @dianafulga In open outgoingPayment, we actually get grantSpentDebitAmount instead of balance. Should we compute balance on each outgoing payment, or just store spentAmount instead and compute as needed?

@dianafulga
Copy link
Contributor

@raducristianpopa @dianafulga In open outgoingPayment, we actually get grantSpentDebitAmount instead of balance. Should we compute balance on each outgoing payment, or just store spentAmount instead and compute as needed?

From what I know, we shouldn't compute anything on our side, it Should come from the API. Wait until it's implemented.

@sidvishnoi
Copy link
Member Author

sidvishnoi commented Jul 1, 2024

It appears it was decided in interledger/open-payments#469 that they'd return spent amount only instead of balance (see edit in issue description).

So, now it's upto us how to use it. We already have what amount is approved in grant. Now, we can either subtract it on each storage, or only when we need the balance. I think we don't need to know balance to know if we can make a payment (like before each payment or after, to reach the out_of_founds state), we can store spentAmount and compute balance as needed (for UI only I believe).

@sidvishnoi sidvishnoi changed the title feat!: store both recurring/one-time grants & balances; add state feat!: store both recurring/one-time grants & spent amounts; add state Jul 2, 2024
@sidvishnoi sidvishnoi changed the title feat!: store both recurring/one-time grants & spent amounts; add state feat!: store both recurring/one-time grants & spents; add state Jul 2, 2024
@sidvishnoi sidvishnoi merged commit f511b5d into main Jul 2, 2024
8 checks passed
@sidvishnoi sidvishnoi deleted the storage-migration-1 branch July 2, 2024 09:43
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 area: popup Improvements or additions to extension popup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update storage structure to support one-time + recurring grants; balance for each
3 participants