From 422b730d7caafdf9e61eedd5286bf90effddc363 Mon Sep 17 00:00:00 2001 From: 1aerostorm Date: Fri, 6 Sep 2024 05:24:59 +0300 Subject: [PATCH] JS - 0.9.75, HF 30 - Optimize private groups, small fix --- golos-lib-js/package.json | 2 +- golos-lib-js/src/auth/index.js | 15 ++++++++++----- golos-lib-js/src/auth/messages.js | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/golos-lib-js/package.json b/golos-lib-js/package.json index a1422d2..05d77b9 100644 --- a/golos-lib-js/package.json +++ b/golos-lib-js/package.json @@ -1,6 +1,6 @@ { "name": "golos-lib-js", - "version": "0.9.74", + "version": "0.9.75", "description": "Golos-js the JavaScript library with API for GOLOS blockchain", "main": "lib/index.js", "scripts": { diff --git a/golos-lib-js/src/auth/index.js b/golos-lib-js/src/auth/index.js index f8b3c4d..c4e5dfd 100644 --- a/golos-lib-js/src/auth/index.js +++ b/golos-lib-js/src/auth/index.js @@ -137,10 +137,6 @@ Auth.withNodeLogin = async function ({ account, keys, api = golosApi } - if (!dgp) { - dgp = await api.getDynamicGlobalPropertiesAsync() - } - let resp const { MultiSession } = multiSession @@ -154,7 +150,16 @@ Auth.withNodeLogin = async function ({ account, keys, } } - const { head_block_number, witness } = dgp + let gprops + if (!dgp) { + gprops = await api.getDynamicGlobalPropertiesAsync() + } else if (typeof(dgp) === 'function') { + gprops = await dgp() + } else { + gprops = dgp + } + + const { head_block_number, witness } = gprops console.time('withNodeLogin - signData') const signed = this.signData(head_block_number.toString(), keys) diff --git a/golos-lib-js/src/auth/messages.js b/golos-lib-js/src/auth/messages.js index 523a52d..59c595e 100644 --- a/golos-lib-js/src/auth/messages.js +++ b/golos-lib-js/src/auth/messages.js @@ -642,7 +642,7 @@ export async function encodeMsg({ group, const encrypted_message = msg.toString('hex') return { - nonce: Aes.uniqueNonce().toString(), + nonce: nonce || Aes.uniqueNonce().toString(), encrypted_message, checksum: 0, from_memo_key: emptyPublicKey,