lint && fix test

pull/4817/head^2
yann300 5 months ago committed by Aniket
parent 33c126b8d8
commit e2a30eded8
  1. 20
      libs/remix-simulator/src/methods/accounts.ts
  2. 11
      libs/remix-simulator/test/accounts.ts

@ -124,45 +124,45 @@ export class Web3Accounts {
eth_signTypedData_v4 (payload, cb) {
const address: string = payload.params[0]
const typedData: TypedMessage<MessageTypes> = payload.params[1]
try {
if (this.accounts[toChecksumAddress(address)] == null) {
throw new Error("cannot sign data; no private key");
}
if (typeof typedData === "string") {
throw new Error("cannot sign data; string sent, expected object");
}
if (!typedData.types) {
throw new Error("cannot sign data; types missing");
}
if (!typedData.types.EIP712Domain) {
throw new Error("cannot sign data; EIP712Domain definition missing");
}
if (!typedData.domain) {
throw new Error("cannot sign data; domain missing");
}
if (!typedData.primaryType) {
throw new Error("cannot sign data; primaryType missing");
}
if (!typedData.message) {
throw new Error("cannot sign data; message missing");
}
const ret = signTypedData({
privateKey: Buffer.from(this.accounts[toChecksumAddress(address)].privateKey),
data: typedData,
version: SignTypedDataVersion.V4
version: SignTypedDataVersion.V4
})
cb(null, ret)
} catch (e) {
cb(e.message)
}
}
}
}

@ -68,13 +68,14 @@ describe('Accounts', () => {
],
},
};
web3.currentProvider.sendAsync({
const result = await web3.currentProvider.sendAsync({
method: 'eth_signTypedData',
params: [accounts[0], typedData]
}, function (err, result) {
console.log(err, result)
assert.equal(result.result, '0xe4ee76332af49888d86a09eea70dfd5b9a7085e2e013cbba4c0cb41766eab69a6216f18b80d9277241ce35b74b6c46add36d5189eb5a94a258f076dfc4dd21161b')
params: [accounts[0], typedData],
id: 0,
jsonrpc: '2.0'
})
console.log(result)
assert.equal(result, '0xe4ee76332af49888d86a09eea70dfd5b9a7085e2e013cbba4c0cb41766eab69a6216f18b80d9277241ce35b74b6c46add36d5189eb5a94a258f076dfc4dd21161b')
})
})
})

Loading…
Cancel
Save