import { BigNumber , SignatureVerifier , DefaultSignatureVerifier , } from '@pigi/core-utils' ; import { Message , ParsedMessage , Property , SignedMessage } from '../../../types' ; import { AndDecider , ForAllSuchThatDecider , MessageNonceLessThanDecider , SignedByDecider , SignedByInput , } from '../../deciders' ; import { SignedByQuantifier } from '../../quantifiers' ; import { deserializeMessage , deserializeMessageString , stateChannelMessageDeserializer , } from '../serializers' ; export interface NonceLessThanProperty { decider : MessageNonceLessThanDecider ; input : any ; } export type NonceLessThanPropertyFactory = ( input : any ) => NonceLessThanProperty ; export interface StateChannelExitClaim extends Property { decider : AndDecider ; input : { properties : [ { decider : SignedByDecider ; input : SignedByInput ; witness : { } ; } , { decider : ForAllSuchThatDecider ; input : { quantifier : SignedByQuantifier ; quantifierParameters : any ; propertyFactory : NonceLessThanPropertyFactory ; } ; } ] ; } ; } export interface AddressBalance { [ address ] : BigNumber ; } export interface StateChannelMessage { addressBalance : AddressBalance ; } param signedMessage param myAddress param signatureVerifier returns export const parseStateChannelSignedMessage = async ( signedMessage , myAddress , signatureVerifier = DefaultSignatureVerifier . instance ( ) ) : Promise < ParsedMessage > => { const message = deserializeMessageString ( signedMessage . serializedMessage , deserializeMessage , stateChannelMessageDeserializer ) ; const sender = await signatureVerifier . verifyMessage ( signedMessage . serializedMessage , signedMessage . signature ) ; const signatures = { } ; signatures [ sender ] = signedMessage . signature ; return { sender , recipient : myAddress , message , signatures , } ; } ;