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

feat: next-gen codegen #368

Merged
merged 67 commits into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
f264a56
initial factories
tjjfvi Nov 9, 2022
30c3b9f
commit codegen output
tjjfvi Nov 9, 2022
b5bfd33
splode codegen output
tjjfvi Nov 9, 2022
a2649ac
update example imports
tjjfvi Nov 9, 2022
f8dcdbb
group reexports
tjjfvi Nov 9, 2022
a287d22
remove unused codegen imports
tjjfvi Nov 9, 2022
b2e9238
use multiaddress and multisig from codegen
tjjfvi Nov 10, 2022
0eea331
fix extrinsic validator
tjjfvi Nov 10, 2022
ced50a9
fix pjs signer example
tjjfvi Nov 10, 2022
c14d86e
move stuff to types directory
tjjfvi Nov 10, 2022
05f3a54
ignore spelling in codegen output
tjjfvi Nov 12, 2022
14d50e3
update dprint config for codegen
tjjfvi Nov 13, 2022
4b4c8cd
remove codegen dependence from frame_metadata
tjjfvi Nov 13, 2022
5557ece
refactor
tjjfvi Nov 13, 2022
ecae574
t.types. -> types.
tjjfvi Nov 13, 2022
3dd356d
initial storage codegen
tjjfvi Nov 14, 2022
dcbf2fa
export extrinsic effect from metadata
tjjfvi Nov 14, 2022
a47235b
add keys method to storage fluent api
tjjfvi Nov 14, 2022
1fd38a1
use capi-crypto-wrappers
tjjfvi Nov 14, 2022
1408156
todo: fix codegen cli
tjjfvi Nov 14, 2022
635d0fc
exclude codegen output from lint
tjjfvi Nov 14, 2022
f98b194
update capi_crypto_wrappers
tjjfvi Nov 14, 2022
852e2f7
restructure to lazily generate files for perf
tjjfvi Nov 14, 2022
4c5601f
rename _codec to codecs
tjjfvi Nov 14, 2022
af44313
fix fee estimate re codegen changes
tjjfvi Nov 14, 2022
ae30fd8
fix codecVisitor test
tjjfvi Nov 14, 2022
96f7451
camelCase
tjjfvi Nov 17, 2022
0464e05
initial server
tjjfvi Nov 17, 2022
afc52fa
add named codecs back
tjjfvi Nov 17, 2022
51f2591
remove codegen/_output
tjjfvi Nov 17, 2022
d5f11c6
send html to browsers
tjjfvi Nov 17, 2022
5741400
continued server codegen work
tjjfvi Nov 17, 2022
cce9cd8
import intellisense
tjjfvi Nov 18, 2022
17db235
misc codegen server changes
tjjfvi Nov 20, 2022
9c0742c
initial deno deploy
tjjfvi Nov 20, 2022
a484bfb
disable dev chains on deploy
tjjfvi Nov 20, 2022
2978bf2
fix landing page
tjjfvi Nov 20, 2022
9daadaa
temp: default to current on prod rather than latest tag
tjjfvi Nov 20, 2022
996ff4e
fix codegen task
tjjfvi Nov 20, 2022
7382e65
escape html
tjjfvi Nov 20, 2022
0e78e71
add code highlighting
tjjfvi Nov 20, 2022
78e32a4
fix line breaks in type visitor
tjjfvi Nov 20, 2022
e968c67
expose constants from codegen
tjjfvi Nov 20, 2022
e4ee3ae
pass headers through in delegateRequest
tjjfvi Nov 20, 2022
e4ab4b4
fix default version
tjjfvi Nov 20, 2022
3f7e37d
remove codegen cli
tjjfvi Nov 20, 2022
522fc58
minor cleanup
tjjfvi Nov 20, 2022
2286f15
suggest older chain versions
tjjfvi Nov 20, 2022
464239e
misc cleanup
tjjfvi Nov 21, 2022
f95dde1
fix bug with version delegation
tjjfvi Nov 21, 2022
abd11b6
misc cleanup; cache rendered ts html
tjjfvi Nov 21, 2022
00840e5
linkify import/exports
tjjfvi Nov 21, 2022
eed1a20
lazy load ts in case html is cached
tjjfvi Nov 21, 2022
3742a12
use ttl
tjjfvi Nov 21, 2022
f5bbcbc
fix codecs test
tjjfvi Nov 21, 2022
3d4983b
add --no-lock to codegen task
tjjfvi Nov 21, 2022
279ecc8
support missing Deno.unrefTimer
tjjfvi Nov 21, 2022
315232d
exclude `multisig_transfer.ts`
tjjfvi Nov 21, 2022
5074b7e
remove duplicate checkout in deno_deploy workflow
tjjfvi Nov 21, 2022
dcd3ba0
fix remote client export
tjjfvi Nov 21, 2022
bcdc028
don't redirect rendered html
tjjfvi Nov 21, 2022
45612a4
support other versions on local server
tjjfvi Nov 22, 2022
16a4d62
fix version suggestions for local server
tjjfvi Nov 22, 2022
fee0498
fix codegen task
tjjfvi Nov 22, 2022
4d06000
fix codecs test
tjjfvi Nov 22, 2022
db33a38
use InMemoryCache for codecs.test.ts
tjjfvi Nov 22, 2022
09b6ada
GIVE_CONSTANTS_ANGER_MANAGEMENT_ISSUES
tjjfvi Nov 22, 2022
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
19 changes: 19 additions & 0 deletions .github/workflows/deno_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Deno Deploy
on: push
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v3
harrysolovay marked this conversation as resolved.
Show resolved Hide resolved
- uses: denoland/setup-deno@9db7f66e8e16b5699a514448ce994936c63f0d54 # v1.1.0
with:
deno-version: v1.x
- run: deno task run _tasks/gen_deploy.ts
- name: Deploy to Deno Deploy
uses: denoland/deployctl@v1
with:
project: capi-dev
entrypoint: target/deploy.ts
1 change: 1 addition & 0 deletions .github/workflows/example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ jobs:
key: ${{ runner.os }}-deno-${{ hashFiles('lock.json', 'deps/**/*.ts') }}
- name: Setup Polkadot
uses: ./.github/actions/setup-polkadot
- run: deno task codegen
- run: deno task run ${{ matrix.example_path }}
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ jobs:
- name: Setup polkadot
uses: ./.github/actions/setup-polkadot
- run: deno task lint
- run: deno task codegen
tjjfvi marked this conversation as resolved.
Show resolved Hide resolved
- run: deno task star
- run: deno task test
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
},
"deno.codeLens.testArgs": ["--no-check=remote", "-A", "-L=info"],
"deno.config": "./deno.jsonc",
"deno.importMap": "./import_map_cache.json",
"deno.suggest.imports.hosts": {
"https://deno.land": true,
"https://x.nest.land": true,
"https://crux.land": true,
"http://localhost:5646": true,
"https://capi.dev": true
},
"deno.enable": true,
"deno.lint": true,
"editor.defaultFormatter": "dprint.dprint",
Expand Down
21 changes: 21 additions & 0 deletions _tasks/codegen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { LocalCapiCodegenServer } from "../codegen/server/local.ts"
import * as fs from "../deps/std/fs.ts"

