Update createFactory to accept one createOrderOpts param to encompass all optional params
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
"version": "1.0.1-rc.3",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Updated to use latest orderFactory interface",
|
||||
"note":
|
||||
"Updated to use latest orderFactory interface, fixed `feeRecipient` spelling error in public interface",
|
||||
"pr": 936
|
||||
}
|
||||
]
|
||||
|
||||
@@ -61,7 +61,7 @@ export class FillScenarios {
|
||||
makerAddress: string,
|
||||
takerAddress: string,
|
||||
fillableAmount: BigNumber,
|
||||
feeRecepientAddress: string,
|
||||
feeRecipientAddress: string,
|
||||
expirationTimeSeconds?: BigNumber,
|
||||
): Promise<SignedOrder> {
|
||||
return this._createAsymmetricFillableSignedOrderWithFeesAsync(
|
||||
@@ -73,7 +73,7 @@ export class FillScenarios {
|
||||
takerAddress,
|
||||
fillableAmount,
|
||||
fillableAmount,
|
||||
feeRecepientAddress,
|
||||
feeRecipientAddress,
|
||||
expirationTimeSeconds,
|
||||
);
|
||||
}
|
||||
@@ -88,7 +88,7 @@ export class FillScenarios {
|
||||
): Promise<SignedOrder> {
|
||||
const makerFee = new BigNumber(0);
|
||||
const takerFee = new BigNumber(0);
|
||||
const feeRecepientAddress = constants.NULL_ADDRESS;
|
||||
const feeRecipientAddress = constants.NULL_ADDRESS;
|
||||
return this._createAsymmetricFillableSignedOrderWithFeesAsync(
|
||||
makerAssetData,
|
||||
takerAssetData,
|
||||
@@ -98,7 +98,7 @@ export class FillScenarios {
|
||||
takerAddress,
|
||||
makerFillableAmount,
|
||||
takerFillableAmount,
|
||||
feeRecepientAddress,
|
||||
feeRecipientAddress,
|
||||
expirationTimeSeconds,
|
||||
);
|
||||
}
|
||||
@@ -148,7 +148,7 @@ export class FillScenarios {
|
||||
takerAddress: string,
|
||||
makerFillableAmount: BigNumber,
|
||||
takerFillableAmount: BigNumber,
|
||||
feeRecepientAddress: string,
|
||||
feeRecipientAddress: string,
|
||||
expirationTimeSeconds?: BigNumber,
|
||||
): Promise<SignedOrder> {
|
||||
const decodedMakerAssetData = assetDataUtils.decodeAssetDataOrThrow(makerAssetData);
|
||||
@@ -199,12 +199,14 @@ export class FillScenarios {
|
||||
takerFillableAmount,
|
||||
takerAssetData,
|
||||
this._exchangeAddress,
|
||||
takerAddress,
|
||||
senderAddress,
|
||||
makerFee,
|
||||
takerFee,
|
||||
feeRecepientAddress,
|
||||
expirationTimeSeconds,
|
||||
{
|
||||
takerAddress,
|
||||
senderAddress,
|
||||
makerFee,
|
||||
takerFee,
|
||||
feeRecipientAddress,
|
||||
expirationTimeSeconds,
|
||||
},
|
||||
);
|
||||
return signedOrder;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
"version": "1.0.1-rc.3",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Added a synchronous `createOrder` method in `orderFactory`",
|
||||
"note":
|
||||
"Added a synchronous `createOrder` method in `orderFactory`, updated public interfaces to support some optional parameters",
|
||||
"pr": 936
|
||||
}
|
||||
]
|
||||
|
||||
@@ -10,6 +10,16 @@ import { generatePseudoRandomSalt } from './salt';
|
||||
import { ecSignOrderHashAsync } from './signature_utils';
|
||||
import { MessagePrefixType } from './types';
|
||||
|
||||
export interface CreateOrderOpts {
|
||||
takerAddress?: string;
|
||||
senderAddress?: string;
|
||||
makerFee?: BigNumber;
|
||||
takerFee?: BigNumber;
|
||||
feeRecipientAddress?: string;
|
||||
salt?: BigNumber;
|
||||
expirationTimeSeconds?: BigNumber;
|
||||
}
|
||||
|
||||
export const orderFactory = {
|
||||
createOrder(
|
||||
makerAddress: string,
|
||||
@@ -18,28 +28,24 @@ export const orderFactory = {
|
||||
takerAssetAmount: BigNumber,
|
||||
takerAssetData: string,
|
||||
exchangeAddress: string,
|
||||
takerAddress: string = constants.NULL_ADDRESS,
|
||||
senderAddress: string = constants.NULL_ADDRESS,
|
||||
makerFee: BigNumber = constants.ZERO_AMOUNT,
|
||||
takerFee: BigNumber = constants.ZERO_AMOUNT,
|
||||
feeRecipientAddress: string = constants.NULL_ADDRESS,
|
||||
salt: BigNumber = generatePseudoRandomSalt(),
|
||||
expirationTimeSeconds: BigNumber = constants.INFINITE_TIMESTAMP_SEC,
|
||||
createOrderOpts: CreateOrderOpts = generateDefaultCreateOrderOpts(),
|
||||
): Order {
|
||||
const defaultCreateOrderOpts = generateDefaultCreateOrderOpts();
|
||||
const order = {
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
senderAddress,
|
||||
makerFee,
|
||||
takerFee,
|
||||
makerAssetAmount,
|
||||
takerAssetAmount,
|
||||
makerAssetData,
|
||||
takerAssetData,
|
||||
salt,
|
||||
exchangeAddress,
|
||||
feeRecipientAddress,
|
||||
expirationTimeSeconds,
|
||||
takerAddress: createOrderOpts.takerAddress || defaultCreateOrderOpts.takerAddress,
|
||||
senderAddress: createOrderOpts.senderAddress || defaultCreateOrderOpts.senderAddress,
|
||||
makerFee: createOrderOpts.makerFee || defaultCreateOrderOpts.makerFee,
|
||||
takerFee: createOrderOpts.takerFee || defaultCreateOrderOpts.takerFee,
|
||||
feeRecipientAddress: createOrderOpts.feeRecipientAddress || defaultCreateOrderOpts.feeRecipientAddress,
|
||||
salt: createOrderOpts.salt || defaultCreateOrderOpts.salt,
|
||||
expirationTimeSeconds:
|
||||
createOrderOpts.expirationTimeSeconds || defaultCreateOrderOpts.expirationTimeSeconds,
|
||||
};
|
||||
return order;
|
||||
},
|
||||
@@ -51,13 +57,7 @@ export const orderFactory = {
|
||||
takerAssetAmount: BigNumber,
|
||||
takerAssetData: string,
|
||||
exchangeAddress: string,
|
||||
takerAddress?: string,
|
||||
senderAddress?: string,
|
||||
makerFee?: BigNumber,
|
||||
takerFee?: BigNumber,
|
||||
feeRecipientAddress?: string,
|
||||
salt?: BigNumber,
|
||||
expirationTimeSeconds?: BigNumber,
|
||||
createOrderOpts?: CreateOrderOpts,
|
||||
): Promise<SignedOrder> {
|
||||
const order = orderFactory.createOrder(
|
||||
makerAddress,
|
||||
@@ -66,13 +66,7 @@ export const orderFactory = {
|
||||
takerAssetAmount,
|
||||
takerAssetData,
|
||||
exchangeAddress,
|
||||
takerAddress,
|
||||
senderAddress,
|
||||
makerFee,
|
||||
takerFee,
|
||||
feeRecipientAddress,
|
||||
salt,
|
||||
expirationTimeSeconds,
|
||||
createOrderOpts,
|
||||
);
|
||||
const orderHash = orderHashUtils.getOrderHashHex(order);
|
||||
const messagePrefixOpts = {
|
||||
@@ -86,6 +80,26 @@ export const orderFactory = {
|
||||
},
|
||||
};
|
||||
|
||||
function generateDefaultCreateOrderOpts(): {
|
||||
takerAddress: string;
|
||||
senderAddress: string;
|
||||
makerFee: BigNumber;
|
||||
takerFee: BigNumber;
|
||||
feeRecipientAddress: string;
|
||||
salt: BigNumber;
|
||||
expirationTimeSeconds: BigNumber;
|
||||
} {
|
||||
return {
|
||||
takerAddress: constants.NULL_ADDRESS,
|
||||
senderAddress: constants.NULL_ADDRESS,
|
||||
makerFee: constants.ZERO_AMOUNT,
|
||||
takerFee: constants.ZERO_AMOUNT,
|
||||
feeRecipientAddress: constants.NULL_ADDRESS,
|
||||
salt: generatePseudoRandomSalt(),
|
||||
expirationTimeSeconds: constants.INFINITE_TIMESTAMP_SEC,
|
||||
};
|
||||
}
|
||||
|
||||
function getVRSHexString(ecSignature: ECSignature): string {
|
||||
const ETH_SIGN_SIGNATURE_TYPE = '03';
|
||||
const vrs = `${intToHex(ecSignature.v)}${ethUtil.stripHexPrefix(ecSignature.r)}${ethUtil.stripHexPrefix(
|
||||
|
||||
Reference in New Issue
Block a user