Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
parity-signer
Commits
10e30dd4
Commit
10e30dd4
authored
Aug 16, 2019
by
Maciej Hirsz
Committed by
YJ
Aug 16, 2019
Browse files
fix: Error handling for hash functions (#319)
parent
8568eee7
Pipeline
#49503
failed with stage
in 17 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
android/app/src/main/java/io/parity/signer/EthkeyBridge.java
View file @
10e30dd4
...
...
@@ -74,12 +74,20 @@ public class EthkeyBridge extends ReactContextBaseJavaModule {
@ReactMethod
public
void
keccak
(
String
data
,
Promise
promise
)
{
promise
.
resolve
(
ethkeyKeccak
(
data
));
try
{
promise
.
resolve
(
ethkeyKeccak
(
data
));
}
catch
(
Exception
e
)
{
promise
.
reject
(
"invalid data, expected hex-encoded string"
,
"invalid data, expected hex-encoded string"
);
}
}
@ReactMethod
public
void
blake2s
(
String
data
,
Promise
promise
)
{
promise
.
resolve
(
ethkeyBlake
(
data
));
try
{
promise
.
resolve
(
ethkeyBlake
(
data
));
}
catch
(
Exception
e
)
{
promise
.
reject
(
"invalid data, expected hex-encoded string"
,
"invalid data, expected hex-encoded string"
);
}
}
@ReactMethod
...
...
ios/NativeSigner/EthkeyBridge.swift
View file @
10e30dd4
...
...
@@ -61,7 +61,11 @@ class EthkeyBridge: NSObject {
let
hash
=
String
.
fromStringPtr
(
ptr
:
hash_rust_str_ptr
!.
pointee
)
rust_string_ptr_destroy
(
hash_rust_str_ptr
)
rust_string_destroy
(
hash_rust_str
)
resolve
(
hash
)
if
(
error
==
0
)
{
resolve
(
hash
)
}
else
{
reject
(
"invalid data, expected hex-encoded string"
,
nil
,
nil
)
}
}
@objc
func
blake2s
(
_
data
:
String
,
resolve
:
RCTPromiseResolveBlock
,
reject
:
RCTPromiseRejectBlock
)
->
Void
{
...
...
@@ -72,7 +76,11 @@ class EthkeyBridge: NSObject {
let
hash
=
String
.
fromStringPtr
(
ptr
:
hash_rust_str_ptr
!.
pointee
)
rust_string_ptr_destroy
(
hash_rust_str_ptr
)
rust_string_destroy
(
hash_rust_str
)
resolve
(
hash
)
if
(
error
==
0
)
{
resolve
(
hash
)
}
else
{
reject
(
"invalid data, expected hex-encoded string"
,
nil
,
nil
)
}
}
@objc
func
ethSign
(
_
data
:
String
,
resolve
:
RCTPromiseResolveBlock
,
reject
:
RCTPromiseRejectBlock
)
->
Void
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment