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
6
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.1.0 to 0.1.1

32

build/src/coders/ecdsa-coder.js

@@ -9,3 +9,2 @@ "use strict";

TxType[TxType["EthSign"] = 1] = "EthSign";
TxType[TxType["createEOA"] = 2] = "createEOA";
TxType[TxType["none"] = 3] = "none";

@@ -16,7 +15,5 @@ })(TxType = exports.TxType || (exports.TxType = {}));

1: TxType.EthSign,
2: TxType.createEOA,
3: TxType.none,
EIP155: TxType.EIP155,
EthSign: TxType.EthSign,
CreateEOA: TxType.createEOA,
None: TxType.none,

@@ -78,3 +75,3 @@ };

const pos = exports.DEFAULT_ECDSA_TX_FIELD_POSITIONS;
if (parseInt(sliceBytes(pos.txType), 16) !== TxType.EIP155) {
if (parseInt(sliceBytes(pos.txType), 16) !== this.txType) {
throw new Error('Invalid tx type');

@@ -118,30 +115,3 @@ }

}
class CreateEOATxDataCoder {
encode(txData) {
const txType = utils_1.encodeHex(TxType.createEOA, utils_1.getLen(exports.CREATE_EOA_FIELD_POSITIONS.txType));
const v = utils_1.encodeHex(txData.sig.v, utils_1.getLen(exports.CREATE_EOA_FIELD_POSITIONS.sig.v));
const r = utils_1.toVerifiedBytes(txData.sig.r, utils_1.getLen(exports.CREATE_EOA_FIELD_POSITIONS.sig.r));
const s = utils_1.toVerifiedBytes(txData.sig.s, utils_1.getLen(exports.CREATE_EOA_FIELD_POSITIONS.sig.s));
const messageHash = txData.messageHash;
return '0x' + txType + r + s + v + messageHash;
}
decode(txData) {
txData = utils_1.remove0x(txData);
const sliceBytes = (position) => txData.slice(position.start * 2, position.end * 2);
const pos = exports.CREATE_EOA_FIELD_POSITIONS;
if (parseInt(sliceBytes(pos.txType), 16) !== TxType.createEOA) {
throw new Error('Invalid tx type');
}
return {
sig: {
r: sliceBytes(pos.sig.r),
s: sliceBytes(pos.sig.s),
v: sliceBytes(pos.sig.v),
},
messageHash: sliceBytes(pos.messageHash),
};
}
}
exports.ctcCoder = {
createEOATxData: new CreateEOATxDataCoder(),
eip155TxData: new Eip155TxCoder(),

@@ -148,0 +118,0 @@ ethSignTxData: new EthSignTxCoder(),

@@ -26,17 +26,2 @@ "use strict";

});
describe('createEOATxData', () => {
it('should encode & then decode to the correct value', () => {
const createEOATxData = {
sig: {
v: '01',
r: '11'.repeat(32),
s: '22'.repeat(32),
},
messageHash: '89'.repeat(32),
};
const encoded = src_1.ctcCoder.createEOATxData.encode(createEOATxData);
const decoded = src_1.ctcCoder.createEOATxData.decode(encoded);
chai_1.expect(createEOATxData).to.deep.equal(decoded);
});
});
describe('appendSequencerBatch', () => {

@@ -43,0 +28,0 @@ it('should work with the simple case', () => {

4

package.json
{
"name": "@eth-optimism/core-utils",
"version": "0.1.0",
"version": "0.1.1",
"description": "Optimism Core Utils",

@@ -34,3 +34,3 @@ "main": "build/index.js",

"@ethersproject/abstract-provider": "^5.0.9",
"axios": "^0.19.0",
"axios": "^0.21.1",
"body-parser": "^1.19.0",

@@ -37,0 +37,0 @@ "debug": "^4.1.1",

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