Skip to content

Commit

Permalink
Complete eth_getStorageAt implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
lukelee-sl committed Jul 20, 2022
1 parent 44d85ef commit 55db696
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
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()');
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

0 comments on commit 55db696

Please sign in to comment.