How to use the @0x/contracts-test-utils.transactionHashUtils.getTransactionHashHex function in @0x/contracts-test-utils

To help you get started, we’ve selected a few @0x/contracts-test-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-coordinator-server / ts / src / handlers.ts View on Github external
private async _handleFillsAsync(
        coordinatorOrders: Order[],
        txOrigin: string,
        signedTransaction: SignedZeroExTransaction,
        takerAssetFillAmounts: BigNumber[],
        chainId: number,
    ): Promise {
        await Handlers._validateFillsAllowedOrThrowAsync(signedTransaction, coordinatorOrders, takerAssetFillAmounts);

        const transactionHash = transactionHashUtils.getTransactionHashHex(signedTransaction);
        const fillRequestReceivedEvent = {
            type: EventTypes.FillRequestReceived,
            data: {
                transactionHash,
            },
        };
        this._broadcastCallback(fillRequestReceivedEvent, chainId);
        await utils.sleepAsync(this._configs.SELECTIVE_DELAY_MS); // Await selective delay

        // Check that still a valid fill request after selective delay
        if (this._configs.SELECTIVE_DELAY_MS !== 0) {
            await Handlers._validateFillsAllowedOrThrowAsync(
                signedTransaction,
                coordinatorOrders,
                takerAssetFillAmounts,
            );
github 0xProject / 0x-coordinator-server / ts / src / handlers.ts View on Github external
});
        if (_.isEmpty(coordinatorOrders)) {
            throw new ValidationError([
                {
                    field: 'signedTransaction.data',
                    code: ValidationErrorCodes.NoCoordinatorOrdersIncluded,
                    reason:
                        '0x transaction data does not include any orders involving this coordinators feeRecipientAddresses',
                },
            ]);
        }

        // 4. Enforce that a 0x transaction hasn't been used before. This prevents someone from requesting
        // the same transaction with a different `txOrigin` in an attempt to fill the order through an
        // alternative tx.origin entry-point.
        const transactionHash = transactionHashUtils.getTransactionHashHex(signedTransaction);
        const transactionIfExists = await transactionModel.findByHashAsync(transactionHash);
        if (transactionIfExists !== undefined) {
            throw new ValidationError([
                {
                    field: 'signedTransaction',
                    code: ValidationErrorCodes.TransactionAlreadyUsed,
                    reason: `A transaction can only be approved once. To request approval to perform the same actions, generate and sign an identical transaction with a different salt value.`,
                },
            ]);
        }

        // 5. Validate the 0x transaction signature
        const isValidSignature = await this._chainIdToContractWrappers[chainId].exchange
            .isValidHashSignature(transactionHash, signedTransaction.signerAddress, signedTransaction.signature)
            .callAsync();
        if (!isValidSignature) {