Compact unwrap (returns raw UInt/Moment) (#636)
This commit is contained in:
committed by
Amaury Martiny
parent
e4de84b225
commit
5898caa71e
@@ -145,6 +145,10 @@ describe('Compact', () => {
|
||||
it('compares against a primitive', () => {
|
||||
expect(new Compact(U32, 12345).eq(12345)).toBe(true);
|
||||
});
|
||||
|
||||
it('unwraps to the wrapped value', () => {
|
||||
expect(new Compact(U32, 12345).unwrap() instanceof U32).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('helpers', () => {
|
||||
|
||||
@@ -133,4 +133,11 @@ export default class Compact extends Base<UInt | Moment> implements Codec {
|
||||
toU8a (isBare?: boolean): Uint8Array {
|
||||
return Compact.encodeU8a(this.raw.toBn());
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the embedded [[UInt]] or [[Moment]] value
|
||||
*/
|
||||
unwrap (): UInt | Moment {
|
||||
return this.raw;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user