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

fix: Account for polkadot-js changes; Harden createCalcFee #376

Merged
merged 6 commits into from
Jan 7, 2021

Conversation

emostov
Copy link
Contributor

@emostov emostov commented Jan 5, 2021

This PR bumps deps, accounts for changes from polkadot-js/api, and hardens createCalcFee which was affected by the polkadot-js changes.

Changes introduced by PR:

  • createCalcFee
    • Forcibly serialize AbstractInts with toString(10), making sure they are decimal form
    • Use native toBigInt on relevant AbstractInt
  • Manually create each extrinsic as a Call type before processing args
  • Use section and method instead of the no longer available sectionName and methodName
  • wasm-pack introduced a new auto-generated method into calc.js, resulting a big diff there

Copy link
Contributor

@dvdplm dvdplm left a comment

Choose a reason for hiding this comment

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

lgtm

@@ -390,11 +394,17 @@ export class BlocksService extends AbstractService {
version.specVersion.toNumber(),
];

// The compiler doesn't know this is an AbastractInt so we do a runtime check.
Copy link
Contributor

Choose a reason for hiding this comment

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

dq: why doesn't it know that and why can't we add type annotations on line 343?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dvdplm Honestly I was on the fence about it. It does not have the TS bindings defined within the API (see here: https://github.com/polkadot-js/api/blob/master/packages/api/src/augment/consts.ts). Not exactly sure why that is but just guessing the script that generates those bindings was run against a runtime that does not use the extrinsicBaseWeight const. I think I will actually just cast it though. No matter the type it certainly will always be a descendant of AbstractInt since it has to be some type of integer.

Co-authored-by: David <dvdplm@gmail.com>
@emostov emostov requested a review from TarikGul January 7, 2021 01:04
@@ -98,6 +98,10 @@ impl CalcFee {
spec_version: u32,
) -> Option<CalcFee> {
debug::setup();
info!(
Copy link
Member

@TarikGul TarikGul Jan 7, 2021

Choose a reason for hiding this comment

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

Spacing needs to get fixed here.

Copy link
Member

@TarikGul TarikGul left a comment

Choose a reason for hiding this comment

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

Spacing in that one file calc/pkg/calc_fee.rs, lgtm though

@emostov emostov merged commit fdee04c into master Jan 7, 2021
@emostov emostov deleted the zeke-dps-21 branch January 7, 2021 02:53
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

Successfully merging this pull request may close these issues.

3 participants