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

chore(deps): update polkadot-js deps #1339

Merged
merged 4 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
"test:test-release": "yarn build:scripts && node scripts/build/runYarnPack.js"
},
"dependencies": {
"@polkadot/api": "^10.9.1",
"@polkadot/api-contract": "^10.9.1",
"@polkadot/util-crypto": "^12.3.2",
"@polkadot/api": "^10.10.1",
"@polkadot/api-contract": "^10.10.1",
"@polkadot/util-crypto": "^12.5.1",
"@substrate/calc": "^0.3.1",
"argparse": "^2.0.1",
"confmgr": "^1.0.10",
Expand Down
34 changes: 20 additions & 14 deletions src/services/AbstractPalletsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ import {
EventMetadataLatest,
FunctionMetadataLatest,
MetadataV14,
MetadataV15,
PalletCallMetadataV14,
PalletConstantMetadataLatest,
PalletConstantMetadataV14,
PalletErrorMetadataV14,
PalletEventMetadataV14,
PalletMetadataV14,
PalletMetadataV15,
PalletStorageMetadataV14,
StorageEntryMetadataV14,
} from '@polkadot/types/interfaces';
Expand Down Expand Up @@ -59,7 +61,7 @@ type IMetadataFieldType =

export abstract class AbstractPalletsService extends AbstractService {
private getPalletMetadataType(
meta: PalletMetadataV14,
meta: PalletMetadataV14 | PalletMetadataV15,
metadataFieldType: IMetadataFieldType
): IPalletMetadata {
return this.getProperty(meta, metadataFieldType);
Expand All @@ -75,24 +77,25 @@ export abstract class AbstractPalletsService extends AbstractService {
* @param palletId identifier for a FRAME pallet as a pallet name or index.
*/
protected findPalletMeta(
adjustedMetadata: MetadataV14,
adjustedMetadata: MetadataV14 | MetadataV15,
palletId: string,
metadataFieldType: IMetadataFieldType
): [PalletMetadataV14, number] {
const pallets: Vec<PalletMetadataV14> = adjustedMetadata['pallets'];
): [PalletMetadataV14 | PalletMetadataV15, number] {
const pallets: Vec<PalletMetadataV14> | Vec<PalletMetadataV15> =
adjustedMetadata['pallets'];
const palletMetaType = this.getPalletMetadataType(
pallets[0],
metadataFieldType
);

const filtered: PalletMetadataV14[] = pallets.filter(
const filtered: (PalletMetadataV14 | PalletMetadataV15)[] = pallets.filter(
(mod) => !(mod[metadataFieldType] as typeof palletMetaType).isEmpty
);

const { isValidPalletName, isValidPalletIndex, parsedPalletId } =
this.validPalletId(pallets, palletId);

let palletMeta: PalletMetadataV14 | undefined;
let palletMeta: PalletMetadataV14 | PalletMetadataV15 | undefined;
let palletIdx: number | undefined;

if (isValidPalletIndex) {
Expand Down Expand Up @@ -142,7 +145,7 @@ export abstract class AbstractPalletsService extends AbstractService {
}

private validPalletId(
modules: Vec<PalletMetadataV14>,
modules: Vec<PalletMetadataV14> | Vec<PalletMetadataV15>,
palletId: string
): {
isValidPalletName: boolean;
Expand Down Expand Up @@ -200,7 +203,7 @@ export abstract class AbstractPalletsService extends AbstractService {
*/
protected findPalletFieldItemMeta(
historicApi: ApiDecoration<'promise'>,
palletMeta: PalletMetadataV14,
palletMeta: PalletMetadataV14 | PalletMetadataV15,
palletItemId: string,
metadataFieldType: IMetadataFieldType
): IPalletFieldMeta {
Expand Down Expand Up @@ -251,14 +254,17 @@ export abstract class AbstractPalletsService extends AbstractService {
}

private getDispatchablesItemMeta(
palletMeta: PalletMetadataV14,
palletMeta: PalletMetadataV14 | PalletMetadataV15,
dispatchableItemMetaIdx: number,
dispatchableItemId: string
): [number, FunctionMetadataLatest] {
const palletName = stringCamelCase(palletMeta.name);
const dispatchables = this.api.tx[palletName];

if ((palletMeta.calls as unknown as PalletCallMetadataV14).isEmpty) {
if (
(palletMeta.calls as unknown as PalletMetadataV14 | PalletMetadataV15)
.isEmpty
) {
throw new InternalServerError(
`No dispatchable items found in ${palletMeta.name.toString()}'s metadata`
);
Expand All @@ -284,7 +290,7 @@ export abstract class AbstractPalletsService extends AbstractService {
}

private getConstItemMeta(
palletMeta: PalletMetadataV14,
palletMeta: PalletMetadataV14 | PalletMetadataV15,
constItemMetaIdx: number,
constItemId: string
): [number, PalletConstantMetadataLatest] {
Expand All @@ -304,7 +310,7 @@ export abstract class AbstractPalletsService extends AbstractService {

private getErrorItemMeta(
historicApi: ApiDecoration<'promise'>,
palletMeta: PalletMetadataV14,
palletMeta: PalletMetadataV14 | PalletMetadataV15,
errorItemMetaIdx: number,
errorItemId: string
): [number, ErrorMetadataLatest] {
Expand Down Expand Up @@ -335,7 +341,7 @@ export abstract class AbstractPalletsService extends AbstractService {

private getEventItemMeta(
historicApi: ApiDecoration<'promise'>,
palletMeta: PalletMetadataV14,
palletMeta: PalletMetadataV14 | PalletMetadataV15,
eventItemMetaIdx: number,
eventItemId: string
): [number, EventMetadataLatest] {
Expand Down Expand Up @@ -365,7 +371,7 @@ export abstract class AbstractPalletsService extends AbstractService {
}

private getStorageItemMeta(
palletMeta: PalletMetadataV14,
palletMeta: PalletMetadataV14 | PalletMetadataV15,
storageItemMetaIdx: number,
storageItemId: string
): [number, StorageEntryMetadataV14] {
Expand Down
4 changes: 2 additions & 2 deletions src/services/paras/ParasService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
ParaLifecycle,
WinningData,
} from '@polkadot/types/interfaces';
import { PolkadotPrimitivesV4CandidateReceipt } from '@polkadot/types/lookup';
import { PolkadotPrimitivesV5CandidateReceipt } from '@polkadot/types/lookup';
import { ITuple } from '@polkadot/types/types';
import { BN_ZERO } from '@polkadot/util';
import BN from 'bn.js';
Expand Down Expand Up @@ -456,7 +456,7 @@ export class ParasService extends AbstractService {
const paraHeaders: IParasHeaders = {};
paraInclusion.forEach(({ event }) => {
const { data } = event;
const paraData = data[0] as PolkadotPrimitivesV4CandidateReceipt;
const paraData = data[0] as PolkadotPrimitivesV5CandidateReceipt;
const headerData = data[1] as Bytes;
const { paraHead, paraId } = paraData.descriptor;
const header = api.createType('Header', headerData);
Expand Down
1 change: 1 addition & 0 deletions src/services/test-helpers/responses/runtime/spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"live": null
},
"properties": {
"isEthereum": false,
"ss58Format": "0",
"tokenDecimals": ["12"],
"tokenSymbol": ["DOT"]
Expand Down
Loading
Loading