diff --git a/packages/caver-rpc/src/governance.js b/packages/caver-rpc/src/governance.js index fd27072e..15b6f355 100644 --- a/packages/caver-rpc/src/governance.js +++ b/packages/caver-rpc/src/governance.js @@ -157,15 +157,18 @@ const Governance = function Governance(...args) { * @instance * * @example + * const result = await caver.rpc.governance.getChainConfig(0) + * // latest by default * const result = await caver.rpc.governance.getChainConfig() * + * @param {number|string} blockNumber A block number, or the hex number string to query chain configuration. * @param {function} [callback] Optional callback, returns an error object as the first parameter and the result as the second. - * @return {Promise} The latest chain configuration + * @return {Promise} The latest chain configuration, or chain configuration at the given block number. */ new Method({ name: 'getChainConfig', - call: 'governance_chainConfig', - params: 0, + call: 'governance_getChainConfig', + params: 1, }), /** * Returns the chain configuration at a specific block. diff --git a/packages/caver-rpc/src/klay.js b/packages/caver-rpc/src/klay.js index a5d7887b..c4cce572 100644 --- a/packages/caver-rpc/src/klay.js +++ b/packages/caver-rpc/src/klay.js @@ -2249,15 +2249,18 @@ class Klay { * @instance * * @example + * const result = await caver.rpc.klay.getChainConfig(0) + * // latest by default * const result = await caver.rpc.klay.getChainConfig() * + * @param {number|string} blockNumber A block number, or the hex number string to query chain configuration. * @param {function} [callback] Optional callback, returns an error object as the first parameter and the result as the second. - * @return {Promise} The latest chain configuration + * @return {Promise} The latest chain configuration, or chain configuration at the given block number. */ new Method({ name: 'getChainConfig', - call: 'klay_chainConfig', - params: 0, + call: 'klay_getChainConfig', + params: 1, }), /** * Returns the chain configuration at a specific block. diff --git a/test/packages/caver.rpc.js b/test/packages/caver.rpc.js index c17b056c..a3df62ac 100644 --- a/test/packages/caver.rpc.js +++ b/test/packages/caver.rpc.js @@ -698,7 +698,7 @@ describe('caver.rpc.klay', () => { const klayRPCStub = sandbox .stub(caver.rpc.klay.getChainConfig.method.requestManager, 'send') .callsFake((payload, sendTxCallback) => { - expect(payload.method).to.equal('klay_chainConfig') + expect(payload.method).to.equal('klay_getChainConfig') expect(payload.params.length).to.equal(caver.rpc.klay.getChainConfig.method.params) const ret = { chainId: 1001, @@ -1098,7 +1098,7 @@ describe('caver.rpc.governance', () => { const govRPCStub = sandbox .stub(caver.rpc.governance.getChainConfig.method.requestManager, 'send') .callsFake((payload, sendTxCallback) => { - expect(payload.method).to.equal('governance_chainConfig') + expect(payload.method).to.equal('governance_getChainConfig') expect(payload.params.length).to.equal(caver.rpc.governance.getChainConfig.method.params) const ret = { chainId: 1001, diff --git a/types/packages/caver-klay/src/index.d.ts b/types/packages/caver-klay/src/index.d.ts index 4b5043e6..53879686 100644 --- a/types/packages/caver-klay/src/index.d.ts +++ b/types/packages/caver-klay/src/index.d.ts @@ -86,8 +86,6 @@ export class DeprecatedKlayRPC { getHeaderByHash: RpcCallToMethod['klay_getHeaderByHash'] getBlockReceipts: RpcCallToMethod['klay_getBlockReceipts'] getRewards: RpcCallToMethod['klay_getRewards'] - getChainConfig: RpcCallToMethod['klay_chainConfig'] - getChainConfigAt: RpcCallToMethod['klay_chainConfigAt'] getNodeAddress: RpcCallToMethod['klay_nodeAddress'] getGovParamsAt: RpcCallToMethod['klay_govParamsAt'] getStakingInfo: RpcCallToMethod['klay_getStakingInfo'] diff --git a/types/packages/caver-rpc/src/governance.d.ts b/types/packages/caver-rpc/src/governance.d.ts index 1e851ea6..ed54eb50 100644 --- a/types/packages/caver-rpc/src/governance.d.ts +++ b/types/packages/caver-rpc/src/governance.d.ts @@ -76,6 +76,7 @@ export class Governance { getMyVotingPower(callback?: (error: Error, result: number) => void): Promise getMyVotes(callback?: (error: Error, result: MyVote[]) => void): Promise getChainConfig(callback?: (error: Error, result: ChainConfig) => void): Promise + getChainConfig(blockNumber: BlockNumber, callback?: (error: Error, result: ChainConfig) => void): Promise getChainConfigAt(callback?: (error: Error, result: ChainConfig) => void): Promise getChainConfigAt(blockNumber: BlockNumber, callback?: (error: Error, result: ChainConfig) => void): Promise getNodeAddress(callback?: (error: Error, result: string) => void): Promise diff --git a/types/packages/caver-rpc/src/klay.d.ts b/types/packages/caver-rpc/src/klay.d.ts index c83a98c8..0823d9cf 100644 --- a/types/packages/caver-rpc/src/klay.d.ts +++ b/types/packages/caver-rpc/src/klay.d.ts @@ -140,6 +140,7 @@ export class Klay { getRewards(blockNumber: BlockNumber, callback?: (error: Error, result: Header) => void): Promise getChainConfig(callback?: (error: Error, result: ChainConfig) => void): Promise + getChainConfig(blockNumber: BlockNumber, callback?: (error: Error, result: ChainConfig) => void): Promise getChainConfigAt(callback?: (error: Error, result: ChainConfig) => void): Promise getChainConfigAt(blockNumber: BlockNumber, callback?: (error: Error, result: ChainConfig) => void): Promise getNodeAddress(callback?: (error: Error, result: string) => void): Promise diff --git a/types/packages/caver-rtm/src/index.d.ts b/types/packages/caver-rtm/src/index.d.ts index 6f6faa90..56fa5a57 100644 --- a/types/packages/caver-rtm/src/index.d.ts +++ b/types/packages/caver-rtm/src/index.d.ts @@ -136,6 +136,10 @@ export default class RpcCallToMethod { klay_chainConfig( callback?: (error: Error, result: ChainConfig) => void ): Promise + klay_getChainConfig( + blockNumberOrHash?: BlockNumber | string, + callback?: (error: Error, result: ChainConfig) => void + ): Promise klay_chainConfigAt( blockNumberOrHash: BlockNumber | string, callback?: (error: Error, result: ChainConfig) => void diff --git a/types/test/rpc-test.ts b/types/test/rpc-test.ts index 0beb131e..2dc55e67 100644 --- a/types/test/rpc-test.ts +++ b/types/test/rpc-test.ts @@ -1191,6 +1191,11 @@ rpc.klay.getRewardbase() // $ExpectType Promise rpc.klay.getRewardbase((err: Error, ret: string) => {}) +// $ExpectType Promise +rpc.klay.getChainConfig() +// $ExpectType Promise +rpc.klay.getChainConfig((err: Error, ret: ChainConfig) => {}) + // $ExpectType Promise rpc.klay.getFilterChanges('filterId') // $ExpectType Promise