How to use the eth-sig-util.TypedDataUtils.sign function in eth-sig-util

To help you get started, we’ve selected a few eth-sig-util 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 OriginProtocol / origin / origin-mobile / src / OriginWallet.js View on Github external
return new Promise((resolve, reject) => {
      let ret
      let shash
      if (params.method == "eth_signTypedData_v3")
      {
        const data = JSON.parse(params.data)
        const pkey = this.getCurrentWeb3Account().privateKey
        const sig = ethUtil.ecsign(TypedDataUtils.sign(data), ethUtil.toBuffer(pkey))
        const result = ethUtil.bufferToHex(concatSig(sig.v, sig.r, sig.s))
        shash = result.slice(2, 6)
        ret = {result}
      } else {
        const msg = params.msg
        const post_phrase_prefix = params.post_phrase_prefix
        console.log("signing message:", msg)
        const signature = this.getCurrentWeb3Account().sign(msg).signature
        shash = result.slice(2, 6)
        ret = {msg, signature, account:this.state.ethAddress}

        if (post_phrase_prefix)
        {
          const sig_key = signature.substring(0, 66)
          const temp_account = web3.eth.accounts.privateKeyToAccount(sig_key)
github OriginProtocol / origin / origin-linking / src / logic / hot.js View on Github external
const rawOffer = await adapter.call('offers', [listingID, offerIndex])

        const payout = web3.utils
          .toBN(rawOffer.value)
          .sub(web3.utils.toBN(rawOffer.refund))
          .toString()
        const verifyFee = '100'
        const data = await origin.contractService.getSignFinalizeData(
          listingID,
          offerID,
          ipfsBytes,
          payout,
          verifyFee
        )
        const sig = ethUtil.ecsign(
          TypedDataUtils.sign(data),
          ethUtil.toBuffer(HOT_WALLET_PK)
        )
        const signature = ethUtil.bufferToHex(concatSig(sig.v, sig.r, sig.s))
        console.log(
          'Signing:',
          data,
          ' signature',
          signature,
          ' payout:',
          payout,
          ' verifyFee:',
          verifyFee
        )
        console.log('raw Offer:', rawOffer)
        return { signature, ipfsBytes, payout, verifyFee }
      }