From b555f4a40e74f4888fdeb4da5924ad370056bbc9 Mon Sep 17 00:00:00 2001 From: skywardboundd Date: Fri, 13 Jun 2025 14:32:02 +0300 Subject: [PATCH 1/3] fix(codegen): use opcodes constants in generated serializers --- src/bindings/typescript/writeStruct.ts | 7 ++++++- src/bindings/writeTypescript.ts | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/bindings/typescript/writeStruct.ts b/src/bindings/typescript/writeStruct.ts index c5c0d00334..32b4eea182 100644 --- a/src/bindings/typescript/writeStruct.ts +++ b/src/bindings/typescript/writeStruct.ts @@ -89,6 +89,7 @@ export function writeSerializer( s: ABIType, allocation: AllocationCell, w: Writer, + contractName?: string, ) { w.append(`export function store${s.name}(src: ${s.name}) {`); w.inIndent(() => { @@ -96,7 +97,11 @@ export function writeSerializer( w.inIndent(() => { w.append(`const b_0 = builder;`); if (s.header) { - w.append(`b_0.storeUint(${s.header}, 32);`); + if (contractName) { + w.append(`b_0.storeUint(${contractName}_opcodes.${s.name}, 32);`); + } else { + w.append(`b_0.storeUint(${s.header}, 32);`); + } } writeSerializerCell(0, allocation, w); }); diff --git a/src/bindings/writeTypescript.ts b/src/bindings/writeTypescript.ts index 25ccac4358..d45bfe5c89 100644 --- a/src/bindings/writeTypescript.ts +++ b/src/bindings/writeTypescript.ts @@ -152,7 +152,7 @@ export function writeTypescript( for (const s of abi.types) { writeStruct(s.name, s.fields, true, w); - writeSerializer(s, allocations[s.name]!.root, w); + writeSerializer(s, allocations[s.name]!.root, w, `${abi.name}$`); writeParser(s, allocations[s.name]!.root, w); writeTupleParser(s, w); writeGetterTupleParser(s, w); From 299a0b4db6a3ea933d30cd7ab8459213f4203fbe Mon Sep 17 00:00:00 2001 From: skywardboundd Date: Fri, 13 Jun 2025 15:13:29 +0300 Subject: [PATCH 2/3] Revert "fix(codegen): use opcodes constants in generated serializers" This reverts commit b555f4a40e74f4888fdeb4da5924ad370056bbc9. --- src/bindings/typescript/writeStruct.ts | 7 +------ src/bindings/writeTypescript.ts | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/bindings/typescript/writeStruct.ts b/src/bindings/typescript/writeStruct.ts index 32b4eea182..c5c0d00334 100644 --- a/src/bindings/typescript/writeStruct.ts +++ b/src/bindings/typescript/writeStruct.ts @@ -89,7 +89,6 @@ export function writeSerializer( s: ABIType, allocation: AllocationCell, w: Writer, - contractName?: string, ) { w.append(`export function store${s.name}(src: ${s.name}) {`); w.inIndent(() => { @@ -97,11 +96,7 @@ export function writeSerializer( w.inIndent(() => { w.append(`const b_0 = builder;`); if (s.header) { - if (contractName) { - w.append(`b_0.storeUint(${contractName}_opcodes.${s.name}, 32);`); - } else { - w.append(`b_0.storeUint(${s.header}, 32);`); - } + w.append(`b_0.storeUint(${s.header}, 32);`); } writeSerializerCell(0, allocation, w); }); diff --git a/src/bindings/writeTypescript.ts b/src/bindings/writeTypescript.ts index d45bfe5c89..25ccac4358 100644 --- a/src/bindings/writeTypescript.ts +++ b/src/bindings/writeTypescript.ts @@ -152,7 +152,7 @@ export function writeTypescript( for (const s of abi.types) { writeStruct(s.name, s.fields, true, w); - writeSerializer(s, allocations[s.name]!.root, w, `${abi.name}$`); + writeSerializer(s, allocations[s.name]!.root, w); writeParser(s, allocations[s.name]!.root, w); writeTupleParser(s, w); writeGetterTupleParser(s, w); From 626f765664841c2385a03c1e31c139deba3835aa Mon Sep 17 00:00:00 2001 From: skywardboundd Date: Fri, 13 Jun 2025 15:22:23 +0300 Subject: [PATCH 3/3] fix(codegen): use opcodes constants in generated serializers --- src/bindings/typescript/writeStruct.ts | 3 ++- src/bindings/writeTypescript.ts | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/bindings/typescript/writeStruct.ts b/src/bindings/typescript/writeStruct.ts index c5c0d00334..2e5f94327b 100644 --- a/src/bindings/typescript/writeStruct.ts +++ b/src/bindings/typescript/writeStruct.ts @@ -89,6 +89,7 @@ export function writeSerializer( s: ABIType, allocation: AllocationCell, w: Writer, + opcodesVar?: string, ) { w.append(`export function store${s.name}(src: ${s.name}) {`); w.inIndent(() => { @@ -96,7 +97,7 @@ export function writeSerializer( w.inIndent(() => { w.append(`const b_0 = builder;`); if (s.header) { - w.append(`b_0.storeUint(${s.header}, 32);`); + w.append(`b_0.storeUint(${opcodesVar!}.${s.name}, 32);`); } writeSerializerCell(0, allocation, w); }); diff --git a/src/bindings/writeTypescript.ts b/src/bindings/writeTypescript.ts index 25ccac4358..41a34337ed 100644 --- a/src/bindings/writeTypescript.ts +++ b/src/bindings/writeTypescript.ts @@ -152,7 +152,12 @@ export function writeTypescript( for (const s of abi.types) { writeStruct(s.name, s.fields, true, w); - writeSerializer(s, allocations[s.name]!.root, w); + writeSerializer( + s, + allocations[s.name]!.root, + w, + `${abi.name}_opcodes`, + ); writeParser(s, allocations[s.name]!.root, w); writeTupleParser(s, w); writeGetterTupleParser(s, w);