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

Implement price API #542

Merged
merged 2 commits into from
Jan 19, 2024
Merged

Implement price API #542

merged 2 commits into from
Jan 19, 2024

Conversation

nesitor
Copy link
Member

@nesitor nesitor commented Jan 15, 2024

Problem: We are unable to get the required tokens or flow for an instance or program VM.

Solution: Create a price API to request it just passing the message item hash.

@nesitor nesitor requested review from hoh and MHHukiewitz January 15, 2024 17:21
@nesitor nesitor self-assigned this Jan 15, 2024
@nesitor nesitor force-pushed the andres-feature-add_vm_pricing_api branch 2 times, most recently from 5ac4393 to e6004cf Compare January 15, 2024 17:30
Copy link
Member

@MHHukiewitz MHHukiewitz left a comment

Choose a reason for hiding this comment

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

LGTM

src/aleph/services/cost.py Outdated Show resolved Hide resolved
src/aleph/services/cost.py Outdated Show resolved Hide resolved
required_tokens = compute_cost(session=session, content=content)

return web.Response(
text=MessagePrice(required_tokens=required_tokens).to_json(),
Copy link
Member

Choose a reason for hiding this comment

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

Why use a dataclass here ?

Suggested change
text=MessagePrice(required_tokens=required_tokens).to_json(),
json={"required_tokens": required_tokens},

Copy link
Member Author

Choose a reason for hiding this comment

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

This suggestion doesn't work, because web.Response method don't have any json field.

Copy link
Member

Choose a reason for hiding this comment

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

src/aleph/web/controllers/prices.py Outdated Show resolved Hide resolved
@nesitor nesitor requested a review from hoh January 18, 2024 11:38
@hoh
Copy link
Member

hoh commented Jan 18, 2024

This branch should be based on dev, not master.
Related: we should merge dev on master.

@nesitor nesitor force-pushed the andres-feature-add_vm_pricing_api branch from f40a897 to 0e91f05 Compare January 18, 2024 15:25
@nesitor nesitor changed the base branch from master to dev January 18, 2024 15:26
@hoh hoh force-pushed the andres-feature-add_vm_pricing_api branch from 3553810 to 179f731 Compare January 19, 2024 14:37
@hoh
Copy link
Member

hoh commented Jan 19, 2024

I added the payment type in the JSON response.

Problem: Checking the balance on Pay as you go payment method don't allow the message to be processed.

Solution: Exclude stream payment method on balance check system.
…ance or program VM.

Solution: Create a price API to request it just passing the message item hash.
@hoh hoh force-pushed the andres-feature-add_vm_pricing_api branch from 179f731 to 273df6b Compare January 19, 2024 14:49
@hoh hoh merged commit 26f14ad into dev Jan 19, 2024
2 checks passed
@hoh hoh deleted the andres-feature-add_vm_pricing_api branch January 19, 2024 14:58
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.

3 participants