-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(common): clarify resourceId (hex) from resource (object) (#1706)
- Loading branch information
Showing
36 changed files
with
121 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
"@latticexyz/common": minor | ||
--- | ||
|
||
Renames `resourceIdToHex` to `resourceToHex` and `hexToResourceId` to `hexToResource`, to better distinguish between a resource ID (hex value) and a resource reference (type, namespace, name). | ||
|
||
```diff | ||
- resourceIdToHex({ type: 'table', namespace: '', name: 'Position' }); | ||
+ resourceToHex({ type: 'table', namespace: '', name: 'Position' }); | ||
``` | ||
|
||
```diff | ||
- hexToResourceId('0x...'); | ||
+ hexToResource('0x...'); | ||
``` | ||
|
||
Previous methods still exist but are now deprecated to ease migration and reduce breaking changes. These will be removed in a future version. | ||
|
||
Also removes the previously deprecated and unused table ID utils (replaced by these resource ID utils). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@latticexyz/cli": patch | ||
"@latticexyz/dev-tools": patch | ||
"@latticexyz/store-sync": patch | ||
--- | ||
|
||
Moved to new resource ID utils. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import { Hex } from "viem"; | ||
import { ResourceType } from "./resourceTypes"; | ||
|
||
export type ResourceId = { | ||
export type Resource = { | ||
resourceId: Hex; | ||
type: ResourceType; | ||
namespace: string; | ||
name: string; | ||
type: ResourceType; | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
packages/common/src/createContract.ts → ...s/common/src/deprecated/createContract.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { getContract } from "./getContract"; | ||
import { getContract } from "../getContract"; | ||
|
||
/** @deprecated use `getContract` instead */ | ||
export const createContract = getContract; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { hexToResource } from "../hexToResource"; | ||
|
||
/** @deprecated use `hexToResource` instead */ | ||
export const hexToResourceId = hexToResource; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { resourceToHex } from "../resourceToHex"; | ||
|
||
/** @deprecated use `resourceToHex` instead */ | ||
export const resourceIdToHex = resourceToHex; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { describe, it, expect } from "vitest"; | ||
import { hexToResource } from "./hexToResource"; | ||
|
||
describe("hexToResource", () => { | ||
it("can convert from hex string", () => { | ||
const resource = hexToResource("0x74626e616d65737061636500000000006e616d65000000000000000000000000"); | ||
expect(resource.type).toMatchInlineSnapshot('"table"'); | ||
expect(resource.namespace).toMatchInlineSnapshot('"namespace"'); | ||
expect(resource.name).toMatchInlineSnapshot('"name"'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.