diff --git a/CHANGELOG.md b/CHANGELOG.md index 061d7ac43d..bef7856927 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,17 @@ Upgrade priority: Low, unless using the new `RewardDestination` or there is a need for transparent at-hash queries - **Important** Substrate changed the `RewardDestination` enum with an extra field for payout-to-any account. If on an older chain consider adding `RewardDestination: 'RewardDestinationTo257'` (Newer chains with this requirement met in their Substrate version should update the API for support) -- Add transparent support for types/metadata, i.e. hash queries such as `rpc.chain.getBlock()` & `query.system.events.at()` now works out-of-the-box with tehe correct metadata & types +- Fix documentation language and typos (Thanks to https://github.com/Meuko) +- Add missing `TransactionPriority` type (Thanks to https://github.com/aniiantt) +- Update definitions for new `CompactAssignments`, including tests (Thanks to https://github.com/kianenigma) +- Add transparent support for types/metadata, i.e. hash queries such as `rpc.chain.getBlock()` & `query.system.events.at()` now works out-of-the-box with the correct metadata & types +- Additional checks on `AccountId` for valid sizes - Add `toBigInt()` (JS built-in `BigInt`) on `Int/Uint`, & `Compact<*>` types +- Support for `.concat` on Codec arrays +- Support for serialization with `isBare` flag on enums - Add `api.swapRegistry(blockHash?)` to manually swap to types for a specific block (no param swaps to default) - `derive.democracy.locks` now returns delegated locks for an account as well +- Adjust unlocking derives with appropriate in-place additions (less object allocations) ## 1.30.1 Aug 24, 2020 diff --git a/packages/types/src/codec/AbstractArray.ts b/packages/types/src/codec/AbstractArray.ts index 391e1593c2..5858ab59c1 100644 --- a/packages/types/src/codec/AbstractArray.ts +++ b/packages/types/src/codec/AbstractArray.ts @@ -135,10 +135,15 @@ export default abstract class AbstractArray extends Array im // we want it to return an Array. We only override the methods that return a // new instance. + /** + * @description Concatenates two arrays + */ + public concat (other: T[]): T[] { + return this.toArray().concat(other instanceof AbstractArray ? other.toArray() : other); + } + /** * @description Filters the array with the callback - * @param callbackfn The filter function - * @param thisArg The `this` object to apply the result to */ public filter (callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: unknown): T[] { return this.toArray().filter(callbackfn, thisArg); @@ -146,8 +151,6 @@ export default abstract class AbstractArray extends Array im /** * @description Maps the array with the callback - * @param callbackfn The mapping function - * @param thisArg The `this` onject to apply the result to */ public map (callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: unknown): U[] { return this.toArray().map(callbackfn, thisArg); diff --git a/packages/types/src/codec/Vec.spec.ts b/packages/types/src/codec/Vec.spec.ts index 34ba312632..31983fa4c6 100644 --- a/packages/types/src/codec/Vec.spec.ts +++ b/packages/types/src/codec/Vec.spec.ts @@ -110,6 +110,12 @@ describe('Vec', (): void => { }); }); + it('exposes a working concat', (): void => { + expect( + vector.concat(new Vec(registry, Text, ['987', '654'])).toString() + ).toEqual('1,23,345,4567,56789,987,654'); + }); + it('exposes a working filter', (): void => { expect( vector.filter((e, i): boolean => i >= 3).toString()