diff options
author | Jacob Evans <jacob@dekz.net> | 2018-06-05 09:40:07 +0800 |
---|---|---|
committer | Jacob Evans <jacob@dekz.net> | 2018-06-06 05:08:04 +0800 |
commit | a59e9f024e76122c76600d938b565ea47938b287 (patch) | |
tree | 749c1485efeca041aa319e64af64aedd579dd8d6 /packages/contracts/src/utils/transaction_factory.ts | |
parent | 4670cc1a5f04d61045a82b4a3bbcf56e009afd56 (diff) | |
download | dexon-sol-tools-a59e9f024e76122c76600d938b565ea47938b287.tar dexon-sol-tools-a59e9f024e76122c76600d938b565ea47938b287.tar.gz dexon-sol-tools-a59e9f024e76122c76600d938b565ea47938b287.tar.bz2 dexon-sol-tools-a59e9f024e76122c76600d938b565ea47938b287.tar.lz dexon-sol-tools-a59e9f024e76122c76600d938b565ea47938b287.tar.xz dexon-sol-tools-a59e9f024e76122c76600d938b565ea47938b287.tar.zst dexon-sol-tools-a59e9f024e76122c76600d938b565ea47938b287.zip |
Update Order utils to use eip712
Diffstat (limited to 'packages/contracts/src/utils/transaction_factory.ts')
-rw-r--r-- | packages/contracts/src/utils/transaction_factory.ts | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/packages/contracts/src/utils/transaction_factory.ts b/packages/contracts/src/utils/transaction_factory.ts index 1c1029d62..7aaf3691c 100644 --- a/packages/contracts/src/utils/transaction_factory.ts +++ b/packages/contracts/src/utils/transaction_factory.ts @@ -1,14 +1,9 @@ -import { crypto, generatePseudoRandomSalt } from '@0xproject/order-utils'; +import { crypto, EIP712Schema, EIP712Utils, generatePseudoRandomSalt } from '@0xproject/order-utils'; import { SignatureType } from '@0xproject/types'; -import { BigNumber } from '@0xproject/utils'; import * as ethUtil from 'ethereumjs-util'; -import * as _ from 'lodash'; -import { crypto } from './crypto'; -import { EIP712Utils } from './eip712_utils'; -import { orderUtils } from './order_utils'; import { signingUtils } from './signing_utils'; -import { EIP712Schema, SignatureType, SignedTransaction } from './types'; +import { SignedTransaction } from './types'; const EIP712_EXECUTE_TRANSACTION_SCHEMA: EIP712Schema = { name: 'ExecuteTransaction', @@ -30,20 +25,15 @@ export class TransactionFactory { } public newSignedTransaction(data: string, signatureType: SignatureType = SignatureType.EthSign): SignedTransaction { const executeTransactionSchemaHashBuff = EIP712Utils.compileSchema(EIP712_EXECUTE_TRANSACTION_SCHEMA); - const salt = generatePseudoRandomSalt(); const dataHash = crypto.solSHA3([ethUtil.toBuffer(data)]); - const executeTransactionDataHash = crypto.solSHA3([ executeTransactionSchemaHashBuff, salt, EIP712Utils.pad32Buffer(this._signerBuff), dataHash, ]); - - const executeTransactionMessageHex = `0x${executeTransactionDataHash.toString('hex')}`; - - const txHash = EIP712Utils.createEIP712Message(executeTransactionMessageHex, this._exchangeAddress); + const txHash = EIP712Utils.createEIP712Message(executeTransactionDataHash, this._exchangeAddress); const signature = signingUtils.signMessage(txHash, this._privateKey, signatureType); const signedTx = { exchangeAddress: this._exchangeAddress, |