-
Notifications
You must be signed in to change notification settings - Fork 7
Description
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
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