Create order expects signed data to be passed in. The order is as follows:
accountId
orderId
marketId
orderType
orderDirection
orderSide
price
quantity
leverage
slippage
postOnly
timeInForce
clientTimestamp
const accountIdBytes = polkadotUtil.hexToU8a(accountId);
const accountIdLowBytes = accountIdBytes.slice(16);
const accountIdHighBytes = accountIdBytes.slice(0, 16);
const orderIdU256 = SubstrateHelper.convertStringToU256(order.id);
const orderIdBytes = polkadotUtil.bnToU8a(orderIdU256, { isLe: false });
const orderIdLowBytes = orderIdBytes.slice(16);
const orderIdHighBytes = orderIdBytes.slice(0, 16);
const elements = [
polkadotUtil.u8aToBn(accountIdLowBytes, { isLe: false }).toString(),
polkadotUtil.u8aToBn(accountIdHighBytes, { isLe: false }).toString(),
polkadotUtil.u8aToBn(orderIdLowBytes, { isLe: false }).toString(),
polkadotUtil.u8aToBn(orderIdHighBytes, { isLe: false }).toString(),
SubstrateHelper.convertStringToU128(order.marketId).toPrimitive(),
SubstrateHelper.convertStringToU256(order.type).toPrimitive(),
SubstrateHelper.convertStringToU256(order.direction).toPrimitive(),
SubstrateHelper.convertStringToU256(order.side).toPrimitive(),
SubstrateHelper.convertNumberToI128(order.price).toPrimitive(),
SubstrateHelper.convertNumberToI128(order.quantity).toPrimitive(),
SubstrateHelper.convertNumberToI128(order.leverage).toPrimitive(),
SubstrateHelper.convertNumberToI128(order.slippage).toPrimitive(),
order.postOnly ? 1 : 0,
SubstrateHelper.convertStringToU256(order.timeInForce).toPrimitive(),
order.clientTimestamp as number,
];
return starknet.hash.computeHashOnElements(elements);