diff --git a/assembly/std/op-datastore/op-datastore.ts b/assembly/std/op-datastore/op-datastore.ts index 6e93cc33..7e0e3520 100644 --- a/assembly/std/op-datastore/op-datastore.ts +++ b/assembly/std/op-datastore/op-datastore.ts @@ -23,38 +23,6 @@ import { env } from '../../env'; import { derKeys } from './util'; -/** - * Retrieves all the keys from the operation datastore. - * - * @param prefix - the serialized prefix to filter the keys (optional) - * - * @returns - a list of keys (e.g. a list of byte array) - * - */ -export function getKeys( - prefix: StaticArray = new StaticArray(0), -): Array> { - let keysSer = env.getKeys(prefix); - return derKeys(keysSer); -} - -/** - * Retrieves all the keys from the operation datastore from a remote address. - * - * @param address - the address in the datastore - * @param prefix - the prefix to filter the keys (optional) - * - * @returns - a list of key (e.g. a list of byte array) - * - */ -export function getKeysOf( - address: string, - prefix: StaticArray = new StaticArray(0), -): Array> { - let keysSer = env.getKeysOf(address, prefix); - return derKeys(keysSer); -} - /** * Checks if a given serialized 'key' is present in the operation datastore. * diff --git a/assembly/std/storage.ts b/assembly/std/storage.ts index bd690124..d02bf50c 100644 --- a/assembly/std/storage.ts +++ b/assembly/std/storage.ts @@ -40,6 +40,7 @@ import { env } from '../env'; import { Address } from './address'; import { Args, bytesToString, stringToBytes } from '@massalabs/as-types'; +import { derKeys } from './op-datastore'; /** * Converts the given value to a StaticArray to match the expected format for datastore operations. @@ -313,3 +314,35 @@ export function has(key: T): bool { export function hasOf(address: Address, key: T): bool { return env.hasOf(address.toString(), toDatastoreFormat(key)); } + +/** + * Retrieves all the keys from the datastore. + * + * @param prefix - the serialized prefix to filter the keys (optional) + * + * @returns - a list of keys (e.g. a list of byte array) + * + */ +export function getKeys( + prefix: StaticArray = new StaticArray(0), +): Array> { + let keysSer = env.getKeys(prefix); + return derKeys(keysSer); +} + +/** + * Retrieves all the keys from the datastore from a remote address. + * + * @param address - the address in the datastore + * @param prefix - the prefix to filter the keys (optional) + * + * @returns - a list of key (e.g. a list of byte array) + * + */ +export function getKeysOf( + address: string, + prefix: StaticArray = new StaticArray(0), +): Array> { + let keysSer = env.getKeysOf(address, prefix); + return derKeys(keysSer); +}