/* Ċ Ġ* ĠCopyright Ġ 2 0 2 2 ĠP era ĠWallet , ĠL DA Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense Ċ Ġ*/ Ċ Ċ package Ġcom . al gor and . android . utils . wallet connect Ċ Ċ import Ġcom . al gor and . android . models . Wallet Connect Session Meta Ċ import Ġcom . al gor and . android . utils . HTTPS _ PROTOCOL Ċ import Ġcom . al gor and . android . utils . HTTP _ PROTOCOL Ċ import Ġcom . al gor and . android . utils . wallet connect . peer meta . Wallet Connect Peer Meta Builder Ċ import Ġcom . al gor and . android . utils . wallet connect . peer meta . Wallet Connect Per a Peer Meta Ċ import Ġcom . squareup . mos hi . M oshi Ċ import Ġjavax . inject . Inject Ċ import Ġokhttp 3 . Ok HttpClient Ċ import Ġorg . wallet connect . Session . Config Ċ import Ġorg . wallet connect . impl s . File WC Session Store Ċ import Ġorg . wallet connect . impl s . M oshi Payload Adapter Ċ import Ġorg . wallet connect . impl s . Ok Http Transport Ċ import Ġorg . wallet connect . impl s . WC Session Ċ Ċ class ĠWallet Connect Session Builder Ġ@ Inject Ġconstructor ( ĊĠĠĠ Ġprivate Ġval Ġm oshi : ĠM oshi , ĊĠĠĠ Ġprivate Ġval Ġok HttpClient : ĠOk HttpClient , ĊĠĠĠ Ġprivate Ġval Ġstorage : ĠFile WC Session Store , ĊĠĠĠ Ġprivate Ġval Ġwallet Connect Mapper : ĠWC Wallet Connect Mapper Ċ ) Ġ{ ĊĊĠĠĠ Ġfun Ġcreate Session ( url : ĠString ): ĠWallet Connect Session Cached Data ? Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġsession Config Ġ= Ġcreate Session Config From Url ( url ) Ġ?: Ġreturn Ġnull ĊĠĠĠĠĠĠĠ Ġreturn Ġcreate WC Session ( session Config ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġcreate Session ( sessionId : ĠLong , Ġsession Meta : ĠWallet Connect Session Meta ): ĠWallet Connect Session Cached Data ? Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġsession Config Ġ= Ġwallet Connect Mapper . create Session Config ( session Meta ) ĊĠĠĠĠĠĠĠ Ġreturn Ġcreate WC Session ( session Config , ĠsessionId ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcreate WC Session ( session Config : ĠConfig , ĠsessionId : ĠLong ? Ġ= Ġnull ): ĠWallet Connect Session Cached Data ? Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfully Qualified Config Ġ= Ġcreate Fully Qualified Session Config ( session Config ) Ġ?: Ġreturn Ġnull ĊĊĠĠĠĠĠĠĠ Ġif Ġ( check If Wallet Connect Config Has Invalid Bridge Protocol ( fully Qualified Config . bridge )) Ġreturn Ġnull ĊĊĠĠĠĠĠĠĠ Ġval Ġsession Ġ= ĠWC Session ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġconfig Ġ= Ġfully Qualified Config , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpayload Adapter Ġ= ĠM oshi Payload Adapter ( mos hi ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsession Store Ġ= Ġstorage , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtransport Builder Ġ= ĠOk Http Transport . Builder ( ok HttpClient , Ġm oshi ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġclient Meta Ġ= ĠWallet Connect Peer Meta Builder . create Peer Meta ( Wallet Connect Per a Peer Meta ) ĊĠĠĠĠĠĠĠ Ġ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinit () ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġreturn ĠWallet Connect Session Cached Data . create ( session , Ġsession Config , ĠsessionId ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcheck If Wallet Connect Config Has Invalid Bridge Protocol ( bridge : ĠString ): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġ! bridge . contains ( HTTPS _ PROTOCOL , Ġtrue ) Ġ&& Ġ! bridge . contains ( HTTP _ PROTOCOL , Ġtrue ) ĊĠĠĠ Ġ} Ċ } Ċ