Expand Data (from identity) with all is/as getters (#3429)

This commit is contained in:
Jaco
2021-04-23 07:34:01 +02:00
committed by GitHub
parent 90d8db651b
commit 5903704b61
2 changed files with 30 additions and 1 deletions
+2 -1
View File
@@ -7,7 +7,8 @@ Changes:
- Adjust Struct decoding with better error messages on invalid input objects
- Add support for new `BoundedVec` type
- Adjusted Statemint `Proxy` type
- Updated Xcm types (with Plularity)
- Expand `Data` type (as used in identity), with all is/as getters
- Updated `Xcm` types (with Plularity)
- Remove metadata generation dependency on well-known.json (dedupe)
- Adjust WebSocket reconnection delay from 1s to 2.5s
- Revert Beefy keys addition for Westend
+28
View File
@@ -59,6 +59,14 @@ export class Data extends Enum {
}, ...decodeData(registry, value));
}
get asBlakeTwo256 (): H256 {
return this.value as H256;
}
get asKeccak256 (): H256 {
return this.value as H256;
}
get asRaw (): Bytes {
return this.value as Bytes;
}
@@ -67,6 +75,22 @@ export class Data extends Enum {
return this.value as H256;
}
get asShaThree256 (): H256 {
return this.value as H256;
}
get isBlakeTwo256 (): boolean {
return this.index === 2;
}
get isKeccak256 (): boolean {
return this.index === 4;
}
get isNone (): boolean {
return this.index === 0;
}
get isRaw (): boolean {
return this.index === 1;
}
@@ -75,6 +99,10 @@ export class Data extends Enum {
return this.index === 3;
}
get isShaThree256 (): boolean {
return this.index === 5;
}
/**
* @description The encoded length
*/