Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

web3-eth-iban

Package Overview
Dependencies
Maintainers
0
Versions
503
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.70352cd.0 to 4.0.8-dev.7109fb2.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.70352cd.0+70352cd",
"version": "4.0.8-dev.7109fb2.0+7109fb2",
"description": "This package converts Ethereum addresses to IBAN addresses and vice versa.",

@@ -56,11 +56,11 @@ "main": "./lib/commonjs/index.js",

"ts-jest": "^29.1.1",
"typescript": "^4.7.4"
"typescript": "^5.5.4"
},
"dependencies": {
"web3-errors": "1.3.1-dev.70352cd.0+70352cd",
"web3-types": "1.8.2-dev.70352cd.0+70352cd",
"web3-utils": "4.3.3-dev.70352cd.0+70352cd",
"web3-validator": "2.0.7-dev.70352cd.0+70352cd"
"web3-errors": "1.3.1-dev.7109fb2.0+7109fb2",
"web3-types": "1.9.1-dev.7109fb2.0+7109fb2",
"web3-utils": "4.3.3-dev.7109fb2.0+7109fb2",
"web3-validator": "2.0.7-dev.7109fb2.0+7109fb2"
},
"gitHead": "70352cdf6fd6eff92b352ca5d6b3a07507fe5472"
"gitHead": "7109fb281dfe7a170ae0b5f8aace54a63776bcac"
}

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