How to use the @waves/marshall.json.stringifyOrder function in @waves/marshall

To help you get started, we’ve selected a few @waves/marshall examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wavesplatform / waves-transactions / src / general.ts View on Github external
export function submitOrder(ord: TOrder, opts: any) {
  let endpoint, matcherUrl: string
  if ( typeof opts === 'string' ){
    matcherUrl = opts
    endpoint = 'matcher/orderbook'
  }else {
    matcherUrl = opts.matcherUrl
    endpoint = opts.market ? 'matcher/orderbook/market' : 'matcher/orderbook'
  }

  return axios.post(endpoint, json.stringifyOrder(ord), {
    baseURL: matcherUrl,
    headers: { 'content-type': 'application/json' },
  })
    .then(x => x.data)
    .catch(e => Promise.reject(e.response && e.response.status === 400 ? new Error(e.response.data.message) : e))
}