This repository has been archived by the owner on Sep 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Harry Solovay <[email protected]>
- Loading branch information
1 parent
1c50936
commit 3fbb532
Showing
161 changed files
with
4,341 additions
and
2,775 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: Lint | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
star: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: denoland/setup-deno@9db7f66e8e16b5699a514448ce994936c63f0d54 # v1.1.0 | ||
with: | ||
deno-version: v1.x | ||
- run: deno lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Star | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
star: | ||
name: Star | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 # :( | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: denoland/setup-deno@9db7f66e8e16b5699a514448ce994936c63f0d54 # v1.1.0 | ||
with: | ||
deno-version: v1.x | ||
- name: Cache Deno dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.deno | ||
~/.cache/deno | ||
key: ${{ runner.os }}-deno-${{ hashFiles('deps/**/*.ts') }} | ||
- name: Setup Polkadot | ||
uses: ./.github/actions/setup-binary | ||
with: | ||
binary-name: polkadot | ||
binary-version: v0.9.36 | ||
binary-github: https://github.com/paritytech/polkadot | ||
- name: Setup Cumulus | ||
uses: ./.github/actions/setup-binary | ||
with: | ||
binary-name: polkadot-parachain | ||
binary-version: v0.9.370 | ||
binary-github: https://github.com/paritytech/cumulus | ||
- name: Setup Zombienet | ||
uses: ./.github/actions/setup-binary | ||
with: | ||
binary-name: zombienet-linux | ||
binary-version: v1.3.18 | ||
binary-github: https://github.com/paritytech/zombienet | ||
- run: deno task star |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,10 +19,6 @@ await Promise.all([ | |
name: "scale-codec", | ||
version: "^0.10.0", | ||
}, | ||
"https://deno.land/x/[email protected]/mod.ts": { | ||
name: "zones", | ||
version: "0.1.0-beta.13", | ||
}, | ||
"https://deno.land/x/[email protected]/index-deno.js": { | ||
name: "@substrate/smoldot-light", | ||
version: "0.7.6", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { Metadata } from "../../frame_metadata/mod.ts" | ||
import { SequenceTyDef, Ty } from "../../scale_info/mod.ts" | ||
import { codecs } from "./codecs.ts" | ||
import { File } from "./File.ts" | ||
import { pallet } from "./pallet.ts" | ||
import { type } from "./type.ts" | ||
import { typeVisitor } from "./typeVisitor.ts" | ||
|
||
export interface FrameCodegenProps { | ||
metadata: Metadata | ||
clientFile: File | ||
} | ||
|
||
export class FrameCodegen { | ||
files = new Map<string, File>() | ||
|
||
metadata | ||
clientFile | ||
|
||
typeVisitor | ||
typeFiles = new Map<string, TypeFile>() | ||
|
||
constructor({ metadata, clientFile }: FrameCodegenProps) { | ||
this.metadata = metadata | ||
this.clientFile = clientFile | ||
|
||
this.typeVisitor = typeVisitor(this) | ||
|
||
for (const [path, typeFile] of this.typeFiles) { | ||
const filePath = path + typeFile.ext | ||
this.files.set(filePath, type(this, path, filePath, typeFile)) | ||
} | ||
|
||
this.files.set("codecs.ts", codecs(this)) | ||
|
||
this.files.set("client.ts", clientFile) | ||
|
||
const callTy = Object | ||
.fromEntries(this.metadata.extrinsic.ty.params.map((x) => [x.name.toLowerCase(), x.ty])) | ||
.call! | ||
|
||
const eventTy = (this.metadata | ||
.pallets.find((x) => x.name === "System") | ||
?.storage?.entries.find((x) => x.name === "Events") | ||
?.value! as SequenceTyDef).typeParam | ||
|
||
let palletNamespaceExports = "" | ||
for (const p of this.metadata.pallets) { | ||
if (!p.calls && !p.constants.length && !p.storage?.entries.length) continue | ||
this.files.set(`${p.name}.ts`, pallet(this, p)) | ||
palletNamespaceExports += `export * as ${p.name} from "./${p.name}.ts"\n` | ||
} | ||
|
||
this.files.set( | ||
"mod.ts", | ||
new File(` | ||
import * as C from "./capi.ts" | ||
import * as types from "./types/mod.ts" | ||
export type Chain = C.Chain<${this.typeVisitor.visit(callTy)}, ${ | ||
this.typeVisitor.visit(eventTy) | ||
}> | ||
export * from "./client.ts" | ||
export * as types from "./types/mod.ts" | ||
${palletNamespaceExports} | ||
`), | ||
) | ||
} | ||
|
||
[Symbol.iterator]() { | ||
return Object.entries(this.files)[Symbol.iterator]() | ||
} | ||
} | ||
|
||
export class TypeFile { | ||
reexports = new Set<string>() | ||
types = new Map<string, Ty>() | ||
get ext() { | ||
return this.reexports.size ? "/mod.ts" : ".ts" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.