import { utils , Contract } from 'ethers' ; import ForceMoveAppArtifact from '../../artifacts/contracts/interfaces/IForceMoveApp.sol/IForceMoveApp.json' ; import { State , getVariablePart } from '../contract/state' ; export const ForceMoveAppContractInterface = new utils . Interface ( ForceMoveAppArtifact . abi ) ; param fromState param toState param appContract returns export async function validTransition ( fromState , toState , appContract ) { const numberOfParticipants = toState . channel . participants . length ; const fromVariablePart = getVariablePart ( fromState ) ; const toVariablePart = getVariablePart ( toState ) ; const turnNumB = toState . turnNum ; return await appContract . validTransition ( fromVariablePart , toVariablePart , turnNumB , numberOfParticipants ) ; } /**
 * Encodes a validTransition method call as the data on an ethereum transaction. Useful for testing gas consumption of a ForceMoveApp.
 */ export function createValidTransitionTransaction ( fromState , toState ) { const numberOfParticipants = toState . channel . participants . length ; const fromVariablePart = getVariablePart ( fromState ) ; const toVariablePart = getVariablePart ( toState ) ; const turnNumB = toState . turnNum ; const data = ForceMoveAppContractInterface . encodeFunctionData ( 'validTransition' , [ fromVariablePart , toVariablePart , turnNumB , numberOfParticipants , ] ) ; return { data } ; }