Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
add yParity field
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmurdoch committed Aug 22, 2023
1 parent 7065916 commit 595c04e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
3 changes: 2 additions & 1 deletion packages/ethereum/ethereum/tests/database.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ describe("database", () => {
accessList: [],
v: "0x0",
r: "0x48507a6e4e1e7bdbcdb0a5021195d13d7c2a1b89f06555049bca5cc246b6f7d4",
s: "0x487a3f23364c97c469f8ee948a9de2bdc80a4502046625793f664bb7be4c0cd9"
s: "0x487a3f23364c97c469f8ee948a9de2bdc80a4502046625793f664bb7be4c0cd9",
yParity: "0x0"
}
],
uncles: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class EIP1559FeeMarketTransaction extends RuntimeTransaction {
public accessListJSON: AccessList;
public accessListDataFee: bigint;
public type: Quantity = Quantity.from("0x2");
public yParity: Quantity = Quantity.from("0x0");

public constructor(
data: EIP1559FeeMarketRawTransaction | EIP1559FeeMarketRpcTransaction,
Expand All @@ -54,7 +55,7 @@ export class EIP1559FeeMarketTransaction extends RuntimeTransaction {
this.accessList = accessListData.accessList;
this.accessListJSON = accessListData.AccessListJSON;
this.accessListDataFee = accessListData.dataFeeEIP2930;
this.v = Quantity.from(data[9]);
this.yParity = this.v = Quantity.from(data[9]);
this.r = Quantity.from(data[10]);
this.s = Quantity.from(data[11]);
this.raw = data;
Expand Down Expand Up @@ -93,6 +94,8 @@ export class EIP1559FeeMarketTransaction extends RuntimeTransaction {
this.accessListJSON = accessListData.AccessListJSON;
this.accessListDataFee = accessListData.dataFeeEIP2930;
this.validateAndSetSignature(data);

this.yParity = this.v;
}
}

Expand Down Expand Up @@ -120,7 +123,8 @@ export class EIP1559FeeMarketTransaction extends RuntimeTransaction {
accessList: this.accessListJSON,
v: this.v,
r: this.r,
s: this.s
s: this.s,
yParity: this.yParity
};
}

Expand Down Expand Up @@ -193,7 +197,7 @@ export class EIP1559FeeMarketTransaction extends RuntimeTransaction {

const msgHash = keccak(digestWithPrefix(2, [data.output], dataLength));
const sig = ecsign(msgHash, privateKey);
this.v = Quantity.from(sig.v);
this.yParity = this.v = Quantity.from(sig.v);
this.r = Quantity.from(sig.r);
this.s = Quantity.from(sig.s);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class EIP2930AccessListTransaction extends RuntimeTransaction {
public accessListDataFee: bigint;
public gasPrice: Quantity;
public type: Quantity = Quantity.from("0x1");
public yParity: Quantity = Quantity.from("0x0");

public constructor(
data: EIP2930AccessListRawTransaction | EIP2930AccessListRpcTransaction,
Expand All @@ -50,7 +51,7 @@ export class EIP2930AccessListTransaction extends RuntimeTransaction {
this.accessList = accessListData.accessList;
this.accessListJSON = accessListData.AccessListJSON;
this.accessListDataFee = accessListData.dataFeeEIP2930;
this.v = Quantity.from(data[8]);
this.yParity = this.v = Quantity.from(data[8]);
this.r = Quantity.from(data[9]);
this.s = Quantity.from(data[10]);
this.raw = data;
Expand Down Expand Up @@ -94,6 +95,7 @@ export class EIP2930AccessListTransaction extends RuntimeTransaction {
this.accessListJSON = accessListData.AccessListJSON;
this.accessListDataFee = accessListData.dataFeeEIP2930;
this.validateAndSetSignature(data);
this.yParity = this.v;
}
}

Expand All @@ -119,7 +121,8 @@ export class EIP2930AccessListTransaction extends RuntimeTransaction {
accessList: this.accessListJSON,
v: this.v,
r: this.r,
s: this.s
s: this.s,
yParity: this.v
};
}
public static fromTxData(
Expand Down Expand Up @@ -179,7 +182,7 @@ export class EIP2930AccessListTransaction extends RuntimeTransaction {

const msgHash = keccak(digestWithPrefix(1, [data.output], dataLength));
const sig = ecsign(msgHash, privateKey);
this.v = Quantity.from(sig.v);
this.yParity = this.v = Quantity.from(sig.v);
this.r = Quantity.from(sig.r);
this.s = Quantity.from(sig.s);

Expand Down
2 changes: 2 additions & 0 deletions packages/ethereum/transaction/src/transaction-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export type EIP2930AccessListTransactionJSON = {
v: Quantity;
r: Quantity;
s: Quantity;
yParity: Quantity;
};

export type EIP1559FeeMarketTransactionJSON = {
Expand All @@ -74,4 +75,5 @@ export type EIP1559FeeMarketTransactionJSON = {
v: Quantity;
r: Quantity;
s: Quantity;
yParity: Quantity;
};
1 change: 0 additions & 1 deletion packages/ethereum/transaction/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
LegacyRawTransaction,
LegacyTransaction,
TransactionFactory,
TransactionType,
TypedDatabaseTransaction,
Transaction,
encodeWithPrefix,
Expand Down

0 comments on commit 595c04e

Please sign in to comment.