Add ownership checks the Registry dApp (#4001)
* Fixes to the Registry dApp * WIP Add Owner Lookup * Proper sha3 implementation * Add working owner lookup to reg dApp * Add errors to Name Reg * Add records error in Reg dApp * Add errors for reverse in reg dApp * PR Grumbles
This commit is contained in:
committed by
Jaco Greeff
parent
4c532f9e3d
commit
63017268ad
@@ -14,8 +14,21 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import { keccak_256 } from 'js-sha3'; // eslint-disable-line camelcase
|
||||
import CryptoJS from 'crypto-js';
|
||||
import CryptoSha3 from 'crypto-js/sha3';
|
||||
|
||||
export function sha3 (value) {
|
||||
return `0x${keccak_256(value)}`;
|
||||
export function sha3 (value, options) {
|
||||
if (options && options.encoding === 'hex') {
|
||||
if (value.length > 2 && value.substr(0, 2) === '0x') {
|
||||
value = value.substr(2);
|
||||
}
|
||||
|
||||
value = CryptoJS.enc.Hex.parse(value);
|
||||
}
|
||||
|
||||
const hash = CryptoSha3(value, {
|
||||
outputLength: 256
|
||||
}).toString();
|
||||
|
||||
return `0x${hash}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user