Skip to content

Commit

Permalink
Merge pull request #130 from ainize-team/release/1.3.1
Browse files Browse the repository at this point in the history
Upgrade version to 1.3.1
  • Loading branch information
yoojinko authored Aug 14, 2024
2 parents 5b9bd5e + f37ac98 commit 08e2a07
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 28 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ainize-team/ainize-js",
"version": "1.3.0",
"version": "1.3.1",
"main": "dist/ainize.js",
"types": "dist/ainize.d.ts",
"scripts": {
Expand Down Expand Up @@ -42,7 +42,7 @@
"typescript": "^4.6.3"
},
"dependencies": {
"@ainblockchain/ain-js": "^1.12.0",
"@ainblockchain/ain-js": "^1.13.0",
"axios": "^0.26.1",
"express": "^4.18.2",
"fast-json-stable-stringify": "^2.1.0",
Expand Down
16 changes: 11 additions & 5 deletions src/ainize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,27 @@ export default class Ainize {

/**
* Login to ainize using AI Network account private key.
* @param {string} privateKey
* @param {string} privateKey The private key to initialize the AinModule with.
* @param {ConnectionCallback} ConnectionCallback The connection callback function.
* @param {DisconnectionCallback} disconnectionCallback The disconnection callback function.
* @param {string} customClientId The custom client id to set.
*/
async login(privateKey: string, connectionCb?: ConnectionCallback, disconnectionCb?: DisconnectionCallback) {
async login(privateKey: string, connectionCb?: ConnectionCallback, disconnectionCb?: DisconnectionCallback, customClientId?: string) {
this.ain.setDefaultAccount(privateKey);
await this.handler.connect(connectionCb, disconnectionCb);
await this.handler.connect(connectionCb, disconnectionCb, customClientId);
console.log('login success! address:', await this.ain.getAddress());
}

/**
* Login to ainize using AIN Wallet Signer.
* @param {ConnectionCallback} ConnectionCallback The connection callback function.
* @param {DisconnectionCallback} disconnectionCallback The disconnection callback function.
* @param {string} customClientId The custom client id to set.
*/
async loginWithSigner(connectionCb?: ConnectionCallback, disconnectionCb?: DisconnectionCallback) {
async loginWithSigner(connectionCb?: ConnectionCallback, disconnectionCb?: DisconnectionCallback, customClientId?: string) {
const signer = new AinWalletSigner;
this.ain.setSigner(signer);
await this.handler.connect(connectionCb, disconnectionCb);
await this.handler.connect(connectionCb, disconnectionCb, customClientId);
console.log('login success! address: ', await this.ain.getAddress());
}

Expand Down
19 changes: 2 additions & 17 deletions src/handlers/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ export default class Handler {
return this.ain.getEventManager().isConnected();
}

async connect(connectionCb?: ConnectionCallback, disconnectionCb?: DisconnectionCallback) {
async connect(connectionCb?: ConnectionCallback, disconnectionCb?: DisconnectionCallback, customClientId?: string) {
this.checkEventManager();
await this.ain.getEventManager().connect(connectionCb, this.connectionRetryCb.bind(this, connectionCb, disconnectionCb));
await this.ain.getEventManager().connect(connectionCb, disconnectionCb, customClientId);
console.log('connected');
};

Expand All @@ -36,21 +36,6 @@ export default class Handler {
console.log('Disconnected');
}

private async connectionRetryCb(connectionCb?: ConnectionCallback, disconnectionCb?: DisconnectionCallback, webSocket?: any) {
try {
if (disconnectionCb) {
disconnectionCb(webSocket);
}
const address = await AinModule.getInstance().getAddress();
if (address) {
console.log('Disconnected. Reconnecting...');
await this.connect(connectionCb, disconnectionCb);
}
} catch (_) {
return;
}
}

async subscribe(subscribePath: string, resolve: any) {
this.checkEventManager();

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# yarn lockfile v1


"@ainblockchain/ain-js@^1.12.0":
version "1.12.0"
resolved "https://registry.yarnpkg.com/@ainblockchain/ain-js/-/ain-js-1.12.0.tgz#6bd2c051ae200b6a8eee28d175f14fa677f56e04"
integrity sha512-wsipsiVzgtAkNhBR04t/UlQ7nXnIt1MRU11kctYzCbFsz8YrVhrX6WM2kXxWEsm37KnmtsZkt7f6WgfO/JdM4Q==
"@ainblockchain/ain-js@^1.13.0":
version "1.13.0"
resolved "https://registry.yarnpkg.com/@ainblockchain/ain-js/-/ain-js-1.13.0.tgz#547a036385ac8ea2fb9a643cbf8151bf4c4b65ed"
integrity sha512-XFxbxamfoUbgh6iOUjIQZPduotEI32lsRZxYCjD5SGlQ/kXzdrZ9rz0EJCFoE0O/Nu6bawC7h96Jvc8M/xon0w==
dependencies:
"@ainblockchain/ain-util" "^1.2.1"
"@types/node" "^12.7.3"
Expand Down

0 comments on commit 08e2a07

Please sign in to comment.