Remove as unknown (#1636)
* Remove some as unknowns * Rename sanitize * Remove file
This commit is contained in:
committed by
Jaco Greeff
parent
b7ba654e48
commit
f78bf9dde1
@@ -28,7 +28,7 @@ export function referendumVotesFor (api: ApiInterfaceRx): (referendumId: BN | nu
|
|||||||
accountId,
|
accountId,
|
||||||
balance: balances[index].votingBalance || createType(api.registry, 'Balance'),
|
balance: balances[index].votingBalance || createType(api.registry, 'Balance'),
|
||||||
vote: votes[index] || createType(api.registry, 'Vote')
|
vote: votes[index] || createType(api.registry, 'Vote')
|
||||||
} as unknown as DerivedReferendumVote))
|
} as DerivedReferendumVote))
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -199,10 +199,10 @@ export default abstract class Decorate<ApiType extends ApiTypes> extends Events
|
|||||||
}
|
}
|
||||||
|
|
||||||
return section;
|
return section;
|
||||||
}, {} as unknown as DecoratedRpcSection<ApiType, RpcInterface[typeof sectionName]>);
|
}, {} as DecoratedRpcSection<ApiType, RpcInterface[typeof sectionName]>);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}, {} as unknown as DecoratedRpc<ApiType, RpcInterface>);
|
}, {} as DecoratedRpc<ApiType, RpcInterface>);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected decorateMulti<ApiType extends ApiTypes> (decorateMethod: DecorateMethod<ApiType>): QueryableStorageMulti<ApiType> {
|
protected decorateMulti<ApiType extends ApiTypes> (decorateMethod: DecorateMethod<ApiType>): QueryableStorageMulti<ApiType> {
|
||||||
@@ -223,10 +223,10 @@ export default abstract class Decorate<ApiType extends ApiTypes> extends Events
|
|||||||
out[name] = this.decorateExtrinsicEntry(method, creator);
|
out[name] = this.decorateExtrinsicEntry(method, creator);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}, {} as unknown as SubmittableModuleExtrinsics<ApiType>);
|
}, {} as SubmittableModuleExtrinsics<ApiType>);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}, creator as unknown as SubmittableExtrinsics<ApiType>);
|
}, creator as SubmittableExtrinsics<ApiType>);
|
||||||
}
|
}
|
||||||
|
|
||||||
private decorateExtrinsicEntry<ApiType extends ApiTypes> (method: CallFunction, creator: (value: Call | Uint8Array | string) => SubmittableExtrinsic<ApiType>): SubmittableExtrinsicFunction<ApiType> {
|
private decorateExtrinsicEntry<ApiType extends ApiTypes> (method: CallFunction, creator: (value: Call | Uint8Array | string) => SubmittableExtrinsic<ApiType>): SubmittableExtrinsicFunction<ApiType> {
|
||||||
@@ -242,10 +242,10 @@ export default abstract class Decorate<ApiType extends ApiTypes> extends Events
|
|||||||
out[name] = this.decorateStorageEntry(method, decorateMethod);
|
out[name] = this.decorateStorageEntry(method, decorateMethod);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}, {} as unknown as QueryableModuleStorage<ApiType>);
|
}, {} as QueryableModuleStorage<ApiType>);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}, {} as unknown as QueryableStorage<ApiType>);
|
}, {} as QueryableStorage<ApiType>);
|
||||||
}
|
}
|
||||||
|
|
||||||
private decorateStorageEntry<ApiType extends ApiTypes> (creator: StorageEntry, decorateMethod: DecorateMethod<ApiType>): QueryableStorageEntry<ApiType> {
|
private decorateStorageEntry<ApiType extends ApiTypes> (creator: StorageEntry, decorateMethod: DecorateMethod<ApiType>): QueryableStorageEntry<ApiType> {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ describe('ApiPromise', (): void => {
|
|||||||
const metadata: any = {};
|
const metadata: any = {};
|
||||||
const key = `${genesisHash}-${specVersion}`;
|
const key = `${genesisHash}-${specVersion}`;
|
||||||
metadata[key] = rpcData;
|
metadata[key] = rpcData;
|
||||||
const api = await ApiPromise.create({ provider, metadata, registry } as unknown as ApiOptions);
|
const api = await ApiPromise.create({ provider, metadata, registry } as ApiOptions);
|
||||||
|
|
||||||
expect(api.genesisHash).toBeDefined();
|
expect(api.genesisHash).toBeDefined();
|
||||||
expect(api.runtimeMetadata).toBeDefined();
|
expect(api.runtimeMetadata).toBeDefined();
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ export default function createClass <ApiType extends ApiTypes> ({ api, apiType,
|
|||||||
genesisHash: this._api.genesisHash,
|
genesisHash: this._api.genesisHash,
|
||||||
runtimeVersion: this._api.runtimeVersion,
|
runtimeVersion: this._api.runtimeVersion,
|
||||||
version: this._api.extrinsicType
|
version: this._api.extrinsicType
|
||||||
} as unknown as SignatureOptions;
|
} as SignatureOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _makeEraOptions (options: Partial<SignerOptions>, { header, nonce }: { header: Header | null; nonce: Index }): SignatureOptions {
|
private _makeEraOptions (options: Partial<SignerOptions>, { header, nonce }: { header: Header | null; nonce: Index }): SignatureOptions {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export default function fromMetadata (registry: Registry, metadata: Metadata): S
|
|||||||
}, { metaVersion: metadata.version });
|
}, { metaVersion: metadata.version });
|
||||||
|
|
||||||
return newModule;
|
return newModule;
|
||||||
}, {} as unknown as ModuleStorage);
|
}, {} as ModuleStorage);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}, { ...getStorage(registry, metadata.version) });
|
}, { ...getStorage(registry, metadata.version) });
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ function createRuntimeFunction (method: string, key: string, { documentation, ty
|
|||||||
modifier: createType(registry, 'StorageEntryModifierLatest', 1), // required
|
modifier: createType(registry, 'StorageEntryModifierLatest', 1), // required
|
||||||
type: createType(registry, 'StorageEntryTypeLatest', type, 0),
|
type: createType(registry, 'StorageEntryTypeLatest', type, 0),
|
||||||
toJSON: (): any => key
|
toJSON: (): any => key
|
||||||
} as unknown as StorageEntryMetadataLatest,
|
} as StorageEntryMetadataLatest,
|
||||||
method,
|
method,
|
||||||
prefix: 'Substrate',
|
prefix: 'Substrate',
|
||||||
section: 'substrate'
|
section: 'substrate'
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ export default class Rpc implements RpcInterface {
|
|||||||
: this.createMethodSend(def);
|
: this.createMethodSend(def);
|
||||||
|
|
||||||
return exposed;
|
return exposed;
|
||||||
}, {} as unknown as RpcInterface[Section]);
|
}, {} as RpcInterface[Section]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private createMethodSend (method: RpcMethod): RpcInterfaceMethod {
|
private createMethodSend (method: RpcMethod): RpcInterfaceMethod {
|
||||||
|
|||||||
@@ -20,31 +20,31 @@ describe('decodeResponse', (): void => {
|
|||||||
|
|
||||||
it('expects a valid jsonrpc field', (): void => {
|
it('expects a valid jsonrpc field', (): void => {
|
||||||
expect(
|
expect(
|
||||||
(): any => coder.decodeResponse({} as unknown as JsonRpcResponse)
|
(): any => coder.decodeResponse({} as JsonRpcResponse)
|
||||||
).toThrow(/Invalid jsonrpc/);
|
).toThrow(/Invalid jsonrpc/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('expects a valid id field', (): void => {
|
it('expects a valid id field', (): void => {
|
||||||
expect(
|
expect(
|
||||||
(): any => coder.decodeResponse({ jsonrpc: '2.0' } as unknown as JsonRpcResponse)
|
(): any => coder.decodeResponse({ jsonrpc: '2.0' } as JsonRpcResponse)
|
||||||
).toThrow(/Invalid id/);
|
).toThrow(/Invalid id/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('expects a valid result field', (): void => {
|
it('expects a valid result field', (): void => {
|
||||||
expect(
|
expect(
|
||||||
(): any => coder.decodeResponse({ id: 1, jsonrpc: '2.0' } as unknown as JsonRpcResponse)
|
(): any => coder.decodeResponse({ id: 1, jsonrpc: '2.0' } as JsonRpcResponse)
|
||||||
).toThrow(/No result/);
|
).toThrow(/No result/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws any error found', (): void => {
|
it('throws any error found', (): void => {
|
||||||
expect(
|
expect(
|
||||||
(): any => coder.decodeResponse({ id: 1, jsonrpc: '2.0', error: { code: 123, message: 'test error' } } as unknown as JsonRpcResponse)
|
(): any => coder.decodeResponse({ id: 1, jsonrpc: '2.0', error: { code: 123, message: 'test error' } } as JsonRpcResponse)
|
||||||
).toThrow(/123: test error/);
|
).toThrow(/123: test error/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns the result', (): void => {
|
it('returns the result', (): void => {
|
||||||
expect(
|
expect(
|
||||||
coder.decodeResponse({ id: 1, jsonrpc: '2.0', result: 'some result' } as unknown as JsonRpcResponse)
|
coder.decodeResponse({ id: 1, jsonrpc: '2.0', result: 'some result' } as JsonRpcResponse)
|
||||||
).toEqual('some result');
|
).toEqual('some result');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ export default class Mock implements ProviderInterface {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return subs;
|
return subs;
|
||||||
}, ({} as unknown as MockStateSubscriptions));
|
}, ({} as MockStateSubscriptions));
|
||||||
|
|
||||||
private subscriptionId = 0;
|
private subscriptionId = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ function extractDef (registry: Registry, _def: Record<string, InterfaceTypes | C
|
|||||||
def[key] = Null;
|
def[key] = Null;
|
||||||
|
|
||||||
return def;
|
return def;
|
||||||
}, {} as unknown as TypesDef),
|
}, {} as TypesDef),
|
||||||
isBasic: true
|
isBasic: true
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export default class Struct<
|
|||||||
|
|
||||||
protected _Types: ConstructorDef;
|
protected _Types: ConstructorDef;
|
||||||
|
|
||||||
constructor (registry: Registry, Types: S, value: V | Map<any, any> | any[] | string = {} as unknown as V, jsonMap: Map<keyof S, string> = new Map()) {
|
constructor (registry: Registry, Types: S, value: V | Map<any, any> | any[] | string = {} as V, jsonMap: Map<keyof S, string> = new Map()) {
|
||||||
const Clazzes = mapToTypeMap(registry, Types);
|
const Clazzes = mapToTypeMap(registry, Types);
|
||||||
const decoded: T = Struct.decodeStruct(registry, Clazzes, value, jsonMap);
|
const decoded: T = Struct.decodeStruct(registry, Clazzes, value, jsonMap);
|
||||||
|
|
||||||
@@ -75,9 +75,9 @@ export default class Struct<
|
|||||||
(raw as any)[key] = values[index];
|
(raw as any)[key] = values[index];
|
||||||
|
|
||||||
return raw;
|
return raw;
|
||||||
}, {} as unknown as T);
|
}, {} as T);
|
||||||
} else if (!value) {
|
} else if (!value) {
|
||||||
return {} as unknown as T;
|
return {} as T;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We assume from here that value is a JS object (Array, Map, Object)
|
// We assume from here that value is a JS object (Array, Map, Object)
|
||||||
@@ -114,7 +114,7 @@ export default class Struct<
|
|||||||
}
|
}
|
||||||
|
|
||||||
return raw;
|
return raw;
|
||||||
}, {} as unknown as T);
|
}, {} as T);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static with<S extends TypesDef> (Types: S): Constructor<Struct<S>> {
|
public static with<S extends TypesDef> (Types: S): Constructor<Struct<S>> {
|
||||||
@@ -162,7 +162,7 @@ export default class Struct<
|
|||||||
(result as any)[key] = new Type(this.registry).toRawType();
|
(result as any)[key] = new Type(this.registry).toRawType();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}, {} as unknown as E);
|
}, {} as E);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -240,7 +240,7 @@ export default class Struct<
|
|||||||
result[key] = new Type(registry).toRawType();
|
result[key] = new Type(registry).toRawType();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}, {} as unknown as Record<string, string>);
|
}, {} as Record<string, string>);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ function _decodeFixedVec (value: TypeDef, type: string, _: string): TypeDef {
|
|||||||
// as a first round, only u8 via u8aFixed, we can add more support
|
// as a first round, only u8 via u8aFixed, we can add more support
|
||||||
assert(vecLen <= 256, `${type}: Only support for [Type; <length>], where length <= 256`);
|
assert(vecLen <= 256, `${type}: Only support for [Type; <length>], where length <= 256`);
|
||||||
|
|
||||||
value.ext = { length: vecLen, type: vecType } as unknown as TypeDefExtVecFixed;
|
value.ext = { length: vecLen, type: vecType } as TypeDefExtVecFixed;
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ function _removeWrap (_check: string): Mapper {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function santize (value: string): string {
|
export default function sanitize (value: string): string {
|
||||||
return mappings.reduce((result, fn): string => {
|
return mappings.reduce((result, fn): string => {
|
||||||
return fn(result);
|
return fn(result);
|
||||||
}, value).trim();
|
}, value).trim();
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ export default class Call extends Struct implements IMethod {
|
|||||||
result[name.toString()] = Type;
|
result[name.toString()] = Type;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}, {} as unknown as ArgsDef);
|
}, {} as ArgsDef);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user