Socket
Socket
Sign inDemoInstall

@multiversx/sdk-wallet

Package Overview
Dependencies
Maintainers
10
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@multiversx/sdk-wallet - npm Package Compare versions

Comparing version 4.4.0 to 4.5.0-beta.0

11

out/userAddress.d.ts
/// <reference types="node" />
/**
* A user Address, as an immutable object.
* @internal
* For internal use only.
*/
export declare class UserAddress {
private readonly buffer;
constructor(buffer: Buffer);
private readonly hrp;
constructor(buffer: Buffer, hrp?: string);
static newFromBech32(value: string): UserAddress;
/**
* @internal
* @deprecated
*/
static fromBech32(value: string): UserAddress;

@@ -9,0 +16,0 @@ /**

54

out/userAddress.js

@@ -28,23 +28,24 @@ "use strict";

*/
const HRP = "erd";
const DEFAULT_HRP = "erd";
/**
* A user Address, as an immutable object.
* @internal
* For internal use only.
*/
class UserAddress {
constructor(buffer) {
constructor(buffer, hrp) {
this.buffer = buffer;
this.hrp = hrp || DEFAULT_HRP;
}
static newFromBech32(value) {
const { hrp, pubkey } = decodeFromBech32({ value, allowCustomHrp: true });
return new UserAddress(pubkey, hrp);
}
/**
* @internal
* @deprecated
*/
static fromBech32(value) {
let decoded;
try {
decoded = bech32.decode(value);
}
catch (err) {
throw new errors_1.ErrBadAddress(value, err);
}
if (decoded.prefix != HRP) {
throw new errors_1.ErrBadAddress(value);
}
let pubkey = Buffer.from(bech32.fromWords(decoded.words));
return new UserAddress(pubkey);
// On this legacy flow, we do not accept addresses with custom hrp (in order to avoid behavioral breaking changes).
const { hrp, pubkey } = decodeFromBech32({ value, allowCustomHrp: false });
return new UserAddress(pubkey, hrp);
}

@@ -61,4 +62,4 @@ /**

bech32() {
let words = bech32.toWords(this.pubkey());
let address = bech32.encode(HRP, words);
const words = bech32.toWords(this.pubkey());
const address = bech32.encode(this.hrp, words);
return address;

@@ -89,2 +90,21 @@ }

exports.UserAddress = UserAddress;
function decodeFromBech32(options) {
const value = options.value;
const allowCustomHrp = options.allowCustomHrp;
let hrp;
let pubkey;
try {
const decoded = bech32.decode(value);
hrp = decoded.prefix;
pubkey = Buffer.from(bech32.fromWords(decoded.words));
}
catch (err) {
throw new errors_1.ErrBadAddress(value, err);
}
// Workaround, in order to avoid behavioral breaking changes on legacy flows.
if (!allowCustomHrp && hrp != DEFAULT_HRP) {
throw new errors_1.ErrBadAddress(value);
}
return { hrp, pubkey };
}
//# sourceMappingURL=userAddress.js.map

@@ -20,4 +20,4 @@ /// <reference types="node" />

hex(): string;
toAddress(): UserAddress;
toAddress(hrp?: string): UserAddress;
valueOf(): Buffer;
}

@@ -80,4 +80,4 @@ "use strict";

}
toAddress() {
return new userAddress_1.UserAddress(this.buffer);
toAddress(hrp) {
return new userAddress_1.UserAddress(this.buffer, hrp);
}

@@ -84,0 +84,0 @@ valueOf() {

@@ -8,3 +8,3 @@ /// <reference types="node" />

interface IUserPublicKey {
toAddress(): {
toAddress(hrp?: string): {
bech32(): string;

@@ -25,4 +25,4 @@ };

*/
getAddress(): UserAddress;
getAddress(hrp?: string): UserAddress;
}
export {};

@@ -46,5 +46,5 @@ "use strict";

*/
getAddress() {
const bech32 = this.secretKey.generatePublicKey().toAddress().bech32();
return userAddress_1.UserAddress.fromBech32(bech32);
getAddress(hrp) {
const bech32 = this.secretKey.generatePublicKey().toAddress(hrp).bech32();
return userAddress_1.UserAddress.newFromBech32(bech32);
}

@@ -51,0 +51,0 @@ }

@@ -46,3 +46,3 @@ /// <reference types="node" />

*/
toJSON(): any;
toJSON(addressHrp?: string): any;
private toJSONWhenKindIsSecretKey;

@@ -49,0 +49,0 @@ getCryptoSectionAsJSON(): any;

@@ -105,9 +105,9 @@ "use strict";

*/
toJSON() {
toJSON(addressHrp) {
if (this.kind == UserWalletKind.SecretKey) {
return this.toJSONWhenKindIsSecretKey();
return this.toJSONWhenKindIsSecretKey(addressHrp);
}
return this.toJSONWhenKindIsMnemonic();
}
toJSONWhenKindIsSecretKey() {
toJSONWhenKindIsSecretKey(addressHrp) {
if (!this.publicKeyWhenKindIsSecretKey) {

@@ -122,3 +122,3 @@ throw new errors_1.Err("Public key isn't available");

address: this.publicKeyWhenKindIsSecretKey.hex(),
bech32: this.publicKeyWhenKindIsSecretKey.toAddress().toString(),
bech32: this.publicKeyWhenKindIsSecretKey.toAddress(addressHrp).toString(),
crypto: cryptoSection

@@ -125,0 +125,0 @@ };

{
"name": "@multiversx/sdk-wallet",
"version": "4.4.0",
"version": "4.5.0-beta.0",
"description": "Wallet components for MultiversX",

@@ -12,2 +12,3 @@ "main": "out/index.js",

"test": "mocha",
"test-with-coverage": "nyc --reporter=html mocha",
"compile-browser": "bash ./scripts/compile_browser.sh",

@@ -14,0 +15,0 @@ "compile": "tsc -p tsconfig.json",

# MultiversX SDK for JavaScript and TypeScript: wallet components
Wallet components (generation, signing) for TypeScript (JavaScript).
Wallet components (generation, signing) for TypeScript (JavaScript).

@@ -21,2 +21,10 @@ ## Distribution

### Additional dependencies
Instanbul, for code coverage:
```
npm install --no-save nyc
```
### Building the library

@@ -23,0 +31,0 @@

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

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