@polkadot-api/substrate-bindings 0.21.2-canary.9fe0b2a → 0.21.2-canary.fedd455
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -23,7 +23,15 @@ const Binary = {
|
|
|
23
23
|
throw new Error("Invalid opaque bytes");
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
-
const SizedBytes = (size) => enhanceCodec(
|
|
26
|
+
const SizedBytes = (size) => enhanceCodec(
|
|
27
|
+
Bytes(size),
|
|
28
|
+
(val) => {
|
|
29
|
+
if (typeof val !== "string")
|
|
30
|
+
throw new Error(`SizedBytes expects HexString, ${typeof val} given`);
|
|
31
|
+
return fromHex(val);
|
|
32
|
+
},
|
|
33
|
+
toHex
|
|
34
|
+
);
|
|
27
35
|
|
|
28
36
|
export { Binary, SizedBytes };
|
|
29
37
|
//# sourceMappingURL=Binary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Binary.js","sources":["../../../src/codecs/scale/Binary.ts"],"sourcesContent":["import { fromHex, mergeUint8, toHex } from \"@polkadot-api/utils\"\nimport { Bytes, Tuple, compact, enhanceCodec } from \"scale-ts\"\nimport type { HexString } from \"./Hex\"\nimport { compactNumber } from \"./compact\"\n\nconst textEncoder = new TextEncoder()\nconst textDecoder = new TextDecoder()\nconst opaqueBytesDec = Tuple(compactNumber, Bytes(Infinity))[1]\n\nexport const Binary = {\n toText: (bytes: Uint8Array) => textDecoder.decode(bytes),\n toHex: (bytes: Uint8Array): HexString => toHex(bytes),\n toOpaque: (bytes: Uint8Array) =>\n mergeUint8([compact[0](bytes.length), bytes]),\n\n fromText: (text: string) => textEncoder.encode(text),\n fromHex: (hex: HexString) => fromHex(hex),\n fromOpaque: (opaque: Uint8Array | HexString) => {\n const data = typeof opaque === \"string\" ? fromHex(opaque) : opaque\n try {\n const [len, bytes] = opaqueBytesDec(data)\n if (len === bytes.length) {\n return bytes\n }\n } catch (_) {}\n throw new Error(\"Invalid opaque bytes\")\n },\n}\n\nexport const SizedBytes = (size: number) =>\n enhanceCodec(Bytes(size), fromHex
|
|
1
|
+
{"version":3,"file":"Binary.js","sources":["../../../src/codecs/scale/Binary.ts"],"sourcesContent":["import { fromHex, mergeUint8, toHex } from \"@polkadot-api/utils\"\nimport { Bytes, Tuple, compact, enhanceCodec } from \"scale-ts\"\nimport type { HexString } from \"./Hex\"\nimport { compactNumber } from \"./compact\"\n\nconst textEncoder = new TextEncoder()\nconst textDecoder = new TextDecoder()\nconst opaqueBytesDec = Tuple(compactNumber, Bytes(Infinity))[1]\n\nexport const Binary = {\n toText: (bytes: Uint8Array) => textDecoder.decode(bytes),\n toHex: (bytes: Uint8Array): HexString => toHex(bytes),\n toOpaque: (bytes: Uint8Array) =>\n mergeUint8([compact[0](bytes.length), bytes]),\n\n fromText: (text: string) => textEncoder.encode(text),\n fromHex: (hex: HexString) => fromHex(hex),\n fromOpaque: (opaque: Uint8Array | HexString) => {\n const data = typeof opaque === \"string\" ? fromHex(opaque) : opaque\n try {\n const [len, bytes] = opaqueBytesDec(data)\n if (len === bytes.length) {\n return bytes\n }\n } catch (_) {}\n throw new Error(\"Invalid opaque bytes\")\n },\n}\n\nexport const SizedBytes = (size: number) =>\n enhanceCodec(\n Bytes(size),\n (val: string | Uint8Array) => {\n if (typeof val !== \"string\")\n throw new Error(`SizedBytes expects HexString, ${typeof val} given`)\n return fromHex(val)\n },\n toHex,\n )\n"],"names":[],"mappings":";;;;AAKA,MAAM,WAAA,GAAc,IAAI,WAAA,EAAY;AACpC,MAAM,WAAA,GAAc,IAAI,WAAA,EAAY;AACpC,MAAM,iBAAiB,KAAA,CAAM,aAAA,EAAe,MAAM,QAAQ,CAAC,EAAE,CAAC,CAAA;AAEvD,MAAM,MAAA,GAAS;AAAA,EACpB,MAAA,EAAQ,CAAC,KAAA,KAAsB,WAAA,CAAY,OAAO,KAAK,CAAA;AAAA,EACvD,KAAA,EAAO,CAAC,KAAA,KAAiC,KAAA,CAAM,KAAK,CAAA;AAAA,EACpD,QAAA,EAAU,CAAC,KAAA,KACT,UAAA,CAAW,CAAC,OAAA,CAAQ,CAAC,CAAA,CAAE,KAAA,CAAM,MAAM,CAAA,EAAG,KAAK,CAAC,CAAA;AAAA,EAE9C,QAAA,EAAU,CAAC,IAAA,KAAiB,WAAA,CAAY,OAAO,IAAI,CAAA;AAAA,EACnD,OAAA,EAAS,CAAC,GAAA,KAAmB,OAAA,CAAQ,GAAG,CAAA;AAAA,EACxC,UAAA,EAAY,CAAC,MAAA,KAAmC;AAC9C,IAAA,MAAM,OAAO,OAAO,MAAA,KAAW,QAAA,GAAW,OAAA,CAAQ,MAAM,CAAA,GAAI,MAAA;AAC5D,IAAA,IAAI;AACF,MAAA,MAAM,CAAC,GAAA,EAAK,KAAK,CAAA,GAAI,eAAe,IAAI,CAAA;AACxC,MAAA,IAAI,GAAA,KAAQ,MAAM,MAAA,EAAQ;AACxB,QAAA,OAAO,KAAA;AAAA,MACT;AAAA,IACF,SAAS,CAAA,EAAG;AAAA,IAAC;AACb,IAAA,MAAM,IAAI,MAAM,sBAAsB,CAAA;AAAA,EACxC;AACF;AAEO,MAAM,UAAA,GAAa,CAAC,IAAA,KACzB,YAAA;AAAA,EACE,MAAM,IAAI,CAAA;AAAA,EACV,CAAC,GAAA,KAA6B;AAC5B,IAAA,IAAI,OAAO,GAAA,KAAQ,QAAA;AACjB,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,8BAAA,EAAiC,OAAO,GAAG,CAAA,MAAA,CAAQ,CAAA;AACrE,IAAA,OAAO,QAAQ,GAAG,CAAA;AAAA,EACpB,CAAA;AAAA,EACA;AACF;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polkadot-api/substrate-bindings",
|
|
3
|
-
"version": "0.21.2-canary.
|
|
3
|
+
"version": "0.21.2-canary.fedd455",
|
|
4
4
|
"author": "Josep M Sobrepere (https://github.com/josepot)",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@noble/hashes": "^2.4.0",
|
|
29
29
|
"@scure/base": "^2.4.0",
|
|
30
30
|
"scale-ts": "^1.6.1",
|
|
31
|
-
"@polkadot-api/utils": "0.4.1-canary.
|
|
31
|
+
"@polkadot-api/utils": "0.4.1-canary.fedd455"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"bigint-conversion": "^2.4.3",
|