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: updated parsing for brokerConfig and brokerSalesInfo #10926

Merged
merged 6 commits into from
Sep 18, 2024

Conversation

piggydoughnut
Copy link
Contributor

No description provided.

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.

It's always better to use the built in type structures, instead of calling toJSON in order to get all the values.

@@ -11,17 +11,17 @@ import { createNamedHook, useApi, useCall } from '@polkadot/react-hooks';
import { stringToBN } from './utils/dataProcessing.js';

function parseConfig (config: PalletBrokerConfigRecord): SimplifiedPalletBrokerConfigRecord {
const c = config.toJSON();
const c = config?.toJSON();
Copy link
Member

Choose a reason for hiding this comment

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

This should actually be like this:

function parseConfig (config: PalletBrokerConfigRecord): SimplifiedPalletBrokerConfigRecord {
  return {
    advanceNotice: config.advanceNotice.toNumber(),
    contributionTimeout: config.contributionTimeout.toNumber(),
    idealBulkProportion: stringToBN(config.idealBulkProportion?.toString()),
    interludeLength: config.interludeLength.toNumber(),
    leadinLength: config.leadinLength.toNumber(),
    limitCoresOffered: config.limitCoresOffered.isSome ? config.limitCoresOffered.unwrap().toNumber() : 0,
    regionLength: config.regionLength.toNumber(),
    renewalBump: stringToBN(config.renewalBump?.toString())
  };
}

Copy link
Member

Choose a reason for hiding this comment

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

And if config can be undefined, then the param type needs to be updated.

record: PalletBrokerSaleInfoRecord
): SimplifiedPalletBrokerSaleInfoRecord {
const rec = record.toJSON();
function parsePalletBrokerSaleInfoRecord (record: PalletBrokerSaleInfoRecord): SimplifiedPalletBrokerSaleInfoRecord {
Copy link
Member

Choose a reason for hiding this comment

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

Same with this as above.

regionBegin: record.regionBegin.toNumber(),
regionEnd: record.regionEnd.toNumber(),
saleStart: record.saleStart.toNumber(),
selloutPrice: record.selloutPrice.isSome ? record.selloutPrice.unwrap() : 0
Copy link
Member

Choose a reason for hiding this comment

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

Small nit, but I think you can set the 0 to new BN(0) if you want the values to be inline. That being said its a small nit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good nit 🤩

@piggydoughnut piggydoughnut merged commit f98eb76 into master Sep 18, 2024
5 checks passed
@piggydoughnut piggydoughnut deleted the dm-fix-coretime-ui branch September 18, 2024 13:40
juangirini pushed a commit to ideal-lab5/polkadot-js-apps that referenced this pull request Sep 19, 2024
…s#10926)

* updated parsing for brokerConfig and brokerSalesInfo

* renamed file

* updated parsing for brokerConfig and brokerSalesInfo

* better type conversion for BN

* BN type change

* lint
@polkadot-js-bot
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@polkadot-js polkadot-js locked as resolved and limited conversation to collaborators Sep 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants