Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

order-utils: Orders Signed By Trust Wallet Return As INVALID_SIGNATURE #1724

Open
pointtoken opened this issue Mar 22, 2019 · 9 comments
Open

Comments

@pointtoken
Copy link

pointtoken commented Mar 22, 2019

When attempting to sign a typed order from Trust Wallet, the signature fails validation.

Here is the code to create the signature

      const signedOrder = await signatureUtils.ecSignTypedDataOrderAsync(
        this.web3,
        order,
        signerAddress
      );
      return signedOrder;

This will successfully fire off the 712 signing UI from Trust Wallet and return a signature. But when the signed order is then passed to validateOrderFillableOrThrowAsync it returns

Error: INVALID_ORDER_SIGNATURE
    at OrderValidationUtils.<anonymous> (node_modules/@0x/order-utils/src/order_validation_utils.ts:154:19)
@dekz
Copy link
Member

dekz commented Mar 25, 2019

what is the web3 object in this context?

@pointtoken
Copy link
Author

Trust Wallet injects it:

this.web3 = this.windowRef.nativeWindow.web3.currentProvider;

Are there any websites or dexes that one can navigate to from Trust Wallet and create a valid signed order?

@dekz
Copy link
Member

dekz commented Mar 25, 2019

I'd suggest the 0x codesandbox but it appears that Trust Wallet has disabled testnet support?

@fabioberger
Copy link
Contributor

@pointtoken are you able to fill the order? Wondering if the issue is with Trust Wallet or validateOrderFillableOrThrowAsync.

@pointtoken
Copy link
Author

@fabioberger no the order is not able to be filled.

@stale
Copy link

stale bot commented May 25, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 25, 2019
@fabioberger fabioberger removed the stale label May 28, 2019
@fabioberger
Copy link
Contributor

@pointtoken if this is still an issue, mind sending as a repro? Or repo where we can see the code? I'd need to put in some debug logs to see what's going on.

@fabioberger fabioberger changed the title Orders Signed By Trust Wallet Return As INVALID_SIGNATURE order-utils: Orders Signed By Trust Wallet Return As INVALID_SIGNATURE Jun 4, 2019
@stale
Copy link

stale bot commented Jul 26, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 26, 2019
@fabioberger fabioberger added pinned and removed stale labels Aug 13, 2019
@amaurer
Copy link
Contributor

amaurer commented Sep 12, 2019

I'm also having an issue with signing typed data in Trust wallet. It seems to immediately fail.

e.toLowerCase is not a function. (In 'e.toLowerCase()', 'e.toLowerCase' is undefined)

I know that isn't much help but it's what I have. It's difficult to debug because we're in an embedded browser within Trust.

Also, this seems to be specific to signing typed data. I am able to sign a message successfully and send it to the exchange contract, but it doesn't pass signature validation. It returns "SIGNATURE_UNSUPPORTED"

Here is some sample code.

  async signTransactionAsync(transaction) {
    return await signatureUtils.ecSignTypedDataTransactionAsync(
      this.provider,
      transaction,
      transaction.signerAddress,
    );
  },

  async submitOrders(afterConfirmation) {
    const data = await this.getEncodedTransactionData();
    const transaction = { // ZeroExTransaction Object
      salt: new Date().getTime(),
      signerAddress: this.account,
      verifyingContractAddress: this.contractWrappers.exchange.address,
      data,
    };

    const signature = await this.signTransactionAsync(transaction);
    const signedTransaction = {
      ...transaction,
      signature,
    };

    const { gas, gasPrice } = await this.getGas();
    const txHash = await this.ourContract.ourFunction.sendTransactionAsync(
      signedTransaction,
      signature,
      {
        from: transaction.signerAddress,
        gas,
        gasPrice,
      },
    );
    return this.web3Wrapper.awaitTransactionMinedAsync(txHash);
  },

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants