fromICAP method

This commit is contained in:
debris 2015-10-05 12:50:19 +02:00
parent 669a70f2fa
commit da082a393c
8 changed files with 56 additions and 14 deletions

12
dist/web3-light.js vendored
View File

@ -2283,7 +2283,6 @@ var toAddress = function (address) {
return '0x' + padLeft(toHex(address).substr(2), 40); return '0x' + padLeft(toHex(address).substr(2), 40);
}; };
/** /**
* Returns true if object is BigNumber, otherwise false * Returns true if object is BigNumber, otherwise false
* *
@ -2443,6 +2442,7 @@ var c = require('./utils/config');
var Property = require('./web3/property'); var Property = require('./web3/property');
var Batch = require('./web3/batch'); var Batch = require('./web3/batch');
var sha3 = require('./utils/sha3'); var sha3 = require('./utils/sha3');
var Iban = require('./web3/iban');
var web3Properties = [ var web3Properties = [
new Property({ new Property({
@ -2535,6 +2535,14 @@ web3.createBatch = function () {
return new Batch(); return new Batch();
}; };
/**
* Transforms direct icap to address
*/
web3.fromICAP = function (icap) {
var iban = new Iban(icap);
return iban.address();
};
// ADD defaultblock // ADD defaultblock
Object.defineProperty(web3.eth, 'defaultBlock', { Object.defineProperty(web3.eth, 'defaultBlock', {
get: function () { get: function () {
@ -2585,7 +2593,7 @@ setupMethods(web3.shh, shh.methods);
module.exports = web3; module.exports = web3;
},{"./utils/config":18,"./utils/sha3":19,"./utils/utils":20,"./version.json":21,"./web3/batch":24,"./web3/filter":28,"./web3/formatters":29,"./web3/method":35,"./web3/methods/db":36,"./web3/methods/eth":37,"./web3/methods/net":38,"./web3/methods/shh":39,"./web3/methods/watches":40,"./web3/property":42,"./web3/requestmanager":43,"./web3/syncing":44}],23:[function(require,module,exports){ },{"./utils/config":18,"./utils/sha3":19,"./utils/utils":20,"./version.json":21,"./web3/batch":24,"./web3/filter":28,"./web3/formatters":29,"./web3/iban":32,"./web3/method":35,"./web3/methods/db":36,"./web3/methods/eth":37,"./web3/methods/net":38,"./web3/methods/shh":39,"./web3/methods/watches":40,"./web3/property":42,"./web3/requestmanager":43,"./web3/syncing":44}],23:[function(require,module,exports){
/* /*
This file is part of ethereum.js. This file is part of ethereum.js.

File diff suppressed because one or more lines are too long

12
dist/web3.js vendored
View File

@ -2283,7 +2283,6 @@ var toAddress = function (address) {
return '0x' + padLeft(toHex(address).substr(2), 40); return '0x' + padLeft(toHex(address).substr(2), 40);
}; };
/** /**
* Returns true if object is BigNumber, otherwise false * Returns true if object is BigNumber, otherwise false
* *
@ -2443,6 +2442,7 @@ var c = require('./utils/config');
var Property = require('./web3/property'); var Property = require('./web3/property');
var Batch = require('./web3/batch'); var Batch = require('./web3/batch');
var sha3 = require('./utils/sha3'); var sha3 = require('./utils/sha3');
var Iban = require('./web3/iban');
var web3Properties = [ var web3Properties = [
new Property({ new Property({
@ -2535,6 +2535,14 @@ web3.createBatch = function () {
return new Batch(); return new Batch();
}; };
/**
* Transforms direct icap to address
*/
web3.fromICAP = function (icap) {
var iban = new Iban(icap);
return iban.address();
};
// ADD defaultblock // ADD defaultblock
Object.defineProperty(web3.eth, 'defaultBlock', { Object.defineProperty(web3.eth, 'defaultBlock', {
get: function () { get: function () {
@ -2585,7 +2593,7 @@ setupMethods(web3.shh, shh.methods);
module.exports = web3; module.exports = web3;
},{"./utils/config":18,"./utils/sha3":19,"./utils/utils":20,"./version.json":21,"./web3/batch":24,"./web3/filter":28,"./web3/formatters":29,"./web3/method":35,"./web3/methods/db":36,"./web3/methods/eth":37,"./web3/methods/net":38,"./web3/methods/shh":39,"./web3/methods/watches":40,"./web3/property":42,"./web3/requestmanager":43,"./web3/syncing":44}],23:[function(require,module,exports){ },{"./utils/config":18,"./utils/sha3":19,"./utils/utils":20,"./version.json":21,"./web3/batch":24,"./web3/filter":28,"./web3/formatters":29,"./web3/iban":32,"./web3/method":35,"./web3/methods/db":36,"./web3/methods/eth":37,"./web3/methods/net":38,"./web3/methods/shh":39,"./web3/methods/watches":40,"./web3/property":42,"./web3/requestmanager":43,"./web3/syncing":44}],23:[function(require,module,exports){
/* /*
This file is part of ethereum.js. This file is part of ethereum.js.

6
dist/web3.js.map vendored

File diff suppressed because one or more lines are too long

6
dist/web3.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -413,7 +413,6 @@ var toAddress = function (address) {
return '0x' + padLeft(toHex(address).substr(2), 40); return '0x' + padLeft(toHex(address).substr(2), 40);
}; };
/** /**
* Returns true if object is BigNumber, otherwise false * Returns true if object is BigNumber, otherwise false
* *

View File

@ -39,6 +39,7 @@ var c = require('./utils/config');
var Property = require('./web3/property'); var Property = require('./web3/property');
var Batch = require('./web3/batch'); var Batch = require('./web3/batch');
var sha3 = require('./utils/sha3'); var sha3 = require('./utils/sha3');
var Iban = require('./web3/iban');
var web3Properties = [ var web3Properties = [
new Property({ new Property({
@ -131,6 +132,14 @@ web3.createBatch = function () {
return new Batch(); return new Batch();
}; };
/**
* Transforms direct icap to address
*/
web3.fromICAP = function (icap) {
var iban = new Iban(icap);
return iban.address();
};
// ADD defaultblock // ADD defaultblock
Object.defineProperty(web3.eth, 'defaultBlock', { Object.defineProperty(web3.eth, 'defaultBlock', {
get: function () { get: function () {

18
test/web3.fromICAP.js Normal file
View File

@ -0,0 +1,18 @@
var chai = require('chai');
var web3 = require('../index');
var assert = chai.assert;
var tests = [
{ direct: 'XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS', address: '00c5496aee77c1ba1f0854206a26dda82a81d6d8'}
];
describe('web3', function () {
describe('fromICAP', function () {
tests.forEach(function (test) {
it('shoud transform iban to address: ' + test.address, function () {
assert.deepEqual(web3.fromICAP(test.direct), test.address);
});
});
});
});