Update coordinator tests to comply with mixed EIP712 domains.
This commit is contained in:
@@ -1,35 +1,43 @@
|
||||
import { SignedZeroExTransaction } from '@0x/types';
|
||||
import { signingUtils } from '@0x/contracts-test-utils';
|
||||
import { SignatureType, SignedZeroExTransaction } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import * as ethUtil from 'ethereumjs-util';
|
||||
|
||||
import { CoordinatorSignatureType, hashUtils, SignedCoordinatorApproval, signingUtils } from './index';
|
||||
import { hashUtils, SignedCoordinatorApproval } from './index';
|
||||
|
||||
export class ApprovalFactory {
|
||||
private readonly _privateKey: Buffer;
|
||||
private readonly _verifyingContractAddress: string;
|
||||
constructor(privateKey: Buffer, verifyingContractAddress: string) {
|
||||
|
||||
constructor(
|
||||
privateKey: Buffer,
|
||||
verifyingContractAddress: string) {
|
||||
|
||||
this._privateKey = privateKey;
|
||||
this._verifyingContractAddress = verifyingContractAddress;
|
||||
}
|
||||
|
||||
public newSignedApproval(
|
||||
transaction: SignedZeroExTransaction,
|
||||
txOrigin: string,
|
||||
approvalExpirationTimeSeconds: BigNumber,
|
||||
signatureType: CoordinatorSignatureType = CoordinatorSignatureType.EthSign,
|
||||
signatureType: SignatureType = SignatureType.EthSign,
|
||||
): SignedCoordinatorApproval {
|
||||
const coordinatorTransaction = {
|
||||
...transaction,
|
||||
verifyingContractAddress: this._verifyingContractAddress,
|
||||
};
|
||||
|
||||
const approvalHashBuff = hashUtils.getApprovalHashBuffer(
|
||||
coordinatorTransaction,
|
||||
transaction,
|
||||
this._verifyingContractAddress,
|
||||
txOrigin,
|
||||
approvalExpirationTimeSeconds,
|
||||
);
|
||||
const signatureBuff = signingUtils.signMessage(approvalHashBuff, this._privateKey, signatureType);
|
||||
const signatureBuff = signingUtils.signMessage(
|
||||
approvalHashBuff,
|
||||
this._privateKey,
|
||||
signatureType,
|
||||
);
|
||||
const signedApproval = {
|
||||
txOrigin,
|
||||
transaction: coordinatorTransaction,
|
||||
transaction: transaction,
|
||||
approvalExpirationTimeSeconds,
|
||||
signature: ethUtil.addHexPrefix(signatureBuff.toString('hex')),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user