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

Book now #12

Open
Tracked by #14
bobetbat opened this issue Jul 20, 2022 · 0 comments
Open
Tracked by #14

Book now #12

bobetbat opened this issue Jul 20, 2022 · 0 comments
Labels

Comments

@bobetbat
Copy link
Contributor

Book now (components)

flowchart
	subgraph book[Book now]
		network[Network selector]
		asset[Asset selector]
		guaranteeIdQuery
		cryptoPayment
		bookingFinalization
	end

	subgraph server
		booking[Booking API]
	end

	contract[Smart contract]

	offer[offer price, currency] --> book
	metamask <--> network
	asset -.-> balance
	guaranteeIdQuery -- request guaranteeId --> booking
	booking -.- guaranteeId -.-> guaranteeIdQuery
	guaranteeIdQuery -- guaranteeId --> cryptoPayment

	start[Start payment] -.-> cryptoPayment

	cryptoPayment <-- asset and price, guaranteeId, value --> contract

	cryptoPayment --> bookingFinalization
	bookingFinalization --> booking
	booking -.-> bookingFinalization
Loading

The Book now component accepts offer price and currency as params.

Network selector allows the user to select desired blockchain network (list of allowed networks must be configured via app config). When a user selects a network from the list the app must send special request to the Metamask wallet that changes the currently selected network.

Each network has its own set of crypto assets allowed for payments. Assets must be configured via app config.

The smart contract has two functions.

  • calc makes a calculation of the selected asset value and accepts the following arguments:
    • asset (asset Id listed in the smart contract)
    • booking price (fiat price)
  • pay makes crypto payment. Accepts the following arguments:
    • asset (asset Id listed in the smart contract)
    • booking price (fiat price)
    • guaranteeId (Simard Pay, obtained through the booking API) OR offerID (???)
    • asset value
    • expiration time (sec) if during the transaction this time will be reached the transaction will be reverted

When the user selected the network the asset the component must send a calculation request using the calc function. After the calculation is obtained the UI must demonstrate to the user the required asset value.

  • If the balance of the asset in the user’s wallet is not enough in the UI must be generated warning message.
  • If the balance of the asset is enough for payment in the UI must be shown a button for starting payment.

The transaction expiration time must be calculated according to the following rule: transaction expiration time must be less than the offer expiration time. The difference between these times must be enough for the completion of the booking procedure via the Glider API.

When the payment transaction is mined the bookingFinalization helper must send a request to the booking API for making the booking via the Glider API.

When booking via the booking API is finished in exchange should be returned a booking ID. This Id should be demonstrated to the user and saved to the local storage into myBookings persistent property.

flowchart

	subgraph state[App state]
		myBookings
	end

	state <--> useAppState
	useAppState <--> bookingFinalization
Loading
@bobetbat bobetbat mentioned this issue Jul 21, 2022
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant