@@ -23,11 +23,7 @@ import * as Web3 from 'web3';
23
23
24
24
import { constants } from './constants' ;
25
25
import { paddedBufferForPrimitive , bufferObjectWithProperties } from './encoding' ;
26
- import { Address , Bytes32 , IssuanceOrder , SolidityTypes , TakerWalletOrder } from './types' ;
27
-
28
- interface Exchanges {
29
- [ exchangeId : string ] : TakerWalletOrder [ ] ;
30
- }
26
+ import { Address , Bytes32 , Exchanges , IssuanceOrder , SolidityTypes , TakerWalletOrder } from './types' ;
31
27
32
28
export function generateTimestamp ( minutes : number ) : BigNumber {
33
29
const timeToExpiration = minutes * 60 * 1000 ;
@@ -84,22 +80,23 @@ export function generateSerializedOrders(
84
80
const orderBuffer : Buffer [ ] = [ ] ;
85
81
// Sort exchange orders by exchange
86
82
const exchanges : Exchanges = {
87
- '1 ' : [ ] ,
88
- '2 ' : [ ] ,
89
- '3 ' : [ ] ,
83
+ 'ZERO_EX ' : [ ] ,
84
+ 'KYBER ' : [ ] ,
85
+ 'TAKER_WALLET ' : [ ] ,
90
86
} ;
91
87
_ . forEach ( orders , ( order : TakerWalletOrder ) => {
92
88
const { exchange } = order ;
93
- const exchangeOrders : object [ ] = exchanges [ exchange ] ;
89
+ const exchangeOrders : TakerWalletOrder [ ] = exchanges [ exchange ] ;
94
90
exchangeOrders . push ( order ) ;
95
91
} ) ;
96
92
// Loop through all exchange orders and create buffers
97
93
_ . forEach ( exchanges , ( exchangeOrders , key ) => {
98
- if ( key === '1' ) { // Todo: Replace with set-protocol-contracts constants
94
+ const exchangeKey : number = constants . EXCHANGES [ key ] ;
95
+ if ( exchangeKey === 1 ) {
99
96
// Handle Zero Ex
100
- } else if ( key === '2' ) {
97
+ } else if ( exchangeKey === 2 ) {
101
98
// Handle Kyber Network
102
- } else if ( key === '3' ) {
99
+ } else if ( exchangeKey === 3 ) {
103
100
orderBuffer . push ( generateTakerWalletOrdersBuffer ( makerTokenAddress , exchangeOrders , web3 ) ) ;
104
101
}
105
102
} ) ;
@@ -145,7 +142,7 @@ export function generateTakerWalletOrdersBuffer(
145
142
) : Buffer {
146
143
// Generate header for taker wallet order
147
144
const takerOrderHeader : Buffer [ ] = [
148
- paddedBufferForPrimitive ( 3 ) , // Todo: Replace with set-protocol-contracts constants
145
+ paddedBufferForPrimitive ( constants . EXCHANGES . KYBER ) ,
149
146
paddedBufferForPrimitive ( orders . length ) , // Include the number of orders as part of header
150
147
paddedBufferForPrimitive ( makerTokenAddress ) ,
151
148
paddedBufferForPrimitive ( 0 ) , // Taker wallet orders do not take any maker token to execute
0 commit comments