Skip to content

Commit 57d134d

Browse files
authored
chore: cherry pick 2523 (#2524)
fix: updated CONTRACT_REVERT error code to the value `3` (#2523) Signed-off-by: Logan Nguyen <[email protected]>
1 parent fde43c6 commit 57d134d

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

packages/relay/src/lib/errors/JsonRpcError.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class JsonRpcError {
3737
export const predefined = {
3838
CONTRACT_REVERT: (errorMessage?: string, data: string = '') =>
3939
new JsonRpcError({
40-
code: -32008,
40+
code: 3,
4141
message: `execution reverted: ${decodeErrorMessage(errorMessage)}`,
4242
data: data,
4343
}),

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ describe('@ethCall Eth Call spec', async function () {
414414
const result = await ethImpl.call(ETH_CALL_REQ_ARGS, 'latest');
415415

416416
expect(result).to.exist;
417-
expect((result as JsonRpcError).code).to.equal(-32008);
417+
expect((result as JsonRpcError).code).to.equal(3);
418418
expect((result as JsonRpcError).name).to.equal(undefined);
419419
expect((result as JsonRpcError).message).to.equal(`execution reverted: ${defaultErrorMessageText}`);
420420
expect((result as JsonRpcError).data).to.equal(defaultErrorMessageHex);
@@ -620,7 +620,7 @@ describe('@ethCall Eth Call spec', async function () {
620620
.reply(400, mockData.contractReverted);
621621
const result = await ethImpl.call(callData, 'latest');
622622
expect(result).to.be.not.null;
623-
expect((result as JsonRpcError).code).to.eq(-32008);
623+
expect((result as JsonRpcError).code).to.eq(3);
624624
expect((result as JsonRpcError).name).to.eq(undefined);
625625
expect((result as JsonRpcError).message).to.contain(mockData.contractReverted._status.messages[0].message);
626626
});
@@ -675,7 +675,7 @@ describe('@ethCall Eth Call spec', async function () {
675675
const result = await ethImpl.call(callData, 'latest');
676676
sinon.assert.notCalled(sdkClientStub.submitContractCallQueryWithRetry);
677677
expect(result).to.not.be.null;
678-
expect((result as JsonRpcError).code).to.eq(-32008);
678+
expect((result as JsonRpcError).code).to.eq(3);
679679
expect((result as JsonRpcError).name).to.eq(undefined);
680680
expect((result as JsonRpcError).message).to.contain(mockData.contractReverted._status.messages[0].message);
681681
});
@@ -706,7 +706,7 @@ describe('@ethCall Eth Call spec', async function () {
706706
const result = await ethImpl.call(callData, 'latest');
707707

708708
expect(result).to.exist;
709-
expect((result as JsonRpcError).code).to.eq(-32008);
709+
expect((result as JsonRpcError).code).to.eq(3);
710710
expect((result as JsonRpcError).name).to.eq(undefined);
711711
expect((result as JsonRpcError).message).to.equal(`execution reverted: ${defaultErrorMessageText}`);
712712
expect((result as JsonRpcError).data).to.equal(defaultErrorMessageHex);

packages/server/src/koaJsonRpc/lib/HttpStatusCodeAndMessage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ const CONTRACT_REVERT = 'CONTRACT REVERT';
1717
const METHOD_NOT_FOUND = 'METHOD NOT FOUND';
1818

1919
export const RpcErrorCodeToStatusMap = {
20+
'3': new HttpStatusCodeAndMessage(200, CONTRACT_REVERT),
2021
'-32603': new HttpStatusCodeAndMessage(500, INTERNAL_ERROR),
21-
'-32008': new HttpStatusCodeAndMessage(200, CONTRACT_REVERT),
2222
'-32600': new HttpStatusCodeAndMessage(400, INVALID_REQUEST),
2323
'-32602': new HttpStatusCodeAndMessage(400, INVALID_PARAMS_ERROR),
2424
'-32601': new HttpStatusCodeAndMessage(400, METHOD_NOT_FOUND),

packages/server/tests/acceptance/rpc_batch3.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ describe('@api-batch-3 RPC Server Acceptance Tests', function () {
608608
expect(response.status).to.be.equal(200);
609609
expect(response.data).to.exist;
610610
expect(response.data.error).to.exist;
611-
expect(response.data.error.code).to.be.equal(-32008);
611+
expect(response.data.error.code).to.be.equal(3);
612612
expect(response.data.error.message).to.contain('execution reverted: CONTRACT_REVERT_EXECUTED');
613613
expect(response.data.error.name).to.undefined;
614614
});

0 commit comments

Comments
 (0)