Add createOrder with no signing to orderFactory
This commit is contained in:
@@ -1,4 +1,12 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "1.1.0-rc.2",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Added a synchronous `createOrder` method in `orderFactory`"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "1.0.1-rc.2",
|
"version": "1.0.1-rc.2",
|
||||||
"changes": [
|
"changes": [
|
||||||
|
|||||||
@@ -10,4 +10,5 @@ export const constants = {
|
|||||||
ERC721_ASSET_DATA_MINIMUM_BYTE_LENGTH: 53,
|
ERC721_ASSET_DATA_MINIMUM_BYTE_LENGTH: 53,
|
||||||
SELECTOR_LENGTH: 4,
|
SELECTOR_LENGTH: 4,
|
||||||
BASE_16: 16,
|
BASE_16: 16,
|
||||||
|
INFINITE_TIMESTAMP_SEC: new BigNumber(2524604400), // Close to infinite
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
import { ECSignature, SignedOrder } from '@0xproject/types';
|
import { ECSignature, Order, SignedOrder } from '@0xproject/types';
|
||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
import { Provider } from 'ethereum-types';
|
import { Provider } from 'ethereum-types';
|
||||||
import * as ethUtil from 'ethereumjs-util';
|
import * as ethUtil from 'ethereumjs-util';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
|
import { constants } from './constants';
|
||||||
import { orderHashUtils } from './order_hash';
|
import { orderHashUtils } from './order_hash';
|
||||||
import { generatePseudoRandomSalt } from './salt';
|
import { generatePseudoRandomSalt } from './salt';
|
||||||
import { ecSignOrderHashAsync } from './signature_utils';
|
import { ecSignOrderHashAsync } from './signature_utils';
|
||||||
import { MessagePrefixType } from './types';
|
import { MessagePrefixType } from './types';
|
||||||
|
|
||||||
export const orderFactory = {
|
export const orderFactory = {
|
||||||
async createSignedOrderAsync(
|
createOrder(
|
||||||
provider: Provider,
|
|
||||||
makerAddress: string,
|
makerAddress: string,
|
||||||
takerAddress: string,
|
takerAddress: string,
|
||||||
senderAddress: string,
|
senderAddress: string,
|
||||||
@@ -24,10 +24,9 @@ export const orderFactory = {
|
|||||||
exchangeAddress: string,
|
exchangeAddress: string,
|
||||||
feeRecipientAddress: string,
|
feeRecipientAddress: string,
|
||||||
expirationTimeSecondsIfExists?: BigNumber,
|
expirationTimeSecondsIfExists?: BigNumber,
|
||||||
): Promise<SignedOrder> {
|
): Order {
|
||||||
const defaultExpirationUnixTimestampSec = new BigNumber(2524604400); // Close to infinite
|
|
||||||
const expirationTimeSeconds = _.isUndefined(expirationTimeSecondsIfExists)
|
const expirationTimeSeconds = _.isUndefined(expirationTimeSecondsIfExists)
|
||||||
? defaultExpirationUnixTimestampSec
|
? constants.INFINITE_TIMESTAMP_SEC
|
||||||
: expirationTimeSecondsIfExists;
|
: expirationTimeSecondsIfExists;
|
||||||
const order = {
|
const order = {
|
||||||
makerAddress,
|
makerAddress,
|
||||||
@@ -44,6 +43,37 @@ export const orderFactory = {
|
|||||||
feeRecipientAddress,
|
feeRecipientAddress,
|
||||||
expirationTimeSeconds,
|
expirationTimeSeconds,
|
||||||
};
|
};
|
||||||
|
return order;
|
||||||
|
},
|
||||||
|
async createSignedOrderAsync(
|
||||||
|
provider: Provider,
|
||||||
|
makerAddress: string,
|
||||||
|
takerAddress: string,
|
||||||
|
senderAddress: string,
|
||||||
|
makerFee: BigNumber,
|
||||||
|
takerFee: BigNumber,
|
||||||
|
makerAssetAmount: BigNumber,
|
||||||
|
makerAssetData: string,
|
||||||
|
takerAssetAmount: BigNumber,
|
||||||
|
takerAssetData: string,
|
||||||
|
exchangeAddress: string,
|
||||||
|
feeRecipientAddress: string,
|
||||||
|
expirationTimeSecondsIfExists?: BigNumber,
|
||||||
|
): Promise<SignedOrder> {
|
||||||
|
const order = orderFactory.createOrder(
|
||||||
|
makerAddress,
|
||||||
|
takerAddress,
|
||||||
|
senderAddress,
|
||||||
|
makerFee,
|
||||||
|
takerFee,
|
||||||
|
makerAssetAmount,
|
||||||
|
makerAssetData,
|
||||||
|
takerAssetAmount,
|
||||||
|
takerAssetData,
|
||||||
|
exchangeAddress,
|
||||||
|
feeRecipientAddress,
|
||||||
|
expirationTimeSecondsIfExists,
|
||||||
|
);
|
||||||
const orderHash = orderHashUtils.getOrderHashHex(order);
|
const orderHash = orderHashUtils.getOrderHashHex(order);
|
||||||
const messagePrefixOpts = {
|
const messagePrefixOpts = {
|
||||||
prefixType: MessagePrefixType.EthSign,
|
prefixType: MessagePrefixType.EthSign,
|
||||||
|
|||||||
Reference in New Issue
Block a user