diff options
author | Amir Bandeali <abandeali1@gmail.com> | 2018-05-24 01:08:06 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2018-05-31 08:11:30 +0800 |
commit | e5b7e29113fb7c87f41e492abb1fd81247f0db46 (patch) | |
tree | bf51ba5949b1aa697d071780bf792445c153ea9f /packages/contracts/src/utils | |
parent | ecdd0ce9f2378a1ac271b9eb5661a6d37d6edf41 (diff) | |
download | dexon-0x-contracts-e5b7e29113fb7c87f41e492abb1fd81247f0db46.tar.gz dexon-0x-contracts-e5b7e29113fb7c87f41e492abb1fd81247f0db46.tar.zst dexon-0x-contracts-e5b7e29113fb7c87f41e492abb1fd81247f0db46.zip |
Add signer to txHash, allow approveValidator to be used with executeTransaction
Diffstat (limited to 'packages/contracts/src/utils')
-rw-r--r-- | packages/contracts/src/utils/transaction_factory.ts | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/packages/contracts/src/utils/transaction_factory.ts b/packages/contracts/src/utils/transaction_factory.ts index 941bff96d..65cdb3f89 100644 --- a/packages/contracts/src/utils/transaction_factory.ts +++ b/packages/contracts/src/utils/transaction_factory.ts @@ -7,26 +7,25 @@ import { signingUtils } from './signing_utils'; import { SignatureType, SignedTransaction } from './types'; export class TransactionFactory { - private _signer: string; + private _signerBuff: Buffer; private _exchangeAddress: string; private _privateKey: Buffer; constructor(privateKey: Buffer, exchangeAddress: string) { this._privateKey = privateKey; this._exchangeAddress = exchangeAddress; - const signerBuff = ethUtil.privateToAddress(this._privateKey); - this._signer = `0x${signerBuff.toString('hex')}`; + this._signerBuff = ethUtil.privateToAddress(this._privateKey); } public newSignedTransaction( data: string, signatureType: SignatureType = SignatureType.Ecrecover, ): SignedTransaction { const salt = generatePseudoRandomSalt(); - const txHash = crypto.solSHA3([this._exchangeAddress, salt, ethUtil.toBuffer(data)]); + const txHash = crypto.solSHA3([this._exchangeAddress, this._signerBuff, salt, ethUtil.toBuffer(data)]); const signature = signingUtils.signMessage(txHash, this._privateKey, signatureType); const signedTx = { exchangeAddress: this._exchangeAddress, salt, - signer: this._signer, + signer: `0x${this._signerBuff.toString('hex')}`, data, signature: `0x${signature.toString('hex')}`, }; |