Skip to content

Commit

Permalink
Fix getModuleList example
Browse files Browse the repository at this point in the history
  • Loading branch information
limemloh committed Oct 6, 2023
1 parent d963d8a commit 1a35f73
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions examples/client/getModuleList.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -54,12 +54,12 @@ const client = new ConcordiumGRPCNodeClient(
cli.flags.block === undefined
? undefined
: BlockHash.fromHexString(cli.flags.block);
const moduleRefs: AsyncIterable<HexString> =
const moduleRefs: AsyncIterable<ModuleReference.Type> =
client.getModuleList(blockHash);
// #endregion documentation-snippet

// Prints module references
for await (const moduleRef of moduleRefs) {
console.log(moduleRef);
console.log(ModuleReference.toHexString(moduleRef));
}
})();
9 changes: 9 additions & 0 deletions packages/sdk/src/types/ModuleReference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 1a35f73

Please sign in to comment.