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

example of getMapEntry #31

Open
kicksomedust opened this issue Feb 14, 2025 · 0 comments
Open

example of getMapEntry #31

kicksomedust opened this issue Feb 14, 2025 · 0 comments

Comments

@kicksomedust
Copy link

I can't find an example of simnet.getMapEntry.
It 's use seems to be quite straightforward, but there is an issue if I want to use a string as the key type for the map.
It won't find the mapped value.
Unless someone tells me that I'm doing it all wrong.

            let key: ClarityValue = Cl.stringUtf8("test1");
            let value: ClarityValue = Cl.stringUtf8("do something");

            //first add something
            const addMessage: any = simnet.callPublicFn("hello-stacks", "add-message", [key, value], address);
            expect(addMessage.result.type).toBe(ClarityType.ResponseOk);
            expect(addMessage.result.value.data).toBe("do something");
            console.log("1 ok");

            //then try to retrieve it
            let key: ClarityValue = Cl.stringUtf8("test1");
            const found: ClarityValue = simnet.getMapEntry("hello-stacks", "messages", key);
            expect(found).toBe("do something");
            console.log("6 ok");
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