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

@polkadot-api/substrate-bindings

Package Overview
Dependencies
Maintainers
2
Versions
602
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@polkadot-api/substrate-bindings - npm Package Compare versions

Comparing version 0.6.3 to 0.7.0

6

dist/index.d.ts

@@ -31,9 +31,13 @@ import * as scale_ts from 'scale-ts';

#private;
constructor(data: Uint8Array);
constructor(data: Uint8Array, opaque?: boolean);
asText: () => string;
asHex: () => string;
asOpaqueHex: () => string;
asBytes: () => Uint8Array;
asOpaqueBytes: () => Uint8Array;
static fromText(input: string): Binary;
static fromHex(input: HexString): Binary;
static fromOpaqueHex(input: HexString): Binary;
static fromBytes(input: Uint8Array): Binary;
static fromOpaqueBytes(input: Uint8Array): Binary;
}

@@ -40,0 +44,0 @@ declare class FixedSizeBinary<_L extends number> extends Binary {

@@ -86,14 +86,33 @@ 'use strict';

var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
var _bytes, _hex, _str;
var _bytes, _opaqueBytes, _hex, _opaqueHex, _str;
const textEncoder$3 = new TextEncoder();
const textDecoder$2 = new TextDecoder();
const opaqueBytesDec = scaleTs.Tuple(scaleTs.compact, scaleTs.Bytes(Infinity))[1];
class Binary {
constructor(data) {
constructor(data, opaque = false) {
__privateAdd(this, _bytes);
__privateAdd(this, _opaqueBytes, null);
__privateAdd(this, _hex, null);
__privateAdd(this, _opaqueHex, null);
__privateAdd(this, _str, null);
__publicField(this, "asText", () => __privateGet(this, _str) === null ? __privateSet(this, _str, textDecoder$2.decode(__privateGet(this, _bytes))) : __privateGet(this, _str));
__publicField(this, "asHex", () => __privateGet(this, _hex) === null ? __privateSet(this, _hex, utils.toHex(__privateGet(this, _bytes))) : __privateGet(this, _hex));
__publicField(this, "asText", () => __privateGet(this, _str) ?? __privateSet(this, _str, textDecoder$2.decode(__privateGet(this, _bytes))));
__publicField(this, "asHex", () => __privateGet(this, _hex) || __privateSet(this, _hex, utils.toHex(__privateGet(this, _bytes))));
__publicField(this, "asOpaqueHex", () => __privateGet(this, _opaqueHex) || __privateSet(this, _opaqueHex, utils.toHex(this.asBytes())));
__publicField(this, "asBytes", () => __privateGet(this, _bytes));
__privateSet(this, _bytes, data);
__publicField(this, "asOpaqueBytes", () => __privateGet(this, _opaqueBytes) || __privateSet(this, _opaqueBytes, utils.mergeUint8(
scaleTs.compact[0](__privateGet(this, _bytes).length),
__privateGet(this, _bytes)
)));
if (opaque) {
try {
const [len, bytes] = opaqueBytesDec(data);
if (len === bytes.length) {
__privateSet(this, _bytes, bytes);
__privateSet(this, _opaqueBytes, data);
return;
}
} catch (_) {
}
throw new Error("Invalid opaque bytes");
} else __privateSet(this, _bytes, data);
}

@@ -106,8 +125,16 @@ static fromText(input) {

}
static fromOpaqueHex(input) {
return new this(utils.fromHex(input), true);
}
static fromBytes(input) {
return new this(input);
}
static fromOpaqueBytes(input) {
return new this(input, true);
}
}
_bytes = new WeakMap();
_opaqueBytes = new WeakMap();
_hex = new WeakMap();
_opaqueHex = new WeakMap();
_str = new WeakMap();

@@ -114,0 +141,0 @@ class FixedSizeBinary extends Binary {

2

package.json
{
"name": "@polkadot-api/substrate-bindings",
"version": "0.6.3",
"version": "0.7.0",
"author": "Josep M Sobrepere (https://github.com/josepot)",

@@ -5,0 +5,0 @@ "repository": {

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