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

Dict serialized wrong #63

Open
glcanvas opened this issue Sep 30, 2024 · 0 comments
Open

Dict serialized wrong #63

glcanvas opened this issue Sep 30, 2024 · 0 comments

Comments

@glcanvas
Copy link
Contributor

glcanvas commented Sep 30, 2024

Hello!
Got an case, when dict serialized wrong.
Let's consider next test:

package org.ton.java;

import org.junit.Test;
import org.ton.java.address.Address;
import org.ton.java.bitstring.BitString;
import org.ton.java.cell.Cell;
import org.ton.java.cell.CellBuilder;
import org.ton.java.cell.CellSlice;
import org.ton.java.cell.TonHashMap;

import java.io.IOException;
import java.math.BigInteger;
import java.nio.file.Files;
import java.nio.file.Path;

public class DictTest {

    String a = Files.readString(Path.of("/path/to/raw-tx.txt"));

    public DictTest() throws IOException {
    }

    @Test
    public void test() {

        TonHashMap dct = CellSlice.beginParse(
                Cell.fromBocBase64(a)
        ).loadDict(267, x -> x.readAddress(), x -> CellSlice.beginParse(x).loadCoins());


        Cell dictCell = CellBuilder.beginCell().storeDictInLine(
                dct.serialize( it -> {
                        BitString x = new BitString();
                        x.writeAddress((Address) it);
                        return x;
                }, it -> {
                        return CellBuilder.beginCell()
                                .storeCoins((BigInteger) it)
                                .endCell();
                })
        ).endCell();
        System.out.println(dictCell.print());
    }
}

This returns formatted cell, like js lib

File with raw cell data: raw-tx.txt
File with formatted cell, returned by js lib: trusted.txt

Diff from trusted.txt and this output:

mac@MacBook-Pro-Mac dct % diff trusted.txt custom.txt
2405c2405
<            x{7F876_}
---
>            x{82076_}
4039c4039
<            x{7F8EE_}
---
>            x{820EE_}
4299c4299
<            x{C0B_}
---
>            x{7C0}
4513c4513
<             x{E0F_}
---
>             x{7F7F}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant