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

Commit

Permalink
feat: add test-users endpoint url to chainFile
Browse files Browse the repository at this point in the history
  • Loading branch information
kratico committed Mar 9, 2023
1 parent 50fca34 commit 6022a28
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions providers/frame/polkadot_dev.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { File } from "../../codegen/frame/mod.ts"
import * as $ from "../../deps/scale.ts"
import { Env, PathInfo } from "../../server/mod.ts"
import { fromPathInfo } from "../../server/PathInfo.ts"
import { getAvailable } from "../../util/port.ts"
import { FrameBinProvider } from "./FrameBinProvider.ts"
import { createCustomChainSpec } from "./utils/mod.ts"
Expand Down Expand Up @@ -30,8 +31,9 @@ export class PolkadotDevProvider extends FrameBinProvider {
}

override async chainFile(pathInfo: PathInfo): Promise<File> {
const url = new URL(fromPathInfo({ ...pathInfo, filePath: "test-users" }), this.env.href)
.toString()
const file = await super.chainFile(pathInfo)

return new File(`
${file.codeRaw}
Expand All @@ -46,7 +48,7 @@ export class PolkadotDevProvider extends FrameBinProvider {
export async function users<N extends number>(count: N): Promise<ArrayOfLength<C.Sr25519, N>>
export async function users(count: number): Promise<C.Sr25519[]> {
const response = await fetch(
"http://localhost:4646/frame/dev/polkadot/@v0.9.37/test-users",
"${url}",
{
method: "POST",
headers: {
Expand All @@ -70,12 +72,6 @@ export class PolkadotDevProvider extends FrameBinProvider {

override async handle(request: Request, pathInfo: PathInfo): Promise<Response> {
if (request.method.toUpperCase() === "POST" && pathInfo.filePath === "test-users") {
console.log("polakdot_dev.handle", {
staticUrl: this.staticUrl(pathInfo),
request,
pathInfo,
})

try {
const { count } = await request.json()
const currentCount = this.#testUserCountCache[this.#getRuntime(pathInfo)] ?? 0
Expand Down

0 comments on commit 6022a28

Please sign in to comment.