Skip to content

Commit

Permalink
fix: login
Browse files Browse the repository at this point in the history
  • Loading branch information
akastercomcom committed Sep 20, 2023
1 parent 60fd8f1 commit 1feb377
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/ainize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export default class Ainize {

constructor(chainId: 1 | 0) {
this.ain.initAin(chainId);
this.handler.connect();
this.cache = new NodeCache();
this.middleware = new Middleware(this.cache);
}
Expand All @@ -24,14 +23,20 @@ export default class Ainize {
return AinModule.getInstance().createAccount();
}

login(privateKey: string) {
async login(privateKey: string) {
this.ain.setDefaultAccount(privateKey);
await this.handler.connect();
console.log('login success! address:', this.ain.getAddress());
}

logout() {
this.ain.removeDefaultAccount();
}

async getAddress(): Promise<string> {
return await this.ain.getAddress();
}

async getAinBalance(): Promise<number> {
return await this.ain.getBalance();
}
Expand All @@ -52,7 +57,7 @@ export default class Ainize {
}

await this.appController.createApp({ appName: modelName, serviceUrl, billingConfig });
return new Model(modelName);
return this.model(modelName);
}

model(modelName: string): Model {
Expand Down
2 changes: 1 addition & 1 deletion src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ModelController from "./controllers/modelController";

export default class Model {
modelName: string;
modelController: ModelController;
private modelController: ModelController;

constructor(modelName: string) {
this.modelName = modelName;
Expand Down

0 comments on commit 1feb377

Please sign in to comment.