Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Commit

Permalink
Merge pull request #93 from nervosnetwork/revert-83-eth_gasPrice
Browse files Browse the repository at this point in the history
Revert "feat: implement eth_gasPrice RPC"
  • Loading branch information
classicalliu authored Dec 3, 2021
2 parents 40edda3 + fec5da4 commit a3e443d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 52 deletions.
32 changes: 3 additions & 29 deletions packages/api-server/src/methods/modules/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ import {
import { middleware, validators } from "../validator";
import { FilterFlag, FilterObject } from "../../cache/types";
import { utils, HexNumber, Hash, Address, HexString } from "@ckb-lumos/base";
import {
FeeConfig,
RawL2Transaction,
RunResult,
} from "@godwoken-web3/godwoken";
import { RawL2Transaction, RunResult } from "@godwoken-web3/godwoken";
import { Script } from "@ckb-lumos/base";
import {
CKB_SUDT_ID,
Expand Down Expand Up @@ -94,7 +90,6 @@ export class Eth {
validators.address,
validators.blockParameter,
]);
// this.gasPrice = middleware(this.gasPrice.bind(this), 0);
this.getStorageAt = middleware(this.getStorageAt.bind(this), 3, [
validators.address,
validators.hexNumber,
Expand Down Expand Up @@ -259,29 +254,8 @@ export class Eth {
return "0x0";
}

/**
* Get the current price per gas in shannon.
* 1 CKB = 100,000,000 Shannons
*
* Note: Polyjuice use CKB to pay fee by default.
* @returns gasPrice (unit: shannon)
*/
async gasPrice(_args: []): Promise<HexNumber> {
try {
let GodwokenFeeConfig: FeeConfig = await this.rpc.getFeeConfig();
if (
!GodwokenFeeConfig?.fee_rates ||
Object.keys(GodwokenFeeConfig.fee_rates).length === 0
) {
// default gasPrice = 0, if GodwokenFeeConfig.fee_rates is empty
return "0x0";
}
// Note: Polyjuice use CKB to pay fee by default.
const CKB_SUDT_ID = "0x1";
return GodwokenFeeConfig.fee_rates[CKB_SUDT_ID];
} catch (error: any) {
throw new Web3Error(error.message);
}
async gasPrice(args: []): Promise<HexNumber> {
return "0x1";
}

/**
Expand Down
9 changes: 0 additions & 9 deletions packages/godwoken/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
RunResult,
U128,
U32,
FeeConfig,
} from "./types";
import { SerializeL2Transaction, SerializeRawL2Transaction } from "../schemas";
import {
Expand Down Expand Up @@ -92,14 +91,6 @@ export class GodwokenClient {
return +nonce;
}

/**
* getFeeConfig from Godwoken RPC
*/
public async getFeeConfig(): Promise<FeeConfig> {
// TODO: cache FeeConfig
return this.rpcCall("get_fee_config");
}

public async getData(
dataHash: Hash,
blockParameter?: BlockParameter
Expand Down
14 changes: 0 additions & 14 deletions packages/godwoken/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,6 @@ export type HexU128 = HexNumber;
// null means `pending`
export type BlockParameter = U64 | null;

/**
* HashMap<fee_sudt_id, fee_rate>
* fee_rate is known as gasPrice in Ethereum.
*/
interface FeeRates {
readonly [sudtId: string]: HexU64;
}
/**
* e.g. {"fee_rates":{"0x1":"0x1f4"},...}
*/
export interface FeeConfig {
fee_rates: FeeRates;
}

export interface LogItem {
account_id: HexU32;
// The actual type is `u8`
Expand Down

0 comments on commit a3e443d

Please sign in to comment.