import { U64 } from "codechain-primitives" ; import { Order , OrderJSON } from "./Order" ; const RLP = require ( "rlp" ) ; export interface OrderOnTransferJSON { order : OrderJSON ; spentQuantity : string ; inputFromIndices : number [ ] ; inputFeeIndices : number [ ] ; outputFromIndices : number [ ] ; outputToIndices : number [ ] ; outputOwnedFeeIndices : number [ ] ; outputTransferredFeeIndices : number [ ] ; } export interface OrderOnTransferData { order : Order ; spentQuantity : U64 ; inputFromIndices : number [ ] ; inputFeeIndices : number [ ] ; outputFromIndices : number [ ] ; outputToIndices : number [ ] ; outputOwnedFeeIndices : number [ ] ; outputTransferredFeeIndices : number [ ] ; } export class OrderOnTransfer { param data returns public static fromJSON ( data ) { const { order , spentQuantity , inputFromIndices , inputFeeIndices , outputFromIndices , outputToIndices , outputOwnedFeeIndices , outputTransferredFeeIndices } = data ; return new OrderOnTransfer ( { order : Order . fromJSON ( order ) , spentQuantity : U64 . ensure ( spentQuantity ) , inputFromIndices , inputFeeIndices , outputFromIndices , outputToIndices , outputOwnedFeeIndices , outputTransferredFeeIndices } ) ; } public readonly order : Order ; public readonly spentQuantity : U64 ; public inputFromIndices : number [ ] ; public inputFeeIndices : number [ ] ; public outputFromIndices : number [ ] ; public outputToIndices : number [ ] ; public outputOwnedFeeIndices : number [ ] ; public outputTransferredFeeIndices : number [ ] ; param params . order param data . spentQuantity param data . inputIndices param data . outputIndices constructor ( data ) { const { order , spentQuantity , inputFromIndices , inputFeeIndices , outputFromIndices , outputToIndices , outputOwnedFeeIndices , outputTransferredFeeIndices } = data ; this . order = order ; this . spentQuantity = spentQuantity ; this . inputFromIndices = inputFromIndices ; this . inputFeeIndices = inputFeeIndices ; this . outputFromIndices = outputFromIndices ; this . outputToIndices = outputToIndices ; this . outputOwnedFeeIndices = outputOwnedFeeIndices ; this . outputTransferredFeeIndices = outputTransferredFeeIndices ; } /**
     * Convert to an object for RLP encoding.
     */ public toEncodeObject ( ) { const { order , spentQuantity , inputFromIndices , inputFeeIndices , outputFromIndices , outputToIndices , outputOwnedFeeIndices , outputTransferredFeeIndices } = this ; return [ order . toEncodeObject ( ) , spentQuantity . toEncodeObject ( ) , inputFromIndices , inputFeeIndices , outputFromIndices , outputToIndices , outputOwnedFeeIndices , outputTransferredFeeIndices ] ; } /**
     * Convert to RLP bytes.
     */ public rlpBytes ( ) { return RLP . encode ( this . toEncodeObject ( ) ) ; } returns public toJSON ( ) { const { order , spentQuantity , inputFromIndices , inputFeeIndices , outputFromIndices , outputToIndices , outputOwnedFeeIndices , outputTransferredFeeIndices } = this ; return { order : order . toJSON ( ) , spentQuantity : spentQuantity . toJSON ( ) , inputFromIndices , inputFeeIndices , outputFromIndices , outputToIndices , outputOwnedFeeIndices , outputTransferredFeeIndices } ; } returns public getConsumedOrder ( ) { return this . order . consume ( this . spentQuantity ) ; } }