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

To help you get started, we’ve selected a few @0x/assert 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 / abi-gen / test-cli / output / typescript / abi_gen_dummy.ts View on Github external
public withdraw(wad: BigNumber): ContractTxFunctionObj {
        const self = (this as any) as AbiGenDummyContract;
        assert.isBigNumber('wad', wad);
        const functionSignature = 'withdraw(uint256)';

        return {
            async sendTransactionAsync(
                txData?: Partial | undefined,
                opts: SendTransactionOpts = { shouldValidate: true },
            ): Promise {
                const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
                    { ...txData, data: this.getABIEncodedTransactionData() },
                    this.estimateGasAsync.bind(this),
                );
                if (opts.shouldValidate !== false) {
                    await this.callAsync(txDataWithDefaults);
                }
                return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
            },
github 0xProject / 0x-monorepo / packages / abi-gen / test-cli / output / typescript / abi_gen_dummy.ts View on Github external
public withAddressInput(
        x: string,
        a: BigNumber,
        b: BigNumber,
        y: string,
        c: BigNumber,
    ): ContractFunctionObj {
        const self = (this as any) as AbiGenDummyContract;
        assert.isString('x', x);
        assert.isBigNumber('a', a);
        assert.isBigNumber('b', b);
        assert.isString('y', y);
        assert.isBigNumber('c', c);
        const functionSignature = 'withAddressInput(address,uint256,uint256,address,uint256)';

        return {
            async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise {
                BaseContract._assertCallParams(callData, defaultBlock);
                const rawCallResult = await self._evmExecAsync(this.getABIEncodedTransactionData());
                const abiEncoder = self._lookupAbiEncoder(functionSignature);
                return abiEncoder.strictDecodeReturnValue(rawCallResult);
            },
            getABIEncodedTransactionData(): string {
                return self._strictEncodeArguments(functionSignature, [x.toLowerCase(), a, b, y.toLowerCase(), c]);
            },
        };
    }
    public withdraw(wad: BigNumber): ContractTxFunctionObj {
github 0xProject / 0x-monorepo / packages / abi-gen-wrappers / src / generated-wrappers / erc1155_mintable.ts View on Github external
public maxIndex(index_0: BigNumber): ContractFunctionObj {
        const self = (this as any) as ERC1155MintableContract;
        assert.isBigNumber('index_0', index_0);
        const functionSignature = 'maxIndex(uint256)';

        return {
            async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise {
                BaseContract._assertCallParams(callData, defaultBlock);
                const rawCallResult = await self._performCallAsync(
                    { ...callData, data: this.getABIEncodedTransactionData() },
                    defaultBlock,
                );
                const abiEncoder = self._lookupAbiEncoder(functionSignature);
                return abiEncoder.strictDecodeReturnValue(rawCallResult);
            },
            getABIEncodedTransactionData(): string {
                return self._strictEncodeArguments(functionSignature, [index_0]);
            },
        };
github 0xProject / 0x-monorepo / packages / abi-gen-wrappers / src / generated-wrappers / dummy_erc721_token.ts View on Github external
public approve(_approved: string, _tokenId: BigNumber): ContractTxFunctionObj {
        const self = (this as any) as DummyERC721TokenContract;
        assert.isString('_approved', _approved);
        assert.isBigNumber('_tokenId', _tokenId);
        const functionSignature = 'approve(address,uint256)';

        return {
            async sendTransactionAsync(
                txData?: Partial | undefined,
                opts: SendTransactionOpts = { shouldValidate: true },
            ): Promise {
                const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
                    { ...txData, data: this.getABIEncodedTransactionData() },
                    this.estimateGasAsync.bind(this),
                );
                if (opts.shouldValidate !== false) {
                    await this.callAsync(txDataWithDefaults);
                }
                return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
            },
github 0xProject / 0x-monorepo / packages / abi-gen-wrappers / src / generated-wrappers / erc1155_proxy.ts View on Github external
getABIEncodedTransactionData(assetData: string, from: string, to: string, amount: BigNumber): string {
            assert.isString('assetData', assetData);
            assert.isString('from', from);
            assert.isString('to', to);
            assert.isBigNumber('amount', amount);
            const self = (this as any) as ERC1155ProxyContract;
            const abiEncodedTransactionData = self._strictEncodeArguments(
                'transferFrom(bytes,address,address,uint256)',
                [assetData, from.toLowerCase(), to.toLowerCase(), amount],
            );
            return abiEncodedTransactionData;
        },
        /**
github 0xProject / 0x-monorepo / packages / abi-gen-wrappers / src / generated-wrappers / static_call_proxy.ts View on Github external
async callAsync(
            assetData: string,
            from: string,
            to: string,
            amount: BigNumber,
            callData: Partial = {},
            defaultBlock?: BlockParam,
        ): Promise {
            assert.isString('assetData', assetData);
            assert.isString('from', from);
            assert.isString('to', to);
            assert.isBigNumber('amount', amount);
            assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
                schemas.addressSchema,
                schemas.numberSchema,
                schemas.jsNumber,
            ]);
            if (defaultBlock !== undefined) {
                assert.isBlockParam('defaultBlock', defaultBlock);
            }
            const self = (this as any) as StaticCallProxyContract;
            const encodedData = self._strictEncodeArguments('transferFrom(bytes,address,address,uint256)', [
                assetData,
                from.toLowerCase(),
                to.toLowerCase(),
                amount,
            ]);
            const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
github 0xProject / 0x-monorepo / packages / contract-wrappers / src / generated-wrappers / erc20_token.ts View on Github external
public transferFrom(_from: string, _to: string, _value: BigNumber): ContractTxFunctionObj {
        const self = (this as any) as ERC20TokenContract;
        assert.isString('_from', _from);
        assert.isString('_to', _to);
        assert.isBigNumber('_value', _value);
        const functionSignature = 'transferFrom(address,address,uint256)';

        return {
            async sendTransactionAsync(
                txData?: Partial | undefined,
                opts: SendTransactionOpts = { shouldValidate: true },
            ): Promise {
                const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
                    { ...txData, data: this.getABIEncodedTransactionData() },
                    this.estimateGasAsync.bind(this),
                );
                if (opts.shouldValidate !== false) {
                    await this.callAsync(txDataWithDefaults);
                }
                return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
            },
github 0xProject / 0x-monorepo / packages / asset-buyer / src / utils / assert.ts View on Github external
isValidSwapQuote(variableName: string, swapQuote: SwapQuote): void {
        sharedAssert.isHexString(`${variableName}.takerAssetData`, swapQuote.takerAssetData);
        sharedAssert.isHexString(`${variableName}.makerAssetData`, swapQuote.makerAssetData);
        sharedAssert.doesConformToSchema(`${variableName}.orders`, swapQuote.orders, schemas.signedOrdersSchema);
        sharedAssert.doesConformToSchema(`${variableName}.feeOrders`, swapQuote.feeOrders, schemas.signedOrdersSchema);
        assert.isValidSwapQuoteInfo(`${variableName}.bestCaseQuoteInfo`, swapQuote.bestCaseQuoteInfo);
        assert.isValidSwapQuoteInfo(`${variableName}.worstCaseQuoteInfo`, swapQuote.worstCaseQuoteInfo);
        if (utils.isSwapQuoteMarketBuy(swapQuote)) {
            sharedAssert.isBigNumber(`${variableName}.makerAssetFillAmount`, swapQuote.makerAssetFillAmount);
        } else if (utils.isSwapQuoteMarketSell(swapQuote)) {
            sharedAssert.isBigNumber(`${variableName}.takerAssetFillAmount`, swapQuote.takerAssetFillAmount);
        } else {
            throw new Error(SwapQuoteConsumerError.InvalidMarketSellOrMarketBuySwapQuote);
        }
    },
    isValidForwarderSwapQuote(variableName: string, swapQuote: SwapQuote, wethAssetData: string): void {
github 0xProject / 0x-monorepo / packages / contract-wrappers / src / generated-wrappers / staking_proxy.ts View on Github external
public aggregatedStatsByEpoch(
        index_0: BigNumber,
    ): ContractFunctionObj<[BigNumber, BigNumber, BigNumber, BigNumber, BigNumber]> {
        const self = (this as any) as StakingProxyContract;
        assert.isBigNumber('index_0', index_0);
        const functionSignature = 'aggregatedStatsByEpoch(uint256)';

        return {
            async callAsync(
                callData: Partial = {},
                defaultBlock?: BlockParam,
            ): Promise<[BigNumber, BigNumber, BigNumber, BigNumber, BigNumber]> {
                BaseContract._assertCallParams(callData, defaultBlock);
                const rawCallResult = await self._performCallAsync(
                    { ...callData, data: this.getABIEncodedTransactionData() },
                    defaultBlock,
                );
                const abiEncoder = self._lookupAbiEncoder(functionSignature);
                return abiEncoder.strictDecodeReturnValue<[BigNumber, BigNumber, BigNumber, BigNumber, BigNumber]>(
                    rawCallResult,
                );
github 0xProject / 0x-monorepo / packages / abi-gen-wrappers / src / generated-wrappers / erc1155_mintable.ts View on Github external
public safeTransferFrom(
        from: string,
        to: string,
        id: BigNumber,
        value: BigNumber,
        data: string,
    ): ContractTxFunctionObj {
        const self = (this as any) as ERC1155MintableContract;
        assert.isString('from', from);
        assert.isString('to', to);
        assert.isBigNumber('id', id);
        assert.isBigNumber('value', value);
        assert.isString('data', data);
        const functionSignature = 'safeTransferFrom(address,address,uint256,uint256,bytes)';

        return {
            async sendTransactionAsync(
                txData?: Partial | undefined,
                opts: SendTransactionOpts = { shouldValidate: true },
            ): Promise {
                const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
                    { ...txData, data: this.getABIEncodedTransactionData() },
                    this.estimateGasAsync.bind(this),
                );
                if (opts.shouldValidate !== false) {
                    await this.callAsync(txDataWithDefaults);
                }