Skip to content

Commit eaad214

Browse files
authored
Replace deprecated package eth-sig-util (#23)
Signed-off-by: Sebastian Martinez <me@sebastinez.dev> Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
1 parent 5f13208 commit eaad214

File tree

3 files changed

+4947
-4875
lines changed

3 files changed

+4947
-4875
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@
3232
"typescript": "^4.1.5"
3333
},
3434
"dependencies": {
35-
"eth-sig-util": "^3.0.1"
35+
"@metamask/eth-sig-util": "^4.0.1"
3636
}
3737
}

src/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { personalSign, decrypt } from 'eth-sig-util'
1+
import { personalSign, decrypt } from '@metamask/eth-sig-util'
22

33
type ProviderSetup = {
44
address: string
@@ -76,9 +76,9 @@ export class MockProvider implements IMockProvider {
7676
return Promise.resolve(this.chainId)
7777

7878
case 'personal_sign': {
79-
const privKey = Buffer.from(this.setup.privateKey, 'hex');
79+
const privateKey = Buffer.from(this.setup.privateKey, 'hex');
8080

81-
const signed: string = personalSign(privKey, { data: params[0] })
81+
const signed: string = personalSign({ privateKey, data: params[0] })
8282

8383
this.log('signed', signed)
8484

@@ -94,9 +94,9 @@ export class MockProvider implements IMockProvider {
9494

9595
const stripped = params[0].substring(2)
9696
const buff = Buffer.from(stripped, 'hex');
97-
const data = JSON.parse(buff.toString('utf8'));
97+
const encryptedData = JSON.parse(buff.toString('utf8'));
9898

99-
const decrypted: string = decrypt(data, this.setup.privateKey)
99+
const decrypted: string = decrypt({ encryptedData, privateKey: this.setup.privateKey })
100100

101101
return Promise.resolve(decrypted)
102102
}

0 commit comments

Comments
 (0)