smartcontractkit / near-protocol-contracts

MIT License
26 stars 8 forks source link

Client should increase allowance before making request #21

Open mikedotexe opened 4 years ago

mikedotexe commented 4 years ago

Context:

Whoever owns the client contract should be able to fund it, and withdraw funds from it.

He who owns the client contract can use it to make requests. The client contract should on every request, increase the allowance for that one request, and store the request with the oracle contract. The oracle contract then transfers the payment amount and stores the request.

This is the flow that we should support.

On Ethereum we try to be conservative on gas so there is a transferAndCall function that does both. On NEAR, it's ok to first allow the transfer, and then oracle makes the transfer when storing request.


Okay, so you're suggesting that before the client calls request on the oracle contract, it first increases allowance. Last night when I read this I thought you might mean in the callback. Sure we can do it this way. I still think there will be cases where the client would rather not increase on every request and simply give a large allowance for many calls, but this will be a good demonstration I agree.