aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contract-wrappers/src
diff options
context:
space:
mode:
authorJacob Evans <jacob@dekz.net>2018-10-05 09:45:53 +0800
committerJacob Evans <jacob@dekz.net>2018-10-05 15:12:17 +0800
commit75d274f330dc0c18577e764ca77ffb36d5a3f27e (patch)
tree9a70714a89783dfe58ffa002d39f3967de957bdc /packages/contract-wrappers/src
parent6e462b7dba61611a5347c9aa181d4ae69294d7af (diff)
downloaddexon-0x-contracts-75d274f330dc0c18577e764ca77ffb36d5a3f27e.tar.gz
dexon-0x-contracts-75d274f330dc0c18577e764ca77ffb36d5a3f27e.tar.zst
dexon-0x-contracts-75d274f330dc0c18577e764ca77ffb36d5a3f27e.zip
Return SignedOrder from signing utils.
Create a helper back in EIP712Utils for code cleanup. Moved constants in order-utils into the constants object
Diffstat (limited to 'packages/contract-wrappers/src')
-rw-r--r--packages/contract-wrappers/src/utils/transaction_encoder.ts27
1 files changed, 3 insertions, 24 deletions
diff --git a/packages/contract-wrappers/src/utils/transaction_encoder.ts b/packages/contract-wrappers/src/utils/transaction_encoder.ts
index 1800f49ad..d9735778e 100644
--- a/packages/contract-wrappers/src/utils/transaction_encoder.ts
+++ b/packages/contract-wrappers/src/utils/transaction_encoder.ts
@@ -1,5 +1,5 @@
import { schemas } from '@0xproject/json-schemas';
-import { EIP712_DOMAIN_NAME, EIP712_DOMAIN_SCHEMA, EIP712_DOMAIN_VERSION } from '@0xproject/order-utils';
+import { eip712Utils } from '@0xproject/order-utils';
import { Order, SignedOrder } from '@0xproject/types';
import { BigNumber, signTypedDataUtils } from '@0xproject/utils';
import _ = require('lodash');
@@ -8,15 +8,6 @@ import { ExchangeContract } from '../contract_wrappers/generated/exchange';
import { assert } from './assert';
-const EIP712_ZEROEX_TRANSACTION_SCHEMA = {
- name: 'ZeroExTransaction',
- parameters: [
- { name: 'salt', type: 'uint256' },
- { name: 'signerAddress', type: 'address' },
- { name: 'data', type: 'bytes' },
- ],
-};
-
/**
* Transaction Encoder. Transaction messages exist for the purpose of calling methods on the Exchange contract
* in the context of another address. For example, UserA can encode and sign a fillOrder transaction and UserB
@@ -37,23 +28,11 @@ export class TransactionEncoder {
public getTransactionHex(data: string, salt: BigNumber, signerAddress: string): string {
const exchangeAddress = this._getExchangeContract().address;
const executeTransactionData = {
- salt: salt.toString(),
+ salt,
signerAddress,
data,
};
- const typedData = {
- types: {
- EIP712Domain: EIP712_DOMAIN_SCHEMA.parameters,
- ZeroExTransaction: EIP712_ZEROEX_TRANSACTION_SCHEMA.parameters,
- },
- domain: {
- name: EIP712_DOMAIN_NAME,
- version: EIP712_DOMAIN_VERSION,
- verifyingContract: exchangeAddress,
- },
- message: executeTransactionData,
- primaryType: EIP712_ZEROEX_TRANSACTION_SCHEMA.name,
- };
+ const typedData = eip712Utils.createZeroExTransactionTypedData(executeTransactionData, exchangeAddress);
const eip712MessageBuffer = signTypedDataUtils.signTypedDataHash(typedData);
const messageHex = `0x${eip712MessageBuffer.toString('hex')}`;
return messageHex;