New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@polkadot-api/substrate-bindings

Package Overview
Dependencies
Maintainers
2
Versions
604
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.9.3 to 0.9.4

5

dist/index.d.ts

@@ -1094,2 +1094,5 @@ import * as scale_ts from 'scale-ts';

type EncoderWithHash<T> = [Codec<T>, (input: Uint8Array) => Uint8Array];
type OpaqueKeyHash = string & {
__opaqueKeyHash?: unknown;
};
declare const Storage: (pallet: string) => <T, A extends Array<EncoderWithHash<any>>>(name: string, dec: Decoder<T>, ...encoders: A) => {

@@ -1101,2 +1104,2 @@ enc: (...args: { [K in keyof A]: A[K] extends EncoderWithHash<infer V> ? V : unknown; }) => string;

export { AccountId, Bin, Binary, type BitSequence, Blake2128, Blake2128Concat, Blake2256, Blake3256, Blake3256Concat, type BlockHeader, type EncoderWithHash, Enum, type EnumVariant, type ExtractEnumValue, FixedSizeBinary, type GetEnum, Hex, type HexString, Identity, type SS58AddressInfo, type SS58String, Self, Storage, Twox128, Twox256, Twox64Concat, type V14, type V14Extrinsic, type V14Lookup, type V15, type V15Extrinsic, Variant, _Enum, bitSequence, blockHeader, char, compactBn, compactNumber, decAnyMetadata, ethAccount, fixedStr, fromBufferToBase58, getSs58AddressInfo, h64, metadata, selfDecoder, selfEncoder, v14, lookup as v14Lookup, v15 };
export { AccountId, Bin, Binary, type BitSequence, Blake2128, Blake2128Concat, Blake2256, Blake3256, Blake3256Concat, type BlockHeader, type EncoderWithHash, Enum, type EnumVariant, type ExtractEnumValue, FixedSizeBinary, type GetEnum, Hex, type HexString, Identity, type OpaqueKeyHash, type SS58AddressInfo, type SS58String, Self, Storage, Twox128, Twox256, Twox64Concat, type V14, type V14Extrinsic, type V14Lookup, type V15, type V15Extrinsic, Variant, _Enum, bitSequence, blockHeader, char, compactBn, compactNumber, decAnyMetadata, ethAccount, fixedStr, fromBufferToBase58, getSs58AddressInfo, h64, metadata, selfDecoder, selfEncoder, v14, lookup as v14Lookup, v15 };

47

dist/index.js

@@ -417,5 +417,5 @@ 'use strict';

});
const hashers = scaleTs.Vector(hashType);
const hashers$1 = scaleTs.Vector(hashType);
const storageMap = scaleTs.Struct({
hashers,
hashers: hashers$1,
key: compactNumber,

@@ -745,2 +745,11 @@ value: compactNumber

const textEncoder = new TextEncoder();
const hashers = /* @__PURE__ */ new Map([
[Identity, 0],
[Twox64Concat, 8],
[Blake2128Concat, 16],
[Blake2128, -16],
[Blake2256, -32],
[Twox128, -16],
[Twox256, -32]
]);
const Storage = (pallet) => {

@@ -754,27 +763,21 @@ const palledEncoded = Twox128(textEncoder.encode(pallet));

const palletItemEncodedHex = utils.toHex(palletItemEncoded);
const bytesToSkip = encoders.map((e) => e[1]).map((x) => {
switch (x) {
case Identity:
return 0;
case Twox64Concat:
return 8;
case Blake2128Concat:
return 16;
default:
return null;
}
}).filter((x) => x !== null);
const keyDecoder = (key) => {
if (!key.startsWith(palletItemEncodedHex))
throw new Error(`key does not match this storage (${pallet}.${name})`);
if (bytesToSkip.length !== encoders.length)
throw new Error("Impossible to decode this key");
if (encoders.length === 0) return [];
const argsKey = key.slice(palletItemEncodedHex.length);
const argsKey = utils.fromHex(key.slice(palletItemEncodedHex.length));
const result = new Array(encoders.length);
for (let i = 0, cur = 0; i < bytesToSkip.length; i++) {
const codec = encoders[i][0];
cur += bytesToSkip[i];
result[i] = codec.dec(argsKey.slice(cur * 2));
cur += codec.enc(result[i]).length;
for (let i = 0, cur = 0; i < encoders.length; i++) {
const [codec, hasher] = encoders[i];
const hBytes = hashers.get(hasher);
if (hBytes == null) throw new Error("Unknown hasher");
if (hBytes < 0) {
const opaqueBytes = hBytes * -1;
result[i] = utils.toHex(argsKey.slice(cur, cur + opaqueBytes));
cur += opaqueBytes;
} else {
cur += hBytes;
result[i] = codec.dec(argsKey.slice(cur));
cur += codec.enc(result[i]).length;
}
}

@@ -781,0 +784,0 @@ return result;

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

@@ -38,4 +38,4 @@ "repository": {

"dependencies": {
"@noble/hashes": "^1.4.0",
"@scure/base": "^1.1.7",
"@noble/hashes": "^1.5.0",
"@scure/base": "^1.1.9",
"scale-ts": "^1.6.1",

@@ -46,3 +46,3 @@ "@polkadot-api/utils": "0.1.2"

"bigint-conversion": "^2.4.3",
"hash-wasm": "^4.11.0"
"hash-wasm": "^4.12.0"
},

@@ -49,0 +49,0 @@ "scripts": {

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