Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
fix: use correct RPC method for gasPrice (#932)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmurdoch authored Aug 9, 2021
1 parent 7e077b8 commit 060adde
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions src/chains/ethereum/ethereum/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,11 +575,11 @@ export default class EthereumApi implements Api {
* @returns `true`.
* @example
* ```javascript
* console.log(await provider.send("miner_setDefaultGasPrice", [300000] ));
* console.log(await provider.send("miner_setGasPrice", [300000] ));
* ```
*/
@assertArgLength(1)
async miner_setDefaultGasPrice(number: QUANTITY) {
async miner_setGasPrice(number: QUANTITY) {
this.#options.miner.defaultGasPrice = Quantity.from(number);
return true;
}
Expand Down Expand Up @@ -1285,12 +1285,12 @@ export default class EthereumApi implements Api {
* @returns Integer of the current gas price in wei.
* @example
* ```javascript
* const defaultGasPrice = await provider.request({ method: "eth_defaultGasPrice", params: [] });
* console.log(defaultGasPrice);
* const gasPrice = await provider.request({ method: "eth_gasPrice", params: [] });
* console.log(gasPrice);
* ```
*/
@assertArgLength(0)
async eth_defaultGasPrice() {
async eth_gasPrice() {
return this.#options.miner.defaultGasPrice;
}

Expand Down
16 changes: 8 additions & 8 deletions src/chains/ethereum/ethereum/tests/api/miner/miner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe("api", () => {
});
});

describe("miner_setDefaultGasPrice", () => {
describe("miner_setGasPrice", () => {
let provider: EthereumProvider;
let accounts: string[];

Expand All @@ -113,15 +113,15 @@ describe("api", () => {
accounts = await provider.send("eth_accounts");
});

it("sets the defaultGasPrice and uses it as the default price in tranactions", async () => {
const newDefaultGasPrice = "0xffff";
const setState = await provider.send("miner_setDefaultGasPrice", [
newDefaultGasPrice
it("sets the gasPrice and uses it as the default price in transactions", async () => {
const newGasPrice = "0xffff";
const setState = await provider.send("miner_setGasPrice", [
newGasPrice
]);
assert.strictEqual(setState, true);

const ethDefaultGasPrice = await provider.send("eth_defaultGasPrice");
assert.strictEqual(ethDefaultGasPrice, newDefaultGasPrice);
const ethGasPrice = await provider.send("eth_gasPrice");
assert.strictEqual(ethGasPrice, newGasPrice);

await provider.send("eth_subscribe", ["newHeads"]);
const txHash = await provider.send("eth_sendTransaction", [
Expand All @@ -132,7 +132,7 @@ describe("api", () => {
const { gasPrice } = await provider.send("eth_getTransactionByHash", [
txHash
]);
assert.strictEqual(gasPrice, newDefaultGasPrice);
assert.strictEqual(gasPrice, newGasPrice);
});
});
});
Expand Down

0 comments on commit 060adde

Please sign in to comment.