-
Notifications
You must be signed in to change notification settings - Fork 337
/
KeyValue.ts
32 lines (27 loc) · 959 Bytes
/
KeyValue.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2017-2018 @polkadot/api-codec authors & contributors
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import Bytes from './codec/Bytes';
import Struct from './codec/Struct';
type KeyValueStruct = {
key?: Uint8Array | string,
value?: Uint8Array | string
};
// KeyValue structure. Since most of the keys and resultant values in Subtrate is
// hashed and/or encoded, this does not wrap a Text, but rather a Bytes
// for the keys and values. (Not to be confused with the KeyValue in Metadata, that
// is actually for Maps, whereas this is a representation of actaul storage values)
export default class KeyValue extends Struct {
constructor (value: KeyValueStruct = {}) {
super({
key: Bytes,
value: Bytes
}, value);
}
get key (): Bytes {
return this.raw.key as Bytes;
}
get value (): Bytes {
return this.raw.value as Bytes;
}
}