Skip to content

Commit c024f1b

Browse files
committed
retrive all methods
1 parent 4e6b5e2 commit c024f1b

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

src/CLI.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ class CLI {
2121
async start() {
2222
try {
2323
this._api = await this._handler.getApi();
24+
console.log(`${this._api.libraryInfo} is loaded`);
2425
this._retriveMethod();
2526
this._repl = repl.start({
2627
prompt: `api-cli (${this._endpoint}) > `,
2728
eval: this._interpret.bind(this),
2829
completer: this._completer.bind(this),
2930
});
3031
this._repl.context.api = this._api;
32+
3133

3234
} catch (e) {
3335
console.log(e);
@@ -64,12 +66,17 @@ class CLI {
6466

6567
private _retriveMethod() {
6668
const types = ['rpc', 'consts', 'query', 'tx', 'derive'];
67-
let modules = Object.keys(this._api.query);
68-
for (let m of modules) {
69-
const methods = Object.keys(this._api.query[m]);
70-
for (let e of methods) {
71-
this._methods.push(`api.query.${m}.${e}`);
69+
let modules = Object.getOwnPropertyNames(this._api.query);
70+
71+
for (let i=0; i < modules.length; i++) {
72+
const module = modules[i];
73+
const methods = Object.getOwnPropertyNames(this._api.query[module]);
74+
75+
for (let j=0; j < methods.length; j++) {
76+
const method = methods[j];
77+
this._methods.push(`api.query.${module}.${method}`);
7278
}
79+
7380
}
7481

7582
// modules = Object.keys(this._api.derive);

0 commit comments

Comments
 (0)