@@ -29,8 +29,8 @@ use futures::StreamExt;
2929use futures:: stream:: { self , BoxStream } ;
3030
3131use truapi:: v01;
32- use truapi:: versioned:: system:: { HostFeatureSupportedRequest , HostFeatureSupportedResponse } ;
3332
33+ use crate :: async_trait;
3434use crate :: {
3535 AuthPresenter , AuthState , ChainProvider , CoreStorage , CoreStorageKey , Features ,
3636 JsonRpcConnection , Navigation , Notifications , Permissions , PreimageHost , ProductStorage ,
@@ -254,9 +254,10 @@ fn core_key(key: &CoreStorageKey) -> String {
254254 match key {
255255 CoreStorageKey :: AuthSession => "core:auth-session" . to_string ( ) ,
256256 CoreStorageKey :: PairingDeviceIdentity => "core:pairing-device-identity" . to_string ( ) ,
257- CoreStorageKey :: PermissionAuthorization { storage_key } => {
258- format ! ( "core:permission:{storage_key}" )
259- }
257+ CoreStorageKey :: PermissionAuthorization {
258+ product_id,
259+ request,
260+ } => format ! ( "core:permission:{product_id}:{request:?}" ) ,
260261 }
261262}
262263
@@ -268,6 +269,7 @@ fn preimage_key(value: &[u8]) -> Vec<u8> {
268269 hasher. finish ( ) . to_le_bytes ( ) . to_vec ( )
269270}
270271
272+ #[ async_trait]
271273impl ProductStorage for MockPlatform {
272274 async fn read ( & self , key : String ) -> Result < Option < Vec < u8 > > , v01:: HostLocalStorageReadError > {
273275 if let Some ( reason) = & self . config . faults . storage_error {
@@ -314,6 +316,7 @@ impl ProductStorage for MockPlatform {
314316 }
315317}
316318
319+ #[ async_trait]
317320impl CoreStorage for MockPlatform {
318321 async fn read_core_storage (
319322 & self ,
@@ -363,6 +366,7 @@ impl CoreStorage for MockPlatform {
363366 }
364367}
365368
369+ #[ async_trait]
366370impl Navigation for MockPlatform {
367371 async fn navigate_to ( & self , url : String ) -> Result < ( ) , v01:: HostNavigateToError > {
368372 if let Some ( reason) = & self . config . faults . navigate_error {
@@ -378,6 +382,7 @@ impl Navigation for MockPlatform {
378382 }
379383}
380384
385+ #[ async_trait]
381386impl Notifications for MockPlatform {
382387 async fn push_notification (
383388 & self ,
@@ -405,6 +410,7 @@ impl Notifications for MockPlatform {
405410 }
406411}
407412
413+ #[ async_trait]
408414impl Permissions for MockPlatform {
409415 async fn device_permission (
410416 & self ,
@@ -425,17 +431,15 @@ impl Permissions for MockPlatform {
425431 }
426432}
427433
434+ #[ async_trait]
428435impl Features for MockPlatform {
429436 async fn feature_supported (
430437 & self ,
431- request : HostFeatureSupportedRequest ,
432- ) -> Result < HostFeatureSupportedResponse , v01:: GenericError > {
433- let HostFeatureSupportedRequest :: V1 ( _) = request;
434- Ok ( HostFeatureSupportedResponse :: V1 (
435- v01:: HostFeatureSupportedResponse {
436- supported : self . config . feature_supported ,
437- } ,
438- ) )
438+ _request : v01:: HostFeatureSupportedRequest ,
439+ ) -> Result < v01:: HostFeatureSupportedResponse , v01:: GenericError > {
440+ Ok ( v01:: HostFeatureSupportedResponse {
441+ supported : self . config . feature_supported ,
442+ } )
439443 }
440444}
441445
@@ -457,8 +461,11 @@ impl JsonRpcConnection for MockConnection {
457461 Some ( frames) => Box :: pin ( stream:: iter ( frames. clone ( ) ) ) ,
458462 }
459463 }
464+
465+ fn close ( & self ) { }
460466}
461467
468+ #[ async_trait]
462469impl ChainProvider for MockPlatform {
463470 async fn connect (
464471 & self ,
@@ -493,6 +500,7 @@ impl AuthPresenter for MockPlatform {
493500 }
494501}
495502
503+ #[ async_trait]
496504impl UserConfirmation for MockPlatform {
497505 async fn confirm_user_action (
498506 & self ,
@@ -519,6 +527,7 @@ impl ThemeHost for MockPlatform {
519527 }
520528}
521529
530+ #[ async_trait]
522531impl PreimageHost for MockPlatform {
523532 async fn submit_preimage ( & self , value : Vec < u8 > ) -> Result < Vec < u8 > , v01:: PreimageSubmitError > {
524533 if let Some ( reason) = & self . config . faults . preimage_submit_error {
@@ -610,12 +619,7 @@ mod tests {
610619 // ...and a product key must not be visible through core storage.
611620 block_on ( p. write ( "x" . into ( ) , vec ! [ 2 ] ) ) . unwrap ( ) ;
612621 assert_eq ! (
613- block_on(
614- p. read_core_storage( CoreStorageKey :: PermissionAuthorization {
615- storage_key: "x" . into( )
616- } )
617- )
618- . unwrap( ) ,
622+ block_on( p. read_core_storage( CoreStorageKey :: PairingDeviceIdentity ) ) . unwrap( ) ,
619623 None
620624 ) ;
621625 }
@@ -744,11 +748,11 @@ mod tests {
744748 feature_supported : false ,
745749 ..Default :: default ( )
746750 } ) ;
747- let HostFeatureSupportedResponse :: V1 ( response) = block_on ( p . feature_supported (
748- HostFeatureSupportedRequest :: V1 ( v01:: HostFeatureSupportedRequest :: Chain {
751+ let response = block_on (
752+ p . feature_supported ( v01:: HostFeatureSupportedRequest :: Chain {
749753 genesis_hash : vec ! [ 0 ; 32 ] ,
750754 } ) ,
751- ) )
755+ )
752756 . unwrap ( ) ;
753757 assert ! ( !response. supported) ;
754758 }
0 commit comments