@hiero-ledger/sdk
Version:
3 lines (2 loc) • 1.14 kB
JavaScript
import*as t from"@ethersproject/rlp";import{decode as s,encode as i}from"./encoding/hex.js";import e from"./EthereumTransactionData.js";import r from"./Cache.js";class a extends e{constructor(t){super(t),this.nonce=t.nonce,this.gasPrice=t.gasPrice,this.gasLimit=t.gasLimit,this.to=t.to,this.value=t.value,this.v=t.v,this.r=t.r,this.s=t.s}static fromBytes(i){if(0===i.length)throw new Error("empty bytes");const e=t.decode(i);if(9!=e.length)throw new Error("invalid ethereum transaction data");return new a({nonce:s(e[0]),gasPrice:s(e[1]),gasLimit:s(e[2]),to:s(e[3]),value:s(e[4]),callData:s(e[5]),v:s(e[6]),r:s(e[7]),s:s(e[8])})}toBytes(){return s(t.encode([this.nonce,this.gasPrice,this.gasLimit,this.to,this.value,this.callData,this.v,this.r,this.s]))}toString(){return JSON.stringify(this.toJSON(),null,2)}toJSON(){return{nonce:i(this.nonce),gasPrice:i(this.gasPrice),gasLimit:i(this.gasLimit),to:i(this.to),value:i(this.value),callData:i(this.callData),v:i(this.v),r:i(this.r),s:i(this.s)}}}r.setEthereumTransactionDataLegacyFromBytes(t=>a.fromBytes(t));export{a as default};
//# sourceMappingURL=EthereumTransactionDataLegacy.js.map