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(polkadot-js): update api, and common deps #934

Merged
merged 3 commits into from
Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
"update-pjs-deps": "substrate-update-pjs-deps && yarn"
},
"dependencies": {
"@polkadot/api": "8.5.1",
"@polkadot/util-crypto": "9.2.1",
"@polkadot/api": "^8.6.2",
"@polkadot/util-crypto": "^9.3.1",
"@substrate/calc": "^0.2.8",
"argparse": "^2.0.1",
"confmgr": "1.0.7",
Expand Down
10 changes: 7 additions & 3 deletions src/services/blocks/BlocksService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ import { AugmentedConst } from '@polkadot/api/types';
import { PromiseRpcResult } from '@polkadot/api-base/types/rpc';
import { GenericExtrinsic, u128, Vec } from '@polkadot/types';
import { GenericCall } from '@polkadot/types/generic';
import { BlockHash, Hash, SignedBlock } from '@polkadot/types/interfaces';
import { FrameSupportWeightsWeightToFeeCoefficient } from '@polkadot/types/lookup';
import {
BlockHash,
Hash,
SignedBlock,
WeightToFeeCoefficient,
} from '@polkadot/types/interfaces';
import { BadRequest } from 'http-errors';
import LRU from 'lru-cache';

Expand Down Expand Up @@ -324,7 +328,7 @@ describe('BlocksService', () => {
'transactionByteFee'
] as unknown) = undefined;
mockHistoricApiClone.consts.transactionPayment['lengthToFee'] =
lengthToFee as unknown as Vec<FrameSupportWeightsWeightToFeeCoefficient> &
lengthToFee as unknown as Vec<WeightToFeeCoefficient> &
AugmentedConst<'promise'>;

const result = blocksService['getPerByte'](mockHistoricApiClone);
Expand Down
27 changes: 16 additions & 11 deletions src/services/blocks/BlocksService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
EventRecord,
Hash,
Header,
WeightToFeeCoefficient,
} from '@polkadot/types/interfaces';
import { AnyJson, Codec, Registry } from '@polkadot/types/types';
import { AbstractInt } from '@polkadot/types-codec';
Expand Down Expand Up @@ -539,16 +540,18 @@ export class BlocksService extends AbstractService {
};
}

const coefficients = weightToFee.map((c) => {
return {
// Anything that could overflow Number.MAX_SAFE_INTEGER needs to be serialized
// to BigInt or string.
coeffInteger: c.coeffInteger.toString(10),
coeffFrac: c.coeffFrac.toNumber(),
degree: c.degree.toNumber(),
negative: c.negative,
};
});
const coefficients = (weightToFee as Vec<WeightToFeeCoefficient>).map(
(c) => {
return {
// Anything that could overflow Number.MAX_SAFE_INTEGER needs to be serialized
// to BigInt or string.
coeffInteger: c.coeffInteger.toString(10),
coeffFrac: c.coeffFrac.toNumber(),
degree: c.degree.toNumber(),
negative: c.negative,
};
}
);

const weights = this.getWeight(historicApi);

Expand Down Expand Up @@ -585,7 +588,9 @@ export class BlocksService extends AbstractService {
}

if (transactionPayment?.lengthToFee) {
return transactionPayment?.lengthToFee.toArray()[0].coeffInteger;
const lengthToFee =
transactionPayment?.lengthToFee as Vec<WeightToFeeCoefficient>;
return lengthToFee[0].coeffInteger;
}

return null;
Expand Down
Loading