2
0
mirror of synced 2025-02-24 12:08:10 +00:00

Added id to utils.

This commit is contained in:
Richard Moore 2017-10-17 16:05:44 -04:00
parent 394761a6ca
commit bbd3c94ec3
4 changed files with 23 additions and 1 deletions

View File

@ -100,10 +100,20 @@ function testNamehash(test) {
test.done();
}
function testId(test) {
var id = require('../utils/id');
var sig = id('setAddr(bytes32,address)').substring(0, 10);
test.equal(sig, '0xd5fa2b00', 'id("setAddr(bytes32,address)")')
test.done();
}
module.exports = {
"address": testAddress,
"contract-address": testContractAddress,
'namehash': testNamehash,
'id': testId,
"rlp-coder": testRLPCoder,
"units": testUnits,
}

10
utils/id.js Normal file
View File

@ -0,0 +1,10 @@
'use strict';
var keccak256 = require('./keccak256');
var utf8 = require('./utf8');
function id(text) {
return keccak256(utf8.toUtf8Bytes(text));
}
module.exports = id;

View File

@ -7,6 +7,7 @@ var address = require('./address');
var bigNumber = require('./bignumber');
var contractAddress = require('./contract-address');
var convert = require('./convert');
var id = require('./id');
var keccak256 = require('./keccak256');
var namehash = require('./namehash');
var sha256 = require('./sha2').sha256;
@ -42,6 +43,7 @@ module.exports = {
toUtf8String: utf8.toUtf8String,
namehash: namehash,
id: id,
getAddress: address.getAddress,
getContractAddress: contractAddress.getContractAddress,

View File

@ -1,6 +1,6 @@
{
"name": "ethers-utils",
"version": "2.1.1",
"version": "2.1.2",
"description": "Utilities for the Ethers Ethereum library.",
"bugs": {
"url": "http://github.com/ethers-io/ethers.js/issues",