import { abi , AbiRange , AbiEncodable , BigNumber , hexStringify , } from '@pigi/core-utils' ; import { AbiStateObject } from './state-object' ; import { OwnershipBody , Transaction } from '../../types' ; param encoded returns const fromEncodedOwnershipBody = ( encoded ) : AbiOwnershipBody => { const decoded = abi . decode ( AbiOwnershipBody . abiTypes , encoded ) ; const newState = AbiStateObject . from ( decoded [ 0 ] ) ; const originBlock = new BigNumber ( decoded [ 1 ] . toString ( ) ) ; const maxBlock = new BigNumber ( decoded [ 2 ] . toString ( ) ) ; return new AbiOwnershipBody ( newState , originBlock , maxBlock ) ; } ; /**
 * Represents a basic abi encodable AbiOwnershipBody
 */ export class AbiOwnershipBody implements OwnershipBody , AbiEncodable { public static abiTypes = [ 'bytes' , 'uint128' , 'uint128' ] ; constructor ( readonly newState , readonly originBlock , readonly maxBlock ) { } returns get encoded ( ) : string { return abi . encode ( AbiOwnershipBody . abiTypes , [ this . newState . encoded , hexStringify ( this . originBlock ) , hexStringify ( this . maxBlock ) , ] ) ; } returns get jsonified ( ) : any { return { newState : this . newState . jsonified , originBlock : hexStringify ( this . originBlock ) , maxBlock : hexStringify ( this . maxBlock ) , } ; } param encoded returns public static from ( encoded ) { if ( typeof encoded === 'string' ) { return fromEncodedOwnershipBody ( encoded ) ; } throw new Error ( 'Got invalid argument type when casting to AbiStateUpdate.' ) ; } } param encoded returns const fromEncodedOwnershipTransaction = ( encoded ) : AbiOwnershipTransaction => { const decoded = abi . decode ( AbiOwnershipTransaction . abiTypes , encoded ) ; const depositAddress = decoded [ 0 ] ; const range = AbiRange . from ( decoded [ 1 ] ) ; const body = AbiOwnershipBody . from ( decoded [ 2 ] ) ; return new AbiOwnershipTransaction ( depositAddress , range , body ) ; } ; /**
 * Represents a basic abi encodable AbiOwnershipTransaction
 */ export class AbiOwnershipTransaction implements Transaction , AbiEncodable { public static abiTypes = [ 'address' , 'bytes' , 'bytes' ] ; constructor ( readonly depositAddress , readonly range , readonly body ) { } returns get encoded ( ) : string { return abi . encode ( AbiOwnershipTransaction . abiTypes , [ this . depositAddress , this . range . encoded , this . body . encoded , ] ) ; } returns get jsonified ( ) : any { return { depositAddress : this . depositAddress , range : this . range . jsonified , body : this . body . encoded , } ; } param value returns public static from ( encoded ) { if ( typeof encoded === 'string' ) { return fromEncodedOwnershipTransaction ( encoded ) ; } throw new Error ( 'Got invalid argument type when casting to AbiStateUpdate.' ) ; } param other returns public equals ( other ) { return this . encoded === other . encoded ; } }