From 72e25f810c91da55809cbb7d3363b79b5e206a11 Mon Sep 17 00:00:00 2001 From: Pana Date: Thu, 16 May 2024 14:12:20 +0800 Subject: [PATCH] add sanitize logic to BatchRequester (#253) --- README.md | 6 ++++-- src/rpc/BatchRequester.js | 7 +++++++ yarn.lock | 4 ++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2533866..63878d4 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![npm](https://img.shields.io/npm/v/js-conflux-sdk.svg)](https://www.npmjs.com/package/js-conflux-sdk) [![npm](https://img.shields.io/npm/dm/js-conflux-sdk.svg)](https://www.npmjs.com/package/js-conflux-sdk) -JavaScript Conflux Software Development Kit is a complete library for interacting with the [Conflux Blockchain Core Space](https://doc.confluxnetwork.org/docs/core/Overview) in both Node.js and browser environment. +JavaScript Conflux Software Development Kit is a complete library for interacting with the **[Conflux Blockchain Core Space](https://doc.confluxnetwork.org/docs/core/Overview)** in both Node.js and browser environment. Featured with: @@ -18,6 +18,8 @@ Featured with: 4. Type conversion * Extensive documentation and examples +For the Conflux eSpace JS SDK, consider using one of the following robust libraries: [ethers.js](https://docs.ethers.org/v6/), [viem](https://viem.sh/), or [web3.js](https://web3js.readthedocs.io/en/v1.10.0/) + ## Docs * [js-conflux-sdk documentation](https://docs.confluxnetwork.org/js-conflux-sdk) @@ -35,7 +37,7 @@ Featured with: Install through npm ```sh -$ npm install js-conflux-sdk +npm install js-conflux-sdk ``` ## How to import diff --git a/src/rpc/BatchRequester.js b/src/rpc/BatchRequester.js index bcafb38..499a36e 100644 --- a/src/rpc/BatchRequester.js +++ b/src/rpc/BatchRequester.js @@ -1,5 +1,6 @@ const RPCError = require('../provider/RPCError'); const Transaction = require('../Transaction'); +const format = require('../util/format'); const SEND_TX_METHOD = 'cfx_sendTransaction'; const SEND_RAW_TX_METHOD = 'cfx_sendRawTransaction'; @@ -172,6 +173,9 @@ class BatchRequester { } _markNonceUsed(from, nonce) { + from = format.address(from, this.conflux.networkId); + nonce = format.bigUInt(nonce); + if (!this.accountUsedNonces[from]) { this.accountUsedNonces[from] = {}; } @@ -179,6 +183,9 @@ class BatchRequester { } _isNonceUsed(from, nonce) { + from = format.address(from, this.conflux.networkId); + nonce = format.bigUInt(nonce); + return this.accountUsedNonces[from] && this.accountUsedNonces[from][nonce]; } diff --git a/yarn.lock b/yarn.lock index e891ea5..45edd2d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -922,9 +922,9 @@ exec-sh "^0.3.2" minimist "^1.2.0" -"@conflux-dev/conflux-address-js@^1.3.16": +"@conflux-dev/conflux-address-js@1.3.16": version "1.3.16" - resolved "https://registry.yarnpkg.com/@conflux-dev/conflux-address-js/-/conflux-address-js-1.3.16.tgz#2ae7733138fe160e177392d7e1dc5f27590d1ee6" + resolved "https://registry.npmmirror.com/@conflux-dev/conflux-address-js/-/conflux-address-js-1.3.16.tgz#2ae7733138fe160e177392d7e1dc5f27590d1ee6" integrity sha512-9n7wFCr7Wu4WYdngPfxB63bRHSk+0xWFHVqVwUPddg3oIRT+sQm+TcHGiXaiuvnjnvjDFfCMbHnjZ+a8X5C/aA== dependencies: jsbi "^3.1.4"