Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use genuine BN type #2529

Merged
merged 9 commits into from
Mar 25, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 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 @@ -16,6 +16,7 @@
"dtslint": "dtslint types --onlyTestTsNext"
},
"dependencies": {
"@types/bn.js": "^4.11.4",
"@babel/runtime": "^7.3.1",
"@types/node": "^10.12.18",
"lodash": "^4.17.11",
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');
nivida marked this conversation as resolved.
Show resolved Hide resolved
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
8 changes: 8 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 @@ -16,6 +16,7 @@
"dtslint": "dtslint types --onlyTestTsNext"
},
"dependencies": {
"@types/bn.js": "^4.11.4",
"@babel/runtime": "^7.3.1",
"lodash": "^4.17.11",
"web3-core": "1.0.0-beta.48",
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');
nivida marked this conversation as resolved.
Show resolved Hide resolved
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
3 changes: 2 additions & 1 deletion packages/web3-utils/types/tests/pad-left-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* @date 2018
*/

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

const bigNumber = new BN(3);

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

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

const bigNumber = new BN(3);

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

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

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

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

const bigNumber = new BN(3);

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

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

// $ExpectType string
sha3('234');
Expand Down
Loading