Skip to content
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

Tact serializes map<Address, Int as coins> incorrectly #985

Open
1 task done
imartemy1524 opened this issue Oct 24, 2024 · 0 comments · May be fixed by #987
Open
1 task done

Tact serializes map<Address, Int as coins> incorrectly #985

imartemy1524 opened this issue Oct 24, 2024 · 0 comments · May be fixed by #987
Assignees
Labels
bug Something isn't working or isn't right
Milestone

Comments

@imartemy1524
Copy link

Are you using the latest released (or pre-released, a.k.a. "next") version?

  • I'm using the latest Tact version

Tact source code

import "@stdlib/deploy";

message ForwardPayload{
    to: map<Address, Int as coins>;
}
contract InvalidSerialization with Deployable {

    receive(m: ForwardPayload){
        foreach(addr, amount in m.to){
            dump(addr);
            dump(amount);
        }
    }
}

Relevant Tact/build system log output

No errors thrown

What happened?

When one tries to send "ForwardPayload" message, it ends with 9 error code, because the serialization and deserialization differ:

export function storeForwardPayload(src: ForwardPayload) {
    return (builder: Builder) => {
        let b_0 = builder;
        b_0.storeUint(3264607134, 32);
        b_0.storeDict(src.to, Dictionary.Keys.Address(), Dictionary.Values.BigUint(124));
    };
}

and in contract code:

    var ($addr, $amount, $fresh$flag_0) = __tact_dict_min_slice_int($m'to, 267, 257);
    while ($fresh$flag_0) {
        __tact_debug_address($addr, __gen_slice_string_fff0772d56d2a3f45220c12e605b1692cb65b9ef6f72a2e11c228fd2152f47e2(), "File contracts/test.tact:11:13:");
        __tact_debug_str(__tact_int_to_string($amount), __gen_slice_string_8ebac137868252bcaf2f59f69a6616ec14a1c79ceaf49369f36485c5fb48a8ec(), "File contracts/test.tact:12:13:");
        ($addr, $amount, $fresh$flag_0) = __tact_dict_next_slice_int($m'to, 267, $addr, 257);

What did you expect?

I expected that the map values are serialized correctly both in the func code and TypeScript

Steps to reproduce

git clone https://github.com/imartemy1524/tact-map-bug
cd tact-map-bug
npm i
npx blueprint build --all
npx blueprint test

How do you run Tact?

Blueprint

Anything else?

Source code: https://github.com/imartemy1524/tact-map-bug

@imartemy1524 imartemy1524 added the bug Something isn't working or isn't right label Oct 24, 2024
@Gusarich Gusarich self-assigned this Oct 25, 2024
@Gusarich Gusarich added this to the v1.6.0 milestone Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working or isn't right
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants