-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(common): clarify resourceId (hex) from resource (object) #1706
Changes from all commits
9077d77
1b1b420
78a343f
83756bf
48fa18c
46a228e
f77f2ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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). |
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. |
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.
This file was deleted.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it seems like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah i see now There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep! we're just keeping things in |
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.
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.
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; |
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 was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since there's
@deprecated
typedoc operator that does a better job of signaling deprecated stuff, I am preferring that now over marking this as deprecated in the export path