Skip to content

Commit d10b0b2

Browse files
Bump 0.15.0-rc1 (#798)
* Bump 0.15.0-rc1 Signed-off-by: lukelee-sl <[email protected]> * 651 add eth methods validations (#663) * Sort errors alphabetically Signed-off-by: Maksim Dimitrov <[email protected]> * Add required params validations Signed-off-by: Maksim Dimitrov <[email protected]> * Add required params tests Signed-off-by: Maksim Dimitrov <[email protected]> * Remove unsused package Signed-off-by: Maksim Dimitrov <[email protected]> * Fix condition Signed-off-by: Maksim Dimitrov <[email protected]> * Validate param types Signed-off-by: Maksim Dimitrov <[email protected]> * Move validation logic to separate class Signed-off-by: Maksim Dimitrov <[email protected]> * Add more validation logic Signed-off-by: Maksim Dimitrov <[email protected]> * Update validations and add server tests Signed-off-by: Maksim Dimitrov <[email protected]> * Fix codesmell Signed-off-by: Maksim Dimitrov <[email protected]> * Rename folder Signed-off-by: Maksim Dimitrov <[email protected]> * Fix array type validation and postman tests Signed-off-by: Maksim Dimitrov <[email protected]> * Some fixes and add tests Signed-off-by: Maksim Dimitrov <[email protected]> * Update test command Signed-off-by: Maksim Dimitrov <[email protected]> * Limit block number regex Signed-off-by: Maksim Dimitrov <[email protected]> * Update gitignore Signed-off-by: Maksim Dimitrov <[email protected]> * Test if coverage will trigger Signed-off-by: Maksim Dimitrov <[email protected]> * Add more tests Signed-off-by: Maksim Dimitrov <[email protected]> * Add tests and fixes Signed-off-by: Maksim Dimitrov <[email protected]> * Try to fix code smells Signed-off-by: Maksim Dimitrov <[email protected]> * Fix code smell Signed-off-by: Maksim Dimitrov <[email protected]> * Try fix complexity Signed-off-by: Maksim Dimitrov <[email protected]> * Add all remaining tests Signed-off-by: Maksim Dimitrov <[email protected]> * Remove obsolete logic. Update tests Signed-off-by: Maksim Dimitrov <[email protected]> * Refactor. Update tests Signed-off-by: Maksim Dimitrov <[email protected]> * Fix getLogs order to asc. Fix tests. Fix acceptance api tests Signed-off-by: Maksim Dimitrov <[email protected]> * Remove merge connflict marker Signed-off-by: Maksim Dimitrov <[email protected]> * Use evm address instead of contract id in getStorageAt test. Skip test until mirror node PR is merged and released Signed-off-by: Maksim Dimitrov <[email protected]> * Make the to param not required Signed-off-by: Maksim Dimitrov <[email protected]> * Return error for unexpected named parameters Signed-off-by: Maksim Dimitrov <[email protected]> * Remove imorts added by the IDE Signed-off-by: Maksim Dimitrov <[email protected]> * Add missing params Signed-off-by: Maksim Dimitrov <[email protected]> * Allow topic to be null Signed-off-by: Maksim Dimitrov <[email protected]> * Add more tests and remove throwing an error Signed-off-by: Maksim Dimitrov <[email protected]> * Fix conflicts, missing validations, tests Signed-off-by: Maksim Dimitrov <[email protected]> * Use single quote Signed-off-by: Maksim Dimitrov <[email protected]> * Remove import added by the IDE Signed-off-by: Maksim Dimitrov <[email protected]> * Rollback getStorageAt changes Signed-off-by: Maksim Dimitrov <[email protected]> * Remove getStorageAt test Signed-off-by: Maksim Dimitrov <[email protected]> * Make block param optional for eth_getStorageAt Signed-off-by: Maksim Dimitrov <[email protected]> * Refactor. Move validation in logAndHandleResponse Signed-off-by: Maksim Dimitrov <[email protected]> * Try to reduce complexity Signed-off-by: Maksim Dimitrov <[email protected]> * Refactor Signed-off-by: Maksim Dimitrov <[email protected]> * Fix slot param in test Signed-off-by: Maksim Dimitrov <[email protected]> * Fix slot param in another test Signed-off-by: Maksim Dimitrov <[email protected]> * Update tests Signed-off-by: Maksim Dimitrov <[email protected]> * Remove only() from test Signed-off-by: Maksim Dimitrov <[email protected]> Signed-off-by: Maksim Dimitrov <[email protected]> Signed-off-by: lukelee-sl <[email protected]> Signed-off-by: Maksim Dimitrov <[email protected]> Co-authored-by: Maksim Dimitrov <[email protected]>
1 parent ca850cd commit d10b0b2

File tree

29 files changed

+2623
-332
lines changed

29 files changed

+2623
-332
lines changed

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,5 @@ tsconfig.tsbuildinfo
66
.idea
77
.vscode/
88
.devcontainer/
9-
packages/relay/coverage/**
10-
packages/server/coverage/**
11-
packages/relay/.nyc_output/**
12-
packages/server/.nyc_output/**
9+
**/**/coverage/
10+
**/**/.nyc_output/

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515

1616
Implementation of an Ethereum JSON RPC APIs for Hedera Hashgraph. Utilises both Hedera Consensus Nodes and Mirror nodes
1717
to support RPC queries as defined in
18-
the [JSON RPC Specification](https://playground.open-rpc.org/?schemaUrl=https://raw.githubusercontent.com/hashgraph/hedera-json-rpc-relay/main/docs/openrpc.json&uiSchema%5BappBar%5D%5Bui:splitView%5D=false&uiSchema%5BappBar%5D%5Bui:input%5D=false&uiSchema%5BappBar%5D%5Bui:examplesDropdown%5D=false)
19-
18+
the [JSON RPC Specification](https://playground.open-rpc.org/?schemaUrl=https://raw.githubusercontent.com/hashgraph/hedera-json-rpc-relay/release/0.15/docs/openrpc.json&uiSchema%5BappBar%5D%5Bui:splitView%5D=false&uiSchema%5BappBar%5D%5Bui:input%5D=false&uiSchema%5BappBar%5D%5Bui:examplesDropdown%5D=false)
2019
## Building
2120

2221
### Pre-requirements

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: "3.7"
22
services:
33
relay:
44
container_name: hedera-jspn-rpc-relay
5-
image: "ghcr.io/hashgraph/hedera-json-rpc-relay:main"
5+
image: "ghcr.io/hashgraph/hedera-json-rpc-relay:0.15.0-rc1"
66
restart: "unless-stopped"
77
ports:
88
- 7546:7546

docs/openrpc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"info": {
44
"title": "Hedera JSON-RPC Specification",
55
"description": "A specification of the implemented Ethereum JSON RPC APIs interface for Hedera clients and adheres to the Ethereum execution APIs schema.",
6-
"version": "0.15.0-SNAPSHOT"
6+
"version": "0.15.0-rc1"
77
},
88
"methods": [
99
{

helm-chart/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ apiVersion: v2
22
name: hedera-json-rpc-relay
33
description: Helm chart deployment of the hashgraph/hedera-json-rpc-relay
44
type: application
5-
version: 0.15.0-SNAPSHOT
6-
appVersion: "0.15.0-SNAPSHOT"
5+
version: 0.15.0-rc1
6+
appVersion: "0.15.0-rc1"
77
home: https://github.com/hashgraph/hedera-json-rpc-relay

package-lock.json

Lines changed: 16 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/relay/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hashgraph/json-rpc-relay",
3-
"version": "0.15.0-SNAPSHOT",
3+
"version": "0.15.0-rc1",
44
"description": "Hedera Hashgraph implementation of Ethereum JSON RPC APIs. Utilises both the Hedera Consensus Nodes and the Mirror Nodes for transaction management and information retrieval",
55
"types": "dist/index.d.ts",
66
"main": "dist/index.js",

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

Lines changed: 89 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -35,115 +35,130 @@ export class JsonRpcError {
3535
}
3636

3737
export const predefined = {
38-
'NO_MINING_WORK': new JsonRpcError({
39-
name: 'No mining work',
38+
'CONTRACT_REVERT': (errorMessage?: string) => new JsonRpcError({
39+
name: 'Contract revert executed',
40+
code: -32008,
41+
message: `execution reverted: ${decodeErrorMessage(errorMessage)}`,
42+
data: errorMessage
43+
}),
44+
'GAS_LIMIT_TOO_HIGH': new JsonRpcError({
45+
name: 'gasLimit too high',
46+
code: -32005,
47+
message: 'Transaction gas limit exceeds block gas limit'
48+
}),
49+
'GAS_LIMIT_TOO_LOW': new JsonRpcError({
50+
name: 'gasLimit too low',
51+
code: -32003,
52+
message: 'Intrinsic gas exceeds gas limit'
53+
}),
54+
'GAS_PRICE_TOO_LOW': new JsonRpcError({
55+
name: 'Gas price too low',
56+
code: -32009,
57+
message: 'Gas price below configured minimum gas price'
58+
}),
59+
'HBAR_RATE_LIMIT_EXCEEDED': new JsonRpcError({
60+
name: 'HBAR Rate limit exceeded',
61+
code: -32606,
62+
message: 'HBAR Rate limit exceeded'
63+
}),
64+
'INCORRECT_NONCE': new JsonRpcError({
65+
name: 'Incorrect nonce',
66+
code: -32006,
67+
message: 'Incorrect nonce'
68+
}),
69+
'INSUFFICIENT_ACCOUNT_BALANCE': new JsonRpcError({
70+
name: 'Insufficient account balance',
4071
code: -32000,
41-
message: 'No mining work available yet'
72+
message: 'Insufficient funds for transfer'
4273
}),
43-
'INVALID_REQUEST': new JsonRpcError({
44-
name: 'Invalid request',
45-
code: -32600,
46-
message: 'Invalid request'
74+
'INTERNAL_ERROR': (message = '') => new JsonRpcError({
75+
name: 'Internal error',
76+
code: -32603,
77+
message: message === '' ? 'Unknown error invoking RPC' : `Error invoking RPC: ${message}`
4778
}),
48-
'UNSUPPORTED_METHOD': new JsonRpcError({
49-
name: 'Method not found',
50-
code: -32601,
51-
message: 'Unsupported JSON-RPC method'
79+
'INVALID_PARAMETER': (index: number | string, message: string) => new JsonRpcError({
80+
name: 'Invalid parameter',
81+
code: -32602,
82+
message: `Invalid parameter ${index}: ${message}`
5283
}),
5384
'INVALID_PARAMETERS': new JsonRpcError({
5485
name: 'Invalid parameters',
5586
code: -32602,
5687
message: 'Invalid params'
5788
}),
58-
'INTERNAL_ERROR': (message: string = '') => new JsonRpcError({
59-
name: 'Internal error',
60-
code: -32603,
61-
message: message === '' ? `Error invoking RPC: ${message}` : 'Unknown error invoking RPC'
89+
'INVALID_REQUEST': new JsonRpcError({
90+
name: 'Invalid request',
91+
code: -32600,
92+
message: 'Invalid request'
6293
}),
63-
'PARSE_ERROR': new JsonRpcError({
64-
name: 'Parse error',
65-
code: -32700,
66-
message: 'Unable to parse JSON'
94+
'IP_RATE_LIMIT_EXCEEDED': (methodName: string) => new JsonRpcError({
95+
name: 'IP Rate limit exceeded',
96+
code: -32605,
97+
message: `IP Rate limit exceeded on ${methodName}`
98+
}),
99+
'MISSING_FROM_BLOCK_PARAM': new JsonRpcError({
100+
name: 'Missing fromBlock parameter',
101+
code: -32011,
102+
message: 'Provided toBlock parameter without specifying fromBlock'
103+
}),
104+
'MISSING_REQUIRED_PARAMETER': (index: number | string) => new JsonRpcError({
105+
name: 'Missing required parameters',
106+
code: -32602,
107+
message: `Missing value for required parameter ${index}`
67108
}),
68109
'NONCE_TOO_LOW': new JsonRpcError({
69110
name: 'Nonce too low',
70111
code: 32001,
71112
message: 'Nonce too low'
72113
}),
73-
'INCORRECT_NONCE': new JsonRpcError({
74-
name: 'Incorrect nonce',
75-
code: -32006,
76-
message: 'Incorrect nonce'
114+
'NO_MINING_WORK': new JsonRpcError({
115+
name: 'No mining work',
116+
code: -32000,
117+
message: 'No mining work available yet'
77118
}),
78-
'GAS_LIMIT_TOO_HIGH': new JsonRpcError({
79-
name: 'gasLimit too high',
80-
code: -32005,
81-
message: 'Transaction gas limit exceeds block gas limit'
119+
'PARSE_ERROR': new JsonRpcError({
120+
name: 'Parse error',
121+
code: -32700,
122+
message: 'Unable to parse JSON'
82123
}),
83-
'GAS_LIMIT_TOO_LOW': new JsonRpcError({
84-
name: 'gasLimit too low',
85-
code: -32003,
86-
message: 'Intrinsic gas exceeds gas limit'
124+
'RANGE_TOO_LARGE': (blockRange: number) => new JsonRpcError({
125+
name: 'Block range too large',
126+
code: -32000,
127+
message: `Exceeded maximum block range: ${blockRange}`
87128
}),
88129
'REQUEST_BEYOND_HEAD_BLOCK': (requested: number, latest: number) => new JsonRpcError({
89130
name: 'Incorrect block',
90131
code: -32000,
91132
message: `Request beyond head block: requested ${requested}, head ${latest}`
92133
}),
93-
'UNSUPPORTED_CHAIN_ID': (requested: string | number, current: string | number) => new JsonRpcError({
94-
name: 'ChainId not supported',
95-
code: -32000,
96-
message: `ChainId (${requested}) not supported. The correct chainId is ${current}`
97-
}),
98-
'GAS_PRICE_TOO_LOW': new JsonRpcError({
99-
name: 'Gas price too low',
100-
code: -32009,
101-
message: 'Gas price below configured minimum gas price'
102-
}),
103-
'INSUFFICIENT_ACCOUNT_BALANCE': new JsonRpcError({
104-
name: 'Insufficient account balance',
105-
code: -32000,
106-
message: 'Insufficient funds for transfer'
107-
}),
108-
'VALUE_TOO_LOW': new JsonRpcError({
109-
name: 'Value too low',
110-
code: -32602,
111-
message: 'Value below 10_000_000_000 wei which is 1 tinybar'
112-
}),
113134
'REQUEST_TIMEOUT': new JsonRpcError({
114135
name: 'Request timeout',
115136
code: -32010,
116137
message: 'Request timeout. Please try again.'
117138
}),
118-
'RESOURCE_NOT_FOUND': (message: string = '') => new JsonRpcError({
139+
'RESOURCE_NOT_FOUND': (message = '') => new JsonRpcError({
119140
name: 'Resource not found',
120141
code: -32001,
121142
message: `Requested resource not found. ${message}`
122143
}),
123-
'RANGE_TOO_LARGE': (blockRange: number) => new JsonRpcError({
124-
name: 'Block range too large',
125-
code: -32000,
126-
message: `Exceeded maximum block range: ${blockRange}`
127-
}),
128-
'IP_RATE_LIMIT_EXCEEDED': (methodName: string) => new JsonRpcError({
129-
name: 'IP Rate limit exceeded',
130-
code: -32605,
131-
message: `IP Rate limit exceeded on ${methodName}`
144+
'UNKNOWN_HISTORICAL_BALANCE': new JsonRpcError({
145+
name: 'Unavailable balance',
146+
code: -32007,
147+
message: 'Historical balance data is available only after 15 minutes.'
132148
}),
133-
'HBAR_RATE_LIMIT_EXCEEDED': new JsonRpcError({
134-
name: 'HBAR Rate limit exceeded',
135-
code: -32606,
136-
message: 'HBAR Rate limit exceeded'
149+
'UNSUPPORTED_CHAIN_ID': (requested: string | number, current: string | number) => new JsonRpcError({
150+
name: 'ChainId not supported',
151+
code: -32000,
152+
message: `ChainId (${requested}) not supported. The correct chainId is ${current}`
137153
}),
138-
'CONTRACT_REVERT': (errorMessage?: string) => new JsonRpcError({
139-
name: 'Contract revert executed',
140-
code: -32008,
141-
message: `execution reverted: ${decodeErrorMessage(errorMessage)}`,
142-
data: errorMessage
154+
'UNSUPPORTED_METHOD': new JsonRpcError({
155+
name: 'Method not found',
156+
code: -32601,
157+
message: 'Unsupported JSON-RPC method'
143158
}),
144-
'MISSING_FROM_BLOCK_PARAM': new JsonRpcError({
145-
name: 'Missing fromBlock parameter',
146-
code: -32011,
147-
message: 'Provided toBlock parameter without specifying fromBlock'
159+
'VALUE_TOO_LOW': new JsonRpcError({
160+
name: 'Value too low',
161+
code: -32602,
162+
message: 'Value below 10_000_000_000 wei which is 1 tinybar'
148163
})
149164
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2632,7 +2632,7 @@ describe('Eth', async function () {
26322632
it('should execute "eth_chainId"', async function () {
26332633
const chainId = await Relay.eth().chainId();
26342634

2635-
expect(chainId).to.be.equal(`0x${process.env.CHAIN_ID}`);
2635+
expect(chainId).to.be.equal('0x' + Number(process.env.CHAIN_ID).toString(16));
26362636
});
26372637

26382638
it('should execute "eth_accounts"', async function () {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ describe("Open RPC Specification", function () {
137137
mock.onGet(`contracts/${log.address}`).reply(200, defaultContract);
138138
}
139139
sdkClientStub.getAccountBalanceInWeiBar.returns(1000);
140-
sdkClientStub.getAccountBalanceInTinyBar.returns(100000000000)
140+
sdkClientStub.getAccountBalanceInTinyBar.returns(100000000000);
141141
sdkClientStub.getContractByteCode.returns(Buffer.from(bytecode.replace('0x', ''), 'hex'));
142142
sdkClientStub.getAccountInfo.returns({ ethereumNonce: '0x1' });
143143
sdkClientStub.submitEthereumTransaction.returns({});

0 commit comments

Comments
 (0)