Skip to content

Commit

Permalink
fix(wrappers): non-null optional struct fields after null ones
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-trunov committed Oct 9, 2024
1 parent 2024557 commit 7d60094
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
},
"dependencies": {
"@tact-lang/opcode": "^0.0.16",
"@ton/core": "0.58.1",
"@ton/core": "0.59.0",
"@ton/crypto": "^3.2.0",
"blockstore-core": "1.0.5",
"change-case": "^4.1.2",
Expand Down
12 changes: 12 additions & 0 deletions src/test/e2e-emulated/contracts/structs.tact
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ struct Dict {
m: map<Int as uint8, Int as coins>;
}

struct OptionalFields {
nickname: String?;
avatar: String?;
}

contract StructsTester {
s1: S = S {a: false, b: 21 + 21};
s2: S;
Expand Down Expand Up @@ -921,4 +926,11 @@ contract StructsTester {
get fun uintFieldsFromCell(src: Cell): UintFields {
return UintFields.fromCell(src);
}

get fun optionalFields(): OptionalFields {
return OptionalFields {
nickname: null,
avatar: "non-null string",
}
}
}
10 changes: 10 additions & 0 deletions src/test/e2e-emulated/structs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
MyStruct1,
MyStruct2,
MyStruct3,
OptionalFields,
StructsTester,
UintFields,
loadMyMessage1,
Expand Down Expand Up @@ -402,5 +403,14 @@ describe("structs", () => {
to: treasure.address,
body: beginCell().storeDict(m).endCell(),
});

const optionalFields: OptionalFields = {
$$type: "OptionalFields",
nickname: null,
avatar: "non-null string",
};
expect(
await contract.getOptionalFields(),
).toMatchObject<OptionalFields>(optionalFields);
});
});
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1291,10 +1291,10 @@
resolved "https://registry.npmjs.org/@tact-lang/ton-jest/-/ton-jest-0.0.4.tgz"
integrity sha512-FWjfiNvhMlE44ZLLL7tgmHbrszMTPMttmYiaTekf1vwFXV3uAOawM8xM9NldYaCVs9eh8840PjgISdMMUTCSCw==

"@ton/core@0.58.1":
version "0.58.1"
resolved "https://registry.npmjs.org/@ton/core/-/core-0.58.1.tgz#f6f2ecef6a7149bcd23825bfbb454f116d54363f"
integrity sha512-zydh42iT6E3U3Ky/DhTFqJMN/ycKKzbsHASY257Qr2sZn97G/MOcHFizPfMnbJJgx0H9iHX6mdyMvp1IKBVAFA==
"@ton/core@0.59.0":
version "0.59.0"
resolved "https://registry.npmjs.org/@ton/core/-/core-0.59.0.tgz#58da9fcaa58e5a0c705b63baf1e86cab6e196689"
integrity sha512-LSIkGst7BoY7fMWshejzcH0UJnoW21JGlRrW0ch+6A7Xb/7EuekxgdKym7fHxcry6OIf6FoeFg97lJ960N/Ghg==
dependencies:
symbol.inspect "1.0.1"

Expand Down

0 comments on commit 7d60094

Please sign in to comment.