import { defaultAbiCoder } from '@ethersproject/abi' ; import * as ExitFormat from '@statechannels/exit-format' ; import { BytesLike , constants , utils } from 'ethers' ; import { Bytes32 } from './types' ; export const MAX_OUTCOME_ITEMS = 600 ; export type AssetOutcome = ExitFormat . SingleAssetExit ; /**
 * The part of a  State which dictates how assets are redistributed when the channel closes
  export type Outcome = ExitFormat . Exit ; export type SimpleAllocation = ExitFormat . Allocation & { allocationType : ExitFormat . AllocationType . simple ; } ; export type GuaranteeAllocation = ExitFormat . Allocation & { allocationType : ExitFormat . AllocationType . guarantee ; } ; export type SingleAssetGuaranteeOutcome = AssetOutcome & { allocations : GuaranteeAllocation [ ] ; } ; export type GuaranteeOutcome = SingleAssetGuaranteeOutcome [ ] ; export const encodeOutcome = ExitFormat . encodeExit ; export const decodeOutcome = ExitFormat . decodeExit ; param outcome returns export function hashOutcome ( outcome ) { const encodedOutcome = encodeOutcome ( outcome ) ; return utils . keccak256 ( encodedOutcome ) ; } export function encodeGuaranteeData ( destinations ) { return defaultAbiCoder . encode ( [ 'bytes32[]' ] , [ destinations ] ) ; } export function decodeGuaranteeData ( data ) { return defaultAbiCoder . decode ( [ 'bytes32[]' ] , data ) [ 0 ] ; } const A_ADDRESS = '0x00000000000000000000000096f7123E3A80C9813eF50213ADEd0e4511CB820f' ; const B_ADDRESS = '0x00000000000000000000000053484E75151D07FfD885159d4CF014B874cd2810' ; const exampleGuaranteeOutcome1 = [ { asset : constants . AddressZero , metadata : '0x' , allocations : [ { destination : '0xjointchannel1' , amount : '0xa' , allocationType : ExitFormat . AllocationType . guarantee , metadata : encodeGuaranteeData ( [ B_ADDRESS , A_ADDRESS ] ) , } , { destination : '0xjointchannel2' , amount : '0xa' , allocationType : ExitFormat . AllocationType . guarantee , metadata : encodeGuaranteeData ( [ A_ADDRESS , B_ADDRESS ] ) , } , ] , } , ] ; const exampleGuaranteeOutcome2 = exampleGuaranteeOutcome1 ;