Skip to content

Commit

Permalink
feat!: Bump polkadot-js and document runtime/metadata API regression (#…
Browse files Browse the repository at this point in the history
…338)

* chore(release): 1.0.0

* Save progress

* feat: Bump polkadot-js and document runtime/metadata API regression
  • Loading branch information
emostov committed Nov 2, 2020
1 parent 9a4ca91 commit effc5eb
Show file tree
Hide file tree
Showing 9 changed files with 650 additions and 522 deletions.
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"test": "jest --silent"
},
"dependencies": {
"@polkadot/api": "^2.3.1",
"@polkadot/api": "^2.4.2-13",
"@polkadot/util-crypto": "^3.6.1",
"@substrate/calc": "^0.1.2",
"confmgr": "^1.0.6",
Expand All @@ -50,21 +50,21 @@
"@types/express-serve-static-core": "^4.17.13",
"@types/http-errors": "^1.6.3",
"@types/jest": "^26.0.15",
"@types/morgan": "^1.9.1",
"@types/morgan": "^1.9.2",
"@types/triple-beam": "^1.3.2",
"@typescript-eslint/eslint-plugin": "^4.5.0",
"@typescript-eslint/parser": "^4.5.0",
"eslint": "^7.11.0",
"eslint-config-prettier": "^6.13.0",
"@typescript-eslint/eslint-plugin": "^4.6.0",
"@typescript-eslint/parser": "^4.6.0",
"eslint": "^7.12.1",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-simple-import-sort": "^5.0.3",
"jest": "^26.6.0",
"jest": "^26.6.1",
"prettier": "^2.1.2",
"rimraf": "^3.0.2",
"standard-version": "^9.0.0",
"ts-jest": "^26.4.1",
"ts-jest": "^26.4.3",
"tsc-watch": "^4.2.9",
"typescript": "^4.0.3"
"typescript": "^4.0.5"
},
"resolutions": {
"node-forge": ">=0.10.0",
Expand Down
14 changes: 7 additions & 7 deletions src/sanitize/sanitizeNumbers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import {
} from '@polkadot/types';
import CodecDate from '@polkadot/types/codec/Date';
import Int from '@polkadot/types/codec/Int';
import StructAny from '@polkadot/types/codec/Json';
import Option from '@polkadot/types/codec/Option';
import StructAny from '@polkadot/types/codec/StructAny';
import UInt from '@polkadot/types/codec/UInt';
import VecFixed from '@polkadot/types/codec/VecFixed';
import Extrinsic from '@polkadot/types/extrinsic/Extrinsic';
Expand Down Expand Up @@ -94,8 +94,8 @@ describe('sanitizeNumbers', () => {
});

it('does not handle WeakSet', () => {
const negInt = new Int(kusamaRegistry, MIN_I32, 32, true);
const maxInt = new Int(kusamaRegistry, MAX_I64, 64, true);
const negInt = new Int(kusamaRegistry, MIN_I32, 32);
const maxInt = new Int(kusamaRegistry, MAX_I64, 64);
const set = new WeakSet([maxInt, negInt]);
expect(sanitizeNumbers(set)).toStrictEqual({});
});
Expand Down Expand Up @@ -184,9 +184,9 @@ describe('sanitizeNumbers', () => {
});

it('converts javascript Set', () => {
const negInt = new Int(kusamaRegistry, MIN_I32, 32, true);
const negInt = new Int(kusamaRegistry, MIN_I32, 32);

const maxInt = new Int(kusamaRegistry, MAX_I64, 64, true);
const maxInt = new Int(kusamaRegistry, MAX_I64, 64);

const struct = new Struct(
kusamaRegistry,
Expand Down Expand Up @@ -386,10 +386,10 @@ describe('sanitizeNumbers', () => {
);
expect(sanitizeNumbers(intPaddedHex)).toBe('22493750000000000');

const maxInt = new Int(kusamaRegistry, MAX_I64, 64, true);
const maxInt = new Int(kusamaRegistry, MAX_I64, 64);
expect(sanitizeNumbers(maxInt)).toBe(MAX_I64);

const negInt = new Int(kusamaRegistry, MIN_I32, 32, true);
const negInt = new Int(kusamaRegistry, MIN_I32, 32);
expect(sanitizeNumbers(negInt)).toBe(MIN_I32);
});

Expand Down
2 changes: 1 addition & 1 deletion src/sanitize/sanitizeNumbers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
} from '@polkadot/types';
import AbstractArray from '@polkadot/types/codec/AbstractArray';
import AbstractInt from '@polkadot/types/codec/AbstractInt';
import StructAny from '@polkadot/types/codec/Json';
import CodecMap from '@polkadot/types/codec/Map';
import StructAny from '@polkadot/types/codec/StructAny';
import { isObject } from '@polkadot/util';
import * as BN from 'bn.js';
import { InternalServerError } from 'http-errors';
Expand Down
5 changes: 2 additions & 3 deletions src/services/test-helpers/mock/mockApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
StakingLedger,
} from '@polkadot/types/interfaces';

import { decoratedPolkadotMetadata } from '../../../test-helpers/metadata/decorated';
import { polkadotMetadata } from '../../../test-helpers/metadata/metadata';
import { polkadotRegistry } from '../../../test-helpers/registries';
import {
balancesTransferValid,
Expand Down Expand Up @@ -55,8 +55,7 @@ const getRuntimeVersion = () =>
};
});

