Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@appliedblockchain/helpers

Package Overview
Dependencies
Maintainers
14
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@appliedblockchain/helpers - npm Package Compare versions

Comparing version 3.1.1 to 3.2.0

checksum-address-of-address.js

9

Changelog.md
# Changelog
## [v3.2.0](../../compare/v3.1.1...v3.2.0) (2019-11-28)
* Updating speculative nonce tests to work on real addresses.
* Updating speculative nonce to work on checksum addresses.
* Adding checksum-address-of-address helper.
* Adding tests around speculative nonce.
* Lowering speculative nonce timeout from 1m to 12s.
* Updating changelog.
## [v3.1.1](../../compare/v3.1.0...v3.1.1) (2019-11-06)

@@ -4,0 +13,0 @@

2

package.json
{
"name": "@appliedblockchain/helpers",
"version": "3.1.1",
"version": "3.2.0",
"description": "No dependency, single file helpers.",

@@ -5,0 +5,0 @@ "main": "index.js",

// @flow
const { inspect } = require('util')
const assert = require('assert')
const { inspect } = require('util')
const rejectTimeout = require('./reject-timeout')
const checksumAddressOfAddress_ = require('./checksum-address-of-address')
const Err = require('./err')
const logOf = require('./log-of')
const rejectTimeout = require('./reject-timeout')

@@ -20,5 +21,13 @@ /*::

/** Expire cached nonces after 1 minute. */
const defaultTimeout = 60 * 1000
/** Expire cached nonces after 12 seconds. */
const defaultTimeout = 12 * 1000
function checksumAddressOfAddress(address) {
const checksumAddress = checksumAddressOfAddress_(address)
if (checksumAddress !== address) {
log.warn(`Invalid checksum address ${address}.`, (new Error).stack)
}
return checksumAddress
}
class SpeculativeNonce {

@@ -43,3 +52,3 @@

this.nonceOfAddress = (address /*: string */) => {
return rejectTimeout(nonceOfAddress(address), defaultTimeout - 1000)
return rejectTimeout(nonceOfAddress(checksumAddressOfAddress(address)), defaultTimeout - 1000)
}

@@ -52,4 +61,6 @@

next(address /*: string */) /*: Promise<number> */ {
next(address_ /*: string */) /*: Promise<number> */ {
const address = checksumAddressOfAddress(address_)
// If there's nonce available, use sync code path to retrieve it.

@@ -66,3 +77,6 @@ const nonce = this.nonces.get(address)

addExecutor(address /*: string */, executor /*: Executor */) {
addExecutor(address_ /*: string */, executor /*: Executor */) {
const address = checksumAddressOfAddress(address_)
const { nonceOfAddress } = this

@@ -80,3 +94,4 @@ const executors = this.executors.get(address)

resolveNonce(address /*: string */, nonce_ /*: number */) {
resolveNonce(address_ /*: string */, nonce_ /*: number */) {
const address = checksumAddressOfAddress(address_)
let nonce = nonce_

@@ -112,3 +127,4 @@ assert(!this.nonces.has(address), `Expected nonce for ${inspect(address)} to be undefined.`)

rejectNonce(address /*: string */, err /*: Error */) {
rejectNonce(address_ /*: string */, err /*: Error */) {
const address = checksumAddressOfAddress(address_)
const executors = this.executors.get(address)

@@ -115,0 +131,0 @@ if (!executors) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc