How to use the @0x/json-schemas.schemas.signedOrderSchema function in @0x/json-schemas

To help you get started, we’ve selected a few @0x/json-schemas 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 / contract-wrappers / src / contract_wrappers / dutch_auction_wrapper.ts View on Github external
public async matchOrdersAsync(
        buyOrder: SignedOrder,
        sellOrder: SignedOrder,
        takerAddress: string,
        orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
    ): Promise {
        // type assertions
        assert.doesConformToSchema('buyOrder', buyOrder, schemas.signedOrderSchema);
        assert.doesConformToSchema('sellOrder', sellOrder, schemas.signedOrderSchema);
        await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
        assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]);
        const normalizedTakerAddress = takerAddress.toLowerCase();
        // other assertions
        if (
            sellOrder.makerAssetData !== buyOrder.takerAssetData ||
            sellOrder.takerAssetData !== buyOrder.makerAssetData
        ) {
            throw new Error(DutchAuctionWrapperError.AssetDataMismatch);
        }
        // validate transaction
        if (orderTransactionOpts.shouldValidate) {
            await this._dutchAuctionContract.matchOrders.callAsync(
                buyOrder,
                sellOrder,
                buyOrder.signature,
github 0xProject / 0x-monorepo / packages / contract-wrappers / src / contract_wrappers / dutch_auction_wrapper.ts View on Github external
public async matchOrdersAsync(
        buyOrder: SignedOrder,
        sellOrder: SignedOrder,
        takerAddress: string,
        orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
    ): Promise {
        // type assertions
        assert.doesConformToSchema('buyOrder', buyOrder, schemas.signedOrderSchema);
        assert.doesConformToSchema('sellOrder', sellOrder, schemas.signedOrderSchema);
        await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
        assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]);
        const normalizedTakerAddress = takerAddress.toLowerCase();
        // other assertions
        if (
            sellOrder.makerAssetData !== buyOrder.takerAssetData ||
            sellOrder.takerAssetData !== buyOrder.makerAssetData
        ) {
            throw new Error(DutchAuctionWrapperError.AssetDataMismatch);
        }
        // validate transaction
        if (orderTransactionOpts.shouldValidate) {
            await this._dutchAuctionContract.matchOrders.callAsync(
                buyOrder,
                sellOrder,
github 0xProject / 0x-monorepo / packages / contract-wrappers / src / utils / transaction_encoder.ts View on Github external
public fillOrderNoThrowTx(signedOrder: SignedOrder, takerAssetFillAmount: BigNumber): string {
        assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
        assert.isValidBaseUnitAmount('takerAssetFillAmount', takerAssetFillAmount);
        const abiEncodedData = this._getExchangeContract().fillOrderNoThrow.getABIEncodedTransactionData(
            signedOrder,
            takerAssetFillAmount,
            signedOrder.signature,
        );
        return abiEncodedData;
    }
    /**
github 0xProject / 0x-monorepo / packages / contract-wrappers / src / contract_wrappers / exchange_wrapper.ts View on Github external
public async validateOrderFillableOrThrowAsync(
        signedOrder: SignedOrder,
        opts: ValidateOrderFillableOpts = {},
    ): Promise {
        assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
        assert.doesConformToSchema('opts', opts, validateOrderFillableOptsSchema);

        const balanceAllowanceFetcher = new AssetBalanceAndProxyAllowanceFetcher(
            this._erc20TokenWrapper,
            this._erc721TokenWrapper,
            BlockParamLiteral.Latest,
        );
        const balanceAllowanceStore = new BalanceAndProxyAllowanceLazyStore(balanceAllowanceFetcher);
        const exchangeTradeSimulator = new ExchangeTransferSimulator(balanceAllowanceStore);
        const filledCancelledFetcher = new OrderFilledCancelledFetcher(this, BlockParamLiteral.Latest);

        let fillableTakerAssetAmount;
        const shouldValidateRemainingOrderAmountIsFillable =
            opts.validateRemainingOrderAmountIsFillable === undefined
                ? true
                : opts.validateRemainingOrderAmountIsFillable;
github 0xProject / 0x-monorepo / packages / connect / src / http_client.ts View on Github external
public async submitOrderAsync(signedOrder: SignedOrder, requestOpts?: RequestOpts): Promise {
        assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
        const httpRequestOpts = {
            params: requestOpts,
            payload: signedOrder,
        };
        await this._requestAsync('/order', HttpRequestType.Post, httpRequestOpts);
    }
    private async _requestAsync(
github 0xProject / 0x-monorepo / packages / contract-wrappers / src / contract_wrappers / order_validator_wrapper.ts View on Github external
public async getOrderAndTraderInfoAsync(order: SignedOrder, takerAddress: string): Promise {
        assert.doesConformToSchema('order', order, schemas.signedOrderSchema);
        assert.isETHAddressHex('takerAddress', takerAddress);
        const orderAndTraderInfo = await this._orderValidatorContract.getOrderAndTraderInfo.callAsync(
            order,
            takerAddress,
        );
        const result = {
            orderInfo: orderAndTraderInfo[0],
            traderInfo: orderAndTraderInfo[1],
        };
        return result;
    }
    /**
github 0xProject / 0x-monorepo / packages / order-watcher / src / order_watcher / order_watcher.ts View on Github external
public async addOrderAsync(signedOrder: SignedOrder): Promise {
        assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
        const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
        await assert.isValidSignatureAsync(this._provider, orderHash, signedOrder.signature, signedOrder.makerAddress);

        const expirationUnixTimestampMs = signedOrder.expirationTimeSeconds.times(MILLISECONDS_IN_A_SECOND);
        this._expirationWatcher.addOrder(orderHash, expirationUnixTimestampMs);

        this._orderByOrderHash[orderHash] = signedOrder;
        this._dependentOrderHashesTracker.addToDependentOrderHashes(signedOrder);

        const orderAssetDatas = [signedOrder.makerAssetData, signedOrder.takerAssetData];
        _.each(orderAssetDatas, assetData => this._addAssetDataToAbiDecoder(assetData));
    }
    /**
github 0xProject / 0x-monorepo / packages / contract-wrappers / src / contract_wrappers / exchange_wrapper.ts View on Github external
public async matchOrdersAsync(
        leftSignedOrder: SignedOrder,
        rightSignedOrder: SignedOrder,
        takerAddress: string,
        orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
    ): Promise {
        assert.doesConformToSchema('leftSignedOrder', leftSignedOrder, schemas.signedOrderSchema);
        assert.doesConformToSchema('rightSignedOrder', rightSignedOrder, schemas.signedOrderSchema);
        await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
        assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]);
        const normalizedTakerAddress = takerAddress.toLowerCase();
        if (
            rightSignedOrder.makerAssetData !== leftSignedOrder.takerAssetData ||
            rightSignedOrder.takerAssetData !== leftSignedOrder.makerAssetData
        ) {
            throw new Error(ExchangeWrapperError.AssetDataMismatch);
        }
        if (orderTransactionOpts.shouldValidate) {
            await this._exchangeContract.matchOrders.callAsync(
                leftSignedOrder,
                rightSignedOrder,
                leftSignedOrder.signature,
                rightSignedOrder.signature,
                {