import { RadixSerializer , includeJSON , includeDSON , RadixParticle , RadixAddress , RadixBytes } from '../..' ; import { createNonce } from '../../primitives/Nonce' ; /**
 * Particle which can hold arbitrary data
 */ @ RadixSerializer . registerClass ( 'radix.particles.message' ) export class RadixMessageParticle extends RadixParticle { @ includeJSON @ includeDSON public from : RadixAddress ; @ includeJSON @ includeDSON public to : RadixAddress ; @ includeDSON @ includeJSON public metaData : { [ s ] : string ; } ; @ includeDSON @ includeJSON public bytes : RadixBytes ; @ includeDSON @ includeJSON public nonce : number ; constructor ( from , to , data , metaData , nonce ? ) { super ( ) ; this . from = from ; this . to = to ; this . bytes = new RadixBytes ( data ) ; this . metaData = metaData ; this . nonce = nonce ? nonce : createNonce ( ) ; } public getAddresses ( ) { return [ this . from , this . to ] ; } public getData ( ) { return this . bytes ; } public getMetaData ( key ) { const metaData = this . metaData ; if ( metaData && key in metaData ) { return metaData [ key ] ; } return null ; } public getNonce ( ) { return this . nonce ; } }