mirror of
https://github.com/logos-storage/nim-nitro.git
synced 2026-01-07 16:13:09 +00:00
Add convenience initializer to Outcome
This commit is contained in:
parent
a8b2cfab5a
commit
a945698ec6
@ -19,13 +19,23 @@ type
|
|||||||
of guaranteeType:
|
of guaranteeType:
|
||||||
guarantee*: Guarantee
|
guarantee*: Guarantee
|
||||||
Allocation* = distinct seq[AllocationItem]
|
Allocation* = distinct seq[AllocationItem]
|
||||||
AllocationItem* = object
|
AllocationItem* = tuple
|
||||||
destination*: Destination
|
destination: Destination
|
||||||
amount*: UInt256
|
amount: UInt256
|
||||||
Guarantee* = object
|
Guarantee* = object
|
||||||
targetChannelId*: Destination
|
targetChannelId*: Destination
|
||||||
destinations*: seq[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) =
|
proc encode*(encoder: var AbiEncoder, guarantee: Guarantee) =
|
||||||
encoder.startTuple()
|
encoder.startTuple()
|
||||||
encoder.startTuple()
|
encoder.startTuple()
|
||||||
|
|||||||
@ -38,10 +38,7 @@ proc example*(_: type ChannelDefinition): ChannelDefinition =
|
|||||||
)
|
)
|
||||||
|
|
||||||
proc example*(_: type AllocationItem): AllocationItem =
|
proc example*(_: type AllocationItem): AllocationItem =
|
||||||
AllocationItem(
|
(Destination.example, UInt256.example)
|
||||||
destination: Destination.example,
|
|
||||||
amount: UInt256.example
|
|
||||||
)
|
|
||||||
|
|
||||||
proc example*(_: type Guarantee): Guarantee =
|
proc example*(_: type Guarantee): Guarantee =
|
||||||
Guarantee(
|
Guarantee(
|
||||||
|
|||||||
@ -94,7 +94,7 @@ suite "outcome":
|
|||||||
"1E90B49563da16D2537CA1Ddd9b1285279103D93"
|
"1E90B49563da16D2537CA1Ddd9b1285279103D93"
|
||||||
).get(),
|
).get(),
|
||||||
allocation: Allocation(@[
|
allocation: Allocation(@[
|
||||||
AllocationItem(
|
(
|
||||||
destination: Destination.parse(
|
destination: Destination.parse(
|
||||||
"f1918e8562236eb17adc8502332f4c9c82bc14e19bfc0aa10ab674ff75b3d2f3"
|
"f1918e8562236eb17adc8502332f4c9c82bc14e19bfc0aa10ab674ff75b3d2f3"
|
||||||
).get(),
|
).get(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user