Skip to content

Commit

Permalink
implemented eth_accounts (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
shunjizhan committed Nov 16, 2021
1 parent 9b0d836 commit e4d2115
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
26 changes: 10 additions & 16 deletions eth-rpc-adapter/src/__tests__/endpoint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,22 +277,6 @@ describe('eth_getTransactionByHash', () => {
expect(res.data.result.hash).to.equal(tx3.transactionHash);
});

it('returns correct input data', async () => {
const allTxReceipts = await getAllTxReceipts();
const tx1 = allTxReceipts.find(({ to }) => !to); // contract creation
const tx2 = allTxReceipts.find(({ to }) => !!to); // normal transaction

// test first one
let res = await eth_getTransactionByHash([tx1.transactionHash]);
expect(res.status).to.equal(200);
expect(res.data.result.input).to.equal('');

// test last one
res = await eth_getTransactionByHash([tx2.transactionHash]);
expect(res.status).to.equal(200);
expect(res.data.result.input.length).to.greaterThan(0);
});

it('return correct error code and messge', async () => {
let res;

Expand All @@ -309,3 +293,13 @@ describe('eth_getTransactionByHash', () => {
expect(res.data.error.message).to.contain('transaction hash not found');
});
});

describe('eth_accounts', () => {
const eth_accounts = rpcGet('eth_accounts');

it('returns empty array', async () => {
const res = await eth_accounts([]);
expect(res.status).to.equal(200);
expect(res.data.result).to.deep.equal([]);
});
});
7 changes: 4 additions & 3 deletions eth-rpc-adapter/src/eip1193-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,10 @@ class Eip1193BridgeImpl {
return hexValue(gasPrice);
}

// async eth_accounts(params: any[]): Promise<any> {

// }
async eth_accounts(params: any[]): Promise<any> {
validate([], params);
return [];
}

/**
* Returns the value from a storage position at a given address.
Expand Down

0 comments on commit e4d2115

Please sign in to comment.