diff --git a/nitro/protocol/outcome.nim b/nitro/protocol/outcome.nim index 45d6b25..ad8f0f1 100644 --- a/nitro/protocol/outcome.nim +++ b/nitro/protocol/outcome.nim @@ -19,13 +19,23 @@ type of guaranteeType: guarantee*: Guarantee Allocation* = distinct seq[AllocationItem] - AllocationItem* = object - destination*: Destination - amount*: UInt256 + AllocationItem* = tuple + destination: Destination + amount: UInt256 Guarantee* = object targetChannelId*: Destination destinations*: seq[Destination] +proc init*(_: type Outcome, + asset: EthAddress, + allocation: openArray[AllocationItem]): Outcome = + let assetOutcome = AssetOutcome( + kind: allocationType, + assetHolder: asset, + allocation: Allocation(@allocation) + ) + Outcome(@[assetOutcome]) + proc encode*(encoder: var AbiEncoder, guarantee: Guarantee) = encoder.startTuple() encoder.startTuple() diff --git a/tests/nitro/examples.nim b/tests/nitro/examples.nim index 41c46da..63cf49c 100644 --- a/tests/nitro/examples.nim +++ b/tests/nitro/examples.nim @@ -38,10 +38,7 @@ proc example*(_: type ChannelDefinition): ChannelDefinition = ) proc example*(_: type AllocationItem): AllocationItem = - AllocationItem( - destination: Destination.example, - amount: UInt256.example - ) + (Destination.example, UInt256.example) proc example*(_: type Guarantee): Guarantee = Guarantee( diff --git a/tests/nitro/protocol/testOutcome.nim b/tests/nitro/protocol/testOutcome.nim index ec707fc..e1a065d 100644 --- a/tests/nitro/protocol/testOutcome.nim +++ b/tests/nitro/protocol/testOutcome.nim @@ -94,7 +94,7 @@ suite "outcome": "1E90B49563da16D2537CA1Ddd9b1285279103D93" ).get(), allocation: Allocation(@[ - AllocationItem( + ( destination: Destination.parse( "f1918e8562236eb17adc8502332f4c9c82bc14e19bfc0aa10ab674ff75b3d2f3" ).get(),