ethfinex / efx-api-node

Client library to interact with the DeversiFi API and smart-contracts for non-custodial trading
https://app.deversifi.com
22 stars 18 forks source link

signatureUtils.ecSignOrderHashAsync is not a function #52

Closed hems closed 5 years ago

hems commented 5 years ago

When trying the new version on the console i got the following error:

node:51080) UnhandledPromiseRejectionWarning: TypeError: signatureUtils.ecSignOrderHashAsync is not a function

Triggered here: https://github.com/ethfinex/efx-api-node/blob/master/src/api/sign/order.js#L8

When checking signatureUtils i noticed the function ecSignOrderHashAsync don't exist anymore, i can only find on the 0x Async Documentation but i guess that's for v1.

I found a couple related functions on the code, but none of them seems to have the 4th parameter we use to set type to "METAMASK" when signing with MetaMask.

When trying to replace the function by ecSignOrderAsync, i got the following error:

(node:51191) UnhandledPromiseRejectionWarning: Error: Expected order to conform to schema /orderSchema
Encountered: "0xaca93d76964c178a0078ef06ca4d2b7a08c8a7fa78d50754544588ee0da8ba68"
Validation errors: instance is not of a type(s) object
    at Object.assert (/Users/h/git/efx/efx-api-node/node_modules/@0x/assert/lib/src/index.js:77:19)
    at Object.doesConformToSchema (/Users/h/git/efx/efx-api-node/node_modules/@0x/assert/lib/src/index.js:65:24)
    at Object.<anonymous> (/Users/h/git/efx/efx-api-node/node_modules/@0x/order-utils/lib/src/signature_utils.js:262:41)
    at step (/Users/h/git/efx/efx-api-node/node_modules/@0x/order-utils/lib/src/signature_utils.js:43:23)
    at Object.next (/Users/h/git/efx/efx-api-node/node_modules/@0x/order-utils/lib/src/signature_utils.js:24:53)
    at /Users/h/git/efx/efx-api-node/node_modules/@0x/order-utils/lib/src/signature_utils.js:18:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/h/git/efx/efx-api-node/node_modules/@0x/order-utils/lib/src/signature_utils.js:14:12)
    at Object.ecSignOrderAsync (/Users/h/git/efx/efx-api-node/node_modules/@0x/order-utils/lib/src/signature_utils.js:257:16)
    at Function.module.exports (/Users/h/git/efx/efx-api-node/src/api/sign/order.js:10:42)

When using ecSignOrderAsync, i got the following error:

(node:51245) UnhandledPromiseRejectionWarning: TypeError: jsSHA3.keccak256 is not a function
    at Object.isChecksumAddress (/Users/h/git/efx/efx-api-node/node_modules/@0x/utils/lib/src/address_utils.js:14:34)
    at Object.isAddress (/Users/h/git/efx/efx-api-node/node_modules/@0x/utils/lib/src/address_utils.js:39:66)
    at Object.isETHAddressHex (/Users/h/git/efx/efx-api-node/node_modules/@0x/assert/lib/src/index.js:31:52)
    at Object.<anonymous> (/Users/h/git/efx/efx-api-node/node_modules/@0x/order-utils/lib/src/signature_utils.js:360:41)
    at step (/Users/h/git/efx/efx-api-node/node_modules/@0x/order-utils/lib/src/signature_utils.js:43:23)
    at Object.next (/Users/h/git/efx/efx-api-node/node_modules/@0x/order-utils/lib/src/signature_utils.js:24:53)
    at /Users/h/git/efx/efx-api-node/node_modules/@0x/order-utils/lib/src/signature_utils.js:18:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/h/git/efx/efx-api-node/node_modules/@0x/order-utils/lib/src/signature_utils.js:14:12)
    at Object.ecSignHashAsync (/Users/h/git/efx/efx-api-node/node_modules/@0x/order-utils/lib/src/signature_utils.js:353:16)
    at Function.module.exports (/Users/h/git/efx/efx-api-node/src/api/sign/order.js:10:42)

This is the hash i was trying to sign:

{ makerAddress: '0xa8950f8c30595be20a279b4f2ca54d140128ab1d',
  takerAddress: '0x0000000000000000000000000000000000000000',
  feeRecipientAddress: '0x61b9898c9b60a159fc91ae8026563cd226b7a0c1',
  senderAddress: '0x61b9898c9b60a159fc91ae8026563cd226b7a0c1',
  makerAssetAmount: 100000000000000000,
  takerAssetAmount: 29464155,
  makerFee: <BN: 0>,
  takerFee: <BN: 0>,
  expirationTimeSeconds: 1553801994,
  salt:
   97456679576074308967352873623444453160347056893932574606726408533677926792530,
  makerAssetData:
   '0xf47261b0000000000000000000000000aa7427d8f17d87a28f5e1ba3adbb270badbe1011',
  takerAssetData:
   '0xf47261b00000000000000000000000001a9b2d827f26b7d7c18fec4c1b27c1e8deeba26e',
  exchangeAddress: '0x4f833a24e1f95d70f028921e27040ca56e09ab0b' }