@@ -148,7 +148,7 @@ describe("parseEntities", () => {
148
148
expect ( result ) . toEqual ( [
149
149
{
150
150
entityId :
151
- "0x14c362c17947ef1d40152d6e3bedd859c98bebfad41f75ef3f26798556a4c85 " ,
151
+ "0x014c362c17947ef1d40152d6e3bedd859c98bebfad41f75ef3f26798556a4c85 " ,
152
152
models : {
153
153
dojo_starter : {
154
154
Position : {
@@ -169,7 +169,7 @@ describe("parseEntities", () => {
169
169
} ,
170
170
{
171
171
entityId :
172
- "0x144c128b8ead7d0da39c6a150abbfdd38f572ba9418d3e36929eb6107b4ce4d " ,
172
+ "0x0144c128b8ead7d0da39c6a150abbfdd38f572ba9418d3e36929eb6107b4ce4d " ,
173
173
models : {
174
174
dojo_starter : {
175
175
Moves : {
@@ -409,6 +409,72 @@ describe("parseEntities", () => {
409
409
) . toBe ( "number" ) ;
410
410
} ) ;
411
411
412
+ it ( "should properly pad entity IDs to consistent length" , ( ) => {
413
+ const toriiResult : torii . Entity [ ] = [
414
+ {
415
+ // Unpadded entity ID (shorter)
416
+ hashed_keys : "0x1" ,
417
+ models : {
418
+ "test-Model" : {
419
+ id : {
420
+ type : "primitive" ,
421
+ type_name : "u32" ,
422
+ value : 1 ,
423
+ key : true ,
424
+ } ,
425
+ } ,
426
+ } ,
427
+ } ,
428
+ {
429
+ // Already padded entity ID
430
+ hashed_keys :
431
+ "0x0000000000000000000000000000000000000000000000000000000000000002" ,
432
+ models : {
433
+ "test-Model" : {
434
+ id : {
435
+ type : "primitive" ,
436
+ type_name : "u32" ,
437
+ value : 2 ,
438
+ key : true ,
439
+ } ,
440
+ } ,
441
+ } ,
442
+ } ,
443
+ {
444
+ // Partially padded entity ID
445
+ hashed_keys : "0x00000003" ,
446
+ models : {
447
+ "test-Model" : {
448
+ id : {
449
+ type : "primitive" ,
450
+ type_name : "u32" ,
451
+ value : 3 ,
452
+ key : true ,
453
+ } ,
454
+ } ,
455
+ } ,
456
+ } ,
457
+ ] ;
458
+
459
+ const res = parseEntities ( toriiResult ) ;
460
+
461
+ // All entity IDs should be padded to 66 characters (0x + 64 hex chars)
462
+ expect ( res [ 0 ] ?. entityId ) . toBe (
463
+ "0x0000000000000000000000000000000000000000000000000000000000000001"
464
+ ) ;
465
+ expect ( res [ 1 ] ?. entityId ) . toBe (
466
+ "0x0000000000000000000000000000000000000000000000000000000000000002"
467
+ ) ;
468
+ expect ( res [ 2 ] ?. entityId ) . toBe (
469
+ "0x0000000000000000000000000000000000000000000000000000000000000003"
470
+ ) ;
471
+
472
+ // Verify all have the same length
473
+ expect ( res [ 0 ] ?. entityId ?. length ) . toBe ( 66 ) ;
474
+ expect ( res [ 1 ] ?. entityId ?. length ) . toBe ( 66 ) ;
475
+ expect ( res [ 2 ] ?. entityId ?. length ) . toBe ( 66 ) ;
476
+ } ) ;
477
+
412
478
it ( "should parse all primitive types correctly according to Rust serialization" , ( ) => {
413
479
const toriiResult : torii . Entity [ ] = [
414
480
{
0 commit comments