Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure Schema compliance with execution-apis schema #372

Merged
merged 8 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 13 additions & 24 deletions docs/openrpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@
"items": {
"title": "rewardPercentile",
"description": "Floating point value between 0 and 100.",
"type": "number"
"type": "number",
"pattern": "^[0-9][0-9]?$|^100$"
}
}
}
Expand Down Expand Up @@ -159,7 +160,9 @@
"description": "An array of gas used ratio.",
"type": "array",
"items": {
"$ref": "#/components/schemas/uint"
"title": "hex encoded unsigned integer",
"type": "string",
"pattern": "^0x([1-9a-f]+[0-9a-f]*|0|0.8)$"
}
},
"baseFeePerGas": {
Expand Down Expand Up @@ -189,18 +192,6 @@
}
}
},
{
Nana-EC marked this conversation as resolved.
Show resolved Hide resolved
"name": "eth_gasPrice",
"summary": "Returns the current price per gas in weibars.",
"params": [],
"result": {
"name": "Gas price",
"schema": {
"title": "Gas price",
"$ref": "#/components/schemas/uint"
}
}
},
{
"name": "eth_getBalance",
"summary": "Returns the balance of the account of given address.",
Expand Down Expand Up @@ -358,11 +349,7 @@
"result": {
"name": "Log objects",
"schema": {
"title": "Filter results",
"type": "array",
"items": {
"$ref": "#/components/schemas/FilterResults"
}
"$ref": "#/components/schemas/FilterResults"
}
}
},
Expand Down Expand Up @@ -460,10 +447,7 @@
"name": "Transaction count",
"schema": {
"title": "Transaction count",
"type": "array",
"items": {
"$ref": "#/components/schemas/uint"
}
"$ref": "#/components/schemas/uint"
}
}
},
Expand Down Expand Up @@ -683,7 +667,7 @@
"name": "The current client version.",
"schema": {
"type": "string",
"pattern": "relay/<semanticVersion>"
"pattern": "relay\/[0-9]\\.[0-9]\\.[0-9]"
}
}
}
Expand Down Expand Up @@ -1378,6 +1362,11 @@
"title": "Error message",
"type": "string",
"pattern": "Unsupported JSON-RPC method"
},
"name": {
"title": "Error name",
"type": "string",
"pattern": "Method not found"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"start": "npx lerna exec --scope @hashgraph/json-rpc-server -- npm run start",
"start:docker": "docker run --name hedera-relay -d -p 7546:7546 ${npm_package_name}:latest",
"test": "npx lerna run test",
"openrpctest": "ts-mocha packages/server/tests/integration/openrpc.spec.ts",
"openrpctest": "ts-mocha packages/relay/tests/lib/openrpc.spec.ts --exit",
"integration:prerequisite": "ts-node packages/server/tests/helpers/prerequisite.ts"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/relay/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ export interface Eth {

getBlockByNumber(blockNum: string, showDetails: boolean): Promise<Block | null>;

getBlockTransactionCountByHash(hash: string): Promise<number | null>;
getBlockTransactionCountByHash(hash: string): Promise<string | null>;

getBlockTransactionCountByNumber(blockNum: string): Promise<number | null>
getBlockTransactionCountByNumber(blockNum: string): Promise<string | null>

getCode(address: string, blockNumber: string | null): Promise<string>;

Expand Down
18 changes: 9 additions & 9 deletions packages/relay/src/lib/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ export class EthImpl implements Eth {
*
* @param hash
*/
async getBlockTransactionCountByHash(hash: string): Promise<number | null> {
async getBlockTransactionCountByHash(hash: string): Promise<string | null> {
this.logger.trace('getBlockTransactionCountByHash(hash=%s, showDetails=%o)', hash);
return this.mirrorNodeClient
.getBlock(hash)
Expand All @@ -555,7 +555,7 @@ export class EthImpl implements Eth {
* Gets the number of transaction in a block by its block number.
* @param blockNumOrTag
*/
async getBlockTransactionCountByNumber(blockNumOrTag: string): Promise<number | null> {
async getBlockTransactionCountByNumber(blockNumOrTag: string): Promise<string | null> {
this.logger.trace('getBlockTransactionCountByNumber(blockNum=%s, showDetails=%o)', blockNumOrTag);
const blockNum = await this.translateBlockTag(blockNumOrTag);
return this.mirrorNodeClient
Expand Down Expand Up @@ -778,13 +778,13 @@ export class EthImpl implements Eth {
input: contractResult.function_parameters,
maxPriorityFeePerGas: maxPriorityFee,
maxFeePerGas: maxFee,
nonce: contractResult.nonce,
nonce: EthImpl.numberTo0x(contractResult.nonce),
r: rSig,
s: sSig,
to: contractResult.to?.substring(0, 42),
transactionIndex: EthImpl.numberTo0x(contractResult.transaction_index),
type: contractResult.type,
v: contractResult.v,
type: EthImpl.numberTo0x(contractResult.type),
v: EthImpl.numberTo0x(contractResult.v),
value: EthImpl.numberTo0x(contractResult.amount),
});
}
Expand Down Expand Up @@ -997,7 +997,7 @@ export class EthImpl implements Eth {
return null;
}

return block.count;
return EthImpl.numberTo0x(block.count);
}

private getTransactionFromContractResults(contractResults: any) {
Expand Down Expand Up @@ -1033,13 +1033,13 @@ export class EthImpl implements Eth {
input: contractResultDetails.function_parameters,
maxPriorityFeePerGas: EthImpl.toNullIfEmptyHex(contractResultDetails.max_priority_fee_per_gas),
maxFeePerGas: EthImpl.toNullIfEmptyHex(contractResultDetails.max_fee_per_gas),
nonce: contractResultDetails.nonce,
nonce: EthImpl.numberTo0x(contractResultDetails.nonce),
r: rSig,
s: sSig,
to: contractResultDetails.to.substring(0, 42),
transactionIndex: EthImpl.numberTo0x(contractResultDetails.transaction_index),
type: contractResultDetails.type,
v: contractResultDetails.v,
type: EthImpl.numberTo0x(contractResultDetails.type),
v: EthImpl.numberTo0x(contractResultDetails.v),
value: EthImpl.numberTo0x(contractResultDetails.amount),
});
})
Expand Down
Loading