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

@eth-optimism/core-utils

Package Overview
Dependencies
Maintainers
5
Versions
228
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eth-optimism/core-utils - npm Package Compare versions

Comparing version 0.0.1-alpha.27 to 0.0.1-alpha.28

21

build/src/app/crypto.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTxSigner = exports.hashFunctionFor = exports.keccak256FromUtf8 = exports.keccak256 = exports.Md5Hash = void 0;
exports.signatureToRSV = exports.rsvToSignature = exports.getTxSigner = exports.hashFunctionFor = exports.keccak256FromUtf8 = exports.keccak256 = exports.Md5Hash = void 0;
const ts_md5_1 = require("ts-md5");

@@ -42,2 +42,21 @@ const ethers_1 = require("ethers");

};
exports.rsvToSignature = (r, s, v) => {
const vString = misc_1.remove0x(misc_1.numberToHexString(v, 1));
const sig = `${misc_1.add0x(r)}${misc_1.remove0x(s)}${vString}`;
if (sig.length !== 132) {
throw Error(`Invalid v [${vString}], r [${r}], s[${s}]. v [${vString.length}] should be 2 chars, r [${r.length}] should be 64 chars, and s [${s.length}] should be 64 chars.`);
}
return sig;
};
exports.signatureToRSV = (sig) => {
const unprefixed = misc_1.remove0x(sig);
if (unprefixed.length !== 130) {
throw Error(`Invalid signature. Must be 132 chars if prefixed with 0x and 130 otherwise. Got ${sig.length} chars. Signature: ${sig}`);
}
return {
r: unprefixed.substr(0, 64),
s: unprefixed.substr(64, 64),
v: parseInt(unprefixed.substr(128, 2), 16),
};
};
//# sourceMappingURL=crypto.js.map

13

build/src/app/scheduled-task.js

@@ -16,4 +16,6 @@ "use strict";

start() {
this.running = true;
this.run();
if (!this.running) {
this.running = true;
this.run();
}
}

@@ -25,4 +27,5 @@ stop() {

while (this.running) {
let rerunImmediately;
try {
await this.runTask();
rerunImmediately = await this.runTask();
}

@@ -34,2 +37,6 @@ catch (e) {

}
if (rerunImmediately) {
this.run();
return;
}
try {

@@ -36,0 +43,0 @@ await misc_1.sleep(this.periodMilliseconds);

@@ -6,2 +6,10 @@ "use strict";

class TestUtils {
static nullSafeEquals(first, second, msg) {
const firstExists = first !== undefined && first !== null;
const secondExists = second !== undefined && first !== null;
firstExists.should.equal(secondExists, msg || `undefined / not undefined mismatch!`);
if (firstExists) {
first.should.equal(second, msg || `values don't match!`);
}
}
static assertThrows(func, errorType) {

@@ -8,0 +16,0 @@ let succeeded = true;

@@ -7,3 +7,3 @@ "use strict";

beforeEach(() => {
counter = new app_1.TimeBucketedCounter(1000, 5);
counter = new app_1.TimeBucketedCounter(4000, 5);
});

@@ -25,7 +25,7 @@ it('accurately increments within time period, no sleeping', () => {

res.should.equal(counter.getTotal(), 'Incorrect total!');
await app_1.sleep(200);
await app_1.sleep(800);
res = counter.increment();
res.should.equal(2, 'Incorrect counter after increment 2');
res.should.equal(counter.getTotal(), 'Incorrect total!');
await app_1.sleep(400);
await app_1.sleep(1600);
res = counter.increment();

@@ -39,7 +39,7 @@ res.should.equal(3, 'Incorrect counter after increment 3');

res.should.equal(counter.getTotal(), 'Incorrect total!');
await app_1.sleep(200);
await app_1.sleep(800);
res = counter.increment();
res.should.equal(2, 'Incorrect counter after increment 2');
res.should.equal(counter.getTotal(), 'Incorrect total!');
await app_1.sleep(600);
await app_1.sleep(1600);
res = counter.increment();

@@ -53,6 +53,6 @@ res.should.equal(3, 'Incorrect counter after increment 3');

res.should.equal(counter.getTotal(), 'Incorrect total!');
await app_1.sleep(1000);
await app_1.sleep(4000);
res = counter.getTotal();
res.should.equal(0, 'Incorrect count!');
});
}).timeout(7500);
it('accurately cycles out old counts, multiple increments', async () => {

@@ -64,11 +64,11 @@ counter.increment();

res.should.equal(counter.getTotal(), 'Incorrect total!');
await app_1.sleep(200);
await app_1.sleep(800);
res = counter.increment();
res.should.equal(4, 'Incorrect counter after increment 2');
res.should.equal(counter.getTotal(), 'Incorrect total!');
await app_1.sleep(600);
await app_1.sleep(2400);
res = counter.increment();
res.should.equal(5, 'Incorrect counter after increment 3');
res.should.equal(counter.getTotal(), 'Incorrect total!');
await app_1.sleep(250);
await app_1.sleep(800);
counter

@@ -80,3 +80,3 @@ .getTotal()

res.should.equal(counter.getTotal(), 'Incorrect total!');
});
}).timeout(7500);
it('accurately cycles out old counts, over time', async () => {

@@ -87,6 +87,6 @@ for (let totalIncrements = 0; totalIncrements < 15; totalIncrements++) {

res.should.equal(expected, `Incorrect increment result! Total increments: ${totalIncrements}`);
await app_1.sleep(250);
await app_1.sleep(1000);
}
});
}).timeout(20000);
});
//# sourceMappingURL=time-bucketed-counter.spec.js.map
{
"name": "@eth-optimism/core-utils",
"version": "0.0.1-alpha.27",
"version": "0.0.1-alpha.28",
"description": "Optimism Core Utils",

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

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