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

Validation Error on bits type #1161

Closed
nikita-fuchs opened this issue Apr 27, 2021 · 2 comments
Closed

Validation Error on bits type #1161

nikita-fuchs opened this issue Apr 27, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@nikita-fuchs
Copy link
Contributor

Maybe I can't figure out the proper formatting, but calling a function with bits param type gives me an error.

Contract:

contract Test = 
    
    record state = 
        {test : int}

    entrypoint init() =
        {test = 2}

    entrypoint get_bits(test: bits) : bits =
        test

Calling with "01010101", "0x01100110" , [1,0,0,1] and other variations fails with the same validation error:

SDK Error:

ValidationError: "Argument" at position 0 fails because ["["01100110"]" with value ""01100110"" fails to match the required pattern: /^(ak_|ct_|ok_|oq_)/]
@nikita-fuchs nikita-fuchs added the bug Something isn't working label Apr 27, 2021
@VitalJeevanjot
Copy link

VitalJeevanjot commented Apr 27, 2021

Greetings,

I also found some things (Examples or regular expressions to validate) related to bits usage.

First: (Some tests)
image

aeternity/aepp-calldata-js@dbb31be#diff-178b8eee263831e53cf2c0736ee121d327270faa4cf8ba5a2677e60edf208fbaR45

Second (Reg exp)
image

https://github.com/aeternity/aebytecode/blob/84e246d9daeb0431a36e8b6d4215cee1b36761d2/src/aeb_fate_asm_scan.template#L26

While reading some more issues, It looks like some prefix like ak th requires and encoding in a certain way.
I am looking for more clues, WIll keep posted.

@davidyuk
Copy link
Member

davidyuk commented Dec 6, 2021

after #1313 these are handled by @aeternity/aepp-calldata package, here is an example of how to pass bits values:

it('Valid', async () => {
(await Promise.all([0, -1n, 0b101n]
.map(async value => [value, (await testContract.methods.bitsFn(value)).decodedResult])))
.forEach(([v1, v2]) => expect(v2).to.be.equal(BigInt(v1)))
})

also see https://github.com/aeternity/aepp-calldata-js#data-types

@davidyuk davidyuk closed this as completed Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants