Added id to utils.
This commit is contained in:
parent
394761a6ca
commit
bbd3c94ec3
@ -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
10
utils/id.js
Normal 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;
|
@ -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,
|
||||
|
@ -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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user