harmony-one / sdk

Javascript SDK of Harmony protocol.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The param "returnObject" is not work in functions: getBlockbyHash and getBlockbyNumber

Renewwen opened this issue · comments

Position

harmony-core/src/blockchain.ts

Questions

For two functions in blockchain.ts, getBlockByHash and getBlockByNumber,
There are three params: blockNumber/blockHahs, returnObject, shardID

The param returnObject dose nothing.

Functions:

// getBlockByHash 
@assertObject({
    blockHash: ['isHash', AssertType.required],
    returnObject: ['isBoolean', AssertType.optional],
    shardID: ['isNumber', AssertType.optional],
  })
  async getBlockByHash({
    blockHash,
    returnObject = true,
    shardID = this.messenger.currentShard,
  }: {
    blockHash: string;
    returnObject?: boolean;
    shardID?: number;
  }) {
    const result = await this.messenger.send(
      RPCMethod.GetBlockByHash,
      [blockHash, returnObject],
      this.messenger.chainPrefix,
      shardID,
    );
    return this.getRpcResult(result);
  }
//getBlockByNumber
  @assertObject({
    blockNumber: ['isBlockNumber', AssertType.optional],
    returnObject: ['isBoolean', AssertType.optional],
    shardID: ['isNumber', AssertType.optional],
  })
  async getBlockByNumber({
    blockNumber = DefaultBlockParams.latest,
    returnObject = true,
    shardID = this.messenger.currentShard,
  }: {
    blockNumber?: string;
    returnObject?: boolean;
    shardID?: number;
  }) {
    const result = await this.messenger.send(
      RPCMethod.GetBlockByNumber,
      [blockNumber, returnObject],
      this.messenger.chainPrefix,
      shardID,
    );
    return this.getRpcResult(result);
  }

Expectation

The typereturnObject is boolean:

  • true: the returned block will contain all transactions as objects
  • false: the returned block only contains the transaction hashes, by default, it's false.