near-daos / sputnik-dao-contract

Smart contracts for https://app.astrodao.com
https://astrodao.com/
MIT License
108 stars 76 forks source link

Added transfer batch proposal kind #100

Closed okalenyk closed 2 years ago

okalenyk commented 2 years ago

This PR is introducing a new Proposal kind: TransferBatch. It is built on top of the Transfer kind we're already familiar with, but adding an ability to specify multiple accounts with the shared token/near amount to transfer.

Execution example

The on_proposal_callback function is updated with the new arg num_callbacks since the transfer batch approach is based on promise chain(in fact - promise merge), so the number of callbacks depends on the number of promises in the batch.

TrevorJTClarke commented 2 years ago

Thanks @okalenyk will take a look and note findings.

okalenyk commented 2 years ago

UPD: Added token 'msg' to TransferBatch proposal as well as the validation of the Proposal. Set max to 15 receivers since we can run out of gas otherwise.

ctindogaru commented 2 years ago

Thank you a lot @okalenyk for your contribution 🤝 .

I'm trying to keep the core smart contract as simple as possible. So if any of the logic can be delegated to the user/UI, I would prefer to do so.

In this case, the TransferBatch proposal can be replicated by the user by having multiple Transfer proposals and then approving each one of them. I know it's a repetitive work, but I would prefer to not flood the contracts with batch logic, especially since the batch logic will be gas-limited to only 10-15 receivers.

I'm forced to postpone this PR for now until there is a real demand to have this sort of action.