mirror of
https://github.com/logos-storage/nim-nitro.git
synced 2026-01-02 13:43:06 +00:00
Add convenience initializer to Outcome
This commit is contained in:
parent
a8b2cfab5a
commit
a945698ec6
@ -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()
|
||||
|
||||
@ -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(
|
||||
|
||||
@ -94,7 +94,7 @@ suite "outcome":
|
||||
"1E90B49563da16D2537CA1Ddd9b1285279103D93"
|
||||
).get(),
|
||||
allocation: Allocation(@[
|
||||
AllocationItem(
|
||||
(
|
||||
destination: Destination.parse(
|
||||
"f1918e8562236eb17adc8502332f4c9c82bc14e19bfc0aa10ab674ff75b3d2f3"
|
||||
).get(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user