diff --git a/e2e/handles/handles.test.ts b/e2e/handles/handles.test.ts index f43c7b6170..1c13362f97 100644 --- a/e2e/handles/handles.test.ts +++ b/e2e/handles/handles.test.ts @@ -121,7 +121,7 @@ describe('๐Ÿค Handles', function () { assert.equal(msaFromHandle.toString(), msa_id.toString(), 'msaFromHandle should be equal to msa_id'); // Check that the rpc returns the index as > 0 - const apiCheck = await ExtrinsicHelper.apiPromise.rpc.handles.checkHandle(handle); + const apiCheck = await ExtrinsicHelper.apiPromise.call.handlesRuntimeApi.checkHandle(handle); assert(apiCheck.suffix_index > 0); }); }); @@ -173,7 +173,7 @@ describe('๐Ÿค Handles', function () { describe('checkHandle basic test', function () { it('expected outcome for a good handle', async function () { - const res = await ExtrinsicHelper.apiPromise.rpc.handles.checkHandle('Little Bobby Tables'); + const res = await ExtrinsicHelper.apiPromise.call.handlesRuntimeApi.checkHandle('Little Bobby Tables'); assert(!res.isEmpty, 'Expected a response'); assert.deepEqual(res.toHuman(), { base_handle: 'Little Bobby Tables', @@ -185,7 +185,7 @@ describe('๐Ÿค Handles', function () { }); it('expected outcome for a bad handle', async function () { - const res = await ExtrinsicHelper.apiPromise.rpc.handles.checkHandle('Robert`DROP TABLE STUDENTS;--'); + const res = await ExtrinsicHelper.apiPromise.call.handlesRuntimeApi.checkHandle('Robert`DROP TABLE STUDENTS;--'); assert(!res.isEmpty, 'Expected a response'); assert.deepEqual(res.toHuman(), { base_handle: 'Robert`DROP TABLE STUDENTS;--', @@ -196,7 +196,7 @@ describe('๐Ÿค Handles', function () { }); }); - it('expected outcome for a good handle with complex whitespace via Runtime API', async function () { + it('expected outcome for a good handle with complex whitespace', async function () { const res = await ExtrinsicHelper.apiPromise.call.handlesRuntimeApi.checkHandle('เคจเฅ€ เคนเฅเคจเฅโ€เคจเฅ เฅค'); assert(!res.isEmpty, 'Expected a response'); assert.deepEqual(res.toHuman(), { @@ -207,22 +207,5 @@ describe('๐Ÿค Handles', function () { valid: true, }); }); - - it('expected outcome for a good handle with complex whitespace via Custom API', async function () { - const res = await ExtrinsicHelper.apiPromise.rpc.handles.checkHandle('เคจเฅ€ เคนเฅเคจเฅโ€เคจเฅ เฅค'); - assert(!res.isEmpty, 'Expected a response'); - assert.deepEqual(res.toHuman(), { - base_handle: 'เคจเฅ€ เคนเฅเคจเฅโ€เคจเฅ เฅค', - canonical_base: 'เคจเคนเคจเคจเฅค', - suffix_index: '0', - suffixes_available: true, - valid: true, - }); - - // Ensure these are the same canonically - const withoutWhitespace = await ExtrinsicHelper.apiPromise.rpc.handles.checkHandle('เคจเฅ€ เคนเฅเคจเฅเคจเฅ เฅค'); - assert(!withoutWhitespace.isEmpty, 'Expected a response'); - assert.equal(withoutWhitespace.toHuman().canonical_base, res.toHuman().canonical_base); - }); }); }); diff --git a/js/api-augment/definitions/handles.ts b/js/api-augment/definitions/handles.ts index 6883174276..2be4ac2a9d 100644 --- a/js/api-augment/definitions/handles.ts +++ b/js/api-augment/definitions/handles.ts @@ -44,16 +44,6 @@ export default { ], type: 'bool', }, - checkHandle: { - description: 'Check the handle and return various data about it', - params: [ - { - name: 'base_handle', - type: 'String', - }, - ], - type: 'CheckHandleResponse', - }, }, types: { HandleSuffix: 'u16', @@ -66,12 +56,5 @@ export default { suffixes: 'Vec', base_handle: 'String', }, - CheckHandleResponse: { - base_handle: 'String', - canonical_base: 'String', - suffix_index: 'u16', - suffixes_available: 'bool', - valid: 'bool', - }, }, }; diff --git a/pallets/handles/src/rpc/src/lib.rs b/pallets/handles/src/rpc/src/lib.rs index a54e1c64ab..8bc7087955 100644 --- a/pallets/handles/src/rpc/src/lib.rs +++ b/pallets/handles/src/rpc/src/lib.rs @@ -11,8 +11,8 @@ use common_helpers::rpc::map_rpc_result; use common_primitives::{ handles::{ - BaseHandle, CheckHandleResponse, DisplayHandle, HandleResponse, - PresumptiveSuffixesResponse, DEFAULT_SUFFIX_COUNT, MAX_SUFFIXES_COUNT, + BaseHandle, DisplayHandle, HandleResponse, PresumptiveSuffixesResponse, + DEFAULT_SUFFIX_COUNT, MAX_SUFFIXES_COUNT, }, msa::MessageSourceId, }; @@ -52,10 +52,6 @@ pub trait HandlesApi { /// validate a handle #[method(name = "handles_validateHandle")] fn validate_handle(&self, base_handle: String) -> RpcResult; - - /// check a handle - #[method(name = "handles_checkHandle")] - fn check_handle(&self, base_handle: String) -> RpcResult; } /// The client handler for the API used by Frequency Service RPC with `jsonrpsee` @@ -137,15 +133,4 @@ where let result = api.validate_handle(at, base_handle); map_rpc_result(result) } - - fn check_handle(&self, base_handle: String) -> RpcResult { - let api = self.client.runtime_api(); - let at = self.client.info().best_hash; - let base_handle: BaseHandle = base_handle - .into_bytes() - .try_into() - .map_err(|_| HandlesRpcError::InvalidHandle)?; - let result = api.check_handle(at, base_handle); - map_rpc_result(result) - } } diff --git a/pallets/handles/src/rpc/src/tests/mod.rs b/pallets/handles/src/rpc/src/tests/mod.rs index 15584528f4..dd40cdf648 100644 --- a/pallets/handles/src/rpc/src/tests/mod.rs +++ b/pallets/handles/src/rpc/src/tests/mod.rs @@ -4,7 +4,7 @@ use super::*; use rpc_mock::*; use common_primitives::{ - handles::{BaseHandle, CheckHandleResponse, DisplayHandle, PresumptiveSuffixesResponse}, + handles::{BaseHandle, DisplayHandle, PresumptiveSuffixesResponse}, node::Block, }; use pallet_handles_runtime_api::HandlesRuntimeApi; @@ -40,16 +40,6 @@ sp_api::mock_impl_runtime_apis! { fn validate_handle(_base_handle: BaseHandle) -> bool { true } - - fn check_handle(base_handle: BaseHandle) -> CheckHandleResponse { - CheckHandleResponse { - base_handle: base_handle.clone().into(), - valid: true, - suffix_index: 0, - suffixes_available: true, - canonical_base: "canonical_base".into() - } - } } } @@ -104,17 +94,3 @@ async fn get_msa_for_handle_with_success() { assert_eq!(true, result.is_ok()); assert_eq!(Some(VALID_MSA_ID), result.unwrap()); } - -#[tokio::test] -async fn check_handle_with_success() { - let client = Arc::new(TestApi {}); - let api = HandlesHandler::new(client); - let result = api.check_handle("base_handle".to_string()); - - assert_eq!(true, result.is_ok()); - let response = result.unwrap(); - assert!(response.valid); - assert!(response.suffixes_available); - assert_eq!(b"base_handle".to_vec(), response.base_handle); - assert_eq!(b"canonical_base".to_vec(), response.canonical_base); -}