Socket
Socket
Sign inDemoInstall

web3-eth-iban

Package Overview
Dependencies
Maintainers
4
Versions
443
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

web3-eth-iban - npm Package Compare versions

Comparing version 4.0.8-dev.040d3a3.0 to 4.0.8-dev.04da324.0

lib/commonjs/tsconfig.cjs.tsbuildinfo

94

lib/commonjs/iban.js

@@ -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.040d3a3.0+040d3a3",
"version": "4.0.8-dev.04da324.0+04da324",
"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 .",

@@ -57,11 +57,11 @@ "format": "prettier --write '**/*'",

"ts-jest": "^29.1.1",
"typescript": "^4.7.4"
"typescript": "^5.5.4"
},
"dependencies": {
"web3-errors": "1.1.5-dev.040d3a3.0+040d3a3",
"web3-types": "1.4.1-dev.040d3a3.0+040d3a3",
"web3-utils": "4.2.1-dev.040d3a3.0+040d3a3",
"web3-validator": "2.0.5-dev.040d3a3.0+040d3a3"
"web3-errors": "1.3.1-dev.04da324.0+04da324",
"web3-types": "1.8.1-dev.04da324.0+04da324",
"web3-utils": "4.3.2-dev.04da324.0+04da324",
"web3-validator": "2.0.7-dev.04da324.0+04da324"
},
"gitHead": "040d3a35e569f47d35a287346451ded4b08c7bbe"
"gitHead": "04da324744d2e8d8b358cd4ccf0e97c08d635be3"
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc