Skip to content

Commit

Permalink
Merge 8bf231c into 7725f13
Browse files Browse the repository at this point in the history
  • Loading branch information
konstantinabl authored Aug 29, 2023
2 parents 7725f13 + 8bf231c commit a870f68
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 11 deletions.
24 changes: 20 additions & 4 deletions docs/openrpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -1159,8 +1159,7 @@
},
"accessList": {
"title": "accessList",
"description": "not supported",
"$ref": "#/components/schemas/null"
"type" : "array"
},
"chainId": {
"title": "chainId",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -1276,7 +1283,16 @@
"properties": {
"v": {
"title": "v",
"$ref": "#/components/schemas/uint"
"oneOf": [
{
"$ref": "#/components/schemas/uint"
},
{
"$ref": "#/components/schemas/null"
}
]


},
"r": {
"title": "r",
Expand Down
3 changes: 2 additions & 1 deletion packages/relay/src/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};

Expand All @@ -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
Expand Down
7 changes: 5 additions & 2 deletions packages/relay/src/lib/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}
}
Expand Down
6 changes: 5 additions & 1 deletion packages/relay/tests/assertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down
3 changes: 2 additions & 1 deletion packages/relay/tests/lib/eth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
6 changes: 4 additions & 2 deletions packages/relay/tests/lib/formatters.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

Expand Down Expand Up @@ -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');
});
});
Expand Down

0 comments on commit a870f68

Please sign in to comment.