How to use the @0x/types.SignatureType.EthSign function in @0x/types

To help you get started, we’ve selected a few @0x/types 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 / contracts / test-utils / src / order_factory.ts View on Github external
public async newSignedOrderAsync(
        customOrderParams: Partial = {},
        signatureType: SignatureType = SignatureType.EthSign,
    ): Promise {
        const fifteenMinutesInSeconds = 15 * 60;
        const currentBlockTimestamp = await getLatestBlockTimestampAsync();
        const order = ({
            takerAddress: constants.NULL_ADDRESS,
            senderAddress: constants.NULL_ADDRESS,
            expirationTimeSeconds: new BigNumber(currentBlockTimestamp).plus(fifteenMinutesInSeconds),
            salt: generatePseudoRandomSalt(),
            ...this._defaultOrderParams,
            ...customOrderParams,
        } as any) as Order;
        const orderHashBuff = orderHashUtils.getOrderHashBuffer(order);
        const signature = signingUtils.signMessage(orderHashBuff, this._privateKey, signatureType);
        const signedOrder = {
            ...order,
            signature: `0x${signature.toString('hex')}`,
github 0xProject / 0x-monorepo / contracts / test-utils / src / transaction_factory.ts View on Github external
public async newSignedTransactionAsync(
        customTransactionParams: Partial,
        signatureType: SignatureType = SignatureType.EthSign,
    ): Promise {
        if (customTransactionParams.data === undefined) {
            throw new Error('Error: ZeroExTransaction data field must be supplied');
        }
        const tenMinutesInSeconds = 10 * 60;
        const currentBlockTimestamp = await getLatestBlockTimestampAsync();
        const salt = generatePseudoRandomSalt();
        const signerAddress = `0x${this._signerBuff.toString('hex')}`;
        const transaction = {
            salt,
            signerAddress,
            data: customTransactionParams.data,
            expirationTimeSeconds: new BigNumber(currentBlockTimestamp).plus(tenMinutesInSeconds),
            gasPrice: new BigNumber(constants.DEFAULT_GAS_PRICE),
            domain: {
                verifyingContract: this._exchangeAddress,
github 0xProject / 0x-monorepo / contracts / coordinator / src / approval_factory.ts View on Github external
public async newSignedApprovalAsync(
        transaction: SignedZeroExTransaction,
        txOrigin: string,
        signatureType: SignatureType = SignatureType.EthSign,
    ): Promise {
        const approvalHashBuff = await hashUtils.getApprovalHashBufferAsync(
            transaction,
            this._verifyingContractAddress,
            txOrigin,
        );
        const signatureBuff = signingUtils.signMessage(approvalHashBuff, this._privateKey, signatureType);
        const signedApproval = {
            txOrigin,
            transaction,
            signature: hexUtils.concat(signatureBuff),
        };
        return signedApproval;
    }
}
github 0xProject / 0x-monorepo / packages / order-utils / src / signature_utils.ts View on Github external
convertECSignatureToSignatureHex(ecSignature: ECSignature): string {
        const signatureBuffer = Buffer.concat([
            ethUtil.toBuffer(ecSignature.v),
            ethUtil.toBuffer(ecSignature.r),
            ethUtil.toBuffer(ecSignature.s),
        ]);
        const signatureHex = `0x${signatureBuffer.toString('hex')}`;
        const signatureWithType = signatureUtils.convertToSignatureWithType(signatureHex, SignatureType.EthSign);
        return signatureWithType;
    },
    /**