* update abi-gen with new method interfaces * wip: get all packages to build * wip: get all packages to build * Fix two contract wrapper calls * Export necessary types part of the contract wrapper public interfaces * Revive and fix wrapper_unit_tests * Remove duplicate type * Fix lib_exchange_rich_error_decoder tests * Fix remaining test failures in contracts-* packages * Prettier fixes * remove transactionHelper * lint and update changelogs * Fix prettier * Revert changes to reference docs * Add back changelog already published and add revert changelog entry * Add missing CHANGELOG entries * Add missing comma * Update mesh-rpc-client dep * Update Mesh RPC logic in @0x/orderbook to v6.0.1-beta * Align package versions
54 lines
2.0 KiB
TypeScript
54 lines
2.0 KiB
TypeScript
import { blockchainTests, constants, expect, randomAddress } from '@0x/contracts-test-utils';
|
|
import { transactionHashUtils } from '@0x/order-utils';
|
|
import { BigNumber } from '@0x/utils';
|
|
|
|
import { hashUtils } from '../src/hash_utils';
|
|
|
|
import { artifacts } from './artifacts';
|
|
|
|
import { CoordinatorContract } from './wrappers';
|
|
|
|
blockchainTests.resets('Libs tests', env => {
|
|
let coordinatorContract: CoordinatorContract;
|
|
let chainId: number;
|
|
const exchangeAddress = randomAddress();
|
|
|
|
before(async () => {
|
|
chainId = await env.getChainIdAsync();
|
|
coordinatorContract = await CoordinatorContract.deployFrom0xArtifactAsync(
|
|
artifacts.Coordinator,
|
|
env.provider,
|
|
env.txDefaults,
|
|
artifacts,
|
|
exchangeAddress,
|
|
new BigNumber(chainId),
|
|
);
|
|
});
|
|
|
|
describe('getApprovalHash', () => {
|
|
it('should return the correct approval hash', async () => {
|
|
const signedTx = {
|
|
salt: constants.ZERO_AMOUNT,
|
|
gasPrice: constants.ZERO_AMOUNT,
|
|
expirationTimeSeconds: constants.ZERO_AMOUNT,
|
|
signerAddress: constants.NULL_ADDRESS,
|
|
data: '0x1234',
|
|
signature: '0x5678',
|
|
domain: {
|
|
verifyingContract: exchangeAddress,
|
|
chainId,
|
|
},
|
|
};
|
|
const txOrigin = constants.NULL_ADDRESS;
|
|
const approval = {
|
|
txOrigin,
|
|
transactionHash: transactionHashUtils.getTransactionHashHex(signedTx),
|
|
transactionSignature: signedTx.signature,
|
|
};
|
|
const expectedApprovalHash = hashUtils.getApprovalHashHex(signedTx, coordinatorContract.address, txOrigin);
|
|
const approvalHash = await coordinatorContract.getCoordinatorApprovalHash(approval).callAsync();
|
|
expect(expectedApprovalHash).to.eq(approvalHash);
|
|
});
|
|
});
|
|
});
|