Skip to content

Commit c139046

Browse files
Fix eth_getТransactionByHash does not return accesslist and yparity for 1559 and 2930 transactions (#1696)
* replaces v to yParit for 1559 and 2930 Signed-off-by: Konstantina Blazhukova <[email protected]> * Fixes tests Signed-off-by: Konstantina Blazhukova <[email protected]> * Fixes tests Signed-off-by: Konstantina Blazhukova <[email protected]> --------- Signed-off-by: Konstantina Blazhukova <[email protected]>
1 parent e1d2e60 commit c139046

File tree

7 files changed

+44
-17
lines changed

7 files changed

+44
-17
lines changed

docs/openrpc.json

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,8 +1159,7 @@
11591159
},
11601160
"accessList": {
11611161
"title": "accessList",
1162-
"description": "not supported",
1163-
"$ref": "#/components/schemas/null"
1162+
"type" : "array"
11641163
},
11651164
"chainId": {
11661165
"title": "chainId",
@@ -1235,7 +1234,15 @@
12351234
"yParity": {
12361235
"title": "yParity",
12371236
"description": "The parity (0 for even, 1 for odd) of the y-value of the secp256k1 signature.",
1238-
"$ref": "#/components/schemas/uint"
1237+
"oneOf": [
1238+
{
1239+
"$ref": "#/components/schemas/byte"
1240+
},
1241+
{
1242+
"$ref": "#/components/schemas/null"
1243+
}
1244+
]
1245+
12391246
},
12401247
"r": {
12411248
"title": "r",
@@ -1276,7 +1283,16 @@
12761283
"properties": {
12771284
"v": {
12781285
"title": "v",
1279-
"$ref": "#/components/schemas/uint"
1286+
"oneOf": [
1287+
{
1288+
"$ref": "#/components/schemas/uint"
1289+
},
1290+
{
1291+
"$ref": "#/components/schemas/null"
1292+
}
1293+
]
1294+
1295+
12801296
},
12811297
"r": {
12821298
"title": "r",

packages/relay/src/formatters.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ const formatContractResult = (cr: any) => {
152152
to: cr.to?.substring(0, 42),
153153
transactionIndex: nullableNumberTo0x(cr.transaction_index),
154154
type: nullableNumberTo0x(cr.type),
155-
v: nanOrNumberTo0x(cr.v),
155+
v: cr.type === null ? null : nanOrNumberTo0x(cr.v),
156156
value: nanOrNumberTo0x(cr.amount),
157157
};
158158

@@ -164,6 +164,7 @@ const formatContractResult = (cr: any) => {
164164
}); // eip 2930 fields
165165
case 2: return new Transaction1559({
166166
...commonFields,
167+
accessList: [],
167168
maxPriorityFeePerGas: toNullIfEmptyHex(cr.max_priority_fee_per_gas),
168169
maxFeePerGas: toNullIfEmptyHex(cr.max_fee_per_gas)
169170
}); // eip 1559 fields

packages/relay/src/lib/model.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export class Transaction {
134134
public readonly to!: string | null;
135135
public readonly transactionIndex!: string | null;
136136
public readonly type!: string;
137-
public readonly v!: string;
137+
public readonly v: string | null;
138138
public readonly value!: string;
139139

140140
constructor(args: any) {
@@ -159,9 +159,12 @@ export class Transaction {
159159

160160
export class Transaction2930 extends Transaction {
161161
public readonly accessList!: AccessListEntry[] | null | [];
162+
public readonly yParity! : string | null;
162163

163164
constructor(args: any) {
164-
super(args);
165+
const {v, ...parentArgs} = args;
166+
super(parentArgs);
167+
this.yParity = v;
165168
this.accessList = args.accessList;
166169
}
167170
}

packages/relay/tests/assertions.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export default class RelayAssertions {
5555
expect(tx).to.exist;
5656
if (tx == null) return;
5757

58-
expect(tx.accessList).to.eq(expectedTx.accessList);
58+
expect(tx.accessList).to.deep.eq(expectedTx.accessList);
5959
expect(tx.blockHash).to.eq(expectedTx.blockHash);
6060
expect(tx.blockNumber).to.eq(expectedTx.blockNumber);
6161
expect(tx.chainId).to.eq(expectedTx.chainId);
@@ -72,7 +72,11 @@ export default class RelayAssertions {
7272
expect(tx.to).to.eq(expectedTx.to);
7373
expect(tx.transactionIndex).to.eq(expectedTx.transactionIndex);
7474
expect(tx.type).to.eq(numberTo0x(expectedTx.type));
75-
expect(tx.v).to.eq(numberTo0x(expectedTx.v));
75+
if(tx.type === "0x1" || tx.type === "0x2") {
76+
expect(tx.yParity).to.eq(numberTo0x(expectedTx.v));
77+
} else {
78+
expect(tx.v).to.eq(numberTo0x(expectedTx.v));
79+
}
7680
expect(tx.value).to.eq(expectedTx.value);
7781
};
7882

packages/relay/tests/helpers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -671,12 +671,12 @@ export const defaultDetailedContractResultByHash = {
671671
"value_written": "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925"
672672
}],
673673
"status": "0x1",
674-
"access_list": "0x",
674+
"access_list": [],
675675
"block_gas_used": 50000000,
676676
"chain_id": "0x12a",
677677
"gas_price": "0x4a817c80",
678-
"max_fee_per_gas": "0x",
679-
"max_priority_fee_per_gas": "0x",
678+
"max_fee_per_gas": "0x55",
679+
"max_priority_fee_per_gas": "0x43",
680680
"r": "0xd693b532a80fed6392b428604171fb32fdbf953728a3a7ecc7d4062b1652c042",
681681
"s": "0x24e9c602ac800b983b035700a14b23f78a253ab762deab5dc27e3555a750b354",
682682
"type": 2,

packages/relay/tests/lib/eth.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4618,7 +4618,7 @@ describe('Eth', async function () {
46184618
const contractEvmAddress = '0xd8db0b1dbf8ba6721ef5256ad5fe07d72d1d04b9';
46194619
const defaultTxHash = '0x4a563af33c4871b51a8b108aa2fe1dd5280a30dfb7236170ae5e5e7957eb6392';
46204620
const defaultTransaction = {
4621-
"accessList": undefined,
4621+
"accessList": [],
46224622
"blockHash": "0xd693b532a80fed6392b428604171fb32fdbf953728a3a7ecc7d4062b1652c042",
46234623
"blockNumber": "0x11",
46244624
"chainId": "0x12a",
@@ -5171,7 +5171,8 @@ describe('Eth', async function () {
51715171
it('handles transactions with v as null', async function () {
51725172
const detailedResultsWithNullNullableValues = {
51735173
...defaultDetailedContractResultByHash,
5174-
v: null
5174+
v: null,
5175+
type: 0
51755176
};
51765177
const uniqueTxHash = '0xb4cad7b827375d12d73af57b6a3e84353645fd31305ea58ff52dda53ec640533';
51775178

packages/relay/tests/lib/formatters.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ describe('Formatters', () => {
200200

201201
it('should return a valid match', () => {
202202
const formattedResult: any = formatContractResult(contractResult);
203-
expect(formattedResult.accessList).to.equal(undefined);
203+
expect(formattedResult.accessList).to.deep.eq([]);
204204
expect(formattedResult.blockHash).to.equal('0xb0f10139fa0bf9e66402c8c0e5ed364e07cf83b3726c8045fabf86a07f488713');
205205
expect(formattedResult.blockNumber).to.equal('0x210');
206206
expect(formattedResult.chainId).to.equal('0x12a');
@@ -217,7 +217,8 @@ describe('Formatters', () => {
217217
expect(formattedResult.to).to.equal('0x0000000000000000000000000000000000000409');
218218
expect(formattedResult.transactionIndex).to.equal('0x9');
219219
expect(formattedResult.type).to.equal('0x2');
220-
expect(formattedResult.v).to.equal('0x1');
220+
expect(formattedResult.yParity).to.equal('0x1');
221+
expect(formattedResult.v).to.equal(undefined);
221222
expect(formattedResult.value).to.equal('0x0');
222223
});
223224

@@ -251,7 +252,8 @@ describe('Formatters', () => {
251252
expect(formattedResult.s).to.equal(null);
252253
expect(formattedResult.to).to.equal('0x0000000000000000000000000000000000000409');
253254
expect(formattedResult.transactionIndex).to.equal(null);
254-
expect(formattedResult.v).to.equal('0x0');
255+
expect(formattedResult.v).to.equal(undefined);
256+
expect(formattedResult.yParity).to.equal('0x0');
255257
expect(formattedResult.value).to.equal('0x0');
256258
});
257259
});

0 commit comments

Comments
 (0)