Skip to content

Commit

Permalink
Merge pull request #2529 from vshab/fix/bn-type
Browse files Browse the repository at this point in the history
Use genuine BN type
  • Loading branch information
nivida authored Mar 25, 2019
2 parents d7f5a80 + dfa7711 commit f8cb5c6
Show file tree
Hide file tree
Showing 49 changed files with 135 additions and 50 deletions.
20 changes: 20 additions & 0 deletions packages/web3-core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/web3-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
},
"dependencies": {
"@babel/runtime": "^7.3.1",
"@types/bn.js": "^4.11.4",
"@types/node": "^10.12.18",
"lodash": "^4.17.11",
"web3-utils": "1.0.0-beta.50"
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-core/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import * as net from 'net';
import BN = require('bn.js');
import {AbstractMethodFactory} from 'web3-core-method';
import {
BatchRequest,
Expand All @@ -29,7 +30,6 @@ import {
WebsocketProvider,
WebsocketProviderOptions
} from 'web3-providers';
import {BN} from 'web3-utils';

export class AbstractWeb3Module {
constructor(
Expand Down
25 changes: 25 additions & 0 deletions packages/web3-eth-contract/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/web3-eth-contract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
},
"dependencies": {
"@babel/runtime": "^7.3.1",
"@types/bn.js": "^4.11.4",
"lodash": "^4.17.11",
"web3-core": "1.0.0-beta.50",
"web3-core-helpers": "1.0.0-beta.50",
Expand Down
3 changes: 2 additions & 1 deletion packages/web3-eth-contract/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
* @date 2018
*/

import BN = require('bn.js');
import {provider} from 'web3-providers';
import {AbiItem, BN} from 'web3-utils';
import {AbiItem} from 'web3-utils';
import {PromiEvent} from 'web3-core';

export class Contract {
Expand Down
7 changes: 1 addition & 6 deletions packages/web3-utils/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* @date 2018
*/

import BigNumber = require('bn.js');
import BN = require('bn.js');
import {Buffer} from 'buffer';

export type Unit =
Expand Down Expand Up @@ -68,11 +68,6 @@ export type Mixed =

export type Hex = string | number;

export class BN extends BigNumber {
constructor(number: number | string | number[] | Buffer | BN, base?: number | 'hex', endian?: 'le' | 'be');
super(number: number | string | number[] | Buffer | BN, base?: number | 'hex', endian?: 'le' | 'be'): BigNumber;
}

// utils types
export function isBN(value: string | number): boolean;
export function isBigNumber(value: BN): boolean;
Expand Down
3 changes: 2 additions & 1 deletion packages/web3-utils/types/tests/ascii-to-hex-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* @date 2018
*/

import {asciiToHex, BN} from 'web3-utils';
import BN = require('bn.js');
import {asciiToHex} from 'web3-utils';

// $ExpectType string
asciiToHex('I have 100!');
Expand Down
3 changes: 2 additions & 1 deletion packages/web3-utils/types/tests/bytes-to-hex-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* @date 2018
*/

import {BN, bytesToHex} from 'web3-utils';
import BN = require('bn.js');
import {bytesToHex} from 'web3-utils';

// $ExpectType string
bytesToHex([72]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* @date 2018
*/

import {BN, checkAddressChecksum} from 'web3-utils';
import BN = require('bn.js');
import {checkAddressChecksum} from 'web3-utils';

// $ExpectType boolean
checkAddressChecksum('0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51');
Expand Down
3 changes: 2 additions & 1 deletion packages/web3-utils/types/tests/from-ascii-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* @date 2018
*/

import {BN, fromAscii} from 'web3-utils';
import BN = require('bn.js');
import {fromAscii} from 'web3-utils';

// $ExpectType string
fromAscii('I have 100!');
Expand Down
3 changes: 2 additions & 1 deletion packages/web3-utils/types/tests/from-decimal-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* @date 2018
*/

import {BN, fromDecimal} from 'web3-utils';
import BN = require('bn.js');
import {fromDecimal} from 'web3-utils';

// $ExpectType string
fromDecimal('232');
Expand Down
3 changes: 2 additions & 1 deletion packages/web3-utils/types/tests/from-utf8-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* @date 2018
*/

import {BN, fromUtf8} from 'web3-utils';
import BN = require('bn.js');
import {fromUtf8} from 'web3-utils';

// $ExpectType string
fromUtf8('I have 100£');
Expand Down
3 changes: 2 additions & 1 deletion packages/web3-utils/types/tests/from-wei-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* @date 2018
*/

import {BN, fromWei} from 'web3-utils';
import BN = require('bn.js');
import {fromWei} from 'web3-utils';

const bigNumber = new BN(3);

Expand Down
3 changes: 2 additions & 1 deletion packages/web3-utils/types/tests/get-signature-params-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* @date 2018
*/

import {BN, getSignatureParameters} from 'web3-utils';
import BN = require('bn.js');
import {getSignatureParameters} from 'web3-utils';

// $ExpectType { r: string; s: string; v: number; }
getSignatureParameters(
Expand Down
3 changes: 2 additions & 1 deletion packages/web3-utils/types/tests/get-unit-value-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* @date 2018
*/

import {BN, getUnitValue} from 'web3-utils';
import BN = require('bn.js');
import {getUnitValue} from 'web3-utils';

// $ExpectType string
getUnitValue('ether');
Expand Down
3 changes: 2 additions & 1 deletion packages/web3-utils/types/tests/hex-to-ascii-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* @date 2018
*/

import {BN, hexToAscii} from 'web3-utils';
import BN = require('bn.js');
import {hexToAscii} from 'web3-utils';

// $ExpectType string
hexToAscii('0x4920686176652031303021');
Expand Down
3 changes: 2 additions & 1 deletion packages/web3-utils/types/tests/hex-to-bytes-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* @date 2018
*/

import {BN, hexToBytes} from 'web3-utils';
import BN = require('bn.js');
import {hexToBytes} from 'web3-utils';

// $ExpectType number[]
hexToBytes('0x000000ea');
Expand Down
3 changes: 2 additions & 1 deletion packages/web3-utils/types/tests/hex-to-number-string-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* @date 2018
*/

import {BN, hexToNumberString} from 'web3-utils';
import BN = require('bn.js');
import {hexToNumberString} from 'web3-utils';

// $ExpectType string
hexToNumberString('0xea');
Expand Down
3 changes: 2 additions & 1 deletion packages/web3-utils/types/tests/hex-to-number-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* @date 2018
*/

import {BN, hexToNumber} from 'web3-utils';
import BN = require('bn.js');
import {hexToNumber} from 'web3-utils';

// $ExpectType number
hexToNumber('232');
Expand Down
3 changes: 2 additions & 1 deletion packages/web3-utils/types/tests/hex-to-string-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* @date 2018
*/

import {BN, hexToString} from 'web3-utils';
import BN = require('bn.js');
import {hexToString} from 'web3-utils';

// $ExpectType string
hexToString('0x49206861766520313030e282ac');
Expand Down
3 changes: 2 additions & 1 deletion packages/web3-utils/types/tests/hex-to-utf8-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* @date 2018
*/

import {BN, hexToUtf8} from 'web3-utils';
import BN = require('bn.js');
import {hexToUtf8} from 'web3-utils';

// $ExpectType string
hexToUtf8('0x49206861766520313030e282ac');
Expand Down
3 changes: 2 additions & 1 deletion packages/web3-utils/types/tests/is-address-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* @date 2018
*/

import {BN, isAddress} from 'web3-utils';
import BN = require('bn.js');
import {isAddress} from 'web3-utils';

// $ExpectType boolean
isAddress('0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51');
Expand Down
3 changes: 2 additions & 1 deletion packages/web3-utils/types/tests/is-big-number-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* @date 2018
*/

import {isBigNumber, BN} from 'web3-utils';
import BN = require('bn.js');
import {isBigNumber} from 'web3-utils';

// $ExpectType boolean
isBigNumber(new BN(3));
Expand Down
3 changes: 2 additions & 1 deletion packages/web3-utils/types/tests/is-bloom-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* @date 2018
*/

import {BN, isBloom} from 'web3-utils';
import BN = require('bn.js');
import {isBloom} from 'web3-utils';

// $ExpectType boolean
isBloom('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef');
Expand Down
3 changes: 2 additions & 1 deletion packages/web3-utils/types/tests/is-bn-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* @date 2018
*/

import {isBN, BN} from 'web3-utils';
import BN = require('bn.js');
import {isBN} from 'web3-utils';

// $ExpectType boolean
isBN(7);
Expand Down
3 changes: 2 additions & 1 deletion packages/web3-utils/types/tests/is-hex-strict-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* @date 2018
*/

import {BN, isHexStrict} from 'web3-utils';
import BN = require('bn.js');
import {isHexStrict} from 'web3-utils';

// $ExpectType boolean
isHexStrict('0xc1912');
Expand Down
3 changes: 2 additions & 1 deletion packages/web3-utils/types/tests/is-hex-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* @date 2018
*/

import {BN, isHex} from 'web3-utils';
import BN = require('bn.js');
import {isHex} from 'web3-utils';

// $ExpectType boolean
isHex('0xc1912');
Expand Down
3 changes: 2 additions & 1 deletion packages/web3-utils/types/tests/is-topic-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* @date 2018
*/

import {BN, isTopic} from 'web3-utils';
import BN = require('bn.js');
import {isTopic} from 'web3-utils';

// $ExpectType boolean
isTopic('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef');
Expand Down
3 changes: 2 additions & 1 deletion packages/web3-utils/types/tests/keccak256-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* @date 2018
*/

import {BN, keccak256} from 'web3-utils';
import BN = require('bn.js');
import {keccak256} from 'web3-utils';

// $ExpectType string
keccak256('234');
Expand Down
3 changes: 2 additions & 1 deletion packages/web3-utils/types/tests/left-pad-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* @date 2018
*/

import {BN, leftPad} from 'web3-utils';
import BN = require('bn.js');
import {leftPad} from 'web3-utils';

const bigNumber = new BN(3);
// $ExpectType string
Expand Down
3 changes: 2 additions & 1 deletion packages/web3-utils/types/tests/number-to-hex-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* @date 2018
*/

import {BN, numberToHex} from 'web3-utils';
import BN = require('bn.js');
import {numberToHex} from 'web3-utils';

// $ExpectType string
numberToHex('232');
Expand Down
Loading

0 comments on commit f8cb5c6

Please sign in to comment.