Split codec into @polkadot/types-codec (#4329)
* Split codec into @polkadot/types-codec
* Additional (test cleanups next)
* Fix tests
* Imports from '@polkadot/types-codec
* All remaining codec imports (only exports left)
* Bytes -> types-codec
* Cleanups
* Bool, BitVec, Text movements
* sanitize move
* Adjust (first build fixes)
* Adjust
* Additional
* Adjust
* Adjustments
* linting
* Adjust, not working atm
* Move {U,I}{8,16,32...} to types-codec
* createTypeUnsafe
* Fix type-only exports
* Folder exports
* Split Lookup/Create on registry interfaces
* Clanup LookupRegistry & CreateRegistry
* Combine CreateRegistry into LookupRegistry
This commit is contained in:
@@ -474,7 +474,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
const lazySection = (section: string) =>
|
||||
lazyMethods({}, Object.keys(query[section]), (method: string) =>
|
||||
blockHash
|
||||
? this._decorateStorageEntryAt(registry, query[section][method], decorateMethod, blockHash)
|
||||
? this._decorateStorageEntryAt(registry as Registry, query[section][method], decorateMethod, blockHash)
|
||||
: this._decorateStorageEntry(query[section][method], decorateMethod)
|
||||
);
|
||||
|
||||
@@ -528,7 +528,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
decorated.sizeAt = decorateMethod((blockHash: Hash | Uint8Array | string, ...args: unknown[]): Observable<u64> =>
|
||||
getQueryAt(blockHash).pipe(
|
||||
switchMap((q) =>
|
||||
this._rpcCore.state.getStorageSize(getArgs(args, q.creator.meta.registry), blockHash))));
|
||||
this._rpcCore.state.getStorageSize(getArgs(args, q.creator.meta.registry as Registry), blockHash))));
|
||||
|
||||
// .keys() & .entries() only available on map types
|
||||
if (creator.iterKey && creator.meta.type.isMap) {
|
||||
|
||||
@@ -14,7 +14,7 @@ import type { VersionedRegistry } from './types';
|
||||
import { firstValueFrom, map, of, switchMap } from 'rxjs';
|
||||
|
||||
import { Metadata, TypeRegistry } from '@polkadot/types';
|
||||
import { getSpecAlias, getSpecExtensions, getSpecHasher, getSpecRpc, getSpecTypes, getUpgradeVersion } from '@polkadot/types/known';
|
||||
import { getSpecAlias, getSpecExtensions, getSpecHasher, getSpecRpc, getSpecTypes, getUpgradeVersion } from '@polkadot/types-known';
|
||||
import { assert, BN_ZERO, isUndefined, logger, objectSpread, u8aEq, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
import { cryptoWaitReady } from '@polkadot/util-crypto';
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { AccountId } from '@polkadot/types/interfaces';
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
import type { ApiInterfaceRx } from '../../types';
|
||||
import type { HeaderExtended } from '../type/types';
|
||||
|
||||
@@ -38,7 +39,7 @@ export function getHeader (instanceId: string, api: ApiInterfaceRx): (blockHash:
|
||||
)
|
||||
]).pipe(
|
||||
map(([header, validators]) =>
|
||||
createHeaderExtended(header.registry, header, validators)
|
||||
createHeaderExtended(header.registry as Registry, header, validators)
|
||||
),
|
||||
catchError((): Observable<undefined> =>
|
||||
// where rpc.chain.getHeader throws, we will land here - it can happen that
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
import type { ApiInterfaceRx } from '../../types';
|
||||
import type { SignedBlockExtended } from '../type/types';
|
||||
|
||||
@@ -32,7 +33,7 @@ export function subscribeNewBlocks (instanceId: string, api: ApiInterfaceRx): ()
|
||||
]);
|
||||
}),
|
||||
map(([header, block, events]) =>
|
||||
createSignedBlockExtended(block.registry, block, events, header.validators)
|
||||
createSignedBlockExtended(block.registry as Registry, block, events, header.validators)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
import type { ApiInterfaceRx } from '../../types';
|
||||
import type { HeaderExtended } from '../type/types';
|
||||
|
||||
@@ -34,7 +35,7 @@ export function subscribeNewHeads (instanceId: string, api: ApiInterfaceRx): ()
|
||||
map(([header, validators]): HeaderExtended => {
|
||||
header.createdAtHash = header.hash;
|
||||
|
||||
return createHeaderExtended(header.registry, header, validators);
|
||||
return createHeaderExtended(header.registry as Registry, header, validators);
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
/* eslint-disable no-dupe-class-members */
|
||||
|
||||
import type { Observable, OperatorFunction } from 'rxjs';
|
||||
import type { Address, ApplyExtrinsicResult, Call, Extrinsic, ExtrinsicEra, ExtrinsicStatus, Hash, Header, Index, RuntimeDispatchInfo } from '@polkadot/types/interfaces';
|
||||
import type { Callback, Codec, Constructor, IKeyringPair, ISubmittableResult, Registry, SignatureOptions } from '@polkadot/types/types';
|
||||
import type { Address, ApplyExtrinsicResult, Call, Extrinsic, ExtrinsicEra, ExtrinsicStatus, Hash, Header, Index, RuntimeDispatchInfo, SignerPayload } from '@polkadot/types/interfaces';
|
||||
import type { Callback, Codec, Constructor, IKeyringPair, ISubmittableResult, SignatureOptions } from '@polkadot/types/types';
|
||||
import type { CodecRegistry } from '@polkadot/types-codec/types';
|
||||
import type { ApiInterfaceRx, ApiTypes, PromiseOrObs, SignerResult } from '../types';
|
||||
import type { AddressOrPair, SignerOptions, SubmittableDryRunResult, SubmittableExtrinsic, SubmittablePaymentResult, SubmittableResultResult, SubmittableResultSubscription } from './types';
|
||||
|
||||
@@ -25,7 +26,7 @@ interface SubmittableOptions<ApiType extends ApiTypes> {
|
||||
|
||||
const identity = <T> (input: T): T => input;
|
||||
|
||||
function makeEraOptions (api: ApiInterfaceRx, registry: Registry, partialOptions: Partial<SignerOptions>, { header, mortalLength, nonce }: { header: Header | null; mortalLength: number; nonce: Index }): SignatureOptions {
|
||||
function makeEraOptions (api: ApiInterfaceRx, registry: CodecRegistry, partialOptions: Partial<SignerOptions>, { header, mortalLength, nonce }: { header: Header | null; mortalLength: number; nonce: Index }): SignatureOptions {
|
||||
if (!header) {
|
||||
if (isNumber(partialOptions.era)) {
|
||||
// since we have no header, it is immortal, remove any option overrides
|
||||
@@ -39,10 +40,10 @@ function makeEraOptions (api: ApiInterfaceRx, registry: Registry, partialOptions
|
||||
|
||||
return makeSignOptions(api, partialOptions, {
|
||||
blockHash: header.hash,
|
||||
era: registry.createType('ExtrinsicEra', {
|
||||
era: registry.createTypeUnsafe<ExtrinsicEra>('ExtrinsicEra', [{
|
||||
current: header.number,
|
||||
period: partialOptions.era || mortalLength
|
||||
}),
|
||||
}]),
|
||||
nonce
|
||||
});
|
||||
}
|
||||
@@ -83,7 +84,7 @@ export function createClass <ApiType extends ApiTypes> ({ api, apiType, decorate
|
||||
|
||||
#transformResult: (input: ISubmittableResult) => ISubmittableResult = identity;
|
||||
|
||||
constructor (registry: Registry, extrinsic: Call | Extrinsic | Uint8Array | string) {
|
||||
constructor (registry: CodecRegistry, extrinsic: Call | Extrinsic | Uint8Array | string) {
|
||||
super(registry, extrinsic, { version: api.extrinsicType });
|
||||
|
||||
this.#ignoreStatusCb = apiType === 'rxjs';
|
||||
@@ -285,11 +286,11 @@ export function createClass <ApiType extends ApiTypes> ({ api, apiType, decorate
|
||||
|
||||
assert(signer, 'No signer specified, either via api.setSigner or via sign options. You possibly need to pass through an explicit keypair for the origin so it can be used for signing.');
|
||||
|
||||
const payload = this.registry.createType('SignerPayload', objectSpread({}, options, {
|
||||
const payload = this.registry.createTypeUnsafe<SignerPayload>('SignerPayload', [objectSpread({}, options, {
|
||||
address,
|
||||
blockNumber: header ? header.number : 0,
|
||||
method: this.method
|
||||
}));
|
||||
})]);
|
||||
let result: SignerResult;
|
||||
|
||||
if (signer.signPayload) {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"references": [
|
||||
{ "path": "../rpc-core" },
|
||||
{ "path": "../rpc-provider" },
|
||||
{ "path": "../types" }
|
||||
{ "path": "../types" },
|
||||
{ "path": "../types-known" }
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user