loopring_sdk icon indicating copy to clipboard operation
loopring_sdk copied to clipboard

generateKeyPair fails & hangs

Open willsmillie opened this issue 2 years ago • 2 comments

Hi,

I've seen an increase in reports in the discord regarding issues with the generateKeyPair with newer releases of the sdk and NodeJS

I tried going back thru previous releases:

3.8.0 & prior give me ERR_REQUIRE_ESM errors.

3.4.0 works but still hangs.

here is the error for the most recent release (3.8.13):


personalSign -> counterFactualInfo undefined keySeed Sign this message to access Loopring Exchange: 0x12b7cccF30ba360e5041C6Ce239C9a188B709b2B with key nonce: 0 walletType Unknown publicKey from sever side  undefined
IsMobile any navigator is undefined
ecRecover before msg Sign this message to access Loopring Exchange: 0x12b7cccF30ba360e5041C6Ce239C9a188B709b2B with key nonce: 0 result 0x85bcef87ba0f75ed55ce80e91557baedc3ec04d42341c5c234f18bab993207217545b8f068598f1927d4bdbdb6dfed3f90d4b602d05d01ba6a014e667a9a12ab1c undefined
Valid: 3. contractWallet before
web3.eth.personal.sign Valid, valid 5 ways, all failed!
generateKeyPair personalSign error web3.eth.personal.sign Valid, valid 5 ways, all failed!
Error: Error: web3.eth.personal.sign Valid, valid 5 ways, all failed!
    at Object.gr [as generateKeyPair] (/Users/willsmillie/Downloads/test_project/node_modules/@loopring-web/loopring-sdk/dist/index.cjs:1:62250)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async signatureKeyPairMock (/Users/willsmillie/Downloads/test_project/test.js:32:20)
    at async authenticate (/Users/willsmillie/Downloads/test_project/test.js:64:22)

my implementation:


const signatureKeyPairMock = async (accInfo, exchangeAddress) => {
  // initialize provider
  const provider = new PrivateKeyProvider(
    ETH_ACCOUNT_PRIVATE_KEY,
    `https://goerli.infura.io/v3/${INFURA_PROJECT_ID}`
  );
  
  const web3 = new Web3(provider);
  const keySeed =
    accInfo.keySeed ||
    sdk.GlobalAPI.KEY_MESSAGE.replace(
      "${exchangeAddress}",
      exchangeAddress
    ).replace("${nonce}", (accInfo.nonce - 1).toString());

  const eddsaKey = await sdk.generateKeyPair({
    web3,
    address: accInfo.owner,
    keySeed,
    walletType: sdk.ConnectorNames.Unknown,
    chainId: parseInt(CHAIN_ID, 10),
  });

  return eddsaKey;
};

willsmillie avatar Dec 20 '23 18:12 willsmillie

Is error at here image I have the same error, and I need a new version to fix the error. and please delete the type: 'module' at package.json

Alan-Cn avatar Dec 25 '23 09:12 Alan-Cn

I published a new version, you can try it. It`s loopring-fix-web-sdk. pls use require const { ChainId, UserAPI, ExchangeAPI, GlobalAPI, generateKeyPair, ConnectorNames, RESULT_INFO, } = require("loopring-fix-web-sdk");

Alan-Cn avatar Dec 29 '23 06:12 Alan-Cn