web3-eth-iban
Advanced tools
Comparing version 1.3.4 to 1.3.5-rc.0
336
lib/index.js
@@ -26,6 +26,6 @@ /* | ||
"use strict"; | ||
var utils = require('web3-utils'); | ||
var BigNumber = require('bn.js'); | ||
var leftPad = function (string, bytes) { | ||
var result = string; | ||
const utils = require('web3-utils'); | ||
const BigNumber = require('bn.js'); | ||
const leftPad = function (string, bytes) { | ||
let result = string; | ||
while (result.length < bytes * 2) { | ||
@@ -44,9 +44,9 @@ result = '0' + result; | ||
*/ | ||
var iso13616Prepare = function (iban) { | ||
var A = 'A'.charCodeAt(0); | ||
var Z = 'Z'.charCodeAt(0); | ||
const iso13616Prepare = function (iban) { | ||
const A = 'A'.charCodeAt(0); | ||
const Z = 'Z'.charCodeAt(0); | ||
iban = iban.toUpperCase(); | ||
iban = iban.substr(4) + iban.substr(0, 4); | ||
return iban.split('').map(function (n) { | ||
var code = n.charCodeAt(0); | ||
const code = n.charCodeAt(0); | ||
if (code >= A && code <= Z) { | ||
@@ -68,4 +68,5 @@ // A = 10, B = 11, ... Z = 35 | ||
*/ | ||
var mod9710 = function (iban) { | ||
var remainder = iban, block; | ||
const mod9710 = function (iban) { | ||
let remainder = iban; | ||
let block; | ||
while (remainder.length > 2) { | ||
@@ -82,157 +83,168 @@ block = remainder.slice(0, 9); | ||
*/ | ||
var Iban = function Iban(iban) { | ||
this._iban = iban; | ||
}; | ||
/** | ||
* This method should be used to create an ethereum address from a direct iban address | ||
* | ||
* @method toAddress | ||
* @param {String} iban address | ||
* @return {String} the ethereum address | ||
*/ | ||
Iban.toAddress = function (ib) { | ||
ib = new Iban(ib); | ||
if (!ib.isDirect()) { | ||
throw new Error('IBAN is indirect and can\'t be converted'); | ||
class Iban { | ||
constructor(iban) { | ||
this._iban = iban; | ||
} | ||
return ib.toAddress(); | ||
}; | ||
/** | ||
* This method should be used to create iban address from an ethereum address | ||
* | ||
* @method toIban | ||
* @param {String} address | ||
* @return {String} the IBAN address | ||
*/ | ||
Iban.toIban = function (address) { | ||
return Iban.fromAddress(address).toString(); | ||
}; | ||
/** | ||
* This method should be used to create iban object from an ethereum address | ||
* | ||
* @method fromAddress | ||
* @param {String} address | ||
* @return {Iban} the IBAN object | ||
*/ | ||
Iban.fromAddress = function (address) { | ||
if (!utils.isAddress(address)) { | ||
throw new Error('Provided address is not a valid address: ' + address); | ||
/** | ||
* This method should be used to create an ethereum address from a direct iban address | ||
* | ||
* @method toAddress | ||
* @param {String} iban address | ||
* @return {String} the ethereum address | ||
*/ | ||
static toAddress(ib) { | ||
ib = new Iban(ib); | ||
if (!ib.isDirect()) { | ||
throw new Error('IBAN is indirect and can\'t be converted'); | ||
} | ||
return ib.toAddress(); | ||
} | ||
address = address.replace('0x', '').replace('0X', ''); | ||
var asBn = new BigNumber(address, 16); | ||
var base36 = asBn.toString(36); | ||
var padded = leftPad(base36, 15); | ||
return Iban.fromBban(padded.toUpperCase()); | ||
}; | ||
/** | ||
* Convert the passed BBAN to an IBAN for this country specification. | ||
* Please note that <i>"generation of the IBAN shall be the exclusive responsibility of the bank/branch servicing the account"</i>. | ||
* This method implements the preferred algorithm described in http://en.wikipedia.org/wiki/International_Bank_Account_Number#Generating_IBAN_check_digits | ||
* | ||
* @method fromBban | ||
* @param {String} bban the BBAN to convert to IBAN | ||
* @returns {Iban} the IBAN object | ||
*/ | ||
Iban.fromBban = function (bban) { | ||
var countryCode = 'XE'; | ||
var remainder = mod9710(iso13616Prepare(countryCode + '00' + bban)); | ||
var checkDigit = ('0' + (98 - remainder)).slice(-2); | ||
return new Iban(countryCode + checkDigit + bban); | ||
}; | ||
/** | ||
* Should be used to create IBAN object for given institution and identifier | ||
* | ||
* @method createIndirect | ||
* @param {Object} options, required options are "institution" and "identifier" | ||
* @return {Iban} the IBAN object | ||
*/ | ||
Iban.createIndirect = function (options) { | ||
return Iban.fromBban('ETH' + options.institution + options.identifier); | ||
}; | ||
/** | ||
* This method should be used to check if given string is valid iban object | ||
* | ||
* @method isValid | ||
* @param {String} iban string | ||
* @return {Boolean} true if it is valid IBAN | ||
*/ | ||
Iban.isValid = function (iban) { | ||
var i = new Iban(iban); | ||
return i.isValid(); | ||
}; | ||
/** | ||
* Should be called to check if iban is correct | ||
* | ||
* @method isValid | ||
* @returns {Boolean} true if it is, otherwise false | ||
*/ | ||
Iban.prototype.isValid = function () { | ||
return /^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30,31})$/.test(this._iban) && | ||
mod9710(iso13616Prepare(this._iban)) === 1; | ||
}; | ||
/** | ||
* Should be called to check if iban number is direct | ||
* | ||
* @method isDirect | ||
* @returns {Boolean} true if it is, otherwise false | ||
*/ | ||
Iban.prototype.isDirect = function () { | ||
return this._iban.length === 34 || this._iban.length === 35; | ||
}; | ||
/** | ||
* Should be called to check if iban number if indirect | ||
* | ||
* @method isIndirect | ||
* @returns {Boolean} true if it is, otherwise false | ||
*/ | ||
Iban.prototype.isIndirect = function () { | ||
return this._iban.length === 20; | ||
}; | ||
/** | ||
* Should be called to get iban checksum | ||
* Uses the mod-97-10 checksumming protocol (ISO/IEC 7064:2003) | ||
* | ||
* @method checksum | ||
* @returns {String} checksum | ||
*/ | ||
Iban.prototype.checksum = function () { | ||
return this._iban.substr(2, 2); | ||
}; | ||
/** | ||
* Should be called to get institution identifier | ||
* eg. XREG | ||
* | ||
* @method institution | ||
* @returns {String} institution identifier | ||
*/ | ||
Iban.prototype.institution = function () { | ||
return this.isIndirect() ? this._iban.substr(7, 4) : ''; | ||
}; | ||
/** | ||
* Should be called to get client identifier within institution | ||
* eg. GAVOFYORK | ||
* | ||
* @method client | ||
* @returns {String} client identifier | ||
*/ | ||
Iban.prototype.client = function () { | ||
return this.isIndirect() ? this._iban.substr(11) : ''; | ||
}; | ||
/** | ||
* Should be called to get client direct address | ||
* | ||
* @method toAddress | ||
* @returns {String} ethereum address | ||
*/ | ||
Iban.prototype.toAddress = function () { | ||
if (this.isDirect()) { | ||
var base36 = this._iban.substr(4); | ||
var asBn = new BigNumber(base36, 36); | ||
return utils.toChecksumAddress(asBn.toString(16, 20)); | ||
/** | ||
* This method should be used to create iban address from an ethereum address | ||
* | ||
* @method toIban | ||
* @param {String} address | ||
* @return {String} the IBAN address | ||
*/ | ||
static toIban(address) { | ||
return Iban.fromAddress(address).toString(); | ||
} | ||
return ''; | ||
}; | ||
Iban.prototype.toString = function () { | ||
return this._iban; | ||
}; | ||
/** | ||
* This method should be used to create iban object from an ethereum address | ||
* | ||
* @method fromAddress | ||
* @param {String} address | ||
* @return {Iban} the IBAN object | ||
*/ | ||
static fromAddress(address) { | ||
if (!utils.isAddress(address)) { | ||
throw new Error('Provided address is not a valid address: ' + address); | ||
} | ||
address = address.replace('0x', '').replace('0X', ''); | ||
const asBn = new BigNumber(address, 16); | ||
const base36 = asBn.toString(36); | ||
const padded = leftPad(base36, 15); | ||
return Iban.fromBban(padded.toUpperCase()); | ||
} | ||
/** | ||
* Convert the passed BBAN to an IBAN for this country specification. | ||
* Please note that <i>"generation of the IBAN shall be the exclusive responsibility of the bank/branch servicing the account"</i>. | ||
* This method implements the preferred algorithm described in http://en.wikipedia.org/wiki/International_Bank_Account_Number#Generating_IBAN_check_digits | ||
* | ||
* @method fromBban | ||
* @param {String} bban the BBAN to convert to IBAN | ||
* @returns {Iban} the IBAN object | ||
*/ | ||
static fromBban(bban) { | ||
const countryCode = 'XE'; | ||
const remainder = mod9710(iso13616Prepare(countryCode + '00' + bban)); | ||
const checkDigit = ('0' + (98 - remainder)).slice(-2); | ||
return new Iban(countryCode + checkDigit + bban); | ||
} | ||
/** | ||
* Should be used to create IBAN object for given institution and identifier | ||
* | ||
* @method createIndirect | ||
* @param {Object} options, required options are "institution" and "identifier" | ||
* @return {Iban} the IBAN object | ||
*/ | ||
static createIndirect(options) { | ||
return Iban.fromBban('ETH' + options.institution + options.identifier); | ||
} | ||
/** | ||
* This method should be used to check if given string is valid iban object | ||
* | ||
* @method isValid | ||
* @param {String} iban string | ||
* @return {Boolean} true if it is valid IBAN | ||
*/ | ||
static isValid(iban) { | ||
const i = new Iban(iban); | ||
return i.isValid(); | ||
} | ||
; | ||
/** | ||
* Should be called to check if iban is correct | ||
* | ||
* @method isValid | ||
* @returns {Boolean} true if it is, otherwise false | ||
*/ | ||
isValid() { | ||
return /^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30,31})$/.test(this._iban) && | ||
mod9710(iso13616Prepare(this._iban)) === 1; | ||
} | ||
; | ||
/** | ||
* Should be called to check if iban number is direct | ||
* | ||
* @method isDirect | ||
* @returns {Boolean} true if it is, otherwise false | ||
*/ | ||
isDirect() { | ||
return this._iban.length === 34 || this._iban.length === 35; | ||
} | ||
; | ||
/** | ||
* Should be called to check if iban number if indirect | ||
* | ||
* @method isIndirect | ||
* @returns {Boolean} true if it is, otherwise false | ||
*/ | ||
isIndirect() { | ||
return this._iban.length === 20; | ||
} | ||
; | ||
/** | ||
* Should be called to get iban checksum | ||
* Uses the mod-97-10 checksumming protocol (ISO/IEC 7064:2003) | ||
* | ||
* @method checksum | ||
* @returns {String} checksum | ||
*/ | ||
checksum() { | ||
return this._iban.substr(2, 2); | ||
} | ||
; | ||
/** | ||
* Should be called to get institution identifier | ||
* eg. XREG | ||
* | ||
* @method institution | ||
* @returns {String} institution identifier | ||
*/ | ||
institution() { | ||
return this.isIndirect() ? this._iban.substr(7, 4) : ''; | ||
} | ||
; | ||
/** | ||
* Should be called to get client identifier within institution | ||
* eg. GAVOFYORK | ||
* | ||
* @method client | ||
* @returns {String} client identifier | ||
*/ | ||
client() { | ||
return this.isIndirect() ? this._iban.substr(11) : ''; | ||
} | ||
; | ||
/** | ||
* Should be called to get client direct address | ||
* | ||
* @method toAddress | ||
* @returns {String} ethereum address | ||
*/ | ||
toAddress() { | ||
if (this.isDirect()) { | ||
const base36 = this._iban.substr(4); | ||
const asBn = new BigNumber(base36, 36); | ||
return utils.toChecksumAddress(asBn.toString(16, 20)); | ||
} | ||
return ''; | ||
} | ||
; | ||
toString() { | ||
return this._iban; | ||
} | ||
; | ||
} | ||
module.exports = Iban; |
{ | ||
"name": "web3-eth-iban", | ||
"version": "1.3.4", | ||
"version": "1.3.5-rc.0", | ||
"description": "This package converts Ethereum addresses to IBAN addresses a vice versa.", | ||
@@ -12,3 +12,3 @@ "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-eth-iban", | ||
"scripts": { | ||
"tsc": "tsc -b tsconfig.json", | ||
"compile": "tsc -b tsconfig.json", | ||
"dtslint": "dtslint --localTs ../../node_modules/typescript/lib types" | ||
@@ -19,3 +19,3 @@ }, | ||
"bn.js": "^4.11.9", | ||
"web3-utils": "1.3.4" | ||
"web3-utils": "1.3.5-rc.0" | ||
}, | ||
@@ -26,3 +26,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "f6d60bd5ec70a932d8b7bc2cbb6a577a2fd22919" | ||
"gitHead": "a79835d91c06820d57ace6b19a75d5e3f5c4d336" | ||
} |
338
src/index.js
@@ -28,8 +28,8 @@ /* | ||
var utils = require('web3-utils'); | ||
var BigNumber = require('bn.js'); | ||
const utils = require('web3-utils'); | ||
const BigNumber = require('bn.js'); | ||
var leftPad = function (string, bytes) { | ||
var result = string; | ||
const leftPad = function (string, bytes) { | ||
let result = string; | ||
while (result.length < bytes * 2) { | ||
@@ -49,5 +49,5 @@ result = '0' + result; | ||
*/ | ||
var iso13616Prepare = function (iban) { | ||
var A = 'A'.charCodeAt(0); | ||
var Z = 'Z'.charCodeAt(0); | ||
const iso13616Prepare = function (iban) { | ||
const A = 'A'.charCodeAt(0); | ||
const Z = 'Z'.charCodeAt(0); | ||
@@ -57,5 +57,5 @@ iban = iban.toUpperCase(); | ||
return iban.split('').map(function(n){ | ||
var code = n.charCodeAt(0); | ||
if (code >= A && code <= Z){ | ||
return iban.split('').map(function(n) { | ||
const code = n.charCodeAt(0); | ||
if (code >= A && code <= Z) { | ||
// A = 10, B = 11, ... Z = 35 | ||
@@ -76,5 +76,5 @@ return code - A + 10; | ||
*/ | ||
var mod9710 = function (iban) { | ||
var remainder = iban, | ||
block; | ||
const mod9710 = function (iban) { | ||
let remainder = iban; | ||
let block; | ||
@@ -94,179 +94,181 @@ while (remainder.length > 2){ | ||
*/ | ||
var Iban = function Iban(iban) { | ||
this._iban = iban; | ||
}; | ||
class Iban { | ||
constructor (iban) { | ||
this._iban = iban; | ||
} | ||
/** | ||
* This method should be used to create an ethereum address from a direct iban address | ||
* | ||
* @method toAddress | ||
* @param {String} iban address | ||
* @return {String} the ethereum address | ||
*/ | ||
Iban.toAddress = function (ib) { | ||
ib = new Iban(ib); | ||
/** | ||
* This method should be used to create an ethereum address from a direct iban address | ||
* | ||
* @method toAddress | ||
* @param {String} iban address | ||
* @return {String} the ethereum address | ||
*/ | ||
static toAddress (ib) { | ||
ib = new Iban(ib); | ||
if(!ib.isDirect()) { | ||
throw new Error('IBAN is indirect and can\'t be converted'); | ||
if(!ib.isDirect()) { | ||
throw new Error('IBAN is indirect and can\'t be converted'); | ||
} | ||
return ib.toAddress(); | ||
} | ||
return ib.toAddress(); | ||
}; | ||
/** | ||
* This method should be used to create iban address from an ethereum address | ||
* | ||
* @method toIban | ||
* @param {String} address | ||
* @return {String} the IBAN address | ||
*/ | ||
static toIban (address) { | ||
return Iban.fromAddress(address).toString(); | ||
} | ||
/** | ||
* This method should be used to create iban address from an ethereum address | ||
* | ||
* @method toIban | ||
* @param {String} address | ||
* @return {String} the IBAN address | ||
*/ | ||
Iban.toIban = function (address) { | ||
return Iban.fromAddress(address).toString(); | ||
}; | ||
/** | ||
* This method should be used to create iban object from an ethereum address | ||
* | ||
* @method fromAddress | ||
* @param {String} address | ||
* @return {Iban} the IBAN object | ||
*/ | ||
static fromAddress (address) { | ||
if(!utils.isAddress(address)){ | ||
throw new Error('Provided address is not a valid address: '+ address); | ||
} | ||
/** | ||
* This method should be used to create iban object from an ethereum address | ||
* | ||
* @method fromAddress | ||
* @param {String} address | ||
* @return {Iban} the IBAN object | ||
*/ | ||
Iban.fromAddress = function (address) { | ||
if(!utils.isAddress(address)){ | ||
throw new Error('Provided address is not a valid address: '+ address); | ||
address = address.replace('0x','').replace('0X',''); | ||
const asBn = new BigNumber(address, 16); | ||
const base36 = asBn.toString(36); | ||
const padded = leftPad(base36, 15); | ||
return Iban.fromBban(padded.toUpperCase()); | ||
} | ||
address = address.replace('0x','').replace('0X',''); | ||
/** | ||
* Convert the passed BBAN to an IBAN for this country specification. | ||
* Please note that <i>"generation of the IBAN shall be the exclusive responsibility of the bank/branch servicing the account"</i>. | ||
* This method implements the preferred algorithm described in http://en.wikipedia.org/wiki/International_Bank_Account_Number#Generating_IBAN_check_digits | ||
* | ||
* @method fromBban | ||
* @param {String} bban the BBAN to convert to IBAN | ||
* @returns {Iban} the IBAN object | ||
*/ | ||
static fromBban (bban) { | ||
const countryCode = 'XE'; | ||
var asBn = new BigNumber(address, 16); | ||
var base36 = asBn.toString(36); | ||
var padded = leftPad(base36, 15); | ||
return Iban.fromBban(padded.toUpperCase()); | ||
}; | ||
const remainder = mod9710(iso13616Prepare(countryCode + '00' + bban)); | ||
const checkDigit = ('0' + (98 - remainder)).slice(-2); | ||
/** | ||
* Convert the passed BBAN to an IBAN for this country specification. | ||
* Please note that <i>"generation of the IBAN shall be the exclusive responsibility of the bank/branch servicing the account"</i>. | ||
* This method implements the preferred algorithm described in http://en.wikipedia.org/wiki/International_Bank_Account_Number#Generating_IBAN_check_digits | ||
* | ||
* @method fromBban | ||
* @param {String} bban the BBAN to convert to IBAN | ||
* @returns {Iban} the IBAN object | ||
*/ | ||
Iban.fromBban = function (bban) { | ||
var countryCode = 'XE'; | ||
return new Iban(countryCode + checkDigit + bban); | ||
} | ||
var remainder = mod9710(iso13616Prepare(countryCode + '00' + bban)); | ||
var checkDigit = ('0' + (98 - remainder)).slice(-2); | ||
/** | ||
* Should be used to create IBAN object for given institution and identifier | ||
* | ||
* @method createIndirect | ||
* @param {Object} options, required options are "institution" and "identifier" | ||
* @return {Iban} the IBAN object | ||
*/ | ||
static createIndirect (options) { | ||
return Iban.fromBban('ETH' + options.institution + options.identifier); | ||
} | ||
return new Iban(countryCode + checkDigit + bban); | ||
}; | ||
/** | ||
* This method should be used to check if given string is valid iban object | ||
* | ||
* @method isValid | ||
* @param {String} iban string | ||
* @return {Boolean} true if it is valid IBAN | ||
*/ | ||
static isValid (iban) { | ||
const i = new Iban(iban); | ||
return i.isValid(); | ||
}; | ||
/** | ||
* Should be used to create IBAN object for given institution and identifier | ||
* | ||
* @method createIndirect | ||
* @param {Object} options, required options are "institution" and "identifier" | ||
* @return {Iban} the IBAN object | ||
*/ | ||
Iban.createIndirect = function (options) { | ||
return Iban.fromBban('ETH' + options.institution + options.identifier); | ||
}; | ||
/** | ||
* Should be called to check if iban is correct | ||
* | ||
* @method isValid | ||
* @returns {Boolean} true if it is, otherwise false | ||
*/ | ||
isValid () { | ||
return /^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30,31})$/.test(this._iban) && | ||
mod9710(iso13616Prepare(this._iban)) === 1; | ||
}; | ||
/** | ||
* This method should be used to check if given string is valid iban object | ||
* | ||
* @method isValid | ||
* @param {String} iban string | ||
* @return {Boolean} true if it is valid IBAN | ||
*/ | ||
Iban.isValid = function (iban) { | ||
var i = new Iban(iban); | ||
return i.isValid(); | ||
}; | ||
/** | ||
* Should be called to check if iban number is direct | ||
* | ||
* @method isDirect | ||
* @returns {Boolean} true if it is, otherwise false | ||
*/ | ||
isDirect () { | ||
return this._iban.length === 34 || this._iban.length === 35; | ||
}; | ||
/** | ||
* Should be called to check if iban is correct | ||
* | ||
* @method isValid | ||
* @returns {Boolean} true if it is, otherwise false | ||
*/ | ||
Iban.prototype.isValid = function () { | ||
return /^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30,31})$/.test(this._iban) && | ||
mod9710(iso13616Prepare(this._iban)) === 1; | ||
}; | ||
/** | ||
* Should be called to check if iban number if indirect | ||
* | ||
* @method isIndirect | ||
* @returns {Boolean} true if it is, otherwise false | ||
*/ | ||
isIndirect () { | ||
return this._iban.length === 20; | ||
}; | ||
/** | ||
* Should be called to check if iban number is direct | ||
* | ||
* @method isDirect | ||
* @returns {Boolean} true if it is, otherwise false | ||
*/ | ||
Iban.prototype.isDirect = function () { | ||
return this._iban.length === 34 || this._iban.length === 35; | ||
}; | ||
/** | ||
* Should be called to get iban checksum | ||
* Uses the mod-97-10 checksumming protocol (ISO/IEC 7064:2003) | ||
* | ||
* @method checksum | ||
* @returns {String} checksum | ||
*/ | ||
checksum () { | ||
return this._iban.substr(2, 2); | ||
}; | ||
/** | ||
* Should be called to check if iban number if indirect | ||
* | ||
* @method isIndirect | ||
* @returns {Boolean} true if it is, otherwise false | ||
*/ | ||
Iban.prototype.isIndirect = function () { | ||
return this._iban.length === 20; | ||
}; | ||
/** | ||
* Should be called to get institution identifier | ||
* eg. XREG | ||
* | ||
* @method institution | ||
* @returns {String} institution identifier | ||
*/ | ||
institution () { | ||
return this.isIndirect() ? this._iban.substr(7, 4) : ''; | ||
}; | ||
/** | ||
* Should be called to get iban checksum | ||
* Uses the mod-97-10 checksumming protocol (ISO/IEC 7064:2003) | ||
* | ||
* @method checksum | ||
* @returns {String} checksum | ||
*/ | ||
Iban.prototype.checksum = function () { | ||
return this._iban.substr(2, 2); | ||
}; | ||
/** | ||
* Should be called to get client identifier within institution | ||
* eg. GAVOFYORK | ||
* | ||
* @method client | ||
* @returns {String} client identifier | ||
*/ | ||
client () { | ||
return this.isIndirect() ? this._iban.substr(11) : ''; | ||
}; | ||
/** | ||
* Should be called to get institution identifier | ||
* eg. XREG | ||
* | ||
* @method institution | ||
* @returns {String} institution identifier | ||
*/ | ||
Iban.prototype.institution = function () { | ||
return this.isIndirect() ? this._iban.substr(7, 4) : ''; | ||
}; | ||
/** | ||
* Should be called to get client direct address | ||
* | ||
* @method toAddress | ||
* @returns {String} ethereum address | ||
*/ | ||
toAddress () { | ||
if (this.isDirect()) { | ||
const base36 = this._iban.substr(4); | ||
const asBn = new BigNumber(base36, 36); | ||
return utils.toChecksumAddress(asBn.toString(16, 20)); | ||
} | ||
/** | ||
* Should be called to get client identifier within institution | ||
* eg. GAVOFYORK | ||
* | ||
* @method client | ||
* @returns {String} client identifier | ||
*/ | ||
Iban.prototype.client = function () { | ||
return this.isIndirect() ? this._iban.substr(11) : ''; | ||
}; | ||
return ''; | ||
}; | ||
/** | ||
* Should be called to get client direct address | ||
* | ||
* @method toAddress | ||
* @returns {String} ethereum address | ||
*/ | ||
Iban.prototype.toAddress = function () { | ||
if (this.isDirect()) { | ||
var base36 = this._iban.substr(4); | ||
var asBn = new BigNumber(base36, 36); | ||
return utils.toChecksumAddress(asBn.toString(16, 20)); | ||
} | ||
toString () { | ||
return this._iban; | ||
}; | ||
} | ||
return ''; | ||
}; | ||
Iban.prototype.toString = function () { | ||
return this._iban; | ||
}; | ||
module.exports = Iban; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23071
686
2
1
+ Addedweb3-utils@1.3.5-rc.0(transitive)
- Removedweb3-utils@1.3.4(transitive)
Updatedweb3-utils@1.3.5-rc.0