diff --git a/src/ain.ts b/src/ain.ts index 1928df4..9044401 100644 --- a/src/ain.ts +++ b/src/ain.ts @@ -3,6 +3,7 @@ import { getBlockChainEndpoint } from "./constants"; import { TransactionBody } from "@ainblockchain/ain-util"; import { txResult } from "./types/type"; import { Signer } from "@ainblockchain/ain-js/lib/signer/signer"; +import { DefaultSigner } from "@ainblockchain/ain-js/lib/signer/default-signer" // NOTE(yoojin): Plz suggest a good name. export default class AinModule { @@ -65,6 +66,15 @@ export default class AinModule { this.ain!.wallet.removeDefaultAccount(); } + removeSigner() { + this.checkAinInitiated(); + const wallet = this.ain!.wallet; + const provider = this.ain!.provider; + wallet.removeDefaultAccount(); + this.ain!.setSigner(new DefaultSigner(wallet, provider)) + } + + async getBalance() { this.isDefaultAccountExist(); return await this.ain!.wallet.getBalance(); diff --git a/src/ainize.ts b/src/ainize.ts index 31f4400..7e2950b 100644 --- a/src/ainize.ts +++ b/src/ainize.ts @@ -56,7 +56,7 @@ export default class Ainize { * Logout from ainize. */ async logout() { - this.ain.removeDefaultAccount(); + this.ain.removeSigner(); await this.handler.disconnect(); console.log('logout success!'); }