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

fix: use correct RPC method for gasPrice #932

Merged
merged 1 commit into from
Aug 9, 2021
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
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