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

chore: codegen + test ctx server refactor #487

Merged
merged 94 commits into from
Jan 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
91880fd
begin fresh refactor
harrysolovay Dec 24, 2022
23886ec
continued
harrysolovay Dec 24, 2022
3238dee
continued
harrysolovay Jan 5, 2023
698dbae
fix changed devcontainer deno config file
harrysolovay Jan 5, 2023
7c05df6
fix broken jsonc formatting
harrysolovay Jan 5, 2023
3dd1fa0
continued
harrysolovay Jan 5, 2023
af0a866
continued
harrysolovay Jan 5, 2023
2c5ac71
continued
harrysolovay Jan 6, 2023
498c776
continued
harrysolovay Jan 7, 2023
9170790
continued
harrysolovay Jan 7, 2023
e815937
continued
harrysolovay Jan 7, 2023
1cfe339
continued
harrysolovay Jan 7, 2023
60f3bbd
continued
harrysolovay Jan 7, 2023
292516d
continued
harrysolovay Jan 7, 2023
1bc7435
continued
harrysolovay Jan 8, 2023
f991d44
continued
harrysolovay Jan 9, 2023
5b59b25
continued
harrysolovay Jan 9, 2023
537f233
rebase against main
harrysolovay Jan 9, 2023
7c452f6
continued
harrysolovay Jan 9, 2023
7f2d663
continued
harrysolovay Jan 9, 2023
85d8a75
continued
harrysolovay Jan 10, 2023
1ca1b2c
continued
harrysolovay Jan 10, 2023
bb7402e
outdent
harrysolovay Jan 10, 2023
ca2be43
work on zombienet provider
harrysolovay Jan 10, 2023
60f5b1c
zombienet integrated
harrysolovay Jan 11, 2023
2505660
continued
harrysolovay Jan 11, 2023
b2c8085
continued
harrysolovay Jan 11, 2023
6129b4c
continued
harrysolovay Jan 13, 2023
da6ad52
continued
harrysolovay Jan 13, 2023
85a03e7
continued
harrysolovay Jan 16, 2023
7ef58c2
continued
harrysolovay Jan 17, 2023
59863ee
continued
harrysolovay Jan 17, 2023
6b83277
continued
harrysolovay Jan 18, 2023
3e581aa
fix serving local capi, begin fixing tests
harrysolovay Jan 18, 2023
4e1a2f7
get tests working
harrysolovay Jan 19, 2023
4bb2b3d
misc simplifying
harrysolovay Jan 19, 2023
22e620d
continued
harrysolovay Jan 19, 2023
dab8be8
fix formatting error
harrysolovay Jan 19, 2023
ca56a78
fix lint errors
harrysolovay Jan 19, 2023
b7e5aa2
fixing ci
harrysolovay Jan 19, 2023
15d3718
clean up xcm example
harrysolovay Jan 20, 2023
a2d6e61
temporarily disable all star task usage
harrysolovay Jan 20, 2023
45cf345
get things working
harrysolovay Jan 20, 2023
b27f10a
uncomment zombienet examples
harrysolovay Jan 20, 2023
cb776f2
debugging zombienet path
harrysolovay Jan 23, 2023
d1df7d6
continue debugging
harrysolovay Jan 23, 2023
0672e31
continue debugging
harrysolovay Jan 23, 2023
727f9c1
tmp
harrysolovay Jan 23, 2023
061c8b0
attempting to fix ci
harrysolovay Jan 23, 2023
feaf17f
update deno std deps
harrysolovay Jan 23, 2023
a6ebd22
t6 feedback
harrysolovay Jan 25, 2023
98fdcc5
continued
harrysolovay Jan 25, 2023
a929ba8
change default port, fixes
harrysolovay Jan 26, 2023
a171be7
fix broken examples
harrysolovay Jan 26, 2023
a6c1a97
try to get ci working
harrysolovay Jan 26, 2023
8a04b4e
remove unused import
harrysolovay Jan 26, 2023
8f634aa
misc changes
harrysolovay Jan 26, 2023
fbab8f9
vscode setting tweak
harrysolovay Jan 26, 2023
00bdc2c
pairing with t6
harrysolovay Jan 27, 2023
253eece
fix lint errors
harrysolovay Jan 27, 2023
4db8312
various fixes
harrysolovay Jan 27, 2023
734eaf5
remove deno deploy goodies
harrysolovay Jan 27, 2023
bf2a5de
debugging ci
harrysolovay Jan 27, 2023
e5ce6a5
debugging ci
harrysolovay Jan 27, 2023
eb8d2f4
correct zombienet throw message
harrysolovay Jan 27, 2023
869d13e
Update .github/workflows/test.yml
harrysolovay Jan 27, 2023
1609994
Update .github/workflows/test.yml
harrysolovay Jan 27, 2023
bb93ca0
clean up ci and expose main.ts cmd exit
harrysolovay Jan 27, 2023
c0fd95a
get rid of unwanted console log
harrysolovay Jan 27, 2023
fc7dfb5
misc ci cleanup
harrysolovay Jan 27, 2023
98b1ac5
re-add star task to test
harrysolovay Jan 27, 2023
11c9b0f
allow zombienet process to throw
harrysolovay Jan 27, 2023
955eb00
Update rpc/provider/proxy.test.ts
harrysolovay Jan 27, 2023
b4f549b
Update deno.jsonc
harrysolovay Jan 27, 2023
b670760
Update .github/workflows/test.yml
harrysolovay Jan 27, 2023
838bddc
Update deps/dprint.ts
harrysolovay Jan 27, 2023
a706215
Update server/Env.ts
harrysolovay Jan 27, 2023
e9a4040
Update util/string.ts
harrysolovay Jan 27, 2023
cc9884a
sort words file
harrysolovay Jan 27, 2023
18fc169
Update server/PathInfo.test.ts
harrysolovay Jan 27, 2023
0bd140c
Update server/PathInfo.ts
harrysolovay Jan 27, 2023
e8d80d3
Update server/local/factories.ts
harrysolovay Jan 27, 2023
9ab5fd4
Update server/local/factories.ts
harrysolovay Jan 27, 2023
278696a
Update server/local/factories.ts
harrysolovay Jan 27, 2023
5d92dde
Update server/local/mod.ts
harrysolovay Jan 27, 2023
d9cf295
Update server/local/factories.ts
harrysolovay Jan 27, 2023
26d8356
get rid of misc pages and add t6 favicon
harrysolovay Jan 27, 2023
7e8869d
get rid of preact
harrysolovay Jan 27, 2023
b2b2cd2
fix ci errors
harrysolovay Jan 27, 2023
4221683
readd lib
harrysolovay Jan 27, 2023
50f84e2
fix typo
harrysolovay Jan 27, 2023
b42803e
Update server/local/mod.ts
harrysolovay Jan 28, 2023
a817246
cleanup
harrysolovay Jan 28, 2023
d8a1037
cleanup
harrysolovay Jan 28, 2023
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
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"[typescript]": {
"editor.defaultFormatter": "dprint.dprint"
},
"deno.codeLens.testArgs": ["--no-check=remote", "-A", "-L=info"],
"deno.codeLens.testArgs": ["-A", "-L=info"],
"deno.config": "./deno.jsonc",
"deno.enable": true,
"deno.lint": true,
Expand All @@ -38,5 +38,5 @@
"vadimcn.vscode-lldb",
"bungcip.better-toml"
],
"postCreateCommand": "deno task codegen && deno task star"
"postCreateCommand": "deno task star"
}
21 changes: 0 additions & 21 deletions .github/workflows/deno_deploy.yml

