diff --git a/_tasks/dnt.ts b/_tasks/dnt.ts index 71fe7bd9f..c9ac1f7f5 100755 --- a/_tasks/dnt.ts +++ b/_tasks/dnt.ts @@ -23,9 +23,9 @@ await Promise.all([ }], outDir, mappings: { - "https://deno.land/x/scale@v0.6.0/mod.ts": { + "https://deno.land/x/scale@v0.6.1/mod.ts": { name: "parity-scale-codec", - version: "^0.6.0", + version: "^0.6.1", }, "deps/smoldot_phantom.ts": { name: "@substrate/smoldot-light", diff --git a/codegen/codecVisitor.ts b/codegen/codecVisitor.ts index 892178e34..7dc887825 100644 --- a/codegen/codecVisitor.ts +++ b/codegen/codecVisitor.ts @@ -15,7 +15,7 @@ export function createCodecVisitor( getContent: () => [ "\n", [ - "import { ChainError, BitSequence, Era, $, $era, $null, $lenPrefixed } from", + "import { ChainError, BitSequence, Era, $, $era, $null } from", S.string(importSource), ], [`import type * as t from "./mod.ts"`], @@ -169,7 +169,7 @@ export function createCodecVisitor( return addCodecDecl(ty, "$era"); }, lenPrefixedWrapper(ty, inner) { - return addCodecDecl(ty, ["$lenPrefixed(", this.visit(inner), ")"]); + return addCodecDecl(ty, ["$.lenPrefixed(", this.visit(inner), ")"]); }, circular(ty) { return ["$.deferred(() =>", getName(getRawCodecPath(ty)), ")"]; diff --git a/deps/scale.ts b/deps/scale.ts index 3c7e7aee2..7616e6e0f 100644 --- a/deps/scale.ts +++ b/deps/scale.ts @@ -1 +1 @@ -export * from "https://deno.land/x/scale@v0.6.0/mod.ts"; +export * from "https://deno.land/x/scale@v0.6.1/mod.ts"; diff --git a/frame_metadata/Codec.ts b/frame_metadata/Codec.ts index 872d62db6..65d6b6784 100644 --- a/frame_metadata/Codec.ts +++ b/frame_metadata/Codec.ts @@ -1,5 +1,4 @@ import * as $ from "../deps/scale.ts"; -import { $lenPrefixed } from "../util/$lenPrefixed.ts"; import { $era } from "./Era.ts"; import type * as M from "./mod.ts"; import { TyVisitor } from "./TyVisitor.ts"; @@ -104,7 +103,7 @@ export function DeriveCodec(tys: M.Ty[]): DeriveCodec { return $era; }, lenPrefixedWrapper(_ty, inner) { - return $lenPrefixed(this.visit(inner)); + return $.lenPrefixed(this.visit(inner)); }, circular(ty) { return $.deferred(() => this.cache[ty.id]!); diff --git a/frame_metadata/Extrinsic.ts b/frame_metadata/Extrinsic.ts index 331c07994..53e1c4aff 100644 --- a/frame_metadata/Extrinsic.ts +++ b/frame_metadata/Extrinsic.ts @@ -2,7 +2,6 @@ import * as $ from "../deps/scale.ts"; import { assert } from "../deps/std/testing/asserts.ts"; import * as H from "../hashers/mod.ts"; import * as ss58 from "../ss58/mod.ts"; -import { $lenPrefixed } from "../util/$lenPrefixed.ts"; import { hex } from "../util/mod.ts"; import { $null, DeriveCodec } from "./Codec.ts"; import { Metadata } from "./Metadata.ts"; @@ -166,7 +165,7 @@ export function $extrinsic(props: ExtrinsicCodecProps): $.Codec { }, }); - return $lenPrefixed($baseExtrinsic); + return $.lenPrefixed($baseExtrinsic); function findExtrinsicTypeParam(name: string) { return metadata.extrinsic.ty.params.find((x) => x.name === name)?.ty; diff --git a/mod.ts b/mod.ts index 4c9b06eb7..dcf17a074 100644 --- a/mod.ts +++ b/mod.ts @@ -7,7 +7,6 @@ export * as M from "./frame_metadata/mod.ts"; export { $era, $null, ChainError, type Era } from "./frame_metadata/mod.ts"; export { kusama, moonbeam, polkadot, rococo, westend } from "./known/mod.ts"; // TODO: get rid of this! export { - $lenPrefixed, type CreateWatchHandler, hex, mapCreateWatchHandler, diff --git a/util/$lenPrefixed.ts b/util/$lenPrefixed.ts deleted file mode 100644 index 1defd07d5..000000000 --- a/util/$lenPrefixed.ts +++ /dev/null @@ -1,23 +0,0 @@ -import * as $ from "../deps/scale.ts"; - -export function $lenPrefixed($inner: $.Codec): $.Codec { - return $.createCodec({ - _metadata: [$lenPrefixed, $inner], - _staticSize: $.compactU32._staticSize + $inner._staticSize, - _encode(buffer, extrinsic) { - const lengthCursor = buffer.createCursor($.compactU32._staticSize); - const contentCursor = buffer.createCursor($inner._staticSize); - $inner._encode(contentCursor, extrinsic); - buffer.waitForBuffer(contentCursor, () => { - const length = contentCursor.finishedSize + contentCursor.index; - $.compactU32._encode(lengthCursor, length); - lengthCursor.close(); - contentCursor.close(); - }); - }, - _decode(buffer) { - const length = $.compactU32._decode(buffer); - return $inner.decode(buffer.array.subarray(buffer.index, buffer.index += length)); - }, - }); -} diff --git a/util/mod.ts b/util/mod.ts index ccadbaefa..3a471c915 100644 --- a/util/mod.ts +++ b/util/mod.ts @@ -1,4 +1,3 @@ -export * from "./$lenPrefixed.ts"; export * from "./branded.ts"; export * from "./error.ts"; export * as hex from "./hex.ts";