[web3]: fix eth.getBalance return type (#29093)

* fix eth.getBalance return type

* fix callback return type too

* docs are wrong, should be BigNumber

* added overload and tests

* correct optional params to be non-optional, add tests
This commit is contained in:
Doug Kent
2018-10-22 11:36:43 -04:00
committed by Sheetal Nandi
parent 22fd132d2e
commit 8f7d68807b
2 changed files with 12 additions and 3 deletions

View File

@@ -87,9 +87,13 @@ export default interface Eth {
getAccounts(cb?: Callback<string[]>): Promise<string[]>;
getBalance(
address: string,
defaultBlock?: BlockType,
cb?: Callback<number>
): Promise<number>;
defaultBlock?: BlockType
): Promise<BigNumber>;
getBalance(
address: string,
defaultBlock: BlockType,
cb: Callback<BigNumber>
): void;
getBlock(
number: BlockType,
returnTransactionObjects?: boolean,

View File

@@ -17,6 +17,11 @@ web3.eth.setProvider(myProvider);
// web3.eth
// --------------------------------------------------------------------------
const storage: Promise<string> = web3.eth.getStorageAt(contractAddress, 0);
const balance1: Promise<BigNumber> = web3.eth.getBalance(contractAddress);
const balance2: Promise<BigNumber> = web3.eth.getBalance(contractAddress, "latest");
const balance3: Promise<BigNumber> = web3.eth.getBalance(contractAddress, 1);
web3.eth.getBalance(contractAddress, "latest", (error: Error, balance: BigNumber) => { });
web3.eth.getBalance(contractAddress, 1, (error: Error, balance: BigNumber) => { });
const sendSignedTransactionTxReceipt0: PromiEvent<TransactionReceipt> = web3.eth.sendSignedTransaction("",
(error: Error, txHash: string) => { });