How to use the @0x/assert.assert.isString 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-wrappers / src / generated-wrappers / i_asset_proxy.ts View on Github external
awaitTransactionSuccessAsync(
            assetData: string,
            from: string,
            to: string,
            amount: BigNumber,
            txData?: Partial,
            opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
        ): PromiseWithTransactionHash {
            assert.isString('assetData', assetData);
            assert.isString('from', from);
            assert.isString('to', to);
            assert.isBigNumber('amount', amount);
            const self = (this as any) as IAssetProxyContract;
            const txHashPromise = self.transferFrom.sendTransactionAsync(
                assetData,
                from.toLowerCase(),
                to.toLowerCase(),
                amount,
                txData,
                opts,
            );
            return new PromiseWithTransactionHash(
                txHashPromise,
                (async (): Promise => {
                    // When the transaction hash resolves, wait for it to be mined.
                    return self._web3Wrapper.awaitTransactionSuccessAsync(
github 0xProject / 0x-monorepo / packages / abi-gen-wrappers / src / generated-wrappers / multi_asset_proxy.ts View on Github external
async callAsync(
            assetProxyId: string,
            callData: Partial = {},
            defaultBlock?: BlockParam,
        ): Promise {
            assert.isString('assetProxyId', assetProxyId);
            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 MultiAssetProxyContract;
            const encodedData = self._strictEncodeArguments('getAssetProxy(bytes4)', [assetProxyId]);
            const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
                {
                    to: self.address,
                    ...callData,
                    data: encodedData,
                },
github 0xProject / 0x-monorepo / packages / abi-gen-wrappers / src / generated-wrappers / erc1155_mintable.ts View on Github external
public isApprovedForAll(owner: string, operator: string): ContractFunctionObj {
        const self = (this as any) as ERC1155MintableContract;
        assert.isString('owner', owner);
        assert.isString('operator', operator);
        const functionSignature = 'isApprovedForAll(address,address)';

        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, [owner.toLowerCase(), operator.toLowerCase()]);
            },
github 0xProject / 0x-monorepo / packages / abi-gen-wrappers / src / generated-wrappers / dummy_erc721_token.ts View on Github external
public safeTransferFrom2(
        _from: string,
        _to: string,
        _tokenId: BigNumber,
        _data: string,
    ): ContractTxFunctionObj {
        const self = (this as any) as DummyERC721TokenContract;
        assert.isString('_from', _from);
        assert.isString('_to', _to);
        assert.isBigNumber('_tokenId', _tokenId);
        assert.isString('_data', _data);
        const functionSignature = 'safeTransferFrom(address,address,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);
github 0xProject / 0x-monorepo / packages / contract-wrappers / src / generated-wrappers / erc20_token.ts View on Github external
public allowance(_owner: string, _spender: string): ContractFunctionObj {
        const self = (this as any) as ERC20TokenContract;
        assert.isString('_owner', _owner);
        assert.isString('_spender', _spender);
        const functionSignature = 'allowance(address,address)';

        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, [_owner.toLowerCase(), _spender.toLowerCase()]);
            },
github 0xProject / 0x-monorepo / packages / abi-gen-wrappers / src / generated-wrappers / erc1155_mintable.ts View on Github external
public setApprovalForAll(operator: string, approved: boolean): ContractTxFunctionObj {
        const self = (this as any) as ERC1155MintableContract;
        assert.isString('operator', operator);
        assert.isBoolean('approved', approved);
        const functionSignature = 'setApprovalForAll(address,bool)';

        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 / contract-wrappers / src / generated-wrappers / erc721_token.ts View on Github external
public balanceOf(_owner: string): ContractFunctionObj {
        const self = (this as any) as ERC721TokenContract;
        assert.isString('_owner', _owner);
        const functionSignature = 'balanceOf(address)';

        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, [_owner.toLowerCase()]);
            },
        };
github 0xProject / 0x-monorepo / packages / abi-gen-wrappers / src / generated-wrappers / dummy_erc721_token.ts View on Github external
public isApprovedForAll(_owner: string, _operator: string): ContractFunctionObj {
        const self = (this as any) as DummyERC721TokenContract;
        assert.isString('_owner', _owner);
        assert.isString('_operator', _operator);
        const functionSignature = 'isApprovedForAll(address,address)';

        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, [_owner.toLowerCase(), _operator.toLowerCase()]);
            },
        };
github 0xProject / 0x-monorepo / packages / contract-wrappers / src / generated-wrappers / coordinator.ts View on Github external
public executeTransaction(
        transaction: {
            salt: BigNumber;
            expirationTimeSeconds: BigNumber;
            gasPrice: BigNumber;
            signerAddress: string;
            data: string;
        },
        txOrigin: string,
        transactionSignature: string,
        approvalSignatures: string[],
    ): ContractTxFunctionObj {
        const self = (this as any) as CoordinatorContract;

        assert.isString('txOrigin', txOrigin);
        assert.isString('transactionSignature', transactionSignature);
        assert.isArray('approvalSignatures', approvalSignatures);
        const functionSignature = 'executeTransaction((uint256,uint256,uint256,address,bytes),address,bytes,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);
                }
                return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
github 0xProject / 0x-monorepo / packages / orderbook / src / orderbook.ts View on Github external
public async getOrdersAsync(makerAssetData: string, takerAssetData: string): Promise {
        assert.isString('makerAssetData', makerAssetData);
        assert.isString('takerAssetData', takerAssetData);
        const assetPairKey = OrderStore.getKeyForAssetPair(makerAssetData, takerAssetData);
        if (!(await this._orderStore.hasAsync(assetPairKey))) {
            await this._orderProvider.createSubscriptionForAssetPairAsync(makerAssetData, takerAssetData);
        }
        const orders = await this._orderStore.valuesAsync(assetPairKey);
        return orders.filter(
            o => o.order.makerAssetData === makerAssetData && o.order.takerAssetData === takerAssetData,
        );
    }
    /**