diff --git a/examples/client/getModuleList.ts b/examples/client/getModuleList.ts index 71822cb54..0d678ac32 100644 --- a/examples/client/getModuleList.ts +++ b/examples/client/getModuleList.ts @@ -1,5 +1,5 @@ import { parseEndpoint } from '../shared/util.js'; -import { BlockHash, HexString } from '@concordium/web-sdk'; +import { BlockHash, ModuleReference } from '@concordium/web-sdk'; import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; @@ -54,12 +54,12 @@ const client = new ConcordiumGRPCNodeClient( cli.flags.block === undefined ? undefined : BlockHash.fromHexString(cli.flags.block); - const moduleRefs: AsyncIterable = + const moduleRefs: AsyncIterable = client.getModuleList(blockHash); // #endregion documentation-snippet // Prints module references for await (const moduleRef of moduleRefs) { - console.log(moduleRef); + console.log(ModuleReference.toHexString(moduleRef)); } })(); diff --git a/packages/sdk/src/types/ModuleReference.ts b/packages/sdk/src/types/ModuleReference.ts index a69f38948..732998a32 100644 --- a/packages/sdk/src/types/ModuleReference.ts +++ b/packages/sdk/src/types/ModuleReference.ts @@ -69,6 +69,15 @@ export function fromHexString(moduleRef: HexString) { ); } +/** + * Get the module reference bytes encoded as hex. + * @param {ModuleReference} moduleReference The module reference. + * @returns {HexString} String with hex encoding. + */ +export function toHexString(moduleReference: ModuleReference): HexString { + return moduleReference.moduleRef; +} + /** * Convert module reference from its protobuf encoding. * @param {Proto.ModuleRef} moduleReference The module reference in protobuf.