This file was deleted.

1 change: 0 additions & 1 deletion .github/workflows/dev-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ jobs:
steps:
- name: Checkout (GitHub)
uses: actions/checkout@v2

- name: Build and run Dev Container task
uses: devcontainers/[email protected]
51 changes: 0 additions & 51 deletions .github/workflows/example.yml

This file was deleted.

30 changes: 26 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,32 @@ jobs:
- uses: denoland/setup-deno@9db7f66e8e16b5699a514448ce994936c63f0d54 # v1.1.0
with:
deno-version: v1.x
- name: Setup polkadot
uses: ./.github/actions/setup-polkadot
- 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.360
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 lint
- run: deno task codegen
- run: deno task star
- run: deno task test
- run: deno task test:examples
# - run: deno task test:examples
10 changes: 7 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
"[typescript]": {
"editor.defaultFormatter": "dprint.dprint"
},
"deno.codeLens.testArgs": ["--no-check=remote", "-A", "-L=info"],
"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,
"https://crux.land": true,
"http://localhost:5646": true,
"https://capi.dev": true
"https://capi.dev": true,
"http://localhost:4646": false
},
"deno.enable": true,
"deno.lint": true,
Expand All @@ -26,5 +26,9 @@
"prettier.printWidth": 100,
"ltex.disabledRules": {
"en-US": ["MORFOLOGIK_RULE_EN_US"]
},
"markdownlint.config": {
"MD013": false,
"MD033": false
}
}
33 changes: 27 additions & 6 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@ Capi is a declarative, TypeScript-first toolkit for crafting interactions with S

