Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

always use eth_personal_sign #278

Open
lukezhangstudio opened this issue Jun 19, 2019 · 3 comments
Open

always use eth_personal_sign #278

lukezhangstudio opened this issue Jun 19, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@lukezhangstudio
Copy link
Contributor

Because of the way Ethers.js implements a workaround for metamask, we have been effectively using personal.sign. Let's just switch to using personal_sign explicitly in case someone imports addressmapper without using dposuser.

Our own workaround:

return new ethers.providers.Web3Provider(provider).getSigner()

@lukezhangstudio lukezhangstudio added the enhancement New feature or request label Jun 19, 2019
@lukezhangstudio
Copy link
Contributor Author

Example of where we use .sign instead of personal.sign

const sign = await ethersSigner.signAsync(hash)

@eduardonunesp
Copy link
Contributor

@lukezhangstudio that function is passing an interface for IEthereumSigner, so in order to use the personal.sign the user should pass the EthersSigner to that function

async addIdentityMappingAsync(
  from: Address,
  to: Address,
  ethersSigner: IEthereumSigner
): Promise<Uint8Array | void> {
  const mappingIdentityRequest = new AddressMapperAddIdentityMappingRequest()
  mappingIdentityRequest.setFrom(from.MarshalPB())
  mappingIdentityRequest.setTo(to.MarshalPB())

  const hash = soliditySha3(
    {
      type: 'address',
      value: from.local.toString().slice(2)
    },
    {
      type: 'address',
      value: to.local.toString().slice(2)
    }
  )

  const sign = await ethersSigner.signAsync(hash)
  mappingIdentityRequest.setSignature(sign)

  return this.callAsync<void>('AddIdentityMapping', mappingIdentityRequest)
}

export class EthersSigner implements IEthereumSigner {

Instead of Web3Signer which not implements personal_sign

export class Web3Signer implements IEthereumSigner {

@eduardonunesp
Copy link
Contributor

eduardonunesp commented Sep 11, 2019

@lukezhangstudio could you please confirm if my comment above makes sense?

await addressMapper.addIdentityMappingAsync(from, to, ethersSigner)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants