* remove assetDataUtils everywhere * export IAssetDataContract from @0x/contract-wrappers to allow @0x/instant to decode asset data synchronously * export generic function `decodeAssetDataOrThrow` and add ERC20Bridge support * export `hexUtils` from order-utils instead of contracts-test-utils
30 lines
995 B
TypeScript
30 lines
995 B
TypeScript
import { eip712Utils } from '@0x/order-utils';
|
|
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,
|
|
);
|
|
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),
|
|
);
|
|
return hashHex;
|
|
},
|
|
};
|