Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .changeset/rude-doors-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
"@dojoengine/state": patch
"template-vite-ts": patch
"@dojoengine/core": patch
"@dojoengine/create-burner": patch
"@dojoengine/create-dojo": patch
"@dojoengine/predeployed-connector": patch
"@dojoengine/react": patch
"@dojoengine/sdk": patch
"@dojoengine/torii-client": patch
"@dojoengine/torii-wasm": patch
"@dojoengine/utils": patch
"@dojoengine/utils-wasm": patch
---

fix: recs convertValues do not set to null
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export function defineContractComponents(world: World) {
},
{
metadata: {
name: "dojo_starter-Position",
namespace: "dojo_starter",
name: "Position",
types: ["contractaddress", "u32", "u32"],
customTypes: ["Vec2"],
},
Expand Down
13 changes: 13 additions & 0 deletions packages/state/src/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,4 +348,17 @@ describe("convertValues", () => {
const expected = {};
expect(convertValues(schema, values)).toEqual(expected);
});
it("should not set value to undefined", () => {
const schema: Schema = {
name: RecsType.String,
age: RecsType.Number,
};
const values = {
name: { value: "Alice", type: "string" },
};
const expected = {
name: "Alice",
};
expect(convertValues(schema, values)).toStrictEqual(expected);
});
});
6 changes: 6 additions & 0 deletions packages/state/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ export function convertValues(schema: Schema, values: any) {
let schemaType = schema[key];
let value = values[key];

// If key in values is not present, no need to set it to null
// so we return the accumulator as is
if (undefined === value) {
return acc;
}

if (value == null) {
acc[key] = value;
return acc;
Expand Down
Loading