## At a Glance

Run the local server.

```sh
deno run -A https://deno.land/x/capi/main.ts
```

Then, open your IDE and import pallet-corresponding modules from the local server.

```ts
import { System } from "https://capi.dev/proxy/wss:rpc.polkadot.io/pallets/mod.ts"
import { System } from "http://localhost:4646/frame/wss/rpc.polkadot.io/@<chain-version>/mod.ts"

const key = System.Account.keys().first()

Expand All @@ -20,11 +28,24 @@ const value = System.Account.entry(key)
console.log(await value.run())
```

> Note: although the codegen server is hosted on https://capi.dev, we encourage you to run it locally with
>
> ```sh
> deno run -A https://deno.land/x/capi/serve.ts
> ```
### Import Mapping

For simplicity, we recommend aliasing import specifiers via import maps.

`import_map.json`

```json
{
"imports": {
"#polkadot/": "http://localhost:4646/frame/wss/rpc.polkadot.io/@<chain-version>/"
}
}
```

```diff
- import { System } from "http://localhost:4646/frame/wss/rpc.polkadot.io/@<chain-version>/mod.ts"
+ import { System } from "#polkadot/mod.ts"
```

## Examples

Expand Down
48 changes: 19 additions & 29 deletions _tasks/download_frame_metadata.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import * as Z from "../deps/zones.ts"
import * as C from "../mod.ts"
import * as U from "../util/mod.ts"
import { rawClient as kusama } from "kusama/mod.ts"
import { rawClient as polkadot } from "polkadot/mod.ts"
import { rawClient as rococo } from "rococo/mod.ts"
import { rawClient as westend } from "westend/mod.ts"

const names = Object.keys(C.knownClients)
const knownClients = { kusama, polkadot, westend, rococo }

const names = Object.keys(knownClients)
const outDir = new URL("../frame_metadata/_downloaded", import.meta.url)
try {
Deno.removeSync(outDir, { recursive: true })
Expand All @@ -26,30 +29,17 @@ async function download(name: string) {
)
}
`
Deno.writeTextFileSync(modFilePath, modFileContents, { create: true })

U.throwIfError(await Z.ls(...Object.entries(C.knownClients).map(download)).run())

function download<Name extends Z.$<string>, Client extends Z.$<C.rpc.Client>>(
entry: [name: Name, client: Client],
) {
return Z.ls(...entry).next(async ([name, client]) => {
try {
const metadataHex = U.throwIfError(await C.state.getMetadata(client)().run())
const outPath = new URL(`_downloaded/${name}.scale`, outDir)
console.log(`Downloading ${name} metadata to "${outPath}".`)
await Deno.writeTextFile(outPath, metadataHex)
return
} catch (cause) {
return new MetadataDownloadError(name, { cause })
}
})
}

class MetadataDownloadError extends Error {
override readonly name = "MetadataDownloadError"
Deno.writeTextFileSync(modFilePath, modFileContents, { create: true })

constructor(readonly chainName: string, options: ErrorOptions) {
super(undefined, options)
}
}
await Promise.all(
Object.entries(knownClients).map(async ([name, client]) => {
const r = await client.call(name, "state_getMetadata", [])
if (r instanceof Error) throw r
if (r.error) throw new Error(r.error.message)
const outPath = new URL(`_downloaded/${name}.scale`, outDir)
console.log(`Downloading ${name} metadata to "${outPath}".`)
await Deno.writeTextFile(outPath, r.result)
await client.discard()
}),
)
18 changes: 0 additions & 18 deletions _tasks/gen_deploy.ts

This file was deleted.

Loading