const getMetadata = () =>
Promise.resolve().then(() => decoratedPolkadotMetadata.metadata);
const getMetadata = () => Promise.resolve().then(() => polkadotMetadata);

const deriveGetHeader = () =>
Promise.resolve().then(() => {
Expand Down
16 changes: 8 additions & 8 deletions src/services/test-helpers/responses/runtime/metadata789629.json
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@
"args": [
{
"name": "equivocation_proof",
"type": "BabeEquivocationProof"
"type": "EquivocationProof"
},
{
"name": "key_owner_proof",
Expand All @@ -1020,7 +1020,7 @@
"args": [
{
"name": "equivocation_proof",
"type": "BabeEquivocationProof"
"type": "EquivocationProof"
},
{
"name": "key_owner_proof",
Expand Down Expand Up @@ -1644,7 +1644,7 @@
"AccountId",
"AccountId",
"Balance",
"BalanceStatus"
"Status"
],
"documentation": [
" Some balance was moved from the reserve of the first account to the second account.",
Expand Down Expand Up @@ -3961,7 +3961,7 @@
"args": [
{
"name": "equivocation_proof",
"type": "GrandpaEquivocationProof"
"type": "EquivocationProof"
},
{
"name": "key_owner_proof",
Expand All @@ -3980,7 +3980,7 @@
"args": [
{
"name": "equivocation_proof",
"type": "GrandpaEquivocationProof"
"type": "EquivocationProof"
},
{
"name": "key_owner_proof",
Expand Down Expand Up @@ -7094,7 +7094,7 @@
"Map": {
"hasher": "Twox64Concat",
"key": "ProposalIndex",
"value": "TreasuryProposal",
"value": "Proposal",
"linked": false
}
},
Expand Down Expand Up @@ -10059,7 +10059,7 @@
},
{
"name": "judgement",
"type": "IdentityJudgement"
"type": "Judgement"
}
],
"documentation": [
Expand Down Expand Up @@ -11584,4 +11584,4 @@
}
}
}
}
}
14 changes: 6 additions & 8 deletions src/test-helpers/metadata/decorated.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import Decorated from '@polkadot/metadata/Decorated';
import substrateMetadataRpc from '@polkadot/metadata/Metadata/v11/static';
import { Metadata } from '@polkadot/types';
import expandMetadata from '@polkadot/metadata/decorate';

import { kusamaRegistry } from '../registries/kusamaRegistry';
import { polkadotRegistry } from '../registries/polkadotRegistry';
import { polkadotV16MetadataRpc } from './polkadotV16Metadata';
import { kusamaMetadata, polkadotMetadata } from './metadata';

/**
* Decorated metadata of the kusamaRegistry (v2008).
*/
export const decoratedKusamaMetadata = new Decorated(
export const decoratedKusamaMetadata = expandMetadata(
kusamaRegistry,
new Metadata(kusamaRegistry, substrateMetadataRpc)
kusamaMetadata
);

/**
* Decorated metadata of the polkadotRegistry (v16).
*/
export const decoratedPolkadotMetadata = new Decorated(
export const decoratedPolkadotMetadata = expandMetadata(
polkadotRegistry,
new Metadata(polkadotRegistry, polkadotV16MetadataRpc)
polkadotMetadata
);
22 changes: 22 additions & 0 deletions src/test-helpers/metadata/metadata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import substrateMetadataRpc from '@polkadot/metadata/v11/static';
import { Metadata } from '@polkadot/types';

import { kusamaRegistry } from '../registries/kusamaRegistry';
import { polkadotRegistry } from '../registries/polkadotRegistry';
import { polkadotV16MetadataRpc } from './polkadotV16Metadata';

/**
* Metadata of the polkadotRegistry (v16).
*/
export const polkadotMetadata = new Metadata(
polkadotRegistry,
polkadotV16MetadataRpc
);

/**
* Metadata of the kusamaRegistry (v2008).
*/
export const kusamaMetadata = new Metadata(
kusamaRegistry,
substrateMetadataRpc
);
2 changes: 1 addition & 1 deletion src/test-helpers/registries/kusamaRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import substrateMetadataRpc from '@polkadot/metadata/Metadata/v11/static';
import substrateMetadataRpc from '@polkadot/metadata/v11/static';
import { Metadata, TypeRegistry } from '@polkadot/types';
import { getSpecTypes } from '@polkadot/types-known';

Expand Down
Loading

0 comments on commit effc5eb

Please sign in to comment.