web3-eth-iban
Advanced tools
Comparing version 4.0.8-dev.0c67cc6.0 to 4.0.8-dev.0cbc23d.0
@@ -46,49 +46,2 @@ "use strict"; | ||
/** | ||
* Construct a direct or indirect IBAN that has conversion methods and validity checks. | ||
* If the provided string was not of either the length of a direct IBAN (34 or 35), | ||
* nor the length of an indirect IBAN (20), an Error will be thrown ('Invalid IBAN was provided'). | ||
* | ||
* @param iban - a Direct or an Indirect IBAN | ||
* @returns - Iban instance | ||
* | ||
* @example | ||
* ```ts | ||
* const iban = new web3.eth.Iban("XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS"); | ||
* > Iban { _iban: 'XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS' } | ||
* ``` | ||
*/ | ||
constructor(iban) { | ||
/** | ||
* This method should be used to create the equivalent ethereum address for the early provided Direct IBAN address. | ||
* If the provided string was not a direct IBAN (has the length of 34 or 35), an Error will be thrown: | ||
* ('Iban is indirect and cannot be converted. Must be length of 34 or 35'). | ||
* Note: this is also available as a static method. | ||
* | ||
* @return the equivalent ethereum address | ||
* | ||
* @example | ||
* ```ts | ||
* const iban = new web3.eth.Iban("XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS"); | ||
* iban.toAddress(); | ||
* > "0x00c5496aEe77C1bA1f0854206A26DdA82a81D6D8" | ||
* ``` | ||
*/ | ||
this.toAddress = () => { | ||
if (this.isDirect()) { | ||
// check if Iban can be converted to an address | ||
const base36 = this._iban.slice(4); | ||
const parsedBigInt = Iban._parseInt(base36, 36); // convert the base36 string to a bigint | ||
const paddedBigInt = (0, web3_utils_1.leftPad)(parsedBigInt, 40); | ||
return (0, web3_utils_1.toChecksumAddress)(paddedBigInt); | ||
} | ||
throw new Error('Iban is indirect and cannot be converted. Must be length of 34 or 35'); | ||
}; | ||
if (Iban.isIndirect(iban) || Iban.isDirect(iban)) { | ||
this._iban = iban; | ||
} | ||
else { | ||
throw new Error('Invalid IBAN was provided'); | ||
} | ||
} | ||
/** | ||
* A static method that checks if an IBAN is Direct. | ||
@@ -198,2 +151,49 @@ * It actually check the length of the provided variable and, only if it is 34 or 35, it returns true. | ||
/** | ||
* Construct a direct or indirect IBAN that has conversion methods and validity checks. | ||
* If the provided string was not of either the length of a direct IBAN (34 or 35), | ||
* nor the length of an indirect IBAN (20), an Error will be thrown ('Invalid IBAN was provided'). | ||
* | ||
* @param iban - a Direct or an Indirect IBAN | ||
* @returns - Iban instance | ||
* | ||
* @example | ||
* ```ts | ||
* const iban = new web3.eth.Iban("XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS"); | ||
* > Iban { _iban: 'XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS' } | ||
* ``` | ||
*/ | ||
constructor(iban) { | ||
/** | ||
* This method should be used to create the equivalent ethereum address for the early provided Direct IBAN address. | ||
* If the provided string was not a direct IBAN (has the length of 34 or 35), an Error will be thrown: | ||
* ('Iban is indirect and cannot be converted. Must be length of 34 or 35'). | ||
* Note: this is also available as a static method. | ||
* | ||
* @return the equivalent ethereum address | ||
* | ||
* @example | ||
* ```ts | ||
* const iban = new web3.eth.Iban("XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS"); | ||
* iban.toAddress(); | ||
* > "0x00c5496aEe77C1bA1f0854206A26DdA82a81D6D8" | ||
* ``` | ||
*/ | ||
this.toAddress = () => { | ||
if (this.isDirect()) { | ||
// check if Iban can be converted to an address | ||
const base36 = this._iban.slice(4); | ||
const parsedBigInt = Iban._parseInt(base36, 36); // convert the base36 string to a bigint | ||
const paddedBigInt = (0, web3_utils_1.leftPad)(parsedBigInt, 40); | ||
return (0, web3_utils_1.toChecksumAddress)(paddedBigInt); | ||
} | ||
throw new Error('Iban is indirect and cannot be converted. Must be length of 34 or 35'); | ||
}; | ||
if (Iban.isIndirect(iban) || Iban.isDirect(iban)) { | ||
this._iban = iban; | ||
} | ||
else { | ||
throw new Error('Invalid IBAN was provided'); | ||
} | ||
} | ||
/** | ||
* Convert the passed BBAN to an IBAN for this country specification. | ||
@@ -200,0 +200,0 @@ * Please note that <i>"generation of the IBAN shall be the exclusive responsibility of the bank/branch servicing the account"</i>. |
/** | ||
* An object that could hold the components for an Indirect IBAN (BBAN) | ||
*/ | ||
export declare type IbanOptions = { | ||
export type IbanOptions = { | ||
institution: string; | ||
identifier: string; | ||
}; |
@@ -43,49 +43,2 @@ /* | ||
/** | ||
* Construct a direct or indirect IBAN that has conversion methods and validity checks. | ||
* If the provided string was not of either the length of a direct IBAN (34 or 35), | ||
* nor the length of an indirect IBAN (20), an Error will be thrown ('Invalid IBAN was provided'). | ||
* | ||
* @param iban - a Direct or an Indirect IBAN | ||
* @returns - Iban instance | ||
* | ||
* @example | ||
* ```ts | ||
* const iban = new web3.eth.Iban("XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS"); | ||
* > Iban { _iban: 'XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS' } | ||
* ``` | ||
*/ | ||
constructor(iban) { | ||
/** | ||
* This method should be used to create the equivalent ethereum address for the early provided Direct IBAN address. | ||
* If the provided string was not a direct IBAN (has the length of 34 or 35), an Error will be thrown: | ||
* ('Iban is indirect and cannot be converted. Must be length of 34 or 35'). | ||
* Note: this is also available as a static method. | ||
* | ||
* @return the equivalent ethereum address | ||
* | ||
* @example | ||
* ```ts | ||
* const iban = new web3.eth.Iban("XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS"); | ||
* iban.toAddress(); | ||
* > "0x00c5496aEe77C1bA1f0854206A26DdA82a81D6D8" | ||
* ``` | ||
*/ | ||
this.toAddress = () => { | ||
if (this.isDirect()) { | ||
// check if Iban can be converted to an address | ||
const base36 = this._iban.slice(4); | ||
const parsedBigInt = Iban._parseInt(base36, 36); // convert the base36 string to a bigint | ||
const paddedBigInt = leftPad(parsedBigInt, 40); | ||
return toChecksumAddress(paddedBigInt); | ||
} | ||
throw new Error('Iban is indirect and cannot be converted. Must be length of 34 or 35'); | ||
}; | ||
if (Iban.isIndirect(iban) || Iban.isDirect(iban)) { | ||
this._iban = iban; | ||
} | ||
else { | ||
throw new Error('Invalid IBAN was provided'); | ||
} | ||
} | ||
/** | ||
* A static method that checks if an IBAN is Direct. | ||
@@ -195,2 +148,49 @@ * It actually check the length of the provided variable and, only if it is 34 or 35, it returns true. | ||
/** | ||
* Construct a direct or indirect IBAN that has conversion methods and validity checks. | ||
* If the provided string was not of either the length of a direct IBAN (34 or 35), | ||
* nor the length of an indirect IBAN (20), an Error will be thrown ('Invalid IBAN was provided'). | ||
* | ||
* @param iban - a Direct or an Indirect IBAN | ||
* @returns - Iban instance | ||
* | ||
* @example | ||
* ```ts | ||
* const iban = new web3.eth.Iban("XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS"); | ||
* > Iban { _iban: 'XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS' } | ||
* ``` | ||
*/ | ||
constructor(iban) { | ||
/** | ||
* This method should be used to create the equivalent ethereum address for the early provided Direct IBAN address. | ||
* If the provided string was not a direct IBAN (has the length of 34 or 35), an Error will be thrown: | ||
* ('Iban is indirect and cannot be converted. Must be length of 34 or 35'). | ||
* Note: this is also available as a static method. | ||
* | ||
* @return the equivalent ethereum address | ||
* | ||
* @example | ||
* ```ts | ||
* const iban = new web3.eth.Iban("XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS"); | ||
* iban.toAddress(); | ||
* > "0x00c5496aEe77C1bA1f0854206A26DdA82a81D6D8" | ||
* ``` | ||
*/ | ||
this.toAddress = () => { | ||
if (this.isDirect()) { | ||
// check if Iban can be converted to an address | ||
const base36 = this._iban.slice(4); | ||
const parsedBigInt = Iban._parseInt(base36, 36); // convert the base36 string to a bigint | ||
const paddedBigInt = leftPad(parsedBigInt, 40); | ||
return toChecksumAddress(paddedBigInt); | ||
} | ||
throw new Error('Iban is indirect and cannot be converted. Must be length of 34 or 35'); | ||
}; | ||
if (Iban.isIndirect(iban) || Iban.isDirect(iban)) { | ||
this._iban = iban; | ||
} | ||
else { | ||
throw new Error('Invalid IBAN was provided'); | ||
} | ||
} | ||
/** | ||
* Convert the passed BBAN to an IBAN for this country specification. | ||
@@ -197,0 +197,0 @@ * Please note that <i>"generation of the IBAN shall be the exclusive responsibility of the bank/branch servicing the account"</i>. |
/** | ||
* An object that could hold the components for an Indirect IBAN (BBAN) | ||
*/ | ||
export declare type IbanOptions = { | ||
export type IbanOptions = { | ||
institution: string; | ||
@@ -6,0 +6,0 @@ identifier: string; |
{ | ||
"name": "web3-eth-iban", | ||
"version": "4.0.8-dev.0c67cc6.0+0c67cc6", | ||
"version": "4.0.8-dev.0cbc23d.0+0cbc23d", | ||
"description": "This package converts Ethereum addresses to IBAN addresses and vice versa.", | ||
@@ -33,3 +33,3 @@ "main": "./lib/commonjs/index.js", | ||
"build:check": "node -e \"require('./lib')\"", | ||
"lint": "eslint --ext .js,.ts .", | ||
"lint": "eslint --cache --cache-strategy content --ext .ts .", | ||
"lint:fix": "eslint --fix --ext .js,.ts .", | ||
@@ -53,15 +53,15 @@ "format": "prettier --write '**/*'", | ||
"eslint-plugin-import": "^2.26.0", | ||
"jest": "^28.1.3", | ||
"jest": "^29.7.0", | ||
"jest-extended": "^3.0.1", | ||
"prettier": "^2.7.1", | ||
"ts-jest": "^28.0.7", | ||
"typescript": "^4.7.4" | ||
"ts-jest": "^29.1.1", | ||
"typescript": "^5.5.4" | ||
}, | ||
"dependencies": { | ||
"web3-errors": "1.1.5-dev.0c67cc6.0+0c67cc6", | ||
"web3-types": "1.3.2-dev.0c67cc6.0+0c67cc6", | ||
"web3-utils": "4.1.1-dev.0c67cc6.0+0c67cc6", | ||
"web3-validator": "2.0.4-dev.0c67cc6.0+0c67cc6" | ||
"web3-errors": "1.3.1-dev.0cbc23d.0+0cbc23d", | ||
"web3-types": "1.9.1-dev.0cbc23d.0+0cbc23d", | ||
"web3-utils": "4.3.3-dev.0cbc23d.0+0cbc23d", | ||
"web3-validator": "2.0.7-dev.0cbc23d.0+0cbc23d" | ||
}, | ||
"gitHead": "0c67cc64a263d3cabc12c417908534f500ec178e" | ||
"gitHead": "0cbc23d25e811cfb30add0bca85e41cc095e8f95" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
82150
31