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

Complete eth_getStorageAt implementation #361

Merged
merged 3 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion packages/relay/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export interface Eth {

getLogs(blockHash: string|null, fromBlock: string|null, toBlock: string|null, address: string|null, topics: any[]|null): Promise<Log[]>;

// getStorageAt(address: string, slot: string, blockNumber: string|null);
getStorageAt(address: string, slot: string, blockNumber: string|null): JsonRpcError;

getTransactionByBlockHashAndIndex(hash: string, index: number): Promise<Transaction | null>;

Expand Down
5 changes: 5 additions & 0 deletions packages/relay/src/lib/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,11 @@ export class EthImpl implements Eth {
return predefined.UNSUPPORTED_METHOD;
}

getStorageAt(address: string, slot: string, blockNumber: string | null): JsonRpcError {
this.logger.trace('getStorageAt(address=%s, slot=%s, blockNumber=%s)', address, slot, blockNumber);
return predefined.UNSUPPORTED_METHOD;
}

/**
* Gets the balance of an account as of the given block.
*
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 @@ -1503,7 +1503,8 @@ describe('Eth', async function () {
'sign',
'sendTransaction',
'protocolVersion',
'coinbase'
'coinbase',
'getStorageAt',
];

unsupportedMethods.forEach(method => {
Expand Down
3 changes: 1 addition & 2 deletions packages/server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,7 @@ rpc.use('eth_getLogs', async (params: any) => {
* returns: Value - The storage value
*/
rpc.use('eth_getStorageAt', async (params: any) => {
return logger.debug("eth_getStorageAt");
//TODO
return logAndHandleResponse("eth_getStorageAt", () => relay.eth().getStorageAt(params?.[0], params?.[1], params?.[2]));
});

/**
Expand Down
11 changes: 11 additions & 0 deletions packages/server/tests/integration/server.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,17 @@ describe('RPC Server', async function() {

BaseTest.unsupportedJsonRpcMethodChecks(res);
});

it('should execute "eth_getStorageAt"', async function() {
const res = await this.testClient.post('/', {
'id': '2',
'jsonrpc': '2.0',
'method': 'eth_getStorageAt',
'params': [null]
});

BaseTest.unsupportedJsonRpcMethodChecks(res);
});
});

class BaseTest {
Expand Down