diff --git a/src/ain.ts b/src/ain.ts index f4c8835..1256256 100644 --- a/src/ain.ts +++ b/src/ain.ts @@ -18,20 +18,23 @@ export default class AinModule { return AinModule.instance; } + static createAccount() { + const blockchainAPIEndpoint = getBlockChainAPIEndpoint(0); + const blockchainEventEndpoint = getBlockChainEventEndpoint(0); + const ain = new Ain(blockchainAPIEndpoint, blockchainEventEndpoint, 0); + + const newAccount = ain.wallet.create(1)[0]; + const wallet = ain.wallet.accounts[newAccount]; + + return wallet; + } + initAin(chainId: 0 | 1) { const blockchainAPIEndpoint = getBlockChainAPIEndpoint(chainId); const blockchainEventEndpoint = getBlockChainEventEndpoint(chainId); this.ain = new Ain(blockchainAPIEndpoint, blockchainEventEndpoint, chainId); } - createAccount() { - this.checkAinInitiated(); - const newAccount = this.ain!.wallet.create(1)[0]; - const wallet = this.ain!.wallet.accounts[newAccount]; - this.ain!.wallet.remove(newAccount); - return wallet; - } - setDefaultAccount(privateKey: string) { this.checkAinInitiated(); this.ain!.wallet.addAndSetDefaultAccount(privateKey); diff --git a/src/ainize.ts b/src/ainize.ts index 0dd631e..8c5c926 100644 --- a/src/ainize.ts +++ b/src/ainize.ts @@ -32,7 +32,7 @@ export default class Ainize { * @returns {Account} created account. */ static createAinAccount (): Account { - return AinModule.getInstance().createAccount(); + return AinModule.createAccount(); } /**