How to use the @0x/utils.BigNumber.isBigNumber function in @0x/utils

To help you get started, we’ve selected a few @0x/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 0xProject / 0x-monorepo / packages / base-contract / src / utils / filter_utils.ts View on Github external
getTopicsForIndexedArgs(abi: EventAbi, indexFilterValues: IndexedFilterValues): Array {
        const topics: Array = [];
        for (const eventInput of abi.inputs) {
            if (!eventInput.indexed) {
                continue;
            }
            if (indexFilterValues[eventInput.name] === undefined) {
                // Null is a wildcard topic in a JSON-RPC call
                topics.push(null);
            } else {
                // tslint:disable: no-unnecessary-type-assertion
                let value = indexFilterValues[eventInput.name] as any;
                if (BigNumber.isBigNumber(value)) {
                    // tslint:disable-next-line custom-no-magic-numbers
                    value = ethUtil.fromSigned(value.toString(10) as any);
                }
                // tslint:enable: no-unnecessary-type-assertion
                const buffer = ethUtil.toBuffer(value);
                const paddedBuffer = ethUtil.setLengthLeft(buffer, TOPIC_LENGTH);
                const topic = ethUtil.bufferToHex(paddedBuffer);
                topics.push(topic);
            }
        }
        return topics;
    },
    matchesFilter(log: LogEntry, filter: FilterObject): boolean {
github 0xProject / 0x-monorepo / packages / base-contract / src / index.ts View on Github external
protected static _bigNumberToString(_type: string, value: any): any {
        return BigNumber.isBigNumber(value) ? value.toString() : value;
    }
    protected static _lookupConstructorAbi(abi: ContractAbi): ConstructorAbi {
github 0xProject / 0x-monorepo / packages / assert / src / index.ts View on Github external
isBigNumber(variableName: string, value: BigNumber): void {
        const isBigNumber = BigNumber.isBigNumber(value);
        assert.assert(isBigNumber, assert.typeAssertionMessage(variableName, 'BigNumber', value));
    },
    isNumberLike(variableName: string, value: BigNumber | number): void {
github 0xProject / 0x-monorepo / packages / order-utils / src / crypto.ts View on Github external
_.each(args, (arg, i) => {
            const isNumber = _.isFinite(arg);
            if (isNumber) {
                argTypes.push('uint8');
            } else if (BigNumber.isBigNumber(arg)) {
                argTypes.push('uint256');
                const base = 10;
                args[i] = new BN(arg.toString(base), base);
            } else if (ethUtil.isValidAddress(arg)) {
                argTypes.push('address');
            } else if (_.isString(arg)) {
                argTypes.push('string');
            } else if (_.isBuffer(arg) || _.isTypedArray(arg)) {
                argTypes.push('bytes');
            } else if (_.isBoolean(arg)) {
                argTypes.push('bool');
            } else {
                throw new Error(`Unable to guess arg type: ${arg}`);
            }
        });
        const hash = hashFunction(argTypes, args);
github 0xProject / 0x-monorepo / packages / assert / src / index.ts View on Github external
isNumberOrBigNumber(variableName: string, value: any): void {
        if (_.isFinite(value)) {
            return;
        } else {
            assert.assert(
                BigNumber.isBigNumber(value),
                assert.typeAssertionMessage(variableName, 'number or BigNumber', value),
            );
        }
    },
    isBoolean(variableName: string, value: boolean): void {
github 0xProject / 0x-monorepo / packages / assert / src / index.ts View on Github external
isNumberLike(variableName: string, value: BigNumber | number): void {
        const isBigNumber = BigNumber.isBigNumber(value);
        const isNumber = typeof value === 'number';
        assert.assert(isBigNumber || isNumber, assert.typeAssertionMessage(variableName, 'BigNumber | number', value));
    },
    isValidBaseUnitAmount(variableName: string, value: BigNumber): void {