aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src/utils/transaction_factory.ts
diff options
context:
space:
mode:
authorJacob Evans <jacob@dekz.net>2018-06-18 18:59:23 +0800
committerJacob Evans <jacob@dekz.net>2018-06-18 19:46:05 +0800
commitd4ee0e862297c16f8ee62efccd31f1193052c64e (patch)
tree4b3f8a4a75dfb9ed73bccc850a01ac789363c830 /packages/contracts/src/utils/transaction_factory.ts
parenta8d328bfc926a62d61830334fadc43fc5d013e0e (diff)
downloaddexon-sol-tools-d4ee0e862297c16f8ee62efccd31f1193052c64e.tar
dexon-sol-tools-d4ee0e862297c16f8ee62efccd31f1193052c64e.tar.gz
dexon-sol-tools-d4ee0e862297c16f8ee62efccd31f1193052c64e.tar.bz2
dexon-sol-tools-d4ee0e862297c16f8ee62efccd31f1193052c64e.tar.lz
dexon-sol-tools-d4ee0e862297c16f8ee62efccd31f1193052c64e.tar.xz
dexon-sol-tools-d4ee0e862297c16f8ee62efccd31f1193052c64e.tar.zst
dexon-sol-tools-d4ee0e862297c16f8ee62efccd31f1193052c64e.zip
Rebase and update feedback
Cache the domain separator data with address this Use the EIP712Types enum for types everywhere Rename EIP712 struct ExecuteTransaction to ZeroExTransaction
Diffstat (limited to 'packages/contracts/src/utils/transaction_factory.ts')
-rw-r--r--packages/contracts/src/utils/transaction_factory.ts16
1 files changed, 8 insertions, 8 deletions
diff --git a/packages/contracts/src/utils/transaction_factory.ts b/packages/contracts/src/utils/transaction_factory.ts
index bb15a0309..c0a32b83a 100644
--- a/packages/contracts/src/utils/transaction_factory.ts
+++ b/packages/contracts/src/utils/transaction_factory.ts
@@ -1,16 +1,16 @@
-import { crypto, EIP712Schema, EIP712Utils, generatePseudoRandomSalt } from '@0xproject/order-utils';
+import { crypto, EIP712Schema, EIP712Types, EIP712Utils, generatePseudoRandomSalt } from '@0xproject/order-utils';
import { SignatureType } from '@0xproject/types';
import * as ethUtil from 'ethereumjs-util';
import { signingUtils } from './signing_utils';
import { SignedTransaction } from './types';
-const EIP712_EXECUTE_TRANSACTION_SCHEMA: EIP712Schema = {
- name: 'ExecuteTransaction',
+const EIP712_ZEROEX_TRANSACTION_SCHEMA: EIP712Schema = {
+ name: 'ZeroExTransaction',
parameters: [
- { name: 'salt', type: 'uint256' },
- { name: 'signer', type: 'address' },
- { name: 'data', type: 'bytes' },
+ { name: 'salt', type: EIP712Types.Uint256 },
+ { name: 'signer', type: EIP712Types.Address },
+ { name: 'data', type: EIP712Types.Bytes },
],
};
@@ -24,7 +24,7 @@ export class TransactionFactory {
this._signerBuff = ethUtil.privateToAddress(this._privateKey);
}
public newSignedTransaction(data: string, signatureType: SignatureType = SignatureType.EthSign): SignedTransaction {
- const executeTransactionSchemaHashBuff = EIP712Utils.compileSchema(EIP712_EXECUTE_TRANSACTION_SCHEMA);
+ const executeTransactionSchemaHashBuff = EIP712Utils.compileSchema(EIP712_ZEROEX_TRANSACTION_SCHEMA);
const salt = generatePseudoRandomSalt();
const signer = `0x${this._signerBuff.toString('hex')}`;
const executeTransactionData = {
@@ -33,7 +33,7 @@ export class TransactionFactory {
data,
};
const executeTransactionHashBuff = EIP712Utils.structHash(
- EIP712_EXECUTE_TRANSACTION_SCHEMA,
+ EIP712_ZEROEX_TRANSACTION_SCHEMA,
executeTransactionData,
);
const txHash = EIP712Utils.createEIP712Message(executeTransactionHashBuff, this._exchangeAddress);