yagna
yagna copied to clipboard
Update Allocation to serve Deposits
To be able to introduce Allowance as a payment option on Yagna we need to create REST API
AS IS:
Allocation REST API creates allocation for an ID (App_key -> Identity)
TO BE:
Allocation REST API creates allocation for an Payer (Address which creates the Deposit) & Signer (App_key -> Identity)
Acceptance Criteria:
- ~Introduce new Endpoint for Allocation Method which serves Allowance~
- Calling new Allocation should sent request to payment driver to verify if Allowance is given on Blockchain
- Update "Yagna Payment Init" to serve new Payer parameter
- update REST API (Ya_Client) spec
Additional Information:
- Yagna Payment Init params: Platform, Address/ID, Receiver, Sender
- When You do Allocation -> Payment Init is called
- Yagna can have multiple App_key for multiple Identities (1 Appkey is always paired with 1 Identity)
- We don't need api modifications: we can use address field as payer and infer signer from app-key
- Optional
deposit
field:- contains deposit contract address
- contains deposit id
- makes the
timeout
field mandatory and it must come before the deposit deadline - makes the
address
field mandatory and it must be the address of the Payer (deposit creator).
- The
timeout
,total_amount
andaddress
fields will be validated against the contract during allocation creation and when the allocation is amended (in case of amending it will be ensured that the remaining amount doesn't exceed the amount remaining in the deposit). - It's validated that spender in the contract is the same as signer.
- Validation will happen at the moment of attempting allocation creation / amending.
Questions
-
Should we add a parameter to opt out of automatically releasing deposits
-- no. Introduces extra complexity for unclear gain. Signer has full control over the lifetime of an allocation (modulo timeout) which should be flexible enough. -
Should we autoamtically track deposit value and update allocation accordingly
-- no. This can lead to a mismatch between amounts on the deposit and the allocation, but we decided that this won't lead to any fatal bugs. However this behavior must be documented -- extending the deposit doesn't imply extending the allocation, in case it's confusing. -
What should be validated by yagna re. deposits
-- yagna shouldn't know anything about the deposit fee, it's a responsibility of the service requesting deposit creation, to validate that deposit in case of malicious clients. Yagna will only validate parts of the deposit relevant to the allocation.