-
Notifications
You must be signed in to change notification settings - Fork 5
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
Handle underfunded claims #22
Conversation
@@ -14,7 +14,11 @@ export function claim( | |||
) { | |||
if (initialTargetOutcome.length !== initialHoldings.length) throw Error; | |||
const updatedTargetOutcome: Exit = []; | |||
let updatedHoldings = initialHoldings; | |||
// We want to create a clone of the original values to prevent mutation | |||
const updatedHoldings = initialHoldings.map((h) => BigNumber.from(h)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think previously we were mutating the values passed in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good aside from one comment about how to update the guarantor channel.
I think we ought to add in the corresponding solidity code, too, before merging (to keep everything in step).
const guarantee = createGuarantee([ | ||
["C2", "0x03", ["A"]], | ||
["C1", "0x0A", ["A", "I", "B"]], | ||
]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this notation a lot, it's easy to parse the important information.
Any reason why you chose C2 as the higher priority and C1 as the lower priority (just wondering about notation)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No strong reason.
In my mind, C1
is the "main" channel (with allocations to A,I,B) and we're using C2 ahead of it to test the underfunded claim scenario. It keeps it consistent-ish with other tests that use C1
as the only channel.
This updates the
claim
method to take into account the order ofguarantees
. We iterate through guarantees that occur before the target one and tally the amount of funds reserved by guarantees.The amount on the
guarantee
is now used to store the funding available for the guarantee.We also now return a
updatedGuaranteeOutcome
that has the amount adjusted after the funds have been claimed.Currently there are only typescript versions of the tests/changes but this should be pretty easy to copy over to solidity.