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

Commit

Permalink
add storage default method and re-add constant codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
harrysolovay committed Mar 25, 2023
1 parent 508abee commit 3ba8008
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
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

0 comments on commit 3ba8008

Please sign in to comment.