Change registry.chainToekn to registry.chainTokens (#3096)

This commit is contained in:
Jaco Greeff
2021-01-23 13:36:30 +01:00
committed by GitHub
parent 6a69fdfbbf
commit 644d0e6c2e
4 changed files with 16 additions and 3 deletions
+13
View File
@@ -1,5 +1,18 @@
# CHANGELOG
## 3.6.x
Upgrade priority: Medium if not already on at least 3.3.1. The next upgrade of Kusama requires it.
- **Breaking change** To support chains with multiple tokens, such as bridges, the `ChainProperties` type now returns an array of tokens and decimals (instead of singular values) in the `token{Decimals, Symbol}` getters. Additionally, this means that the `registry` interfaces has been changes, to `registry.chainDecimals: number[]` and `registry.chainTokens: string[]`. Where used the `[0]` index will return the first value if only interested in a single, for a straight conversion.
Changes:
- Cater for multiple tokens and decimals in the chain the chain `system.properties` (as per the chain specification)
- Add a `instances: { [key]: [module1, module2] }` definition in teh bundle types, allowing for multiple instances (e.g. Balances)
- Adjust the `api-derive` for balances to retrieve values via `instances` as well as across multiple modules
## 3.5.1 Jan 18, 2020
Upgrade priority: Low. Recommended for parachain developers.
+1 -1
View File
@@ -181,7 +181,7 @@ export abstract class AbstractInt extends BN implements Codec {
? 'everything'
// FIXME In the case of multiples we need some way of detecting which instance this belongs
// to. as it stands we will always format (incorrectly) against the first token defined
: formatBalance(this, { decimals: this.registry.chainDecimals[0], withSi: true, withUnit: this.registry.chainToken[0] });
: formatBalance(this, { decimals: this.registry.chainDecimals[0], withSi: true, withUnit: this.registry.chainTokens[0] });
}
const [, divisor] = FORMATTERS.find(([type]) => type === rawType) || [];
+1 -1
View File
@@ -178,7 +178,7 @@ export class TypeRegistry implements Registry {
: undefined;
}
public get chainToken (): string[] {
public get chainTokens (): string[] {
if (this.#chainProperties?.tokenSymbol.isSome) {
const allTokens = this.#chainProperties.tokenSymbol.unwrap();
+1 -1
View File
@@ -84,7 +84,7 @@ export interface RegisteredTypes {
export interface Registry {
readonly chainDecimals: number[];
readonly chainSS58: number | undefined;
readonly chainToken: string[];
readonly chainTokens: string[];
readonly knownTypes: RegisteredTypes;
readonly signedExtensions: string[];