From e4d97bca4648277a03dc7b27efe93c933b5f77c3 Mon Sep 17 00:00:00 2001 From: alvarius Date: Thu, 21 Sep 2023 16:34:49 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Kevin Ingersoll --- packages/common/src/hexToResourceId.test.ts | 2 +- packages/common/src/hexToResourceId.ts | 4 ++-- packages/world/src/interfaces/IModule.sol | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/common/src/hexToResourceId.test.ts b/packages/common/src/hexToResourceId.test.ts index 28ae646a03..56ebfecfdb 100644 --- a/packages/common/src/hexToResourceId.test.ts +++ b/packages/common/src/hexToResourceId.test.ts @@ -4,8 +4,8 @@ import { hexToResourceId } from "./hexToResourceId"; describe("hexToResourceId", () => { it("can convert from hex string", () => { const resourceId = hexToResourceId("0x74626e616d65737061636500000000006e616d65000000000000000000000000"); + expect(resourceId.type).toMatchInlineSnapshot('"table"'); expect(resourceId.namespace).toMatchInlineSnapshot('"namespace"'); expect(resourceId.name).toMatchInlineSnapshot('"name"'); - expect(resourceId.type).toMatchInlineSnapshot('"table"'); }); }); diff --git a/packages/common/src/hexToResourceId.ts b/packages/common/src/hexToResourceId.ts index b2bce87dfd..2f45ac2c17 100644 --- a/packages/common/src/hexToResourceId.ts +++ b/packages/common/src/hexToResourceId.ts @@ -18,13 +18,13 @@ function getResourceType(resourceTypeId: string): ResourceType | undefined { export function hexToResourceId(hex: Hex): ResourceId { const resourceTypeId = hexToString(sliceHex(hex, 0, 2)).replace(/\0+$/, ""); + const type = getResourceType(resourceTypeId); const namespace = hexToString(sliceHex(hex, 2, 16)).replace(/\0+$/, ""); const name = hexToString(sliceHex(hex, 16, 32)).replace(/\0+$/, ""); - const type = getResourceType(resourceTypeId); if (!type) { throw new Error(`Unknown resource type: ${resourceTypeId}`); } - return { namespace, name, type }; + return { type, namespace, name }; } diff --git a/packages/world/src/interfaces/IModule.sol b/packages/world/src/interfaces/IModule.sol index 407cbd51de..8a79abd7db 100644 --- a/packages/world/src/interfaces/IModule.sol +++ b/packages/world/src/interfaces/IModule.sol @@ -10,7 +10,6 @@ bytes4 constant MODULE_INTERFACE_ID = IModule.getName.selector ^ ERC165_INTERFACE_ID; interface IModule is IERC165 { - error RequiredModuleNotFound(string moduleIdString); error RootInstallModeNotSupported(); error NonRootInstallNotSupported();