-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add function to combine open and deposit #1436
Comments
@karlb Some questions to the prototype below:
+ /// @notice Opens a new channel between `participant1` and `participant2`
+ /// Can be called by anyone
+ /// @param participant1 Ethereum address of a channel participant
+ /// @param participant2 Ethereum address of the other channel participant
+ /// @param settle_timeout Number of blocks that need to be mined between a
+ /// call to closeChannel and settleChannel
+ /// @param participant1_total_deposit The total amount of tokens that participant1
+ /// will have as a deposit
+ function openChannelWithDeposit(
+ address participant1,
+ address participant2,
+ uint256 settle_timeout,
+ uint256 participant1_total_deposit
+ )
+ public
+ isSafe
+ settleTimeoutValid(settle_timeout)
+ returns (uint256)
+ {
+ uint256 channel_identifier;
+
+ channel_identifier = openChannel(participant1, participant2, settle_timeout);
+ setTotalDeposit(channel_identifier, participant1, participant1_total_deposit, participant2);
+
+ return channel_identifier;
+ } |
With the above code, you already can deposit for the other participant by choosing him as participant1. Depositing to both doesn't seem very useful, since depositing to yourself and sending a transfer is cheaper.
I would keep it as participant1_total_deposit for consistency, although I see the point in renaming it. |
When a channel is opened, the user usually also wants to deposit tokens into the channel. Right now, this involves two transactions and waiting for confirmation in between. Adding a function that combines these two operations will allow them to happen in a single transaction, thus reducing the time until the channel can be used. (An approve transaction has to be done in both cases, in addition to the transactions mentioned)
This function could be in an auxiliary contract. But if there is enough space left if the TokenNetwork contract, I suggest adding it there to keep the number of contracts low.
The expectation is that this is a low effort thing to add. If this is not the case, please bring up the complications in this issue before spending much time on the implementation, so we can reconsider if it's worth implementing.
The text was updated successfully, but these errors were encountered: