Cherry-pick changes from feat/dev-utils/dydx-bridge-validation
This commit is contained in:
@@ -3,27 +3,13 @@ import { SignedZeroExTransaction } from '@0x/types';
|
||||
import { hexUtils, signTypedDataUtils } from '@0x/utils';
|
||||
|
||||
export const hashUtils = {
|
||||
async getApprovalHashBufferAsync(
|
||||
transaction: SignedZeroExTransaction,
|
||||
verifyingContract: string,
|
||||
txOrigin: string,
|
||||
): Promise<Buffer> {
|
||||
const typedData = await eip712Utils.createCoordinatorApprovalTypedDataAsync(
|
||||
transaction,
|
||||
verifyingContract,
|
||||
txOrigin,
|
||||
);
|
||||
getApprovalHashBuffer(transaction: SignedZeroExTransaction, verifyingContract: string, txOrigin: string): Buffer {
|
||||
const typedData = eip712Utils.createCoordinatorApprovalTypedData(transaction, verifyingContract, txOrigin);
|
||||
const hashBuffer = signTypedDataUtils.generateTypedDataHash(typedData);
|
||||
return hashBuffer;
|
||||
},
|
||||
async getApprovalHashHexAsync(
|
||||
transaction: SignedZeroExTransaction,
|
||||
verifyingContract: string,
|
||||
txOrigin: string,
|
||||
): Promise<string> {
|
||||
const hashHex = hexUtils.concat(
|
||||
await hashUtils.getApprovalHashBufferAsync(transaction, verifyingContract, txOrigin),
|
||||
);
|
||||
getApprovalHashHex(transaction: SignedZeroExTransaction, verifyingContract: string, txOrigin: string): string {
|
||||
const hashHex = hexUtils.concat(hashUtils.getApprovalHashBuffer(transaction, verifyingContract, txOrigin));
|
||||
return hashHex;
|
||||
},
|
||||
};
|
||||
|
Reference in New Issue
Block a user