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

Integrate calldata package, drop joi package #1313

Merged
merged 11 commits into from
Nov 12, 2021
Merged

Conversation

davidyuk
Copy link
Member

@davidyuk davidyuk commented Oct 27, 2021

closes #1312, closes #435, closes #1253

@codecov
Copy link

codecov bot commented Oct 27, 2021

Codecov Report

Merging #1313 (e52c6d8) into develop (c4579fc) will increase coverage by 15.59%.
The diff coverage is 85.29%.

Impacted file tree graph

@@             Coverage Diff              @@
##           develop    #1313       +/-   ##
============================================
+ Coverage    68.34%   83.93%   +15.59%     
============================================
  Files           56       55        -1     
  Lines         2527     2415      -112     
  Branches        36       36               
============================================
+ Hits          1727     2027      +300     
+ Misses         792      372      -420     
- Partials         8       16        +8     
Impacted Files Coverage Δ
src/contract/aci/transformation.js 87.50% <ø> (-8.80%) ⬇️
src/index.js 100.00% <ø> (ø)
src/ae/contract.js 81.08% <60.00%> (+7.27%) ⬆️
src/contract/aci/index.js 92.06% <88.88%> (-2.58%) ⬇️
src/node-pool/index.js 97.22% <90.90%> (-2.78%) ⬇️
src/tx/builder/schema.js 96.34% <0.00%> (+0.60%) ⬆️
src/tx/builder/index.js 83.21% <0.00%> (+2.79%) ⬆️
src/account/multiple.js 93.93% <0.00%> (+6.06%) ⬆️
src/utils/crypto.js 69.87% <0.00%> (+7.22%) ⬆️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c4579fc...e52c6d8. Read the comment docs.

@davidyuk davidyuk requested a review from mradkov October 27, 2021 17:16
Copy link
Contributor

@mradkov mradkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tentatively approve :D Some tests are still failing for me locally, but looking at the CI builds everything is good.

@mradkov mradkov marked this pull request as ready for review October 28, 2021 08:27
@marc0olo
Copy link
Contributor

marc0olo commented Oct 28, 2021

@davidyuk I'd be interested if this issue is also covered with the integration of calldata-lib now: #1253

@davidyuk
Copy link
Member Author

this PR is not ready to be merged, it needs to be rebased at the top of #1310

@mradkov
Copy link
Contributor

mradkov commented Oct 28, 2021

this PR is not ready to be merged, it needs to be rebased at the top of #1310

#1310 is merged now, so feel free to rebase it :)

@thepiwo
Copy link
Collaborator

thepiwo commented Oct 31, 2021

trying to encode undefined for an option(int) seems to fail with

Error: Variant value should be an object with "variant" and "values" fields, got undefined instead

same for trying 1 for option(int)

Error: Variant value should be an object with "variant" and "values" fields, got 1 instead

@marc0olo
Copy link
Contributor

@thepiwo We have two open issues in the calldata lib regarding variants:

Not sure how this is related. But just to let you know.

const result = await deployed.callStatic('getArg', ['42'])
return result.decode().should.eventually.become(42)
const result = await deployed.callStatic('getArg', [42])
expect(result.decodedResult).to.be.equal(42n)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this with 'n' here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's BigInt which is used in the calldata lib right now. this is also sth. that should be addressed with the integration. I have some open issues in that regards, see:

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should figure this out or provide a different solution with chai if this is the issue

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidyuk can you verify the problem and comment this again?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created a new project with the latest mocha (9.1.3) and chai (4.3.4):

import { expect } from 'chai'

it('works', () => {
    expect({ a: 1n }).to.be.eql({ a: 2n })
})

mocha test.js outputs:

  1) works:

      AssertionError: expected { a: 1n } to deeply equal { a: 2n }
      + expected - actual

       {
      -  "a": "1"
      +  "a": "2"
       }

in the diff section at the end BigInts presented as strings for some reason. If this is the issue, I don't think that we should do anything on our side to avoid that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expect({ a: '1' }).to.be.eql({ a: 2n })
       {
      -  "a": "1"
      +  "a": "2"
       }

🤷‍♀️

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't get why we have to have it like this. If it stays like this there needs to be a big explainer everywhere for ALL aepp devs to adjust their aepps

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean the BigInt in general? well I think in the past we just weren't able to use it and in the calldata lib it makes definitely sense to use it as it is possible now.

I can understand your point of view. but isn't BigInt the right way to do it?

@thepiwo wouldn't you have to touch all repos again anyway with the upcoming AEproject release or how will that transition look like again? (can't exactly remember)

I mean it's definitely a bit unfortunate but it will be a major release - so we could (and maybe should) do it this way 🤷‍♀️

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, repos that don't use aeproject don't have to be touched, e.g. governance-server, governance-aepp, superhero wallet, graffiti-aepp, graffiti-server.

We should just make the use of BigInt very clear in docs and Changelogs and so on, I'm not saying its bad to have it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we will do that for sure! - this release in general needs a dedicated article / announcement

@davidyuk davidyuk force-pushed the feature/calldata branch 2 times, most recently from 30957be to 6a07772 Compare November 2, 2021 07:06
@davidyuk davidyuk force-pushed the feature/calldata branch 6 times, most recently from e1b18e9 to 5b20d1c Compare November 10, 2021 14:14
@davidyuk
Copy link
Member Author

@mradkov I think this one is ready to merge

Copy link
Collaborator

@thepiwo thepiwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty speedy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants