Skip to content

Commit 835e1be

Browse files
authored
Merge pull request #35 from Terran-One/feat/storage-keys
IStorage.keys method
2 parents 5eabe0e + 0af1d27 commit 835e1be

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@terran-one/cosmwasm-vm-js",
3-
"version": "0.1.14",
3+
"version": "0.1.15",
44
"license": "MIT",
55
"author": "TerranOne",
66
"main": "dist/index.js",

src/backend/storage.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export interface IStorage {
99
set(key: Uint8Array, value: Uint8Array): void;
1010

1111
remove(key: Uint8Array): void;
12+
13+
keys(): Iterable<Uint8Array>;
1214
}
1315

1416
export class Record {
@@ -42,6 +44,12 @@ export interface IIterStorage {
4244
export class BasicKVStorage implements IStorage {
4345
// TODO: Add binary uint / typed Addr maps for cw-storage-plus compatibility
4446
constructor(public dict: Immutable.Map<string, string> = Immutable.Map()) {}
47+
48+
*keys() {
49+
for (const key of this.dict.keys()) {
50+
yield fromBase64(key);
51+
}
52+
}
4553

4654
get(key: Uint8Array): Uint8Array | null {
4755
const keyStr = toBase64(key);

0 commit comments

Comments
 (0)