fix: signatures

This commit is contained in:
Richard Ramos 2020-10-27 12:49:55 -04:00 committed by RichΛrd
parent 5461d6f93c
commit 0a13940742
3 changed files with 28 additions and 3 deletions

View File

@ -73,6 +73,9 @@ QtObject:
proc hex2Ascii*(self: UtilsView, value: string): string {.slot.} =
result = string.fromBytes(hexToSeqByte(value))
proc ascii2Hex*(self: UtilsView, value: string): string {.slot.} =
result = "0x" & toHex(value)
proc hex2Eth*(self: UtilsView, value: string): string {.slot.} =
return stripTrailingZeroes(status_utils.wei2Eth(stint.fromHex(StUint[256], value)))

View File

@ -87,6 +87,13 @@ Rectangle {
signal web3Response(string data);
function signValue(input){
if(Utils.isHex(input) && Utils.startsWith0x(input)){
return input
}
return utilsModel.ascii2Hex(input)
}
function postMessage(data) {
var request;
try {
@ -189,6 +196,12 @@ Rectangle {
signDialog.signMessage = function (enteredPassword) {
signDialog.interactedWith = true;
request.payload.password = enteredPassword;
switch(request.payload.method){
case Constants.personal_sign:
request.payload.params[0] = signValue(request.payload.params[0]);
case Constants.eth_sign:
request.payload.params[1] = signValue(request.payload.params[1]);
}
const response = web3Provider.postMessage(JSON.stringify(request));
provider.web3Response(response);
try {

View File

@ -34,7 +34,16 @@ ModalPopup {
}
}));
}
stack.reset()
}
function displayValue(input){
if(Utils.isHex(input) && Utils.startsWith0x(input)){
if (input.length === bytes32Length){
return input;
}
return utilsModel.hex2Ascii(input)
}
return input;
}
Item {
@ -52,9 +61,9 @@ ModalPopup {
text: {
switch(request.payload.method){
case Constants.personal_sign:
return request.payload.params[0].length === bytes32Length ? request.payload.params[0] : utilsModel.hex2Ascii(request.payload.params[0]);
return displayValue(request.payload.params[0]);
case Constants.eth_sign:
return request.payload.params[1];
return displayValue(request.payload.params[1]);
case Constants.eth_signTypedData:
case Constants.eth_signTypedData_v3:
return JSON.stringify(request.payload.params[1]); // TODO: requires design