package Ġcom . deriv hack Ċ Ċ import Ġco . parallel universe . fib ers . Suspend able Ċ import Ġnet . cord a . cd ms upport . Validation Un success full Ċ import Ġnet . cord a . cd ms upport . event parsing . parse Event FromJson Ċ import Ġnet . cord a . cd ms upport . transaction building . C dm Transaction Builder Ċ import Ġnet . cord a . cd ms upport . validators . C dm Validators Ċ import Ġnet . cord a . cd ms upport . vault query ing . Default C dm Vault Query Ċ import Ġnet . cord a . core . contracts . require That Ċ import Ġnet . cord a . core . flows .* Ċ import Ġnet . cord a . core . transactions . Signed Transaction Ċ Ċ @ Initi ating Flow Ċ @ Start able By RPC Ċ class ĠAl location Flow ( val Ġallocation Json : ĠString ) Ġ: ĠFlow Logic < Signed Transaction >() Ġ{ ĊĊĠĠĠ Ġ// TODO ĊĠĠĠ Ġ/** ĊĠĠĠĠ Ġ* Ġ ĠYou 're Ġexpected Ġto Ġwork Ġtowards Ġthe ĠJSON Ġfiles Ġfor Ġthe Ġallocation Ġevent Ġprovided Ġfor Ġthe ĊĠĠĠĠ Ġ* Ġ ĠUse ĠCase Ġ 2 Ġ( UC 2 _ Allocation _ Trade _ AT 1 . json Ġ... ), Ġby Ġusing Ġthe Ġparse Event FromJson Ġfunction ĊĠĠĠĠ Ġ* Ġ Ġfrom Ġthe Ġc dm - support Ġpackage Ġand Ġingest / consume Ġthe Ġallocation Ġtr ades Ġon ĠC ord a , ĊĠĠĠĠ Ġ* Ġ Ġdemonstrate Ġline age Ġto Ġthe Ġblock Ġtrade Ġfrom ĠU C 1 Ġand Ġvalidate Ġthe Ġtrade ĊĠĠĠĠ Ġ* Ġ Ġagainst ĠC DM Ġdata Ġrules Ġby Ġcreating Ġvalidations Ġsimilar Ġto Ġthose Ġfor ĠU C 1 . ĊĠĠĠĠ Ġ* ĊĠĠĠĠ Ġ* Ġ ĠB onus : ĠInstead Ġof Ġjust Ġloading Ġthe Ġready Ġto Ġuse ĠJson Ġfil , Ġyou Ġcan Ġbuild Ġyour Ġown ĊĠĠĠĠ Ġ* Ġ ĠAl location ĠEvent , Ġusing Ġthe ĠAllocate Ġfunctions Ġof Ġthe ĠC DM Ġand Ġthe ĠC ord a ĠImplementation ĊĠĠĠĠ Ġ* Ġ Ġand Ġbuild ers Ġthat Ġyou Ġcan Ġfind Ġin Ġnet . cord a . cd ms upport . builders Ġpackage Ġin Ġthe Ġproject ĊĠĠĠĠ Ġ* ĊĠĠĠĠ Ġ* Ġ ĠAdd Ġan ĠObserver y Ġmode Ġto Ġthe Ġtransaction ĊĠĠĠĠ Ġ*/ ĊĊĠĠĠ Ġ@ Suspend able ĊĠĠĠ Ġoverride Ġfun Ġcall (): ĠSigned Transaction Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġevent Ġ= Ġparse Event FromJson ( allocation Json ) ĊĠĠĠĠĠĠĠ Ġval Ġnot ary Ġ= Ġservice Hub . network Map Cache . not ary Id entities . first () ĊĠĠĠĠĠĠĠ Ġval Ġc dm Transaction Builder Ġ= ĠC dm Transaction Builder ( not ary , Ġevent , ĠDefault C dm Vault Query ( service Hub )) ĊĠĠĠĠĠĠĠ Ġc dm Transaction Builder . verify ( service Hub ) ĊĠĠĠĠĠĠĠ Ġval Ġsigned By Me Ġ= Ġservice Hub . sign Initial Transaction ( cd m Transaction Builder ) ĊĊĠĠĠĠĠĠĠ Ġval Ġcounter Party Sessions Ġ= Ġc dm Transaction Builder . get Part ies To Sign (). minus ( our Identity ). map Ġ{ Ġinitiate Flow ( it ) Ġ} ĊĊĊĊĠĠĠĠĠĠĠ Ġval Ġfully Signed Tx Ġ= Ġsub Flow ( Collect Signatures Flow ( signed By Me , Ġcounter Party Sessions , ĠCollect Signatures Flow . tracker ())) ĊĠĠĠĠĠĠĠ Ġval Ġfinal ity Tx Ġ= Ġsub Flow ( Final ity Flow ( fully Signed Tx , Ġcounter Party Sessions )) ĊĊĊĠĠĠĠĠĠĠ Ġreturn Ġfinal ity Tx ĊĊĠĠĠ Ġ} Ċ } Ċ Ċ @ Initi ated By ( Allocation Flow :: class ) Ċ class ĠAl location Response ( val Ġflow Session : ĠFlow Session ) Ġ: ĠFlow Logic < Signed Transaction >() Ġ{ ĊĊĠĠĠ Ġ@ Suspend able ĊĠĠĠ Ġoverride Ġfun Ġcall (): ĠSigned Transaction Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġsigned Transaction Flow Ġ= Ġobject Ġ: ĠSign Transaction Flow ( flow Session ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġcheck Transaction ( st x : ĠSigned Transaction ) Ġ= Ġrequire That Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġsigned Id Ġ= Ġsub Flow ( signed Transaction Flow ) ĊĊĠĠĠĠĠĠĠ Ġreturn Ġsub Flow ( Receive Final ity Flow ( other Side Session Ġ= Ġflow Session , Ġexpected Tx Id Ġ= Ġsigned Id . id )) ĊĠĠĠ Ġ} Ċ } ĊĊ