Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

feat: add storageRune.default and re-add constants codegen #799

Merged
merged 1 commit into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
},
"deno.codeLens.testArgs": ["-A", "-L=info"],
"deno.config": "./deno.jsonc",
"deno.importMap": "./import_map.json",
"deno.suggest.imports.hosts": {
"https://deno.land": true,
"https://x.nest.land": true,
Expand Down
12 changes: 12 additions & 0 deletions codegen/FrameCodegen.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { hex } from "../crypto/mod.ts"
import * as $ from "../deps/scale.ts"
import { FrameMetadata } from "../frame_metadata/mod.ts"
import { CodecCodegen } from "./CodecCodegen.ts"
Expand Down Expand Up @@ -66,6 +67,7 @@ export * as types from "./types/mod.js"
`
import { chain, ${isTypes ? this.chainName : ""} } from "./chain.js"
import * as C from "./capi.js"
import * as _codecs from "./codecs.js"
import * as t from "./types/mod.js"
${
Expand All @@ -89,6 +91,16 @@ export ${isTypes ? `namespace ${pallet.name}` : `const ${pallet.name} =`} {
).join("\n\n")
}
${
Object.values(pallet.constants).map((constant) =>
isTypes
? `export const ${constant.name}: ${this.typeCodegen.native(constant.codec)}`
: `${constant.name}: ${
this.codecCodegen.print(constant.codec)
}.decode(C.hex.decode(${JSON.stringify(hex.encode(constant.value))})),`
).join("\n\n")
}
${
new $.CodecVisitor<string[]>()
.add($.taggedUnion, (_, _tagKey: string, variants) =>
Expand Down
6 changes: 6 additions & 0 deletions fluent/StorageRune.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ export class StorageRune<
.rehandle(null, () => Rune.constant(undefined))
}

default() {
return this.$value
.decoded(this.into(ValueRune).access("default").unhandle(undefined))
.rehandle(undefined)
}

entryPageRaw<X>(
...[count, partialKey, start, blockHash]: RunicArgs<X, [
count: number,
Expand Down