await fs.emptyDir("target/codegen/generated")
const port = 5646
harrysolovay marked this conversation as resolved.
Show resolved Hide resolved
const server = new LocalCapiCodegenServer()
tjjfvi marked this conversation as resolved.
Show resolved Hide resolved
server.listen(port)

await Deno.run({
cmd: [
"deno",
"cache",
"--no-lock",
"--import-map",
"import_map_localhost.json",
`--reload=http://localhost:${port}/`,
"examples/mod.ts",
],
tjjfvi marked this conversation as resolved.
Show resolved Hide resolved
}).status()

server.abortController.abort()
18 changes: 18 additions & 0 deletions _tasks/gen_deploy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { getModuleIndex, getSha } from "../codegen/server/git_utils.ts"
import { ensureDir } from "../deps/std/fs.ts"

const sha = await getSha()
const index = await getModuleIndex()

await ensureDir("target")
await Deno.writeTextFile(
"target/deploy.ts",
`
import { DenoDeployCodegenServer } from "../codegen/server/deploy.ts"

new DenoDeployCodegenServer(
"sha:${sha}",
${JSON.stringify(index)},
).listen(80)
`,
)
61 changes: 0 additions & 61 deletions codegen.ts

This file was deleted.

33 changes: 5 additions & 28 deletions codegen/Files.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,9 @@
import { tsFormatter } from "../deps/dprint.ts"
import * as path from "../deps/std/path.ts"
import { S } from "./utils.ts"

export type File = { getContent: () => S }
export class Files extends Map<string, File> {
async write(outDir: string) {
const errors = []
try {
await Deno.remove(outDir, { recursive: true })
} catch (e) {
if (!(e instanceof Deno.errors.NotFound)) {
throw e
}
}
await Deno.mkdir(outDir, { recursive: true })
for (const [relativePath, file] of this.entries()) {
const outputPath = path.join(outDir, relativePath)
const content = S.toString(file.getContent())
try {
const formatted = tsFormatter.formatText("gen.ts", content)
await Deno.writeTextFile(outputPath, formatted)
} catch (e) {
await Deno.writeTextFile(outputPath, content)
errors.push(e)
}
}
if (errors.length) {
throw errors
}
export class Files extends Map<string, () => string> {
getFormatted(key: string) {
const file = this.get(key)
if (!file) return undefined
return tsFormatter.formatText(key, file())
}
}
185 changes: 0 additions & 185 deletions codegen/codecVisitor.ts

This file was deleted.

Loading