@eth-optimism/core-utils
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -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', () => { |
{ | ||
"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", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
51867
1273
+ Addedaxios@0.21.4(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
- Removedaxios@0.19.2(transitive)
- Removedfollow-redirects@1.5.10(transitive)
Updatedaxios@^0.21.1