morkeltry / GAP-microfinance

GAP microfinance frontend and Solidity prototype
0 stars 1 forks source link

/registeroffer #25

Open morkeltry opened 6 years ago

morkeltry commented 6 years ago

endpoint accepts as params:

lenderEthAddr and, optionally, { id; startDate; endDate; duration; repaymentSchedule; lenderName; lenderEthAddr; BorrowerEthAddr}

OR offers: stringified array of { id; startDate; endDate; duration; repaymentSchedule; lenderName; lenderEthAddr; BorrowerEthAddr}objects.


If only lenderEthAddr provided, then retrieve an array of offers made by that lender from db, excluding those which are also in accepted loans. If more fields than lenderEthAddr are provided, wrap params object in array. If offers passed, unwrap into array

Filter array keeping only objects where all of { duration; lenderEthAddr; BorrowerEthAddr } provided or all of { startDate; endDate; lenderEthAddr; BorrowerEthAddr } provided

For each object, calculate startDate; endDate; duration if missing.

For each object, add two properties txWithdraw & txRegister which are clones of each other:

= {
  from: borrowerEthAddr,
  to: contractAddr,  // use env2 to set this as app constant - '0x12345' is fine
  gasPrice: "9000000000",
  gas: "85000",
  data: ""
};

as in #5

and respond with stringified resulting array