Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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')}`,
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,
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;
}
}
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;
},
/**