diff --git a/docs/openrpc.json b/docs/openrpc.json index 19a7d44c42..7d5fb085e7 100644 --- a/docs/openrpc.json +++ b/docs/openrpc.json @@ -1159,8 +1159,7 @@ }, "accessList": { "title": "accessList", - "description": "not supported", - "$ref": "#/components/schemas/null" + "type" : "array" }, "chainId": { "title": "chainId", @@ -1235,7 +1234,15 @@ "yParity": { "title": "yParity", "description": "The parity (0 for even, 1 for odd) of the y-value of the secp256k1 signature.", - "$ref": "#/components/schemas/uint" + "oneOf": [ + { + "$ref": "#/components/schemas/byte" + }, + { + "$ref": "#/components/schemas/null" + } + ] + }, "r": { "title": "r", @@ -1276,7 +1283,16 @@ "properties": { "v": { "title": "v", - "$ref": "#/components/schemas/uint" + "oneOf": [ + { + "$ref": "#/components/schemas/uint" + }, + { + "$ref": "#/components/schemas/null" + } + ] + + }, "r": { "title": "r", diff --git a/packages/relay/src/formatters.ts b/packages/relay/src/formatters.ts index 0f4e2ee74d..faba1b4095 100644 --- a/packages/relay/src/formatters.ts +++ b/packages/relay/src/formatters.ts @@ -152,7 +152,7 @@ const formatContractResult = (cr: any) => { to: cr.to?.substring(0, 42), transactionIndex: nullableNumberTo0x(cr.transaction_index), type: nullableNumberTo0x(cr.type), - v: nanOrNumberTo0x(cr.v), + v: cr.type === null ? null : nanOrNumberTo0x(cr.v), value: nanOrNumberTo0x(cr.amount), }; @@ -164,6 +164,7 @@ const formatContractResult = (cr: any) => { }); // eip 2930 fields case 2: return new Transaction1559({ ...commonFields, + accessList: [], maxPriorityFeePerGas: toNullIfEmptyHex(cr.max_priority_fee_per_gas), maxFeePerGas: toNullIfEmptyHex(cr.max_fee_per_gas) }); // eip 1559 fields diff --git a/packages/relay/src/lib/model.ts b/packages/relay/src/lib/model.ts index 23739b3a4c..0b4f23b827 100644 --- a/packages/relay/src/lib/model.ts +++ b/packages/relay/src/lib/model.ts @@ -134,7 +134,7 @@ export class Transaction { public readonly to!: string | null; public readonly transactionIndex!: string | null; public readonly type!: string; - public readonly v!: string; + public readonly v: string | null; public readonly value!: string; constructor(args: any) { @@ -159,9 +159,12 @@ export class Transaction { export class Transaction2930 extends Transaction { public readonly accessList!: AccessListEntry[] | null | []; + public readonly yParity! : string | null; constructor(args: any) { - super(args); + const {v, ...parentArgs} = args; + super(parentArgs); + this.yParity = v; this.accessList = args.accessList; } } diff --git a/packages/relay/tests/assertions.ts b/packages/relay/tests/assertions.ts index 66138af3dc..c4ac4b1ab3 100644 --- a/packages/relay/tests/assertions.ts +++ b/packages/relay/tests/assertions.ts @@ -55,7 +55,7 @@ export default class RelayAssertions { expect(tx).to.exist; if (tx == null) return; - expect(tx.accessList).to.eq(expectedTx.accessList); + expect(tx.accessList).to.deep.eq(expectedTx.accessList); expect(tx.blockHash).to.eq(expectedTx.blockHash); expect(tx.blockNumber).to.eq(expectedTx.blockNumber); expect(tx.chainId).to.eq(expectedTx.chainId); @@ -72,7 +72,11 @@ export default class RelayAssertions { expect(tx.to).to.eq(expectedTx.to); expect(tx.transactionIndex).to.eq(expectedTx.transactionIndex); expect(tx.type).to.eq(numberTo0x(expectedTx.type)); - expect(tx.v).to.eq(numberTo0x(expectedTx.v)); + if(tx.type === "0x1" || tx.type === "0x2") { + expect(tx.yParity).to.eq(numberTo0x(expectedTx.v)); + } else { + expect(tx.v).to.eq(numberTo0x(expectedTx.v)); + } expect(tx.value).to.eq(expectedTx.value); }; diff --git a/packages/relay/tests/helpers.ts b/packages/relay/tests/helpers.ts index 155ee114c9..622f7e488d 100644 --- a/packages/relay/tests/helpers.ts +++ b/packages/relay/tests/helpers.ts @@ -671,12 +671,12 @@ export const defaultDetailedContractResultByHash = { "value_written": "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925" }], "status": "0x1", - "access_list": "0x", + "access_list": [], "block_gas_used": 50000000, "chain_id": "0x12a", "gas_price": "0x4a817c80", - "max_fee_per_gas": "0x", - "max_priority_fee_per_gas": "0x", + "max_fee_per_gas": "0x55", + "max_priority_fee_per_gas": "0x43", "r": "0xd693b532a80fed6392b428604171fb32fdbf953728a3a7ecc7d4062b1652c042", "s": "0x24e9c602ac800b983b035700a14b23f78a253ab762deab5dc27e3555a750b354", "type": 2, diff --git a/packages/relay/tests/lib/eth.spec.ts b/packages/relay/tests/lib/eth.spec.ts index cfc541ba1c..946514c2fa 100644 --- a/packages/relay/tests/lib/eth.spec.ts +++ b/packages/relay/tests/lib/eth.spec.ts @@ -4618,7 +4618,7 @@ describe('Eth', async function () { const contractEvmAddress = '0xd8db0b1dbf8ba6721ef5256ad5fe07d72d1d04b9'; const defaultTxHash = '0x4a563af33c4871b51a8b108aa2fe1dd5280a30dfb7236170ae5e5e7957eb6392'; const defaultTransaction = { - "accessList": undefined, + "accessList": [], "blockHash": "0xd693b532a80fed6392b428604171fb32fdbf953728a3a7ecc7d4062b1652c042", "blockNumber": "0x11", "chainId": "0x12a", @@ -5171,7 +5171,8 @@ describe('Eth', async function () { it('handles transactions with v as null', async function () { const detailedResultsWithNullNullableValues = { ...defaultDetailedContractResultByHash, - v: null + v: null, + type: 0 }; const uniqueTxHash = '0xb4cad7b827375d12d73af57b6a3e84353645fd31305ea58ff52dda53ec640533'; diff --git a/packages/relay/tests/lib/formatters.spec.ts b/packages/relay/tests/lib/formatters.spec.ts index f6d94656c1..c40c67622f 100644 --- a/packages/relay/tests/lib/formatters.spec.ts +++ b/packages/relay/tests/lib/formatters.spec.ts @@ -200,7 +200,7 @@ describe('Formatters', () => { it('should return a valid match', () => { const formattedResult: any = formatContractResult(contractResult); - expect(formattedResult.accessList).to.equal(undefined); + expect(formattedResult.accessList).to.deep.eq([]); expect(formattedResult.blockHash).to.equal('0xb0f10139fa0bf9e66402c8c0e5ed364e07cf83b3726c8045fabf86a07f488713'); expect(formattedResult.blockNumber).to.equal('0x210'); expect(formattedResult.chainId).to.equal('0x12a'); @@ -217,7 +217,8 @@ describe('Formatters', () => { expect(formattedResult.to).to.equal('0x0000000000000000000000000000000000000409'); expect(formattedResult.transactionIndex).to.equal('0x9'); expect(formattedResult.type).to.equal('0x2'); - expect(formattedResult.v).to.equal('0x1'); + expect(formattedResult.yParity).to.equal('0x1'); + expect(formattedResult.v).to.equal(undefined); expect(formattedResult.value).to.equal('0x0'); }); @@ -251,7 +252,8 @@ describe('Formatters', () => { expect(formattedResult.s).to.equal(null); expect(formattedResult.to).to.equal('0x0000000000000000000000000000000000000409'); expect(formattedResult.transactionIndex).to.equal(null); - expect(formattedResult.v).to.equal('0x0'); + expect(formattedResult.v).to.equal(undefined); + expect(formattedResult.yParity).to.equal('0x0'); expect(formattedResult.value).to.equal('0x0'); }); });