import { BinaryReader , BinaryWriter , createSerializeWire , InvalidFormatError , JSONHelper , toWitnessScope , WitnessScopeModel , } from '@neo-one/client-common' ; import { DeserializeWireBaseOptions , DeserializeWireOptions , SerializableContainer , SerializableContainerType , } from './Serializable' ; import { Signer } from './Signer' ; import { Witness } from './Witness' ; export interface SignersAdd { readonly signers : readonly Signer [ ] ; } export class Signers implements SerializableContainer { public static deserializeWireBase ( options ) { const { reader } = options ; const signers = reader . readArray ( ( ) => Signer . deserializeWireBase ( options ) ) ; return new this ( { signers } ) ; } public static deserializeWire ( options ) { return this . deserializeWireBase ( { context : options . context , reader : new BinaryReader ( options . buffer ) } ) ; } public static fromJSON ( json ) { if ( ! Array . isArray ( json ) ) { throw new InvalidFormatError ( ) ; } return new Signers ( { signers : json . map ( ( signer ) => new Signer ( { account : JSONHelper . readUInt160 ( signer . account ) , scopes : signer . scopes === undefined ? WitnessScopeModel . None : toWitnessScope ( signer ?. scopes ) , allowedContracts : signer . allowedcontracts ?. map ( ( contract ) => JSONHelper . readUInt160 ( contract ) ) , allowedGroups : signer . allowedgroups ?. map ( ( group ) => JSONHelper . readECPoint ( group ) ) } ) ) } ) ; } public readonly type : SerializableContainerType = 'Signers' ; public readonly serializeWire = createSerializeWire ( this . serializeWireBase . bind ( this ) ) ; public readonly signers : readonly Signer [ ] ; public readonly witnesses : readonly Witness [ ] = [ ] ; public constructor ( { signers } ) { this . signers = signers ; } public getScriptHashesForVerifying ( ) { return this . signers . map ( ( signer ) => signer . account ) ; } public serializeWireBase ( writer ) { writer . writeArray ( this . signers , ( signer ) => signer . serializeWireBase ( writer ) ) ; } }